@tscircuit/runframe 0.0.3086 → 0.0.3087
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/standalone.min.js
CHANGED
|
@@ -5632,7 +5632,7 @@ svg { font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; }
|
|
|
5632
5632
|
.sv-simulation-item[data-highlighted], .sv-simulation-item:hover { background-color: #f1f3f5; }
|
|
5633
5633
|
.sv-simulation-chevron { transition: transform 0.2s ease; }
|
|
5634
5634
|
[data-state="open"] > .sv-simulation-chevron { transform: rotate(180deg); }
|
|
5635
|
-
`,Emo=()=>T.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:T.jsx("path",{d:"M20 6 9 17l-5-5"})}),nmo=({className:g})=>T.jsx("svg",{className:g,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.6,flexShrink:0},"aria-hidden":"true",children:T.jsx("path",{d:"m6 9 6 6 6-6"})}),smo=g=>{const A=new Map;return g.map(I=>{const e=(A.get(I.name)??0)+1;return A.set(I.name,e),{simulation:I,label:e===1?I.name:`${I.name} (${e})`}})},amo=({simulations:g,selectedSimulationExperimentId:A,onSelectSimulation:I})=>{const[e,t]=z.useState(!1);if(g.length<=1)return null;const o=smo(g),C=o.find(({simulation:Q})=>Q.simulation_experiment_id===A)?.label??"Select simulation";return T.jsxs(T.Fragment,{children:[T.jsx("style",{children:imo}),T.jsxs(mmA,{open:e,onOpenChange:t,modal:!1,children:[T.jsx(pmA,{asChild:!0,children:T.jsxs("button",{type:"button",title:C,onPointerDown:Q=>Q.stopPropagation(),style:{position:"absolute",top:"16px",left:"16px",display:"flex",alignItems:"center",gap:"6px",maxWidth:"280px",padding:"8px 12px",backgroundColor:"#ffffff",color:"#000000",border:"none",outline:"none",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",fontSize:"13px",fontFamily:dCg,zIndex:fS.viewMenuIcon},children:[T.jsx("span",{style:{color:"#888888",flexShrink:0},children:"Simulation:"}),T.jsx("span",{style:{...tPI,minWidth:0},children:C}),T.jsx(nmo,{className:"sv-simulation-chevron"})]})}),T.jsx(GO,{children:T.jsx(_tA,{style:Bmo,side:"bottom",align:"start",sideOffset:8,collisionPadding:10,children:o.map(({simulation:Q,label:i})=>{const E=Q.simulation_experiment_id===A;return T.jsxs(lF,{className:"sv-simulation-item",style:Cmo,title:i,onSelect:n=>n.preventDefault(),onPointerUp:()=>{I(Q.simulation_experiment_id),t(!1)},children:[T.jsx("span",{style:Qmo,children:E&&T.jsx(Emo,{})}),T.jsx("span",{style:{...tPI,minWidth:0},children:i})]},Q.simulation_experiment_id)})})})]})]})},rmo=1200,cmo=1,hmo=2,lmo=({circuitJson:g,containerStyle:A,colorOverrides:I,width:e,height:t,className:o,hideSchematic:B=!1,onSimulationChange:C,acSweepView:Q="magnitude"})=>{const[i,E]=z.useState(null),[n,s]=z.useState(!0),[r,a]=z.useState(null),[c,h]=z.useState(null),l=z.useRef(null),D=z.useRef(null),{containerWidth:d}=VJI(l),[y,w]=z.useState(!1),{ref:u}=QoA({onSetTransform(V){D.current&&(D.current.style.transform=nN(V))}}),m=e&&t?e/t:B?hmo:cmo,p=e||(t?t*m:d)||rmo,k=t||p/m;z.useEffect(()=>{s(!0),a(null),E(g),s(!1)},[g]);const S=z.useMemo(()=>i?i.filter(V=>V.type==="simulation_experiment"):[],[i]),[R,x]=z.useState(null),N=(R&&S.some(V=>V.simulation_experiment_id===R)?R:S[0]?.simulation_experiment_id)??null;z.useEffect(()=>{N!==R&&x(N)},[N,R]);const U=V=>{x(V),C?.(V)},K=z.useMemo(()=>{if(!i||!p||!k||!N)return"";try{const V={circuitJson:i,simulation_experiment_id:N,ac_sweep_view:Q,width:p,height:k};return B?YJI(V):Yuo({...V,schematicOptions:{colorOverrides:I}})}catch(V){return console.error("Failed to generate simulation SVG:",V),""}},[i,p,k,I,B,N,Q]);z.useEffect(()=>{if(!K){h(null);return}try{const V=new Blob([K],{type:"image/svg+xml"}),W=URL.createObjectURL(V);return h(W),()=>{URL.revokeObjectURL(W)}}catch(V){console.error("Failed to create SVG object URL:",V),h(null)}},[K]);const Y=z.useMemo(()=>omo(K,I),[K,I]),_=V=>{w(!0)},Z=V=>{w(!0)};return z.useEffect(()=>{const V=()=>{w(!1)},W=()=>{w(!1)};return window.addEventListener("mouseup",V),window.addEventListener("touchend",W),()=>{window.removeEventListener("mouseup",V),window.removeEventListener("touchend",W)}},[]),n?T.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f5f5f5",minHeight:"300px",fontFamily:"sans-serif",fontSize:"16px",color:"#666",...A},className:o,children:"Loading circuit..."}):r?T.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#fef2f2",minHeight:"300px",fontFamily:"sans-serif",fontSize:"16px",color:"#dc2626",...A},className:o,children:T.jsxs("div",{style:{textAlign:"center",padding:"20px"},children:[T.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:"Circuit Conversion Error"}),T.jsx("div",{style:{fontSize:"14px"},children:r})]})}):K?T.jsxs("div",{ref:V=>{l.current=V,u.current=V},style:{position:"relative",backgroundColor:Y,overflow:"hidden",minHeight:"300px",cursor:y?"grabbing":"grab",...A},className:o,onMouseDown:_,onTouchStart:Z,children:[T.jsx(amo,{simulations:S,selectedSimulationExperimentId:N,onSelectSimulation:U}),c?T.jsx("img",{ref:D,src:c,alt:"Circuit Simulation",style:{transformOrigin:"0 0",width:"100%",height:"100%",display:"block",objectFit:"contain"}}):T.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",minHeight:"300px",color:"#666",fontFamily:"sans-serif"},children:"Failed to render SVG"})]}):T.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"#f8fafc",minHeight:"300px",fontFamily:"sans-serif",gap:"12px",...A},className:o,children:[T.jsx("div",{style:{fontSize:"16px",color:"#475569",fontWeight:500},children:"No Simulation Found"}),T.jsxs("div",{style:{fontSize:"14px",color:"#64748b"},children:["Use"," ",T.jsx("code",{style:{backgroundColor:"#e2e8f0",padding:"2px 6px",borderRadius:"4px",fontFamily:"monospace",fontSize:"13px"},children:"<analogsimulation />"})," ","to create simulations"]})]})},Dmo=()=>{const[g,A]=z.useState(null),I=z.useCallback(o=>{A({schematicComponentId:o})},[]),e=z.useCallback(o=>{A(B=>B===o?null:B)},[]);return{controller:z.useMemo(()=>({focusRequest:g,onFocusRequestHandled:e}),[g,e]),focusSchematicComponent:I}},oPI=g=>{const[A,I]=z.useState(0),[e,t]=z.useState(0);return z.useEffect(()=>{if(!g.current)return;const o=()=>{const C=g.current?.getBoundingClientRect();I(C?.width||0),t(C?.height||0)};o();const B=new ResizeObserver(o);return B.observe(g.current),window.addEventListener("resize",o),()=>{B.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:A,containerHeight:e}};kE("assembly-viewer");var BPI=()=>{kE.enable("assembly-viewer*")},dmo=({circuitJson:g,containerStyle:A,debugGrid:I=!1,debug:e=!1})=>{e&&BPI();const t=z.useRef(null),{ref:o}=QoA({onSetTransform(E){t.current&&(t.current.style.transform=TV(E))}}),{containerWidth:B,containerHeight:C}=oPI(o),Q=z.useMemo(()=>!B||!C?"":OtI(g,{width:B,height:C||720}),[g,B,C]);z.useMemo(()=>{if(!Q)return n4();const E=Q.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return $NA(E)}catch(n){return console.error(n),n4()}},[Q]);const i=z.useMemo(()=>T.jsx("div",{ref:t,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:Q}}),[Q]);return T.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:i})},ymo=({circuitJson:g,containerStyle:A,debugGrid:I=!1,debug:e=!1})=>{e&&BPI();const t=z.useRef(null),{ref:o}=QoA({onSetTransform(E){t.current&&(t.current.style.transform=TV(E))}}),{containerWidth:B,containerHeight:C}=oPI(o),Q=z.useMemo(()=>!B||!C?"":IoI(g,{width:B,height:C||720}),[g,B,C]);z.useMemo(()=>{if(!Q)return n4();const E=Q.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return $NA(E)}catch(n){return console.error(n),n4()}},[Q]);const i=z.useMemo(()=>T.jsx("div",{ref:t,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:Q}}),[Q]);return T.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:i})};const CPI=["Initialize a tscircuit project using [tsci init](https://github.com/tscircuit/cli) before adding components.","Define reusable modules with cached routes using [<subcircuit />](https://docs.tscircuit.com/elements/subcircuit)","Run `tsci dev` on the command line to preview your boards before export",'Use units like mm or mils consistently across your designs (e.g. pcbX="10mm")',"Quickly set footprints with the [footprint prop](https://docs.tscircuit.com/footprints/footprinter-strings)","Check out the guide on [ordering prototypes](https://docs.tscircuit.com/building-electronics/ordering-prototypes)","Use [net labels](https://docs.tscircuit.com/elements/net) and [group elements](https://docs.tscircuit.com/elements/group) to organize complex schematics.","You can manually drag components on the PCB and Schematic using [manual edits](https://docs.tscircuit.com/guides/manual-edits)","Every tscircuit module can export to [Circuit JSON](https://github.com/tscircuit/circuit-json), Gerbers, Pick'n'Place CSV files, Bill of Materials CSV and more","You can import components from [JLCPCB](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-jlcpcb) or [KiCad](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-kicad)","Any module you push to the [registry](https://tscircuit.com/trending) will have [simple image urls](https://docs.tscircuit.com/web-apis/image-generation-api) you can use display images on a website","The default [Parts Engine](https://docs.tscircuit.com/guides/platform-configuration) will automatically find parts from common vendors for your BOM",'[Pin selectors](https://docs.tscircuit.com/guides/using-sel-references) are similar to CSS selectors, ".R1 > .pin1" means "connect to the first pin of the component R1"',"You can use the [sel](https://docs.tscircuit.com/guides/using-sel-references) object to select pins in a type-safe way","Publish modules via the [registry](https://tscircuit.com/trending) for working with a team or sharing your work","[Explore tutorials](https://docs.tscircuit.com/category/tutorials) for real-world circuit design examples.","Upload your Circuit JSON to [circuitjson.com](https://circuitjson.com) for a quick preview.","You can display Circuit JSON in 3D, PCB or Schematic mode with the [<CircuitJsonPreview />](https://docs.tscircuit.com/guides/running-tscircuit/displaying-circuit-json-on-a-webpage#react-display-all-available-previews-with-circuitjsonpreview-) React component","Use a [<group />](https://docs.tscircuit.com/elements/group) element to move multiple components at once in a schematic or PCB layout.","Check out the [GitHub Discussions page](https://github.com/tscircuit/tscircuit/discussions) to upvote features","You can customize the autorouter using the [autorouter prop](https://docs.tscircuit.com/elements/board#setting-the-autorouter)","Use the [<constraint />](https://docs.tscircuit.com/footprints/constraint) element to enforce geometric relationships in PCB designs.","When working on component placement and circuit design, autorouting can slow down your iteration cycle. Use [routingDisabled](https://docs.tscircuit.com/elements/board#disabling-routing-with-routingdisabled) on the <board /> element to disable autorouting temporarily.","Join the [Discord server](https://tscircuit.com/join) to discuss issues and get help directly from the community."],wmo=(()=>{let g=CPI[Math.floor(Math.random()*CPI.length)];return g=g.replace(/</g,"<"),g=g.replace(/>/g,">"),g=g.replace(new RegExp('(?<!href=")(?<!\\()(?<!\\]\\()(https?:\\/\\/[^\\s\\)\\]]+)',"g"),(A,I)=>`<a class="rf-text-blue-500 rf-underline" href="${A}" target="_blank">${A}</a>`),g=g.replace(/\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/g,'<a class="rf-text-blue-500 rf-underline" href="$2" target="_blank">$1</a>'),g})(),QP=({onRunClicked:g})=>T.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-justify-center rf-h-full rf-bg-gray-50 rf-text-gray-500 rf-p-4",children:[T.jsx(cco,{className:"rf-size-14 rf-mb-4"}),T.jsxs("p",{className:"rf-text-md rf-break-words rf-max-w-xl rf-text-center",children:["Tip: ",T.jsx("span",{dangerouslySetInnerHTML:{__html:wmo}})]}),g&&T.jsxs(si,{className:"rf-mt-4 rf-bg-blue-600 rf-hover:bg-blue-500",onClick:g,children:["Run Code",T.jsx(sxI,{className:"rf-w-3 rf-h-3 rf-ml-2"})]})]}),npA=({text:g,onClick:A})=>T.jsx("span",{className:"rf-cursor-pointer rf-underline rf-text-blue-600 rf-mx-2",onClick:A,children:g}),spA=g=>T.jsxs("div",{className:"rf-leading-5",children:[T.jsx("div",{className:"rf-py-2 rf-font-bold",children:g.column.name}),T.jsx("div",{children:g.field?.()??T.jsx("input",{type:"text",className:"rf-border rf-rounded rf-p-1 rf-w-full",onChange:A=>{g.onTextChange?.(A.target.value)}})})]}),umo=({open:g,children:A,title:I,onClose:e})=>g?T.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-justify-center rf-items-center rf-z-50",onClick:e,children:T.jsxs("div",{className:"rf-bg-white rf-p-5 rf-rounded-lg rf-relative rf-w-11/12 rf-max-w-2xl",onClick:t=>{t.preventDefault(),t.stopPropagation()},children:[T.jsx("h2",{className:"rf-mt-0 rf-text-md rf-pb-4",children:I}),T.jsx("button",{type:"button",className:"rf-absolute rf-top-2 rf-right-4 rf-text-2xl rf-font-bold",onClick:e,children:"×"}),A]})}):null,Gmo=({elements:g})=>{const[A,I]=z.useState({open:!1}),[e,t]=z.useReducer((E,n)=>({...E,...n}),{}),o=[...new Set(g.map(E=>E.type))],B=g.map(E=>{const n=E[`${E.type}_id`],s=Object.fromEntries(Object.entries(E).filter(([a])=>!(a===`${E.type}_id`||!a.endsWith("_id")))),r=Object.fromEntries(Object.entries(E).filter(([a])=>!a.endsWith("_id")));return{primary_id:n,other_ids:s,...r,_og_elm:E}}),C=B.map(E=>{let n="";const s=r=>{const a=Object.keys(r.other_ids).find(l=>l.startsWith("source_"));if(!a)return`.${r.name}`;const c=a.slice(0,-3),h=B.find(l=>l.type===c&&l.primary_id===r.other_ids[a]);return h?"name"in h?`${s(h)} > .${r.name}`:`#${h.primary_id} > .${r.name}`:`??? > .${r.name}`};return"name"in E&&(n=s(E)),{...E,selector_path:n}}),Q=[{key:"primary_id",name:"primary_id",renderCell:E=>T.jsxs("div",{className:"rf-flex rf-items-center",children:[T.jsx(npA,{text:E.primary_id,onClick:()=>t({focused_id:E.primary_id,id_search:void 0,selector_search:void 0})}),T.jsx("span",{className:"rf-flex-grow"}),T.jsx(npA,{text:"(JSON)",onClick:()=>I({open:!0,element:E._og_elm,title:E.primary_id})})]}),renderHeaderCell:E=>T.jsx(spA,{column:E,onTextChange:n=>t({id_search:n}),field:e.focused_id?()=>T.jsxs("div",{children:["Focus:"," ",T.jsx("span",{className:"rf-underline",children:e.focused_id}),T.jsx(npA,{text:"(unfocus)",onClick:()=>t({focused_id:void 0})})]}):void 0})},{key:"type",name:"type",renderHeaderCell:E=>T.jsx(spA,{column:E,field:()=>T.jsxs("select",{onChange:n=>t({component_type_filter:n.target.value}),className:"rf-border rf-rounded rf-p-1 rf-w-full",children:[T.jsx("option",{value:"any",children:"any"},"any"),T.jsx("option",{value:"source",children:"source"},"source"),T.jsx("option",{value:"source/pcb",children:"source/pcb"},"source/pcb"),T.jsx("option",{value:"source/schematic",children:"source/schematic"},"source/schematic"),o.map(n=>T.jsx("option",{value:n,children:n},n))]})})},{key:"name",name:"name",renderHeaderCell:E=>T.jsx(spA,{column:E,onTextChange:n=>t({name_search:n})})},{key:"selector_path",name:"selector_path",renderHeaderCell:E=>T.jsx(spA,{column:E,onTextChange:n=>t({selector_search:n})})},{key:"other_ids",name:"other_ids",renderCell:E=>T.jsx("div",{className:"rf-space-x-2",children:Object.entries(E.other_ids).map(([n,s])=>T.jsx(npA,{text:s,onClick:()=>t({focused_id:s})},s))})}],i=C.filter(E=>e.name_search?E.name?.toLowerCase()?.includes(e.name_search.toLowerCase()):!0).filter(E=>!e.component_type_filter||e.component_type_filter==="any"?!0:e.component_type_filter==="source"?E.type.startsWith("source_"):e.component_type_filter==="source/pcb"?E.type.startsWith("source_")||E.type.startsWith("pcb_"):e.component_type_filter==="source/schematic"?E.type.startsWith("source_")||E.type.startsWith("schematic_"):E.type?.includes(e.component_type_filter)).filter(E=>e.selector_search?e.selector_search.split(" ").filter(s=>s.length>0).every(s=>E.selector_path?.includes(s)):!0).filter(E=>e.id_search?E.primary_id?.includes(e.id_search):!0).filter(E=>!!(!e.focused_id||E.primary_id===e.focused_id||Object.values(E.other_ids).includes(e.focused_id)));return T.jsxs("div",{className:"rf-font-mono rf-text-xs rf-bg-white",children:[T.jsx("div",{className:"rf-overflow-x-auto",children:T.jsxs("table",{className:"rf-table-auto rf-w-full rf-text-left",children:[T.jsx("thead",{children:T.jsx("tr",{children:Q.map(E=>T.jsx("th",{className:"rf-px-4 rf-py-2 rf-border-b",children:E.renderHeaderCell?E.renderHeaderCell(E):E.name},E.key))})}),T.jsx("tbody",{children:i.map((E,n)=>T.jsx("tr",{className:"rf-hover:bg-gray-100",children:Q.map(s=>T.jsx("td",{className:"rf-px-4 rf-py-2 rf-border-b",children:s.renderCell?s.renderCell(E):E[s.key]},s.key))},n))})]})}),T.jsx(umo,{open:A.open,onClose:()=>I({open:!1}),title:A.open?A.title:"",children:T.jsx("div",{className:"rf-bg-gray-800 rf-p-3 rf-text-white rf-rounded",children:T.jsx("pre",{className:"rf-whitespace-pre-wrap",children:A.open?JSON.stringify(A.element,null,2):""})})})]})};var mmo=()=>{if(globalThis.tscircuitDynamicModules)return globalThis.tscircuitDynamicModules;const g={};return globalThis.tscircuitDynamicModules=g,g},pmo=["circuit-json-to-3d-png","circuit-json-to-bom-csv","circuit-json-to-bpc","circuit-json-to-connectivity-map","circuit-json-to-fdm-component-box","circuit-json-to-gerber","circuit-json-to-gltf","circuit-json-to-kicad","circuit-json-to-lbrn","circuit-json-to-pnp-csv","circuit-json-to-readable-netlist","circuit-json-to-simple-3d","circuit-json-to-spice","circuit-json-to-step","circuit-json-to-tscircuit","circuit-to-canvas","circuit-to-svg","kicad-to-circuit-json","@tscircuit/circuit-json-schematic-placement-analysis"],QPI=g=>{const A=g.indexOf("@",g.startsWith("@")?1:0);return A===-1?g:g.slice(0,A)},kmo="https://jscdn.tscircuit.com";function iPI(){return typeof window<"u"&&window.TSCIRCUIT_JSCDN_BASE_URL||void 0}var Mmo=new Set(pmo),Smo=new Map([["@tscircuit/circuit-json-schematic-placement-analysis","dist/browser.js"]]);function fmo(g){if(!Mmo.has(QPI(g)))throw new Error(`Unsupported module: ${g}`)}var Rmo=g=>{fmo(g);const A=QPI(g),I=g.length===A.length?"latest":g.slice(A.length+1),e=Smo.get(A)??"+esm",t=iPI(),B=`${(t??kmo).replace(/\/+$/,"")}/${A}/${I}/${e}`;return t?new URL(B,window.location.href).href:B},Nmo=g=>{const A=Rmo(g);return iPI()?[A]:[A,`https://esm.run/${g}`]};function xmo(g=A=>import(A)){return async A=>{const I=mmo();if(Object.hasOwn(I,A))return I[A];let e;for(const t of Nmo(A))try{const o=await g(t);return I[A]=o,o}catch(o){e=o}throw e}}var Fmo=()=>globalThis.tscircuitDynamicImportResolver,EPI=xmo();async function Umo(g){const A=Fmo();return A?A(g,EPI):EPI(g)}var RS=Umo;const Jmo=(g,A)=>T.jsx("a",{className:"rf-underline rf-text-blue-500",target:"_blank",rel:"noreferrer",href:`https://jlcpcb.com/partdetail/${A}`,children:A}),Pmo=g=>g?.map(({manufacturer:A,mpn:I})=>`${A}: ${I}`).join(", "),Kmo=g=>{const A=new Set;let I=!1,e=!1;for(const t of g){t.supplier_part_number_columns?.["JLCPCB Part #"]!==void 0&&(I=!0);for(const o of Object.keys(t.extra_columns??{}))A.add(o);(t.manufacturer_mpn_pairs?.length??0)>0&&(e=!0)}return{extraColumnNames:[...A],hasSupplierColumn:I,hasManufacturerColumn:e}},Lmo=g=>{const A=[{key:"designator",label:"Designator",getCell:I=>I.designator},{key:"comment",label:"Comment",getCell:I=>I.comment},{key:"value",label:"Component Value",getCell:I=>I.value},{key:"footprint",label:"Footprint",getCell:I=>I.footprint}];g.hasSupplierColumn&&A.push({key:"supplier:JLCPCB Part #",label:"JLCPCB Part #",getCell:I=>{const e=I.supplier_part_number_columns?.["JLCPCB Part #"];return e?Jmo("jlcpcb",e):""}}),g.hasManufacturerColumn&&A.push({key:"manufacturer_mpn_pairs",label:"Manufacturer / MPN",getCell:I=>Pmo(I.manufacturer_mpn_pairs)});for(const I of g.extraColumnNames)A.push({key:`extra:${I}`,label:I,getCell:e=>e.extra_columns?.[I]||""});return A},Ymo=({circuitJson:g})=>{const[A,I]=z.useState(null),[e,t]=z.useState(null);if(z.useEffect(()=>{let C=!1;return(async()=>{try{t(null),I(null);const{convertCircuitJsonToBomRows:i}=await RS("circuit-json-to-bom-csv"),E=await i({circuitJson:g});C||I(E)}catch(i){C||t(i instanceof Error?i.message:"Unknown BOM error")}})(),()=>{C=!0}},[g]),e)throw new Error(e);const o=Kmo(A??[]),B=Lmo(o);return A?T.jsx("div",{className:"rf-overflow-x-auto",children:T.jsxs("table",{className:"rf-w-full rf-text-left rf-text-sm",children:[T.jsx("thead",{children:T.jsx("tr",{className:"rf-border-b",children:B.map(C=>T.jsx("th",{className:"rf-p-2",children:C.label},C.key))})}),T.jsx("tbody",{children:A.map((C,Q)=>T.jsx("tr",{className:"rf-border-b",children:B.map(i=>T.jsx("td",{className:"rf-p-2",children:i.getCell(C)},i.key))},C.designator||`${Q}`))})]})}):T.jsx("div",{className:"rf-p-4 rf-text-sm rf-text-muted-foreground",children:"Loading BOM..."})},yCg=z.forwardRef(({className:g,type:A,...I},e)=>T.jsx("input",{type:A,className:co("rf-flex rf-h-9 rf-w-full rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-px-3 rf-py-1 rf-text-sm rf-shadow-sm rf-transition-colors file:rf-border-0 file:rf-bg-transparent file:rf-text-sm file:rf-font-medium placeholder:rf-text-zinc-500 focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-placeholder-zinc-400 dark:focus-visible:rf-ring-zinc-300",g),ref:e,...I}));yCg.displayName="Input";const _mo=({circuitJson:g,containerClassName:A,...I})=>{const e=z.useRef(null),[t,o]=z.useState(620);return z.useLayoutEffect(()=>{const B=()=>{if(e.current){const Q=e.current.clientHeight;o(Q||620)}};B();const C=new ResizeObserver(B);return e.current&&C.observe(e.current),window.addEventListener("resize",B),()=>{C.disconnect(),window.removeEventListener("resize",B)}},[]),T.jsx("div",{ref:e,className:A||"rf-w-full rf-h-full",children:T.jsx(vog,{...I,circuitJson:g,height:t})})},bmo='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-1{right:.25rem}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.\\!rf-z-\\[200\\]{z-index:200!important}.rf-z-10{z-index:10}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.rf-z-\\[101\\]{z-index:101}.rf-z-\\[102\\]{z-index:102}.rf-order-1{order:1}.rf-order-2{order:2}.rf-order-3{order:3}.rf-m-0{margin:0}.rf-m-1{margin:.25rem}.rf-m-6{margin:1.5rem}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-4{margin-left:1rem;margin-right:1rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-0{margin-bottom:0}.rf-mb-0\\.5{margin-bottom:.125rem}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-7{margin-bottom:1.75rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-6{margin-left:1.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mr-4{margin-right:1rem}.rf-mr-auto{margin-right:auto}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline-block{display:inline-block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-\\[4\\/3\\]{aspect-ratio:4/3}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-2{height:.5rem;width:.5rem}.rf-size-3{height:.75rem;width:.75rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.rf-h-0{height:0}.rf-h-0\\.5{height:.125rem}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-20{height:5rem}.rf-h-24{height:6rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-7{height:1.75rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[620px\\]{height:620px}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-auto{height:auto}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-16{max-height:4rem}.rf-max-h-20{max-height:5rem}.rf-max-h-24{max-height:6rem}.rf-max-h-28{max-height:7rem}.rf-max-h-32{max-height:8rem}.rf-max-h-64{max-height:16rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[120px\\]{max-height:120px}.rf-max-h-\\[150px\\]{max-height:150px}.rf-max-h-\\[200px\\]{max-height:200px}.rf-max-h-\\[300px\\]{max-height:300px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-max-h-none{max-height:none}.rf-min-h-0{min-height:0}.rf-min-h-56{min-height:14rem}.rf-min-h-72{min-height:18rem}.rf-min-h-\\[100px\\]{min-height:100px}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[300px\\]{min-height:300px}.rf-min-h-\\[360px\\]{min-height:360px}.rf-min-h-\\[400px\\]{min-height:400px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-full{min-height:100%}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.\\!rf-w-\\[95vw\\]{width:95vw!important}.rf-w-1{width:.25rem}.rf-w-10{width:2.5rem}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-20{width:5rem}.rf-w-24{width:6rem}.rf-w-28{width:7rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-40{width:10rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-7{width:1.75rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-80{width:20rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[6ch\\]{width:6ch}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-w-screen{width:100vw}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-32{min-width:8rem}.rf-min-w-80{min-width:20rem}.rf-min-w-96{min-width:24rem}.rf-min-w-\\[12px\\]{min-width:12px}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[192px\\]{min-width:192px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[95vw\\]{max-width:95vw!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-64{max-width:16rem}.rf-max-w-7xl{max-width:80rem}.rf-max-w-96{max-width:24rem}.rf-max-w-\\[150px\\]{max-width:150px}.rf-max-w-\\[200px\\]{max-width:200px}.rf-max-w-\\[320px\\]{max-width:320px}.rf-max-w-\\[40\\%\\]{max-width:40%}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-max-w-xs{max-width:20rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-basis-48{flex-basis:12rem}.rf-table-auto{table-layout:auto}.rf-origin-\\[--radix-popover-content-transform-origin\\]{transform-origin:var(--radix-popover-content-transform-origin)}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf--translate-y-0{--tw-translate-y:-0px}.rf--translate-y-0,.rf--translate-y-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-y-1{--tw-translate-y:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.-rf-rotate-90{--tw-rotate:-90deg}.-rf-rotate-90,.rf-rotate-90{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-rotate-90{--tw-rotate:90deg}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-content-center{place-content:center}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-items-baseline{align-items:baseline}.rf-items-stretch{align-items:stretch}.rf-justify-start{justify-content:flex-start}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-1\\.5{gap:.375rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-gap-x-5{-moz-column-gap:1.25rem;column-gap:1.25rem}.rf-gap-y-1{row-gap:.25rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.25rem*var(--tw-space-y-reverse));margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rf-whitespace-normal{white-space:normal}.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-text-nowrap{text-wrap:nowrap}.rf-break-words{overflow-wrap:break-word}.rf-break-all{word-break:break-all}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-none{border-radius:0}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-0{border-width:0}.rf-border-2{border-width:2px}.rf-border-y{border-top-width:1px}.rf-border-b,.rf-border-y{border-bottom-width:1px}.rf-border-l-2{border-left-width:2px}.rf-border-l-4{border-left-width:4px}.rf-border-r{border-right-width:1px}.rf-border-t{border-top-width:1px}.rf-border-none{border-style:none}.rf-border-blue-100{--tw-border-opacity:1;border-color:rgb(219 234 254/var(--tw-border-opacity,1))}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-300{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.rf-border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-border{border-color:hsl(var(--border))}.rf-border-emerald-500{--tw-border-opacity:1;border-color:rgb(16 185 129/var(--tw-border-opacity,1))}.rf-border-gray-100{--tw-border-opacity:1;border-color:rgb(243 244 246/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-green-400{--tw-border-opacity:1;border-color:rgb(74 222 128/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-100{--tw-border-opacity:1;border-color:rgb(255 237 213/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-orange-500{--tw-border-opacity:1;border-color:rgb(249 115 22/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-100{--tw-border-opacity:1;border-color:rgb(254 226 226/var(--tw-border-opacity,1))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-300{--tw-border-opacity:1;border-color:rgb(252 165 165/var(--tw-border-opacity,1))}.rf-border-red-400{--tw-border-opacity:1;border-color:rgb(248 113 113/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-red-600{--tw-border-opacity:1;border-color:rgb(220 38 38/var(--tw-border-opacity,1))}.rf-border-red-700{--tw-border-opacity:1;border-color:rgb(185 28 28/var(--tw-border-opacity,1))}.rf-border-red-800{--tw-border-opacity:1;border-color:rgb(153 27 27/var(--tw-border-opacity,1))}.rf-border-slate-200{--tw-border-opacity:1;border-color:rgb(226 232 240/var(--tw-border-opacity,1))}.rf-border-slate-700{--tw-border-opacity:1;border-color:rgb(51 65 85/var(--tw-border-opacity,1))}.rf-border-slate-800{--tw-border-opacity:1;border-color:rgb(30 41 59/var(--tw-border-opacity,1))}.rf-border-slate-800\\/60{border-color:rgba(30,41,59,.6)}.rf-border-transparent{border-color:transparent}.rf-border-yellow-200{--tw-border-opacity:1;border-color:rgb(254 240 138/var(--tw-border-opacity,1))}.rf-border-zinc-100{--tw-border-opacity:1;border-color:rgb(244 244 245/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-border-l-blue-500{--tw-border-opacity:1;border-left-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-t-blue-600{--tw-border-opacity:1;border-top-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-bg-amber-50{--tw-bg-opacity:1;background-color:rgb(255 251 235/var(--tw-bg-opacity,1))}.rf-bg-amber-50\\/30{background-color:rgba(255,251,235,.3)}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-emerald-500{--tw-bg-opacity:1;background-color:rgb(16 185 129/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-300{--tw-bg-opacity:1;background-color:rgb(134 239 172/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-green-600{--tw-bg-opacity:1;background-color:rgb(22 163 74/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-100{--tw-bg-opacity:1;background-color:rgb(255 237 213/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-orange-50\\/50{background-color:rgba(255,247,237,.5)}.rf-bg-orange-500{--tw-bg-opacity:1;background-color:rgb(249 115 22/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-purple-500{--tw-bg-opacity:1;background-color:rgb(168 85 247/var(--tw-bg-opacity,1))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-50\\/50{background-color:rgba(254,242,242,.5)}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-600{--tw-bg-opacity:1;background-color:rgb(220 38 38/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-red-950{--tw-bg-opacity:1;background-color:rgb(69 10 10/var(--tw-bg-opacity,1))}.rf-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.rf-bg-slate-800{--tw-bg-opacity:1;background-color:rgb(30 41 59/var(--tw-bg-opacity,1))}.rf-bg-slate-900{--tw-bg-opacity:1;background-color:rgb(15 23 42/var(--tw-bg-opacity,1))}.rf-bg-transparent{background-color:transparent}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-yellow-50{--tw-bg-opacity:1;background-color:rgb(254 252 232/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-zinc-950{--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.rf-from-blue-500{--tw-gradient-from:#3b82f6 var(--tw-gradient-from-position);--tw-gradient-to:rgba(59,130,246,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-emerald-500{--tw-gradient-from:#10b981 var(--tw-gradient-from-position);--tw-gradient-to:rgba(16,185,129,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-green-500{--tw-gradient-from:#22c55e var(--tw-gradient-from-position);--tw-gradient-to:rgba(34,197,94,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-red-500{--tw-gradient-from:#ef4444 var(--tw-gradient-from-position);--tw-gradient-to:rgba(239,68,68,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-to-blue-600{--tw-gradient-to:#2563eb var(--tw-gradient-to-position)}.rf-to-emerald-600{--tw-gradient-to:#059669 var(--tw-gradient-to-position)}.rf-to-green-600{--tw-gradient-to:#16a34a var(--tw-gradient-to-position)}.rf-to-red-600{--tw-gradient-to:#dc2626 var(--tw-gradient-to-position)}.rf-fill-amber-500{fill:#f59e0b}.rf-fill-current{fill:currentColor}.rf-stroke-1{stroke-width:1}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-1\\.5{padding-left:.375rem;padding-right:.375rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-2\\.5{padding-left:.625rem;padding-right:.625rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-5{padding-left:1.25rem;padding-right:1.25rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-1{padding-bottom:.25rem}.rf-pb-1\\.5{padding-bottom:.375rem}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pb-px{padding-bottom:1px}.rf-pl-10{padding-left:2.5rem}.rf-pl-11{padding-left:2.75rem}.rf-pl-12{padding-left:3rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-0{padding-top:0}.rf-pt-1{padding-top:.25rem}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-align-bottom{vertical-align:bottom}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-font-sans{font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[10px\\]{font-size:10px}.rf-text-\\[11px\\]{font-size:11px}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.\\!rf-font-normal{font-weight:400!important}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-normal{font-weight:400}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-4{line-height:1rem}.rf-leading-5{line-height:1.25rem}.rf-leading-\\[0\\.95rem\\]{line-height:.95rem}.rf-leading-\\[1rem\\]{line-height:1rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-tight{letter-spacing:-.025em}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-wider{letter-spacing:.05em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-amber-500{--tw-text-opacity:1;color:rgb(245 158 11/var(--tw-text-opacity,1))}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-emerald-600{--tw-text-opacity:1;color:rgb(5 150 105/var(--tw-text-opacity,1))}.rf-text-foreground{color:hsl(var(--foreground))}.rf-text-gray-200{--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity,1))}.rf-text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity,1))}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted{color:hsl(var(--muted))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-400{--tw-text-opacity:1;color:rgb(251 146 60/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-700{--tw-text-opacity:1;color:rgb(194 65 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-slate-200{--tw-text-opacity:1;color:rgb(226 232 240/var(--tw-text-opacity,1))}.rf-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1))}.rf-text-slate-50{--tw-text-opacity:1;color:rgb(248 250 252/var(--tw-text-opacity,1))}.rf-text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity,1))}.rf-text-slate-600{--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.rf-text-slate-800{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-600{--tw-text-opacity:1;color:rgb(202 138 4/var(--tw-text-opacity,1))}.rf-text-yellow-700{--tw-text-opacity:1;color:rgb(161 98 7/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-600{--tw-text-opacity:1;color:rgb(82 82 91/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-accent-blue-600{accent-color:#2563eb}.rf-opacity-0{opacity:0}.rf-opacity-10{opacity:.1}.rf-opacity-100{opacity:1}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-70{opacity:.7}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-none{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-shadow-sm,.rf-shadow-xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-xl{--tw-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 8px 10px -6px rgba(0,0,0,.1);--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color),0 8px 10px -6px var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-transform{transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-150{transition-duration:.15s}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-animate-in{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.rf-fade-in-0{--tw-enter-opacity:0}.rf-zoom-in-95{--tw-enter-scale:.95}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-150{animation-duration:.15s}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.no-scrollbar::-webkit-scrollbar{display:none}.no-scrollbar{-ms-overflow-style:none;scrollbar-width:none}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf--translate-y-0\\.5:hover{--tw-translate-y:-0.125rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:rf-border-zinc-300:hover{--tw-border-opacity:1;border-color:rgb(212 212 216/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-gray-50:hover{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.hover\\:rf-bg-orange-100:hover{--tw-bg-opacity:1;background-color:rgb(255 237 213/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-100:hover{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-slate-100:hover{--tw-bg-opacity:1;background-color:rgb(241 245 249/var(--tw-bg-opacity,1))}.hover\\:rf-bg-slate-200:hover{--tw-bg-opacity:1;background-color:rgb(226 232 240/var(--tw-bg-opacity,1))}.hover\\:rf-bg-slate-50:hover{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-blue-800:hover{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.hover\\:rf-text-gray-700:hover{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-800:hover{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-900:hover{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.hover\\:rf-shadow-md:hover{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-blue-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-900:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(24 24 27/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-text-gray-500:disabled{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.disabled\\:rf-opacity-40:disabled{opacity:.4}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group:hover .group-hover\\:rf-scale-\\[1\\.03\\]{--tw-scale-x:1.03;--tw-scale-y:1.03;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-group:hover .group-hover\\:rf-opacity-100,.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.rf-peer:disabled~.peer-disabled\\:rf-cursor-not-allowed{cursor:not-allowed}.rf-peer:disabled~.peer-disabled\\:rf-opacity-70{opacity:.7}.data-\\[disabled\\=true\\]\\:rf-pointer-events-none[data-disabled=true],.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[selected\\=true\\]\\:rf-bg-zinc-100[data-selected=true]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[selected\\=true\\]\\:rf-text-zinc-900[data-selected=true]{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\=true\\]\\:rf-opacity-50[data-disabled=true],.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-gray-700:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.dark\\:rf-bg-gray-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-gray-500:is(.rf-dark *){--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-300:is(.rf-dark *){--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-bg-zinc-800[data-selected=true]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-text-zinc-50[data-selected=true]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-order-1{order:1}.sm\\:rf-order-2{order:2}.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-mt-4{margin-top:1rem}.sm\\:rf-block{display:block}.sm\\:rf-inline{display:inline}.sm\\:rf-grid{display:grid}.sm\\:rf-hidden{display:none}.sm\\:rf-h-5{height:1.25rem}.sm\\:rf-w-1\\/2{width:50%}.sm\\:rf-w-5{width:1.25rem}.sm\\:rf-w-\\[90vw\\]{width:90vw}.sm\\:rf-w-auto{width:auto}.sm\\:rf-max-w-\\[500px\\]{max-width:500px}.sm\\:rf-max-w-md{max-width:28rem}.sm\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\\:rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\\:rf-grid-cols-\\[1fr_auto\\]{grid-template-columns:1fr auto}.sm\\:rf-grid-cols-\\[minmax\\(0\\2c 1fr\\)_auto\\]{grid-template-columns:minmax(0,1fr) auto}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-items-center{align-items:center}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-gap-3{gap:.75rem}.sm\\:rf-gap-4{gap:1rem}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-p-3{padding:.75rem}.sm\\:rf-p-6{padding:1.5rem}.sm\\:rf-px-4{padding-left:1rem;padding-right:1rem}.sm\\:rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.sm\\:rf-px-8{padding-left:2rem;padding-right:2rem}.sm\\:rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.sm\\:rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.sm\\:rf-text-left{text-align:left}.sm\\:rf-text-2xl{font-size:1.5rem;line-height:2rem}.sm\\:rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.sm\\:rf-text-base{font-size:1rem;line-height:1.5rem}.sm\\:rf-text-sm{font-size:.875rem;line-height:1.25rem}.sm\\:rf-text-xl{font-size:1.25rem;line-height:1.75rem}}@media (min-width:768px){.md\\:rf-w-52{width:13rem}.md\\:rf-w-auto{width:auto}.md\\:rf-min-w-0{min-width:0}.md\\:rf-max-w-\\[660px\\]{max-width:660px}.md\\:rf-max-w-lg{max-width:32rem}.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\\:rf-grid-cols-\\[220px_1fr\\]{grid-template-columns:220px 1fr}.md\\:rf-flex-row{flex-direction:row}.md\\:rf-flex-col{flex-direction:column}.md\\:rf-overflow-y-auto{overflow-y:auto}.md\\:rf-overflow-x-hidden{overflow-x:hidden}.md\\:rf-border-b-0{border-bottom-width:0}.md\\:rf-border-r{border-right-width:1px}.md\\:rf-p-8{padding:2rem}.md\\:rf-py-8{padding-bottom:2rem;padding-top:2rem}.md\\:rf-text-3xl{font-size:1.875rem;line-height:2.25rem}}@media (min-width:1024px){.lg\\:rf-max-w-\\[720px\\]{max-width:720px}.lg\\:rf-max-w-xl{max-width:36rem}.lg\\:rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (min-width:1280px){.xl\\:rf-max-w-\\[800px\\]{max-width:800px}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-py-1\\.5 [cmdk-group-heading]{padding-bottom:.375rem;padding-top:.375rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-font-medium [cmdk-group-heading]{font-weight:500}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-500 [cmdk-group-heading]{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.dark\\:\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-400 [cmdk-group-heading]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group\\]\\:not\\(\\[hidden\\]\\)_\\~\\[cmdk-group\\]\\]\\:rf-pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\\[\\&_\\[cmdk-group\\]\\]\\:rf-px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\\[\\&_\\[cmdk-input\\]\\]\\:rf-h-12 [cmdk-input]{height:3rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-py-3 [cmdk-item]{padding-bottom:.75rem;padding-top:.75rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-h-5 [cmdk-item] svg{height:1.25rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-w-5 [cmdk-item] svg{width:1.25rem}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',noA=()=>{z.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const A=document.createElement("style");A.setAttribute("data-styles","tscircuit-runframe"),A.textContent=bmo,document.head.appendChild(A)},[])},Hmo=g=>{z.useEffect(()=>(g?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[g])},nPI=g=>`hsl(${OM.indexOf(g)*137.5%360}, 70%, 50%)`,vmo=({phaseTimings:g})=>{if(!g)return null;const A=Object.values(g).reduce((I,e)=>I+e,0);return T.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[T.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:OM.map(I=>{const e=g[I]||0,t=e/A*100;return T.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${t}%`,backgroundColor:nPI(I)},children:T.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[I,": ",e.toFixed(1),"ms"]})},I)})}),T.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",A.toFixed(2),"ms"]})]})},Tmo=g=>{if(g instanceof Blob)return g;if(g==null)return"";if(typeof g=="string")return g;if(typeof g=="object")try{return JSON.stringify(g,null,2)}catch{return String(g)}return String(g)},qmo=({renderLog:g,onRerunWithDebug:A})=>{const[I,e]=z.useState("chronological"),[t,o]=z.useState(""),B=[{value:"",label:"None"},{value:"DEBUG=Group_doInitialSchematicTraceRender",label:"DEBUG=Group_doInitialSchematicTraceRender"},{value:"DEBUG=Group_doInitialSchematicLayoutMatchpack",label:"DEBUG=Group_doInitialSchematicLayoutMatchpack"},{value:"DEBUG=Group_doInitialPcbLayoutPack",label:"DEBUG=Group_doInitialPcbLayoutPack"}];if(!g)return T.jsxs("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:[T.jsx("div",{className:"rf-mb-4",children:"No render log, make sure this tab is open when you render"}),A&&T.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[T.jsx("select",{value:t,onChange:i=>o(i.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:B.map(i=>T.jsx("option",{value:i.value,children:i.label},i.value))}),T.jsx(si,{onClick:()=>A(t),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]})]});const C=Object.entries(g?.phaseTimings??{});I==="chronological"?C.sort((i,E)=>OM.indexOf(i[0])-OM.indexOf(E[0])):C.sort((i,E)=>E[1]-i[1]);const Q=C.reduce((i,[E,n])=>i+n,0);return T.jsxs("div",{className:"rf-bg-white",children:[T.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mb-4",children:[T.jsx("div",{children:"Render Logs"}),T.jsxs("div",{className:"rf-flex rf-gap-4 rf-items-center",children:[A&&T.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[T.jsx("select",{value:t,onChange:i=>o(i.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:B.map(i=>T.jsx("option",{value:i.value,children:i.label},i.value))}),T.jsx(si,{onClick:()=>A(t),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]}),T.jsx("div",{className:"rf-flex rf-gap-2 rf-items-center",children:T.jsxs("select",{onChange:i=>{if(i.target.value){const E=g?.debugOutputs?.find(n=>n.name===i.target.value);if(E){const n=Tmo(E.content),s=n instanceof Blob?n:new Blob([n],{type:"text/plain"}),r=URL.createObjectURL(s),a=document.createElement("a");a.href=r,a.download=`debug-${E.name}.txt`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)}i.target.value=""}},disabled:!g?.debugOutputs||g.debugOutputs.length===0,className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white disabled:rf-opacity-50 disabled:rf-cursor-not-allowed",children:[T.jsx("option",{value:"",children:"Download Debug Output"}),g?.debugOutputs?.map(i=>T.jsx("option",{value:i.name,children:i.name},i.name))]})}),T.jsxs("div",{className:"rf-flex rf-text-xs rf-items-center",children:[T.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),T.jsxs("select",{value:I,onChange:i=>e(i.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[T.jsx("option",{value:"chronological",children:"Phase Order"}),T.jsx("option",{value:"longest",children:"Duration"})]})]})]})]}),T.jsx(vmo,{phaseTimings:g.phaseTimings}),T.jsxs("table",{className:"rf-w-full rf-text-xs",children:[T.jsx("thead",{children:T.jsxs("tr",{children:[T.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),T.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),T.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),T.jsx("tbody",{children:C.map(([i,E])=>T.jsxs("tr",{children:[T.jsx("td",{className:"rf-p-2",children:OM.indexOf(i)}),T.jsx("td",{className:"rf-p-2",children:i}),T.jsx("td",{className:"rf-p-2",children:T.jsx("div",{className:"rf-w-8",children:T.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:nPI(i),width:`${E/Q*100}%`}})})}),T.jsx("td",{className:"rf-p-2",children:T.jsxs("div",{className:"rf-flex w-full",children:[T.jsxs("span",{className:"rf-flex-grow",children:[E,"ms"]}),T.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(E/Q*100).toFixed(1),"%"]})]})})]},i))})]})]})};var Zmo=8,wCg=g=>Math.hypot(g.a,g.b)||1,Omo=g=>[g.label,g.inlineLabel].filter(Boolean).join(`
|
|
5635
|
+
`,Emo=()=>T.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:T.jsx("path",{d:"M20 6 9 17l-5-5"})}),nmo=({className:g})=>T.jsx("svg",{className:g,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.6,flexShrink:0},"aria-hidden":"true",children:T.jsx("path",{d:"m6 9 6 6 6-6"})}),smo=g=>{const A=new Map;return g.map(I=>{const e=(A.get(I.name)??0)+1;return A.set(I.name,e),{simulation:I,label:e===1?I.name:`${I.name} (${e})`}})},amo=({simulations:g,selectedSimulationExperimentId:A,onSelectSimulation:I})=>{const[e,t]=z.useState(!1);if(g.length<=1)return null;const o=smo(g),C=o.find(({simulation:Q})=>Q.simulation_experiment_id===A)?.label??"Select simulation";return T.jsxs(T.Fragment,{children:[T.jsx("style",{children:imo}),T.jsxs(mmA,{open:e,onOpenChange:t,modal:!1,children:[T.jsx(pmA,{asChild:!0,children:T.jsxs("button",{type:"button",title:C,onPointerDown:Q=>Q.stopPropagation(),style:{position:"absolute",top:"16px",left:"16px",display:"flex",alignItems:"center",gap:"6px",maxWidth:"280px",padding:"8px 12px",backgroundColor:"#ffffff",color:"#000000",border:"none",outline:"none",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",fontSize:"13px",fontFamily:dCg,zIndex:fS.viewMenuIcon},children:[T.jsx("span",{style:{color:"#888888",flexShrink:0},children:"Simulation:"}),T.jsx("span",{style:{...tPI,minWidth:0},children:C}),T.jsx(nmo,{className:"sv-simulation-chevron"})]})}),T.jsx(GO,{children:T.jsx(_tA,{style:Bmo,side:"bottom",align:"start",sideOffset:8,collisionPadding:10,children:o.map(({simulation:Q,label:i})=>{const E=Q.simulation_experiment_id===A;return T.jsxs(lF,{className:"sv-simulation-item",style:Cmo,title:i,onSelect:n=>n.preventDefault(),onPointerUp:()=>{I(Q.simulation_experiment_id),t(!1)},children:[T.jsx("span",{style:Qmo,children:E&&T.jsx(Emo,{})}),T.jsx("span",{style:{...tPI,minWidth:0},children:i})]},Q.simulation_experiment_id)})})})]})]})},rmo=1200,cmo=1,hmo=2,lmo=({circuitJson:g,containerStyle:A,colorOverrides:I,width:e,height:t,className:o,hideSchematic:B=!1,onSimulationChange:C,acSweepView:Q="magnitude"})=>{const[i,E]=z.useState(null),[n,s]=z.useState(!0),[r,a]=z.useState(null),[c,h]=z.useState(null),l=z.useRef(null),D=z.useRef(null),{containerWidth:d}=VJI(l),[y,w]=z.useState(!1),{ref:u}=QoA({onSetTransform(V){D.current&&(D.current.style.transform=nN(V))}}),m=e&&t?e/t:B?hmo:cmo,p=e||(t?t*m:d)||rmo,k=t||p/m;z.useEffect(()=>{s(!0),a(null),E(g),s(!1)},[g]);const S=z.useMemo(()=>i?i.filter(V=>V.type==="simulation_experiment"):[],[i]),[R,x]=z.useState(null),N=(R&&S.some(V=>V.simulation_experiment_id===R)?R:S[0]?.simulation_experiment_id)??null;z.useEffect(()=>{N!==R&&x(N)},[N,R]);const U=V=>{x(V),C?.(V)},K=z.useMemo(()=>{if(!i||!p||!k||!N)return"";try{const V={circuitJson:i,simulation_experiment_id:N,ac_sweep_view:Q,width:p,height:k};return B?YJI(V):Yuo({...V,schematicOptions:{colorOverrides:I}})}catch(V){return console.error("Failed to generate simulation SVG:",V),""}},[i,p,k,I,B,N,Q]);z.useEffect(()=>{if(!K){h(null);return}try{const V=new Blob([K],{type:"image/svg+xml"}),W=URL.createObjectURL(V);return h(W),()=>{URL.revokeObjectURL(W)}}catch(V){console.error("Failed to create SVG object URL:",V),h(null)}},[K]);const Y=z.useMemo(()=>omo(K,I),[K,I]),_=V=>{w(!0)},Z=V=>{w(!0)};return z.useEffect(()=>{const V=()=>{w(!1)},W=()=>{w(!1)};return window.addEventListener("mouseup",V),window.addEventListener("touchend",W),()=>{window.removeEventListener("mouseup",V),window.removeEventListener("touchend",W)}},[]),n?T.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f5f5f5",minHeight:"300px",fontFamily:"sans-serif",fontSize:"16px",color:"#666",...A},className:o,children:"Loading circuit..."}):r?T.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#fef2f2",minHeight:"300px",fontFamily:"sans-serif",fontSize:"16px",color:"#dc2626",...A},className:o,children:T.jsxs("div",{style:{textAlign:"center",padding:"20px"},children:[T.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:"Circuit Conversion Error"}),T.jsx("div",{style:{fontSize:"14px"},children:r})]})}):K?T.jsxs("div",{ref:V=>{l.current=V,u.current=V},style:{position:"relative",backgroundColor:Y,overflow:"hidden",minHeight:"300px",cursor:y?"grabbing":"grab",...A},className:o,onMouseDown:_,onTouchStart:Z,children:[T.jsx(amo,{simulations:S,selectedSimulationExperimentId:N,onSelectSimulation:U}),c?T.jsx("img",{ref:D,src:c,alt:"Circuit Simulation",style:{transformOrigin:"0 0",width:"100%",height:"100%",display:"block",objectFit:"contain"}}):T.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",minHeight:"300px",color:"#666",fontFamily:"sans-serif"},children:"Failed to render SVG"})]}):T.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"#f8fafc",minHeight:"300px",fontFamily:"sans-serif",gap:"12px",...A},className:o,children:[T.jsx("div",{style:{fontSize:"16px",color:"#475569",fontWeight:500},children:"No Simulation Found"}),T.jsxs("div",{style:{fontSize:"14px",color:"#64748b"},children:["Use"," ",T.jsx("code",{style:{backgroundColor:"#e2e8f0",padding:"2px 6px",borderRadius:"4px",fontFamily:"monospace",fontSize:"13px"},children:"<analogsimulation />"})," ","to create simulations"]})]})},Dmo=()=>{const[g,A]=z.useState(null),I=z.useCallback(o=>{A({schematicComponentId:o})},[]),e=z.useCallback(o=>{A(B=>B===o?null:B)},[]);return{controller:z.useMemo(()=>({focusRequest:g,onFocusRequestHandled:e}),[g,e]),focusSchematicComponent:I}},oPI=g=>{const[A,I]=z.useState(0),[e,t]=z.useState(0);return z.useEffect(()=>{if(!g.current)return;const o=()=>{const C=g.current?.getBoundingClientRect();I(C?.width||0),t(C?.height||0)};o();const B=new ResizeObserver(o);return B.observe(g.current),window.addEventListener("resize",o),()=>{B.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:A,containerHeight:e}};kE("assembly-viewer");var BPI=()=>{kE.enable("assembly-viewer*")},dmo=({circuitJson:g,containerStyle:A,debugGrid:I=!1,debug:e=!1})=>{e&&BPI();const t=z.useRef(null),{ref:o}=QoA({onSetTransform(E){t.current&&(t.current.style.transform=TV(E))}}),{containerWidth:B,containerHeight:C}=oPI(o),Q=z.useMemo(()=>!B||!C?"":OtI(g,{width:B,height:C||720}),[g,B,C]);z.useMemo(()=>{if(!Q)return n4();const E=Q.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return $NA(E)}catch(n){return console.error(n),n4()}},[Q]);const i=z.useMemo(()=>T.jsx("div",{ref:t,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:Q}}),[Q]);return T.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:i})},ymo=({circuitJson:g,containerStyle:A,debugGrid:I=!1,debug:e=!1})=>{e&&BPI();const t=z.useRef(null),{ref:o}=QoA({onSetTransform(E){t.current&&(t.current.style.transform=TV(E))}}),{containerWidth:B,containerHeight:C}=oPI(o),Q=z.useMemo(()=>!B||!C?"":IoI(g,{width:B,height:C||720}),[g,B,C]);z.useMemo(()=>{if(!Q)return n4();const E=Q.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return $NA(E)}catch(n){return console.error(n),n4()}},[Q]);const i=z.useMemo(()=>T.jsx("div",{ref:t,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:Q}}),[Q]);return T.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:i})};const CPI=["Initialize a tscircuit project using [tsci init](https://github.com/tscircuit/cli) before adding components.","Define reusable modules with cached routes using [<subcircuit />](https://docs.tscircuit.com/elements/subcircuit)","Run `tsci dev` on the command line to preview your boards before export",'Use units like mm or mils consistently across your designs (e.g. pcbX="10mm")',"Quickly set footprints with the [footprint prop](https://docs.tscircuit.com/footprints/footprinter-strings)","Check out the guide on [ordering prototypes](https://docs.tscircuit.com/building-electronics/ordering-prototypes)","Use [net labels](https://docs.tscircuit.com/elements/net) and [group elements](https://docs.tscircuit.com/elements/group) to organize complex schematics.","You can manually drag components on the PCB and Schematic using [manual edits](https://docs.tscircuit.com/guides/manual-edits)","Every tscircuit module can export to [Circuit JSON](https://github.com/tscircuit/circuit-json), Gerbers, Pick'n'Place CSV files, Bill of Materials CSV and more","You can import components from [JLCPCB](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-jlcpcb) or [KiCad](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-kicad)","Any module you push to the [registry](https://tscircuit.com/trending) will have [simple image urls](https://docs.tscircuit.com/web-apis/image-generation-api) you can use display images on a website","The default [Parts Engine](https://docs.tscircuit.com/guides/platform-configuration) will automatically find parts from common vendors for your BOM",'[Pin selectors](https://docs.tscircuit.com/guides/using-sel-references) are similar to CSS selectors, ".R1 > .pin1" means "connect to the first pin of the component R1"',"You can use the [sel](https://docs.tscircuit.com/guides/using-sel-references) object to select pins in a type-safe way","Publish modules via the [registry](https://tscircuit.com/trending) for working with a team or sharing your work","[Explore tutorials](https://docs.tscircuit.com/category/tutorials) for real-world circuit design examples.","Upload your Circuit JSON to [circuitjson.com](https://circuitjson.com) for a quick preview.","You can display Circuit JSON in 3D, PCB or Schematic mode with the [<CircuitJsonPreview />](https://docs.tscircuit.com/guides/running-tscircuit/displaying-circuit-json-on-a-webpage#react-display-all-available-previews-with-circuitjsonpreview-) React component","Use a [<group />](https://docs.tscircuit.com/elements/group) element to move multiple components at once in a schematic or PCB layout.","Check out the [GitHub Discussions page](https://github.com/tscircuit/tscircuit/discussions) to upvote features","You can customize the autorouter using the [autorouter prop](https://docs.tscircuit.com/elements/board#setting-the-autorouter)","Use the [<constraint />](https://docs.tscircuit.com/footprints/constraint) element to enforce geometric relationships in PCB designs.","When working on component placement and circuit design, autorouting can slow down your iteration cycle. Use [routingDisabled](https://docs.tscircuit.com/elements/board#disabling-routing-with-routingdisabled) on the <board /> element to disable autorouting temporarily.","Join the [Discord server](https://tscircuit.com/join) to discuss issues and get help directly from the community."],wmo=(()=>{let g=CPI[Math.floor(Math.random()*CPI.length)];return g=g.replace(/</g,"<"),g=g.replace(/>/g,">"),g=g.replace(new RegExp('(?<!href=")(?<!\\()(?<!\\]\\()(https?:\\/\\/[^\\s\\)\\]]+)',"g"),(A,I)=>`<a class="rf-text-blue-500 rf-underline" href="${A}" target="_blank">${A}</a>`),g=g.replace(/\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/g,'<a class="rf-text-blue-500 rf-underline" href="$2" target="_blank">$1</a>'),g})(),QP=({onRunClicked:g})=>T.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-justify-center rf-h-full rf-bg-gray-50 rf-text-gray-500 rf-p-4",children:[T.jsx(cco,{className:"rf-size-14 rf-mb-4"}),T.jsxs("p",{className:"rf-text-md rf-break-words rf-max-w-xl rf-text-center",children:["Tip: ",T.jsx("span",{dangerouslySetInnerHTML:{__html:wmo}})]}),g&&T.jsxs(si,{className:"rf-mt-4 rf-bg-blue-600 rf-hover:bg-blue-500",onClick:g,children:["Run Code",T.jsx(sxI,{className:"rf-w-3 rf-h-3 rf-ml-2"})]})]}),npA=({text:g,onClick:A})=>T.jsx("span",{className:"rf-cursor-pointer rf-underline rf-text-blue-600 rf-mx-2",onClick:A,children:g}),spA=g=>T.jsxs("div",{className:"rf-leading-5",children:[T.jsx("div",{className:"rf-py-2 rf-font-bold",children:g.column.name}),T.jsx("div",{children:g.field?.()??T.jsx("input",{type:"text",className:"rf-border rf-rounded rf-p-1 rf-w-full",onChange:A=>{g.onTextChange?.(A.target.value)}})})]}),umo=({open:g,children:A,title:I,onClose:e})=>g?T.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-justify-center rf-items-center rf-z-50",onClick:e,children:T.jsxs("div",{className:"rf-bg-white rf-p-5 rf-rounded-lg rf-relative rf-w-11/12 rf-max-w-2xl",onClick:t=>{t.preventDefault(),t.stopPropagation()},children:[T.jsx("h2",{className:"rf-mt-0 rf-text-md rf-pb-4",children:I}),T.jsx("button",{type:"button",className:"rf-absolute rf-top-2 rf-right-4 rf-text-2xl rf-font-bold",onClick:e,children:"×"}),A]})}):null,Gmo=({elements:g})=>{const[A,I]=z.useState({open:!1}),[e,t]=z.useReducer((E,n)=>({...E,...n}),{}),o=[...new Set(g.map(E=>E.type))],B=g.map(E=>{const n=E[`${E.type}_id`],s=Object.fromEntries(Object.entries(E).filter(([a])=>!(a===`${E.type}_id`||!a.endsWith("_id")))),r=Object.fromEntries(Object.entries(E).filter(([a])=>!a.endsWith("_id")));return{primary_id:n,other_ids:s,...r,_og_elm:E}}),C=B.map(E=>{let n="";const s=r=>{const a=Object.keys(r.other_ids).find(l=>l.startsWith("source_"));if(!a)return`.${r.name}`;const c=a.slice(0,-3),h=B.find(l=>l.type===c&&l.primary_id===r.other_ids[a]);return h?"name"in h?`${s(h)} > .${r.name}`:`#${h.primary_id} > .${r.name}`:`??? > .${r.name}`};return"name"in E&&(n=s(E)),{...E,selector_path:n}}),Q=[{key:"primary_id",name:"primary_id",renderCell:E=>T.jsxs("div",{className:"rf-flex rf-items-center",children:[T.jsx(npA,{text:E.primary_id,onClick:()=>t({focused_id:E.primary_id,id_search:void 0,selector_search:void 0})}),T.jsx("span",{className:"rf-flex-grow"}),T.jsx(npA,{text:"(JSON)",onClick:()=>I({open:!0,element:E._og_elm,title:E.primary_id})})]}),renderHeaderCell:E=>T.jsx(spA,{column:E,onTextChange:n=>t({id_search:n}),field:e.focused_id?()=>T.jsxs("div",{children:["Focus:"," ",T.jsx("span",{className:"rf-underline",children:e.focused_id}),T.jsx(npA,{text:"(unfocus)",onClick:()=>t({focused_id:void 0})})]}):void 0})},{key:"type",name:"type",renderHeaderCell:E=>T.jsx(spA,{column:E,field:()=>T.jsxs("select",{onChange:n=>t({component_type_filter:n.target.value}),className:"rf-border rf-rounded rf-p-1 rf-w-full",children:[T.jsx("option",{value:"any",children:"any"},"any"),T.jsx("option",{value:"source",children:"source"},"source"),T.jsx("option",{value:"source/pcb",children:"source/pcb"},"source/pcb"),T.jsx("option",{value:"source/schematic",children:"source/schematic"},"source/schematic"),o.map(n=>T.jsx("option",{value:n,children:n},n))]})})},{key:"name",name:"name",renderHeaderCell:E=>T.jsx(spA,{column:E,onTextChange:n=>t({name_search:n})})},{key:"selector_path",name:"selector_path",renderHeaderCell:E=>T.jsx(spA,{column:E,onTextChange:n=>t({selector_search:n})})},{key:"other_ids",name:"other_ids",renderCell:E=>T.jsx("div",{className:"rf-space-x-2",children:Object.entries(E.other_ids).map(([n,s])=>T.jsx(npA,{text:s,onClick:()=>t({focused_id:s})},s))})}],i=C.filter(E=>e.name_search?E.name?.toLowerCase()?.includes(e.name_search.toLowerCase()):!0).filter(E=>!e.component_type_filter||e.component_type_filter==="any"?!0:e.component_type_filter==="source"?E.type.startsWith("source_"):e.component_type_filter==="source/pcb"?E.type.startsWith("source_")||E.type.startsWith("pcb_"):e.component_type_filter==="source/schematic"?E.type.startsWith("source_")||E.type.startsWith("schematic_"):E.type?.includes(e.component_type_filter)).filter(E=>e.selector_search?e.selector_search.split(" ").filter(s=>s.length>0).every(s=>E.selector_path?.includes(s)):!0).filter(E=>e.id_search?E.primary_id?.includes(e.id_search):!0).filter(E=>!!(!e.focused_id||E.primary_id===e.focused_id||Object.values(E.other_ids).includes(e.focused_id)));return T.jsxs("div",{className:"rf-font-mono rf-text-xs rf-bg-white",children:[T.jsx("div",{className:"rf-overflow-x-auto",children:T.jsxs("table",{className:"rf-table-auto rf-w-full rf-text-left",children:[T.jsx("thead",{children:T.jsx("tr",{children:Q.map(E=>T.jsx("th",{className:"rf-px-4 rf-py-2 rf-border-b",children:E.renderHeaderCell?E.renderHeaderCell(E):E.name},E.key))})}),T.jsx("tbody",{children:i.map((E,n)=>T.jsx("tr",{className:"rf-hover:bg-gray-100",children:Q.map(s=>T.jsx("td",{className:"rf-px-4 rf-py-2 rf-border-b",children:s.renderCell?s.renderCell(E):E[s.key]},s.key))},n))})]})}),T.jsx(umo,{open:A.open,onClose:()=>I({open:!1}),title:A.open?A.title:"",children:T.jsx("div",{className:"rf-bg-gray-800 rf-p-3 rf-text-white rf-rounded",children:T.jsx("pre",{className:"rf-whitespace-pre-wrap",children:A.open?JSON.stringify(A.element,null,2):""})})})]})};var mmo=()=>{if(globalThis.tscircuitDynamicModules)return globalThis.tscircuitDynamicModules;const g={};return globalThis.tscircuitDynamicModules=g,g},pmo=["circuit-json-to-3d-png","circuit-json-to-bom-csv","circuit-json-to-bpc","circuit-json-to-connectivity-map","circuit-json-to-fdm-component-box","circuit-json-to-gerber","circuit-json-to-gltf","circuit-json-to-kicad","circuit-json-to-lbrn","circuit-json-to-pnp-csv","circuit-json-to-readable-netlist","circuit-json-to-simple-3d","circuit-json-to-spice","circuit-json-to-step","circuit-json-to-tscircuit","circuit-to-canvas","circuit-to-svg","kicad-to-circuit-json","@tscircuit/circuit-json-schematic-placement-analysis"],QPI=g=>{const A=g.indexOf("@",g.startsWith("@")?1:0);return A===-1?g:g.slice(0,A)},kmo="https://jscdn.tscircuit.com";function iPI(){return typeof window<"u"&&window.TSCIRCUIT_JSCDN_BASE_URL||void 0}var Mmo=new Set(pmo),Smo=new Map([["@tscircuit/circuit-json-schematic-placement-analysis","dist/browser.js"]]);function fmo(g){if(!Mmo.has(QPI(g)))throw new Error(`Unsupported module: ${g}`)}var Rmo=g=>{fmo(g);const A=QPI(g),I=g.length===A.length?"latest":g.slice(A.length+1),e=Smo.get(A)??"+esm",t=iPI(),B=`${(t??kmo).replace(/\/+$/,"")}/${A}/${I}/${e}`;return t?new URL(B,window.location.href).href:B},Nmo=g=>{const A=Rmo(g);return iPI()?[A]:[A,`https://esm.run/${g}`]};function xmo(g=A=>import(A)){return async A=>{const I=mmo();if(Object.hasOwn(I,A))return I[A];let e;for(const t of Nmo(A))try{const o=await g(t);return I[A]=o,o}catch(o){e=o}throw e}}var Fmo=()=>globalThis.tscircuitDynamicImportResolver,EPI=xmo();async function Umo(g){const A=Fmo();return A?A(g,EPI):EPI(g)}var RS=Umo;const Jmo=(g,A)=>T.jsx("a",{className:"rf-underline rf-text-blue-500",target:"_blank",rel:"noreferrer",href:`https://jlcpcb.com/partdetail/${A}`,children:A}),Pmo=g=>g?.map(({manufacturer:A,mpn:I})=>`${A}: ${I}`).join(", "),Kmo=g=>{const A=new Set;let I=!1,e=!1;for(const t of g){t.supplier_part_number_columns?.["JLCPCB Part #"]!==void 0&&(I=!0);for(const o of Object.keys(t.extra_columns??{}))A.add(o);(t.manufacturer_mpn_pairs?.length??0)>0&&(e=!0)}return{extraColumnNames:[...A],hasSupplierColumn:I,hasManufacturerColumn:e}},Lmo=g=>{const A=[{key:"designator",label:"Designator",getCell:I=>I.designator},{key:"comment",label:"Comment",getCell:I=>I.comment},{key:"value",label:"Component Value",getCell:I=>I.value},{key:"footprint",label:"Footprint",getCell:I=>I.footprint}];g.hasSupplierColumn&&A.push({key:"supplier:JLCPCB Part #",label:"JLCPCB Part #",getCell:I=>{const e=I.supplier_part_number_columns?.["JLCPCB Part #"];return e?Jmo("jlcpcb",e):""}}),g.hasManufacturerColumn&&A.push({key:"manufacturer_mpn_pairs",label:"Manufacturer / MPN",getCell:I=>Pmo(I.manufacturer_mpn_pairs)});for(const I of g.extraColumnNames)A.push({key:`extra:${I}`,label:I,getCell:e=>e.extra_columns?.[I]||""});return A},Ymo=({circuitJson:g})=>{const[A,I]=z.useState(null),[e,t]=z.useState(null);if(z.useEffect(()=>{let C=!1;return(async()=>{try{t(null),I(null);const{convertCircuitJsonToBomRows:i}=await RS("circuit-json-to-bom-csv"),E=await i({circuitJson:g});C||I(E)}catch(i){C||t(i instanceof Error?i.message:"Unknown BOM error")}})(),()=>{C=!0}},[g]),e)throw new Error(e);const o=Kmo(A??[]),B=Lmo(o);return A?T.jsx("div",{className:"rf-overflow-x-auto",children:T.jsxs("table",{className:"rf-w-full rf-text-left rf-text-sm",children:[T.jsx("thead",{children:T.jsx("tr",{className:"rf-border-b",children:B.map(C=>T.jsx("th",{className:"rf-p-2",children:C.label},C.key))})}),T.jsx("tbody",{children:A.map((C,Q)=>T.jsx("tr",{className:"rf-border-b",children:B.map(i=>T.jsx("td",{className:"rf-p-2",children:i.getCell(C)},i.key))},C.designator||`${Q}`))})]})}):T.jsx("div",{className:"rf-p-4 rf-text-sm rf-text-muted-foreground",children:"Loading BOM..."})},yCg=z.forwardRef(({className:g,type:A,...I},e)=>T.jsx("input",{type:A,className:co("rf-flex rf-h-9 rf-w-full rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-px-3 rf-py-1 rf-text-sm rf-shadow-sm rf-transition-colors file:rf-border-0 file:rf-bg-transparent file:rf-text-sm file:rf-font-medium placeholder:rf-text-zinc-500 focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-placeholder-zinc-400 dark:focus-visible:rf-ring-zinc-300",g),ref:e,...I}));yCg.displayName="Input";const _mo=({circuitJson:g,containerClassName:A,...I})=>{const e=z.useRef(null),[t,o]=z.useState(620);return z.useLayoutEffect(()=>{const B=()=>{if(e.current){const Q=e.current.clientHeight;o(Q||620)}};B();const C=new ResizeObserver(B);return e.current&&C.observe(e.current),window.addEventListener("resize",B),()=>{C.disconnect(),window.removeEventListener("resize",B)}},[]),T.jsx("div",{ref:e,className:A||"rf-w-full rf-h-full",children:T.jsx(vog,{...I,circuitJson:g,height:t})})},bmo='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-1{right:.25rem}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.\\!rf-z-\\[200\\]{z-index:200!important}.rf-z-10{z-index:10}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.rf-z-\\[101\\]{z-index:101}.rf-z-\\[102\\]{z-index:102}.rf-order-1{order:1}.rf-order-2{order:2}.rf-order-3{order:3}.rf-m-0{margin:0}.rf-m-1{margin:.25rem}.rf-m-6{margin:1.5rem}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-4{margin-left:1rem;margin-right:1rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-0{margin-bottom:0}.rf-mb-0\\.5{margin-bottom:.125rem}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-7{margin-bottom:1.75rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-6{margin-left:1.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mr-4{margin-right:1rem}.rf-mr-auto{margin-right:auto}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline-block{display:inline-block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-\\[4\\/3\\]{aspect-ratio:4/3}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-2{height:.5rem;width:.5rem}.rf-size-3{height:.75rem;width:.75rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.rf-h-0{height:0}.rf-h-0\\.5{height:.125rem}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-20{height:5rem}.rf-h-24{height:6rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-7{height:1.75rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[620px\\]{height:620px}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-auto{height:auto}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-16{max-height:4rem}.rf-max-h-20{max-height:5rem}.rf-max-h-24{max-height:6rem}.rf-max-h-28{max-height:7rem}.rf-max-h-32{max-height:8rem}.rf-max-h-64{max-height:16rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[120px\\]{max-height:120px}.rf-max-h-\\[150px\\]{max-height:150px}.rf-max-h-\\[200px\\]{max-height:200px}.rf-max-h-\\[300px\\]{max-height:300px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-max-h-none{max-height:none}.rf-min-h-0{min-height:0}.rf-min-h-56{min-height:14rem}.rf-min-h-72{min-height:18rem}.rf-min-h-\\[100px\\]{min-height:100px}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[300px\\]{min-height:300px}.rf-min-h-\\[360px\\]{min-height:360px}.rf-min-h-\\[400px\\]{min-height:400px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-full{min-height:100%}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.\\!rf-w-\\[95vw\\]{width:95vw!important}.rf-w-1{width:.25rem}.rf-w-10{width:2.5rem}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-20{width:5rem}.rf-w-24{width:6rem}.rf-w-28{width:7rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-40{width:10rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-7{width:1.75rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-80{width:20rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[6ch\\]{width:6ch}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-w-screen{width:100vw}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-32{min-width:8rem}.rf-min-w-80{min-width:20rem}.rf-min-w-96{min-width:24rem}.rf-min-w-\\[12px\\]{min-width:12px}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[192px\\]{min-width:192px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[95vw\\]{max-width:95vw!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-64{max-width:16rem}.rf-max-w-7xl{max-width:80rem}.rf-max-w-96{max-width:24rem}.rf-max-w-\\[150px\\]{max-width:150px}.rf-max-w-\\[200px\\]{max-width:200px}.rf-max-w-\\[320px\\]{max-width:320px}.rf-max-w-\\[40\\%\\]{max-width:40%}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-max-w-xs{max-width:20rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-basis-48{flex-basis:12rem}.rf-table-auto{table-layout:auto}.rf-origin-\\[--radix-popover-content-transform-origin\\]{transform-origin:var(--radix-popover-content-transform-origin)}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf--translate-y-0{--tw-translate-y:-0px}.rf--translate-y-0,.rf--translate-y-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-y-1{--tw-translate-y:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.-rf-rotate-90{--tw-rotate:-90deg}.-rf-rotate-90,.rf-rotate-90{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-rotate-90{--tw-rotate:90deg}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-content-center{place-content:center}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-items-baseline{align-items:baseline}.rf-items-stretch{align-items:stretch}.rf-justify-start{justify-content:flex-start}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-1\\.5{gap:.375rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-gap-x-5{-moz-column-gap:1.25rem;column-gap:1.25rem}.rf-gap-y-1{row-gap:.25rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.25rem*var(--tw-space-y-reverse));margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-y-hidden{overflow-y:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rf-whitespace-normal{white-space:normal}.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-text-nowrap{text-wrap:nowrap}.rf-break-words{overflow-wrap:break-word}.rf-break-all{word-break:break-all}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-none{border-radius:0}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-0{border-width:0}.rf-border-2{border-width:2px}.rf-border-y{border-top-width:1px}.rf-border-b,.rf-border-y{border-bottom-width:1px}.rf-border-l-2{border-left-width:2px}.rf-border-l-4{border-left-width:4px}.rf-border-r{border-right-width:1px}.rf-border-t{border-top-width:1px}.rf-border-none{border-style:none}.rf-border-blue-100{--tw-border-opacity:1;border-color:rgb(219 234 254/var(--tw-border-opacity,1))}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-300{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.rf-border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-border{border-color:hsl(var(--border))}.rf-border-emerald-500{--tw-border-opacity:1;border-color:rgb(16 185 129/var(--tw-border-opacity,1))}.rf-border-gray-100{--tw-border-opacity:1;border-color:rgb(243 244 246/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-green-400{--tw-border-opacity:1;border-color:rgb(74 222 128/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-100{--tw-border-opacity:1;border-color:rgb(255 237 213/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-orange-500{--tw-border-opacity:1;border-color:rgb(249 115 22/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-100{--tw-border-opacity:1;border-color:rgb(254 226 226/var(--tw-border-opacity,1))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-300{--tw-border-opacity:1;border-color:rgb(252 165 165/var(--tw-border-opacity,1))}.rf-border-red-400{--tw-border-opacity:1;border-color:rgb(248 113 113/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-red-600{--tw-border-opacity:1;border-color:rgb(220 38 38/var(--tw-border-opacity,1))}.rf-border-red-700{--tw-border-opacity:1;border-color:rgb(185 28 28/var(--tw-border-opacity,1))}.rf-border-red-800{--tw-border-opacity:1;border-color:rgb(153 27 27/var(--tw-border-opacity,1))}.rf-border-slate-200{--tw-border-opacity:1;border-color:rgb(226 232 240/var(--tw-border-opacity,1))}.rf-border-slate-700{--tw-border-opacity:1;border-color:rgb(51 65 85/var(--tw-border-opacity,1))}.rf-border-slate-800{--tw-border-opacity:1;border-color:rgb(30 41 59/var(--tw-border-opacity,1))}.rf-border-slate-800\\/60{border-color:rgba(30,41,59,.6)}.rf-border-transparent{border-color:transparent}.rf-border-yellow-200{--tw-border-opacity:1;border-color:rgb(254 240 138/var(--tw-border-opacity,1))}.rf-border-zinc-100{--tw-border-opacity:1;border-color:rgb(244 244 245/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-border-l-blue-500{--tw-border-opacity:1;border-left-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-t-blue-600{--tw-border-opacity:1;border-top-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-bg-amber-50{--tw-bg-opacity:1;background-color:rgb(255 251 235/var(--tw-bg-opacity,1))}.rf-bg-amber-50\\/30{background-color:rgba(255,251,235,.3)}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-emerald-500{--tw-bg-opacity:1;background-color:rgb(16 185 129/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-300{--tw-bg-opacity:1;background-color:rgb(134 239 172/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-green-600{--tw-bg-opacity:1;background-color:rgb(22 163 74/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-100{--tw-bg-opacity:1;background-color:rgb(255 237 213/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-orange-50\\/50{background-color:rgba(255,247,237,.5)}.rf-bg-orange-500{--tw-bg-opacity:1;background-color:rgb(249 115 22/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-purple-500{--tw-bg-opacity:1;background-color:rgb(168 85 247/var(--tw-bg-opacity,1))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-50\\/50{background-color:rgba(254,242,242,.5)}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-600{--tw-bg-opacity:1;background-color:rgb(220 38 38/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-red-950{--tw-bg-opacity:1;background-color:rgb(69 10 10/var(--tw-bg-opacity,1))}.rf-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.rf-bg-slate-800{--tw-bg-opacity:1;background-color:rgb(30 41 59/var(--tw-bg-opacity,1))}.rf-bg-slate-900{--tw-bg-opacity:1;background-color:rgb(15 23 42/var(--tw-bg-opacity,1))}.rf-bg-transparent{background-color:transparent}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-yellow-50{--tw-bg-opacity:1;background-color:rgb(254 252 232/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-zinc-950{--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.rf-from-blue-500{--tw-gradient-from:#3b82f6 var(--tw-gradient-from-position);--tw-gradient-to:rgba(59,130,246,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-emerald-500{--tw-gradient-from:#10b981 var(--tw-gradient-from-position);--tw-gradient-to:rgba(16,185,129,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-green-500{--tw-gradient-from:#22c55e var(--tw-gradient-from-position);--tw-gradient-to:rgba(34,197,94,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-from-red-500{--tw-gradient-from:#ef4444 var(--tw-gradient-from-position);--tw-gradient-to:rgba(239,68,68,0) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.rf-to-blue-600{--tw-gradient-to:#2563eb var(--tw-gradient-to-position)}.rf-to-emerald-600{--tw-gradient-to:#059669 var(--tw-gradient-to-position)}.rf-to-green-600{--tw-gradient-to:#16a34a var(--tw-gradient-to-position)}.rf-to-red-600{--tw-gradient-to:#dc2626 var(--tw-gradient-to-position)}.rf-fill-amber-500{fill:#f59e0b}.rf-fill-current{fill:currentColor}.rf-stroke-1{stroke-width:1}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-1\\.5{padding-left:.375rem;padding-right:.375rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-2\\.5{padding-left:.625rem;padding-right:.625rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-5{padding-left:1.25rem;padding-right:1.25rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-1{padding-bottom:.25rem}.rf-pb-1\\.5{padding-bottom:.375rem}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pb-px{padding-bottom:1px}.rf-pl-10{padding-left:2.5rem}.rf-pl-11{padding-left:2.75rem}.rf-pl-12{padding-left:3rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-0{padding-top:0}.rf-pt-1{padding-top:.25rem}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-align-bottom{vertical-align:bottom}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-font-sans{font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[10px\\]{font-size:10px}.rf-text-\\[11px\\]{font-size:11px}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.\\!rf-font-normal{font-weight:400!important}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-normal{font-weight:400}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-4{line-height:1rem}.rf-leading-5{line-height:1.25rem}.rf-leading-\\[0\\.95rem\\]{line-height:.95rem}.rf-leading-\\[1rem\\]{line-height:1rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-tight{letter-spacing:-.025em}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-wider{letter-spacing:.05em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-amber-500{--tw-text-opacity:1;color:rgb(245 158 11/var(--tw-text-opacity,1))}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-emerald-600{--tw-text-opacity:1;color:rgb(5 150 105/var(--tw-text-opacity,1))}.rf-text-foreground{color:hsl(var(--foreground))}.rf-text-gray-200{--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity,1))}.rf-text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity,1))}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted{color:hsl(var(--muted))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-400{--tw-text-opacity:1;color:rgb(251 146 60/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-700{--tw-text-opacity:1;color:rgb(194 65 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-slate-200{--tw-text-opacity:1;color:rgb(226 232 240/var(--tw-text-opacity,1))}.rf-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1))}.rf-text-slate-50{--tw-text-opacity:1;color:rgb(248 250 252/var(--tw-text-opacity,1))}.rf-text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity,1))}.rf-text-slate-600{--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.rf-text-slate-800{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-600{--tw-text-opacity:1;color:rgb(202 138 4/var(--tw-text-opacity,1))}.rf-text-yellow-700{--tw-text-opacity:1;color:rgb(161 98 7/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-600{--tw-text-opacity:1;color:rgb(82 82 91/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-accent-blue-600{accent-color:#2563eb}.rf-opacity-0{opacity:0}.rf-opacity-10{opacity:.1}.rf-opacity-100{opacity:1}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-70{opacity:.7}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-none{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-shadow-sm,.rf-shadow-xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-xl{--tw-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 8px 10px -6px rgba(0,0,0,.1);--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color),0 8px 10px -6px var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-transform{transition-duration:.15s;transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-150{transition-duration:.15s}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-animate-in{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.rf-fade-in-0{--tw-enter-opacity:0}.rf-zoom-in-95{--tw-enter-scale:.95}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-150{animation-duration:.15s}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.no-scrollbar::-webkit-scrollbar{display:none}.no-scrollbar{-ms-overflow-style:none;scrollbar-width:none}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf--translate-y-0\\.5:hover{--tw-translate-y:-0.125rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:rf-border-zinc-300:hover{--tw-border-opacity:1;border-color:rgb(212 212 216/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-gray-50:hover{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.hover\\:rf-bg-orange-100:hover{--tw-bg-opacity:1;background-color:rgb(255 237 213/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-100:hover{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-slate-100:hover{--tw-bg-opacity:1;background-color:rgb(241 245 249/var(--tw-bg-opacity,1))}.hover\\:rf-bg-slate-200:hover{--tw-bg-opacity:1;background-color:rgb(226 232 240/var(--tw-bg-opacity,1))}.hover\\:rf-bg-slate-50:hover{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-blue-800:hover{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.hover\\:rf-text-gray-700:hover{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-800:hover{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-900:hover{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.hover\\:rf-shadow-md:hover{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-blue-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-900:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(24 24 27/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-text-gray-500:disabled{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.disabled\\:rf-opacity-40:disabled{opacity:.4}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group:hover .group-hover\\:rf-scale-\\[1\\.03\\]{--tw-scale-x:1.03;--tw-scale-y:1.03;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-group:hover .group-hover\\:rf-opacity-100,.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.rf-peer:disabled~.peer-disabled\\:rf-cursor-not-allowed{cursor:not-allowed}.rf-peer:disabled~.peer-disabled\\:rf-opacity-70{opacity:.7}.data-\\[disabled\\=true\\]\\:rf-pointer-events-none[data-disabled=true],.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[selected\\=true\\]\\:rf-bg-zinc-100[data-selected=true]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[selected\\=true\\]\\:rf-text-zinc-900[data-selected=true]{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\=true\\]\\:rf-opacity-50[data-disabled=true],.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-gray-700:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.dark\\:rf-bg-gray-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-gray-500:is(.rf-dark *){--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-300:is(.rf-dark *){--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-bg-zinc-800[data-selected=true]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-text-zinc-50[data-selected=true]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-order-1{order:1}.sm\\:rf-order-2{order:2}.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-mt-4{margin-top:1rem}.sm\\:rf-block{display:block}.sm\\:rf-inline{display:inline}.sm\\:rf-grid{display:grid}.sm\\:rf-hidden{display:none}.sm\\:rf-h-5{height:1.25rem}.sm\\:rf-w-1\\/2{width:50%}.sm\\:rf-w-5{width:1.25rem}.sm\\:rf-w-\\[90vw\\]{width:90vw}.sm\\:rf-w-auto{width:auto}.sm\\:rf-max-w-\\[500px\\]{max-width:500px}.sm\\:rf-max-w-md{max-width:28rem}.sm\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\\:rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\\:rf-grid-cols-\\[1fr_auto\\]{grid-template-columns:1fr auto}.sm\\:rf-grid-cols-\\[minmax\\(0\\2c 1fr\\)_auto\\]{grid-template-columns:minmax(0,1fr) auto}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-items-center{align-items:center}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-gap-3{gap:.75rem}.sm\\:rf-gap-4{gap:1rem}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-p-3{padding:.75rem}.sm\\:rf-p-6{padding:1.5rem}.sm\\:rf-px-4{padding-left:1rem;padding-right:1rem}.sm\\:rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.sm\\:rf-px-8{padding-left:2rem;padding-right:2rem}.sm\\:rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.sm\\:rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.sm\\:rf-text-left{text-align:left}.sm\\:rf-text-2xl{font-size:1.5rem;line-height:2rem}.sm\\:rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.sm\\:rf-text-base{font-size:1rem;line-height:1.5rem}.sm\\:rf-text-sm{font-size:.875rem;line-height:1.25rem}.sm\\:rf-text-xl{font-size:1.25rem;line-height:1.75rem}}@media (min-width:768px){.md\\:rf-w-52{width:13rem}.md\\:rf-w-auto{width:auto}.md\\:rf-min-w-0{min-width:0}.md\\:rf-max-w-\\[660px\\]{max-width:660px}.md\\:rf-max-w-lg{max-width:32rem}.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\\:rf-grid-cols-\\[220px_1fr\\]{grid-template-columns:220px 1fr}.md\\:rf-flex-row{flex-direction:row}.md\\:rf-flex-col{flex-direction:column}.md\\:rf-overflow-y-auto{overflow-y:auto}.md\\:rf-overflow-x-hidden{overflow-x:hidden}.md\\:rf-border-b-0{border-bottom-width:0}.md\\:rf-border-r{border-right-width:1px}.md\\:rf-p-8{padding:2rem}.md\\:rf-py-8{padding-bottom:2rem;padding-top:2rem}.md\\:rf-text-3xl{font-size:1.875rem;line-height:2.25rem}}@media (min-width:1024px){.lg\\:rf-max-w-\\[720px\\]{max-width:720px}.lg\\:rf-max-w-xl{max-width:36rem}.lg\\:rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (min-width:1280px){.xl\\:rf-max-w-\\[800px\\]{max-width:800px}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-py-1\\.5 [cmdk-group-heading]{padding-bottom:.375rem;padding-top:.375rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-font-medium [cmdk-group-heading]{font-weight:500}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-500 [cmdk-group-heading]{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.dark\\:\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-400 [cmdk-group-heading]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group\\]\\:not\\(\\[hidden\\]\\)_\\~\\[cmdk-group\\]\\]\\:rf-pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\\[\\&_\\[cmdk-group\\]\\]\\:rf-px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\\[\\&_\\[cmdk-input\\]\\]\\:rf-h-12 [cmdk-input]{height:3rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-py-3 [cmdk-item]{padding-bottom:.75rem;padding-top:.75rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-h-5 [cmdk-item] svg{height:1.25rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-w-5 [cmdk-item] svg{width:1.25rem}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',noA=()=>{z.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const A=document.createElement("style");A.setAttribute("data-styles","tscircuit-runframe"),A.textContent=bmo,document.head.appendChild(A)},[])},Hmo=g=>{z.useEffect(()=>(g?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[g])},nPI=g=>`hsl(${OM.indexOf(g)*137.5%360}, 70%, 50%)`,vmo=({phaseTimings:g})=>{if(!g)return null;const A=Object.values(g).reduce((I,e)=>I+e,0);return T.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[T.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:OM.map(I=>{const e=g[I]||0,t=e/A*100;return T.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${t}%`,backgroundColor:nPI(I)},children:T.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[I,": ",e.toFixed(1),"ms"]})},I)})}),T.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",A.toFixed(2),"ms"]})]})},Tmo=g=>{if(g instanceof Blob)return g;if(g==null)return"";if(typeof g=="string")return g;if(typeof g=="object")try{return JSON.stringify(g,null,2)}catch{return String(g)}return String(g)},qmo=({renderLog:g,onRerunWithDebug:A})=>{const[I,e]=z.useState("chronological"),[t,o]=z.useState(""),B=[{value:"",label:"None"},{value:"DEBUG=Group_doInitialSchematicTraceRender",label:"DEBUG=Group_doInitialSchematicTraceRender"},{value:"DEBUG=Group_doInitialSchematicLayoutMatchpack",label:"DEBUG=Group_doInitialSchematicLayoutMatchpack"},{value:"DEBUG=Group_doInitialPcbLayoutPack",label:"DEBUG=Group_doInitialPcbLayoutPack"}];if(!g)return T.jsxs("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:[T.jsx("div",{className:"rf-mb-4",children:"No render log, make sure this tab is open when you render"}),A&&T.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[T.jsx("select",{value:t,onChange:i=>o(i.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:B.map(i=>T.jsx("option",{value:i.value,children:i.label},i.value))}),T.jsx(si,{onClick:()=>A(t),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]})]});const C=Object.entries(g?.phaseTimings??{});I==="chronological"?C.sort((i,E)=>OM.indexOf(i[0])-OM.indexOf(E[0])):C.sort((i,E)=>E[1]-i[1]);const Q=C.reduce((i,[E,n])=>i+n,0);return T.jsxs("div",{className:"rf-bg-white",children:[T.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mb-4",children:[T.jsx("div",{children:"Render Logs"}),T.jsxs("div",{className:"rf-flex rf-gap-4 rf-items-center",children:[A&&T.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[T.jsx("select",{value:t,onChange:i=>o(i.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:B.map(i=>T.jsx("option",{value:i.value,children:i.label},i.value))}),T.jsx(si,{onClick:()=>A(t),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]}),T.jsx("div",{className:"rf-flex rf-gap-2 rf-items-center",children:T.jsxs("select",{onChange:i=>{if(i.target.value){const E=g?.debugOutputs?.find(n=>n.name===i.target.value);if(E){const n=Tmo(E.content),s=n instanceof Blob?n:new Blob([n],{type:"text/plain"}),r=URL.createObjectURL(s),a=document.createElement("a");a.href=r,a.download=`debug-${E.name}.txt`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)}i.target.value=""}},disabled:!g?.debugOutputs||g.debugOutputs.length===0,className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white disabled:rf-opacity-50 disabled:rf-cursor-not-allowed",children:[T.jsx("option",{value:"",children:"Download Debug Output"}),g?.debugOutputs?.map(i=>T.jsx("option",{value:i.name,children:i.name},i.name))]})}),T.jsxs("div",{className:"rf-flex rf-text-xs rf-items-center",children:[T.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),T.jsxs("select",{value:I,onChange:i=>e(i.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[T.jsx("option",{value:"chronological",children:"Phase Order"}),T.jsx("option",{value:"longest",children:"Duration"})]})]})]})]}),T.jsx(vmo,{phaseTimings:g.phaseTimings}),T.jsxs("table",{className:"rf-w-full rf-text-xs",children:[T.jsx("thead",{children:T.jsxs("tr",{children:[T.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),T.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),T.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),T.jsx("tbody",{children:C.map(([i,E])=>T.jsxs("tr",{children:[T.jsx("td",{className:"rf-p-2",children:OM.indexOf(i)}),T.jsx("td",{className:"rf-p-2",children:i}),T.jsx("td",{className:"rf-p-2",children:T.jsx("div",{className:"rf-w-8",children:T.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:nPI(i),width:`${E/Q*100}%`}})})}),T.jsx("td",{className:"rf-p-2",children:T.jsxs("div",{className:"rf-flex w-full",children:[T.jsxs("span",{className:"rf-flex-grow",children:[E,"ms"]}),T.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(E/Q*100).toFixed(1),"%"]})]})})]},i))})]})]})};var Zmo=8,wCg=g=>Math.hypot(g.a,g.b)||1,Omo=g=>[g.label,g.inlineLabel].filter(Boolean).join(`
|
|
5636
5636
|
`),soA=(g,A)=>Math.hypot(g.x-A.x,g.y-A.y),sPI=(g,A,I)=>{const e=I.x-A.x,t=I.y-A.y,o=e*e+t*t;if(o===0)return soA(g,A);const B=((g.x-A.x)*e+(g.y-A.y)*t)/o,C=Math.max(0,Math.min(1,B));return soA(g,{x:A.x+e*C,y:A.y+t*C})},Wmo=(g,A,I)=>{const e=I.x-A.x,t=I.y-A.y,o=Math.hypot(e,t);return o===0?soA(g,A):Math.abs(t*g.x-e*g.y+I.x*A.y-I.y*A.x)/o},uCg=(g,A)=>{let I=!1;for(let e=0,t=A.length-1;e<A.length;t=e++){const o=A[e],B=A[t];o.y>g.y!=B.y>g.y&&g.x<(B.x-o.x)*(g.y-o.y)/(B.y-o.y)+o.x&&(I=!I)}return I},GCg=(g,A,I,e=!1)=>{if(A.length===0)return!1;const t=e?A.length:A.length-1;for(let o=0;o<t;o+=1){const B=A[o],C=A[(o+1)%A.length];if(sPI(g,B,C)<=I)return!0}return!1},aPI=(g,A,I)=>Math.max(I,(g??2)*wCg(A)/2+4),iP=(g,A)=>KI(g,A),mCg=(g,A,I,e)=>soA(g,iP(I,A))<=e,Vmo=(g,A,I,e)=>{if(A.points.length===0)return!1;if(A.points.length===1)return mCg(g,A.points[0],I,e);const t=A.points.map(o=>iP(I,o));return GCg(g,t,aPI(A.strokeWidth,I,e))},jmo=(g,A,I,e)=>{const{origin:t,directionVector:o}=A;if(o.x===0&&o.y===0)return!1;const B=iP(I,t),C=iP(I,{x:t.x+o.x,y:t.y+o.y});return Wmo(g,B,C)<=aPI(A.strokeWidth,I,e)},zmo=(g,A,I,e)=>{const t=G_A(A,I).corners;return uCg(g,t)||GCg(g,t,e,!0)},Xmo=(g,A,I,e)=>{const t=iP(I,A.center),o=A.radius*wCg(I);return soA(g,t)<=o+e},$mo=(g,A,I,e)=>{if(A.points.length===0)return!1;if(A.points.length===1)return mCg(g,A.points[0],I,e);const t=A.points.map(o=>iP(I,o));return uCg(g,t)||GCg(g,t,e,!0)},Apo=(g,A,I,e)=>{const t=h$(A),o=iP(I,t.shaftStart),B=iP(I,t.shaftEnd),C=Math.max(e,t.shaftWidth*wCg(I)/2+4);return sPI(g,o,B)<=C?!0:t.heads.some(Q=>{const i=[Q.tip,Q.leftWing,Q.rightWing].map(E=>iP(I,E));return uCg(g,i)})};function gpo(g,A,I,e={}){const t=e.hitSlop??Zmo;for(let B=(g.points?.length??0)-1;B>=0;B-=1){const C=g.points?.[B];if(C?.label&&mCg(I,C,A,t))return C.label}for(let B=(g.infiniteLines?.length??0)-1;B>=0;B-=1){const C=g.infiniteLines?.[B];if(C?.label&&jmo(I,C,A,t))return C.label}const o=g.lines?.map((B,C)=>({line:B,originalIndex:C})).sort((B,C)=>(B.line.zIndex??0)-(C.line.zIndex??0)||B.originalIndex-C.originalIndex)??[];for(let B=o.length-1;B>=0;B-=1){const C=o[B]?.line;if(C?.label&&Vmo(I,C,A,t))return C.label}for(let B=(g.arrows?.length??0)-1;B>=0;B-=1){const C=g.arrows?.[B],Q=C?Omo(C):"";if(!(!C||!Q)&&Apo(I,C,A,t))return Q}for(let B=(g.polygons?.length??0)-1;B>=0;B-=1){const C=g.polygons?.[B];if(C?.label&&$mo(I,C,A,t))return C.label}for(let B=(g.circles?.length??0)-1;B>=0;B-=1){const C=g.circles?.[B];if(C?.label&&Xmo(I,C,A,t))return C.label}for(let B=(g.rects?.length??0)-1;B>=0;B-=1){const C=g.rects?.[B];if(C?.label&&zmo(I,C,A,t))return C.label}return null}const Ipo=rC[typeof document<"u"&&document.createElement!==void 0?"useLayoutEffect":"useEffect"],epo=g=>{const A=z.useRef(g);return z.useEffect(()=>{A.current=g}),A};function tpo(){}function rPI(g,A,I={}){const e=Bpo(I.polyfill),t=epo(A);return Ipo(()=>{let o=!1;const B=g&&"current"in g?g.current:g;if(!B)return tpo;function C(Q,i){o||t.current(Q,i)}return e.subscribe(B,C),()=>{o=!0,e.unsubscribe(B,C)}},[g,e,t]),e.observer}function opo(g){let A=!1,I=[];const e=new Map,t=new(g||window.ResizeObserver)((o,B)=>{I=I.concat(o);function C(){const Q=new Set;for(let i=0;i<I.length;i++){if(Q.has(I[i].target))continue;Q.add(I[i].target);const E=e.get(I[i].target);E?.forEach(n=>n(I[i],B))}I=[],A=!1}A||window.requestAnimationFrame(C),A=!0});return{observer:t,subscribe(o,B){var C;t.observe(o);const Q=(C=e.get(o))!==null&&C!==void 0?C:[];Q.push(B),e.set(o,Q)},unsubscribe(o,B){var C;const Q=(C=e.get(o))!==null&&C!==void 0?C:[];if(Q.length===1){t.unobserve(o),e.delete(o);return}const i=Q.indexOf(B);i!==-1&&Q.splice(i,1),e.set(o,Q)}}}let pCg;const Bpo=g=>pCg||(pCg=opo(g));var Cpo=g=>{const A={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(const I of g.lines??[])for(const e of I.points??[])A.minX=Math.min(A.minX,e.x),A.minY=Math.min(A.minY,e.y),A.maxX=Math.max(A.maxX,e.x),A.maxY=Math.max(A.maxY,e.y);for(const I of g.rects??[]){const e=S5e(I);A.minX=Math.min(A.minX,e.minX),A.minY=Math.min(A.minY,e.minY),A.maxX=Math.max(A.maxX,e.maxX),A.maxY=Math.max(A.maxY,e.maxY)}for(const I of g.polygons??[])for(const e of I.points??[])A.minX=Math.min(A.minX,e.x),A.minY=Math.min(A.minY,e.y),A.maxX=Math.max(A.maxX,e.x),A.maxY=Math.max(A.maxY,e.y);for(const I of g.points??[])A.minX=Math.min(A.minX,I.x),A.minY=Math.min(A.minY,I.y),A.maxX=Math.max(A.maxX,I.x),A.maxY=Math.max(A.maxY,I.y);for(const I of g.circles??[])A.minX=Math.min(A.minX,I.center.x-I.radius),A.minY=Math.min(A.minY,I.center.y-I.radius),A.maxX=Math.max(A.maxX,I.center.x+I.radius),A.maxY=Math.max(A.maxY,I.center.y+I.radius);for(const I of g.arrows??[]){const e=aHg(I);A.minX=Math.min(A.minX,e.minX),A.minY=Math.min(A.minY,e.minY),A.maxX=Math.max(A.maxX,e.maxX),A.maxY=Math.max(A.maxY,e.maxY)}for(const I of g.texts??[])A.minX=Math.min(A.minX,I.x),A.minY=Math.min(A.minY,I.y),A.maxX=Math.max(A.maxX,I.x),A.maxY=Math.max(A.maxY,I.y);return A};function cPI(g){const A=E=>!E||E.length===0?0:E.reduce((n,s)=>{const r=Number.isNaN(s.step)?0:s.step||0;return Math.max(n,r)},0),I=A(g.points),e=A(g.lines),t=A(g.infiniteLines),o=A(g.rects),B=A(g.polygons),C=A(g.circles),Q=A(g.texts),i=A(g.arrows);return Math.max(I,e,t,o,B,C,Q,i)}var Qpo=g=>g.slice().sort((A,I)=>I.width*I.height-A.width*A.height);function ipo(g){const{dimensionStart:A,dimensionEnd:I,screenDimensionStart:e,screenDimensionEnd:t,flipX:o,flipY:B}=g,C=I.x-A.x,Q=I.y-A.y,i=Math.sqrt(C*C+Q*Q),E=t.x-e.x,n=t.y-e.y,s=Math.sqrt(E*E+n*n),r=Math.atan2(n,E)*(180/Math.PI),a=Math.abs(r)%90,h=Math.min(a,90-a)>15,l=(e.x+t.x)/2,D=(e.y+t.y)/2,d=15,y=r+90;let w=Math.cos(y*Math.PI/180)*d,u=Math.sin(y*Math.PI/180)*d;const G=E>0&&n<0,m=E>0&&n>0,p=E<0&&n>0;o!==B&&!G&&(w=-w,u=-u),G&&(w+=Math.cos(y*Math.PI/180)*-45,u+=Math.sin(y*Math.PI/180)*-45),m&&(w+=Math.cos(y*Math.PI/180)+-20,u+=Math.sin(y*Math.PI/180)+-10),p&&(w+=Math.cos(y*Math.PI/180)*10,u+=Math.sin(y*Math.PI/180)*10);const k=l+w,S=D+u;return{distance:i,screenDistance:s,x:k,y:S,show:i>.01&&s>30&&h}}function Epo(g){const{dimensionStart:A,dimensionEnd:I,screenDimensionStart:e,screenDimensionEnd:t,flipX:o,flipY:B}=g;return z.useMemo(()=>ipo({dimensionStart:A,dimensionEnd:I,screenDimensionStart:e,screenDimensionEnd:t,flipX:o,flipY:B}),[A,I,e,t,o,B])}var npo=({children:g,transform:A})=>{A||(A=n4());const[I,e]=z.useState(!1),[t,o]=z.useState(!1),[B,C]=z.useState({x:0,y:0}),[Q,i]=z.useState({x:0,y:0}),E=z.useRef({x:0,y:0}),n=z.useRef(null),s=z.useRef(!1),a=n.current?.getBoundingClientRect(),c=z.useCallback(()=>{s.current=!0,n.current?.focus()},[]),h=z.useCallback(()=>{s.current=!1},[]);z.useEffect(()=>{const w=u=>{const G=n.current?.contains(document.activeElement)||document.activeElement===n.current;!s.current&&!G||(u.key==="d"&&(C({x:E.current.x,y:E.current.y}),i({x:E.current.x,y:E.current.y}),e(m=>!m),o(!0)),u.key==="Escape"&&(e(!1),o(!1)))};return window.addEventListener("keydown",w),()=>{window.removeEventListener("keydown",w)}},[]);const l=KI(A,B),D=KI(A,Q),d={left:Math.min(l.x,D.x),right:Math.max(l.x,D.x),top:Math.min(l.y,D.y),bottom:Math.max(l.y,D.y),flipX:l.x>D.x,flipY:l.y>D.y,width:0,height:0};d.width=d.right-d.left,d.height=d.bottom-d.top;const y=Epo({dimensionStart:B,dimensionEnd:Q,screenDimensionStart:l,screenDimensionEnd:D,flipX:d.flipX,flipY:d.flipY});return T.jsxs("div",{ref:n,tabIndex:0,style:{position:"relative"},onMouseMove:w=>{const u=w.currentTarget.getBoundingClientRect(),G=w.clientX-u.left,m=w.clientY-u.top,p=KI(HV(A),{x:G,y:m});E.current.x=p.x,E.current.y=p.y,t&&i({x:p.x,y:p.y})},onMouseDown:()=>{t?o(!1):I&&e(!1)},onMouseEnter:c,onMouseLeave:h,children:[g,I&&T.jsxs(T.Fragment,{children:[y.show&&T.jsx("div",{style:{position:"absolute",left:y.x,top:y.y,color:"red",mixBlendMode:"difference",pointerEvents:"none",fontSize:12,fontFamily:"sans-serif",whiteSpace:"nowrap",zIndex:30},children:y.distance.toFixed(2)}),T.jsx("div",{style:{position:"absolute",left:d.left,width:d.width,textAlign:"center",top:l.y+2,color:"red",mixBlendMode:"difference",pointerEvents:"none",marginTop:d.flipY?0:-20,fontSize:12,fontFamily:"sans-serif",zIndex:30},children:Math.abs(B.x-Q.x).toFixed(2)}),T.jsx("div",{style:{position:"absolute",left:D.x,height:d.height,display:"flex",flexDirection:"column",justifyContent:"center",top:d.top,color:"red",pointerEvents:"none",mixBlendMode:"difference",fontSize:12,fontFamily:"sans-serif",zIndex:30},children:T.jsx("div",{style:{marginLeft:d.flipX?"-100%":4,paddingRight:4},children:Math.abs(B.y-Q.y).toFixed(2)})}),T.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:30},width:a?.width||"100%",height:a?.height||"100%",children:[T.jsx("defs",{children:T.jsx("marker",{id:"head",orient:"auto",markerWidth:"3",markerHeight:"4",refX:"2",refY:"2",children:T.jsx("path",{d:"M0,0 V4 L2,2 Z",fill:"red"})})}),T.jsx("line",{x1:l.x,y1:l.y,x2:D.x,y2:D.y,markerEnd:"url(#head)",strokeWidth:1.5,fill:"none",stroke:"red"}),T.jsx("line",{x1:l.x,y1:l.y,x2:D.x,y2:l.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"}),T.jsx("line",{x1:D.x,y1:l.y,x2:D.x,y2:D.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"})]}),T.jsxs("div",{style:{right:0,bottom:0,position:"absolute",color:"red",fontFamily:"sans-serif",fontSize:12,margin:4},children:["(",B.x.toFixed(2),",",B.y.toFixed(2),")",T.jsx("br",{}),"(",Q.x.toFixed(2),",",Q.y.toFixed(2),")",T.jsx("br",{}),"dist:"," ",Math.sqrt((Q.x-B.x)**2+(Q.y-B.y)**2).toFixed(2)]})]})]})},hPI=({label:g,onClose:A})=>T.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Object label",onClick:A,style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",padding:16,background:"rgba(0, 0, 0, 0.28)"},children:T.jsxs("div",{onClick:I=>{I.stopPropagation()},style:{width:"min(420px, 100%)",background:"#fff",borderRadius:10,boxShadow:"0 12px 32px rgba(0, 0, 0, 0.2)",padding:16},children:[T.jsx("div",{style:{fontWeight:600,marginBottom:8},children:"Object label"}),T.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",marginBottom:16},children:g}),T.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:T.jsx("button",{type:"button",onClick:A,children:"Close"})})]})}),lPI=(g,A,I,e,t,o)=>{const B=g-I,C=A-e,Q=t-I,i=o-e,E=B*Q+C*i,n=Q*Q+i*i;let s=-1;n!==0&&(s=E/n);let r=0,a=0;s<0?(r=I,a=e):s>1?(r=t,a=o):(r=I+s*Q,a=e+s*i);const c=g-r,h=A-a;return Math.sqrt(c*c+h*h)},aN=(g,A)=>{try{return n5e(g,A)}catch{return A}},spo=({arrow:g,index:A,interactiveState:I})=>{const{realToScreen:e,onObjectClicked:t,setHoverTooltip:o}=I,[B,C]=z.useState(!1),Q=z.useMemo(()=>h$(g),[g]),i=z.useMemo(()=>({shaftStart:KI(e,Q.shaftStart),shaftEnd:KI(e,Q.shaftEnd),heads:Q.heads.map(w=>({tip:KI(e,w.tip),base:KI(e,w.base),leftWing:KI(e,w.leftWing),rightWing:KI(e,w.rightWing)}))}),[Q,e]),E=Math.abs(e.a),n=12,s=Q.shaftWidth*(E||1),r=n*.6,a=z.useMemo(()=>UcA(i.shaftStart,i.shaftEnd,{fontSize:n,strokeWidth:s,normalPadding:6,alongOffset:g.label?r:0}),[i,n,s,g.label,r]),c=z.useMemo(()=>UcA(i.shaftStart,i.shaftEnd,{fontSize:n,strokeWidth:s,normalPadding:12,alongOffset:g.inlineLabel?-r:0}),[i,n,s,g.inlineLabel,r]),h=g.color||dh[A%dh.length]||"black",l=B?aN(.2,h):h,D=[g.label,g.inlineLabel].filter(Boolean).join(`
|
|
5637
5637
|
`),d=g.label?c:a;z.useEffect(()=>{if(!(!B||!D))return o?.({text:D,x:d.x,y:d.y}),()=>{o?.(null)}},[B,o,d.x,d.y,D]);const y=w=>{const u=w.currentTarget.getBoundingClientRect(),G=w.clientX-u.left,m=w.clientY-u.top,p=10,S=[{from:i.shaftStart,to:i.shaftEnd},...i.heads.flatMap(R=>[{from:R.base,to:R.leftWing},{from:R.leftWing,to:R.tip},{from:R.tip,to:R.rightWing},{from:R.rightWing,to:R.base}])].some(({from:R,to:x})=>lPI(G,m,R.x,R.y,x.x,x.y)<p);C(S)};return T.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"},children:T.jsxs("svg",{style:{width:"100%",height:"100%",pointerEvents:"auto"},onMouseMove:y,onMouseLeave:()=>{C(!1),o?.(null)},onClick:B?w=>{w.stopPropagation(),t?.({type:"arrow",index:A,object:g})}:void 0,children:[T.jsx("line",{x1:i.shaftStart.x,y1:i.shaftStart.y,x2:i.shaftEnd.x,y2:i.shaftEnd.y,stroke:l,strokeWidth:s,strokeLinecap:"round",pointerEvents:"stroke"}),i.heads.map((w,u)=>T.jsx("polygon",{points:`${w.tip.x},${w.tip.y} ${w.leftWing.x},${w.leftWing.y} ${w.rightWing.x},${w.rightWing.y}`,fill:l},u))]})})},apo=({circle:g,interactiveState:A,index:I})=>{const e=dh[I%dh.length];let{center:t,radius:o,fill:B,stroke:C,layer:Q,step:i,label:E}=g;const{activeLayers:n,activeStep:s,realToScreen:r,onObjectClicked:a,setHoverTooltip:c}=A,[h,l]=z.useState(!1),D=KI(r,t),d=o*r.a;let y=B||e;return h&&(y=aN(.2,y),C=C&&aN(.2,C)),z.useEffect(()=>{if(!(!h||!E))return c?.({text:E,x:D.x,y:D.y-d}),()=>{c?.(null)}},[h,E,D.x,D.y,d,c]),T.jsx("div",{style:{position:"absolute",left:D.x-d,top:D.y-d,width:d*2,height:d*2,borderRadius:"50%",backgroundColor:y,border:C?`2px solid ${C}`:"none",cursor:"pointer",transition:"border-color 0.2s"},onMouseEnter:()=>l(!0),onMouseLeave:()=>{l(!1),c?.(null)},onClick:()=>a?.({type:"circle",index:I,object:g})})},rpo=({x:g,y:A,onSaveCamera:I,onLoadCamera:e,onClearCamera:t,onAddMark:o,onClearMarks:B,onClose:C})=>{const Q=z.useRef(null);z.useEffect(()=>{const r=a=>{Q.current&&!Q.current.contains(a.target)&&C()};return document.addEventListener("mousedown",r),()=>{document.removeEventListener("mousedown",r)}},[C]);const i={position:"absolute",left:g,top:A,backgroundColor:"white",border:"1px solid #ccc",borderRadius:3,boxShadow:"0 2px 6px rgba(0,0,0,0.1)",padding:0,zIndex:1e3,minWidth:160,fontSize:"12px"},E={padding:"4px 8px",cursor:"pointer",userSelect:"none",lineHeight:"1.5"},n=r=>{r.currentTarget.style.backgroundColor="#f5f5f5"},s=r=>{r.currentTarget.style.backgroundColor=""};return T.jsxs("div",{ref:Q,style:i,children:[T.jsx("div",{style:E,onClick:()=>{I(),C()},onMouseEnter:n,onMouseLeave:s,children:"Save Camera Position"}),T.jsx("div",{style:E,onClick:()=>{e(),C()},onMouseEnter:n,onMouseLeave:s,children:"Load Camera Position"}),T.jsx("div",{style:E,onClick:()=>{t(),C()},onMouseEnter:n,onMouseLeave:s,children:"Clear Saved Camera Position"}),T.jsx("div",{style:E,onClick:()=>{o(),C()},onMouseEnter:n,onMouseLeave:s,children:"Add Mark"}),T.jsx("div",{style:E,onClick:()=>{B(),C()},onMouseEnter:n,onMouseLeave:s,children:"Clear Marks"})]})},cpo=({infiniteLine:g,index:A,interactiveState:I,size:e})=>{const{realToScreen:t,onObjectClicked:o,setHoverTooltip:B}=I,[C,Q]=z.useState(!1),i=BHg(t,e.width,e.height),E=oHg(g,i);if(!E)return null;const[n,s]=E,r=KI(t,n),a=KI(t,s),c=g.strokeColor??dh[A%dh.length],h=(g.strokeWidth??1/Math.abs(t.a))*Math.abs(t.a),l=(r.x+a.x)/2,D=(r.y+a.y)/2;return T.jsx("div",{style:{position:"absolute",top:0,left:0,width:e.width,height:e.height,pointerEvents:"none"},children:T.jsxs("svg",{style:{width:e.width,height:e.height,pointerEvents:"none"},children:[T.jsx("line",{x1:r.x,y1:r.y,x2:a.x,y2:a.y,stroke:"transparent",strokeWidth:h+10,pointerEvents:"stroke",onMouseEnter:()=>{Q(!0),g.label&&B?.({text:g.label,x:l,y:D})},onMouseLeave:()=>{Q(!1),B?.(null)},onClick:()=>o?.({type:"infinite-line",index:A,object:g})}),T.jsx("line",{x1:r.x,y1:r.y,x2:a.x,y2:a.y,stroke:C?aN(.2,c):c,strokeWidth:h,strokeDasharray:g.strokeDash?typeof g.strokeDash=="string"?g.strokeDash:g.strokeDash.map(d=>d*Math.abs(t.a)).join(","):void 0,pointerEvents:"none"})]})})},hpo=({line:g,index:A,interactiveState:I,size:e,mousePosition:t})=>{const{activeLayers:o,activeStep:B,realToScreen:C,onObjectClicked:Q,setHoverTooltip:i}=I,{points:E,layer:n,step:s,strokeColor:r,strokeWidth:a=1/C.a,strokeDash:c}=g,h=E.map(m=>KI(C,m)),l=a*Math.abs(C.a),y=Math.max(l/2+3,6),w=y*2,u=z.useMemo(()=>{if(!t)return!1;for(let m=0;m<h.length-1;m++)if(lPI(t.x,t.y,h[m].x,h[m].y,h[m+1].x,h[m+1].y)<=y)return!0;return!1},[y,t,h]),G=r??dh[A%dh.length];return z.useEffect(()=>{if(!(!u||!g.label||!t))return i?.({text:g.label,x:t.x,y:t.y}),()=>{i?.(null)}},[u,g.label,t?.x,t?.y,i]),T.jsx("div",{style:{position:"absolute",top:0,left:0,width:e.width,height:e.height,pointerEvents:"none"},children:T.jsxs("svg",{style:{width:e.width,height:e.height,overflow:"visible",pointerEvents:"none"},children:[T.jsx("polyline",{points:h.map(m=>`${m.x},${m.y}`).join(" "),stroke:"transparent",fill:"none",strokeWidth:w,strokeLinecap:"round",strokeLinejoin:"round",pointerEvents:"stroke",onClick:u?()=>Q?.({type:"line",index:A,object:g}):void 0}),T.jsx("polyline",{points:h.map(m=>`${m.x},${m.y}`).join(" "),stroke:u?aN(.2,G):G,fill:"none",strokeWidth:l,strokeDasharray:c?typeof c=="string"?c:`${c[0]*Math.abs(C.a)}, ${c[1]*Math.abs(C.a)}`:void 0,strokeLinecap:"round",strokeLinejoin:"round",pointerEvents:"none"})]})})},lpo=({marker:g,transform:A})=>{const[I,e]=KI(A,[g.x,g.y]);return T.jsx("svg",{style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:900},children:T.jsxs("g",{transform:`translate(${I}, ${e})`,children:[T.jsx("circle",{r:7,fill:"rgba(255, 0, 0, 0.5)",stroke:"rgba(255, 0, 0, 0.8)",strokeWidth:2}),T.jsx("circle",{r:2,fill:"rgba(255, 0, 0, 0.9)"})]})})},Dpo=({point:g,interactiveState:A,index:I})=>{const{color:e,label:t,layer:o,step:B}=g,{activeLayers:C,activeStep:Q,realToScreen:i,onObjectClicked:E,setHoverTooltip:n}=A,[s,r]=z.useState(!1),a=KI(i,g),c=10,h=`${t?`${t}
|
|
5638
5638
|
`:""}x: ${g.x.toFixed(2)}, y: ${g.y.toFixed(2)}`;return z.useEffect(()=>{if(s)return n?.({text:h,x:a.x,y:a.y-c/2}),()=>{n?.(null)}},[s,a.x,a.y,n,h]),T.jsx("div",{style:{position:"absolute",left:a.x-c/2,top:a.y-c/2,width:c,height:c,borderRadius:"50%",border:`2px solid ${s?aN(.2,e??dh[I%dh.length]):e??dh[I%dh.length]}`,cursor:"pointer",transition:"border-color 0.2s"},onMouseEnter:()=>r(!0),onMouseLeave:()=>{r(!1),n?.(null)},onClick:()=>E?.({type:"point",index:I,object:g})})},dpo=({polygon:g,interactiveState:A,index:I})=>{const{points:e,fill:t,stroke:o,strokeWidth:B}=g,{realToScreen:C,onObjectClicked:Q,setHoverTooltip:i}=A,[E,n]=z.useState(!1),s=!!(e&&e.length>0),r=s?e.map(Y=>KI(C,Y)):[],a=r.map(Y=>Y.x),c=r.map(Y=>Y.y),h=s?Math.min(...a):0,l=s?Math.max(...a):0,D=s?Math.min(...c):0,d=s?Math.max(...c):0,y=4,w=h-y,u=D-y,G=Math.max(l-h,0)+y*2,m=Math.max(d-D,0)+y*2,p=r.map(Y=>({x:Y.x-w,y:Y.y-u})),k=dh[I%dh.length],R=t!==void 0||o!==void 0?t||"transparent":k,x=o,N=E?aN(.2,R):R,U=x?E?aN(.2,x):x:void 0,K=B===void 0?void 0:B*C.a;return z.useEffect(()=>{if(!(!s||!E||!g.label))return i?.({text:g.label,x:(h+l)/2,y:u}),()=>{i?.(null)}},[s,E,l,h,g.label,i,u]),s?T.jsx("div",{style:{position:"absolute",top:u,left:w,width:G,height:m,pointerEvents:"none"},children:T.jsx("svg",{width:G,height:m,style:{display:"block"},children:T.jsx("polygon",{points:p.map(Y=>`${Y.x},${Y.y}`).join(" "),fill:N,stroke:U??"none",strokeWidth:K,pointerEvents:"all",onMouseEnter:()=>n(!0),onMouseLeave:()=>{n(!1),i?.(null)},onClick:()=>Q?.({type:"polygon",index:I,object:g})})})}):null},ypo=({rect:g,interactiveState:A,index:I})=>{const e=dh[I%dh.length];let{fill:t,stroke:o}=g;const{activeLayers:B,activeStep:C,realToScreen:Q,onObjectClicked:i,setHoverTooltip:E}=A,[n,s]=z.useState(!1),r=G_A(g,Q);let c=t!==void 0||o!==void 0?t||"transparent":e;return n&&(c=aN(.2,c),o=aN(.2,o)),z.useEffect(()=>{if(!(!n||!g.label))return E?.({text:g.label,x:r.center.x,y:r.center.y-r.height/2}),()=>{E?.(null)}},[n,r.center.x,r.center.y,r.height,g.label,E]),T.jsx("div",{style:{position:"absolute",left:r.center.x,top:r.center.y,width:r.width,height:r.height,transform:"translate(-50%, -50%)",pointerEvents:"none"},children:T.jsx("div",{style:{width:"100%",height:"100%",backgroundColor:c,border:o?`2px solid ${n?aN(.2,o):o}`:"none",boxSizing:"border-box",cursor:"pointer",transition:"border-color 0.2s",transformOrigin:"center",transform:`rotate(${r.angleDegrees}deg)`,pointerEvents:"auto"},onMouseEnter:()=>s(!0),onMouseLeave:()=>{s(!1),E?.(null)},onClick:()=>i?.({type:"rect",index:I,object:g})})})},wpo=({textObj:g,interactiveState:A,index:I})=>{const{realToScreen:e,onObjectClicked:t}=A,{x:o,y:B,text:C,color:Q,fontSize:i,anchorSide:E}=g,n=KI(e,{x:o,y:B}),r={top_left:"translate(0%, 0%)",top_center:"translate(-50%, 0%)",top_right:"translate(-100%, 0%)",center_left:"translate(0%, -50%)",center:"translate(-50%, -50%)",center_right:"translate(-100%, -50%)",bottom_left:"translate(0%, -100%)",bottom_center:"translate(-50%, -100%)",bottom_right:"translate(-100%, -100%)"}[E??"center"];return T.jsx("div",{style:{position:"absolute",left:n.x,top:n.y,transform:r,color:Q||"black",fontSize:i??12,whiteSpace:"pre",cursor:"default"},onClick:()=>t?.({type:"text",index:I,object:g}),children:C})},DPI=({text:g})=>T.jsx("div",{style:{background:"white",border:"1px solid #ccc",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",borderRadius:"4px",padding:"4px 8px",fontSize:"12px",minWidth:"120px",maxWidth:"300px",whiteSpace:"pre-wrap",overflowWrap:"anywhere",zIndex:100},children:g}),yf=5,upo=(g,A)=>z.useMemo(()=>(I,e)=>{const t=KI(g,I),o=KI(g,e),B=-yf,C=A.width+yf,Q=-yf,i=A.height+yf;if(t.x>=B&&t.x<=C&&t.y>=Q&&t.y<=i||o.x>=B&&o.x<=C&&o.y>=Q&&o.y<=i)return!0;const E=(n,s,r,a)=>{const c=(s.x-n.x)*(a.y-r.y)-(s.y-n.y)*(a.x-r.x);if(c===0)return!1;const h=((a.y-r.y)*(a.x-n.x)+(r.x-a.x)*(a.y-n.y))/c,l=((n.y-s.y)*(a.x-n.x)+(s.x-n.x)*(a.y-n.y))/c;return h>=0&&h<=1&&l>=0&&l<=1};return E(t,o,{x:B,y:Q},{x:C,y:Q})||E(t,o,{x:C,y:Q},{x:C,y:i})||E(t,o,{x:B,y:i},{x:C,y:i})||E(t,o,{x:B,y:Q},{x:B,y:i})},[g,A]),Gpo=(g,A)=>z.useMemo(()=>I=>{const e=KI(g,I);return e.x>=-yf&&e.x<=A.width+yf&&e.y>=-yf&&e.y<=A.height+yf},[g,A]),mpo=({isPointOnScreen:g,doesLineIntersectViewport:A,filterLayerAndStep:I})=>z.useMemo(()=>e=>{if(!I(e))return!1;if(e.points.some(t=>g(t)))return!0;for(let t=0;t<e.points.length-1;t++)if(A(e.points[t],e.points[t+1]))return!0;return!!(e.points.length>2&&e.closed&&A(e.points[e.points.length-1],e.points[0]))},[g,A,I]),ppo=({isPointOnScreen:g,filterLayerAndStep:A})=>z.useMemo(()=>I=>A(I)?g(I):!1,[g,A]),kpo=({realToScreen:g,isPointOnScreen:A,doesLineIntersectViewport:I,filterLayerAndStep:e})=>z.useMemo(()=>t=>{if(!e(t))return!1;const{center:o}=t,[B,C,Q,i]=EHg(t,g);return A(o)||A(B)||A(C)||A(Q)||A(i)?!0:I(B,C)||I(C,Q)||I(Q,i)||I(i,B)},[g,A,I,e]),Mpo=({isPointOnScreen:g,filterLayerAndStep:A,realToScreen:I,size:e})=>z.useMemo(()=>t=>{if(!A(t))return!1;const{center:o,radius:B}=t;if(g(o)||g({x:o.x+B,y:o.y})||g({x:o.x-B,y:o.y})||g({x:o.x,y:o.y+B})||g({x:o.x,y:o.y-B}))return!0;const C=KI(I,o),Q=Math.abs(I.a),i=B*Q,E=-yf,n=e.width+yf,s=-yf,r=e.height+yf;if(C.x>=E&&C.x<=n&&(Math.abs(C.y-s)<=i||Math.abs(C.y-r)<=i)||C.y>=s&&C.y<=r&&(Math.abs(C.x-E)<=i||Math.abs(C.x-n)<=i))return!0;const a=(h,l)=>{const D=C.x-h,d=C.y-l;return D*D+d*d},c=i*i;return a(E,s)<=c||a(n,s)<=c||a(E,r)<=c||a(n,r)<=c},[g,A,I,e]),Spo=({isPointOnScreen:g,filterLayerAndStep:A})=>z.useMemo(()=>I=>A(I)?g({x:I.x,y:I.y}):!1,[g,A]),fpo=({isPointOnScreen:g,doesLineIntersectViewport:A})=>z.useMemo(()=>I=>{const e=h$(I),{shaftStart:t,shaftEnd:o,heads:B}=e;return g(t)||g(o)||B.some(Q=>g(Q.tip)||g(Q.leftWing)||g(Q.rightWing)||g(Q.base))?!0:[[t,o],...B.flatMap(Q=>[[Q.base,Q.leftWing],[Q.leftWing,Q.tip],[Q.tip,Q.rightWing],[Q.rightWing,Q.base]])].some(([Q,i])=>A(Q,i))},[g,A]),Rpo=({isPointOnScreen:g,doesLineIntersectViewport:A,filterLayerAndStep:I})=>z.useMemo(()=>e=>{if(!I(e)||!e.points||e.points.length===0)return!1;if(e.points.some(t=>g(t)))return!0;for(let t=0;t<e.points.length;t++){const o=e.points[t],B=e.points[(t+1)%e.points.length];if(A(o,B))return!0}return!1},[g,A,I]),Npo=1e3,xpo=({graphics:g,onObjectClicked:A,objectLimit:I,height:e=600,stepMetadata:t,alwaysShowToolbar:o=!1})=>{const[B,C]=z.useState(null),[Q,i]=z.useState(null),[E,n]=z.useState(!0),[s,r]=z.useState({width:600,height:e}),[a,c]=z.useState(null),[h,l]=z.useState(!1),[D,d]=z.useState(null),[y,w]=z.useState([]),[u,G]=z.useState(null),[m,p]=z.useState(null),k=Array.from(new Set([...g.lines?.map(og=>og.layer).filter(Boolean)??[],...g.infiniteLines?.map(og=>og.layer).filter(Boolean)??[],...g.rects?.map(og=>og.layer).filter(Boolean)??[],...g.polygons?.map(og=>og.layer).filter(Boolean)??[],...g.points?.map(og=>og.layer).filter(Boolean)??[],...g.texts?.map(og=>og.layer).filter(Boolean)??[],...g.circles?.map(og=>og.layer).filter(Boolean)??[]])),S=cPI(g),R=z.useMemo(()=>{const og=Cpo(g),dg=og.maxX-og.minX,Sg=og.maxY-og.minY;return{minX:og.minX-dg/10,minY:og.minY-Sg/10,maxX:og.maxX+dg/10,maxY:og.maxY+Sg/10}},[g]),x=z.useCallback(()=>{const og=window.location.pathname,dg=window.location.search;return`saved-camera-position-${og}${dg}`},[]),N=z.useCallback(()=>{const og=Math.max(R.maxX-R.minX,1),dg=Math.max(R.maxY-R.minY,1),Sg=Math.min(s.width/og,s.height/dg);return Tr(TQ(s.width/2,s.height/2),Xu(Sg,-Sg),TQ(-(R.maxX+R.minX)/2,-(R.maxY+R.minY)/2))},[s,R]),U=z.useCallback(()=>{try{const og=localStorage.getItem(x());if(og)return JSON.parse(og)}catch(og){console.error("Error loading saved data:",og)}return null},[x]),K=z.useCallback(()=>U()?.transform||null,[U]),{transform:Y,ref:_,setTransform:Z}=HJI({initialTransform:N()});rPI(_,og=>{r({width:og.contentRect.width,height:og.contentRect.height})}),z.useEffect(()=>{const og=U();og?.markers&&w(og.markers)},[U]);const V=z.useCallback(og=>{og.preventDefault();const dg=og.clientX,Sg=og.clientY,Bg=og.currentTarget.getBoundingClientRect(),Yg=Bg.left,iI=Bg.top,GA=window.innerWidth,ng=window.innerHeight,pg=160,Ug=100;let mg=dg-Yg,Rg=Sg-iI;dg>GA/2&&(mg=mg-pg),Sg>ng/2&&(Rg=Rg-Ug),c({x:mg,y:Rg,clientX:dg,clientY:Sg})},[]),W=z.useCallback((og,dg)=>{try{const Sg={transform:og,markers:dg};localStorage.setItem(x(),JSON.stringify(Sg))}catch(Sg){console.error("Error saving data:",Sg)}},[x]),q=z.useCallback(()=>{W(Y,y)},[W,Y,y]),X=z.useCallback(()=>{try{const og=K();og&&Z(og)}catch(og){console.error("Error loading camera position:",og)}},[K,Z]),tA=z.useCallback(()=>{try{const og=N();W(og,y),Z(og)}catch(og){console.error("Error clearing camera position:",og)}},[W,N,Z,y]),IA=z.useCallback(()=>{if(a)try{const og={x:a.clientX,y:a.clientY},dg=_.current?.getBoundingClientRect();if(dg){const Sg=og.x-dg.left,Bg=og.y-dg.top,Yg=HV(Y),[iI,GA]=KI(Yg,[Sg,Bg]),ng={x:iI,y:GA},pg=[...y,ng];w(pg);const Ug=U();Ug?.transform&&W(Ug.transform,pg)}}catch(og){console.error("Error adding marker:",og)}},[a,_,Y,y,W]),QA=z.useCallback(()=>{w([]);const og=U();og?.transform&&W(og.transform,[])},[U,W]),sA=z.useCallback(og=>{switch(og.type){case"arrow":return[og.object.label,og.object.inlineLabel].filter(Boolean).join(`
|
|
@@ -5668,7 +5668,7 @@ test("${i} should solve problem correctly", () => {
|
|
|
5668
5668
|
// Add more specific assertions based on expected output
|
|
5669
5669
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5670
5670
|
})
|
|
5671
|
-
`,n=new Blob([E],{type:"text/plain"}),s=URL.createObjectURL(n),r=document.createElement("a");r.href=s,r.download=`${i}.test.ts`,r.click(),URL.revokeObjectURL(s)}catch(Q){alert(`Error generating test.ts for ${g.getSolverName()}: ${Q instanceof Error?Q.message:String(Q)}`)}e(!1)};return T.jsxs("div",{className:`relative ${A}`,ref:t,children:[T.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>e(!I),title:`Download options for ${g.getSolverName()}`,children:g.getSolverName()}),I&&T.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[T.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),T.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:B,children:"Download page.tsx"}),T.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:C,children:"Download test.ts"})]})]})},dPI=g=>g.activeSubSolver?[g,...dPI(g.activeSubSolver)]:[g],Kpo=({solver:g})=>{const A=dPI(g);return T.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((I,e)=>T.jsxs("div",{className:"flex items-center",children:[e>0&&T.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),T.jsx(Ppo,{solver:I})]},I.getSolverName()))})},Lpo=({solver:g,triggerRender:A,animationSpeed:I=25,renderer:e,onRendererChange:t,onAnimationSpeedChange:o,onDownloadVisualization:B,onSolverStarted:C,onSolverCompleted:Q})=>{const[i,E]=z.useReducer(m=>!m,!1),n=z.useRef(void 0),s=z.useRef(null),r="solver-debugger-last-iteration",[a,c]=z.useState(null),h=z.useRef(null),l=z.useMemo(()=>[{label:"Slow",value:250,description:"250ms"},{label:"Normal",value:100,description:"100ms"},{label:"Fast",value:10,description:"10ms"},{label:"Fast (2x)",value:5,description:"5ms"},{label:"Fast (10x)",value:1,description:"1ms"},{label:"Fast 20x",value:.5,description:"2 steps / 1ms"},{label:"Fast 100x",value:.1,description:"10 steps / 1ms"}],[]),D=()=>{const m=Math.max(1,I),p=I<1?Math.round(1/I):1;n.current=setInterval(()=>{if(g.solved||g.failed){n.current&&(clearInterval(n.current),n.current=void 0),E(),A(),Q&&g.solved&&Q(g);return}for(let k=0;k<p&&!(g.solved||g.failed);k++)g.step();A()},m)},d=()=>{n.current&&(clearInterval(n.current),n.current=void 0)},y=()=>{!g.solved&&!g.failed&&(g.step(),A())},w=()=>{!g.solved&&!g.failed&&(C&&C(g),g.solve(),A(),Q&&Q(g))},u=()=>{i?(d(),E()):(E(),D())},G=()=>{if(g.solved||g.failed||i)return;s.current===null&&typeof window<"u"&&(s.current=window.localStorage.getItem(r));const m=window.prompt("Step until which iteration?",s.current??`${g.iterations}`);if(m===null)return;s.current=m,typeof window<"u"&&window.localStorage.setItem(r,m);const p=Number(m);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;g.iterations<p&&!g.solved&&!g.failed;)g.step();A(),g.solved&&Q&&Q(g)};return z.useEffect(()=>()=>{d()},[]),z.useEffect(()=>{(g.solved||g.failed)&&i&&(d(),E())},[g.solved,g.failed,i]),z.useEffect(()=>{i&&(d(),D())},[I,i]),z.useEffect(()=>{if(typeof document>"u")return;const m=p=>{h.current&&!h.current.contains(p.target)&&c(null)};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]),T.jsxs("div",{className:"space-y-2 p-2 border-b",children:[T.jsx("div",{className:"flex items-center",children:T.jsxs("div",{className:"flex items-center gap-2",ref:h,children:[T.jsxs("div",{className:"flex h-9 items-center space-x-1 rounded-md border border-slate-200 bg-white p-1 shadow-sm",children:[T.jsxs("div",{className:"relative",children:[T.jsx("button",{type:"button",onClick:()=>c(a==="renderer"?null:"renderer"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":a==="renderer"?"open":"closed",children:"Renderer"}),a==="renderer"&&T.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[10rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:["vector","canvas"].map(m=>T.jsxs("button",{type:"button",onClick:()=>{t(m),c(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[m==="vector"?"Vector":"Canvas",e===m&&T.jsx("span",{className:"ml-auto text-xs text-slate-500",children:"✓"})]},m))})]}),T.jsxs("div",{className:"relative",children:[T.jsx("button",{type:"button",onClick:()=>c(a==="debug"?null:"debug"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":a==="debug"?"open":"closed",children:"Debug"}),a==="debug"&&T.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:T.jsx("button",{type:"button",onClick:()=>{B(),c(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:"Download Visualization"})})]}),T.jsxs("div",{className:"relative",children:[T.jsx("button",{type:"button",onClick:()=>c(a==="animation"?null:"animation"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":a==="animation"?"open":"closed",children:"Animation"}),a==="animation"&&T.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:l.map(m=>T.jsxs("button",{type:"button",onClick:()=>{o(m.value),c(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[m.label,T.jsx("span",{className:"ml-auto text-xs text-slate-500",children:m.description}),I===m.value&&T.jsx("span",{className:"ml-2 text-xs text-slate-500",children:"✓"})]},m.value))})]})]}),T.jsx(Kpo,{solver:g})]})}),T.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[T.jsx("button",{onClick:y,disabled:g.solved||g.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),T.jsx("button",{onClick:w,disabled:g.solved||g.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),T.jsx("button",{onClick:u,disabled:g.solved||g.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),T.jsx("button",{onClick:G,disabled:g.solved||g.failed||i,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),T.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",g.iterations]}),g.timeToSolve!==void 0&&T.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(g.timeToSolve/1e3).toFixed(3),"s"]}),g.solved&&T.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),g.failed&&T.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),g.error&&T.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",g.error]})]})},Ypo=g=>g!==null&&"pipelineDef"in g&&Array.isArray(g.pipelineDef),_po=(g,A,I)=>{const e=g.currentPipelineStageIndex;return A<e?"Completed":A===e&&g.activeSubSolver?g.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},bpo=(g,A)=>{const e=g.pipelineDef[A].solverName,t=_po(g,A),o=g[e],B=g.firstIterationOfStage?.[e]??(A===g.currentPipelineStageIndex?g.iterations:null),C=g.iterations;let Q=0;if(t==="Completed"){const s=g.pipelineDef[A+1],r=s?g.firstIterationOfStage?.[s.solverName]:void 0;r!==void 0&&B!==null?Q=r-B:B!==null&&(Q=C-B)}else t==="In Progress"&&B!==null&&(Q=C-B);const i=g.timeSpentOnStage?.[e]??0;let E=0;t==="Completed"?E=1:t==="In Progress"&&o&&(E=o.progress??0);const n=o?.stats??null;return{index:A,name:e,status:t,firstIteration:B,iterations:Q,progress:E,timeSpent:i,stats:n&&Object.keys(n).length>0?n:null,solverInstance:o??null}},Hpo=({status:g})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return T.jsx("span",{className:`font-medium ${A[g]}`,children:g})},vpo=({progress:g})=>{if(g===0)return null;const A=Math.round(g*100);return T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:T.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),T.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},yPI=g=>{if(typeof g=="string")return g;if(typeof g=="number"||typeof g=="boolean"||typeof g=="bigint"||g==null)return String(g);if(typeof g=="object")try{return JSON.stringify(g)}catch{return String(g)}return String(g)},Tpo=g=>Object.entries(g).map(([A,I])=>`${A}: ${yPI(I)}`).join(", "),qpo=({stats:g})=>{if(!g||Object.keys(g).length===0)return T.jsx("span",{children:"-"});const A=Object.entries(g),I=Tpo(g);return T.jsxs("details",{className:"cursor-pointer",children:[T.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:I}),T.jsx("div",{className:"mt-1 text-xs",children:A.map(([e,t])=>T.jsxs("div",{children:[e,": ",yPI(t)]},e))})]})},kCg=g=>{if(g===null||typeof g!="object")return g;if(Array.isArray(g))return g.map(kCg);const A={};for(const[I,e]of Object.entries(g))I.startsWith("_")||(A[I]=kCg(e));return A},Zpo=(g,A)=>{try{if(typeof g.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const I=kCg(g.getConstructorParams()),e=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),t=URL.createObjectURL(e),o=document.createElement("a");o.href=t,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(t)}catch(I){alert(`Error downloading input for ${A}: ${I instanceof Error?I.message:String(I)}`)}},Opo=({expanded:g})=>T.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:`w-4 h-4 transition-transform duration-200 ${g?"rotate-90":""}`,children:T.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})}),wPI=g=>{let A=g;for(;A.activeSubSolver;)A=A.activeSubSolver;return A},uPI=({solver:g,onStepUntilPhase:A,onDownloadInput:I,isNested:e=!1,indentLevel:t=0,triggerRender:o})=>{const[B,C]=z.useState(new Set),Q=g.pipelineDef.map((h,l)=>bpo(g,l)),i=h=>{C(l=>{const D=new Set(l);return D.has(h)?D.delete(h):D.add(h),D})},E=h=>{A?.(h)},n=h=>{h.solverInstance&&(I?I(h.solverInstance,h.name):Zpo(h.solverInstance,h.name))},s=h=>`${(h/1e3).toFixed(2)}s`,r=()=>{if(!g.solved&&!g.failed){const h=g.activeSubSolver;for(;!g.solved&&!g.failed&&(g.step(),!(g.activeSubSolver&&g.activeSubSolver!==h)););o?.()}},a=()=>{if(!g.solved&&!g.failed){const h=wPI(g);for(;!g.solved&&!g.failed&&(g.step(),wPI(g)===h););o?.()}},c=t*24;return T.jsxs("div",{className:e?"":"border-t border-gray-200",children:[!e&&T.jsxs("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between",children:[T.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Stages"}),T.jsxs("div",{className:"flex gap-2",children:[T.jsx("button",{onClick:a,disabled:g.solved||g.failed,className:"bg-indigo-500 hover:bg-indigo-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Solver"}),T.jsx("button",{onClick:r,disabled:g.solved||g.failed,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Stage"})]})]}),T.jsx("div",{className:"overflow-x-auto",children:T.jsxs("table",{className:"w-full text-sm",children:[!e&&T.jsx("thead",{children:T.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stage"}),T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),T.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",T.jsx("sub",{children:"0"})]}),T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),T.jsx("tbody",{children:Q.map(h=>{const l=Ypo(h.solverInstance),D=B.has(h.name);return T.jsxs(rC.Fragment,{children:[T.jsxs("tr",{className:`border-b border-gray-100 ${h.status==="In Progress"?"bg-yellow-50":""}`,children:[T.jsx("td",{className:"px-4 py-2",children:T.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:c},children:[l?T.jsx("button",{onClick:()=>i(h.name),className:"text-gray-500 hover:text-gray-700",title:D?"Collapse":"Expand",children:T.jsx(Opo,{expanded:D})}):T.jsx("span",{className:"w-4"}),T.jsx("span",{className:"text-gray-400 w-6",children:String(h.index+1).padStart(2,"0")}),T.jsx("button",{onClick:()=>E(h.name),disabled:h.status==="Completed"||g.solved||g.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${h.name} completes`,children:T.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:T.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),T.jsx("span",{className:"font-medium text-gray-900",children:h.name})]})}),T.jsx("td",{className:"px-4 py-2",children:T.jsx(Hpo,{status:h.status})}),T.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:h.firstIteration!==null?h.firstIteration:""}),T.jsx("td",{className:"px-4 py-2 text-gray-600",children:h.iterations}),T.jsx("td",{className:"px-4 py-2",children:T.jsx(vpo,{progress:h.progress})}),T.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(h.timeSpent)}),T.jsx("td",{className:"px-4 py-2 text-gray-500",children:T.jsx(qpo,{stats:h.stats})}),T.jsx("td",{className:"px-4 py-2",children:h.solverInstance?T.jsxs("button",{onClick:()=>n(h),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${h.name}`,children:[T.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:T.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),T.jsx("span",{children:"Input"})]}):null})]}),l&&D&&T.jsx("tr",{children:T.jsx("td",{colSpan:8,className:"p-0",children:T.jsx(uPI,{solver:h.solverInstance,onStepUntilPhase:A,onDownloadInput:I,isNested:!0,indentLevel:t+1,triggerRender:o})})})]},h.name)})})]})})]})};function Wpo({graphics:g}){const A=g.points??[],I=g.lines??[],e=g.rects??[],t=g.circles??[],o=g.texts??[];let B=Number.POSITIVE_INFINITY,C=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const E=(h,l)=>{typeof h=="number"&&(h<B&&(B=h),h>Q&&(Q=h)),typeof l=="number"&&(l<C&&(C=l),l>i&&(i=l))};for(const h of A)E(h.x,h.y);for(const h of I){const l=h.points??[];for(const D of l)E(D.x,D.y)}for(const h of e){const l=h.x??0,D=h.y??0,d=h.width??0,y=h.height??0;E(l,D),E(l+d,D+y)}for(const h of t){const l=h.x??0,D=h.y??0,d=h.radius??1;E(l-d,D-d),E(l+d,D+d)}for(const h of o)E(h.x,h.y);(!isFinite(B)||!isFinite(C)||!isFinite(Q)||!isFinite(i))&&(B=-20,C=-20,Q=20,i=20);const n=10,s=B-n,r=C-n,a=Math.max(1,Q-B+2*n),c=Math.max(1,i-C+2*n);return T.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${s} ${r} ${a} ${c}`,role:"img","aria-label":"Graphics fallback",children:[e.map((h,l)=>T.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${l}`)),I.map((h,l)=>T.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(D=>`${D.x??0},${D.y??0}`).join(" ")},`line-${l}`)),t.map((h,l)=>T.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${l}`)),A.map((h,l)=>T.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${l}`)),o.map((h,l)=>T.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${l}`))]})}var Vpo=class extends rC.Component{constructor(g){super(g),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(g){console.error("InteractiveGraphics render error:",g)}render(){return this.state.hasError?this.props.fallback:this.props.children}},jpo=({solver:g,createSolver:A,animationSpeed:I=25,onSolverStarted:e,onSolverCompleted:t})=>{const[o,B]=z.useReducer(D=>D+1,0),[C]=z.useState(()=>{if(A)return A();if(!g)throw new Error("GenericSolverDebugger requires solver or createSolver");return g}),[Q,i]=z.useState(()=>typeof window>"u"?"vector":window.localStorage.getItem("solver-utils-renderer")==="canvas"?"canvas":"vector"),[E,n]=z.useState(I),s=z.useMemo(()=>{try{return C.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(D){return console.error("Visualization error:",D),{points:[],lines:[],rects:[],circles:[]}}},[C,o]),r=z.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);z.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const D=document.createElement("script");D.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(D)}},[]),z.useEffect(()=>{n(I)},[I]);const a=C.pipelineDef!==void 0,c=D=>{const d=C;if(!C.solved&&!C.failed){for(;!C.solved&&!C.failed&&d.currentPipelineStageIndex<=d.pipelineDef.findIndex(y=>y.solverName===D);)C.step();B()}},h=()=>{const D=JSON.stringify(s,null,2),d=new Blob([D],{type:"application/json"}),y=URL.createObjectURL(d),w=document.createElement("a");w.download="visualization.json",w.href=y,document.body.appendChild(w),w.click(),document.body.removeChild(w),URL.revokeObjectURL(y)},l=D=>{i(D),typeof window<"u"&&window.localStorage.setItem("solver-utils-renderer",D)};return T.jsxs("div",{children:[T.jsx(Lpo,{solver:C,triggerRender:B,animationSpeed:E,renderer:Q,onRendererChange:l,onAnimationSpeedChange:n,onDownloadVisualization:h,onSolverStarted:e,onSolverCompleted:t}),r?T.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):T.jsx(Vpo,{fallback:T.jsx(Wpo,{graphics:s}),children:Q==="canvas"?T.jsx(Jpo,{graphics:s}):T.jsx(xpo,{graphics:s})}),a&&T.jsx(uPI,{solver:C,onStepUntilPhase:c,triggerRender:B})]})};const zpo=()=>{z.useEffect(()=>{const g="tailwind-cdn-script";if(document.getElementById(g)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const I=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),I)return;const e=document.createElement("script");e.id=g,e.src="https://cdn.tailwindcss.com",document.head.appendChild(e)},[])},Xpo=1e3,bk=(g,A)=>{const{fileName:I,mimeType:e="text/plain"}=A,t=g instanceof Blob?g:new Blob([g],{type:e}),o=URL.createObjectURL(t),B=document.createElement("a");B.href=o,B.download=I,B.target="_blank",B.rel="noopener noreferrer",B.style.display="none",document.body.appendChild(B),B.click(),document.body.removeChild(B),setTimeout(()=>{URL.revokeObjectURL(o)},Xpo)},MCg=g=>{let A=g.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(A)&&(A=`_${A}`),A=A.slice(0,200),A||"untitled"},$po=g=>{const A=g.solverConstructorArgs??[g.solverParams];if(g.solverName!=="AutoroutingPipelineSolver7_MultiGraph"||A.length!==1)return A;const[{input:I,options:e}]=A;return[I,e]},dF="https://github.com/tscircuit/tscircuit-autorouter/issues/new",GPI="https://github.com/tscircuit/copper-pour-solver/issues/new",mPI="https://github.com/tscircuit/calculate-packing/issues/new",Ako="https://github.com/tscircuit/matchpack/issues/new",pPI="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",gko={PackSolver2:mPI,LayoutPipelineSolver:Ako,AutoroutingPipelineSolver:dF,AssignableAutoroutingPipeline2:dF,AssignableAutoroutingPipeline3:dF,AutoroutingPipeline1_OriginalUnravel:dF,AutoroutingPipelineSolver3_HgPortPointPathing:dF,AutoroutingPipelineSolver4:dF,AutoroutingPipelineSolver5:dF,AutoroutingPipelineSolver7_MultiGraph:dF,AutoroutingPipelineSolver8:dF,CopperPourPipelineSolver:GPI,SchematicTracePipelineSolver:pPI},Iko=g=>g.toLowerCase().includes("pack")?nxI:g.toLowerCase().includes("rout")?axI:Aco,kPI=g=>{const A=gko[g];if(A)return A;const I=g.toLowerCase();return I.includes("autorout")?dF:I.includes("schematic")&&I.includes("trace")?pPI:I.includes("copperpour")?GPI:I.includes("pack")?mPI:null},eko=g=>`${MCg(`${g.componentName}-${g.solverName}`)}-solver-input.json`,MPI=g=>{bk(JSON.stringify(g.solverParams,null,2),{fileName:eko(g),mimeType:"application/json"})},tko=({solverEvent:g})=>{const A=kPI(g.solverName);return T.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[T.jsxs(si,{type:"button",variant:"outline",size:"sm",onClick:()=>MPI(g),children:[T.jsx(NtA,{className:"rf-w-4 rf-h-4"}),"Download"]}),A?T.jsx(si,{asChild:!0,variant:"outline",size:"sm",children:T.jsxs("a",{href:A,target:"_blank",rel:"noopener noreferrer",children:[T.jsx(qGA,{className:"rf-w-4 rf-h-4"}),"Report"]})}):T.jsxs(si,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[T.jsx(qGA,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},oko=({solverEvent:g})=>{const A=kPI(g.solverName);return A?T.jsx(si,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:T.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:T.jsx(qGA,{className:"rf-w-4 rf-h-4"})})}):T.jsx(si,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:T.jsx(qGA,{className:"rf-w-4 rf-h-4"})})},Bko=({solverEvents:g=[]})=>{const[A,I]=z.useState(null);zpo();const e=z.useMemo(()=>{const C=new Map;for(const Q of g){const i=`${Q.componentName}-${Q.solverName}`;C.set(i,Q)}return C},[g]),t=z.useMemo(()=>Array.from(e.keys()),[e]),o=A?e.get(A):null,B=z.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const C=W9A[o.solverName];if(!C)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(W9A).join(", ")}`,classFound:!1};try{return{instance:new C(...$po(o)),error:null,classFound:!0}}catch(Q){const i=Q instanceof Error?Q.message:String(Q);return console.error("Failed to reconstruct solver:",Q),{instance:null,error:`Failed to instantiate solver: ${i}`,classFound:!0}}},[o]);return g.length===0?T.jsx("div",{className:"rf-p-4",children:T.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:T.jsxs("div",{className:"rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),T.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):T.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[T.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[T.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[t.length," ",t.length===1?"Solver":"Solvers"]}),t.map(C=>{const Q=e.get(C),i=A===C;return T.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${i?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>I(C),children:(()=>{const E=Iko(Q.solverName);return T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[T.jsx(E,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),T.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[T.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:Q.componentName}),T.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:Q.solverName})]})]})})()},C)})]}),T.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?B.instance?T.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[T.jsx(tko,{solverEvent:o}),T.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:T.jsx(GS,{fallback:T.jsx("div",{className:"rf-p-4",children:T.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),T.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:T.jsx(jpo,{solver:B.instance})})})]}):T.jsxs("div",{className:"rf-p-4",children:[T.jsxs("div",{className:"rf-mb-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),T.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),B.error&&T.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${B.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:T.jsx("p",{className:`rf-text-sm ${B.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:B.error})}),T.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[T.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[T.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[T.jsx(oko,{solverEvent:o}),T.jsx(si,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>MPI(o),children:T.jsx(NtA,{className:"rf-w-4 rf-h-4"})})]})]}),T.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:T.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):T.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:T.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Cko=["subcircuit_id","componentDisplayName","phaseName","routingPhaseIndex","phaseOrdinal","phaseCount","phaseStageIndex","phaseStageCount","connectionCount","obstacleCount","previousTraceCount","isReroutePhase","autorouterName","autorouterVersion","solverName","effort","cacheStatus"],Qko=["phaseOrdinal","routingPhaseIndex","phaseName","phaseStageIndex"];function iko(g,A){let I=-1,e=-1;for(let t=g.length-1;t>=0;t--){const o=g[t];if(o.status!=="running"||o.subcircuit_id!==A.subcircuit_id||o.componentDisplayName!==A.componentDisplayName)continue;let B=0,C=!1;for(const Q of Qko)if(!(o[Q]===void 0||A[Q]===void 0)){if(o[Q]!==A[Q]){C=!0;break}B++}!C&&B>e&&(I=t,e=B)}return I}function Eko(g,A){const I=Object.fromEntries(Cko.filter(B=>A[B]!==void 0).map(B=>[B,A[B]])),e=A.simpleRouteJson?structuredClone(A.simpleRouteJson):void 0,t=A.type==="autorouting:start"?-1:iko(g,A),o={...t===-1?{id:`autorouting_phase_${g.length+1}`}:g[t],...I,status:A.type==="autorouting:start"?"running":A.type==="autorouting:end"?"complete":"error",...A.type==="autorouting:start"?{startSimpleRouteJson:e}:A.type==="autorouting:end"?{endSimpleRouteJson:e}:{errorSimpleRouteJson:e,error:A.error?{...A.error}:void 0}};return t===-1?[...g,o]:g.map((B,C)=>C===t?o:B)}const nko=new Map([["custom","Custom"],["fanout","Fanout"],["single_layer_fanout","Single layer fanout"],["tscircuit_simplify","Simplify"]]),sko=new Set(["tscircuit","default","auto","auto_local"]);function ako(g){if(g==="FanoutSolver")return"Fanout";if(g==="AutoroutingPipelineSolver11_Simplification")return"Simplify";const A=g.match(/^AutoroutingPipeline(?:Solver)?(\d+)(?:_|$)/);if(A)return`Pipeline${A[1]}`;const I=g.match(/^AssignableAutoroutingPipeline(\d+)$/);return I?`Assignable${I[1]}`:g}function rko(g){const A=g.autorouterName?.trim(),I=A?.replace(/-/g,"_"),e=I&&nko.get(I);if(e)return e;if(I&&!sko.has(I))return A;const t=g.solverName?.trim();if(t)return ako(t);const o=g.autorouterVersion?.trim();if(o){const B=o.match(/^beta[_-]pipeline(\d+)$/);return B?`Pipeline${B[1]}`:o==="latest"?"default":o}return A?"default":"Unknown"}const SCg="#fbbf24";function cko(g){const A=g.endSimpleRouteJson?.traces??[],I=new Set(A.flatMap(t=>[t.pcb_trace_id,t.__replaces_pcb_trace_id].filter(o=>o!==void 0)));return[...(g.startSimpleRouteJson?.traces??[]).filter(t=>!I.has(t.pcb_trace_id)),...A]}function SPI(g){const A=new Map((g.startSimpleRouteJson?.traces??[]).map(I=>[I.pcb_trace_id,I]));return(g.endSimpleRouteJson?.traces??[]).filter(I=>{const e=A.get(I.pcb_trace_id);return!e||!!I.__replaces_pcb_trace_id&&I.__replaces_pcb_trace_id!==e.__replaces_pcb_trace_id||JSON.stringify(e.route)!==JSON.stringify(I.route)}).map(I=>I.pcb_trace_id)}function hko(g,A){return{outer_diameter:g.via_diameter??A.minViaPadDiameter??A.min_via_pad_diameter??A.minViaDiameter??.6,hole_diameter:g.via_hole_diameter??A.minViaHoleDiameter??A.min_via_hole_diameter??.3}}function fPI(g,A){const I=[];for(const C of g.route)C.route_type==="wire"?I.push({...C,layer:C.layer}):C.route_type==="via"?I.push({route_type:"via",x:C.x,y:C.y,from_layer:C.from_layer,to_layer:C.to_layer,...hko(C,A)}):C.route_type==="through_obstacle"&&I.push({route_type:"through_pad",start:{...C.start},end:{...C.end},width:C.width,start_layer:C.from_layer,end_layer:C.to_layer,pcb_smtpad_id:C.circuitJsonMetadata?.pcb_smtpad_id,pcb_plated_hole_id:C.circuitJsonMetadata?.pcb_plated_hole_id});const e=C=>{let Q=-1,i=Number.POSITIVE_INFINITY;return I.forEach((E,n)=>{if(E.route_type!=="wire")return;const s=Math.hypot(E.x-C.x,E.y-C.y);s<i&&(i=s,Q=n)}),Q},t=g.route.filter(C=>C.route_type==="jumper").map(C=>[e(C.start),e(C.end)].sort((Q,i)=>Q-i)).filter(([C,Q])=>C>=0&&Q>C).sort(([C],[Q])=>C-Q),o=[];let B=0;for(const[C,Q]of t)C>=B&&o.push(I.slice(B,C+1)),B=Math.max(B,Q);return B<I.length&&o.push(I.slice(B)),o}function lko(g){const A=[],I=[],e=g.endSimpleRouteJson;if(!e)return{lines:A,circles:I};const t=new Set(SPI(g));for(const o of e.traces??[])if(t.has(o.pcb_trace_id))for(const B of fPI(o,e)){let C;for(const Q of B){if(Q.route_type==="through_pad"){C={...Q.end,layer:Q.end_layer,width:Q.width};continue}const i=Q.route_type==="wire"?Q.layer:Q.from_layer;C&&C.layer===i&&(C.x!==Q.x||C.y!==Q.y)&&A.push({points:[{x:C.x,y:C.y},{x:Q.x,y:Q.y}],strokeWidth:Q.route_type==="wire"?Q.width:C.width,strokeColor:SCg,layer:i}),Q.route_type==="via"&&I.push({center:{x:Q.x,y:Q.y},radius:Q.outer_diameter/2,stroke:SCg,fill:"transparent"}),C={x:Q.x,y:Q.y,layer:Q.route_type==="wire"?Q.layer:Q.to_layer,width:Q.route_type==="wire"?Q.width:C?.width??e.minTraceWidth}}}return{coordinateSystem:"cartesian",lines:A,circles:I}}function Dko(g){const A=JSON.stringify(g);let I=2166136261;for(let e=0;e<A.length;e++)I=Math.imul(I^A.charCodeAt(e),16777619);return(I>>>0).toString(36)}const dko=new Set(["pcb_trace","pcb_via","pcb_copper_pour","pcb_ground_plane","pcb_ground_plane_region","pcb_thermal_spoke","pcb_breakout_point"]);function yko(g,A,I){const e=I==="input"?A.startSimpleRouteJson??A.errorSimpleRouteJson:A.endSimpleRouteJson,t=g.filter(i=>!dko.has(i.type)&&!i.type.endsWith("_error")&&!i.type.endsWith("_warning"));if(!e)return t;const o=I==="input"?e.traces??[]:cko(A),B=new Set(g.filter(i=>i.type==="source_trace").map(i=>i.source_trace_id)),C=["top",...Array.from({length:Math.max(0,e.layerCount-2)},(i,E)=>`inner${E+1}`),...e.layerCount>1?["bottom"]:[]],Q=[];for(const i of o){const n=e.connections.find(r=>r.name===i.connection_name||r.source_trace_id===i.connection_name)?.source_trace_id??i.connection_name??"",s=fPI(i,e);for(const[r,a]of s.entries()){const c={type:"pcb_trace",pcb_trace_id:`${A.id}_${I}_${i.pcb_trace_id}_${r}_${Dko(a)}`,subcircuit_id:A.subcircuit_id??void 0,source_trace_id:B.has(n)?n:void 0,route:a};Q.push(c);for(const[h,l]of a.entries()){if(l.route_type!=="via")continue;const D=C.indexOf(l.from_layer),d=C.indexOf(l.to_layer),y={type:"pcb_via",pcb_via_id:`${c.pcb_trace_id}_via_${h}`,pcb_trace_id:c.pcb_trace_id,subcircuit_id:A.subcircuit_id??void 0,x:l.x,y:l.y,outer_diameter:l.outer_diameter,hole_diameter:l.hole_diameter,layers:D>=0&&d>=0?C.slice(Math.min(D,d),Math.max(D,d)+1):[l.from_layer,l.to_layer]};Q.push(y)}}}return[...t,...Q]}const fCg=(g,A)=>g.phaseName||`Phase ${g.phaseOrdinal??A+1}`,RPI=g=>g.componentDisplayName?.match(/name="([^"]+)"/)?.[1]?.replace(/^\./,"")||g.componentDisplayName||g.subcircuit_id||"Board",NPI=g=>g.startSimpleRouteJson??g.endSimpleRouteJson??g.errorSimpleRouteJson,wko={is_showing_autorouting:!0,is_showing_rats_nest:!1,is_showing_drc_errors:!1,is_showing_drc_warnings:!1,is_showing_pcb_groups:!1},uko=({circuitJson:g,phases:A=[],isRunning:I=!1})=>{const[e,t]=z.useState(null),[o,B]=z.useState("output"),[C,Q]=z.useState(!0),[i,E]=z.useState(!1),n=z.useRef(null),[s,r]=z.useState(480),a=e?A.findIndex(N=>N.id===e.id&&NPI(N)===NPI(e)):-1,c=a<0?A.length-1:a,h=A[c],l=a<0,D=!!h?.endSimpleRouteJson,d=h?.startSimpleRouteJson??h?.errorSimpleRouteJson,y=!!d,w=o==="output"&&!D?"input":o==="input"&&!y?"output":o,u=w==="input"?d:h?.endSimpleRouteJson,G=z.useMemo(()=>!h||!u?null:yko(g??[],h,w),[g,h,u,w]),m=z.useMemo(()=>h&&w==="output"&&C?lko(h):{lines:[],circles:[]},[h,w,C]);if(z.useLayoutEffect(()=>{const N=n.current;if(!N)return;const U=()=>r(Math.max(360,N.clientHeight));U();const K=new ResizeObserver(U);return K.observe(N),()=>K.disconnect()},[!!h]),!h)return T.jsxs("div",{className:"rf-flex rf-min-h-[400px] rf-flex-col rf-items-center rf-justify-center rf-gap-3 rf-p-8 rf-text-center",children:[T.jsx(axI,{className:"rf-h-7 rf-w-7 rf-text-blue-500"}),T.jsx("h3",{className:"rf-text-base rf-font-medium",children:I?"Waiting for autorouting":"No autorouting captures"}),T.jsx("p",{className:"rf-max-w-md rf-text-sm rf-text-gray-500",children:I?"Phases appear as the circuit routes. Each capture includes its input and output on the PCB.":"Run a circuit with autorouting enabled to inspect its phases. A circuit JSON file alone does not include routing history."})]});const p=fCg(h,c),k=h.status==="running"&&I,S=!D,R=d?.connections.length,x=G?.filter(N=>N.type==="pcb_trace").length??0;return T.jsxs("div",{className:"rf-flex rf-h-full rf-min-h-[620px] rf-flex-col rf-bg-white md:rf-flex-row","data-testid":"autorouting-explorer",children:[T.jsxs("aside",{className:"rf-flex rf-shrink-0 rf-flex-col rf-border-b rf-border-gray-200 md:rf-w-52 md:rf-border-b-0 md:rf-border-r","aria-label":"Routing phases",children:[T.jsxs("div",{className:"rf-flex rf-items-center rf-justify-between rf-px-3 rf-py-2 rf-text-xs rf-text-gray-500",children:[T.jsx("span",{children:"Routing phases"}),T.jsx("span",{children:A.length})]}),T.jsx("div",{className:"rf-flex rf-gap-1 rf-overflow-x-auto rf-px-1.5 rf-pb-1.5 md:rf-flex-col md:rf-overflow-x-hidden md:rf-overflow-y-auto",children:A.map((N,U)=>{const K=SPI(N).length,Y=N.endSimpleRouteJson?`${K} ${K===1?"trace":"traces"} routed`:N.status==="error"?"Failed":N.status==="running"&&I?"Routing…":"No output";return T.jsxs("button",{type:"button","aria-pressed":U===c,title:`${RPI(N)} · ${Y}`,onClick:()=>t(N),className:co("rf-flex rf-min-w-[192px] rf-items-start rf-gap-2 rf-rounded-md rf-border rf-px-2 rf-py-2 rf-text-left md:rf-min-w-0",U===c?"rf-border-blue-200 rf-bg-blue-50":"rf-border-transparent hover:rf-bg-gray-50"),children:[T.jsx("span",{className:co("rf-flex rf-h-5 rf-w-5 rf-shrink-0 rf-items-center rf-justify-center rf-rounded-full rf-text-[11px]",U===c?"rf-bg-blue-600 rf-text-white":"rf-bg-gray-100 rf-text-gray-500"),children:U+1}),T.jsxs("span",{className:"rf-min-w-0 rf-flex-1",children:[T.jsxs("span",{className:"rf-flex rf-items-center rf-gap-1",children:[T.jsx("span",{className:"rf-min-w-0 rf-flex-1 rf-truncate rf-text-xs rf-font-medium rf-leading-5 rf-text-gray-800",title:fCg(N,U),children:fCg(N,U)}),N.status==="complete"?T.jsx(sF,{"aria-label":"Captured",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-green-600"}):N.status==="error"?T.jsx(Zog,{"aria-label":"Failed",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-red-500"}):I?T.jsx(mS,{"aria-label":"Routing",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-animate-spin rf-text-blue-500"}):null]}),T.jsxs("span",{className:"rf-block rf-text-[11px] rf-leading-4 rf-text-gray-500",children:[rko(N)," · ",Y]})]})]},N.id)})})]}),T.jsxs("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-flex-col",children:[T.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-gap-3 rf-border-b rf-border-gray-200 rf-px-4 rf-py-3",children:[T.jsxs("h3",{className:"rf-mr-auto rf-flex rf-items-center rf-gap-2 rf-text-sm rf-font-medium",children:[p,T.jsxs("span",{className:"rf-text-xs rf-font-normal rf-text-gray-500",children:[c+1," of ",A.length]})]}),I&&T.jsx("button",{type:"button",onClick:()=>t(null),disabled:l,className:"rf-text-xs rf-text-blue-600 disabled:rf-text-gray-500",children:l?"Following latest":"Follow latest"}),T.jsx("div",{className:"rf-flex rf-rounded-md rf-bg-gray-100 rf-p-1","aria-label":"Phase snapshot",children:["input","output"].map(N=>T.jsx("button",{type:"button","aria-pressed":w===N,disabled:N==="input"?!y:!D,onClick:()=>B(N),className:co("rf-rounded rf-px-3 rf-py-1 rf-text-xs disabled:rf-opacity-40",w===N?"rf-bg-white rf-text-gray-900 rf-shadow-sm":"rf-text-gray-500"),children:N==="input"?"Input":"Output"},N))})]}),T.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-px-4 rf-py-2 rf-text-xs rf-text-gray-600",children:[T.jsxs("label",{className:"rf-flex rf-items-center rf-gap-2",children:[T.jsx("input",{type:"checkbox",checked:C,disabled:w!=="output",onChange:N=>Q(N.target.checked),className:"rf-accent-blue-600"}),T.jsx("span",{"aria-hidden":"true",className:"rf-inline-block rf-h-0.5 rf-w-3",style:{backgroundColor:SCg}}),"Highlight changes (all layers)"]}),T.jsxs("span",{children:[w==="input"?"Before this phase":"After this phase"," ","· ",x," traces"]})]}),S&&T.jsx("div",{className:co("rf-border-y rf-px-4 rf-py-2 rf-text-xs",h.status==="error"?"rf-border-red-100 rf-bg-red-50 rf-text-red-700":"rf-border-blue-100 rf-bg-blue-50 rf-text-blue-700"),role:"status",children:h.status==="error"?`Routing failed: ${h.error?.message||"No output was captured."}`:k?"Routing in progress. Showing captured input until output is available.":"No output was captured for this phase. Showing the available input."}),T.jsx("div",{ref:n,className:"rf-relative rf-min-h-[360px] rf-flex-1","data-testid":"autorouting-pcb",children:G?T.jsx(vog,{circuitJson:G,height:s,allowEditing:!1,clickToInteractEnabled:!1,initialState:wko,debugGraphics:m}):T.jsx("div",{className:"rf-p-6 rf-text-sm rf-text-gray-500",children:"No PCB snapshot available for this capture."})}),T.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-border-t rf-border-gray-200 rf-px-4 rf-py-3 rf-text-xs rf-text-gray-500",children:[T.jsxs("span",{children:[R===void 0?"Input unavailable":`${R} input connections`,` · ${RPI(h)}`]}),T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4",children:[T.jsxs("button",{type:"button",disabled:!u,onClick:()=>bk(JSON.stringify(u,null,2),{fileName:`${h.id}-${w}.srj.json`,mimeType:"application/json"}),className:"rf-flex rf-items-center rf-gap-1 disabled:rf-opacity-40",children:[T.jsx(NtA,{className:"rf-h-3 rf-w-3"}),"Download SRJ"]}),T.jsxs("button",{type:"button","aria-expanded":i,onClick:()=>E(!i),className:"rf-flex rf-items-center rf-gap-1",children:[T.jsx(Fb,{className:co("rf-h-3 rf-w-3",i&&"rf-rotate-90")}),"Inspect SRJ"]})]})]}),i&&T.jsx("pre",{className:"rf-m-0 rf-max-h-64 rf-overflow-auto rf-border-t rf-border-gray-200 rf-bg-gray-50 rf-p-4 rf-text-xs","aria-label":`${p} ${w} SRJ`,children:u?JSON.stringify(u,null,2):"No snapshot captured."})]})]})},xPI=({errorMessage:g,errorStack:A,circuitJsonErrors:I})=>{z.useEffect(()=>{if(uJ("TSCIRCUIT_TELEMETRY_DISABLED")!==!0&&g){const e=new Error(g);A&&(e.stack=A);try{xq.captureException(e)}catch{}}},[g,A]),z.useEffect(()=>{if(uJ("TSCIRCUIT_TELEMETRY_DISABLED")!==!0&&I&&I.length>0)for(const e of I){const t=new Error(e.message||"Circuit JSON Error");e.stack&&(t.stack=e.stack);try{xq.captureException(t,{error_type:e.type})}catch{}}},[I])},FPI=g=>{z.useEffect(()=>{try{pdt(g)}catch{}},[g.source,g.component,g.isWebEmbedded,g.activeTab])},UPI="0.0.3085",Gko={version:UPI},apA=DXg()(dXg(g=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{g({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),mko=g=>{const[A,I]=z.useState([]),[e,t]=z.useState(null),[o,B]=z.useState(""),[C,Q]=gq("eval-version-selection",null),i=apA(r=>r.setLastRunEvalVersion),E=apA(r=>r.lastRunEvalVersion);return z.useEffect(()=>{g&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(r=>r.json()).then(r=>{if(Array.isArray(r?.versions)){let a=[...r.versions];r.tags?.latest&&(t(r.tags.latest),a=a.filter(c=>c!==r.tags.latest)),I(a)}}).catch(()=>{})},[g]),z.useEffect(()=>{g&&(C?(window.TSCIRCUIT_LATEST_EVAL_VERSION=C,i(C)):e&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=e,i(e)))},[g,C,e]),{versions:z.useMemo(()=>A.filter(r=>r.includes(o)).slice(0,50),[A,o]),latestVersion:e,lastRunEvalVersion:E,search:o,setSearch:B,selectVersion:r=>{Q(r),B("")}}},pko=({snippetNames:g,onSelect:A,onCancel:I,isOpen:e})=>{const[t,o]=z.useState(""),[B,C]=z.useState("");if(!e)return null;const Q=g.filter(n=>n.toLowerCase().includes(B.toLowerCase())),i=B&&!g.includes(B),E=n=>{n.key==="Enter"&&(Q.length===1?o(Q[0]):i&&o(B))};return T.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:T.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[T.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),T.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:B,onChange:n=>C(n.target.value),onKeyDown:E}),T.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[Q.map(n=>T.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${t===n?"bg-blue-50":""}`,onClick:()=>o(n),children:n},n)),i&&T.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${t===B?"bg-blue-50":""}`,onClick:()=>o(B),children:['Create new "',B,'"']})]}),T.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[T.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:I,children:"Cancel"}),T.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>t&&A(t),disabled:!t,children:t===B?`Create "${t}"`:`Save to ${t}`})]})]})})},kko=g=>{const A=z.useRef(null),I=Kc(e=>e.recentEvents);z.useEffect(()=>{if(I.length===0)return;const e=I[0];e.event_id!==A.current&&(g(e),A.current=e.event_id)},[I,g])};var Mko=Object.defineProperty,EP=(g,A)=>Mko(g,"name",{value:A,configurable:!0}),Sko="AlertDialog",[fko,FCB]=hk(Sko,[_FI]),nP=_FI(),Rko=EP(g=>{const{__scopeAlertDialog:A,...I}=g,e=nP(A);return T.jsx(fmA,{...e,...I,modal:!0})},"AlertDialog");z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=nP(e);return T.jsx(plo,{...o,...t,ref:I})},"AlertDialogTrigger"));var Nko=EP(g=>{const{__scopeAlertDialog:A,...I}=g,e=nP(A);return T.jsx(RmA,{...e,...I})},"AlertDialogPortal"),JPI=z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=nP(e);return T.jsx(TtA,{...o,...t,ref:I})},"AlertDialogOverlay")),xko="AlertDialogContent",[Fko,Uko]=fko(xko),PPI=z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,children:t,...o}=A,B=nP(e),C=z.useRef(null),Q=Gi(I,C),i=z.useRef(null);return T.jsx(Fko,{scope:e,cancelRef:i,children:T.jsx(ZtA,{role:"alertdialog",...B,...o,ref:Q,onOpenAutoFocus:fo(o.onOpenAutoFocus,E=>{E.preventDefault(),i.current?.focus({preventScroll:!0})}),onPointerDownOutside:E=>E.preventDefault(),onInteractOutside:E=>E.preventDefault(),children:t})})},"AlertDialogContent")),KPI=z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=nP(e);return T.jsx(NmA,{...o,...t,ref:I})},"AlertDialogTitle")),LPI=z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=nP(e);return T.jsx(xmA,{...o,...t,ref:I})},"AlertDialogDescription")),YPI=z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=nP(e);return T.jsx(JBg,{...o,...t,ref:I})},"AlertDialogAction")),Jko="AlertDialogCancel",_PI=z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,...t}=A,{cancelRef:o}=Uko(Jko,e),B=nP(e),C=Gi(I,o);return T.jsx(JBg,{...B,...t,ref:C})},"AlertDialogCancel"));const bPI=Rko,Pko=Nko,HPI=z.forwardRef(({className:g,...A},I)=>T.jsx(JPI,{className:co("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",g),...A,ref:I}));HPI.displayName=JPI.displayName;const RCg=z.forwardRef(({className:g,...A},I)=>T.jsxs(Pko,{children:[T.jsx(HPI,{}),T.jsx(PPI,{ref:I,className:co("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",g),...A})]}));RCg.displayName=PPI.displayName;const NCg=({className:g,...A})=>T.jsx("div",{className:co("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",g),...A});NCg.displayName="AlertDialogHeader";const xCg=({className:g,...A})=>T.jsx("div",{className:co("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",g),...A});xCg.displayName="AlertDialogFooter";const FCg=z.forwardRef(({className:g,...A},I)=>T.jsx(KPI,{ref:I,className:co("rf-text-lg rf-font-semibold",g),...A}));FCg.displayName=KPI.displayName;const UCg=z.forwardRef(({className:g,...A},I)=>T.jsx(LPI,{ref:I,className:co("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",g),...A}));UCg.displayName=LPI.displayName;const Kko=z.forwardRef(({className:g,...A},I)=>T.jsx(YPI,{ref:I,className:co(sO(),g),...A}));Kko.displayName=YPI.displayName;const JCg=z.forwardRef(({className:g,...A},I)=>T.jsx(_PI,{ref:I,className:co(sO({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",g),...A}));JCg.displayName=_PI.displayName;var Lko=Object.defineProperty,sP=(g,A)=>Lko(g,"name",{value:A,configurable:!0}),PCg="Checkbox",[Yko,UCB]=hk(PCg),[_ko,KCg]=Yko(PCg);function vPI(g){const{__scopeCheckbox:A,checked:I,children:e,defaultChecked:t,disabled:o,form:B,name:C,onCheckedChange:Q,required:i,value:E="on",internal_do_not_use_render:n}=g,[s,r]=xR({prop:I,defaultProp:t??!1,onChange:Q,caller:PCg}),[a,c]=z.useState(null),[h,l]=z.useState(null),[D,d]=z.useState(null),y=a?!!B||!!a.closest("form"):!0,w={checked:s,disabled:o,setChecked:r,control:a,setControl:c,name:C,form:B,value:E,userClick:D,onUserClick:d,required:i,defaultChecked:wf(t)?!1:t,isFormControl:y,bubbleInput:h,setBubbleInput:l};return T.jsx(_ko,{scope:A,...w,children:qPI(n)?n(w):e})}sP(vPI,"CheckboxProvider");var bko="CheckboxTrigger",Hko=z.forwardRef(sP(function({__scopeCheckbox:A,onKeyDown:I,onClick:e,...t},o){const{control:B,value:C,disabled:Q,checked:i,required:E,setControl:n,setChecked:s,onUserClick:r,isFormControl:a,bubbleInput:c}=KCg(bko,A),h=Gi(o,n),l=z.useRef(i);return z.useEffect(()=>{const D=B?.form;if(D){const d=sP(()=>s(l.current),"reset");return D.addEventListener("reset",d),()=>D.removeEventListener("reset",d)}},[B,s]),T.jsx(yQ.button,{type:"button",role:"checkbox","aria-checked":wf(i)?"mixed":i,"aria-required":E,"data-state":LCg(i),"data-disabled":Q?"":void 0,disabled:Q,value:C,...t,ref:h,onKeyDown:fo(I,D=>{D.key==="Enter"&&D.preventDefault()}),onClick:fo(e,D=>{const d=D.isPropagationStopped();r({requestedChecked:wf(i)?!0:!i,hasConsumerStoppedPropagation:d}),s(y=>wf(y)?!0:!y),c&&a&&(d||D.stopPropagation())})})},"CheckboxTrigger")),TPI=z.forwardRef(sP(function(A,I){const{__scopeCheckbox:e,name:t,checked:o,defaultChecked:B,required:C,disabled:Q,value:i,onCheckedChange:E,form:n,...s}=A;return T.jsx(vPI,{__scopeCheckbox:e,checked:o,defaultChecked:B,disabled:Q,required:C,onCheckedChange:E,name:t,form:n,value:i,internal_do_not_use_render:({isFormControl:r})=>T.jsxs(T.Fragment,{children:[T.jsx(Hko,{...s,ref:I,__scopeCheckbox:e}),r&&T.jsx(Zko,{__scopeCheckbox:e})]})})},"Checkbox")),vko="CheckboxIndicator",Tko=z.forwardRef(sP(function(A,I){const{__scopeCheckbox:e,forceMount:t,...o}=A,B=KCg(vko,e);return T.jsx(AS,{present:t||wf(B.checked)||B.checked===!0,children:T.jsx(yQ.span,{"data-state":LCg(B.checked),"data-disabled":B.disabled?"":void 0,...o,ref:I,style:{pointerEvents:"none",...A.style}})})},"CheckboxIndicator")),qko="CheckboxBubbleInput",Zko=z.forwardRef(sP(function({__scopeCheckbox:A,onClick:I,...e},t){const{control:o,userClick:B,checked:C,defaultChecked:Q,required:i,disabled:E,name:n,value:s,form:r,bubbleInput:a,setBubbleInput:c}=KCg(qko,A),h=Gi(t,c),l=hBg(o),D=z.useRef(!1),d=z.useRef(C),y=z.useRef(B),w=z.useRef(null);z.useEffect(()=>{const G=a;if(!G)return;const m=window.HTMLInputElement.prototype,k=Object.getOwnPropertyDescriptor(m,"checked").set;if(!k)return;const S=d.current!==C;d.current=C;const R=B!==null&&B!==y.current;if(y.current=B,R)w.current=S?null:B,S&&(G.indeterminate=wf(C),k.call(G,wf(C)?!1:C)),G.dispatchEvent(new Event("click",{bubbles:!B.hasConsumerStoppedPropagation}));else if(S){const x=w.current;w.current=null;const N=x?.requestedChecked===C;D.current=!0,G.indeterminate=wf(C),k.call(G,wf(C)?!1:C),G.dispatchEvent(new Event("click",{bubbles:!(N&&x.hasConsumerStoppedPropagation)})),D.current=!1}},[a,C,B]);const u=z.useRef(wf(C)?!1:C);return T.jsx(yQ.input,{type:"checkbox","aria-hidden":!0,defaultChecked:Q??u.current,required:i,disabled:E,name:n,value:s,form:r,...e,tabIndex:-1,ref:h,onClick:fo(I,G=>{D.current&&G.stopPropagation()}),style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function qPI(g){return typeof g=="function"}sP(qPI,"isFunction");function wf(g){return g==="indeterminate"}sP(wf,"isIndeterminate");function LCg(g){return wf(g)?"indeterminate":g?"checked":"unchecked"}sP(LCg,"getState");const roA=z.forwardRef(({className:g,...A},I)=>T.jsx(TPI,{ref:I,className:co("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",g),...A,children:T.jsx(Tko,{className:co("rf-flex rf-items-center rf-justify-center rf-text-current"),children:T.jsx(sF,{className:"rf-h-4 rf-w-4"})})}));roA.displayName=TPI.displayName;const Hb=fmA,Oko=RmA,ZPI=z.forwardRef(({className:g,...A},I)=>T.jsx(TtA,{className:co("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",g),...A,ref:I}));ZPI.displayName=TtA.displayName;const xL=z.forwardRef(({className:g,children:A,showOverlay:I=!0,...e},t)=>T.jsxs(Oko,{children:[T.jsx(ZPI,{className:co(I?"":"rf-hidden")}),T.jsx(ZtA,{ref:t,className:co("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",g),...e,children:A})]}));xL.displayName=ZtA.displayName;const FL=({className:g,...A})=>T.jsx("div",{className:co("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",g),...A});FL.displayName="DialogHeader";const _O=({className:g,...A})=>T.jsx("div",{className:co("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",g),...A});_O.displayName="DialogFooter";const UL=z.forwardRef(({className:g,...A},I)=>T.jsx(NmA,{ref:I,className:co("rf-text-lg rf-font-semibold",g),...A}));UL.displayName=NmA.displayName;const vb=z.forwardRef(({className:g,...A},I)=>T.jsx(xmA,{ref:I,className:co("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",g),...A}));vb.displayName=xmA.displayName;const rpA={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},Wko="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let YCg=null;const _Cg=async()=>(YCg||(YCg=import(Wko)),YCg),Vko=g=>(A,I)=>{const e=new Headers(I?.headers),t={};return e.forEach((o,B)=>{t[B]=o}),fetch(`${g?.apiBase??Jm}/proxy`,{...I,headers:{...t,"X-Target-Url":A.toString(),"X-Sender-Origin":t.origin??"","X-Sender-Host":t.host??"https://easyeda.com","X-Sender-Referer":t.referer??"","X-Sender-User-Agent":t["user-agent"]??"","X-Sender-Cookie":t.cookie??"",authority:t.authority??"","content-type":t["content-type"]??"",...g?.headers}})},jko=async(g,A=10)=>{const I=encodeURIComponent(g),e=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${A}&q=${I}`);if(!e.ok)throw new Error(`JLCPCB API error: ${e.status}`);return(await e.json()).components??[]},zko=g=>({lcscId:g.lcsc,manufacturer:g.mfr,description:g.description,partNumber:`C${g.lcsc}`,package:g.package,price:g.price,stock:g.stock,isBasic:g.is_basic}),OPI=async(g,A)=>{const{fetchEasyEDAComponent:I}=await _Cg();return I(g,{fetch:Vko(A),includeModelMetadata:A?.includeModelMetadata})},Xko=async(g,A)=>{const{convertRawEasyToTsx:I}=await _Cg(),e=await OPI(g,A);return I({rawEasy:e})},$ko=async(g,A)=>{const{EasyEdaJsonSchema:I,convertEasyEdaJsonToCircuitJson:e}=await _Cg(),t=await OPI(g,{...A,includeModelMetadata:!1}),o=I.parse(t);return e(o,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function JL(g){return Array.isArray?Array.isArray(g):VPI(g)==="[object Array]"}function AMo(g){if(typeof g=="string")return g;if(typeof g=="bigint")return g.toString();const A=g+"";return A=="0"&&1/g==-1/0?"-0":A}function bCg(g){return g==null?"":AMo(g)}function GG(g){return typeof g=="string"}function cpA(g){return typeof g=="number"}function gMo(g){return g===!0||g===!1||IMo(g)&&VPI(g)=="[object Boolean]"}function WPI(g){return typeof g=="object"}function IMo(g){return WPI(g)&&g!==null}function NS(g){return g!=null}function hpA(g){return!g.trim().length}function VPI(g){return g==null?g===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(g)}const eMo="Incorrect 'index' type",HCg="Invalid doc index: must be a non-negative integer within the bounds of the docs array",tMo=g=>`Invalid value for key ${g}`,oMo=g=>`Pattern length exceeds max of ${g}.`,BMo=g=>`Missing ${g} property in key`,CMo=g=>`Property 'weight' in key '${g}' must be a positive integer`,QMo="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",jPI=Object.prototype.hasOwnProperty;var iMo=class{constructor(g){this._keys=[],this._keyMap={};let A=0;g.forEach(I=>{const e=zPI(I);this._keys.push(e),this._keyMap[e.id]=e,A+=e.weight}),this._keys.forEach(I=>{I.weight/=A})}get(g){return this._keyMap[g]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function zPI(g){let A=null,I=null,e=null,t=1,o=null;if(GG(g)||JL(g))e=g,A=XPI(g),I=lpA(g);else{if(!jPI.call(g,"name"))throw new Error(BMo("name"));const B=g.name;if(e=B,jPI.call(g,"weight")&&g.weight!==void 0&&(t=g.weight,t<=0))throw new Error(CMo(lpA(B)));A=XPI(B),I=lpA(B),o=g.getFn??null}return{path:A,id:I,weight:t,src:e,getFn:o}}function XPI(g){return JL(g)?g:g.split(".")}function lpA(g){return JL(g)?g.join("."):g}function EMo(g,A){const I=[];let e=!1;const t=(o,B,C,Q)=>{if(NS(o))if(!B[C])I.push(Q!==void 0?{v:o,i:Q}:o);else{const i=o[B[C]];if(!NS(i))return;if(C===B.length-1&&(GG(i)||cpA(i)||gMo(i)||typeof i=="bigint"))I.push(Q!==void 0?{v:bCg(i),i:Q}:bCg(i));else if(JL(i)){e=!0;for(let E=0,n=i.length;E<n;E+=1)t(i[E],B,C+1,E)}else B.length&&t(i,B,C+1,Q)}};return t(g,GG(A)?A.split("."):A,0),e?I:I[0]}const cQ=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(g,A)=>g.score===A.score?g.idx<A.idx?-1:1:g.score<A.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:EMo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function nMo(g){return g>=9&&g<=13||g===32||g===160}function sMo(g=1,A=3){const I=new Map,e=Math.pow(10,A);return{get(t){let o=0,B=!1;for(let Q=0;Q<t.length;Q++)nMo(t.charCodeAt(Q))?B=!1:B||(o++,B=!0);if(o===0&&(o=1),I.has(o))return I.get(o);const C=Math.round(e/Math.pow(o,.5*g))/e;return I.set(o,C),C},clear(){I.clear()}}}var vCg=class{constructor({getFn:g=cQ.getFn,fieldNormWeight:A=cQ.fieldNormWeight}={}){this.norm=sMo(A,3),this.getFn=g,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(g=[]){this.docs=g}setIndexRecords(g=[]){this.records=g}setKeys(g=[]){this.keys=g,this._keysMap={},g.forEach((A,I)=>{this._keysMap[A.id]=I})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const g=this.docs.length;this.records=new Array(g);let A=0;if(GG(this.docs[0]))for(let I=0;I<g;I++){const e=this._createStringRecord(this.docs[I],I);e&&(this.records[A++]=e)}else for(let I=0;I<g;I++)this.records[A++]=this._createObjectRecord(this.docs[I],I);this.records.length=A,this.norm.clear()}add(g,A){if(!Number.isInteger(A)||A<0)throw new Error(HCg);if(GG(g)){const e=this._createStringRecord(g,A);return e&&this.records.push(e),e}const I=this._createObjectRecord(g,A);return this.records.push(I),I}removeAt(g){if(!Number.isInteger(g)||g<0)throw new Error(HCg);for(let A=0,I=this.records.length;A<I;A+=1)if(this.records[A].i===g){this.records.splice(A,1);break}for(let A=0,I=this.records.length;A<I;A+=1)this.records[A].i>g&&(this.records[A].i-=1)}removeAll(g){const A=new Set;for(const e of g)Number.isInteger(e)&&e>=0&&A.add(e);if(A.size===0)return;this.records=this.records.filter(e=>!A.has(e.i));const I=Array.from(A).sort((e,t)=>e-t);for(const e of this.records){let t=0,o=I.length;for(;t<o;){const B=t+o>>>1;I[B]<e.i?t=B+1:o=B}e.i-=t}}getValueForItemAtKeyId(g,A){return g[this._keysMap[A]]}size(){return this.records.length}_createStringRecord(g,A){return!NS(g)||hpA(g)?null:{v:g,i:A,n:this.norm.get(g)}}_createObjectRecord(g,A){const I={i:A,$:{}};for(let e=0,t=this.keys.length;e<t;e++){const o=this.keys[e],B=o.getFn?o.getFn(g):this.getFn(g,o.path);if(NS(B)){if(JL(B)){const C=[];for(let Q=0,i=B.length;Q<i;Q+=1){const E=B[Q];if(NS(E)){if(GG(E)){if(!hpA(E)){const n={v:E,i:Q,n:this.norm.get(E)};C.push(n)}}else if(NS(E.v)){const n=GG(E.v)?E.v:bCg(E.v);if(!hpA(n)){const s={v:n,i:E.i,n:this.norm.get(n)};C.push(s)}}}}I.$[e]=C}else if(GG(B)&&!hpA(B)){const C={v:B,n:this.norm.get(B)};I.$[e]=C}}}return I}toJSON(){return{keys:this.keys.map(({getFn:g,...A})=>A),records:this.records}}};function $PI(g,A,{getFn:I=cQ.getFn,fieldNormWeight:e=cQ.fieldNormWeight}={}){const t=new vCg({getFn:I,fieldNormWeight:e});return t.setKeys(g.map(zPI)),t.setSources(A),t.create(),t}function aMo(g,{getFn:A=cQ.getFn,fieldNormWeight:I=cQ.fieldNormWeight}={}){const{keys:e,records:t}=g,o=new vCg({getFn:A,fieldNormWeight:I});return o.setKeys(e),o.setIndexRecords(t),o}function rMo(g=[],A=cQ.minMatchCharLength){const I=[];let e=-1,t=-1,o=0;for(let B=g.length;o<B;o+=1){const C=g[o];C&&e===-1?e=o:!C&&e!==-1&&(t=o-1,t-e+1>=A&&I.push([e,t]),e=-1)}return g[o-1]&&o-e>=A&&I.push([e,o-1]),I}function cMo(g,A,I,{location:e=cQ.location,distance:t=cQ.distance,threshold:o=cQ.threshold,findAllMatches:B=cQ.findAllMatches,minMatchCharLength:C=cQ.minMatchCharLength,includeMatches:Q=cQ.includeMatches,ignoreLocation:i=cQ.ignoreLocation}={}){if(A.length>32)throw new Error(oMo(32));const E=A.length,n=g.length,s=Math.max(0,Math.min(e,n));let r=o,a=s;const c=(p,k)=>{const S=p/E;if(i)return S;const R=Math.abs(s-k);return t?S+R/t:R?1:S},h=C>1||Q,l=h?Array(n):[];let D;for(;(D=g.indexOf(A,a))>-1;){const p=c(0,D);if(r=Math.min(p,r),a=D+E,h){let k=0;for(;k<E;)l[D+k]=1,k+=1}}a=-1;let d=[],y=1,w=0,u=E+n;const G=1<<E-1;for(let p=0;p<E;p+=1){let k=0,S=u;for(;k<S;)c(p,s+S)<=r?k=S:u=S,S=Math.floor((u-k)/2+k);u=S;let R=Math.max(1,s-S+1);const x=B?n:Math.min(s+S,n)+E,N=Array(x+2);N[x+1]=(1<<p)-1;for(let U=x;U>=R;U-=1){const K=U-1,Y=I[g[K]];if(N[U]=(N[U+1]<<1|1)&Y,p&&(N[U]|=(d[U+1]|d[U])<<1|1|d[U+1]),N[U]&G&&(y=c(p,K),y<=r)){if(r=y,a=K,w=p,a<=s)break;R=Math.max(1,2*s-a)}}if(c(p+1,s)>r)break;d=N}if(h&&a>=0){const p=Math.min(n-1,a+E-1+w);for(let k=a;k<=p;k+=1)I[g[k]]&&(l[k]=1)}const m={isMatch:a>=0,score:Math.max(.001,y)};if(h){const p=rMo(l,C);p.length?Q&&(m.indices=p):m.isMatch=!1}return m}function hMo(g){const A={};for(let I=0,e=g.length;I<e;I+=1){const t=g.charAt(I);A[t]=(A[t]||0)|1<<e-I-1}return A}function TCg(g){if(g.length<=1)return g;g.sort((I,e)=>I[0]-e[0]||I[1]-e[1]);const A=[g[0]];for(let I=1,e=g.length;I<e;I+=1){const t=A[A.length-1],o=g[I];o[0]<=t[1]+1?t[1]=Math.max(t[1],o[1]):A.push(o)}return A}const A4I={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},lMo=new RegExp("["+Object.keys(A4I).join("")+"]","g"),coA=typeof String.prototype.normalize=="function"?g=>g.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(lMo,A=>A4I[A]):g=>g;var qCg=class{constructor(g,{location:A=cQ.location,threshold:I=cQ.threshold,distance:e=cQ.distance,includeMatches:t=cQ.includeMatches,findAllMatches:o=cQ.findAllMatches,minMatchCharLength:B=cQ.minMatchCharLength,isCaseSensitive:C=cQ.isCaseSensitive,ignoreDiacritics:Q=cQ.ignoreDiacritics,ignoreLocation:i=cQ.ignoreLocation}={}){if(this.options={location:A,threshold:I,distance:e,includeMatches:t,findAllMatches:o,minMatchCharLength:B,isCaseSensitive:C,ignoreDiacritics:Q,ignoreLocation:i},g=C?g:g.toLowerCase(),g=Q?coA(g):g,this.pattern=g,this.chunks=[],!this.pattern.length)return;const E=(s,r)=>{this.chunks.push({pattern:s,alphabet:hMo(s),startIndex:r})},n=this.pattern.length;if(n>32){let s=0;const r=n%32,a=n-r;for(;s<a;)E(this.pattern.substr(s,32),s),s+=32;if(r){const c=n-32;E(this.pattern.substr(c),c)}}else E(this.pattern,0)}searchIn(g){const{isCaseSensitive:A,ignoreDiacritics:I,includeMatches:e}=this.options;if(g=A?g:g.toLowerCase(),g=I?coA(g):g,this.pattern===g){if(g.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const a={isMatch:!0,score:0};return e&&(a.indices=[[0,g.length-1]]),a}const{location:t,distance:o,threshold:B,findAllMatches:C,minMatchCharLength:Q,ignoreLocation:i}=this.options,E=[];let n=0,s=!1;this.chunks.forEach(({pattern:a,alphabet:c,startIndex:h})=>{const{isMatch:l,score:D,indices:d}=cMo(g,a,c,{location:t+h,distance:o,threshold:B,findAllMatches:C,minMatchCharLength:Q,includeMatches:e,ignoreLocation:i});l&&(s=!0),n+=D,l&&d&&E.push(...d)});const r={isMatch:s,score:s?n/this.chunks.length:1};return s&&e&&(r.indices=TCg(E)),r}};const DMo=new Set(["fuzzy","include"]);function dMo(g){return g.startsWith("inverse")}const ZCg=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:g=>({type:"exact",search(A){const I=A===g;return{isMatch:I,score:I?0:1,indices:[0,g.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:g=>({type:"include",search(A){let I=0,e;const t=[],o=g.length;for(;(e=A.indexOf(g,I))>-1;)I=e+o,t.push([e,I-1]);const B=!!t.length;return{isMatch:B,score:B?0:1,indices:t}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:g=>({type:"prefix-exact",search(A){const I=A.startsWith(g);return{isMatch:I,score:I?0:1,indices:[0,g.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:g=>({type:"inverse-prefix-exact",search(A){const I=!A.startsWith(g);return{isMatch:I,score:I?0:1,indices:[0,A.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:g=>({type:"inverse-suffix-exact",search(A){const I=!A.endsWith(g);return{isMatch:I,score:I?0:1,indices:[0,A.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:g=>({type:"suffix-exact",search(A){const I=A.endsWith(g);return{isMatch:I,score:I?0:1,indices:[A.length-g.length,A.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:g=>({type:"inverse-exact",search(A){const I=A.indexOf(g)===-1;return{isMatch:I,score:I?0:1,indices:[0,A.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(g,A={})=>{const I=new qCg(g,{location:A.location??cQ.location,threshold:A.threshold??cQ.threshold,distance:A.distance??cQ.distance,includeMatches:A.includeMatches??cQ.includeMatches,findAllMatches:A.findAllMatches??cQ.findAllMatches,minMatchCharLength:A.minMatchCharLength??cQ.minMatchCharLength,isCaseSensitive:A.isCaseSensitive??cQ.isCaseSensitive,ignoreDiacritics:A.ignoreDiacritics??cQ.ignoreDiacritics,ignoreLocation:A.ignoreLocation??cQ.ignoreLocation});return{type:"fuzzy",search(e){return I.searchIn(e)}}}}],g4I=ZCg.length,yMo="\0",wMo="|";function uMo(g){const A=[],I=g.length;let e=0;for(;e<I;){for(;e<I&&g[e]===" ";)e++;if(e>=I)break;let t=e;for(;t<I&&g[t]!==" "&&g[t]!=='"';)t++;if(t<I&&g[t]==='"'){for(t++;t<I;){if(g[t]==='"'){const o=t+1;if(o>=I||g[o]===" "){t++;break}if(g[o]==="$"&&(o+1>=I||g[o+1]===" ")){t+=2;break}}t++}A.push(g.substring(e,t)),e=t}else{for(;t<I&&g[t]!==" ";)t++;A.push(g.substring(e,t)),e=t}}return A}function I4I(g,A){const I=g.match(A);return I?I[1]:null}function GMo(g,A={}){return g.replace(/\\\|/g,yMo).split(wMo).map(I=>{const e=uMo(I.replace(/\u0000/g,"|").trim()).filter(o=>o&&!!o.trim()),t=[];for(let o=0,B=e.length;o<B;o+=1){const C=e[o];let Q=!1,i=-1;for(;!Q&&++i<g4I;){const E=ZCg[i],n=I4I(C,E.multiRegex);n&&(t.push(E.create(n,A)),Q=!0)}if(!Q)for(i=-1;++i<g4I;){const E=ZCg[i],n=I4I(C,E.singleRegex);if(n){t.push(E.create(n,A));break}}}return t})}var mMo=class{constructor(g,{isCaseSensitive:A=cQ.isCaseSensitive,ignoreDiacritics:I=cQ.ignoreDiacritics,includeMatches:e=cQ.includeMatches,minMatchCharLength:t=cQ.minMatchCharLength,ignoreLocation:o=cQ.ignoreLocation,findAllMatches:B=cQ.findAllMatches,location:C=cQ.location,threshold:Q=cQ.threshold,distance:i=cQ.distance}={}){this.query=null,this.options={isCaseSensitive:A,ignoreDiacritics:I,includeMatches:e,minMatchCharLength:t,findAllMatches:B,ignoreLocation:o,location:C,threshold:Q,distance:i},g=A?g:g.toLowerCase(),g=I?coA(g):g,this.pattern=g,this.query=GMo(this.pattern,this.options)}static condition(g,A){return A.useExtendedSearch}searchIn(g){const A=this.query;if(!A)return{isMatch:!1,score:1};const{includeMatches:I,isCaseSensitive:e,ignoreDiacritics:t}=this.options;g=e?g:g.toLowerCase(),g=t?coA(g):g;let o=0;const B=[];let C=0,Q=!1;for(let i=0,E=A.length;i<E;i+=1){const n=A[i];B.length=0,o=0,Q=!1;for(let s=0,r=n.length;s<r;s+=1){const a=n[s],{isMatch:c,indices:h,score:l}=a.search(g);if(c)o+=1,C+=l,dMo(a.type)&&(Q=!0),I&&(DMo.has(a.type)?B.push(...h):B.push(h));else{C=0,o=0,B.length=0,Q=!1;break}}if(o){const s={isMatch:!0,score:C/o};return Q&&(s.hasInverse=!0),I&&(s.indices=TCg(B)),s}}return{isMatch:!1,score:1}}};const OCg=[];function WCg(...g){OCg.push(...g)}function DpA(g,A){for(let I=0,e=OCg.length;I<e;I+=1){const t=OCg[I];if(t.condition(g,A))return new t(g,A)}return new qCg(g,A)}const dpA={AND:"$and",OR:"$or"},VCg={PATH:"$path",PATTERN:"$val"},jCg=g=>!!(g[dpA.AND]||g[dpA.OR]),pMo=g=>!!g[VCg.PATH],kMo=g=>!JL(g)&&WPI(g)&&!jCg(g),e4I=g=>({[dpA.AND]:Object.keys(g).map(A=>({[A]:g[A]}))});function t4I(g,A,{auto:I=!0}={}){const e=t=>{if(GG(t)){const Q={keyId:null,pattern:t};return I&&(Q.searcher=DpA(t,A)),Q}const o=Object.keys(t),B=pMo(t);if(!B&&o.length>1&&!jCg(t))return e(e4I(t));if(kMo(t)){const Q=B?t[VCg.PATH]:o[0],i=B?t[VCg.PATTERN]:t[Q];if(!GG(i))throw new Error(tMo(Q));const E={keyId:lpA(Q),pattern:i};return I&&(E.searcher=DpA(i,A)),E}const C={children:[],operator:o[0]};return o.forEach(Q=>{const i=t[Q];JL(i)&&i.forEach(E=>{C.children.push(e(E))})}),C};return jCg(g)||(g=e4I(g)),e(g)}function zCg(g,{ignoreFieldNorm:A=cQ.ignoreFieldNorm}){let I=1;return g.forEach(({key:e,norm:t,score:o})=>{const B=e?e.weight:null;I*=Math.pow(o===0&&B?Number.EPSILON:o,(B||1)*(A?1:t))}),I}function MMo(g,{ignoreFieldNorm:A=cQ.ignoreFieldNorm}){g.forEach(I=>{I.score=zCg(I.matches,{ignoreFieldNorm:A})})}var SMo=class{constructor(g,A){this.limit=g,this.heap=[],this.comparator=A}get size(){return this.heap.length}insert(g){this.size<this.limit?(this.heap.push(g),this._bubbleUp(this.size-1)):this.comparator(g,this.heap[0])<0&&(this.heap[0]=g,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(g){const A=this.heap;for(;g>0;){const I=g-1>>1;if(this.comparator(A[g],A[I])<=0)break;const e=A[g];A[g]=A[I],A[I]=e,g=I}}_sinkDown(g){const A=this.heap,I=A.length;let e=g;do{g=e;const t=2*g+1,o=2*g+2;if(t<I&&this.comparator(A[t],A[e])>0&&(e=t),o<I&&this.comparator(A[o],A[e])>0&&(e=o),e!==g){const B=A[g];A[g]=A[e],A[e]=B}}while(e!==g)}};function fMo(g){const A=[];return g.matches.forEach(I=>{if(!NS(I.indices)||!I.indices.length)return;const e={indices:I.indices,value:I.value};I.key&&(e.key=I.key.id),I.idx>-1&&(e.refIndex=I.idx),A.push(e)}),A}function RMo(g,A,{includeMatches:I=cQ.includeMatches,includeScore:e=cQ.includeScore}={}){return g.map(t=>{const{idx:o}=t,B={item:A[o],refIndex:o};return I&&(B.matches=fMo(t)),e&&(B.score=t.score),B})}const NMo=/[\p{L}\p{M}\p{N}_]+/gu,o4I=new WeakSet;function xMo(g){o4I.has(g)||(o4I.add(g),console.warn(`[Fuse] tokenize regex ${g} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function FMo(g){if(typeof g=="function"){let A=!1;return I=>{const e=g(I);if(!A&&(A=!0,!Array.isArray(e)||e.some(t=>typeof t!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(e)?"array containing non-strings":typeof e}.`);return e}}return g instanceof RegExp?(g.global||xMo(g),A=>A.match(g)||[]):A=>A.match(NMo)||[]}function XCg({isCaseSensitive:g=!1,ignoreDiacritics:A=!1,tokenize:I}={}){const e=FMo(I);return{tokenize(t){return g||(t=t.toLowerCase()),A&&(t=coA(t)),e(t)}}}var UMo=class{static condition(g,A){return A.useTokenSearch}constructor(g,A){this.options=A,this.analyzer=XCg({isCaseSensitive:A.isCaseSensitive,ignoreDiacritics:A.ignoreDiacritics,tokenize:A.tokenize});const I=this.analyzer.tokenize(g),{df:e,fieldCount:t}=A._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const o of I){this.termSearchers.push(new qCg(o,{location:A.location,threshold:A.threshold,distance:A.distance,includeMatches:A.includeMatches,findAllMatches:A.findAllMatches,minMatchCharLength:A.minMatchCharLength,isCaseSensitive:A.isCaseSensitive,ignoreDiacritics:A.ignoreDiacritics,ignoreLocation:!0}));const B=e.get(o)||0,C=Math.log(1+(t-B+.5)/(B+.5));this.idfWeights.push(C)}this.combineAll=A.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(g){if(!this.termSearchers.length)return{isMatch:!1,score:1};const A=[];let I=0,e=0,t=0,o=0;const B=this.combineAll&&!this.useMask?new Set:null;for(let i=0;i<this.termSearchers.length;i++){const E=this.termSearchers[i].searchIn(g),n=this.idfWeights[i];e+=n,E.isMatch&&(t++,I+=n*(1-E.score),E.indices&&A.push(...E.indices),this.combineAll&&(this.useMask?o|=1<<i:B.add(i)))}if(t===0)return{isMatch:!1,score:1};const C=e>0?1-I/e:0,Q={isMatch:!0,score:Math.max(.001,C)};return this.options.includeMatches&&A.length&&(Q.indices=TCg(A)),this.combineAll&&(this.useMask?Q.matchedMask=o:Q.matchedTerms=B,Q.termCount=this.numTerms),Q}};function $Cg(g,A,I,e){const t=e.tokenize(A);if(!t.length)return;g.fieldCount++,g.docFieldCount.set(I,(g.docFieldCount.get(I)||0)+1);const o=new Set(t);let B=g.docTermFieldHits.get(I);B||(B=new Map,g.docTermFieldHits.set(I,B));for(const C of o)B.set(C,(B.get(C)||0)+1),g.df.set(C,(g.df.get(C)||0)+1)}function B4I(g,A,I,e){const{i:t,v:o,$:B}=A;if(o!==void 0){$Cg(g,o,t,e);return}if(B)for(let C=0;C<I;C++){const Q=B[C];if(Q)if(Array.isArray(Q))for(const i of Q)$Cg(g,i.v,t,e);else $Cg(g,Q.v,t,e)}}function JMo(g,A,I){const e={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const t of g)B4I(e,t,A,I);return e}function PMo(g,A,I,e){B4I(g,A,I,e)}function KMo(g,A){const I=g.docFieldCount.get(A);if(I===void 0)return;g.fieldCount-=I,g.docFieldCount.delete(A);const e=g.docTermFieldHits.get(A);if(e){for(const[t,o]of e){const B=(g.df.get(t)||0)-o;B<=0?g.df.delete(t):g.df.set(t,B)}g.docTermFieldHits.delete(A)}}function C4I(g,A){if(A.length===0)return;const I=Array.from(new Set(A)).sort((C,Q)=>C-Q);for(const C of I)KMo(g,C);const e=C=>{let Q=0,i=I.length;for(;Q<i;){const E=Q+i>>>1;I[E]<C?Q=E+1:i=E}return C-Q},t=I[0],o=new Map;for(const[C,Q]of g.docFieldCount)o.set(C>t?e(C):C,Q);g.docFieldCount=o;const B=new Map;for(const[C,Q]of g.docTermFieldHits)B.set(C>t?e(C):C,Q);g.docTermFieldHits=B}var PL=class{constructor(g,A,I){this.options={...cQ,...A},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new iMo(this.options.keys),this._docs=g,this._myIndex=null,this._invertedIndex=null,this.setCollection(g,I),this._lastQuery=null,this._lastSearcher=null}_getSearcher(g){if(this._lastQuery===g)return this._lastSearcher;const A=DpA(g,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=g,this._lastSearcher=A,A}setCollection(g,A){if(this._docs=g,A&&!(A instanceof vCg))throw new Error(eMo);if(this._myIndex=A||$PI(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const I=XCg({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=JMo(this._myIndex.records,this._myIndex.keys.length,I)}this._invalidateSearcherCache()}add(g){if(!NS(g))return;this._docs.push(g);const A=this._myIndex.add(g,this._docs.length-1);if(this._invertedIndex&&A){const I=XCg({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});PMo(this._invertedIndex,A,this._myIndex.keys.length,I)}this._invalidateSearcherCache()}remove(g=()=>!1){const A=[],I=[];for(let e=0,t=this._docs.length;e<t;e+=1)g(this._docs[e],e)&&(A.push(this._docs[e]),I.push(e));if(I.length){this._invertedIndex&&C4I(this._invertedIndex,I);const e=new Set(I);this._docs=this._docs.filter((t,o)=>!e.has(o)),this._myIndex.removeAll(I),this._invalidateSearcherCache()}return A}removeAt(g){if(!Number.isInteger(g)||g<0||g>=this._docs.length)throw new Error(HCg);this._invertedIndex&&C4I(this._invertedIndex,[g]);const A=this._docs.splice(g,1)[0];return this._myIndex.removeAt(g),this._invalidateSearcherCache(),A}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(g=>this._keyStore.get(g.id)||g)}search(g,A){const{limit:I=-1}=A||{},{includeMatches:e,includeScore:t,shouldSort:o,sortFn:B,ignoreFieldNorm:C}=this.options;if(GG(g)&&!g.trim()){let s=this._docs.map((r,a)=>({item:r,refIndex:a}));return cpA(I)&&I>-1&&(s=s.slice(0,I)),s}const Q=o&&cpA(I)&&I>0&&GG(g),i=B,E=(s,r)=>i(s,r)||s.idx-r.idx;let n;if(Q){const s=new SMo(I,E);GG(this._docs[0])?this._searchStringList(g,{heap:s,ignoreFieldNorm:C}):this._searchObjectList(g,{heap:s,ignoreFieldNorm:C}),n=s.extractSorted()}else n=GG(g)?GG(this._docs[0])?this._searchStringList(g):this._searchObjectList(g):this._searchLogical(g),MMo(n,{ignoreFieldNorm:C}),o&&n.sort(GG(g)?E:i),cpA(I)&&I>-1&&(n=n.slice(0,I));return RMo(n,this._docs,{includeMatches:e,includeScore:t})}_searchStringList(g,{heap:A,ignoreFieldNorm:I}={}){const e=this._getSearcher(g),t=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:o}=this._myIndex,B=A?null:[];return o.forEach(({v:C,i:Q,n:i})=>{if(!NS(C))return;const E=e.searchIn(C);if(E.isMatch){const n={score:E.score,value:C,norm:i,indices:E.indices};t&&(n.matchedMask=E.matchedMask,n.matchedTerms=E.matchedTerms,n.termCount=E.termCount);const s=[n];if(!t||this._coversAllTokens(s)){const r={item:C,idx:Q,matches:s};A?(r.score=zCg(r.matches,{ignoreFieldNorm:I}),A.insert(r)):B.push(r)}}}),B}_searchLogical(g){const A=t4I(g,this.options),I=this._normalizedKeys(),e=(C,Q,i)=>{if(!("children"in C)){const{keyId:r,searcher:a}=C;let c;return r===null?(c=[],I.forEach((h,l)=>{c.push(...this._findMatches({key:h,value:Q[l],searcher:a}))})):c=this._findMatches({key:this._keyStore.get(r),value:this._myIndex.getValueForItemAtKeyId(Q,r),searcher:a}),c&&c.length?[{idx:i,item:Q,matches:c}]:[]}const{children:E,operator:n}=C,s=[];for(let r=0,a=E.length;r<a;r+=1){const c=E[r],h=e(c,Q,i);if(h.length)s.push(...h);else if(n===dpA.AND)return[]}return s},t=this._myIndex.records,o=new Map,B=[];return t.forEach(({$:C,i:Q})=>{if(NS(C)){const i=e(A,C,Q);i.length&&(o.has(Q)||(o.set(Q,{idx:Q,item:C,matches:[]}),B.push(o.get(Q))),i.forEach(({matches:E})=>{o.get(Q).matches.push(...E)}))}}),B}_searchObjectList(g,{heap:A,ignoreFieldNorm:I}={}){const e=this._getSearcher(g),t=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:o}=this._myIndex,B=this._normalizedKeys(),C=A?null:[];return o.forEach(({$:Q,i})=>{if(!NS(Q))return;const E=[];let n=!1,s=!1;if(B.forEach((r,a)=>{const c=this._findMatches({key:r,value:Q[a],searcher:e});c.length?(E.push(...c),c[0].hasInverse&&(s=!0)):n=!0}),!(s&&n)&&E.length&&(!t||this._coversAllTokens(E))){const r={idx:i,item:Q,matches:E};A?(r.score=zCg(r.matches,{ignoreFieldNorm:I}),A.insert(r)):C.push(r)}}),C}_findMatches({key:g,value:A,searcher:I}){if(!NS(A))return[];const e=[];if(JL(A))A.forEach(({v:t,i:o,n:B})=>{if(!NS(t))return;const C=I.searchIn(t);if(C.isMatch){const Q={score:C.score,key:g,value:t,idx:o,norm:B,indices:C.indices,hasInverse:C.hasInverse};C.termCount!==void 0&&(Q.matchedMask=C.matchedMask,Q.matchedTerms=C.matchedTerms,Q.termCount=C.termCount),e.push(Q)}});else{const{v:t,n:o}=A,B=I.searchIn(t);if(B.isMatch){const C={score:B.score,key:g,value:t,norm:o,indices:B.indices,hasInverse:B.hasInverse};B.termCount!==void 0&&(C.matchedMask=B.matchedMask,C.matchedTerms=B.matchedTerms,C.termCount=B.termCount),e.push(C)}}return e}_coversAllTokens(g){const A=g.length?g[0].termCount:void 0;if(A===void 0)return!0;if(A<=31){let e=0;for(let t=0;t<g.length;t++)e|=g[t].matchedMask||0;return e===2**A-1}const I=new Set;for(let e=0;e<g.length;e++){const t=g[e].matchedTerms;if(t)for(const o of t)I.add(o)}return I.size===A}};PL.version="7.5.0",PL.createIndex=$PI,PL.parseIndex=aMo,PL.config=cQ,PL.match=function(g,A,I){if(I&&I.useTokenSearch)throw new Error(QMo);return DpA(g,{...cQ,...I}).searchIn(A)},PL.parseQuery=t4I,WCg(mMo),WCg(UMo),PL.use=function(...g){g.forEach(A=>WCg(A))};var LMo=PL;const YMo="https://kicad-mod-cache.tscircuit.com";let AQg=null,hoA=null,gQg=null;const _Mo=async()=>AQg||hoA||(hoA=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(g=>g.json()).then(g=>(AQg=g,hoA=null,g)),hoA),bMo=async(g,A=20)=>{const I=await _Mo();return gQg||(gQg=new LMo(I)),gQg.search(g).slice(0,A).map(e=>e.item)},HMo=g=>{const A=g.replace(".pretty/","/").replace(".kicad_mod",""),I=`kicad:${A}`;return{path:g,qualifiedName:I,description:A}},vMo=g=>g.replace(/^\/+/,"").split("/").map(A=>encodeURIComponent(A)).join("/"),TMo=async g=>{const A=await fetch(`${YMo}/${vMo(g)}`);if(!A.ok)throw new Error(`KiCad footprint fetch failed: ${A.status}`);const I=await A.text(),{KicadFootprintToCircuitJsonConverter:e}=await RS("kicad-to-circuit-json"),t=new e;return t.addFile(g.split("/").pop()??"selected-footprint.kicad_mod",I),t.runUntilFinished(),t.getOutput()},Q4I=g=>g?.source==="jlcpcb"||g?.source==="kicad",qMo=async(g,A)=>{if(g.source==="jlcpcb")return $ko(g.component.partNumber,A?.jlcpcb);if(g.source==="kicad")return TMo(g.footprint.path);throw new Error("Footprint preview is not available for this source")},ZMo=({query:g,placeholder:A,isSearching:I,onQueryChange:e,onSubmit:t})=>{const o=z.useCallback(B=>{B.key==="Enter"&&(B.preventDefault(),t())},[t]);return T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[T.jsxs("div",{className:"rf-relative rf-flex-grow",children:[T.jsx(Wog,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),T.jsx(yCg,{placeholder:A,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:g,onChange:B=>e(B.target.value),onKeyDown:o})]}),T.jsx(si,{onClick:t,disabled:I||g.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:I?T.jsx(mS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):T.jsxs(T.Fragment,{children:[T.jsx(Wog,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),T.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},OMo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),WMo=g=>OMo.format(g),i4I=g=>{switch(g.source){case"tscircuit.com":{const A=g.package;return`tscircuit-${A.package_id??`${A.org_owner_tscircuit_handle??"unknown"}-${A.unscoped_name??A.name??"package"}`}`}case"jlcpcb":return`jlc-${g.component.lcscId}`;case"kicad":return`kicad-${g.footprint.path}`;default:return"unknown"}},VMo=g=>{switch(g.source){case"tscircuit.com":return g.package.unscoped_name;case"jlcpcb":return g.component.isDirectLookup?g.component.partNumber:g.component.manufacturer;case"kicad":return g.footprint.qualifiedName}},jMo=g=>{switch(g.source){case"tscircuit.com":return g.package.description||(g.package.org_owner_tscircuit_handle?`Component by ${g.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return g.component.description;case"kicad":return g.footprint.description}},zMo=g=>{switch(g.source){case"tscircuit.com":return g.package.name;case"jlcpcb":return g.component.isDirectLookup?void 0:g.component.partNumber;case"kicad":return}},XMo=({results:g,selected:A,onSelect:I,onShowDetails:e})=>{const t=A?i4I(A):null;return T.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:g.map(o=>{const B=i4I(o),C=t===B,Q=VMo(o),i=jMo(o),E=zMo(o),n=o.source==="jlcpcb"?o.component.stock:null,s=o.source==="jlcpcb"?o.component.price:null,r=o.source==="jlcpcb"?o.component.isBasic:null,a=o.source==="jlcpcb"?o.component.isDirectLookup:!1;return T.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${C?"rf-bg-zinc-100":""}`,onClick:()=>I(o),children:[T.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[T.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[T.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[Q,o.source==="jlcpcb"&&r!=null&&T.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${r?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:r?"Basic":"Extended"}),a&&T.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),o.source==="tscircuit.com"&&o.package.is_private&&T.jsx(hco,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),o.source==="jlcpcb"&&n!=null?T.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[n.toLocaleString()," in stock"]}):null]}),T.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[E?T.jsx("span",{className:"rf-mr-2",children:E}):null,i]})]}),T.jsxs("div",{children:[o.source==="tscircuit.com"&&e?T.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:T.jsx(si,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:c=>{c.stopPropagation(),e(o)},children:"See Details"})}):o.source==="jlcpcb"&&n!=null?T.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[n.toLocaleString()," in stock"]}):null,s!=null&&T.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:WMo(s)})]})]},B)})})},$Mo=({circuitJson:g,error:A,isLoading:I,height:e})=>T.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:e},children:I?T.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:e},children:[T.jsx(mS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):A?T.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:e},children:T.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[T.jsx(Zog,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),T.jsx("span",{children:A})]})}):g?T.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:T.jsx(vog,{circuitJson:g,height:e,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):T.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:e},children:"No preview"})}),E4I={importComponentDialog:101,importComponentDetailsDialog:102},ASo=({packageResult:g,isOpen:A,onOpenChange:I,isLoading:e,details:t,previewTab:o,onPreviewTabChange:B,isSubmitting:C,onImport:Q})=>{const i=g?.package??null,E=i?.latest_pcb_preview_image_url,n=i?.latest_sch_preview_image_url,s=i?.latest_cad_preview_image_url,r=i?.unscoped_name?.split("/").pop()??i?.unscoped_name,a=i?.org_owner_tscircuit_handle??void 0,c=a?`https://tscircuit.com/${a}`:void 0,h=a&&r?`https://tscircuit.com/${a}/${r}`:void 0;return T.jsx(Hb,{open:A,onOpenChange:I,children:T.jsxs(xL,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:E4I.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[T.jsx(FL,{className:"rf-pb-4 rf-border-b",children:T.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:T.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[T.jsx(UL,{className:"rf-text-xl rf-font-semibold rf-truncate",children:r}),T.jsx(vb,{children:i?.description})]})})}),T.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[a?T.jsxs("div",{children:[T.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),T.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:c?T.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:a}):a})]}):null,(s||E||n)&&T.jsx(T.Fragment,{children:T.jsxs("div",{children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),T.jsxs(jvA,{value:o,onValueChange:l=>B(l),children:[T.jsxs(vDA,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[E&&T.jsx(mx,{value:"pcb",children:"PCB"}),n&&T.jsx(mx,{value:"schematic",children:"Schematic"}),s&&T.jsx(mx,{value:"3d",children:"3D"})]}),T.jsxs("div",{className:"rf-mt-4",children:[T.jsx(Fy,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:E?T.jsx("img",{src:E,alt:`${r??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),T.jsx(Fy,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:n?T.jsx("img",{src:n,alt:`${r??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),T.jsx(Fy,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:s?T.jsx("img",{src:s,alt:`${r??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),t?.ai_description?T.jsxs("section",{children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),T.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:T.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:t.ai_description})})]}):null,t?.ai_usage_instructions?T.jsxs("section",{children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),T.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:T.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:t.ai_usage_instructions})})]}):null,e?T.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[T.jsx(mS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),T.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),T.jsxs(_O,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[T.jsx("div",{className:"rf-flex-1",children:h?T.jsxs(si,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(h,"_blank"),children:[T.jsx(ico,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),T.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[T.jsx(si,{variant:"outline",onClick:()=>I(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),T.jsx(si,{onClick:Q,disabled:C,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:C?T.jsx(mS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},gSo=()=>{const[g,A]=z.useState(null),[I,e]=z.useState(!1),t=z.useCallback(async(B,C)=>{e(!0);try{const Q=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${B}/${C}`)}`);if(!Q.ok)throw new Error(`Failed to load package details: ${Q.status}`);const i=await Q.json();A(i.package??null)}catch(Q){console.error("Failed to fetch package details",Q),A(null)}finally{e(!1)}},[]),o=z.useCallback(()=>{A(null),e(!1)},[]);return{details:g,isLoading:I,fetchDetails:t,reset:o}},ISo=(g,A)=>{const[I,e]=z.useState({circuitJson:null,error:null,isLoading:!1});return z.useEffect(()=>{if(!g||!Q4I(g)){e({circuitJson:null,error:null,isLoading:!1});return}let t=!1;return e({circuitJson:null,error:null,isLoading:!0}),qMo(g,A).then(o=>{t||e({circuitJson:o,error:null,isLoading:!1})}).catch(o=>{t||e({circuitJson:null,error:o instanceof Error?o.message:"Failed to load footprint preview",isLoading:!1})}),()=>{t=!0}},[g,A]),I},eSo=async(g,A)=>{const I={"Content-Type":"application/json"};A&&(I.Authorization=`Bearer ${A}`);const e=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:I,body:JSON.stringify({query:g})});if(!e.ok)throw new Error(`tscircuit registry error: ${e.status}`);return(await e.json()).packages??[]},tSo=({sessionToken:g})=>{const[A,I]=z.useState([]),[e,t]=z.useState(!1),[o,B]=z.useState(null),[C,Q]=z.useState(!1),i=z.useCallback(async n=>{const s=n.trim();if(!s)return[];t(!0),B(null);try{const a=(await eSo(s,g)).map(c=>({source:"tscircuit.com",package:c}));return I(a),a}catch(r){return console.error("Error searching tscircuit packages",r),I([]),B(r instanceof Error?r.message:"Failed to search tscircuit packages"),[]}finally{t(!1),Q(!0)}},[g]),E=z.useCallback(()=>{I([]),t(!1),B(null),Q(!1)},[]);return{results:A,isSearching:e,error:o,hasSearched:C,search:i,reset:E}},oSo=g=>{const A=/^C(\d+)$/i.exec(g.trim());if(!A)return null;const I=Number(A[1]);if(!Number.isSafeInteger(I))return null;const e=`C${A[1]}`;return{source:"jlcpcb",component:{lcscId:I,manufacturer:e,partNumber:e,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},n4I=(g,A)=>{const I=oSo(g);return I?A.some(t=>t.component.partNumber.toUpperCase()===I.component.partNumber)?A:[I,...A]:A},BSo=g=>{const A=g.trim();return/^C\d+/i.test(A)?A.replace(/^C/i,""):A},CSo=()=>{const[g,A]=z.useState([]),[I,e]=z.useState(!1),[t,o]=z.useState(null),[B,C]=z.useState(!1),Q=z.useCallback(async E=>{const n=BSo(E);if(!n)return[];e(!0),o(null);try{const s=await jko(n,10),r=n4I(E,s.map(a=>({source:"jlcpcb",component:zko(a)})));return A(r),r}catch(s){console.error("Error searching JLCPCB components",s);const r=n4I(E,[]);return A(r),o(r.length>0?null:s instanceof Error?s.message:"Failed to search JLCPCB components"),r}finally{e(!1),C(!0)}},[]),i=z.useCallback(()=>{A([]),e(!1),o(null),C(!1)},[]);return{results:g,isSearching:I,error:t,hasSearched:B,search:Q,reset:i}},QSo=()=>{const[g,A]=z.useState([]),[I,e]=z.useState(!1),[t,o]=z.useState(null),[B,C]=z.useState(!1),Q=z.useCallback(async E=>{const n=E.trim();if(!n)return[];e(!0),o(null);try{const r=(await bMo(n,20)).map(a=>({source:"kicad",footprint:HMo(a)}));return A(r),r}catch(s){return console.error("Error searching KiCad footprints",s),A([]),o(s instanceof Error?s.message:"Failed to search KiCad footprints"),[]}finally{e(!1),C(!0)}},[]),i=z.useCallback(()=>{A([]),e(!1),o(null),C(!1)},[]);return{results:g,isSearching:I,error:t,hasSearched:B,search:Q,reset:i}},iSo=({onTscircuitPackageSelected:g,onJlcpcbComponentTsxLoaded:A,onKicadStringSelected:I})=>{const e=[];return g&&e.push("tscircuit.com"),A&&e.push("jlcpcb"),I&&e.push("kicad"),e},ESo=({isOpen:g,onClose:A,jlcpcbProxyRequestHeaders:I,onKicadStringSelected:e,onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:o,jlcpcbProxyApiBase:B,tscircuitSessionToken:C})=>{noA();const Q=z.useMemo(()=>iSo({onKicadStringSelected:e,onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:o}),[e,t,o]),i=Q.length>0,E=Q.length===1,[n,s]=z.useState(Q[0]??"tscircuit.com"),[r,a]=z.useState(""),[c,h]=z.useState(null),{results:l,isSearching:D,error:d,hasSearched:y,search:w,reset:u}=tSo({sessionToken:C}),{results:G,isSearching:m,error:p,hasSearched:k,search:S,reset:R}=CSo(),{results:x,isSearching:N,error:U,hasSearched:K,search:Y,reset:_}=QSo(),{details:Z,isLoading:V,fetchDetails:W,reset:q}=gSo(),[X,tA]=z.useState(null),[IA,QA]=z.useState(!1),[sA,DA]=z.useState("pcb"),[CA,hA]=z.useState(null),[nA,aA]=z.useState(!1),SA=z.useMemo(()=>({jlcpcb:{headers:I,apiBase:B}}),[B,I]),{circuitJson:FA,error:rA,isLoading:NA}=ISo(c,SA),RA=Q4I(c);z.useEffect(()=>{hA(null)},[c]);const xA=z.useCallback(()=>{u(),R(),_(),h(null)},[R,_,u]);z.useEffect(()=>{g||(xA(),a(""),QA(!1),tA(null),hA(null))},[g,xA]),z.useEffect(()=>{a(""),h(null),n==="tscircuit.com"?u():n==="jlcpcb"?R():n==="kicad"&&_()},[n,R,_,u]);const bA=kA=>{h(kA),tA(kA),DA("pcb"),QA(!0),q();const OA=kA.package.org_owner_tscircuit_handle,$A=kA.package.unscoped_name;if(OA&&$A){const og=$A.split("/").pop()??$A;W(OA,og)}},JA=async()=>{r.trim()&&(h(null),n==="tscircuit.com"?await w(r):n==="jlcpcb"?await S(r):n==="kicad"&&await Y(r))},mA=async kA=>{try{if(hA(null),aA(!0),kA.source==="kicad"){if(!e)throw new Error("KiCad handler not provided");await e({result:kA,footprint:kA.footprint.qualifiedName})}else if(kA.source==="jlcpcb"){if(!o)throw new Error("JLCPCB handler not provided");const OA=await Xko(kA.component.partNumber,{headers:I,apiBase:B});await o({result:kA,tsx:OA})}else if(kA.source==="tscircuit.com"){if(!t)throw new Error("tscircuit package handler not provided");const OA=kA.package.org_owner_tscircuit_handle,$A=kA.package.unscoped_name;if(!OA||!$A)throw new Error("Missing package metadata");const og=$A.split("/").pop()??$A,dg=`@tsci/${OA}.${og}`;await t({result:kA,fullPackageName:dg})}return!0}catch(OA){return console.error("Failed to import component",OA),hA(OA instanceof Error?OA.message:"Failed to import component"),!1}finally{aA(!1)}};let LA=[],dA=!1,HA=null,WA=!1;n==="tscircuit.com"?(LA=l,dA=D,HA=d,WA=y):n==="jlcpcb"?(LA=G,dA=m,HA=p,WA=k):n==="kicad"&&(LA=x,dA=N,HA=U,WA=K);const Qg=async()=>{if(!c)return;await mA(c)&&(A(),xA(),a(""))},YA=kA=>{kA||A()},uA=kA=>{QA(kA),kA||tA(null)};return T.jsxs(Hb,{open:g,onOpenChange:YA,children:[T.jsxs(xL,{style:{width:"calc(100vw - 2rem)",maxWidth:RA?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:E4I.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[T.jsxs(FL,{children:[T.jsxs(UL,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",E?rpA[n].label:""," ","Component"]}),T.jsx(vb,{className:"rf-text-sm",children:i?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),i?T.jsxs(jvA,{value:n,onValueChange:kA=>s(kA),className:"rf-min-w-0 rf-w-full",children:[!E&&T.jsx(vDA,{className:"rf-flex rf-w-full rf-gap-2",children:Q.map(kA=>T.jsx(mx,{value:kA,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:rpA[kA].label},kA))}),T.jsxs("div",{className:"rf-min-w-0",style:RA?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[T.jsxs("div",{className:"rf-min-w-0",children:[T.jsx(ZMo,{query:r,placeholder:rpA[n].placeholder,isSearching:dA,onQueryChange:a,onSubmit:JA}),T.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:dA?T.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[T.jsx(mS,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),T.jsx("p",{children:"Searching..."})]}):LA.length>0?T.jsx(XMo,{results:LA,selected:c,onSelect:h,onShowDetails:n==="tscircuit.com"?bA:void 0}):T.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:HA?`Error: ${HA}`:WA?rpA[n].emptyMessage:"Enter a search term to find components"})})]}),RA?T.jsx("div",{className:"rf-mt-4",children:T.jsx($Mo,{circuitJson:FA,error:rA,isLoading:NA,height:325})}):null]})]}):null,CA?T.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:CA}):null,T.jsxs(_O,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[T.jsx(si,{variant:"outline",onClick:A,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),T.jsx(si,{onClick:Qg,disabled:!c||nA,className:"rf-order-1 sm:rf-order-2",children:nA?T.jsx(mS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),T.jsx(ASo,{packageResult:X,isOpen:IA,onOpenChange:uA,isLoading:V,details:Z,previewTab:sA,onPreviewTabChange:kA=>DA(kA),isSubmitting:nA,onImport:()=>{X&&mA(X).then(kA=>{kA&&(QA(!1),A(),xA(),a(""))})}})]})},nSo=g=>{const A=g.match(/export const (\w+) =/);if(!A)throw new Error("Could not determine component name from TSX contents");return A[1]},s4I=g=>{const A=Kc(B=>B.pushEvent),I=Kc(B=>B.upsertFile),e=async({result:B,fullPackageName:C})=>{const i=B.package.unscoped_name??B.package.name;await LC.promise(A({event_type:"INSTALL_PACKAGE",full_package_name:C}),{loading:`Requesting install for "${i}"`,success:`Install requested for "${i}"`,error:E=>`Failed to request install: ${E instanceof Error?E.message:String(E)}`})},t=async({footprint:B})=>{await LC.promise(navigator.clipboard.writeText(B),{loading:`Copying "${B}"`,success:`Copied "${B}" to clipboard`,error:C=>`Failed to copy footprint: ${C instanceof Error?C.message:String(C)}`})},o=async({result:B,tsx:C})=>{const i=`imports/${nSo(C)}.tsx`;await LC.promise(I(i,C),{loading:`Importing ${B.component.partNumber}`,success:`Imported to "${i}"`,error:E=>`Failed to import component: ${E instanceof Error?E.message:String(E)}`})};return T.jsx(ESo,{...g,onTscircuitPackageSelected:e,onKicadStringSelected:t,onJlcpcbComponentTsxLoaded:o})};s4I.displayName="ImportComponentDialogForCli";const sSo=async({circuitJson:g,projectName:A})=>{const{convertCircuitJsonToAltiumZip:I}=await Promise.resolve().then(()=>xTo),e=await I(g,A);return new Blob([new Uint8Array(e)],{type:"application/zip"})},aSo=async({circuitJson:g,projectName:A})=>{await LC.promise((async()=>{const I=await sSo({circuitJson:g,projectName:A});bk(I,{fileName:`${A}_altium_project.zip`})})(),{loading:"Generating Altium project...",success:"Altium project ZIP ready",error:I=>`Failed to generate Altium project: ${I instanceof Error?I.message:String(I)}`})};var IQg={exports:{}},a4I;function rSo(){return a4I||(a4I=1,(function(g,A){var I={env:{},version:""};(function(e){g.exports=e()})(function(){return(function e(t,o,B){function C(E,n){if(!o[E]){if(!t[E]){var s=typeof rU=="function"&&rU;if(!n&&s)return s(E,!0);if(Q)return Q(E,!0);var r=new Error("Cannot find module '"+E+"'");throw r.code="MODULE_NOT_FOUND",r}var a=o[E]={exports:{}};t[E][0].call(a.exports,function(c){var h=t[E][1][c];return C(h||c)},a,a.exports,e,t,o,B)}return o[E].exports}for(var Q=typeof rU=="function"&&rU,i=0;i<B.length;i++)C(B[i]);return C})({1:[function(e,t,o){var B=e("./utils"),C=e("./support"),Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(i){for(var E,n,s,r,a,c,h,l=[],D=0,d=i.length,y=d,w=B.getTypeOf(i)!=="string";D<i.length;)y=d-D,s=w?(E=i[D++],n=D<d?i[D++]:0,D<d?i[D++]:0):(E=i.charCodeAt(D++),n=D<d?i.charCodeAt(D++):0,D<d?i.charCodeAt(D++):0),r=E>>2,a=(3&E)<<4|n>>4,c=1<y?(15&n)<<2|s>>6:64,h=2<y?63&s:64,l.push(Q.charAt(r)+Q.charAt(a)+Q.charAt(c)+Q.charAt(h));return l.join("")},o.decode=function(i){var E,n,s,r,a,c,h=0,l=0,D="data:";if(i.substr(0,D.length)===D)throw new Error("Invalid base64 input, it looks like a data url.");var d,y=3*(i=i.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(i.charAt(i.length-1)===Q.charAt(64)&&y--,i.charAt(i.length-2)===Q.charAt(64)&&y--,y%1!=0)throw new Error("Invalid base64 input, bad content length.");for(d=C.uint8array?new Uint8Array(0|y):new Array(0|y);h<i.length;)E=Q.indexOf(i.charAt(h++))<<2|(r=Q.indexOf(i.charAt(h++)))>>4,n=(15&r)<<4|(a=Q.indexOf(i.charAt(h++)))>>2,s=(3&a)<<6|(c=Q.indexOf(i.charAt(h++))),d[l++]=E,a!==64&&(d[l++]=n),c!==64&&(d[l++]=s);return d}},{"./support":30,"./utils":32}],2:[function(e,t,o){var B=e("./external"),C=e("./stream/DataWorker"),Q=e("./stream/Crc32Probe"),i=e("./stream/DataLengthProbe");function E(n,s,r,a,c){this.compressedSize=n,this.uncompressedSize=s,this.crc32=r,this.compression=a,this.compressedContent=c}E.prototype={getContentWorker:function(){var n=new C(B.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new i("data_length")),s=this;return n.on("end",function(){if(this.streamInfo.data_length!==s.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),n},getCompressedWorker:function(){return new C(B.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},E.createWorkerFrom=function(n,s,r){return n.pipe(new Q).pipe(new i("uncompressedSize")).pipe(s.compressWorker(r)).pipe(new i("compressedSize")).withStreamInfo("compression",s)},t.exports=E},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,o){var B=e("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new B("STORE compression")},uncompressWorker:function(){return new B("STORE decompression")}},o.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,o){var B=e("./utils"),C=(function(){for(var Q,i=[],E=0;E<256;E++){Q=E;for(var n=0;n<8;n++)Q=1&Q?3988292384^Q>>>1:Q>>>1;i[E]=Q}return i})();t.exports=function(Q,i){return Q!==void 0&&Q.length?B.getTypeOf(Q)!=="string"?(function(E,n,s,r){var a=C,c=r+s;E^=-1;for(var h=r;h<c;h++)E=E>>>8^a[255&(E^n[h])];return-1^E})(0|i,Q,Q.length,0):(function(E,n,s,r){var a=C,c=r+s;E^=-1;for(var h=r;h<c;h++)E=E>>>8^a[255&(E^n.charCodeAt(h))];return-1^E})(0|i,Q,Q.length,0):0}},{"./utils":32}],5:[function(e,t,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(e,t,o){var B=null;B=typeof Promise<"u"?Promise:e("lie"),t.exports={Promise:B}},{lie:37}],7:[function(e,t,o){var B=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",C=e("pako"),Q=e("./utils"),i=e("./stream/GenericWorker"),E=B?"uint8array":"array";function n(s,r){i.call(this,"FlateWorker/"+s),this._pako=null,this._pakoAction=s,this._pakoOptions=r,this.meta={}}o.magic="\b\0",Q.inherits(n,i),n.prototype.processChunk=function(s){this.meta=s.meta,this._pako===null&&this._createPako(),this._pako.push(Q.transformTo(E,s.data),!1)},n.prototype.flush=function(){i.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},n.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this._pako=null},n.prototype._createPako=function(){this._pako=new C[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var s=this;this._pako.onData=function(r){s.push({data:r,meta:s.meta})}},o.compressWorker=function(s){return new n("Deflate",s)},o.uncompressWorker=function(){return new n("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,o){function B(a,c){var h,l="";for(h=0;h<c;h++)l+=String.fromCharCode(255&a),a>>>=8;return l}function C(a,c,h,l,D,d){var y,w,u=a.file,G=a.compression,m=d!==E.utf8encode,p=Q.transformTo("string",d(u.name)),k=Q.transformTo("string",E.utf8encode(u.name)),S=u.comment,R=Q.transformTo("string",d(S)),x=Q.transformTo("string",E.utf8encode(S)),N=k.length!==u.name.length,U=x.length!==S.length,K="",Y="",_="",Z=u.dir,V=u.date,W={crc32:0,compressedSize:0,uncompressedSize:0};c&&!h||(W.crc32=a.crc32,W.compressedSize=a.compressedSize,W.uncompressedSize=a.uncompressedSize);var q=0;c&&(q|=8),m||!N&&!U||(q|=2048);var X=0,tA=0;Z&&(X|=16),D==="UNIX"?(tA=798,X|=(function(QA,sA){var DA=QA;return QA||(DA=sA?16893:33204),(65535&DA)<<16})(u.unixPermissions,Z)):(tA=20,X|=(function(QA){return 63&(QA||0)})(u.dosPermissions)),y=V.getUTCHours(),y<<=6,y|=V.getUTCMinutes(),y<<=5,y|=V.getUTCSeconds()/2,w=V.getUTCFullYear()-1980,w<<=4,w|=V.getUTCMonth()+1,w<<=5,w|=V.getUTCDate(),N&&(Y=B(1,1)+B(n(p),4)+k,K+="up"+B(Y.length,2)+Y),U&&(_=B(1,1)+B(n(R),4)+x,K+="uc"+B(_.length,2)+_);var IA="";return IA+=`
|
|
5671
|
+
`,n=new Blob([E],{type:"text/plain"}),s=URL.createObjectURL(n),r=document.createElement("a");r.href=s,r.download=`${i}.test.ts`,r.click(),URL.revokeObjectURL(s)}catch(Q){alert(`Error generating test.ts for ${g.getSolverName()}: ${Q instanceof Error?Q.message:String(Q)}`)}e(!1)};return T.jsxs("div",{className:`relative ${A}`,ref:t,children:[T.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>e(!I),title:`Download options for ${g.getSolverName()}`,children:g.getSolverName()}),I&&T.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[T.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),T.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:B,children:"Download page.tsx"}),T.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:C,children:"Download test.ts"})]})]})},dPI=g=>g.activeSubSolver?[g,...dPI(g.activeSubSolver)]:[g],Kpo=({solver:g})=>{const A=dPI(g);return T.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((I,e)=>T.jsxs("div",{className:"flex items-center",children:[e>0&&T.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),T.jsx(Ppo,{solver:I})]},I.getSolverName()))})},Lpo=({solver:g,triggerRender:A,animationSpeed:I=25,renderer:e,onRendererChange:t,onAnimationSpeedChange:o,onDownloadVisualization:B,onSolverStarted:C,onSolverCompleted:Q})=>{const[i,E]=z.useReducer(m=>!m,!1),n=z.useRef(void 0),s=z.useRef(null),r="solver-debugger-last-iteration",[a,c]=z.useState(null),h=z.useRef(null),l=z.useMemo(()=>[{label:"Slow",value:250,description:"250ms"},{label:"Normal",value:100,description:"100ms"},{label:"Fast",value:10,description:"10ms"},{label:"Fast (2x)",value:5,description:"5ms"},{label:"Fast (10x)",value:1,description:"1ms"},{label:"Fast 20x",value:.5,description:"2 steps / 1ms"},{label:"Fast 100x",value:.1,description:"10 steps / 1ms"}],[]),D=()=>{const m=Math.max(1,I),p=I<1?Math.round(1/I):1;n.current=setInterval(()=>{if(g.solved||g.failed){n.current&&(clearInterval(n.current),n.current=void 0),E(),A(),Q&&g.solved&&Q(g);return}for(let k=0;k<p&&!(g.solved||g.failed);k++)g.step();A()},m)},d=()=>{n.current&&(clearInterval(n.current),n.current=void 0)},y=()=>{!g.solved&&!g.failed&&(g.step(),A())},w=()=>{!g.solved&&!g.failed&&(C&&C(g),g.solve(),A(),Q&&Q(g))},u=()=>{i?(d(),E()):(E(),D())},G=()=>{if(g.solved||g.failed||i)return;s.current===null&&typeof window<"u"&&(s.current=window.localStorage.getItem(r));const m=window.prompt("Step until which iteration?",s.current??`${g.iterations}`);if(m===null)return;s.current=m,typeof window<"u"&&window.localStorage.setItem(r,m);const p=Number(m);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;g.iterations<p&&!g.solved&&!g.failed;)g.step();A(),g.solved&&Q&&Q(g)};return z.useEffect(()=>()=>{d()},[]),z.useEffect(()=>{(g.solved||g.failed)&&i&&(d(),E())},[g.solved,g.failed,i]),z.useEffect(()=>{i&&(d(),D())},[I,i]),z.useEffect(()=>{if(typeof document>"u")return;const m=p=>{h.current&&!h.current.contains(p.target)&&c(null)};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]),T.jsxs("div",{className:"space-y-2 p-2 border-b",children:[T.jsx("div",{className:"flex items-center",children:T.jsxs("div",{className:"flex items-center gap-2",ref:h,children:[T.jsxs("div",{className:"flex h-9 items-center space-x-1 rounded-md border border-slate-200 bg-white p-1 shadow-sm",children:[T.jsxs("div",{className:"relative",children:[T.jsx("button",{type:"button",onClick:()=>c(a==="renderer"?null:"renderer"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":a==="renderer"?"open":"closed",children:"Renderer"}),a==="renderer"&&T.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[10rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:["vector","canvas"].map(m=>T.jsxs("button",{type:"button",onClick:()=>{t(m),c(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[m==="vector"?"Vector":"Canvas",e===m&&T.jsx("span",{className:"ml-auto text-xs text-slate-500",children:"✓"})]},m))})]}),T.jsxs("div",{className:"relative",children:[T.jsx("button",{type:"button",onClick:()=>c(a==="debug"?null:"debug"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":a==="debug"?"open":"closed",children:"Debug"}),a==="debug"&&T.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:T.jsx("button",{type:"button",onClick:()=>{B(),c(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:"Download Visualization"})})]}),T.jsxs("div",{className:"relative",children:[T.jsx("button",{type:"button",onClick:()=>c(a==="animation"?null:"animation"),className:"flex select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100","data-state":a==="animation"?"open":"closed",children:"Animation"}),a==="animation"&&T.jsx("div",{className:"absolute left-0 z-50 mt-1 min-w-[12rem] rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md",children:l.map(m=>T.jsxs("button",{type:"button",onClick:()=>{o(m.value),c(null)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-slate-100",children:[m.label,T.jsx("span",{className:"ml-auto text-xs text-slate-500",children:m.description}),I===m.value&&T.jsx("span",{className:"ml-2 text-xs text-slate-500",children:"✓"})]},m.value))})]})]}),T.jsx(Kpo,{solver:g})]})}),T.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[T.jsx("button",{onClick:y,disabled:g.solved||g.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),T.jsx("button",{onClick:w,disabled:g.solved||g.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),T.jsx("button",{onClick:u,disabled:g.solved||g.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),T.jsx("button",{onClick:G,disabled:g.solved||g.failed||i,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),T.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",g.iterations]}),g.timeToSolve!==void 0&&T.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(g.timeToSolve/1e3).toFixed(3),"s"]}),g.solved&&T.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),g.failed&&T.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),g.error&&T.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",g.error]})]})},Ypo=g=>g!==null&&"pipelineDef"in g&&Array.isArray(g.pipelineDef),_po=(g,A,I)=>{const e=g.currentPipelineStageIndex;return A<e?"Completed":A===e&&g.activeSubSolver?g.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},bpo=(g,A)=>{const e=g.pipelineDef[A].solverName,t=_po(g,A),o=g[e],B=g.firstIterationOfStage?.[e]??(A===g.currentPipelineStageIndex?g.iterations:null),C=g.iterations;let Q=0;if(t==="Completed"){const s=g.pipelineDef[A+1],r=s?g.firstIterationOfStage?.[s.solverName]:void 0;r!==void 0&&B!==null?Q=r-B:B!==null&&(Q=C-B)}else t==="In Progress"&&B!==null&&(Q=C-B);const i=g.timeSpentOnStage?.[e]??0;let E=0;t==="Completed"?E=1:t==="In Progress"&&o&&(E=o.progress??0);const n=o?.stats??null;return{index:A,name:e,status:t,firstIteration:B,iterations:Q,progress:E,timeSpent:i,stats:n&&Object.keys(n).length>0?n:null,solverInstance:o??null}},Hpo=({status:g})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return T.jsx("span",{className:`font-medium ${A[g]}`,children:g})},vpo=({progress:g})=>{if(g===0)return null;const A=Math.round(g*100);return T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:T.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),T.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},yPI=g=>{if(typeof g=="string")return g;if(typeof g=="number"||typeof g=="boolean"||typeof g=="bigint"||g==null)return String(g);if(typeof g=="object")try{return JSON.stringify(g)}catch{return String(g)}return String(g)},Tpo=g=>Object.entries(g).map(([A,I])=>`${A}: ${yPI(I)}`).join(", "),qpo=({stats:g})=>{if(!g||Object.keys(g).length===0)return T.jsx("span",{children:"-"});const A=Object.entries(g),I=Tpo(g);return T.jsxs("details",{className:"cursor-pointer",children:[T.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:I}),T.jsx("div",{className:"mt-1 text-xs",children:A.map(([e,t])=>T.jsxs("div",{children:[e,": ",yPI(t)]},e))})]})},kCg=g=>{if(g===null||typeof g!="object")return g;if(Array.isArray(g))return g.map(kCg);const A={};for(const[I,e]of Object.entries(g))I.startsWith("_")||(A[I]=kCg(e));return A},Zpo=(g,A)=>{try{if(typeof g.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const I=kCg(g.getConstructorParams()),e=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),t=URL.createObjectURL(e),o=document.createElement("a");o.href=t,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(t)}catch(I){alert(`Error downloading input for ${A}: ${I instanceof Error?I.message:String(I)}`)}},Opo=({expanded:g})=>T.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:`w-4 h-4 transition-transform duration-200 ${g?"rotate-90":""}`,children:T.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})}),wPI=g=>{let A=g;for(;A.activeSubSolver;)A=A.activeSubSolver;return A},uPI=({solver:g,onStepUntilPhase:A,onDownloadInput:I,isNested:e=!1,indentLevel:t=0,triggerRender:o})=>{const[B,C]=z.useState(new Set),Q=g.pipelineDef.map((h,l)=>bpo(g,l)),i=h=>{C(l=>{const D=new Set(l);return D.has(h)?D.delete(h):D.add(h),D})},E=h=>{A?.(h)},n=h=>{h.solverInstance&&(I?I(h.solverInstance,h.name):Zpo(h.solverInstance,h.name))},s=h=>`${(h/1e3).toFixed(2)}s`,r=()=>{if(!g.solved&&!g.failed){const h=g.activeSubSolver;for(;!g.solved&&!g.failed&&(g.step(),!(g.activeSubSolver&&g.activeSubSolver!==h)););o?.()}},a=()=>{if(!g.solved&&!g.failed){const h=wPI(g);for(;!g.solved&&!g.failed&&(g.step(),wPI(g)===h););o?.()}},c=t*24;return T.jsxs("div",{className:e?"":"border-t border-gray-200",children:[!e&&T.jsxs("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between",children:[T.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Stages"}),T.jsxs("div",{className:"flex gap-2",children:[T.jsx("button",{onClick:a,disabled:g.solved||g.failed,className:"bg-indigo-500 hover:bg-indigo-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Solver"}),T.jsx("button",{onClick:r,disabled:g.solved||g.failed,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 disabled:cursor-not-allowed cursor-pointer text-white px-3 py-1 rounded text-sm",children:"Next Stage"})]})]}),T.jsx("div",{className:"overflow-x-auto",children:T.jsxs("table",{className:"w-full text-sm",children:[!e&&T.jsx("thead",{children:T.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stage"}),T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),T.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",T.jsx("sub",{children:"0"})]}),T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),T.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),T.jsx("tbody",{children:Q.map(h=>{const l=Ypo(h.solverInstance),D=B.has(h.name);return T.jsxs(rC.Fragment,{children:[T.jsxs("tr",{className:`border-b border-gray-100 ${h.status==="In Progress"?"bg-yellow-50":""}`,children:[T.jsx("td",{className:"px-4 py-2",children:T.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:c},children:[l?T.jsx("button",{onClick:()=>i(h.name),className:"text-gray-500 hover:text-gray-700",title:D?"Collapse":"Expand",children:T.jsx(Opo,{expanded:D})}):T.jsx("span",{className:"w-4"}),T.jsx("span",{className:"text-gray-400 w-6",children:String(h.index+1).padStart(2,"0")}),T.jsx("button",{onClick:()=>E(h.name),disabled:h.status==="Completed"||g.solved||g.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${h.name} completes`,children:T.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:T.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),T.jsx("span",{className:"font-medium text-gray-900",children:h.name})]})}),T.jsx("td",{className:"px-4 py-2",children:T.jsx(Hpo,{status:h.status})}),T.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:h.firstIteration!==null?h.firstIteration:""}),T.jsx("td",{className:"px-4 py-2 text-gray-600",children:h.iterations}),T.jsx("td",{className:"px-4 py-2",children:T.jsx(vpo,{progress:h.progress})}),T.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(h.timeSpent)}),T.jsx("td",{className:"px-4 py-2 text-gray-500",children:T.jsx(qpo,{stats:h.stats})}),T.jsx("td",{className:"px-4 py-2",children:h.solverInstance?T.jsxs("button",{onClick:()=>n(h),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${h.name}`,children:[T.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:T.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),T.jsx("span",{children:"Input"})]}):null})]}),l&&D&&T.jsx("tr",{children:T.jsx("td",{colSpan:8,className:"p-0",children:T.jsx(uPI,{solver:h.solverInstance,onStepUntilPhase:A,onDownloadInput:I,isNested:!0,indentLevel:t+1,triggerRender:o})})})]},h.name)})})]})})]})};function Wpo({graphics:g}){const A=g.points??[],I=g.lines??[],e=g.rects??[],t=g.circles??[],o=g.texts??[];let B=Number.POSITIVE_INFINITY,C=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const E=(h,l)=>{typeof h=="number"&&(h<B&&(B=h),h>Q&&(Q=h)),typeof l=="number"&&(l<C&&(C=l),l>i&&(i=l))};for(const h of A)E(h.x,h.y);for(const h of I){const l=h.points??[];for(const D of l)E(D.x,D.y)}for(const h of e){const l=h.x??0,D=h.y??0,d=h.width??0,y=h.height??0;E(l,D),E(l+d,D+y)}for(const h of t){const l=h.x??0,D=h.y??0,d=h.radius??1;E(l-d,D-d),E(l+d,D+d)}for(const h of o)E(h.x,h.y);(!isFinite(B)||!isFinite(C)||!isFinite(Q)||!isFinite(i))&&(B=-20,C=-20,Q=20,i=20);const n=10,s=B-n,r=C-n,a=Math.max(1,Q-B+2*n),c=Math.max(1,i-C+2*n);return T.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${s} ${r} ${a} ${c}`,role:"img","aria-label":"Graphics fallback",children:[e.map((h,l)=>T.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${l}`)),I.map((h,l)=>T.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(D=>`${D.x??0},${D.y??0}`).join(" ")},`line-${l}`)),t.map((h,l)=>T.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${l}`)),A.map((h,l)=>T.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${l}`)),o.map((h,l)=>T.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${l}`))]})}var Vpo=class extends rC.Component{constructor(g){super(g),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(g){console.error("InteractiveGraphics render error:",g)}render(){return this.state.hasError?this.props.fallback:this.props.children}},jpo=({solver:g,createSolver:A,animationSpeed:I=25,onSolverStarted:e,onSolverCompleted:t})=>{const[o,B]=z.useReducer(D=>D+1,0),[C]=z.useState(()=>{if(A)return A();if(!g)throw new Error("GenericSolverDebugger requires solver or createSolver");return g}),[Q,i]=z.useState(()=>typeof window>"u"?"vector":window.localStorage.getItem("solver-utils-renderer")==="canvas"?"canvas":"vector"),[E,n]=z.useState(I),s=z.useMemo(()=>{try{return C.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(D){return console.error("Visualization error:",D),{points:[],lines:[],rects:[],circles:[]}}},[C,o]),r=z.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);z.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const D=document.createElement("script");D.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(D)}},[]),z.useEffect(()=>{n(I)},[I]);const a=C.pipelineDef!==void 0,c=D=>{const d=C;if(!C.solved&&!C.failed){for(;!C.solved&&!C.failed&&d.currentPipelineStageIndex<=d.pipelineDef.findIndex(y=>y.solverName===D);)C.step();B()}},h=()=>{const D=JSON.stringify(s,null,2),d=new Blob([D],{type:"application/json"}),y=URL.createObjectURL(d),w=document.createElement("a");w.download="visualization.json",w.href=y,document.body.appendChild(w),w.click(),document.body.removeChild(w),URL.revokeObjectURL(y)},l=D=>{i(D),typeof window<"u"&&window.localStorage.setItem("solver-utils-renderer",D)};return T.jsxs("div",{children:[T.jsx(Lpo,{solver:C,triggerRender:B,animationSpeed:E,renderer:Q,onRendererChange:l,onAnimationSpeedChange:n,onDownloadVisualization:h,onSolverStarted:e,onSolverCompleted:t}),r?T.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):T.jsx(Vpo,{fallback:T.jsx(Wpo,{graphics:s}),children:Q==="canvas"?T.jsx(Jpo,{graphics:s}):T.jsx(xpo,{graphics:s})}),a&&T.jsx(uPI,{solver:C,onStepUntilPhase:c,triggerRender:B})]})};const zpo=()=>{z.useEffect(()=>{const g="tailwind-cdn-script";if(document.getElementById(g)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const I=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),I)return;const e=document.createElement("script");e.id=g,e.src="https://cdn.tailwindcss.com",document.head.appendChild(e)},[])},Xpo=1e3,bk=(g,A)=>{const{fileName:I,mimeType:e="text/plain"}=A,t=g instanceof Blob?g:new Blob([g],{type:e}),o=URL.createObjectURL(t),B=document.createElement("a");B.href=o,B.download=I,B.target="_blank",B.rel="noopener noreferrer",B.style.display="none",document.body.appendChild(B),B.click(),document.body.removeChild(B),setTimeout(()=>{URL.revokeObjectURL(o)},Xpo)},MCg=g=>{let A=g.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(A)&&(A=`_${A}`),A=A.slice(0,200),A||"untitled"},$po=g=>{const A=g.solverConstructorArgs??[g.solverParams];if(g.solverName!=="AutoroutingPipelineSolver7_MultiGraph"||A.length!==1)return A;const[{input:I,options:e}]=A;return[I,e]},dF="https://github.com/tscircuit/tscircuit-autorouter/issues/new",GPI="https://github.com/tscircuit/copper-pour-solver/issues/new",mPI="https://github.com/tscircuit/calculate-packing/issues/new",Ako="https://github.com/tscircuit/matchpack/issues/new",pPI="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",gko={PackSolver2:mPI,LayoutPipelineSolver:Ako,AutoroutingPipelineSolver:dF,AssignableAutoroutingPipeline2:dF,AssignableAutoroutingPipeline3:dF,AutoroutingPipeline1_OriginalUnravel:dF,AutoroutingPipelineSolver3_HgPortPointPathing:dF,AutoroutingPipelineSolver4:dF,AutoroutingPipelineSolver5:dF,AutoroutingPipelineSolver7_MultiGraph:dF,AutoroutingPipelineSolver8:dF,CopperPourPipelineSolver:GPI,SchematicTracePipelineSolver:pPI},Iko=g=>g.toLowerCase().includes("pack")?nxI:g.toLowerCase().includes("rout")?axI:Aco,kPI=g=>{const A=gko[g];if(A)return A;const I=g.toLowerCase();return I.includes("autorout")?dF:I.includes("schematic")&&I.includes("trace")?pPI:I.includes("copperpour")?GPI:I.includes("pack")?mPI:null},eko=g=>`${MCg(`${g.componentName}-${g.solverName}`)}-solver-input.json`,MPI=g=>{bk(JSON.stringify(g.solverParams,null,2),{fileName:eko(g),mimeType:"application/json"})},tko=({solverEvent:g})=>{const A=kPI(g.solverName);return T.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[T.jsxs(si,{type:"button",variant:"outline",size:"sm",onClick:()=>MPI(g),children:[T.jsx(NtA,{className:"rf-w-4 rf-h-4"}),"Download"]}),A?T.jsx(si,{asChild:!0,variant:"outline",size:"sm",children:T.jsxs("a",{href:A,target:"_blank",rel:"noopener noreferrer",children:[T.jsx(qGA,{className:"rf-w-4 rf-h-4"}),"Report"]})}):T.jsxs(si,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[T.jsx(qGA,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},oko=({solverEvent:g})=>{const A=kPI(g.solverName);return A?T.jsx(si,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:T.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:T.jsx(qGA,{className:"rf-w-4 rf-h-4"})})}):T.jsx(si,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:T.jsx(qGA,{className:"rf-w-4 rf-h-4"})})},Bko=({solverEvents:g=[]})=>{const[A,I]=z.useState(null);zpo();const e=z.useMemo(()=>{const C=new Map;for(const Q of g){const i=`${Q.componentName}-${Q.solverName}`;C.set(i,Q)}return C},[g]),t=z.useMemo(()=>Array.from(e.keys()),[e]),o=A?e.get(A):null,B=z.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const C=W9A[o.solverName];if(!C)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(W9A).join(", ")}`,classFound:!1};try{return{instance:new C(...$po(o)),error:null,classFound:!0}}catch(Q){const i=Q instanceof Error?Q.message:String(Q);return console.error("Failed to reconstruct solver:",Q),{instance:null,error:`Failed to instantiate solver: ${i}`,classFound:!0}}},[o]);return g.length===0?T.jsx("div",{className:"rf-p-4",children:T.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:T.jsxs("div",{className:"rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),T.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):T.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[T.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[T.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[t.length," ",t.length===1?"Solver":"Solvers"]}),t.map(C=>{const Q=e.get(C),i=A===C;return T.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${i?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>I(C),children:(()=>{const E=Iko(Q.solverName);return T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[T.jsx(E,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),T.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[T.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:Q.componentName}),T.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:Q.solverName})]})]})})()},C)})]}),T.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?B.instance?T.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[T.jsx(tko,{solverEvent:o}),T.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:T.jsx(GS,{fallback:T.jsx("div",{className:"rf-p-4",children:T.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),T.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:T.jsx(jpo,{solver:B.instance})})})]}):T.jsxs("div",{className:"rf-p-4",children:[T.jsxs("div",{className:"rf-mb-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),T.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),B.error&&T.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${B.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:T.jsx("p",{className:`rf-text-sm ${B.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:B.error})}),T.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[T.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[T.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[T.jsx(oko,{solverEvent:o}),T.jsx(si,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>MPI(o),children:T.jsx(NtA,{className:"rf-w-4 rf-h-4"})})]})]}),T.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:T.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):T.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:T.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Cko=["subcircuit_id","componentDisplayName","phaseName","routingPhaseIndex","phaseOrdinal","phaseCount","phaseStageIndex","phaseStageCount","connectionCount","obstacleCount","previousTraceCount","isReroutePhase","autorouterName","autorouterVersion","solverName","effort","cacheStatus"],Qko=["phaseOrdinal","routingPhaseIndex","phaseName","phaseStageIndex"];function iko(g,A){let I=-1,e=-1;for(let t=g.length-1;t>=0;t--){const o=g[t];if(o.status!=="running"||o.subcircuit_id!==A.subcircuit_id||o.componentDisplayName!==A.componentDisplayName)continue;let B=0,C=!1;for(const Q of Qko)if(!(o[Q]===void 0||A[Q]===void 0)){if(o[Q]!==A[Q]){C=!0;break}B++}!C&&B>e&&(I=t,e=B)}return I}function Eko(g,A){const I=Object.fromEntries(Cko.filter(B=>A[B]!==void 0).map(B=>[B,A[B]])),e=A.simpleRouteJson?structuredClone(A.simpleRouteJson):void 0,t=A.type==="autorouting:start"?-1:iko(g,A),o={...t===-1?{id:`autorouting_phase_${g.length+1}`}:g[t],...I,status:A.type==="autorouting:start"?"running":A.type==="autorouting:end"?"complete":"error",...A.type==="autorouting:start"?{startSimpleRouteJson:e}:A.type==="autorouting:end"?{endSimpleRouteJson:e}:{errorSimpleRouteJson:e,error:A.error?{...A.error}:void 0}};return t===-1?[...g,o]:g.map((B,C)=>C===t?o:B)}const nko=new Map([["custom","Custom"],["fanout","Fanout"],["single_layer_fanout","Single layer fanout"],["tscircuit_simplify","Simplify"]]),sko=new Set(["tscircuit","default","auto","auto_local"]);function ako(g){if(g==="FanoutSolver")return"Fanout";if(g==="AutoroutingPipelineSolver11_Simplification")return"Simplify";const A=g.match(/^AutoroutingPipeline(?:Solver)?(\d+)(?:_|$)/);if(A)return`Pipeline${A[1]}`;const I=g.match(/^AssignableAutoroutingPipeline(\d+)$/);return I?`Assignable${I[1]}`:g}function rko(g){const A=g.autorouterName?.trim(),I=A?.replace(/-/g,"_"),e=I&&nko.get(I);if(e)return e;if(I&&!sko.has(I))return A;const t=g.solverName?.trim();if(t)return ako(t);const o=g.autorouterVersion?.trim();if(o){const B=o.match(/^beta[_-]pipeline(\d+)$/);return B?`Pipeline${B[1]}`:o==="latest"?"default":o}return A?"default":"Unknown"}const SCg="#fbbf24";function cko(g){const A=g.endSimpleRouteJson?.traces??[],I=new Set(A.flatMap(t=>[t.pcb_trace_id,t.__replaces_pcb_trace_id].filter(o=>o!==void 0)));return[...(g.startSimpleRouteJson?.traces??[]).filter(t=>!I.has(t.pcb_trace_id)),...A]}function SPI(g){const A=new Map((g.startSimpleRouteJson?.traces??[]).map(I=>[I.pcb_trace_id,I]));return(g.endSimpleRouteJson?.traces??[]).filter(I=>{const e=A.get(I.pcb_trace_id);return!e||!!I.__replaces_pcb_trace_id&&I.__replaces_pcb_trace_id!==e.__replaces_pcb_trace_id||JSON.stringify(e.route)!==JSON.stringify(I.route)}).map(I=>I.pcb_trace_id)}function hko(g,A){return{outer_diameter:g.via_diameter??A.minViaPadDiameter??A.min_via_pad_diameter??A.minViaDiameter??.6,hole_diameter:g.via_hole_diameter??A.minViaHoleDiameter??A.min_via_hole_diameter??.3}}function fPI(g,A){const I=[];for(const C of g.route)C.route_type==="wire"?I.push({...C,layer:C.layer}):C.route_type==="via"?I.push({route_type:"via",x:C.x,y:C.y,from_layer:C.from_layer,to_layer:C.to_layer,...hko(C,A)}):C.route_type==="through_obstacle"&&I.push({route_type:"through_pad",start:{...C.start},end:{...C.end},width:C.width,start_layer:C.from_layer,end_layer:C.to_layer,pcb_smtpad_id:C.circuitJsonMetadata?.pcb_smtpad_id,pcb_plated_hole_id:C.circuitJsonMetadata?.pcb_plated_hole_id});const e=C=>{let Q=-1,i=Number.POSITIVE_INFINITY;return I.forEach((E,n)=>{if(E.route_type!=="wire")return;const s=Math.hypot(E.x-C.x,E.y-C.y);s<i&&(i=s,Q=n)}),Q},t=g.route.filter(C=>C.route_type==="jumper").map(C=>[e(C.start),e(C.end)].sort((Q,i)=>Q-i)).filter(([C,Q])=>C>=0&&Q>C).sort(([C],[Q])=>C-Q),o=[];let B=0;for(const[C,Q]of t)C>=B&&o.push(I.slice(B,C+1)),B=Math.max(B,Q);return B<I.length&&o.push(I.slice(B)),o}function lko(g){const A=[],I=[],e=g.endSimpleRouteJson;if(!e)return{lines:A,circles:I};const t=new Set(SPI(g));for(const o of e.traces??[])if(t.has(o.pcb_trace_id))for(const B of fPI(o,e)){let C;for(const Q of B){if(Q.route_type==="through_pad"){C={...Q.end,layer:Q.end_layer,width:Q.width};continue}const i=Q.route_type==="wire"?Q.layer:Q.from_layer;C&&C.layer===i&&(C.x!==Q.x||C.y!==Q.y)&&A.push({points:[{x:C.x,y:C.y},{x:Q.x,y:Q.y}],strokeWidth:Q.route_type==="wire"?Q.width:C.width,strokeColor:SCg,layer:i}),Q.route_type==="via"&&I.push({center:{x:Q.x,y:Q.y},radius:Q.outer_diameter/2,stroke:SCg,fill:"transparent"}),C={x:Q.x,y:Q.y,layer:Q.route_type==="wire"?Q.layer:Q.to_layer,width:Q.route_type==="wire"?Q.width:C?.width??e.minTraceWidth}}}return{coordinateSystem:"cartesian",lines:A,circles:I}}function Dko(g){const A=JSON.stringify(g);let I=2166136261;for(let e=0;e<A.length;e++)I=Math.imul(I^A.charCodeAt(e),16777619);return(I>>>0).toString(36)}const dko=new Set(["pcb_trace","pcb_via","pcb_copper_pour","pcb_ground_plane","pcb_ground_plane_region","pcb_thermal_spoke","pcb_breakout_point"]);function yko(g,A,I){const e=I==="input"?A.startSimpleRouteJson??A.errorSimpleRouteJson:A.endSimpleRouteJson,t=g.filter(i=>!dko.has(i.type)&&!i.type.endsWith("_error")&&!i.type.endsWith("_warning"));if(!e)return t;const o=I==="input"?e.traces??[]:cko(A),B=new Set(g.filter(i=>i.type==="source_trace").map(i=>i.source_trace_id)),C=["top",...Array.from({length:Math.max(0,e.layerCount-2)},(i,E)=>`inner${E+1}`),...e.layerCount>1?["bottom"]:[]],Q=[];for(const i of o){const n=e.connections.find(r=>r.name===i.connection_name||r.source_trace_id===i.connection_name)?.source_trace_id??i.connection_name??"",s=fPI(i,e);for(const[r,a]of s.entries()){const c={type:"pcb_trace",pcb_trace_id:`${A.id}_${I}_${i.pcb_trace_id}_${r}_${Dko(a)}`,subcircuit_id:A.subcircuit_id??void 0,source_trace_id:B.has(n)?n:void 0,route:a};Q.push(c);for(const[h,l]of a.entries()){if(l.route_type!=="via")continue;const D=C.indexOf(l.from_layer),d=C.indexOf(l.to_layer),y={type:"pcb_via",pcb_via_id:`${c.pcb_trace_id}_via_${h}`,pcb_trace_id:c.pcb_trace_id,subcircuit_id:A.subcircuit_id??void 0,x:l.x,y:l.y,outer_diameter:l.outer_diameter,hole_diameter:l.hole_diameter,layers:D>=0&&d>=0?C.slice(Math.min(D,d),Math.max(D,d)+1):[l.from_layer,l.to_layer]};Q.push(y)}}}return[...t,...Q]}const fCg=(g,A)=>g.phaseName||`Phase ${g.phaseOrdinal??A+1}`,RPI=g=>g.componentDisplayName?.match(/name="([^"]+)"/)?.[1]?.replace(/^\./,"")||g.componentDisplayName||g.subcircuit_id||"Board",NPI=g=>g.startSimpleRouteJson??g.endSimpleRouteJson??g.errorSimpleRouteJson,wko={is_showing_autorouting:!0,is_showing_rats_nest:!1,is_showing_drc_errors:!1,is_showing_drc_warnings:!1,is_showing_pcb_groups:!1},uko=({circuitJson:g,phases:A=[],isRunning:I=!1})=>{const[e,t]=z.useState(null),[o,B]=z.useState("output"),[C,Q]=z.useState(!0),[i,E]=z.useState(!1),n=z.useRef(null),[s,r]=z.useState(480),a=e?A.findIndex(N=>N.id===e.id&&NPI(N)===NPI(e)):-1,c=a<0?A.length-1:a,h=A[c],l=a<0,D=!!h?.endSimpleRouteJson,d=h?.startSimpleRouteJson??h?.errorSimpleRouteJson,y=!!d,w=o==="output"&&!D?"input":o==="input"&&!y?"output":o,u=w==="input"?d:h?.endSimpleRouteJson,G=z.useMemo(()=>!h||!u?null:yko(g??[],h,w),[g,h,u,w]),m=z.useMemo(()=>h&&w==="output"&&C?lko(h):{lines:[],circles:[]},[h,w,C]);if(z.useLayoutEffect(()=>{const N=n.current;if(!N)return;const U=()=>r(Math.max(360,N.clientHeight));U();const K=new ResizeObserver(U);return K.observe(N),()=>K.disconnect()},[!!h]),!h)return T.jsxs("div",{className:"rf-flex rf-min-h-[400px] rf-flex-col rf-items-center rf-justify-center rf-gap-3 rf-p-8 rf-text-center",children:[T.jsx(axI,{className:"rf-h-7 rf-w-7 rf-text-blue-500"}),T.jsx("h3",{className:"rf-text-base rf-font-medium",children:I?"Waiting for autorouting":"No autorouting captures"}),T.jsx("p",{className:"rf-max-w-md rf-text-sm rf-text-gray-500",children:I?"Phases appear as the circuit routes. Each capture includes its input and output on the PCB.":"Run a circuit with autorouting enabled to inspect its phases. A circuit JSON file alone does not include routing history."})]});const p=fCg(h,c),k=h.status==="running"&&I,S=!D,R=d?.connections.length,x=G?.filter(N=>N.type==="pcb_trace").length??0;return T.jsxs("div",{className:"rf-flex rf-h-full rf-min-h-[620px] rf-flex-col rf-bg-white md:rf-flex-row","data-testid":"autorouting-explorer",children:[T.jsxs("aside",{className:"rf-flex rf-shrink-0 rf-flex-col rf-border-b rf-border-gray-200 md:rf-w-52 md:rf-border-b-0 md:rf-border-r","aria-label":"Routing phases",children:[T.jsxs("div",{className:"rf-flex rf-items-center rf-justify-between rf-px-3 rf-py-2 rf-text-xs rf-text-gray-500",children:[T.jsx("span",{children:"Routing phases"}),T.jsx("span",{children:A.length})]}),T.jsx("div",{className:"rf-flex rf-gap-1 rf-overflow-x-auto rf-px-1.5 rf-pb-1.5 md:rf-flex-col md:rf-overflow-x-hidden md:rf-overflow-y-auto",children:A.map((N,U)=>{const K=SPI(N).length,Y=N.endSimpleRouteJson?`${K} ${K===1?"trace":"traces"} routed`:N.status==="error"?"Failed":N.status==="running"&&I?"Routing…":"No output";return T.jsxs("button",{type:"button","aria-pressed":U===c,title:`${RPI(N)} · ${Y}`,onClick:()=>t(N),className:co("rf-flex rf-min-w-[192px] rf-items-start rf-gap-2 rf-rounded-md rf-border rf-px-2 rf-py-2 rf-text-left md:rf-min-w-0",U===c?"rf-border-blue-200 rf-bg-blue-50":"rf-border-transparent hover:rf-bg-gray-50"),children:[T.jsx("span",{className:co("rf-flex rf-h-5 rf-w-5 rf-shrink-0 rf-items-center rf-justify-center rf-rounded-full rf-text-[11px]",U===c?"rf-bg-blue-600 rf-text-white":"rf-bg-gray-100 rf-text-gray-500"),children:U+1}),T.jsxs("span",{className:"rf-min-w-0 rf-flex-1",children:[T.jsxs("span",{className:"rf-flex rf-items-center rf-gap-1",children:[T.jsx("span",{className:"rf-min-w-0 rf-flex-1 rf-truncate rf-text-xs rf-font-medium rf-leading-5 rf-text-gray-800",title:fCg(N,U),children:fCg(N,U)}),N.status==="complete"?T.jsx(sF,{"aria-label":"Captured",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-green-600"}):N.status==="error"?T.jsx(Zog,{"aria-label":"Failed",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-red-500"}):I?T.jsx(mS,{"aria-label":"Routing",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-animate-spin rf-text-blue-500"}):null]}),T.jsxs("span",{className:"rf-block rf-text-[11px] rf-leading-4 rf-text-gray-500",children:[rko(N)," · ",Y]})]})]},N.id)})})]}),T.jsxs("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-flex-col",children:[T.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-gap-3 rf-border-b rf-border-gray-200 rf-px-4 rf-py-3",children:[T.jsxs("h3",{className:"rf-mr-auto rf-flex rf-items-center rf-gap-2 rf-text-sm rf-font-medium",children:[p,T.jsxs("span",{className:"rf-text-xs rf-font-normal rf-text-gray-500",children:[c+1," of ",A.length]})]}),I&&T.jsx("button",{type:"button",onClick:()=>t(null),disabled:l,className:"rf-text-xs rf-text-blue-600 disabled:rf-text-gray-500",children:l?"Following latest":"Follow latest"}),T.jsx("div",{className:"rf-flex rf-rounded-md rf-bg-gray-100 rf-p-1","aria-label":"Phase snapshot",children:["input","output"].map(N=>T.jsx("button",{type:"button","aria-pressed":w===N,disabled:N==="input"?!y:!D,onClick:()=>B(N),className:co("rf-rounded rf-px-3 rf-py-1 rf-text-xs disabled:rf-opacity-40",w===N?"rf-bg-white rf-text-gray-900 rf-shadow-sm":"rf-text-gray-500"),children:N==="input"?"Input":"Output"},N))})]}),T.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-px-4 rf-py-2 rf-text-xs rf-text-gray-600",children:[T.jsxs("label",{className:"rf-flex rf-items-center rf-gap-2",children:[T.jsx("input",{type:"checkbox",checked:C,disabled:w!=="output",onChange:N=>Q(N.target.checked),className:"rf-accent-blue-600"}),T.jsx("span",{"aria-hidden":"true",className:"rf-inline-block rf-h-0.5 rf-w-3",style:{backgroundColor:SCg}}),"Highlight changes (all layers)"]}),T.jsxs("span",{children:[w==="input"?"Before this phase":"After this phase"," ","· ",x," traces"]})]}),S&&T.jsx("div",{className:co("rf-border-y rf-px-4 rf-py-2 rf-text-xs",h.status==="error"?"rf-border-red-100 rf-bg-red-50 rf-text-red-700":"rf-border-blue-100 rf-bg-blue-50 rf-text-blue-700"),role:"status",children:h.status==="error"?`Routing failed: ${h.error?.message||"No output was captured."}`:k?"Routing in progress. Showing captured input until output is available.":"No output was captured for this phase. Showing the available input."}),T.jsx("div",{ref:n,className:"rf-relative rf-min-h-[360px] rf-flex-1","data-testid":"autorouting-pcb",children:G?T.jsx(vog,{circuitJson:G,height:s,allowEditing:!1,clickToInteractEnabled:!1,initialState:wko,debugGraphics:m}):T.jsx("div",{className:"rf-p-6 rf-text-sm rf-text-gray-500",children:"No PCB snapshot available for this capture."})}),T.jsxs("div",{className:"rf-flex rf-flex-wrap rf-items-center rf-justify-between rf-gap-2 rf-border-t rf-border-gray-200 rf-px-4 rf-py-3 rf-text-xs rf-text-gray-500",children:[T.jsxs("span",{children:[R===void 0?"Input unavailable":`${R} input connections`,` · ${RPI(h)}`]}),T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4",children:[T.jsxs("button",{type:"button",disabled:!u,onClick:()=>bk(JSON.stringify(u,null,2),{fileName:`${h.id}-${w}.srj.json`,mimeType:"application/json"}),className:"rf-flex rf-items-center rf-gap-1 disabled:rf-opacity-40",children:[T.jsx(NtA,{className:"rf-h-3 rf-w-3"}),"Download SRJ"]}),T.jsxs("button",{type:"button","aria-expanded":i,onClick:()=>E(!i),className:"rf-flex rf-items-center rf-gap-1",children:[T.jsx(Fb,{className:co("rf-h-3 rf-w-3",i&&"rf-rotate-90")}),"Inspect SRJ"]})]})]}),i&&T.jsx("pre",{className:"rf-m-0 rf-max-h-64 rf-overflow-auto rf-border-t rf-border-gray-200 rf-bg-gray-50 rf-p-4 rf-text-xs","aria-label":`${p} ${w} SRJ`,children:u?JSON.stringify(u,null,2):"No snapshot captured."})]})]})},xPI=({errorMessage:g,errorStack:A,circuitJsonErrors:I})=>{z.useEffect(()=>{if(uJ("TSCIRCUIT_TELEMETRY_DISABLED")!==!0&&g){const e=new Error(g);A&&(e.stack=A);try{xq.captureException(e)}catch{}}},[g,A]),z.useEffect(()=>{if(uJ("TSCIRCUIT_TELEMETRY_DISABLED")!==!0&&I&&I.length>0)for(const e of I){const t=new Error(e.message||"Circuit JSON Error");e.stack&&(t.stack=e.stack);try{xq.captureException(t,{error_type:e.type})}catch{}}},[I])},FPI=g=>{z.useEffect(()=>{try{pdt(g)}catch{}},[g.source,g.component,g.isWebEmbedded,g.activeTab])},UPI="0.0.3086",Gko={version:UPI},apA=DXg()(dXg(g=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{g({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),mko=g=>{const[A,I]=z.useState([]),[e,t]=z.useState(null),[o,B]=z.useState(""),[C,Q]=gq("eval-version-selection",null),i=apA(r=>r.setLastRunEvalVersion),E=apA(r=>r.lastRunEvalVersion);return z.useEffect(()=>{g&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(r=>r.json()).then(r=>{if(Array.isArray(r?.versions)){let a=[...r.versions];r.tags?.latest&&(t(r.tags.latest),a=a.filter(c=>c!==r.tags.latest)),I(a)}}).catch(()=>{})},[g]),z.useEffect(()=>{g&&(C?(window.TSCIRCUIT_LATEST_EVAL_VERSION=C,i(C)):e&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=e,i(e)))},[g,C,e]),{versions:z.useMemo(()=>A.filter(r=>r.includes(o)).slice(0,50),[A,o]),latestVersion:e,lastRunEvalVersion:E,search:o,setSearch:B,selectVersion:r=>{Q(r),B("")}}},pko=({snippetNames:g,onSelect:A,onCancel:I,isOpen:e})=>{const[t,o]=z.useState(""),[B,C]=z.useState("");if(!e)return null;const Q=g.filter(n=>n.toLowerCase().includes(B.toLowerCase())),i=B&&!g.includes(B),E=n=>{n.key==="Enter"&&(Q.length===1?o(Q[0]):i&&o(B))};return T.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:T.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[T.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),T.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:B,onChange:n=>C(n.target.value),onKeyDown:E}),T.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[Q.map(n=>T.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${t===n?"bg-blue-50":""}`,onClick:()=>o(n),children:n},n)),i&&T.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${t===B?"bg-blue-50":""}`,onClick:()=>o(B),children:['Create new "',B,'"']})]}),T.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[T.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:I,children:"Cancel"}),T.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>t&&A(t),disabled:!t,children:t===B?`Create "${t}"`:`Save to ${t}`})]})]})})},kko=g=>{const A=z.useRef(null),I=Kc(e=>e.recentEvents);z.useEffect(()=>{if(I.length===0)return;const e=I[0];e.event_id!==A.current&&(g(e),A.current=e.event_id)},[I,g])};var Mko=Object.defineProperty,EP=(g,A)=>Mko(g,"name",{value:A,configurable:!0}),Sko="AlertDialog",[fko,FCB]=hk(Sko,[_FI]),nP=_FI(),Rko=EP(g=>{const{__scopeAlertDialog:A,...I}=g,e=nP(A);return T.jsx(fmA,{...e,...I,modal:!0})},"AlertDialog");z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=nP(e);return T.jsx(plo,{...o,...t,ref:I})},"AlertDialogTrigger"));var Nko=EP(g=>{const{__scopeAlertDialog:A,...I}=g,e=nP(A);return T.jsx(RmA,{...e,...I})},"AlertDialogPortal"),JPI=z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=nP(e);return T.jsx(TtA,{...o,...t,ref:I})},"AlertDialogOverlay")),xko="AlertDialogContent",[Fko,Uko]=fko(xko),PPI=z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,children:t,...o}=A,B=nP(e),C=z.useRef(null),Q=Gi(I,C),i=z.useRef(null);return T.jsx(Fko,{scope:e,cancelRef:i,children:T.jsx(ZtA,{role:"alertdialog",...B,...o,ref:Q,onOpenAutoFocus:fo(o.onOpenAutoFocus,E=>{E.preventDefault(),i.current?.focus({preventScroll:!0})}),onPointerDownOutside:E=>E.preventDefault(),onInteractOutside:E=>E.preventDefault(),children:t})})},"AlertDialogContent")),KPI=z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=nP(e);return T.jsx(NmA,{...o,...t,ref:I})},"AlertDialogTitle")),LPI=z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=nP(e);return T.jsx(xmA,{...o,...t,ref:I})},"AlertDialogDescription")),YPI=z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,...t}=A,o=nP(e);return T.jsx(JBg,{...o,...t,ref:I})},"AlertDialogAction")),Jko="AlertDialogCancel",_PI=z.forwardRef(EP(function(A,I){const{__scopeAlertDialog:e,...t}=A,{cancelRef:o}=Uko(Jko,e),B=nP(e),C=Gi(I,o);return T.jsx(JBg,{...B,...t,ref:C})},"AlertDialogCancel"));const bPI=Rko,Pko=Nko,HPI=z.forwardRef(({className:g,...A},I)=>T.jsx(JPI,{className:co("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",g),...A,ref:I}));HPI.displayName=JPI.displayName;const RCg=z.forwardRef(({className:g,...A},I)=>T.jsxs(Pko,{children:[T.jsx(HPI,{}),T.jsx(PPI,{ref:I,className:co("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",g),...A})]}));RCg.displayName=PPI.displayName;const NCg=({className:g,...A})=>T.jsx("div",{className:co("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",g),...A});NCg.displayName="AlertDialogHeader";const xCg=({className:g,...A})=>T.jsx("div",{className:co("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",g),...A});xCg.displayName="AlertDialogFooter";const FCg=z.forwardRef(({className:g,...A},I)=>T.jsx(KPI,{ref:I,className:co("rf-text-lg rf-font-semibold",g),...A}));FCg.displayName=KPI.displayName;const UCg=z.forwardRef(({className:g,...A},I)=>T.jsx(LPI,{ref:I,className:co("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",g),...A}));UCg.displayName=LPI.displayName;const Kko=z.forwardRef(({className:g,...A},I)=>T.jsx(YPI,{ref:I,className:co(sO(),g),...A}));Kko.displayName=YPI.displayName;const JCg=z.forwardRef(({className:g,...A},I)=>T.jsx(_PI,{ref:I,className:co(sO({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",g),...A}));JCg.displayName=_PI.displayName;var Lko=Object.defineProperty,sP=(g,A)=>Lko(g,"name",{value:A,configurable:!0}),PCg="Checkbox",[Yko,UCB]=hk(PCg),[_ko,KCg]=Yko(PCg);function vPI(g){const{__scopeCheckbox:A,checked:I,children:e,defaultChecked:t,disabled:o,form:B,name:C,onCheckedChange:Q,required:i,value:E="on",internal_do_not_use_render:n}=g,[s,r]=xR({prop:I,defaultProp:t??!1,onChange:Q,caller:PCg}),[a,c]=z.useState(null),[h,l]=z.useState(null),[D,d]=z.useState(null),y=a?!!B||!!a.closest("form"):!0,w={checked:s,disabled:o,setChecked:r,control:a,setControl:c,name:C,form:B,value:E,userClick:D,onUserClick:d,required:i,defaultChecked:wf(t)?!1:t,isFormControl:y,bubbleInput:h,setBubbleInput:l};return T.jsx(_ko,{scope:A,...w,children:qPI(n)?n(w):e})}sP(vPI,"CheckboxProvider");var bko="CheckboxTrigger",Hko=z.forwardRef(sP(function({__scopeCheckbox:A,onKeyDown:I,onClick:e,...t},o){const{control:B,value:C,disabled:Q,checked:i,required:E,setControl:n,setChecked:s,onUserClick:r,isFormControl:a,bubbleInput:c}=KCg(bko,A),h=Gi(o,n),l=z.useRef(i);return z.useEffect(()=>{const D=B?.form;if(D){const d=sP(()=>s(l.current),"reset");return D.addEventListener("reset",d),()=>D.removeEventListener("reset",d)}},[B,s]),T.jsx(yQ.button,{type:"button",role:"checkbox","aria-checked":wf(i)?"mixed":i,"aria-required":E,"data-state":LCg(i),"data-disabled":Q?"":void 0,disabled:Q,value:C,...t,ref:h,onKeyDown:fo(I,D=>{D.key==="Enter"&&D.preventDefault()}),onClick:fo(e,D=>{const d=D.isPropagationStopped();r({requestedChecked:wf(i)?!0:!i,hasConsumerStoppedPropagation:d}),s(y=>wf(y)?!0:!y),c&&a&&(d||D.stopPropagation())})})},"CheckboxTrigger")),TPI=z.forwardRef(sP(function(A,I){const{__scopeCheckbox:e,name:t,checked:o,defaultChecked:B,required:C,disabled:Q,value:i,onCheckedChange:E,form:n,...s}=A;return T.jsx(vPI,{__scopeCheckbox:e,checked:o,defaultChecked:B,disabled:Q,required:C,onCheckedChange:E,name:t,form:n,value:i,internal_do_not_use_render:({isFormControl:r})=>T.jsxs(T.Fragment,{children:[T.jsx(Hko,{...s,ref:I,__scopeCheckbox:e}),r&&T.jsx(Zko,{__scopeCheckbox:e})]})})},"Checkbox")),vko="CheckboxIndicator",Tko=z.forwardRef(sP(function(A,I){const{__scopeCheckbox:e,forceMount:t,...o}=A,B=KCg(vko,e);return T.jsx(AS,{present:t||wf(B.checked)||B.checked===!0,children:T.jsx(yQ.span,{"data-state":LCg(B.checked),"data-disabled":B.disabled?"":void 0,...o,ref:I,style:{pointerEvents:"none",...A.style}})})},"CheckboxIndicator")),qko="CheckboxBubbleInput",Zko=z.forwardRef(sP(function({__scopeCheckbox:A,onClick:I,...e},t){const{control:o,userClick:B,checked:C,defaultChecked:Q,required:i,disabled:E,name:n,value:s,form:r,bubbleInput:a,setBubbleInput:c}=KCg(qko,A),h=Gi(t,c),l=hBg(o),D=z.useRef(!1),d=z.useRef(C),y=z.useRef(B),w=z.useRef(null);z.useEffect(()=>{const G=a;if(!G)return;const m=window.HTMLInputElement.prototype,k=Object.getOwnPropertyDescriptor(m,"checked").set;if(!k)return;const S=d.current!==C;d.current=C;const R=B!==null&&B!==y.current;if(y.current=B,R)w.current=S?null:B,S&&(G.indeterminate=wf(C),k.call(G,wf(C)?!1:C)),G.dispatchEvent(new Event("click",{bubbles:!B.hasConsumerStoppedPropagation}));else if(S){const x=w.current;w.current=null;const N=x?.requestedChecked===C;D.current=!0,G.indeterminate=wf(C),k.call(G,wf(C)?!1:C),G.dispatchEvent(new Event("click",{bubbles:!(N&&x.hasConsumerStoppedPropagation)})),D.current=!1}},[a,C,B]);const u=z.useRef(wf(C)?!1:C);return T.jsx(yQ.input,{type:"checkbox","aria-hidden":!0,defaultChecked:Q??u.current,required:i,disabled:E,name:n,value:s,form:r,...e,tabIndex:-1,ref:h,onClick:fo(I,G=>{D.current&&G.stopPropagation()}),style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function qPI(g){return typeof g=="function"}sP(qPI,"isFunction");function wf(g){return g==="indeterminate"}sP(wf,"isIndeterminate");function LCg(g){return wf(g)?"indeterminate":g?"checked":"unchecked"}sP(LCg,"getState");const roA=z.forwardRef(({className:g,...A},I)=>T.jsx(TPI,{ref:I,className:co("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",g),...A,children:T.jsx(Tko,{className:co("rf-flex rf-items-center rf-justify-center rf-text-current"),children:T.jsx(sF,{className:"rf-h-4 rf-w-4"})})}));roA.displayName=TPI.displayName;const Hb=fmA,Oko=RmA,ZPI=z.forwardRef(({className:g,...A},I)=>T.jsx(TtA,{className:co("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",g),...A,ref:I}));ZPI.displayName=TtA.displayName;const xL=z.forwardRef(({className:g,children:A,showOverlay:I=!0,...e},t)=>T.jsxs(Oko,{children:[T.jsx(ZPI,{className:co(I?"":"rf-hidden")}),T.jsx(ZtA,{ref:t,className:co("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",g),...e,children:A})]}));xL.displayName=ZtA.displayName;const FL=({className:g,...A})=>T.jsx("div",{className:co("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",g),...A});FL.displayName="DialogHeader";const _O=({className:g,...A})=>T.jsx("div",{className:co("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",g),...A});_O.displayName="DialogFooter";const UL=z.forwardRef(({className:g,...A},I)=>T.jsx(NmA,{ref:I,className:co("rf-text-lg rf-font-semibold",g),...A}));UL.displayName=NmA.displayName;const vb=z.forwardRef(({className:g,...A},I)=>T.jsx(xmA,{ref:I,className:co("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",g),...A}));vb.displayName=xmA.displayName;const rpA={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},Wko="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let YCg=null;const _Cg=async()=>(YCg||(YCg=import(Wko)),YCg),Vko=g=>(A,I)=>{const e=new Headers(I?.headers),t={};return e.forEach((o,B)=>{t[B]=o}),fetch(`${g?.apiBase??Jm}/proxy`,{...I,headers:{...t,"X-Target-Url":A.toString(),"X-Sender-Origin":t.origin??"","X-Sender-Host":t.host??"https://easyeda.com","X-Sender-Referer":t.referer??"","X-Sender-User-Agent":t["user-agent"]??"","X-Sender-Cookie":t.cookie??"",authority:t.authority??"","content-type":t["content-type"]??"",...g?.headers}})},jko=async(g,A=10)=>{const I=encodeURIComponent(g),e=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${A}&q=${I}`);if(!e.ok)throw new Error(`JLCPCB API error: ${e.status}`);return(await e.json()).components??[]},zko=g=>({lcscId:g.lcsc,manufacturer:g.mfr,description:g.description,partNumber:`C${g.lcsc}`,package:g.package,price:g.price,stock:g.stock,isBasic:g.is_basic}),OPI=async(g,A)=>{const{fetchEasyEDAComponent:I}=await _Cg();return I(g,{fetch:Vko(A),includeModelMetadata:A?.includeModelMetadata})},Xko=async(g,A)=>{const{convertRawEasyToTsx:I}=await _Cg(),e=await OPI(g,A);return I({rawEasy:e})},$ko=async(g,A)=>{const{EasyEdaJsonSchema:I,convertEasyEdaJsonToCircuitJson:e}=await _Cg(),t=await OPI(g,{...A,includeModelMetadata:!1}),o=I.parse(t);return e(o,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function JL(g){return Array.isArray?Array.isArray(g):VPI(g)==="[object Array]"}function AMo(g){if(typeof g=="string")return g;if(typeof g=="bigint")return g.toString();const A=g+"";return A=="0"&&1/g==-1/0?"-0":A}function bCg(g){return g==null?"":AMo(g)}function GG(g){return typeof g=="string"}function cpA(g){return typeof g=="number"}function gMo(g){return g===!0||g===!1||IMo(g)&&VPI(g)=="[object Boolean]"}function WPI(g){return typeof g=="object"}function IMo(g){return WPI(g)&&g!==null}function NS(g){return g!=null}function hpA(g){return!g.trim().length}function VPI(g){return g==null?g===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(g)}const eMo="Incorrect 'index' type",HCg="Invalid doc index: must be a non-negative integer within the bounds of the docs array",tMo=g=>`Invalid value for key ${g}`,oMo=g=>`Pattern length exceeds max of ${g}.`,BMo=g=>`Missing ${g} property in key`,CMo=g=>`Property 'weight' in key '${g}' must be a positive integer`,QMo="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",jPI=Object.prototype.hasOwnProperty;var iMo=class{constructor(g){this._keys=[],this._keyMap={};let A=0;g.forEach(I=>{const e=zPI(I);this._keys.push(e),this._keyMap[e.id]=e,A+=e.weight}),this._keys.forEach(I=>{I.weight/=A})}get(g){return this._keyMap[g]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function zPI(g){let A=null,I=null,e=null,t=1,o=null;if(GG(g)||JL(g))e=g,A=XPI(g),I=lpA(g);else{if(!jPI.call(g,"name"))throw new Error(BMo("name"));const B=g.name;if(e=B,jPI.call(g,"weight")&&g.weight!==void 0&&(t=g.weight,t<=0))throw new Error(CMo(lpA(B)));A=XPI(B),I=lpA(B),o=g.getFn??null}return{path:A,id:I,weight:t,src:e,getFn:o}}function XPI(g){return JL(g)?g:g.split(".")}function lpA(g){return JL(g)?g.join("."):g}function EMo(g,A){const I=[];let e=!1;const t=(o,B,C,Q)=>{if(NS(o))if(!B[C])I.push(Q!==void 0?{v:o,i:Q}:o);else{const i=o[B[C]];if(!NS(i))return;if(C===B.length-1&&(GG(i)||cpA(i)||gMo(i)||typeof i=="bigint"))I.push(Q!==void 0?{v:bCg(i),i:Q}:bCg(i));else if(JL(i)){e=!0;for(let E=0,n=i.length;E<n;E+=1)t(i[E],B,C+1,E)}else B.length&&t(i,B,C+1,Q)}};return t(g,GG(A)?A.split("."):A,0),e?I:I[0]}const cQ=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(g,A)=>g.score===A.score?g.idx<A.idx?-1:1:g.score<A.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:EMo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function nMo(g){return g>=9&&g<=13||g===32||g===160}function sMo(g=1,A=3){const I=new Map,e=Math.pow(10,A);return{get(t){let o=0,B=!1;for(let Q=0;Q<t.length;Q++)nMo(t.charCodeAt(Q))?B=!1:B||(o++,B=!0);if(o===0&&(o=1),I.has(o))return I.get(o);const C=Math.round(e/Math.pow(o,.5*g))/e;return I.set(o,C),C},clear(){I.clear()}}}var vCg=class{constructor({getFn:g=cQ.getFn,fieldNormWeight:A=cQ.fieldNormWeight}={}){this.norm=sMo(A,3),this.getFn=g,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(g=[]){this.docs=g}setIndexRecords(g=[]){this.records=g}setKeys(g=[]){this.keys=g,this._keysMap={},g.forEach((A,I)=>{this._keysMap[A.id]=I})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const g=this.docs.length;this.records=new Array(g);let A=0;if(GG(this.docs[0]))for(let I=0;I<g;I++){const e=this._createStringRecord(this.docs[I],I);e&&(this.records[A++]=e)}else for(let I=0;I<g;I++)this.records[A++]=this._createObjectRecord(this.docs[I],I);this.records.length=A,this.norm.clear()}add(g,A){if(!Number.isInteger(A)||A<0)throw new Error(HCg);if(GG(g)){const e=this._createStringRecord(g,A);return e&&this.records.push(e),e}const I=this._createObjectRecord(g,A);return this.records.push(I),I}removeAt(g){if(!Number.isInteger(g)||g<0)throw new Error(HCg);for(let A=0,I=this.records.length;A<I;A+=1)if(this.records[A].i===g){this.records.splice(A,1);break}for(let A=0,I=this.records.length;A<I;A+=1)this.records[A].i>g&&(this.records[A].i-=1)}removeAll(g){const A=new Set;for(const e of g)Number.isInteger(e)&&e>=0&&A.add(e);if(A.size===0)return;this.records=this.records.filter(e=>!A.has(e.i));const I=Array.from(A).sort((e,t)=>e-t);for(const e of this.records){let t=0,o=I.length;for(;t<o;){const B=t+o>>>1;I[B]<e.i?t=B+1:o=B}e.i-=t}}getValueForItemAtKeyId(g,A){return g[this._keysMap[A]]}size(){return this.records.length}_createStringRecord(g,A){return!NS(g)||hpA(g)?null:{v:g,i:A,n:this.norm.get(g)}}_createObjectRecord(g,A){const I={i:A,$:{}};for(let e=0,t=this.keys.length;e<t;e++){const o=this.keys[e],B=o.getFn?o.getFn(g):this.getFn(g,o.path);if(NS(B)){if(JL(B)){const C=[];for(let Q=0,i=B.length;Q<i;Q+=1){const E=B[Q];if(NS(E)){if(GG(E)){if(!hpA(E)){const n={v:E,i:Q,n:this.norm.get(E)};C.push(n)}}else if(NS(E.v)){const n=GG(E.v)?E.v:bCg(E.v);if(!hpA(n)){const s={v:n,i:E.i,n:this.norm.get(n)};C.push(s)}}}}I.$[e]=C}else if(GG(B)&&!hpA(B)){const C={v:B,n:this.norm.get(B)};I.$[e]=C}}}return I}toJSON(){return{keys:this.keys.map(({getFn:g,...A})=>A),records:this.records}}};function $PI(g,A,{getFn:I=cQ.getFn,fieldNormWeight:e=cQ.fieldNormWeight}={}){const t=new vCg({getFn:I,fieldNormWeight:e});return t.setKeys(g.map(zPI)),t.setSources(A),t.create(),t}function aMo(g,{getFn:A=cQ.getFn,fieldNormWeight:I=cQ.fieldNormWeight}={}){const{keys:e,records:t}=g,o=new vCg({getFn:A,fieldNormWeight:I});return o.setKeys(e),o.setIndexRecords(t),o}function rMo(g=[],A=cQ.minMatchCharLength){const I=[];let e=-1,t=-1,o=0;for(let B=g.length;o<B;o+=1){const C=g[o];C&&e===-1?e=o:!C&&e!==-1&&(t=o-1,t-e+1>=A&&I.push([e,t]),e=-1)}return g[o-1]&&o-e>=A&&I.push([e,o-1]),I}function cMo(g,A,I,{location:e=cQ.location,distance:t=cQ.distance,threshold:o=cQ.threshold,findAllMatches:B=cQ.findAllMatches,minMatchCharLength:C=cQ.minMatchCharLength,includeMatches:Q=cQ.includeMatches,ignoreLocation:i=cQ.ignoreLocation}={}){if(A.length>32)throw new Error(oMo(32));const E=A.length,n=g.length,s=Math.max(0,Math.min(e,n));let r=o,a=s;const c=(p,k)=>{const S=p/E;if(i)return S;const R=Math.abs(s-k);return t?S+R/t:R?1:S},h=C>1||Q,l=h?Array(n):[];let D;for(;(D=g.indexOf(A,a))>-1;){const p=c(0,D);if(r=Math.min(p,r),a=D+E,h){let k=0;for(;k<E;)l[D+k]=1,k+=1}}a=-1;let d=[],y=1,w=0,u=E+n;const G=1<<E-1;for(let p=0;p<E;p+=1){let k=0,S=u;for(;k<S;)c(p,s+S)<=r?k=S:u=S,S=Math.floor((u-k)/2+k);u=S;let R=Math.max(1,s-S+1);const x=B?n:Math.min(s+S,n)+E,N=Array(x+2);N[x+1]=(1<<p)-1;for(let U=x;U>=R;U-=1){const K=U-1,Y=I[g[K]];if(N[U]=(N[U+1]<<1|1)&Y,p&&(N[U]|=(d[U+1]|d[U])<<1|1|d[U+1]),N[U]&G&&(y=c(p,K),y<=r)){if(r=y,a=K,w=p,a<=s)break;R=Math.max(1,2*s-a)}}if(c(p+1,s)>r)break;d=N}if(h&&a>=0){const p=Math.min(n-1,a+E-1+w);for(let k=a;k<=p;k+=1)I[g[k]]&&(l[k]=1)}const m={isMatch:a>=0,score:Math.max(.001,y)};if(h){const p=rMo(l,C);p.length?Q&&(m.indices=p):m.isMatch=!1}return m}function hMo(g){const A={};for(let I=0,e=g.length;I<e;I+=1){const t=g.charAt(I);A[t]=(A[t]||0)|1<<e-I-1}return A}function TCg(g){if(g.length<=1)return g;g.sort((I,e)=>I[0]-e[0]||I[1]-e[1]);const A=[g[0]];for(let I=1,e=g.length;I<e;I+=1){const t=A[A.length-1],o=g[I];o[0]<=t[1]+1?t[1]=Math.max(t[1],o[1]):A.push(o)}return A}const A4I={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},lMo=new RegExp("["+Object.keys(A4I).join("")+"]","g"),coA=typeof String.prototype.normalize=="function"?g=>g.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(lMo,A=>A4I[A]):g=>g;var qCg=class{constructor(g,{location:A=cQ.location,threshold:I=cQ.threshold,distance:e=cQ.distance,includeMatches:t=cQ.includeMatches,findAllMatches:o=cQ.findAllMatches,minMatchCharLength:B=cQ.minMatchCharLength,isCaseSensitive:C=cQ.isCaseSensitive,ignoreDiacritics:Q=cQ.ignoreDiacritics,ignoreLocation:i=cQ.ignoreLocation}={}){if(this.options={location:A,threshold:I,distance:e,includeMatches:t,findAllMatches:o,minMatchCharLength:B,isCaseSensitive:C,ignoreDiacritics:Q,ignoreLocation:i},g=C?g:g.toLowerCase(),g=Q?coA(g):g,this.pattern=g,this.chunks=[],!this.pattern.length)return;const E=(s,r)=>{this.chunks.push({pattern:s,alphabet:hMo(s),startIndex:r})},n=this.pattern.length;if(n>32){let s=0;const r=n%32,a=n-r;for(;s<a;)E(this.pattern.substr(s,32),s),s+=32;if(r){const c=n-32;E(this.pattern.substr(c),c)}}else E(this.pattern,0)}searchIn(g){const{isCaseSensitive:A,ignoreDiacritics:I,includeMatches:e}=this.options;if(g=A?g:g.toLowerCase(),g=I?coA(g):g,this.pattern===g){if(g.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const a={isMatch:!0,score:0};return e&&(a.indices=[[0,g.length-1]]),a}const{location:t,distance:o,threshold:B,findAllMatches:C,minMatchCharLength:Q,ignoreLocation:i}=this.options,E=[];let n=0,s=!1;this.chunks.forEach(({pattern:a,alphabet:c,startIndex:h})=>{const{isMatch:l,score:D,indices:d}=cMo(g,a,c,{location:t+h,distance:o,threshold:B,findAllMatches:C,minMatchCharLength:Q,includeMatches:e,ignoreLocation:i});l&&(s=!0),n+=D,l&&d&&E.push(...d)});const r={isMatch:s,score:s?n/this.chunks.length:1};return s&&e&&(r.indices=TCg(E)),r}};const DMo=new Set(["fuzzy","include"]);function dMo(g){return g.startsWith("inverse")}const ZCg=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:g=>({type:"exact",search(A){const I=A===g;return{isMatch:I,score:I?0:1,indices:[0,g.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:g=>({type:"include",search(A){let I=0,e;const t=[],o=g.length;for(;(e=A.indexOf(g,I))>-1;)I=e+o,t.push([e,I-1]);const B=!!t.length;return{isMatch:B,score:B?0:1,indices:t}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:g=>({type:"prefix-exact",search(A){const I=A.startsWith(g);return{isMatch:I,score:I?0:1,indices:[0,g.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:g=>({type:"inverse-prefix-exact",search(A){const I=!A.startsWith(g);return{isMatch:I,score:I?0:1,indices:[0,A.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:g=>({type:"inverse-suffix-exact",search(A){const I=!A.endsWith(g);return{isMatch:I,score:I?0:1,indices:[0,A.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:g=>({type:"suffix-exact",search(A){const I=A.endsWith(g);return{isMatch:I,score:I?0:1,indices:[A.length-g.length,A.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:g=>({type:"inverse-exact",search(A){const I=A.indexOf(g)===-1;return{isMatch:I,score:I?0:1,indices:[0,A.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(g,A={})=>{const I=new qCg(g,{location:A.location??cQ.location,threshold:A.threshold??cQ.threshold,distance:A.distance??cQ.distance,includeMatches:A.includeMatches??cQ.includeMatches,findAllMatches:A.findAllMatches??cQ.findAllMatches,minMatchCharLength:A.minMatchCharLength??cQ.minMatchCharLength,isCaseSensitive:A.isCaseSensitive??cQ.isCaseSensitive,ignoreDiacritics:A.ignoreDiacritics??cQ.ignoreDiacritics,ignoreLocation:A.ignoreLocation??cQ.ignoreLocation});return{type:"fuzzy",search(e){return I.searchIn(e)}}}}],g4I=ZCg.length,yMo="\0",wMo="|";function uMo(g){const A=[],I=g.length;let e=0;for(;e<I;){for(;e<I&&g[e]===" ";)e++;if(e>=I)break;let t=e;for(;t<I&&g[t]!==" "&&g[t]!=='"';)t++;if(t<I&&g[t]==='"'){for(t++;t<I;){if(g[t]==='"'){const o=t+1;if(o>=I||g[o]===" "){t++;break}if(g[o]==="$"&&(o+1>=I||g[o+1]===" ")){t+=2;break}}t++}A.push(g.substring(e,t)),e=t}else{for(;t<I&&g[t]!==" ";)t++;A.push(g.substring(e,t)),e=t}}return A}function I4I(g,A){const I=g.match(A);return I?I[1]:null}function GMo(g,A={}){return g.replace(/\\\|/g,yMo).split(wMo).map(I=>{const e=uMo(I.replace(/\u0000/g,"|").trim()).filter(o=>o&&!!o.trim()),t=[];for(let o=0,B=e.length;o<B;o+=1){const C=e[o];let Q=!1,i=-1;for(;!Q&&++i<g4I;){const E=ZCg[i],n=I4I(C,E.multiRegex);n&&(t.push(E.create(n,A)),Q=!0)}if(!Q)for(i=-1;++i<g4I;){const E=ZCg[i],n=I4I(C,E.singleRegex);if(n){t.push(E.create(n,A));break}}}return t})}var mMo=class{constructor(g,{isCaseSensitive:A=cQ.isCaseSensitive,ignoreDiacritics:I=cQ.ignoreDiacritics,includeMatches:e=cQ.includeMatches,minMatchCharLength:t=cQ.minMatchCharLength,ignoreLocation:o=cQ.ignoreLocation,findAllMatches:B=cQ.findAllMatches,location:C=cQ.location,threshold:Q=cQ.threshold,distance:i=cQ.distance}={}){this.query=null,this.options={isCaseSensitive:A,ignoreDiacritics:I,includeMatches:e,minMatchCharLength:t,findAllMatches:B,ignoreLocation:o,location:C,threshold:Q,distance:i},g=A?g:g.toLowerCase(),g=I?coA(g):g,this.pattern=g,this.query=GMo(this.pattern,this.options)}static condition(g,A){return A.useExtendedSearch}searchIn(g){const A=this.query;if(!A)return{isMatch:!1,score:1};const{includeMatches:I,isCaseSensitive:e,ignoreDiacritics:t}=this.options;g=e?g:g.toLowerCase(),g=t?coA(g):g;let o=0;const B=[];let C=0,Q=!1;for(let i=0,E=A.length;i<E;i+=1){const n=A[i];B.length=0,o=0,Q=!1;for(let s=0,r=n.length;s<r;s+=1){const a=n[s],{isMatch:c,indices:h,score:l}=a.search(g);if(c)o+=1,C+=l,dMo(a.type)&&(Q=!0),I&&(DMo.has(a.type)?B.push(...h):B.push(h));else{C=0,o=0,B.length=0,Q=!1;break}}if(o){const s={isMatch:!0,score:C/o};return Q&&(s.hasInverse=!0),I&&(s.indices=TCg(B)),s}}return{isMatch:!1,score:1}}};const OCg=[];function WCg(...g){OCg.push(...g)}function DpA(g,A){for(let I=0,e=OCg.length;I<e;I+=1){const t=OCg[I];if(t.condition(g,A))return new t(g,A)}return new qCg(g,A)}const dpA={AND:"$and",OR:"$or"},VCg={PATH:"$path",PATTERN:"$val"},jCg=g=>!!(g[dpA.AND]||g[dpA.OR]),pMo=g=>!!g[VCg.PATH],kMo=g=>!JL(g)&&WPI(g)&&!jCg(g),e4I=g=>({[dpA.AND]:Object.keys(g).map(A=>({[A]:g[A]}))});function t4I(g,A,{auto:I=!0}={}){const e=t=>{if(GG(t)){const Q={keyId:null,pattern:t};return I&&(Q.searcher=DpA(t,A)),Q}const o=Object.keys(t),B=pMo(t);if(!B&&o.length>1&&!jCg(t))return e(e4I(t));if(kMo(t)){const Q=B?t[VCg.PATH]:o[0],i=B?t[VCg.PATTERN]:t[Q];if(!GG(i))throw new Error(tMo(Q));const E={keyId:lpA(Q),pattern:i};return I&&(E.searcher=DpA(i,A)),E}const C={children:[],operator:o[0]};return o.forEach(Q=>{const i=t[Q];JL(i)&&i.forEach(E=>{C.children.push(e(E))})}),C};return jCg(g)||(g=e4I(g)),e(g)}function zCg(g,{ignoreFieldNorm:A=cQ.ignoreFieldNorm}){let I=1;return g.forEach(({key:e,norm:t,score:o})=>{const B=e?e.weight:null;I*=Math.pow(o===0&&B?Number.EPSILON:o,(B||1)*(A?1:t))}),I}function MMo(g,{ignoreFieldNorm:A=cQ.ignoreFieldNorm}){g.forEach(I=>{I.score=zCg(I.matches,{ignoreFieldNorm:A})})}var SMo=class{constructor(g,A){this.limit=g,this.heap=[],this.comparator=A}get size(){return this.heap.length}insert(g){this.size<this.limit?(this.heap.push(g),this._bubbleUp(this.size-1)):this.comparator(g,this.heap[0])<0&&(this.heap[0]=g,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(g){const A=this.heap;for(;g>0;){const I=g-1>>1;if(this.comparator(A[g],A[I])<=0)break;const e=A[g];A[g]=A[I],A[I]=e,g=I}}_sinkDown(g){const A=this.heap,I=A.length;let e=g;do{g=e;const t=2*g+1,o=2*g+2;if(t<I&&this.comparator(A[t],A[e])>0&&(e=t),o<I&&this.comparator(A[o],A[e])>0&&(e=o),e!==g){const B=A[g];A[g]=A[e],A[e]=B}}while(e!==g)}};function fMo(g){const A=[];return g.matches.forEach(I=>{if(!NS(I.indices)||!I.indices.length)return;const e={indices:I.indices,value:I.value};I.key&&(e.key=I.key.id),I.idx>-1&&(e.refIndex=I.idx),A.push(e)}),A}function RMo(g,A,{includeMatches:I=cQ.includeMatches,includeScore:e=cQ.includeScore}={}){return g.map(t=>{const{idx:o}=t,B={item:A[o],refIndex:o};return I&&(B.matches=fMo(t)),e&&(B.score=t.score),B})}const NMo=/[\p{L}\p{M}\p{N}_]+/gu,o4I=new WeakSet;function xMo(g){o4I.has(g)||(o4I.add(g),console.warn(`[Fuse] tokenize regex ${g} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function FMo(g){if(typeof g=="function"){let A=!1;return I=>{const e=g(I);if(!A&&(A=!0,!Array.isArray(e)||e.some(t=>typeof t!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(e)?"array containing non-strings":typeof e}.`);return e}}return g instanceof RegExp?(g.global||xMo(g),A=>A.match(g)||[]):A=>A.match(NMo)||[]}function XCg({isCaseSensitive:g=!1,ignoreDiacritics:A=!1,tokenize:I}={}){const e=FMo(I);return{tokenize(t){return g||(t=t.toLowerCase()),A&&(t=coA(t)),e(t)}}}var UMo=class{static condition(g,A){return A.useTokenSearch}constructor(g,A){this.options=A,this.analyzer=XCg({isCaseSensitive:A.isCaseSensitive,ignoreDiacritics:A.ignoreDiacritics,tokenize:A.tokenize});const I=this.analyzer.tokenize(g),{df:e,fieldCount:t}=A._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const o of I){this.termSearchers.push(new qCg(o,{location:A.location,threshold:A.threshold,distance:A.distance,includeMatches:A.includeMatches,findAllMatches:A.findAllMatches,minMatchCharLength:A.minMatchCharLength,isCaseSensitive:A.isCaseSensitive,ignoreDiacritics:A.ignoreDiacritics,ignoreLocation:!0}));const B=e.get(o)||0,C=Math.log(1+(t-B+.5)/(B+.5));this.idfWeights.push(C)}this.combineAll=A.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(g){if(!this.termSearchers.length)return{isMatch:!1,score:1};const A=[];let I=0,e=0,t=0,o=0;const B=this.combineAll&&!this.useMask?new Set:null;for(let i=0;i<this.termSearchers.length;i++){const E=this.termSearchers[i].searchIn(g),n=this.idfWeights[i];e+=n,E.isMatch&&(t++,I+=n*(1-E.score),E.indices&&A.push(...E.indices),this.combineAll&&(this.useMask?o|=1<<i:B.add(i)))}if(t===0)return{isMatch:!1,score:1};const C=e>0?1-I/e:0,Q={isMatch:!0,score:Math.max(.001,C)};return this.options.includeMatches&&A.length&&(Q.indices=TCg(A)),this.combineAll&&(this.useMask?Q.matchedMask=o:Q.matchedTerms=B,Q.termCount=this.numTerms),Q}};function $Cg(g,A,I,e){const t=e.tokenize(A);if(!t.length)return;g.fieldCount++,g.docFieldCount.set(I,(g.docFieldCount.get(I)||0)+1);const o=new Set(t);let B=g.docTermFieldHits.get(I);B||(B=new Map,g.docTermFieldHits.set(I,B));for(const C of o)B.set(C,(B.get(C)||0)+1),g.df.set(C,(g.df.get(C)||0)+1)}function B4I(g,A,I,e){const{i:t,v:o,$:B}=A;if(o!==void 0){$Cg(g,o,t,e);return}if(B)for(let C=0;C<I;C++){const Q=B[C];if(Q)if(Array.isArray(Q))for(const i of Q)$Cg(g,i.v,t,e);else $Cg(g,Q.v,t,e)}}function JMo(g,A,I){const e={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const t of g)B4I(e,t,A,I);return e}function PMo(g,A,I,e){B4I(g,A,I,e)}function KMo(g,A){const I=g.docFieldCount.get(A);if(I===void 0)return;g.fieldCount-=I,g.docFieldCount.delete(A);const e=g.docTermFieldHits.get(A);if(e){for(const[t,o]of e){const B=(g.df.get(t)||0)-o;B<=0?g.df.delete(t):g.df.set(t,B)}g.docTermFieldHits.delete(A)}}function C4I(g,A){if(A.length===0)return;const I=Array.from(new Set(A)).sort((C,Q)=>C-Q);for(const C of I)KMo(g,C);const e=C=>{let Q=0,i=I.length;for(;Q<i;){const E=Q+i>>>1;I[E]<C?Q=E+1:i=E}return C-Q},t=I[0],o=new Map;for(const[C,Q]of g.docFieldCount)o.set(C>t?e(C):C,Q);g.docFieldCount=o;const B=new Map;for(const[C,Q]of g.docTermFieldHits)B.set(C>t?e(C):C,Q);g.docTermFieldHits=B}var PL=class{constructor(g,A,I){this.options={...cQ,...A},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new iMo(this.options.keys),this._docs=g,this._myIndex=null,this._invertedIndex=null,this.setCollection(g,I),this._lastQuery=null,this._lastSearcher=null}_getSearcher(g){if(this._lastQuery===g)return this._lastSearcher;const A=DpA(g,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=g,this._lastSearcher=A,A}setCollection(g,A){if(this._docs=g,A&&!(A instanceof vCg))throw new Error(eMo);if(this._myIndex=A||$PI(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const I=XCg({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=JMo(this._myIndex.records,this._myIndex.keys.length,I)}this._invalidateSearcherCache()}add(g){if(!NS(g))return;this._docs.push(g);const A=this._myIndex.add(g,this._docs.length-1);if(this._invertedIndex&&A){const I=XCg({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});PMo(this._invertedIndex,A,this._myIndex.keys.length,I)}this._invalidateSearcherCache()}remove(g=()=>!1){const A=[],I=[];for(let e=0,t=this._docs.length;e<t;e+=1)g(this._docs[e],e)&&(A.push(this._docs[e]),I.push(e));if(I.length){this._invertedIndex&&C4I(this._invertedIndex,I);const e=new Set(I);this._docs=this._docs.filter((t,o)=>!e.has(o)),this._myIndex.removeAll(I),this._invalidateSearcherCache()}return A}removeAt(g){if(!Number.isInteger(g)||g<0||g>=this._docs.length)throw new Error(HCg);this._invertedIndex&&C4I(this._invertedIndex,[g]);const A=this._docs.splice(g,1)[0];return this._myIndex.removeAt(g),this._invalidateSearcherCache(),A}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(g=>this._keyStore.get(g.id)||g)}search(g,A){const{limit:I=-1}=A||{},{includeMatches:e,includeScore:t,shouldSort:o,sortFn:B,ignoreFieldNorm:C}=this.options;if(GG(g)&&!g.trim()){let s=this._docs.map((r,a)=>({item:r,refIndex:a}));return cpA(I)&&I>-1&&(s=s.slice(0,I)),s}const Q=o&&cpA(I)&&I>0&&GG(g),i=B,E=(s,r)=>i(s,r)||s.idx-r.idx;let n;if(Q){const s=new SMo(I,E);GG(this._docs[0])?this._searchStringList(g,{heap:s,ignoreFieldNorm:C}):this._searchObjectList(g,{heap:s,ignoreFieldNorm:C}),n=s.extractSorted()}else n=GG(g)?GG(this._docs[0])?this._searchStringList(g):this._searchObjectList(g):this._searchLogical(g),MMo(n,{ignoreFieldNorm:C}),o&&n.sort(GG(g)?E:i),cpA(I)&&I>-1&&(n=n.slice(0,I));return RMo(n,this._docs,{includeMatches:e,includeScore:t})}_searchStringList(g,{heap:A,ignoreFieldNorm:I}={}){const e=this._getSearcher(g),t=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:o}=this._myIndex,B=A?null:[];return o.forEach(({v:C,i:Q,n:i})=>{if(!NS(C))return;const E=e.searchIn(C);if(E.isMatch){const n={score:E.score,value:C,norm:i,indices:E.indices};t&&(n.matchedMask=E.matchedMask,n.matchedTerms=E.matchedTerms,n.termCount=E.termCount);const s=[n];if(!t||this._coversAllTokens(s)){const r={item:C,idx:Q,matches:s};A?(r.score=zCg(r.matches,{ignoreFieldNorm:I}),A.insert(r)):B.push(r)}}}),B}_searchLogical(g){const A=t4I(g,this.options),I=this._normalizedKeys(),e=(C,Q,i)=>{if(!("children"in C)){const{keyId:r,searcher:a}=C;let c;return r===null?(c=[],I.forEach((h,l)=>{c.push(...this._findMatches({key:h,value:Q[l],searcher:a}))})):c=this._findMatches({key:this._keyStore.get(r),value:this._myIndex.getValueForItemAtKeyId(Q,r),searcher:a}),c&&c.length?[{idx:i,item:Q,matches:c}]:[]}const{children:E,operator:n}=C,s=[];for(let r=0,a=E.length;r<a;r+=1){const c=E[r],h=e(c,Q,i);if(h.length)s.push(...h);else if(n===dpA.AND)return[]}return s},t=this._myIndex.records,o=new Map,B=[];return t.forEach(({$:C,i:Q})=>{if(NS(C)){const i=e(A,C,Q);i.length&&(o.has(Q)||(o.set(Q,{idx:Q,item:C,matches:[]}),B.push(o.get(Q))),i.forEach(({matches:E})=>{o.get(Q).matches.push(...E)}))}}),B}_searchObjectList(g,{heap:A,ignoreFieldNorm:I}={}){const e=this._getSearcher(g),t=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:o}=this._myIndex,B=this._normalizedKeys(),C=A?null:[];return o.forEach(({$:Q,i})=>{if(!NS(Q))return;const E=[];let n=!1,s=!1;if(B.forEach((r,a)=>{const c=this._findMatches({key:r,value:Q[a],searcher:e});c.length?(E.push(...c),c[0].hasInverse&&(s=!0)):n=!0}),!(s&&n)&&E.length&&(!t||this._coversAllTokens(E))){const r={idx:i,item:Q,matches:E};A?(r.score=zCg(r.matches,{ignoreFieldNorm:I}),A.insert(r)):C.push(r)}}),C}_findMatches({key:g,value:A,searcher:I}){if(!NS(A))return[];const e=[];if(JL(A))A.forEach(({v:t,i:o,n:B})=>{if(!NS(t))return;const C=I.searchIn(t);if(C.isMatch){const Q={score:C.score,key:g,value:t,idx:o,norm:B,indices:C.indices,hasInverse:C.hasInverse};C.termCount!==void 0&&(Q.matchedMask=C.matchedMask,Q.matchedTerms=C.matchedTerms,Q.termCount=C.termCount),e.push(Q)}});else{const{v:t,n:o}=A,B=I.searchIn(t);if(B.isMatch){const C={score:B.score,key:g,value:t,norm:o,indices:B.indices,hasInverse:B.hasInverse};B.termCount!==void 0&&(C.matchedMask=B.matchedMask,C.matchedTerms=B.matchedTerms,C.termCount=B.termCount),e.push(C)}}return e}_coversAllTokens(g){const A=g.length?g[0].termCount:void 0;if(A===void 0)return!0;if(A<=31){let e=0;for(let t=0;t<g.length;t++)e|=g[t].matchedMask||0;return e===2**A-1}const I=new Set;for(let e=0;e<g.length;e++){const t=g[e].matchedTerms;if(t)for(const o of t)I.add(o)}return I.size===A}};PL.version="7.5.0",PL.createIndex=$PI,PL.parseIndex=aMo,PL.config=cQ,PL.match=function(g,A,I){if(I&&I.useTokenSearch)throw new Error(QMo);return DpA(g,{...cQ,...I}).searchIn(A)},PL.parseQuery=t4I,WCg(mMo),WCg(UMo),PL.use=function(...g){g.forEach(A=>WCg(A))};var LMo=PL;const YMo="https://kicad-mod-cache.tscircuit.com";let AQg=null,hoA=null,gQg=null;const _Mo=async()=>AQg||hoA||(hoA=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(g=>g.json()).then(g=>(AQg=g,hoA=null,g)),hoA),bMo=async(g,A=20)=>{const I=await _Mo();return gQg||(gQg=new LMo(I)),gQg.search(g).slice(0,A).map(e=>e.item)},HMo=g=>{const A=g.replace(".pretty/","/").replace(".kicad_mod",""),I=`kicad:${A}`;return{path:g,qualifiedName:I,description:A}},vMo=g=>g.replace(/^\/+/,"").split("/").map(A=>encodeURIComponent(A)).join("/"),TMo=async g=>{const A=await fetch(`${YMo}/${vMo(g)}`);if(!A.ok)throw new Error(`KiCad footprint fetch failed: ${A.status}`);const I=await A.text(),{KicadFootprintToCircuitJsonConverter:e}=await RS("kicad-to-circuit-json"),t=new e;return t.addFile(g.split("/").pop()??"selected-footprint.kicad_mod",I),t.runUntilFinished(),t.getOutput()},Q4I=g=>g?.source==="jlcpcb"||g?.source==="kicad",qMo=async(g,A)=>{if(g.source==="jlcpcb")return $ko(g.component.partNumber,A?.jlcpcb);if(g.source==="kicad")return TMo(g.footprint.path);throw new Error("Footprint preview is not available for this source")},ZMo=({query:g,placeholder:A,isSearching:I,onQueryChange:e,onSubmit:t})=>{const o=z.useCallback(B=>{B.key==="Enter"&&(B.preventDefault(),t())},[t]);return T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[T.jsxs("div",{className:"rf-relative rf-flex-grow",children:[T.jsx(Wog,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),T.jsx(yCg,{placeholder:A,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:g,onChange:B=>e(B.target.value),onKeyDown:o})]}),T.jsx(si,{onClick:t,disabled:I||g.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:I?T.jsx(mS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):T.jsxs(T.Fragment,{children:[T.jsx(Wog,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),T.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},OMo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),WMo=g=>OMo.format(g),i4I=g=>{switch(g.source){case"tscircuit.com":{const A=g.package;return`tscircuit-${A.package_id??`${A.org_owner_tscircuit_handle??"unknown"}-${A.unscoped_name??A.name??"package"}`}`}case"jlcpcb":return`jlc-${g.component.lcscId}`;case"kicad":return`kicad-${g.footprint.path}`;default:return"unknown"}},VMo=g=>{switch(g.source){case"tscircuit.com":return g.package.unscoped_name;case"jlcpcb":return g.component.isDirectLookup?g.component.partNumber:g.component.manufacturer;case"kicad":return g.footprint.qualifiedName}},jMo=g=>{switch(g.source){case"tscircuit.com":return g.package.description||(g.package.org_owner_tscircuit_handle?`Component by ${g.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return g.component.description;case"kicad":return g.footprint.description}},zMo=g=>{switch(g.source){case"tscircuit.com":return g.package.name;case"jlcpcb":return g.component.isDirectLookup?void 0:g.component.partNumber;case"kicad":return}},XMo=({results:g,selected:A,onSelect:I,onShowDetails:e})=>{const t=A?i4I(A):null;return T.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:g.map(o=>{const B=i4I(o),C=t===B,Q=VMo(o),i=jMo(o),E=zMo(o),n=o.source==="jlcpcb"?o.component.stock:null,s=o.source==="jlcpcb"?o.component.price:null,r=o.source==="jlcpcb"?o.component.isBasic:null,a=o.source==="jlcpcb"?o.component.isDirectLookup:!1;return T.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${C?"rf-bg-zinc-100":""}`,onClick:()=>I(o),children:[T.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[T.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[T.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[Q,o.source==="jlcpcb"&&r!=null&&T.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${r?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:r?"Basic":"Extended"}),a&&T.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),o.source==="tscircuit.com"&&o.package.is_private&&T.jsx(hco,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),o.source==="jlcpcb"&&n!=null?T.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[n.toLocaleString()," in stock"]}):null]}),T.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[E?T.jsx("span",{className:"rf-mr-2",children:E}):null,i]})]}),T.jsxs("div",{children:[o.source==="tscircuit.com"&&e?T.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:T.jsx(si,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:c=>{c.stopPropagation(),e(o)},children:"See Details"})}):o.source==="jlcpcb"&&n!=null?T.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[n.toLocaleString()," in stock"]}):null,s!=null&&T.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:WMo(s)})]})]},B)})})},$Mo=({circuitJson:g,error:A,isLoading:I,height:e})=>T.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:e},children:I?T.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:e},children:[T.jsx(mS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):A?T.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:e},children:T.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[T.jsx(Zog,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),T.jsx("span",{children:A})]})}):g?T.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:T.jsx(vog,{circuitJson:g,height:e,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):T.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:e},children:"No preview"})}),E4I={importComponentDialog:101,importComponentDetailsDialog:102},ASo=({packageResult:g,isOpen:A,onOpenChange:I,isLoading:e,details:t,previewTab:o,onPreviewTabChange:B,isSubmitting:C,onImport:Q})=>{const i=g?.package??null,E=i?.latest_pcb_preview_image_url,n=i?.latest_sch_preview_image_url,s=i?.latest_cad_preview_image_url,r=i?.unscoped_name?.split("/").pop()??i?.unscoped_name,a=i?.org_owner_tscircuit_handle??void 0,c=a?`https://tscircuit.com/${a}`:void 0,h=a&&r?`https://tscircuit.com/${a}/${r}`:void 0;return T.jsx(Hb,{open:A,onOpenChange:I,children:T.jsxs(xL,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:E4I.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[T.jsx(FL,{className:"rf-pb-4 rf-border-b",children:T.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:T.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[T.jsx(UL,{className:"rf-text-xl rf-font-semibold rf-truncate",children:r}),T.jsx(vb,{children:i?.description})]})})}),T.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[a?T.jsxs("div",{children:[T.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),T.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:c?T.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:a}):a})]}):null,(s||E||n)&&T.jsx(T.Fragment,{children:T.jsxs("div",{children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),T.jsxs(jvA,{value:o,onValueChange:l=>B(l),children:[T.jsxs(vDA,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[E&&T.jsx(mx,{value:"pcb",children:"PCB"}),n&&T.jsx(mx,{value:"schematic",children:"Schematic"}),s&&T.jsx(mx,{value:"3d",children:"3D"})]}),T.jsxs("div",{className:"rf-mt-4",children:[T.jsx(Fy,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:E?T.jsx("img",{src:E,alt:`${r??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),T.jsx(Fy,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:n?T.jsx("img",{src:n,alt:`${r??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),T.jsx(Fy,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:s?T.jsx("img",{src:s,alt:`${r??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),t?.ai_description?T.jsxs("section",{children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),T.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:T.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:t.ai_description})})]}):null,t?.ai_usage_instructions?T.jsxs("section",{children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),T.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:T.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:t.ai_usage_instructions})})]}):null,e?T.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[T.jsx(mS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),T.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),T.jsxs(_O,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[T.jsx("div",{className:"rf-flex-1",children:h?T.jsxs(si,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(h,"_blank"),children:[T.jsx(ico,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),T.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[T.jsx(si,{variant:"outline",onClick:()=>I(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),T.jsx(si,{onClick:Q,disabled:C,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:C?T.jsx(mS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},gSo=()=>{const[g,A]=z.useState(null),[I,e]=z.useState(!1),t=z.useCallback(async(B,C)=>{e(!0);try{const Q=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${B}/${C}`)}`);if(!Q.ok)throw new Error(`Failed to load package details: ${Q.status}`);const i=await Q.json();A(i.package??null)}catch(Q){console.error("Failed to fetch package details",Q),A(null)}finally{e(!1)}},[]),o=z.useCallback(()=>{A(null),e(!1)},[]);return{details:g,isLoading:I,fetchDetails:t,reset:o}},ISo=(g,A)=>{const[I,e]=z.useState({circuitJson:null,error:null,isLoading:!1});return z.useEffect(()=>{if(!g||!Q4I(g)){e({circuitJson:null,error:null,isLoading:!1});return}let t=!1;return e({circuitJson:null,error:null,isLoading:!0}),qMo(g,A).then(o=>{t||e({circuitJson:o,error:null,isLoading:!1})}).catch(o=>{t||e({circuitJson:null,error:o instanceof Error?o.message:"Failed to load footprint preview",isLoading:!1})}),()=>{t=!0}},[g,A]),I},eSo=async(g,A)=>{const I={"Content-Type":"application/json"};A&&(I.Authorization=`Bearer ${A}`);const e=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:I,body:JSON.stringify({query:g})});if(!e.ok)throw new Error(`tscircuit registry error: ${e.status}`);return(await e.json()).packages??[]},tSo=({sessionToken:g})=>{const[A,I]=z.useState([]),[e,t]=z.useState(!1),[o,B]=z.useState(null),[C,Q]=z.useState(!1),i=z.useCallback(async n=>{const s=n.trim();if(!s)return[];t(!0),B(null);try{const a=(await eSo(s,g)).map(c=>({source:"tscircuit.com",package:c}));return I(a),a}catch(r){return console.error("Error searching tscircuit packages",r),I([]),B(r instanceof Error?r.message:"Failed to search tscircuit packages"),[]}finally{t(!1),Q(!0)}},[g]),E=z.useCallback(()=>{I([]),t(!1),B(null),Q(!1)},[]);return{results:A,isSearching:e,error:o,hasSearched:C,search:i,reset:E}},oSo=g=>{const A=/^C(\d+)$/i.exec(g.trim());if(!A)return null;const I=Number(A[1]);if(!Number.isSafeInteger(I))return null;const e=`C${A[1]}`;return{source:"jlcpcb",component:{lcscId:I,manufacturer:e,partNumber:e,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},n4I=(g,A)=>{const I=oSo(g);return I?A.some(t=>t.component.partNumber.toUpperCase()===I.component.partNumber)?A:[I,...A]:A},BSo=g=>{const A=g.trim();return/^C\d+/i.test(A)?A.replace(/^C/i,""):A},CSo=()=>{const[g,A]=z.useState([]),[I,e]=z.useState(!1),[t,o]=z.useState(null),[B,C]=z.useState(!1),Q=z.useCallback(async E=>{const n=BSo(E);if(!n)return[];e(!0),o(null);try{const s=await jko(n,10),r=n4I(E,s.map(a=>({source:"jlcpcb",component:zko(a)})));return A(r),r}catch(s){console.error("Error searching JLCPCB components",s);const r=n4I(E,[]);return A(r),o(r.length>0?null:s instanceof Error?s.message:"Failed to search JLCPCB components"),r}finally{e(!1),C(!0)}},[]),i=z.useCallback(()=>{A([]),e(!1),o(null),C(!1)},[]);return{results:g,isSearching:I,error:t,hasSearched:B,search:Q,reset:i}},QSo=()=>{const[g,A]=z.useState([]),[I,e]=z.useState(!1),[t,o]=z.useState(null),[B,C]=z.useState(!1),Q=z.useCallback(async E=>{const n=E.trim();if(!n)return[];e(!0),o(null);try{const r=(await bMo(n,20)).map(a=>({source:"kicad",footprint:HMo(a)}));return A(r),r}catch(s){return console.error("Error searching KiCad footprints",s),A([]),o(s instanceof Error?s.message:"Failed to search KiCad footprints"),[]}finally{e(!1),C(!0)}},[]),i=z.useCallback(()=>{A([]),e(!1),o(null),C(!1)},[]);return{results:g,isSearching:I,error:t,hasSearched:B,search:Q,reset:i}},iSo=({onTscircuitPackageSelected:g,onJlcpcbComponentTsxLoaded:A,onKicadStringSelected:I})=>{const e=[];return g&&e.push("tscircuit.com"),A&&e.push("jlcpcb"),I&&e.push("kicad"),e},ESo=({isOpen:g,onClose:A,jlcpcbProxyRequestHeaders:I,onKicadStringSelected:e,onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:o,jlcpcbProxyApiBase:B,tscircuitSessionToken:C})=>{noA();const Q=z.useMemo(()=>iSo({onKicadStringSelected:e,onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:o}),[e,t,o]),i=Q.length>0,E=Q.length===1,[n,s]=z.useState(Q[0]??"tscircuit.com"),[r,a]=z.useState(""),[c,h]=z.useState(null),{results:l,isSearching:D,error:d,hasSearched:y,search:w,reset:u}=tSo({sessionToken:C}),{results:G,isSearching:m,error:p,hasSearched:k,search:S,reset:R}=CSo(),{results:x,isSearching:N,error:U,hasSearched:K,search:Y,reset:_}=QSo(),{details:Z,isLoading:V,fetchDetails:W,reset:q}=gSo(),[X,tA]=z.useState(null),[IA,QA]=z.useState(!1),[sA,DA]=z.useState("pcb"),[CA,hA]=z.useState(null),[nA,aA]=z.useState(!1),SA=z.useMemo(()=>({jlcpcb:{headers:I,apiBase:B}}),[B,I]),{circuitJson:FA,error:rA,isLoading:NA}=ISo(c,SA),RA=Q4I(c);z.useEffect(()=>{hA(null)},[c]);const xA=z.useCallback(()=>{u(),R(),_(),h(null)},[R,_,u]);z.useEffect(()=>{g||(xA(),a(""),QA(!1),tA(null),hA(null))},[g,xA]),z.useEffect(()=>{a(""),h(null),n==="tscircuit.com"?u():n==="jlcpcb"?R():n==="kicad"&&_()},[n,R,_,u]);const bA=kA=>{h(kA),tA(kA),DA("pcb"),QA(!0),q();const OA=kA.package.org_owner_tscircuit_handle,$A=kA.package.unscoped_name;if(OA&&$A){const og=$A.split("/").pop()??$A;W(OA,og)}},JA=async()=>{r.trim()&&(h(null),n==="tscircuit.com"?await w(r):n==="jlcpcb"?await S(r):n==="kicad"&&await Y(r))},mA=async kA=>{try{if(hA(null),aA(!0),kA.source==="kicad"){if(!e)throw new Error("KiCad handler not provided");await e({result:kA,footprint:kA.footprint.qualifiedName})}else if(kA.source==="jlcpcb"){if(!o)throw new Error("JLCPCB handler not provided");const OA=await Xko(kA.component.partNumber,{headers:I,apiBase:B});await o({result:kA,tsx:OA})}else if(kA.source==="tscircuit.com"){if(!t)throw new Error("tscircuit package handler not provided");const OA=kA.package.org_owner_tscircuit_handle,$A=kA.package.unscoped_name;if(!OA||!$A)throw new Error("Missing package metadata");const og=$A.split("/").pop()??$A,dg=`@tsci/${OA}.${og}`;await t({result:kA,fullPackageName:dg})}return!0}catch(OA){return console.error("Failed to import component",OA),hA(OA instanceof Error?OA.message:"Failed to import component"),!1}finally{aA(!1)}};let LA=[],dA=!1,HA=null,WA=!1;n==="tscircuit.com"?(LA=l,dA=D,HA=d,WA=y):n==="jlcpcb"?(LA=G,dA=m,HA=p,WA=k):n==="kicad"&&(LA=x,dA=N,HA=U,WA=K);const Qg=async()=>{if(!c)return;await mA(c)&&(A(),xA(),a(""))},YA=kA=>{kA||A()},uA=kA=>{QA(kA),kA||tA(null)};return T.jsxs(Hb,{open:g,onOpenChange:YA,children:[T.jsxs(xL,{style:{width:"calc(100vw - 2rem)",maxWidth:RA?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:E4I.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[T.jsxs(FL,{children:[T.jsxs(UL,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",E?rpA[n].label:""," ","Component"]}),T.jsx(vb,{className:"rf-text-sm",children:i?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),i?T.jsxs(jvA,{value:n,onValueChange:kA=>s(kA),className:"rf-min-w-0 rf-w-full",children:[!E&&T.jsx(vDA,{className:"rf-flex rf-w-full rf-gap-2",children:Q.map(kA=>T.jsx(mx,{value:kA,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:rpA[kA].label},kA))}),T.jsxs("div",{className:"rf-min-w-0",style:RA?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[T.jsxs("div",{className:"rf-min-w-0",children:[T.jsx(ZMo,{query:r,placeholder:rpA[n].placeholder,isSearching:dA,onQueryChange:a,onSubmit:JA}),T.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:dA?T.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[T.jsx(mS,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),T.jsx("p",{children:"Searching..."})]}):LA.length>0?T.jsx(XMo,{results:LA,selected:c,onSelect:h,onShowDetails:n==="tscircuit.com"?bA:void 0}):T.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:HA?`Error: ${HA}`:WA?rpA[n].emptyMessage:"Enter a search term to find components"})})]}),RA?T.jsx("div",{className:"rf-mt-4",children:T.jsx($Mo,{circuitJson:FA,error:rA,isLoading:NA,height:325})}):null]})]}):null,CA?T.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:CA}):null,T.jsxs(_O,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[T.jsx(si,{variant:"outline",onClick:A,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),T.jsx(si,{onClick:Qg,disabled:!c||nA,className:"rf-order-1 sm:rf-order-2",children:nA?T.jsx(mS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),T.jsx(ASo,{packageResult:X,isOpen:IA,onOpenChange:uA,isLoading:V,details:Z,previewTab:sA,onPreviewTabChange:kA=>DA(kA),isSubmitting:nA,onImport:()=>{X&&mA(X).then(kA=>{kA&&(QA(!1),A(),xA(),a(""))})}})]})},nSo=g=>{const A=g.match(/export const (\w+) =/);if(!A)throw new Error("Could not determine component name from TSX contents");return A[1]},s4I=g=>{const A=Kc(B=>B.pushEvent),I=Kc(B=>B.upsertFile),e=async({result:B,fullPackageName:C})=>{const i=B.package.unscoped_name??B.package.name;await LC.promise(A({event_type:"INSTALL_PACKAGE",full_package_name:C}),{loading:`Requesting install for "${i}"`,success:`Install requested for "${i}"`,error:E=>`Failed to request install: ${E instanceof Error?E.message:String(E)}`})},t=async({footprint:B})=>{await LC.promise(navigator.clipboard.writeText(B),{loading:`Copying "${B}"`,success:`Copied "${B}" to clipboard`,error:C=>`Failed to copy footprint: ${C instanceof Error?C.message:String(C)}`})},o=async({result:B,tsx:C})=>{const i=`imports/${nSo(C)}.tsx`;await LC.promise(I(i,C),{loading:`Importing ${B.component.partNumber}`,success:`Imported to "${i}"`,error:E=>`Failed to import component: ${E instanceof Error?E.message:String(E)}`})};return T.jsx(ESo,{...g,onTscircuitPackageSelected:e,onKicadStringSelected:t,onJlcpcbComponentTsxLoaded:o})};s4I.displayName="ImportComponentDialogForCli";const sSo=async({circuitJson:g,projectName:A})=>{const{convertCircuitJsonToAltiumZip:I}=await Promise.resolve().then(()=>xTo),e=await I(g,A);return new Blob([new Uint8Array(e)],{type:"application/zip"})},aSo=async({circuitJson:g,projectName:A})=>{await LC.promise((async()=>{const I=await sSo({circuitJson:g,projectName:A});bk(I,{fileName:`${A}_altium_project.zip`})})(),{loading:"Generating Altium project...",success:"Altium project ZIP ready",error:I=>`Failed to generate Altium project: ${I instanceof Error?I.message:String(I)}`})};var IQg={exports:{}},a4I;function rSo(){return a4I||(a4I=1,(function(g,A){var I={env:{},version:""};(function(e){g.exports=e()})(function(){return(function e(t,o,B){function C(E,n){if(!o[E]){if(!t[E]){var s=typeof rU=="function"&&rU;if(!n&&s)return s(E,!0);if(Q)return Q(E,!0);var r=new Error("Cannot find module '"+E+"'");throw r.code="MODULE_NOT_FOUND",r}var a=o[E]={exports:{}};t[E][0].call(a.exports,function(c){var h=t[E][1][c];return C(h||c)},a,a.exports,e,t,o,B)}return o[E].exports}for(var Q=typeof rU=="function"&&rU,i=0;i<B.length;i++)C(B[i]);return C})({1:[function(e,t,o){var B=e("./utils"),C=e("./support"),Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(i){for(var E,n,s,r,a,c,h,l=[],D=0,d=i.length,y=d,w=B.getTypeOf(i)!=="string";D<i.length;)y=d-D,s=w?(E=i[D++],n=D<d?i[D++]:0,D<d?i[D++]:0):(E=i.charCodeAt(D++),n=D<d?i.charCodeAt(D++):0,D<d?i.charCodeAt(D++):0),r=E>>2,a=(3&E)<<4|n>>4,c=1<y?(15&n)<<2|s>>6:64,h=2<y?63&s:64,l.push(Q.charAt(r)+Q.charAt(a)+Q.charAt(c)+Q.charAt(h));return l.join("")},o.decode=function(i){var E,n,s,r,a,c,h=0,l=0,D="data:";if(i.substr(0,D.length)===D)throw new Error("Invalid base64 input, it looks like a data url.");var d,y=3*(i=i.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(i.charAt(i.length-1)===Q.charAt(64)&&y--,i.charAt(i.length-2)===Q.charAt(64)&&y--,y%1!=0)throw new Error("Invalid base64 input, bad content length.");for(d=C.uint8array?new Uint8Array(0|y):new Array(0|y);h<i.length;)E=Q.indexOf(i.charAt(h++))<<2|(r=Q.indexOf(i.charAt(h++)))>>4,n=(15&r)<<4|(a=Q.indexOf(i.charAt(h++)))>>2,s=(3&a)<<6|(c=Q.indexOf(i.charAt(h++))),d[l++]=E,a!==64&&(d[l++]=n),c!==64&&(d[l++]=s);return d}},{"./support":30,"./utils":32}],2:[function(e,t,o){var B=e("./external"),C=e("./stream/DataWorker"),Q=e("./stream/Crc32Probe"),i=e("./stream/DataLengthProbe");function E(n,s,r,a,c){this.compressedSize=n,this.uncompressedSize=s,this.crc32=r,this.compression=a,this.compressedContent=c}E.prototype={getContentWorker:function(){var n=new C(B.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new i("data_length")),s=this;return n.on("end",function(){if(this.streamInfo.data_length!==s.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),n},getCompressedWorker:function(){return new C(B.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},E.createWorkerFrom=function(n,s,r){return n.pipe(new Q).pipe(new i("uncompressedSize")).pipe(s.compressWorker(r)).pipe(new i("compressedSize")).withStreamInfo("compression",s)},t.exports=E},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,o){var B=e("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new B("STORE compression")},uncompressWorker:function(){return new B("STORE decompression")}},o.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,o){var B=e("./utils"),C=(function(){for(var Q,i=[],E=0;E<256;E++){Q=E;for(var n=0;n<8;n++)Q=1&Q?3988292384^Q>>>1:Q>>>1;i[E]=Q}return i})();t.exports=function(Q,i){return Q!==void 0&&Q.length?B.getTypeOf(Q)!=="string"?(function(E,n,s,r){var a=C,c=r+s;E^=-1;for(var h=r;h<c;h++)E=E>>>8^a[255&(E^n[h])];return-1^E})(0|i,Q,Q.length,0):(function(E,n,s,r){var a=C,c=r+s;E^=-1;for(var h=r;h<c;h++)E=E>>>8^a[255&(E^n.charCodeAt(h))];return-1^E})(0|i,Q,Q.length,0):0}},{"./utils":32}],5:[function(e,t,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(e,t,o){var B=null;B=typeof Promise<"u"?Promise:e("lie"),t.exports={Promise:B}},{lie:37}],7:[function(e,t,o){var B=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",C=e("pako"),Q=e("./utils"),i=e("./stream/GenericWorker"),E=B?"uint8array":"array";function n(s,r){i.call(this,"FlateWorker/"+s),this._pako=null,this._pakoAction=s,this._pakoOptions=r,this.meta={}}o.magic="\b\0",Q.inherits(n,i),n.prototype.processChunk=function(s){this.meta=s.meta,this._pako===null&&this._createPako(),this._pako.push(Q.transformTo(E,s.data),!1)},n.prototype.flush=function(){i.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},n.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this._pako=null},n.prototype._createPako=function(){this._pako=new C[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var s=this;this._pako.onData=function(r){s.push({data:r,meta:s.meta})}},o.compressWorker=function(s){return new n("Deflate",s)},o.uncompressWorker=function(){return new n("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,o){function B(a,c){var h,l="";for(h=0;h<c;h++)l+=String.fromCharCode(255&a),a>>>=8;return l}function C(a,c,h,l,D,d){var y,w,u=a.file,G=a.compression,m=d!==E.utf8encode,p=Q.transformTo("string",d(u.name)),k=Q.transformTo("string",E.utf8encode(u.name)),S=u.comment,R=Q.transformTo("string",d(S)),x=Q.transformTo("string",E.utf8encode(S)),N=k.length!==u.name.length,U=x.length!==S.length,K="",Y="",_="",Z=u.dir,V=u.date,W={crc32:0,compressedSize:0,uncompressedSize:0};c&&!h||(W.crc32=a.crc32,W.compressedSize=a.compressedSize,W.uncompressedSize=a.uncompressedSize);var q=0;c&&(q|=8),m||!N&&!U||(q|=2048);var X=0,tA=0;Z&&(X|=16),D==="UNIX"?(tA=798,X|=(function(QA,sA){var DA=QA;return QA||(DA=sA?16893:33204),(65535&DA)<<16})(u.unixPermissions,Z)):(tA=20,X|=(function(QA){return 63&(QA||0)})(u.dosPermissions)),y=V.getUTCHours(),y<<=6,y|=V.getUTCMinutes(),y<<=5,y|=V.getUTCSeconds()/2,w=V.getUTCFullYear()-1980,w<<=4,w|=V.getUTCMonth()+1,w<<=5,w|=V.getUTCDate(),N&&(Y=B(1,1)+B(n(p),4)+k,K+="up"+B(Y.length,2)+Y),U&&(_=B(1,1)+B(n(R),4)+x,K+="uc"+B(_.length,2)+_);var IA="";return IA+=`
|
|
5672
5672
|
\0`,IA+=B(q,2),IA+=G.magic,IA+=B(y,2),IA+=B(w,2),IA+=B(W.crc32,4),IA+=B(W.compressedSize,4),IA+=B(W.uncompressedSize,4),IA+=B(p.length,2),IA+=B(K.length,2),{fileRecord:s.LOCAL_FILE_HEADER+IA+p+K,dirRecord:s.CENTRAL_FILE_HEADER+B(tA,2)+IA+B(R.length,2)+"\0\0\0\0"+B(X,4)+B(l,4)+p+K+R}}var Q=e("../utils"),i=e("../stream/GenericWorker"),E=e("../utf8"),n=e("../crc32"),s=e("../signature");function r(a,c,h,l){i.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=c,this.zipPlatform=h,this.encodeFileName=l,this.streamFiles=a,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}Q.inherits(r,i),r.prototype.push=function(a){var c=a.meta.percent||0,h=this.entriesCount,l=this._sources.length;this.accumulate?this.contentBuffer.push(a):(this.bytesWritten+=a.data.length,i.prototype.push.call(this,{data:a.data,meta:{currentFile:this.currentFile,percent:h?(c+100*(h-l-1))/h:100}}))},r.prototype.openedSource=function(a){this.currentSourceOffset=this.bytesWritten,this.currentFile=a.file.name;var c=this.streamFiles&&!a.file.dir;if(c){var h=C(a,c,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:h.fileRecord,meta:{percent:0}})}else this.accumulate=!0},r.prototype.closedSource=function(a){this.accumulate=!1;var c=this.streamFiles&&!a.file.dir,h=C(a,c,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(h.dirRecord),c)this.push({data:(function(l){return s.DATA_DESCRIPTOR+B(l.crc32,4)+B(l.compressedSize,4)+B(l.uncompressedSize,4)})(a),meta:{percent:100}});else for(this.push({data:h.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},r.prototype.flush=function(){for(var a=this.bytesWritten,c=0;c<this.dirRecords.length;c++)this.push({data:this.dirRecords[c],meta:{percent:100}});var h=this.bytesWritten-a,l=(function(D,d,y,w,u){var G=Q.transformTo("string",u(w));return s.CENTRAL_DIRECTORY_END+"\0\0\0\0"+B(D,2)+B(D,2)+B(d,4)+B(y,4)+B(G.length,2)+G})(this.dirRecords.length,h,a,this.zipComment,this.encodeFileName);this.push({data:l,meta:{percent:100}})},r.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},r.prototype.registerPrevious=function(a){this._sources.push(a);var c=this;return a.on("data",function(h){c.processChunk(h)}),a.on("end",function(){c.closedSource(c.previous.streamInfo),c._sources.length?c.prepareNextSource():c.end()}),a.on("error",function(h){c.error(h)}),this},r.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},r.prototype.error=function(a){var c=this._sources;if(!i.prototype.error.call(this,a))return!1;for(var h=0;h<c.length;h++)try{c[h].error(a)}catch{}return!0},r.prototype.lock=function(){i.prototype.lock.call(this);for(var a=this._sources,c=0;c<a.length;c++)a[c].lock()},t.exports=r},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,o){var B=e("../compressions"),C=e("./ZipFileWorker");o.generateWorker=function(Q,i,E){var n=new C(i.streamFiles,E,i.platform,i.encodeFileName),s=0;try{Q.forEach(function(r,a){s++;var c=(function(d,y){var w=d||y,u=B[w];if(!u)throw new Error(w+" is not a valid compression method !");return u})(a.options.compression,i.compression),h=a.options.compressionOptions||i.compressionOptions||{},l=a.dir,D=a.date;a._compressWorker(c,h).withStreamInfo("file",{name:r,dir:l,date:D,comment:a.comment||"",unixPermissions:a.unixPermissions,dosPermissions:a.dosPermissions}).pipe(n)}),n.entriesCount=s}catch(r){n.error(r)}return n}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,o){function B(){if(!(this instanceof B))return new B;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var C=new B;for(var Q in this)typeof this[Q]!="function"&&(C[Q]=this[Q]);return C}}(B.prototype=e("./object")).loadAsync=e("./load"),B.support=e("./support"),B.defaults=e("./defaults"),B.version="3.10.2",B.loadAsync=function(C,Q){return new B().loadAsync(C,Q)},B.external=e("./external"),t.exports=B},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,o){var B=e("./utils"),C=e("./external"),Q=e("./utf8"),i=e("./zipEntries"),E=e("./stream/Crc32Probe"),n=e("./nodejsUtils");function s(r){return new C.Promise(function(a,c){var h=r.decompressed.getContentWorker().pipe(new E);h.on("error",function(l){c(l)}).on("end",function(){h.streamInfo.crc32!==r.decompressed.crc32?c(new Error("Corrupted zip : CRC32 mismatch")):a()}).resume()})}t.exports=function(r,a){var c=this;return a=B.extend(a||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:Q.utf8decode}),n.isNode&&n.isStream(r)?C.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):B.prepareContent("the loaded zip file",r,!0,a.optimizedBinaryString,a.base64).then(function(h){var l=new i(a);return l.load(h),l}).then(function(h){var l=[C.Promise.resolve(h)],D=h.files;if(a.checkCRC32)for(var d=0;d<D.length;d++)l.push(s(D[d]));return C.Promise.all(l)}).then(function(h){for(var l=h.shift(),D=l.files,d=0;d<D.length;d++){var y=D[d],w=y.fileNameStr,u=B.resolve(y.fileNameStr);c.file(u,y.decompressed,{binary:!0,optimizedBinaryString:!0,date:y.date,dir:y.dir,comment:y.fileCommentStr.length?y.fileCommentStr:null,unixPermissions:y.unixPermissions,dosPermissions:y.dosPermissions,createFolders:a.createFolders}),y.dir||(c.file(u).unsafeOriginalName=w)}return l.zipComment.length&&(c.comment=l.zipComment),c})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,o){var B=e("../utils"),C=e("../stream/GenericWorker");function Q(i,E){C.call(this,"Nodejs stream input adapter for "+i),this._upstreamEnded=!1,this._bindStream(E)}B.inherits(Q,C),Q.prototype._bindStream=function(i){var E=this;(this._stream=i).pause(),i.on("data",function(n){E.push({data:n,meta:{percent:0}})}).on("error",function(n){E.isPaused?this.generatedError=n:E.error(n)}).on("end",function(){E.isPaused?E._upstreamEnded=!0:E.end()})},Q.prototype.pause=function(){return!!C.prototype.pause.call(this)&&(this._stream.pause(),!0)},Q.prototype.resume=function(){return!!C.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=Q},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,o){var B=e("readable-stream").Readable;function C(Q,i,E){B.call(this,i),this._helper=Q;var n=this;Q.on("data",function(s,r){n.push(s)||n._helper.pause(),E&&E(r)}).on("error",function(s){n.emit("error",s)}).on("end",function(){n.push(null)})}e("../utils").inherits(C,B),C.prototype._read=function(){this._helper.resume()},t.exports=C},{"../utils":32,"readable-stream":16}],14:[function(e,t,o){t.exports={isNode:typeof Buffer<"u",newBufferFrom:function(B,C){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(B,C);if(typeof B=="number")throw new Error('The "data" argument must not be a number');return new Buffer(B,C)},allocBuffer:function(B){if(Buffer.alloc)return Buffer.alloc(B);var C=new Buffer(B);return C.fill(0),C},isBuffer:function(B){return Buffer.isBuffer(B)},isStream:function(B){return B&&typeof B.on=="function"&&typeof B.pause=="function"&&typeof B.resume=="function"}}},{}],15:[function(e,t,o){function B(u,G,m){var p,k=Q.getTypeOf(G),S=Q.extend(m||{},n);S.date=S.date||new Date,S.compression!==null&&(S.compression=S.compression.toUpperCase()),typeof S.unixPermissions=="string"&&(S.unixPermissions=parseInt(S.unixPermissions,8)),S.unixPermissions&&16384&S.unixPermissions&&(S.dir=!0),S.dosPermissions&&16&S.dosPermissions&&(S.dir=!0),S.dir&&(u=D(u)),S.createFolders&&(p=l(u))&&d.call(this,p,!0);var R=k==="string"&&S.binary===!1&&S.base64===!1;m&&m.binary!==void 0||(S.binary=!R),(G instanceof s&&G.uncompressedSize===0||S.dir||!G||G.length===0)&&(S.base64=!1,S.binary=!0,G="",S.compression="STORE",k="string");var x=null;x=G instanceof s||G instanceof i?G:c.isNode&&c.isStream(G)?new h(u,G):Q.prepareContent(u,G,S.binary,S.optimizedBinaryString,S.base64);var N=new r(u,x,S);this.files[u]=N}var C=e("./utf8"),Q=e("./utils"),i=e("./stream/GenericWorker"),E=e("./stream/StreamHelper"),n=e("./defaults"),s=e("./compressedObject"),r=e("./zipObject"),a=e("./generate"),c=e("./nodejsUtils"),h=e("./nodejs/NodejsStreamInputAdapter"),l=function(u){u.slice(-1)==="/"&&(u=u.substring(0,u.length-1));var G=u.lastIndexOf("/");return 0<G?u.substring(0,G):""},D=function(u){return u.slice(-1)!=="/"&&(u+="/"),u},d=function(u,G){return G=G!==void 0?G:n.createFolders,u=D(u),this.files[u]||B.call(this,u,null,{dir:!0,createFolders:G}),this.files[u]};function y(u){return Object.prototype.toString.call(u)==="[object RegExp]"}var w={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(u){var G,m,p;for(G in this.files)p=this.files[G],(m=G.slice(this.root.length,G.length))&&G.slice(0,this.root.length)===this.root&&u(m,p)},filter:function(u){var G=[];return this.forEach(function(m,p){u(m,p)&&G.push(p)}),G},file:function(u,G,m){if(arguments.length!==1)return u=this.root+u,B.call(this,u,G,m),this;if(y(u)){var p=u;return this.filter(function(S,R){return!R.dir&&p.test(S)})}var k=this.files[this.root+u];return k&&!k.dir?k:null},folder:function(u){if(!u)return this;if(y(u))return this.filter(function(k,S){return S.dir&&u.test(k)});var G=this.root+u,m=d.call(this,G),p=this.clone();return p.root=m.name,p},remove:function(u){u=this.root+u;var G=this.files[u];if(G||(u.slice(-1)!=="/"&&(u+="/"),G=this.files[u]),G&&!G.dir)delete this.files[u];else for(var m=this.filter(function(k,S){return S.name.slice(0,u.length)===u}),p=0;p<m.length;p++)delete this.files[m[p].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(u){var G,m={};try{if((m=Q.extend(u||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:C.utf8encode})).type=m.type.toLowerCase(),m.compression=m.compression.toUpperCase(),m.type==="binarystring"&&(m.type="string"),!m.type)throw new Error("No output type specified.");Q.checkSupport(m.type),m.platform!=="darwin"&&m.platform!=="freebsd"&&m.platform!=="linux"&&m.platform!=="sunos"||(m.platform="UNIX"),m.platform==="win32"&&(m.platform="DOS");var p=m.comment||this.comment||"";G=a.generateWorker(this,m,p)}catch(k){(G=new i("error")).error(k)}return new E(G,m.type||"string",m.mimeType)},generateAsync:function(u,G){return this.generateInternalStream(u).accumulate(G)},generateNodeStream:function(u,G){return(u=u||{}).type||(u.type="nodebuffer"),this.generateInternalStream(u).toNodejsStream(G)}};t.exports=w},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,t,o){t.exports=e("stream")},{stream:void 0}],17:[function(e,t,o){var B=e("./DataReader");function C(Q){B.call(this,Q);for(var i=0;i<this.data.length;i++)Q[i]=255&Q[i]}e("../utils").inherits(C,B),C.prototype.byteAt=function(Q){return this.data[this.zero+Q]},C.prototype.lastIndexOfSignature=function(Q){for(var i=Q.charCodeAt(0),E=Q.charCodeAt(1),n=Q.charCodeAt(2),s=Q.charCodeAt(3),r=this.length-4;0<=r;--r)if(this.data[r]===i&&this.data[r+1]===E&&this.data[r+2]===n&&this.data[r+3]===s)return r-this.zero;return-1},C.prototype.readAndCheckSignature=function(Q){var i=Q.charCodeAt(0),E=Q.charCodeAt(1),n=Q.charCodeAt(2),s=Q.charCodeAt(3),r=this.readData(4);return i===r[0]&&E===r[1]&&n===r[2]&&s===r[3]},C.prototype.readData=function(Q){if(this.checkOffset(Q),Q===0)return[];var i=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,i},t.exports=C},{"../utils":32,"./DataReader":18}],18:[function(e,t,o){var B=e("../utils");function C(Q){this.data=Q,this.length=Q.length,this.index=0,this.zero=0}C.prototype={checkOffset:function(Q){this.checkIndex(this.index+Q)},checkIndex:function(Q){if(this.length<this.zero+Q||Q<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+Q+"). Corrupted zip ?")},setIndex:function(Q){this.checkIndex(Q),this.index=Q},skip:function(Q){this.setIndex(this.index+Q)},byteAt:function(){},readInt:function(Q){var i,E=0;for(this.checkOffset(Q),i=this.index+Q-1;i>=this.index;i--)E=(E<<8)+this.byteAt(i);return this.index+=Q,E},readString:function(Q){return B.transformTo("string",this.readData(Q))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var Q=this.readInt(4);return new Date(Date.UTC(1980+(Q>>25&127),(Q>>21&15)-1,Q>>16&31,Q>>11&31,Q>>5&63,(31&Q)<<1))}},t.exports=C},{"../utils":32}],19:[function(e,t,o){var B=e("./Uint8ArrayReader");function C(Q){B.call(this,Q)}e("../utils").inherits(C,B),C.prototype.readData=function(Q){this.checkOffset(Q);var i=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,i},t.exports=C},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,o){var B=e("./DataReader");function C(Q){B.call(this,Q)}e("../utils").inherits(C,B),C.prototype.byteAt=function(Q){return this.data.charCodeAt(this.zero+Q)},C.prototype.lastIndexOfSignature=function(Q){return this.data.lastIndexOf(Q)-this.zero},C.prototype.readAndCheckSignature=function(Q){return Q===this.readData(4)},C.prototype.readData=function(Q){this.checkOffset(Q);var i=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,i},t.exports=C},{"../utils":32,"./DataReader":18}],21:[function(e,t,o){var B=e("./ArrayReader");function C(Q){B.call(this,Q)}e("../utils").inherits(C,B),C.prototype.readData=function(Q){if(this.checkOffset(Q),Q===0)return new Uint8Array(0);var i=this.data.subarray(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,i},t.exports=C},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,o){var B=e("../utils"),C=e("../support"),Q=e("./ArrayReader"),i=e("./StringReader"),E=e("./NodeBufferReader"),n=e("./Uint8ArrayReader");t.exports=function(s){var r=B.getTypeOf(s);return B.checkSupport(r),r!=="string"||C.uint8array?r==="nodebuffer"?new E(s):C.uint8array?new n(B.transformTo("uint8array",s)):new Q(B.transformTo("array",s)):new i(s)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,t,o){var B=e("./GenericWorker"),C=e("../utils");function Q(i){B.call(this,"ConvertWorker to "+i),this.destType=i}C.inherits(Q,B),Q.prototype.processChunk=function(i){this.push({data:C.transformTo(this.destType,i.data),meta:i.meta})},t.exports=Q},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,o){var B=e("./GenericWorker"),C=e("../crc32");function Q(){B.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(Q,B),Q.prototype.processChunk=function(i){this.streamInfo.crc32=C(i.data,this.streamInfo.crc32||0),this.push(i)},t.exports=Q},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,o){var B=e("../utils"),C=e("./GenericWorker");function Q(i){C.call(this,"DataLengthProbe for "+i),this.propName=i,this.withStreamInfo(i,0)}B.inherits(Q,C),Q.prototype.processChunk=function(i){if(i){var E=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=E+i.data.length}C.prototype.processChunk.call(this,i)},t.exports=Q},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,o){var B=e("../utils"),C=e("./GenericWorker");function Q(i){C.call(this,"DataWorker");var E=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,i.then(function(n){E.dataIsReady=!0,E.data=n,E.max=n&&n.length||0,E.type=B.getTypeOf(n),E.isPaused||E._tickAndRepeat()},function(n){E.error(n)})}B.inherits(Q,C),Q.prototype.cleanUp=function(){C.prototype.cleanUp.call(this),this.data=null},Q.prototype.resume=function(){return!!C.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,B.delay(this._tickAndRepeat,[],this)),!0)},Q.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(B.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},Q.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var i=null,E=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":i=this.data.substring(this.index,E);break;case"uint8array":i=this.data.subarray(this.index,E);break;case"array":case"nodebuffer":i=this.data.slice(this.index,E)}return this.index=E,this.push({data:i,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=Q},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,o){function B(C){this.name=C||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}B.prototype={push:function(C){this.emit("data",C)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(C){this.emit("error",C)}return!0},error:function(C){return!this.isFinished&&(this.isPaused?this.generatedError=C:(this.isFinished=!0,this.emit("error",C),this.previous&&this.previous.error(C),this.cleanUp()),!0)},on:function(C,Q){return this._listeners[C].push(Q),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(C,Q){if(this._listeners[C])for(var i=0;i<this._listeners[C].length;i++)this._listeners[C][i].call(this,Q)},pipe:function(C){return C.registerPrevious(this)},registerPrevious:function(C){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=C.streamInfo,this.mergeStreamInfo(),this.previous=C;var Q=this;return C.on("data",function(i){Q.processChunk(i)}),C.on("end",function(){Q.end()}),C.on("error",function(i){Q.error(i)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var C=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),C=!0),this.previous&&this.previous.resume(),!C},flush:function(){},processChunk:function(C){this.push(C)},withStreamInfo:function(C,Q){return this.extraStreamInfo[C]=Q,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var C in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,C)&&(this.streamInfo[C]=this.extraStreamInfo[C])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var C="Worker "+this.name;return this.previous?this.previous+" -> "+C:C}},t.exports=B},{}],29:[function(e,t,o){var B=e("../utils"),C=e("./ConvertWorker"),Q=e("./GenericWorker"),i=e("../base64"),E=e("../support"),n=e("../external"),s=null;if(E.nodestream)try{s=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function r(c,h){return new n.Promise(function(l,D){var d=[],y=c._internalType,w=c._outputType,u=c._mimeType;c.on("data",function(G,m){d.push(G),h&&h(m)}).on("error",function(G){d=[],D(G)}).on("end",function(){try{var G=(function(m,p,k){switch(m){case"blob":return B.newBlob(B.transformTo("arraybuffer",p),k);case"base64":return i.encode(p);default:return B.transformTo(m,p)}})(w,(function(m,p){var k,S=0,R=null,x=0;for(k=0;k<p.length;k++)x+=p[k].length;switch(m){case"string":return p.join("");case"array":return Array.prototype.concat.apply([],p);case"uint8array":for(R=new Uint8Array(x),k=0;k<p.length;k++)R.set(p[k],S),S+=p[k].length;return R;case"nodebuffer":return Buffer.concat(p);default:throw new Error("concat : unsupported type '"+m+"'")}})(y,d),u);l(G)}catch(m){D(m)}d=[]}).resume()})}function a(c,h,l){var D=h;switch(h){case"blob":case"arraybuffer":D="uint8array";break;case"base64":D="string"}try{this._internalType=D,this._outputType=h,this._mimeType=l,B.checkSupport(D),this._worker=c.pipe(new C(D)),c.lock()}catch(d){this._worker=new Q("error"),this._worker.error(d)}}a.prototype={accumulate:function(c){return r(this,c)},on:function(c,h){var l=this;return c==="data"?this._worker.on(c,function(D){h.call(l,D.data,D.meta)}):this._worker.on(c,function(){B.delay(h,arguments,l)}),this},resume:function(){return B.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(c){if(B.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new s(this,{objectMode:this._outputType!=="nodebuffer"},c)}},t.exports=a},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,o){if(o.base64=!0,o.array=!0,o.string=!0,o.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",o.nodebuffer=typeof Buffer<"u",o.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")o.blob=!1;else{var B=new ArrayBuffer(0);try{o.blob=new Blob([B],{type:"application/zip"}).size===0}catch{try{var C=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);C.append(B),o.blob=C.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!e("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,o){for(var B=e("./utils"),C=e("./support"),Q=e("./nodejsUtils"),i=e("./stream/GenericWorker"),E=new Array(256),n=0;n<256;n++)E[n]=252<=n?6:248<=n?5:240<=n?4:224<=n?3:192<=n?2:1;E[254]=E[254]=1;function s(){i.call(this,"utf-8 decode"),this.leftOver=null}function r(){i.call(this,"utf-8 encode")}o.utf8encode=function(a){return C.nodebuffer?Q.newBufferFrom(a,"utf-8"):(function(c){var h,l,D,d,y,w=c.length,u=0;for(d=0;d<w;d++)(64512&(l=c.charCodeAt(d)))==55296&&d+1<w&&(64512&(D=c.charCodeAt(d+1)))==56320&&(l=65536+(l-55296<<10)+(D-56320),d++),u+=l<128?1:l<2048?2:l<65536?3:4;for(h=C.uint8array?new Uint8Array(u):new Array(u),d=y=0;y<u;d++)(64512&(l=c.charCodeAt(d)))==55296&&d+1<w&&(64512&(D=c.charCodeAt(d+1)))==56320&&(l=65536+(l-55296<<10)+(D-56320),d++),l<128?h[y++]=l:(l<2048?h[y++]=192|l>>>6:(l<65536?h[y++]=224|l>>>12:(h[y++]=240|l>>>18,h[y++]=128|l>>>12&63),h[y++]=128|l>>>6&63),h[y++]=128|63&l);return h})(a)},o.utf8decode=function(a){return C.nodebuffer?B.transformTo("nodebuffer",a).toString("utf-8"):(function(c){var h,l,D,d,y=c.length,w=new Array(2*y);for(h=l=0;h<y;)if((D=c[h++])<128)w[l++]=D;else if(4<(d=E[D]))w[l++]=65533,h+=d-1;else{for(D&=d===2?31:d===3?15:7;1<d&&h<y;)D=D<<6|63&c[h++],d--;1<d?w[l++]=65533:D<65536?w[l++]=D:(D-=65536,w[l++]=55296|D>>10&1023,w[l++]=56320|1023&D)}return w.length!==l&&(w.subarray?w=w.subarray(0,l):w.length=l),B.applyFromCharCode(w)})(a=B.transformTo(C.uint8array?"uint8array":"array",a))},B.inherits(s,i),s.prototype.processChunk=function(a){var c=B.transformTo(C.uint8array?"uint8array":"array",a.data);if(this.leftOver&&this.leftOver.length){if(C.uint8array){var h=c;(c=new Uint8Array(h.length+this.leftOver.length)).set(this.leftOver,0),c.set(h,this.leftOver.length)}else c=this.leftOver.concat(c);this.leftOver=null}var l=(function(d,y){var w;for((y=y||d.length)>d.length&&(y=d.length),w=y-1;0<=w&&(192&d[w])==128;)w--;return w<0||w===0?y:w+E[d[w]]>y?w:y})(c),D=c;l!==c.length&&(C.uint8array?(D=c.subarray(0,l),this.leftOver=c.subarray(l,c.length)):(D=c.slice(0,l),this.leftOver=c.slice(l,c.length))),this.push({data:o.utf8decode(D),meta:a.meta})},s.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=s,B.inherits(r,i),r.prototype.processChunk=function(a){this.push({data:o.utf8encode(a.data),meta:a.meta})},o.Utf8EncodeWorker=r},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,o){var B=e("./support"),C=e("./base64"),Q=e("./nodejsUtils"),i=e("./external");function E(h){return h}function n(h,l){for(var D=0;D<h.length;++D)l[D]=255&h.charCodeAt(D);return l}e("setimmediate"),o.newBlob=function(h,l){o.checkSupport("blob");try{return new Blob([h],{type:l})}catch{try{var D=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return D.append(h),D.getBlob(l)}catch{throw new Error("Bug : can't construct the Blob.")}}};var s={stringifyByChunk:function(h,l,D){var d=[],y=0,w=h.length;if(w<=D)return String.fromCharCode.apply(null,h);for(;y<w;)l==="array"||l==="nodebuffer"?d.push(String.fromCharCode.apply(null,h.slice(y,Math.min(y+D,w)))):d.push(String.fromCharCode.apply(null,h.subarray(y,Math.min(y+D,w)))),y+=D;return d.join("")},stringifyByChar:function(h){for(var l="",D=0;D<h.length;D++)l+=String.fromCharCode(h[D]);return l},applyCanBeUsed:{uint8array:(function(){try{return B.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return B.nodebuffer&&String.fromCharCode.apply(null,Q.allocBuffer(1)).length===1}catch{return!1}})()}};function r(h){var l=65536,D=o.getTypeOf(h),d=!0;if(D==="uint8array"?d=s.applyCanBeUsed.uint8array:D==="nodebuffer"&&(d=s.applyCanBeUsed.nodebuffer),d)for(;1<l;)try{return s.stringifyByChunk(h,D,l)}catch{l=Math.floor(l/2)}return s.stringifyByChar(h)}function a(h,l){for(var D=0;D<h.length;D++)l[D]=h[D];return l}o.applyFromCharCode=r;var c={};c.string={string:E,array:function(h){return n(h,new Array(h.length))},arraybuffer:function(h){return c.string.uint8array(h).buffer},uint8array:function(h){return n(h,new Uint8Array(h.length))},nodebuffer:function(h){return n(h,Q.allocBuffer(h.length))}},c.array={string:r,array:E,arraybuffer:function(h){return new Uint8Array(h).buffer},uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return Q.newBufferFrom(h)}},c.arraybuffer={string:function(h){return r(new Uint8Array(h))},array:function(h){return a(new Uint8Array(h),new Array(h.byteLength))},arraybuffer:E,uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return Q.newBufferFrom(new Uint8Array(h))}},c.uint8array={string:r,array:function(h){return a(h,new Array(h.length))},arraybuffer:function(h){return h.buffer},uint8array:E,nodebuffer:function(h){return Q.newBufferFrom(h)}},c.nodebuffer={string:r,array:function(h){return a(h,new Array(h.length))},arraybuffer:function(h){return c.nodebuffer.uint8array(h).buffer},uint8array:function(h){return a(h,new Uint8Array(h.length))},nodebuffer:E},o.transformTo=function(h,l){if(l=l||"",!h)return l;o.checkSupport(h);var D=o.getTypeOf(l);return c[D][h](l)},o.resolve=function(h){for(var l=h.split("/"),D=[],d=0;d<l.length;d++){var y=l[d];y==="."||y===""&&d!==0&&d!==l.length-1||(y===".."?D.pop():D.push(y))}return D.join("/")},o.getTypeOf=function(h){if(typeof h=="string")return"string";var l=Object.prototype.toString.call(h);return l==="[object Array]"?"array":B.nodebuffer&&Q.isBuffer(h)?"nodebuffer":B.uint8array&&l==="[object Uint8Array]"?"uint8array":B.arraybuffer&&l==="[object ArrayBuffer]"?"arraybuffer":void 0},o.checkSupport=function(h){if(!B[h.toLowerCase()])throw new Error(h+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(h){var l,D,d="";for(D=0;D<(h||"").length;D++)d+="\\x"+((l=h.charCodeAt(D))<16?"0":"")+l.toString(16).toUpperCase();return d},o.delay=function(h,l,D){setImmediate(function(){h.apply(D||null,l||[])})},o.inherits=function(h,l){function D(){}D.prototype=l.prototype,h.prototype=new D},o.extend=function(){var h,l,D={};for(h=0;h<arguments.length;h++)for(l in arguments[h])Object.prototype.hasOwnProperty.call(arguments[h],l)&&D[l]===void 0&&(D[l]=arguments[h][l]);return D},o.prepareContent=function(h,l,D,d,y){return i.Promise.resolve(l).then(function(w){return B.blob&&(w instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(w))!==-1)?Blob.prototype.arrayBuffer!==void 0?w.arrayBuffer():typeof FileReader<"u"?new i.Promise(function(u,G){var m=new FileReader;m.onload=function(p){u(p.target.result)},m.onerror=function(p){G(p.target.error)},m.readAsArrayBuffer(w)}):i.Promise.reject(new Error(h+" is a Blob, but we have no way of reading it.")):w}).then(function(w){var u=o.getTypeOf(w);return u?(u==="arraybuffer"?w=o.transformTo("uint8array",w):u==="string"&&(y?w=C.decode(w):D&&d!==!0&&(w=(function(G){return n(G,B.uint8array?new Uint8Array(G.length):new Array(G.length))})(w))),w):i.Promise.reject(new Error("Can't read the data of '"+h+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,t,o){var B=e("./reader/readerFor"),C=e("./utils"),Q=e("./signature"),i=e("./zipEntry"),E=e("./support");function n(s){this.files=[],this.loadOptions=s}n.prototype={checkSignature:function(s){if(!this.reader.readAndCheckSignature(s)){this.reader.index-=4;var r=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+C.pretty(r)+", expected "+C.pretty(s)+")")}},isSignature:function(s,r){var a=this.reader.index;this.reader.setIndex(s);var c=this.reader.readString(4)===r;return this.reader.setIndex(a),c},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var s=this.reader.readData(this.zipCommentLength),r=E.uint8array?"uint8array":"array",a=C.transformTo(r,s);this.zipComment=this.loadOptions.decodeFileName(a)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var s,r,a,c=this.zip64EndOfCentralSize-44;0<c;)s=this.reader.readInt(2),r=this.reader.readInt(4),a=this.reader.readData(r),this.zip64ExtensibleData[s]={id:s,length:r,value:a}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var s,r;for(s=0;s<this.files.length;s++)r=this.files[s],this.reader.setIndex(r.localHeaderOffset),this.checkSignature(Q.LOCAL_FILE_HEADER),r.readLocalPart(this.reader),r.handleUTF8(),r.processAttributes()},readCentralDir:function(){var s;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(Q.CENTRAL_FILE_HEADER);)(s=new i({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(s);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var s=this.reader.lastIndexOfSignature(Q.CENTRAL_DIRECTORY_END);if(s<0)throw this.isSignature(0,Q.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(s);var r=s;if(this.checkSignature(Q.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===C.MAX_VALUE_16BITS||this.diskWithCentralDirStart===C.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===C.MAX_VALUE_16BITS||this.centralDirRecords===C.MAX_VALUE_16BITS||this.centralDirSize===C.MAX_VALUE_32BITS||this.centralDirOffset===C.MAX_VALUE_32BITS){if(this.zip64=!0,(s=this.reader.lastIndexOfSignature(Q.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(s),this.checkSignature(Q.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,Q.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(Q.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(Q.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var a=this.centralDirOffset+this.centralDirSize;this.zip64&&(a+=20,a+=12+this.zip64EndOfCentralSize);var c=r-a;if(0<c)this.isSignature(r,Q.CENTRAL_FILE_HEADER)||(this.reader.zero=c);else if(c<0)throw new Error("Corrupted zip: missing "+Math.abs(c)+" bytes.")},prepareReader:function(s){this.reader=B(s)},load:function(s){this.prepareReader(s),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=n},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,t,o){var B=e("./reader/readerFor"),C=e("./utils"),Q=e("./compressedObject"),i=e("./crc32"),E=e("./utf8"),n=e("./compressions"),s=e("./support");function r(a,c){this.options=a,this.loadOptions=c}r.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(a){var c,h;if(a.skip(22),this.fileNameLength=a.readInt(2),h=a.readInt(2),this.fileName=a.readData(this.fileNameLength),a.skip(h),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((c=(function(l){for(var D in n)if(Object.prototype.hasOwnProperty.call(n,D)&&n[D].magic===l)return n[D];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+C.pretty(this.compressionMethod)+" unknown (inner file : "+C.transformTo("string",this.fileName)+")");this.decompressed=new Q(this.compressedSize,this.uncompressedSize,this.crc32,c,a.readData(this.compressedSize))},readCentralPart:function(a){this.versionMadeBy=a.readInt(2),a.skip(2),this.bitFlag=a.readInt(2),this.compressionMethod=a.readString(2),this.date=a.readDate(),this.crc32=a.readInt(4),this.compressedSize=a.readInt(4),this.uncompressedSize=a.readInt(4);var c=a.readInt(2);if(this.extraFieldsLength=a.readInt(2),this.fileCommentLength=a.readInt(2),this.diskNumberStart=a.readInt(2),this.internalFileAttributes=a.readInt(2),this.externalFileAttributes=a.readInt(4),this.localHeaderOffset=a.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");a.skip(c),this.readExtraFields(a),this.parseZIP64ExtraField(a),this.fileComment=a.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var a=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),a==0&&(this.dosPermissions=63&this.externalFileAttributes),a==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var a=B(this.extraFields[1].value);this.uncompressedSize===C.MAX_VALUE_32BITS&&(this.uncompressedSize=a.readInt(8)),this.compressedSize===C.MAX_VALUE_32BITS&&(this.compressedSize=a.readInt(8)),this.localHeaderOffset===C.MAX_VALUE_32BITS&&(this.localHeaderOffset=a.readInt(8)),this.diskNumberStart===C.MAX_VALUE_32BITS&&(this.diskNumberStart=a.readInt(4))}},readExtraFields:function(a){var c,h,l,D=a.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});a.index+4<D;)c=a.readInt(2),h=a.readInt(2),l=a.readData(h),this.extraFields[c]={id:c,length:h,value:l};a.setIndex(D)},handleUTF8:function(){var a=s.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=E.utf8decode(this.fileName),this.fileCommentStr=E.utf8decode(this.fileComment);else{var c=this.findExtraFieldUnicodePath();if(c!==null)this.fileNameStr=c;else{var h=C.transformTo(a,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(h)}var l=this.findExtraFieldUnicodeComment();if(l!==null)this.fileCommentStr=l;else{var D=C.transformTo(a,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(D)}}},findExtraFieldUnicodePath:function(){var a=this.extraFields[28789];if(a){var c=B(a.value);return c.readInt(1)!==1||i(this.fileName)!==c.readInt(4)?null:E.utf8decode(c.readData(a.length-5))}return null},findExtraFieldUnicodeComment:function(){var a=this.extraFields[25461];if(a){var c=B(a.value);return c.readInt(1)!==1||i(this.fileComment)!==c.readInt(4)?null:E.utf8decode(c.readData(a.length-5))}return null}},t.exports=r},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,o){function B(c,h,l){this.name=c,this.dir=l.dir,this.date=l.date,this.comment=l.comment,this.unixPermissions=l.unixPermissions,this.dosPermissions=l.dosPermissions,this._data=h,this._dataBinary=l.binary,this.options={compression:l.compression,compressionOptions:l.compressionOptions}}var C=e("./stream/StreamHelper"),Q=e("./stream/DataWorker"),i=e("./utf8"),E=e("./compressedObject"),n=e("./stream/GenericWorker");B.prototype={internalStream:function(c){var h=null,l="string";try{if(!c)throw new Error("No output type specified.");var D=(l=c.toLowerCase())==="string"||l==="text";l!=="binarystring"&&l!=="text"||(l="string"),h=this._decompressWorker();var d=!this._dataBinary;d&&!D&&(h=h.pipe(new i.Utf8EncodeWorker)),!d&&D&&(h=h.pipe(new i.Utf8DecodeWorker))}catch(y){(h=new n("error")).error(y)}return new C(h,l,"")},async:function(c,h){return this.internalStream(c).accumulate(h)},nodeStream:function(c,h){return this.internalStream(c||"nodebuffer").toNodejsStream(h)},_compressWorker:function(c,h){if(this._data instanceof E&&this._data.compression.magic===c.magic)return this._data.getCompressedWorker();var l=this._decompressWorker();return this._dataBinary||(l=l.pipe(new i.Utf8EncodeWorker)),E.createWorkerFrom(l,c,h)},_decompressWorker:function(){return this._data instanceof E?this._data.getContentWorker():this._data instanceof n?this._data:new Q(this._data)}};for(var s=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],r=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},a=0;a<s.length;a++)B.prototype[s[a]]=r;t.exports=B},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,t,o){(function(B){var C,Q,i=B.MutationObserver||B.WebKitMutationObserver;if(i){var E=0,n=new i(c),s=B.document.createTextNode("");n.observe(s,{characterData:!0}),C=function(){s.data=E=++E%2}}else if(B.setImmediate||B.MessageChannel===void 0)C="document"in B&&"onreadystatechange"in B.document.createElement("script")?function(){var h=B.document.createElement("script");h.onreadystatechange=function(){c(),h.onreadystatechange=null,h.parentNode.removeChild(h),h=null},B.document.documentElement.appendChild(h)}:function(){setTimeout(c,0)};else{var r=new B.MessageChannel;r.port1.onmessage=c,C=function(){r.port2.postMessage(0)}}var a=[];function c(){var h,l;Q=!0;for(var D=a.length;D;){for(l=a,a=[],h=-1;++h<D;)l[h]();D=a.length}Q=!1}t.exports=function(h){a.push(h)!==1||Q||C()}}).call(this,typeof JY<"u"?JY:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(e,t,o){var B=e("immediate");function C(){}var Q={},i=["REJECTED"],E=["FULFILLED"],n=["PENDING"];function s(D){if(typeof D!="function")throw new TypeError("resolver must be a function");this.state=n,this.queue=[],this.outcome=void 0,D!==C&&h(this,D)}function r(D,d,y){this.promise=D,typeof d=="function"&&(this.onFulfilled=d,this.callFulfilled=this.otherCallFulfilled),typeof y=="function"&&(this.onRejected=y,this.callRejected=this.otherCallRejected)}function a(D,d,y){B(function(){var w;try{w=d(y)}catch(u){return Q.reject(D,u)}w===D?Q.reject(D,new TypeError("Cannot resolve promise with itself")):Q.resolve(D,w)})}function c(D){var d=D&&D.then;if(D&&(typeof D=="object"||typeof D=="function")&&typeof d=="function")return function(){d.apply(D,arguments)}}function h(D,d){var y=!1;function w(m){y||(y=!0,Q.reject(D,m))}function u(m){y||(y=!0,Q.resolve(D,m))}var G=l(function(){d(u,w)});G.status==="error"&&w(G.value)}function l(D,d){var y={};try{y.value=D(d),y.status="success"}catch(w){y.status="error",y.value=w}return y}(t.exports=s).prototype.finally=function(D){if(typeof D!="function")return this;var d=this.constructor;return this.then(function(y){return d.resolve(D()).then(function(){return y})},function(y){return d.resolve(D()).then(function(){throw y})})},s.prototype.catch=function(D){return this.then(null,D)},s.prototype.then=function(D,d){if(typeof D!="function"&&this.state===E||typeof d!="function"&&this.state===i)return this;var y=new this.constructor(C);return this.state!==n?a(y,this.state===E?D:d,this.outcome):this.queue.push(new r(y,D,d)),y},r.prototype.callFulfilled=function(D){Q.resolve(this.promise,D)},r.prototype.otherCallFulfilled=function(D){a(this.promise,this.onFulfilled,D)},r.prototype.callRejected=function(D){Q.reject(this.promise,D)},r.prototype.otherCallRejected=function(D){a(this.promise,this.onRejected,D)},Q.resolve=function(D,d){var y=l(c,d);if(y.status==="error")return Q.reject(D,y.value);var w=y.value;if(w)h(D,w);else{D.state=E,D.outcome=d;for(var u=-1,G=D.queue.length;++u<G;)D.queue[u].callFulfilled(d)}return D},Q.reject=function(D,d){D.state=i,D.outcome=d;for(var y=-1,w=D.queue.length;++y<w;)D.queue[y].callRejected(d);return D},s.resolve=function(D){return D instanceof this?D:Q.resolve(new this(C),D)},s.reject=function(D){var d=new this(C);return Q.reject(d,D)},s.all=function(D){var d=this;if(Object.prototype.toString.call(D)!=="[object Array]")return this.reject(new TypeError("must be an array"));var y=D.length,w=!1;if(!y)return this.resolve([]);for(var u=new Array(y),G=0,m=-1,p=new this(C);++m<y;)k(D[m],m);return p;function k(S,R){d.resolve(S).then(function(x){u[R]=x,++G!==y||w||(w=!0,Q.resolve(p,u))},function(x){w||(w=!0,Q.reject(p,x))})}},s.race=function(D){var d=this;if(Object.prototype.toString.call(D)!=="[object Array]")return this.reject(new TypeError("must be an array"));var y=D.length,w=!1;if(!y)return this.resolve([]);for(var u=-1,G=new this(C);++u<y;)m=D[u],d.resolve(m).then(function(p){w||(w=!0,Q.resolve(G,p))},function(p){w||(w=!0,Q.reject(G,p))});var m;return G}},{immediate:36}],38:[function(e,t,o){var B={};(0,e("./lib/utils/common").assign)(B,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=B},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,o){var B=e("./zlib/deflate"),C=e("./utils/common"),Q=e("./utils/strings"),i=e("./zlib/messages"),E=e("./zlib/zstream"),n=Object.prototype.toString,s=0,r=-1,a=0,c=8;function h(D){if(!(this instanceof h))return new h(D);this.options=C.assign({level:r,method:c,chunkSize:16384,windowBits:15,memLevel:8,strategy:a,to:""},D||{});var d=this.options;d.raw&&0<d.windowBits?d.windowBits=-d.windowBits:d.gzip&&0<d.windowBits&&d.windowBits<16&&(d.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new E,this.strm.avail_out=0;var y=B.deflateInit2(this.strm,d.level,d.method,d.windowBits,d.memLevel,d.strategy);if(y!==s)throw new Error(i[y]);if(d.header&&B.deflateSetHeader(this.strm,d.header),d.dictionary){var w;if(w=typeof d.dictionary=="string"?Q.string2buf(d.dictionary):n.call(d.dictionary)==="[object ArrayBuffer]"?new Uint8Array(d.dictionary):d.dictionary,(y=B.deflateSetDictionary(this.strm,w))!==s)throw new Error(i[y]);this._dict_set=!0}}function l(D,d){var y=new h(d);if(y.push(D,!0),y.err)throw y.msg||i[y.err];return y.result}h.prototype.push=function(D,d){var y,w,u=this.strm,G=this.options.chunkSize;if(this.ended)return!1;w=d===~~d?d:d===!0?4:0,typeof D=="string"?u.input=Q.string2buf(D):n.call(D)==="[object ArrayBuffer]"?u.input=new Uint8Array(D):u.input=D,u.next_in=0,u.avail_in=u.input.length;do{if(u.avail_out===0&&(u.output=new C.Buf8(G),u.next_out=0,u.avail_out=G),(y=B.deflate(u,w))!==1&&y!==s)return this.onEnd(y),!(this.ended=!0);u.avail_out!==0&&(u.avail_in!==0||w!==4&&w!==2)||(this.options.to==="string"?this.onData(Q.buf2binstring(C.shrinkBuf(u.output,u.next_out))):this.onData(C.shrinkBuf(u.output,u.next_out)))}while((0<u.avail_in||u.avail_out===0)&&y!==1);return w===4?(y=B.deflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===s):w!==2||(this.onEnd(s),!(u.avail_out=0))},h.prototype.onData=function(D){this.chunks.push(D)},h.prototype.onEnd=function(D){D===s&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=C.flattenChunks(this.chunks)),this.chunks=[],this.err=D,this.msg=this.strm.msg},o.Deflate=h,o.deflate=l,o.deflateRaw=function(D,d){return(d=d||{}).raw=!0,l(D,d)},o.gzip=function(D,d){return(d=d||{}).gzip=!0,l(D,d)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,o){var B=e("./zlib/inflate"),C=e("./utils/common"),Q=e("./utils/strings"),i=e("./zlib/constants"),E=e("./zlib/messages"),n=e("./zlib/zstream"),s=e("./zlib/gzheader"),r=Object.prototype.toString;function a(h){if(!(this instanceof a))return new a(h);this.options=C.assign({chunkSize:16384,windowBits:0,to:""},h||{});var l=this.options;l.raw&&0<=l.windowBits&&l.windowBits<16&&(l.windowBits=-l.windowBits,l.windowBits===0&&(l.windowBits=-15)),!(0<=l.windowBits&&l.windowBits<16)||h&&h.windowBits||(l.windowBits+=32),15<l.windowBits&&l.windowBits<48&&(15&l.windowBits)==0&&(l.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new n,this.strm.avail_out=0;var D=B.inflateInit2(this.strm,l.windowBits);if(D!==i.Z_OK)throw new Error(E[D]);this.header=new s,B.inflateGetHeader(this.strm,this.header)}function c(h,l){var D=new a(l);if(D.push(h,!0),D.err)throw D.msg||E[D.err];return D.result}a.prototype.push=function(h,l){var D,d,y,w,u,G,m=this.strm,p=this.options.chunkSize,k=this.options.dictionary,S=!1;if(this.ended)return!1;d=l===~~l?l:l===!0?i.Z_FINISH:i.Z_NO_FLUSH,typeof h=="string"?m.input=Q.binstring2buf(h):r.call(h)==="[object ArrayBuffer]"?m.input=new Uint8Array(h):m.input=h,m.next_in=0,m.avail_in=m.input.length;do{if(m.avail_out===0&&(m.output=new C.Buf8(p),m.next_out=0,m.avail_out=p),(D=B.inflate(m,i.Z_NO_FLUSH))===i.Z_NEED_DICT&&k&&(G=typeof k=="string"?Q.string2buf(k):r.call(k)==="[object ArrayBuffer]"?new Uint8Array(k):k,D=B.inflateSetDictionary(this.strm,G)),D===i.Z_BUF_ERROR&&S===!0&&(D=i.Z_OK,S=!1),D!==i.Z_STREAM_END&&D!==i.Z_OK)return this.onEnd(D),!(this.ended=!0);m.next_out&&(m.avail_out!==0&&D!==i.Z_STREAM_END&&(m.avail_in!==0||d!==i.Z_FINISH&&d!==i.Z_SYNC_FLUSH)||(this.options.to==="string"?(y=Q.utf8border(m.output,m.next_out),w=m.next_out-y,u=Q.buf2string(m.output,y),m.next_out=w,m.avail_out=p-w,w&&C.arraySet(m.output,m.output,y,w,0),this.onData(u)):this.onData(C.shrinkBuf(m.output,m.next_out)))),m.avail_in===0&&m.avail_out===0&&(S=!0)}while((0<m.avail_in||m.avail_out===0)&&D!==i.Z_STREAM_END);return D===i.Z_STREAM_END&&(d=i.Z_FINISH),d===i.Z_FINISH?(D=B.inflateEnd(this.strm),this.onEnd(D),this.ended=!0,D===i.Z_OK):d!==i.Z_SYNC_FLUSH||(this.onEnd(i.Z_OK),!(m.avail_out=0))},a.prototype.onData=function(h){this.chunks.push(h)},a.prototype.onEnd=function(h){h===i.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=C.flattenChunks(this.chunks)),this.chunks=[],this.err=h,this.msg=this.strm.msg},o.Inflate=a,o.inflate=c,o.inflateRaw=function(h,l){return(l=l||{}).raw=!0,c(h,l)},o.ungzip=c},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,o){var B=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";o.assign=function(i){for(var E=Array.prototype.slice.call(arguments,1);E.length;){var n=E.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(var s in n)n.hasOwnProperty(s)&&(i[s]=n[s])}}return i},o.shrinkBuf=function(i,E){return i.length===E?i:i.subarray?i.subarray(0,E):(i.length=E,i)};var C={arraySet:function(i,E,n,s,r){if(E.subarray&&i.subarray)i.set(E.subarray(n,n+s),r);else for(var a=0;a<s;a++)i[r+a]=E[n+a]},flattenChunks:function(i){var E,n,s,r,a,c;for(E=s=0,n=i.length;E<n;E++)s+=i[E].length;for(c=new Uint8Array(s),E=r=0,n=i.length;E<n;E++)a=i[E],c.set(a,r),r+=a.length;return c}},Q={arraySet:function(i,E,n,s,r){for(var a=0;a<s;a++)i[r+a]=E[n+a]},flattenChunks:function(i){return[].concat.apply([],i)}};o.setTyped=function(i){i?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,C)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,Q))},o.setTyped(B)},{}],42:[function(e,t,o){var B=e("./common"),C=!0,Q=!0;try{String.fromCharCode.apply(null,[0])}catch{C=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Q=!1}for(var i=new B.Buf8(256),E=0;E<256;E++)i[E]=252<=E?6:248<=E?5:240<=E?4:224<=E?3:192<=E?2:1;function n(s,r){if(r<65537&&(s.subarray&&Q||!s.subarray&&C))return String.fromCharCode.apply(null,B.shrinkBuf(s,r));for(var a="",c=0;c<r;c++)a+=String.fromCharCode(s[c]);return a}i[254]=i[254]=1,o.string2buf=function(s){var r,a,c,h,l,D=s.length,d=0;for(h=0;h<D;h++)(64512&(a=s.charCodeAt(h)))==55296&&h+1<D&&(64512&(c=s.charCodeAt(h+1)))==56320&&(a=65536+(a-55296<<10)+(c-56320),h++),d+=a<128?1:a<2048?2:a<65536?3:4;for(r=new B.Buf8(d),h=l=0;l<d;h++)(64512&(a=s.charCodeAt(h)))==55296&&h+1<D&&(64512&(c=s.charCodeAt(h+1)))==56320&&(a=65536+(a-55296<<10)+(c-56320),h++),a<128?r[l++]=a:(a<2048?r[l++]=192|a>>>6:(a<65536?r[l++]=224|a>>>12:(r[l++]=240|a>>>18,r[l++]=128|a>>>12&63),r[l++]=128|a>>>6&63),r[l++]=128|63&a);return r},o.buf2binstring=function(s){return n(s,s.length)},o.binstring2buf=function(s){for(var r=new B.Buf8(s.length),a=0,c=r.length;a<c;a++)r[a]=s.charCodeAt(a);return r},o.buf2string=function(s,r){var a,c,h,l,D=r||s.length,d=new Array(2*D);for(a=c=0;a<D;)if((h=s[a++])<128)d[c++]=h;else if(4<(l=i[h]))d[c++]=65533,a+=l-1;else{for(h&=l===2?31:l===3?15:7;1<l&&a<D;)h=h<<6|63&s[a++],l--;1<l?d[c++]=65533:h<65536?d[c++]=h:(h-=65536,d[c++]=55296|h>>10&1023,d[c++]=56320|1023&h)}return n(d,c)},o.utf8border=function(s,r){var a;for((r=r||s.length)>s.length&&(r=s.length),a=r-1;0<=a&&(192&s[a])==128;)a--;return a<0||a===0?r:a+i[s[a]]>r?a:r}},{"./common":41}],43:[function(e,t,o){t.exports=function(B,C,Q,i){for(var E=65535&B|0,n=B>>>16&65535|0,s=0;Q!==0;){for(Q-=s=2e3<Q?2e3:Q;n=n+(E=E+C[i++]|0)|0,--s;);E%=65521,n%=65521}return E|n<<16|0}},{}],44:[function(e,t,o){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,t,o){var B=(function(){for(var C,Q=[],i=0;i<256;i++){C=i;for(var E=0;E<8;E++)C=1&C?3988292384^C>>>1:C>>>1;Q[i]=C}return Q})();t.exports=function(C,Q,i,E){var n=B,s=E+i;C^=-1;for(var r=E;r<s;r++)C=C>>>8^n[255&(C^Q[r])];return-1^C}},{}],46:[function(e,t,o){var B,C=e("../utils/common"),Q=e("./trees"),i=e("./adler32"),E=e("./crc32"),n=e("./messages"),s=0,r=4,a=0,c=-2,h=-1,l=4,D=2,d=8,y=9,w=286,u=30,G=19,m=2*w+1,p=15,k=3,S=258,R=S+k+1,x=42,N=113,U=1,K=2,Y=3,_=4;function Z(rA,NA){return rA.msg=n[NA],NA}function V(rA){return(rA<<1)-(4<rA?9:0)}function W(rA){for(var NA=rA.length;0<=--NA;)rA[NA]=0}function q(rA){var NA=rA.state,RA=NA.pending;RA>rA.avail_out&&(RA=rA.avail_out),RA!==0&&(C.arraySet(rA.output,NA.pending_buf,NA.pending_out,RA,rA.next_out),rA.next_out+=RA,NA.pending_out+=RA,rA.total_out+=RA,rA.avail_out-=RA,NA.pending-=RA,NA.pending===0&&(NA.pending_out=0))}function X(rA,NA){Q._tr_flush_block(rA,0<=rA.block_start?rA.block_start:-1,rA.strstart-rA.block_start,NA),rA.block_start=rA.strstart,q(rA.strm)}function tA(rA,NA){rA.pending_buf[rA.pending++]=NA}function IA(rA,NA){rA.pending_buf[rA.pending++]=NA>>>8&255,rA.pending_buf[rA.pending++]=255&NA}function QA(rA,NA){var RA,xA,bA=rA.max_chain_length,JA=rA.strstart,mA=rA.prev_length,LA=rA.nice_match,dA=rA.strstart>rA.w_size-R?rA.strstart-(rA.w_size-R):0,HA=rA.window,WA=rA.w_mask,Qg=rA.prev,YA=rA.strstart+S,uA=HA[JA+mA-1],kA=HA[JA+mA];rA.prev_length>=rA.good_match&&(bA>>=2),LA>rA.lookahead&&(LA=rA.lookahead);do if(HA[(RA=NA)+mA]===kA&&HA[RA+mA-1]===uA&&HA[RA]===HA[JA]&&HA[++RA]===HA[JA+1]){JA+=2,RA++;do;while(HA[++JA]===HA[++RA]&&HA[++JA]===HA[++RA]&&HA[++JA]===HA[++RA]&&HA[++JA]===HA[++RA]&&HA[++JA]===HA[++RA]&&HA[++JA]===HA[++RA]&&HA[++JA]===HA[++RA]&&HA[++JA]===HA[++RA]&&JA<YA);if(xA=S-(YA-JA),JA=YA-S,mA<xA){if(rA.match_start=NA,LA<=(mA=xA))break;uA=HA[JA+mA-1],kA=HA[JA+mA]}}while((NA=Qg[NA&WA])>dA&&--bA!=0);return mA<=rA.lookahead?mA:rA.lookahead}function sA(rA){var NA,RA,xA,bA,JA,mA,LA,dA,HA,WA,Qg=rA.w_size;do{if(bA=rA.window_size-rA.lookahead-rA.strstart,rA.strstart>=Qg+(Qg-R)){for(C.arraySet(rA.window,rA.window,Qg,Qg,0),rA.match_start-=Qg,rA.strstart-=Qg,rA.block_start-=Qg,NA=RA=rA.hash_size;xA=rA.head[--NA],rA.head[NA]=Qg<=xA?xA-Qg:0,--RA;);for(NA=RA=Qg;xA=rA.prev[--NA],rA.prev[NA]=Qg<=xA?xA-Qg:0,--RA;);bA+=Qg}if(rA.strm.avail_in===0)break;if(mA=rA.strm,LA=rA.window,dA=rA.strstart+rA.lookahead,HA=bA,WA=void 0,WA=mA.avail_in,HA<WA&&(WA=HA),RA=WA===0?0:(mA.avail_in-=WA,C.arraySet(LA,mA.input,mA.next_in,WA,dA),mA.state.wrap===1?mA.adler=i(mA.adler,LA,WA,dA):mA.state.wrap===2&&(mA.adler=E(mA.adler,LA,WA,dA)),mA.next_in+=WA,mA.total_in+=WA,WA),rA.lookahead+=RA,rA.lookahead+rA.insert>=k)for(JA=rA.strstart-rA.insert,rA.ins_h=rA.window[JA],rA.ins_h=(rA.ins_h<<rA.hash_shift^rA.window[JA+1])&rA.hash_mask;rA.insert&&(rA.ins_h=(rA.ins_h<<rA.hash_shift^rA.window[JA+k-1])&rA.hash_mask,rA.prev[JA&rA.w_mask]=rA.head[rA.ins_h],rA.head[rA.ins_h]=JA,JA++,rA.insert--,!(rA.lookahead+rA.insert<k)););}while(rA.lookahead<R&&rA.strm.avail_in!==0)}function DA(rA,NA){for(var RA,xA;;){if(rA.lookahead<R){if(sA(rA),rA.lookahead<R&&NA===s)return U;if(rA.lookahead===0)break}if(RA=0,rA.lookahead>=k&&(rA.ins_h=(rA.ins_h<<rA.hash_shift^rA.window[rA.strstart+k-1])&rA.hash_mask,RA=rA.prev[rA.strstart&rA.w_mask]=rA.head[rA.ins_h],rA.head[rA.ins_h]=rA.strstart),RA!==0&&rA.strstart-RA<=rA.w_size-R&&(rA.match_length=QA(rA,RA)),rA.match_length>=k)if(xA=Q._tr_tally(rA,rA.strstart-rA.match_start,rA.match_length-k),rA.lookahead-=rA.match_length,rA.match_length<=rA.max_lazy_match&&rA.lookahead>=k){for(rA.match_length--;rA.strstart++,rA.ins_h=(rA.ins_h<<rA.hash_shift^rA.window[rA.strstart+k-1])&rA.hash_mask,RA=rA.prev[rA.strstart&rA.w_mask]=rA.head[rA.ins_h],rA.head[rA.ins_h]=rA.strstart,--rA.match_length!=0;);rA.strstart++}else rA.strstart+=rA.match_length,rA.match_length=0,rA.ins_h=rA.window[rA.strstart],rA.ins_h=(rA.ins_h<<rA.hash_shift^rA.window[rA.strstart+1])&rA.hash_mask;else xA=Q._tr_tally(rA,0,rA.window[rA.strstart]),rA.lookahead--,rA.strstart++;if(xA&&(X(rA,!1),rA.strm.avail_out===0))return U}return rA.insert=rA.strstart<k-1?rA.strstart:k-1,NA===r?(X(rA,!0),rA.strm.avail_out===0?Y:_):rA.last_lit&&(X(rA,!1),rA.strm.avail_out===0)?U:K}function CA(rA,NA){for(var RA,xA,bA;;){if(rA.lookahead<R){if(sA(rA),rA.lookahead<R&&NA===s)return U;if(rA.lookahead===0)break}if(RA=0,rA.lookahead>=k&&(rA.ins_h=(rA.ins_h<<rA.hash_shift^rA.window[rA.strstart+k-1])&rA.hash_mask,RA=rA.prev[rA.strstart&rA.w_mask]=rA.head[rA.ins_h],rA.head[rA.ins_h]=rA.strstart),rA.prev_length=rA.match_length,rA.prev_match=rA.match_start,rA.match_length=k-1,RA!==0&&rA.prev_length<rA.max_lazy_match&&rA.strstart-RA<=rA.w_size-R&&(rA.match_length=QA(rA,RA),rA.match_length<=5&&(rA.strategy===1||rA.match_length===k&&4096<rA.strstart-rA.match_start)&&(rA.match_length=k-1)),rA.prev_length>=k&&rA.match_length<=rA.prev_length){for(bA=rA.strstart+rA.lookahead-k,xA=Q._tr_tally(rA,rA.strstart-1-rA.prev_match,rA.prev_length-k),rA.lookahead-=rA.prev_length-1,rA.prev_length-=2;++rA.strstart<=bA&&(rA.ins_h=(rA.ins_h<<rA.hash_shift^rA.window[rA.strstart+k-1])&rA.hash_mask,RA=rA.prev[rA.strstart&rA.w_mask]=rA.head[rA.ins_h],rA.head[rA.ins_h]=rA.strstart),--rA.prev_length!=0;);if(rA.match_available=0,rA.match_length=k-1,rA.strstart++,xA&&(X(rA,!1),rA.strm.avail_out===0))return U}else if(rA.match_available){if((xA=Q._tr_tally(rA,0,rA.window[rA.strstart-1]))&&X(rA,!1),rA.strstart++,rA.lookahead--,rA.strm.avail_out===0)return U}else rA.match_available=1,rA.strstart++,rA.lookahead--}return rA.match_available&&(xA=Q._tr_tally(rA,0,rA.window[rA.strstart-1]),rA.match_available=0),rA.insert=rA.strstart<k-1?rA.strstart:k-1,NA===r?(X(rA,!0),rA.strm.avail_out===0?Y:_):rA.last_lit&&(X(rA,!1),rA.strm.avail_out===0)?U:K}function hA(rA,NA,RA,xA,bA){this.good_length=rA,this.max_lazy=NA,this.nice_length=RA,this.max_chain=xA,this.func=bA}function nA(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=d,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new C.Buf16(2*m),this.dyn_dtree=new C.Buf16(2*(2*u+1)),this.bl_tree=new C.Buf16(2*(2*G+1)),W(this.dyn_ltree),W(this.dyn_dtree),W(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new C.Buf16(p+1),this.heap=new C.Buf16(2*w+1),W(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new C.Buf16(2*w+1),W(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function aA(rA){var NA;return rA&&rA.state?(rA.total_in=rA.total_out=0,rA.data_type=D,(NA=rA.state).pending=0,NA.pending_out=0,NA.wrap<0&&(NA.wrap=-NA.wrap),NA.status=NA.wrap?x:N,rA.adler=NA.wrap===2?0:1,NA.last_flush=s,Q._tr_init(NA),a):Z(rA,c)}function SA(rA){var NA=aA(rA);return NA===a&&(function(RA){RA.window_size=2*RA.w_size,W(RA.head),RA.max_lazy_match=B[RA.level].max_lazy,RA.good_match=B[RA.level].good_length,RA.nice_match=B[RA.level].nice_length,RA.max_chain_length=B[RA.level].max_chain,RA.strstart=0,RA.block_start=0,RA.lookahead=0,RA.insert=0,RA.match_length=RA.prev_length=k-1,RA.match_available=0,RA.ins_h=0})(rA.state),NA}function FA(rA,NA,RA,xA,bA,JA){if(!rA)return c;var mA=1;if(NA===h&&(NA=6),xA<0?(mA=0,xA=-xA):15<xA&&(mA=2,xA-=16),bA<1||y<bA||RA!==d||xA<8||15<xA||NA<0||9<NA||JA<0||l<JA)return Z(rA,c);xA===8&&(xA=9);var LA=new nA;return(rA.state=LA).strm=rA,LA.wrap=mA,LA.gzhead=null,LA.w_bits=xA,LA.w_size=1<<LA.w_bits,LA.w_mask=LA.w_size-1,LA.hash_bits=bA+7,LA.hash_size=1<<LA.hash_bits,LA.hash_mask=LA.hash_size-1,LA.hash_shift=~~((LA.hash_bits+k-1)/k),LA.window=new C.Buf8(2*LA.w_size),LA.head=new C.Buf16(LA.hash_size),LA.prev=new C.Buf16(LA.w_size),LA.lit_bufsize=1<<bA+6,LA.pending_buf_size=4*LA.lit_bufsize,LA.pending_buf=new C.Buf8(LA.pending_buf_size),LA.d_buf=1*LA.lit_bufsize,LA.l_buf=3*LA.lit_bufsize,LA.level=NA,LA.strategy=JA,LA.method=RA,SA(rA)}B=[new hA(0,0,0,0,function(rA,NA){var RA=65535;for(RA>rA.pending_buf_size-5&&(RA=rA.pending_buf_size-5);;){if(rA.lookahead<=1){if(sA(rA),rA.lookahead===0&&NA===s)return U;if(rA.lookahead===0)break}rA.strstart+=rA.lookahead,rA.lookahead=0;var xA=rA.block_start+RA;if((rA.strstart===0||rA.strstart>=xA)&&(rA.lookahead=rA.strstart-xA,rA.strstart=xA,X(rA,!1),rA.strm.avail_out===0)||rA.strstart-rA.block_start>=rA.w_size-R&&(X(rA,!1),rA.strm.avail_out===0))return U}return rA.insert=0,NA===r?(X(rA,!0),rA.strm.avail_out===0?Y:_):(rA.strstart>rA.block_start&&(X(rA,!1),rA.strm.avail_out),U)}),new hA(4,4,8,4,DA),new hA(4,5,16,8,DA),new hA(4,6,32,32,DA),new hA(4,4,16,16,CA),new hA(8,16,32,32,CA),new hA(8,16,128,128,CA),new hA(8,32,128,256,CA),new hA(32,128,258,1024,CA),new hA(32,258,258,4096,CA)],o.deflateInit=function(rA,NA){return FA(rA,NA,d,15,8,0)},o.deflateInit2=FA,o.deflateReset=SA,o.deflateResetKeep=aA,o.deflateSetHeader=function(rA,NA){return rA&&rA.state?rA.state.wrap!==2?c:(rA.state.gzhead=NA,a):c},o.deflate=function(rA,NA){var RA,xA,bA,JA;if(!rA||!rA.state||5<NA||NA<0)return rA?Z(rA,c):c;if(xA=rA.state,!rA.output||!rA.input&&rA.avail_in!==0||xA.status===666&&NA!==r)return Z(rA,rA.avail_out===0?-5:c);if(xA.strm=rA,RA=xA.last_flush,xA.last_flush=NA,xA.status===x)if(xA.wrap===2)rA.adler=0,tA(xA,31),tA(xA,139),tA(xA,8),xA.gzhead?(tA(xA,(xA.gzhead.text?1:0)+(xA.gzhead.hcrc?2:0)+(xA.gzhead.extra?4:0)+(xA.gzhead.name?8:0)+(xA.gzhead.comment?16:0)),tA(xA,255&xA.gzhead.time),tA(xA,xA.gzhead.time>>8&255),tA(xA,xA.gzhead.time>>16&255),tA(xA,xA.gzhead.time>>24&255),tA(xA,xA.level===9?2:2<=xA.strategy||xA.level<2?4:0),tA(xA,255&xA.gzhead.os),xA.gzhead.extra&&xA.gzhead.extra.length&&(tA(xA,255&xA.gzhead.extra.length),tA(xA,xA.gzhead.extra.length>>8&255)),xA.gzhead.hcrc&&(rA.adler=E(rA.adler,xA.pending_buf,xA.pending,0)),xA.gzindex=0,xA.status=69):(tA(xA,0),tA(xA,0),tA(xA,0),tA(xA,0),tA(xA,0),tA(xA,xA.level===9?2:2<=xA.strategy||xA.level<2?4:0),tA(xA,3),xA.status=N);else{var mA=d+(xA.w_bits-8<<4)<<8;mA|=(2<=xA.strategy||xA.level<2?0:xA.level<6?1:xA.level===6?2:3)<<6,xA.strstart!==0&&(mA|=32),mA+=31-mA%31,xA.status=N,IA(xA,mA),xA.strstart!==0&&(IA(xA,rA.adler>>>16),IA(xA,65535&rA.adler)),rA.adler=1}if(xA.status===69)if(xA.gzhead.extra){for(bA=xA.pending;xA.gzindex<(65535&xA.gzhead.extra.length)&&(xA.pending!==xA.pending_buf_size||(xA.gzhead.hcrc&&xA.pending>bA&&(rA.adler=E(rA.adler,xA.pending_buf,xA.pending-bA,bA)),q(rA),bA=xA.pending,xA.pending!==xA.pending_buf_size));)tA(xA,255&xA.gzhead.extra[xA.gzindex]),xA.gzindex++;xA.gzhead.hcrc&&xA.pending>bA&&(rA.adler=E(rA.adler,xA.pending_buf,xA.pending-bA,bA)),xA.gzindex===xA.gzhead.extra.length&&(xA.gzindex=0,xA.status=73)}else xA.status=73;if(xA.status===73)if(xA.gzhead.name){bA=xA.pending;do{if(xA.pending===xA.pending_buf_size&&(xA.gzhead.hcrc&&xA.pending>bA&&(rA.adler=E(rA.adler,xA.pending_buf,xA.pending-bA,bA)),q(rA),bA=xA.pending,xA.pending===xA.pending_buf_size)){JA=1;break}JA=xA.gzindex<xA.gzhead.name.length?255&xA.gzhead.name.charCodeAt(xA.gzindex++):0,tA(xA,JA)}while(JA!==0);xA.gzhead.hcrc&&xA.pending>bA&&(rA.adler=E(rA.adler,xA.pending_buf,xA.pending-bA,bA)),JA===0&&(xA.gzindex=0,xA.status=91)}else xA.status=91;if(xA.status===91)if(xA.gzhead.comment){bA=xA.pending;do{if(xA.pending===xA.pending_buf_size&&(xA.gzhead.hcrc&&xA.pending>bA&&(rA.adler=E(rA.adler,xA.pending_buf,xA.pending-bA,bA)),q(rA),bA=xA.pending,xA.pending===xA.pending_buf_size)){JA=1;break}JA=xA.gzindex<xA.gzhead.comment.length?255&xA.gzhead.comment.charCodeAt(xA.gzindex++):0,tA(xA,JA)}while(JA!==0);xA.gzhead.hcrc&&xA.pending>bA&&(rA.adler=E(rA.adler,xA.pending_buf,xA.pending-bA,bA)),JA===0&&(xA.status=103)}else xA.status=103;if(xA.status===103&&(xA.gzhead.hcrc?(xA.pending+2>xA.pending_buf_size&&q(rA),xA.pending+2<=xA.pending_buf_size&&(tA(xA,255&rA.adler),tA(xA,rA.adler>>8&255),rA.adler=0,xA.status=N)):xA.status=N),xA.pending!==0){if(q(rA),rA.avail_out===0)return xA.last_flush=-1,a}else if(rA.avail_in===0&&V(NA)<=V(RA)&&NA!==r)return Z(rA,-5);if(xA.status===666&&rA.avail_in!==0)return Z(rA,-5);if(rA.avail_in!==0||xA.lookahead!==0||NA!==s&&xA.status!==666){var LA=xA.strategy===2?(function(dA,HA){for(var WA;;){if(dA.lookahead===0&&(sA(dA),dA.lookahead===0)){if(HA===s)return U;break}if(dA.match_length=0,WA=Q._tr_tally(dA,0,dA.window[dA.strstart]),dA.lookahead--,dA.strstart++,WA&&(X(dA,!1),dA.strm.avail_out===0))return U}return dA.insert=0,HA===r?(X(dA,!0),dA.strm.avail_out===0?Y:_):dA.last_lit&&(X(dA,!1),dA.strm.avail_out===0)?U:K})(xA,NA):xA.strategy===3?(function(dA,HA){for(var WA,Qg,YA,uA,kA=dA.window;;){if(dA.lookahead<=S){if(sA(dA),dA.lookahead<=S&&HA===s)return U;if(dA.lookahead===0)break}if(dA.match_length=0,dA.lookahead>=k&&0<dA.strstart&&(Qg=kA[YA=dA.strstart-1])===kA[++YA]&&Qg===kA[++YA]&&Qg===kA[++YA]){uA=dA.strstart+S;do;while(Qg===kA[++YA]&&Qg===kA[++YA]&&Qg===kA[++YA]&&Qg===kA[++YA]&&Qg===kA[++YA]&&Qg===kA[++YA]&&Qg===kA[++YA]&&Qg===kA[++YA]&&YA<uA);dA.match_length=S-(uA-YA),dA.match_length>dA.lookahead&&(dA.match_length=dA.lookahead)}if(dA.match_length>=k?(WA=Q._tr_tally(dA,1,dA.match_length-k),dA.lookahead-=dA.match_length,dA.strstart+=dA.match_length,dA.match_length=0):(WA=Q._tr_tally(dA,0,dA.window[dA.strstart]),dA.lookahead--,dA.strstart++),WA&&(X(dA,!1),dA.strm.avail_out===0))return U}return dA.insert=0,HA===r?(X(dA,!0),dA.strm.avail_out===0?Y:_):dA.last_lit&&(X(dA,!1),dA.strm.avail_out===0)?U:K})(xA,NA):B[xA.level].func(xA,NA);if(LA!==Y&&LA!==_||(xA.status=666),LA===U||LA===Y)return rA.avail_out===0&&(xA.last_flush=-1),a;if(LA===K&&(NA===1?Q._tr_align(xA):NA!==5&&(Q._tr_stored_block(xA,0,0,!1),NA===3&&(W(xA.head),xA.lookahead===0&&(xA.strstart=0,xA.block_start=0,xA.insert=0))),q(rA),rA.avail_out===0))return xA.last_flush=-1,a}return NA!==r?a:xA.wrap<=0?1:(xA.wrap===2?(tA(xA,255&rA.adler),tA(xA,rA.adler>>8&255),tA(xA,rA.adler>>16&255),tA(xA,rA.adler>>24&255),tA(xA,255&rA.total_in),tA(xA,rA.total_in>>8&255),tA(xA,rA.total_in>>16&255),tA(xA,rA.total_in>>24&255)):(IA(xA,rA.adler>>>16),IA(xA,65535&rA.adler)),q(rA),0<xA.wrap&&(xA.wrap=-xA.wrap),xA.pending!==0?a:1)},o.deflateEnd=function(rA){var NA;return rA&&rA.state?(NA=rA.state.status)!==x&&NA!==69&&NA!==73&&NA!==91&&NA!==103&&NA!==N&&NA!==666?Z(rA,c):(rA.state=null,NA===N?Z(rA,-3):a):c},o.deflateSetDictionary=function(rA,NA){var RA,xA,bA,JA,mA,LA,dA,HA,WA=NA.length;if(!rA||!rA.state||(JA=(RA=rA.state).wrap)===2||JA===1&&RA.status!==x||RA.lookahead)return c;for(JA===1&&(rA.adler=i(rA.adler,NA,WA,0)),RA.wrap=0,WA>=RA.w_size&&(JA===0&&(W(RA.head),RA.strstart=0,RA.block_start=0,RA.insert=0),HA=new C.Buf8(RA.w_size),C.arraySet(HA,NA,WA-RA.w_size,RA.w_size,0),NA=HA,WA=RA.w_size),mA=rA.avail_in,LA=rA.next_in,dA=rA.input,rA.avail_in=WA,rA.next_in=0,rA.input=NA,sA(RA);RA.lookahead>=k;){for(xA=RA.strstart,bA=RA.lookahead-(k-1);RA.ins_h=(RA.ins_h<<RA.hash_shift^RA.window[xA+k-1])&RA.hash_mask,RA.prev[xA&RA.w_mask]=RA.head[RA.ins_h],RA.head[RA.ins_h]=xA,xA++,--bA;);RA.strstart=xA,RA.lookahead=k-1,sA(RA)}return RA.strstart+=RA.lookahead,RA.block_start=RA.strstart,RA.insert=RA.lookahead,RA.lookahead=0,RA.match_length=RA.prev_length=k-1,RA.match_available=0,rA.next_in=LA,rA.input=dA,rA.avail_in=mA,RA.wrap=JA,a},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,o){t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,t,o){t.exports=function(B,C){var Q,i,E,n,s,r,a,c,h,l,D,d,y,w,u,G,m,p,k,S,R,x,N,U,K;Q=B.state,i=B.next_in,U=B.input,E=i+(B.avail_in-5),n=B.next_out,K=B.output,s=n-(C-B.avail_out),r=n+(B.avail_out-257),a=Q.dmax,c=Q.wsize,h=Q.whave,l=Q.wnext,D=Q.window,d=Q.hold,y=Q.bits,w=Q.lencode,u=Q.distcode,G=(1<<Q.lenbits)-1,m=(1<<Q.distbits)-1;A:do{y<15&&(d+=U[i++]<<y,y+=8,d+=U[i++]<<y,y+=8),p=w[d&G];g:for(;;){if(d>>>=k=p>>>24,y-=k,(k=p>>>16&255)===0)K[n++]=65535&p;else{if(!(16&k)){if((64&k)==0){p=w[(65535&p)+(d&(1<<k)-1)];continue g}if(32&k){Q.mode=12;break A}B.msg="invalid literal/length code",Q.mode=30;break A}S=65535&p,(k&=15)&&(y<k&&(d+=U[i++]<<y,y+=8),S+=d&(1<<k)-1,d>>>=k,y-=k),y<15&&(d+=U[i++]<<y,y+=8,d+=U[i++]<<y,y+=8),p=u[d&m];I:for(;;){if(d>>>=k=p>>>24,y-=k,!(16&(k=p>>>16&255))){if((64&k)==0){p=u[(65535&p)+(d&(1<<k)-1)];continue I}B.msg="invalid distance code",Q.mode=30;break A}if(R=65535&p,y<(k&=15)&&(d+=U[i++]<<y,(y+=8)<k&&(d+=U[i++]<<y,y+=8)),a<(R+=d&(1<<k)-1)){B.msg="invalid distance too far back",Q.mode=30;break A}if(d>>>=k,y-=k,(k=n-s)<R){if(h<(k=R-k)&&Q.sane){B.msg="invalid distance too far back",Q.mode=30;break A}if(N=D,(x=0)===l){if(x+=c-k,k<S){for(S-=k;K[n++]=D[x++],--k;);x=n-R,N=K}}else if(l<k){if(x+=c+l-k,(k-=l)<S){for(S-=k;K[n++]=D[x++],--k;);if(x=0,l<S){for(S-=k=l;K[n++]=D[x++],--k;);x=n-R,N=K}}}else if(x+=l-k,k<S){for(S-=k;K[n++]=D[x++],--k;);x=n-R,N=K}for(;2<S;)K[n++]=N[x++],K[n++]=N[x++],K[n++]=N[x++],S-=3;S&&(K[n++]=N[x++],1<S&&(K[n++]=N[x++]))}else{for(x=n-R;K[n++]=K[x++],K[n++]=K[x++],K[n++]=K[x++],2<(S-=3););S&&(K[n++]=K[x++],1<S&&(K[n++]=K[x++]))}break}}break}}while(i<E&&n<r);i-=S=y>>3,d&=(1<<(y-=S<<3))-1,B.next_in=i,B.next_out=n,B.avail_in=i<E?E-i+5:5-(i-E),B.avail_out=n<r?r-n+257:257-(n-r),Q.hold=d,Q.bits=y}},{}],49:[function(e,t,o){var B=e("../utils/common"),C=e("./adler32"),Q=e("./crc32"),i=e("./inffast"),E=e("./inftrees"),n=1,s=2,r=0,a=-2,c=1,h=852,l=592;function D(x){return(x>>>24&255)+(x>>>8&65280)+((65280&x)<<8)+((255&x)<<24)}function d(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new B.Buf16(320),this.work=new B.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function y(x){var N;return x&&x.state?(N=x.state,x.total_in=x.total_out=N.total=0,x.msg="",N.wrap&&(x.adler=1&N.wrap),N.mode=c,N.last=0,N.havedict=0,N.dmax=32768,N.head=null,N.hold=0,N.bits=0,N.lencode=N.lendyn=new B.Buf32(h),N.distcode=N.distdyn=new B.Buf32(l),N.sane=1,N.back=-1,r):a}function w(x){var N;return x&&x.state?((N=x.state).wsize=0,N.whave=0,N.wnext=0,y(x)):a}function u(x,N){var U,K;return x&&x.state?(K=x.state,N<0?(U=0,N=-N):(U=1+(N>>4),N<48&&(N&=15)),N&&(N<8||15<N)?a:(K.window!==null&&K.wbits!==N&&(K.window=null),K.wrap=U,K.wbits=N,w(x))):a}function G(x,N){var U,K;return x?(K=new d,(x.state=K).window=null,(U=u(x,N))!==r&&(x.state=null),U):a}var m,p,k=!0;function S(x){if(k){var N;for(m=new B.Buf32(512),p=new B.Buf32(32),N=0;N<144;)x.lens[N++]=8;for(;N<256;)x.lens[N++]=9;for(;N<280;)x.lens[N++]=7;for(;N<288;)x.lens[N++]=8;for(E(n,x.lens,0,288,m,0,x.work,{bits:9}),N=0;N<32;)x.lens[N++]=5;E(s,x.lens,0,32,p,0,x.work,{bits:5}),k=!1}x.lencode=m,x.lenbits=9,x.distcode=p,x.distbits=5}function R(x,N,U,K){var Y,_=x.state;return _.window===null&&(_.wsize=1<<_.wbits,_.wnext=0,_.whave=0,_.window=new B.Buf8(_.wsize)),K>=_.wsize?(B.arraySet(_.window,N,U-_.wsize,_.wsize,0),_.wnext=0,_.whave=_.wsize):(K<(Y=_.wsize-_.wnext)&&(Y=K),B.arraySet(_.window,N,U-K,Y,_.wnext),(K-=Y)?(B.arraySet(_.window,N,U-K,K,0),_.wnext=K,_.whave=_.wsize):(_.wnext+=Y,_.wnext===_.wsize&&(_.wnext=0),_.whave<_.wsize&&(_.whave+=Y))),0}o.inflateReset=w,o.inflateReset2=u,o.inflateResetKeep=y,o.inflateInit=function(x){return G(x,15)},o.inflateInit2=G,o.inflate=function(x,N){var U,K,Y,_,Z,V,W,q,X,tA,IA,QA,sA,DA,CA,hA,nA,aA,SA,FA,rA,NA,RA,xA,bA=0,JA=new B.Buf8(4),mA=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!x||!x.state||!x.output||!x.input&&x.avail_in!==0)return a;(U=x.state).mode===12&&(U.mode=13),Z=x.next_out,Y=x.output,W=x.avail_out,_=x.next_in,K=x.input,V=x.avail_in,q=U.hold,X=U.bits,tA=V,IA=W,NA=r;A:for(;;)switch(U.mode){case c:if(U.wrap===0){U.mode=13;break}for(;X<16;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}if(2&U.wrap&&q===35615){JA[U.check=0]=255&q,JA[1]=q>>>8&255,U.check=Q(U.check,JA,2,0),X=q=0,U.mode=2;break}if(U.flags=0,U.head&&(U.head.done=!1),!(1&U.wrap)||(((255&q)<<8)+(q>>8))%31){x.msg="incorrect header check",U.mode=30;break}if((15&q)!=8){x.msg="unknown compression method",U.mode=30;break}if(X-=4,rA=8+(15&(q>>>=4)),U.wbits===0)U.wbits=rA;else if(rA>U.wbits){x.msg="invalid window size",U.mode=30;break}U.dmax=1<<rA,x.adler=U.check=1,U.mode=512&q?10:12,X=q=0;break;case 2:for(;X<16;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}if(U.flags=q,(255&U.flags)!=8){x.msg="unknown compression method",U.mode=30;break}if(57344&U.flags){x.msg="unknown header flags set",U.mode=30;break}U.head&&(U.head.text=q>>8&1),512&U.flags&&(JA[0]=255&q,JA[1]=q>>>8&255,U.check=Q(U.check,JA,2,0)),X=q=0,U.mode=3;case 3:for(;X<32;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}U.head&&(U.head.time=q),512&U.flags&&(JA[0]=255&q,JA[1]=q>>>8&255,JA[2]=q>>>16&255,JA[3]=q>>>24&255,U.check=Q(U.check,JA,4,0)),X=q=0,U.mode=4;case 4:for(;X<16;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}U.head&&(U.head.xflags=255&q,U.head.os=q>>8),512&U.flags&&(JA[0]=255&q,JA[1]=q>>>8&255,U.check=Q(U.check,JA,2,0)),X=q=0,U.mode=5;case 5:if(1024&U.flags){for(;X<16;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}U.length=q,U.head&&(U.head.extra_len=q),512&U.flags&&(JA[0]=255&q,JA[1]=q>>>8&255,U.check=Q(U.check,JA,2,0)),X=q=0}else U.head&&(U.head.extra=null);U.mode=6;case 6:if(1024&U.flags&&(V<(QA=U.length)&&(QA=V),QA&&(U.head&&(rA=U.head.extra_len-U.length,U.head.extra||(U.head.extra=new Array(U.head.extra_len)),B.arraySet(U.head.extra,K,_,QA,rA)),512&U.flags&&(U.check=Q(U.check,K,QA,_)),V-=QA,_+=QA,U.length-=QA),U.length))break A;U.length=0,U.mode=7;case 7:if(2048&U.flags){if(V===0)break A;for(QA=0;rA=K[_+QA++],U.head&&rA&&U.length<65536&&(U.head.name+=String.fromCharCode(rA)),rA&&QA<V;);if(512&U.flags&&(U.check=Q(U.check,K,QA,_)),V-=QA,_+=QA,rA)break A}else U.head&&(U.head.name=null);U.length=0,U.mode=8;case 8:if(4096&U.flags){if(V===0)break A;for(QA=0;rA=K[_+QA++],U.head&&rA&&U.length<65536&&(U.head.comment+=String.fromCharCode(rA)),rA&&QA<V;);if(512&U.flags&&(U.check=Q(U.check,K,QA,_)),V-=QA,_+=QA,rA)break A}else U.head&&(U.head.comment=null);U.mode=9;case 9:if(512&U.flags){for(;X<16;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}if(q!==(65535&U.check)){x.msg="header crc mismatch",U.mode=30;break}X=q=0}U.head&&(U.head.hcrc=U.flags>>9&1,U.head.done=!0),x.adler=U.check=0,U.mode=12;break;case 10:for(;X<32;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}x.adler=U.check=D(q),X=q=0,U.mode=11;case 11:if(U.havedict===0)return x.next_out=Z,x.avail_out=W,x.next_in=_,x.avail_in=V,U.hold=q,U.bits=X,2;x.adler=U.check=1,U.mode=12;case 12:if(N===5||N===6)break A;case 13:if(U.last){q>>>=7&X,X-=7&X,U.mode=27;break}for(;X<3;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}switch(U.last=1&q,X-=1,3&(q>>>=1)){case 0:U.mode=14;break;case 1:if(S(U),U.mode=20,N!==6)break;q>>>=2,X-=2;break A;case 2:U.mode=17;break;case 3:x.msg="invalid block type",U.mode=30}q>>>=2,X-=2;break;case 14:for(q>>>=7&X,X-=7&X;X<32;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}if((65535&q)!=(q>>>16^65535)){x.msg="invalid stored block lengths",U.mode=30;break}if(U.length=65535&q,X=q=0,U.mode=15,N===6)break A;case 15:U.mode=16;case 16:if(QA=U.length){if(V<QA&&(QA=V),W<QA&&(QA=W),QA===0)break A;B.arraySet(Y,K,_,QA,Z),V-=QA,_+=QA,W-=QA,Z+=QA,U.length-=QA;break}U.mode=12;break;case 17:for(;X<14;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}if(U.nlen=257+(31&q),q>>>=5,X-=5,U.ndist=1+(31&q),q>>>=5,X-=5,U.ncode=4+(15&q),q>>>=4,X-=4,286<U.nlen||30<U.ndist){x.msg="too many length or distance symbols",U.mode=30;break}U.have=0,U.mode=18;case 18:for(;U.have<U.ncode;){for(;X<3;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}U.lens[mA[U.have++]]=7&q,q>>>=3,X-=3}for(;U.have<19;)U.lens[mA[U.have++]]=0;if(U.lencode=U.lendyn,U.lenbits=7,RA={bits:U.lenbits},NA=E(0,U.lens,0,19,U.lencode,0,U.work,RA),U.lenbits=RA.bits,NA){x.msg="invalid code lengths set",U.mode=30;break}U.have=0,U.mode=19;case 19:for(;U.have<U.nlen+U.ndist;){for(;hA=(bA=U.lencode[q&(1<<U.lenbits)-1])>>>16&255,nA=65535&bA,!((CA=bA>>>24)<=X);){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}if(nA<16)q>>>=CA,X-=CA,U.lens[U.have++]=nA;else{if(nA===16){for(xA=CA+2;X<xA;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}if(q>>>=CA,X-=CA,U.have===0){x.msg="invalid bit length repeat",U.mode=30;break}rA=U.lens[U.have-1],QA=3+(3&q),q>>>=2,X-=2}else if(nA===17){for(xA=CA+3;X<xA;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}X-=CA,rA=0,QA=3+(7&(q>>>=CA)),q>>>=3,X-=3}else{for(xA=CA+7;X<xA;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}X-=CA,rA=0,QA=11+(127&(q>>>=CA)),q>>>=7,X-=7}if(U.have+QA>U.nlen+U.ndist){x.msg="invalid bit length repeat",U.mode=30;break}for(;QA--;)U.lens[U.have++]=rA}}if(U.mode===30)break;if(U.lens[256]===0){x.msg="invalid code -- missing end-of-block",U.mode=30;break}if(U.lenbits=9,RA={bits:U.lenbits},NA=E(n,U.lens,0,U.nlen,U.lencode,0,U.work,RA),U.lenbits=RA.bits,NA){x.msg="invalid literal/lengths set",U.mode=30;break}if(U.distbits=6,U.distcode=U.distdyn,RA={bits:U.distbits},NA=E(s,U.lens,U.nlen,U.ndist,U.distcode,0,U.work,RA),U.distbits=RA.bits,NA){x.msg="invalid distances set",U.mode=30;break}if(U.mode=20,N===6)break A;case 20:U.mode=21;case 21:if(6<=V&&258<=W){x.next_out=Z,x.avail_out=W,x.next_in=_,x.avail_in=V,U.hold=q,U.bits=X,i(x,IA),Z=x.next_out,Y=x.output,W=x.avail_out,_=x.next_in,K=x.input,V=x.avail_in,q=U.hold,X=U.bits,U.mode===12&&(U.back=-1);break}for(U.back=0;hA=(bA=U.lencode[q&(1<<U.lenbits)-1])>>>16&255,nA=65535&bA,!((CA=bA>>>24)<=X);){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}if(hA&&(240&hA)==0){for(aA=CA,SA=hA,FA=nA;hA=(bA=U.lencode[FA+((q&(1<<aA+SA)-1)>>aA)])>>>16&255,nA=65535&bA,!(aA+(CA=bA>>>24)<=X);){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}q>>>=aA,X-=aA,U.back+=aA}if(q>>>=CA,X-=CA,U.back+=CA,U.length=nA,hA===0){U.mode=26;break}if(32&hA){U.back=-1,U.mode=12;break}if(64&hA){x.msg="invalid literal/length code",U.mode=30;break}U.extra=15&hA,U.mode=22;case 22:if(U.extra){for(xA=U.extra;X<xA;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}U.length+=q&(1<<U.extra)-1,q>>>=U.extra,X-=U.extra,U.back+=U.extra}U.was=U.length,U.mode=23;case 23:for(;hA=(bA=U.distcode[q&(1<<U.distbits)-1])>>>16&255,nA=65535&bA,!((CA=bA>>>24)<=X);){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}if((240&hA)==0){for(aA=CA,SA=hA,FA=nA;hA=(bA=U.distcode[FA+((q&(1<<aA+SA)-1)>>aA)])>>>16&255,nA=65535&bA,!(aA+(CA=bA>>>24)<=X);){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}q>>>=aA,X-=aA,U.back+=aA}if(q>>>=CA,X-=CA,U.back+=CA,64&hA){x.msg="invalid distance code",U.mode=30;break}U.offset=nA,U.extra=15&hA,U.mode=24;case 24:if(U.extra){for(xA=U.extra;X<xA;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}U.offset+=q&(1<<U.extra)-1,q>>>=U.extra,X-=U.extra,U.back+=U.extra}if(U.offset>U.dmax){x.msg="invalid distance too far back",U.mode=30;break}U.mode=25;case 25:if(W===0)break A;if(QA=IA-W,U.offset>QA){if((QA=U.offset-QA)>U.whave&&U.sane){x.msg="invalid distance too far back",U.mode=30;break}sA=QA>U.wnext?(QA-=U.wnext,U.wsize-QA):U.wnext-QA,QA>U.length&&(QA=U.length),DA=U.window}else DA=Y,sA=Z-U.offset,QA=U.length;for(W<QA&&(QA=W),W-=QA,U.length-=QA;Y[Z++]=DA[sA++],--QA;);U.length===0&&(U.mode=21);break;case 26:if(W===0)break A;Y[Z++]=U.length,W--,U.mode=21;break;case 27:if(U.wrap){for(;X<32;){if(V===0)break A;V--,q|=K[_++]<<X,X+=8}if(IA-=W,x.total_out+=IA,U.total+=IA,IA&&(x.adler=U.check=U.flags?Q(U.check,Y,IA,Z-IA):C(U.check,Y,IA,Z-IA)),IA=W,(U.flags?q:D(q))!==U.check){x.msg="incorrect data check",U.mode=30;break}X=q=0}U.mode=28;case 28:if(U.wrap&&U.flags){for(;X<32;){if(V===0)break A;V--,q+=K[_++]<<X,X+=8}if(q!==(4294967295&U.total)){x.msg="incorrect length check",U.mode=30;break}X=q=0}U.mode=29;case 29:NA=1;break A;case 30:NA=-3;break A;case 31:return-4;default:return a}return x.next_out=Z,x.avail_out=W,x.next_in=_,x.avail_in=V,U.hold=q,U.bits=X,(U.wsize||IA!==x.avail_out&&U.mode<30&&(U.mode<27||N!==4))&&R(x,x.output,x.next_out,IA-x.avail_out)?(U.mode=31,-4):(tA-=x.avail_in,IA-=x.avail_out,x.total_in+=tA,x.total_out+=IA,U.total+=IA,U.wrap&&IA&&(x.adler=U.check=U.flags?Q(U.check,Y,IA,x.next_out-IA):C(U.check,Y,IA,x.next_out-IA)),x.data_type=U.bits+(U.last?64:0)+(U.mode===12?128:0)+(U.mode===20||U.mode===15?256:0),(tA==0&&IA===0||N===4)&&NA===r&&(NA=-5),NA)},o.inflateEnd=function(x){if(!x||!x.state)return a;var N=x.state;return N.window&&(N.window=null),x.state=null,r},o.inflateGetHeader=function(x,N){var U;return x&&x.state?(2&(U=x.state).wrap)==0?a:((U.head=N).done=!1,r):a},o.inflateSetDictionary=function(x,N){var U,K=N.length;return x&&x.state?(U=x.state).wrap!==0&&U.mode!==11?a:U.mode===11&&C(1,N,K,0)!==U.check?-3:R(x,N,K,K)?(U.mode=31,-4):(U.havedict=1,r):a},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,o){var B=e("../utils/common"),C=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Q=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],i=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],E=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(n,s,r,a,c,h,l,D){var d,y,w,u,G,m,p,k,S,R=D.bits,x=0,N=0,U=0,K=0,Y=0,_=0,Z=0,V=0,W=0,q=0,X=null,tA=0,IA=new B.Buf16(16),QA=new B.Buf16(16),sA=null,DA=0;for(x=0;x<=15;x++)IA[x]=0;for(N=0;N<a;N++)IA[s[r+N]]++;for(Y=R,K=15;1<=K&&IA[K]===0;K--);if(K<Y&&(Y=K),K===0)return c[h++]=20971520,c[h++]=20971520,D.bits=1,0;for(U=1;U<K&&IA[U]===0;U++);for(Y<U&&(Y=U),x=V=1;x<=15;x++)if(V<<=1,(V-=IA[x])<0)return-1;if(0<V&&(n===0||K!==1))return-1;for(QA[1]=0,x=1;x<15;x++)QA[x+1]=QA[x]+IA[x];for(N=0;N<a;N++)s[r+N]!==0&&(l[QA[s[r+N]]++]=N);if(m=n===0?(X=sA=l,19):n===1?(X=C,tA-=257,sA=Q,DA-=257,256):(X=i,sA=E,-1),x=U,G=h,Z=N=q=0,w=-1,u=(W=1<<(_=Y))-1,n===1&&852<W||n===2&&592<W)return 1;for(;;){for(p=x-Z,S=l[N]<m?(k=0,l[N]):l[N]>m?(k=sA[DA+l[N]],X[tA+l[N]]):(k=96,0),d=1<<x-Z,U=y=1<<_;c[G+(q>>Z)+(y-=d)]=p<<24|k<<16|S|0,y!==0;);for(d=1<<x-1;q&d;)d>>=1;if(d!==0?(q&=d-1,q+=d):q=0,N++,--IA[x]==0){if(x===K)break;x=s[r+l[N]]}if(Y<x&&(q&u)!==w){for(Z===0&&(Z=Y),G+=U,V=1<<(_=x-Z);_+Z<K&&!((V-=IA[_+Z])<=0);)_++,V<<=1;if(W+=1<<_,n===1&&852<W||n===2&&592<W)return 1;c[w=q&u]=Y<<24|_<<16|G-h|0}}return q!==0&&(c[G+q]=x-Z<<24|64<<16|0),D.bits=Y,0}},{"../utils/common":41}],51:[function(e,t,o){t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,t,o){var B=e("../utils/common"),C=0,Q=1;function i(bA){for(var JA=bA.length;0<=--JA;)bA[JA]=0}var E=0,n=29,s=256,r=s+1+n,a=30,c=19,h=2*r+1,l=15,D=16,d=7,y=256,w=16,u=17,G=18,m=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],p=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],k=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],R=new Array(2*(r+2));i(R);var x=new Array(2*a);i(x);var N=new Array(512);i(N);var U=new Array(256);i(U);var K=new Array(n);i(K);var Y,_,Z,V=new Array(a);function W(bA,JA,mA,LA,dA){this.static_tree=bA,this.extra_bits=JA,this.extra_base=mA,this.elems=LA,this.max_length=dA,this.has_stree=bA&&bA.length}function q(bA,JA){this.dyn_tree=bA,this.max_code=0,this.stat_desc=JA}function X(bA){return bA<256?N[bA]:N[256+(bA>>>7)]}function tA(bA,JA){bA.pending_buf[bA.pending++]=255&JA,bA.pending_buf[bA.pending++]=JA>>>8&255}function IA(bA,JA,mA){bA.bi_valid>D-mA?(bA.bi_buf|=JA<<bA.bi_valid&65535,tA(bA,bA.bi_buf),bA.bi_buf=JA>>D-bA.bi_valid,bA.bi_valid+=mA-D):(bA.bi_buf|=JA<<bA.bi_valid&65535,bA.bi_valid+=mA)}function QA(bA,JA,mA){IA(bA,mA[2*JA],mA[2*JA+1])}function sA(bA,JA){for(var mA=0;mA|=1&bA,bA>>>=1,mA<<=1,0<--JA;);return mA>>>1}function DA(bA,JA,mA){var LA,dA,HA=new Array(l+1),WA=0;for(LA=1;LA<=l;LA++)HA[LA]=WA=WA+mA[LA-1]<<1;for(dA=0;dA<=JA;dA++){var Qg=bA[2*dA+1];Qg!==0&&(bA[2*dA]=sA(HA[Qg]++,Qg))}}function CA(bA){var JA;for(JA=0;JA<r;JA++)bA.dyn_ltree[2*JA]=0;for(JA=0;JA<a;JA++)bA.dyn_dtree[2*JA]=0;for(JA=0;JA<c;JA++)bA.bl_tree[2*JA]=0;bA.dyn_ltree[2*y]=1,bA.opt_len=bA.static_len=0,bA.last_lit=bA.matches=0}function hA(bA){8<bA.bi_valid?tA(bA,bA.bi_buf):0<bA.bi_valid&&(bA.pending_buf[bA.pending++]=bA.bi_buf),bA.bi_buf=0,bA.bi_valid=0}function nA(bA,JA,mA,LA){var dA=2*JA,HA=2*mA;return bA[dA]<bA[HA]||bA[dA]===bA[HA]&&LA[JA]<=LA[mA]}function aA(bA,JA,mA){for(var LA=bA.heap[mA],dA=mA<<1;dA<=bA.heap_len&&(dA<bA.heap_len&&nA(JA,bA.heap[dA+1],bA.heap[dA],bA.depth)&&dA++,!nA(JA,LA,bA.heap[dA],bA.depth));)bA.heap[mA]=bA.heap[dA],mA=dA,dA<<=1;bA.heap[mA]=LA}function SA(bA,JA,mA){var LA,dA,HA,WA,Qg=0;if(bA.last_lit!==0)for(;LA=bA.pending_buf[bA.d_buf+2*Qg]<<8|bA.pending_buf[bA.d_buf+2*Qg+1],dA=bA.pending_buf[bA.l_buf+Qg],Qg++,LA===0?QA(bA,dA,JA):(QA(bA,(HA=U[dA])+s+1,JA),(WA=m[HA])!==0&&IA(bA,dA-=K[HA],WA),QA(bA,HA=X(--LA),mA),(WA=p[HA])!==0&&IA(bA,LA-=V[HA],WA)),Qg<bA.last_lit;);QA(bA,y,JA)}function FA(bA,JA){var mA,LA,dA,HA=JA.dyn_tree,WA=JA.stat_desc.static_tree,Qg=JA.stat_desc.has_stree,YA=JA.stat_desc.elems,uA=-1;for(bA.heap_len=0,bA.heap_max=h,mA=0;mA<YA;mA++)HA[2*mA]!==0?(bA.heap[++bA.heap_len]=uA=mA,bA.depth[mA]=0):HA[2*mA+1]=0;for(;bA.heap_len<2;)HA[2*(dA=bA.heap[++bA.heap_len]=uA<2?++uA:0)]=1,bA.depth[dA]=0,bA.opt_len--,Qg&&(bA.static_len-=WA[2*dA+1]);for(JA.max_code=uA,mA=bA.heap_len>>1;1<=mA;mA--)aA(bA,HA,mA);for(dA=YA;mA=bA.heap[1],bA.heap[1]=bA.heap[bA.heap_len--],aA(bA,HA,1),LA=bA.heap[1],bA.heap[--bA.heap_max]=mA,bA.heap[--bA.heap_max]=LA,HA[2*dA]=HA[2*mA]+HA[2*LA],bA.depth[dA]=(bA.depth[mA]>=bA.depth[LA]?bA.depth[mA]:bA.depth[LA])+1,HA[2*mA+1]=HA[2*LA+1]=dA,bA.heap[1]=dA++,aA(bA,HA,1),2<=bA.heap_len;);bA.heap[--bA.heap_max]=bA.heap[1],(function(kA,OA){var $A,og,dg,Sg,Bg,Yg,iI=OA.dyn_tree,GA=OA.max_code,ng=OA.stat_desc.static_tree,pg=OA.stat_desc.has_stree,Ug=OA.stat_desc.extra_bits,mg=OA.stat_desc.extra_base,Rg=OA.stat_desc.max_length,Kg=0;for(Sg=0;Sg<=l;Sg++)kA.bl_count[Sg]=0;for(iI[2*kA.heap[kA.heap_max]+1]=0,$A=kA.heap_max+1;$A<h;$A++)Rg<(Sg=iI[2*iI[2*(og=kA.heap[$A])+1]+1]+1)&&(Sg=Rg,Kg++),iI[2*og+1]=Sg,GA<og||(kA.bl_count[Sg]++,Bg=0,mg<=og&&(Bg=Ug[og-mg]),Yg=iI[2*og],kA.opt_len+=Yg*(Sg+Bg),pg&&(kA.static_len+=Yg*(ng[2*og+1]+Bg)));if(Kg!==0){do{for(Sg=Rg-1;kA.bl_count[Sg]===0;)Sg--;kA.bl_count[Sg]--,kA.bl_count[Sg+1]+=2,kA.bl_count[Rg]--,Kg-=2}while(0<Kg);for(Sg=Rg;Sg!==0;Sg--)for(og=kA.bl_count[Sg];og!==0;)GA<(dg=kA.heap[--$A])||(iI[2*dg+1]!==Sg&&(kA.opt_len+=(Sg-iI[2*dg+1])*iI[2*dg],iI[2*dg+1]=Sg),og--)}})(bA,JA),DA(HA,uA,bA.bl_count)}function rA(bA,JA,mA){var LA,dA,HA=-1,WA=JA[1],Qg=0,YA=7,uA=4;for(WA===0&&(YA=138,uA=3),JA[2*(mA+1)+1]=65535,LA=0;LA<=mA;LA++)dA=WA,WA=JA[2*(LA+1)+1],++Qg<YA&&dA===WA||(Qg<uA?bA.bl_tree[2*dA]+=Qg:dA!==0?(dA!==HA&&bA.bl_tree[2*dA]++,bA.bl_tree[2*w]++):Qg<=10?bA.bl_tree[2*u]++:bA.bl_tree[2*G]++,HA=dA,uA=(Qg=0)===WA?(YA=138,3):dA===WA?(YA=6,3):(YA=7,4))}function NA(bA,JA,mA){var LA,dA,HA=-1,WA=JA[1],Qg=0,YA=7,uA=4;for(WA===0&&(YA=138,uA=3),LA=0;LA<=mA;LA++)if(dA=WA,WA=JA[2*(LA+1)+1],!(++Qg<YA&&dA===WA)){if(Qg<uA)for(;QA(bA,dA,bA.bl_tree),--Qg!=0;);else dA!==0?(dA!==HA&&(QA(bA,dA,bA.bl_tree),Qg--),QA(bA,w,bA.bl_tree),IA(bA,Qg-3,2)):Qg<=10?(QA(bA,u,bA.bl_tree),IA(bA,Qg-3,3)):(QA(bA,G,bA.bl_tree),IA(bA,Qg-11,7));HA=dA,uA=(Qg=0)===WA?(YA=138,3):dA===WA?(YA=6,3):(YA=7,4)}}i(V);var RA=!1;function xA(bA,JA,mA,LA){IA(bA,(E<<1)+(LA?1:0),3),(function(dA,HA,WA,Qg){hA(dA),tA(dA,WA),tA(dA,~WA),B.arraySet(dA.pending_buf,dA.window,HA,WA,dA.pending),dA.pending+=WA})(bA,JA,mA)}o._tr_init=function(bA){RA||((function(){var JA,mA,LA,dA,HA,WA=new Array(l+1);for(dA=LA=0;dA<n-1;dA++)for(K[dA]=LA,JA=0;JA<1<<m[dA];JA++)U[LA++]=dA;for(U[LA-1]=dA,dA=HA=0;dA<16;dA++)for(V[dA]=HA,JA=0;JA<1<<p[dA];JA++)N[HA++]=dA;for(HA>>=7;dA<a;dA++)for(V[dA]=HA<<7,JA=0;JA<1<<p[dA]-7;JA++)N[256+HA++]=dA;for(mA=0;mA<=l;mA++)WA[mA]=0;for(JA=0;JA<=143;)R[2*JA+1]=8,JA++,WA[8]++;for(;JA<=255;)R[2*JA+1]=9,JA++,WA[9]++;for(;JA<=279;)R[2*JA+1]=7,JA++,WA[7]++;for(;JA<=287;)R[2*JA+1]=8,JA++,WA[8]++;for(DA(R,r+1,WA),JA=0;JA<a;JA++)x[2*JA+1]=5,x[2*JA]=sA(JA,5);Y=new W(R,m,s+1,r,l),_=new W(x,p,0,a,l),Z=new W(new Array(0),k,0,c,d)})(),RA=!0),bA.l_desc=new q(bA.dyn_ltree,Y),bA.d_desc=new q(bA.dyn_dtree,_),bA.bl_desc=new q(bA.bl_tree,Z),bA.bi_buf=0,bA.bi_valid=0,CA(bA)},o._tr_stored_block=xA,o._tr_flush_block=function(bA,JA,mA,LA){var dA,HA,WA=0;0<bA.level?(bA.strm.data_type===2&&(bA.strm.data_type=(function(Qg){var YA,uA=4093624447;for(YA=0;YA<=31;YA++,uA>>>=1)if(1&uA&&Qg.dyn_ltree[2*YA]!==0)return C;if(Qg.dyn_ltree[18]!==0||Qg.dyn_ltree[20]!==0||Qg.dyn_ltree[26]!==0)return Q;for(YA=32;YA<s;YA++)if(Qg.dyn_ltree[2*YA]!==0)return Q;return C})(bA)),FA(bA,bA.l_desc),FA(bA,bA.d_desc),WA=(function(Qg){var YA;for(rA(Qg,Qg.dyn_ltree,Qg.l_desc.max_code),rA(Qg,Qg.dyn_dtree,Qg.d_desc.max_code),FA(Qg,Qg.bl_desc),YA=c-1;3<=YA&&Qg.bl_tree[2*S[YA]+1]===0;YA--);return Qg.opt_len+=3*(YA+1)+5+5+4,YA})(bA),dA=bA.opt_len+3+7>>>3,(HA=bA.static_len+3+7>>>3)<=dA&&(dA=HA)):dA=HA=mA+5,mA+4<=dA&&JA!==-1?xA(bA,JA,mA,LA):bA.strategy===4||HA===dA?(IA(bA,2+(LA?1:0),3),SA(bA,R,x)):(IA(bA,4+(LA?1:0),3),(function(Qg,YA,uA,kA){var OA;for(IA(Qg,YA-257,5),IA(Qg,uA-1,5),IA(Qg,kA-4,4),OA=0;OA<kA;OA++)IA(Qg,Qg.bl_tree[2*S[OA]+1],3);NA(Qg,Qg.dyn_ltree,YA-1),NA(Qg,Qg.dyn_dtree,uA-1)})(bA,bA.l_desc.max_code+1,bA.d_desc.max_code+1,WA+1),SA(bA,bA.dyn_ltree,bA.dyn_dtree)),CA(bA),LA&&hA(bA)},o._tr_tally=function(bA,JA,mA){return bA.pending_buf[bA.d_buf+2*bA.last_lit]=JA>>>8&255,bA.pending_buf[bA.d_buf+2*bA.last_lit+1]=255&JA,bA.pending_buf[bA.l_buf+bA.last_lit]=255&mA,bA.last_lit++,JA===0?bA.dyn_ltree[2*mA]++:(bA.matches++,JA--,bA.dyn_ltree[2*(U[mA]+s+1)]++,bA.dyn_dtree[2*X(JA)]++),bA.last_lit===bA.lit_bufsize-1},o._tr_align=function(bA){IA(bA,2,3),QA(bA,y,R),(function(JA){JA.bi_valid===16?(tA(JA,JA.bi_buf),JA.bi_buf=0,JA.bi_valid=0):8<=JA.bi_valid&&(JA.pending_buf[JA.pending++]=255&JA.bi_buf,JA.bi_buf>>=8,JA.bi_valid-=8)})(bA)}},{"../utils/common":41}],53:[function(e,t,o){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,o){(function(B){(function(C,Q){if(!C.setImmediate){var i,E,n,s,r=1,a={},c=!1,h=C.document,l=Object.getPrototypeOf&&Object.getPrototypeOf(C);l=l&&l.setTimeout?l:C,i={}.toString.call(C.process)==="[object process]"?function(w){I.nextTick(function(){d(w)})}:(function(){if(C.postMessage&&!C.importScripts){var w=!0,u=C.onmessage;return C.onmessage=function(){w=!1},C.postMessage("","*"),C.onmessage=u,w}})()?(s="setImmediate$"+Math.random()+"$",C.addEventListener?C.addEventListener("message",y,!1):C.attachEvent("onmessage",y),function(w){C.postMessage(s+w,"*")}):C.MessageChannel?((n=new MessageChannel).port1.onmessage=function(w){d(w.data)},function(w){n.port2.postMessage(w)}):h&&"onreadystatechange"in h.createElement("script")?(E=h.documentElement,function(w){var u=h.createElement("script");u.onreadystatechange=function(){d(w),u.onreadystatechange=null,E.removeChild(u),u=null},E.appendChild(u)}):function(w){setTimeout(d,0,w)},l.setImmediate=function(w){typeof w!="function"&&(w=new Function(""+w));for(var u=new Array(arguments.length-1),G=0;G<u.length;G++)u[G]=arguments[G+1];var m={callback:w,args:u};return a[r]=m,i(r),r++},l.clearImmediate=D}function D(w){delete a[w]}function d(w){if(c)setTimeout(d,0,w);else{var u=a[w];if(u){c=!0;try{(function(G){var m=G.callback,p=G.args;switch(p.length){case 0:m();break;case 1:m(p[0]);break;case 2:m(p[0],p[1]);break;case 3:m(p[0],p[1],p[2]);break;default:m.apply(Q,p)}})(u)}finally{D(w),c=!1}}}}function y(w){w.source===C&&typeof w.data=="string"&&w.data.indexOf(s)===0&&d(+w.data.slice(s.length))}})(typeof self>"u"?B===void 0?this:B:self)}).call(this,typeof JY<"u"?JY:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(IQg)),IQg.exports}var cSo=rSo();const loA=vp(cSo),hSo=async()=>await Promise.resolve().then(()=>FVo),lSo=async({circuitJson:g,projectName:A})=>{try{const{circuitJsonToStep:I}=await hSo(),e=await I(g,{exportMode:"assembly"}),t=new loA;for(const[o,B]of Object.entries(e))t.file(o,B);bk(await t.generateAsync({type:"blob"}),{fileName:`${A}-assembly.zip`})}catch(I){LC.error(`Failed to export assembly STEP: ${I instanceof Error?I.message:String(I)}`)}},DSo=async({circuitJson:g,projectName:A})=>{await LC.promise((async()=>{const I=new loA,[e,{convertCircuitJsonToBomRows:t,convertBomRowsToCsv:o},{convertCircuitJsonToPickAndPlaceCsv:B}]=await Promise.all([RS("circuit-json-to-gerber"),RS("circuit-json-to-bom-csv"),RS("circuit-json-to-pnp-csv")]),C=g.filter(r=>!("error_type"in r)&&!("warning_type"in r)),Q=e.convertCircuitJsonToGerberFiles(C,{flip_y_axis:!1});for(const[r,a]of Object.entries(Q))I.file(`gerber/${r}`,a);const i=await t({circuitJson:g}),E=await o(i);I.file("bom.csv",E);const n=await B(g,{supplier:"jlcpcb"});I.file("pick_and_place.csv",n);const s=await I.generateAsync({type:"blob"});bk(s,{fileName:`${A}_fabrication_files.zip`})})(),{loading:"Generating fabrication files...",success:"Fabrication ZIP ready",error:I=>`Failed to generate fabrication files: ${I instanceof Error?I.message:String(I)}`})},dSo=async g=>{const{createFdmComponentBox:A,renderFdmComponentBoxPng:I}=await RS("circuit-json-to-fdm-component-box"),[e,t]=await Promise.all([A(g),I(g,{},{width:960,height:640})]);return{...e,previewPng:t}},ySo=async g=>{const{createFdmComponentBox:A}=await RS("circuit-json-to-fdm-component-box");return A(g)},r4I=({generatedBox:g,projectName:A})=>{const I=Uint8Array.from(g.threeMf);bk(new Blob([I.buffer],{type:"model/3mf"}),{fileName:`${MCg(A)}-component-box.3mf`})},wSo=async({circuitJson:g,projectName:A})=>{await LC.promise((async()=>{const I=await ySo(g);r4I({generatedBox:I,projectName:A})})(),{loading:"Generating component box...",success:"Component box 3MF ready",error:I=>`Failed to generate component box: ${I instanceof Error?I.message:String(I)}`})},uSo=async({circuitJson:g,projectName:A})=>{let I;try{const{convertCircuitJsonToGltf:e}=await RS("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",e);const t=await e(g,{format:"glb",boardTextureResolution:1024});if(!t||!(t instanceof ArrayBuffer))throw new Error("Invalid GLB data returned from converter");I=new Blob([t],{type:"model/gltf-binary"})}catch(e){console.error("GLB Export Error:",e);return}bk(I,{fileName:`${A}.glb`})},GSo=async({circuitJson:g,libraryName:A})=>{const{CircuitJsonToKicadLibraryConverter:I}=await RS("circuit-json-to-kicad"),e=new I(g,{libraryName:A,footprintLibraryName:A});e.runUntilFinished();const t=e.getOutput(),o=new loA;o.file(`${A}.kicad_sym`,t.kicadSymString);for(const B of t.footprints){const C=o.folder(`${A}.pretty`);C&&C.file(`${B.footprintName}.kicad_mod`,`${B.kicadModString}
|
|
5673
5673
|
`)}if(t.model3dSourcePaths.length>0){const B=o.folder(`${A}.3dshapes`);if(B)for(const C of t.model3dSourcePaths)try{const Q=C.split("/").pop()||C,i=await fetch(C);if(i.ok){const E=await i.arrayBuffer();B.file(Q,E)}}catch{}}return o.file("fp-lib-table",t.fpLibTableString),o.file("sym-lib-table",t.symLibTableString),o},mSo=async({circuitJson:g,projectName:A})=>{await LC.promise((async()=>{const e=await(await GSo({circuitJson:g,libraryName:A})).generateAsync({type:"blob"});bk(e,{fileName:`${A}_kicad_library.zip`})})(),{loading:"Generating KiCad library...",success:"KiCad library ZIP ready",error:I=>`Failed to generate KiCad library: ${I instanceof Error?I.message:String(I)}`})},pSo=async({circuitJson:g,projectName:A})=>{const{CircuitJsonToKicadPcbConverter:I,CircuitJsonToKicadSchConverter:e,CircuitJsonToKicadProConverter:t,resolveAndLoadKicad3dModelFiles:o}=await RS("circuit-json-to-kicad"),B=new e(g);B.runUntilFinished();const C=B.getOutputString(),Q=new I(g,{includeBuiltin3dModels:!0,projectName:A});Q.runUntilFinished();const i=Q.getOutputString(),E=new t(g,{projectName:A,schematicFilename:`${A}.kicad_sch`,pcbFilename:`${A}.kicad_pcb`});E.runUntilFinished();const n=E.getOutputString(),s=new loA;return s.file(`${A}.kicad_sch`,C),s.file(`${A}.kicad_pcb`,i),s.file(`${A}.kicad_pro`,n),await o({projectName:A,model3dSourcePaths:Q.getModel3dSourcePaths(),fetch,onModelFile:({outputPath:r,content:a})=>{s.file(r,a)},onError:({sourcePath:r})=>{console.warn(`Failed to load 3D model from ${r}`)}}),s},kSo=async({circuitJson:g,projectName:A})=>{await LC.promise((async()=>{const e=await(await pSo({circuitJson:g,projectName:A})).generateAsync({type:"blob"});bk(e,{fileName:`${A}_kicad_project.zip`})})(),{loading:"Generating KiCad project...",success:"KiCad project ZIP ready",error:I=>`Failed to generate KiCad project: ${I instanceof Error?I.message:String(I)}`})},c4I=async({circuitJson:g,projectName:A,options:I={}})=>{try{const{convertCircuitJsonToLbrn:e}=await RS("circuit-json-to-lbrn"),o=(await e(g,{includeSilkscreen:I.includeSilkscreen??!1,includeOxidationCleaningLayer:I.includeOxidationCleaningLayer??!0})).toXml(),B=new Blob([o],{type:"application/lbrn"});bk(B,{fileName:`${A}.lbrn2`})}catch(e){const t=e instanceof Error?e.message:"Unknown error";LC.error(`Failed to export to LBRN format: ${t}`)}},MSo=async({circuitJson:g,projectName:A})=>{const{convertCircuitJsonToPinoutSvg:I}=await RS("circuit-to-svg"),e=I(g);bk(e,{fileName:`${A}-pinout.svg`,mimeType:"image/svg+xml"})},SSo=async({circuitJson:g,projectName:A})=>{const{circuitJsonToStep:I}=await RS("circuit-json-to-step"),e=g.find(i=>i.type==="pcb_board"),t=e&&"width"in e?e.width:void 0,o=e&&"height"in e?e.height:void 0,B=e&&"thickness"in e?e.thickness:void 0;if(t===void 0||o===void 0||B===void 0){LC.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let C;try{C=await I(g,{boardWidth:t,boardHeight:o,boardThickness:B,productName:A,includeComponents:!0,includeExternalMeshes:!0})}catch(i){const E=i instanceof Error?i.message:"Unknown error";LC.error(`Failed to convert circuit to STEP format: ${E}`);return}const Q=new Blob([C],{type:"application/step"});try{bk(Q,{fileName:`${A}.step`})}catch(i){const E=i instanceof Error?i.message:"Unknown error";LC.error(`Failed to download STEP file: ${E}`)}},fSo=[{extension:"json",name:"Circuit JSON"},{extension:"json",name:"Simple Route JSON"},{extension:"zip",name:"Fabrication Files"},{extension:"zip",name:"KiCad Project"},{extension:"zip",name:"Altium Project"},{extension:"zip",name:"KiCad Library"},{extension:"glb",name:"GLB (Binary GLTF)"},{extension:"svg",name:"Pinout SVG"},{extension:"step",name:"STEP"},{extension:"zip",name:"Assembly STEP"},{extension:"lbrn2",name:"LightBurn"}],RSo=async({exportName:g,circuitJson:A,simpleRouteJson:I,projectName:e})=>{const t=MCg(e);if(g==="Fabrication Files"){await DSo({circuitJson:A,projectName:t});return}if(g==="KiCad Project"){await kSo({circuitJson:A,projectName:t});return}if(g==="Altium Project"){await aSo({circuitJson:A,projectName:t});return}if(g==="KiCad Library"){await mSo({circuitJson:A,projectName:t});return}if(g==="Circuit JSON"){bk(JSON.stringify(A,null,2),{fileName:`${t}.circuit.json`,mimeType:"application/json"});return}if(g==="Simple Route JSON"){if(!I)throw new Error("No Simple Route JSON available to export");bk(JSON.stringify(I,null,2),{fileName:`${t}.simple-route.json`,mimeType:"application/json"});return}if(g==="GLB (Binary GLTF)"){await uSo({circuitJson:A,projectName:t});return}if(g==="Pinout SVG"){MSo({circuitJson:A,projectName:t});return}if(g==="STEP"){await SSo({circuitJson:A,projectName:t});return}if(g==="Assembly STEP"){await lSo({circuitJson:A,projectName:t});return}if(g==="Component Box (3MF)"){await wSo({circuitJson:A,projectName:t});return}if(g==="LightBurn"){await c4I({circuitJson:A,projectName:t});return}throw new Error(`Unsupported export type: "${g}"`)},NSo=({packageName:g,onSelectReview:A})=>{const I=Kc(n=>n.fsMap),e=Kc(n=>n.circuitJson),[t,o]=z.useState([]),[B,C]=z.useState(!1),[Q,i]=z.useState(!1);z.useEffect(()=>{!g||!HDA()||(C(!0),NgA.get("ai_reviews/list",{searchParams:{package_name:g}}).json().then(n=>o(n.ai_reviews)).catch(n=>{console.error("Failed to load AI reviews",n),LC.error("Failed to load AI reviews")}).finally(()=>C(!1)))},[g]);const E=async()=>{if(!e){LC.error("Need Circuit JSON to Request AI Review");return}if(!HDA()){LC.error("Missing registry token");return}i(!0);try{const{ai_review:n}=await NgA.post("ai_reviews/create",{json:{package_name:g??"unknown",fs_map:Object.fromEntries(I),circuit_json:e}}).json();o(s=>[n,...s]),A(n),LC.success("AI review requested")}catch(n){console.error("Failed to create AI review",n),LC.error("Failed to request AI review")}finally{i(!1)}};return T.jsxs(T.Fragment,{children:[T.jsxs(FL,{children:[T.jsx(UL,{children:"AI Review"}),T.jsx(vb,{children:"Select an AI review or request a new one."})]}),T.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:T.jsx("div",{className:"rf-w-48 rf-h-64 rf-overflow-y-auto rf-border rf-rounded rf-p-2 rf-flex-shrink-0",children:B?T.jsx("div",{className:"rf-text-sm",children:"Loading..."}):t.length>0?t.map(n=>T.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>A(n),children:new Date(n.created_at||"").toLocaleString()},n.ai_review_id)):T.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),T.jsx(_O,{className:"rf-mt-4",children:T.jsx(si,{onClick:E,disabled:Q,children:Q?"Requesting...":"Review my Board"})})]})};function eQg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Tb=eQg();function h4I(g){Tb=g}var DoA={exec:()=>null};function Zs(g,A=""){let I=typeof g=="string"?g:g.source;const e={replace:(t,o)=>{let B=typeof o=="string"?o:o.source;return B=B.replace(jm.caret,"$1"),I=I.replace(t,B),e},getRegex:()=>new RegExp(I,A)};return e}var jm={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:g=>new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:g=>new RegExp(`^ {0,${Math.min(3,g-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:g=>new RegExp(`^ {0,${Math.min(3,g-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:g=>new RegExp(`^ {0,${Math.min(3,g-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:g=>new RegExp(`^ {0,${Math.min(3,g-1)}}#`),htmlBeginRegex:g=>new RegExp(`^ {0,${Math.min(3,g-1)}}<(?:[a-z].*>|!--)`,"i")},xSo=/^(?:[ \t]*(?:\n|$))+/,FSo=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,USo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,doA=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,JSo=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,tQg=/(?:[*+-]|\d{1,9}[.)])/,l4I=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,D4I=Zs(l4I).replace(/bull/g,tQg).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),PSo=Zs(l4I).replace(/bull/g,tQg).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),oQg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,KSo=/^[^\n]+/,BQg=/(?!\s*\])(?:\\.|[^\[\]\\])+/,LSo=Zs(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",BQg).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),YSo=Zs(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,tQg).getRegex(),ypA="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",CQg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,_So=Zs("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",CQg).replace("tag",ypA).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),d4I=Zs(oQg).replace("hr",doA).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ypA).getRegex(),bSo=Zs(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",d4I).getRegex(),QQg={blockquote:bSo,code:FSo,def:LSo,fences:USo,heading:JSo,hr:doA,html:_So,lheading:D4I,list:YSo,newline:xSo,paragraph:d4I,table:DoA,text:KSo},y4I=Zs("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",doA).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ypA).getRegex(),HSo={...QQg,lheading:PSo,table:y4I,paragraph:Zs(oQg).replace("hr",doA).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",y4I).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ypA).getRegex()},vSo={...QQg,html:Zs(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",CQg).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:DoA,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Zs(oQg).replace("hr",doA).replace("heading",` *#{1,6} *[^
|
|
5674
5674
|
]`).replace("lheading",D4I).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},TSo=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,qSo=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,w4I=/^( {2,}|\\)\n(?!\s*$)/,ZSo=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,wpA=/[\p{P}\p{S}]/u,iQg=/[\s\p{P}\p{S}]/u,u4I=/[^\s\p{P}\p{S}]/u,OSo=Zs(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,iQg).getRegex(),G4I=/(?!~)[\p{P}\p{S}]/u,WSo=/(?!~)[\s\p{P}\p{S}]/u,VSo=/(?:[^\s\p{P}\p{S}]|~)/u,jSo=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,m4I=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,zSo=Zs(m4I,"u").replace(/punct/g,wpA).getRegex(),XSo=Zs(m4I,"u").replace(/punct/g,G4I).getRegex(),p4I="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",$So=Zs(p4I,"gu").replace(/notPunctSpace/g,u4I).replace(/punctSpace/g,iQg).replace(/punct/g,wpA).getRegex(),A2o=Zs(p4I,"gu").replace(/notPunctSpace/g,VSo).replace(/punctSpace/g,WSo).replace(/punct/g,G4I).getRegex(),g2o=Zs("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,u4I).replace(/punctSpace/g,iQg).replace(/punct/g,wpA).getRegex(),I2o=Zs(/\\(punct)/,"gu").replace(/punct/g,wpA).getRegex(),e2o=Zs(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),t2o=Zs(CQg).replace("(?:-->|$)","-->").getRegex(),o2o=Zs("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",t2o).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),upA=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,B2o=Zs(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",upA).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),k4I=Zs(/^!?\[(label)\]\[(ref)\]/).replace("label",upA).replace("ref",BQg).getRegex(),M4I=Zs(/^!?\[(ref)\](?:\[\])?/).replace("ref",BQg).getRegex(),C2o=Zs("reflink|nolink(?!\\()","g").replace("reflink",k4I).replace("nolink",M4I).getRegex(),EQg={_backpedal:DoA,anyPunctuation:I2o,autolink:e2o,blockSkip:jSo,br:w4I,code:qSo,del:DoA,emStrongLDelim:zSo,emStrongRDelimAst:$So,emStrongRDelimUnd:g2o,escape:TSo,link:B2o,nolink:M4I,punctuation:OSo,reflink:k4I,reflinkSearch:C2o,tag:o2o,text:ZSo,url:DoA},Q2o={...EQg,link:Zs(/^!?\[(label)\]\((.*?)\)/).replace("label",upA).getRegex(),reflink:Zs(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",upA).getRegex()},nQg={...EQg,emStrongRDelimAst:A2o,emStrongLDelim:XSo,url:Zs(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},i2o={...nQg,br:Zs(w4I).replace("{2,}","*").getRegex(),text:Zs(nQg.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},GpA={normal:QQg,gfm:HSo,pedantic:vSo},yoA={normal:EQg,gfm:nQg,breaks:i2o,pedantic:Q2o},E2o={"&":"&","<":"<",">":">",'"':""","'":"'"},S4I=g=>E2o[g];function yF(g,A){if(A){if(jm.escapeTest.test(g))return g.replace(jm.escapeReplace,S4I)}else if(jm.escapeTestNoEncode.test(g))return g.replace(jm.escapeReplaceNoEncode,S4I);return g}function f4I(g){try{g=encodeURI(g).replace(jm.percentDecode,"%")}catch{return null}return g}function R4I(g,A){const I=g.replace(jm.findPipe,(o,B,C)=>{let Q=!1,i=B;for(;--i>=0&&C[i]==="\\";)Q=!Q;return Q?"|":" |"}),e=I.split(jm.splitPipe);let t=0;if(e[0].trim()||e.shift(),e.length>0&&!e.at(-1)?.trim()&&e.pop(),A)if(e.length>A)e.splice(A);else for(;e.length<A;)e.push("");for(;t<e.length;t++)e[t]=e[t].trim().replace(jm.slashPipe,"|");return e}function woA(g,A,I){const e=g.length;if(e===0)return"";let t=0;for(;t<e&&g.charAt(e-t-1)===A;)t++;return g.slice(0,e-t)}function n2o(g,A){if(g.indexOf(A[1])===-1)return-1;let I=0;for(let e=0;e<g.length;e++)if(g[e]==="\\")e++;else if(g[e]===A[0])I++;else if(g[e]===A[1]&&(I--,I<0))return e;return I>0?-2:-1}function N4I(g,A,I,e,t){const o=A.href,B=A.title||null,C=g[1].replace(t.other.outputLinkReplace,"$1");e.state.inLink=!0;const Q={type:g[0].charAt(0)==="!"?"image":"link",raw:I,href:o,title:B,text:C,tokens:e.inlineTokens(C)};return e.state.inLink=!1,Q}function s2o(g,A,I){const e=g.match(I.other.indentCodeCompensation);if(e===null)return A;const t=e[1];return A.split(`
|
|
@@ -5745,7 +5745,7 @@ Please report this to https://github.com/markedjs/marked.`,g){const e="<p>An err
|
|
|
5745
5745
|
rf-max-h-[90vh] rf-overflow-y-auto
|
|
5746
5746
|
`,children:T.jsx("div",{className:"rf-relative rf-w-full",children:I==="initial"&&T.jsx(X2o,{onCancel:A,packageReleaseId:o??"",signIn:B??(()=>{}),isLoggedIn:C})})})})}),tfo=({isOpen:g,onClose:A,stage:I,setStage:e,signIn:t,isLoggedIn:o})=>{const B=Kc(C=>C.circuitJson);return T.jsx(efo,{signIn:t,isOpen:g,onClose:A,stage:I,setStage:e,circuitJson:B,isLoggedIn:o??!1})},ofo=()=>{const[g,A]=z.useState(!1),[I,e]=z.useState("initial");return{isOpen:g,stage:I,open:()=>A(!0),close:()=>{A(!1),e("initial")},setStage:e,OrderDialog:tfo}};async function j4I(){const g=await fetch(`${Jm}/files/list`),{file_list:A}=await g.json(),I=new Map;for(const e of A){const o=await(await fetch(`${Jm}/files/get?file_path=${encodeURIComponent(e.file_path)}`)).json();(o.file?.text_content||o.file?.binary_content_b64)&&I.set(e.file_path,{text_content:o.file.text_content,binary_content_b64:o.file.binary_content_b64})}return I}const Bfo="https://api.tscircuit.com/bug_reports/view?bug_report_id=",Cfo=g=>`${Bfo}${g}`,Qfo=g=>{const[A,I]=z.useState(!1),[e,t]=z.useState(!1),[o,B]=z.useState(null),[C,Q]=z.useState(null),[i,E]=z.useState([]),n=z.useRef(null),[s,r]=z.useState(null),[a,c]=z.useState(0),h=g?.onLoginRequired,l=z.useMemo(()=>HDA()?!0:typeof document>"u"?!1:document.cookie.split(";").some(u=>u.trim().startsWith("session=")),[A]);z.useEffect(()=>{if(A&&!s&&n.current){const u=typeof window<"u"?window.__TSCIRCUIT_LAST_EXECUTION_ERROR:void 0;u&&(n.current.value=`I'm getting this execution error:
|
|
5747
5747
|
|
|
5748
|
-
${u}`)}},[A,s]),z.useEffect(()=>{A&&!s&&j4I().then(u=>{c(u.size)}).catch(u=>{console.error("Failed to fetch file count",u),c(0)})},[A,s]);const D=z.useCallback(()=>{B(null),r(null),Q(null),E([]),n.current&&(n.current.value=""),I(!0)},[]),d=z.useCallback(()=>{I(!1)},[]),y=z.useCallback(async()=>{t(!0),B(null),Q(null),E([]);const u=d3(),G=n.current?.value||"";try{const m=await j4I();if(m.size===0){LC.error("No project files available to include in the bug report"),t(!1);return}const p=new Date(Date.now()+1440*60*1e3).toISOString(),S=(await u.post("bug_reports/create",{json:{text:G.trim()||void 0,is_auto_deleted:!0,delete_at:p}}).json()).bug_report.bug_report_id,R=Array.from(m.entries()),x=[];for(let U=0;U<R.length;U++){const[K,Y]=R[U];Q({current:U+1,total:R.length,currentFile:K});try{const _={bug_report_id:S,file_path:K};Y.text_content&&(_.content_text=Y.text_content),Y.binary_content_b64&&(_.content_base64=Y.binary_content_b64),await u.post("bug_reports/upload_file",{json:_})}catch(_){const Z=_ instanceof wJ?`HTTP ${_.response.status}`:_ instanceof Error?_.message:"Upload failed";x.push({filePath:K,message:Z}),E([...x])}}Q(null);const N=Cfo(S);r({bugReportUrl:N})}catch(m){if(console.error("Failed to submit bug report",m),m instanceof wJ)if(m.response.status===401)if(l){const p="Your session has expired. Please sign in again to continue.";B(p),LC.error(p),h&&(d(),h())}else{const p="You must be logged in to report a bug. Please sign in via cli and try again.";B(p),LC.error(p),setTimeout(()=>{h&&(d(),h())},1e3)}else{const p=`Failed to submit bug report (${m.response.status})`;B(p),LC.error(p)}else if(m instanceof Error)B(m.message),LC.error(m.message);else{const p="Failed to submit bug report";B(p),LC.error(p)}}finally{t(!1)}},[l,h]);return{BugReportDialog:z.useMemo(()=>{const u=C?Math.round(C.current/C.total*100):0;return T.jsx(bPI,{open:A,onOpenChange:G=>{G?(B(null),r(null),Q(null),E([]),I(!0)):e||d()},children:T.jsxs(RCg,{children:[T.jsxs(NCg,{children:[T.jsx(FCg,{children:s?"Bug Report Created":"Report Bug"}),T.jsx(UCg,{asChild:!0,children:s?T.jsxs("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:[T.jsx("p",{children:"Bug report created successfully."}),i.length>0&&T.jsxs("div",{className:"rf-bg-red-50 rf-border rf-border-red-200 rf-rounded rf-p-2 rf-max-h-28 rf-overflow-y-auto rf-overflow-x-hidden",children:[T.jsxs("p",{className:"rf-text-red-700 rf-font-medium rf-text-xs rf-mb-1",children:[i.length," file(s) failed:"]}),i.map((G,m)=>T.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${G.filePath}: ${G.message}`,children:[T.jsx("span",{className:"rf-font-medium rf-break-all",children:G.filePath.split("/").pop()}),T.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:G.message})]},m))]}),T.jsx("div",{children:T.jsx("a",{className:"rf-text-blue-600 hover:rf-underline",href:s.bugReportUrl,target:"_blank",rel:"noreferrer",children:"View bug report"})}),T.jsxs("p",{children:["Please share this link privately with tscircuit staff so we can help debug. Join the",T.jsx("a",{className:"rf-ml-1 rf-text-blue-600 hover:rf-underline",href:"https://tscircuit.com/join",target:"_blank",rel:"noreferrer",children:"tscircuit Discord"}),"."]})]}):T.jsx("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:C?T.jsxs("div",{className:"rf-space-y-2 rf-overflow-hidden",children:[T.jsxs("div",{className:"rf-flex rf-justify-between rf-text-xs",children:[T.jsx("span",{children:"Uploading files..."}),T.jsxs("span",{children:[C.current,"/",C.total]})]}),T.jsx("div",{className:"rf-w-full rf-h-2 rf-bg-gray-200 rf-rounded-full rf-overflow-hidden",children:T.jsx("div",{className:"rf-h-full rf-bg-blue-500 rf-transition-all rf-duration-150",style:{width:`${u}%`}})}),T.jsx("p",{className:"rf-text-xs rf-text-gray-500 rf-break-all rf-truncate rf-w-full rf-max-w-full",children:`${C.currentFile.slice(0,60)}${C.currentFile.length>60?"...":""}`}),i.length>0&&T.jsx("div",{className:"rf-bg-red-50 rf-border rf-border-red-200 rf-rounded rf-p-2 rf-max-h-20 rf-overflow-y-auto rf-overflow-x-hidden",children:i.map((G,m)=>T.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${G.filePath}: ${G.message}`,children:[T.jsx("span",{className:"rf-font-medium rf-break-all",children:G.filePath.split("/").pop()}),T.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:G.message})]},m))})]}):T.jsxs(T.Fragment,{children:[T.jsxs("p",{children:["Reporting a bug will upload your entire project",a>0?` (${a} file${a===1?"":"s"})`:""," ","to tscircuit support."]}),T.jsxs("div",{className:"rf-space-y-2",children:[T.jsx("label",{htmlFor:"bug-description",className:"rf-block rf-font-medium",children:"Description (optional)"}),T.jsx("textarea",{ref:n,id:"bug-description",className:"rf-w-full rf-min-h-[100px] rf-px-3 rf-py-2 rf-text-sm rf-border rf-border-gray-300 rf-rounded-md focus:rf-outline-none focus:rf-ring-2 focus:rf-ring-blue-500",placeholder:"Describe the issue you're experiencing...",disabled:e})]}),T.jsxs("p",{children:["Share the generated bug report link privately with tscircuit staff so we can help debug your issue. You can also reach out on our",T.jsx("a",{className:"rf-ml-1 rf-text-blue-600 hover:rf-underline",href:"https://tscircuit.com/join",target:"_blank",rel:"noreferrer",children:"Discord community"}),"."]}),!l&&T.jsx("p",{className:"rf-text-red-600",children:"You appear to be logged out. Please log in before reporting a bug or the upload will fail."}),o&&T.jsx("p",{className:"rf-text-red-600",children:o})]})})})]}),T.jsx(xCg,{children:s?T.jsx("button",{type:"button",className:sO(),onClick:()=>{d()},children:"Close"}):T.jsxs(T.Fragment,{children:[T.jsx(JCg,{disabled:e,onClick:()=>{e||d()},children:"Cancel"}),!l&&h?T.jsx("button",{type:"button",className:sO(),onClick:G=>{G.preventDefault(),d(),h()},children:"Sign In"}):T.jsx("button",{type:"button",className:FR(sO(),e&&"rf-opacity-70 rf-cursor-not-allowed"),disabled:e,onClick:G=>{G.preventDefault(),y()},children:e?"Reporting...":"Upload & Report"})]})})]})},"bug-report-dialog")},[A,e,d,o,s,a,l,y,h,C,i]),openBugReportDialog:D}};function ifo({open:g,onOpenChange:A,onExport:I}){const[e,t]=z.useState(!1),o=()=>{I({includeSilkscreen:e}),A(!1)},B=()=>{A(!1)};return T.jsx(Hb,{open:g,onOpenChange:A,children:T.jsxs(xL,{children:[T.jsxs(FL,{children:[T.jsx(UL,{children:"LightBurn Export Options"}),T.jsx(vb,{children:"Configure export settings for PCB laser ablation with LightBurn"})]}),T.jsx("div",{className:"rf-flex rf-flex-col rf-gap-4 rf-py-4",children:T.jsxs("div",{className:"rf-flex rf-items-center rf-space-x-2",children:[T.jsx(roA,{id:"includeSilkscreen",checked:e,onCheckedChange:C=>t(C===!0)}),T.jsx("label",{htmlFor:"includeSilkscreen",className:"rf-text-xs rf-font-medium rf-leading-none peer-disabled:rf-cursor-not-allowed peer-disabled:rf-opacity-70",children:"Include silkscreen layer"})]})}),T.jsxs(_O,{children:[T.jsx(si,{variant:"outline",onClick:B,children:"Cancel"}),T.jsx(si,{onClick:o,children:"Export"})]})]})})}const Efo=/#(\d+)/,nfo=g=>{const A=g.match(Efo);if(!A)return null;const I=Number.parseInt(A[1],10);return Number.isFinite(I)?I:null},sfo=g=>{if(typeof g=="number")return Number.isFinite(g)?g:null;if(typeof g=="string"){const A=new Date(g).getTime();return Number.isFinite(A)?A:null}return null},afo=g=>{if(!g)return null;let A=null,I=-1,e=-1;for(const[t,o]of Object.entries(g)){const B=nfo(t),C=sfo(o.createdAt);if(B!==null){B>I&&(I=B,A={key:t,value:o});continue}if(I===-1){if(C!==null&&C>e){e=C,A={key:t,value:o};continue}A||(A={key:t,value:o})}}return A};var rfo=Object.defineProperty,cfo=(g,A)=>rfo(g,"name",{value:A,configurable:!0});function dQg(g,[A,I]){return Math.min(I,Math.max(A,g))}cfo(dQg,"clamp");var hfo=Object.defineProperty,lfo=(g,A)=>hfo(g,"name",{value:A,configurable:!0}),z4I=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Dfo=z.forwardRef(lfo(function(A,I){return T.jsx(yQ.span,{...A,ref:I,style:{...z4I,...A.style}})},"VisuallyHidden")),dfo=Object.defineProperty,ZE=(g,A)=>dfo(g,"name",{value:A,configurable:!0}),X4I={ItemAligned:"item-aligned",Popper:"popper"},yfo={RTL:"rtl"},wfo=[" ","Enter","ArrowUp","ArrowDown"],ufo=[" ","Enter"],HO="Select",[PpA,KpA,Gfo]=TlA(HO),[Ob,YCB]=hk(HO,[Gfo,ML]),yQg=ML(),[mfo,LL]=Ob(HO),[pfo,kfo]=Ob(HO);function $4I(g){const{__scopeSelect:A,children:I,open:e,defaultOpen:t,onOpenChange:o,value:B,defaultValue:C,onValueChange:Q,dir:i,name:E,autoComplete:n,disabled:s,required:r,form:a,internal_do_not_use_render:c}=g,h=yQg(A),[l,D]=z.useState(null),[d,y]=z.useState(null),[w,u]=z.useState(!1),G=WAA(i),[m,p]=xR({prop:e,defaultProp:t??!1,onChange:o,caller:HO}),[k,S]=xR({prop:B,defaultProp:C,onChange:Q,caller:HO}),R=z.useRef(null),x=z.useRef(!1),[N,U]=z.useState(null),K=ZE(QA=>{U({value:QA,hasConsumerStoppedPropagation:x.current}),S(QA)},"handleUserSelect"),Y=z.useRef(k);z.useEffect(()=>{const QA=a?l?.ownerDocument.getElementById(a):l?.form;if(QA instanceof HTMLFormElement){const sA=ZE(()=>S(Y.current),"reset");return QA.addEventListener("reset",sA),()=>QA.removeEventListener("reset",sA)}},[a,l,S]);const _=l?!!a||!!l.closest("form"):!0,[Z,V]=z.useState(new Set),W=_0(),q=Array.from(Z).map(QA=>QA.props.value).join(";"),X=z.useCallback(QA=>{V(sA=>new Set(sA).add(QA))},[]),tA=z.useCallback(QA=>{V(sA=>{const DA=new Set(sA);return DA.delete(QA),DA})},[]),IA={required:r,trigger:l,onTriggerChange:D,valueNode:d,onValueNodeChange:y,valueNodeHasChildren:w,onValueNodeHasChildrenChange:u,contentId:W,value:k,onValueChange:S,hasConsumerStoppedPropagationRef:x,userSelection:N,onUserSelect:K,open:m,onOpenChange:p,dir:G,triggerPointerDownPosRef:R,disabled:s,name:E,autoComplete:n,form:a,nativeOptions:Z,nativeSelectKey:q,isFormControl:_};return T.jsx(JtA,{...h,children:T.jsx(mfo,{scope:A,...IA,children:T.jsx(PpA.Provider,{scope:A,children:T.jsx(pfo,{scope:A,onNativeOptionAdd:X,onNativeOptionRemove:tA,children:rKI(c)?c(IA):I})})})})}ZE($4I,"SelectProvider");var Mfo=ZE(g=>{const{__scopeSelect:A,children:I,...e}=g;return T.jsx($4I,{__scopeSelect:A,...e,internal_do_not_use_render:({isFormControl:t})=>T.jsxs(T.Fragment,{children:[I,t?T.jsx(jfo,{__scopeSelect:A}):null]})})},"Select"),Sfo="SelectTrigger",AKI=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,disabled:t=!1,...o}=A,B=yQg(e),C=LL(Sfo,e),Q=C.disabled||t,i=Gi(I,C.onTriggerChange),E=KpA(e),n=z.useRef("touch"),[s,r,a]=GQg(h=>{const l=E().filter(y=>!y.disabled),D=l.find(y=>y.value===C.value),d=mQg(l,h,D);d!==void 0&&C.onUserSelect(d.value)}),c=ZE(h=>{Q||(C.onOpenChange(!0),a()),h&&(C.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})},"handleOpen");return T.jsx(QmA,{asChild:!0,...B,children:T.jsx(yQ.button,{type:"button",role:"combobox","aria-controls":C.open?C.contentId:void 0,"aria-expanded":C.open,"aria-required":C.required,"aria-autocomplete":"none",dir:C.dir,"data-state":C.open?"open":"closed",disabled:Q,"data-disabled":Q?"":void 0,"data-placeholder":moA(C.value)?"":void 0,...o,ref:i,onClick:fo(o.onClick,h=>{h.currentTarget.focus(),n.current!=="mouse"&&c(h)}),onPointerDown:fo(o.onPointerDown,h=>{n.current=h.pointerType;const l=h.target;l.hasPointerCapture(h.pointerId)&&l.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(c(h),h.preventDefault())}),onKeyDown:fo(o.onKeyDown,h=>{const l=s.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&(C.hasConsumerStoppedPropagationRef.current=h.isPropagationStopped(),r(h.key)),!(l&&h.key===" ")&&wfo.includes(h.key)&&(c(),h.preventDefault())})})})},"SelectTrigger")),ffo="SelectValue",Rfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,className:t,style:o,children:B,placeholder:C="",...Q}=A,i=LL(ffo,e),{onValueNodeHasChildrenChange:E}=i,n=B!==void 0,s=Gi(I,i.onValueNodeChange);uh(()=>{E(n)},[E,n]);const r=moA(i.value);return T.jsx(yQ.span,{...Q,asChild:r?!1:Q.asChild,ref:s,style:{pointerEvents:"none"},children:T.jsx(z.Fragment,{children:r?C:B},r?"placeholder":"value")})},"SelectValue")),Nfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,children:t,...o}=A;return T.jsx(yQ.span,{"aria-hidden":!0,...o,ref:I,children:t||"▼"})},"SelectIcon")),xfo="SelectPortal",[Ffo,Ufo]=Ob(xfo,{forceMount:void 0}),Jfo=ZE(g=>{const{__scopeSelect:A,forceMount:I,...e}=g;return T.jsx(Ffo,{scope:g.__scopeSelect,forceMount:I,children:T.jsx(nmA,{asChild:!0,...e})})},"SelectPortal"),Wb="SelectContent",gKI=z.forwardRef(ZE(function(A,I){const e=Ufo(Wb,A.__scopeSelect),{forceMount:t=e.forceMount,...o}=A,B=LL(Wb,A.__scopeSelect),[C,Q]=z.useState();return uh(()=>{Q(new DocumentFragment)},[]),T.jsx(AS,{present:t||B.open,children:({present:i})=>i?T.jsx(Lfo,{...o,ref:I}):T.jsx(Pfo,{...o,fragment:C})})},"SelectContent")),Pfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,children:t,fragment:o}=A;return o?dx.createPortal(T.jsx(IKI,{scope:e,children:T.jsx(PpA.Slot,{scope:e,children:T.jsx("div",{ref:I,children:t})})}),o):null},"SelectContentFragment")),rN=10,[IKI,Vb]=Ob(Wb),Kfo=NR("SelectContent.RemoveScroll"),Lfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e}=A,{position:t=X4I.ItemAligned,onCloseAutoFocus:o,onEscapeKeyDown:B,onPointerDownOutside:C,side:Q,sideOffset:i,align:E,alignOffset:n,arrowPadding:s,collisionBoundary:r,collisionPadding:a,sticky:c,hideWhenDetached:h,avoidCollisions:l,...D}=A,d=LL(Wb,e),[y,w]=z.useState(null),[u,G]=z.useState(null),m=Gi(I,w),[p,k]=z.useState(null),[S,R]=z.useState(null),x=KpA(e),[N,U]=z.useState(!1),K=z.useRef(!1),Y=z.useRef(!1),_=z.useRef(!1);z.useEffect(()=>{if(y)return rmA(y)},[y]),rO();const Z=z.useCallback(hA=>{const[nA,...aA]=x().map(rA=>rA.ref.current),[SA]=aA.slice(-1),FA=document.activeElement;for(const rA of hA)if(rA===FA||(rA?.scrollIntoView({block:"nearest"}),rA===nA&&u&&(u.scrollTop=0),rA===SA&&u&&(u.scrollTop=u.scrollHeight),rA?.focus(),document.activeElement!==FA))return},[x,u]),V=z.useCallback(()=>Z([p,y]),[Z,p,y]);z.useEffect(()=>{N&&V()},[N,V]);const{onOpenChange:W,triggerPointerDownPosRef:q}=d;z.useEffect(()=>{if(y){let hA={x:0,y:0};const nA=ZE(SA=>{hA={x:Math.abs(Math.round(SA.pageX)-(q.current?.x??0)),y:Math.abs(Math.round(SA.pageY)-(q.current?.y??0))}},"handlePointerMove"),aA=ZE(SA=>{hA.x<=10&&hA.y<=10?SA.preventDefault():SA.composedPath().includes(y)||W(!1),document.removeEventListener("pointermove",nA),q.current=null},"handlePointerUp");return q.current!==null&&(document.addEventListener("pointermove",nA),document.addEventListener("pointerup",aA,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",nA),document.removeEventListener("pointerup",aA,{capture:!0})}}},[y,W,q]),z.useEffect(()=>{const hA=ZE(()=>W(!1),"close");return window.addEventListener("blur",hA),window.addEventListener("resize",hA),()=>{window.removeEventListener("blur",hA),window.removeEventListener("resize",hA)}},[W]);const[X,tA]=GQg(hA=>{const nA=x().filter(FA=>!FA.disabled),aA=nA.find(FA=>FA.ref.current===document.activeElement),SA=mQg(nA,hA,aA);SA&&setTimeout(()=>SA.ref.current?.focus())}),IA=z.useCallback((hA,nA,aA)=>{const SA=!Y.current;SA&&(Y.current=!0);const FA=!K.current&&!aA;d.value!==void 0&&d.value===nA||FA?(k(hA),FA&&(K.current=!0)):SA&&k(hA)},[d.value]),QA=z.useCallback(()=>y?.focus(),[y]),sA=z.useCallback((hA,nA,aA)=>{if(!hA)return;const SA=!_.current;SA&&(_.current=!0);const FA=!K.current&&!aA;(d.value!==void 0&&d.value===nA||FA||SA)&&R(hA)},[d.value]),DA=t===X4I.Popper?eKI:Yfo,CA=DA===eKI?{side:Q,sideOffset:i,align:E,alignOffset:n,arrowPadding:s,collisionBoundary:r,collisionPadding:a,sticky:c,hideWhenDetached:h,avoidCollisions:l}:{};return T.jsx(IKI,{scope:e,content:y,viewport:u,onViewportChange:G,itemRefCallback:IA,selectedItem:p,onItemLeave:QA,itemTextRefCallback:sA,focusSelectedItem:V,selectedItemText:S,position:t,isPositioned:N,searchRef:X,children:T.jsx(PtA,{as:Kfo,allowPinchZoom:!0,children:T.jsx(OGA,{asChild:!0,trapped:d.open,onMountAutoFocus:hA=>{hA.preventDefault()},onUnmountAutoFocus:fo(o,hA=>{d.trigger?.focus({preventScroll:!0}),hA.preventDefault()}),children:T.jsx(xtA,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:B,onPointerDownOutside:C,onFocusOutside:hA=>hA.preventDefault(),onDismiss:()=>d.onOpenChange(!1),children:T.jsx(DA,{role:"listbox",id:d.contentId,"data-state":d.open?"open":"closed",dir:d.dir,onContextMenu:hA=>hA.preventDefault(),...D,...CA,onPlaced:()=>U(!0),ref:m,style:{display:"flex",flexDirection:"column",outline:"none",...D.style},onKeyDown:fo(D.onKeyDown,hA=>{const nA=hA.ctrlKey||hA.altKey||hA.metaKey;if(hA.key==="Tab"&&hA.preventDefault(),!nA&&hA.key.length===1&&tA(hA.key),["ArrowUp","ArrowDown","Home","End"].includes(hA.key)){let SA=x().filter(FA=>!FA.disabled).map(FA=>FA.ref.current);if(["ArrowUp","End"].includes(hA.key)&&(SA=SA.slice().reverse()),["ArrowUp","ArrowDown"].includes(hA.key)){const FA=hA.target,rA=SA.indexOf(FA);SA=SA.slice(rA+1)}setTimeout(()=>Z(SA)),hA.preventDefault()}})})})})})})},"SelectContentImpl")),Yfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,onPlaced:t,...o}=A,B=LL(Wb,e),C=Vb(Wb,e),[Q,i]=z.useState(null),[E,n]=z.useState(null),s=Gi(I,n),r=KpA(e),a=z.useRef(!1),c=z.useRef(!0),{viewport:h,selectedItem:l,selectedItemText:D,focusSelectedItem:d}=C,y=z.useCallback(()=>{if(B.trigger&&B.valueNode&&Q&&E&&h&&l&&D){const m=B.trigger.getBoundingClientRect(),p=E.getBoundingClientRect(),k=B.valueNode.getBoundingClientRect(),S=D.getBoundingClientRect();if(B.dir!==yfo.RTL){const aA=S.left-p.left,SA=k.left-aA,FA=m.left-SA,rA=m.width+FA,NA=Math.max(rA,p.width),RA=window.innerWidth-rN,xA=dQg(SA,[rN,Math.max(rN,RA-NA)]);Q.style.minWidth=rA+"px",Q.style.left=xA+"px"}else{const aA=p.right-S.right,SA=window.innerWidth-k.right-aA,FA=window.innerWidth-m.right-SA,rA=m.width+FA,NA=Math.max(rA,p.width),RA=window.innerWidth-rN,xA=dQg(SA,[rN,Math.max(rN,RA-NA)]);Q.style.minWidth=rA+"px",Q.style.right=xA+"px"}const R=r(),x=window.innerHeight-rN*2,N=h.scrollHeight,U=window.getComputedStyle(E),K=parseInt(U.borderTopWidth,10),Y=parseInt(U.paddingTop,10),_=parseInt(U.borderBottomWidth,10),Z=parseInt(U.paddingBottom,10),V=K+Y+N+Z+_,W=Math.min(l.offsetHeight*5,V),q=window.getComputedStyle(h),X=parseInt(q.paddingTop,10),tA=parseInt(q.paddingBottom,10),IA=m.top+m.height/2-rN,QA=x-IA,sA=l.offsetHeight/2,DA=l.offsetTop+sA,CA=K+Y+DA,hA=V-CA;if(CA<=IA){const aA=R.length>0&&l===R[R.length-1].ref.current;Q.style.bottom="0px";const SA=E.clientHeight-h.offsetTop-h.offsetHeight,FA=Math.max(QA,sA+(aA?tA:0)+SA+_),rA=CA+FA;Q.style.height=rA+"px"}else{const aA=R.length>0&&l===R[0].ref.current;Q.style.top="0px";const FA=Math.max(IA,K+h.offsetTop+(aA?X:0)+sA)+hA;Q.style.height=FA+"px",h.scrollTop=CA-IA+h.offsetTop}Q.style.margin=`${rN}px 0`,Q.style.minHeight=W+"px",Q.style.maxHeight=x+"px",t?.(),requestAnimationFrame(()=>a.current=!0)}},[r,B.trigger,B.valueNode,Q,E,h,l,D,B.dir,t]);uh(()=>y(),[y]);const[w,u]=z.useState();uh(()=>{E&&u(window.getComputedStyle(E).zIndex)},[E]);const G=z.useCallback(m=>{m&&c.current===!0&&(y(),d?.(),c.current=!1)},[y,d]);return T.jsx(_fo,{scope:e,contentWrapper:Q,shouldExpandOnScrollRef:a,onScrollButtonChange:G,children:T.jsx("div",{ref:i,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:T.jsx(yQ.div,{...o,ref:s,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})},"SelectItemAlignedPosition")),eKI=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,align:t="start",collisionPadding:o=rN,...B}=A,C=yQg(e);return T.jsx(imA,{...C,...B,ref:I,align:t,collisionPadding:o,style:{boxSizing:"border-box",...B.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[_fo,wQg]=Ob(Wb,{}),tKI="SelectViewport",bfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,nonce:t,...o}=A,B=Vb(tKI,e),C=wQg(tKI,e),Q=Gi(I,B.onViewportChange),i=z.useRef(0);return T.jsxs(T.Fragment,{children:[T.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:t}),T.jsx(PpA.Slot,{scope:e,children:T.jsx(yQ.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:Q,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fo(o.onScroll,E=>{const n=E.currentTarget,{contentWrapper:s,shouldExpandOnScrollRef:r}=C;if(r?.current&&s){const a=Math.abs(i.current-n.scrollTop);if(a>0){const c=window.innerHeight-rN*2,h=parseFloat(s.style.minHeight),l=parseFloat(s.style.height),D=Math.max(h,l);if(D<c){const d=D+a,y=Math.min(c,d),w=d-y;s.style.height=y+"px",s.style.bottom==="0px"&&(n.scrollTop=w>0?w:0,s.style.justifyContent="flex-end")}}}i.current=n.scrollTop})})})]})},"SelectViewport")),Hfo="SelectGroup",[_CB,vfo]=Ob(Hfo),Tfo="SelectLabel",oKI=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,...t}=A,o=vfo(Tfo,e);return T.jsx(yQ.div,{id:o.id,...t,ref:I})},"SelectLabel")),uQg="SelectItem",[qfo,BKI]=Ob(uQg),CKI=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,value:t,disabled:o=!1,textValue:B,...C}=A,Q=LL(uQg,e),i=Vb(uQg,e),E=Q.value===t,[n,s]=z.useState(B??""),[r,a]=z.useState(!1),c=$M(y=>i.itemRefCallback?.(y,t,o)),h=Gi(I,c),l=_0(),D=z.useRef("touch");function d(y){Q.hasConsumerStoppedPropagationRef.current=y.isPropagationStopped(),Q.onUserSelect(t),Q.onOpenChange(!1)}return ZE(d,"handleSelect"),T.jsx(qfo,{scope:e,value:t,disabled:o,textId:l,isSelected:E,onItemTextChange:z.useCallback(y=>{s(w=>w||(y?.textContent??"").trim())},[]),children:T.jsx(PpA.ItemSlot,{scope:e,value:t,disabled:o,textValue:n,children:T.jsx(yQ.div,{role:"option","aria-labelledby":l,"data-highlighted":r?"":void 0,"aria-selected":E&&r,"data-state":E?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...C,ref:h,onFocus:fo(C.onFocus,()=>a(!0)),onBlur:fo(C.onBlur,()=>a(!1)),onClick:fo(C.onClick,y=>{o||D.current!=="mouse"&&d(y)}),onPointerUp:fo(C.onPointerUp,y=>{o||D.current==="mouse"&&d(y)}),onPointerDown:fo(C.onPointerDown,y=>{D.current=y.pointerType}),onPointerMove:fo(C.onPointerMove,y=>{D.current=y.pointerType,o?i.onItemLeave?.():D.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:fo(C.onPointerLeave,y=>{y.currentTarget===document.activeElement&&i.onItemLeave?.()}),onKeyDown:fo(C.onKeyDown,y=>{o||y.target!==y.currentTarget||i.searchRef?.current!==""&&y.key===" "||(ufo.includes(y.key)&&d(y),y.key===" "&&y.preventDefault())})})})})},"SelectItem")),LpA="SelectItemText",Zfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,className:t,style:o,...B}=A,C=LL(LpA,e),Q=Vb(LpA,e),i=BKI(LpA,e),E=kfo(LpA,e),[n,s]=z.useState(null),r=$M(d=>Q.itemTextRefCallback?.(d,i.value,i.disabled)),a=Gi(I,s,i.onItemTextChange,r),c=n?.textContent,h=z.useMemo(()=>T.jsx("option",{value:i.value,disabled:i.disabled,children:c},i.value),[i.disabled,i.value,c]),{onNativeOptionAdd:l,onNativeOptionRemove:D}=E;return uh(()=>(l(h),()=>D(h)),[l,D,h]),T.jsxs(T.Fragment,{children:[T.jsx(yQ.span,{id:i.textId,...B,ref:a}),i.isSelected&&C.valueNode&&!C.valueNodeHasChildren&&!moA(C.value)?dx.createPortal(B.children,C.valueNode):null]})},"SelectItemText")),Ofo="SelectItemIndicator",Wfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,...t}=A;return BKI(Ofo,e).isSelected?T.jsx(yQ.span,{"aria-hidden":!0,...t,ref:I}):null},"SelectItemIndicator")),QKI="SelectScrollUpButton",iKI=z.forwardRef(ZE(function(A,I){const e=Vb(QKI,A.__scopeSelect),t=wQg(QKI,A.__scopeSelect),[o,B]=z.useState(!1),C=Gi(I,t.onScrollButtonChange);return uh(()=>{if(e.viewport&&e.isPositioned){let Q=function(){const E=i.scrollTop>0;B(E)};ZE(Q,"handleScroll");const i=e.viewport;return Q(),i.addEventListener("scroll",Q),()=>i.removeEventListener("scroll",Q)}},[e.viewport,e.isPositioned]),o?T.jsx(sKI,{...A,ref:C,onAutoScroll:()=>{const{viewport:Q,selectedItem:i}=e;Q&&i&&(Q.scrollTop=Q.scrollTop-i.offsetHeight)}}):null},"SelectScrollUpButton")),EKI="SelectScrollDownButton",nKI=z.forwardRef(ZE(function(A,I){const e=Vb(EKI,A.__scopeSelect),t=wQg(EKI,A.__scopeSelect),[o,B]=z.useState(!1),C=Gi(I,t.onScrollButtonChange);return uh(()=>{if(e.viewport&&e.isPositioned){let Q=function(){const E=i.scrollHeight-i.clientHeight,n=Math.ceil(i.scrollTop)<E;B(n)};ZE(Q,"handleScroll");const i=e.viewport;return Q(),i.addEventListener("scroll",Q),()=>i.removeEventListener("scroll",Q)}},[e.viewport,e.isPositioned]),o?T.jsx(sKI,{...A,ref:C,onAutoScroll:()=>{const{viewport:Q,selectedItem:i}=e;Q&&i&&(Q.scrollTop=Q.scrollTop+i.offsetHeight)}}):null},"SelectScrollDownButton")),sKI=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,onAutoScroll:t,...o}=A,B=Vb("SelectScrollButton",e),C=z.useRef(null),Q=KpA(e),i=z.useCallback(()=>{C.current!==null&&(window.clearInterval(C.current),C.current=null)},[]);return z.useEffect(()=>()=>i(),[i]),uh(()=>{Q().find(n=>n.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[Q]),T.jsx(yQ.div,{"aria-hidden":!0,...o,ref:I,style:{flexShrink:0,...o.style},onPointerDown:fo(o.onPointerDown,()=>{C.current===null&&(C.current=window.setInterval(t,50))}),onPointerMove:fo(o.onPointerMove,()=>{B.onItemLeave?.(),C.current===null&&(C.current=window.setInterval(t,50))}),onPointerLeave:fo(o.onPointerLeave,()=>{i()})})},"SelectScrollButtonImpl")),aKI=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,...t}=A;return T.jsx(yQ.div,{"aria-hidden":!0,...t,ref:I})},"SelectSeparator")),Vfo="SelectBubbleInput",jfo=z.forwardRef(ZE(function({__scopeSelect:A,...I},e){const t=LL(Vfo,A),{value:o,onValueChange:B,required:C,disabled:Q,name:i,autoComplete:E,form:n,userSelection:s}=t,{nativeOptions:r,nativeSelectKey:a}=t,c=z.useRef(null),h=Gi(e,c),l=o??"",D=z.useRef(l),d=z.useRef(s),y=z.useRef(!1),w=Array.from(r).some(u=>(u.props.value??"")==="");return z.useEffect(()=>{const u=c.current;if(!u)return;const G=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(G,"value").set,k=s!==null&&s!==d.current;d.current=s;const S=D.current!==l;D.current=l;const R=k&&S;if(k&&!S&&s.value!==l&&!s.hasConsumerStoppedPropagation&&p){y.current=!0;try{p.call(u,s.value),u.dispatchEvent(new Event("change",{bubbles:!0}))}finally{y.current=!1,p.call(u,l)}return}const x=R&&!s.hasConsumerStoppedPropagation;if(S&&p){const N=new Event("change",{bubbles:x});p.call(u,l),u.dispatchEvent(N)}},[l,s]),T.jsxs(yQ.select,{"aria-hidden":!0,required:C,tabIndex:-1,name:i,autoComplete:E,disabled:Q,form:n,onChange:u=>{y.current||B(u.target.value)},...I,style:{...z4I,...I.style},ref:h,defaultValue:l,children:[moA(o)&&!w?T.jsx("option",{value:""}):null,Array.from(r)]},a)},"SelectBubbleInput"));function rKI(g){return typeof g=="function"}ZE(rKI,"isFunction");function moA(g){return g===""||g===void 0}ZE(moA,"shouldShowPlaceholder");function GQg(g){const A=$M(g),I=z.useRef(""),e=z.useRef(0),t=z.useCallback(B=>{const C=I.current+B;A(C);function Q(i){I.current=i,window.clearTimeout(e.current),i!==""&&(e.current=window.setTimeout(()=>Q(""),1e3))}ZE(Q,"updateSearch"),Q(C)},[A]),o=z.useCallback(()=>{I.current="",window.clearTimeout(e.current)},[]);return z.useEffect(()=>()=>window.clearTimeout(e.current),[]),[I,t,o]}ZE(GQg,"useTypeaheadSearch");function mQg(g,A,I){const t=A.length>1&&Array.from(A).every(i=>i===A[0])?A[0]:A,o=I?g.indexOf(I):-1;let B=cKI(g,Math.max(o,0));t.length===1&&(B=B.filter(i=>i!==I));const Q=B.find(i=>i.textValue.toLowerCase().startsWith(t.toLowerCase()));return Q!==I?Q:void 0}ZE(mQg,"findNextItem");function cKI(g,A){return g.map((I,e)=>g[(A+e)%g.length])}ZE(cKI,"wrapArray");const zfo=Mfo,Xfo=Rfo,hKI=z.forwardRef(({className:g,children:A,...I},e)=>T.jsxs(AKI,{ref:e,className:co("rf-flex rf-h-10 rf-w-full rf-items-center rf-justify-between rf-rounded-md rf-border rf-border-input rf-bg-background rf-px-3 rf-py-2 rf-text-sm rf-ring-offset-background rf-placeholder:text-muted-foreground focus:rf-outline-none focus:rf-ring-2 focus:rf-ring-ring focus:rf-ring-offset-2 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 [&>span]:rf-line-clamp-1",g),...I,children:[A,T.jsx(Nfo,{asChild:!0,children:T.jsx(RtA,{className:"rf-h-4 rf-w-4 rf-opacity-50"})})]}));hKI.displayName=AKI.displayName;const lKI=z.forwardRef(({className:g,...A},I)=>T.jsx(iKI,{ref:I,className:co("rf-flex rf-cursor-default rf-items-center rf-justify-center rf-py-1",g),...A,children:T.jsx(gco,{className:"rf-h-4 rf-w-4"})}));lKI.displayName=iKI.displayName;const DKI=z.forwardRef(({className:g,...A},I)=>T.jsx(nKI,{ref:I,className:co("rf-flex rf-cursor-default rf-items-center rf-justify-center rf-py-1",g),...A,children:T.jsx(RtA,{className:"rf-h-4 rf-w-4"})}));DKI.displayName=nKI.displayName;const dKI=z.forwardRef(({className:g,children:A,position:I="popper",...e},t)=>T.jsx(Jfo,{children:T.jsxs(gKI,{ref:t,className:co("rf-relative rf-z-[100] rf-max-h-96 rf-min-w-[8rem] rf-overflow-hidden rf-rounded-md rf-border rf-bg-white rf-text-black rf-shadow-md data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2",I==="popper"&&"data-[side=bottom]:rf-translate-y-1 data-[side=left]:-rf-translate-x-1 data-[side=right]:rf-translate-x-1 data-[side=top]:-rf-translate-y-1",g),position:I,...e,children:[T.jsx(lKI,{}),T.jsx(bfo,{className:co("rf-p-1",I==="popper"&&"rf-h-[var(--radix-select-trigger-height)] rf-w-full rf-min-w-[var(--radix-select-trigger-width)]"),children:A}),T.jsx(DKI,{})]})}));dKI.displayName=gKI.displayName;const $fo=z.forwardRef(({className:g,...A},I)=>T.jsx(oKI,{ref:I,className:co("rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-font-semibold",g),...A}));$fo.displayName=oKI.displayName;const yKI=z.forwardRef(({className:g,children:A,...I},e)=>T.jsxs(CKI,{ref:e,className:co("rf-relative rf-flex rf-w-full rf-cursor-default rf-select-none rf-items-center rf-rounded-sm rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-text-gray-800 rf-outline-none focus:rf-bg-gray-100 focus:rf-text-gray-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50",g),...I,children:[T.jsx("span",{className:"rf-absolute rf-left-2 rf-flex rf-h-3.5 rf-w-3.5 rf-items-center rf-justify-center",children:T.jsx(Wfo,{children:T.jsx(sF,{className:"rf-h-4 rf-w-4"})})}),T.jsx(Zfo,{children:A})]}));yKI.displayName=CKI.displayName;const ARo=z.forwardRef(({className:g,...A},I)=>T.jsx(aKI,{ref:I,className:co("-rf-mx-1 rf-my-1 rf-h-px rf-bg-muted",g),...A}));ARo.displayName=aKI.displayName;const wKI="Component Box (3MF)",pQg=g=>`${g.toFixed(1)} mm`;function gRo({open:g,onOpenChange:A,circuitJson:I,projectName:e}){noA();const[t,o]=z.useState(""),[B,C]=z.useState(null),[Q,i]=z.useState(null),[E,n]=z.useState(!1),[s,r]=z.useState(null);z.useEffect(()=>()=>{Q&&URL.revokeObjectURL(Q)},[Q]),z.useEffect(()=>{if(!g||t!==wKI)return;let c=!1;return n(!0),C(null),r(null),dSo(I).then(h=>{if(c)return;const l=Uint8Array.from(h.previewPng);C(h),i(URL.createObjectURL(new Blob([l.buffer],{type:"image/png"})))}).catch(h=>{c||r(h instanceof Error?h.message:String(h))}).finally(()=>{c||n(!1)}),()=>{c=!0}},[I,g,t]);const a=c=>{c||(o(""),C(null),i(null),r(null),n(!1)),A(c)};return T.jsx(Hb,{open:g,onOpenChange:a,children:T.jsxs(xL,{className:"rf-max-h-[90vh] rf-max-w-3xl rf-overflow-y-auto",children:[T.jsxs(FL,{children:[T.jsx(UL,{children:"Export Accessory"}),T.jsx(vb,{children:"Generate a printable accessory from the components in this circuit."})]}),T.jsxs("div",{className:"rf-grid rf-gap-5 md:rf-grid-cols-[220px_1fr]",children:[T.jsxs("div",{className:"rf-space-y-2",children:[T.jsx("label",{htmlFor:"accessory-select",className:"rf-text-sm rf-font-medium",children:"Accessory"}),T.jsxs(zfo,{value:t,onValueChange:c=>o(c),children:[T.jsx(hKI,{id:"accessory-select",children:T.jsx(Xfo,{placeholder:"Choose an accessory"})}),T.jsx(dKI,{children:T.jsx(yKI,{value:wKI,children:"Component Box"})})]}),T.jsx("p",{className:"rf-text-xs rf-leading-relaxed rf-text-zinc-500",children:"Creates grouped compartments with raised refdes labels as a multi-material 3MF."})]}),T.jsxs("div",{className:"rf-overflow-hidden rf-rounded-lg rf-border rf-border-zinc-200 rf-bg-zinc-50 dark:rf-border-zinc-800 dark:rf-bg-zinc-900",children:[T.jsxs("div",{className:"rf-flex rf-min-h-56 rf-items-center rf-justify-center",children:[!t&&T.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-3 rf-p-8 rf-text-center rf-text-zinc-500",children:[T.jsx(dco,{className:"rf-h-10 rf-w-10 rf-stroke-1"}),T.jsx("p",{className:"rf-text-sm",children:"Choose an accessory to generate its preview."})]}),E&&T.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-3 rf-p-8 rf-text-zinc-600 dark:rf-text-zinc-300",children:[T.jsx(mS,{className:"rf-h-8 rf-w-8 rf-animate-spin"}),T.jsx("p",{className:"rf-text-sm",children:"Generating component box…"})]}),s&&!E&&T.jsxs("div",{className:"rf-p-8 rf-text-center",children:[T.jsx("p",{className:"rf-text-sm rf-font-medium rf-text-red-600",children:"Could not generate the preview"}),T.jsx("p",{className:"rf-mt-1 rf-text-xs rf-text-red-500",children:s})]}),Q&&B&&!E&&T.jsx("img",{src:Q,alt:"Generated component box preview",className:"rf-block rf-h-auto rf-max-h-[300px] rf-w-full rf-object-contain"})]}),B&&!E&&T.jsxs("div",{className:"rf-flex rf-flex-wrap rf-gap-x-5 rf-gap-y-1 rf-border-t rf-border-zinc-200 rf-bg-white rf-px-4 rf-py-3 rf-text-xs rf-text-zinc-600 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-300",children:[T.jsxs("span",{children:[B.compartments.length," compartments"]}),T.jsxs("span",{children:[pQg(B.dimensions.width)," ×"," ",pQg(B.dimensions.depth)," ×"," ",pQg(B.dimensions.height)]})]})]})]}),T.jsxs(_O,{children:[T.jsx(si,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),T.jsxs(si,{disabled:!B||E,onClick:()=>{B&&r4I({generatedBox:B,projectName:e})},children:[T.jsx(NtA,{}),"Download 3MF"]})]})]})})}const YpA=g=>{const A=apA(aA=>aA.lastRunEvalVersion),I=Kc(aA=>aA.currentMainComponentPath),[e,t]=z.useState(null),[o,B]=z.useState(!1),[C,Q]=z.useState(!0),[i,E]=z.useState(!1),[n,s]=z.useState(null),[r,a]=z.useState(null),[c,h]=z.useState(!1),[l,D]=z.useState(null),[d,y]=z.useState(null),[w,u]=z.useState(!1),[G,m]=z.useState(!1),[p,k]=z.useState(!1),[S,R]=z.useState(!1),[x,N]=z.useState(null),U=ofo(),K=Kc(aA=>aA.pushEvent),Y=Kc(aA=>aA.recentEvents),_=z.useMemo(()=>Date.now(),[]);kko(aA=>{if(!(new Date(aA.created_at).valueOf()<_+500)){if(aA.event_type==="FILE_UPDATED"){B(!0);return}if(aA.event_type==="SNIPPET_SAVED"){B(!1),Q(!1),D("Snippet saved successfully."),u(!1);return}aA.event_type==="REQUEST_EXPORT"&&(m(!0),D("Export processing..."),u(!1)),aA.event_type==="EXPORT_CREATED"&&(D(`Export created: ${aA.exportFilePath}`),u(!1),m(!1))}}),z.useEffect(()=>{if(!i||n===null)return;const aA=Y.filter(rA=>new Date(rA.created_at).valueOf()>n),SA=aA.find(rA=>rA.event_type==="FAILED_TO_SAVE_SNIPPET"),FA=aA.find(rA=>rA.event_type==="SNIPPET_SAVED");SA&&(E(!1),s(null),y(SA.message??"Failed to save snippet. See console for error."),console.error(SA.message),u(!0),SA.error_code==="SNIPPET_UNSET"&&SA.available_snippet_names&&(a(SA.available_snippet_names),h(!0))),FA&&(E(!1),s(null),D("Snippet saved successfully."),u(!1))},[Y,i]);const Z=async()=>{E(!0),s(Date.now()),D(null),u(!1),await K({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:e})},W=Kc(aA=>aA.circuitJson)??g.circuitJson,q=z.useMemo(()=>{let aA="Untitled";if(I){const SA=I.split("/").pop();SA&&(aA=SA.replace(/\.[^.]+$/,""))}return(g.projectName??e??aA).replace(/\.(board|circuit)$/,"")},[I,g.projectName,e]),[X,tA]=z.useState(!1),[IA,QA]=z.useState(!1),{BugReportDialog:sA,openBugReportDialog:DA}=Qfo({onLoginRequired:g.onLoginRequired}),CA=async aA=>{x&&(await c4I({circuitJson:x.circuitJson,projectName:x.projectName,options:aA}),N(null))},hA=z.useMemo(()=>afo(g.autoroutingLog),[g.autoroutingLog]),nA=aA=>{if(!W){LC.error("No Circuit JSON to export");return}const SA=hA?.value.simpleRouteJson;if(aA==="LightBurn"){N({circuitJson:W,projectName:q}),k(!0);return}RSo({exportName:aA,circuitJson:W,simpleRouteJson:SA,projectName:q})};return T.jsxs(T.Fragment,{children:[T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1 rf-flex-shrink-0",children:[T.jsxs(MmA,{children:[T.jsx(SmA,{asChild:!0,children:T.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"File"})}),T.jsxs(vtA,{className:"rf-z-[101]",children:[!g.isWebEmbedded&&T.jsxs(T.Fragment,{children:[T.jsx(a0,{className:"rf-text-xs",onSelect:Z,disabled:i,children:i?"Saving...":"Push"}),parseInt(window.location.port)>5e3&&T.jsx(a0,{className:"rf-text-xs",onSelect:()=>{U.open()},children:"Order"}),T.jsx(a0,{className:"rf-text-xs",onSelect:()=>tA(!0),disabled:i,children:"Import"}),T.jsx(a0,{className:"rf-text-xs",onSelect:()=>{if(!HDA()){LC.error("Requires tscircuit token");return}QA(!0)},children:"AI Review"})]}),!g.isWebEmbedded&&g.onLoginRequired&&T.jsx(a0,{className:"rf-text-xs",onSelect:()=>{g.onLoginRequired?.()},children:"Sign In"}),!g.isWebEmbedded&&T.jsxs(HtA,{children:[T.jsx(mO,{className:"rf-text-xs",children:"Report Bug"}),T.jsx(btA,{children:T.jsxs(pO,{children:[T.jsx(a0,{className:"rf-text-xs",onSelect:()=>{DA()},children:"Report Entire Circuit"}),T.jsx(a0,{className:"rf-text-xs",disabled:!hA||!g.onReportAutoroutingLog,onSelect:()=>{!hA||!g.onReportAutoroutingLog||g.onReportAutoroutingLog(hA.key,{simpleRouteJson:hA.value.simpleRouteJson})},children:"Report Autorouter Bug"})]})})]}),T.jsxs(HtA,{children:[T.jsx(mO,{className:"rf-text-xs",disabled:G,children:G?"Exporting...":"Export"}),T.jsx(btA,{children:T.jsx(pO,{children:fSo.map((aA,SA)=>T.jsx(a0,{onSelect:()=>nA(aA.name),disabled:G||aA.name==="Simple Route JSON"&&!hA,children:T.jsx("span",{className:"rf-text-xs",children:aA.name})},SA))})})]}),T.jsx(a0,{className:"rf-text-xs",disabled:G,onSelect:()=>{if(!W){LC.error("No Circuit JSON to export");return}R(!0)},children:"Export Accessory…"}),!g.isWebEmbedded&&T.jsxs(HtA,{children:[T.jsx(mO,{className:"rf-text-xs",children:"Advanced"}),T.jsx(btA,{children:T.jsxs(pO,{children:[T.jsx(a0,{className:"rf-flex rf-items-center rf-gap-2",children:T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[T.jsx(roA,{id:"load-latest-eval",checked:g.shouldLoadLatestEval,onCheckedChange:aA=>{g.onChangeShouldLoadLatestEval?.(aA===!0)}}),T.jsx("label",{htmlFor:"load-latest-eval",className:"rf-text-xs rf-cursor-pointer",children:"Force Latest @tscircuit/eval"})]})}),A&&T.jsx(a0,{className:"rf-flex rf-items-center rf-gap-2",children:T.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:T.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/eval@",A]})})}),T.jsx(a0,{className:"rf-flex rf-items-center rf-gap-2",children:T.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:T.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/runframe@",Gko.version]})})}),T.jsx(a0,{className:"rf-flex rf-items-center rf-gap-2",onClick:()=>{window.open("/api/admin","_blank")},children:T.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:T.jsx("span",{className:"rf-text-xs",children:"CLI Admin Panel"})})})]})})]})]}),T.jsx(bPI,{open:w,onOpenChange:u,children:T.jsxs(RCg,{children:[T.jsxs(NCg,{children:[T.jsx(FCg,{children:"Error Saving Snippet"}),T.jsx(UCg,{children:d})]}),T.jsx(xCg,{children:T.jsx(JCg,{onClick:()=>u(!1),children:"Dismiss"})})]})}),T.jsx(pko,{snippetNames:r??[],onSelect:async aA=>{E(!0),s(Date.now()),t(aA),await K({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:aA}),h(!1)},onCancel:()=>h(!1),isOpen:c})]}),T.jsxs(MmA,{children:[T.jsx(SmA,{asChild:!0,children:T.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"View"})}),T.jsx(vtA,{className:"rf-z-[101]",children:T.jsxs(HtA,{children:[T.jsx(mO,{className:"rf-text-xs",children:"Schematic"}),T.jsx(btA,{children:T.jsxs(pO,{children:[T.jsx(a0,{className:"rf-flex rf-items-center rf-gap-2",onSelect:aA=>aA.preventDefault(),children:T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[T.jsx(roA,{id:"show-schematic-ports",checked:g.showSchematicPorts,onCheckedChange:aA=>{g.onChangeShowSchematicPorts?.(aA===!0)}}),T.jsx("label",{htmlFor:"show-schematic-ports",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Ports"})]})}),T.jsx(a0,{className:"rf-flex rf-items-center rf-gap-2",onSelect:aA=>aA.preventDefault(),children:T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[T.jsx(roA,{id:"show-schematic-grid",checked:g.showSchematicDebugGrid,onCheckedChange:aA=>{g.onChangeShowSchematicDebugGrid?.(aA===!0)}}),T.jsx("label",{htmlFor:"show-schematic-grid",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Grid"})]})})]})})]})})]})]}),sA,T.jsx(ifo,{open:p,onOpenChange:k,onExport:CA}),W&&T.jsx(gRo,{open:S,onOpenChange:R,circuitJson:W,projectName:q}),T.jsx(s4I,{isOpen:X,onClose:()=>tA(!1)}),T.jsx(c2o,{isOpen:IA,onClose:()=>QA(!1),packageName:e}),T.jsx(gGI,{position:"top-center",reverseOrder:!1,containerStyle:{zIndex:1e5},toastOptions:{className:"rf-break-all",style:{zIndex:1e5}}}),T.jsx(U.OrderDialog,{isOpen:U.isOpen,onClose:U.close,stage:U.stage,setStage:U.setStage})]})};var IRo=Object.defineProperty,Wy=(g,A)=>IRo(g,"name",{value:A,configurable:!0}),[kQg,bCB]=hk("Tooltip",[ML]),MQg=ML(),eRo="TooltipProvider",tRo=700,SQg="tooltip.open",[oRo,fQg]=kQg(eRo),BRo=Wy(g=>{const{__scopeTooltip:A,delayDuration:I=tRo,skipDelayDuration:e=300,disableHoverableContent:t=!1,children:o}=g,B=z.useRef(!0),C=z.useRef(!1),Q=z.useRef(0);return z.useEffect(()=>{const i=Q.current;return()=>window.clearTimeout(i)},[]),T.jsx(oRo,{scope:A,isOpenDelayedRef:B,delayDuration:I,onOpen:z.useCallback(()=>{e<=0||(window.clearTimeout(Q.current),B.current=!1)},[e]),onClose:z.useCallback(()=>{e<=0||(window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>B.current=!0,e))},[e]),isPointerInTransitRef:C,onPointerInTransitChange:z.useCallback(i=>{C.current=i},[]),disableHoverableContent:t,children:o})},"TooltipProvider"),RQg="Tooltip",[CRo,_pA]=kQg(RQg),QRo=Wy(g=>{const{__scopeTooltip:A,children:I,open:e,defaultOpen:t,onOpenChange:o,disableHoverableContent:B,delayDuration:C}=g,Q=fQg(RQg,g.__scopeTooltip),i=MQg(A),[E,n]=z.useState(null),[s,r]=z.useState(void 0),a=_0(),c=z.useRef(0),h=B??Q.disableHoverableContent,l=C??Q.delayDuration,D=z.useRef(!1),[d,y]=xR({prop:e,defaultProp:t??!1,onChange:Wy(k=>{k?(Q.onOpen(),document.dispatchEvent(new CustomEvent(SQg))):Q.onClose(),o?.(k)},"onChange"),caller:RQg}),w=z.useMemo(()=>d?D.current?"delayed-open":"instant-open":"closed",[d]),u=z.useCallback(()=>{window.clearTimeout(c.current),c.current=0,D.current=!1,y(!0)},[y]),G=z.useCallback(()=>{window.clearTimeout(c.current),c.current=0,y(!1)},[y]),m=z.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>{D.current=!0,y(!0),c.current=0},l)},[l,y]);z.useEffect(()=>()=>{c.current&&(window.clearTimeout(c.current),c.current=0)},[]);const p=s??a;return T.jsx(JtA,{...i,children:T.jsx(CRo,{scope:A,contentId:p,setContentId:r,open:d,stateAttribute:w,trigger:E,onTriggerChange:n,onTriggerEnter:z.useCallback(()=>{Q.isOpenDelayedRef.current?m():u()},[Q.isOpenDelayedRef,m,u]),onTriggerLeave:z.useCallback(()=>{h?G():(window.clearTimeout(c.current),c.current=0)},[G,h]),onOpen:u,onClose:G,disableHoverableContent:h,children:I})})},"Tooltip"),uKI="TooltipTrigger",iRo=z.forwardRef(Wy(function(A,I){const{__scopeTooltip:e,"aria-describedby":t,...o}=A,B=_pA(uKI,e),C=fQg(uKI,e),Q=MQg(e),i=z.useRef(null),E=Gi(I,i,B.onTriggerChange),n=z.useRef(!1),s=z.useRef(!1),r=z.useCallback(()=>n.current=!1,[]);return z.useEffect(()=>()=>document.removeEventListener("pointerup",r),[r]),T.jsx(QmA,{asChild:!0,...Q,children:T.jsx(yQ.button,{"aria-describedby":B.open?NKI(t,B.contentId):t,"data-state":B.stateAttribute,...o,ref:E,onPointerMove:fo(A.onPointerMove,a=>{a.pointerType!=="touch"&&!s.current&&!C.isPointerInTransitRef.current&&(B.onTriggerEnter(),s.current=!0)}),onPointerLeave:fo(A.onPointerLeave,()=>{B.onTriggerLeave(),s.current=!1}),onPointerDown:fo(A.onPointerDown,()=>{B.open&&B.onClose(),n.current=!0,document.addEventListener("pointerup",r,{once:!0})}),onFocus:fo(A.onFocus,()=>{n.current||B.onOpen()}),onBlur:fo(A.onBlur,B.onClose),onClick:fo(A.onClick,B.onClose)})})},"TooltipTrigger")),ERo="TooltipPortal",[HCB,nRo]=kQg(ERo,{forceMount:void 0}),poA="TooltipContent",GKI=z.forwardRef(Wy(function(A,I){const e=nRo(poA,A.__scopeTooltip),{forceMount:t=e.forceMount,side:o="top",...B}=A,C=_pA(poA,A.__scopeTooltip);return T.jsx(AS,{present:t||C.open,children:C.disableHoverableContent?T.jsx(mKI,{side:o,...B,ref:I}):T.jsx(sRo,{side:o,...B,ref:I})})},"TooltipContent")),sRo=z.forwardRef(Wy(function(A,I){const e=_pA(poA,A.__scopeTooltip),t=fQg(poA,A.__scopeTooltip),o=z.useRef(null),B=Gi(I,o),[C,Q]=z.useState(null),{trigger:i,onClose:E}=e,n=o.current,{onPointerInTransitChange:s}=t,r=z.useCallback(()=>{Q(null),s(!1)},[s]),a=z.useCallback((c,h)=>{const l=c.currentTarget,D={x:c.clientX,y:c.clientY},d=pKI(D,l.getBoundingClientRect()),y=kKI(D,d),w=MKI(h.getBoundingClientRect()),u=fKI([...y,...w]);Q(u),s(!0)},[s]);return z.useEffect(()=>()=>r(),[r]),z.useEffect(()=>{if(i&&n){const c=Wy(l=>a(l,n),"handleTriggerLeave"),h=Wy(l=>a(l,i),"handleContentLeave");return i.addEventListener("pointerleave",c),n.addEventListener("pointerleave",h),()=>{i.removeEventListener("pointerleave",c),n.removeEventListener("pointerleave",h)}}},[i,n,a,r]),z.useEffect(()=>{if(C){const c=Wy(h=>{const l=h.target,D={x:h.clientX,y:h.clientY},d=i?.contains(l)||n?.contains(l),y=!SKI(D,C);d?r():y&&(r(),E())},"handleTrackPointerGrace");return document.addEventListener("pointermove",c),()=>document.removeEventListener("pointermove",c)}},[i,n,C,E,r]),T.jsx(mKI,{...A,ref:B})},"TooltipContentHoverable")),aRo=kXg("TooltipContent"),mKI=z.forwardRef(Wy(function(A,I){const{__scopeTooltip:e,children:t,"aria-label":o,id:B,onEscapeKeyDown:C,onPointerDownOutside:Q,...i}=A,E=_pA(poA,e),n=MQg(e),{onClose:s}=E,[r,a]=z.useState(null),c=Gi(I,a);jGA(r),z.useEffect(()=>(document.addEventListener(SQg,s),()=>document.removeEventListener(SQg,s)),[s]),z.useEffect(()=>{if(E.trigger){const l=Wy(D=>{D.target instanceof Node&&D.target.contains(E.trigger)&&s()},"handleScroll");return window.addEventListener("scroll",l,{capture:!0}),()=>window.removeEventListener("scroll",l,{capture:!0})}},[E.trigger,s]);const{setContentId:h}=E;return uh(()=>(h(B),()=>{h(void 0)}),[B,h]),T.jsx(xtA,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:C,onPointerDownOutside:Q,onFocusOutside:l=>l.preventDefault(),onDismiss:s,children:T.jsxs(imA,{"data-state":E.stateAttribute,role:o?void 0:"tooltip",id:o?void 0:E.contentId,...n,...i,ref:c,style:{...i.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[T.jsx(aRo,{children:t}),o?T.jsx(Dfo,{id:E.contentId,role:"tooltip",children:o}):null]})})},"TooltipContentImpl"));function pKI(g,A){const I=Math.abs(A.top-g.y),e=Math.abs(A.bottom-g.y),t=Math.abs(A.right-g.x),o=Math.abs(A.left-g.x);switch(Math.min(I,e,t,o)){case o:return"left";case t:return"right";case I:return"top";case e:return"bottom";default:throw new Error("unreachable")}}Wy(pKI,"getExitSideFromRect");function kKI(g,A,I=5){const e=[];switch(A){case"top":e.push({x:g.x-I,y:g.y+I},{x:g.x+I,y:g.y+I});break;case"bottom":e.push({x:g.x-I,y:g.y-I},{x:g.x+I,y:g.y-I});break;case"left":e.push({x:g.x+I,y:g.y-I},{x:g.x+I,y:g.y+I});break;case"right":e.push({x:g.x-I,y:g.y-I},{x:g.x-I,y:g.y+I});break}return e}Wy(kKI,"getPaddedExitPoints");function MKI(g){const{top:A,right:I,bottom:e,left:t}=g;return[{x:t,y:A},{x:I,y:A},{x:I,y:e},{x:t,y:e}]}Wy(MKI,"getPointsFromRect");function SKI(g,A){const{x:I,y:e}=g;let t=!1;for(let o=0,B=A.length-1;o<A.length;B=o++){const C=A[o],Q=A[B],i=C.x,E=C.y,n=Q.x,s=Q.y;E>e!=s>e&&I<(n-i)*(e-E)/(s-E)+i&&(t=!t)}return t}Wy(SKI,"isPointInPolygon");function fKI(g){const A=g.slice();return A.sort((I,e)=>I.x<e.x?-1:I.x>e.x?1:I.y<e.y?-1:I.y>e.y?1:0),RKI(A)}Wy(fKI,"getHull");function RKI(g){if(g.length<=1)return g.slice();const A=[];for(let e=0;e<g.length;e++){const t=g[e];for(;A.length>=2;){const o=A[A.length-1],B=A[A.length-2];if((o.x-B.x)*(t.y-B.y)>=(o.y-B.y)*(t.x-B.x))A.pop();else break}A.push(t)}A.pop();const I=[];for(let e=g.length-1;e>=0;e--){const t=g[e];for(;I.length>=2;){const o=I[I.length-1],B=I[I.length-2];if((o.x-B.x)*(t.y-B.y)>=(o.y-B.y)*(t.x-B.x))I.pop();else break}I.push(t)}return I.pop(),A.length===1&&I.length===1&&A[0].x===I[0].x&&A[0].y===I[0].y?A:A.concat(I)}Wy(RKI,"getHullPresorted");function NKI(...g){const A=new Set;for(const I of g)if(typeof I=="string")for(const e of String(I).trim().split(/\s+/))e&&A.add(e);return A.size>0?Array.from(A).join(" "):void 0}Wy(NKI,"concatAriaDescribedby");const NQg=BRo,xQg=QRo,FQg=iRo,bpA=z.forwardRef(({className:g,sideOffset:A=4,...I},e)=>T.jsx(GKI,{ref:e,sideOffset:A,className:co("z-50 overflow-hidden rounded-md bg-slate-900 px-3 py-1.5 text-xs text-slate-50 animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:bg-slate-50 dark:text-slate-900",g),...I}));bpA.displayName=GKI.displayName;const rRo="24b58135-86c7-4e4b-bf6e-cca862bc4b26",xKI="runframe-crisp-chat-script",cRo="tscircuit.com",koA=g=>{window.$crisp=window.$crisp||[],window.$crisp.push(g)},hRo=()=>{if(window.$crisp=window.$crisp||[],window.CRISP_WEBSITE_ID=rRo,window.__RUNFRAME_CRISP_CONFIGURED__||(window.__RUNFRAME_CRISP_CONFIGURED__=!0,koA(["do","chat:hide"]),koA(["on","chat:closed",()=>koA(["do","chat:hide"])])),!document.getElementById(xKI)){const g=document.createElement("script");g.id=xKI,g.src="https://client.crisp.chat/l.js",g.async=!0,document.head.appendChild(g)}},lRo=()=>{hRo(),koA(["do","chat:show"]),koA(["do","chat:open"])},DRo=({isCli:g,hostname:A=typeof window<"u"?window.location.hostname:void 0}={})=>A?.toLowerCase()===cRo?!1:!!g,dRo=()=>T.jsx(NQg,{children:T.jsxs(xQg,{children:[T.jsx(FQg,{asChild:!0,children:T.jsx(si,{type:"button",variant:"ghost",size:"icon","aria-label":"Get Support or Give Feedback",onClick:lRo,className:"rf-h-8 rf-w-8",children:T.jsx(lco,{className:"rf-h-4 rf-w-4 rf-text-gray-500"})})}),T.jsx(bpA,{side:"bottom",children:"Get Support or Give Feedback"})]})}),wF="rf-h-[620px] rf-min-h-full rf-max-h-full",FKI=["assembly","pinout","analog_simulation","bom","circuit_json","errors","render_log","autorouting","solvers"],UQg=g=>g instanceof Error?g.message:"An unknown error occurred",UKI=({platformConfig:g,code:A,fsMap:I,onRunClicked:e=void 0,errorMessage:t,errorStack:o,circuitJson:B,autoroutingGraphics:C,showRightHeaderContent:Q=!0,showCodeTab:i=!1,codeTabContent:E,showJsonTab:n=!0,showRenderLogTab:s=!0,onActiveTabChange:r,renderLog:a,showImportAndFormatButtons:c=!0,className:h,headerClassName:l,leftHeaderContent:D,readOnly:d,isStreaming:y,autoroutingLog:w,onReportAutoroutingLog:u,isRunningCode:G,hasCodeChangedSinceLastRun:m,onEditEvent:p,editEvents:k,defaultActiveTab:S,defaultTab:R,availableTabs:x,extraTabs:N,autoRotate3dViewerDisabled:U,showSchematicDebugGrid:K=!1,showSchematicPorts:Y=!1,onChangeShowSchematicDebugGrid:_,onChangeShowSchematicPorts:Z,showToggleFullScreen:V=!0,defaultToFullScreen:W=!1,activeEffectName:q,allowSelectingVersion:X=uJ("TSCIRCUIT_ALLOW_SELECTING_EVAL_VERSION")!==!1,showFileMenu:tA=!1,isWebEmbedded:IA=!1,isCli:QA=!1,projectName:sA,schematicSvgOptions:DA,hideSchematicInAnalogSimulation:CA=!1,onRerunWithDebug:hA,solverEvents:nA,autoroutingPhases:aA,onPcbBoundsSelected:SA})=>{noA();const{versions:FA,latestVersion:rA,lastRunEvalVersion:NA,search:RA,setSearch:xA,selectVersion:bA}=mko(X),JA=z.useMemo(()=>B?B.filter(Jg=>Jg&&"error_type"in Jg||Jg.type.includes("error")):null,[B]),mA=z.useMemo(()=>B?B.filter(Jg=>Jg&&"warning_type"in Jg||Jg.type.includes("warning")):null,[B]),LA=z.useMemo(()=>B?B.some(Jg=>Jg.type==="schematic_group"):!0,[B]),dA=z.useMemo(()=>B?.some(Jg=>Jg.type==="pcb_panel"),[B]),HA=(!x||x.includes("schematic"))&&LA&&!dA,{controller:WA,focusSchematicComponent:Qg}=Dmo(),{controller:YA,focusPcbComponent:uA}=bro(),OA=!x||x.includes("pcb")?({source_component_id:Jg})=>{const AI=B?.find(Og=>Og.type==="pcb_component"&&Og.source_component_id===Jg);AI?.type==="pcb_component"&&(uA(AI.pcb_component_id),YI("pcb"))}:void 0,$A=HA?({source_component_id:Jg})=>{const AI=B?.find(Og=>Og.type==="schematic_component"&&Og.source_component_id===Jg);AI?.type==="schematic_component"&&(Qg(AI.schematic_component_id),YI("schematic"))}:void 0,og=z.useMemo(()=>!B||!G||JA?.length?!1:B.some(AI=>AI.type==="simulation_experiment")&&!kpt(B),[B,JA,G]),dg=z.useMemo(()=>JA?.find(Jg=>Jg.type.startsWith("simulation_")),[JA]);xPI({errorMessage:t,errorStack:o,circuitJsonErrors:JA});const Sg=z.useMemo(()=>oBo(N),[N]),Bg=[...["pcb","schematic","cad",...FKI].filter(Jg=>(!x||x.includes(Jg))&&(Jg!=="render_log"||s)),...i?["code"]:[],...Sg.map(Jg=>Jg.tabId)],Yg=S??R,iI=Yg&&Bg.includes(Yg)?Yg:x?.find(Jg=>Bg.includes(Jg))??Bg[0]??"pcb",[GA,ng]=gq("runframe-active-tab",iI,S),pg=Bg.includes(GA)?GA:iI;z.useEffect(()=>{GA!==pg&&(ng(pg),r?.(pg))},[GA,pg,ng,r]);const Ug=Sg.find(Jg=>Jg.tabId===pg);FPI({source:"runframe",component:"CircuitJsonPreview",isWebEmbedded:IA,activeTab:pg});const[mg,Rg]=z.useState(null),[Kg,gg]=z.useState(W),[ag,wg]=z.useState(K),[Hg,II]=z.useState(Y),BI=_?K:ag,$g=Z?Y:Hg,pI=_??wg,DI=Z??II;Hmo(Kg);const YI=z.useCallback(Jg=>{ng(Jg),r?.(Jg)},[r,ng]),Ae=()=>{gg(!Kg)};z.useEffect(()=>{t&&(pg!=="errors"&&Rg(pg),YI("errors"))},[t]),z.useEffect(()=>{(pg==="code"||pg==="errors")&&B&&!t&&YI(mg&&Bg.includes(mg)?mg:iI)},[B]);const PA=z.useCallback(Jg=>{window.TSCIRCUIT_3D_OBJECT_REF=Jg===null?void 0:Jg},[]);return T.jsx("div",{className:co("flex flex-col relative rf-overflow-x-hidden rf-h-full",h),children:T.jsx("div",{className:co("rf-md:sticky rf-md:top-2 rf-h-full",Kg&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-h-full rf-bg-white rf-overflow-hidden"),children:T.jsxs(jvA,{value:pg,onValueChange:YI,className:"rf-flex-grow rf-flex rf-flex-col rf-h-full",children:[T.jsxs("div",{className:co("rf-flex rf-flex-wrap rf-items-center rf-gap-2 rf-p-2 rf-pb-0 rf-shrink-0",l),children:[T.jsxs("div",{className:co("rf-flex rf-flex-1 rf-min-w-0 rf-items-center",(D||tA)&&"rf-basis-48"),children:[D,tA&&!D&&T.jsx(YpA,{isWebEmbedded:IA,circuitJson:B,projectName:sA,autoroutingLog:w,onReportAutoroutingLog:u,showSchematicDebugGrid:BI,onChangeShowSchematicDebugGrid:pI,showSchematicPorts:$g,onChangeShowSchematicPorts:DI}),!D&&!tA&&G&&T.jsx(mS,{className:"rf-w-4 rf-h-4 rf-animate-spin"})]}),a&&a.progress!==1&&!t&&T.jsxs("div",{className:"rf-flex rf-w-48 rf-max-w-full rf-shrink-0 rf-items-center rf-gap-2 rf-min-w-0",children:[T.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0 rf-flex-1",title:q??a.lastRenderEvent?.phase??"",children:q??a.lastRenderEvent?.phase}),T.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white rf-flex-shrink-0",children:T.jsx(mS,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),T.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums rf-flex-shrink-0 rf-w-[6ch] rf-text-right",children:[((a.progress??0)*100).toFixed(1),"%"]})]}),Q&&DRo({isCli:QA})&&T.jsx(dRo,{}),T.jsxs("div",{className:"rf-flex rf-min-w-0 rf-max-w-full rf-items-center rf-gap-2 rf-ml-auto",children:[Q&&T.jsxs(vDA,{className:"rf-min-w-0 rf-justify-start rf-overflow-x-auto",children:[i&&T.jsx(mx,{value:"code",children:"Code"}),!x||x.includes("pcb")?T.jsxs(mx,{value:"pcb",className:"rf-whitespace-nowrap",children:[B&&T.jsx("span",{className:co("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",m?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}):null,!x||x.includes("schematic")?T.jsxs(mx,{value:"schematic",className:co("rf-whitespace-nowrap",B&&!LA&&"rf-opacity-50"),disabled:B?!LA||dA:!1,children:[B&&T.jsx("span",{className:co("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",m?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}):null,!x||x.includes("cad")?T.jsxs(mx,{value:"cad",children:[B&&T.jsx("span",{className:co("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",m?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}):null,!["pcb","cad","schematic"].includes(pg)&&T.jsx(mx,{value:pg,children:Ug?.tabName??OeI(pg)}),T.jsxs(MmA,{children:[T.jsx(SmA,{asChild:!0,children:T.jsxs("button",{type:"button","aria-label":"More views",className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[T.jsx(Qco,{className:"rf-w-4 rf-h-4"}),(JA&&JA.length>0||t)&&T.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),T.jsxs(vtA,{className:"rf-*:text-xs rf-z-[101]",children:[Sg.map(Jg=>T.jsxs(a0,{onSelect:()=>YI(Jg.tabId),children:[pg===Jg.tabId?T.jsx(sF,{className:"rf-w-3 rf-h-3"}):T.jsx(Oog,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),T.jsx("div",{className:"rf-pr-2",children:Jg.tabName})]},Jg.tabId)),FKI.filter(Jg=>!x||x.includes(Jg)).map(Jg=>T.jsxs(a0,{onSelect:()=>YI(Jg),children:[pg!==Jg&&T.jsx(Oog,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),pg===Jg&&T.jsx(sF,{className:"rf-w-3 rf-h-3"}),T.jsx("div",{className:"rf-pr-2",children:OeI(Jg)}),Jg==="errors"&&(JA&&JA.length>0||t)&&T.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:t?1:JA?.length}),Jg==="solvers"&&nA&&nA.length>0&&T.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-min-w-[12px] rf-h-3 rf-px-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-blue-500 rf-rounded-full",children:nA.length})]},Jg)),T.jsx(a0,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:T.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",UPI.split(".").map((Jg,AI)=>AI===2?parseInt(Jg)+1:Jg).join(".")]})}),X?T.jsxs(HtA,{onOpenChange:Jg=>!Jg&&xA(""),children:[T.jsx(mO,{className:"rf-text-xs rf-opacity-60",children:T.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",NA??rA??"latest"]})}),T.jsx(btA,{children:T.jsxs(pO,{className:"rf-*:text-xs rf-w-40 rf-max-h-[200px] rf-overflow-y-auto",children:[T.jsx("div",{className:"rf-p-1",children:T.jsx(yCg,{value:RA,onChange:Jg=>xA(Jg.target.value),placeholder:"Search...",className:"rf-h-7 rf-text-xs"})}),T.jsx(KFI,{}),T.jsx(a0,{onSelect:()=>bA(null),children:rA?`${rA} (latest)`:"latest"}),FA.map(Jg=>T.jsx(a0,{onSelect:()=>bA(Jg),children:Jg},Jg))]})})]}):NA&&T.jsx(a0,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:T.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",NA]})})]})]})]}),V&&T.jsx(si,{onClick:Ae,"aria-label":Kg?"Exit fullscreen":"Enter fullscreen",variant:"ghost",className:"rf-shrink-0",children:Kg?T.jsx(Dco,{size:16}):T.jsx(aco,{size:16})})]})]}),i&&T.jsx(Fy,{value:"code",className:"rf-flex-grow rf-min-h-0 rf-overflow-hidden",children:T.jsx("div",{className:"rf-h-full",children:E})}),(!x||x.includes("pcb"))&&T.jsx(Fy,{value:"pcb",className:"rf-min-h-0",children:T.jsx("div",{className:"rf-overflow-hidden rf-h-full",children:T.jsx(GS,{fallbackRender:({error:Jg})=>T.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:T.jsxs("div",{className:"rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),T.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:UQg(Jg)})]})}),children:B?T.jsx(_mo,{controller:YA,focusOnHover:!1,circuitJson:B,debugGraphics:C,onBoundsSelected:SA,onViewSchematicComponent:$A,containerClassName:"rf-h-full rf-w-full rf-min-h-0",onEditEventsChanged:Jg=>{if(p)for(const AI of Jg)p(AI)}}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("assembly"))&&T.jsx(Fy,{value:"assembly",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallback:T.jsx("div",{children:"Error loading Assembly"}),children:B?T.jsx(dmo,{circuitJson:B,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("pinout"))&&T.jsx(Fy,{value:"pinout",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallback:T.jsx("div",{children:"Error loading Pinout Viewer"}),children:B?T.jsx(ymo,{circuitJson:B,containerStyle:{height:"100%"}}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("schematic"))&&T.jsx(Fy,{value:"schematic",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto rf-bg-white",wF),children:T.jsx(GS,{fallbackRender:({error:Jg})=>T.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:T.jsxs("div",{className:"rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),T.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:UQg(Jg)})]})}),children:B?T.jsx(Imo,{platformConfig:g,onViewPcbComponent:OA,controller:WA,circuitJson:B,containerStyle:{height:"100%"},debugGrid:BI,showSchematicPorts:$g,css:DA?.css,className:DA?.className}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("cad"))&&T.jsx(Fy,{value:"cad",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallbackRender:({error:Jg,resetErrorBoundary:AI})=>T.jsx(Hro,{error:Jg,resetErrorBoundary:AI}),children:B?T.jsx(eBo,{ref:PA,circuitJson:B,autoRotateDisabled:U,onViewSchematicComponent:$A},`cad-${Kg}`):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("analog_simulation"))&&T.jsx(Fy,{value:"analog_simulation",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallback:T.jsx("div",{children:"Error loading Analog Simulation"}),children:B?dg?T.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:T.jsxs("div",{className:"rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error running analog simulation"}),T.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:dg.message})]})}):og?T.jsx("div",{className:"rf-flex rf-h-full rf-min-h-[300px] rf-items-center rf-justify-center rf-bg-slate-50",children:T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-text-sm rf-text-slate-600",children:[T.jsx(mS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Running analog simulation..."]})}):T.jsx(lmo,{circuitJson:B,hideSchematic:CA,containerStyle:{height:"100%"}}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("bom"))&&T.jsx(Fy,{value:"bom",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallbackRender:({error:Jg})=>T.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:T.jsxs("div",{className:"rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),T.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:UQg(Jg)})]})}),children:B?T.jsx(Ymo,{circuitJson:B}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("circuit_json"))&&T.jsx(Fy,{value:"circuit_json",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallback:T.jsx("div",{children:"Error loading JSON viewer"}),children:B?T.jsx(Gmo,{elements:B}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("errors"))&&T.jsx(Fy,{value:"errors",className:"rf-h-full rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-hidden",wF),children:t||JA&&JA.length>0||B?T.jsx(wlo,{code:A,fsMap:I,circuitJsonErrors:JA,circuitJsonWarnings:mA,errorMessage:t,errorStack:o,circuitJson:B,evalVersion:NA,autoroutingLog:w,onReportAutoroutingLog:u}):T.jsx(QP,{onRunClicked:e})})}),s&&(!x||x.includes("render_log"))&&T.jsx(Fy,{value:"render_log",className:"rf-min-h-0",children:T.jsx(qmo,{renderLog:a,onRerunWithDebug:hA})}),(!x||x.includes("autorouting"))&&T.jsx(Fy,{value:"autorouting",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallback:T.jsx("div",{className:"rf-p-4",children:"Error loading autorouting captures"}),children:T.jsx(uko,{circuitJson:B,phases:aA,isRunning:G})})})}),(!x||x.includes("solvers"))&&T.jsx(Fy,{value:"solvers",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-hidden",wF),children:T.jsx(GS,{fallback:T.jsx("div",{children:"Error loading Solvers view"}),children:T.jsx(Bko,{solverEvents:nA})})})}),Sg.map(Jg=>T.jsx(BBo,{tab:Jg,active:pg===Jg.tabId,isFullScreen:Kg},Jg.tabId))]})})})};const JKI=Symbol("Comlink.proxy"),yRo=Symbol("Comlink.endpoint"),PKI=Symbol("Comlink.releaseProxy"),JQg=Symbol("Comlink.finalizer"),HpA=Symbol("Comlink.thrown"),KKI=g=>typeof g=="object"&&g!==null||typeof g=="function",wRo={canHandle:g=>KKI(g)&&g[JKI],serialize(g){const{port1:A,port2:I}=new MessageChannel;return YKI(g,A),[I,[I]]},deserialize(g){return g.start(),bKI(g)}},uRo={canHandle:g=>KKI(g)&&HpA in g,serialize({value:g}){let A;return g instanceof Error?A={isError:!0,value:{message:g.message,name:g.name,stack:g.stack}}:A={isError:!1,value:g},[A,[]]},deserialize(g){throw g.isError?Object.assign(new Error(g.value.message),g.value):g.value}},LKI=new Map([["proxy",wRo],["throw",uRo]]);function GRo(g,A){for(const I of g)if(A===I||I==="*"||I instanceof RegExp&&I.test(A))return!0;return!1}function YKI(g,A=globalThis,I=["*"]){A.addEventListener("message",function e(t){if(!t||!t.data)return;if(!GRo(I,t.origin)){console.warn(`Invalid origin '${t.origin}' for comlink proxy`);return}const{id:o,type:B,path:C}=Object.assign({path:[]},t.data),Q=(t.data.argumentList||[]).map(jb);let i;try{const E=C.slice(0,-1).reduce((s,r)=>s[r],g),n=C.reduce((s,r)=>s[r],g);switch(B){case"GET":i=n;break;case"SET":E[C.slice(-1)[0]]=jb(t.data.value),i=!0;break;case"APPLY":i=n.apply(E,Q);break;case"CONSTRUCT":{const s=new n(...Q);i=KQg(s)}break;case"ENDPOINT":{const{port1:s,port2:r}=new MessageChannel;YKI(g,r),i=SRo(s,[s])}break;case"RELEASE":i=void 0;break;default:return}}catch(E){i={value:E,[HpA]:0}}Promise.resolve(i).catch(E=>({value:E,[HpA]:0})).then(E=>{const[n,s]=ZpA(E);A.postMessage(Object.assign(Object.assign({},n),{id:o}),s),B==="RELEASE"&&(A.removeEventListener("message",e),_KI(A),JQg in g&&typeof g[JQg]=="function"&&g[JQg]())}).catch(E=>{const[n,s]=ZpA({value:new TypeError("Unserializable return value"),[HpA]:0});A.postMessage(Object.assign(Object.assign({},n),{id:o}),s)})}),A.start&&A.start()}function mRo(g){return g.constructor.name==="MessagePort"}function _KI(g){mRo(g)&&g.close()}function bKI(g,A){const I=new Map;return g.addEventListener("message",function(t){const{data:o}=t;if(!o||!o.id)return;const B=I.get(o.id);if(B)try{B(o)}finally{I.delete(o.id)}}),PQg(g,I,[],A)}function vpA(g){if(g)throw new Error("Proxy has been released and is not useable")}function HKI(g){return vO(g,new Map,{type:"RELEASE"}).then(()=>{_KI(g)})}const TpA=new WeakMap,qpA="FinalizationRegistry"in globalThis&&new FinalizationRegistry(g=>{const A=(TpA.get(g)||0)-1;TpA.set(g,A),A===0&&HKI(g)});function pRo(g,A){const I=(TpA.get(A)||0)+1;TpA.set(A,I),qpA&&qpA.register(g,A,g)}function kRo(g){qpA&&qpA.unregister(g)}function PQg(g,A,I=[],e=function(){}){let t=!1;const o=new Proxy(e,{get(B,C){if(vpA(t),C===PKI)return()=>{kRo(o),HKI(g),A.clear(),t=!0};if(C==="then"){if(I.length===0)return{then:()=>o};const Q=vO(g,A,{type:"GET",path:I.map(i=>i.toString())}).then(jb);return Q.then.bind(Q)}return PQg(g,A,[...I,C])},set(B,C,Q){vpA(t);const[i,E]=ZpA(Q);return vO(g,A,{type:"SET",path:[...I,C].map(n=>n.toString()),value:i},E).then(jb)},apply(B,C,Q){vpA(t);const i=I[I.length-1];if(i===yRo)return vO(g,A,{type:"ENDPOINT"}).then(jb);if(i==="bind")return PQg(g,A,I.slice(0,-1));const[E,n]=vKI(Q);return vO(g,A,{type:"APPLY",path:I.map(s=>s.toString()),argumentList:E},n).then(jb)},construct(B,C){vpA(t);const[Q,i]=vKI(C);return vO(g,A,{type:"CONSTRUCT",path:I.map(E=>E.toString()),argumentList:Q},i).then(jb)}});return pRo(o,g),o}function MRo(g){return Array.prototype.concat.apply([],g)}function vKI(g){const A=g.map(ZpA);return[A.map(I=>I[0]),MRo(A.map(I=>I[1]))]}const TKI=new WeakMap;function SRo(g,A){return TKI.set(g,A),g}function KQg(g){return Object.assign(g,{[JKI]:!0})}function ZpA(g){for(const[A,I]of LKI)if(I.canHandle(g)){const[e,t]=I.serialize(g);return[{type:"HANDLER",name:A,value:e},t]}return[{type:"RAW",value:g},TKI.get(g)||[]]}function jb(g){switch(g.type){case"HANDLER":return LKI.get(g.name).deserialize(g.value);case"RAW":return g.value}}function vO(g,A,I,e){return new Promise(t=>{const o=fRo();A.set(o,t),g.start&&g.start(),g.postMessage(Object.assign({id:o},I),e)})}function fRo(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function LQg(g,A=""){const I=[];for(const e in g){if(!Object.prototype.hasOwnProperty.call(g,e))continue;const t=g[e],o=A?`${A}.${e}`:e;if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const B=LQg(t,o);I.push(...B)}else I.push(o)}return I}function qKI(g,A){const I=A.split(".");let e=g;for(const t of I)e=e[t];return e}var RRo=(g="latest")=>[`https://jscdn.tscircuit.com/@tscircuit/eval/${g}/dist/webworker/entrypoint.js`,`https://cdn.jsdelivr.net/npm/@tscircuit/eval@${g}/dist/webworker/entrypoint.js`,`https://unpkg.com/@tscircuit/eval@${g}/dist/webworker/entrypoint.js`],NRo=async(g="latest",A=!1)=>{let I;for(const e of RRo(g))try{const t=await globalThis.fetch(e);if(!t.ok)throw new Error(`Failed to fetch webworker entrypoint from ${e}: ${t.status} ${t.statusText}`);return await t.blob()}catch(t){I=t,A&&console.warn(`[Worker] Failed to fetch webworker entrypoint from ${e}, trying next CDN fallback if available`,t)}throw I instanceof Error?I:new Error("Failed to fetch webworker entrypoint from CDN fallbacks")},xRo=async g=>{const A=globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER;if(A&&typeof A.kill=="function"){g.verbose&&console.log("[Worker] Killing previous global worker instance...");try{await A.kill()}catch(s){g.verbose&&console.warn("[Worker] Error killing previous global worker instance:",s),globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER===A&&(globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER=void 0)}}g.verbose&&console.log("[Worker] Creating circuit web worker with config:",g);let I=g.webWorkerBlobUrl??g.webWorkerUrl;if(!I){const s=await NRo(g.evalVersion??"latest",g.verbose);I=URL.createObjectURL(s)}const e=new Worker(I,{type:"module"});let t;e.addEventListener("error",s=>{console.error("[Worker] Error in worker",s),t=s}),e.addEventListener("unhandledrejection",s=>{console.error("[Worker] Unhandled rejection in worker",s)}),e.addEventListener("messageerror",s=>{console.error("[Worker] Message error in worker",s)});const o=s=>{console.log("[Worker] Message in worker",s)};if(e.addEventListener("message",o),e.addEventListener("message",async s=>{const r=s.data;if(r?.type==="worker_fetch")try{const a=await globalThis.fetch(r.input,r.init),c=await a.text();e.postMessage({type:"worker_fetch_result",requestId:r.requestId,success:!0,response:{body:c,status:a.status,statusText:a.statusText,headers:(()=>{const h={};return a.headers.forEach((l,D)=>{h[D]=l}),h})()}})}catch(a){e.postMessage({type:"worker_fetch_result",requestId:r.requestId,success:!1,error:{name:a.name,message:a.message,stack:a.stack}})}}),t)throw t;const B=bKI(e);e.removeEventListener("message",o);function C(s){return!s||typeof s!="object"?s:s.type&&s.props!==void 0?{__isSerializedReactElement:!0,type:s.type,props:Q(s.props),key:s.key}:s}function Q(s){if(!s||typeof s!="object")return s;const r={};for(const[a,c]of Object.entries(s))a==="children"?Array.isArray(c)?r.children=c.map(C):r.children=C(c):r[a]=c;return r}g.enableFetchProxy&&e.postMessage({type:"override_global_fetch"}),g.disableCdnLoading&&await B.setDisableCdnLoading(!0),g.snippetsApiBaseUrl&&await B.setSnippetsApiBaseUrl(g.snippetsApiBaseUrl),g.tscircuitSessionToken&&await B.setTscircuitSessionToken(g.tscircuitSessionToken),g.easyEdaProxyConfig&&await B.setEasyEdaProxyConfig(g.easyEdaProxyConfig),g.partsEngineOptions&&await B.setPartsEngineOptions(g.partsEngineOptions);const i=s=>typeof s=="function"?KQg(s):s;if(g.platform)for(const s of LQg(g.platform))await B.setPlatformConfigProperty(s,i(qKI(g.platform,s))).catch(r=>{throw new Error(`Error setting platform config property ${s}: ${r instanceof Error?r.message:String(r)}`)});if(g.projectConfig)for(const s of LQg(g.projectConfig))await B.setProjectConfigProperty(s,i(qKI(g.projectConfig,s))).catch(r=>{throw new Error(`Error setting project config property ${s}: ${r instanceof Error?r.message:String(r)}`)});let E=!1;const n={clearEventListeners:B.clearEventListeners.bind(B),enableDebug:async(...s)=>{if(E)throw new Error("CircuitWebWorker was terminated, can't enableDebug");return B.enableDebug.bind(B)(...s)},version:B.version.bind(B),execute:async(...s)=>{if(E)throw new Error("CircuitWebWorker was terminated, can't execute");return B.execute.bind(B)(...s)},executeComponent:async s=>{if(E)throw new Error("CircuitWebWorker was terminated, can't executeComponent");if(typeof s=="function")return B.executeComponent.bind(B)(s);if(s&&typeof s=="object"&&s.type){const r=C(s);return B.executeComponent.bind(B)(r)}return B.executeComponent.bind(B)(s)},executeWithFsMap:async(...s)=>{if(E)throw new Error("CircuitWebWorker was terminated, can't executeWithFsMap");return B.executeWithFsMap.bind(B)(...s)},renderUntilSettled:B.renderUntilSettled.bind(B),getCircuitJson:B.getCircuitJson.bind(B),on:(s,r)=>{const a=KQg(r);B.on(s,a)},kill:async()=>{B[PKI](),e.terminate(),E=!0,globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER===n&&(globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER=void 0)}};return n.__rawWorker=e,globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER=n,n};const FRo=({error:g,resetErrorBoundary:A,componentStack:I})=>{const e=g instanceof Error?g:new Error(String(g));return T.jsx("section",{className:"rf-h-full rf-w-full rf-grid rf-place-items-center",children:T.jsx("div",{className:"rf-min-h-full rf-flex rf-items-center rf-justify-center rf-px-4",children:T.jsxs("div",{className:"rf-max-w-lg rf-w-full rf-text-center",children:[T.jsxs("div",{className:"rf-mb-8",children:[T.jsx("div",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-20 rf-h-20 rf-bg-red-100 rf-rounded-full rf-mb-6",children:T.jsx(Gco,{className:"rf-w-10 rf-h-10 rf-text-red-600"})}),T.jsx("h1",{className:"rf-text-2xl rf-font-bold rf-text-gray-900 rf-mb-3",children:"Oops! Something went wrong"}),T.jsx("p",{className:"rf-text-gray-600 rf-mb-4",children:"RunFrame encountered an unexpected error."}),T.jsx("pre",{className:"rf-text-xs no-scrollbar rf-font-mono rf-text-left rf-whitespace-pre-wrap rf-text-red-600 rf-bg-red-50 rf-border rf-border-red-200 rf-p-3 rf-rounded-lg rf-mb-4 rf-overflow-auto rf-max-h-[120px]",children:e.message}),e.stack&&T.jsxs("details",{className:"rf-text-center rf-mb-6",children:[T.jsx("summary",{className:"rf-text-xs rf-text-gray-500 rf-cursor-pointer hover:rf-text-gray-700",children:"View stack trace"}),T.jsx("pre",{className:"rf-text-xs rf-font-mono no-scrollbar rf-whitespace-pre-wrap rf-text-gray-500 rf-bg-gray-100 rf-p-3 rf-rounded-lg rf-mt-2 rf-overflow-auto rf-text-left rf-max-h-[150px]",children:e.stack})]}),I&&T.jsxs("details",{className:"rf-text-center rf-mb-6",children:[T.jsx("summary",{className:"rf-text-xs rf-text-gray-500 rf-cursor-pointer hover:rf-text-gray-700",children:"View component stack"}),T.jsx("pre",{className:"rf-text-xs rf-font-mono no-scrollbar rf-whitespace-pre-wrap rf-text-gray-500 rf-bg-gray-100 rf-p-3 rf-rounded-lg rf-mt-2 rf-overflow-auto rf-text-left rf-max-h-[150px]",children:I})]})]}),T.jsxs("div",{className:"rf-flex rf-flex-col rf-gap-2 rf-justify-center",children:[T.jsx(si,{variant:"destructive",size:"lg",onClick:()=>window.location.reload(),children:"Refresh Dev Server"}),T.jsx(si,{variant:"outline",size:"lg",onClick:A,children:"Try Again"})]})]})})})},ZKI=g=>{const A={};if(!g)return A;for(const e of OM)A[e]=0;const I=new Map;for(const e of g){const[,,t,o]=e.type.split(":");if(o==="start"){I.set(`${t}:${e.renderId}`,e);continue}if(o==="end"){const B=I.get(`${t}:${e.renderId}`);if(B){const C=e.createdAt-B.createdAt;A[t]=(A[t]||0)+C}}}return A},MoA=g=>{const A=g.toLowerCase(),I=A.split("/").pop();return A.endsWith(".circuit.json")||I==="circuit.json"},URo=g=>g.endsWith(".tsx")||MoA(g)||g.endsWith(".jsx"),JRo=({mainComponentPath:g,fsMap:A})=>{const I=g!=null&&MoA(g),e=g?A.get(g):void 0;return z.useMemo(()=>{if(!I)return{isStaticCircuitJson:!1,circuitJson:null,error:null};if(!e)return{isStaticCircuitJson:!0,circuitJson:null,error:`Circuit JSON file not found: ${g}`};try{return{isStaticCircuitJson:!0,circuitJson:JSON.parse(e),error:null}}catch(t){return{isStaticCircuitJson:!0,circuitJson:null,error:`Failed to parse circuit.json: ${t instanceof Error?t.message:String(t)}`}}},[g,e])},PRo=(g,A)=>{const I={};for(const[e,t]of g.entries()){const o=A.get(e);o!==t&&(I[e]={old:t,new:o})}for(const[e,t]of A.entries())g.has(e)||(I[e]={old:void 0,new:t});return I},KRo=({message:g="Loading files..."})=>T.jsxs("div",{className:"rf-flex rf-flex-col rf-w-full rf-h-full",children:[T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4 rf-p-2 rf-border-b",children:[T.jsx("div",{className:"rf-w-20 rf-h-9 rf-bg-gray-200 dark:rf-bg-gray-700 rf-rounded-md rf-animate-pulse"}),T.jsx("div",{className:"rf-flex rf-gap-6 rf-ml-auto",children:["PCB","Schematic","3D"].map((A,I)=>T.jsx("div",{className:"rf-h-6 rf-w-20 rf-bg-gray-200 dark:rf-bg-gray-700 rf-rounded rf-animate-pulse"},I))})]}),T.jsx("div",{className:"rf-flex-1 rf-p-4",children:T.jsx("div",{className:"rf-w-full rf-h-full rf-rounded-lg rf-bg-gray-100 dark:rf-bg-gray-800 rf-animate-pulse rf-flex rf-items-center rf-justify-center",children:T.jsx("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-4",children:T.jsx("div",{className:"rf-text-sm rf-text-gray-400 dark:rf-text-gray-500",children:g})})})})]}),LRo=({projectBaseUrl:g,enablePartOrientationAnalysis:A})=>({projectBaseUrl:g,enablePartOrientationAnalysis:A??!0}),YRo=g=>!g||typeof g!="object"?!1:!!("error_type"in g||typeof g.type=="string"&&g.type.includes("error")),_Ro=g=>g instanceof Error?{name:g.name,message:g.message,stack:g.stack}:typeof g=="string"?{message:g}:g&&typeof g=="object"?g:{message:String(g)},bRo=g=>Array.isArray(g)?g.filter(YRo):[],OpA=({circuitJson:g,executionError:A})=>{const I=[];A&&I.push(_Ro(A));const e=bRo(g);return I.push(...e),{hasExecutionError:!!A,...I.length>0?{errors:I}:{}}};function HRo(){const g=z.useRef(Promise.resolve()),A=z.useRef(!1),I=z.useRef(null),e=z.useCallback(async B=>{await g.current;const C={cancelled:!1};I.current=C;let Q;const i=new Promise(E=>{Q=E});try{return g.current=i,A.current=!0,await B()}catch(E){if(!C.cancelled)throw E}finally{A.current=!1,I.current=null,Q()}},[]),t=z.useCallback(()=>{I.current&&(I.current.cancelled=!0),g.current=Promise.resolve(),A.current=!1},[]),o=z.useCallback(()=>A.current,[]);return{runWithMutex:e,isLocked:o,cancel:t}}const vRo=26,xS=kE("run-frame:RunFrame"),TRo=async()=>{try{const g=await fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval");if(g.ok)return(await g.json()).tags?.latest}catch(g){console.error("Failed to fetch latest eval version",g)}},qRo=async(g,A)=>{if(g)return g;if(A||!window.TSCIRCUIT_LATEST_EVAL_VERSION){const I=await TRo();if(I)return window.TSCIRCUIT_LATEST_EVAL_VERSION=I,I}return window.TSCIRCUIT_LATEST_EVAL_VERSION?window.TSCIRCUIT_LATEST_EVAL_VERSION:"latest"},OKI=g=>{noA();const A=g.mainComponentPath!=null&&MoA(g.mainComponentPath),I=Kc(xA=>xA.circuitJson),e=Kc(xA=>xA.setCircuitJson),[t,o]=z.useState(null),[B,C]=z.useState(null),Q=z.useRef(null),i=z.useRef(!0),E=z.useRef(null),[n,s]=z.useState(null),[r,a]=z.useReducer((xA,bA)=>xA+1,0),c=apA(xA=>xA.setLastRunEvalVersion),h=z.useRef(0),l=HRo(),[D,d]=z.useState(!1),[y,w]=z.useState(!1),[u,G]=z.useState({}),[m,p]=z.useState(""),[k,S]=z.useState(!1),[R,x]=z.useState(!1);z.useEffect(()=>(i.current=!0,()=>{i.current=!1,Q.current?.(),E.current?.then(({worker:bA})=>{if(!i.current&&globalThis.runFrameWorker!==bA)return bA.kill()}).catch(()=>{})}),[]);const N=()=>{if(E.current)return E.current;const xA=(async()=>{const JA=await qRo(g.evalVersion,!globalThis.runFrameWorker&&g.forceLatestEvalVersion),mA={jlcSearchBaseUrl:window.TSCIRCUIT_JLCSEARCH_BASE_URL,datasheetApiBaseUrl:window.TSCIRCUIT_DATASHEET_API_BASE_URL},LA=mA.jlcSearchBaseUrl!==void 0||mA.datasheetApiBaseUrl!==void 0;return{worker:globalThis.runFrameWorker??await xRo({evalVersion:JA,webWorkerBlobUrl:g.evalWebWorkerBlobUrl,projectConfig:LRo({enablePartOrientationAnalysis:g.platformConfig?.enablePartOrientationAnalysis,projectBaseUrl:g.projectBaseUrl??g.platformConfig?.projectBaseUrl??`${Jm}/files/static`}),...g.platformConfig&&{platform:g.platformConfig},verbose:!0,...g.enableFetchProxy&&{enableFetchProxy:g.enableFetchProxy},...window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI&&{disableCdnLoading:!0},...g.tscircuitSessionToken&&{tscircuitSessionToken:g.tscircuitSessionToken},...g.easyEdaProxyConfig&&{easyEdaProxyConfig:g.easyEdaProxyConfig},...LA&&{partsEngineOptions:mA}}),evalVersion:JA}})();E.current=xA;const bA=()=>{E.current===xA&&(E.current=null)};return xA.then(bA,bA),xA},U=Object.values(u).sort((xA,bA)=>xA.startTime-bA.startTime)[0]?.effectName,K=xA=>{g.onRunCompleted?.(xA)};z.useEffect(()=>{if(A)return;const xA=bA=>{(bA.ctrlKey||bA.metaKey)&&bA.key==="Enter"&&!D&&(bA.preventDefault(),bA.stopPropagation(),a(1))};return window.addEventListener("keydown",xA,{capture:!0}),()=>window.removeEventListener("keydown",xA,{capture:!0})},[D,A]),z.useEffect(()=>{if(A)return;let xA=!1;return(async()=>{try{if(!globalThis.runFrameWorker){const{worker:JA,evalVersion:mA}=await N();if(xA||!i.current)return;globalThis.runFrameWorker=JA,c(mA)}xA||w(!0)}catch(JA){!xA&&i.current&&console.error("Failed to preload eval worker",JA)}})(),()=>{xA=!0}},[A,g.evalVersion,g.evalWebWorkerBlobUrl,g.forceLatestEvalVersion,g.tscircuitSessionToken]);const[Y,_]=z.useState(null),[Z,V]=z.useState({}),[W,q]=z.useState([]),[X,tA]=z.useState([]),IA=z.useRef(0),[QA,sA]=z.useState(g.defaultActiveTab??g.defaultTab??"pcb");FPI({source:"runframe",component:"RunFrame",isWebEmbedded:g.isWebEmbedded,activeTab:QA}),z.useEffect(()=>{g.debug&&kE.enable("run-frame*")},[g.debug]);const DA=z.useMemo(()=>g.fsMap instanceof Map?g.fsMap:new Map(Object.entries(g.fsMap??{})),[g.fsMap]),CA=z.useRef(null),hA=z.useRef(null),nA=z.useRef(null),{circuitJson:aA,error:SA}=JRo({mainComponentPath:g.mainComponentPath,fsMap:DA});z.useEffect(()=>{if(!A){nA.current=null;return}if(g.isLoadingFiles)return;const xA=aA??SA;if(xA!==nA.current){if(nA.current=xA,aA)g.onRenderStarted?.(),e(aA),o(null),g.onCircuitJsonChange?.(aA),g.onInitialRender?.({circuitJson:aA}),K(OpA({circuitJson:aA})),g.onRenderFinished?.({circuitJson:aA});else if(SA){e(null),o({error:SA,stack:""});const bA=new Error(SA);g.onError?.(bA),K(OpA({executionError:bA}))}}},[A,aA,SA,g.isLoadingFiles]),z.useEffect(()=>{if(A||g.isLoadingFiles){IA.current+=1,Q.current?.(),Q.current=null,d(!1),G({}),g.isLoadingFiles&&e(null);return}const xA=DA instanceof Map?Object.fromEntries(DA.entries()):DA;if(!xA||Object.keys(xA).length===0){e(null),o({error:"No files provided. Please provide at least one file with code to execute.",stack:""}),d(!1);return}const bA=r!==h.current;if(CA.current&&I){const WA=PRo(CA.current,DA);if(Object.keys(WA).length>0)xS("code changes detected");else if(hA.current!==g.entrypoint)xS("render triggered by entrypoint change");else if(!bA){xS("render triggered without changes to fsMap, skipping");return}}if(g.showRunButton&&r===h.current)return;CA.current=DA,hA.current=g.entrypoint??null,h.current=r,d(!0);let JA=!1;const mA=++IA.current,LA=()=>i.current&&!JA&&mA===IA.current;let dA;const HA=async()=>{if(!LA())return;xS("running render worker"),o(null),_(null),G({}),q([]),tA([]);const WA={progress:0,debugOutputs:[]};Q.current=()=>{JA=!0};const{worker:Qg,evalVersion:YA}=await N();if(!LA()||(xS("resolvedEvalVersion",YA),globalThis.runFrameWorker=Qg,c(YA),await Qg.clearEventListeners(),!LA()))return;m?.trim()&&Qg.enableDebug(m.replace("DEBUG=","")),xS("Starting render..."),g.onRenderStarted?.();const uA=DA instanceof Map?Object.fromEntries(DA.entries()):DA;let kA=Date.now();Qg.on("asyncEffect:start",Bg=>{const Yg=`${Bg.phase}|${Bg.componentDisplayName??""}|${Bg.effectName}`;G(iI=>({...iI,[Yg]:{...Bg,startTime:Date.now()}}))}),Qg.on("asyncEffect:end",Bg=>{const Yg=`${Bg.phase}|${Bg.componentDisplayName??""}|${Bg.effectName}`;G(iI=>{const{[Yg]:GA,...ng}=iI;return ng})});let OA=[];const $A=Bg=>{JA||mA!==IA.current||(OA=Eko(OA,Bg),tA(OA))};if(Qg.on("autorouting:end",Bg=>$A({...Bg,type:"autorouting:end"})),Qg.on("autorouting:error",Bg=>$A({...Bg,type:"autorouting:error"})),Qg.on("autorouting:start",Bg=>{$A({...Bg,type:"autorouting:start"}),V({...Z,[Bg.componentDisplayName]:{simpleRouteJson:Bg.simpleRouteJson,createdAt:Date.now()}})}),Qg.on("solver:started",Bg=>{xS("solver:started",Bg),q(Yg=>{const iI=`${Bg.componentName}-${Bg.solverName}`;return Yg.some(ng=>`${ng.componentName}-${ng.solverName}`===iI)?Yg:[...Yg,Bg]})}),Qg.on("board:renderPhaseStarted",Bg=>{WA.lastRenderEvent=Bg,WA.eventsProcessed=(WA.eventsProcessed??0)+1;const Yg=OM.indexOf(Bg.phase)/vRo*.75+WA.eventsProcessed/1e3*.25,iI=1-Math.exp(-Yg*3);WA.progress=iI,JA||_({...WA})}),QA==="render_log"&&Qg.on("renderable:renderLifecycle:anyEvent",Bg=>{WA.renderEvents=WA.renderEvents??[],Bg.createdAt=Date.now(),WA.renderEvents.push(Bg),Date.now()-kA>500&&(WA.phaseTimings=ZKI(WA.renderEvents??[]),kA=Date.now()),JA||_({...WA})}),Qg.on("autorouting:progress",Bg=>{s(Bg.debugGraphics)}),Qg.on("debug:logOutput",Bg=>{WA.debugOutputs=WA.debugOutputs??[],WA.debugOutputs.push({type:"debug",name:Bg.name,content:Bg.content}),JA||_({...WA})}),xS("Executing fsMap..."),await Qg.executeWithFsMap({entrypoint:g.entrypoint,fsMap:uA,...g.mainComponentPath?{mainComponentPath:g.mainComponentPath}:{}}),!LA())return;xS("worker call started");const og=Qg.renderUntilSettled().then(()=>({success:!0}),Bg=>({success:!1,error:Bg}));dA=og,xS("waiting for initial circuit json...");let dg=await Qg.getCircuitJson();if(!LA())return;if(!dg)throw new Error("Eval worker returned no Circuit JSON");xS("got initial circuit json"),e(dg),g.onCircuitJsonChange?.(dg),g.onInitialRender?.({circuitJson:dg});const Sg=await og;if(LA()){if(!Sg.success)throw Sg.error;xS("getting final circuit json"),dg=await Qg.getCircuitJson(),LA()&&(g.onCircuitJsonChange?.(dg),e(dg),K(OpA({circuitJson:dg})),g.onRenderFinished?.({circuitJson:dg}),s({}),QA==="render_log"&&(WA.phaseTimings=ZKI(WA.renderEvents??[])),WA.progress=1,JA||_({...WA}),d(!1),G({}),p(""),Q.current=null)}};l.runWithMutex(async()=>{try{await HA()}finally{await dA}}).catch(WA=>{if(!LA())return;const Qg=WA instanceof Error?WA:new Error(String(WA));xS("worker execution failed",Qg),g.onError?.(Qg),K(OpA({executionError:Qg})),e(null),o({error:Qg.message.replace("Error: ",""),stack:Qg.stack}),_(null),d(!1),G({}),p(""),Q.current=null})},[g.fsMap,g.entrypoint,r,g.evalVersion,g.mainComponentPath,g.isLoadingFiles,m,A]);const FA=z.useRef(null),rA=z.useRef(null),NA=xA=>{if(!xA||xA===null){console.warn("[RunFrame] handleEditEvent received null or undefined event.");return}xA.in_progress?(FA.current=xA,rA.current&&(clearTimeout(rA.current),rA.current=null)):(rA.current&&clearTimeout(rA.current),rA.current=setTimeout(()=>{const bA=xA||FA.current;g.onEditEvent?.(bA),FA.current=null,rA.current=null},100))},RA=async(xA,bA)=>{let JA="";const mA=Array.isArray(I)&&I.find(HA=>HA.type==="software_project_metadata"),LA=g.projectUrl??mA?.project_url;if(LA)try{JA=new URL(LA).pathname}catch{JA=LA}const dA=JA?`${JA} - ${xA}`:xA;await NgA.post("autorouting/bug_reports/create",{json:{title:dA,simple_route_json:bA.simpleRouteJson}}).json().then(({autorouting_bug_report:HA})=>{window.open(`https://api.tscircuit.com/autorouting/bug_reports/view?autorouting_bug_report_id=${HA.autorouting_bug_report_id}`,"_blank")}).catch(HA=>{console.error("Failed to report autorouting bug",HA);const WA=HA instanceof wJ&&HA.response?.status===401,Qg=HA instanceof wJ&&HA.response?.status===413;if(WA){g.onLoginRequired?g.onLoginRequired():alert("You must be logged in to report autorouting bugs");return}if(Qg){alert("This autorouting log is too large to report online. Download the log and attach it to a GitHub issue.");return}const YA=HA instanceof Error?HA.message:"Failed to report autorouting bug";alert(`Failed to report autorouting bug: ${YA}`)})};return g.isLoadingFiles?T.jsx(KRo,{}):T.jsx(GS,{onError:(xA,bA)=>{C(bA.componentStack??null)},onReset:()=>C(null),fallbackRender:xA=>T.jsx(FRo,{...xA,componentStack:B}),children:T.jsx(UKI,{platformConfig:g.platformConfig,code:DA.get(g.entrypoint??g.mainComponentPath??""),fsMap:DA,defaultActiveTab:g.defaultActiveTab??g.defaultTab,defaultTab:g.defaultTab,availableTabs:g.availableTabs,extraTabs:mtg(g.extraTabs,g.mainComponentPath??g.entrypoint),schematicSvgOptions:g.schematicSvgOptions,showToggleFullScreen:g.showToggleFullScreen,autoroutingGraphics:n,autoroutingLog:Z,onReportAutoroutingLog:g.onReportAutoroutingLog||RA,leftHeaderContent:T.jsxs(T.Fragment,{children:[g.showRunButton&&T.jsx(NQg,{children:T.jsxs(xQg,{children:[T.jsx(FQg,{asChild:!0,children:T.jsxs("div",{className:"rf-relative rf-inline-flex",children:[T.jsxs("button",{type:"button",onClick:()=>{a(1)},className:"rf-flex rf-items-center rf-gap-2 rf-px-4 rf-py-2 rf-bg-blue-600 hover:rf-bg-blue-700 rf-text-white rf-rounded-md disabled:rf-opacity-50 transition-colors duration-200",disabled:D||!y,children:["Run"," ",D||!y?T.jsx(mS,{className:"rf-w-3 rf-h-3 rf-animate-spin"}):T.jsx(sxI,{className:"rf-w-3 rf-h-3"})]}),D&&T.jsx("div",{className:"rf-flex rf-items-center rf-ml-1",children:T.jsx(si,{onClick:xA=>{xA.stopPropagation(),d(!1),_(null),o(null),Q.current&&(Q.current(),Q.current=null),l.cancel(),G({}),globalThis.runFrameWorker&&(globalThis.runFrameWorker.kill(),globalThis.runFrameWorker=null)},variant:"ghost",size:"icon",className:"rf-text-red-300 hover:rf-text-red-400 hover:!rf-bg-transparent [&>svg]:rf-text-red-300 [&>svg]:hover:rf-text-red-400 rf-flex rf-items-center rf-justify-center",children:T.jsx(uco,{className:"!rf-h-2.5 !rf-w-2.5",fill:"currentColor",stroke:"currentColor"})})})]})}),T.jsx(bpA,{sideOffset:8,className:"rf-p-0 rf-bg-transparent rf-border-none rf-shadow-none rf-pointer-events-none",children:T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-px-2.5 rf-py-1.5 rf-bg-slate-900 rf-rounded-md rf-shadow-xl rf-border rf-border-slate-800/60",children:[T.jsx("kbd",{className:"rf-bg-slate-800 rf-px-1.5 rf-py-0.5 rf-rounded rf-text-[10px] rf-font-sans rf-font-medium rf-border rf-border-slate-700 rf-text-slate-200 rf-leading-none",children:"Ctrl"}),T.jsx("span",{className:"rf-text-slate-500 rf-text-[11px] rf-font-medium rf-leading-none",children:"+"}),T.jsx("kbd",{className:"rf-bg-slate-800 rf-px-1.5 rf-py-0.5 rf-rounded rf-text-[10px] rf-font-sans rf-font-medium rf-border rf-border-slate-700 rf-text-slate-200 rf-leading-none",children:"Enter"})]})})]})}),g.showFileMenu!==!1&&T.jsx(YpA,{isWebEmbedded:g.isWebEmbedded,onLoginRequired:g.onLoginRequired,showSchematicDebugGrid:k,onChangeShowSchematicDebugGrid:S,showSchematicPorts:R,onChangeShowSchematicPorts:x,autoroutingLog:Z,onReportAutoroutingLog:g.onReportAutoroutingLog||RA,shouldLoadLatestEval:g.shouldLoadLatestEval,onChangeShouldLoadLatestEval:g.onChangeShouldLoadLatestEval}),g.leftHeaderContent]}),onActiveTabChange:sA,circuitJson:I,renderLog:Y,activeEffectName:U,isRunningCode:D,errorMessage:t?.error,errorStack:t?.stack,onEditEvent:NA,editEvents:g.editEvents,onPcbBoundsSelected:g.onPcbBoundsSelected,defaultToFullScreen:g.defaultToFullScreen,onRerunWithDebug:xA=>{p(xA||""),a(1)},solverEvents:W,autoroutingPhases:A?[]:X,isCli:g.isCli,showSchematicDebugGrid:k,showSchematicPorts:R,onChangeShowSchematicDebugGrid:S,onChangeShowSchematicPorts:x})})},ZRo=g=>new Promise(A=>setTimeout(A,g)),ORo=({isOpen:g,onClose:A,onLoginSuccess:I})=>{const[e,t]=z.useState("idle"),[o,B]=z.useState(null),[C,Q]=z.useState(null),i=Kc(c=>c.pushEvent),E=z.useRef(null);z.useEffect(()=>()=>{E.current&&E.current.abort()},[]);const n=z.useCallback(async()=>{t("creating"),Q(null),E.current=new AbortController;try{const c=d3(),{login_page:h}=await c.post("sessions/login_page/create",{json:{},signal:E.current?.signal}).json();B(h.url),t("waiting");const l=new URL(h.url);for(l.searchParams.set("autoclose","true"),window.open(l.toString(),"_blank");!E.current?.signal.aborted;){const{login_page:d}=await c.post("sessions/login_page/get",{json:{login_page_id:h.login_page_id},headers:{Authorization:`Bearer ${h.login_page_auth_token}`},signal:E.current?.signal}).json();if(d.was_login_successful){t("exchanging");break}if(d.is_expired)throw new Error("Login page expired. Please try again.");await ZRo(1e3)}if(E.current?.signal.aborted){t("idle");return}const{session:D}=await c.post("sessions/login_page/exchange_for_cli_session",{json:{login_page_id:h.login_page_id},headers:{Authorization:`Bearer ${h.login_page_auth_token}`},signal:E.current?.signal}).json();typeof window<"u"&&(window.TSCIRCUIT_REGISTRY_TOKEN=D.token),await i({event_type:"TOKEN_UPDATED",registry_token:D.token}),t("success"),LC.success("Successfully logged in!"),I?.(),setTimeout(()=>{A(),t("idle"),B(null)},1e3)}catch(c){if(c instanceof DOMException&&c.name==="AbortError"){t("idle");return}console.error("Login error:",c);const h=c instanceof Error?c.message:"Failed to complete login";Q(h),t("error"),LC.error(h)}},[i,I,A]),s=z.useCallback(()=>{E.current&&E.current.abort(),t("idle"),B(null),Q(null),A()},[A]),r=e==="creating"||e==="waiting"||e==="exchanging",a=()=>{switch(e){case"creating":return"Creating login page...";case"waiting":return"Waiting for you to complete login in the browser...";case"exchanging":return"Generating token...";case"success":return"Successfully logged in!";case"error":return C||"An error occurred";default:return null}};return T.jsx(Hb,{open:g,onOpenChange:c=>!c&&!r&&s(),children:T.jsxs(xL,{className:"rf-max-w-md",children:[T.jsxs(FL,{children:[T.jsx(UL,{children:"Sign In Required"}),T.jsx(vb,{children:e==="idle"||e==="error"?"Sign in to continue. A new browser window will open for authentication.":"Complete the login process in the opened browser window."})]}),T.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-4 rf-py-4",children:[e==="idle"||e==="error"?T.jsx(si,{onClick:n,className:"rf-w-full",children:"Sign In"}):T.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-3 rf-w-full",children:[e!=="success"&&T.jsx("div",{className:"rf-animate-spin rf-w-6 rf-h-6 rf-border-2 rf-border-gray-300 rf-border-t-blue-600 rf-rounded-full"}),T.jsx("p",{className:"rf-text-sm rf-text-gray-600 rf-text-center",children:a()}),o&&e==="waiting"&&T.jsx("a",{href:o,target:"_blank",rel:"noreferrer",className:"rf-text-xs rf-text-blue-600 hover:rf-underline",children:"Click here if the window didn't open"})]}),C&&e==="error"&&T.jsx("p",{className:"rf-text-sm rf-text-red-600 rf-text-center",children:C}),r&&T.jsx(si,{variant:"outline",onClick:s,className:"rf-w-full",children:"Cancel"})]})]})})},WRo=()=>{const[g,A]=z.useState(!1),I=z.useCallback(()=>{A(!0)},[]),e=z.useCallback(()=>{A(!1)},[]),t=z.useCallback(()=>{A(!1)},[]);return{LoginDialog:T.jsx(ORo,{isOpen:g,onClose:e,onLoginSuccess:t}),openLoginDialog:I}},VRo=({apiBaseUrl:g,fetchImpl:A=globalThis.fetch.bind(globalThis)})=>{const I=`${g.replace(/\/$/,"")}/cache`;return{getItem:async e=>{try{const t=await A(`${I}?key=${encodeURIComponent(e)}`);return t.ok?await t.text():null}catch{return null}},setItem:async(e,t)=>{try{await A(`${I}?key=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"text/plain; charset=utf-8"},body:t})}catch{}}}},jRo=g=>{const[A,I]=gq("load-latest-eval",!0),e=g.evalWebWorkerBlobUrl??g.workerBlobUrl,t=g.apiBaseUrl??Jm,o=z.useMemo(()=>({...g.platformConfig,localCacheEngine:g.platformConfig?.localCacheEngine??VRo({apiBaseUrl:t})}),[t,g.platformConfig]),[B]=z.useState(()=>typeof window>"u"?void 0:new URLSearchParams(window.location.hash.slice(1)).get("main_component")??void 0),C=z.useCallback(E=>{if(typeof window>"u")return;const n=new URLSearchParams(window.location.hash.slice(1));if(n.get("main_component")===E)return;n.set("main_component",E);const s=n.toString(),r=`${window.location.pathname}${window.location.search}${s.length>0?`#${s}`:""}`;window.history.replaceState(null,"",r)},[]),{LoginDialog:Q,openLoginDialog:i}=WRo();return T.jsxs(T.Fragment,{children:[Q,T.jsx(L3I,{extraTabs:g.extraTabs,debug:g.debug,forceLatestEvalVersion:!e&&A,defaultToFullScreen:!0,showToggleFullScreen:!1,evalWebWorkerBlobUrl:e,apiBaseUrl:g.apiBaseUrl,platformConfig:o,isCli:!0,showFilesSwitch:!0,enableFetchProxy:g.enableFetchProxy,initialMainComponentPath:B,onLoginRequired:i,onMainComponentPathChange:C,shouldLoadLatestEval:!e&&A,onChangeShouldLoadLatestEval:E=>{I(E),globalThis.runFrameWorker=null},leftHeaderContent:T.jsx("div",{className:"rf-flex rf-items-center rf-justify-between",children:g.scenarioSelectorContent})})]})};kE("run-frame:ImportComponentDialog");var WKI=1,zRo=.9,XRo=.8,$Ro=.17,YQg=.1,_Qg=.999,ANo=.9999,gNo=.99,INo=/[\\\/_+.#"@\[\(\{&]/,eNo=/[\\\/_+.#"@\[\(\{&]/g,tNo=/[\s-]/,VKI=/[\s-]/g;function bQg(g,A,I,e,t,o,B){if(o===A.length)return t===g.length?WKI:gNo;var C=`${t},${o}`;if(B[C]!==void 0)return B[C];for(var Q=e.charAt(o),i=I.indexOf(Q,t),E=0,n,s,r,a;i>=0;)n=bQg(g,A,I,e,i+1,o+1,B),n>E&&(i===t?n*=WKI:INo.test(g.charAt(i-1))?(n*=XRo,r=g.slice(t,i-1).match(eNo),r&&t>0&&(n*=Math.pow(_Qg,r.length))):tNo.test(g.charAt(i-1))?(n*=zRo,a=g.slice(t,i-1).match(VKI),a&&t>0&&(n*=Math.pow(_Qg,a.length))):(n*=$Ro,t>0&&(n*=Math.pow(_Qg,i-t))),g.charAt(i)!==A.charAt(o)&&(n*=ANo)),(n<YQg&&I.charAt(i-1)===e.charAt(o+1)||e.charAt(o+1)===e.charAt(o)&&I.charAt(i-1)!==e.charAt(o))&&(s=bQg(g,A,I,e,i+1,o+2,B),s*YQg>n&&(n=s*YQg)),n>E&&(E=n),i=I.indexOf(Q,i+1);return B[C]=E,E}function jKI(g){return g.toLowerCase().replace(VKI," ")}function oNo(g,A,I){return g=I&&I.length>0?`${g+" "+I.join(" ")}`:g,bQg(g,A,jKI(g),jKI(A),0,0,{})}var SoA='[cmdk-group=""]',HQg='[cmdk-group-items=""]',BNo='[cmdk-group-heading=""]',zKI='[cmdk-item=""]',XKI=`${zKI}:not([aria-disabled="true"])`,vQg="cmdk-item-select",TO="data-value",CNo=(g,A,I)=>oNo(g,A,I),$KI=z.createContext(void 0),foA=()=>z.useContext($KI),A3I=z.createContext(void 0),TQg=()=>z.useContext(A3I),g3I=z.createContext(void 0),I3I=z.forwardRef((g,A)=>{let I=qO(()=>{var q,X;return{search:"",value:(X=(q=g.value)!=null?q:g.defaultValue)!=null?X:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),e=qO(()=>new Set),t=qO(()=>new Map),o=qO(()=>new Map),B=qO(()=>new Set),C=e3I(g),{label:Q,children:i,value:E,onValueChange:n,filter:s,shouldFilter:r,loop:a,disablePointerSelection:c=!1,vimBindings:h=!0,...l}=g,D=_0(),d=_0(),y=_0(),w=z.useRef(null),u=DNo();zb(()=>{if(E!==void 0){let q=E.trim();I.current.value=q,G.emit()}},[E]),zb(()=>{u(6,x)},[]);let G=z.useMemo(()=>({subscribe:q=>(B.current.add(q),()=>B.current.delete(q)),snapshot:()=>I.current,setState:(q,X,tA)=>{var IA,QA,sA,DA;if(!Object.is(I.current[q],X)){if(I.current[q]=X,q==="search")R(),k(),u(1,S);else if(q==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let CA=document.getElementById(y);CA?CA.focus():(IA=document.getElementById(D))==null||IA.focus()}if(u(7,()=>{var CA;I.current.selectedItemId=(CA=N())==null?void 0:CA.id,G.emit()}),tA||u(5,x),((QA=C.current)==null?void 0:QA.value)!==void 0){let CA=X??"";(DA=(sA=C.current).onValueChange)==null||DA.call(sA,CA);return}}G.emit()}},emit:()=>{B.current.forEach(q=>q())}}),[]),m=z.useMemo(()=>({value:(q,X,tA)=>{var IA;X!==((IA=o.current.get(q))==null?void 0:IA.value)&&(o.current.set(q,{value:X,keywords:tA}),I.current.filtered.items.set(q,p(X,tA)),u(2,()=>{k(),G.emit()}))},item:(q,X)=>(e.current.add(q),X&&(t.current.has(X)?t.current.get(X).add(q):t.current.set(X,new Set([q]))),u(3,()=>{R(),k(),I.current.value||S(),G.emit()}),()=>{o.current.delete(q),e.current.delete(q),I.current.filtered.items.delete(q);let tA=N();u(4,()=>{R(),tA?.getAttribute("id")===q&&S(),G.emit()})}),group:q=>(t.current.has(q)||t.current.set(q,new Set),()=>{o.current.delete(q),t.current.delete(q)}),filter:()=>C.current.shouldFilter,label:Q||g["aria-label"],getDisablePointerSelection:()=>C.current.disablePointerSelection,listId:D,inputId:y,labelId:d,listInnerRef:w}),[]);function p(q,X){var tA,IA;let QA=(IA=(tA=C.current)==null?void 0:tA.filter)!=null?IA:CNo;return q?QA(q,I.current.search,X):0}function k(){if(!I.current.search||C.current.shouldFilter===!1)return;let q=I.current.filtered.items,X=[];I.current.filtered.groups.forEach(IA=>{let QA=t.current.get(IA),sA=0;QA.forEach(DA=>{let CA=q.get(DA);sA=Math.max(CA,sA)}),X.push([IA,sA])});let tA=w.current;U().sort((IA,QA)=>{var sA,DA;let CA=IA.getAttribute("id"),hA=QA.getAttribute("id");return((sA=q.get(hA))!=null?sA:0)-((DA=q.get(CA))!=null?DA:0)}).forEach(IA=>{let QA=IA.closest(HQg);QA?QA.appendChild(IA.parentElement===QA?IA:IA.closest(`${HQg} > *`)):tA.appendChild(IA.parentElement===tA?IA:IA.closest(`${HQg} > *`))}),X.sort((IA,QA)=>QA[1]-IA[1]).forEach(IA=>{var QA;let sA=(QA=w.current)==null?void 0:QA.querySelector(`${SoA}[${TO}="${encodeURIComponent(IA[0])}"]`);sA?.parentElement.appendChild(sA)})}function S(){let q=U().find(tA=>tA.getAttribute("aria-disabled")!=="true"),X=q?.getAttribute(TO);G.setState("value",X||void 0)}function R(){var q,X,tA,IA;if(!I.current.search||C.current.shouldFilter===!1){I.current.filtered.count=e.current.size;return}I.current.filtered.groups=new Set;let QA=0;for(let sA of e.current){let DA=(X=(q=o.current.get(sA))==null?void 0:q.value)!=null?X:"",CA=(IA=(tA=o.current.get(sA))==null?void 0:tA.keywords)!=null?IA:[],hA=p(DA,CA);I.current.filtered.items.set(sA,hA),hA>0&&QA++}for(let[sA,DA]of t.current)for(let CA of DA)if(I.current.filtered.items.get(CA)>0){I.current.filtered.groups.add(sA);break}I.current.filtered.count=QA}function x(){var q,X,tA;let IA=N();IA&&(((q=IA.parentElement)==null?void 0:q.firstChild)===IA&&((tA=(X=IA.closest(SoA))==null?void 0:X.querySelector(BNo))==null||tA.scrollIntoView({block:"nearest"})),IA.scrollIntoView({block:"nearest"}))}function N(){var q;return(q=w.current)==null?void 0:q.querySelector(`${zKI}[aria-selected="true"]`)}function U(){var q;return Array.from(((q=w.current)==null?void 0:q.querySelectorAll(XKI))||[])}function K(q){let X=U()[q];X&&G.setState("value",X.getAttribute(TO))}function Y(q){var X;let tA=N(),IA=U(),QA=IA.findIndex(DA=>DA===tA),sA=IA[QA+q];(X=C.current)!=null&&X.loop&&(sA=QA+q<0?IA[IA.length-1]:QA+q===IA.length?IA[0]:IA[QA+q]),sA&&G.setState("value",sA.getAttribute(TO))}function _(q){let X=N(),tA=X?.closest(SoA),IA;for(;tA&&!IA;)tA=q>0?hNo(tA,SoA):lNo(tA,SoA),IA=tA?.querySelector(XKI);IA?G.setState("value",IA.getAttribute(TO)):Y(q)}let Z=()=>K(U().length-1),V=q=>{q.preventDefault(),q.metaKey?Z():q.altKey?_(1):Y(1)},W=q=>{q.preventDefault(),q.metaKey?K(0):q.altKey?_(-1):Y(-1)};return z.createElement(yQ.div,{ref:A,tabIndex:-1,...l,"cmdk-root":"",onKeyDown:q=>{var X;(X=l.onKeyDown)==null||X.call(l,q);let tA=q.nativeEvent.isComposing||q.keyCode===229;if(!(q.defaultPrevented||tA))switch(q.key){case"n":case"j":{h&&q.ctrlKey&&V(q);break}case"ArrowDown":{V(q);break}case"p":case"k":{h&&q.ctrlKey&&W(q);break}case"ArrowUp":{W(q);break}case"Home":{q.preventDefault(),K(0);break}case"End":{q.preventDefault(),Z();break}case"Enter":{q.preventDefault();let IA=N();if(IA){let QA=new Event(vQg);IA.dispatchEvent(QA)}}}}},z.createElement("label",{"cmdk-label":"",htmlFor:m.inputId,id:m.labelId,style:yNo},Q),WpA(g,q=>z.createElement(A3I.Provider,{value:G},z.createElement($KI.Provider,{value:m},q))))}),QNo=z.forwardRef((g,A)=>{var I,e;let t=_0(),o=z.useRef(null),B=z.useContext(g3I),C=foA(),Q=e3I(g),i=(e=(I=Q.current)==null?void 0:I.forceMount)!=null?e:B?.forceMount;zb(()=>{if(!i)return C.item(t,B?.id)},[i]);let E=t3I(t,o,[g.value,g.children,o],g.keywords),n=TQg(),s=YL(u=>u.value&&u.value===E.current),r=YL(u=>i||C.filter()===!1?!0:u.search?u.filtered.items.get(t)>0:!0);z.useEffect(()=>{let u=o.current;if(!(!u||g.disabled))return u.addEventListener(vQg,a),()=>u.removeEventListener(vQg,a)},[r,g.onSelect,g.disabled]);function a(){var u,G;c(),(G=(u=Q.current).onSelect)==null||G.call(u,E.current)}function c(){n.setState("value",E.current,!0)}if(!r)return null;let{disabled:h,value:l,onSelect:D,forceMount:d,keywords:y,...w}=g;return z.createElement(yQ.div,{ref:C5(o,A),...w,id:t,"cmdk-item":"",role:"option","aria-disabled":!!h,"aria-selected":!!s,"data-disabled":!!h,"data-selected":!!s,onPointerMove:h||C.getDisablePointerSelection()?void 0:c,onClick:h?void 0:a},g.children)}),iNo=z.forwardRef((g,A)=>{let{heading:I,children:e,forceMount:t,...o}=g,B=_0(),C=z.useRef(null),Q=z.useRef(null),i=_0(),E=foA(),n=YL(r=>t||E.filter()===!1?!0:r.search?r.filtered.groups.has(B):!0);zb(()=>E.group(B),[]),t3I(B,C,[g.value,g.heading,Q]);let s=z.useMemo(()=>({id:B,forceMount:t}),[t]);return z.createElement(yQ.div,{ref:C5(C,A),...o,"cmdk-group":"",role:"presentation",hidden:n?void 0:!0},I&&z.createElement("div",{ref:Q,"cmdk-group-heading":"","aria-hidden":!0,id:i},I),WpA(g,r=>z.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":I?i:void 0},z.createElement(g3I.Provider,{value:s},r))))}),ENo=z.forwardRef((g,A)=>{let{alwaysRender:I,...e}=g,t=z.useRef(null),o=YL(B=>!B.search);return!I&&!o?null:z.createElement(yQ.div,{ref:C5(t,A),...e,"cmdk-separator":"",role:"separator"})}),nNo=z.forwardRef((g,A)=>{let{onValueChange:I,...e}=g,t=g.value!=null,o=TQg(),B=YL(i=>i.search),C=YL(i=>i.selectedItemId),Q=foA();return z.useEffect(()=>{g.value!=null&&o.setState("search",g.value)},[g.value]),z.createElement(yQ.input,{ref:A,...e,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":Q.listId,"aria-labelledby":Q.labelId,"aria-activedescendant":C,id:Q.inputId,type:"text",value:t?g.value:B,onChange:i=>{t||o.setState("search",i.target.value),I?.(i.target.value)}})}),sNo=z.forwardRef((g,A)=>{let{children:I,label:e="Suggestions",...t}=g,o=z.useRef(null),B=z.useRef(null),C=YL(i=>i.selectedItemId),Q=foA();return z.useEffect(()=>{if(B.current&&o.current){let i=B.current,E=o.current,n,s=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let r=i.offsetHeight;E.style.setProperty("--cmdk-list-height",r.toFixed(1)+"px")})});return s.observe(i),()=>{cancelAnimationFrame(n),s.unobserve(i)}}},[]),z.createElement(yQ.div,{ref:C5(o,A),...t,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":C,"aria-label":e,id:Q.listId},WpA(g,i=>z.createElement("div",{ref:C5(B,Q.listInnerRef),"cmdk-list-sizer":""},i)))}),aNo=z.forwardRef((g,A)=>{let{open:I,onOpenChange:e,overlayClassName:t,contentClassName:o,container:B,...C}=g;return z.createElement(fmA,{open:I,onOpenChange:e},z.createElement(RmA,{container:B},z.createElement(TtA,{"cmdk-overlay":"",className:t}),z.createElement(ZtA,{"aria-label":g.label,"cmdk-dialog":"",className:o},z.createElement(I3I,{ref:A,...C}))))}),rNo=z.forwardRef((g,A)=>YL(I=>I.filtered.count===0)?z.createElement(yQ.div,{ref:A,...g,"cmdk-empty":"",role:"presentation"}):null),cNo=z.forwardRef((g,A)=>{let{progress:I,children:e,label:t="Loading...",...o}=g;return z.createElement(yQ.div,{ref:A,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":I,"aria-valuemin":0,"aria-valuemax":100,"aria-label":t},WpA(g,B=>z.createElement("div",{"aria-hidden":!0},B)))}),Hk=Object.assign(I3I,{List:sNo,Item:QNo,Input:nNo,Group:iNo,Separator:ENo,Dialog:aNo,Empty:rNo,Loading:cNo});function hNo(g,A){let I=g.nextElementSibling;for(;I;){if(I.matches(A))return I;I=I.nextElementSibling}}function lNo(g,A){let I=g.previousElementSibling;for(;I;){if(I.matches(A))return I;I=I.previousElementSibling}}function e3I(g){let A=z.useRef(g);return zb(()=>{A.current=g}),A}var zb=typeof window>"u"?z.useEffect:z.useLayoutEffect;function qO(g){let A=z.useRef();return A.current===void 0&&(A.current=g()),A}function YL(g){let A=TQg(),I=()=>g(A.snapshot());return z.useSyncExternalStore(A.subscribe,I,I)}function t3I(g,A,I,e=[]){let t=z.useRef(),o=foA();return zb(()=>{var B;let C=(()=>{var i;for(let E of I){if(typeof E=="string")return E.trim();if(typeof E=="object"&&"current"in E)return E.current?(i=E.current.textContent)==null?void 0:i.trim():t.current}})(),Q=e.map(i=>i.trim());o.value(g,C,Q),(B=A.current)==null||B.setAttribute(TO,C),t.current=C}),t}var DNo=()=>{let[g,A]=z.useState(),I=qO(()=>new Map);return zb(()=>{I.current.forEach(e=>e()),I.current=new Map},[g]),(e,t)=>{I.current.set(e,t),A({})}};function dNo(g){let A=g.type;return typeof A=="function"?A(g.props):"render"in A?A.render(g.props):g}function WpA({asChild:g,children:A},I){return g&&z.isValidElement(A)?z.cloneElement(dNo(A),{ref:A.ref},I(A.props.children)):I(A)}var yNo={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const o3I=z.forwardRef(({className:g,...A},I)=>T.jsx(Hk,{ref:I,className:co("rf-flex rf-h-full rf-w-full rf-flex-col rf-overflow-hidden rf-rounded-md rf-bg-white rf-text-zinc-950 dark:rf-bg-zinc-950 dark:rf-text-zinc-50",g),...A}));o3I.displayName=Hk.displayName;const B3I=z.forwardRef(({className:g,...A},I)=>T.jsxs("div",{className:"rf-flex rf-items-center rf-border-b rf-px-3","cmdk-input-wrapper":"",children:[T.jsx(Wog,{className:"rf-mr-2 rf-h-4 rf-w-4 rf-shrink-0 rf-opacity-50"}),T.jsx(Hk.Input,{ref:I,className:co("rf-flex rf-h-10 rf-w-full rf-rounded-md rf-bg-transparent rf-py-3 rf-text-sm rf-outline-none placeholder:rf-text-zinc-500 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 dark:placeholder:rf-text-zinc-400",g),...A})]}));B3I.displayName=Hk.Input.displayName;const C3I=z.forwardRef(({className:g,...A},I)=>T.jsx(Hk.List,{ref:I,className:co("rf-max-h-[300px] rf-overflow-y-auto rf-overflow-x-hidden rf-py-1",g),...A}));C3I.displayName=Hk.List.displayName;const qQg=z.forwardRef((g,A)=>T.jsx(Hk.Empty,{ref:A,className:"rf-py-6 rf-text-center rf-text-sm",...g}));qQg.displayName=Hk.Empty.displayName;const RoA=z.forwardRef(({className:g,...A},I)=>T.jsx(Hk.Group,{ref:I,className:co("rf-overflow-hidden rf-px-1 rf-py-0 rf-text-zinc-950 [&_[cmdk-group-heading]]:rf-px-2 [&_[cmdk-group-heading]]:rf-py-1.5 [&_[cmdk-group-heading]]:rf-text-xs [&_[cmdk-group-heading]]:rf-font-medium [&_[cmdk-group-heading]]:rf-text-zinc-500 dark:rf-text-zinc-50 dark:[&_[cmdk-group-heading]]:rf-text-zinc-400",g),...A}));RoA.displayName=Hk.Group.displayName;const wNo=z.forwardRef(({className:g,...A},I)=>T.jsx(Hk.Separator,{ref:I,className:co("rf--mx-1 rf-h-px rf-bg-zinc-200 dark:rf-bg-zinc-800",g),...A}));wNo.displayName=Hk.Separator.displayName;const NoA=z.forwardRef(({className:g,...A},I)=>T.jsx(Hk.Item,{ref:I,className:co("rf-relative rf-flex rf-cursor-default rf-gap-2 rf-select-none rf-items-center rf-rounded-sm rf-px-2 rf-py-1.5 rf-text-sm rf-outline-none data-[disabled=true]:rf-pointer-events-none data-[selected=true]:rf-bg-zinc-100 data-[selected=true]:rf-text-zinc-900 data-[disabled=true]:rf-opacity-50 [&_svg]:rf-pointer-events-none [&_svg]:rf-size-4 [&_svg]:rf-shrink-0 dark:data-[selected=true]:rf-bg-zinc-800 dark:data-[selected=true]:rf-text-zinc-50",g),...A}));NoA.displayName=Hk.Item.displayName;var uNo=Object.defineProperty,cP=(g,A)=>uNo(g,"name",{value:A,configurable:!0}),ZQg="Popover",[Q3I,TCB]=hk(ZQg,[ML]),OQg=ML(),[GNo,ZO]=Q3I(ZQg),mNo=cP(g=>{const{__scopePopover:A,children:I,open:e,defaultOpen:t,onOpenChange:o,modal:B=!1}=g,C=OQg(A),Q=z.useRef(null),[i,E]=z.useState(!1),[n,s]=z.useState(0),[r,a]=z.useState(0),[c,h]=xR({prop:e,defaultProp:t??!1,onChange:o,caller:ZQg});return T.jsx(JtA,{...C,children:T.jsx(GNo,{scope:A,contentId:_0(),titleId:_0(),descriptionId:_0(),titlePresent:n>0,descriptionPresent:r>0,setTitleCount:s,setDescriptionCount:a,triggerRef:Q,open:c,onOpenChange:h,onOpenToggle:z.useCallback(()=>h(l=>!l),[h]),hasCustomAnchor:i,onCustomAnchorAdd:z.useCallback(()=>E(!0),[]),onCustomAnchorRemove:z.useCallback(()=>E(!1),[]),modal:B,children:I})})},"Popover"),pNo="PopoverTrigger",kNo=z.forwardRef(cP(function(A,I){const{__scopePopover:e,...t}=A,o=ZO(pNo,e),B=OQg(e),C=Gi(I,o.triggerRef),Q=T.jsx(yQ.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":WQg(o.open),...t,ref:C,onClick:fo(A.onClick,o.onOpenToggle)});return o.hasCustomAnchor?Q:T.jsx(QmA,{asChild:!0,...B,children:Q})},"PopoverTrigger")),i3I="PopoverPortal",[MNo,SNo]=Q3I(i3I,{forceMount:void 0}),fNo=cP(g=>{const{__scopePopover:A,forceMount:I,children:e,container:t}=g,o=ZO(i3I,A);return T.jsx(MNo,{scope:A,forceMount:I,children:T.jsx(AS,{present:I||o.open,children:T.jsx(nmA,{asChild:!0,container:t,children:e})})})},"PopoverPortal"),xoA="PopoverContent",E3I=z.forwardRef(cP(function(A,I){const e=SNo(xoA,A.__scopePopover),{forceMount:t=e.forceMount,...o}=A,B=ZO(xoA,A.__scopePopover);return T.jsx(AS,{present:t||B.open,children:B.modal?T.jsx(NNo,{...o,ref:I}):T.jsx(xNo,{...o,ref:I})})},"PopoverContent")),RNo=NR("PopoverContent.RemoveScroll"),NNo=z.forwardRef(cP(function(A,I){const e=ZO(xoA,A.__scopePopover),t=z.useRef(null),o=Gi(I,t),B=z.useRef(!1),{nodes:C,registry:Q}=VGA();return z.useEffect(()=>{const i=t.current;if(i)return rmA(i)},[]),T.jsx(PtA,{as:RNo,allowPinchZoom:!0,shards:z.useMemo(()=>[t,...C.map(i=>({current:i}))],[t,C]),children:T.jsx(n3I,{...A,ref:o,branchNodes:C,branchRegistry:Q,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fo(A.onCloseAutoFocus,i=>{i.preventDefault(),B.current||e.triggerRef.current?.focus()}),onPointerDownOutside:fo(A.onPointerDownOutside,i=>{const E=i.detail.originalEvent,n=E.button===0&&E.ctrlKey===!0,s=E.button===2||n;B.current=s},{checkForDefaultPrevented:!1}),onFocusOutside:fo(A.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),xNo=z.forwardRef(cP(function(A,I){const e=ZO(xoA,A.__scopePopover),t=z.useRef(!1),o=z.useRef(!1);return T.jsx(n3I,{...A,ref:I,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:B=>{A.onCloseAutoFocus?.(B),B.defaultPrevented||(t.current||e.triggerRef.current?.focus(),B.preventDefault()),t.current=!1,o.current=!1},onInteractOutside:B=>{A.onInteractOutside?.(B),B.defaultPrevented||(t.current=!0,B.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const C=B.target;e.triggerRef.current?.contains(C)&&B.preventDefault(),B.detail.originalEvent.type==="focusin"&&o.current&&B.preventDefault()}})},"PopoverContentNonModal")),n3I=z.forwardRef(cP(function(A,I){const{__scopePopover:e,trapFocus:t,onOpenAutoFocus:o,onCloseAutoFocus:B,disableOutsidePointerEvents:C,onEscapeKeyDown:Q,onPointerDownOutside:i,onFocusOutside:E,onInteractOutside:n,"aria-describedby":s,branchNodes:r,branchRegistry:a,...c}=A,h=ZO(xoA,e),l=OQg(e),[D,d]=z.useState(null),y=Gi(I,d);return jGA(D),rO(),T.jsx(WGA,{registry:a,children:T.jsx(OGA,{asChild:!0,loop:!0,trapped:t,branches:r,onMountAutoFocus:o,onUnmountAutoFocus:B,children:T.jsx(xtA,{asChild:!0,disableOutsidePointerEvents:C,onInteractOutside:n,onEscapeKeyDown:Q,onPointerDownOutside:i,onFocusOutside:E,onDismiss:()=>h.onOpenChange(!1),deferPointerDownOutside:!0,children:T.jsx(imA,{"data-state":WQg(h.open),role:"dialog",id:h.contentId,"aria-labelledby":h.titlePresent?h.titleId:void 0,"aria-describedby":h.descriptionPresent?s3I(s,h.descriptionId):s,...l,...c,ref:y,style:{...c.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})})},"PopoverContentImpl"));function WQg(g){return g?"open":"closed"}cP(WQg,"getState");function s3I(...g){const A=new Set;for(const I of g)if(typeof I=="string")for(const e of String(I).trim().split(/\s+/))e&&A.add(e);return A.size>0?Array.from(A).join(" "):void 0}cP(s3I,"concatAriaDescribedby");const FNo=mNo,UNo=kNo,a3I=z.forwardRef(({className:g,align:A="center",sideOffset:I=4,...e},t)=>T.jsx(fNo,{children:T.jsx(E3I,{ref:t,align:A,sideOffset:I,className:co("rf-z-50 rf-w-72 rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-p-4 rf-text-zinc-950 rf-shadow-md rf-outline-none data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2 rf-origin-[--radix-popover-content-transform-origin] dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-50",g),...e})}));a3I.displayName=E3I.displayName;function r3I(g,A){const I=g.lastIndexOf("."),e=A.lastIndexOf("."),t=I>0?g.substring(0,I):g,o=e>0?A.substring(0,e):A;if(t!==o&&g.substring(I)===A.substring(e)){if(t.startsWith(o))return 1;if(o.startsWith(t))return-1}return g.localeCompare(A,void 0,{numeric:!0,sensitivity:"base"})}function JNo(g){const A=[],I=new Map;I.set("",{name:"",path:"",type:"folder",children:A});for(const e of g){const t=e.split("/");let o="";for(let B=0;B<t.length;B++){const C=t[B],Q=o;if(o=o?`${o}/${C}`:C,!I.has(o)){const i=B===t.length-1,E={name:C,path:o,type:i?"file":"folder",children:i?void 0:[]};I.set(o,E);const n=I.get(Q);n&&n.children&&n.children.push(E)}}}return A}function c3I(g,A){for(const I of g){if(I.path===A)return I;if(I.children){const e=c3I(I.children,A);if(e)return e}}return null}function PNo(g,A){let I;if(A?I=c3I(g,A):I={name:"",path:"",type:"folder",children:g},!I||!I.children)return{files:[],folders:[]};const e=I.children.filter(o=>o.type==="file"),t=I.children.filter(o=>o.type==="folder");return e.sort((o,B)=>r3I(o.name,B.name)),t.sort((o,B)=>r3I(o.name,B.name)),{files:e,folders:t}}const KNo=g=>{const A=g.split("/").pop()||"";return A.endsWith(".py.tsx")?A.slice(0,-4):A};function VQg(g){const A=g.lastIndexOf("/");return A===-1?"/":g.substring(0,A)}function LNo({currentFile:g,files:A}){const[I,e]=z.useState(!1),[t,o]=z.useState(()=>{if(typeof window<"u"){const Q=new URLSearchParams(window.location.search),i=new URLSearchParams(window.location.hash.slice(1)),E=Q.get("file")??i.get("file");if(E&&A.includes(E)){const n=VQg(E);return n==="/"?null:n}}if(g&&A.includes(g)){const Q=VQg(g);return Q==="/"?null:Q}return null});return z.useEffect(()=>{if(g&&!I&&A.includes(g)){const Q=VQg(g);o(Q==="/"?null:Q)}},[g,I,A]),{currentFolder:t,navigateToFolder:Q=>{o(Q),e(!0)},resetManualNavigation:()=>{e(!1)}}}const jQg=g=>g.endsWith(".tsx")||g.endsWith(".jsx")?T.jsx(Cco,{className:"rf-h-4 rf-w-4 rf-text-blue-500"}):g.endsWith(".md")||g.endsWith(".txt")?T.jsx(Eco,{className:"rf-h-4 rf-w-4 rf-text-gray-600"}):T.jsx(nco,{className:"rf-h-4 rf-w-4 rf-text-gray-500"}),YNo=g=>g.endsWith(".tsx")||MoA(g)||g.endsWith(".jsx"),_No=g=>KNo(g),h3I=g=>g.substring(0,g.lastIndexOf("/"))||"/",l3I=({files:g,onFileChange:A,currentFile:I,fileFilter:e=YNo,getDisplayName:t=_No,placeholder:o="Select file",searchPlaceholder:B="Search for file",emptyMessage:C="No files found in this directory.",pinnedFiles:Q=[],onToggleFavorite:i,recentlySavedFiles:E=[]})=>{const[n,s]=z.useState(!1),[r,a]=z.useState(I),{currentFolder:c,navigateToFolder:h,resetManualNavigation:l}=LNo({currentFile:r,files:g}),[D,d]=z.useState(0),[y,w]=z.useState(""),[u,G]=gq("runframe:recentlyViewed",[]),[m,p]=gq("runframe:showRecents",!1);z.useEffect(()=>{const q=X=>{(X.metaKey||X.ctrlKey)&&X.key==="k"&&(X.preventDefault(),s(tA=>!tA))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]);const k=g.filter(e),S=z.useRef(null);z.useEffect(()=>{const q=()=>{S.current&&(clearTimeout(S.current),S.current=null)};return a(I),I&&k.includes(I)&&(q(),S.current=setTimeout(()=>{G(X=>{if(X[0]===I)return X;const tA=X.filter(IA=>IA!==I);return[I,...tA].slice(0,10)})},500)),q},[I,k,G]);const R=JNo(k),{files:x,folders:N}=PNo(R,c||""),K=(()=>{if(!y.trim())return{currentDirResults:[],globalResults:[]};const q=y.toLowerCase(),tA=k.map(sA=>{const DA=sA.split("/").pop()||"";return{path:sA,fileName:DA}}).filter(sA=>sA.fileName.toLowerCase().includes(q)||sA.path.toLowerCase().includes(q)),IA=tA.filter(sA=>c?sA.path.substring(0,sA.path.lastIndexOf("/"))===c:!sA.path.includes("/")),QA=tA.filter(sA=>c?sA.path.substring(0,sA.path.lastIndexOf("/"))!==c:sA.path.includes("/"));return{currentDirResults:IA,globalResults:QA}})(),Y=y.trim().length>0,_=q=>{h(q),d(0)},Z=z.useCallback(()=>{if(!c)return;const q=c.lastIndexOf("/"),X=q===-1?null:c.substring(0,q);_(X)},[c,_]);z.useEffect(()=>{if(!n)return;const q=X=>{(X.metaKey||X.ctrlKey)&&X.key==="ArrowUp"&&(X.preventDefault(),Z())};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[n,Z]);const V=z.useCallback((q,X,tA=!1)=>{if(a(q),d(X),s(!1),A(q),tA){const IA=q.lastIndexOf("/"),QA=IA===-1?null:q.substring(0,IA);_(QA)}},[A,_]);z.useEffect(()=>{const q=X=>{if((X.metaKey||X.ctrlKey)&&(X.key==="ArrowLeft"||X.key==="ArrowRight")){if(X.preventDefault(),!I||x.length===0)return;const tA=x.findIndex(sA=>sA.path===I);if(tA===-1)return;let IA;X.key==="ArrowLeft"?IA=tA===0?x.length-1:tA-1:IA=tA===x.length-1?0:tA+1;const QA=x[IA];QA&&V(QA.path,IA)}};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[I,x,V]),z.useEffect(()=>{if(x.length>0){const q=x.findIndex(X=>X.path===I);q>=0&&d(q)}},[x,I]);const W=z.useMemo(()=>{const q=E.filter(IA=>k.includes(IA)),X=u.filter(IA=>k.includes(IA)),tA=[];q.length>0&&tA.push({path:q[0],type:"saved"});for(const IA of X){if(tA.length>=3)break;tA.some(QA=>QA.path===IA)||tA.push({path:IA,type:"viewed"})}return tA},[E,u,k]);return T.jsx("div",{className:"rf-flex rf-min-w-0 rf-max-w-96 rf-items-center rf-gap-1",children:T.jsxs(FNo,{open:n,onOpenChange:q=>{s(q),q||(w(""),l())},children:[T.jsx(UNo,{asChild:!0,children:T.jsxs(si,{variant:"outline",role:"combobox","aria-expanded":n,className:"rf-w-full rf-min-w-0 rf-justify-center rf-items-center rf-gap-1 !rf-font-normal",title:r||o,children:[T.jsx("span",{className:"rf-truncate rf-text-left",children:r?t(r):o}),T.jsx(Ico,{className:"rf-opacity-50 rf-flex-shrink-0"})]})}),T.jsx(a3I,{collisionPadding:8,className:"!rf-p-0 !rf-overflow-y-auto !rf-z-[200]",style:{width:"min(600px, calc(100vw - 16px))",maxHeight:"min(80vh, var(--radix-popover-content-available-height))"},children:T.jsxs(o3I,{shouldFilter:!1,children:[T.jsx(B3I,{placeholder:B,className:"rf-h-9 rf-w-full",value:y,onValueChange:w}),W.length>0&&T.jsxs("div",{className:"rf-border-b rf-border-gray-200",children:[T.jsxs("button",{onClick:()=>p(!m),className:"rf-w-full rf-px-3 rf-py-2 rf-flex rf-items-center rf-justify-between rf-text-xs rf-text-slate-600 hover:rf-bg-slate-50 rf-bg-transparent rf-border-none rf-cursor-pointer",children:[T.jsx("span",{className:"rf-font-medium",children:"Recent Files"}),T.jsx(RtA,{className:co("rf-h-4 rf-w-4 rf-transition-transform",!m&&"-rf-rotate-90")})]}),m&&T.jsx("div",{className:"rf-pb-1",children:W.map((q,X)=>T.jsxs("div",{onClick:()=>V(q.path,X,!0),className:co("rf-flex rf-items-center rf-px-3 rf-py-1.5 rf-cursor-pointer hover:rf-bg-slate-100",q.path===I&&"rf-font-medium"),children:[q.type==="saved"?T.jsx("span",{title:"Recently saved",children:T.jsx(wco,{className:"rf-mr-2 rf-h-4 rf-w-4 rf-text-green-500"})}):T.jsx("span",{title:"Recently viewed",children:T.jsx(Bco,{className:"rf-mr-2 rf-h-4 rf-w-4 rf-text-blue-500"})}),T.jsx("span",{className:"rf-min-w-0 rf-truncate rf-text-sm",title:q.path,children:t(q.path.split("/").pop()||"")}),T.jsx("span",{className:"rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[40%]",children:h3I(q.path)}),T.jsx(sF,{className:co("rf-ml-auto rf-h-4 rf-w-4 rf-shrink-0",q.path===I?"rf-opacity-100":"rf-opacity-0")})]},q.path))})]}),T.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-slate-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[T.jsx("div",{className:"rf-flex rf-items-center rf-text-xs rf-text-slate-600 rf-min-w-0 rf-flex-1",children:T.jsxs("div",{className:"rf-flex rf-min-w-0 rf-items-center rf-overflow-x-auto rf-whitespace-nowrap",children:[T.jsx("button",{onClick:()=>_(null),className:"rf-text-blue-600 hover:rf-text-blue-800 rf-underline rf-cursor-pointer rf-bg-transparent rf-border-none rf-p-0 rf-flex-shrink-0",children:"root"}),c?.split("/").filter(Boolean).map((q,X,tA)=>{const IA=tA.slice(0,X+1).join("/");return T.jsxs("span",{className:"rf-flex rf-items-center rf-shrink-0",children:[T.jsx("span",{className:"rf-mx-1 rf-flex-shrink-0",children:"/"}),X===tA.length-1?T.jsx("span",{className:"rf-text-slate-800 rf-truncate rf-max-w-[200px]",title:q,children:q}):T.jsx("button",{onClick:()=>_(IA),className:"rf-text-blue-600 hover:rf-text-blue-800 rf-underline rf-cursor-pointer rf-bg-transparent rf-border-none rf-p-0 rf-truncate rf-max-w-[150px]",title:q,children:q})]},IA)})]})}),T.jsx("div",{className:"rf-flex rf-items-center rf-gap-2 rf-flex-shrink-0",children:c&&T.jsxs("button",{onClick:Z,className:"rf-flex rf-items-center rf-gap-1 rf-text-slate-600 hover:rf-text-slate-800 rf-bg-transparent rf-border-none rf-p-1 rf-rounded hover:rf-bg-slate-200 rf-transition-colors",title:"Go up one level",children:[T.jsx($ro,{className:"rf-h-3 rf-w-3"}),T.jsx("span",{className:"rf-text-xs rf-font-medium",children:"Up"})]})})]}),T.jsx(C3I,{className:"rf-overflow-visible rf-max-h-none",children:Y?T.jsx(T.Fragment,{children:K.currentDirResults.length===0&&K.globalResults.length===0?T.jsxs(qQg,{children:['No files found matching "',y,'".']}):T.jsxs(T.Fragment,{children:[K.currentDirResults.length>0&&T.jsx(RoA,{children:K.currentDirResults.map((q,X)=>T.jsxs(NoA,{value:`search-current:${q.path}`,onSelect:()=>{a(q.path),s(!1),A(q.path)},className:co(q.path===I&&"rf-font-medium","rf-group"),children:[T.jsx("span",{className:"rf-mr-2",children:jQg(q.fileName)}),T.jsxs("div",{className:"rf-flex rf-items-center rf-w-full rf-min-w-0",children:[T.jsx("span",{className:"rf-truncate rf-flex-1",children:t(q.fileName)}),T.jsx("span",{className:"rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[40%]",children:c||"/"}),q.path===I&&T.jsx(sF,{className:"rf-ml-2 rf-h-4 rf-w-4 rf-flex-shrink-0"})]})]},q.path))}),K.globalResults.length>0&&T.jsx(RoA,{children:K.globalResults.map(q=>T.jsxs(NoA,{value:`search-global:${q.path}`,onSelect:()=>{a(q.path),s(!1),A(q.path)},className:co(q.path===I&&"rf-font-medium","rf-group"),children:[T.jsx("span",{className:"rf-mr-2",children:jQg(q.fileName)}),T.jsxs("div",{className:"rf-flex rf-items-center rf-w-full rf-min-w-0",children:[T.jsx("span",{className:"rf-truncate rf-flex-1",children:t(q.fileName)}),T.jsx("span",{className:"rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[40%]",children:h3I(q.path)}),q.path===I&&T.jsx(sF,{className:"rf-ml-2 rf-h-4 rf-w-4 rf-flex-shrink-0"})]})]},q.path))})]})}):T.jsxs(T.Fragment,{children:[T.jsx(qQg,{children:C}),x.length>0&&T.jsx(RoA,{children:x.map((q,X)=>T.jsxs(NoA,{value:`current:${q.path}`,onSelect:()=>V(q.path,X),className:co(q.path===I&&"rf-font-medium","rf-group"),children:[T.jsx("span",{className:"rf-mr-2 rf-shrink-0",children:jQg(q.name)}),T.jsx("span",{className:"rf-min-w-0 rf-truncate",title:q.path,children:t(q.name)}),T.jsx("div",{className:"rf-ml-auto rf-flex rf-shrink-0 rf-items-center rf-gap-1",children:T.jsx(sF,{className:co("rf-h-4 rf-w-4",q.path===I?"rf-opacity-100":"rf-opacity-0")})})]},q.path))}),N.length>0&&T.jsx(RoA,{children:N.map(q=>T.jsxs(NoA,{value:`folder-${q.path}`,onSelect:()=>_(q.path),className:"rf-text-slate-600 hover:rf-text-slate-900",children:[T.jsx(sco,{className:"rf-mr-2 rf-h-4 rf-w-4 rf-shrink-0 rf-text-blue-600"}),T.jsx("span",{className:"rf-min-w-0 rf-truncate",title:q.path,children:q.name}),T.jsx(Fb,{className:"rf-ml-auto rf-h-4 rf-w-4 rf-shrink-0"})]},q.path))}),x.length===0&&N.length===0&&T.jsx("div",{className:"rf-p-4 rf-text-center rf-text-slate-500 rf-text-sm",children:"No files or folders in this directory"})]})})]})})]})})},bNo=({files:g,onFileChange:A,currentFile:I})=>T.jsx(l3I,{files:g,onFileChange:A,currentFile:I,fileFilter:()=>!0,placeholder:"Select circuit",searchPlaceholder:"Search for circuit file",emptyMessage:"No circuit files found in this directory."}),D3I=g=>g!==null&&!["0","false","off","no"].includes(g.toLowerCase()),HNo=({hash:g,search:A=""})=>{const I=new URLSearchParams(g.startsWith("#")?g.slice(1):g),e=new URLSearchParams(A.startsWith("?")?A.slice(1):A);return D3I(I.get("gallery"))||D3I(e.get("gallery"))},vNo=({hash:g,initialCircuitPath:A})=>{const I=new URLSearchParams(g.startsWith("#")?g.slice(1):g);return I.get("file")??I.get("main_component")??A??""},TNo=({hash:g,filePath:A})=>{const I=new URLSearchParams(g.startsWith("#")?g.slice(1):g);if(I.get("file")===A&&!I.has("gallery")&&(!I.has("main_component")||I.get("main_component")===A))return g.startsWith("#")?g:g?`#${g}`:"";I.delete("gallery"),I.set("file",A),I.has("main_component")&&I.set("main_component",A);const e=I.toString();return e?`#${e}`:""},qNo=(g,A=!1)=>{const[I,e]=z.useState(()=>typeof window>"u"?g??"":vNo({hash:window.location.hash,initialCircuitPath:g})),[t,o]=z.useState(()=>typeof window>"u"?A:A||HNo({hash:window.location.hash,search:window.location.search})),B=z.useCallback(E=>{if(typeof window>"u")return;const n=new URLSearchParams(window.location.hash.slice(1)),s=new URLSearchParams(window.location.search.slice(1));E?n.set("gallery","true"):(n.delete("gallery"),s.delete("gallery"));const r=s.toString(),a=n.toString();window.history.replaceState(null,"",`${window.location.pathname}${r?`?${r}`:""}${a?`#${a}`:""}`)},[]),C=z.useCallback(()=>{o(!0),B(!0)},[B]),Q=z.useCallback(()=>{o(!1),B(!1)},[B]),i=z.useCallback(E=>{if(typeof window>"u")return;const n=TNo({hash:window.location.hash,filePath:E}),s=new URLSearchParams(window.location.search.slice(1));s.delete("gallery");const r=s.toString(),a=`${window.location.pathname}${r?`?${r}`:""}${n}`;n===window.location.hash&&`${r?`?${r}`:""}`===window.location.search||window.history.replaceState(null,"",a)},[]);return{currentCircuitJsonPath:I,setCurrentCircuitJsonPath:e,updateFileHash:i,isGalleryVisible:t,showGallery:C,hideGallery:Q}},ZNo=g=>{const A=g.fileStaticAssetUrl,I=A.search(/[?#]/),e=I===-1?A:A.slice(0,I),t=I===-1?"":A.slice(I),o=e.includes("/")?e.slice(0,e.lastIndexOf("/")+1):"";return["3d.png","pcb.png","pcb.svg","schematic.png","schematic.svg"].map(B=>`${o}${B}${t}`)},d3I=g=>(g.split("/").pop()??g).replace(/(\.board|\.circuit)?\.(tsx|jsx|json)$/i,""),ONo=({fileRef:g})=>{const A=ZNo(g),[I,e]=z.useState(0);return I>=A.length?T.jsx("div",{className:"rf-flex rf-h-full rf-w-full rf-items-center rf-justify-center rf-bg-zinc-100 rf-text-zinc-400",children:T.jsx(rco,{className:"rf-h-8 rf-w-8","aria-hidden":"true"})}):T.jsx("img",{src:A[I],alt:`Preview of ${d3I(g.filePath)}`,className:"rf-h-full rf-w-full rf-object-contain rf-transition-transform rf-duration-200 group-hover:rf-scale-[1.03]",loading:"lazy",onError:()=>e(t=>t+1)})},WNo=({files:g,projectName:A,onSelectFile:I,onClose:e})=>(z.useEffect(()=>{const t=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),T.jsx("main",{className:"rf-h-full rf-w-full rf-overflow-y-auto rf-bg-zinc-50",children:T.jsxs("div",{className:"rf-mx-auto rf-w-full rf-max-w-7xl rf-px-5 rf-py-8 sm:rf-px-8 sm:rf-py-10",children:[T.jsxs("div",{className:"rf-mb-7 rf-flex rf-items-start rf-justify-between rf-gap-4",children:[T.jsxs("div",{children:[T.jsx("p",{className:"rf-mb-1 rf-text-xs rf-font-medium rf-uppercase rf-tracking-wider rf-text-zinc-500",children:A??"tscircuit project"}),T.jsx("h1",{className:"rf-text-2xl rf-font-semibold rf-tracking-tight rf-text-zinc-950 sm:rf-text-3xl",children:"Circuit gallery"}),T.jsxs("p",{className:"rf-mt-2 rf-text-sm rf-text-zinc-600",children:["Explore ",g.length," ",g.length===1?"board":"boards",". Select one to open its interactive preview."]})]}),T.jsxs(si,{type:"button",variant:"outline",onClick:e,children:[T.jsx(Xro,{className:"rf-h-4 rf-w-4"}),"Back to circuit"]})]}),T.jsx("div",{className:"rf-grid rf-grid-cols-1 rf-gap-5 sm:rf-grid-cols-2 lg:rf-grid-cols-3",children:g.map(t=>T.jsxs("button",{type:"button",onClick:()=>I(t.filePath),className:"group rf-overflow-hidden rf-rounded-xl rf-border rf-border-zinc-200 rf-bg-white rf-text-left rf-shadow-sm rf-transition-all hover:rf--translate-y-0.5 hover:rf-border-zinc-300 hover:rf-shadow-md focus-visible:rf-outline-none focus-visible:rf-ring-2 focus-visible:rf-ring-zinc-900 focus-visible:rf-ring-offset-2",children:[T.jsx("div",{className:"rf-aspect-[4/3] rf-w-full rf-overflow-hidden rf-bg-white rf-p-3",children:T.jsx(ONo,{fileRef:t})}),T.jsxs("div",{className:"rf-border-t rf-border-zinc-100 rf-px-4 rf-py-3",children:[T.jsx("div",{className:"rf-truncate rf-text-sm rf-font-medium rf-text-zinc-900",children:d3I(t.filePath)}),T.jsx("div",{className:"rf-mt-0.5 rf-truncate rf-text-xs rf-text-zinc-500",children:t.filePath})]})]},t.filePath))})]})})),VNo=g=>g instanceof Error?g.message:"An unknown error occurred",jNo=g=>{noA();const{currentCircuitJsonPath:A,setCurrentCircuitJsonPath:I,updateFileHash:e,isGalleryVisible:t,showGallery:o,hideGallery:B}=qNo(g.initialCircuitPath,g.defaultToGallery),[C,Q]=z.useState(null),[i,E]=z.useState(!1),[n,s]=z.useState({}),[r,a]=z.useState(new Set),[c,h]=z.useState(new Set),l=g.files,D=l.map(p=>p.filePath),d=z.useCallback(async p=>{if(!p.fileStaticAssetUrl)throw new Error(`No fileStaticAssetUrl provided for ${p.filePath}`);const k=await fetch(p.fileStaticAssetUrl);if(!k.ok)throw new Error(`Failed to fetch ${p.filePath}: ${k.statusText}`);return await k.json()},[]),y=z.useCallback(async p=>{if(n[p]){Q(n[p]),e(p),g.onCircuitJsonPathChange?.(p);return}if(c.has(p)){console.warn(`Skipping failed file: ${p}`),Q(null);return}if(!r.has(p)){a(k=>new Set(k).add(p)),E(!0),Q(null);try{const k=l.find(x=>x.filePath===p);if(!k)throw new Error(`File reference not found for ${p}`);const R=await(g.onFetchFile||d)(k);s(x=>({...x,[p]:R})),Q(R),e(p),g.onCircuitJsonPathChange?.(p),h(x=>{const N=new Set(x);return N.delete(p),N})}catch(k){console.error(`Failed to load circuit JSON file ${p}:`,k),h(S=>new Set(S).add(p)),Q(null)}finally{a(k=>{const S=new Set(k);return S.delete(p),S}),E(!1)}}},[l,n,r,c,g.onFetchFile,g.onCircuitJsonPathChange,d,e]);z.useEffect(()=>{if(D.length===0||t)return;let p=A;(!p||!D.includes(p))&&(p=K3I(D)??D[0],I(p)),p&&D.includes(p)&&y(p)},[A,t]);const w=z.useCallback(p=>{B(),I(p)},[B]),u=z.useCallback(p=>{h(k=>{const S=new Set(k);return S.delete(p),S}),y(p)},[y]);if(D.length===0)return T.jsx("div",{className:"rf-flex rf-flex-col rf-w-full rf-h-full rf-items-center rf-justify-center",children:T.jsxs("div",{className:"rf-text-center rf-p-8",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-2",children:"No Circuit JSON Files Found"}),T.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Please provide circuit JSON files to view."})]})});if(t)return T.jsx(WNo,{files:l,projectName:g.projectName,onSelectFile:w,onClose:B});const G=D.length>1?T.jsxs(T.Fragment,{children:[T.jsx(bNo,{currentFile:A,files:D,onFileChange:w}),T.jsx(si,{type:"button",variant:"outline",size:"icon",className:"rf-shrink-0",onClick:o,"aria-label":`Browse all ${D.length} circuits as a gallery`,title:"Open circuit gallery",children:T.jsx(nxI,{className:"rf-h-4 rf-w-4"})})]}):null,m=c.has(A);return T.jsx(GS,{fallbackRender:({error:p})=>T.jsx("div",{className:"rf-mt-4 rf-mx-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:T.jsxs("div",{className:"rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Circuit JSON Preview"}),T.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:VNo(p)})]})}),children:m?T.jsxs("div",{className:"rf-w-full rf-h-full rf-flex rf-flex-col",children:[T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-min-w-0 rf-w-full rf-p-4 rf-border-b rf-border-gray-200",children:[(g.showFileMenu??!0)&&T.jsx(YpA,{isWebEmbedded:!0,circuitJson:null,projectName:g.projectName}),D.length>1&&T.jsx("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-items-center rf-gap-2",children:G})]}),T.jsx("div",{className:"rf-flex-1 rf-flex rf-items-center rf-justify-center",children:T.jsxs("div",{className:"rf-text-center rf-p-8",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-600 rf-mb-2",children:"Failed to Load Circuit File"}),T.jsxs("p",{className:"rf-text-sm rf-text-gray-600 rf-mb-4",children:["Could not load: ",A]}),T.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-2",children:[T.jsx("button",{onClick:()=>u(A),className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600",children:"Retry"}),D.length>1&&T.jsx("p",{className:"rf-text-xs rf-text-gray-500",children:"Or select a different file from the dropdown above"})]})]})})]}):T.jsx(UKI,{extraTabs:mtg(g.extraTabs,A),circuitJson:C,defaultToFullScreen:g.defaultToFullScreen,showToggleFullScreen:g.showToggleFullScreen,showFileMenu:!1,isWebEmbedded:!1,projectName:g.projectName,defaultActiveTab:g.tabSelected,leftHeaderContent:T.jsxs("div",{className:"rf-flex rf-min-w-0 rf-w-full rf-items-center rf-gap-2",children:[(g.showFileMenu??!0)&&T.jsx(YpA,{isWebEmbedded:!0,circuitJson:C,projectName:g.projectName}),D.length>1&&T.jsx("div",{className:`rf-flex rf-min-w-0 rf-flex-1 rf-items-center rf-gap-2 ${i?"rf-opacity-50":""}`,children:G})]})})})},zNo=()=>{const g=Kc(A=>A.fsMap);z.useEffect(()=>{if(!document||!g)return;const A=Array.from(g.keys()),I=K3I(A),e=g.get("package.json");try{if(e){const t=JSON.parse(e);if(t?.name){document.title=t.name;return}}}catch{}I&&(document.title=I)},[g])},y3I=(g,A,I)=>{const e=g instanceof RegExp?w3I(g,I):g,t=A instanceof RegExp?w3I(A,I):A,o=e!==null&&t!=null&&XNo(e,t,I);return o&&{start:o[0],end:o[1],pre:I.slice(0,o[0]),body:I.slice(o[0]+e.length,o[1]),post:I.slice(o[1]+t.length)}},w3I=(g,A)=>{const I=A.match(g);return I?I[0]:null},XNo=(g,A,I)=>{let e,t,o,B,C,Q=I.indexOf(g),i=I.indexOf(A,Q+1),E=Q;if(Q>=0&&i>0){if(g===A)return[Q,i];for(e=[],o=I.length;E>=0&&!C;){if(E===Q)e.push(E),Q=I.indexOf(g,E+1);else if(e.length===1){const n=e.pop();n!==void 0&&(C=[n,i])}else t=e.pop(),t!==void 0&&t<o&&(o=t,B=i),i=I.indexOf(A,E+1);E=Q<i&&Q>=0?Q:i}e.length&&B!==void 0&&(C=[o,B])}return C},u3I="\0SLASH"+Math.random()+"\0",G3I="\0OPEN"+Math.random()+"\0",zQg="\0CLOSE"+Math.random()+"\0",m3I="\0COMMA"+Math.random()+"\0",p3I="\0PERIOD"+Math.random()+"\0",$No=new RegExp(u3I,"g"),A1o=new RegExp(G3I,"g"),g1o=new RegExp(zQg,"g"),I1o=new RegExp(m3I,"g"),e1o=new RegExp(p3I,"g"),t1o=/\\\\/g,o1o=/\\{/g,B1o=/\\}/g,C1o=/\\,/g,Q1o=/\\\./g,i1o=1e5,E1o=4e6,n1o=1e3,s1o=1e3;function XQg(g){return isNaN(g)?g.charCodeAt(0):parseInt(g,10)}function a1o(g){return g.replace(t1o,u3I).replace(o1o,G3I).replace(B1o,zQg).replace(C1o,m3I).replace(Q1o,p3I)}function r1o(g){return g.replace($No,"\\").replace(A1o,"{").replace(g1o,"}").replace(I1o,",").replace(e1o,".")}function $Qg(g,A){for(let I=0;I<A.length;I++)g.push(A[I])}function c1o(g){const A=[];let I="";for(;;){const e=y3I("{","}",g);if(!e){const Q=g.split(",");return Q[0]=I+Q[0],$Qg(A,Q),A}const{pre:t,body:o,post:B}=e,C=t.split(",");if(C[0]=I+C[0],C[C.length-1]+="{"+o+"}",!B.length)return $Qg(A,C),A;I=C.pop(),$Qg(A,C),g=B}}function h1o(g,A={}){if(!g)return[];const{max:I=i1o,maxLength:e=E1o,maxDepth:t=n1o,maxRewrites:o=s1o}=A;return g.slice(0,2)==="{}"&&(g="\\{\\}"+g.slice(2)),Aig(a1o(g),I,e,t,0,o,!0).map(r1o)}function l1o(g){return"{"+g+"}"}function D1o(g){return/^-?0\d/.test(g)}function d1o(g,A){return g<=A}function y1o(g,A){return g>=A}function FoA(g,A,I,e,t,o){const B=[];let C=0;for(let Q=0;Q<g.length;Q++)for(let i=0;i<I.length;i++){if(B.length>=e)return B;const E=g[Q]+A+I[i];if(!(o&&!E)){if(C+E.length>t)return B;B.push(E),C+=E.length}}return B}function w1o(g,A,I,e){const t=g.split(/\.\./),o=[];if(t[0]===void 0||t[1]===void 0)return o;const B=XQg(t[0]),C=XQg(t[1]),Q=Math.max(t[0].length,t[1].length);let i=t.length===3&&t[2]!==void 0?Math.max(Math.abs(XQg(t[2])),1):1,E=d1o;C<B&&(i*=-1,E=y1o);const s=t.some(D1o);let r=0;for(let a=B;E(a,C)&&o.length<I;a+=i){let c;if(A)c=String.fromCharCode(a),c==="\\"&&(c="");else if(c=String(a),s){const h=Q-c.length;if(h>0){const l=new Array(h+1).join("0");a<0?c="-"+l+c.slice(1):c=l+c}}if(r+c.length>e)break;o.push(c),r+=c.length}return o}function Aig(g,A,I,e,t,o,B){if(t>e)return[g];let C=[""],Q=0,i=!1,E=!0;for(;;){const n=y3I("{","}",g);if(!n)return FoA(C,g,[""],A,I,i);const s=n.pre;if(/\$$/.test(s)){if(C=FoA(C,s+"{"+n.body+"}",[""],A,I,i&&!n.post.length),E=!1,!n.post.length)break;g=n.post;continue}const r=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),c=r||a,h=n.body.indexOf(",")>=0;if(!c&&!h){if(Q<o&&n.post.match(/,(?!,).*\}/)){Q++,g=n.pre+"{"+n.body+zQg+n.post,B=!0;continue}return FoA(C,s+"{"+n.body+"}"+n.post,[""],A,I,i)}E&&(i=B&&!c,E=!1);let l;if(c)l=w1o(n.body,a,A,I);else{let D=c1o(n.body);if(D.length===1&&D[0]!==void 0&&(D=Aig(D[0],A,I,e,t+1,o,!1).map(l1o),D.length===1)){if(C=FoA(C,s+D[0],[""],A,I,i&&!n.post.length),!n.post.length)break;g=n.post;continue}let d=i&&!n.post.length&&!s;for(let w=0;d&&w<C.length;w++)C[w]&&(d=!1);l=[];let y=0;A:for(let w=0;w<D.length;w++){const u=Aig(D[w],A,I,e,t+1,o,!1);for(let G=0;G<u.length;G++){const m=u[G];if(!(d&&!m)){if(l.length>=A||y+m.length>I)break A;l.push(m),y+=m.length}}}}if(C=FoA(C,s,l,A,I,i&&!n.post.length),!n.post.length)break;g=n.post}return C}const u1o=1024*64,VpA=g=>{if(typeof g!="string")throw new TypeError("invalid pattern");if(g.length>u1o)throw new TypeError("pattern is too long")},G1o={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},UoA=g=>g.replace(/[[\]\\-]/g,"\\$&"),m1o=g=>g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),k3I=g=>g.join(""),p1o=(g,A)=>{const I=A;if(g.charAt(I)!=="[")throw new Error("not in a brace expression");const e=[],t=[];let o=I+1,B=!1,C=!1,Q=!1,i=!1,E=I,n="";A:for(;o<g.length;){const c=g.charAt(o);if((c==="!"||c==="^")&&o===I+1){i=!0,o++;continue}if(c==="]"&&B&&!Q){E=o+1;break}if(B=!0,c==="\\"&&!Q){Q=!0,o++;continue}if(c==="["&&!Q){for(const[h,[l,D,d]]of Object.entries(G1o))if(g.startsWith(h,o)){if(n)return["$.",!1,g.length-I,!0];o+=h.length,d?t.push(l):e.push(l),C=C||D;continue A}}if(Q=!1,n){c>n?e.push(UoA(n)+"-"+UoA(c)):c===n&&e.push(UoA(c)),n="",o++;continue}if(g.startsWith("-]",o+1)){e.push(UoA(c+"-")),o+=2;continue}if(g.startsWith("-",o+1)){n=c,o+=2;continue}e.push(UoA(c)),o++}if(E<o)return["",!1,0,!1];if(!e.length&&!t.length)return["$.",!1,g.length-I,!0];if(t.length===0&&e.length===1&&/^\\?.$/.test(e[0])&&!i){const c=e[0].length===2?e[0].slice(-1):e[0];return[m1o(c),!1,E-I,!1]}const s="["+(i?"^":"")+k3I(e)+"]",r="["+(i?"":"^")+k3I(t)+"]";return[e.length&&t.length?"("+s+"|"+r+")":e.length?s:r,C,E-I,!0]},JoA=(g,{windowsPathsNoEscape:A=!1,magicalBraces:I=!0}={})=>I?A?g.replace(/\[([^/\\])\]/g,"$1"):g.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):A?g.replace(/\[([^/\\{}])\]/g,"$1"):g.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var vk;const k1o=new Set(["!","?","+","*","@"]),gig=g=>k1o.has(g),M3I=g=>gig(g.type),M1o=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),S1o=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),f1o=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),S3I=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),R1o="(?!(?:^|/)\\.\\.?(?:$|/))",jpA="(?!\\.)",N1o=new Set(["[","."]),x1o=new Set(["..","."]),F1o=new Set("().*{}+?[]^$\\!"),U1o=g=>g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Iig="[^/]",f3I=Iig+"*?",R3I=Iig+"+?";let J1o=0;class eig{type;#e;#I;#t=!1;#g=[];#A;#B;#o;#i=!1;#C;#E;#s=!1;id=++J1o;get depth(){return(this.#A?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#A?.id,depth:this.depth,partsLength:this.#g.length,parts:this.#g}}constructor(A,I,e={}){this.type=A,A&&(this.#I=!0),this.#A=I,this.#e=this.#A?this.#A.#e:this,this.#C=this.#e===this?e:this.#e.#C,this.#o=this.#e===this?[]:this.#e.#o,A==="!"&&!this.#e.#i&&this.#o.push(this),this.#B=this.#A?this.#A.#g.length:0}get hasMagic(){if(this.#I!==void 0)return this.#I;for(const A of this.#g)if(typeof A!="string"&&(A.type||A.hasMagic))return this.#I=!0;return this.#I}toString(){return this.#E!==void 0?this.#E:this.type?this.#E=this.type+"("+this.#g.map(A=>String(A)).join("|")+")":this.#E=this.#g.map(A=>String(A)).join("")}#a(){if(this!==this.#e)throw new Error("should only call on root");if(this.#i)return this;this.toString(),this.#i=!0;let A;for(;A=this.#o.pop();){if(A.type!=="!")continue;let I=A,e=I.#A;for(;e;){for(let t=I.#B+1;!e.type&&t<e.#g.length;t++)for(const o of A.#g){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(e.#g[t])}I=e,e=I.#A}}return this}push(...A){for(const I of A)if(I!==""){if(typeof I!="string"&&!(I instanceof vk&&I.#A===this))throw new Error("invalid part: "+I);this.#g.push(I)}}toJSON(){const A=this.type===null?this.#g.slice().map(I=>typeof I=="string"?I:I.toJSON()):[this.type,...this.#g.map(I=>I.toJSON())];return this.isStart()&&!this.type&&A.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#i&&this.#A?.type==="!")&&A.push({}),A}isStart(){if(this.#e===this)return!0;if(!this.#A?.isStart())return!1;if(this.#B===0)return!0;const A=this.#A;for(let I=0;I<this.#B;I++){const e=A.#g[I];if(!(e instanceof vk&&e.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#A?.type==="!")return!0;if(!this.#A?.isEnd())return!1;if(!this.type)return this.#A?.isEnd();const A=this.#A?this.#A.#g.length:0;return this.#B===A-1}copyIn(A){typeof A=="string"?this.push(A):this.push(A.clone(this))}clone(A){const I=new vk(this.type,A);for(const e of this.#g)I.copyIn(e);return I}static#Q(A,I,e,t,o){const B=t.maxExtglobRecursion??2;let C=!1,Q=!1,i=-1,E=!1;if(I.type===null){let c=e,h="";for(;c<A.length;){const l=A.charAt(c++);if(C||l==="\\"){C=!C,h+=l;continue}if(Q){c===i+1?(l==="^"||l==="!")&&(E=!0):l==="]"&&!(c===i+2&&E)&&(Q=!1),h+=l;continue}else if(l==="["){Q=!0,i=c,E=!1,h+=l;continue}if(!t.noext&&gig(l)&&A.charAt(c)==="("&&o<=B){I.push(h),h="";const d=new vk(l,I);c=vk.#Q(A,d,c,t,o+1),I.push(d);continue}h+=l}return I.push(h),c}let n=e+1,s=new vk(null,I);const r=[];let a="";for(;n<A.length;){const c=A.charAt(n++);if(C||c==="\\"){C=!C,a+=c;continue}if(Q){n===i+1?(c==="^"||c==="!")&&(E=!0):c==="]"&&!(n===i+2&&E)&&(Q=!1),a+=c;continue}else if(c==="["){Q=!0,i=n,E=!1,a+=c;continue}if(!t.noext&&gig(c)&&A.charAt(n)==="("&&(o<=B||I&&I.#n(c))){const l=I&&I.#n(c)?0:1;s.push(a),a="";const D=new vk(c,s);s.push(D),n=vk.#Q(A,D,n,t,o+l);continue}if(c==="|"){s.push(a),a="",r.push(s),s=new vk(null,I);continue}if(c===")")return a===""&&I.#g.length===0&&(I.#s=!0),s.push(a),a="",I.push(...r,s),n;a+=c}return I.type=null,I.#I=void 0,I.#g=[A.substring(e-1)],n}#h(A){return this.#l(A,S1o)}#l(A,I=M1o){if(!A||typeof A!="object"||A.type!==null||A.#g.length!==1||this.type===null)return!1;const e=A.#g[0];return!e||typeof e!="object"||e.type===null?!1:this.#n(e.type,I)}#n(A,I=f1o){return!!I.get(this.type)?.includes(A)}#r(A,I){const e=A.#g[0],t=new vk(null,e,this.options);t.#g.push(""),e.push(t),this.#c(A,I)}#c(A,I){const e=A.#g[0];this.#g.splice(I,1,...e.#g);for(const t of e.#g)typeof t=="object"&&(t.#A=this);this.#E=void 0}#y(A){return!!S3I.get(this.type)?.has(A)}#w(A){if(!A||typeof A!="object"||A.type!==null||A.#g.length!==1||this.type===null||this.#g.length!==1)return!1;const I=A.#g[0];return!I||typeof I!="object"||I.type===null?!1:this.#y(I.type)}#u(A){const I=S3I.get(this.type),e=A.#g[0],t=I?.get(e.type);if(!t)return!1;this.#g=e.#g;for(const o of this.#g)typeof o=="object"&&(o.#A=this);this.type=t,this.#E=void 0,this.#s=!1}static fromGlob(A,I={}){const e=new vk(null,void 0,I);return vk.#Q(A,e,0,I,0),e}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();const A=this.toString(),[I,e,t,o]=this.toRegExpSource();if(!(t||this.#I||this.#C.nocase&&!this.#C.nocaseMagicOnly&&A.toUpperCase()!==A.toLowerCase()))return e;const C=(this.#C.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${I}$`,C),{_src:I,_glob:A})}get options(){return this.#C}toRegExpSource(A){const I=A??!!this.#C.dot;if(this.#e===this&&(this.#D(),this.#a()),!M3I(this)){const Q=this.isStart()&&this.isEnd()&&!this.#g.some(r=>typeof r!="string"),i=this.#g.map(r=>{const[a,c,h,l]=typeof r=="string"?vk.#G(r,this.#I,Q):r.toRegExpSource(A);return this.#I=this.#I||h,this.#t=this.#t||l,a}).join("");let E="";if(this.isStart()&&typeof this.#g[0]=="string"&&!(this.#g.length===1&&x1o.has(this.#g[0]))){const a=N1o,c=I&&a.has(i.charAt(0))||i.startsWith("\\.")&&a.has(i.charAt(2))||i.startsWith("\\.\\.")&&a.has(i.charAt(4)),h=!I&&!A&&a.has(i.charAt(0));E=c?R1o:h?jpA:""}let n="";return this.isEnd()&&this.#e.#i&&this.#A?.type==="!"&&(n="(?:$|\\/)"),[E+i+n,JoA(i),this.#I=!!this.#I,this.#t]}const e=this.type==="*"||this.type==="+",t=this.type==="!"?"(?:(?!(?:":"(?:";let o=this.#d(I);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){const Q=this.toString(),i=this;return i.#g=[Q],i.type=null,i.#I=void 0,[Q,JoA(this.toString()),!1,!1]}let B=!e||A||I||!jpA?"":this.#d(!0);B===o&&(B=""),B&&(o=`(?:${o})(?:${B})*?`);let C="";if(this.type==="!"&&this.#s)C=(this.isStart()&&!I?jpA:"")+R3I;else{const Q=this.type==="!"?"))"+(this.isStart()&&!I&&!A?jpA:"")+f3I+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&B?")":this.type==="*"&&B?")?":`)${this.type}`;C=t+o+Q}return[C,JoA(o),this.#I=!!this.#I,this.#t]}#D(){if(M3I(this)){let A=0,I=!1;do{I=!0;for(let e=0;e<this.#g.length;e++){const t=this.#g[e];typeof t=="object"&&(t.#D(),this.#l(t)?(I=!1,this.#c(t,e)):this.#h(t)?(I=!1,this.#r(t,e)):this.#w(t)&&(I=!1,this.#u(t)))}}while(!I&&++A<10)}else for(const A of this.#g)typeof A=="object"&&A.#D();this.#E=void 0}#d(A){return this.#g.map(I=>{if(typeof I=="string")throw new Error("string type in extglob ast??");const[e,t,o,B]=I.toRegExpSource(A);return this.#t=this.#t||B,e}).filter(I=>!(this.isStart()&&this.isEnd())||!!I).join("|")}static#G(A,I,e=!1){let t=!1,o="",B=!1,C=!1;for(let Q=0;Q<A.length;Q++){const i=A.charAt(Q);if(t){t=!1,o+=(F1o.has(i)?"\\":"")+i;continue}if(i==="*"){if(C)continue;C=!0,o+=e&&/^[*]+$/.test(A)?R3I:f3I,I=!0;continue}else C=!1;if(i==="\\"){Q===A.length-1?o+="\\\\":t=!0;continue}if(i==="["){const[E,n,s,r]=p1o(A,Q);if(s){o+=E,B=B||n,Q+=s-1,I=I||r;continue}}if(i==="?"){o+=Iig,I=!0;continue}o+=U1o(i)}return[o,JoA(A),!!I,B]}}vk=eig;const P1o=(g,{windowsPathsNoEscape:A=!1,magicalBraces:I=!1}={})=>I?A?g.replace(/[?*()[\]{}]/g,"[$&]"):g.replace(/[?*()[\]\\{}]/g,"\\$&"):A?g.replace(/[?*()[\]]/g,"[$&]"):g.replace(/[?*()[\]\\]/g,"\\$&");var OO={env:{}};const zm=(g,A,I={})=>(VpA(A),!I.nocomment&&A.charAt(0)==="#"?!1:new PoA(A,I).match(g)),K1o=/^\*+([^+@!?*[(]*)$/,L1o=g=>A=>!A.startsWith(".")&&A.endsWith(g),Y1o=g=>A=>A.endsWith(g),_1o=g=>(g=g.toLowerCase(),A=>!A.startsWith(".")&&A.toLowerCase().endsWith(g)),b1o=g=>(g=g.toLowerCase(),A=>A.toLowerCase().endsWith(g)),H1o=/^\*+\.\*+$/,v1o=g=>!g.startsWith(".")&&g.includes("."),T1o=g=>g!=="."&&g!==".."&&g.includes("."),q1o=/^\.\*+$/,Z1o=g=>g!=="."&&g!==".."&&g.startsWith("."),O1o=/^\*+$/,W1o=g=>g.length!==0&&!g.startsWith("."),V1o=g=>g.length!==0&&g!=="."&&g!=="..",j1o=/^\?+([^+@!?*[(]*)?$/,z1o=([g,A=""])=>{const I=N3I([g]);return A?(A=A.toLowerCase(),e=>I(e)&&e.toLowerCase().endsWith(A)):I},X1o=([g,A=""])=>{const I=x3I([g]);return A?(A=A.toLowerCase(),e=>I(e)&&e.toLowerCase().endsWith(A)):I},$1o=([g,A=""])=>{const I=x3I([g]);return A?e=>I(e)&&e.endsWith(A):I},Axo=([g,A=""])=>{const I=N3I([g]);return A?e=>I(e)&&e.endsWith(A):I},N3I=([g])=>{const A=g.length;return I=>I.length===A&&!I.startsWith(".")},x3I=([g])=>{const A=g.length;return I=>I.length===A&&I!=="."&&I!==".."},F3I=typeof OO=="object"&&OO?typeof OO.env=="object"&&OO.env&&OO.env.__MINIMATCH_TESTING_PLATFORM__||OO.platform:"posix",U3I={win32:{sep:"\\"},posix:{sep:"/"}},gxo=F3I==="win32"?U3I.win32.sep:U3I.posix.sep;zm.sep=gxo;const mG=Symbol("globstar **");zm.GLOBSTAR=mG;const Ixo="[^/]"+"*?",exo="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",txo="(?:(?!(?:\\/|^)\\.).)*?",oxo=(g,A={})=>I=>zm(I,g,A);zm.filter=oxo;const uf=(g,A={})=>Object.assign({},g,A),Bxo=g=>{if(!g||typeof g!="object"||!Object.keys(g).length)return zm;const A=zm;return Object.assign((e,t,o={})=>A(e,t,uf(g,o)),{Minimatch:class extends A.Minimatch{constructor(t,o={}){super(t,uf(g,o))}static defaults(t){return A.defaults(uf(g,t)).Minimatch}},AST:class extends A.AST{constructor(t,o,B={}){super(t,o,uf(g,B))}static fromGlob(t,o={}){return A.AST.fromGlob(t,uf(g,o))}},unescape:(e,t={})=>A.unescape(e,uf(g,t)),escape:(e,t={})=>A.escape(e,uf(g,t)),filter:(e,t={})=>A.filter(e,uf(g,t)),defaults:e=>A.defaults(uf(g,e)),makeRe:(e,t={})=>A.makeRe(e,uf(g,t)),braceExpand:(e,t={})=>A.braceExpand(e,uf(g,t)),match:(e,t,o={})=>A.match(e,t,uf(g,o)),sep:A.sep,GLOBSTAR:mG})};zm.defaults=Bxo;const J3I=(g,A={})=>(VpA(g),A.nobrace||!/\{(?:(?!\{).)*\}/.test(g)?[g]:h1o(g,{max:A.braceExpandMax}));zm.braceExpand=J3I;const Cxo=(g,A={})=>new PoA(g,A).makeRe();zm.makeRe=Cxo;const Qxo=(g,A,I={})=>{const e=new PoA(A,I);return g=g.filter(t=>e.match(t)),e.options.nonull&&!g.length&&g.push(A),g};zm.match=Qxo;const P3I=/[?*]|[+@!]\(.*?\)|\[|\]/,ixo=g=>g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class PoA{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(A,I={}){VpA(A),I=I||{},this.options=I,this.maxGlobstarRecursion=I.maxGlobstarRecursion??200,this.pattern=A,this.platform=I.platform||F3I,this.isWindows=this.platform==="win32";const e="allowWindowsEscape";this.windowsPathsNoEscape=!!I.windowsPathsNoEscape||I[e]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!I.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!I.nonegate,this.comment=!1,this.empty=!1,this.partial=!!I.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=I.windowsNoMagicRoot!==void 0?I.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(const A of this.set)for(const I of A)if(typeof I!="string")return!0;return!1}debug(...A){}make(){const A=this.pattern,I=this.options;if(!I.nocomment&&A.charAt(0)==="#"){this.comment=!0;return}if(!A){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],I.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);const e=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(e),this.debug(this.pattern,this.globParts);let t=this.globParts.map((o,B,C)=>{if(this.isWindows&&this.windowsNoMagicRoot){const Q=o[0]===""&&o[1]===""&&(o[2]==="?"||!P3I.test(o[2]))&&!P3I.test(o[3]),i=/^[a-z]:/i.test(o[0]);if(Q)return[...o.slice(0,4),...o.slice(4).map(E=>this.parse(E))];if(i)return[o[0],...o.slice(1).map(E=>this.parse(E))]}return o.map(Q=>this.parse(Q))});if(this.debug(this.pattern,t),this.set=t.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){const B=this.set[o];B[0]===""&&B[1]===""&&this.globParts[o][2]==="?"&&typeof B[3]=="string"&&/^[a-z]:$/i.test(B[3])&&(B[2]="?")}this.debug(this.pattern,this.set)}preprocess(A){if(this.options.noglobstar)for(const e of A)for(let t=0;t<e.length;t++)e[t]==="**"&&(e[t]="*");const{optimizationLevel:I=1}=this.options;return I>=2?(A=this.firstPhasePreProcess(A),A=this.secondPhasePreProcess(A)):I>=1?A=this.levelOneOptimize(A):A=this.adjascentGlobstarOptimize(A),A}adjascentGlobstarOptimize(A){return A.map(I=>{let e=-1;for(;(e=I.indexOf("**",e+1))!==-1;){let t=e;for(;I[t+1]==="**";)t++;t!==e&&I.splice(e,t-e)}return I})}levelOneOptimize(A){return A.map(I=>(I=I.reduce((e,t)=>{const o=e[e.length-1];return t==="**"&&o==="**"?e:t===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(e.pop(),e):(e.push(t),e)},[]),I.length===0?[""]:I))}levelTwoFileOptimize(A){Array.isArray(A)||(A=this.slashSplit(A));let I=!1;do{if(I=!1,!this.preserveMultipleSlashes){for(let t=1;t<A.length-1;t++){const o=A[t];t===1&&o===""&&A[0]===""||(o==="."||o==="")&&(I=!0,A.splice(t,1),t--)}A[0]==="."&&A.length===2&&(A[1]==="."||A[1]==="")&&(I=!0,A.pop())}let e=0;for(;(e=A.indexOf("..",e+1))!==-1;){const t=A[e-1];t&&t!=="."&&t!==".."&&t!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(t))&&(I=!0,A.splice(e-1,2),e-=2)}}while(I);return A.length===0?[""]:A}firstPhasePreProcess(A){let I=!1;do{I=!1;for(let e of A){let t=-1;for(;(t=e.indexOf("**",t+1))!==-1;){let B=t;for(;e[B+1]==="**";)B++;B>t&&e.splice(t+1,B-t);let C=e[t+1];const Q=e[t+2],i=e[t+3];if(C!==".."||!Q||Q==="."||Q===".."||!i||i==="."||i==="..")continue;I=!0,e.splice(t,1);const E=e.slice(0);E[t]="**",A.push(E),t--}if(!this.preserveMultipleSlashes){for(let B=1;B<e.length-1;B++){const C=e[B];B===1&&C===""&&e[0]===""||(C==="."||C==="")&&(I=!0,e.splice(B,1),B--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(I=!0,e.pop())}let o=0;for(;(o=e.indexOf("..",o+1))!==-1;){const B=e[o-1];if(B&&B!=="."&&B!==".."&&B!=="**"){I=!0;const Q=o===1&&e[o+1]==="**"?["."]:[];e.splice(o-1,2,...Q),e.length===0&&e.push(""),o-=2}}}}while(I);return A}secondPhasePreProcess(A){for(let I=0;I<A.length-1;I++)for(let e=I+1;e<A.length;e++){const t=this.partsMatch(A[I],A[e],!this.preserveMultipleSlashes);if(t){A[I]=[],A[e]=t;break}}return A.filter(I=>I.length)}partsMatch(A,I,e=!1){let t=0,o=0,B=[],C="";for(;t<A.length&&o<I.length;)if(A[t]===I[o])B.push(C==="b"?I[o]:A[t]),t++,o++;else if(e&&A[t]==="**"&&I[o]===A[t+1])B.push(A[t]),t++;else if(e&&I[o]==="**"&&A[t]===I[o+1])B.push(I[o]),o++;else if(A[t]==="*"&&I[o]&&(this.options.dot||!I[o].startsWith("."))&&I[o]!=="**"){if(C==="b")return!1;C="a",B.push(A[t]),t++,o++}else if(I[o]==="*"&&A[t]&&(this.options.dot||!A[t].startsWith("."))&&A[t]!=="**"){if(C==="a")return!1;C="b",B.push(I[o]),t++,o++}else return!1;return A.length===I.length&&B}parseNegate(){if(this.nonegate)return;const A=this.pattern;let I=!1,e=0;for(let t=0;t<A.length&&A.charAt(t)==="!";t++)I=!I,e++;e&&(this.pattern=A.slice(e)),this.negate=I}matchOne(A,I,e=!1){let t=0,o=0;if(this.isWindows){const C=typeof A[0]=="string"&&/^[a-z]:$/i.test(A[0]),Q=!C&&A[0]===""&&A[1]===""&&A[2]==="?"&&/^[a-z]:$/i.test(A[3]),i=typeof I[0]=="string"&&/^[a-z]:$/i.test(I[0]),E=!i&&I[0]===""&&I[1]===""&&I[2]==="?"&&typeof I[3]=="string"&&/^[a-z]:$/i.test(I[3]),n=Q?3:C?0:void 0,s=E?3:i?0:void 0;if(typeof n=="number"&&typeof s=="number"){const[r,a]=[A[n],I[s]];r.toLowerCase()===a.toLowerCase()&&(I[s]=r,o=s,t=n)}}const{optimizationLevel:B=1}=this.options;return B>=2&&(A=this.levelTwoFileOptimize(A)),I.includes(mG)?this.#e(A,I,e,t,o):this.#t(A,I,e,t,o)}#e(A,I,e,t,o){const B=I.indexOf(mG,o),C=I.lastIndexOf(mG),[Q,i,E]=e?[I.slice(o,B),I.slice(B+1),[]]:[I.slice(o,B),I.slice(B+1,C),I.slice(C+1)];if(Q.length){const D=A.slice(t,t+Q.length);if(!this.#t(D,Q,e,0,0))return!1;t+=Q.length,o+=Q.length}let n=0;if(E.length){if(E.length+t>A.length)return!1;let D=A.length-E.length;if(this.#t(A,E,e,D,0))n=E.length;else{if(A[A.length-1]!==""||t+E.length===A.length||(D--,!this.#t(A,E,e,D,0)))return!1;n=E.length+1}}if(!i.length){let D=!!n;for(let d=t;d<A.length-n;d++){const y=String(A[d]);if(D=!0,y==="."||y===".."||!this.options.dot&&y.startsWith("."))return!1}return e||D}const s=[[[],0]];let r=s[0],a=0;const c=[0];for(const D of i)D===mG?(c.push(a),r=[[],0],s.push(r)):(r[0].push(D),a++);let h=s.length-1;const l=A.length-n;for(const D of s)D[1]=l-(c[h--]+D[0].length);return!!this.#I(A,s,t,0,e,0,!!n)}#I(A,I,e,t,o,B,C){const Q=I[t];if(!Q){for(let n=e;n<A.length;n++){C=!0;const s=A[n];if(s==="."||s===".."||!this.options.dot&&s.startsWith("."))return!1}return C}const[i,E]=Q;for(;e<=E;){if(this.#t(A.slice(0,e+i.length),i,o,e,0)&&B<this.maxGlobstarRecursion){const r=this.#I(A,I,e+i.length,t+1,o,B+1,C);if(r!==!1)return r}const s=A[e];if(s==="."||s===".."||!this.options.dot&&s.startsWith("."))return!1;e++}return o||null}#t(A,I,e,t,o){let B,C,Q,i;for(B=t,C=o,i=A.length,Q=I.length;B<i&&C<Q;B++,C++){this.debug("matchOne loop");let E=I[C],n=A[B];if(this.debug(I,E,n),E===!1||E===mG)return!1;let s;if(typeof E=="string"?(s=n===E,this.debug("string match",E,n,s)):(s=E.test(n),this.debug("pattern match",E,n,s)),!s)return!1}if(B===i&&C===Q)return!0;if(B===i)return e;if(C===Q)return B===i-1&&A[B]==="";throw new Error("wtf?")}braceExpand(){return J3I(this.pattern,this.options)}parse(A){VpA(A);const I=this.options;if(A==="**")return mG;if(A==="")return"";let e,t=null;(e=A.match(O1o))?t=I.dot?V1o:W1o:(e=A.match(K1o))?t=(I.nocase?I.dot?b1o:_1o:I.dot?Y1o:L1o)(e[1]):(e=A.match(j1o))?t=(I.nocase?I.dot?X1o:z1o:I.dot?$1o:Axo)(e):(e=A.match(H1o))?t=I.dot?T1o:v1o:(e=A.match(q1o))&&(t=Z1o);const o=eig.fromGlob(A,this.options).toMMPattern();return t&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:t}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;const A=this.set;if(!A.length)return this.regexp=!1,this.regexp;const I=this.options,e=I.noglobstar?Ixo:I.dot?exo:txo,t=new Set(I.nocase?["i"]:[]);let o=A.map(Q=>{const i=Q.map(n=>{if(n instanceof RegExp)for(const s of n.flags.split(""))t.add(s);return typeof n=="string"?ixo(n):n===mG?mG:n._src});i.forEach((n,s)=>{const r=i[s+1],a=i[s-1];n!==mG||a===mG||(a===void 0?r!==void 0&&r!==mG?i[s+1]="(?:\\/|"+e+"\\/)?"+r:i[s]=e:r===void 0?i[s-1]=a+"(?:\\/|\\/"+e+")?":r!==mG&&(i[s-1]=a+"(?:\\/|\\/"+e+"\\/)"+r,i[s+1]=mG))});const E=i.filter(n=>n!==mG);if(this.partial&&E.length>=1){const n=[];for(let s=1;s<=E.length;s++)n.push(E.slice(0,s).join("/"));return"(?:"+n.join("|")+")"}return E.join("/")}).join("|");const[B,C]=A.length>1?["(?:",")"]:["",""];o="^"+B+o+C+"$",this.partial&&(o="^(?:\\/|"+B+o.slice(1,-1)+C+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...t].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(A){return this.preserveMultipleSlashes?A.split("/"):this.isWindows&&/^\/\/[^/]+/.test(A)?["",...A.split(/\/+/)]:A.split(/\/+/)}match(A,I=this.partial){if(this.debug("match",A,this.pattern),this.comment)return!1;if(this.empty)return A==="";if(A==="/"&&I)return!0;const e=this.options;this.isWindows&&(A=A.split("\\").join("/"));const t=this.slashSplit(A);this.debug(this.pattern,"split",t);const o=this.set;this.debug(this.pattern,"set",o);let B=t[t.length-1];if(!B)for(let C=t.length-2;!B&&C>=0;C--)B=t[C];for(const C of o){let Q=t;if(e.matchBase&&C.length===1&&(Q=[B]),this.matchOne(Q,C,I))return e.flipNegate?!0:!this.negate}return e.flipNegate?!1:this.negate}static defaults(A){return zm.defaults(A).Minimatch}}zm.AST=eig,zm.Minimatch=PoA,zm.escape=P1o,zm.unescape=JoA;const Exo=g=>(g.endsWith(".tsx")||g.endsWith(".ts")||g.endsWith(".jsx")||g.endsWith(".js")||MoA(g))&&!g.endsWith(".d.ts"),nxo=g=>{if(!g)return null;try{const A=JSON.parse(g);return Iie.parse(A)}catch(A){return console.warn("Failed to parse tscircuit.config.json",A),null}},sxo=(g,A)=>{const e=nxo(A)?.includeBoardFiles?.filter(Boolean);if(e&&e.length>0){const t=e.map(o=>new PoA(o,{dot:!0}));return g.filter(o=>t.some(B=>B.match(o)))}return g.filter(Exo)},tig=kE("run-frame:RunFrameWithApi"),axo=()=>{const A=!!Kc(e=>e.error),I=A?"Dev server disconnected":"Dev server connected";return T.jsx(NQg,{children:T.jsxs(xQg,{children:[T.jsx(FQg,{asChild:!0,children:T.jsx("button",{type:"button","aria-label":I,className:"rf-inline-flex rf-items-center rf-justify-center rf-p-2 rf-rounded-full rf-outline-none",children:T.jsx("span",{className:co("rf-inline-flex rf-size-2 rf-rounded-full rf-flex-shrink-0",A?"rf-bg-red-600":"rf-bg-green-600 rf-opacity-50"),"aria-hidden":"true"})})}),T.jsx(bpA,{side:"right",children:I})]})})},K3I=g=>g.find(A=>A.includes("entrypoint."))??g.find(A=>A.includes("index."))??g.find(A=>A.includes("main."))??g.find(A=>A.endsWith(".tsx")),rxo=g=>g.find(A=>A.includes("manual-edits."))??g.find(A=>A.includes("manual-edit."))??g.find(A=>A.endsWith(".json")),L3I=g=>{const{apiBaseUrl:A,leftHeaderContent:I}=g;z.useEffect(()=>{g.debug&&kE.enable("run-frame*")},[g.debug]);const e=Kc(x=>x.startPolling),t=Kc(x=>x.stopPolling),o=Kc(x=>x.setCurrentMainComponentPath),B=Kc(x=>x.pushEvent),C=Qrt(),Q=Kc(x=>x.fsMap),i=Kc(x=>x.recentlySavedFiles),E=z.useMemo(()=>Array.from(Q.keys()),[Q]),n=z.useMemo(()=>{const x=Q.get("tscircuit.config.json");return typeof x=="string"?x:void 0},[Q]),s=z.useMemo(()=>sxo(E,n),[E,n]),r=Kc(x=>x.circuitJson),[a,c]=z.useState(()=>typeof window>"u"?g.initialMainComponentPath??"":new URLSearchParams(window.location.hash.slice(1)).get("file")??g.initialMainComponentPath??""),[h,l]=gq("runframe:favorites",[]),D=!C,d=z.useCallback(x=>{l(N=>N.includes(x)?N.filter(U=>U!==x):[...N,x])},[l]),y=g.fileFilter??URo,w=z.useMemo(()=>s.filter(y),[s,y]);z.useEffect(()=>{if(a&&(w.includes(a)||s.includes(a)))return;if(a){const Y=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"",_=w.find(Z=>(Z.includes("/")?Z.substring(0,Z.lastIndexOf("/")):"")===Y);if(_){c(_);return}}const x=window?.TSCIRCUIT_DEFAULT_MAIN_COMPONENT_PATH,N=[g.initialMainComponentPath,x].filter(Y=>!!Y);for(const Y of N)if(w.includes(Y)){c(Y);return}const K=(w.length>0?w:s)[0];K&&c(K)},[w,s,g.initialMainComponentPath,a]);const u=z.useCallback(x=>{if(typeof window>"u")return;const N=new URLSearchParams(window.location.hash.slice(1));if(N.get("file")===x)return;N.set("file",x);const U=N.toString(),K=`${window.location.pathname}${window.location.search}${U.length>0?`#${U}`:""}`;window.history.replaceState(null,"",K)},[]);z.useEffect(()=>{a&&(u(a),g.onMainComponentPathChange?.(a),o(a))},[a,g.onMainComponentPathChange,u,o]),zNo();const{editEventsForRender:G,pushEditEvent:m,markRenderStarted:p,markRenderComplete:k}=Crt();z.useEffect(()=>{A&&(window.TSCIRCUIT_FILESERVER_API_BASE_URL=A)},[A]),z.useEffect(()=>(e(),()=>t()),[e,t]);const S=z.useMemo(()=>String(a).length>0?{mainComponentPath:a}:{},[a]),R=z.useCallback(async x=>{try{await B({event_type:"RUN_COMPLETED",initiator:"runframe",...x})}catch(N){tig("Failed to push RUN_COMPLETED event",N)}},[B]);return T.jsx(OKI,{extraTabs:mtg(g.extraTabs,a),fsMap:Q,showFileMenu:g.showFileMenu,shouldLoadLatestEval:g.shouldLoadLatestEval,onChangeShouldLoadLatestEval:g.onChangeShouldLoadLatestEval,isCli:g.isCli,schematicSvgOptions:g.schematicSvgOptions,isLoadingFiles:D,evalVersion:g.evalVersion,forceLatestEvalVersion:g.forceLatestEvalVersion,evalWebWorkerBlobUrl:g.evalWebWorkerBlobUrl??g.workerBlobUrl,platformConfig:g.platformConfig,enableFetchProxy:g.enableFetchProxy,leftHeaderContent:T.jsxs("div",{className:"rf-flex rf-min-w-0 rf-w-full rf-items-center rf-gap-2",children:[T.jsxs("div",{className:"rf-flex rf-shrink-0 rf-items-center rf-gap-2",children:[g.leftHeaderContent,T.jsx(axo,{})]}),g.showFilesSwitch&&T.jsx("div",{className:"rf-min-w-0 rf-flex-1",children:T.jsx(l3I,{currentFile:a,files:w,onFileChange:x=>{typeof Q.get(x)=="string"&&c(x)},pinnedFiles:h,onToggleFavorite:d,fileFilter:y,recentlySavedFiles:i})})]}),defaultToFullScreen:g.defaultToFullScreen,showToggleFullScreen:g.showToggleFullScreen,onInitialRender:()=>{tig("onInitialRender / markRenderStarted"),p()},onRenderFinished:()=>{tig("onRenderFinished / markRenderComplete"),k()},onRunCompleted:R,editEvents:G,onEditEvent:x=>{m(x),fetch(`${Jm}/events/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_type:"USER_CREATED_MANUAL_EDIT",...x})});const N=rxo(Array.from(Q.keys()))??"manual-edits.json",U=Q.get(N),K=JSON.parse(U??"{}");WVg({circuitJson:r,editEvents:[x],manualEditsFile:K}),fetch(`${Jm}/files/upsert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:N,text_content:JSON.stringify(K),initiator:"runframe"})})},onLoginRequired:g.onLoginRequired,easyEdaProxyConfig:{proxyEndpointUrl:`${Jm}/proxy`},...S})},Y3I="tscircuit:extra-runframe-tabs-change",_3I=()=>{if(typeof window>"u")return[];const g=window.TSCIRCUIT_EXTRA_RUNFRAME_TABS;return Array.isArray(g)?[...g]:[]};function cxo(){const[g,A]=z.useState(_3I);return z.useEffect(()=>{const I=()=>A(_3I());return window.addEventListener(Y3I,I),I(),()=>window.removeEventListener(Y3I,I)},[]),g}const hxo=()=>new Promise(g=>{document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>g()):g()}),lxo=()=>{const g=window.location.hash.slice(1),I=new URLSearchParams(g).get("tab")?.toLowerCase()?.trim();return I&&["pcb","schematic","cad"].includes(I)?I:"pcb"},Dxo=()=>{const g=document.getElementById("root");if(g)return g;const A=document.createElement("div");return A.id="root",A.style.height="100vh",document.body.appendChild(A),A},dxo=async()=>{const g=Array.from(document.querySelectorAll("script[type='tscircuit-tsx']")),A=new Map;return await Promise.all(g.map(async(I,e)=>{const t=I.dataset.path||I.getAttribute("data-file-path")||`script${e?e+1:""}.tsx`;if(I.src){const B=await(await fetch(I.src)).text();A.set(t,B)}else A.set(t,I.textContent||"")})),{fsMap:A}},b3I="<--INJECT_TSCIRCUIT_EVAL_WEB_WORKER_BLOB_URL-->",oig={evalWebWorkerBlobUrl:b3I.includes("<--")?void 0:b3I,enableFetchProxy:"<--INJECT_ENABLE_FETCH_PROXY-->".includes("<--")?void 0:!0};function yxo({staticFileList:g,defaultMainComponentPath:A,projectName:I,isCli:e,fsMap:t}){const o=cxo();return Array.isArray(g)?T.jsx(jNo,{files:g,initialCircuitPath:A,tabSelected:lxo(),projectName:I,extraTabs:o}):e?T.jsx(jRo,{...oig,extraTabs:o}):t.size>0?T.jsx(OKI,{...oig,fsMap:t,extraTabs:o}):T.jsx(L3I,{...oig,extraTabs:o})}(async()=>{await hxo();const g=bVI.createRoot(Dxo()),A=window.TSCIRCUIT_RUNFRAME_STATIC_FILE_LIST,I=window.TSCIRCUIT_DEFAULT_MAIN_COMPONENT_PATH,e=window.TSCIRCUIT_PACKAGE_NAME,t=window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI,{fsMap:o}=!Array.isArray(A)&&!t?await dxo():{fsMap:new Map};g.render(T.jsx(yxo,{staticFileList:A,defaultMainComponentPath:I,projectName:e,isCli:t,fsMap:o}))})();const Xb=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));var wxo=0,uF=class{_nodeId;hasExplicitNodeId;_sourceLocation;_dirty=!1;_parent;_revision=0;constructor(g={}){this.hasExplicitNodeId=g.nodeId!==void 0,this._nodeId=g.nodeId??H3I(g.sourceLocation,this.constructor.name)??`altium-node-${(++wxo).toString(36)}`,this._sourceLocation=g.sourceLocation}get document(){let g=this;for(;g.parent;)g=g.parent;return g}get nodeId(){return this._nodeId}get isDirty(){return this._dirty}get parent(){return this._parent}get revision(){return this._revision}get sourceLocation(){return this._sourceLocation}setParent(g){return this._parent=g,this}setSourceLocation(g){return this._sourceLocation=g,this.hasExplicitNodeId||(this._nodeId=H3I(g,this.constructor.name)??this._nodeId),this}adoptChildren(g){for(const A of g)A.setParent(this)}markDirty(){this._dirty=!0,this._revision++,this.parent?.markDirty()}clearDirty(g=!1){if(this._dirty=!1,g)for(const A of this.getChildren())A.clearDirty(!0)}*walk(g=!0){g&&(yield this);for(const A of this.getChildren())yield*A.walk(!0)}visit(g){const A=(I,e,t)=>{if(g(I,{depth:t,parent:e})!==!1)for(const B of I.getChildren())A(B,I,t+1)};A(this,this.parent,0)}findAll(g,A=!0){return[...this.walk(A)].filter(g)}deepEquals(g){if(this.type!==g.type||this.getString()!==g.getString())return!1;const A=this.getChildren(),I=g.getChildren();return A.length===I.length&&A.every((e,t)=>{const o=I[t];return o!==void 0&&e.deepEquals(o)})}getStructuralHash(){let g=2166136261;const A=`${this.type}\0${this.getString()}`;for(let I=0;I<A.length;I++)g^=A.charCodeAt(I),g=Math.imul(g,16777619);return(g>>>0).toString(16).padStart(8,"0")}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,text:this.getString(),children:this.getChildren().map(g=>g.toJSON())}}};function H3I(g,A){if(!g)return;const I=g.streamPath!==void 0?[g.streamPath,g.recordIndex??"",g.fieldIndex??"",g.byteOffset??""].join(":"):g.startOffset!==void 0?`text:${g.startOffset}`:g.byteOffset!==void 0?`byte:${g.byteOffset}`:void 0;return I===void 0?void 0:`${I}:${A}`}var $b=class extends Error{code;constructor(g,A="ALTIUM_ERROR",I){super(g,I),this.name=new.target.name,this.code=A}},_L=class extends $b{excerpt;fieldName;location;recordKind;constructor(g,A={}){super(g,"ALTIUM_SYNTAX",{cause:A.cause}),this.excerpt=A.excerpt,this.fieldName=A.fieldName,this.location=A.location,this.recordKind=A.recordKind}},tu=class extends $b{constructor(g,A){super(g,"ALTIUM_FORMAT_DETECTION",A)}},XQ=class extends $b{byteOffset;constructor(g,A={}){super(g,"ALTIUM_CORRUPT_CONTAINER",{cause:A.cause}),this.byteOffset=A.byteOffset}},uxo=class extends $b{constructor(g,A){super(g,"ALTIUM_UNSUPPORTED_VERSION",A)}},Big=class extends $b{constructor(g,A){super(g,"ALTIUM_UNSUPPORTED_FEATURE",A)}},Qc=class extends $b{constructor(g,A){super(g,"ALTIUM_SERIALIZATION",A)}},Nh=class extends $b{byteOffset;constructor(g,A,I){super(g,"ALTIUM_TRUNCATED_RECORD",I),this.byteOffset=A}},Gxo=class extends uF{type="embedded-model";index;record;stream;constructor(g){super({sourceLocation:g.stream.sourceLocation}),this.index=g.index,this.record=g.record,this.stream=g.stream}get compressedSize(){return this.stream.metadata.size}get isCompressedDataLoaded(){return this.stream.isContentLoaded}getCompressedBytes(){return this.stream.content.slice()}async getDecompressedBytes(g={}){return mxo(this.stream.content,g)}getChildren(){return[this.record,this.stream]}getString(){return this.record.getString()}};async function mxo(g,A={}){const I=A.maximumOutputSize??67108864;if(!Number.isSafeInteger(I)||I<=0)throw new RangeError("maximumOutputSize must be a positive safe integer number of bytes");const e=[];let t=0;try{const C=new McA(i=>{if(t+=i.byteLength,t>I)throw new XQ(`Embedded model expands beyond the ${I}-byte limit`);e.push(i)}),Q=64*1024;for(let i=0;i<g.byteLength;){const E=Math.min(i+Q,g.byteLength);C.push(g.subarray(i,E),E===g.byteLength),i=E}}catch(C){throw C instanceof XQ?C:new XQ(`Embedded model zlib decompression failed: ${C instanceof Error?C.message:String(C)}`)}const o=new Uint8Array(t);let B=0;for(const C of e)o.set(C,B),B+=C.byteLength;return o}function ou(g){if(!Number.isFinite(g))return g;const A=(g%360+360)%360;return Object.is(A,-0)?0:A}function Cig(g,A,I=1e-9){return Math.abs(g.x-A.x)<=I&&Math.abs(g.y-A.y)<=I}function pxo(g){if(g.length===0)return;let A=Number.POSITIVE_INFINITY,I=Number.POSITIVE_INFINITY,e=Number.NEGATIVE_INFINITY,t=Number.NEGATIVE_INFINITY;for(const o of g)!Number.isFinite(o.x)||!Number.isFinite(o.y)||(A=Math.min(A,o.x),I=Math.min(I,o.y),e=Math.max(e,o.x),t=Math.max(t,o.y));return Number.isFinite(A)?{minX:A,minY:I,maxX:e,maxY:t}:void 0}function kxo(g){if(g.length<3)return 0;let A=0;for(let I=0;I<g.length;I++){const e=g[I],t=g[(I+1)%g.length];!e||!t||(A+=e.x*t.y-t.x*e.y)}return A/2}function Mxo(g){const A=kxo(g);return Math.abs(A)<=Number.EPSILON?"degenerate":A<0?"clockwise":"counterclockwise"}var Qig=class extends uF{terminator;constructor(g={}){super(g),this.terminator=g.terminator??""}},cN=class extends uF{type="field";_key;_value;constructor(g){super(g),v3I(g.key),T3I(g.value??""),this._key=g.key,this._value=g.value??""}get key(){return this._key}set key(g){v3I(g),g!==this._key&&(this._key=g,this.markDirty())}get value(){return this._value}set value(g){T3I(g),g!==this._value&&(this._value=g,this.markDirty())}getChildren(){return[]}getString(){return`${this.key}=${this.value}`}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,key:this.key,value:this.value}}};function v3I(g){if(g.length===0||/[=|\r\n]/u.test(g))throw new Error(`Invalid Altium field key: ${JSON.stringify(g)}`)}function T3I(g){if(/[|\r\n]/u.test(g))throw new Error(`Altium field values cannot contain record delimiters: ${JSON.stringify(g)}`)}var Sxo={cm:1e4/25.4,in:1e3,inch:1e3,inches:1e3,mil:1,mils:1,mm:1e3/25.4},fxo=/^([+-]?(?:\d+\.\d*|\d+|\.\d+)(?:e[+-]?\d+)?)([a-z]+)?$/iu,KoA=class _OI{unit;value;#e;constructor(A){if(!Number.isFinite(A.value))throw new RangeError("Altium measurement value must be finite");this.value=A.value,this.unit=A.unit,this.#e=A.raw??`${xxo(A.value)}${A.unit===void 0?"":A.unit}`}static parse(A){const I=fxo.exec(A.trim());if(!I?.[1])return;const e=Number(I[1]);if(Number.isFinite(e))return new _OI({raw:A,unit:I[2],value:e})}get normalizedUnit(){return this.unit?.toLowerCase()}get raw(){return this.#e}toMils(){return this.normalizedUnit===void 0?this.value:this.value*(Sxo[this.normalizedUnit]??1)}toMillimeters(){return this.toMils()*.0254}to(A){const I=this.toMils();return A==="mil"?I:A==="mm"?I*.0254:A==="cm"?I*.00254:I/1e3}equals(A,I=0){return Math.abs(this.toMils()-A.toMils())<=I}toString(){return this.raw}toJSON(){return{raw:this.raw,unit:this.unit,value:this.value}}};function WO(g){return g===void 0?void 0:KoA.parse(g)}function LoA(g){return WO(g)?.toMils()}function Rxo(g,A="mil"){if(g instanceof KoA)return g;if(typeof g=="string"){const I=KoA.parse(g);if(!I)throw new TypeError(`Invalid Altium measurement ${JSON.stringify(g)}`);return I}return typeof g=="number"?new KoA({unit:A,value:g}):new KoA(g)}function Nxo(g,A="mil"){return Rxo(g,A).toString()}function xxo(g){return Object.is(g,-0)?"-0":String(g)}var vn=class extends Qig{type="record";items;_originalBinaryPayload;constructor(g={}){super(g),this.items=g.items??[],this._originalBinaryPayload=g.originalBinaryPayload?.slice(),this.adoptChildren(this.items)}get originalBinaryPayload(){return this._originalBinaryPayload?.slice()}setOriginalBinaryPayload(g){return this._originalBinaryPayload=g?.slice(),this}getAltiumMeasurement(g){return WO(this.getCaseInsensitive(g))}get recordKind(){return this.get("RECORD")}get fields(){return this.items.filter(g=>g instanceof cN)}get(g){return this.fields.find(A=>A.key===g)?.value}getCaseInsensitive(g){const A=g.toUpperCase();return this.fields.find(I=>I.key.toUpperCase()===A)?.value}getDecoded(g){const A=this.getCaseInsensitive(`%UTF8%${g}`);return A===void 0?this.getCaseInsensitive(g):Jxo(A)}getAll(g){return this.fields.filter(A=>A.key===g).map(A=>A.value)}getFirstField(g){return this.fields.find(A=>A.key===g)}getLastField(g){return this.fields.findLast(A=>A.key===g)}getAllFields(g){return this.fields.filter(A=>A.key===g)}getBoolean(g){const A=this.getCaseInsensitive(g)?.toUpperCase();if(A==="TRUE"||A==="T")return!0;if(A==="FALSE"||A==="F")return!1}getNumber(g){const A=this.getCaseInsensitive(g);if(!(A===void 0||!Fxo(A)))return Number(A)}getMeasurement(g){const A=this.getCaseInsensitive(g);if(A===void 0)return;const I=/^\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)\s*([a-z]+)?\s*$/iu.exec(A);if(!I?.[1])return;const e=I[2];return e===void 0?{value:Number(I[1])}:{value:Number(I[1]),unit:e}}set(g,A){const I=this.fields.find(e=>e.key===g);if(I)I.value=A;else{const e=new cN({key:g,value:A}).setParent(this);this.items.push(e),this.markDirty()}return this}setMeasurement(g,A,I="mil"){return this.set(g,Nxo(A,I))}setPoint(g,A,I="mil"){return this.setMeasurement(g.x,A.x,I),this.setMeasurement(g.y,A.y,I),this}setSize(g,A,I="mil"){return this.setMeasurement(g.width,A.width,I),this.setMeasurement(g.height,A.height,I),this}setAngle(g,A){if(!Number.isFinite(A))throw new RangeError("Altium angles must be finite");return this.set(g,String(ou(A)))}insertField(g,A,I={}){const e=new cN({key:g,value:A}).setParent(this);let t=I.index;if(t===void 0&&I.beforeKey!==void 0&&(t=this.items.findIndex(B=>B instanceof cN&&B.key===I.beforeKey)),t===void 0&&I.afterKey!==void 0){const B=this.items.findLastIndex(C=>C instanceof cN&&C.key===I.afterKey);t=B<0?this.items.length:B+1}const o=t===void 0?this.items.length:Math.min(Math.max(t,0),this.items.length);return this.items.splice(o,0,e),this.markDirty(),e}replaceFieldOccurrence(g,A,I){if(!Number.isInteger(A)||A<0)return!1;const e=this.getAllFields(g)[A];return e?(e.value=I,!0):!1}delete(g){const A=this.items.length;this.items=this.items.filter(e=>!(e instanceof cN&&e.key===g));const I=A-this.items.length;return I>0&&this.markDirty(),I}getChildren(){return[...this.items]}getString(){return`|${this.items.map(g=>g.getString()).join("|")}`}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,recordKind:this.recordKind,originalBinaryPayloadLength:this._originalBinaryPayload?.byteLength,fields:this.fields.map(g=>({key:g.key,value:g.value})),items:this.items.map(g=>g.toJSON())}}};function Fxo(g){return/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/iu.test(g.trim())}var Uxo=new Map([["€",128],["‚",130],["ƒ",131],["„",132],["…",133],["†",134],["‡",135],["ˆ",136],["‰",137],["Š",138],["‹",139],["Œ",140],["Ž",142],["‘",145],["’",146],["“",147],["”",148],["•",149],["–",150],["—",151],["˜",152],["™",153],["š",154],["›",155],["œ",156],["ž",158],["Ÿ",159]]);function Jxo(g){const A=[];for(const I of g){const e=Uxo.get(I);if(e!==void 0){A.push(e);continue}const t=I.codePointAt(0);if(t===void 0||t>255)return g;A.push(t)}try{return new TextDecoder("utf-8",{fatal:!0}).decode(Uint8Array.from(A))}catch{return g}}function Zi(g,...A){for(const I of A){const e=LoA(g.getCaseInsensitive(I));if(e!==void 0)return e}}function c0(g,A,I){const e=Zi(g,...A),t=Zi(g,...I);return e===void 0||t===void 0?void 0:{x:e,y:t}}function YoA(g,A,I){const e=Zi(g,...A),t=Zi(g,...I);return e===void 0||t===void 0?void 0:{width:e,height:t}}function xt(g,...A){for(const I of A){const e=g.getDecoded(I);if(e!==void 0)return e}}function Pxo(g,...A){for(const I of A){const e=g.getNumber(I);if(e!==void 0)return e}}var zpA=class extends vn{type="component-record";constructor(g={}){super(g)}get id(){return this.getNumber("ID")}get designator(){return xt(this,"SOURCEDESIGNATOR","DESIGNATOR")}get comment(){return xt(this,"SOURCECOMMENT","COMMENT")}get footprint(){return xt(this,"PATTERN","FOOTPRINT")}get footprintLibrary(){return xt(this,"SOURCEFOOTPRINTLIBRARY")}get sourceLibrary(){return xt(this,"SOURCECOMPONENTLIBRARY")}get sourceLibraryReference(){return xt(this,"SOURCELIBREFERENCE")}get sourceUniqueId(){return xt(this,"SOURCEUNIQUEID")}get sourceHierarchicalPath(){return xt(this,"SOURCEHIERARCHICALPATH")}get position(){return c0(this,["X","LOCATION.X"],["Y","LOCATION.Y"])}get rotation(){return ou(this.getNumber("ROTATION")??0)}get side(){const g=this.getCaseInsensitive("LAYER")?.toUpperCase();return g==="TOP"||g==="TOP LAYER"?"top":g==="BOTTOM"||g==="BOTTOM LAYER"?"bottom":"unknown"}get mirrored(){return this.side==="bottom"}get locked(){return this.getBoolean("LOCKED")}get selected(){return this.getBoolean("SELECTION")}get unionIndex(){return this.getNumber("UNIONINDEX")}get channelOffset(){return this.getNumber("CHANNELOFFSET")}get heightMils(){return Zi(this,"HEIGHT")}getOwnedPrimitives(g){return g.getRecordsOwnedByComponent(this)}getBounds(g,A){return g.getComponentBounds(this,A)}},XpA=class extends vn{type="net-record";constructor(g={}){super(g)}get id(){return this.getNumber("ID")}get name(){return xt(this,"NAME")}get visible(){return this.getBoolean("VISIBLE")}get color(){return this.getNumber("COLOR")}},Kxo=65535,q3I=new WeakMap,Lxo=class{constructor(g){this.document=g,this.components=g.getRecordsByKind("Component").filter(A=>A instanceof zpA),this.nets=g.getRecordsByKind("Net").filter(A=>A instanceof XpA),this.polygons=g.getRecordsByKind("Polygon"),this.rules=[...g.getRecordsByKind("Rule"),...g.getRecordsByKind("DXPRule")],this.componentTargets=AkA(this.components),this.netTargets=AkA(this.nets),this.polygonTargets=AkA(this.polygons),this.ruleTargets=AkA(this.rules);for(const A of g.records){nig(this.byKind,A.recordKind??"Unknown",A);const I=A.getDecoded("LAYER");I!==void 0&&nig(this.byLayer,I.toUpperCase(),A),gkA(this.byComponent,A,"COMPONENT"),gkA(this.byNet,A,"NET"),gkA(this.byPolygon,A,"POLYGON"),gkA(this.byRule,A,"RULE");const e=A.getDecoded("UNIQUEID");if(!e)continue;const t=e.toUpperCase(),o=this.uniqueIds.get(t);if(!o){this.uniqueIds.set(t,A);continue}const B=this.duplicateUniqueIds.get(t)??[o];B.push(A),this.duplicateUniqueIds.set(t,B)}}document;byComponent=new Map;byKind=new Map;byLayer=new Map;byNet=new Map;byPolygon=new Map;byRule=new Map;components;duplicateUniqueIds=new Map;nets;polygons;rules;uniqueIds=new Map;componentTargets;netTargets;polygonTargets;ruleTargets;getComponent(g){return g9(g)?this.componentTargets.get(g):void 0}getNet(g){return g9(g)?this.netTargets.get(g):void 0}getPolygon(g){return g9(g)?this.polygonTargets.get(g):void 0}getRule(g){return g9(g)?this.ruleTargets.get(g):void 0}getRecordByUniqueId(g){return this.uniqueIds.get(g.toUpperCase())}getDanglingReferences(){const g=[],A=[["COMPONENT",this.componentTargets],["NET",this.netTargets],["POLYGON",this.polygonTargets],["RULE",this.ruleTargets]];for(const I of this.document.records)for(const[e,t]of A){const o=A9(I,e);o!==void 0&&!t.has(o)&&g.push({field:e,index:o,record:I})}return g}};function yr(g){const A=q3I.get(g);if(A?.revision===g.revision)return A.index;const I=new Lxo(g);return q3I.set(g,{index:I,revision:g.revision}),I}function Z3I(g,A){return yr(g).getComponent(A)}function O3I(g,A){return yr(g).getNet(A)}function W3I(g,A){return yr(g).getPolygon(A)}function V3I(g,A){return yr(g).getRule(A)}function iig(g,A){return A instanceof zpA?bL(yr(g).components,A):A9(A,"COMPONENT")}function Eig(g,A){return A instanceof XpA?bL(yr(g).nets,A):A9(A,"NET")}function Yxo(g,A){return A.recordKind==="Polygon"?bL(yr(g).polygons,A):A9(A,"POLYGON")}function _xo(g,A){return A.recordKind==="Rule"||A.recordKind==="DXPRule"?bL(yr(g).rules,A):A9(A,"RULE")??A9(A,"RULEINDEX")}function j3I(g,A){const I=iig(g,A);return I===void 0?void 0:yr(g).getComponent(I)}function z3I(g,A){const I=Eig(g,A);return I===void 0?void 0:yr(g).getNet(I)}function X3I(g,A){const I=Yxo(g,A);return I===void 0?void 0:yr(g).getPolygon(I)}function $3I(g,A){const I=_xo(g,A);return I===void 0?void 0:yr(g).getRule(I)}function $pA(g,A){const I=typeof A=="number"?A:bL(yr(g).components,A);return I===void 0?[]:[...yr(g).byComponent.get(I)??[]]}function ALI(g,A){const I=typeof A=="number"?A:bL(yr(g).nets,A);return I===void 0?[]:[...yr(g).byNet.get(I)??[]]}function gLI(g,A){const I=typeof A=="number"?A:bL(yr(g).polygons,A);return I===void 0?[]:[...yr(g).byPolygon.get(I)??[]]}function ILI(g,A){const I=typeof A=="number"?A:bL(yr(g).rules,A);return I===void 0?[]:[...yr(g).byRule.get(I)??[]]}function AkA(g){const A=new Map,I=g.some(e=>e.getNumber("ID")!==void 0);return g.forEach((e,t)=>{const o=I?e.getNumber("ID"):t;o!==void 0&&g9(o)&&A.set(o,e)}),A}function bL(g,A){if(g.some(t=>t.getNumber("ID")!==void 0)){const t=A.getNumber("ID");return t!==void 0&&g9(t)?t:void 0}const e=g.indexOf(A);return e>=0?e:void 0}function gkA(g,A,I){const e=A9(A,I);e!==void 0&&nig(g,e,A)}function nig(g,A,I){const e=g.get(A);e?e.push(I):g.set(A,[I])}function A9(g,A){const I=g.getNumber(A);return I!==void 0&&g9(I)?I:void 0}function g9(g){return Number.isInteger(g)&&g>=0&&g<Kxo}var eLI=1e5,bxo=1e4;function sig(g){return tkA(Hxo(g))}function Hxo(g){return tLI(QLI(g))}function tLI(g){const A=[];for(let I=0;I<eLI;I++){const e=I9(g,`VX${I}`),t=I9(g,`VY${I}`);if(e===void 0||t===void 0)break;const o=rig(g,`KIND${I}`),B={x:e,y:t};if(o!==1){A.push({index:I,kind:o===void 0||o===0?"line":"unknown",position:B,rawKind:o});continue}const C=I9(g,`CX${I}`),Q=I9(g,`CY${I}`),i=I9(g,`R${I}`),E=rig(g,`SA${I}`),n=rig(g,`EA${I}`),s=C!==void 0&&Q!==void 0&&i!==void 0&&i>0&&E!==void 0&&n!==void 0?{center:{x:C,y:Q},endAngleDegrees:n,radiusMils:i,startAngleDegrees:E}:void 0;A.push({arc:s,index:I,kind:s?"arc":"unknown",position:B,rawKind:o})}return A}function IkA(g){const A=QLI(g),I=[],e=iLI(A.get("HOLECOUNT"),bxo);for(let t=0;t<e;t++){const o=iLI(A.get(`HOLE${t}COUNT`),eLI),B=[];for(let C=0;C<o;C++){const Q=I9(A,`HOLE${t}VX${C}`),i=I9(A,`HOLE${t}VY${C}`);if(Q===void 0||i===void 0)break;B.push({index:C,kind:"line",position:{x:Q,y:i},rawKind:0})}B.length>=3&&I.push(tkA(B))}return{holes:I,outline:tkA(tLI(A)),record:g}}function oLI(g){const A=g.board?sig(g.board):tkA([]),I=g.records.filter(e=>e.recordKind==="BoardRegion"||e.recordKind==="Region");return{cutouts:I.filter(e=>ekA(e)==="BOARD_CUTOUT").map(IkA),layerStackRegions:I.filter(e=>ekA(e)==="LAYER_STACK_REGION").map(IkA),outline:A,polygonCutouts:I.filter(e=>ekA(e)==="POLYGON_CUTOUT").map(IkA)}}function ekA(g){if(g.recordKind==="BoardRegion"||g.getDecoded("OBJECTKIND")?.toUpperCase()==="BOARDREGION"||g.getDecoded("LAYERSTACKID")!==void 0)return"LAYER_STACK_REGION";const I=(g.getDecoded("REGIONKIND")??g.getDecoded("KIND")??void 0)?.replace(/[\s-]+/gu,"_").toUpperCase();return I==="0"?g.getBoolean("ISBOARDCUTOUT")===!0?"BOARD_CUTOUT":"COPPER":I==="1"?"POLYGON_CUTOUT":I==="2"?"DASHED_OUTLINE":I==="3"?"UNKNOWN_3":I==="4"?"CAVITY_DEFINITION":I}function tkA(g){const A=[];for(const t of g){if(!t.arc){CLI(A,t.position);continue}for(const o of vxo(t.position,t.arc))CLI(A,o)}const I=A[0],e=A.at(-1);return{bounds:pxo(A),isExplicitlyClosed:I!==void 0&&e!==void 0&&Cig(I,e,1e-4),points:A,vertices:g,winding:Mxo(A)}}function vxo(g,A){const I=aig(A.center,A.radiusMils,A.startAngleDegrees),e=aig(A.center,A.radiusMils,A.endAngleDegrees),t=Txo(A.endAngleDegrees-A.startAngleDegrees)||360,o=BLI(g,I)<=BLI(g,e),B=o?A.startAngleDegrees:A.endAngleDegrees,C=o?t:-t,Q=Math.max(2,Math.ceil(Math.abs(C)/7.5)),i=[];for(let E=0;E<=Q;E++)i.push(aig(A.center,A.radiusMils,B+C*E/Q));return i}function aig(g,A,I){const e=I*Math.PI/180;return{x:g.x+Math.cos(e)*A,y:g.y+Math.sin(e)*A}}function Txo(g){return(g%360+360)%360}function BLI(g,A){const I=g.x-A.x,e=g.y-A.y;return I*I+e*e}function CLI(g,A){const I=g.at(-1);I&&Cig(I,A,1e-4)||g.push(A)}function QLI(g){const A=new Map;for(const I of g.fields){const e=I.key.toUpperCase();A.has(e)||A.set(e,I.value)}return A}function I9(g,A){return LoA(g.get(A.toUpperCase()))}function rig(g,A){const I=Number(g.get(A.toUpperCase()));return Number.isFinite(I)?I:void 0}function iLI(g,A){const I=Number(g??0);return Number.isInteger(I)?Math.min(Math.max(I,0),A):0}var ELI=class extends vn{type="dimension-record";constructor(g={}){super(g)}get dimensionKind(){return xt(this,"DIMENSIONKIND","KIND")}get start(){return this.referencePoints[0]??c0(this,["X1"],["Y1"])}get end(){return this.referencePoints[1]??c0(this,["X2"],["Y2"])}get dimensionLineAnchor(){return c0(this,["X1"],["Y1"])}get referencePoints(){return nLI({pointInfix:"POINT",prefix:"REFERENCE",record:this})}get textPoints(){const g=c0(this,["TEXTX"],["TEXTY"]);return g?[g]:nLI({pointInfix:"",prefix:"TEXT",record:this})}get unit(){return xt(this,"TEXTDIMENSIONUNIT","DIMENSIONUNIT","UNIT")}get precision(){return Pxo(this,"TEXTPRECISION","PRECISION")??Zi(this,"TEXTPRECISION","PRECISION")}get prefix(){return xt(this,"TEXTPREFIX","PREFIX")}get suffix(){return xt(this,"TEXTSUFFIX","SUFFIX")}get lineWidthMils(){return Zi(this,"LINEWIDTH","ARROWLINEWIDTH","WIDTH")}get textHeightMils(){return Zi(this,"TEXTHEIGHT","HEIGHT")}};function nLI({pointInfix:g,prefix:A,record:I}){const e=[],t=A==="REFERENCE"?I.getNumber("REFERENCES_COUNT"):void 0,o=Math.min(Math.max(t??100,0),1e4),B=A==="REFERENCE"?0:1;for(let C=B;C<B+o;C++){const Q=c0(I,[`${A}${C}${g}X`],[`${A}${C}${g}Y`]);if(!Q)break;e.push(Q)}return e}var qxo=class extends vn{type="coordinate-record";get position(){return c0(this,["X","LOCATION.X"],["Y","LOCATION.Y"])}};function Zxo(g){return g.replace(/[\s_-]/gu,"").toUpperCase()}function VO(g){return LoA(g)}function Oc(g,A,I=0){return VO(g.getCaseInsensitive(A))??I}function Oxo(g){return sig(g).points}function Wxo(g){if(!(g instanceof ELI))return;const A=g,I=A.start,e=A.end;if(!I||!e)return;const t=e.x-I.x,o=e.y-I.y,B=Math.hypot(t,o);if(B===0)return;const C=-o/B,Q=t/B,i=A.dimensionLineAnchor??I,E=(i.x-I.x)*C+(i.y-I.y)*Q,n={x:I.x+C*E,y:I.y+Q*E},s={x:e.x+C*E,y:e.y+Q*E},r=A.textPoints[0]??{x:(n.x+s.x)/2,y:(n.y+s.y)/2},a=Vxo({dimension:A,measuredDistanceMils:B}),c=A.textHeightMils??50,h=sLI({fallbackMils:10,fieldName:"TEXTGAP",record:g});return{arrowSize:sLI({fallbackMils:40,fieldName:"ARROWSIZE",record:g}),dimensionEnd:s,dimensionStart:n,estimatedTextHalfWidth:a.length*c*.3+h,label:a,lineWidth:A.lineWidthMils??8,referenceEnd:e,referenceStart:I,textHeight:c,textPosition:r}}function Vxo({dimension:g,measuredDistanceMils:A}){const I=g.getDecoded("TEXTFORMAT")?.trim();if(I&&I!=="<>")return I;const e=Math.min(Math.max(g.precision??2,0),6),t=g.unit?.toUpperCase()??"MILS",{amount:o,unitLabel:B}=jxo({measuredDistanceMils:A,normalizedUnit:t}),C=g.prefix??"",Q=g.suffix??` ${B}`;return`${C}${o.toFixed(e)}${Q}`}function jxo({measuredDistanceMils:g,normalizedUnit:A}){return A.includes("MILLIMETER")?{amount:g*.0254,unitLabel:"mm"}:A.includes("CENTIMETER")?{amount:g*.00254,unitLabel:"cm"}:A.includes("INCH")?{amount:g/1e3,unitLabel:"in"}:{amount:g,unitLabel:"mil"}}function sLI({fallbackMils:g,fieldName:A,record:I}){return I.getAltiumMeasurement(A)?.toMils()??g}var cig=Zxo;function zxo(g,A){const I=$xo(g,A),e=g.getNumber("PADMODE")??0,t=Xxo(g,I,e),o=g.getCaseInsensitive(`LAYER${I}ALTSHAPE`)?.toUpperCase(),B=Number(g.getCaseInsensitive(`LAYER${I}CORNERRADIUS`)??0),C=o==="ROUNDRECT"&&Number.isFinite(B)?Math.min(t.width,t.height)*B/200:0,Q=g.getNumber("HOLETYPE"),i=g.getCaseInsensitive("HOLESHAPE")?.toUpperCase()??(Q===1?"SQUARE":Q===2?"SLOT":"ROUND"),E=Oc(g,"HOLESIZE"),n=VO(g.getCaseInsensitive("SLOTLENGTH"))??(i==="SLOT"?VO(g.getCaseInsensitive("HOLEWIDTH")):void 0)??E;return{cornerRadius:C,height:t.height,holeOffsetX:Oc(g,`LAYER${I}HOLEXOFFSET`,Oc(g,`PADXOFFSET${I}`)),holeOffsetY:Oc(g,`LAYER${I}HOLEYOFFSET`,Oc(g,`PADYOFFSET${I}`)),holeRotation:Number(g.getCaseInsensitive("SLOTROTATION")??g.getCaseInsensitive("HOLEROTATION")??0),holeShape:i,holeSize:E,layerOrdinal:I,plated:g.getBoolean("PLATED")!==!1,rotation:Number(g.getCaseInsensitive("ROTATION")??0),shape:o==="ROUNDRECT"?o:t.shape,slotLength:n,width:t.width,x:Oc(g,"X"),y:Oc(g,"Y")}}function Xxo(g,A,I){if(!(cig(g.getCaseInsensitive("LAYER")??"")==="MULTILAYER")||I===0||A===0)return{height:hP(g,["YSIZE","TOPYSIZE"])??hP(g,["XSIZE","TOPXSIZE"])??20,shape:okA(g,["SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:hP(g,["XSIZE","TOPXSIZE"])??20};if(A===31){const B=hP(g,["BOTTOMXSIZE","BOTXSIZE","XSIZE","TOPXSIZE"])??20;return{height:hP(g,["BOTTOMYSIZE","BOTYSIZE","YSIZE","TOPYSIZE"])??B,shape:okA(g,["BOTTOMSHAPE","BOTSHAPE","SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:B}}if(I===2&&A>=2){const B=hP(g,[`LAYER${A}XSIZE`,"MIDXSIZE","XSIZE"])??20;return{height:hP(g,[`LAYER${A}YSIZE`,"MIDYSIZE","YSIZE"])??B,shape:okA(g,[`LAYER${A}SHAPE`,"MIDSHAPE","SHAPE"])?.toUpperCase()??"ROUND",width:B}}const o=hP(g,["MIDXSIZE","XSIZE","TOPXSIZE"])??20;return{height:hP(g,["MIDYSIZE","YSIZE","TOPYSIZE"])??o,shape:okA(g,["MIDSHAPE","SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:o}}function $xo(g,A){const I=A?.length===1?cig(A[0]??""):cig(g.getCaseInsensitive("LAYER")??"");if(I==="BOTTOM")return 31;if(I==="TOP")return 0;const e=/^(?:MIDLAYER|MID|INTERNALPLANE)(\d+)$/u.exec(I);return e?.[1]?Math.min(Math.max(Number(e[1]),1),30):0}function hP(g,A){for(const I of A){const e=VO(g.getCaseInsensitive(I));if(e!==void 0)return e}}function okA(g,A){for(const I of A){const e=g.getCaseInsensitive(I);if(e!==void 0)return e}}function hig(g){if(g.length!==0)return{minX:Math.min(...g.map(A=>A.x)),minY:Math.min(...g.map(A=>A.y)),maxX:Math.max(...g.map(A=>A.x)),maxY:Math.max(...g.map(A=>A.y))}}function AFo(g,A){return g?A?{minX:Math.min(g.minX,A.minX),minY:Math.min(g.minY,A.minY),maxX:Math.max(g.maxX,A.maxX),maxY:Math.max(g.maxY,A.maxY)}:g:A}function lig(g,A){return{minX:g.minX-A,minY:g.minY-A,maxX:g.maxX+A,maxY:g.maxY+A}}function gFo(g,A){const I=g.recordKind;if(I==="Dimension"){const e=Wxo(g);if(!e)return;const t=e.dimensionEnd.x-e.dimensionStart.x,o=e.dimensionEnd.y-e.dimensionStart.y,B=Math.hypot(t,o),C={x:t/B,y:o/B},Q=hig([e.referenceStart,e.referenceEnd,e.dimensionStart,e.dimensionEnd,e.textPosition,{x:e.textPosition.x-C.x*e.estimatedTextHalfWidth,y:e.textPosition.y-C.y*e.estimatedTextHalfWidth},{x:e.textPosition.x+C.x*e.estimatedTextHalfWidth,y:e.textPosition.y+C.y*e.estimatedTextHalfWidth}]);return Q?lig(Q,Math.max(e.arrowSize,e.textHeight)):void 0}if(I==="Track"){const e=hig([{x:Oc(g,"X1"),y:Oc(g,"Y1")},{x:Oc(g,"X2"),y:Oc(g,"Y2")}]),t=Oc(g,"WIDTH");return e&&t>0?lig(e,t/2):e}if(I==="Pad"){const e=zxo(g,A),t=e.rotation*Math.PI/180,o=e.width/2,B=e.height/2,C=Math.abs(Math.cos(t))*o+Math.abs(Math.sin(t))*B,Q=Math.abs(Math.sin(t))*o+Math.abs(Math.cos(t))*B;return{minX:e.x-C,minY:e.y-Q,maxX:e.x+C,maxY:e.y+Q}}if(I==="Via"){const e=Oc(g,"X"),t=Oc(g,"Y"),o=VO(g.getCaseInsensitive("DIAMETER"))??VO(g.getCaseInsensitive("TOPLAYERSIZE"))??20;return{minX:e-o/2,minY:t-o/2,maxX:e+o/2,maxY:t+o/2}}if(I==="Arc"){const e=Oc(g,"LOCATION.X"),t=Oc(g,"LOCATION.Y"),o=Oc(g,"RADIUS"),B=Oc(g,"WIDTH"),C=o+Math.max(B/2,0);return{minX:e-C,minY:t-C,maxX:e+C,maxY:t+C}}if(I==="ComponentBody"||I==="Region"||I==="Polygon"||I==="Board")return hig(Oxo(g));if(I==="Text"){const e=Oc(g,"X"),t=Oc(g,"Y"),o=Oc(g,"HEIGHT",30);return lig({minX:e,minY:t,maxX:e,maxY:t},o)}if(I==="Fill"){const e=Oc(g,"X1"),t=Oc(g,"Y1"),o=Oc(g,"X2"),B=Oc(g,"Y2"),C=(e+o)/2,Q=(t+B)/2,i=Math.abs(o-e)/2,E=Math.abs(B-t)/2,n=Number(g.getCaseInsensitive("ROTATION")??0)*Math.PI/180,s=Math.abs(Math.cos(n))*i+Math.abs(Math.sin(n))*E,r=Math.abs(Math.sin(n))*i+Math.abs(Math.cos(n))*E;return{minX:C-s,minY:Q-r,maxX:C+s,maxY:Q+r}}}var aLI=new WeakMap,IFo=class{constructor(g){this.document=g;const A=yr(g);this.edges=A.nets.flatMap((I,e)=>{const t=I.getNumber("ID")??e,o=A.byNet.get(t)??[],B=new Map;for(const C of o){const Q=iig(g,C),i=B.get(Q);i?i.push(C):B.set(Q,[C])}return[...B].map(([C,Q])=>({component:C===void 0?void 0:A.getComponent(C),net:I,primitives:Q}))})}document;edges;getConnectedRecords(g){const A=Eig(this.document,g);return A===void 0?[]:[...yr(this.document).byNet.get(A)??[]].filter(I=>I!==g)}getNetsForComponent(g){const A=yr(this.document),I=new Set;for(const e of $pA(this.document,g)){const t=Eig(this.document,e),o=t===void 0?void 0:A.getNet(t);o&&I.add(o)}return[...I]}getComponentsForNet(g){const A=yr(this.document),I=typeof g=="number"?g:g.getNumber("ID")??A.nets.indexOf(g);if(I<0)return[];const e=new Set;for(const t of A.byNet.get(I)??[]){const o=iig(this.document,t),B=o===void 0?void 0:A.getComponent(o);B&&e.add(B)}return[...e]}getConnectedComponents(g){const A=new Set,I=typeof g=="number"?yr(this.document).getComponent(g):g;for(const e of this.getNetsForComponent(g))for(const t of this.getComponentsForNet(e))t!==I&&A.add(t);return[...A]}};function rLI(g){const A=aLI.get(g);if(A?.revision===g.revision)return A.graph;const I=new IFo(g);return aLI.set(g,{graph:I,revision:g.revision}),I}function cLI(g,A,I){let e;for(const t of $pA(g,A))e=AFo(e,gFo(t,I));return e}var eFo=class extends uF{type="binary-pcb-document";compoundFile;embeddedModels;primitiveRecords;propertyRecords;streamSummaries;wideStrings;constructor(g){super({sourceLocation:{byteOffset:0,streamPath:"/"}}),this.compoundFile=g.compoundFile,this.primitiveRecords=g.primitiveRecords,this.propertyRecords=g.propertyRecords,this.streamSummaries=g.streamSummaries,this.wideStrings=g.wideStrings??new Map,this.embeddedModels=this.models.flatMap((A,I)=>{const e=this.compoundFile.getStream(["Models",String(I)]);return e?[new Gxo({index:I,record:A,stream:e})]:[]}),this.adoptChildren([this.compoundFile,...this.records]),this.clearDirty(!0)}get records(){return[...this.propertyRecords.values(),...this.primitiveRecords.values()].flat()}get board(){return this.propertyRecords.get("Board6")?.[0]}get components(){return this.propertyRecords.get("Components6")??[]}get componentBodies(){return this.primitiveRecords.get("ShapeBasedComponentBodies6")??this.primitiveRecords.get("ComponentBodies6")??[]}get legacyComponentBodies(){return this.primitiveRecords.get("ComponentBodies6")??[]}get nets(){return this.propertyRecords.get("Nets6")??[]}get index(){return yr(this)}get connectivity(){return rLI(this)}get boardGeometry(){return oLI(this)}get polygons(){return this.propertyRecords.get("Polygons6")??[]}get rules(){return this.propertyRecords.get("Rules6")??[]}getComponentByIndex(g){return Z3I(this,g)}getNetByIndex(g){return O3I(this,g)}getPolygonByIndex(g){return W3I(this,g)}getRuleByIndex(g){return V3I(this,g)}getComponentForRecord(g){return j3I(this,g)}getNetForRecord(g){return z3I(this,g)}getPolygonForRecord(g){return X3I(this,g)}getRuleForRecord(g){return $3I(this,g)}getRecordsOwnedByComponent(g){return $pA(this,g)}getRecordsOnNet(g){return ALI(this,g)}getRecordsForPolygon(g){return gLI(this,g)}getRecordsForRule(g){return ILI(this,g)}getRecordsByLayer(g){return[...this.index.byLayer.get(g.toUpperCase())??[]]}getComponentBounds(g,A){return cLI(this,g,A)}getRecordByUniqueId(g){return this.index.getRecordByUniqueId(g)}get models(){return this.propertyRecords.get("Models")??[]}getModelsById(g){const A=g.toUpperCase();return this.models.filter(I=>I.getDecoded("ID")?.toUpperCase()===A)}getModelForComponentBody(g){const A=g.getDecoded("MODELID");if(!A)return;const I=this.getModelsById(A);return I.length<=1?I[0]:I.find(e=>Dig(e.getNumber("ROTX"),g.getNumber("MODEL.3D.ROTX"))&&Dig(e.getNumber("ROTY"),g.getNumber("MODEL.3D.ROTY"))&&Dig(e.getNumber("ROTZ"),g.getNumber("MODEL.3D.ROTZ")))??I[0]}getEmbeddedModelForComponentBody(g){const A=this.getModelForComponentBody(g);return this.embeddedModels.find(I=>I.record===A)}get tracks(){return this.primitiveRecords.get("Tracks6")??[]}get arcs(){return this.primitiveRecords.get("Arcs6")??[]}get vias(){return this.primitiveRecords.get("Vias6")??[]}get pads(){return this.primitiveRecords.get("Pads6")??[]}get fills(){return this.primitiveRecords.get("Fills6")??[]}get regions(){return this.primitiveRecords.get("ShapeBasedRegions6")??this.primitiveRecords.get("Regions6")??[]}get regionFills(){return this.primitiveRecords.get("Regions6")??[]}get boardRegions(){return this.primitiveRecords.get("BoardRegions")??[]}get texts(){return this.primitiveRecords.get("Texts6")??[]}getRecordsByKind(g){return this.records.filter(A=>A.recordKind===g)}getStreamSummary(g){return this.streamSummaries.find(A=>A.family.toLowerCase()===g.toLowerCase())}getBytes(){if(this.isDirty)throw new Qc("Modified binary PCB documents cannot yet be serialized safely");return this.compoundFile.getBytes()}getChildren(){return[this.compoundFile,...this.records]}getString(){return this.records.map(g=>g.getString()).join(`
|
|
5748
|
+
${u}`)}},[A,s]),z.useEffect(()=>{A&&!s&&j4I().then(u=>{c(u.size)}).catch(u=>{console.error("Failed to fetch file count",u),c(0)})},[A,s]);const D=z.useCallback(()=>{B(null),r(null),Q(null),E([]),n.current&&(n.current.value=""),I(!0)},[]),d=z.useCallback(()=>{I(!1)},[]),y=z.useCallback(async()=>{t(!0),B(null),Q(null),E([]);const u=d3(),G=n.current?.value||"";try{const m=await j4I();if(m.size===0){LC.error("No project files available to include in the bug report"),t(!1);return}const p=new Date(Date.now()+1440*60*1e3).toISOString(),S=(await u.post("bug_reports/create",{json:{text:G.trim()||void 0,is_auto_deleted:!0,delete_at:p}}).json()).bug_report.bug_report_id,R=Array.from(m.entries()),x=[];for(let U=0;U<R.length;U++){const[K,Y]=R[U];Q({current:U+1,total:R.length,currentFile:K});try{const _={bug_report_id:S,file_path:K};Y.text_content&&(_.content_text=Y.text_content),Y.binary_content_b64&&(_.content_base64=Y.binary_content_b64),await u.post("bug_reports/upload_file",{json:_})}catch(_){const Z=_ instanceof wJ?`HTTP ${_.response.status}`:_ instanceof Error?_.message:"Upload failed";x.push({filePath:K,message:Z}),E([...x])}}Q(null);const N=Cfo(S);r({bugReportUrl:N})}catch(m){if(console.error("Failed to submit bug report",m),m instanceof wJ)if(m.response.status===401)if(l){const p="Your session has expired. Please sign in again to continue.";B(p),LC.error(p),h&&(d(),h())}else{const p="You must be logged in to report a bug. Please sign in via cli and try again.";B(p),LC.error(p),setTimeout(()=>{h&&(d(),h())},1e3)}else{const p=`Failed to submit bug report (${m.response.status})`;B(p),LC.error(p)}else if(m instanceof Error)B(m.message),LC.error(m.message);else{const p="Failed to submit bug report";B(p),LC.error(p)}}finally{t(!1)}},[l,h]);return{BugReportDialog:z.useMemo(()=>{const u=C?Math.round(C.current/C.total*100):0;return T.jsx(bPI,{open:A,onOpenChange:G=>{G?(B(null),r(null),Q(null),E([]),I(!0)):e||d()},children:T.jsxs(RCg,{children:[T.jsxs(NCg,{children:[T.jsx(FCg,{children:s?"Bug Report Created":"Report Bug"}),T.jsx(UCg,{asChild:!0,children:s?T.jsxs("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:[T.jsx("p",{children:"Bug report created successfully."}),i.length>0&&T.jsxs("div",{className:"rf-bg-red-50 rf-border rf-border-red-200 rf-rounded rf-p-2 rf-max-h-28 rf-overflow-y-auto rf-overflow-x-hidden",children:[T.jsxs("p",{className:"rf-text-red-700 rf-font-medium rf-text-xs rf-mb-1",children:[i.length," file(s) failed:"]}),i.map((G,m)=>T.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${G.filePath}: ${G.message}`,children:[T.jsx("span",{className:"rf-font-medium rf-break-all",children:G.filePath.split("/").pop()}),T.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:G.message})]},m))]}),T.jsx("div",{children:T.jsx("a",{className:"rf-text-blue-600 hover:rf-underline",href:s.bugReportUrl,target:"_blank",rel:"noreferrer",children:"View bug report"})}),T.jsxs("p",{children:["Please share this link privately with tscircuit staff so we can help debug. Join the",T.jsx("a",{className:"rf-ml-1 rf-text-blue-600 hover:rf-underline",href:"https://tscircuit.com/join",target:"_blank",rel:"noreferrer",children:"tscircuit Discord"}),"."]})]}):T.jsx("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:C?T.jsxs("div",{className:"rf-space-y-2 rf-overflow-hidden",children:[T.jsxs("div",{className:"rf-flex rf-justify-between rf-text-xs",children:[T.jsx("span",{children:"Uploading files..."}),T.jsxs("span",{children:[C.current,"/",C.total]})]}),T.jsx("div",{className:"rf-w-full rf-h-2 rf-bg-gray-200 rf-rounded-full rf-overflow-hidden",children:T.jsx("div",{className:"rf-h-full rf-bg-blue-500 rf-transition-all rf-duration-150",style:{width:`${u}%`}})}),T.jsx("p",{className:"rf-text-xs rf-text-gray-500 rf-break-all rf-truncate rf-w-full rf-max-w-full",children:`${C.currentFile.slice(0,60)}${C.currentFile.length>60?"...":""}`}),i.length>0&&T.jsx("div",{className:"rf-bg-red-50 rf-border rf-border-red-200 rf-rounded rf-p-2 rf-max-h-20 rf-overflow-y-auto rf-overflow-x-hidden",children:i.map((G,m)=>T.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${G.filePath}: ${G.message}`,children:[T.jsx("span",{className:"rf-font-medium rf-break-all",children:G.filePath.split("/").pop()}),T.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:G.message})]},m))})]}):T.jsxs(T.Fragment,{children:[T.jsxs("p",{children:["Reporting a bug will upload your entire project",a>0?` (${a} file${a===1?"":"s"})`:""," ","to tscircuit support."]}),T.jsxs("div",{className:"rf-space-y-2",children:[T.jsx("label",{htmlFor:"bug-description",className:"rf-block rf-font-medium",children:"Description (optional)"}),T.jsx("textarea",{ref:n,id:"bug-description",className:"rf-w-full rf-min-h-[100px] rf-px-3 rf-py-2 rf-text-sm rf-border rf-border-gray-300 rf-rounded-md focus:rf-outline-none focus:rf-ring-2 focus:rf-ring-blue-500",placeholder:"Describe the issue you're experiencing...",disabled:e})]}),T.jsxs("p",{children:["Share the generated bug report link privately with tscircuit staff so we can help debug your issue. You can also reach out on our",T.jsx("a",{className:"rf-ml-1 rf-text-blue-600 hover:rf-underline",href:"https://tscircuit.com/join",target:"_blank",rel:"noreferrer",children:"Discord community"}),"."]}),!l&&T.jsx("p",{className:"rf-text-red-600",children:"You appear to be logged out. Please log in before reporting a bug or the upload will fail."}),o&&T.jsx("p",{className:"rf-text-red-600",children:o})]})})})]}),T.jsx(xCg,{children:s?T.jsx("button",{type:"button",className:sO(),onClick:()=>{d()},children:"Close"}):T.jsxs(T.Fragment,{children:[T.jsx(JCg,{disabled:e,onClick:()=>{e||d()},children:"Cancel"}),!l&&h?T.jsx("button",{type:"button",className:sO(),onClick:G=>{G.preventDefault(),d(),h()},children:"Sign In"}):T.jsx("button",{type:"button",className:FR(sO(),e&&"rf-opacity-70 rf-cursor-not-allowed"),disabled:e,onClick:G=>{G.preventDefault(),y()},children:e?"Reporting...":"Upload & Report"})]})})]})},"bug-report-dialog")},[A,e,d,o,s,a,l,y,h,C,i]),openBugReportDialog:D}};function ifo({open:g,onOpenChange:A,onExport:I}){const[e,t]=z.useState(!1),o=()=>{I({includeSilkscreen:e}),A(!1)},B=()=>{A(!1)};return T.jsx(Hb,{open:g,onOpenChange:A,children:T.jsxs(xL,{children:[T.jsxs(FL,{children:[T.jsx(UL,{children:"LightBurn Export Options"}),T.jsx(vb,{children:"Configure export settings for PCB laser ablation with LightBurn"})]}),T.jsx("div",{className:"rf-flex rf-flex-col rf-gap-4 rf-py-4",children:T.jsxs("div",{className:"rf-flex rf-items-center rf-space-x-2",children:[T.jsx(roA,{id:"includeSilkscreen",checked:e,onCheckedChange:C=>t(C===!0)}),T.jsx("label",{htmlFor:"includeSilkscreen",className:"rf-text-xs rf-font-medium rf-leading-none peer-disabled:rf-cursor-not-allowed peer-disabled:rf-opacity-70",children:"Include silkscreen layer"})]})}),T.jsxs(_O,{children:[T.jsx(si,{variant:"outline",onClick:B,children:"Cancel"}),T.jsx(si,{onClick:o,children:"Export"})]})]})})}const Efo=/#(\d+)/,nfo=g=>{const A=g.match(Efo);if(!A)return null;const I=Number.parseInt(A[1],10);return Number.isFinite(I)?I:null},sfo=g=>{if(typeof g=="number")return Number.isFinite(g)?g:null;if(typeof g=="string"){const A=new Date(g).getTime();return Number.isFinite(A)?A:null}return null},afo=g=>{if(!g)return null;let A=null,I=-1,e=-1;for(const[t,o]of Object.entries(g)){const B=nfo(t),C=sfo(o.createdAt);if(B!==null){B>I&&(I=B,A={key:t,value:o});continue}if(I===-1){if(C!==null&&C>e){e=C,A={key:t,value:o};continue}A||(A={key:t,value:o})}}return A};var rfo=Object.defineProperty,cfo=(g,A)=>rfo(g,"name",{value:A,configurable:!0});function dQg(g,[A,I]){return Math.min(I,Math.max(A,g))}cfo(dQg,"clamp");var hfo=Object.defineProperty,lfo=(g,A)=>hfo(g,"name",{value:A,configurable:!0}),z4I=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Dfo=z.forwardRef(lfo(function(A,I){return T.jsx(yQ.span,{...A,ref:I,style:{...z4I,...A.style}})},"VisuallyHidden")),dfo=Object.defineProperty,ZE=(g,A)=>dfo(g,"name",{value:A,configurable:!0}),X4I={ItemAligned:"item-aligned",Popper:"popper"},yfo={RTL:"rtl"},wfo=[" ","Enter","ArrowUp","ArrowDown"],ufo=[" ","Enter"],HO="Select",[PpA,KpA,Gfo]=TlA(HO),[Ob,YCB]=hk(HO,[Gfo,ML]),yQg=ML(),[mfo,LL]=Ob(HO),[pfo,kfo]=Ob(HO);function $4I(g){const{__scopeSelect:A,children:I,open:e,defaultOpen:t,onOpenChange:o,value:B,defaultValue:C,onValueChange:Q,dir:i,name:E,autoComplete:n,disabled:s,required:r,form:a,internal_do_not_use_render:c}=g,h=yQg(A),[l,D]=z.useState(null),[d,y]=z.useState(null),[w,u]=z.useState(!1),G=WAA(i),[m,p]=xR({prop:e,defaultProp:t??!1,onChange:o,caller:HO}),[k,S]=xR({prop:B,defaultProp:C,onChange:Q,caller:HO}),R=z.useRef(null),x=z.useRef(!1),[N,U]=z.useState(null),K=ZE(QA=>{U({value:QA,hasConsumerStoppedPropagation:x.current}),S(QA)},"handleUserSelect"),Y=z.useRef(k);z.useEffect(()=>{const QA=a?l?.ownerDocument.getElementById(a):l?.form;if(QA instanceof HTMLFormElement){const sA=ZE(()=>S(Y.current),"reset");return QA.addEventListener("reset",sA),()=>QA.removeEventListener("reset",sA)}},[a,l,S]);const _=l?!!a||!!l.closest("form"):!0,[Z,V]=z.useState(new Set),W=_0(),q=Array.from(Z).map(QA=>QA.props.value).join(";"),X=z.useCallback(QA=>{V(sA=>new Set(sA).add(QA))},[]),tA=z.useCallback(QA=>{V(sA=>{const DA=new Set(sA);return DA.delete(QA),DA})},[]),IA={required:r,trigger:l,onTriggerChange:D,valueNode:d,onValueNodeChange:y,valueNodeHasChildren:w,onValueNodeHasChildrenChange:u,contentId:W,value:k,onValueChange:S,hasConsumerStoppedPropagationRef:x,userSelection:N,onUserSelect:K,open:m,onOpenChange:p,dir:G,triggerPointerDownPosRef:R,disabled:s,name:E,autoComplete:n,form:a,nativeOptions:Z,nativeSelectKey:q,isFormControl:_};return T.jsx(JtA,{...h,children:T.jsx(mfo,{scope:A,...IA,children:T.jsx(PpA.Provider,{scope:A,children:T.jsx(pfo,{scope:A,onNativeOptionAdd:X,onNativeOptionRemove:tA,children:rKI(c)?c(IA):I})})})})}ZE($4I,"SelectProvider");var Mfo=ZE(g=>{const{__scopeSelect:A,children:I,...e}=g;return T.jsx($4I,{__scopeSelect:A,...e,internal_do_not_use_render:({isFormControl:t})=>T.jsxs(T.Fragment,{children:[I,t?T.jsx(jfo,{__scopeSelect:A}):null]})})},"Select"),Sfo="SelectTrigger",AKI=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,disabled:t=!1,...o}=A,B=yQg(e),C=LL(Sfo,e),Q=C.disabled||t,i=Gi(I,C.onTriggerChange),E=KpA(e),n=z.useRef("touch"),[s,r,a]=GQg(h=>{const l=E().filter(y=>!y.disabled),D=l.find(y=>y.value===C.value),d=mQg(l,h,D);d!==void 0&&C.onUserSelect(d.value)}),c=ZE(h=>{Q||(C.onOpenChange(!0),a()),h&&(C.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})},"handleOpen");return T.jsx(QmA,{asChild:!0,...B,children:T.jsx(yQ.button,{type:"button",role:"combobox","aria-controls":C.open?C.contentId:void 0,"aria-expanded":C.open,"aria-required":C.required,"aria-autocomplete":"none",dir:C.dir,"data-state":C.open?"open":"closed",disabled:Q,"data-disabled":Q?"":void 0,"data-placeholder":moA(C.value)?"":void 0,...o,ref:i,onClick:fo(o.onClick,h=>{h.currentTarget.focus(),n.current!=="mouse"&&c(h)}),onPointerDown:fo(o.onPointerDown,h=>{n.current=h.pointerType;const l=h.target;l.hasPointerCapture(h.pointerId)&&l.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(c(h),h.preventDefault())}),onKeyDown:fo(o.onKeyDown,h=>{const l=s.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&(C.hasConsumerStoppedPropagationRef.current=h.isPropagationStopped(),r(h.key)),!(l&&h.key===" ")&&wfo.includes(h.key)&&(c(),h.preventDefault())})})})},"SelectTrigger")),ffo="SelectValue",Rfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,className:t,style:o,children:B,placeholder:C="",...Q}=A,i=LL(ffo,e),{onValueNodeHasChildrenChange:E}=i,n=B!==void 0,s=Gi(I,i.onValueNodeChange);uh(()=>{E(n)},[E,n]);const r=moA(i.value);return T.jsx(yQ.span,{...Q,asChild:r?!1:Q.asChild,ref:s,style:{pointerEvents:"none"},children:T.jsx(z.Fragment,{children:r?C:B},r?"placeholder":"value")})},"SelectValue")),Nfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,children:t,...o}=A;return T.jsx(yQ.span,{"aria-hidden":!0,...o,ref:I,children:t||"▼"})},"SelectIcon")),xfo="SelectPortal",[Ffo,Ufo]=Ob(xfo,{forceMount:void 0}),Jfo=ZE(g=>{const{__scopeSelect:A,forceMount:I,...e}=g;return T.jsx(Ffo,{scope:g.__scopeSelect,forceMount:I,children:T.jsx(nmA,{asChild:!0,...e})})},"SelectPortal"),Wb="SelectContent",gKI=z.forwardRef(ZE(function(A,I){const e=Ufo(Wb,A.__scopeSelect),{forceMount:t=e.forceMount,...o}=A,B=LL(Wb,A.__scopeSelect),[C,Q]=z.useState();return uh(()=>{Q(new DocumentFragment)},[]),T.jsx(AS,{present:t||B.open,children:({present:i})=>i?T.jsx(Lfo,{...o,ref:I}):T.jsx(Pfo,{...o,fragment:C})})},"SelectContent")),Pfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,children:t,fragment:o}=A;return o?dx.createPortal(T.jsx(IKI,{scope:e,children:T.jsx(PpA.Slot,{scope:e,children:T.jsx("div",{ref:I,children:t})})}),o):null},"SelectContentFragment")),rN=10,[IKI,Vb]=Ob(Wb),Kfo=NR("SelectContent.RemoveScroll"),Lfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e}=A,{position:t=X4I.ItemAligned,onCloseAutoFocus:o,onEscapeKeyDown:B,onPointerDownOutside:C,side:Q,sideOffset:i,align:E,alignOffset:n,arrowPadding:s,collisionBoundary:r,collisionPadding:a,sticky:c,hideWhenDetached:h,avoidCollisions:l,...D}=A,d=LL(Wb,e),[y,w]=z.useState(null),[u,G]=z.useState(null),m=Gi(I,w),[p,k]=z.useState(null),[S,R]=z.useState(null),x=KpA(e),[N,U]=z.useState(!1),K=z.useRef(!1),Y=z.useRef(!1),_=z.useRef(!1);z.useEffect(()=>{if(y)return rmA(y)},[y]),rO();const Z=z.useCallback(hA=>{const[nA,...aA]=x().map(rA=>rA.ref.current),[SA]=aA.slice(-1),FA=document.activeElement;for(const rA of hA)if(rA===FA||(rA?.scrollIntoView({block:"nearest"}),rA===nA&&u&&(u.scrollTop=0),rA===SA&&u&&(u.scrollTop=u.scrollHeight),rA?.focus(),document.activeElement!==FA))return},[x,u]),V=z.useCallback(()=>Z([p,y]),[Z,p,y]);z.useEffect(()=>{N&&V()},[N,V]);const{onOpenChange:W,triggerPointerDownPosRef:q}=d;z.useEffect(()=>{if(y){let hA={x:0,y:0};const nA=ZE(SA=>{hA={x:Math.abs(Math.round(SA.pageX)-(q.current?.x??0)),y:Math.abs(Math.round(SA.pageY)-(q.current?.y??0))}},"handlePointerMove"),aA=ZE(SA=>{hA.x<=10&&hA.y<=10?SA.preventDefault():SA.composedPath().includes(y)||W(!1),document.removeEventListener("pointermove",nA),q.current=null},"handlePointerUp");return q.current!==null&&(document.addEventListener("pointermove",nA),document.addEventListener("pointerup",aA,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",nA),document.removeEventListener("pointerup",aA,{capture:!0})}}},[y,W,q]),z.useEffect(()=>{const hA=ZE(()=>W(!1),"close");return window.addEventListener("blur",hA),window.addEventListener("resize",hA),()=>{window.removeEventListener("blur",hA),window.removeEventListener("resize",hA)}},[W]);const[X,tA]=GQg(hA=>{const nA=x().filter(FA=>!FA.disabled),aA=nA.find(FA=>FA.ref.current===document.activeElement),SA=mQg(nA,hA,aA);SA&&setTimeout(()=>SA.ref.current?.focus())}),IA=z.useCallback((hA,nA,aA)=>{const SA=!Y.current;SA&&(Y.current=!0);const FA=!K.current&&!aA;d.value!==void 0&&d.value===nA||FA?(k(hA),FA&&(K.current=!0)):SA&&k(hA)},[d.value]),QA=z.useCallback(()=>y?.focus(),[y]),sA=z.useCallback((hA,nA,aA)=>{if(!hA)return;const SA=!_.current;SA&&(_.current=!0);const FA=!K.current&&!aA;(d.value!==void 0&&d.value===nA||FA||SA)&&R(hA)},[d.value]),DA=t===X4I.Popper?eKI:Yfo,CA=DA===eKI?{side:Q,sideOffset:i,align:E,alignOffset:n,arrowPadding:s,collisionBoundary:r,collisionPadding:a,sticky:c,hideWhenDetached:h,avoidCollisions:l}:{};return T.jsx(IKI,{scope:e,content:y,viewport:u,onViewportChange:G,itemRefCallback:IA,selectedItem:p,onItemLeave:QA,itemTextRefCallback:sA,focusSelectedItem:V,selectedItemText:S,position:t,isPositioned:N,searchRef:X,children:T.jsx(PtA,{as:Kfo,allowPinchZoom:!0,children:T.jsx(OGA,{asChild:!0,trapped:d.open,onMountAutoFocus:hA=>{hA.preventDefault()},onUnmountAutoFocus:fo(o,hA=>{d.trigger?.focus({preventScroll:!0}),hA.preventDefault()}),children:T.jsx(xtA,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:B,onPointerDownOutside:C,onFocusOutside:hA=>hA.preventDefault(),onDismiss:()=>d.onOpenChange(!1),children:T.jsx(DA,{role:"listbox",id:d.contentId,"data-state":d.open?"open":"closed",dir:d.dir,onContextMenu:hA=>hA.preventDefault(),...D,...CA,onPlaced:()=>U(!0),ref:m,style:{display:"flex",flexDirection:"column",outline:"none",...D.style},onKeyDown:fo(D.onKeyDown,hA=>{const nA=hA.ctrlKey||hA.altKey||hA.metaKey;if(hA.key==="Tab"&&hA.preventDefault(),!nA&&hA.key.length===1&&tA(hA.key),["ArrowUp","ArrowDown","Home","End"].includes(hA.key)){let SA=x().filter(FA=>!FA.disabled).map(FA=>FA.ref.current);if(["ArrowUp","End"].includes(hA.key)&&(SA=SA.slice().reverse()),["ArrowUp","ArrowDown"].includes(hA.key)){const FA=hA.target,rA=SA.indexOf(FA);SA=SA.slice(rA+1)}setTimeout(()=>Z(SA)),hA.preventDefault()}})})})})})})},"SelectContentImpl")),Yfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,onPlaced:t,...o}=A,B=LL(Wb,e),C=Vb(Wb,e),[Q,i]=z.useState(null),[E,n]=z.useState(null),s=Gi(I,n),r=KpA(e),a=z.useRef(!1),c=z.useRef(!0),{viewport:h,selectedItem:l,selectedItemText:D,focusSelectedItem:d}=C,y=z.useCallback(()=>{if(B.trigger&&B.valueNode&&Q&&E&&h&&l&&D){const m=B.trigger.getBoundingClientRect(),p=E.getBoundingClientRect(),k=B.valueNode.getBoundingClientRect(),S=D.getBoundingClientRect();if(B.dir!==yfo.RTL){const aA=S.left-p.left,SA=k.left-aA,FA=m.left-SA,rA=m.width+FA,NA=Math.max(rA,p.width),RA=window.innerWidth-rN,xA=dQg(SA,[rN,Math.max(rN,RA-NA)]);Q.style.minWidth=rA+"px",Q.style.left=xA+"px"}else{const aA=p.right-S.right,SA=window.innerWidth-k.right-aA,FA=window.innerWidth-m.right-SA,rA=m.width+FA,NA=Math.max(rA,p.width),RA=window.innerWidth-rN,xA=dQg(SA,[rN,Math.max(rN,RA-NA)]);Q.style.minWidth=rA+"px",Q.style.right=xA+"px"}const R=r(),x=window.innerHeight-rN*2,N=h.scrollHeight,U=window.getComputedStyle(E),K=parseInt(U.borderTopWidth,10),Y=parseInt(U.paddingTop,10),_=parseInt(U.borderBottomWidth,10),Z=parseInt(U.paddingBottom,10),V=K+Y+N+Z+_,W=Math.min(l.offsetHeight*5,V),q=window.getComputedStyle(h),X=parseInt(q.paddingTop,10),tA=parseInt(q.paddingBottom,10),IA=m.top+m.height/2-rN,QA=x-IA,sA=l.offsetHeight/2,DA=l.offsetTop+sA,CA=K+Y+DA,hA=V-CA;if(CA<=IA){const aA=R.length>0&&l===R[R.length-1].ref.current;Q.style.bottom="0px";const SA=E.clientHeight-h.offsetTop-h.offsetHeight,FA=Math.max(QA,sA+(aA?tA:0)+SA+_),rA=CA+FA;Q.style.height=rA+"px"}else{const aA=R.length>0&&l===R[0].ref.current;Q.style.top="0px";const FA=Math.max(IA,K+h.offsetTop+(aA?X:0)+sA)+hA;Q.style.height=FA+"px",h.scrollTop=CA-IA+h.offsetTop}Q.style.margin=`${rN}px 0`,Q.style.minHeight=W+"px",Q.style.maxHeight=x+"px",t?.(),requestAnimationFrame(()=>a.current=!0)}},[r,B.trigger,B.valueNode,Q,E,h,l,D,B.dir,t]);uh(()=>y(),[y]);const[w,u]=z.useState();uh(()=>{E&&u(window.getComputedStyle(E).zIndex)},[E]);const G=z.useCallback(m=>{m&&c.current===!0&&(y(),d?.(),c.current=!1)},[y,d]);return T.jsx(_fo,{scope:e,contentWrapper:Q,shouldExpandOnScrollRef:a,onScrollButtonChange:G,children:T.jsx("div",{ref:i,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:T.jsx(yQ.div,{...o,ref:s,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})},"SelectItemAlignedPosition")),eKI=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,align:t="start",collisionPadding:o=rN,...B}=A,C=yQg(e);return T.jsx(imA,{...C,...B,ref:I,align:t,collisionPadding:o,style:{boxSizing:"border-box",...B.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[_fo,wQg]=Ob(Wb,{}),tKI="SelectViewport",bfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,nonce:t,...o}=A,B=Vb(tKI,e),C=wQg(tKI,e),Q=Gi(I,B.onViewportChange),i=z.useRef(0);return T.jsxs(T.Fragment,{children:[T.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:t}),T.jsx(PpA.Slot,{scope:e,children:T.jsx(yQ.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:Q,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fo(o.onScroll,E=>{const n=E.currentTarget,{contentWrapper:s,shouldExpandOnScrollRef:r}=C;if(r?.current&&s){const a=Math.abs(i.current-n.scrollTop);if(a>0){const c=window.innerHeight-rN*2,h=parseFloat(s.style.minHeight),l=parseFloat(s.style.height),D=Math.max(h,l);if(D<c){const d=D+a,y=Math.min(c,d),w=d-y;s.style.height=y+"px",s.style.bottom==="0px"&&(n.scrollTop=w>0?w:0,s.style.justifyContent="flex-end")}}}i.current=n.scrollTop})})})]})},"SelectViewport")),Hfo="SelectGroup",[_CB,vfo]=Ob(Hfo),Tfo="SelectLabel",oKI=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,...t}=A,o=vfo(Tfo,e);return T.jsx(yQ.div,{id:o.id,...t,ref:I})},"SelectLabel")),uQg="SelectItem",[qfo,BKI]=Ob(uQg),CKI=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,value:t,disabled:o=!1,textValue:B,...C}=A,Q=LL(uQg,e),i=Vb(uQg,e),E=Q.value===t,[n,s]=z.useState(B??""),[r,a]=z.useState(!1),c=$M(y=>i.itemRefCallback?.(y,t,o)),h=Gi(I,c),l=_0(),D=z.useRef("touch");function d(y){Q.hasConsumerStoppedPropagationRef.current=y.isPropagationStopped(),Q.onUserSelect(t),Q.onOpenChange(!1)}return ZE(d,"handleSelect"),T.jsx(qfo,{scope:e,value:t,disabled:o,textId:l,isSelected:E,onItemTextChange:z.useCallback(y=>{s(w=>w||(y?.textContent??"").trim())},[]),children:T.jsx(PpA.ItemSlot,{scope:e,value:t,disabled:o,textValue:n,children:T.jsx(yQ.div,{role:"option","aria-labelledby":l,"data-highlighted":r?"":void 0,"aria-selected":E&&r,"data-state":E?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...C,ref:h,onFocus:fo(C.onFocus,()=>a(!0)),onBlur:fo(C.onBlur,()=>a(!1)),onClick:fo(C.onClick,y=>{o||D.current!=="mouse"&&d(y)}),onPointerUp:fo(C.onPointerUp,y=>{o||D.current==="mouse"&&d(y)}),onPointerDown:fo(C.onPointerDown,y=>{D.current=y.pointerType}),onPointerMove:fo(C.onPointerMove,y=>{D.current=y.pointerType,o?i.onItemLeave?.():D.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:fo(C.onPointerLeave,y=>{y.currentTarget===document.activeElement&&i.onItemLeave?.()}),onKeyDown:fo(C.onKeyDown,y=>{o||y.target!==y.currentTarget||i.searchRef?.current!==""&&y.key===" "||(ufo.includes(y.key)&&d(y),y.key===" "&&y.preventDefault())})})})})},"SelectItem")),LpA="SelectItemText",Zfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,className:t,style:o,...B}=A,C=LL(LpA,e),Q=Vb(LpA,e),i=BKI(LpA,e),E=kfo(LpA,e),[n,s]=z.useState(null),r=$M(d=>Q.itemTextRefCallback?.(d,i.value,i.disabled)),a=Gi(I,s,i.onItemTextChange,r),c=n?.textContent,h=z.useMemo(()=>T.jsx("option",{value:i.value,disabled:i.disabled,children:c},i.value),[i.disabled,i.value,c]),{onNativeOptionAdd:l,onNativeOptionRemove:D}=E;return uh(()=>(l(h),()=>D(h)),[l,D,h]),T.jsxs(T.Fragment,{children:[T.jsx(yQ.span,{id:i.textId,...B,ref:a}),i.isSelected&&C.valueNode&&!C.valueNodeHasChildren&&!moA(C.value)?dx.createPortal(B.children,C.valueNode):null]})},"SelectItemText")),Ofo="SelectItemIndicator",Wfo=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,...t}=A;return BKI(Ofo,e).isSelected?T.jsx(yQ.span,{"aria-hidden":!0,...t,ref:I}):null},"SelectItemIndicator")),QKI="SelectScrollUpButton",iKI=z.forwardRef(ZE(function(A,I){const e=Vb(QKI,A.__scopeSelect),t=wQg(QKI,A.__scopeSelect),[o,B]=z.useState(!1),C=Gi(I,t.onScrollButtonChange);return uh(()=>{if(e.viewport&&e.isPositioned){let Q=function(){const E=i.scrollTop>0;B(E)};ZE(Q,"handleScroll");const i=e.viewport;return Q(),i.addEventListener("scroll",Q),()=>i.removeEventListener("scroll",Q)}},[e.viewport,e.isPositioned]),o?T.jsx(sKI,{...A,ref:C,onAutoScroll:()=>{const{viewport:Q,selectedItem:i}=e;Q&&i&&(Q.scrollTop=Q.scrollTop-i.offsetHeight)}}):null},"SelectScrollUpButton")),EKI="SelectScrollDownButton",nKI=z.forwardRef(ZE(function(A,I){const e=Vb(EKI,A.__scopeSelect),t=wQg(EKI,A.__scopeSelect),[o,B]=z.useState(!1),C=Gi(I,t.onScrollButtonChange);return uh(()=>{if(e.viewport&&e.isPositioned){let Q=function(){const E=i.scrollHeight-i.clientHeight,n=Math.ceil(i.scrollTop)<E;B(n)};ZE(Q,"handleScroll");const i=e.viewport;return Q(),i.addEventListener("scroll",Q),()=>i.removeEventListener("scroll",Q)}},[e.viewport,e.isPositioned]),o?T.jsx(sKI,{...A,ref:C,onAutoScroll:()=>{const{viewport:Q,selectedItem:i}=e;Q&&i&&(Q.scrollTop=Q.scrollTop+i.offsetHeight)}}):null},"SelectScrollDownButton")),sKI=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,onAutoScroll:t,...o}=A,B=Vb("SelectScrollButton",e),C=z.useRef(null),Q=KpA(e),i=z.useCallback(()=>{C.current!==null&&(window.clearInterval(C.current),C.current=null)},[]);return z.useEffect(()=>()=>i(),[i]),uh(()=>{Q().find(n=>n.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[Q]),T.jsx(yQ.div,{"aria-hidden":!0,...o,ref:I,style:{flexShrink:0,...o.style},onPointerDown:fo(o.onPointerDown,()=>{C.current===null&&(C.current=window.setInterval(t,50))}),onPointerMove:fo(o.onPointerMove,()=>{B.onItemLeave?.(),C.current===null&&(C.current=window.setInterval(t,50))}),onPointerLeave:fo(o.onPointerLeave,()=>{i()})})},"SelectScrollButtonImpl")),aKI=z.forwardRef(ZE(function(A,I){const{__scopeSelect:e,...t}=A;return T.jsx(yQ.div,{"aria-hidden":!0,...t,ref:I})},"SelectSeparator")),Vfo="SelectBubbleInput",jfo=z.forwardRef(ZE(function({__scopeSelect:A,...I},e){const t=LL(Vfo,A),{value:o,onValueChange:B,required:C,disabled:Q,name:i,autoComplete:E,form:n,userSelection:s}=t,{nativeOptions:r,nativeSelectKey:a}=t,c=z.useRef(null),h=Gi(e,c),l=o??"",D=z.useRef(l),d=z.useRef(s),y=z.useRef(!1),w=Array.from(r).some(u=>(u.props.value??"")==="");return z.useEffect(()=>{const u=c.current;if(!u)return;const G=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(G,"value").set,k=s!==null&&s!==d.current;d.current=s;const S=D.current!==l;D.current=l;const R=k&&S;if(k&&!S&&s.value!==l&&!s.hasConsumerStoppedPropagation&&p){y.current=!0;try{p.call(u,s.value),u.dispatchEvent(new Event("change",{bubbles:!0}))}finally{y.current=!1,p.call(u,l)}return}const x=R&&!s.hasConsumerStoppedPropagation;if(S&&p){const N=new Event("change",{bubbles:x});p.call(u,l),u.dispatchEvent(N)}},[l,s]),T.jsxs(yQ.select,{"aria-hidden":!0,required:C,tabIndex:-1,name:i,autoComplete:E,disabled:Q,form:n,onChange:u=>{y.current||B(u.target.value)},...I,style:{...z4I,...I.style},ref:h,defaultValue:l,children:[moA(o)&&!w?T.jsx("option",{value:""}):null,Array.from(r)]},a)},"SelectBubbleInput"));function rKI(g){return typeof g=="function"}ZE(rKI,"isFunction");function moA(g){return g===""||g===void 0}ZE(moA,"shouldShowPlaceholder");function GQg(g){const A=$M(g),I=z.useRef(""),e=z.useRef(0),t=z.useCallback(B=>{const C=I.current+B;A(C);function Q(i){I.current=i,window.clearTimeout(e.current),i!==""&&(e.current=window.setTimeout(()=>Q(""),1e3))}ZE(Q,"updateSearch"),Q(C)},[A]),o=z.useCallback(()=>{I.current="",window.clearTimeout(e.current)},[]);return z.useEffect(()=>()=>window.clearTimeout(e.current),[]),[I,t,o]}ZE(GQg,"useTypeaheadSearch");function mQg(g,A,I){const t=A.length>1&&Array.from(A).every(i=>i===A[0])?A[0]:A,o=I?g.indexOf(I):-1;let B=cKI(g,Math.max(o,0));t.length===1&&(B=B.filter(i=>i!==I));const Q=B.find(i=>i.textValue.toLowerCase().startsWith(t.toLowerCase()));return Q!==I?Q:void 0}ZE(mQg,"findNextItem");function cKI(g,A){return g.map((I,e)=>g[(A+e)%g.length])}ZE(cKI,"wrapArray");const zfo=Mfo,Xfo=Rfo,hKI=z.forwardRef(({className:g,children:A,...I},e)=>T.jsxs(AKI,{ref:e,className:co("rf-flex rf-h-10 rf-w-full rf-items-center rf-justify-between rf-rounded-md rf-border rf-border-input rf-bg-background rf-px-3 rf-py-2 rf-text-sm rf-ring-offset-background rf-placeholder:text-muted-foreground focus:rf-outline-none focus:rf-ring-2 focus:rf-ring-ring focus:rf-ring-offset-2 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 [&>span]:rf-line-clamp-1",g),...I,children:[A,T.jsx(Nfo,{asChild:!0,children:T.jsx(RtA,{className:"rf-h-4 rf-w-4 rf-opacity-50"})})]}));hKI.displayName=AKI.displayName;const lKI=z.forwardRef(({className:g,...A},I)=>T.jsx(iKI,{ref:I,className:co("rf-flex rf-cursor-default rf-items-center rf-justify-center rf-py-1",g),...A,children:T.jsx(gco,{className:"rf-h-4 rf-w-4"})}));lKI.displayName=iKI.displayName;const DKI=z.forwardRef(({className:g,...A},I)=>T.jsx(nKI,{ref:I,className:co("rf-flex rf-cursor-default rf-items-center rf-justify-center rf-py-1",g),...A,children:T.jsx(RtA,{className:"rf-h-4 rf-w-4"})}));DKI.displayName=nKI.displayName;const dKI=z.forwardRef(({className:g,children:A,position:I="popper",...e},t)=>T.jsx(Jfo,{children:T.jsxs(gKI,{ref:t,className:co("rf-relative rf-z-[100] rf-max-h-96 rf-min-w-[8rem] rf-overflow-hidden rf-rounded-md rf-border rf-bg-white rf-text-black rf-shadow-md data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2",I==="popper"&&"data-[side=bottom]:rf-translate-y-1 data-[side=left]:-rf-translate-x-1 data-[side=right]:rf-translate-x-1 data-[side=top]:-rf-translate-y-1",g),position:I,...e,children:[T.jsx(lKI,{}),T.jsx(bfo,{className:co("rf-p-1",I==="popper"&&"rf-h-[var(--radix-select-trigger-height)] rf-w-full rf-min-w-[var(--radix-select-trigger-width)]"),children:A}),T.jsx(DKI,{})]})}));dKI.displayName=gKI.displayName;const $fo=z.forwardRef(({className:g,...A},I)=>T.jsx(oKI,{ref:I,className:co("rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-font-semibold",g),...A}));$fo.displayName=oKI.displayName;const yKI=z.forwardRef(({className:g,children:A,...I},e)=>T.jsxs(CKI,{ref:e,className:co("rf-relative rf-flex rf-w-full rf-cursor-default rf-select-none rf-items-center rf-rounded-sm rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-text-gray-800 rf-outline-none focus:rf-bg-gray-100 focus:rf-text-gray-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50",g),...I,children:[T.jsx("span",{className:"rf-absolute rf-left-2 rf-flex rf-h-3.5 rf-w-3.5 rf-items-center rf-justify-center",children:T.jsx(Wfo,{children:T.jsx(sF,{className:"rf-h-4 rf-w-4"})})}),T.jsx(Zfo,{children:A})]}));yKI.displayName=CKI.displayName;const ARo=z.forwardRef(({className:g,...A},I)=>T.jsx(aKI,{ref:I,className:co("-rf-mx-1 rf-my-1 rf-h-px rf-bg-muted",g),...A}));ARo.displayName=aKI.displayName;const wKI="Component Box (3MF)",pQg=g=>`${g.toFixed(1)} mm`;function gRo({open:g,onOpenChange:A,circuitJson:I,projectName:e}){noA();const[t,o]=z.useState(""),[B,C]=z.useState(null),[Q,i]=z.useState(null),[E,n]=z.useState(!1),[s,r]=z.useState(null);z.useEffect(()=>()=>{Q&&URL.revokeObjectURL(Q)},[Q]),z.useEffect(()=>{if(!g||t!==wKI)return;let c=!1;return n(!0),C(null),r(null),dSo(I).then(h=>{if(c)return;const l=Uint8Array.from(h.previewPng);C(h),i(URL.createObjectURL(new Blob([l.buffer],{type:"image/png"})))}).catch(h=>{c||r(h instanceof Error?h.message:String(h))}).finally(()=>{c||n(!1)}),()=>{c=!0}},[I,g,t]);const a=c=>{c||(o(""),C(null),i(null),r(null),n(!1)),A(c)};return T.jsx(Hb,{open:g,onOpenChange:a,children:T.jsxs(xL,{className:"rf-max-h-[90vh] rf-max-w-3xl rf-overflow-y-auto",children:[T.jsxs(FL,{children:[T.jsx(UL,{children:"Export Accessory"}),T.jsx(vb,{children:"Generate a printable accessory from the components in this circuit."})]}),T.jsxs("div",{className:"rf-grid rf-gap-5 md:rf-grid-cols-[220px_1fr]",children:[T.jsxs("div",{className:"rf-space-y-2",children:[T.jsx("label",{htmlFor:"accessory-select",className:"rf-text-sm rf-font-medium",children:"Accessory"}),T.jsxs(zfo,{value:t,onValueChange:c=>o(c),children:[T.jsx(hKI,{id:"accessory-select",children:T.jsx(Xfo,{placeholder:"Choose an accessory"})}),T.jsx(dKI,{children:T.jsx(yKI,{value:wKI,children:"Component Box"})})]}),T.jsx("p",{className:"rf-text-xs rf-leading-relaxed rf-text-zinc-500",children:"Creates grouped compartments with raised refdes labels as a multi-material 3MF."})]}),T.jsxs("div",{className:"rf-overflow-hidden rf-rounded-lg rf-border rf-border-zinc-200 rf-bg-zinc-50 dark:rf-border-zinc-800 dark:rf-bg-zinc-900",children:[T.jsxs("div",{className:"rf-flex rf-min-h-56 rf-items-center rf-justify-center",children:[!t&&T.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-3 rf-p-8 rf-text-center rf-text-zinc-500",children:[T.jsx(dco,{className:"rf-h-10 rf-w-10 rf-stroke-1"}),T.jsx("p",{className:"rf-text-sm",children:"Choose an accessory to generate its preview."})]}),E&&T.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-3 rf-p-8 rf-text-zinc-600 dark:rf-text-zinc-300",children:[T.jsx(mS,{className:"rf-h-8 rf-w-8 rf-animate-spin"}),T.jsx("p",{className:"rf-text-sm",children:"Generating component box…"})]}),s&&!E&&T.jsxs("div",{className:"rf-p-8 rf-text-center",children:[T.jsx("p",{className:"rf-text-sm rf-font-medium rf-text-red-600",children:"Could not generate the preview"}),T.jsx("p",{className:"rf-mt-1 rf-text-xs rf-text-red-500",children:s})]}),Q&&B&&!E&&T.jsx("img",{src:Q,alt:"Generated component box preview",className:"rf-block rf-h-auto rf-max-h-[300px] rf-w-full rf-object-contain"})]}),B&&!E&&T.jsxs("div",{className:"rf-flex rf-flex-wrap rf-gap-x-5 rf-gap-y-1 rf-border-t rf-border-zinc-200 rf-bg-white rf-px-4 rf-py-3 rf-text-xs rf-text-zinc-600 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-300",children:[T.jsxs("span",{children:[B.compartments.length," compartments"]}),T.jsxs("span",{children:[pQg(B.dimensions.width)," ×"," ",pQg(B.dimensions.depth)," ×"," ",pQg(B.dimensions.height)]})]})]})]}),T.jsxs(_O,{children:[T.jsx(si,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),T.jsxs(si,{disabled:!B||E,onClick:()=>{B&&r4I({generatedBox:B,projectName:e})},children:[T.jsx(NtA,{}),"Download 3MF"]})]})]})})}const YpA=g=>{const A=apA(aA=>aA.lastRunEvalVersion),I=Kc(aA=>aA.currentMainComponentPath),[e,t]=z.useState(null),[o,B]=z.useState(!1),[C,Q]=z.useState(!0),[i,E]=z.useState(!1),[n,s]=z.useState(null),[r,a]=z.useState(null),[c,h]=z.useState(!1),[l,D]=z.useState(null),[d,y]=z.useState(null),[w,u]=z.useState(!1),[G,m]=z.useState(!1),[p,k]=z.useState(!1),[S,R]=z.useState(!1),[x,N]=z.useState(null),U=ofo(),K=Kc(aA=>aA.pushEvent),Y=Kc(aA=>aA.recentEvents),_=z.useMemo(()=>Date.now(),[]);kko(aA=>{if(!(new Date(aA.created_at).valueOf()<_+500)){if(aA.event_type==="FILE_UPDATED"){B(!0);return}if(aA.event_type==="SNIPPET_SAVED"){B(!1),Q(!1),D("Snippet saved successfully."),u(!1);return}aA.event_type==="REQUEST_EXPORT"&&(m(!0),D("Export processing..."),u(!1)),aA.event_type==="EXPORT_CREATED"&&(D(`Export created: ${aA.exportFilePath}`),u(!1),m(!1))}}),z.useEffect(()=>{if(!i||n===null)return;const aA=Y.filter(rA=>new Date(rA.created_at).valueOf()>n),SA=aA.find(rA=>rA.event_type==="FAILED_TO_SAVE_SNIPPET"),FA=aA.find(rA=>rA.event_type==="SNIPPET_SAVED");SA&&(E(!1),s(null),y(SA.message??"Failed to save snippet. See console for error."),console.error(SA.message),u(!0),SA.error_code==="SNIPPET_UNSET"&&SA.available_snippet_names&&(a(SA.available_snippet_names),h(!0))),FA&&(E(!1),s(null),D("Snippet saved successfully."),u(!1))},[Y,i]);const Z=async()=>{E(!0),s(Date.now()),D(null),u(!1),await K({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:e})},W=Kc(aA=>aA.circuitJson)??g.circuitJson,q=z.useMemo(()=>{let aA="Untitled";if(I){const SA=I.split("/").pop();SA&&(aA=SA.replace(/\.[^.]+$/,""))}return(g.projectName??e??aA).replace(/\.(board|circuit)$/,"")},[I,g.projectName,e]),[X,tA]=z.useState(!1),[IA,QA]=z.useState(!1),{BugReportDialog:sA,openBugReportDialog:DA}=Qfo({onLoginRequired:g.onLoginRequired}),CA=async aA=>{x&&(await c4I({circuitJson:x.circuitJson,projectName:x.projectName,options:aA}),N(null))},hA=z.useMemo(()=>afo(g.autoroutingLog),[g.autoroutingLog]),nA=aA=>{if(!W){LC.error("No Circuit JSON to export");return}const SA=hA?.value.simpleRouteJson;if(aA==="LightBurn"){N({circuitJson:W,projectName:q}),k(!0);return}RSo({exportName:aA,circuitJson:W,simpleRouteJson:SA,projectName:q})};return T.jsxs(T.Fragment,{children:[T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1 rf-flex-shrink-0",children:[T.jsxs(MmA,{children:[T.jsx(SmA,{asChild:!0,children:T.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"File"})}),T.jsxs(vtA,{className:"rf-z-[101]",children:[!g.isWebEmbedded&&T.jsxs(T.Fragment,{children:[T.jsx(a0,{className:"rf-text-xs",onSelect:Z,disabled:i,children:i?"Saving...":"Push"}),parseInt(window.location.port)>5e3&&T.jsx(a0,{className:"rf-text-xs",onSelect:()=>{U.open()},children:"Order"}),T.jsx(a0,{className:"rf-text-xs",onSelect:()=>tA(!0),disabled:i,children:"Import"}),T.jsx(a0,{className:"rf-text-xs",onSelect:()=>{if(!HDA()){LC.error("Requires tscircuit token");return}QA(!0)},children:"AI Review"})]}),!g.isWebEmbedded&&g.onLoginRequired&&T.jsx(a0,{className:"rf-text-xs",onSelect:()=>{g.onLoginRequired?.()},children:"Sign In"}),!g.isWebEmbedded&&T.jsxs(HtA,{children:[T.jsx(mO,{className:"rf-text-xs",children:"Report Bug"}),T.jsx(btA,{children:T.jsxs(pO,{children:[T.jsx(a0,{className:"rf-text-xs",onSelect:()=>{DA()},children:"Report Entire Circuit"}),T.jsx(a0,{className:"rf-text-xs",disabled:!hA||!g.onReportAutoroutingLog,onSelect:()=>{!hA||!g.onReportAutoroutingLog||g.onReportAutoroutingLog(hA.key,{simpleRouteJson:hA.value.simpleRouteJson})},children:"Report Autorouter Bug"})]})})]}),T.jsxs(HtA,{children:[T.jsx(mO,{className:"rf-text-xs",disabled:G,children:G?"Exporting...":"Export"}),T.jsx(btA,{children:T.jsx(pO,{children:fSo.map((aA,SA)=>T.jsx(a0,{onSelect:()=>nA(aA.name),disabled:G||aA.name==="Simple Route JSON"&&!hA,children:T.jsx("span",{className:"rf-text-xs",children:aA.name})},SA))})})]}),T.jsx(a0,{className:"rf-text-xs",disabled:G,onSelect:()=>{if(!W){LC.error("No Circuit JSON to export");return}R(!0)},children:"Export Accessory…"}),!g.isWebEmbedded&&T.jsxs(HtA,{children:[T.jsx(mO,{className:"rf-text-xs",children:"Advanced"}),T.jsx(btA,{children:T.jsxs(pO,{children:[T.jsx(a0,{className:"rf-flex rf-items-center rf-gap-2",children:T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[T.jsx(roA,{id:"load-latest-eval",checked:g.shouldLoadLatestEval,onCheckedChange:aA=>{g.onChangeShouldLoadLatestEval?.(aA===!0)}}),T.jsx("label",{htmlFor:"load-latest-eval",className:"rf-text-xs rf-cursor-pointer",children:"Force Latest @tscircuit/eval"})]})}),A&&T.jsx(a0,{className:"rf-flex rf-items-center rf-gap-2",children:T.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:T.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/eval@",A]})})}),T.jsx(a0,{className:"rf-flex rf-items-center rf-gap-2",children:T.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:T.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/runframe@",Gko.version]})})}),T.jsx(a0,{className:"rf-flex rf-items-center rf-gap-2",onClick:()=>{window.open("/api/admin","_blank")},children:T.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:T.jsx("span",{className:"rf-text-xs",children:"CLI Admin Panel"})})})]})})]})]}),T.jsx(bPI,{open:w,onOpenChange:u,children:T.jsxs(RCg,{children:[T.jsxs(NCg,{children:[T.jsx(FCg,{children:"Error Saving Snippet"}),T.jsx(UCg,{children:d})]}),T.jsx(xCg,{children:T.jsx(JCg,{onClick:()=>u(!1),children:"Dismiss"})})]})}),T.jsx(pko,{snippetNames:r??[],onSelect:async aA=>{E(!0),s(Date.now()),t(aA),await K({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:aA}),h(!1)},onCancel:()=>h(!1),isOpen:c})]}),T.jsxs(MmA,{children:[T.jsx(SmA,{asChild:!0,children:T.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"View"})}),T.jsx(vtA,{className:"rf-z-[101]",children:T.jsxs(HtA,{children:[T.jsx(mO,{className:"rf-text-xs",children:"Schematic"}),T.jsx(btA,{children:T.jsxs(pO,{children:[T.jsx(a0,{className:"rf-flex rf-items-center rf-gap-2",onSelect:aA=>aA.preventDefault(),children:T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[T.jsx(roA,{id:"show-schematic-ports",checked:g.showSchematicPorts,onCheckedChange:aA=>{g.onChangeShowSchematicPorts?.(aA===!0)}}),T.jsx("label",{htmlFor:"show-schematic-ports",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Ports"})]})}),T.jsx(a0,{className:"rf-flex rf-items-center rf-gap-2",onSelect:aA=>aA.preventDefault(),children:T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[T.jsx(roA,{id:"show-schematic-grid",checked:g.showSchematicDebugGrid,onCheckedChange:aA=>{g.onChangeShowSchematicDebugGrid?.(aA===!0)}}),T.jsx("label",{htmlFor:"show-schematic-grid",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Grid"})]})})]})})]})})]})]}),sA,T.jsx(ifo,{open:p,onOpenChange:k,onExport:CA}),W&&T.jsx(gRo,{open:S,onOpenChange:R,circuitJson:W,projectName:q}),T.jsx(s4I,{isOpen:X,onClose:()=>tA(!1)}),T.jsx(c2o,{isOpen:IA,onClose:()=>QA(!1),packageName:e}),T.jsx(gGI,{position:"top-center",reverseOrder:!1,containerStyle:{zIndex:1e5},toastOptions:{className:"rf-break-all",style:{zIndex:1e5}}}),T.jsx(U.OrderDialog,{isOpen:U.isOpen,onClose:U.close,stage:U.stage,setStage:U.setStage})]})};var IRo=Object.defineProperty,Wy=(g,A)=>IRo(g,"name",{value:A,configurable:!0}),[kQg,bCB]=hk("Tooltip",[ML]),MQg=ML(),eRo="TooltipProvider",tRo=700,SQg="tooltip.open",[oRo,fQg]=kQg(eRo),BRo=Wy(g=>{const{__scopeTooltip:A,delayDuration:I=tRo,skipDelayDuration:e=300,disableHoverableContent:t=!1,children:o}=g,B=z.useRef(!0),C=z.useRef(!1),Q=z.useRef(0);return z.useEffect(()=>{const i=Q.current;return()=>window.clearTimeout(i)},[]),T.jsx(oRo,{scope:A,isOpenDelayedRef:B,delayDuration:I,onOpen:z.useCallback(()=>{e<=0||(window.clearTimeout(Q.current),B.current=!1)},[e]),onClose:z.useCallback(()=>{e<=0||(window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>B.current=!0,e))},[e]),isPointerInTransitRef:C,onPointerInTransitChange:z.useCallback(i=>{C.current=i},[]),disableHoverableContent:t,children:o})},"TooltipProvider"),RQg="Tooltip",[CRo,_pA]=kQg(RQg),QRo=Wy(g=>{const{__scopeTooltip:A,children:I,open:e,defaultOpen:t,onOpenChange:o,disableHoverableContent:B,delayDuration:C}=g,Q=fQg(RQg,g.__scopeTooltip),i=MQg(A),[E,n]=z.useState(null),[s,r]=z.useState(void 0),a=_0(),c=z.useRef(0),h=B??Q.disableHoverableContent,l=C??Q.delayDuration,D=z.useRef(!1),[d,y]=xR({prop:e,defaultProp:t??!1,onChange:Wy(k=>{k?(Q.onOpen(),document.dispatchEvent(new CustomEvent(SQg))):Q.onClose(),o?.(k)},"onChange"),caller:RQg}),w=z.useMemo(()=>d?D.current?"delayed-open":"instant-open":"closed",[d]),u=z.useCallback(()=>{window.clearTimeout(c.current),c.current=0,D.current=!1,y(!0)},[y]),G=z.useCallback(()=>{window.clearTimeout(c.current),c.current=0,y(!1)},[y]),m=z.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>{D.current=!0,y(!0),c.current=0},l)},[l,y]);z.useEffect(()=>()=>{c.current&&(window.clearTimeout(c.current),c.current=0)},[]);const p=s??a;return T.jsx(JtA,{...i,children:T.jsx(CRo,{scope:A,contentId:p,setContentId:r,open:d,stateAttribute:w,trigger:E,onTriggerChange:n,onTriggerEnter:z.useCallback(()=>{Q.isOpenDelayedRef.current?m():u()},[Q.isOpenDelayedRef,m,u]),onTriggerLeave:z.useCallback(()=>{h?G():(window.clearTimeout(c.current),c.current=0)},[G,h]),onOpen:u,onClose:G,disableHoverableContent:h,children:I})})},"Tooltip"),uKI="TooltipTrigger",iRo=z.forwardRef(Wy(function(A,I){const{__scopeTooltip:e,"aria-describedby":t,...o}=A,B=_pA(uKI,e),C=fQg(uKI,e),Q=MQg(e),i=z.useRef(null),E=Gi(I,i,B.onTriggerChange),n=z.useRef(!1),s=z.useRef(!1),r=z.useCallback(()=>n.current=!1,[]);return z.useEffect(()=>()=>document.removeEventListener("pointerup",r),[r]),T.jsx(QmA,{asChild:!0,...Q,children:T.jsx(yQ.button,{"aria-describedby":B.open?NKI(t,B.contentId):t,"data-state":B.stateAttribute,...o,ref:E,onPointerMove:fo(A.onPointerMove,a=>{a.pointerType!=="touch"&&!s.current&&!C.isPointerInTransitRef.current&&(B.onTriggerEnter(),s.current=!0)}),onPointerLeave:fo(A.onPointerLeave,()=>{B.onTriggerLeave(),s.current=!1}),onPointerDown:fo(A.onPointerDown,()=>{B.open&&B.onClose(),n.current=!0,document.addEventListener("pointerup",r,{once:!0})}),onFocus:fo(A.onFocus,()=>{n.current||B.onOpen()}),onBlur:fo(A.onBlur,B.onClose),onClick:fo(A.onClick,B.onClose)})})},"TooltipTrigger")),ERo="TooltipPortal",[HCB,nRo]=kQg(ERo,{forceMount:void 0}),poA="TooltipContent",GKI=z.forwardRef(Wy(function(A,I){const e=nRo(poA,A.__scopeTooltip),{forceMount:t=e.forceMount,side:o="top",...B}=A,C=_pA(poA,A.__scopeTooltip);return T.jsx(AS,{present:t||C.open,children:C.disableHoverableContent?T.jsx(mKI,{side:o,...B,ref:I}):T.jsx(sRo,{side:o,...B,ref:I})})},"TooltipContent")),sRo=z.forwardRef(Wy(function(A,I){const e=_pA(poA,A.__scopeTooltip),t=fQg(poA,A.__scopeTooltip),o=z.useRef(null),B=Gi(I,o),[C,Q]=z.useState(null),{trigger:i,onClose:E}=e,n=o.current,{onPointerInTransitChange:s}=t,r=z.useCallback(()=>{Q(null),s(!1)},[s]),a=z.useCallback((c,h)=>{const l=c.currentTarget,D={x:c.clientX,y:c.clientY},d=pKI(D,l.getBoundingClientRect()),y=kKI(D,d),w=MKI(h.getBoundingClientRect()),u=fKI([...y,...w]);Q(u),s(!0)},[s]);return z.useEffect(()=>()=>r(),[r]),z.useEffect(()=>{if(i&&n){const c=Wy(l=>a(l,n),"handleTriggerLeave"),h=Wy(l=>a(l,i),"handleContentLeave");return i.addEventListener("pointerleave",c),n.addEventListener("pointerleave",h),()=>{i.removeEventListener("pointerleave",c),n.removeEventListener("pointerleave",h)}}},[i,n,a,r]),z.useEffect(()=>{if(C){const c=Wy(h=>{const l=h.target,D={x:h.clientX,y:h.clientY},d=i?.contains(l)||n?.contains(l),y=!SKI(D,C);d?r():y&&(r(),E())},"handleTrackPointerGrace");return document.addEventListener("pointermove",c),()=>document.removeEventListener("pointermove",c)}},[i,n,C,E,r]),T.jsx(mKI,{...A,ref:B})},"TooltipContentHoverable")),aRo=kXg("TooltipContent"),mKI=z.forwardRef(Wy(function(A,I){const{__scopeTooltip:e,children:t,"aria-label":o,id:B,onEscapeKeyDown:C,onPointerDownOutside:Q,...i}=A,E=_pA(poA,e),n=MQg(e),{onClose:s}=E,[r,a]=z.useState(null),c=Gi(I,a);jGA(r),z.useEffect(()=>(document.addEventListener(SQg,s),()=>document.removeEventListener(SQg,s)),[s]),z.useEffect(()=>{if(E.trigger){const l=Wy(D=>{D.target instanceof Node&&D.target.contains(E.trigger)&&s()},"handleScroll");return window.addEventListener("scroll",l,{capture:!0}),()=>window.removeEventListener("scroll",l,{capture:!0})}},[E.trigger,s]);const{setContentId:h}=E;return uh(()=>(h(B),()=>{h(void 0)}),[B,h]),T.jsx(xtA,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:C,onPointerDownOutside:Q,onFocusOutside:l=>l.preventDefault(),onDismiss:s,children:T.jsxs(imA,{"data-state":E.stateAttribute,role:o?void 0:"tooltip",id:o?void 0:E.contentId,...n,...i,ref:c,style:{...i.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[T.jsx(aRo,{children:t}),o?T.jsx(Dfo,{id:E.contentId,role:"tooltip",children:o}):null]})})},"TooltipContentImpl"));function pKI(g,A){const I=Math.abs(A.top-g.y),e=Math.abs(A.bottom-g.y),t=Math.abs(A.right-g.x),o=Math.abs(A.left-g.x);switch(Math.min(I,e,t,o)){case o:return"left";case t:return"right";case I:return"top";case e:return"bottom";default:throw new Error("unreachable")}}Wy(pKI,"getExitSideFromRect");function kKI(g,A,I=5){const e=[];switch(A){case"top":e.push({x:g.x-I,y:g.y+I},{x:g.x+I,y:g.y+I});break;case"bottom":e.push({x:g.x-I,y:g.y-I},{x:g.x+I,y:g.y-I});break;case"left":e.push({x:g.x+I,y:g.y-I},{x:g.x+I,y:g.y+I});break;case"right":e.push({x:g.x-I,y:g.y-I},{x:g.x-I,y:g.y+I});break}return e}Wy(kKI,"getPaddedExitPoints");function MKI(g){const{top:A,right:I,bottom:e,left:t}=g;return[{x:t,y:A},{x:I,y:A},{x:I,y:e},{x:t,y:e}]}Wy(MKI,"getPointsFromRect");function SKI(g,A){const{x:I,y:e}=g;let t=!1;for(let o=0,B=A.length-1;o<A.length;B=o++){const C=A[o],Q=A[B],i=C.x,E=C.y,n=Q.x,s=Q.y;E>e!=s>e&&I<(n-i)*(e-E)/(s-E)+i&&(t=!t)}return t}Wy(SKI,"isPointInPolygon");function fKI(g){const A=g.slice();return A.sort((I,e)=>I.x<e.x?-1:I.x>e.x?1:I.y<e.y?-1:I.y>e.y?1:0),RKI(A)}Wy(fKI,"getHull");function RKI(g){if(g.length<=1)return g.slice();const A=[];for(let e=0;e<g.length;e++){const t=g[e];for(;A.length>=2;){const o=A[A.length-1],B=A[A.length-2];if((o.x-B.x)*(t.y-B.y)>=(o.y-B.y)*(t.x-B.x))A.pop();else break}A.push(t)}A.pop();const I=[];for(let e=g.length-1;e>=0;e--){const t=g[e];for(;I.length>=2;){const o=I[I.length-1],B=I[I.length-2];if((o.x-B.x)*(t.y-B.y)>=(o.y-B.y)*(t.x-B.x))I.pop();else break}I.push(t)}return I.pop(),A.length===1&&I.length===1&&A[0].x===I[0].x&&A[0].y===I[0].y?A:A.concat(I)}Wy(RKI,"getHullPresorted");function NKI(...g){const A=new Set;for(const I of g)if(typeof I=="string")for(const e of String(I).trim().split(/\s+/))e&&A.add(e);return A.size>0?Array.from(A).join(" "):void 0}Wy(NKI,"concatAriaDescribedby");const NQg=BRo,xQg=QRo,FQg=iRo,bpA=z.forwardRef(({className:g,sideOffset:A=4,...I},e)=>T.jsx(GKI,{ref:e,sideOffset:A,className:co("z-50 overflow-hidden rounded-md bg-slate-900 px-3 py-1.5 text-xs text-slate-50 animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:bg-slate-50 dark:text-slate-900",g),...I}));bpA.displayName=GKI.displayName;const rRo="24b58135-86c7-4e4b-bf6e-cca862bc4b26",xKI="runframe-crisp-chat-script",cRo="tscircuit.com",koA=g=>{window.$crisp=window.$crisp||[],window.$crisp.push(g)},hRo=()=>{if(window.$crisp=window.$crisp||[],window.CRISP_WEBSITE_ID=rRo,window.__RUNFRAME_CRISP_CONFIGURED__||(window.__RUNFRAME_CRISP_CONFIGURED__=!0,koA(["do","chat:hide"]),koA(["on","chat:closed",()=>koA(["do","chat:hide"])])),!document.getElementById(xKI)){const g=document.createElement("script");g.id=xKI,g.src="https://client.crisp.chat/l.js",g.async=!0,document.head.appendChild(g)}},lRo=()=>{hRo(),koA(["do","chat:show"]),koA(["do","chat:open"])},DRo=({isCli:g,hostname:A=typeof window<"u"?window.location.hostname:void 0}={})=>A?.toLowerCase()===cRo?!1:!!g,dRo=()=>T.jsx(NQg,{children:T.jsxs(xQg,{children:[T.jsx(FQg,{asChild:!0,children:T.jsx(si,{type:"button",variant:"ghost",size:"icon","aria-label":"Get Support or Give Feedback",onClick:lRo,className:"rf-h-8 rf-w-8",children:T.jsx(lco,{className:"rf-h-4 rf-w-4 rf-text-gray-500"})})}),T.jsx(bpA,{side:"bottom",children:"Get Support or Give Feedback"})]})}),wF="rf-h-[620px] rf-min-h-full rf-max-h-full",FKI=["assembly","pinout","analog_simulation","bom","circuit_json","errors","render_log","autorouting","solvers"],UQg=g=>g instanceof Error?g.message:"An unknown error occurred",UKI=({platformConfig:g,code:A,fsMap:I,onRunClicked:e=void 0,errorMessage:t,errorStack:o,circuitJson:B,autoroutingGraphics:C,showRightHeaderContent:Q=!0,showCodeTab:i=!1,codeTabContent:E,showJsonTab:n=!0,showRenderLogTab:s=!0,onActiveTabChange:r,renderLog:a,showImportAndFormatButtons:c=!0,className:h,headerClassName:l,leftHeaderContent:D,readOnly:d,isStreaming:y,autoroutingLog:w,onReportAutoroutingLog:u,isRunningCode:G,hasCodeChangedSinceLastRun:m,onEditEvent:p,editEvents:k,defaultActiveTab:S,defaultTab:R,availableTabs:x,extraTabs:N,autoRotate3dViewerDisabled:U,showSchematicDebugGrid:K=!1,showSchematicPorts:Y=!1,onChangeShowSchematicDebugGrid:_,onChangeShowSchematicPorts:Z,showToggleFullScreen:V=!0,defaultToFullScreen:W=!1,activeEffectName:q,allowSelectingVersion:X=uJ("TSCIRCUIT_ALLOW_SELECTING_EVAL_VERSION")!==!1,showFileMenu:tA=!1,isWebEmbedded:IA=!1,isCli:QA=!1,projectName:sA,schematicSvgOptions:DA,hideSchematicInAnalogSimulation:CA=!1,onRerunWithDebug:hA,solverEvents:nA,autoroutingPhases:aA,onPcbBoundsSelected:SA})=>{noA();const{versions:FA,latestVersion:rA,lastRunEvalVersion:NA,search:RA,setSearch:xA,selectVersion:bA}=mko(X),JA=z.useMemo(()=>B?B.filter(Jg=>Jg&&"error_type"in Jg||Jg.type.includes("error")):null,[B]),mA=z.useMemo(()=>B?B.filter(Jg=>Jg&&"warning_type"in Jg||Jg.type.includes("warning")):null,[B]),LA=z.useMemo(()=>B?B.some(Jg=>Jg.type==="schematic_group"):!0,[B]),dA=z.useMemo(()=>B?.some(Jg=>Jg.type==="pcb_panel"),[B]),HA=(!x||x.includes("schematic"))&&LA&&!dA,{controller:WA,focusSchematicComponent:Qg}=Dmo(),{controller:YA,focusPcbComponent:uA}=bro(),OA=!x||x.includes("pcb")?({source_component_id:Jg})=>{const AI=B?.find(Og=>Og.type==="pcb_component"&&Og.source_component_id===Jg);AI?.type==="pcb_component"&&(uA(AI.pcb_component_id),YI("pcb"))}:void 0,$A=HA?({source_component_id:Jg})=>{const AI=B?.find(Og=>Og.type==="schematic_component"&&Og.source_component_id===Jg);AI?.type==="schematic_component"&&(Qg(AI.schematic_component_id),YI("schematic"))}:void 0,og=z.useMemo(()=>!B||!G||JA?.length?!1:B.some(AI=>AI.type==="simulation_experiment")&&!kpt(B),[B,JA,G]),dg=z.useMemo(()=>JA?.find(Jg=>Jg.type.startsWith("simulation_")),[JA]);xPI({errorMessage:t,errorStack:o,circuitJsonErrors:JA});const Sg=z.useMemo(()=>oBo(N),[N]),Bg=[...["pcb","schematic","cad",...FKI].filter(Jg=>(!x||x.includes(Jg))&&(Jg!=="render_log"||s)),...i?["code"]:[],...Sg.map(Jg=>Jg.tabId)],Yg=S??R,iI=Yg&&Bg.includes(Yg)?Yg:x?.find(Jg=>Bg.includes(Jg))??Bg[0]??"pcb",[GA,ng]=gq("runframe-active-tab",iI,S),pg=Bg.includes(GA)?GA:iI;z.useEffect(()=>{GA!==pg&&(ng(pg),r?.(pg))},[GA,pg,ng,r]);const Ug=Sg.find(Jg=>Jg.tabId===pg);FPI({source:"runframe",component:"CircuitJsonPreview",isWebEmbedded:IA,activeTab:pg});const[mg,Rg]=z.useState(null),[Kg,gg]=z.useState(W),[ag,wg]=z.useState(K),[Hg,II]=z.useState(Y),BI=_?K:ag,$g=Z?Y:Hg,pI=_??wg,DI=Z??II;Hmo(Kg);const YI=z.useCallback(Jg=>{ng(Jg),r?.(Jg)},[r,ng]),Ae=()=>{gg(!Kg)};z.useEffect(()=>{t&&(pg!=="errors"&&Rg(pg),YI("errors"))},[t]),z.useEffect(()=>{(pg==="code"||pg==="errors")&&B&&!t&&YI(mg&&Bg.includes(mg)?mg:iI)},[B]);const PA=z.useCallback(Jg=>{window.TSCIRCUIT_3D_OBJECT_REF=Jg===null?void 0:Jg},[]);return T.jsx("div",{className:co("flex flex-col relative rf-overflow-x-hidden rf-h-full",h),children:T.jsx("div",{className:co("rf-md:sticky rf-md:top-2 rf-h-full",Kg&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-h-full rf-bg-white rf-overflow-hidden"),children:T.jsxs(jvA,{value:pg,onValueChange:YI,className:"rf-flex-grow rf-flex rf-flex-col rf-h-full",children:[T.jsxs("div",{className:co("rf-flex rf-flex-wrap rf-items-center rf-gap-2 rf-p-2 rf-pb-0 rf-shrink-0",l),children:[T.jsxs("div",{className:co("rf-flex rf-flex-1 rf-min-w-0 rf-items-center",(D||tA)&&"rf-basis-48"),children:[D,tA&&!D&&T.jsx(YpA,{isWebEmbedded:IA,circuitJson:B,projectName:sA,autoroutingLog:w,onReportAutoroutingLog:u,showSchematicDebugGrid:BI,onChangeShowSchematicDebugGrid:pI,showSchematicPorts:$g,onChangeShowSchematicPorts:DI}),!D&&!tA&&G&&T.jsx(mS,{className:"rf-w-4 rf-h-4 rf-animate-spin"})]}),a&&a.progress!==1&&!t&&T.jsxs("div",{className:"rf-flex rf-w-48 rf-max-w-full rf-shrink-0 rf-items-center rf-gap-2 rf-min-w-0",children:[T.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0 rf-flex-1",title:q??a.lastRenderEvent?.phase??"",children:q??a.lastRenderEvent?.phase}),T.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white rf-flex-shrink-0",children:T.jsx(mS,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),T.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums rf-flex-shrink-0 rf-w-[6ch] rf-text-right",children:[((a.progress??0)*100).toFixed(1),"%"]})]}),Q&&DRo({isCli:QA})&&T.jsx(dRo,{}),T.jsxs("div",{className:"rf-flex rf-min-w-0 rf-max-w-full rf-items-center rf-gap-2 rf-ml-auto",children:[Q&&T.jsxs(vDA,{className:"rf-min-w-0 rf-justify-start rf-overflow-x-auto rf-overflow-y-hidden",children:[i&&T.jsx(mx,{value:"code",children:"Code"}),!x||x.includes("pcb")?T.jsxs(mx,{value:"pcb",className:"rf-whitespace-nowrap",children:[B&&T.jsx("span",{className:co("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",m?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}):null,!x||x.includes("schematic")?T.jsxs(mx,{value:"schematic",className:co("rf-whitespace-nowrap",B&&!LA&&"rf-opacity-50"),disabled:B?!LA||dA:!1,children:[B&&T.jsx("span",{className:co("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",m?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}):null,!x||x.includes("cad")?T.jsxs(mx,{value:"cad",children:[B&&T.jsx("span",{className:co("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",m?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}):null,!["pcb","cad","schematic"].includes(pg)&&T.jsx(mx,{value:pg,children:Ug?.tabName??OeI(pg)}),T.jsxs(MmA,{children:[T.jsx(SmA,{asChild:!0,children:T.jsxs("button",{type:"button","aria-label":"More views",className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[T.jsx(Qco,{className:"rf-w-4 rf-h-4"}),(JA&&JA.length>0||t)&&T.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),T.jsxs(vtA,{className:"rf-*:text-xs rf-z-[101]",children:[Sg.map(Jg=>T.jsxs(a0,{onSelect:()=>YI(Jg.tabId),children:[pg===Jg.tabId?T.jsx(sF,{className:"rf-w-3 rf-h-3"}):T.jsx(Oog,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),T.jsx("div",{className:"rf-pr-2",children:Jg.tabName})]},Jg.tabId)),FKI.filter(Jg=>!x||x.includes(Jg)).map(Jg=>T.jsxs(a0,{onSelect:()=>YI(Jg),children:[pg!==Jg&&T.jsx(Oog,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),pg===Jg&&T.jsx(sF,{className:"rf-w-3 rf-h-3"}),T.jsx("div",{className:"rf-pr-2",children:OeI(Jg)}),Jg==="errors"&&(JA&&JA.length>0||t)&&T.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:t?1:JA?.length}),Jg==="solvers"&&nA&&nA.length>0&&T.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-min-w-[12px] rf-h-3 rf-px-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-blue-500 rf-rounded-full",children:nA.length})]},Jg)),T.jsx(a0,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:T.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",UPI.split(".").map((Jg,AI)=>AI===2?parseInt(Jg)+1:Jg).join(".")]})}),X?T.jsxs(HtA,{onOpenChange:Jg=>!Jg&&xA(""),children:[T.jsx(mO,{className:"rf-text-xs rf-opacity-60",children:T.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",NA??rA??"latest"]})}),T.jsx(btA,{children:T.jsxs(pO,{className:"rf-*:text-xs rf-w-40 rf-max-h-[200px] rf-overflow-y-auto",children:[T.jsx("div",{className:"rf-p-1",children:T.jsx(yCg,{value:RA,onChange:Jg=>xA(Jg.target.value),placeholder:"Search...",className:"rf-h-7 rf-text-xs"})}),T.jsx(KFI,{}),T.jsx(a0,{onSelect:()=>bA(null),children:rA?`${rA} (latest)`:"latest"}),FA.map(Jg=>T.jsx(a0,{onSelect:()=>bA(Jg),children:Jg},Jg))]})})]}):NA&&T.jsx(a0,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:T.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",NA]})})]})]})]}),V&&T.jsx(si,{onClick:Ae,"aria-label":Kg?"Exit fullscreen":"Enter fullscreen",variant:"ghost",className:"rf-shrink-0",children:Kg?T.jsx(Dco,{size:16}):T.jsx(aco,{size:16})})]})]}),i&&T.jsx(Fy,{value:"code",className:"rf-flex-grow rf-min-h-0 rf-overflow-hidden",children:T.jsx("div",{className:"rf-h-full",children:E})}),(!x||x.includes("pcb"))&&T.jsx(Fy,{value:"pcb",className:"rf-min-h-0",children:T.jsx("div",{className:"rf-overflow-hidden rf-h-full",children:T.jsx(GS,{fallbackRender:({error:Jg})=>T.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:T.jsxs("div",{className:"rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),T.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:UQg(Jg)})]})}),children:B?T.jsx(_mo,{controller:YA,focusOnHover:!1,circuitJson:B,debugGraphics:C,onBoundsSelected:SA,onViewSchematicComponent:$A,containerClassName:"rf-h-full rf-w-full rf-min-h-0",onEditEventsChanged:Jg=>{if(p)for(const AI of Jg)p(AI)}}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("assembly"))&&T.jsx(Fy,{value:"assembly",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallback:T.jsx("div",{children:"Error loading Assembly"}),children:B?T.jsx(dmo,{circuitJson:B,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("pinout"))&&T.jsx(Fy,{value:"pinout",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallback:T.jsx("div",{children:"Error loading Pinout Viewer"}),children:B?T.jsx(ymo,{circuitJson:B,containerStyle:{height:"100%"}}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("schematic"))&&T.jsx(Fy,{value:"schematic",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto rf-bg-white",wF),children:T.jsx(GS,{fallbackRender:({error:Jg})=>T.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:T.jsxs("div",{className:"rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),T.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:UQg(Jg)})]})}),children:B?T.jsx(Imo,{platformConfig:g,onViewPcbComponent:OA,controller:WA,circuitJson:B,containerStyle:{height:"100%"},debugGrid:BI,showSchematicPorts:$g,css:DA?.css,className:DA?.className}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("cad"))&&T.jsx(Fy,{value:"cad",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallbackRender:({error:Jg,resetErrorBoundary:AI})=>T.jsx(Hro,{error:Jg,resetErrorBoundary:AI}),children:B?T.jsx(eBo,{ref:PA,circuitJson:B,autoRotateDisabled:U,onViewSchematicComponent:$A},`cad-${Kg}`):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("analog_simulation"))&&T.jsx(Fy,{value:"analog_simulation",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallback:T.jsx("div",{children:"Error loading Analog Simulation"}),children:B?dg?T.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:T.jsxs("div",{className:"rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error running analog simulation"}),T.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:dg.message})]})}):og?T.jsx("div",{className:"rf-flex rf-h-full rf-min-h-[300px] rf-items-center rf-justify-center rf-bg-slate-50",children:T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-text-sm rf-text-slate-600",children:[T.jsx(mS,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Running analog simulation..."]})}):T.jsx(lmo,{circuitJson:B,hideSchematic:CA,containerStyle:{height:"100%"}}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("bom"))&&T.jsx(Fy,{value:"bom",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallbackRender:({error:Jg})=>T.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:T.jsxs("div",{className:"rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),T.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:UQg(Jg)})]})}),children:B?T.jsx(Ymo,{circuitJson:B}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("circuit_json"))&&T.jsx(Fy,{value:"circuit_json",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallback:T.jsx("div",{children:"Error loading JSON viewer"}),children:B?T.jsx(Gmo,{elements:B}):T.jsx(QP,{onRunClicked:e})})})}),(!x||x.includes("errors"))&&T.jsx(Fy,{value:"errors",className:"rf-h-full rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-hidden",wF),children:t||JA&&JA.length>0||B?T.jsx(wlo,{code:A,fsMap:I,circuitJsonErrors:JA,circuitJsonWarnings:mA,errorMessage:t,errorStack:o,circuitJson:B,evalVersion:NA,autoroutingLog:w,onReportAutoroutingLog:u}):T.jsx(QP,{onRunClicked:e})})}),s&&(!x||x.includes("render_log"))&&T.jsx(Fy,{value:"render_log",className:"rf-min-h-0",children:T.jsx(qmo,{renderLog:a,onRerunWithDebug:hA})}),(!x||x.includes("autorouting"))&&T.jsx(Fy,{value:"autorouting",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-auto",wF),children:T.jsx(GS,{fallback:T.jsx("div",{className:"rf-p-4",children:"Error loading autorouting captures"}),children:T.jsx(uko,{circuitJson:B,phases:aA,isRunning:G})})})}),(!x||x.includes("solvers"))&&T.jsx(Fy,{value:"solvers",className:"rf-min-h-0",children:T.jsx("div",{className:co("rf-overflow-hidden",wF),children:T.jsx(GS,{fallback:T.jsx("div",{children:"Error loading Solvers view"}),children:T.jsx(Bko,{solverEvents:nA})})})}),Sg.map(Jg=>T.jsx(BBo,{tab:Jg,active:pg===Jg.tabId,isFullScreen:Kg},Jg.tabId))]})})})};const JKI=Symbol("Comlink.proxy"),yRo=Symbol("Comlink.endpoint"),PKI=Symbol("Comlink.releaseProxy"),JQg=Symbol("Comlink.finalizer"),HpA=Symbol("Comlink.thrown"),KKI=g=>typeof g=="object"&&g!==null||typeof g=="function",wRo={canHandle:g=>KKI(g)&&g[JKI],serialize(g){const{port1:A,port2:I}=new MessageChannel;return YKI(g,A),[I,[I]]},deserialize(g){return g.start(),bKI(g)}},uRo={canHandle:g=>KKI(g)&&HpA in g,serialize({value:g}){let A;return g instanceof Error?A={isError:!0,value:{message:g.message,name:g.name,stack:g.stack}}:A={isError:!1,value:g},[A,[]]},deserialize(g){throw g.isError?Object.assign(new Error(g.value.message),g.value):g.value}},LKI=new Map([["proxy",wRo],["throw",uRo]]);function GRo(g,A){for(const I of g)if(A===I||I==="*"||I instanceof RegExp&&I.test(A))return!0;return!1}function YKI(g,A=globalThis,I=["*"]){A.addEventListener("message",function e(t){if(!t||!t.data)return;if(!GRo(I,t.origin)){console.warn(`Invalid origin '${t.origin}' for comlink proxy`);return}const{id:o,type:B,path:C}=Object.assign({path:[]},t.data),Q=(t.data.argumentList||[]).map(jb);let i;try{const E=C.slice(0,-1).reduce((s,r)=>s[r],g),n=C.reduce((s,r)=>s[r],g);switch(B){case"GET":i=n;break;case"SET":E[C.slice(-1)[0]]=jb(t.data.value),i=!0;break;case"APPLY":i=n.apply(E,Q);break;case"CONSTRUCT":{const s=new n(...Q);i=KQg(s)}break;case"ENDPOINT":{const{port1:s,port2:r}=new MessageChannel;YKI(g,r),i=SRo(s,[s])}break;case"RELEASE":i=void 0;break;default:return}}catch(E){i={value:E,[HpA]:0}}Promise.resolve(i).catch(E=>({value:E,[HpA]:0})).then(E=>{const[n,s]=ZpA(E);A.postMessage(Object.assign(Object.assign({},n),{id:o}),s),B==="RELEASE"&&(A.removeEventListener("message",e),_KI(A),JQg in g&&typeof g[JQg]=="function"&&g[JQg]())}).catch(E=>{const[n,s]=ZpA({value:new TypeError("Unserializable return value"),[HpA]:0});A.postMessage(Object.assign(Object.assign({},n),{id:o}),s)})}),A.start&&A.start()}function mRo(g){return g.constructor.name==="MessagePort"}function _KI(g){mRo(g)&&g.close()}function bKI(g,A){const I=new Map;return g.addEventListener("message",function(t){const{data:o}=t;if(!o||!o.id)return;const B=I.get(o.id);if(B)try{B(o)}finally{I.delete(o.id)}}),PQg(g,I,[],A)}function vpA(g){if(g)throw new Error("Proxy has been released and is not useable")}function HKI(g){return vO(g,new Map,{type:"RELEASE"}).then(()=>{_KI(g)})}const TpA=new WeakMap,qpA="FinalizationRegistry"in globalThis&&new FinalizationRegistry(g=>{const A=(TpA.get(g)||0)-1;TpA.set(g,A),A===0&&HKI(g)});function pRo(g,A){const I=(TpA.get(A)||0)+1;TpA.set(A,I),qpA&&qpA.register(g,A,g)}function kRo(g){qpA&&qpA.unregister(g)}function PQg(g,A,I=[],e=function(){}){let t=!1;const o=new Proxy(e,{get(B,C){if(vpA(t),C===PKI)return()=>{kRo(o),HKI(g),A.clear(),t=!0};if(C==="then"){if(I.length===0)return{then:()=>o};const Q=vO(g,A,{type:"GET",path:I.map(i=>i.toString())}).then(jb);return Q.then.bind(Q)}return PQg(g,A,[...I,C])},set(B,C,Q){vpA(t);const[i,E]=ZpA(Q);return vO(g,A,{type:"SET",path:[...I,C].map(n=>n.toString()),value:i},E).then(jb)},apply(B,C,Q){vpA(t);const i=I[I.length-1];if(i===yRo)return vO(g,A,{type:"ENDPOINT"}).then(jb);if(i==="bind")return PQg(g,A,I.slice(0,-1));const[E,n]=vKI(Q);return vO(g,A,{type:"APPLY",path:I.map(s=>s.toString()),argumentList:E},n).then(jb)},construct(B,C){vpA(t);const[Q,i]=vKI(C);return vO(g,A,{type:"CONSTRUCT",path:I.map(E=>E.toString()),argumentList:Q},i).then(jb)}});return pRo(o,g),o}function MRo(g){return Array.prototype.concat.apply([],g)}function vKI(g){const A=g.map(ZpA);return[A.map(I=>I[0]),MRo(A.map(I=>I[1]))]}const TKI=new WeakMap;function SRo(g,A){return TKI.set(g,A),g}function KQg(g){return Object.assign(g,{[JKI]:!0})}function ZpA(g){for(const[A,I]of LKI)if(I.canHandle(g)){const[e,t]=I.serialize(g);return[{type:"HANDLER",name:A,value:e},t]}return[{type:"RAW",value:g},TKI.get(g)||[]]}function jb(g){switch(g.type){case"HANDLER":return LKI.get(g.name).deserialize(g.value);case"RAW":return g.value}}function vO(g,A,I,e){return new Promise(t=>{const o=fRo();A.set(o,t),g.start&&g.start(),g.postMessage(Object.assign({id:o},I),e)})}function fRo(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function LQg(g,A=""){const I=[];for(const e in g){if(!Object.prototype.hasOwnProperty.call(g,e))continue;const t=g[e],o=A?`${A}.${e}`:e;if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const B=LQg(t,o);I.push(...B)}else I.push(o)}return I}function qKI(g,A){const I=A.split(".");let e=g;for(const t of I)e=e[t];return e}var RRo=(g="latest")=>[`https://jscdn.tscircuit.com/@tscircuit/eval/${g}/dist/webworker/entrypoint.js`,`https://cdn.jsdelivr.net/npm/@tscircuit/eval@${g}/dist/webworker/entrypoint.js`,`https://unpkg.com/@tscircuit/eval@${g}/dist/webworker/entrypoint.js`],NRo=async(g="latest",A=!1)=>{let I;for(const e of RRo(g))try{const t=await globalThis.fetch(e);if(!t.ok)throw new Error(`Failed to fetch webworker entrypoint from ${e}: ${t.status} ${t.statusText}`);return await t.blob()}catch(t){I=t,A&&console.warn(`[Worker] Failed to fetch webworker entrypoint from ${e}, trying next CDN fallback if available`,t)}throw I instanceof Error?I:new Error("Failed to fetch webworker entrypoint from CDN fallbacks")},xRo=async g=>{const A=globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER;if(A&&typeof A.kill=="function"){g.verbose&&console.log("[Worker] Killing previous global worker instance...");try{await A.kill()}catch(s){g.verbose&&console.warn("[Worker] Error killing previous global worker instance:",s),globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER===A&&(globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER=void 0)}}g.verbose&&console.log("[Worker] Creating circuit web worker with config:",g);let I=g.webWorkerBlobUrl??g.webWorkerUrl;if(!I){const s=await NRo(g.evalVersion??"latest",g.verbose);I=URL.createObjectURL(s)}const e=new Worker(I,{type:"module"});let t;e.addEventListener("error",s=>{console.error("[Worker] Error in worker",s),t=s}),e.addEventListener("unhandledrejection",s=>{console.error("[Worker] Unhandled rejection in worker",s)}),e.addEventListener("messageerror",s=>{console.error("[Worker] Message error in worker",s)});const o=s=>{console.log("[Worker] Message in worker",s)};if(e.addEventListener("message",o),e.addEventListener("message",async s=>{const r=s.data;if(r?.type==="worker_fetch")try{const a=await globalThis.fetch(r.input,r.init),c=await a.text();e.postMessage({type:"worker_fetch_result",requestId:r.requestId,success:!0,response:{body:c,status:a.status,statusText:a.statusText,headers:(()=>{const h={};return a.headers.forEach((l,D)=>{h[D]=l}),h})()}})}catch(a){e.postMessage({type:"worker_fetch_result",requestId:r.requestId,success:!1,error:{name:a.name,message:a.message,stack:a.stack}})}}),t)throw t;const B=bKI(e);e.removeEventListener("message",o);function C(s){return!s||typeof s!="object"?s:s.type&&s.props!==void 0?{__isSerializedReactElement:!0,type:s.type,props:Q(s.props),key:s.key}:s}function Q(s){if(!s||typeof s!="object")return s;const r={};for(const[a,c]of Object.entries(s))a==="children"?Array.isArray(c)?r.children=c.map(C):r.children=C(c):r[a]=c;return r}g.enableFetchProxy&&e.postMessage({type:"override_global_fetch"}),g.disableCdnLoading&&await B.setDisableCdnLoading(!0),g.snippetsApiBaseUrl&&await B.setSnippetsApiBaseUrl(g.snippetsApiBaseUrl),g.tscircuitSessionToken&&await B.setTscircuitSessionToken(g.tscircuitSessionToken),g.easyEdaProxyConfig&&await B.setEasyEdaProxyConfig(g.easyEdaProxyConfig),g.partsEngineOptions&&await B.setPartsEngineOptions(g.partsEngineOptions);const i=s=>typeof s=="function"?KQg(s):s;if(g.platform)for(const s of LQg(g.platform))await B.setPlatformConfigProperty(s,i(qKI(g.platform,s))).catch(r=>{throw new Error(`Error setting platform config property ${s}: ${r instanceof Error?r.message:String(r)}`)});if(g.projectConfig)for(const s of LQg(g.projectConfig))await B.setProjectConfigProperty(s,i(qKI(g.projectConfig,s))).catch(r=>{throw new Error(`Error setting project config property ${s}: ${r instanceof Error?r.message:String(r)}`)});let E=!1;const n={clearEventListeners:B.clearEventListeners.bind(B),enableDebug:async(...s)=>{if(E)throw new Error("CircuitWebWorker was terminated, can't enableDebug");return B.enableDebug.bind(B)(...s)},version:B.version.bind(B),execute:async(...s)=>{if(E)throw new Error("CircuitWebWorker was terminated, can't execute");return B.execute.bind(B)(...s)},executeComponent:async s=>{if(E)throw new Error("CircuitWebWorker was terminated, can't executeComponent");if(typeof s=="function")return B.executeComponent.bind(B)(s);if(s&&typeof s=="object"&&s.type){const r=C(s);return B.executeComponent.bind(B)(r)}return B.executeComponent.bind(B)(s)},executeWithFsMap:async(...s)=>{if(E)throw new Error("CircuitWebWorker was terminated, can't executeWithFsMap");return B.executeWithFsMap.bind(B)(...s)},renderUntilSettled:B.renderUntilSettled.bind(B),getCircuitJson:B.getCircuitJson.bind(B),on:(s,r)=>{const a=KQg(r);B.on(s,a)},kill:async()=>{B[PKI](),e.terminate(),E=!0,globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER===n&&(globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER=void 0)}};return n.__rawWorker=e,globalThis.TSCIRCUIT_GLOBAL_CIRCUIT_WORKER=n,n};const FRo=({error:g,resetErrorBoundary:A,componentStack:I})=>{const e=g instanceof Error?g:new Error(String(g));return T.jsx("section",{className:"rf-h-full rf-w-full rf-grid rf-place-items-center",children:T.jsx("div",{className:"rf-min-h-full rf-flex rf-items-center rf-justify-center rf-px-4",children:T.jsxs("div",{className:"rf-max-w-lg rf-w-full rf-text-center",children:[T.jsxs("div",{className:"rf-mb-8",children:[T.jsx("div",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-20 rf-h-20 rf-bg-red-100 rf-rounded-full rf-mb-6",children:T.jsx(Gco,{className:"rf-w-10 rf-h-10 rf-text-red-600"})}),T.jsx("h1",{className:"rf-text-2xl rf-font-bold rf-text-gray-900 rf-mb-3",children:"Oops! Something went wrong"}),T.jsx("p",{className:"rf-text-gray-600 rf-mb-4",children:"RunFrame encountered an unexpected error."}),T.jsx("pre",{className:"rf-text-xs no-scrollbar rf-font-mono rf-text-left rf-whitespace-pre-wrap rf-text-red-600 rf-bg-red-50 rf-border rf-border-red-200 rf-p-3 rf-rounded-lg rf-mb-4 rf-overflow-auto rf-max-h-[120px]",children:e.message}),e.stack&&T.jsxs("details",{className:"rf-text-center rf-mb-6",children:[T.jsx("summary",{className:"rf-text-xs rf-text-gray-500 rf-cursor-pointer hover:rf-text-gray-700",children:"View stack trace"}),T.jsx("pre",{className:"rf-text-xs rf-font-mono no-scrollbar rf-whitespace-pre-wrap rf-text-gray-500 rf-bg-gray-100 rf-p-3 rf-rounded-lg rf-mt-2 rf-overflow-auto rf-text-left rf-max-h-[150px]",children:e.stack})]}),I&&T.jsxs("details",{className:"rf-text-center rf-mb-6",children:[T.jsx("summary",{className:"rf-text-xs rf-text-gray-500 rf-cursor-pointer hover:rf-text-gray-700",children:"View component stack"}),T.jsx("pre",{className:"rf-text-xs rf-font-mono no-scrollbar rf-whitespace-pre-wrap rf-text-gray-500 rf-bg-gray-100 rf-p-3 rf-rounded-lg rf-mt-2 rf-overflow-auto rf-text-left rf-max-h-[150px]",children:I})]})]}),T.jsxs("div",{className:"rf-flex rf-flex-col rf-gap-2 rf-justify-center",children:[T.jsx(si,{variant:"destructive",size:"lg",onClick:()=>window.location.reload(),children:"Refresh Dev Server"}),T.jsx(si,{variant:"outline",size:"lg",onClick:A,children:"Try Again"})]})]})})})},ZKI=g=>{const A={};if(!g)return A;for(const e of OM)A[e]=0;const I=new Map;for(const e of g){const[,,t,o]=e.type.split(":");if(o==="start"){I.set(`${t}:${e.renderId}`,e);continue}if(o==="end"){const B=I.get(`${t}:${e.renderId}`);if(B){const C=e.createdAt-B.createdAt;A[t]=(A[t]||0)+C}}}return A},MoA=g=>{const A=g.toLowerCase(),I=A.split("/").pop();return A.endsWith(".circuit.json")||I==="circuit.json"},URo=g=>g.endsWith(".tsx")||MoA(g)||g.endsWith(".jsx"),JRo=({mainComponentPath:g,fsMap:A})=>{const I=g!=null&&MoA(g),e=g?A.get(g):void 0;return z.useMemo(()=>{if(!I)return{isStaticCircuitJson:!1,circuitJson:null,error:null};if(!e)return{isStaticCircuitJson:!0,circuitJson:null,error:`Circuit JSON file not found: ${g}`};try{return{isStaticCircuitJson:!0,circuitJson:JSON.parse(e),error:null}}catch(t){return{isStaticCircuitJson:!0,circuitJson:null,error:`Failed to parse circuit.json: ${t instanceof Error?t.message:String(t)}`}}},[g,e])},PRo=(g,A)=>{const I={};for(const[e,t]of g.entries()){const o=A.get(e);o!==t&&(I[e]={old:t,new:o})}for(const[e,t]of A.entries())g.has(e)||(I[e]={old:void 0,new:t});return I},KRo=({message:g="Loading files..."})=>T.jsxs("div",{className:"rf-flex rf-flex-col rf-w-full rf-h-full",children:[T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4 rf-p-2 rf-border-b",children:[T.jsx("div",{className:"rf-w-20 rf-h-9 rf-bg-gray-200 dark:rf-bg-gray-700 rf-rounded-md rf-animate-pulse"}),T.jsx("div",{className:"rf-flex rf-gap-6 rf-ml-auto",children:["PCB","Schematic","3D"].map((A,I)=>T.jsx("div",{className:"rf-h-6 rf-w-20 rf-bg-gray-200 dark:rf-bg-gray-700 rf-rounded rf-animate-pulse"},I))})]}),T.jsx("div",{className:"rf-flex-1 rf-p-4",children:T.jsx("div",{className:"rf-w-full rf-h-full rf-rounded-lg rf-bg-gray-100 dark:rf-bg-gray-800 rf-animate-pulse rf-flex rf-items-center rf-justify-center",children:T.jsx("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-4",children:T.jsx("div",{className:"rf-text-sm rf-text-gray-400 dark:rf-text-gray-500",children:g})})})})]}),LRo=({projectBaseUrl:g,enablePartOrientationAnalysis:A})=>({projectBaseUrl:g,enablePartOrientationAnalysis:A??!0}),YRo=g=>!g||typeof g!="object"?!1:!!("error_type"in g||typeof g.type=="string"&&g.type.includes("error")),_Ro=g=>g instanceof Error?{name:g.name,message:g.message,stack:g.stack}:typeof g=="string"?{message:g}:g&&typeof g=="object"?g:{message:String(g)},bRo=g=>Array.isArray(g)?g.filter(YRo):[],OpA=({circuitJson:g,executionError:A})=>{const I=[];A&&I.push(_Ro(A));const e=bRo(g);return I.push(...e),{hasExecutionError:!!A,...I.length>0?{errors:I}:{}}};function HRo(){const g=z.useRef(Promise.resolve()),A=z.useRef(!1),I=z.useRef(null),e=z.useCallback(async B=>{await g.current;const C={cancelled:!1};I.current=C;let Q;const i=new Promise(E=>{Q=E});try{return g.current=i,A.current=!0,await B()}catch(E){if(!C.cancelled)throw E}finally{A.current=!1,I.current=null,Q()}},[]),t=z.useCallback(()=>{I.current&&(I.current.cancelled=!0),g.current=Promise.resolve(),A.current=!1},[]),o=z.useCallback(()=>A.current,[]);return{runWithMutex:e,isLocked:o,cancel:t}}const vRo=26,xS=kE("run-frame:RunFrame"),TRo=async()=>{try{const g=await fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval");if(g.ok)return(await g.json()).tags?.latest}catch(g){console.error("Failed to fetch latest eval version",g)}},qRo=async(g,A)=>{if(g)return g;if(A||!window.TSCIRCUIT_LATEST_EVAL_VERSION){const I=await TRo();if(I)return window.TSCIRCUIT_LATEST_EVAL_VERSION=I,I}return window.TSCIRCUIT_LATEST_EVAL_VERSION?window.TSCIRCUIT_LATEST_EVAL_VERSION:"latest"},OKI=g=>{noA();const A=g.mainComponentPath!=null&&MoA(g.mainComponentPath),I=Kc(xA=>xA.circuitJson),e=Kc(xA=>xA.setCircuitJson),[t,o]=z.useState(null),[B,C]=z.useState(null),Q=z.useRef(null),i=z.useRef(!0),E=z.useRef(null),[n,s]=z.useState(null),[r,a]=z.useReducer((xA,bA)=>xA+1,0),c=apA(xA=>xA.setLastRunEvalVersion),h=z.useRef(0),l=HRo(),[D,d]=z.useState(!1),[y,w]=z.useState(!1),[u,G]=z.useState({}),[m,p]=z.useState(""),[k,S]=z.useState(!1),[R,x]=z.useState(!1);z.useEffect(()=>(i.current=!0,()=>{i.current=!1,Q.current?.(),E.current?.then(({worker:bA})=>{if(!i.current&&globalThis.runFrameWorker!==bA)return bA.kill()}).catch(()=>{})}),[]);const N=()=>{if(E.current)return E.current;const xA=(async()=>{const JA=await qRo(g.evalVersion,!globalThis.runFrameWorker&&g.forceLatestEvalVersion),mA={jlcSearchBaseUrl:window.TSCIRCUIT_JLCSEARCH_BASE_URL,datasheetApiBaseUrl:window.TSCIRCUIT_DATASHEET_API_BASE_URL},LA=mA.jlcSearchBaseUrl!==void 0||mA.datasheetApiBaseUrl!==void 0;return{worker:globalThis.runFrameWorker??await xRo({evalVersion:JA,webWorkerBlobUrl:g.evalWebWorkerBlobUrl,projectConfig:LRo({enablePartOrientationAnalysis:g.platformConfig?.enablePartOrientationAnalysis,projectBaseUrl:g.projectBaseUrl??g.platformConfig?.projectBaseUrl??`${Jm}/files/static`}),...g.platformConfig&&{platform:g.platformConfig},verbose:!0,...g.enableFetchProxy&&{enableFetchProxy:g.enableFetchProxy},...window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI&&{disableCdnLoading:!0},...g.tscircuitSessionToken&&{tscircuitSessionToken:g.tscircuitSessionToken},...g.easyEdaProxyConfig&&{easyEdaProxyConfig:g.easyEdaProxyConfig},...LA&&{partsEngineOptions:mA}}),evalVersion:JA}})();E.current=xA;const bA=()=>{E.current===xA&&(E.current=null)};return xA.then(bA,bA),xA},U=Object.values(u).sort((xA,bA)=>xA.startTime-bA.startTime)[0]?.effectName,K=xA=>{g.onRunCompleted?.(xA)};z.useEffect(()=>{if(A)return;const xA=bA=>{(bA.ctrlKey||bA.metaKey)&&bA.key==="Enter"&&!D&&(bA.preventDefault(),bA.stopPropagation(),a(1))};return window.addEventListener("keydown",xA,{capture:!0}),()=>window.removeEventListener("keydown",xA,{capture:!0})},[D,A]),z.useEffect(()=>{if(A)return;let xA=!1;return(async()=>{try{if(!globalThis.runFrameWorker){const{worker:JA,evalVersion:mA}=await N();if(xA||!i.current)return;globalThis.runFrameWorker=JA,c(mA)}xA||w(!0)}catch(JA){!xA&&i.current&&console.error("Failed to preload eval worker",JA)}})(),()=>{xA=!0}},[A,g.evalVersion,g.evalWebWorkerBlobUrl,g.forceLatestEvalVersion,g.tscircuitSessionToken]);const[Y,_]=z.useState(null),[Z,V]=z.useState({}),[W,q]=z.useState([]),[X,tA]=z.useState([]),IA=z.useRef(0),[QA,sA]=z.useState(g.defaultActiveTab??g.defaultTab??"pcb");FPI({source:"runframe",component:"RunFrame",isWebEmbedded:g.isWebEmbedded,activeTab:QA}),z.useEffect(()=>{g.debug&&kE.enable("run-frame*")},[g.debug]);const DA=z.useMemo(()=>g.fsMap instanceof Map?g.fsMap:new Map(Object.entries(g.fsMap??{})),[g.fsMap]),CA=z.useRef(null),hA=z.useRef(null),nA=z.useRef(null),{circuitJson:aA,error:SA}=JRo({mainComponentPath:g.mainComponentPath,fsMap:DA});z.useEffect(()=>{if(!A){nA.current=null;return}if(g.isLoadingFiles)return;const xA=aA??SA;if(xA!==nA.current){if(nA.current=xA,aA)g.onRenderStarted?.(),e(aA),o(null),g.onCircuitJsonChange?.(aA),g.onInitialRender?.({circuitJson:aA}),K(OpA({circuitJson:aA})),g.onRenderFinished?.({circuitJson:aA});else if(SA){e(null),o({error:SA,stack:""});const bA=new Error(SA);g.onError?.(bA),K(OpA({executionError:bA}))}}},[A,aA,SA,g.isLoadingFiles]),z.useEffect(()=>{if(A||g.isLoadingFiles){IA.current+=1,Q.current?.(),Q.current=null,d(!1),G({}),g.isLoadingFiles&&e(null);return}const xA=DA instanceof Map?Object.fromEntries(DA.entries()):DA;if(!xA||Object.keys(xA).length===0){e(null),o({error:"No files provided. Please provide at least one file with code to execute.",stack:""}),d(!1);return}const bA=r!==h.current;if(CA.current&&I){const WA=PRo(CA.current,DA);if(Object.keys(WA).length>0)xS("code changes detected");else if(hA.current!==g.entrypoint)xS("render triggered by entrypoint change");else if(!bA){xS("render triggered without changes to fsMap, skipping");return}}if(g.showRunButton&&r===h.current)return;CA.current=DA,hA.current=g.entrypoint??null,h.current=r,d(!0);let JA=!1;const mA=++IA.current,LA=()=>i.current&&!JA&&mA===IA.current;let dA;const HA=async()=>{if(!LA())return;xS("running render worker"),o(null),_(null),G({}),q([]),tA([]);const WA={progress:0,debugOutputs:[]};Q.current=()=>{JA=!0};const{worker:Qg,evalVersion:YA}=await N();if(!LA()||(xS("resolvedEvalVersion",YA),globalThis.runFrameWorker=Qg,c(YA),await Qg.clearEventListeners(),!LA()))return;m?.trim()&&Qg.enableDebug(m.replace("DEBUG=","")),xS("Starting render..."),g.onRenderStarted?.();const uA=DA instanceof Map?Object.fromEntries(DA.entries()):DA;let kA=Date.now();Qg.on("asyncEffect:start",Bg=>{const Yg=`${Bg.phase}|${Bg.componentDisplayName??""}|${Bg.effectName}`;G(iI=>({...iI,[Yg]:{...Bg,startTime:Date.now()}}))}),Qg.on("asyncEffect:end",Bg=>{const Yg=`${Bg.phase}|${Bg.componentDisplayName??""}|${Bg.effectName}`;G(iI=>{const{[Yg]:GA,...ng}=iI;return ng})});let OA=[];const $A=Bg=>{JA||mA!==IA.current||(OA=Eko(OA,Bg),tA(OA))};if(Qg.on("autorouting:end",Bg=>$A({...Bg,type:"autorouting:end"})),Qg.on("autorouting:error",Bg=>$A({...Bg,type:"autorouting:error"})),Qg.on("autorouting:start",Bg=>{$A({...Bg,type:"autorouting:start"}),V({...Z,[Bg.componentDisplayName]:{simpleRouteJson:Bg.simpleRouteJson,createdAt:Date.now()}})}),Qg.on("solver:started",Bg=>{xS("solver:started",Bg),q(Yg=>{const iI=`${Bg.componentName}-${Bg.solverName}`;return Yg.some(ng=>`${ng.componentName}-${ng.solverName}`===iI)?Yg:[...Yg,Bg]})}),Qg.on("board:renderPhaseStarted",Bg=>{WA.lastRenderEvent=Bg,WA.eventsProcessed=(WA.eventsProcessed??0)+1;const Yg=OM.indexOf(Bg.phase)/vRo*.75+WA.eventsProcessed/1e3*.25,iI=1-Math.exp(-Yg*3);WA.progress=iI,JA||_({...WA})}),QA==="render_log"&&Qg.on("renderable:renderLifecycle:anyEvent",Bg=>{WA.renderEvents=WA.renderEvents??[],Bg.createdAt=Date.now(),WA.renderEvents.push(Bg),Date.now()-kA>500&&(WA.phaseTimings=ZKI(WA.renderEvents??[]),kA=Date.now()),JA||_({...WA})}),Qg.on("autorouting:progress",Bg=>{s(Bg.debugGraphics)}),Qg.on("debug:logOutput",Bg=>{WA.debugOutputs=WA.debugOutputs??[],WA.debugOutputs.push({type:"debug",name:Bg.name,content:Bg.content}),JA||_({...WA})}),xS("Executing fsMap..."),await Qg.executeWithFsMap({entrypoint:g.entrypoint,fsMap:uA,...g.mainComponentPath?{mainComponentPath:g.mainComponentPath}:{}}),!LA())return;xS("worker call started");const og=Qg.renderUntilSettled().then(()=>({success:!0}),Bg=>({success:!1,error:Bg}));dA=og,xS("waiting for initial circuit json...");let dg=await Qg.getCircuitJson();if(!LA())return;if(!dg)throw new Error("Eval worker returned no Circuit JSON");xS("got initial circuit json"),e(dg),g.onCircuitJsonChange?.(dg),g.onInitialRender?.({circuitJson:dg});const Sg=await og;if(LA()){if(!Sg.success)throw Sg.error;xS("getting final circuit json"),dg=await Qg.getCircuitJson(),LA()&&(g.onCircuitJsonChange?.(dg),e(dg),K(OpA({circuitJson:dg})),g.onRenderFinished?.({circuitJson:dg}),s({}),QA==="render_log"&&(WA.phaseTimings=ZKI(WA.renderEvents??[])),WA.progress=1,JA||_({...WA}),d(!1),G({}),p(""),Q.current=null)}};l.runWithMutex(async()=>{try{await HA()}finally{await dA}}).catch(WA=>{if(!LA())return;const Qg=WA instanceof Error?WA:new Error(String(WA));xS("worker execution failed",Qg),g.onError?.(Qg),K(OpA({executionError:Qg})),e(null),o({error:Qg.message.replace("Error: ",""),stack:Qg.stack}),_(null),d(!1),G({}),p(""),Q.current=null})},[g.fsMap,g.entrypoint,r,g.evalVersion,g.mainComponentPath,g.isLoadingFiles,m,A]);const FA=z.useRef(null),rA=z.useRef(null),NA=xA=>{if(!xA||xA===null){console.warn("[RunFrame] handleEditEvent received null or undefined event.");return}xA.in_progress?(FA.current=xA,rA.current&&(clearTimeout(rA.current),rA.current=null)):(rA.current&&clearTimeout(rA.current),rA.current=setTimeout(()=>{const bA=xA||FA.current;g.onEditEvent?.(bA),FA.current=null,rA.current=null},100))},RA=async(xA,bA)=>{let JA="";const mA=Array.isArray(I)&&I.find(HA=>HA.type==="software_project_metadata"),LA=g.projectUrl??mA?.project_url;if(LA)try{JA=new URL(LA).pathname}catch{JA=LA}const dA=JA?`${JA} - ${xA}`:xA;await NgA.post("autorouting/bug_reports/create",{json:{title:dA,simple_route_json:bA.simpleRouteJson}}).json().then(({autorouting_bug_report:HA})=>{window.open(`https://api.tscircuit.com/autorouting/bug_reports/view?autorouting_bug_report_id=${HA.autorouting_bug_report_id}`,"_blank")}).catch(HA=>{console.error("Failed to report autorouting bug",HA);const WA=HA instanceof wJ&&HA.response?.status===401,Qg=HA instanceof wJ&&HA.response?.status===413;if(WA){g.onLoginRequired?g.onLoginRequired():alert("You must be logged in to report autorouting bugs");return}if(Qg){alert("This autorouting log is too large to report online. Download the log and attach it to a GitHub issue.");return}const YA=HA instanceof Error?HA.message:"Failed to report autorouting bug";alert(`Failed to report autorouting bug: ${YA}`)})};return g.isLoadingFiles?T.jsx(KRo,{}):T.jsx(GS,{onError:(xA,bA)=>{C(bA.componentStack??null)},onReset:()=>C(null),fallbackRender:xA=>T.jsx(FRo,{...xA,componentStack:B}),children:T.jsx(UKI,{platformConfig:g.platformConfig,code:DA.get(g.entrypoint??g.mainComponentPath??""),fsMap:DA,defaultActiveTab:g.defaultActiveTab??g.defaultTab,defaultTab:g.defaultTab,availableTabs:g.availableTabs,extraTabs:mtg(g.extraTabs,g.mainComponentPath??g.entrypoint),schematicSvgOptions:g.schematicSvgOptions,showToggleFullScreen:g.showToggleFullScreen,autoroutingGraphics:n,autoroutingLog:Z,onReportAutoroutingLog:g.onReportAutoroutingLog||RA,leftHeaderContent:T.jsxs(T.Fragment,{children:[g.showRunButton&&T.jsx(NQg,{children:T.jsxs(xQg,{children:[T.jsx(FQg,{asChild:!0,children:T.jsxs("div",{className:"rf-relative rf-inline-flex",children:[T.jsxs("button",{type:"button",onClick:()=>{a(1)},className:"rf-flex rf-items-center rf-gap-2 rf-px-4 rf-py-2 rf-bg-blue-600 hover:rf-bg-blue-700 rf-text-white rf-rounded-md disabled:rf-opacity-50 transition-colors duration-200",disabled:D||!y,children:["Run"," ",D||!y?T.jsx(mS,{className:"rf-w-3 rf-h-3 rf-animate-spin"}):T.jsx(sxI,{className:"rf-w-3 rf-h-3"})]}),D&&T.jsx("div",{className:"rf-flex rf-items-center rf-ml-1",children:T.jsx(si,{onClick:xA=>{xA.stopPropagation(),d(!1),_(null),o(null),Q.current&&(Q.current(),Q.current=null),l.cancel(),G({}),globalThis.runFrameWorker&&(globalThis.runFrameWorker.kill(),globalThis.runFrameWorker=null)},variant:"ghost",size:"icon",className:"rf-text-red-300 hover:rf-text-red-400 hover:!rf-bg-transparent [&>svg]:rf-text-red-300 [&>svg]:hover:rf-text-red-400 rf-flex rf-items-center rf-justify-center",children:T.jsx(uco,{className:"!rf-h-2.5 !rf-w-2.5",fill:"currentColor",stroke:"currentColor"})})})]})}),T.jsx(bpA,{sideOffset:8,className:"rf-p-0 rf-bg-transparent rf-border-none rf-shadow-none rf-pointer-events-none",children:T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-px-2.5 rf-py-1.5 rf-bg-slate-900 rf-rounded-md rf-shadow-xl rf-border rf-border-slate-800/60",children:[T.jsx("kbd",{className:"rf-bg-slate-800 rf-px-1.5 rf-py-0.5 rf-rounded rf-text-[10px] rf-font-sans rf-font-medium rf-border rf-border-slate-700 rf-text-slate-200 rf-leading-none",children:"Ctrl"}),T.jsx("span",{className:"rf-text-slate-500 rf-text-[11px] rf-font-medium rf-leading-none",children:"+"}),T.jsx("kbd",{className:"rf-bg-slate-800 rf-px-1.5 rf-py-0.5 rf-rounded rf-text-[10px] rf-font-sans rf-font-medium rf-border rf-border-slate-700 rf-text-slate-200 rf-leading-none",children:"Enter"})]})})]})}),g.showFileMenu!==!1&&T.jsx(YpA,{isWebEmbedded:g.isWebEmbedded,onLoginRequired:g.onLoginRequired,showSchematicDebugGrid:k,onChangeShowSchematicDebugGrid:S,showSchematicPorts:R,onChangeShowSchematicPorts:x,autoroutingLog:Z,onReportAutoroutingLog:g.onReportAutoroutingLog||RA,shouldLoadLatestEval:g.shouldLoadLatestEval,onChangeShouldLoadLatestEval:g.onChangeShouldLoadLatestEval}),g.leftHeaderContent]}),onActiveTabChange:sA,circuitJson:I,renderLog:Y,activeEffectName:U,isRunningCode:D,errorMessage:t?.error,errorStack:t?.stack,onEditEvent:NA,editEvents:g.editEvents,onPcbBoundsSelected:g.onPcbBoundsSelected,defaultToFullScreen:g.defaultToFullScreen,onRerunWithDebug:xA=>{p(xA||""),a(1)},solverEvents:W,autoroutingPhases:A?[]:X,isCli:g.isCli,showSchematicDebugGrid:k,showSchematicPorts:R,onChangeShowSchematicDebugGrid:S,onChangeShowSchematicPorts:x})})},ZRo=g=>new Promise(A=>setTimeout(A,g)),ORo=({isOpen:g,onClose:A,onLoginSuccess:I})=>{const[e,t]=z.useState("idle"),[o,B]=z.useState(null),[C,Q]=z.useState(null),i=Kc(c=>c.pushEvent),E=z.useRef(null);z.useEffect(()=>()=>{E.current&&E.current.abort()},[]);const n=z.useCallback(async()=>{t("creating"),Q(null),E.current=new AbortController;try{const c=d3(),{login_page:h}=await c.post("sessions/login_page/create",{json:{},signal:E.current?.signal}).json();B(h.url),t("waiting");const l=new URL(h.url);for(l.searchParams.set("autoclose","true"),window.open(l.toString(),"_blank");!E.current?.signal.aborted;){const{login_page:d}=await c.post("sessions/login_page/get",{json:{login_page_id:h.login_page_id},headers:{Authorization:`Bearer ${h.login_page_auth_token}`},signal:E.current?.signal}).json();if(d.was_login_successful){t("exchanging");break}if(d.is_expired)throw new Error("Login page expired. Please try again.");await ZRo(1e3)}if(E.current?.signal.aborted){t("idle");return}const{session:D}=await c.post("sessions/login_page/exchange_for_cli_session",{json:{login_page_id:h.login_page_id},headers:{Authorization:`Bearer ${h.login_page_auth_token}`},signal:E.current?.signal}).json();typeof window<"u"&&(window.TSCIRCUIT_REGISTRY_TOKEN=D.token),await i({event_type:"TOKEN_UPDATED",registry_token:D.token}),t("success"),LC.success("Successfully logged in!"),I?.(),setTimeout(()=>{A(),t("idle"),B(null)},1e3)}catch(c){if(c instanceof DOMException&&c.name==="AbortError"){t("idle");return}console.error("Login error:",c);const h=c instanceof Error?c.message:"Failed to complete login";Q(h),t("error"),LC.error(h)}},[i,I,A]),s=z.useCallback(()=>{E.current&&E.current.abort(),t("idle"),B(null),Q(null),A()},[A]),r=e==="creating"||e==="waiting"||e==="exchanging",a=()=>{switch(e){case"creating":return"Creating login page...";case"waiting":return"Waiting for you to complete login in the browser...";case"exchanging":return"Generating token...";case"success":return"Successfully logged in!";case"error":return C||"An error occurred";default:return null}};return T.jsx(Hb,{open:g,onOpenChange:c=>!c&&!r&&s(),children:T.jsxs(xL,{className:"rf-max-w-md",children:[T.jsxs(FL,{children:[T.jsx(UL,{children:"Sign In Required"}),T.jsx(vb,{children:e==="idle"||e==="error"?"Sign in to continue. A new browser window will open for authentication.":"Complete the login process in the opened browser window."})]}),T.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-4 rf-py-4",children:[e==="idle"||e==="error"?T.jsx(si,{onClick:n,className:"rf-w-full",children:"Sign In"}):T.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-3 rf-w-full",children:[e!=="success"&&T.jsx("div",{className:"rf-animate-spin rf-w-6 rf-h-6 rf-border-2 rf-border-gray-300 rf-border-t-blue-600 rf-rounded-full"}),T.jsx("p",{className:"rf-text-sm rf-text-gray-600 rf-text-center",children:a()}),o&&e==="waiting"&&T.jsx("a",{href:o,target:"_blank",rel:"noreferrer",className:"rf-text-xs rf-text-blue-600 hover:rf-underline",children:"Click here if the window didn't open"})]}),C&&e==="error"&&T.jsx("p",{className:"rf-text-sm rf-text-red-600 rf-text-center",children:C}),r&&T.jsx(si,{variant:"outline",onClick:s,className:"rf-w-full",children:"Cancel"})]})]})})},WRo=()=>{const[g,A]=z.useState(!1),I=z.useCallback(()=>{A(!0)},[]),e=z.useCallback(()=>{A(!1)},[]),t=z.useCallback(()=>{A(!1)},[]);return{LoginDialog:T.jsx(ORo,{isOpen:g,onClose:e,onLoginSuccess:t}),openLoginDialog:I}},VRo=({apiBaseUrl:g,fetchImpl:A=globalThis.fetch.bind(globalThis)})=>{const I=`${g.replace(/\/$/,"")}/cache`;return{getItem:async e=>{try{const t=await A(`${I}?key=${encodeURIComponent(e)}`);return t.ok?await t.text():null}catch{return null}},setItem:async(e,t)=>{try{await A(`${I}?key=${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"text/plain; charset=utf-8"},body:t})}catch{}}}},jRo=g=>{const[A,I]=gq("load-latest-eval",!0),e=g.evalWebWorkerBlobUrl??g.workerBlobUrl,t=g.apiBaseUrl??Jm,o=z.useMemo(()=>({...g.platformConfig,localCacheEngine:g.platformConfig?.localCacheEngine??VRo({apiBaseUrl:t})}),[t,g.platformConfig]),[B]=z.useState(()=>typeof window>"u"?void 0:new URLSearchParams(window.location.hash.slice(1)).get("main_component")??void 0),C=z.useCallback(E=>{if(typeof window>"u")return;const n=new URLSearchParams(window.location.hash.slice(1));if(n.get("main_component")===E)return;n.set("main_component",E);const s=n.toString(),r=`${window.location.pathname}${window.location.search}${s.length>0?`#${s}`:""}`;window.history.replaceState(null,"",r)},[]),{LoginDialog:Q,openLoginDialog:i}=WRo();return T.jsxs(T.Fragment,{children:[Q,T.jsx(L3I,{extraTabs:g.extraTabs,debug:g.debug,forceLatestEvalVersion:!e&&A,defaultToFullScreen:!0,showToggleFullScreen:!1,evalWebWorkerBlobUrl:e,apiBaseUrl:g.apiBaseUrl,platformConfig:o,isCli:!0,showFilesSwitch:!0,enableFetchProxy:g.enableFetchProxy,initialMainComponentPath:B,onLoginRequired:i,onMainComponentPathChange:C,shouldLoadLatestEval:!e&&A,onChangeShouldLoadLatestEval:E=>{I(E),globalThis.runFrameWorker=null},leftHeaderContent:T.jsx("div",{className:"rf-flex rf-items-center rf-justify-between",children:g.scenarioSelectorContent})})]})};kE("run-frame:ImportComponentDialog");var WKI=1,zRo=.9,XRo=.8,$Ro=.17,YQg=.1,_Qg=.999,ANo=.9999,gNo=.99,INo=/[\\\/_+.#"@\[\(\{&]/,eNo=/[\\\/_+.#"@\[\(\{&]/g,tNo=/[\s-]/,VKI=/[\s-]/g;function bQg(g,A,I,e,t,o,B){if(o===A.length)return t===g.length?WKI:gNo;var C=`${t},${o}`;if(B[C]!==void 0)return B[C];for(var Q=e.charAt(o),i=I.indexOf(Q,t),E=0,n,s,r,a;i>=0;)n=bQg(g,A,I,e,i+1,o+1,B),n>E&&(i===t?n*=WKI:INo.test(g.charAt(i-1))?(n*=XRo,r=g.slice(t,i-1).match(eNo),r&&t>0&&(n*=Math.pow(_Qg,r.length))):tNo.test(g.charAt(i-1))?(n*=zRo,a=g.slice(t,i-1).match(VKI),a&&t>0&&(n*=Math.pow(_Qg,a.length))):(n*=$Ro,t>0&&(n*=Math.pow(_Qg,i-t))),g.charAt(i)!==A.charAt(o)&&(n*=ANo)),(n<YQg&&I.charAt(i-1)===e.charAt(o+1)||e.charAt(o+1)===e.charAt(o)&&I.charAt(i-1)!==e.charAt(o))&&(s=bQg(g,A,I,e,i+1,o+2,B),s*YQg>n&&(n=s*YQg)),n>E&&(E=n),i=I.indexOf(Q,i+1);return B[C]=E,E}function jKI(g){return g.toLowerCase().replace(VKI," ")}function oNo(g,A,I){return g=I&&I.length>0?`${g+" "+I.join(" ")}`:g,bQg(g,A,jKI(g),jKI(A),0,0,{})}var SoA='[cmdk-group=""]',HQg='[cmdk-group-items=""]',BNo='[cmdk-group-heading=""]',zKI='[cmdk-item=""]',XKI=`${zKI}:not([aria-disabled="true"])`,vQg="cmdk-item-select",TO="data-value",CNo=(g,A,I)=>oNo(g,A,I),$KI=z.createContext(void 0),foA=()=>z.useContext($KI),A3I=z.createContext(void 0),TQg=()=>z.useContext(A3I),g3I=z.createContext(void 0),I3I=z.forwardRef((g,A)=>{let I=qO(()=>{var q,X;return{search:"",value:(X=(q=g.value)!=null?q:g.defaultValue)!=null?X:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),e=qO(()=>new Set),t=qO(()=>new Map),o=qO(()=>new Map),B=qO(()=>new Set),C=e3I(g),{label:Q,children:i,value:E,onValueChange:n,filter:s,shouldFilter:r,loop:a,disablePointerSelection:c=!1,vimBindings:h=!0,...l}=g,D=_0(),d=_0(),y=_0(),w=z.useRef(null),u=DNo();zb(()=>{if(E!==void 0){let q=E.trim();I.current.value=q,G.emit()}},[E]),zb(()=>{u(6,x)},[]);let G=z.useMemo(()=>({subscribe:q=>(B.current.add(q),()=>B.current.delete(q)),snapshot:()=>I.current,setState:(q,X,tA)=>{var IA,QA,sA,DA;if(!Object.is(I.current[q],X)){if(I.current[q]=X,q==="search")R(),k(),u(1,S);else if(q==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let CA=document.getElementById(y);CA?CA.focus():(IA=document.getElementById(D))==null||IA.focus()}if(u(7,()=>{var CA;I.current.selectedItemId=(CA=N())==null?void 0:CA.id,G.emit()}),tA||u(5,x),((QA=C.current)==null?void 0:QA.value)!==void 0){let CA=X??"";(DA=(sA=C.current).onValueChange)==null||DA.call(sA,CA);return}}G.emit()}},emit:()=>{B.current.forEach(q=>q())}}),[]),m=z.useMemo(()=>({value:(q,X,tA)=>{var IA;X!==((IA=o.current.get(q))==null?void 0:IA.value)&&(o.current.set(q,{value:X,keywords:tA}),I.current.filtered.items.set(q,p(X,tA)),u(2,()=>{k(),G.emit()}))},item:(q,X)=>(e.current.add(q),X&&(t.current.has(X)?t.current.get(X).add(q):t.current.set(X,new Set([q]))),u(3,()=>{R(),k(),I.current.value||S(),G.emit()}),()=>{o.current.delete(q),e.current.delete(q),I.current.filtered.items.delete(q);let tA=N();u(4,()=>{R(),tA?.getAttribute("id")===q&&S(),G.emit()})}),group:q=>(t.current.has(q)||t.current.set(q,new Set),()=>{o.current.delete(q),t.current.delete(q)}),filter:()=>C.current.shouldFilter,label:Q||g["aria-label"],getDisablePointerSelection:()=>C.current.disablePointerSelection,listId:D,inputId:y,labelId:d,listInnerRef:w}),[]);function p(q,X){var tA,IA;let QA=(IA=(tA=C.current)==null?void 0:tA.filter)!=null?IA:CNo;return q?QA(q,I.current.search,X):0}function k(){if(!I.current.search||C.current.shouldFilter===!1)return;let q=I.current.filtered.items,X=[];I.current.filtered.groups.forEach(IA=>{let QA=t.current.get(IA),sA=0;QA.forEach(DA=>{let CA=q.get(DA);sA=Math.max(CA,sA)}),X.push([IA,sA])});let tA=w.current;U().sort((IA,QA)=>{var sA,DA;let CA=IA.getAttribute("id"),hA=QA.getAttribute("id");return((sA=q.get(hA))!=null?sA:0)-((DA=q.get(CA))!=null?DA:0)}).forEach(IA=>{let QA=IA.closest(HQg);QA?QA.appendChild(IA.parentElement===QA?IA:IA.closest(`${HQg} > *`)):tA.appendChild(IA.parentElement===tA?IA:IA.closest(`${HQg} > *`))}),X.sort((IA,QA)=>QA[1]-IA[1]).forEach(IA=>{var QA;let sA=(QA=w.current)==null?void 0:QA.querySelector(`${SoA}[${TO}="${encodeURIComponent(IA[0])}"]`);sA?.parentElement.appendChild(sA)})}function S(){let q=U().find(tA=>tA.getAttribute("aria-disabled")!=="true"),X=q?.getAttribute(TO);G.setState("value",X||void 0)}function R(){var q,X,tA,IA;if(!I.current.search||C.current.shouldFilter===!1){I.current.filtered.count=e.current.size;return}I.current.filtered.groups=new Set;let QA=0;for(let sA of e.current){let DA=(X=(q=o.current.get(sA))==null?void 0:q.value)!=null?X:"",CA=(IA=(tA=o.current.get(sA))==null?void 0:tA.keywords)!=null?IA:[],hA=p(DA,CA);I.current.filtered.items.set(sA,hA),hA>0&&QA++}for(let[sA,DA]of t.current)for(let CA of DA)if(I.current.filtered.items.get(CA)>0){I.current.filtered.groups.add(sA);break}I.current.filtered.count=QA}function x(){var q,X,tA;let IA=N();IA&&(((q=IA.parentElement)==null?void 0:q.firstChild)===IA&&((tA=(X=IA.closest(SoA))==null?void 0:X.querySelector(BNo))==null||tA.scrollIntoView({block:"nearest"})),IA.scrollIntoView({block:"nearest"}))}function N(){var q;return(q=w.current)==null?void 0:q.querySelector(`${zKI}[aria-selected="true"]`)}function U(){var q;return Array.from(((q=w.current)==null?void 0:q.querySelectorAll(XKI))||[])}function K(q){let X=U()[q];X&&G.setState("value",X.getAttribute(TO))}function Y(q){var X;let tA=N(),IA=U(),QA=IA.findIndex(DA=>DA===tA),sA=IA[QA+q];(X=C.current)!=null&&X.loop&&(sA=QA+q<0?IA[IA.length-1]:QA+q===IA.length?IA[0]:IA[QA+q]),sA&&G.setState("value",sA.getAttribute(TO))}function _(q){let X=N(),tA=X?.closest(SoA),IA;for(;tA&&!IA;)tA=q>0?hNo(tA,SoA):lNo(tA,SoA),IA=tA?.querySelector(XKI);IA?G.setState("value",IA.getAttribute(TO)):Y(q)}let Z=()=>K(U().length-1),V=q=>{q.preventDefault(),q.metaKey?Z():q.altKey?_(1):Y(1)},W=q=>{q.preventDefault(),q.metaKey?K(0):q.altKey?_(-1):Y(-1)};return z.createElement(yQ.div,{ref:A,tabIndex:-1,...l,"cmdk-root":"",onKeyDown:q=>{var X;(X=l.onKeyDown)==null||X.call(l,q);let tA=q.nativeEvent.isComposing||q.keyCode===229;if(!(q.defaultPrevented||tA))switch(q.key){case"n":case"j":{h&&q.ctrlKey&&V(q);break}case"ArrowDown":{V(q);break}case"p":case"k":{h&&q.ctrlKey&&W(q);break}case"ArrowUp":{W(q);break}case"Home":{q.preventDefault(),K(0);break}case"End":{q.preventDefault(),Z();break}case"Enter":{q.preventDefault();let IA=N();if(IA){let QA=new Event(vQg);IA.dispatchEvent(QA)}}}}},z.createElement("label",{"cmdk-label":"",htmlFor:m.inputId,id:m.labelId,style:yNo},Q),WpA(g,q=>z.createElement(A3I.Provider,{value:G},z.createElement($KI.Provider,{value:m},q))))}),QNo=z.forwardRef((g,A)=>{var I,e;let t=_0(),o=z.useRef(null),B=z.useContext(g3I),C=foA(),Q=e3I(g),i=(e=(I=Q.current)==null?void 0:I.forceMount)!=null?e:B?.forceMount;zb(()=>{if(!i)return C.item(t,B?.id)},[i]);let E=t3I(t,o,[g.value,g.children,o],g.keywords),n=TQg(),s=YL(u=>u.value&&u.value===E.current),r=YL(u=>i||C.filter()===!1?!0:u.search?u.filtered.items.get(t)>0:!0);z.useEffect(()=>{let u=o.current;if(!(!u||g.disabled))return u.addEventListener(vQg,a),()=>u.removeEventListener(vQg,a)},[r,g.onSelect,g.disabled]);function a(){var u,G;c(),(G=(u=Q.current).onSelect)==null||G.call(u,E.current)}function c(){n.setState("value",E.current,!0)}if(!r)return null;let{disabled:h,value:l,onSelect:D,forceMount:d,keywords:y,...w}=g;return z.createElement(yQ.div,{ref:C5(o,A),...w,id:t,"cmdk-item":"",role:"option","aria-disabled":!!h,"aria-selected":!!s,"data-disabled":!!h,"data-selected":!!s,onPointerMove:h||C.getDisablePointerSelection()?void 0:c,onClick:h?void 0:a},g.children)}),iNo=z.forwardRef((g,A)=>{let{heading:I,children:e,forceMount:t,...o}=g,B=_0(),C=z.useRef(null),Q=z.useRef(null),i=_0(),E=foA(),n=YL(r=>t||E.filter()===!1?!0:r.search?r.filtered.groups.has(B):!0);zb(()=>E.group(B),[]),t3I(B,C,[g.value,g.heading,Q]);let s=z.useMemo(()=>({id:B,forceMount:t}),[t]);return z.createElement(yQ.div,{ref:C5(C,A),...o,"cmdk-group":"",role:"presentation",hidden:n?void 0:!0},I&&z.createElement("div",{ref:Q,"cmdk-group-heading":"","aria-hidden":!0,id:i},I),WpA(g,r=>z.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":I?i:void 0},z.createElement(g3I.Provider,{value:s},r))))}),ENo=z.forwardRef((g,A)=>{let{alwaysRender:I,...e}=g,t=z.useRef(null),o=YL(B=>!B.search);return!I&&!o?null:z.createElement(yQ.div,{ref:C5(t,A),...e,"cmdk-separator":"",role:"separator"})}),nNo=z.forwardRef((g,A)=>{let{onValueChange:I,...e}=g,t=g.value!=null,o=TQg(),B=YL(i=>i.search),C=YL(i=>i.selectedItemId),Q=foA();return z.useEffect(()=>{g.value!=null&&o.setState("search",g.value)},[g.value]),z.createElement(yQ.input,{ref:A,...e,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":Q.listId,"aria-labelledby":Q.labelId,"aria-activedescendant":C,id:Q.inputId,type:"text",value:t?g.value:B,onChange:i=>{t||o.setState("search",i.target.value),I?.(i.target.value)}})}),sNo=z.forwardRef((g,A)=>{let{children:I,label:e="Suggestions",...t}=g,o=z.useRef(null),B=z.useRef(null),C=YL(i=>i.selectedItemId),Q=foA();return z.useEffect(()=>{if(B.current&&o.current){let i=B.current,E=o.current,n,s=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let r=i.offsetHeight;E.style.setProperty("--cmdk-list-height",r.toFixed(1)+"px")})});return s.observe(i),()=>{cancelAnimationFrame(n),s.unobserve(i)}}},[]),z.createElement(yQ.div,{ref:C5(o,A),...t,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":C,"aria-label":e,id:Q.listId},WpA(g,i=>z.createElement("div",{ref:C5(B,Q.listInnerRef),"cmdk-list-sizer":""},i)))}),aNo=z.forwardRef((g,A)=>{let{open:I,onOpenChange:e,overlayClassName:t,contentClassName:o,container:B,...C}=g;return z.createElement(fmA,{open:I,onOpenChange:e},z.createElement(RmA,{container:B},z.createElement(TtA,{"cmdk-overlay":"",className:t}),z.createElement(ZtA,{"aria-label":g.label,"cmdk-dialog":"",className:o},z.createElement(I3I,{ref:A,...C}))))}),rNo=z.forwardRef((g,A)=>YL(I=>I.filtered.count===0)?z.createElement(yQ.div,{ref:A,...g,"cmdk-empty":"",role:"presentation"}):null),cNo=z.forwardRef((g,A)=>{let{progress:I,children:e,label:t="Loading...",...o}=g;return z.createElement(yQ.div,{ref:A,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":I,"aria-valuemin":0,"aria-valuemax":100,"aria-label":t},WpA(g,B=>z.createElement("div",{"aria-hidden":!0},B)))}),Hk=Object.assign(I3I,{List:sNo,Item:QNo,Input:nNo,Group:iNo,Separator:ENo,Dialog:aNo,Empty:rNo,Loading:cNo});function hNo(g,A){let I=g.nextElementSibling;for(;I;){if(I.matches(A))return I;I=I.nextElementSibling}}function lNo(g,A){let I=g.previousElementSibling;for(;I;){if(I.matches(A))return I;I=I.previousElementSibling}}function e3I(g){let A=z.useRef(g);return zb(()=>{A.current=g}),A}var zb=typeof window>"u"?z.useEffect:z.useLayoutEffect;function qO(g){let A=z.useRef();return A.current===void 0&&(A.current=g()),A}function YL(g){let A=TQg(),I=()=>g(A.snapshot());return z.useSyncExternalStore(A.subscribe,I,I)}function t3I(g,A,I,e=[]){let t=z.useRef(),o=foA();return zb(()=>{var B;let C=(()=>{var i;for(let E of I){if(typeof E=="string")return E.trim();if(typeof E=="object"&&"current"in E)return E.current?(i=E.current.textContent)==null?void 0:i.trim():t.current}})(),Q=e.map(i=>i.trim());o.value(g,C,Q),(B=A.current)==null||B.setAttribute(TO,C),t.current=C}),t}var DNo=()=>{let[g,A]=z.useState(),I=qO(()=>new Map);return zb(()=>{I.current.forEach(e=>e()),I.current=new Map},[g]),(e,t)=>{I.current.set(e,t),A({})}};function dNo(g){let A=g.type;return typeof A=="function"?A(g.props):"render"in A?A.render(g.props):g}function WpA({asChild:g,children:A},I){return g&&z.isValidElement(A)?z.cloneElement(dNo(A),{ref:A.ref},I(A.props.children)):I(A)}var yNo={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const o3I=z.forwardRef(({className:g,...A},I)=>T.jsx(Hk,{ref:I,className:co("rf-flex rf-h-full rf-w-full rf-flex-col rf-overflow-hidden rf-rounded-md rf-bg-white rf-text-zinc-950 dark:rf-bg-zinc-950 dark:rf-text-zinc-50",g),...A}));o3I.displayName=Hk.displayName;const B3I=z.forwardRef(({className:g,...A},I)=>T.jsxs("div",{className:"rf-flex rf-items-center rf-border-b rf-px-3","cmdk-input-wrapper":"",children:[T.jsx(Wog,{className:"rf-mr-2 rf-h-4 rf-w-4 rf-shrink-0 rf-opacity-50"}),T.jsx(Hk.Input,{ref:I,className:co("rf-flex rf-h-10 rf-w-full rf-rounded-md rf-bg-transparent rf-py-3 rf-text-sm rf-outline-none placeholder:rf-text-zinc-500 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 dark:placeholder:rf-text-zinc-400",g),...A})]}));B3I.displayName=Hk.Input.displayName;const C3I=z.forwardRef(({className:g,...A},I)=>T.jsx(Hk.List,{ref:I,className:co("rf-max-h-[300px] rf-overflow-y-auto rf-overflow-x-hidden rf-py-1",g),...A}));C3I.displayName=Hk.List.displayName;const qQg=z.forwardRef((g,A)=>T.jsx(Hk.Empty,{ref:A,className:"rf-py-6 rf-text-center rf-text-sm",...g}));qQg.displayName=Hk.Empty.displayName;const RoA=z.forwardRef(({className:g,...A},I)=>T.jsx(Hk.Group,{ref:I,className:co("rf-overflow-hidden rf-px-1 rf-py-0 rf-text-zinc-950 [&_[cmdk-group-heading]]:rf-px-2 [&_[cmdk-group-heading]]:rf-py-1.5 [&_[cmdk-group-heading]]:rf-text-xs [&_[cmdk-group-heading]]:rf-font-medium [&_[cmdk-group-heading]]:rf-text-zinc-500 dark:rf-text-zinc-50 dark:[&_[cmdk-group-heading]]:rf-text-zinc-400",g),...A}));RoA.displayName=Hk.Group.displayName;const wNo=z.forwardRef(({className:g,...A},I)=>T.jsx(Hk.Separator,{ref:I,className:co("rf--mx-1 rf-h-px rf-bg-zinc-200 dark:rf-bg-zinc-800",g),...A}));wNo.displayName=Hk.Separator.displayName;const NoA=z.forwardRef(({className:g,...A},I)=>T.jsx(Hk.Item,{ref:I,className:co("rf-relative rf-flex rf-cursor-default rf-gap-2 rf-select-none rf-items-center rf-rounded-sm rf-px-2 rf-py-1.5 rf-text-sm rf-outline-none data-[disabled=true]:rf-pointer-events-none data-[selected=true]:rf-bg-zinc-100 data-[selected=true]:rf-text-zinc-900 data-[disabled=true]:rf-opacity-50 [&_svg]:rf-pointer-events-none [&_svg]:rf-size-4 [&_svg]:rf-shrink-0 dark:data-[selected=true]:rf-bg-zinc-800 dark:data-[selected=true]:rf-text-zinc-50",g),...A}));NoA.displayName=Hk.Item.displayName;var uNo=Object.defineProperty,cP=(g,A)=>uNo(g,"name",{value:A,configurable:!0}),ZQg="Popover",[Q3I,TCB]=hk(ZQg,[ML]),OQg=ML(),[GNo,ZO]=Q3I(ZQg),mNo=cP(g=>{const{__scopePopover:A,children:I,open:e,defaultOpen:t,onOpenChange:o,modal:B=!1}=g,C=OQg(A),Q=z.useRef(null),[i,E]=z.useState(!1),[n,s]=z.useState(0),[r,a]=z.useState(0),[c,h]=xR({prop:e,defaultProp:t??!1,onChange:o,caller:ZQg});return T.jsx(JtA,{...C,children:T.jsx(GNo,{scope:A,contentId:_0(),titleId:_0(),descriptionId:_0(),titlePresent:n>0,descriptionPresent:r>0,setTitleCount:s,setDescriptionCount:a,triggerRef:Q,open:c,onOpenChange:h,onOpenToggle:z.useCallback(()=>h(l=>!l),[h]),hasCustomAnchor:i,onCustomAnchorAdd:z.useCallback(()=>E(!0),[]),onCustomAnchorRemove:z.useCallback(()=>E(!1),[]),modal:B,children:I})})},"Popover"),pNo="PopoverTrigger",kNo=z.forwardRef(cP(function(A,I){const{__scopePopover:e,...t}=A,o=ZO(pNo,e),B=OQg(e),C=Gi(I,o.triggerRef),Q=T.jsx(yQ.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":WQg(o.open),...t,ref:C,onClick:fo(A.onClick,o.onOpenToggle)});return o.hasCustomAnchor?Q:T.jsx(QmA,{asChild:!0,...B,children:Q})},"PopoverTrigger")),i3I="PopoverPortal",[MNo,SNo]=Q3I(i3I,{forceMount:void 0}),fNo=cP(g=>{const{__scopePopover:A,forceMount:I,children:e,container:t}=g,o=ZO(i3I,A);return T.jsx(MNo,{scope:A,forceMount:I,children:T.jsx(AS,{present:I||o.open,children:T.jsx(nmA,{asChild:!0,container:t,children:e})})})},"PopoverPortal"),xoA="PopoverContent",E3I=z.forwardRef(cP(function(A,I){const e=SNo(xoA,A.__scopePopover),{forceMount:t=e.forceMount,...o}=A,B=ZO(xoA,A.__scopePopover);return T.jsx(AS,{present:t||B.open,children:B.modal?T.jsx(NNo,{...o,ref:I}):T.jsx(xNo,{...o,ref:I})})},"PopoverContent")),RNo=NR("PopoverContent.RemoveScroll"),NNo=z.forwardRef(cP(function(A,I){const e=ZO(xoA,A.__scopePopover),t=z.useRef(null),o=Gi(I,t),B=z.useRef(!1),{nodes:C,registry:Q}=VGA();return z.useEffect(()=>{const i=t.current;if(i)return rmA(i)},[]),T.jsx(PtA,{as:RNo,allowPinchZoom:!0,shards:z.useMemo(()=>[t,...C.map(i=>({current:i}))],[t,C]),children:T.jsx(n3I,{...A,ref:o,branchNodes:C,branchRegistry:Q,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fo(A.onCloseAutoFocus,i=>{i.preventDefault(),B.current||e.triggerRef.current?.focus()}),onPointerDownOutside:fo(A.onPointerDownOutside,i=>{const E=i.detail.originalEvent,n=E.button===0&&E.ctrlKey===!0,s=E.button===2||n;B.current=s},{checkForDefaultPrevented:!1}),onFocusOutside:fo(A.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),xNo=z.forwardRef(cP(function(A,I){const e=ZO(xoA,A.__scopePopover),t=z.useRef(!1),o=z.useRef(!1);return T.jsx(n3I,{...A,ref:I,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:B=>{A.onCloseAutoFocus?.(B),B.defaultPrevented||(t.current||e.triggerRef.current?.focus(),B.preventDefault()),t.current=!1,o.current=!1},onInteractOutside:B=>{A.onInteractOutside?.(B),B.defaultPrevented||(t.current=!0,B.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const C=B.target;e.triggerRef.current?.contains(C)&&B.preventDefault(),B.detail.originalEvent.type==="focusin"&&o.current&&B.preventDefault()}})},"PopoverContentNonModal")),n3I=z.forwardRef(cP(function(A,I){const{__scopePopover:e,trapFocus:t,onOpenAutoFocus:o,onCloseAutoFocus:B,disableOutsidePointerEvents:C,onEscapeKeyDown:Q,onPointerDownOutside:i,onFocusOutside:E,onInteractOutside:n,"aria-describedby":s,branchNodes:r,branchRegistry:a,...c}=A,h=ZO(xoA,e),l=OQg(e),[D,d]=z.useState(null),y=Gi(I,d);return jGA(D),rO(),T.jsx(WGA,{registry:a,children:T.jsx(OGA,{asChild:!0,loop:!0,trapped:t,branches:r,onMountAutoFocus:o,onUnmountAutoFocus:B,children:T.jsx(xtA,{asChild:!0,disableOutsidePointerEvents:C,onInteractOutside:n,onEscapeKeyDown:Q,onPointerDownOutside:i,onFocusOutside:E,onDismiss:()=>h.onOpenChange(!1),deferPointerDownOutside:!0,children:T.jsx(imA,{"data-state":WQg(h.open),role:"dialog",id:h.contentId,"aria-labelledby":h.titlePresent?h.titleId:void 0,"aria-describedby":h.descriptionPresent?s3I(s,h.descriptionId):s,...l,...c,ref:y,style:{...c.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})})},"PopoverContentImpl"));function WQg(g){return g?"open":"closed"}cP(WQg,"getState");function s3I(...g){const A=new Set;for(const I of g)if(typeof I=="string")for(const e of String(I).trim().split(/\s+/))e&&A.add(e);return A.size>0?Array.from(A).join(" "):void 0}cP(s3I,"concatAriaDescribedby");const FNo=mNo,UNo=kNo,a3I=z.forwardRef(({className:g,align:A="center",sideOffset:I=4,...e},t)=>T.jsx(fNo,{children:T.jsx(E3I,{ref:t,align:A,sideOffset:I,className:co("rf-z-50 rf-w-72 rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-p-4 rf-text-zinc-950 rf-shadow-md rf-outline-none data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2 rf-origin-[--radix-popover-content-transform-origin] dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-50",g),...e})}));a3I.displayName=E3I.displayName;function r3I(g,A){const I=g.lastIndexOf("."),e=A.lastIndexOf("."),t=I>0?g.substring(0,I):g,o=e>0?A.substring(0,e):A;if(t!==o&&g.substring(I)===A.substring(e)){if(t.startsWith(o))return 1;if(o.startsWith(t))return-1}return g.localeCompare(A,void 0,{numeric:!0,sensitivity:"base"})}function JNo(g){const A=[],I=new Map;I.set("",{name:"",path:"",type:"folder",children:A});for(const e of g){const t=e.split("/");let o="";for(let B=0;B<t.length;B++){const C=t[B],Q=o;if(o=o?`${o}/${C}`:C,!I.has(o)){const i=B===t.length-1,E={name:C,path:o,type:i?"file":"folder",children:i?void 0:[]};I.set(o,E);const n=I.get(Q);n&&n.children&&n.children.push(E)}}}return A}function c3I(g,A){for(const I of g){if(I.path===A)return I;if(I.children){const e=c3I(I.children,A);if(e)return e}}return null}function PNo(g,A){let I;if(A?I=c3I(g,A):I={name:"",path:"",type:"folder",children:g},!I||!I.children)return{files:[],folders:[]};const e=I.children.filter(o=>o.type==="file"),t=I.children.filter(o=>o.type==="folder");return e.sort((o,B)=>r3I(o.name,B.name)),t.sort((o,B)=>r3I(o.name,B.name)),{files:e,folders:t}}const KNo=g=>{const A=g.split("/").pop()||"";return A.endsWith(".py.tsx")?A.slice(0,-4):A};function VQg(g){const A=g.lastIndexOf("/");return A===-1?"/":g.substring(0,A)}function LNo({currentFile:g,files:A}){const[I,e]=z.useState(!1),[t,o]=z.useState(()=>{if(typeof window<"u"){const Q=new URLSearchParams(window.location.search),i=new URLSearchParams(window.location.hash.slice(1)),E=Q.get("file")??i.get("file");if(E&&A.includes(E)){const n=VQg(E);return n==="/"?null:n}}if(g&&A.includes(g)){const Q=VQg(g);return Q==="/"?null:Q}return null});return z.useEffect(()=>{if(g&&!I&&A.includes(g)){const Q=VQg(g);o(Q==="/"?null:Q)}},[g,I,A]),{currentFolder:t,navigateToFolder:Q=>{o(Q),e(!0)},resetManualNavigation:()=>{e(!1)}}}const jQg=g=>g.endsWith(".tsx")||g.endsWith(".jsx")?T.jsx(Cco,{className:"rf-h-4 rf-w-4 rf-text-blue-500"}):g.endsWith(".md")||g.endsWith(".txt")?T.jsx(Eco,{className:"rf-h-4 rf-w-4 rf-text-gray-600"}):T.jsx(nco,{className:"rf-h-4 rf-w-4 rf-text-gray-500"}),YNo=g=>g.endsWith(".tsx")||MoA(g)||g.endsWith(".jsx"),_No=g=>KNo(g),h3I=g=>g.substring(0,g.lastIndexOf("/"))||"/",l3I=({files:g,onFileChange:A,currentFile:I,fileFilter:e=YNo,getDisplayName:t=_No,placeholder:o="Select file",searchPlaceholder:B="Search for file",emptyMessage:C="No files found in this directory.",pinnedFiles:Q=[],onToggleFavorite:i,recentlySavedFiles:E=[]})=>{const[n,s]=z.useState(!1),[r,a]=z.useState(I),{currentFolder:c,navigateToFolder:h,resetManualNavigation:l}=LNo({currentFile:r,files:g}),[D,d]=z.useState(0),[y,w]=z.useState(""),[u,G]=gq("runframe:recentlyViewed",[]),[m,p]=gq("runframe:showRecents",!1);z.useEffect(()=>{const q=X=>{(X.metaKey||X.ctrlKey)&&X.key==="k"&&(X.preventDefault(),s(tA=>!tA))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]);const k=g.filter(e),S=z.useRef(null);z.useEffect(()=>{const q=()=>{S.current&&(clearTimeout(S.current),S.current=null)};return a(I),I&&k.includes(I)&&(q(),S.current=setTimeout(()=>{G(X=>{if(X[0]===I)return X;const tA=X.filter(IA=>IA!==I);return[I,...tA].slice(0,10)})},500)),q},[I,k,G]);const R=JNo(k),{files:x,folders:N}=PNo(R,c||""),K=(()=>{if(!y.trim())return{currentDirResults:[],globalResults:[]};const q=y.toLowerCase(),tA=k.map(sA=>{const DA=sA.split("/").pop()||"";return{path:sA,fileName:DA}}).filter(sA=>sA.fileName.toLowerCase().includes(q)||sA.path.toLowerCase().includes(q)),IA=tA.filter(sA=>c?sA.path.substring(0,sA.path.lastIndexOf("/"))===c:!sA.path.includes("/")),QA=tA.filter(sA=>c?sA.path.substring(0,sA.path.lastIndexOf("/"))!==c:sA.path.includes("/"));return{currentDirResults:IA,globalResults:QA}})(),Y=y.trim().length>0,_=q=>{h(q),d(0)},Z=z.useCallback(()=>{if(!c)return;const q=c.lastIndexOf("/"),X=q===-1?null:c.substring(0,q);_(X)},[c,_]);z.useEffect(()=>{if(!n)return;const q=X=>{(X.metaKey||X.ctrlKey)&&X.key==="ArrowUp"&&(X.preventDefault(),Z())};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[n,Z]);const V=z.useCallback((q,X,tA=!1)=>{if(a(q),d(X),s(!1),A(q),tA){const IA=q.lastIndexOf("/"),QA=IA===-1?null:q.substring(0,IA);_(QA)}},[A,_]);z.useEffect(()=>{const q=X=>{if((X.metaKey||X.ctrlKey)&&(X.key==="ArrowLeft"||X.key==="ArrowRight")){if(X.preventDefault(),!I||x.length===0)return;const tA=x.findIndex(sA=>sA.path===I);if(tA===-1)return;let IA;X.key==="ArrowLeft"?IA=tA===0?x.length-1:tA-1:IA=tA===x.length-1?0:tA+1;const QA=x[IA];QA&&V(QA.path,IA)}};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[I,x,V]),z.useEffect(()=>{if(x.length>0){const q=x.findIndex(X=>X.path===I);q>=0&&d(q)}},[x,I]);const W=z.useMemo(()=>{const q=E.filter(IA=>k.includes(IA)),X=u.filter(IA=>k.includes(IA)),tA=[];q.length>0&&tA.push({path:q[0],type:"saved"});for(const IA of X){if(tA.length>=3)break;tA.some(QA=>QA.path===IA)||tA.push({path:IA,type:"viewed"})}return tA},[E,u,k]);return T.jsx("div",{className:"rf-flex rf-min-w-0 rf-max-w-96 rf-items-center rf-gap-1",children:T.jsxs(FNo,{open:n,onOpenChange:q=>{s(q),q||(w(""),l())},children:[T.jsx(UNo,{asChild:!0,children:T.jsxs(si,{variant:"outline",role:"combobox","aria-expanded":n,className:"rf-w-full rf-min-w-0 rf-justify-center rf-items-center rf-gap-1 !rf-font-normal",title:r||o,children:[T.jsx("span",{className:"rf-truncate rf-text-left",children:r?t(r):o}),T.jsx(Ico,{className:"rf-opacity-50 rf-flex-shrink-0"})]})}),T.jsx(a3I,{collisionPadding:8,className:"!rf-p-0 !rf-overflow-y-auto !rf-z-[200]",style:{width:"min(600px, calc(100vw - 16px))",maxHeight:"min(80vh, var(--radix-popover-content-available-height))"},children:T.jsxs(o3I,{shouldFilter:!1,children:[T.jsx(B3I,{placeholder:B,className:"rf-h-9 rf-w-full",value:y,onValueChange:w}),W.length>0&&T.jsxs("div",{className:"rf-border-b rf-border-gray-200",children:[T.jsxs("button",{onClick:()=>p(!m),className:"rf-w-full rf-px-3 rf-py-2 rf-flex rf-items-center rf-justify-between rf-text-xs rf-text-slate-600 hover:rf-bg-slate-50 rf-bg-transparent rf-border-none rf-cursor-pointer",children:[T.jsx("span",{className:"rf-font-medium",children:"Recent Files"}),T.jsx(RtA,{className:co("rf-h-4 rf-w-4 rf-transition-transform",!m&&"-rf-rotate-90")})]}),m&&T.jsx("div",{className:"rf-pb-1",children:W.map((q,X)=>T.jsxs("div",{onClick:()=>V(q.path,X,!0),className:co("rf-flex rf-items-center rf-px-3 rf-py-1.5 rf-cursor-pointer hover:rf-bg-slate-100",q.path===I&&"rf-font-medium"),children:[q.type==="saved"?T.jsx("span",{title:"Recently saved",children:T.jsx(wco,{className:"rf-mr-2 rf-h-4 rf-w-4 rf-text-green-500"})}):T.jsx("span",{title:"Recently viewed",children:T.jsx(Bco,{className:"rf-mr-2 rf-h-4 rf-w-4 rf-text-blue-500"})}),T.jsx("span",{className:"rf-min-w-0 rf-truncate rf-text-sm",title:q.path,children:t(q.path.split("/").pop()||"")}),T.jsx("span",{className:"rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[40%]",children:h3I(q.path)}),T.jsx(sF,{className:co("rf-ml-auto rf-h-4 rf-w-4 rf-shrink-0",q.path===I?"rf-opacity-100":"rf-opacity-0")})]},q.path))})]}),T.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-slate-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[T.jsx("div",{className:"rf-flex rf-items-center rf-text-xs rf-text-slate-600 rf-min-w-0 rf-flex-1",children:T.jsxs("div",{className:"rf-flex rf-min-w-0 rf-items-center rf-overflow-x-auto rf-whitespace-nowrap",children:[T.jsx("button",{onClick:()=>_(null),className:"rf-text-blue-600 hover:rf-text-blue-800 rf-underline rf-cursor-pointer rf-bg-transparent rf-border-none rf-p-0 rf-flex-shrink-0",children:"root"}),c?.split("/").filter(Boolean).map((q,X,tA)=>{const IA=tA.slice(0,X+1).join("/");return T.jsxs("span",{className:"rf-flex rf-items-center rf-shrink-0",children:[T.jsx("span",{className:"rf-mx-1 rf-flex-shrink-0",children:"/"}),X===tA.length-1?T.jsx("span",{className:"rf-text-slate-800 rf-truncate rf-max-w-[200px]",title:q,children:q}):T.jsx("button",{onClick:()=>_(IA),className:"rf-text-blue-600 hover:rf-text-blue-800 rf-underline rf-cursor-pointer rf-bg-transparent rf-border-none rf-p-0 rf-truncate rf-max-w-[150px]",title:q,children:q})]},IA)})]})}),T.jsx("div",{className:"rf-flex rf-items-center rf-gap-2 rf-flex-shrink-0",children:c&&T.jsxs("button",{onClick:Z,className:"rf-flex rf-items-center rf-gap-1 rf-text-slate-600 hover:rf-text-slate-800 rf-bg-transparent rf-border-none rf-p-1 rf-rounded hover:rf-bg-slate-200 rf-transition-colors",title:"Go up one level",children:[T.jsx($ro,{className:"rf-h-3 rf-w-3"}),T.jsx("span",{className:"rf-text-xs rf-font-medium",children:"Up"})]})})]}),T.jsx(C3I,{className:"rf-overflow-visible rf-max-h-none",children:Y?T.jsx(T.Fragment,{children:K.currentDirResults.length===0&&K.globalResults.length===0?T.jsxs(qQg,{children:['No files found matching "',y,'".']}):T.jsxs(T.Fragment,{children:[K.currentDirResults.length>0&&T.jsx(RoA,{children:K.currentDirResults.map((q,X)=>T.jsxs(NoA,{value:`search-current:${q.path}`,onSelect:()=>{a(q.path),s(!1),A(q.path)},className:co(q.path===I&&"rf-font-medium","rf-group"),children:[T.jsx("span",{className:"rf-mr-2",children:jQg(q.fileName)}),T.jsxs("div",{className:"rf-flex rf-items-center rf-w-full rf-min-w-0",children:[T.jsx("span",{className:"rf-truncate rf-flex-1",children:t(q.fileName)}),T.jsx("span",{className:"rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[40%]",children:c||"/"}),q.path===I&&T.jsx(sF,{className:"rf-ml-2 rf-h-4 rf-w-4 rf-flex-shrink-0"})]})]},q.path))}),K.globalResults.length>0&&T.jsx(RoA,{children:K.globalResults.map(q=>T.jsxs(NoA,{value:`search-global:${q.path}`,onSelect:()=>{a(q.path),s(!1),A(q.path)},className:co(q.path===I&&"rf-font-medium","rf-group"),children:[T.jsx("span",{className:"rf-mr-2",children:jQg(q.fileName)}),T.jsxs("div",{className:"rf-flex rf-items-center rf-w-full rf-min-w-0",children:[T.jsx("span",{className:"rf-truncate rf-flex-1",children:t(q.fileName)}),T.jsx("span",{className:"rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[40%]",children:h3I(q.path)}),q.path===I&&T.jsx(sF,{className:"rf-ml-2 rf-h-4 rf-w-4 rf-flex-shrink-0"})]})]},q.path))})]})}):T.jsxs(T.Fragment,{children:[T.jsx(qQg,{children:C}),x.length>0&&T.jsx(RoA,{children:x.map((q,X)=>T.jsxs(NoA,{value:`current:${q.path}`,onSelect:()=>V(q.path,X),className:co(q.path===I&&"rf-font-medium","rf-group"),children:[T.jsx("span",{className:"rf-mr-2 rf-shrink-0",children:jQg(q.name)}),T.jsx("span",{className:"rf-min-w-0 rf-truncate",title:q.path,children:t(q.name)}),T.jsx("div",{className:"rf-ml-auto rf-flex rf-shrink-0 rf-items-center rf-gap-1",children:T.jsx(sF,{className:co("rf-h-4 rf-w-4",q.path===I?"rf-opacity-100":"rf-opacity-0")})})]},q.path))}),N.length>0&&T.jsx(RoA,{children:N.map(q=>T.jsxs(NoA,{value:`folder-${q.path}`,onSelect:()=>_(q.path),className:"rf-text-slate-600 hover:rf-text-slate-900",children:[T.jsx(sco,{className:"rf-mr-2 rf-h-4 rf-w-4 rf-shrink-0 rf-text-blue-600"}),T.jsx("span",{className:"rf-min-w-0 rf-truncate",title:q.path,children:q.name}),T.jsx(Fb,{className:"rf-ml-auto rf-h-4 rf-w-4 rf-shrink-0"})]},q.path))}),x.length===0&&N.length===0&&T.jsx("div",{className:"rf-p-4 rf-text-center rf-text-slate-500 rf-text-sm",children:"No files or folders in this directory"})]})})]})})]})})},bNo=({files:g,onFileChange:A,currentFile:I})=>T.jsx(l3I,{files:g,onFileChange:A,currentFile:I,fileFilter:()=>!0,placeholder:"Select circuit",searchPlaceholder:"Search for circuit file",emptyMessage:"No circuit files found in this directory."}),D3I=g=>g!==null&&!["0","false","off","no"].includes(g.toLowerCase()),HNo=({hash:g,search:A=""})=>{const I=new URLSearchParams(g.startsWith("#")?g.slice(1):g),e=new URLSearchParams(A.startsWith("?")?A.slice(1):A);return D3I(I.get("gallery"))||D3I(e.get("gallery"))},vNo=({hash:g,initialCircuitPath:A})=>{const I=new URLSearchParams(g.startsWith("#")?g.slice(1):g);return I.get("file")??I.get("main_component")??A??""},TNo=({hash:g,filePath:A})=>{const I=new URLSearchParams(g.startsWith("#")?g.slice(1):g);if(I.get("file")===A&&!I.has("gallery")&&(!I.has("main_component")||I.get("main_component")===A))return g.startsWith("#")?g:g?`#${g}`:"";I.delete("gallery"),I.set("file",A),I.has("main_component")&&I.set("main_component",A);const e=I.toString();return e?`#${e}`:""},qNo=(g,A=!1)=>{const[I,e]=z.useState(()=>typeof window>"u"?g??"":vNo({hash:window.location.hash,initialCircuitPath:g})),[t,o]=z.useState(()=>typeof window>"u"?A:A||HNo({hash:window.location.hash,search:window.location.search})),B=z.useCallback(E=>{if(typeof window>"u")return;const n=new URLSearchParams(window.location.hash.slice(1)),s=new URLSearchParams(window.location.search.slice(1));E?n.set("gallery","true"):(n.delete("gallery"),s.delete("gallery"));const r=s.toString(),a=n.toString();window.history.replaceState(null,"",`${window.location.pathname}${r?`?${r}`:""}${a?`#${a}`:""}`)},[]),C=z.useCallback(()=>{o(!0),B(!0)},[B]),Q=z.useCallback(()=>{o(!1),B(!1)},[B]),i=z.useCallback(E=>{if(typeof window>"u")return;const n=TNo({hash:window.location.hash,filePath:E}),s=new URLSearchParams(window.location.search.slice(1));s.delete("gallery");const r=s.toString(),a=`${window.location.pathname}${r?`?${r}`:""}${n}`;n===window.location.hash&&`${r?`?${r}`:""}`===window.location.search||window.history.replaceState(null,"",a)},[]);return{currentCircuitJsonPath:I,setCurrentCircuitJsonPath:e,updateFileHash:i,isGalleryVisible:t,showGallery:C,hideGallery:Q}},ZNo=g=>{const A=g.fileStaticAssetUrl,I=A.search(/[?#]/),e=I===-1?A:A.slice(0,I),t=I===-1?"":A.slice(I),o=e.includes("/")?e.slice(0,e.lastIndexOf("/")+1):"";return["3d.png","pcb.png","pcb.svg","schematic.png","schematic.svg"].map(B=>`${o}${B}${t}`)},d3I=g=>(g.split("/").pop()??g).replace(/(\.board|\.circuit)?\.(tsx|jsx|json)$/i,""),ONo=({fileRef:g})=>{const A=ZNo(g),[I,e]=z.useState(0);return I>=A.length?T.jsx("div",{className:"rf-flex rf-h-full rf-w-full rf-items-center rf-justify-center rf-bg-zinc-100 rf-text-zinc-400",children:T.jsx(rco,{className:"rf-h-8 rf-w-8","aria-hidden":"true"})}):T.jsx("img",{src:A[I],alt:`Preview of ${d3I(g.filePath)}`,className:"rf-h-full rf-w-full rf-object-contain rf-transition-transform rf-duration-200 group-hover:rf-scale-[1.03]",loading:"lazy",onError:()=>e(t=>t+1)})},WNo=({files:g,projectName:A,onSelectFile:I,onClose:e})=>(z.useEffect(()=>{const t=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),T.jsx("main",{className:"rf-h-full rf-w-full rf-overflow-y-auto rf-bg-zinc-50",children:T.jsxs("div",{className:"rf-mx-auto rf-w-full rf-max-w-7xl rf-px-5 rf-py-8 sm:rf-px-8 sm:rf-py-10",children:[T.jsxs("div",{className:"rf-mb-7 rf-flex rf-items-start rf-justify-between rf-gap-4",children:[T.jsxs("div",{children:[T.jsx("p",{className:"rf-mb-1 rf-text-xs rf-font-medium rf-uppercase rf-tracking-wider rf-text-zinc-500",children:A??"tscircuit project"}),T.jsx("h1",{className:"rf-text-2xl rf-font-semibold rf-tracking-tight rf-text-zinc-950 sm:rf-text-3xl",children:"Circuit gallery"}),T.jsxs("p",{className:"rf-mt-2 rf-text-sm rf-text-zinc-600",children:["Explore ",g.length," ",g.length===1?"board":"boards",". Select one to open its interactive preview."]})]}),T.jsxs(si,{type:"button",variant:"outline",onClick:e,children:[T.jsx(Xro,{className:"rf-h-4 rf-w-4"}),"Back to circuit"]})]}),T.jsx("div",{className:"rf-grid rf-grid-cols-1 rf-gap-5 sm:rf-grid-cols-2 lg:rf-grid-cols-3",children:g.map(t=>T.jsxs("button",{type:"button",onClick:()=>I(t.filePath),className:"group rf-overflow-hidden rf-rounded-xl rf-border rf-border-zinc-200 rf-bg-white rf-text-left rf-shadow-sm rf-transition-all hover:rf--translate-y-0.5 hover:rf-border-zinc-300 hover:rf-shadow-md focus-visible:rf-outline-none focus-visible:rf-ring-2 focus-visible:rf-ring-zinc-900 focus-visible:rf-ring-offset-2",children:[T.jsx("div",{className:"rf-aspect-[4/3] rf-w-full rf-overflow-hidden rf-bg-white rf-p-3",children:T.jsx(ONo,{fileRef:t})}),T.jsxs("div",{className:"rf-border-t rf-border-zinc-100 rf-px-4 rf-py-3",children:[T.jsx("div",{className:"rf-truncate rf-text-sm rf-font-medium rf-text-zinc-900",children:d3I(t.filePath)}),T.jsx("div",{className:"rf-mt-0.5 rf-truncate rf-text-xs rf-text-zinc-500",children:t.filePath})]})]},t.filePath))})]})})),VNo=g=>g instanceof Error?g.message:"An unknown error occurred",jNo=g=>{noA();const{currentCircuitJsonPath:A,setCurrentCircuitJsonPath:I,updateFileHash:e,isGalleryVisible:t,showGallery:o,hideGallery:B}=qNo(g.initialCircuitPath,g.defaultToGallery),[C,Q]=z.useState(null),[i,E]=z.useState(!1),[n,s]=z.useState({}),[r,a]=z.useState(new Set),[c,h]=z.useState(new Set),l=g.files,D=l.map(p=>p.filePath),d=z.useCallback(async p=>{if(!p.fileStaticAssetUrl)throw new Error(`No fileStaticAssetUrl provided for ${p.filePath}`);const k=await fetch(p.fileStaticAssetUrl);if(!k.ok)throw new Error(`Failed to fetch ${p.filePath}: ${k.statusText}`);return await k.json()},[]),y=z.useCallback(async p=>{if(n[p]){Q(n[p]),e(p),g.onCircuitJsonPathChange?.(p);return}if(c.has(p)){console.warn(`Skipping failed file: ${p}`),Q(null);return}if(!r.has(p)){a(k=>new Set(k).add(p)),E(!0),Q(null);try{const k=l.find(x=>x.filePath===p);if(!k)throw new Error(`File reference not found for ${p}`);const R=await(g.onFetchFile||d)(k);s(x=>({...x,[p]:R})),Q(R),e(p),g.onCircuitJsonPathChange?.(p),h(x=>{const N=new Set(x);return N.delete(p),N})}catch(k){console.error(`Failed to load circuit JSON file ${p}:`,k),h(S=>new Set(S).add(p)),Q(null)}finally{a(k=>{const S=new Set(k);return S.delete(p),S}),E(!1)}}},[l,n,r,c,g.onFetchFile,g.onCircuitJsonPathChange,d,e]);z.useEffect(()=>{if(D.length===0||t)return;let p=A;(!p||!D.includes(p))&&(p=K3I(D)??D[0],I(p)),p&&D.includes(p)&&y(p)},[A,t]);const w=z.useCallback(p=>{B(),I(p)},[B]),u=z.useCallback(p=>{h(k=>{const S=new Set(k);return S.delete(p),S}),y(p)},[y]);if(D.length===0)return T.jsx("div",{className:"rf-flex rf-flex-col rf-w-full rf-h-full rf-items-center rf-justify-center",children:T.jsxs("div",{className:"rf-text-center rf-p-8",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-2",children:"No Circuit JSON Files Found"}),T.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Please provide circuit JSON files to view."})]})});if(t)return T.jsx(WNo,{files:l,projectName:g.projectName,onSelectFile:w,onClose:B});const G=D.length>1?T.jsxs(T.Fragment,{children:[T.jsx(bNo,{currentFile:A,files:D,onFileChange:w}),T.jsx(si,{type:"button",variant:"outline",size:"icon",className:"rf-shrink-0",onClick:o,"aria-label":`Browse all ${D.length} circuits as a gallery`,title:"Open circuit gallery",children:T.jsx(nxI,{className:"rf-h-4 rf-w-4"})})]}):null,m=c.has(A);return T.jsx(GS,{fallbackRender:({error:p})=>T.jsx("div",{className:"rf-mt-4 rf-mx-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:T.jsxs("div",{className:"rf-p-4",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Circuit JSON Preview"}),T.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:VNo(p)})]})}),children:m?T.jsxs("div",{className:"rf-w-full rf-h-full rf-flex rf-flex-col",children:[T.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-min-w-0 rf-w-full rf-p-4 rf-border-b rf-border-gray-200",children:[(g.showFileMenu??!0)&&T.jsx(YpA,{isWebEmbedded:!0,circuitJson:null,projectName:g.projectName}),D.length>1&&T.jsx("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-items-center rf-gap-2",children:G})]}),T.jsx("div",{className:"rf-flex-1 rf-flex rf-items-center rf-justify-center",children:T.jsxs("div",{className:"rf-text-center rf-p-8",children:[T.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-600 rf-mb-2",children:"Failed to Load Circuit File"}),T.jsxs("p",{className:"rf-text-sm rf-text-gray-600 rf-mb-4",children:["Could not load: ",A]}),T.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-gap-2",children:[T.jsx("button",{onClick:()=>u(A),className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600",children:"Retry"}),D.length>1&&T.jsx("p",{className:"rf-text-xs rf-text-gray-500",children:"Or select a different file from the dropdown above"})]})]})})]}):T.jsx(UKI,{extraTabs:mtg(g.extraTabs,A),circuitJson:C,defaultToFullScreen:g.defaultToFullScreen,showToggleFullScreen:g.showToggleFullScreen,showFileMenu:!1,isWebEmbedded:!1,projectName:g.projectName,defaultActiveTab:g.tabSelected,leftHeaderContent:T.jsxs("div",{className:"rf-flex rf-min-w-0 rf-w-full rf-items-center rf-gap-2",children:[(g.showFileMenu??!0)&&T.jsx(YpA,{isWebEmbedded:!0,circuitJson:C,projectName:g.projectName}),D.length>1&&T.jsx("div",{className:`rf-flex rf-min-w-0 rf-flex-1 rf-items-center rf-gap-2 ${i?"rf-opacity-50":""}`,children:G})]})})})},zNo=()=>{const g=Kc(A=>A.fsMap);z.useEffect(()=>{if(!document||!g)return;const A=Array.from(g.keys()),I=K3I(A),e=g.get("package.json");try{if(e){const t=JSON.parse(e);if(t?.name){document.title=t.name;return}}}catch{}I&&(document.title=I)},[g])},y3I=(g,A,I)=>{const e=g instanceof RegExp?w3I(g,I):g,t=A instanceof RegExp?w3I(A,I):A,o=e!==null&&t!=null&&XNo(e,t,I);return o&&{start:o[0],end:o[1],pre:I.slice(0,o[0]),body:I.slice(o[0]+e.length,o[1]),post:I.slice(o[1]+t.length)}},w3I=(g,A)=>{const I=A.match(g);return I?I[0]:null},XNo=(g,A,I)=>{let e,t,o,B,C,Q=I.indexOf(g),i=I.indexOf(A,Q+1),E=Q;if(Q>=0&&i>0){if(g===A)return[Q,i];for(e=[],o=I.length;E>=0&&!C;){if(E===Q)e.push(E),Q=I.indexOf(g,E+1);else if(e.length===1){const n=e.pop();n!==void 0&&(C=[n,i])}else t=e.pop(),t!==void 0&&t<o&&(o=t,B=i),i=I.indexOf(A,E+1);E=Q<i&&Q>=0?Q:i}e.length&&B!==void 0&&(C=[o,B])}return C},u3I="\0SLASH"+Math.random()+"\0",G3I="\0OPEN"+Math.random()+"\0",zQg="\0CLOSE"+Math.random()+"\0",m3I="\0COMMA"+Math.random()+"\0",p3I="\0PERIOD"+Math.random()+"\0",$No=new RegExp(u3I,"g"),A1o=new RegExp(G3I,"g"),g1o=new RegExp(zQg,"g"),I1o=new RegExp(m3I,"g"),e1o=new RegExp(p3I,"g"),t1o=/\\\\/g,o1o=/\\{/g,B1o=/\\}/g,C1o=/\\,/g,Q1o=/\\\./g,i1o=1e5,E1o=4e6,n1o=1e3,s1o=1e3;function XQg(g){return isNaN(g)?g.charCodeAt(0):parseInt(g,10)}function a1o(g){return g.replace(t1o,u3I).replace(o1o,G3I).replace(B1o,zQg).replace(C1o,m3I).replace(Q1o,p3I)}function r1o(g){return g.replace($No,"\\").replace(A1o,"{").replace(g1o,"}").replace(I1o,",").replace(e1o,".")}function $Qg(g,A){for(let I=0;I<A.length;I++)g.push(A[I])}function c1o(g){const A=[];let I="";for(;;){const e=y3I("{","}",g);if(!e){const Q=g.split(",");return Q[0]=I+Q[0],$Qg(A,Q),A}const{pre:t,body:o,post:B}=e,C=t.split(",");if(C[0]=I+C[0],C[C.length-1]+="{"+o+"}",!B.length)return $Qg(A,C),A;I=C.pop(),$Qg(A,C),g=B}}function h1o(g,A={}){if(!g)return[];const{max:I=i1o,maxLength:e=E1o,maxDepth:t=n1o,maxRewrites:o=s1o}=A;return g.slice(0,2)==="{}"&&(g="\\{\\}"+g.slice(2)),Aig(a1o(g),I,e,t,0,o,!0).map(r1o)}function l1o(g){return"{"+g+"}"}function D1o(g){return/^-?0\d/.test(g)}function d1o(g,A){return g<=A}function y1o(g,A){return g>=A}function FoA(g,A,I,e,t,o){const B=[];let C=0;for(let Q=0;Q<g.length;Q++)for(let i=0;i<I.length;i++){if(B.length>=e)return B;const E=g[Q]+A+I[i];if(!(o&&!E)){if(C+E.length>t)return B;B.push(E),C+=E.length}}return B}function w1o(g,A,I,e){const t=g.split(/\.\./),o=[];if(t[0]===void 0||t[1]===void 0)return o;const B=XQg(t[0]),C=XQg(t[1]),Q=Math.max(t[0].length,t[1].length);let i=t.length===3&&t[2]!==void 0?Math.max(Math.abs(XQg(t[2])),1):1,E=d1o;C<B&&(i*=-1,E=y1o);const s=t.some(D1o);let r=0;for(let a=B;E(a,C)&&o.length<I;a+=i){let c;if(A)c=String.fromCharCode(a),c==="\\"&&(c="");else if(c=String(a),s){const h=Q-c.length;if(h>0){const l=new Array(h+1).join("0");a<0?c="-"+l+c.slice(1):c=l+c}}if(r+c.length>e)break;o.push(c),r+=c.length}return o}function Aig(g,A,I,e,t,o,B){if(t>e)return[g];let C=[""],Q=0,i=!1,E=!0;for(;;){const n=y3I("{","}",g);if(!n)return FoA(C,g,[""],A,I,i);const s=n.pre;if(/\$$/.test(s)){if(C=FoA(C,s+"{"+n.body+"}",[""],A,I,i&&!n.post.length),E=!1,!n.post.length)break;g=n.post;continue}const r=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),c=r||a,h=n.body.indexOf(",")>=0;if(!c&&!h){if(Q<o&&n.post.match(/,(?!,).*\}/)){Q++,g=n.pre+"{"+n.body+zQg+n.post,B=!0;continue}return FoA(C,s+"{"+n.body+"}"+n.post,[""],A,I,i)}E&&(i=B&&!c,E=!1);let l;if(c)l=w1o(n.body,a,A,I);else{let D=c1o(n.body);if(D.length===1&&D[0]!==void 0&&(D=Aig(D[0],A,I,e,t+1,o,!1).map(l1o),D.length===1)){if(C=FoA(C,s+D[0],[""],A,I,i&&!n.post.length),!n.post.length)break;g=n.post;continue}let d=i&&!n.post.length&&!s;for(let w=0;d&&w<C.length;w++)C[w]&&(d=!1);l=[];let y=0;A:for(let w=0;w<D.length;w++){const u=Aig(D[w],A,I,e,t+1,o,!1);for(let G=0;G<u.length;G++){const m=u[G];if(!(d&&!m)){if(l.length>=A||y+m.length>I)break A;l.push(m),y+=m.length}}}}if(C=FoA(C,s,l,A,I,i&&!n.post.length),!n.post.length)break;g=n.post}return C}const u1o=1024*64,VpA=g=>{if(typeof g!="string")throw new TypeError("invalid pattern");if(g.length>u1o)throw new TypeError("pattern is too long")},G1o={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},UoA=g=>g.replace(/[[\]\\-]/g,"\\$&"),m1o=g=>g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),k3I=g=>g.join(""),p1o=(g,A)=>{const I=A;if(g.charAt(I)!=="[")throw new Error("not in a brace expression");const e=[],t=[];let o=I+1,B=!1,C=!1,Q=!1,i=!1,E=I,n="";A:for(;o<g.length;){const c=g.charAt(o);if((c==="!"||c==="^")&&o===I+1){i=!0,o++;continue}if(c==="]"&&B&&!Q){E=o+1;break}if(B=!0,c==="\\"&&!Q){Q=!0,o++;continue}if(c==="["&&!Q){for(const[h,[l,D,d]]of Object.entries(G1o))if(g.startsWith(h,o)){if(n)return["$.",!1,g.length-I,!0];o+=h.length,d?t.push(l):e.push(l),C=C||D;continue A}}if(Q=!1,n){c>n?e.push(UoA(n)+"-"+UoA(c)):c===n&&e.push(UoA(c)),n="",o++;continue}if(g.startsWith("-]",o+1)){e.push(UoA(c+"-")),o+=2;continue}if(g.startsWith("-",o+1)){n=c,o+=2;continue}e.push(UoA(c)),o++}if(E<o)return["",!1,0,!1];if(!e.length&&!t.length)return["$.",!1,g.length-I,!0];if(t.length===0&&e.length===1&&/^\\?.$/.test(e[0])&&!i){const c=e[0].length===2?e[0].slice(-1):e[0];return[m1o(c),!1,E-I,!1]}const s="["+(i?"^":"")+k3I(e)+"]",r="["+(i?"":"^")+k3I(t)+"]";return[e.length&&t.length?"("+s+"|"+r+")":e.length?s:r,C,E-I,!0]},JoA=(g,{windowsPathsNoEscape:A=!1,magicalBraces:I=!0}={})=>I?A?g.replace(/\[([^/\\])\]/g,"$1"):g.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):A?g.replace(/\[([^/\\{}])\]/g,"$1"):g.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var vk;const k1o=new Set(["!","?","+","*","@"]),gig=g=>k1o.has(g),M3I=g=>gig(g.type),M1o=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),S1o=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),f1o=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),S3I=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),R1o="(?!(?:^|/)\\.\\.?(?:$|/))",jpA="(?!\\.)",N1o=new Set(["[","."]),x1o=new Set(["..","."]),F1o=new Set("().*{}+?[]^$\\!"),U1o=g=>g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Iig="[^/]",f3I=Iig+"*?",R3I=Iig+"+?";let J1o=0;class eig{type;#e;#I;#t=!1;#g=[];#A;#B;#o;#i=!1;#C;#E;#s=!1;id=++J1o;get depth(){return(this.#A?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#A?.id,depth:this.depth,partsLength:this.#g.length,parts:this.#g}}constructor(A,I,e={}){this.type=A,A&&(this.#I=!0),this.#A=I,this.#e=this.#A?this.#A.#e:this,this.#C=this.#e===this?e:this.#e.#C,this.#o=this.#e===this?[]:this.#e.#o,A==="!"&&!this.#e.#i&&this.#o.push(this),this.#B=this.#A?this.#A.#g.length:0}get hasMagic(){if(this.#I!==void 0)return this.#I;for(const A of this.#g)if(typeof A!="string"&&(A.type||A.hasMagic))return this.#I=!0;return this.#I}toString(){return this.#E!==void 0?this.#E:this.type?this.#E=this.type+"("+this.#g.map(A=>String(A)).join("|")+")":this.#E=this.#g.map(A=>String(A)).join("")}#a(){if(this!==this.#e)throw new Error("should only call on root");if(this.#i)return this;this.toString(),this.#i=!0;let A;for(;A=this.#o.pop();){if(A.type!=="!")continue;let I=A,e=I.#A;for(;e;){for(let t=I.#B+1;!e.type&&t<e.#g.length;t++)for(const o of A.#g){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(e.#g[t])}I=e,e=I.#A}}return this}push(...A){for(const I of A)if(I!==""){if(typeof I!="string"&&!(I instanceof vk&&I.#A===this))throw new Error("invalid part: "+I);this.#g.push(I)}}toJSON(){const A=this.type===null?this.#g.slice().map(I=>typeof I=="string"?I:I.toJSON()):[this.type,...this.#g.map(I=>I.toJSON())];return this.isStart()&&!this.type&&A.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#i&&this.#A?.type==="!")&&A.push({}),A}isStart(){if(this.#e===this)return!0;if(!this.#A?.isStart())return!1;if(this.#B===0)return!0;const A=this.#A;for(let I=0;I<this.#B;I++){const e=A.#g[I];if(!(e instanceof vk&&e.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#A?.type==="!")return!0;if(!this.#A?.isEnd())return!1;if(!this.type)return this.#A?.isEnd();const A=this.#A?this.#A.#g.length:0;return this.#B===A-1}copyIn(A){typeof A=="string"?this.push(A):this.push(A.clone(this))}clone(A){const I=new vk(this.type,A);for(const e of this.#g)I.copyIn(e);return I}static#Q(A,I,e,t,o){const B=t.maxExtglobRecursion??2;let C=!1,Q=!1,i=-1,E=!1;if(I.type===null){let c=e,h="";for(;c<A.length;){const l=A.charAt(c++);if(C||l==="\\"){C=!C,h+=l;continue}if(Q){c===i+1?(l==="^"||l==="!")&&(E=!0):l==="]"&&!(c===i+2&&E)&&(Q=!1),h+=l;continue}else if(l==="["){Q=!0,i=c,E=!1,h+=l;continue}if(!t.noext&&gig(l)&&A.charAt(c)==="("&&o<=B){I.push(h),h="";const d=new vk(l,I);c=vk.#Q(A,d,c,t,o+1),I.push(d);continue}h+=l}return I.push(h),c}let n=e+1,s=new vk(null,I);const r=[];let a="";for(;n<A.length;){const c=A.charAt(n++);if(C||c==="\\"){C=!C,a+=c;continue}if(Q){n===i+1?(c==="^"||c==="!")&&(E=!0):c==="]"&&!(n===i+2&&E)&&(Q=!1),a+=c;continue}else if(c==="["){Q=!0,i=n,E=!1,a+=c;continue}if(!t.noext&&gig(c)&&A.charAt(n)==="("&&(o<=B||I&&I.#n(c))){const l=I&&I.#n(c)?0:1;s.push(a),a="";const D=new vk(c,s);s.push(D),n=vk.#Q(A,D,n,t,o+l);continue}if(c==="|"){s.push(a),a="",r.push(s),s=new vk(null,I);continue}if(c===")")return a===""&&I.#g.length===0&&(I.#s=!0),s.push(a),a="",I.push(...r,s),n;a+=c}return I.type=null,I.#I=void 0,I.#g=[A.substring(e-1)],n}#h(A){return this.#l(A,S1o)}#l(A,I=M1o){if(!A||typeof A!="object"||A.type!==null||A.#g.length!==1||this.type===null)return!1;const e=A.#g[0];return!e||typeof e!="object"||e.type===null?!1:this.#n(e.type,I)}#n(A,I=f1o){return!!I.get(this.type)?.includes(A)}#r(A,I){const e=A.#g[0],t=new vk(null,e,this.options);t.#g.push(""),e.push(t),this.#c(A,I)}#c(A,I){const e=A.#g[0];this.#g.splice(I,1,...e.#g);for(const t of e.#g)typeof t=="object"&&(t.#A=this);this.#E=void 0}#y(A){return!!S3I.get(this.type)?.has(A)}#w(A){if(!A||typeof A!="object"||A.type!==null||A.#g.length!==1||this.type===null||this.#g.length!==1)return!1;const I=A.#g[0];return!I||typeof I!="object"||I.type===null?!1:this.#y(I.type)}#u(A){const I=S3I.get(this.type),e=A.#g[0],t=I?.get(e.type);if(!t)return!1;this.#g=e.#g;for(const o of this.#g)typeof o=="object"&&(o.#A=this);this.type=t,this.#E=void 0,this.#s=!1}static fromGlob(A,I={}){const e=new vk(null,void 0,I);return vk.#Q(A,e,0,I,0),e}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();const A=this.toString(),[I,e,t,o]=this.toRegExpSource();if(!(t||this.#I||this.#C.nocase&&!this.#C.nocaseMagicOnly&&A.toUpperCase()!==A.toLowerCase()))return e;const C=(this.#C.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${I}$`,C),{_src:I,_glob:A})}get options(){return this.#C}toRegExpSource(A){const I=A??!!this.#C.dot;if(this.#e===this&&(this.#D(),this.#a()),!M3I(this)){const Q=this.isStart()&&this.isEnd()&&!this.#g.some(r=>typeof r!="string"),i=this.#g.map(r=>{const[a,c,h,l]=typeof r=="string"?vk.#G(r,this.#I,Q):r.toRegExpSource(A);return this.#I=this.#I||h,this.#t=this.#t||l,a}).join("");let E="";if(this.isStart()&&typeof this.#g[0]=="string"&&!(this.#g.length===1&&x1o.has(this.#g[0]))){const a=N1o,c=I&&a.has(i.charAt(0))||i.startsWith("\\.")&&a.has(i.charAt(2))||i.startsWith("\\.\\.")&&a.has(i.charAt(4)),h=!I&&!A&&a.has(i.charAt(0));E=c?R1o:h?jpA:""}let n="";return this.isEnd()&&this.#e.#i&&this.#A?.type==="!"&&(n="(?:$|\\/)"),[E+i+n,JoA(i),this.#I=!!this.#I,this.#t]}const e=this.type==="*"||this.type==="+",t=this.type==="!"?"(?:(?!(?:":"(?:";let o=this.#d(I);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){const Q=this.toString(),i=this;return i.#g=[Q],i.type=null,i.#I=void 0,[Q,JoA(this.toString()),!1,!1]}let B=!e||A||I||!jpA?"":this.#d(!0);B===o&&(B=""),B&&(o=`(?:${o})(?:${B})*?`);let C="";if(this.type==="!"&&this.#s)C=(this.isStart()&&!I?jpA:"")+R3I;else{const Q=this.type==="!"?"))"+(this.isStart()&&!I&&!A?jpA:"")+f3I+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&B?")":this.type==="*"&&B?")?":`)${this.type}`;C=t+o+Q}return[C,JoA(o),this.#I=!!this.#I,this.#t]}#D(){if(M3I(this)){let A=0,I=!1;do{I=!0;for(let e=0;e<this.#g.length;e++){const t=this.#g[e];typeof t=="object"&&(t.#D(),this.#l(t)?(I=!1,this.#c(t,e)):this.#h(t)?(I=!1,this.#r(t,e)):this.#w(t)&&(I=!1,this.#u(t)))}}while(!I&&++A<10)}else for(const A of this.#g)typeof A=="object"&&A.#D();this.#E=void 0}#d(A){return this.#g.map(I=>{if(typeof I=="string")throw new Error("string type in extglob ast??");const[e,t,o,B]=I.toRegExpSource(A);return this.#t=this.#t||B,e}).filter(I=>!(this.isStart()&&this.isEnd())||!!I).join("|")}static#G(A,I,e=!1){let t=!1,o="",B=!1,C=!1;for(let Q=0;Q<A.length;Q++){const i=A.charAt(Q);if(t){t=!1,o+=(F1o.has(i)?"\\":"")+i;continue}if(i==="*"){if(C)continue;C=!0,o+=e&&/^[*]+$/.test(A)?R3I:f3I,I=!0;continue}else C=!1;if(i==="\\"){Q===A.length-1?o+="\\\\":t=!0;continue}if(i==="["){const[E,n,s,r]=p1o(A,Q);if(s){o+=E,B=B||n,Q+=s-1,I=I||r;continue}}if(i==="?"){o+=Iig,I=!0;continue}o+=U1o(i)}return[o,JoA(A),!!I,B]}}vk=eig;const P1o=(g,{windowsPathsNoEscape:A=!1,magicalBraces:I=!1}={})=>I?A?g.replace(/[?*()[\]{}]/g,"[$&]"):g.replace(/[?*()[\]\\{}]/g,"\\$&"):A?g.replace(/[?*()[\]]/g,"[$&]"):g.replace(/[?*()[\]\\]/g,"\\$&");var OO={env:{}};const zm=(g,A,I={})=>(VpA(A),!I.nocomment&&A.charAt(0)==="#"?!1:new PoA(A,I).match(g)),K1o=/^\*+([^+@!?*[(]*)$/,L1o=g=>A=>!A.startsWith(".")&&A.endsWith(g),Y1o=g=>A=>A.endsWith(g),_1o=g=>(g=g.toLowerCase(),A=>!A.startsWith(".")&&A.toLowerCase().endsWith(g)),b1o=g=>(g=g.toLowerCase(),A=>A.toLowerCase().endsWith(g)),H1o=/^\*+\.\*+$/,v1o=g=>!g.startsWith(".")&&g.includes("."),T1o=g=>g!=="."&&g!==".."&&g.includes("."),q1o=/^\.\*+$/,Z1o=g=>g!=="."&&g!==".."&&g.startsWith("."),O1o=/^\*+$/,W1o=g=>g.length!==0&&!g.startsWith("."),V1o=g=>g.length!==0&&g!=="."&&g!=="..",j1o=/^\?+([^+@!?*[(]*)?$/,z1o=([g,A=""])=>{const I=N3I([g]);return A?(A=A.toLowerCase(),e=>I(e)&&e.toLowerCase().endsWith(A)):I},X1o=([g,A=""])=>{const I=x3I([g]);return A?(A=A.toLowerCase(),e=>I(e)&&e.toLowerCase().endsWith(A)):I},$1o=([g,A=""])=>{const I=x3I([g]);return A?e=>I(e)&&e.endsWith(A):I},Axo=([g,A=""])=>{const I=N3I([g]);return A?e=>I(e)&&e.endsWith(A):I},N3I=([g])=>{const A=g.length;return I=>I.length===A&&!I.startsWith(".")},x3I=([g])=>{const A=g.length;return I=>I.length===A&&I!=="."&&I!==".."},F3I=typeof OO=="object"&&OO?typeof OO.env=="object"&&OO.env&&OO.env.__MINIMATCH_TESTING_PLATFORM__||OO.platform:"posix",U3I={win32:{sep:"\\"},posix:{sep:"/"}},gxo=F3I==="win32"?U3I.win32.sep:U3I.posix.sep;zm.sep=gxo;const mG=Symbol("globstar **");zm.GLOBSTAR=mG;const Ixo="[^/]"+"*?",exo="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",txo="(?:(?!(?:\\/|^)\\.).)*?",oxo=(g,A={})=>I=>zm(I,g,A);zm.filter=oxo;const uf=(g,A={})=>Object.assign({},g,A),Bxo=g=>{if(!g||typeof g!="object"||!Object.keys(g).length)return zm;const A=zm;return Object.assign((e,t,o={})=>A(e,t,uf(g,o)),{Minimatch:class extends A.Minimatch{constructor(t,o={}){super(t,uf(g,o))}static defaults(t){return A.defaults(uf(g,t)).Minimatch}},AST:class extends A.AST{constructor(t,o,B={}){super(t,o,uf(g,B))}static fromGlob(t,o={}){return A.AST.fromGlob(t,uf(g,o))}},unescape:(e,t={})=>A.unescape(e,uf(g,t)),escape:(e,t={})=>A.escape(e,uf(g,t)),filter:(e,t={})=>A.filter(e,uf(g,t)),defaults:e=>A.defaults(uf(g,e)),makeRe:(e,t={})=>A.makeRe(e,uf(g,t)),braceExpand:(e,t={})=>A.braceExpand(e,uf(g,t)),match:(e,t,o={})=>A.match(e,t,uf(g,o)),sep:A.sep,GLOBSTAR:mG})};zm.defaults=Bxo;const J3I=(g,A={})=>(VpA(g),A.nobrace||!/\{(?:(?!\{).)*\}/.test(g)?[g]:h1o(g,{max:A.braceExpandMax}));zm.braceExpand=J3I;const Cxo=(g,A={})=>new PoA(g,A).makeRe();zm.makeRe=Cxo;const Qxo=(g,A,I={})=>{const e=new PoA(A,I);return g=g.filter(t=>e.match(t)),e.options.nonull&&!g.length&&g.push(A),g};zm.match=Qxo;const P3I=/[?*]|[+@!]\(.*?\)|\[|\]/,ixo=g=>g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class PoA{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(A,I={}){VpA(A),I=I||{},this.options=I,this.maxGlobstarRecursion=I.maxGlobstarRecursion??200,this.pattern=A,this.platform=I.platform||F3I,this.isWindows=this.platform==="win32";const e="allowWindowsEscape";this.windowsPathsNoEscape=!!I.windowsPathsNoEscape||I[e]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!I.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!I.nonegate,this.comment=!1,this.empty=!1,this.partial=!!I.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=I.windowsNoMagicRoot!==void 0?I.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(const A of this.set)for(const I of A)if(typeof I!="string")return!0;return!1}debug(...A){}make(){const A=this.pattern,I=this.options;if(!I.nocomment&&A.charAt(0)==="#"){this.comment=!0;return}if(!A){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],I.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);const e=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(e),this.debug(this.pattern,this.globParts);let t=this.globParts.map((o,B,C)=>{if(this.isWindows&&this.windowsNoMagicRoot){const Q=o[0]===""&&o[1]===""&&(o[2]==="?"||!P3I.test(o[2]))&&!P3I.test(o[3]),i=/^[a-z]:/i.test(o[0]);if(Q)return[...o.slice(0,4),...o.slice(4).map(E=>this.parse(E))];if(i)return[o[0],...o.slice(1).map(E=>this.parse(E))]}return o.map(Q=>this.parse(Q))});if(this.debug(this.pattern,t),this.set=t.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){const B=this.set[o];B[0]===""&&B[1]===""&&this.globParts[o][2]==="?"&&typeof B[3]=="string"&&/^[a-z]:$/i.test(B[3])&&(B[2]="?")}this.debug(this.pattern,this.set)}preprocess(A){if(this.options.noglobstar)for(const e of A)for(let t=0;t<e.length;t++)e[t]==="**"&&(e[t]="*");const{optimizationLevel:I=1}=this.options;return I>=2?(A=this.firstPhasePreProcess(A),A=this.secondPhasePreProcess(A)):I>=1?A=this.levelOneOptimize(A):A=this.adjascentGlobstarOptimize(A),A}adjascentGlobstarOptimize(A){return A.map(I=>{let e=-1;for(;(e=I.indexOf("**",e+1))!==-1;){let t=e;for(;I[t+1]==="**";)t++;t!==e&&I.splice(e,t-e)}return I})}levelOneOptimize(A){return A.map(I=>(I=I.reduce((e,t)=>{const o=e[e.length-1];return t==="**"&&o==="**"?e:t===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(e.pop(),e):(e.push(t),e)},[]),I.length===0?[""]:I))}levelTwoFileOptimize(A){Array.isArray(A)||(A=this.slashSplit(A));let I=!1;do{if(I=!1,!this.preserveMultipleSlashes){for(let t=1;t<A.length-1;t++){const o=A[t];t===1&&o===""&&A[0]===""||(o==="."||o==="")&&(I=!0,A.splice(t,1),t--)}A[0]==="."&&A.length===2&&(A[1]==="."||A[1]==="")&&(I=!0,A.pop())}let e=0;for(;(e=A.indexOf("..",e+1))!==-1;){const t=A[e-1];t&&t!=="."&&t!==".."&&t!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(t))&&(I=!0,A.splice(e-1,2),e-=2)}}while(I);return A.length===0?[""]:A}firstPhasePreProcess(A){let I=!1;do{I=!1;for(let e of A){let t=-1;for(;(t=e.indexOf("**",t+1))!==-1;){let B=t;for(;e[B+1]==="**";)B++;B>t&&e.splice(t+1,B-t);let C=e[t+1];const Q=e[t+2],i=e[t+3];if(C!==".."||!Q||Q==="."||Q===".."||!i||i==="."||i==="..")continue;I=!0,e.splice(t,1);const E=e.slice(0);E[t]="**",A.push(E),t--}if(!this.preserveMultipleSlashes){for(let B=1;B<e.length-1;B++){const C=e[B];B===1&&C===""&&e[0]===""||(C==="."||C==="")&&(I=!0,e.splice(B,1),B--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(I=!0,e.pop())}let o=0;for(;(o=e.indexOf("..",o+1))!==-1;){const B=e[o-1];if(B&&B!=="."&&B!==".."&&B!=="**"){I=!0;const Q=o===1&&e[o+1]==="**"?["."]:[];e.splice(o-1,2,...Q),e.length===0&&e.push(""),o-=2}}}}while(I);return A}secondPhasePreProcess(A){for(let I=0;I<A.length-1;I++)for(let e=I+1;e<A.length;e++){const t=this.partsMatch(A[I],A[e],!this.preserveMultipleSlashes);if(t){A[I]=[],A[e]=t;break}}return A.filter(I=>I.length)}partsMatch(A,I,e=!1){let t=0,o=0,B=[],C="";for(;t<A.length&&o<I.length;)if(A[t]===I[o])B.push(C==="b"?I[o]:A[t]),t++,o++;else if(e&&A[t]==="**"&&I[o]===A[t+1])B.push(A[t]),t++;else if(e&&I[o]==="**"&&A[t]===I[o+1])B.push(I[o]),o++;else if(A[t]==="*"&&I[o]&&(this.options.dot||!I[o].startsWith("."))&&I[o]!=="**"){if(C==="b")return!1;C="a",B.push(A[t]),t++,o++}else if(I[o]==="*"&&A[t]&&(this.options.dot||!A[t].startsWith("."))&&A[t]!=="**"){if(C==="a")return!1;C="b",B.push(I[o]),t++,o++}else return!1;return A.length===I.length&&B}parseNegate(){if(this.nonegate)return;const A=this.pattern;let I=!1,e=0;for(let t=0;t<A.length&&A.charAt(t)==="!";t++)I=!I,e++;e&&(this.pattern=A.slice(e)),this.negate=I}matchOne(A,I,e=!1){let t=0,o=0;if(this.isWindows){const C=typeof A[0]=="string"&&/^[a-z]:$/i.test(A[0]),Q=!C&&A[0]===""&&A[1]===""&&A[2]==="?"&&/^[a-z]:$/i.test(A[3]),i=typeof I[0]=="string"&&/^[a-z]:$/i.test(I[0]),E=!i&&I[0]===""&&I[1]===""&&I[2]==="?"&&typeof I[3]=="string"&&/^[a-z]:$/i.test(I[3]),n=Q?3:C?0:void 0,s=E?3:i?0:void 0;if(typeof n=="number"&&typeof s=="number"){const[r,a]=[A[n],I[s]];r.toLowerCase()===a.toLowerCase()&&(I[s]=r,o=s,t=n)}}const{optimizationLevel:B=1}=this.options;return B>=2&&(A=this.levelTwoFileOptimize(A)),I.includes(mG)?this.#e(A,I,e,t,o):this.#t(A,I,e,t,o)}#e(A,I,e,t,o){const B=I.indexOf(mG,o),C=I.lastIndexOf(mG),[Q,i,E]=e?[I.slice(o,B),I.slice(B+1),[]]:[I.slice(o,B),I.slice(B+1,C),I.slice(C+1)];if(Q.length){const D=A.slice(t,t+Q.length);if(!this.#t(D,Q,e,0,0))return!1;t+=Q.length,o+=Q.length}let n=0;if(E.length){if(E.length+t>A.length)return!1;let D=A.length-E.length;if(this.#t(A,E,e,D,0))n=E.length;else{if(A[A.length-1]!==""||t+E.length===A.length||(D--,!this.#t(A,E,e,D,0)))return!1;n=E.length+1}}if(!i.length){let D=!!n;for(let d=t;d<A.length-n;d++){const y=String(A[d]);if(D=!0,y==="."||y===".."||!this.options.dot&&y.startsWith("."))return!1}return e||D}const s=[[[],0]];let r=s[0],a=0;const c=[0];for(const D of i)D===mG?(c.push(a),r=[[],0],s.push(r)):(r[0].push(D),a++);let h=s.length-1;const l=A.length-n;for(const D of s)D[1]=l-(c[h--]+D[0].length);return!!this.#I(A,s,t,0,e,0,!!n)}#I(A,I,e,t,o,B,C){const Q=I[t];if(!Q){for(let n=e;n<A.length;n++){C=!0;const s=A[n];if(s==="."||s===".."||!this.options.dot&&s.startsWith("."))return!1}return C}const[i,E]=Q;for(;e<=E;){if(this.#t(A.slice(0,e+i.length),i,o,e,0)&&B<this.maxGlobstarRecursion){const r=this.#I(A,I,e+i.length,t+1,o,B+1,C);if(r!==!1)return r}const s=A[e];if(s==="."||s===".."||!this.options.dot&&s.startsWith("."))return!1;e++}return o||null}#t(A,I,e,t,o){let B,C,Q,i;for(B=t,C=o,i=A.length,Q=I.length;B<i&&C<Q;B++,C++){this.debug("matchOne loop");let E=I[C],n=A[B];if(this.debug(I,E,n),E===!1||E===mG)return!1;let s;if(typeof E=="string"?(s=n===E,this.debug("string match",E,n,s)):(s=E.test(n),this.debug("pattern match",E,n,s)),!s)return!1}if(B===i&&C===Q)return!0;if(B===i)return e;if(C===Q)return B===i-1&&A[B]==="";throw new Error("wtf?")}braceExpand(){return J3I(this.pattern,this.options)}parse(A){VpA(A);const I=this.options;if(A==="**")return mG;if(A==="")return"";let e,t=null;(e=A.match(O1o))?t=I.dot?V1o:W1o:(e=A.match(K1o))?t=(I.nocase?I.dot?b1o:_1o:I.dot?Y1o:L1o)(e[1]):(e=A.match(j1o))?t=(I.nocase?I.dot?X1o:z1o:I.dot?$1o:Axo)(e):(e=A.match(H1o))?t=I.dot?T1o:v1o:(e=A.match(q1o))&&(t=Z1o);const o=eig.fromGlob(A,this.options).toMMPattern();return t&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:t}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;const A=this.set;if(!A.length)return this.regexp=!1,this.regexp;const I=this.options,e=I.noglobstar?Ixo:I.dot?exo:txo,t=new Set(I.nocase?["i"]:[]);let o=A.map(Q=>{const i=Q.map(n=>{if(n instanceof RegExp)for(const s of n.flags.split(""))t.add(s);return typeof n=="string"?ixo(n):n===mG?mG:n._src});i.forEach((n,s)=>{const r=i[s+1],a=i[s-1];n!==mG||a===mG||(a===void 0?r!==void 0&&r!==mG?i[s+1]="(?:\\/|"+e+"\\/)?"+r:i[s]=e:r===void 0?i[s-1]=a+"(?:\\/|\\/"+e+")?":r!==mG&&(i[s-1]=a+"(?:\\/|\\/"+e+"\\/)"+r,i[s+1]=mG))});const E=i.filter(n=>n!==mG);if(this.partial&&E.length>=1){const n=[];for(let s=1;s<=E.length;s++)n.push(E.slice(0,s).join("/"));return"(?:"+n.join("|")+")"}return E.join("/")}).join("|");const[B,C]=A.length>1?["(?:",")"]:["",""];o="^"+B+o+C+"$",this.partial&&(o="^(?:\\/|"+B+o.slice(1,-1)+C+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...t].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(A){return this.preserveMultipleSlashes?A.split("/"):this.isWindows&&/^\/\/[^/]+/.test(A)?["",...A.split(/\/+/)]:A.split(/\/+/)}match(A,I=this.partial){if(this.debug("match",A,this.pattern),this.comment)return!1;if(this.empty)return A==="";if(A==="/"&&I)return!0;const e=this.options;this.isWindows&&(A=A.split("\\").join("/"));const t=this.slashSplit(A);this.debug(this.pattern,"split",t);const o=this.set;this.debug(this.pattern,"set",o);let B=t[t.length-1];if(!B)for(let C=t.length-2;!B&&C>=0;C--)B=t[C];for(const C of o){let Q=t;if(e.matchBase&&C.length===1&&(Q=[B]),this.matchOne(Q,C,I))return e.flipNegate?!0:!this.negate}return e.flipNegate?!1:this.negate}static defaults(A){return zm.defaults(A).Minimatch}}zm.AST=eig,zm.Minimatch=PoA,zm.escape=P1o,zm.unescape=JoA;const Exo=g=>(g.endsWith(".tsx")||g.endsWith(".ts")||g.endsWith(".jsx")||g.endsWith(".js")||MoA(g))&&!g.endsWith(".d.ts"),nxo=g=>{if(!g)return null;try{const A=JSON.parse(g);return Iie.parse(A)}catch(A){return console.warn("Failed to parse tscircuit.config.json",A),null}},sxo=(g,A)=>{const e=nxo(A)?.includeBoardFiles?.filter(Boolean);if(e&&e.length>0){const t=e.map(o=>new PoA(o,{dot:!0}));return g.filter(o=>t.some(B=>B.match(o)))}return g.filter(Exo)},tig=kE("run-frame:RunFrameWithApi"),axo=()=>{const A=!!Kc(e=>e.error),I=A?"Dev server disconnected":"Dev server connected";return T.jsx(NQg,{children:T.jsxs(xQg,{children:[T.jsx(FQg,{asChild:!0,children:T.jsx("button",{type:"button","aria-label":I,className:"rf-inline-flex rf-items-center rf-justify-center rf-p-2 rf-rounded-full rf-outline-none",children:T.jsx("span",{className:co("rf-inline-flex rf-size-2 rf-rounded-full rf-flex-shrink-0",A?"rf-bg-red-600":"rf-bg-green-600 rf-opacity-50"),"aria-hidden":"true"})})}),T.jsx(bpA,{side:"right",children:I})]})})},K3I=g=>g.find(A=>A.includes("entrypoint."))??g.find(A=>A.includes("index."))??g.find(A=>A.includes("main."))??g.find(A=>A.endsWith(".tsx")),rxo=g=>g.find(A=>A.includes("manual-edits."))??g.find(A=>A.includes("manual-edit."))??g.find(A=>A.endsWith(".json")),L3I=g=>{const{apiBaseUrl:A,leftHeaderContent:I}=g;z.useEffect(()=>{g.debug&&kE.enable("run-frame*")},[g.debug]);const e=Kc(x=>x.startPolling),t=Kc(x=>x.stopPolling),o=Kc(x=>x.setCurrentMainComponentPath),B=Kc(x=>x.pushEvent),C=Qrt(),Q=Kc(x=>x.fsMap),i=Kc(x=>x.recentlySavedFiles),E=z.useMemo(()=>Array.from(Q.keys()),[Q]),n=z.useMemo(()=>{const x=Q.get("tscircuit.config.json");return typeof x=="string"?x:void 0},[Q]),s=z.useMemo(()=>sxo(E,n),[E,n]),r=Kc(x=>x.circuitJson),[a,c]=z.useState(()=>typeof window>"u"?g.initialMainComponentPath??"":new URLSearchParams(window.location.hash.slice(1)).get("file")??g.initialMainComponentPath??""),[h,l]=gq("runframe:favorites",[]),D=!C,d=z.useCallback(x=>{l(N=>N.includes(x)?N.filter(U=>U!==x):[...N,x])},[l]),y=g.fileFilter??URo,w=z.useMemo(()=>s.filter(y),[s,y]);z.useEffect(()=>{if(a&&(w.includes(a)||s.includes(a)))return;if(a){const Y=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"",_=w.find(Z=>(Z.includes("/")?Z.substring(0,Z.lastIndexOf("/")):"")===Y);if(_){c(_);return}}const x=window?.TSCIRCUIT_DEFAULT_MAIN_COMPONENT_PATH,N=[g.initialMainComponentPath,x].filter(Y=>!!Y);for(const Y of N)if(w.includes(Y)){c(Y);return}const K=(w.length>0?w:s)[0];K&&c(K)},[w,s,g.initialMainComponentPath,a]);const u=z.useCallback(x=>{if(typeof window>"u")return;const N=new URLSearchParams(window.location.hash.slice(1));if(N.get("file")===x)return;N.set("file",x);const U=N.toString(),K=`${window.location.pathname}${window.location.search}${U.length>0?`#${U}`:""}`;window.history.replaceState(null,"",K)},[]);z.useEffect(()=>{a&&(u(a),g.onMainComponentPathChange?.(a),o(a))},[a,g.onMainComponentPathChange,u,o]),zNo();const{editEventsForRender:G,pushEditEvent:m,markRenderStarted:p,markRenderComplete:k}=Crt();z.useEffect(()=>{A&&(window.TSCIRCUIT_FILESERVER_API_BASE_URL=A)},[A]),z.useEffect(()=>(e(),()=>t()),[e,t]);const S=z.useMemo(()=>String(a).length>0?{mainComponentPath:a}:{},[a]),R=z.useCallback(async x=>{try{await B({event_type:"RUN_COMPLETED",initiator:"runframe",...x})}catch(N){tig("Failed to push RUN_COMPLETED event",N)}},[B]);return T.jsx(OKI,{extraTabs:mtg(g.extraTabs,a),fsMap:Q,showFileMenu:g.showFileMenu,shouldLoadLatestEval:g.shouldLoadLatestEval,onChangeShouldLoadLatestEval:g.onChangeShouldLoadLatestEval,isCli:g.isCli,schematicSvgOptions:g.schematicSvgOptions,isLoadingFiles:D,evalVersion:g.evalVersion,forceLatestEvalVersion:g.forceLatestEvalVersion,evalWebWorkerBlobUrl:g.evalWebWorkerBlobUrl??g.workerBlobUrl,platformConfig:g.platformConfig,enableFetchProxy:g.enableFetchProxy,leftHeaderContent:T.jsxs("div",{className:"rf-flex rf-min-w-0 rf-w-full rf-items-center rf-gap-2",children:[T.jsxs("div",{className:"rf-flex rf-shrink-0 rf-items-center rf-gap-2",children:[g.leftHeaderContent,T.jsx(axo,{})]}),g.showFilesSwitch&&T.jsx("div",{className:"rf-min-w-0 rf-flex-1",children:T.jsx(l3I,{currentFile:a,files:w,onFileChange:x=>{typeof Q.get(x)=="string"&&c(x)},pinnedFiles:h,onToggleFavorite:d,fileFilter:y,recentlySavedFiles:i})})]}),defaultToFullScreen:g.defaultToFullScreen,showToggleFullScreen:g.showToggleFullScreen,onInitialRender:()=>{tig("onInitialRender / markRenderStarted"),p()},onRenderFinished:()=>{tig("onRenderFinished / markRenderComplete"),k()},onRunCompleted:R,editEvents:G,onEditEvent:x=>{m(x),fetch(`${Jm}/events/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_type:"USER_CREATED_MANUAL_EDIT",...x})});const N=rxo(Array.from(Q.keys()))??"manual-edits.json",U=Q.get(N),K=JSON.parse(U??"{}");WVg({circuitJson:r,editEvents:[x],manualEditsFile:K}),fetch(`${Jm}/files/upsert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:N,text_content:JSON.stringify(K),initiator:"runframe"})})},onLoginRequired:g.onLoginRequired,easyEdaProxyConfig:{proxyEndpointUrl:`${Jm}/proxy`},...S})},Y3I="tscircuit:extra-runframe-tabs-change",_3I=()=>{if(typeof window>"u")return[];const g=window.TSCIRCUIT_EXTRA_RUNFRAME_TABS;return Array.isArray(g)?[...g]:[]};function cxo(){const[g,A]=z.useState(_3I);return z.useEffect(()=>{const I=()=>A(_3I());return window.addEventListener(Y3I,I),I(),()=>window.removeEventListener(Y3I,I)},[]),g}const hxo=()=>new Promise(g=>{document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>g()):g()}),lxo=()=>{const g=window.location.hash.slice(1),I=new URLSearchParams(g).get("tab")?.toLowerCase()?.trim();return I&&["pcb","schematic","cad"].includes(I)?I:"pcb"},Dxo=()=>{const g=document.getElementById("root");if(g)return g;const A=document.createElement("div");return A.id="root",A.style.height="100vh",document.body.appendChild(A),A},dxo=async()=>{const g=Array.from(document.querySelectorAll("script[type='tscircuit-tsx']")),A=new Map;return await Promise.all(g.map(async(I,e)=>{const t=I.dataset.path||I.getAttribute("data-file-path")||`script${e?e+1:""}.tsx`;if(I.src){const B=await(await fetch(I.src)).text();A.set(t,B)}else A.set(t,I.textContent||"")})),{fsMap:A}},b3I="<--INJECT_TSCIRCUIT_EVAL_WEB_WORKER_BLOB_URL-->",oig={evalWebWorkerBlobUrl:b3I.includes("<--")?void 0:b3I,enableFetchProxy:"<--INJECT_ENABLE_FETCH_PROXY-->".includes("<--")?void 0:!0};function yxo({staticFileList:g,defaultMainComponentPath:A,projectName:I,isCli:e,fsMap:t}){const o=cxo();return Array.isArray(g)?T.jsx(jNo,{files:g,initialCircuitPath:A,tabSelected:lxo(),projectName:I,extraTabs:o}):e?T.jsx(jRo,{...oig,extraTabs:o}):t.size>0?T.jsx(OKI,{...oig,fsMap:t,extraTabs:o}):T.jsx(L3I,{...oig,extraTabs:o})}(async()=>{await hxo();const g=bVI.createRoot(Dxo()),A=window.TSCIRCUIT_RUNFRAME_STATIC_FILE_LIST,I=window.TSCIRCUIT_DEFAULT_MAIN_COMPONENT_PATH,e=window.TSCIRCUIT_PACKAGE_NAME,t=window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI,{fsMap:o}=!Array.isArray(A)&&!t?await dxo():{fsMap:new Map};g.render(T.jsx(yxo,{staticFileList:A,defaultMainComponentPath:I,projectName:e,isCli:t,fsMap:o}))})();const Xb=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));var wxo=0,uF=class{_nodeId;hasExplicitNodeId;_sourceLocation;_dirty=!1;_parent;_revision=0;constructor(g={}){this.hasExplicitNodeId=g.nodeId!==void 0,this._nodeId=g.nodeId??H3I(g.sourceLocation,this.constructor.name)??`altium-node-${(++wxo).toString(36)}`,this._sourceLocation=g.sourceLocation}get document(){let g=this;for(;g.parent;)g=g.parent;return g}get nodeId(){return this._nodeId}get isDirty(){return this._dirty}get parent(){return this._parent}get revision(){return this._revision}get sourceLocation(){return this._sourceLocation}setParent(g){return this._parent=g,this}setSourceLocation(g){return this._sourceLocation=g,this.hasExplicitNodeId||(this._nodeId=H3I(g,this.constructor.name)??this._nodeId),this}adoptChildren(g){for(const A of g)A.setParent(this)}markDirty(){this._dirty=!0,this._revision++,this.parent?.markDirty()}clearDirty(g=!1){if(this._dirty=!1,g)for(const A of this.getChildren())A.clearDirty(!0)}*walk(g=!0){g&&(yield this);for(const A of this.getChildren())yield*A.walk(!0)}visit(g){const A=(I,e,t)=>{if(g(I,{depth:t,parent:e})!==!1)for(const B of I.getChildren())A(B,I,t+1)};A(this,this.parent,0)}findAll(g,A=!0){return[...this.walk(A)].filter(g)}deepEquals(g){if(this.type!==g.type||this.getString()!==g.getString())return!1;const A=this.getChildren(),I=g.getChildren();return A.length===I.length&&A.every((e,t)=>{const o=I[t];return o!==void 0&&e.deepEquals(o)})}getStructuralHash(){let g=2166136261;const A=`${this.type}\0${this.getString()}`;for(let I=0;I<A.length;I++)g^=A.charCodeAt(I),g=Math.imul(g,16777619);return(g>>>0).toString(16).padStart(8,"0")}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,text:this.getString(),children:this.getChildren().map(g=>g.toJSON())}}};function H3I(g,A){if(!g)return;const I=g.streamPath!==void 0?[g.streamPath,g.recordIndex??"",g.fieldIndex??"",g.byteOffset??""].join(":"):g.startOffset!==void 0?`text:${g.startOffset}`:g.byteOffset!==void 0?`byte:${g.byteOffset}`:void 0;return I===void 0?void 0:`${I}:${A}`}var $b=class extends Error{code;constructor(g,A="ALTIUM_ERROR",I){super(g,I),this.name=new.target.name,this.code=A}},_L=class extends $b{excerpt;fieldName;location;recordKind;constructor(g,A={}){super(g,"ALTIUM_SYNTAX",{cause:A.cause}),this.excerpt=A.excerpt,this.fieldName=A.fieldName,this.location=A.location,this.recordKind=A.recordKind}},tu=class extends $b{constructor(g,A){super(g,"ALTIUM_FORMAT_DETECTION",A)}},XQ=class extends $b{byteOffset;constructor(g,A={}){super(g,"ALTIUM_CORRUPT_CONTAINER",{cause:A.cause}),this.byteOffset=A.byteOffset}},uxo=class extends $b{constructor(g,A){super(g,"ALTIUM_UNSUPPORTED_VERSION",A)}},Big=class extends $b{constructor(g,A){super(g,"ALTIUM_UNSUPPORTED_FEATURE",A)}},Qc=class extends $b{constructor(g,A){super(g,"ALTIUM_SERIALIZATION",A)}},Nh=class extends $b{byteOffset;constructor(g,A,I){super(g,"ALTIUM_TRUNCATED_RECORD",I),this.byteOffset=A}},Gxo=class extends uF{type="embedded-model";index;record;stream;constructor(g){super({sourceLocation:g.stream.sourceLocation}),this.index=g.index,this.record=g.record,this.stream=g.stream}get compressedSize(){return this.stream.metadata.size}get isCompressedDataLoaded(){return this.stream.isContentLoaded}getCompressedBytes(){return this.stream.content.slice()}async getDecompressedBytes(g={}){return mxo(this.stream.content,g)}getChildren(){return[this.record,this.stream]}getString(){return this.record.getString()}};async function mxo(g,A={}){const I=A.maximumOutputSize??67108864;if(!Number.isSafeInteger(I)||I<=0)throw new RangeError("maximumOutputSize must be a positive safe integer number of bytes");const e=[];let t=0;try{const C=new McA(i=>{if(t+=i.byteLength,t>I)throw new XQ(`Embedded model expands beyond the ${I}-byte limit`);e.push(i)}),Q=64*1024;for(let i=0;i<g.byteLength;){const E=Math.min(i+Q,g.byteLength);C.push(g.subarray(i,E),E===g.byteLength),i=E}}catch(C){throw C instanceof XQ?C:new XQ(`Embedded model zlib decompression failed: ${C instanceof Error?C.message:String(C)}`)}const o=new Uint8Array(t);let B=0;for(const C of e)o.set(C,B),B+=C.byteLength;return o}function ou(g){if(!Number.isFinite(g))return g;const A=(g%360+360)%360;return Object.is(A,-0)?0:A}function Cig(g,A,I=1e-9){return Math.abs(g.x-A.x)<=I&&Math.abs(g.y-A.y)<=I}function pxo(g){if(g.length===0)return;let A=Number.POSITIVE_INFINITY,I=Number.POSITIVE_INFINITY,e=Number.NEGATIVE_INFINITY,t=Number.NEGATIVE_INFINITY;for(const o of g)!Number.isFinite(o.x)||!Number.isFinite(o.y)||(A=Math.min(A,o.x),I=Math.min(I,o.y),e=Math.max(e,o.x),t=Math.max(t,o.y));return Number.isFinite(A)?{minX:A,minY:I,maxX:e,maxY:t}:void 0}function kxo(g){if(g.length<3)return 0;let A=0;for(let I=0;I<g.length;I++){const e=g[I],t=g[(I+1)%g.length];!e||!t||(A+=e.x*t.y-t.x*e.y)}return A/2}function Mxo(g){const A=kxo(g);return Math.abs(A)<=Number.EPSILON?"degenerate":A<0?"clockwise":"counterclockwise"}var Qig=class extends uF{terminator;constructor(g={}){super(g),this.terminator=g.terminator??""}},cN=class extends uF{type="field";_key;_value;constructor(g){super(g),v3I(g.key),T3I(g.value??""),this._key=g.key,this._value=g.value??""}get key(){return this._key}set key(g){v3I(g),g!==this._key&&(this._key=g,this.markDirty())}get value(){return this._value}set value(g){T3I(g),g!==this._value&&(this._value=g,this.markDirty())}getChildren(){return[]}getString(){return`${this.key}=${this.value}`}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,key:this.key,value:this.value}}};function v3I(g){if(g.length===0||/[=|\r\n]/u.test(g))throw new Error(`Invalid Altium field key: ${JSON.stringify(g)}`)}function T3I(g){if(/[|\r\n]/u.test(g))throw new Error(`Altium field values cannot contain record delimiters: ${JSON.stringify(g)}`)}var Sxo={cm:1e4/25.4,in:1e3,inch:1e3,inches:1e3,mil:1,mils:1,mm:1e3/25.4},fxo=/^([+-]?(?:\d+\.\d*|\d+|\.\d+)(?:e[+-]?\d+)?)([a-z]+)?$/iu,KoA=class _OI{unit;value;#e;constructor(A){if(!Number.isFinite(A.value))throw new RangeError("Altium measurement value must be finite");this.value=A.value,this.unit=A.unit,this.#e=A.raw??`${xxo(A.value)}${A.unit===void 0?"":A.unit}`}static parse(A){const I=fxo.exec(A.trim());if(!I?.[1])return;const e=Number(I[1]);if(Number.isFinite(e))return new _OI({raw:A,unit:I[2],value:e})}get normalizedUnit(){return this.unit?.toLowerCase()}get raw(){return this.#e}toMils(){return this.normalizedUnit===void 0?this.value:this.value*(Sxo[this.normalizedUnit]??1)}toMillimeters(){return this.toMils()*.0254}to(A){const I=this.toMils();return A==="mil"?I:A==="mm"?I*.0254:A==="cm"?I*.00254:I/1e3}equals(A,I=0){return Math.abs(this.toMils()-A.toMils())<=I}toString(){return this.raw}toJSON(){return{raw:this.raw,unit:this.unit,value:this.value}}};function WO(g){return g===void 0?void 0:KoA.parse(g)}function LoA(g){return WO(g)?.toMils()}function Rxo(g,A="mil"){if(g instanceof KoA)return g;if(typeof g=="string"){const I=KoA.parse(g);if(!I)throw new TypeError(`Invalid Altium measurement ${JSON.stringify(g)}`);return I}return typeof g=="number"?new KoA({unit:A,value:g}):new KoA(g)}function Nxo(g,A="mil"){return Rxo(g,A).toString()}function xxo(g){return Object.is(g,-0)?"-0":String(g)}var vn=class extends Qig{type="record";items;_originalBinaryPayload;constructor(g={}){super(g),this.items=g.items??[],this._originalBinaryPayload=g.originalBinaryPayload?.slice(),this.adoptChildren(this.items)}get originalBinaryPayload(){return this._originalBinaryPayload?.slice()}setOriginalBinaryPayload(g){return this._originalBinaryPayload=g?.slice(),this}getAltiumMeasurement(g){return WO(this.getCaseInsensitive(g))}get recordKind(){return this.get("RECORD")}get fields(){return this.items.filter(g=>g instanceof cN)}get(g){return this.fields.find(A=>A.key===g)?.value}getCaseInsensitive(g){const A=g.toUpperCase();return this.fields.find(I=>I.key.toUpperCase()===A)?.value}getDecoded(g){const A=this.getCaseInsensitive(`%UTF8%${g}`);return A===void 0?this.getCaseInsensitive(g):Jxo(A)}getAll(g){return this.fields.filter(A=>A.key===g).map(A=>A.value)}getFirstField(g){return this.fields.find(A=>A.key===g)}getLastField(g){return this.fields.findLast(A=>A.key===g)}getAllFields(g){return this.fields.filter(A=>A.key===g)}getBoolean(g){const A=this.getCaseInsensitive(g)?.toUpperCase();if(A==="TRUE"||A==="T")return!0;if(A==="FALSE"||A==="F")return!1}getNumber(g){const A=this.getCaseInsensitive(g);if(!(A===void 0||!Fxo(A)))return Number(A)}getMeasurement(g){const A=this.getCaseInsensitive(g);if(A===void 0)return;const I=/^\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)\s*([a-z]+)?\s*$/iu.exec(A);if(!I?.[1])return;const e=I[2];return e===void 0?{value:Number(I[1])}:{value:Number(I[1]),unit:e}}set(g,A){const I=this.fields.find(e=>e.key===g);if(I)I.value=A;else{const e=new cN({key:g,value:A}).setParent(this);this.items.push(e),this.markDirty()}return this}setMeasurement(g,A,I="mil"){return this.set(g,Nxo(A,I))}setPoint(g,A,I="mil"){return this.setMeasurement(g.x,A.x,I),this.setMeasurement(g.y,A.y,I),this}setSize(g,A,I="mil"){return this.setMeasurement(g.width,A.width,I),this.setMeasurement(g.height,A.height,I),this}setAngle(g,A){if(!Number.isFinite(A))throw new RangeError("Altium angles must be finite");return this.set(g,String(ou(A)))}insertField(g,A,I={}){const e=new cN({key:g,value:A}).setParent(this);let t=I.index;if(t===void 0&&I.beforeKey!==void 0&&(t=this.items.findIndex(B=>B instanceof cN&&B.key===I.beforeKey)),t===void 0&&I.afterKey!==void 0){const B=this.items.findLastIndex(C=>C instanceof cN&&C.key===I.afterKey);t=B<0?this.items.length:B+1}const o=t===void 0?this.items.length:Math.min(Math.max(t,0),this.items.length);return this.items.splice(o,0,e),this.markDirty(),e}replaceFieldOccurrence(g,A,I){if(!Number.isInteger(A)||A<0)return!1;const e=this.getAllFields(g)[A];return e?(e.value=I,!0):!1}delete(g){const A=this.items.length;this.items=this.items.filter(e=>!(e instanceof cN&&e.key===g));const I=A-this.items.length;return I>0&&this.markDirty(),I}getChildren(){return[...this.items]}getString(){return`|${this.items.map(g=>g.getString()).join("|")}`}toJSON(){return{type:this.type,nodeId:this.nodeId,sourceLocation:this.sourceLocation,recordKind:this.recordKind,originalBinaryPayloadLength:this._originalBinaryPayload?.byteLength,fields:this.fields.map(g=>({key:g.key,value:g.value})),items:this.items.map(g=>g.toJSON())}}};function Fxo(g){return/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/iu.test(g.trim())}var Uxo=new Map([["€",128],["‚",130],["ƒ",131],["„",132],["…",133],["†",134],["‡",135],["ˆ",136],["‰",137],["Š",138],["‹",139],["Œ",140],["Ž",142],["‘",145],["’",146],["“",147],["”",148],["•",149],["–",150],["—",151],["˜",152],["™",153],["š",154],["›",155],["œ",156],["ž",158],["Ÿ",159]]);function Jxo(g){const A=[];for(const I of g){const e=Uxo.get(I);if(e!==void 0){A.push(e);continue}const t=I.codePointAt(0);if(t===void 0||t>255)return g;A.push(t)}try{return new TextDecoder("utf-8",{fatal:!0}).decode(Uint8Array.from(A))}catch{return g}}function Zi(g,...A){for(const I of A){const e=LoA(g.getCaseInsensitive(I));if(e!==void 0)return e}}function c0(g,A,I){const e=Zi(g,...A),t=Zi(g,...I);return e===void 0||t===void 0?void 0:{x:e,y:t}}function YoA(g,A,I){const e=Zi(g,...A),t=Zi(g,...I);return e===void 0||t===void 0?void 0:{width:e,height:t}}function xt(g,...A){for(const I of A){const e=g.getDecoded(I);if(e!==void 0)return e}}function Pxo(g,...A){for(const I of A){const e=g.getNumber(I);if(e!==void 0)return e}}var zpA=class extends vn{type="component-record";constructor(g={}){super(g)}get id(){return this.getNumber("ID")}get designator(){return xt(this,"SOURCEDESIGNATOR","DESIGNATOR")}get comment(){return xt(this,"SOURCECOMMENT","COMMENT")}get footprint(){return xt(this,"PATTERN","FOOTPRINT")}get footprintLibrary(){return xt(this,"SOURCEFOOTPRINTLIBRARY")}get sourceLibrary(){return xt(this,"SOURCECOMPONENTLIBRARY")}get sourceLibraryReference(){return xt(this,"SOURCELIBREFERENCE")}get sourceUniqueId(){return xt(this,"SOURCEUNIQUEID")}get sourceHierarchicalPath(){return xt(this,"SOURCEHIERARCHICALPATH")}get position(){return c0(this,["X","LOCATION.X"],["Y","LOCATION.Y"])}get rotation(){return ou(this.getNumber("ROTATION")??0)}get side(){const g=this.getCaseInsensitive("LAYER")?.toUpperCase();return g==="TOP"||g==="TOP LAYER"?"top":g==="BOTTOM"||g==="BOTTOM LAYER"?"bottom":"unknown"}get mirrored(){return this.side==="bottom"}get locked(){return this.getBoolean("LOCKED")}get selected(){return this.getBoolean("SELECTION")}get unionIndex(){return this.getNumber("UNIONINDEX")}get channelOffset(){return this.getNumber("CHANNELOFFSET")}get heightMils(){return Zi(this,"HEIGHT")}getOwnedPrimitives(g){return g.getRecordsOwnedByComponent(this)}getBounds(g,A){return g.getComponentBounds(this,A)}},XpA=class extends vn{type="net-record";constructor(g={}){super(g)}get id(){return this.getNumber("ID")}get name(){return xt(this,"NAME")}get visible(){return this.getBoolean("VISIBLE")}get color(){return this.getNumber("COLOR")}},Kxo=65535,q3I=new WeakMap,Lxo=class{constructor(g){this.document=g,this.components=g.getRecordsByKind("Component").filter(A=>A instanceof zpA),this.nets=g.getRecordsByKind("Net").filter(A=>A instanceof XpA),this.polygons=g.getRecordsByKind("Polygon"),this.rules=[...g.getRecordsByKind("Rule"),...g.getRecordsByKind("DXPRule")],this.componentTargets=AkA(this.components),this.netTargets=AkA(this.nets),this.polygonTargets=AkA(this.polygons),this.ruleTargets=AkA(this.rules);for(const A of g.records){nig(this.byKind,A.recordKind??"Unknown",A);const I=A.getDecoded("LAYER");I!==void 0&&nig(this.byLayer,I.toUpperCase(),A),gkA(this.byComponent,A,"COMPONENT"),gkA(this.byNet,A,"NET"),gkA(this.byPolygon,A,"POLYGON"),gkA(this.byRule,A,"RULE");const e=A.getDecoded("UNIQUEID");if(!e)continue;const t=e.toUpperCase(),o=this.uniqueIds.get(t);if(!o){this.uniqueIds.set(t,A);continue}const B=this.duplicateUniqueIds.get(t)??[o];B.push(A),this.duplicateUniqueIds.set(t,B)}}document;byComponent=new Map;byKind=new Map;byLayer=new Map;byNet=new Map;byPolygon=new Map;byRule=new Map;components;duplicateUniqueIds=new Map;nets;polygons;rules;uniqueIds=new Map;componentTargets;netTargets;polygonTargets;ruleTargets;getComponent(g){return g9(g)?this.componentTargets.get(g):void 0}getNet(g){return g9(g)?this.netTargets.get(g):void 0}getPolygon(g){return g9(g)?this.polygonTargets.get(g):void 0}getRule(g){return g9(g)?this.ruleTargets.get(g):void 0}getRecordByUniqueId(g){return this.uniqueIds.get(g.toUpperCase())}getDanglingReferences(){const g=[],A=[["COMPONENT",this.componentTargets],["NET",this.netTargets],["POLYGON",this.polygonTargets],["RULE",this.ruleTargets]];for(const I of this.document.records)for(const[e,t]of A){const o=A9(I,e);o!==void 0&&!t.has(o)&&g.push({field:e,index:o,record:I})}return g}};function yr(g){const A=q3I.get(g);if(A?.revision===g.revision)return A.index;const I=new Lxo(g);return q3I.set(g,{index:I,revision:g.revision}),I}function Z3I(g,A){return yr(g).getComponent(A)}function O3I(g,A){return yr(g).getNet(A)}function W3I(g,A){return yr(g).getPolygon(A)}function V3I(g,A){return yr(g).getRule(A)}function iig(g,A){return A instanceof zpA?bL(yr(g).components,A):A9(A,"COMPONENT")}function Eig(g,A){return A instanceof XpA?bL(yr(g).nets,A):A9(A,"NET")}function Yxo(g,A){return A.recordKind==="Polygon"?bL(yr(g).polygons,A):A9(A,"POLYGON")}function _xo(g,A){return A.recordKind==="Rule"||A.recordKind==="DXPRule"?bL(yr(g).rules,A):A9(A,"RULE")??A9(A,"RULEINDEX")}function j3I(g,A){const I=iig(g,A);return I===void 0?void 0:yr(g).getComponent(I)}function z3I(g,A){const I=Eig(g,A);return I===void 0?void 0:yr(g).getNet(I)}function X3I(g,A){const I=Yxo(g,A);return I===void 0?void 0:yr(g).getPolygon(I)}function $3I(g,A){const I=_xo(g,A);return I===void 0?void 0:yr(g).getRule(I)}function $pA(g,A){const I=typeof A=="number"?A:bL(yr(g).components,A);return I===void 0?[]:[...yr(g).byComponent.get(I)??[]]}function ALI(g,A){const I=typeof A=="number"?A:bL(yr(g).nets,A);return I===void 0?[]:[...yr(g).byNet.get(I)??[]]}function gLI(g,A){const I=typeof A=="number"?A:bL(yr(g).polygons,A);return I===void 0?[]:[...yr(g).byPolygon.get(I)??[]]}function ILI(g,A){const I=typeof A=="number"?A:bL(yr(g).rules,A);return I===void 0?[]:[...yr(g).byRule.get(I)??[]]}function AkA(g){const A=new Map,I=g.some(e=>e.getNumber("ID")!==void 0);return g.forEach((e,t)=>{const o=I?e.getNumber("ID"):t;o!==void 0&&g9(o)&&A.set(o,e)}),A}function bL(g,A){if(g.some(t=>t.getNumber("ID")!==void 0)){const t=A.getNumber("ID");return t!==void 0&&g9(t)?t:void 0}const e=g.indexOf(A);return e>=0?e:void 0}function gkA(g,A,I){const e=A9(A,I);e!==void 0&&nig(g,e,A)}function nig(g,A,I){const e=g.get(A);e?e.push(I):g.set(A,[I])}function A9(g,A){const I=g.getNumber(A);return I!==void 0&&g9(I)?I:void 0}function g9(g){return Number.isInteger(g)&&g>=0&&g<Kxo}var eLI=1e5,bxo=1e4;function sig(g){return tkA(Hxo(g))}function Hxo(g){return tLI(QLI(g))}function tLI(g){const A=[];for(let I=0;I<eLI;I++){const e=I9(g,`VX${I}`),t=I9(g,`VY${I}`);if(e===void 0||t===void 0)break;const o=rig(g,`KIND${I}`),B={x:e,y:t};if(o!==1){A.push({index:I,kind:o===void 0||o===0?"line":"unknown",position:B,rawKind:o});continue}const C=I9(g,`CX${I}`),Q=I9(g,`CY${I}`),i=I9(g,`R${I}`),E=rig(g,`SA${I}`),n=rig(g,`EA${I}`),s=C!==void 0&&Q!==void 0&&i!==void 0&&i>0&&E!==void 0&&n!==void 0?{center:{x:C,y:Q},endAngleDegrees:n,radiusMils:i,startAngleDegrees:E}:void 0;A.push({arc:s,index:I,kind:s?"arc":"unknown",position:B,rawKind:o})}return A}function IkA(g){const A=QLI(g),I=[],e=iLI(A.get("HOLECOUNT"),bxo);for(let t=0;t<e;t++){const o=iLI(A.get(`HOLE${t}COUNT`),eLI),B=[];for(let C=0;C<o;C++){const Q=I9(A,`HOLE${t}VX${C}`),i=I9(A,`HOLE${t}VY${C}`);if(Q===void 0||i===void 0)break;B.push({index:C,kind:"line",position:{x:Q,y:i},rawKind:0})}B.length>=3&&I.push(tkA(B))}return{holes:I,outline:tkA(tLI(A)),record:g}}function oLI(g){const A=g.board?sig(g.board):tkA([]),I=g.records.filter(e=>e.recordKind==="BoardRegion"||e.recordKind==="Region");return{cutouts:I.filter(e=>ekA(e)==="BOARD_CUTOUT").map(IkA),layerStackRegions:I.filter(e=>ekA(e)==="LAYER_STACK_REGION").map(IkA),outline:A,polygonCutouts:I.filter(e=>ekA(e)==="POLYGON_CUTOUT").map(IkA)}}function ekA(g){if(g.recordKind==="BoardRegion"||g.getDecoded("OBJECTKIND")?.toUpperCase()==="BOARDREGION"||g.getDecoded("LAYERSTACKID")!==void 0)return"LAYER_STACK_REGION";const I=(g.getDecoded("REGIONKIND")??g.getDecoded("KIND")??void 0)?.replace(/[\s-]+/gu,"_").toUpperCase();return I==="0"?g.getBoolean("ISBOARDCUTOUT")===!0?"BOARD_CUTOUT":"COPPER":I==="1"?"POLYGON_CUTOUT":I==="2"?"DASHED_OUTLINE":I==="3"?"UNKNOWN_3":I==="4"?"CAVITY_DEFINITION":I}function tkA(g){const A=[];for(const t of g){if(!t.arc){CLI(A,t.position);continue}for(const o of vxo(t.position,t.arc))CLI(A,o)}const I=A[0],e=A.at(-1);return{bounds:pxo(A),isExplicitlyClosed:I!==void 0&&e!==void 0&&Cig(I,e,1e-4),points:A,vertices:g,winding:Mxo(A)}}function vxo(g,A){const I=aig(A.center,A.radiusMils,A.startAngleDegrees),e=aig(A.center,A.radiusMils,A.endAngleDegrees),t=Txo(A.endAngleDegrees-A.startAngleDegrees)||360,o=BLI(g,I)<=BLI(g,e),B=o?A.startAngleDegrees:A.endAngleDegrees,C=o?t:-t,Q=Math.max(2,Math.ceil(Math.abs(C)/7.5)),i=[];for(let E=0;E<=Q;E++)i.push(aig(A.center,A.radiusMils,B+C*E/Q));return i}function aig(g,A,I){const e=I*Math.PI/180;return{x:g.x+Math.cos(e)*A,y:g.y+Math.sin(e)*A}}function Txo(g){return(g%360+360)%360}function BLI(g,A){const I=g.x-A.x,e=g.y-A.y;return I*I+e*e}function CLI(g,A){const I=g.at(-1);I&&Cig(I,A,1e-4)||g.push(A)}function QLI(g){const A=new Map;for(const I of g.fields){const e=I.key.toUpperCase();A.has(e)||A.set(e,I.value)}return A}function I9(g,A){return LoA(g.get(A.toUpperCase()))}function rig(g,A){const I=Number(g.get(A.toUpperCase()));return Number.isFinite(I)?I:void 0}function iLI(g,A){const I=Number(g??0);return Number.isInteger(I)?Math.min(Math.max(I,0),A):0}var ELI=class extends vn{type="dimension-record";constructor(g={}){super(g)}get dimensionKind(){return xt(this,"DIMENSIONKIND","KIND")}get start(){return this.referencePoints[0]??c0(this,["X1"],["Y1"])}get end(){return this.referencePoints[1]??c0(this,["X2"],["Y2"])}get dimensionLineAnchor(){return c0(this,["X1"],["Y1"])}get referencePoints(){return nLI({pointInfix:"POINT",prefix:"REFERENCE",record:this})}get textPoints(){const g=c0(this,["TEXTX"],["TEXTY"]);return g?[g]:nLI({pointInfix:"",prefix:"TEXT",record:this})}get unit(){return xt(this,"TEXTDIMENSIONUNIT","DIMENSIONUNIT","UNIT")}get precision(){return Pxo(this,"TEXTPRECISION","PRECISION")??Zi(this,"TEXTPRECISION","PRECISION")}get prefix(){return xt(this,"TEXTPREFIX","PREFIX")}get suffix(){return xt(this,"TEXTSUFFIX","SUFFIX")}get lineWidthMils(){return Zi(this,"LINEWIDTH","ARROWLINEWIDTH","WIDTH")}get textHeightMils(){return Zi(this,"TEXTHEIGHT","HEIGHT")}};function nLI({pointInfix:g,prefix:A,record:I}){const e=[],t=A==="REFERENCE"?I.getNumber("REFERENCES_COUNT"):void 0,o=Math.min(Math.max(t??100,0),1e4),B=A==="REFERENCE"?0:1;for(let C=B;C<B+o;C++){const Q=c0(I,[`${A}${C}${g}X`],[`${A}${C}${g}Y`]);if(!Q)break;e.push(Q)}return e}var qxo=class extends vn{type="coordinate-record";get position(){return c0(this,["X","LOCATION.X"],["Y","LOCATION.Y"])}};function Zxo(g){return g.replace(/[\s_-]/gu,"").toUpperCase()}function VO(g){return LoA(g)}function Oc(g,A,I=0){return VO(g.getCaseInsensitive(A))??I}function Oxo(g){return sig(g).points}function Wxo(g){if(!(g instanceof ELI))return;const A=g,I=A.start,e=A.end;if(!I||!e)return;const t=e.x-I.x,o=e.y-I.y,B=Math.hypot(t,o);if(B===0)return;const C=-o/B,Q=t/B,i=A.dimensionLineAnchor??I,E=(i.x-I.x)*C+(i.y-I.y)*Q,n={x:I.x+C*E,y:I.y+Q*E},s={x:e.x+C*E,y:e.y+Q*E},r=A.textPoints[0]??{x:(n.x+s.x)/2,y:(n.y+s.y)/2},a=Vxo({dimension:A,measuredDistanceMils:B}),c=A.textHeightMils??50,h=sLI({fallbackMils:10,fieldName:"TEXTGAP",record:g});return{arrowSize:sLI({fallbackMils:40,fieldName:"ARROWSIZE",record:g}),dimensionEnd:s,dimensionStart:n,estimatedTextHalfWidth:a.length*c*.3+h,label:a,lineWidth:A.lineWidthMils??8,referenceEnd:e,referenceStart:I,textHeight:c,textPosition:r}}function Vxo({dimension:g,measuredDistanceMils:A}){const I=g.getDecoded("TEXTFORMAT")?.trim();if(I&&I!=="<>")return I;const e=Math.min(Math.max(g.precision??2,0),6),t=g.unit?.toUpperCase()??"MILS",{amount:o,unitLabel:B}=jxo({measuredDistanceMils:A,normalizedUnit:t}),C=g.prefix??"",Q=g.suffix??` ${B}`;return`${C}${o.toFixed(e)}${Q}`}function jxo({measuredDistanceMils:g,normalizedUnit:A}){return A.includes("MILLIMETER")?{amount:g*.0254,unitLabel:"mm"}:A.includes("CENTIMETER")?{amount:g*.00254,unitLabel:"cm"}:A.includes("INCH")?{amount:g/1e3,unitLabel:"in"}:{amount:g,unitLabel:"mil"}}function sLI({fallbackMils:g,fieldName:A,record:I}){return I.getAltiumMeasurement(A)?.toMils()??g}var cig=Zxo;function zxo(g,A){const I=$xo(g,A),e=g.getNumber("PADMODE")??0,t=Xxo(g,I,e),o=g.getCaseInsensitive(`LAYER${I}ALTSHAPE`)?.toUpperCase(),B=Number(g.getCaseInsensitive(`LAYER${I}CORNERRADIUS`)??0),C=o==="ROUNDRECT"&&Number.isFinite(B)?Math.min(t.width,t.height)*B/200:0,Q=g.getNumber("HOLETYPE"),i=g.getCaseInsensitive("HOLESHAPE")?.toUpperCase()??(Q===1?"SQUARE":Q===2?"SLOT":"ROUND"),E=Oc(g,"HOLESIZE"),n=VO(g.getCaseInsensitive("SLOTLENGTH"))??(i==="SLOT"?VO(g.getCaseInsensitive("HOLEWIDTH")):void 0)??E;return{cornerRadius:C,height:t.height,holeOffsetX:Oc(g,`LAYER${I}HOLEXOFFSET`,Oc(g,`PADXOFFSET${I}`)),holeOffsetY:Oc(g,`LAYER${I}HOLEYOFFSET`,Oc(g,`PADYOFFSET${I}`)),holeRotation:Number(g.getCaseInsensitive("SLOTROTATION")??g.getCaseInsensitive("HOLEROTATION")??0),holeShape:i,holeSize:E,layerOrdinal:I,plated:g.getBoolean("PLATED")!==!1,rotation:Number(g.getCaseInsensitive("ROTATION")??0),shape:o==="ROUNDRECT"?o:t.shape,slotLength:n,width:t.width,x:Oc(g,"X"),y:Oc(g,"Y")}}function Xxo(g,A,I){if(!(cig(g.getCaseInsensitive("LAYER")??"")==="MULTILAYER")||I===0||A===0)return{height:hP(g,["YSIZE","TOPYSIZE"])??hP(g,["XSIZE","TOPXSIZE"])??20,shape:okA(g,["SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:hP(g,["XSIZE","TOPXSIZE"])??20};if(A===31){const B=hP(g,["BOTTOMXSIZE","BOTXSIZE","XSIZE","TOPXSIZE"])??20;return{height:hP(g,["BOTTOMYSIZE","BOTYSIZE","YSIZE","TOPYSIZE"])??B,shape:okA(g,["BOTTOMSHAPE","BOTSHAPE","SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:B}}if(I===2&&A>=2){const B=hP(g,[`LAYER${A}XSIZE`,"MIDXSIZE","XSIZE"])??20;return{height:hP(g,[`LAYER${A}YSIZE`,"MIDYSIZE","YSIZE"])??B,shape:okA(g,[`LAYER${A}SHAPE`,"MIDSHAPE","SHAPE"])?.toUpperCase()??"ROUND",width:B}}const o=hP(g,["MIDXSIZE","XSIZE","TOPXSIZE"])??20;return{height:hP(g,["MIDYSIZE","YSIZE","TOPYSIZE"])??o,shape:okA(g,["MIDSHAPE","SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:o}}function $xo(g,A){const I=A?.length===1?cig(A[0]??""):cig(g.getCaseInsensitive("LAYER")??"");if(I==="BOTTOM")return 31;if(I==="TOP")return 0;const e=/^(?:MIDLAYER|MID|INTERNALPLANE)(\d+)$/u.exec(I);return e?.[1]?Math.min(Math.max(Number(e[1]),1),30):0}function hP(g,A){for(const I of A){const e=VO(g.getCaseInsensitive(I));if(e!==void 0)return e}}function okA(g,A){for(const I of A){const e=g.getCaseInsensitive(I);if(e!==void 0)return e}}function hig(g){if(g.length!==0)return{minX:Math.min(...g.map(A=>A.x)),minY:Math.min(...g.map(A=>A.y)),maxX:Math.max(...g.map(A=>A.x)),maxY:Math.max(...g.map(A=>A.y))}}function AFo(g,A){return g?A?{minX:Math.min(g.minX,A.minX),minY:Math.min(g.minY,A.minY),maxX:Math.max(g.maxX,A.maxX),maxY:Math.max(g.maxY,A.maxY)}:g:A}function lig(g,A){return{minX:g.minX-A,minY:g.minY-A,maxX:g.maxX+A,maxY:g.maxY+A}}function gFo(g,A){const I=g.recordKind;if(I==="Dimension"){const e=Wxo(g);if(!e)return;const t=e.dimensionEnd.x-e.dimensionStart.x,o=e.dimensionEnd.y-e.dimensionStart.y,B=Math.hypot(t,o),C={x:t/B,y:o/B},Q=hig([e.referenceStart,e.referenceEnd,e.dimensionStart,e.dimensionEnd,e.textPosition,{x:e.textPosition.x-C.x*e.estimatedTextHalfWidth,y:e.textPosition.y-C.y*e.estimatedTextHalfWidth},{x:e.textPosition.x+C.x*e.estimatedTextHalfWidth,y:e.textPosition.y+C.y*e.estimatedTextHalfWidth}]);return Q?lig(Q,Math.max(e.arrowSize,e.textHeight)):void 0}if(I==="Track"){const e=hig([{x:Oc(g,"X1"),y:Oc(g,"Y1")},{x:Oc(g,"X2"),y:Oc(g,"Y2")}]),t=Oc(g,"WIDTH");return e&&t>0?lig(e,t/2):e}if(I==="Pad"){const e=zxo(g,A),t=e.rotation*Math.PI/180,o=e.width/2,B=e.height/2,C=Math.abs(Math.cos(t))*o+Math.abs(Math.sin(t))*B,Q=Math.abs(Math.sin(t))*o+Math.abs(Math.cos(t))*B;return{minX:e.x-C,minY:e.y-Q,maxX:e.x+C,maxY:e.y+Q}}if(I==="Via"){const e=Oc(g,"X"),t=Oc(g,"Y"),o=VO(g.getCaseInsensitive("DIAMETER"))??VO(g.getCaseInsensitive("TOPLAYERSIZE"))??20;return{minX:e-o/2,minY:t-o/2,maxX:e+o/2,maxY:t+o/2}}if(I==="Arc"){const e=Oc(g,"LOCATION.X"),t=Oc(g,"LOCATION.Y"),o=Oc(g,"RADIUS"),B=Oc(g,"WIDTH"),C=o+Math.max(B/2,0);return{minX:e-C,minY:t-C,maxX:e+C,maxY:t+C}}if(I==="ComponentBody"||I==="Region"||I==="Polygon"||I==="Board")return hig(Oxo(g));if(I==="Text"){const e=Oc(g,"X"),t=Oc(g,"Y"),o=Oc(g,"HEIGHT",30);return lig({minX:e,minY:t,maxX:e,maxY:t},o)}if(I==="Fill"){const e=Oc(g,"X1"),t=Oc(g,"Y1"),o=Oc(g,"X2"),B=Oc(g,"Y2"),C=(e+o)/2,Q=(t+B)/2,i=Math.abs(o-e)/2,E=Math.abs(B-t)/2,n=Number(g.getCaseInsensitive("ROTATION")??0)*Math.PI/180,s=Math.abs(Math.cos(n))*i+Math.abs(Math.sin(n))*E,r=Math.abs(Math.sin(n))*i+Math.abs(Math.cos(n))*E;return{minX:C-s,minY:Q-r,maxX:C+s,maxY:Q+r}}}var aLI=new WeakMap,IFo=class{constructor(g){this.document=g;const A=yr(g);this.edges=A.nets.flatMap((I,e)=>{const t=I.getNumber("ID")??e,o=A.byNet.get(t)??[],B=new Map;for(const C of o){const Q=iig(g,C),i=B.get(Q);i?i.push(C):B.set(Q,[C])}return[...B].map(([C,Q])=>({component:C===void 0?void 0:A.getComponent(C),net:I,primitives:Q}))})}document;edges;getConnectedRecords(g){const A=Eig(this.document,g);return A===void 0?[]:[...yr(this.document).byNet.get(A)??[]].filter(I=>I!==g)}getNetsForComponent(g){const A=yr(this.document),I=new Set;for(const e of $pA(this.document,g)){const t=Eig(this.document,e),o=t===void 0?void 0:A.getNet(t);o&&I.add(o)}return[...I]}getComponentsForNet(g){const A=yr(this.document),I=typeof g=="number"?g:g.getNumber("ID")??A.nets.indexOf(g);if(I<0)return[];const e=new Set;for(const t of A.byNet.get(I)??[]){const o=iig(this.document,t),B=o===void 0?void 0:A.getComponent(o);B&&e.add(B)}return[...e]}getConnectedComponents(g){const A=new Set,I=typeof g=="number"?yr(this.document).getComponent(g):g;for(const e of this.getNetsForComponent(g))for(const t of this.getComponentsForNet(e))t!==I&&A.add(t);return[...A]}};function rLI(g){const A=aLI.get(g);if(A?.revision===g.revision)return A.graph;const I=new IFo(g);return aLI.set(g,{graph:I,revision:g.revision}),I}function cLI(g,A,I){let e;for(const t of $pA(g,A))e=AFo(e,gFo(t,I));return e}var eFo=class extends uF{type="binary-pcb-document";compoundFile;embeddedModels;primitiveRecords;propertyRecords;streamSummaries;wideStrings;constructor(g){super({sourceLocation:{byteOffset:0,streamPath:"/"}}),this.compoundFile=g.compoundFile,this.primitiveRecords=g.primitiveRecords,this.propertyRecords=g.propertyRecords,this.streamSummaries=g.streamSummaries,this.wideStrings=g.wideStrings??new Map,this.embeddedModels=this.models.flatMap((A,I)=>{const e=this.compoundFile.getStream(["Models",String(I)]);return e?[new Gxo({index:I,record:A,stream:e})]:[]}),this.adoptChildren([this.compoundFile,...this.records]),this.clearDirty(!0)}get records(){return[...this.propertyRecords.values(),...this.primitiveRecords.values()].flat()}get board(){return this.propertyRecords.get("Board6")?.[0]}get components(){return this.propertyRecords.get("Components6")??[]}get componentBodies(){return this.primitiveRecords.get("ShapeBasedComponentBodies6")??this.primitiveRecords.get("ComponentBodies6")??[]}get legacyComponentBodies(){return this.primitiveRecords.get("ComponentBodies6")??[]}get nets(){return this.propertyRecords.get("Nets6")??[]}get index(){return yr(this)}get connectivity(){return rLI(this)}get boardGeometry(){return oLI(this)}get polygons(){return this.propertyRecords.get("Polygons6")??[]}get rules(){return this.propertyRecords.get("Rules6")??[]}getComponentByIndex(g){return Z3I(this,g)}getNetByIndex(g){return O3I(this,g)}getPolygonByIndex(g){return W3I(this,g)}getRuleByIndex(g){return V3I(this,g)}getComponentForRecord(g){return j3I(this,g)}getNetForRecord(g){return z3I(this,g)}getPolygonForRecord(g){return X3I(this,g)}getRuleForRecord(g){return $3I(this,g)}getRecordsOwnedByComponent(g){return $pA(this,g)}getRecordsOnNet(g){return ALI(this,g)}getRecordsForPolygon(g){return gLI(this,g)}getRecordsForRule(g){return ILI(this,g)}getRecordsByLayer(g){return[...this.index.byLayer.get(g.toUpperCase())??[]]}getComponentBounds(g,A){return cLI(this,g,A)}getRecordByUniqueId(g){return this.index.getRecordByUniqueId(g)}get models(){return this.propertyRecords.get("Models")??[]}getModelsById(g){const A=g.toUpperCase();return this.models.filter(I=>I.getDecoded("ID")?.toUpperCase()===A)}getModelForComponentBody(g){const A=g.getDecoded("MODELID");if(!A)return;const I=this.getModelsById(A);return I.length<=1?I[0]:I.find(e=>Dig(e.getNumber("ROTX"),g.getNumber("MODEL.3D.ROTX"))&&Dig(e.getNumber("ROTY"),g.getNumber("MODEL.3D.ROTY"))&&Dig(e.getNumber("ROTZ"),g.getNumber("MODEL.3D.ROTZ")))??I[0]}getEmbeddedModelForComponentBody(g){const A=this.getModelForComponentBody(g);return this.embeddedModels.find(I=>I.record===A)}get tracks(){return this.primitiveRecords.get("Tracks6")??[]}get arcs(){return this.primitiveRecords.get("Arcs6")??[]}get vias(){return this.primitiveRecords.get("Vias6")??[]}get pads(){return this.primitiveRecords.get("Pads6")??[]}get fills(){return this.primitiveRecords.get("Fills6")??[]}get regions(){return this.primitiveRecords.get("ShapeBasedRegions6")??this.primitiveRecords.get("Regions6")??[]}get regionFills(){return this.primitiveRecords.get("Regions6")??[]}get boardRegions(){return this.primitiveRecords.get("BoardRegions")??[]}get texts(){return this.primitiveRecords.get("Texts6")??[]}getRecordsByKind(g){return this.records.filter(A=>A.recordKind===g)}getStreamSummary(g){return this.streamSummaries.find(A=>A.family.toLowerCase()===g.toLowerCase())}getBytes(){if(this.isDirty)throw new Qc("Modified binary PCB documents cannot yet be serialized safely");return this.compoundFile.getBytes()}getChildren(){return[this.compoundFile,...this.records]}getString(){return this.records.map(g=>g.getString()).join(`
|
|
5749
5749
|
`)}};function Dig(g,A){return g!==void 0&&A!==void 0&&Math.abs(g-A)<Number.EPSILON}function dig(g,A){if(A!==void 0)return{encoding:A,text:A==="utf-16le"?CkA(g,!0):A==="utf-16be"?CkA(g,!1):new TextDecoder(A,{fatal:A==="utf-8"}).decode(g)};if(g[0]===239&&g[1]===187&&g[2]===191)return{encoding:"utf-8-bom",text:`\uFEFF${new TextDecoder().decode(g.subarray(3))}`};if(g[0]===255&&g[1]===254)return{encoding:"utf-16le-bom",text:`\uFEFF${CkA(g.subarray(2),!0)}`};if(g[0]===254&&g[1]===255)return{encoding:"utf-16be-bom",text:`\uFEFF${CkA(g.subarray(2),!1)}`};try{return{encoding:"utf-8",text:new TextDecoder("utf-8",{fatal:!0}).decode(g)}}catch{return{encoding:"windows-1252",text:new TextDecoder("windows-1252").decode(g)}}}function BkA(g,A="utf-8"){const I=A.endsWith("-bom"),e=I&&g.startsWith("\uFEFF")?g.slice(1):g;if(A==="utf-8"||A==="utf-8-bom"){const i=new TextEncoder().encode(e);return I?Uint8Array.from([239,187,191,...i]):i}if(A==="windows-1252")return oFo(e);const t=A==="utf-16le"||A==="utf-16le-bom",o=e.length*2+(I?2:0),B=new Uint8Array(o),C=new DataView(B.buffer);let Q=0;I&&(B[0]=t?255:254,B[1]=t?254:255,Q=2);for(let i=0;i<e.length;i++)C.setUint16(Q,e.charCodeAt(i),t),Q+=2;return B}function CkA(g,A){const I=new DataView(g.buffer,g.byteOffset,g.byteLength),e=[],t=8192;for(let o=0;o+2<=g.byteLength;o+=t*2){const B=Math.min(o+t*2,g.byteLength),C=[];for(let Q=o;Q+2<=B;Q+=2)C.push(I.getUint16(Q,A));e.push(String.fromCharCode(...C))}return e.join("")}var tFo=new Map([["€",128],["‚",130],["ƒ",131],["„",132],["…",133],["†",134],["‡",135],["ˆ",136],["‰",137],["Š",138],["‹",139],["Œ",140],["Ž",142],["‘",145],["’",146],["“",147],["”",148],["•",149],["–",150],["—",151],["˜",152],["™",153],["š",154],["›",155],["œ",156],["ž",158],["Ÿ",159]]);function oFo(g){const A=[];for(const I of g){const e=tFo.get(I);if(e!==void 0){A.push(e);continue}const t=I.codePointAt(0);if(t===void 0||t>255)throw new RangeError(`Character ${JSON.stringify(I)} cannot be encoded as Windows-1252`);A.push(t)}return Uint8Array.from(A)}function BFo(g){const A=new Map(g.fields.map(o=>[o.key.toUpperCase(),o.value])),I=[...yig(A,"LAYER_V8_","v8"),...yig(A,"LAYERV7_","v7")];I.length===0&&I.push(...yig(A,"LAYER","legacy"));const e=A.has("V9_MASTERSTACK_ID")?"V9_MASTERSTACK_":"LAYERMASTERSTACK_V8",t=QFo(A);return{entries:I.sort((o,B)=>o.index-B.index),id:Bu(A,`${e}ID`),impedanceProfiles:CFo(A,t),isFlex:Xm(Bu(A,`${e}ISFLEX`)),layerPairs:EFo(A),name:Bu(A,`${e}NAME`),style:Bu(A,`${e}STYLE`)??Bu(A,"LAYERSTACKSTYLE"),subStacks:iFo(A),traceImpedanceConfigurations:t}}function CFo(g,A){return[..._oA(g,/^V9_IMPEDANCEPROFILE(\d+)_ID$/u)].sort((I,e)=>I-e).map(I=>{const e=`V9_IMPEDANCEPROFILE${I}_`,t=Bu(g,`${e}ID`);return{displayName:Bu(g,`${e}DISPLAY_NAME`),id:t,index:I,isDifferentialPair:Xm(Bu(g,`${e}ISDIFFPAIR`)),name:Bu(g,`${e}NAME`),targetImpedanceOhms:HL(Bu(g,`${e}IMPEDANCE`)),traceConfigurations:A.filter(({profileId:o})=>t!==void 0&&o?.toUpperCase()===t.toUpperCase())}})}function QFo(g){return[..._oA(g,/^V9_TRACEIMPEDANCE(\d+)_PROFILE_ID$/u)].sort((A,I)=>A-I).map(A=>{const I=`V9_TRACEIMPEDANCE${A}_`,e=o=>Bu(g,`${I}${o}`),t=o=>LoA(e(o));return{calculatedImpedanceOhms:HL(e("CALC_IMPEDANCE")),differentialPairGapMils:t("DIFF_PAIR_GAP"),differentialPairMaximumGapMils:t("DIFF_PAIR_MAXGAP"),differentialPairMinimumGapMils:t("DIFF_PAIR_MINGAP"),enabled:Xm(e("ENABLED")),etchFactor:HL(e("ETCH_FACTOR")),impedanceErrorPercent:HL(e("IMPEDANCE_ERR")),index:A,layerId:e("LAYER_V7ID"),profileId:e("PROFILE_ID"),propagationSpeed:HL(e("PROPAGATION_SPEED")),referenceBottomLayerId:e("REF_BOT_V7ID"),referenceTopLayerId:e("REF_TOP_V7ID"),subStackId:e("SUBSTACK_ID"),traceGapLocked:Xm(e("TRACEGAP_LOCKED")),traceMaximumWidthMils:t("TRACE_MAXWIDTH"),traceMinimumWidthMils:t("TRACE_MINWIDTH"),traceWidthLocked:Xm(e("TRACEWIDTH_LOCKED")),traceWidthMils:t("TRACE_WIDTH")}})}function iFo(g){const A=_oA(g,/^V9_SUBSTACK(\d+)_ID$/u),I=A.size>0?"v9":"v8";return[...I==="v9"?A:_oA(g,/^LAYERSUBSTACK_V8_(\d+)ID$/u)].sort((t,o)=>t-o).map(t=>{const o=I==="v9"?`V9_SUBSTACK${t}_`:`LAYERSUBSTACK_V8_${t}`,B=C=>Bu(g,`${o}${C}`);return{id:B("ID"),index:t,isFlex:Xm(B("ISFLEX")),name:B("NAME"),service:Xm(B("SERVICE")),showBottomDielectric:Xm(B("SHOWBOTTOMDIELECTRIC")),showTopDielectric:Xm(B("SHOWTOPDIELECTRIC")),source:I,type:HL(B("TYPE")),usedByPrimitives:Xm(B("USEDBYPRIMS"))}})}function EFo(g){return[..._oA(g,/^LAYERPAIR(\d+)LOW$/u)].sort((I,e)=>I-e).map(I=>{const e=`LAYERPAIR${I}`,t=`${e}SUBSTACK_`,o=[...g].flatMap(([B,C])=>{if(!B.startsWith(t))return[];const Q=B.slice(t.length);return/^\d+$/u.test(Q)?[{index:Number(Q),value:C}]:[]}).sort((B,C)=>B.index-C.index).map(({value:B})=>B);return{drillDrawing:Xm(Bu(g,`${e}DRILLDRAWING`)),drillGuide:Xm(Bu(g,`${e}DRILLGUIDE`)),highLayer:Bu(g,`${e}HIGH`),index:I,lowLayer:Bu(g,`${e}LOW`),subStackIds:o}})}function _oA(g,A){const I=new Set;for(const e of g.keys()){const t=A.exec(e)?.[1];t!==void 0&&I.add(Number(t))}return I}function yig(g,A,I){const e=new Set,t=I==="legacy"?/^LAYER(\d+)NAME$/u:new RegExp(`^${nFo(A)}(\\d+)(?:_|)(?:ID|NAME|LAYERID)$`,"u");for(const o of g.keys()){const B=t.exec(o);B?.[1]&&e.add(Number(B[1]))}return[...e].map(o=>{const B=`${A}${o}`,C=i=>Bu(g,`${B}${i}`),Q={index:o,source:I};return I==="v8"?(Q.id=C("ID"),Q.name=C("NAME"),Q.layerId=C("LAYERID"),Q.usedByPrimitives=Xm(C("USEDBYPRIMS")),Q.mechanicalEnabled=Xm(C("MECHENABLED")),Q.copperThickness=WO(C("COPTHICK")??""),Q.dielectricType=C("DIELTYPE"),Q.dielectricConstant=HL(C("DIELCONST")),Q.dielectricHeight=WO(C("DIELHEIGHT")??""),Q.dielectricMaterial=C("DIELMATERIAL"),Q):(Q.layerId=C("LAYERID"),Q.name=C("NAME"),Q.previous=C("PREV"),Q.next=C("NEXT"),Q.mechanicalEnabled=Xm(C("MECHENABLED")),Q.copperThickness=WO(C("COPTHICK")??""),Q.dielectricType=C("DIELTYPE"),Q.dielectricConstant=HL(C("DIELCONST")),Q.dielectricHeight=WO(C("DIELHEIGHT")??""),Q.dielectricMaterial=C("DIELMATERIAL"),Q)})}function Bu(g,A){return g.get(A.toUpperCase())}function Xm(g){if(g!==void 0){if(/^(?:T|TRUE|1)$/iu.test(g))return!0;if(/^(?:F|FALSE|0)$/iu.test(g))return!1}}function HL(g){if(g===void 0)return;const A=Number(g);return Number.isFinite(A)?A:void 0}function nFo(g){return g.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}var hLI=class extends vn{type="board-record";constructor(g={}){super(g)}get fileName(){return xt(this,"FILENAME")}get version(){return xt(this,"VERSION")}get date(){return xt(this,"DATE")}get time(){return xt(this,"TIME")}get displayUnit(){return xt(this,"DISPLAYUNIT")}get origin(){return c0(this,["ORIGINX","ORIGIN.X"],["ORIGINY","ORIGIN.Y"])}get sheetOrigin(){return c0(this,["SHEETX"],["SHEETY"])}get sheetSize(){return YoA(this,["SHEETWIDTH"],["SHEETHEIGHT"])}get uniqueId(){return xt(this,"UNIQUEID")}get grid(){return{dotGrid:this.getBoolean("DOTGRID"),electricalGridEnabled:this.getBoolean("ELECTRICALGRIDENABLED"),electricalGridRangeMils:Zi(this,"ELECTRICALGRIDRANGE"),largeVisibleGridMultiplier:this.getNumber("BIGVISIBLEGRIDMULTFACTOR"),largeVisibleGridSize:this.getNumber("BIGVISIBLEGRIDSIZE"),snapEnabled:this.getBoolean("GRIDSNAPENABLED"),snapSizeMils:Zi(this,"GRIDSIZE"),visibleGridMultiplier:this.getNumber("VISIBLEGRIDMULTFACTOR"),visibleGridSize:this.getNumber("VISIBLEGRIDSIZE")}}get outline(){return sig(this)}get layerStack(){return BFo(this)}},wig=class extends vn{type="class-record";constructor(g={}){super(g)}get name(){return xt(this,"NAME")}get classKind(){return xt(this,"KIND")}get superClass(){return this.getBoolean("SUPERCLASS")}get uniqueId(){return xt(this,"UNIQUEID")}get members(){const g=[];for(let A=0;A<1e5;A++){const I=xt(this,`M${A}`);if(I===void 0)break;g.push(I)}return g}},sFo=class extends wig{type="signal-class-record"},lLI=class extends vn{type="polygon-record";constructor(g={}){super(g)}get id(){return this.getNumber("ID")}get name(){return xt(this,"NAME")}get layer(){return xt(this,"LAYER")}get netIndex(){return this.getNumber("NET")}get polygonType(){return xt(this,"POLYGONTYPE")}get pourOverStyle(){return xt(this,"POUROVERSTYLE","POUROVER")}get hatchStyle(){return xt(this,"HATCHSTYLE")}get pourIndex(){return this.getNumber("POURINDEX")}get priority(){return this.getNumber("POURORDER")??this.getNumber("PRIORITY")}get shelved(){return this.getBoolean("SHELVED")}get removeDeadCopper(){return this.getBoolean("REMOVEDEAD")}get trackWidthMils(){return Zi(this,"TRACKWIDTH")}get gridSizeMils(){return Zi(this,"GRIDSIZE")}},uig=class extends vn{type="rule-record";constructor(g={}){super(g)}get name(){return xt(this,"NAME")}get ruleKind(){return xt(this,"RULEKIND")}get priority(){return this.getNumber("PRIORITY")??this.getNumber("INDEXFORSAVE")}get enabled(){return this.getBoolean("ENABLED")}get scope1Expression(){return xt(this,"SCOPE1EXPRESSION")}get scope2Expression(){return xt(this,"SCOPE2EXPRESSION")}get comment(){return xt(this,"COMMENT")}get uniqueId(){return xt(this,"UNIQUEID")}get category(){const g=this.ruleKind?.toUpperCase();return g?["BOARDOUTLINECLEARANCE","CLEARANCE","COMPONENTCLEARANCE","HOLETOHOLECLEARANCE","PLANECLEARANCE"].includes(g)?"clearance":g==="WIDTH"?"routing-width":g==="ROUTINGVIAS"?"via-style":g==="ROUTINGLAYERS"?"routing-layer":g==="DIFFPAIRSROUTING"?"differential-pair":g==="LENGTH"||g==="MATCHEDLENGTHS"?"length":g==="PLANECONNECT"?"plane-connect":g==="POLYGONCONNECT"?"polygon-connect":g==="SOLDERMASKEXPANSION"||g==="PASTEMASKEXPANSION"?"mask":/(?:ASSEMBLY|FABRICATION|HEIGHT|HOLE|SILK|SLIVER|TESTPOINT)/u.test(g)?"manufacturing":"unknown":"unknown"}get clearanceMils(){if(this.category==="clearance")return Zi(this,"GAP","GENERICCLEARANCE","CLEARANCE")}get verticalClearanceMils(){if(this.category==="clearance")return Zi(this,"VERTICALGAP")}get widthConstraint(){if(this.normalizedRuleKind==="WIDTH")return vL(this,["MINLIMIT"],["PREFEREDWIDTH","PREFERREDWIDTH"],["MAXLIMIT"])}get layerConstraints(){if(!["DIFFPAIRSROUTING","WIDTH"].includes(this.normalizedRuleKind??""))return[];const g=new Map;for(const A of this.fields){const I=/^(TOPLAYER|BOTTOMLAYER|MIDLAYER(\d+))_(MINWIDTH|PREFWIDTH|MAXWIDTH|MINGAP|PREFGAP|MAXGAP)$/u.exec(A.key.toUpperCase());if(!I?.[1]||!I[3])continue;const e=aFo(I[1],I[2]),t=g.get(e)??{layer:e},o=Zi(this,A.key);o!==void 0&&(I[3].endsWith("GAP")?(t.gap??={},dLI(t.gap,I[3],o)):dLI(t,I[3],o),g.set(e,t))}return[...g.values()]}get viaDiameterConstraint(){if(this.normalizedRuleKind==="ROUTINGVIAS")return vL(this,["MINWIDTH"],["WIDTH","PREFEREDWIDTH"],["MAXWIDTH"])}get viaHoleConstraint(){if(this.normalizedRuleKind==="ROUTINGVIAS")return vL(this,["MINHOLEWIDTH"],["HOLEWIDTH","PREFEREDHOLEWIDTH"],["MAXHOLEWIDTH"])}get viaStyle(){if(this.normalizedRuleKind==="ROUTINGVIAS")return xt(this,"VIASTYLE")}get routingLayers(){if(this.normalizedRuleKind!=="ROUTINGLAYERS")return[];const g=new Map;for(const A of this.fields){const I=/^(TOP LAYER|BOTTOM LAYER|MID LAYER (\d+))(_V5)?$/u.exec(A.key.toUpperCase());if(!I?.[1])continue;const e=rFo(I[1],I[2]),t=g.get(e)??{layer:e};I[3]?t.enabled=cFo(A.value):t.mode=A.value,g.set(e,t)}return[...g.values()]}get differentialPairGap(){if(this.normalizedRuleKind==="DIFFPAIRSROUTING")return vL(this,["MINLIMIT"],["MOSTFREQGAP","PREFEREDGAP","PREFERREDGAP"],["MAXLIMIT"])}get maximumUncoupledLengthMils(){if(this.normalizedRuleKind==="DIFFPAIRSROUTING")return Zi(this,"MAXUNCOUPLEDLENGTH")}get matchedLengthToleranceMils(){if(["LENGTH","MATCHEDLENGTHS"].includes(this.normalizedRuleKind??""))return Zi(this,"TOLERANCE")}get impedanceConstraint(){if(this.normalizedRuleKind!=="WIDTH")return;const g={maximum:this.getNumber("MAXIMP"),minimum:this.getNumber("MINIMP"),preferred:this.getNumber("FAVIMP")};return QkA(g)?g:void 0}get thermalRelief(){if(!["PLANECONNECT","POLYGONCONNECT"].includes(this.normalizedRuleKind??""))return;const g={airGapMils:Zi(this,"AIRGAPWIDTH","RELIEFAIRGAP"),angle:xt(this,"POLYGONRELIEFANGLE"),conductorWidthMils:Zi(this,"RELIEFCONDUCTORWIDTH"),connectionStyle:xt(this,"CONNECTSTYLE","PLANECONNECTSTYLE"),expansionMils:Zi(this,"RELIEFEXPANSION"),spokeCount:this.getNumber("RELIEFENTRIES")};return QkA(g)?g:void 0}get maskExpansionMils(){if(["PASTEMASKEXPANSION","SOLDERMASKEXPANSION"].includes(this.normalizedRuleKind??""))return Zi(this,"EXPANSION")}get heightConstraint(){if(this.normalizedRuleKind==="HEIGHT")return vL(this,["MINHEIGHT"],["PREFHEIGHT","PREFEREDHEIGHT"],["MAXHEIGHT"])}get holeSizeConstraint(){if(this.normalizedRuleKind==="HOLESIZE")return vL(this,["MINLIMIT"],[],["MAXLIMIT"])}get minimumSolderMaskSliverMils(){if(this.normalizedRuleKind==="MINIMUMSOLDERMASKSLIVER")return Zi(this,"MINSOLDERMASKWIDTH")}get minimumSilkClearanceMils(){if(["SILKTOBOARDREGIONCLEARANCE","SILKTOSILKCLEARANCE","SILKTOSOLDERMASKCLEARANCE"].includes(this.normalizedRuleKind??""))return Zi(this,"MINSILKSCREENTOMASKGAP","SILKTOSILKCLEARANCE")}get testPointSettings(){if(!this.normalizedRuleKind?.includes("TESTPOINT"))return;const g={allowBottom:this.getBoolean("ALLOWSIDEBOTTOM"),allowTop:this.getBoolean("ALLOWSIDETOP"),gridMils:Zi(this,"TESTPOINTGRID"),holeSize:vL(this,["MINHOLESIZE"],["PREFEREDHOLESIZE","PREFERREDHOLESIZE"],["MAXHOLESIZE"]),padSize:vL(this,["MINSIZE"],["PREFEREDSIZE","PREFERREDSIZE"],["MAXSIZE"]),underComponent:this.getBoolean("TESTPOINTUNDERCOMPONENT"),useGrid:this.getBoolean("USEGRID")};return QkA(g)?g:void 0}get normalizedRuleKind(){return this.ruleKind?.toUpperCase()}},DLI=class extends uig{type="dxp-rule-record"};function vL(g,A,I,e){const t={maximumMils:Zi(g,...e),minimumMils:Zi(g,...A),preferredMils:Zi(g,...I)};return QkA(t)?t:void 0}function dLI(g,A,I){A.startsWith("MIN")?g.minimumMils=I:A.startsWith("MAX")?g.maximumMils=I:g.preferredMils=I}function aFo(g,A){return g==="TOPLAYER"?"TOP":g==="BOTTOMLAYER"?"BOTTOM":`MID-LAYER${A??""}`}function rFo(g,A){return g==="TOP LAYER"?"TOP":g==="BOTTOM LAYER"?"BOTTOM":`MID-LAYER${A??""}`}function cFo(g){if(/^(?:TRUE|T|1)$/iu.test(g))return!0;if(/^(?:FALSE|F|0)$/iu.test(g))return!1}function QkA(g){return Object.values(g).some(A=>A!==void 0)}var hFo=class extends uF{type="pcb-document";_lines;originalBytes;originalSource;sourceEncoding;constructor(g={}){super({sourceLocation:{column:1,endOffset:g.originalSource?.length,line:1,startOffset:0}}),this._lines=g.lines??[],this.originalBytes=g.originalBytes?.slice(),this.originalSource=g.originalSource,this.sourceEncoding=g.sourceEncoding,this.adoptChildren(this._lines),this.clearDirty(!0)}setOriginalBytes(g,A){return this.originalBytes=g.slice(),this.sourceEncoding=A,this}getBytes(){return!this.isDirty&&this.originalBytes?this.originalBytes.slice():BkA(this.getString(),this.sourceEncoding)}get lines(){return this._lines}set lines(g){g!==this._lines&&(this._lines=g,this.adoptChildren(g),this.markDirty())}get records(){return this.lines.filter(g=>g instanceof vn)}get board(){return this.records.find(g=>g instanceof hLI)}get components(){return this.records.filter(g=>g instanceof zpA)}get nets(){return this.records.filter(g=>g instanceof XpA)}get classes(){return this.records.filter(g=>g instanceof wig)}get index(){return yr(this)}get connectivity(){return rLI(this)}get boardGeometry(){return oLI(this)}get polygons(){return this.records.filter(g=>g instanceof lLI)}get rules(){return this.records.filter(g=>g instanceof uig||g instanceof DLI)}getComponentByIndex(g){return Z3I(this,g)}getNetByIndex(g){return O3I(this,g)}getPolygonByIndex(g){return W3I(this,g)}getRuleByIndex(g){return V3I(this,g)}getComponentForRecord(g){return j3I(this,g)}getNetForRecord(g){return z3I(this,g)}getPolygonForRecord(g){return X3I(this,g)}getRuleForRecord(g){return $3I(this,g)}getRecordsOwnedByComponent(g){return $pA(this,g)}getRecordsOnNet(g){return ALI(this,g)}getRecordsForPolygon(g){return gLI(this,g)}getRecordsForRule(g){return ILI(this,g)}getRecordsByLayer(g){return[...this.index.byLayer.get(g.toUpperCase())??[]]}getComponentBounds(g,A){return cLI(this,g,A)}getRecordByUniqueId(g){return this.index.getRecordByUniqueId(g)}getRecordsByKind(g){return this.records.filter(A=>A.recordKind===g)}insertRecord(g,A=this.lines.length){const I=Math.min(Math.max(A,0),this.lines.length);return g.setParent(this),this.lines.splice(I,0,g),this.markDirty(),this}removeRecord(g){const A=this.lines.indexOf(g);return A<0?!1:(this.lines.splice(A,1),g.setParent(void 0),this.markDirty(),!0)}allocateRecordId(g,A="ID"){const I=new Set(this.getRecordsByKind(g).map(t=>t.getNumber(A)).filter(t=>t!==void 0));let e=0;for(;I.has(e);)e++;return e}getChildren(){return[...this.lines]}getString(){return!this.isDirty&&this.originalSource!==void 0?this.originalSource:this.lines.map(g=>`${g.getString()}${g.terminator}`).join("")}},lFo=class{index;name;record;storage;compressedBytes;decodedPayload;constructor(g){this.compressedBytes=g.compressedBytes,this.index=g.index,this.name=g.name,this.record=g.record,this.storage=g.storage}get compressedSize(){return this.compressedBytes.byteLength}getCompressedBytes(){return this.compressedBytes.slice()}getBitmapBytes(g={}){return this.getPayload(g).bitmapBytes.slice()}getEnhancedMetafileBytes(g={}){return this.getPayload(g).enhancedMetafileBytes?.slice()}getNativePngBytes(g={}){return this.getPayload(g).nativePngBytes?.slice()}getDataUrl(g={}){return`data:image/png;base64,${pFo(this.getPngBytes(g))}`}getPngBytes(g={}){const A=this.getPayload(g);return A.nativePngBytes?.slice()??GFo(A.bitmapBytes)}getPayload(g){return Object.keys(g).length>0?yLI(this.compressedBytes,g):(this.decodedPayload??=yLI(this.compressedBytes),this.decodedPayload)}};function DFo(g,A){if(!g||A.length===0)return[];const I=dFo(g.content),e=new Set(I);return A.flatMap((t,o)=>{const B=uLI(t.fileName),C=I.find(Q=>e.has(Q)&&uLI(Q.name)===B)??I.find(Q=>e.has(Q));return C?(e.delete(C),[new lFo({compressedBytes:C.compressedBytes,index:o,name:C.name,record:t,storage:g})]):[]})}function dFo(g){if(g.byteLength<4)throw new XQ("Schematic image storage header is truncated");const A=new DataView(g.buffer,g.byteOffset,g.byteLength);let e=4+A.getUint32(0,!0);if(e>g.byteLength)throw new XQ("Schematic image storage header exceeds the stream");const t=[];for(;e<g.byteLength;){if(e+4>g.byteLength)throw new XQ("Schematic image storage frame length is truncated");const o=A.getUint32(e,!0)&16777215,B=e+4,C=B+o;if(o===0||C>g.byteLength)throw new XQ(`Invalid schematic image storage frame length ${o}`);if(B+2>C||g[B]!==208)throw new XQ("Schematic image storage entry header is invalid");const Q=g[B+1]??0,i=B+2,E=i+Q;if(E+4>C)throw new XQ("Schematic image storage entry name is truncated");const n=A.getUint32(E,!0),s=E+4,r=s+n;if(r>C)throw new XQ("Schematic image storage compressed payload is truncated");t.push({compressedBytes:g.subarray(s,r),name:new TextDecoder("windows-1252").decode(g.subarray(i,E))}),e=C}return t}function yLI(g,A={}){const I=A.maximumBitmapSize??33554432,e=A.maximumMetafileSize??32*1024*1024,t=A.maximumNativeImageSize??32*1024*1024,o=A.maximumOutputSize??64*1024*1024;for(const[s,r]of[["maximumBitmapSize",I],["maximumMetafileSize",e],["maximumNativeImageSize",t],["maximumOutputSize",o]])if(!Number.isSafeInteger(r)||r<=0)throw new RangeError(`${s} must be a positive safe integer`);let B=0;const C=[];try{const s=new McA(a=>{if(B+=a.byteLength,B>o)throw new XQ(`Schematic image expands beyond the ${o}-byte limit`);C.push(a.slice())}),r=64*1024;for(let a=0;a<g.byteLength;){const c=Math.min(a+r,g.byteLength);s.push(g.subarray(a,c),c===g.byteLength),a=c}}catch(s){throw s instanceof XQ?s:new XQ(`Schematic image zlib decompression failed: ${s instanceof Error?s.message:String(s)}`)}const Q=wLI(C);if(Q.byteLength<6||Q[0]!==66||Q[1]!==77)throw new XQ("Embedded schematic image is not a Windows bitmap");const E=new DataView(Q.buffer,Q.byteOffset,Q.byteLength).getUint32(2,!0);if(E<14||E>I)throw new XQ(`Embedded schematic bitmap declares invalid size ${E}`);if(E>Q.byteLength)throw new XQ("Embedded schematic bitmap payload is truncated");const n=yFo(Q,E,e,t);return{bitmapBytes:Q.slice(0,E),...n}}function yFo(g,A,I,e){if(A>=g.byteLength)return{};const t=g[A]??0,o=A+1,B=o+t;if(B>g.byteLength)return{};const C=new TextDecoder("windows-1252").decode(g.subarray(o,B));if(C==="TdxPNGImage"){const a=uFo(g.subarray(B),e);return a?{nativePngBytes:a}:{}}if(C!=="TMetafile"||B+88>g.byteLength)return{};const Q=new DataView(g.buffer,g.byteOffset+B,g.byteLength-B),i=Q.getUint32(0,!0),E=Q.getUint32(4,!0),n=Q.getUint32(40,!0),s=Q.getUint32(48,!0);if(i!==1||![88,100,108].includes(E)||n!==1179469088||s<E||s%4!==0||s>I||B+s>g.byteLength)return{};const r=g.slice(B,B+s);return wFo(r,E)?{enhancedMetafileBytes:r}:{}}function wFo(g,A){const I=new DataView(g.buffer,g.byteOffset,g.byteLength);let e=A;for(;e+8<=g.byteLength;){const t=I.getUint32(e,!0),o=I.getUint32(e+4,!0),B=e+o;if(o<8||o%4!==0||B<=e||B>g.byteLength)return!1;if(t===14)return o>=20&&B===g.byteLength;e=B}return!1}function uFo(g,A){const I=[137,80,78,71,13,10,26,10];if(g.byteLength<20||g.byteLength>A||!I.every((B,C)=>g[C]===B))return;const e=new DataView(g.buffer,g.byteOffset,g.byteLength);let t=I.length,o=!1;for(;t+12<=g.byteLength;){const B=e.getUint32(t),C=t+12+B;if(B>A||C>g.byteLength||C>A)return;const Q=new TextDecoder().decode(g.subarray(t+4,t+8));if(!o){if(Q!=="IHDR"||B!==13)return;o=!0}if(Q==="IEND")return B!==0?void 0:g.slice(0,C);t=C}}function GFo(g){if(g.byteLength<54||g[0]!==66||g[1]!==77)throw new XQ("Embedded schematic image is not a supported Windows bitmap");const A=new DataView(g.buffer,g.byteOffset,g.byteLength),I=A.getUint32(10,!0),e=A.getUint32(14,!0),t=A.getInt32(18,!0),o=A.getInt32(22,!0),B=A.getUint16(26,!0),C=A.getUint16(28,!0),Q=A.getUint32(30,!0),i=Math.abs(o);if(e<40||t<=0||i<=0||t>16384||i>16384||B!==1||C!==24&&C!==32||Q!==0)throw new XQ(`Unsupported schematic bitmap (${t}x${o}, ${C}-bit, compression ${Q})`);const E=C/8,n=Math.ceil(t*E/4)*4,s=n*i;if(!Number.isSafeInteger(s)||I<14+e||I+s>g.byteLength)throw new XQ("Embedded schematic bitmap pixel payload is truncated");const r=1+t*4,a=new Uint8Array(r*i),c=o<0;for(let D=0;D<i;D++){const d=c?D:i-D-1,y=I+d*n,w=D*r;a[w]=0;for(let u=0;u<t;u++){const G=y+u*E,m=w+1+u*4;a[m]=g[G+2]??0,a[m+1]=g[G+1]??0,a[m+2]=g[G]??0,a[m+3]=C===32?g[G+3]??255:255}}const h=new Uint8Array(13),l=new DataView(h.buffer);return l.setUint32(0,t),l.setUint32(4,i),h[8]=8,h[9]=6,wLI([new Uint8Array([137,80,78,71,13,10,26,10]),Gig("IHDR",h),Gig("IDAT",N9g(a,{level:6})),Gig("IEND",new Uint8Array)])}function Gig(g,A){const I=new TextEncoder().encode(g),e=new Uint8Array(12+A.byteLength),t=new DataView(e.buffer);return t.setUint32(0,A.byteLength),e.set(I,4),e.set(A,8),t.setUint32(8+A.byteLength,mFo(e.subarray(4,8+A.byteLength))),e}function mFo(g){let A=4294967295;for(const I of g){A^=I;for(let e=0;e<8;e++)A=A>>>1^(A&1?3988292384:0)}return(A^4294967295)>>>0}function wLI(g){const A=new Uint8Array(g.reduce((e,t)=>e+t.byteLength,0));let I=0;for(const e of g)A.set(e,I),I+=e.byteLength;return A}function uLI(g){return g?.replace(/\\/gu,"/").split("/").at(-1)?.toLowerCase()}function pFo(g){const A=[];for(let e=0;e<g.byteLength;e+=32768)A.push(String.fromCharCode(...g.subarray(e,e+32768)));return btoa(A.join(""))}var In=class extends vn{type="schematic-record";constructor(g={}){super(g)}get ownerIndex(){return this.getNumber("OWNERINDEX")}get ownerPartId(){return this.getNumber("OWNERPARTID")}get indexInSheet(){return this.getNumber("INDEXINSHEET")}get uniqueId(){return xt(this,"UNIQUEID")}get position(){const g=fLI(this,"LOCATION.X"),A=fLI(this,"LOCATION.Y");return g===void 0||A===void 0?void 0:{x:g,y:A}}},GLI=class extends In{type="schematic-component-record";get libraryReference(){return xt(this,"LIBREFERENCE")}},mig=class extends In{type="schematic-pin-record";get name(){return xt(this,"NAME")}get designator(){return xt(this,"DESIGNATOR")}get electricalType(){return this.getNumber("ELECTRICAL")}get hidden(){return this.getBoolean("ISHIDDEN")}},pig=class extends In{type="schematic-label-record";get text(){return xt(this,"TEXT")}},kFo=class extends In{type="schematic-bezier-record"},MFo=class extends In{type="schematic-polyline-record"},SFo=class extends In{type="schematic-polygon-record"},fFo=class extends In{type="schematic-ellipse-record"},RFo=class extends In{type="schematic-rounded-rectangle-record"},NFo=class extends In{type="schematic-elliptical-arc-record"},xFo=class extends In{type="schematic-arc-record"},FFo=class extends In{type="schematic-line-record"},UFo=class extends In{type="schematic-rectangle-record"},mLI=class extends In{type="schematic-sheet-symbol-record";get fileName(){return xt(this,"FILENAME")}},JFo=class extends In{type="schematic-sheet-entry-record";get name(){return xt(this,"NAME")}},kig=class extends In{type="schematic-power-port-record";get text(){return xt(this,"TEXT")}},Mig=class extends In{type="schematic-port-record";get name(){return xt(this,"NAME")}},Sig=class extends In{type="schematic-net-label-record";get text(){return xt(this,"TEXT")}},PFo=class extends In{type="schematic-bus-record"},KFo=class extends In{type="schematic-bus-entry-record"},pLI=class extends In{type="schematic-wire-record"},LFo=class extends In{type="schematic-no-erc-record"},YFo=class extends In{type="schematic-text-frame-record";get text(){return xt(this,"TEXT")}},_Fo=class extends In{type="schematic-junction-record"},kLI=class extends In{type="schematic-image-record";get fileName(){return xt(this,"FILENAME")}},bFo=class extends In{type="schematic-sheet-record"},MLI=class extends In{type="schematic-sheet-name-record"},SLI=class extends In{type="schematic-sheet-file-name-record"},HFo=class extends In{type="schematic-designator-record";get text(){return xt(this,"TEXT")}},vFo=class extends In{type="schematic-template-record";get fileName(){return xt(this,"FILENAME")}},TFo=class extends In{type="schematic-parameter-record";get name(){return xt(this,"NAME")}get text(){return xt(this,"TEXT")}},qFo=class extends In{type="schematic-implementation-list-record"},ZFo=class extends In{type="schematic-implementation-record";get modelName(){return xt(this,"MODELNAME")}get modelType(){return xt(this,"MODELTYPE")}},OFo=class extends In{type="schematic-implementation-map-record"},WFo=class extends In{type="schematic-implementation-parameter-record"},VFo=class extends In{type="schematic-note-record";get text(){return xt(this,"TEXT")}};function fLI(g,A){const I=g.getCaseInsensitive(A);if(I===void 0)return;const e=Number(I);if(!Number.isFinite(e))return;const t=g.getCaseInsensitive(`${A}_FRAC`);if(t===void 0)return e;const o=+`0.${t.replace(/^[+-]/u,"")}`;return Number.isFinite(o)?e<0?e-o:e+o:e}var RLI=new WeakMap,NLI=new WeakMap,jFo=class{constructor(g){this.document=g,this.records=g.records;for(const A of this.records){const I=A.getNumber("OWNERINDEX");if(I!==void 0&&I>=0){const C=this.byOwner.get(I);C?C.push(A):this.byOwner.set(I,[A])}const e=A.getDecoded("UNIQUEID");if(!e)continue;const t=e.toUpperCase(),o=this.uniqueIds.get(t);if(!o){this.uniqueIds.set(t,A);continue}const B=this.duplicateUniqueIds.get(t)??[o];B.push(A),this.duplicateUniqueIds.set(t,B)}}document;byOwner=new Map;duplicateUniqueIds=new Map;records;uniqueIds=new Map;getParent(g){const A=g.getNumber("OWNERINDEX");return A===void 0||A<0?void 0:this.records[A]}getOwnedRecords(g){const A=typeof g=="number"?g:this.records.indexOf(g);return A<0?[]:[...this.byOwner.get(A)??[]]}getRecordByUniqueId(g){return this.uniqueIds.get(g.toUpperCase())}getOwnershipCycles(){const g=[],A=new Set;for(const I of this.records){if(A.has(I))continue;const e=[],t=new Map;let o=I;for(;o;){const B=t.get(o);if(B!==void 0){g.push(e.slice(B));break}if(A.has(o))break;t.set(o,e.length),e.push(o),o=this.getParent(o)}for(const B of e)A.add(B)}return g}},zFo=class{constructor(g){this.document=g;const A=new IUo,I=new Map,e=new Map;for(const C of g.wires){const Q=AUo(C);for(const i of Q){const E=ikA(i);A.add(E),e.set(E,i),ULI(I,E,C)}for(let i=1;i<Q.length;i++){const E=Q[i-1],n=Q[i];E&&n&&A.union(ikA(E),ikA(n))}}const t=[...g.pins,...g.labels,...g.netLabels,...g.ports,...g.powerPorts];for(const C of t){const Q=C.position;if(!Q)continue;const i=ikA(Q);A.add(i),e.set(i,Q),ULI(I,i,C)}const o=new Map;for(const[C,Q]of I){const i=A.find(C),E=o.get(i)??{names:new Set,points:new Map,records:new Set},n=e.get(C);n&&E.points.set(C,n);for(const s of Q){E.records.add(s);const r=gUo(s);r&&E.names.add(r)}o.set(i,E)}const B=[];for(const[C,Q]of o){const i=new Set([...Q.names].map(s=>s.toUpperCase())),E=B.filter(s=>[...s.names].some(r=>i.has(r.toUpperCase())));if(E.length===0||i.size===0){B.push({id:C,...Q});continue}const n=E[0];if(n){JLI(n,Q);for(const s of E.slice(1)){JLI(n,s);const r=B.indexOf(s);r>=0&&B.splice(r,1)}}}this.nets=B.map(C=>({id:C.id,names:[...C.names],points:[...C.points.values()],records:[...C.records]}));for(const C of this.nets)for(const Q of C.records)this.recordNets.set(Q,C)}document;nets;recordNets=new Map;getNetForRecord(g){return this.recordNets.get(g)}getNetsByName(g){const A=g.toUpperCase();return this.nets.filter(I=>I.names.some(e=>e.toUpperCase()===A))}getPinsForComponent(g){return fig(this.document).getOwnedRecords(g).filter(A=>A instanceof mig)}};function fig(g){const A=RLI.get(g);if(A?.revision===g.revision)return A.index;const I=new jFo(g);return RLI.set(g,{index:I,revision:g.revision}),I}function XFo(g){const A=NLI.get(g);if(A?.revision===g.revision)return A.graph;const I=new zFo(g);return NLI.set(g,{graph:I,revision:g.revision}),I}function $Fo(g){const A=fig(g);return g.sheetSymbols.map(I=>{const e=A.getOwnedRecords(I),t=e.find(B=>B instanceof MLI),o=e.find(B=>B instanceof SLI);return{fileName:o?.getDecoded("TEXT"),fileNameRecord:o,name:t?.getDecoded("TEXT"),nameRecord:t,symbol:I}})}function AUo(g){const A=g.getNumber("LOCATIONCOUNT"),I=A===void 0?1e5:Math.min(Math.max(A,0),1e5),e=[];for(let t=1;t<=I;t++){const o=xLI(g,`X${t}`),B=xLI(g,`Y${t}`);if(o===void 0||B===void 0)break;e.push({x:o,y:B})}return e}function gUo(g){if(g instanceof Sig||g instanceof pig||g instanceof kig)return g.getDecoded("TEXT");if(g instanceof Mig)return g.getDecoded("NAME")}function xLI(g,A){const I=g.getCaseInsensitive(A);if(I===void 0)return;const e=Number(I);if(!Number.isFinite(e))return;const t=g.getCaseInsensitive(`${A}_FRAC`);if(t===void 0)return e;const o=+`0.${t.replace(/^[+-]/u,"")}`;return Number.isFinite(o)?e<0?e-o:e+o:e}function ikA(g){return`${FLI(g.x)},${FLI(g.y)}`}function FLI(g){return g.toFixed(6).replace(/\.?0+$/u,"")}function ULI(g,A,I){const e=g.get(A);e?e.push(I):g.set(A,[I])}function JLI(g,A){for(const I of A.names)g.names.add(I);for(const[I,e]of A.points)g.points.set(I,e);for(const I of A.records)g.records.add(I)}var IUo=class{parents=new Map;add(g){this.parents.has(g)||this.parents.set(g,g)}find(g){this.add(g);const A=this.parents.get(g);if(A===void 0||A===g)return g;const I=this.find(A);return this.parents.set(g,I),I}union(g,A){const I=this.find(g),e=this.find(A);I!==e&&this.parents.set(e,I)}},EkA=class extends uF{type="schematic-document";compoundFile;embeddedImages;originalBytes;originalText;sourceEncoding;sourceFormat;_lines;constructor(g){super({sourceLocation:g.sourceFormat==="binary"?{byteOffset:0,streamPath:"/"}:{column:1,endOffset:g.originalText?.length,line:1,startOffset:0}}),this.compoundFile=g.compoundFile,this._lines=g.lines??[],this.originalBytes=g.originalBytes,this.originalText=g.originalText,this.sourceEncoding=g.sourceEncoding,this.sourceFormat=g.sourceFormat,this.embeddedImages=DFo(this.compoundFile?.getStream("/Storage"),this.records.filter(A=>A instanceof kLI)),this.adoptChildren([...this.compoundFile?[this.compoundFile]:[],...this._lines]),this.clearDirty(!0)}get lines(){return this._lines}set lines(g){g!==this._lines&&(this._lines=g,this.adoptChildren(g),this.markDirty())}get header(){return this.lines.find(g=>g instanceof vn&&g.getCaseInsensitive("HEADER")!==void 0)}get records(){return this.lines.filter(g=>g instanceof vn&&g.recordKind!==void 0)}get index(){return fig(this)}get netGraph(){return XFo(this)}get components(){return this.records.filter(g=>g instanceof GLI)}get pins(){return this.records.filter(g=>g instanceof mig)}get wires(){return this.records.filter(g=>g instanceof pLI)}get labels(){return this.records.filter(g=>g instanceof pig)}get netLabels(){return this.records.filter(g=>g instanceof Sig)}get ports(){return this.records.filter(g=>g instanceof Mig)}get powerPorts(){return this.records.filter(g=>g instanceof kig)}get sheetSymbols(){return this.records.filter(g=>g instanceof mLI)}get sheetLinks(){return $Fo(this)}getEmbeddedImageForRecord(g){return this.embeddedImages.find(A=>A.record===g)}getRecordsByKind(g){return this.records.filter(A=>A.recordKind===g)}getParent(g){return this.index.getParent(g)}getOwnedRecords(g){return this.index.getOwnedRecords(g)}getRecordByUniqueId(g){return this.index.getRecordByUniqueId(g)}getBytes(){if(!this.isDirty&&this.originalBytes)return this.originalBytes.slice();if(this.sourceFormat==="binary")throw new Qc("Modified binary schematic documents cannot yet be serialized safely");return BkA(this.getString(),this.sourceEncoding)}getChildren(){return[...this.compoundFile?[this.compoundFile]:[],...this.lines]}getString(){return!this.isDirty&&this.originalText!==void 0?this.originalText:this.lines.map(g=>`${g.getString()}${g.terminator}`).join("")}},PLI=class extends uF{metadata;path;constructor(g,A){super(),this.metadata=g,this.path=A,this.setSourceLocation({recordIndex:g.id,streamPath:`/${A.join("/")}`})}get name(){return this.metadata.name}get pathString(){return`/${this.path.join("/")}`}getString(){return this.pathString}},Rig=class extends PLI{type="compound-stream";contentSource;loadedContent;constructor(g,A,I){super(g,A),this.contentSource=I,I instanceof Uint8Array&&(this.loadedContent=I)}get content(){return this.loadedContent??=typeof this.contentSource=="function"?this.contentSource():this.contentSource,this.loadedContent}get isContentLoaded(){return this.loadedContent!==void 0}replaceContent(g){this.loadedContent=g.slice(),this.markDirty()}getChildren(){return[]}},KLI=class bOI extends PLI{type="compound-storage";entries;constructor(A,I,e){super(A,I),this.entries=e,this.adoptChildren(e)}get storages(){return this.entries.filter(A=>A instanceof bOI)}get streams(){return this.entries.filter(A=>A instanceof Rig)}getChildren(){return[...this.entries]}},eUo=class extends uF{type="compound-file";header;originalBytes;root;constructor(g){super({sourceLocation:{byteOffset:0,streamPath:"/"}}),this.header=g.header,this.originalBytes=g.originalBytes,this.root=g.root,this.adoptChildren([this.root]),this.clearDirty(!0)}get entries(){const g=[],A=I=>{for(const e of I.entries)g.push(e),e instanceof KLI&&A(e)};return A(this.root),g}get streams(){return this.entries.filter(g=>g instanceof Rig)}getStream(g){const A=tUo(g);return this.streams.find(I=>I.path.length===A.length&&I.path.every((e,t)=>e.toLowerCase()===A[t]?.toLowerCase()))}getBytes(){if(this.isDirty)throw new Qc("Modified compound files cannot yet be serialized safely");return this.originalBytes.slice()}getChildren(){return[this.root]}getString(){return this.entries.map(g=>g.pathString).join(`
|
|
5750
5750
|
`)}};function tUo(g){return(Array.isArray(g)?g:g.split(/[\\/]/u)).filter(Boolean)}var Nig=class extends Qig{},boA=class extends Nig{type="ini-section-line";_name;leading;trailing;constructor(g){super(g),this._name=g.name,this.leading=g.leading??"",this.trailing=g.trailing??""}get name(){return this._name}set name(g){if(/[\]\r\n]/u.test(g))throw new Error("INI section names cannot contain closing brackets");g!==this._name&&(this._name=g,this.markDirty())}getChildren(){return[]}getString(){return`${this.leading}[${this.name}]${this.trailing}`}},xig=class extends Nig{type="ini-key-value-line";_key;_value;afterEquals;beforeEquals;leading;constructor(g){super(g),this._key=g.key,this._value=g.value??"",this.leading=g.leading??"",this.beforeEquals=g.beforeEquals??"",this.afterEquals=g.afterEquals??""}get key(){return this._key}set key(g){if(g.length===0||/[=\r\n]/u.test(g))throw new Error("INI keys must be non-empty and cannot contain '='");g!==this._key&&(this._key=g,this.markDirty())}get value(){return this._value}set value(g){if(/[\r\n]/u.test(g))throw new Error("INI values cannot contain line terminators");g!==this._value&&(this._value=g,this.markDirty())}getChildren(){return[]}getString(){return`${this.leading}${this.key}${this.beforeEquals}=${this.afterEquals}${this.value}`}},LLI=class extends Nig{type="ini-comment-line";_raw;constructor(g){super(g),this._raw=g.raw}get raw(){return this._raw}set raw(g){if(/[\r\n]/u.test(g))throw new Error("INI comments cannot contain line terminators");g!==this._raw&&(this._raw=g,this.markDirty())}getChildren(){return[]}getString(){return this.raw}},oUo=class extends LLI{type="ini-raw-line"},nkA=class extends uF{type="ini-document";_lines;originalBytes;originalSource;sourceEncoding;constructor(g={}){super({sourceLocation:{column:1,endOffset:g.originalSource?.length,line:1,startOffset:0}}),this._lines=g.lines??[],this.originalBytes=g.originalBytes?.slice(),this.originalSource=g.originalSource,this.sourceEncoding=g.sourceEncoding,this.adoptChildren(this._lines),this.clearDirty(!0)}setOriginalBytes(g,A){return this.originalBytes=g.slice(),this.sourceEncoding=A,this}getBytes(){return!this.isDirty&&this.originalBytes?this.originalBytes.slice():BkA(this.getString(),this.sourceEncoding)}get lines(){return this._lines}set lines(g){g!==this._lines&&(this._lines=g,this.adoptChildren(g),this.markDirty())}get sections(){const g=[{entries:[],name:""}];for(const A of this.lines)A instanceof boA?g.push({entries:[],header:A,name:A.name}):A instanceof xig&&g.at(-1)?.entries.push(A);return g}getSection(g){const A=g.toUpperCase();return this.sections.find(I=>I.name.toUpperCase()===A)}getAll(g,A){const I=A.toUpperCase();return this.getSection(g)?.entries.filter(e=>e.key.toUpperCase()===I).map(e=>e.value)??[]}get(g,A){return this.getAll(g,A)[0]}set(g,A,I){const e=this.getSection(g),t=A.toUpperCase(),o=e?.entries.find(Q=>Q.key.toUpperCase()===t);if(o)return o.value=I,this;let B=this.lines.length;if(e){const Q=e.header?this.lines.indexOf(e.header):-1,i=this.lines.findIndex((E,n)=>n>Q&&E instanceof boA);B=i<0?this.lines.length:i}else{const Q=YLI(this),i=this.lines.at(-1);i&&i.terminator===""&&(i.terminator=Q,i.markDirty());const E=new boA({name:g,terminator:Q}).setParent(this);this.lines.push(E),B=this.lines.length}const C=new xig({key:A,terminator:YLI(this),value:I}).setParent(this);return this.lines.splice(B,0,C),this.markDirty(),this}removeSection(g){const A=this.getSection(g);if(!A)return!1;const I=A.header?this.lines.indexOf(A.header):0,e=this.lines.findIndex((B,C)=>C>I&&B instanceof boA),t=(e<0?this.lines.length:e)-I,o=this.lines.splice(I,t);for(const B of o)B.setParent(void 0);return this.markDirty(),!0}getChildren(){return[...this.lines]}getString(){return!this.isDirty&&this.originalSource!==void 0?this.originalSource:this.lines.map(g=>`${g.getString()}${g.terminator}`).join("")}};function BUo(g){return new nkA({lines:skA(g),originalSource:g})}function skA(g){return CUo(g).map(({content:A,lineNumber:I,startOffset:e,terminator:t})=>{const o={column:1,endColumn:A.length+1,endLine:I,endOffset:e+A.length,line:I,startOffset:e},B={nodeId:`ini:${e}`,sourceLocation:o,terminator:t},C=/^(\s*)\[([^\]]*)\](\s*)$/u.exec(A);if(C?.[2]!==void 0)return new boA({...B,leading:C[1],name:C[2],trailing:C[3]});if(/^\s*[;#]/u.test(A))return new LLI({...B,raw:A});const Q=A.indexOf("=");if(Q>0){const i=A.slice(0,Q),E=/^\s*/u.exec(i)?.[0]??"",n=i.slice(E.length),s=n.trimEnd(),r=n.slice(s.length),a=A.slice(Q+1),c=/^\s*/u.exec(a)?.[0]??"";return new xig({...B,afterEquals:c,beforeEquals:r,key:s,leading:E,value:a.slice(c.length)})}return new oUo({...B,raw:A})})}function CUo(g){const A=[];let I=0,e=1;for(let t=0;t<g.length;t++){const o=g[t];if(o!=="\r"&&o!==`
|
|
5751
5751
|
`)continue;const B=o==="\r"&&g[t+1]===`
|