import{t as e}from"./chunk/LoggableType.js";import{i as t}from"./chunk/Colors.js";let n=[];function r(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches}window.addEventListener(`message`,a=>{if(a.data===`port`){let o=a.ports[0];o.onmessage=a=>{let o=a.data;if(o.name!==`set-config`)return;let s=o.data;document.title=s.title+` Help — AdvantageScope`;let c=[];s.types.forEach(n=>{if(!n.showDocs)return;let r=n.display,a=n.symbol,o=`#000000`;if(n.color.startsWith(`#`))o=n.color;else{let e=n.options.find(e=>e.key===n.color);if(e!==void 0){let t=0;do o=e.values[t].key,t++;while(c.includes(o));c.push(o)}}let l=n.darkColor===void 0?o:n.darkColor;o=t(o,!1),l=t(l,!0);let u=n.sourceTypes;s.types.forEach(e=>{e.key.startsWith(n.key)&&e.sourceTypes.forEach(e=>{u.includes(e)||u.push(e)})}),u=u.map(t=>Object.values(e).includes(t)?t.replaceAll(`Array`,`[]`).toLowerCase():t.split(`:`)[0]);let d=[];n.childOf!==void 0&&s.types.forEach(e=>{e.parentKey===n.childOf&&!d.includes(e.display)&&d.push(e.display)});let f=n.options.map(e=>({name:e.display,values:e.values}));i(r,a,o,l,u,d,f)});let l=null,u=()=>{let e=r();e!==l&&(l=e,n.forEach(e=>{e()})),window.requestAnimationFrame(u)};window.requestAnimationFrame(u)}}});function i(e,i,o,s,c,l,u){let d=document.createElement(`div`);d.classList.add(`type-header`),document.body.appendChild(d);let f=document.createElement(`div`);f.classList.add(`type-icon-container`),d.appendChild(f);let p=document.createElement(`object`);p.classList.add(`type-icon`),p.tabIndex=-1,p.type=`image/svg+xml`,p.data=`symbols/sourceList/`+i+`.svg`,f.appendChild(p);let m=()=>{if(p.contentDocument!==null){let e=p.contentDocument.getElementsByTagName(`svg`)[0];e!==void 0&&(e.style.color=r()?s:o)}};p.addEventListener(`load`,m),n.push(m);let h=document.createElement(`div`);if(h.classList.add(`type-title`),d.appendChild(h),h.innerText=e,l.length>0){let e=document.createElement(`div`);e.classList.add(`parent-warning`),document.body.appendChild(e),e.innerText=`Add to existing `+a(l.map(e=>`"`+e+`"`))+` item.`}if(u.length>0){let e=document.createElement(`table`);e.classList.add(`options`),document.body.appendChild(e);let r=document.createElement(`tbody`);e.appendChild(r),u.forEach(e=>{let i=document.createElement(`tr`);r.appendChild(i);let o=document.createElement(`td`);i.appendChild(o),o.innerHTML=e.name+`:`;let s=document.createElement(`td`);i.appendChild(s),s.innerHTML=a(e.values.map(e=>`<span>`+e.display+`</span>`)),Array.from(s.getElementsByTagName(`span`)).forEach((r,i)=>{let a=e.values[i].key;if(a.startsWith(`#`)){let e=()=>{r.style.color=t(a)};e(),n.push(e)}})})}let g=document.createElement(`div`);g.classList.add(`source-types`),document.body.appendChild(g),g.innerText=`Source`+(c.length===1?``:`s`)+`: `+a(c)}function a(e){switch(e.length){case 0:return``;case 1:return e[0];case 2:return e[0]+` or `+e[1];default:return[...e.slice(0,-1),`or `+e[e.length-1]].join(`, `)}}