@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.
@@ -5628,7 +5628,7 @@ svg { font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; }
5628
5628
  .sv-simulation-item[data-highlighted], .sv-simulation-item:hover { background-color: #f1f3f5; }
5629
5629
  .sv-simulation-chevron { transition: transform 0.2s ease; }
5630
5630
  [data-state="open"] > .sv-simulation-chevron { transform: rotate(180deg); }
5631
- `,wwo=()=>W.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:W.jsx("path",{d:"M20 6 9 17l-5-5"})}),uwo=({className:g})=>W.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:W.jsx("path",{d:"m6 9 6 6 6-6"})}),Gwo=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})`}})},mwo=({simulations:g,selectedSimulationExperimentId:A,onSelectSimulation:I})=>{const[e,t]=gA.useState(!1);if(g.length<=1)return null;const o=Gwo(g),C=o.find(({simulation:Q})=>Q.simulation_experiment_id===A)?.label??"Select simulation";return W.jsxs(W.Fragment,{children:[W.jsx("style",{children:ywo}),W.jsxs(YGA,{open:e,onOpenChange:t,modal:!1,children:[W.jsx(_GA,{asChild:!0,children:W.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:pBg,zIndex:dS.viewMenuIcon},children:[W.jsx("span",{style:{color:"#888888",flexShrink:0},children:"Simulation:"}),W.jsx("span",{style:{...LUI,minWidth:0},children:C}),W.jsx(uwo,{className:"sv-simulation-chevron"})]})}),W.jsx(QO,{children:W.jsx(ltA,{style:lwo,side:"bottom",align:"start",sideOffset:8,collisionPadding:10,children:o.map(({simulation:Q,label:i})=>{const E=Q.simulation_experiment_id===A;return W.jsxs(QF,{className:"sv-simulation-item",style:Dwo,title:i,onSelect:n=>n.preventDefault(),onPointerUp:()=>{I(Q.simulation_experiment_id),t(!1)},children:[W.jsx("span",{style:dwo,children:E&&W.jsx(wwo,{})}),W.jsx("span",{style:{...LUI,minWidth:0},children:i})]},Q.simulation_experiment_id)})})})]})]})},pwo=1200,kwo=1,Mwo=2,Swo=({circuitJson:g,containerStyle:A,colorOverrides:I,width:e,height:t,className:o,hideSchematic:B=!1,onSimulationChange:C,acSweepView:Q="magnitude"})=>{const[i,E]=gA.useState(null),[n,s]=gA.useState(!0),[r,a]=gA.useState(null),[c,h]=gA.useState(null),l=gA.useRef(null),D=gA.useRef(null),{containerWidth:d}=fUI(l),[y,w]=gA.useState(!1),{ref:u}=KtA({onSetTransform(j){D.current&&(D.current.style.transform=gN(j))}}),m=e&&t?e/t:B?Mwo:kwo,p=e||(t?t*m:d)||pwo,k=t||p/m;gA.useEffect(()=>{s(!0),a(null),E(g),s(!1)},[g]);const S=gA.useMemo(()=>i?i.filter(j=>j.type==="simulation_experiment"):[],[i]),[R,x]=gA.useState(null),N=(R&&S.some(j=>j.simulation_experiment_id===R)?R:S[0]?.simulation_experiment_id)??null;gA.useEffect(()=>{N!==R&&x(N)},[N,R]);const U=j=>{x(j),C?.(j)},K=gA.useMemo(()=>{if(!i||!p||!k||!N)return"";try{const j={circuitJson:i,simulation_experiment_id:N,ac_sweep_view:Q,width:p,height:k};return B?dUI(j):jdo({...j,schematicOptions:{colorOverrides:I}})}catch(j){return console.error("Failed to generate simulation SVG:",j),""}},[i,p,k,I,B,N,Q]);gA.useEffect(()=>{if(!K){h(null);return}try{const j=new Blob([K],{type:"image/svg+xml"}),Z=URL.createObjectURL(j);return h(Z),()=>{URL.revokeObjectURL(Z)}}catch(j){console.error("Failed to create SVG object URL:",j),h(null)}},[K]);const Y=gA.useMemo(()=>hwo(K,I),[K,I]),_=j=>{w(!0)},q=j=>{w(!0)};return gA.useEffect(()=>{const j=()=>{w(!1)},Z=()=>{w(!1)};return window.addEventListener("mouseup",j),window.addEventListener("touchend",Z),()=>{window.removeEventListener("mouseup",j),window.removeEventListener("touchend",Z)}},[]),n?W.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?W.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#fef2f2",minHeight:"300px",fontFamily:"sans-serif",fontSize:"16px",color:"#dc2626",...A},className:o,children:W.jsxs("div",{style:{textAlign:"center",padding:"20px"},children:[W.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:"Circuit Conversion Error"}),W.jsx("div",{style:{fontSize:"14px"},children:r})]})}):K?W.jsxs("div",{ref:j=>{l.current=j,u.current=j},style:{position:"relative",backgroundColor:Y,overflow:"hidden",minHeight:"300px",cursor:y?"grabbing":"grab",...A},className:o,onMouseDown:_,onTouchStart:q,children:[W.jsx(mwo,{simulations:S,selectedSimulationExperimentId:N,onSelectSimulation:U}),c?W.jsx("img",{ref:D,src:c,alt:"Circuit Simulation",style:{transformOrigin:"0 0",width:"100%",height:"100%",display:"block",objectFit:"contain"}}):W.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",minHeight:"300px",color:"#666",fontFamily:"sans-serif"},children:"Failed to render SVG"})]}):W.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"#f8fafc",minHeight:"300px",fontFamily:"sans-serif",gap:"12px",...A},className:o,children:[W.jsx("div",{style:{fontSize:"16px",color:"#475569",fontWeight:500},children:"No Simulation Found"}),W.jsxs("div",{style:{fontSize:"14px",color:"#64748b"},children:["Use"," ",W.jsx("code",{style:{backgroundColor:"#e2e8f0",padding:"2px 6px",borderRadius:"4px",fontFamily:"monospace",fontSize:"13px"},children:"<analogsimulation />"})," ","to create simulations"]})]})},fwo=()=>{const[g,A]=gA.useState(null),I=gA.useCallback(o=>{A({schematicComponentId:o})},[]),e=gA.useCallback(o=>{A(B=>B===o?null:B)},[]);return{controller:gA.useMemo(()=>({focusRequest:g,onFocusRequestHandled:e}),[g,e]),focusSchematicComponent:I}},YUI=g=>{const[A,I]=gA.useState(0),[e,t]=gA.useState(0);return gA.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}};ys("assembly-viewer");var _UI=()=>{ys.enable("assembly-viewer*")},Rwo=({circuitJson:g,containerStyle:A,debugGrid:I=!1,debug:e=!1})=>{e&&_UI();const t=gA.useRef(null),{ref:o}=KtA({onSetTransform(E){t.current&&(t.current.style.transform=nj(E))}}),{containerWidth:B,containerHeight:C}=YUI(o),Q=gA.useMemo(()=>!B||!C?"":U1g(g,{width:B,height:C||720}),[g,B,C]);gA.useMemo(()=>{if(!Q)return nP();const E=Q.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return MxA(E)}catch(n){return console.error(n),nP()}},[Q]);const i=gA.useMemo(()=>W.jsx("div",{ref:t,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:Q}}),[Q]);return W.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:i})},Nwo=({circuitJson:g,containerStyle:A,debugGrid:I=!1,debug:e=!1})=>{e&&_UI();const t=gA.useRef(null),{ref:o}=KtA({onSetTransform(E){t.current&&(t.current.style.transform=nj(E))}}),{containerWidth:B,containerHeight:C}=YUI(o),Q=gA.useMemo(()=>!B||!C?"":v1g(g,{width:B,height:C||720}),[g,B,C]);gA.useMemo(()=>{if(!Q)return nP();const E=Q.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return MxA(E)}catch(n){return console.error(n),nP()}},[Q]);const i=gA.useMemo(()=>W.jsx("div",{ref:t,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:Q}}),[Q]);return W.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:i})};const bUI=["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."],xwo=(()=>{let g=bUI[Math.floor(Math.random()*bUI.length)];return g=g.replace(/</g,"&lt;"),g=g.replace(/>/g,"&gt;"),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})(),$J=({onRunClicked:g})=>W.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:[W.jsx(Sso,{className:"rf-size-14 rf-mb-4"}),W.jsxs("p",{className:"rf-text-md rf-break-words rf-max-w-xl rf-text-center",children:["Tip: ",W.jsx("span",{dangerouslySetInnerHTML:{__html:xwo}})]}),g&&W.jsxs($E,{className:"rf-mt-4 rf-bg-blue-600 rf-hover:bg-blue-500",onClick:g,children:["Run Code",W.jsx(Uso,{className:"rf-w-3 rf-h-3 rf-ml-2"})]})]}),kmA=({text:g,onClick:A})=>W.jsx("span",{className:"rf-cursor-pointer rf-underline rf-text-blue-600 rf-mx-2",onClick:A,children:g}),MmA=g=>W.jsxs("div",{className:"rf-leading-5",children:[W.jsx("div",{className:"rf-py-2 rf-font-bold",children:g.column.name}),W.jsx("div",{children:g.field?.()??W.jsx("input",{type:"text",className:"rf-border rf-rounded rf-p-1 rf-w-full",onChange:A=>{g.onTextChange?.(A.target.value)}})})]}),Fwo=({open:g,children:A,title:I,onClose:e})=>g?W.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:W.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:[W.jsx("h2",{className:"rf-mt-0 rf-text-md rf-pb-4",children:I}),W.jsx("button",{type:"button",className:"rf-absolute rf-top-2 rf-right-4 rf-text-2xl rf-font-bold",onClick:e,children:"×"}),A]})}):null,Uwo=({elements:g})=>{const[A,I]=gA.useState({open:!1}),[e,t]=gA.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=>W.jsxs("div",{className:"rf-flex rf-items-center",children:[W.jsx(kmA,{text:E.primary_id,onClick:()=>t({focused_id:E.primary_id,id_search:void 0,selector_search:void 0})}),W.jsx("span",{className:"rf-flex-grow"}),W.jsx(kmA,{text:"(JSON)",onClick:()=>I({open:!0,element:E._og_elm,title:E.primary_id})})]}),renderHeaderCell:E=>W.jsx(MmA,{column:E,onTextChange:n=>t({id_search:n}),field:e.focused_id?()=>W.jsxs("div",{children:["Focus:"," ",W.jsx("span",{className:"rf-underline",children:e.focused_id}),W.jsx(kmA,{text:"(unfocus)",onClick:()=>t({focused_id:void 0})})]}):void 0})},{key:"type",name:"type",renderHeaderCell:E=>W.jsx(MmA,{column:E,field:()=>W.jsxs("select",{onChange:n=>t({component_type_filter:n.target.value}),className:"rf-border rf-rounded rf-p-1 rf-w-full",children:[W.jsx("option",{value:"any",children:"any"},"any"),W.jsx("option",{value:"source",children:"source"},"source"),W.jsx("option",{value:"source/pcb",children:"source/pcb"},"source/pcb"),W.jsx("option",{value:"source/schematic",children:"source/schematic"},"source/schematic"),o.map(n=>W.jsx("option",{value:n,children:n},n))]})})},{key:"name",name:"name",renderHeaderCell:E=>W.jsx(MmA,{column:E,onTextChange:n=>t({name_search:n})})},{key:"selector_path",name:"selector_path",renderHeaderCell:E=>W.jsx(MmA,{column:E,onTextChange:n=>t({selector_search:n})})},{key:"other_ids",name:"other_ids",renderCell:E=>W.jsx("div",{className:"rf-space-x-2",children:Object.entries(E.other_ids).map(([n,s])=>W.jsx(kmA,{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 W.jsxs("div",{className:"rf-font-mono rf-text-xs rf-bg-white",children:[W.jsx("div",{className:"rf-overflow-x-auto",children:W.jsxs("table",{className:"rf-table-auto rf-w-full rf-text-left",children:[W.jsx("thead",{children:W.jsx("tr",{children:Q.map(E=>W.jsx("th",{className:"rf-px-4 rf-py-2 rf-border-b",children:E.renderHeaderCell?E.renderHeaderCell(E):E.name},E.key))})}),W.jsx("tbody",{children:i.map((E,n)=>W.jsx("tr",{className:"rf-hover:bg-gray-100",children:Q.map(s=>W.jsx("td",{className:"rf-px-4 rf-py-2 rf-border-b",children:s.renderCell?s.renderCell(E):E[s.key]},s.key))},n))})]})}),W.jsx(Fwo,{open:A.open,onClose:()=>I({open:!1}),title:A.open?A.title:"",children:W.jsx("div",{className:"rf-bg-gray-800 rf-p-3 rf-text-white rf-rounded",children:W.jsx("pre",{className:"rf-whitespace-pre-wrap",children:A.open?JSON.stringify(A.element,null,2):""})})})]})};var Jwo=()=>{if(globalThis.tscircuitDynamicModules)return globalThis.tscircuitDynamicModules;const g={};return globalThis.tscircuitDynamicModules=g,g},Pwo=["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"],HUI=g=>{const A=g.indexOf("@",g.startsWith("@")?1:0);return A===-1?g:g.slice(0,A)},Kwo="https://jscdn.tscircuit.com";function vUI(){return typeof window<"u"&&window.TSCIRCUIT_JSCDN_BASE_URL||void 0}var Lwo=new Set(Pwo),Ywo=new Map([["@tscircuit/circuit-json-schematic-placement-analysis","dist/browser.js"]]);function _wo(g){if(!Lwo.has(HUI(g)))throw new Error(`Unsupported module: ${g}`)}var bwo=g=>{_wo(g);const A=HUI(g),I=g.length===A.length?"latest":g.slice(A.length+1),e=Ywo.get(A)??"+esm",t=vUI(),B=`${(t??Kwo).replace(/\/+$/,"")}/${A}/${I}/${e}`;return t?new URL(B,window.location.href).href:B},Hwo=g=>{const A=bwo(g);return vUI()?[A]:[A,`https://esm.run/${g}`]};function vwo(g=A=>import(A)){return async A=>{const I=Jwo();if(Object.hasOwn(I,A))return I[A];let e;for(const t of Hwo(A))try{const o=await g(t);return I[A]=o,o}catch(o){e=o}throw e}}var qwo=()=>globalThis.tscircuitDynamicImportResolver,qUI=vwo();async function Two(g){const A=qwo();return A?A(g,qUI):qUI(g)}var yS=Two;const Zwo=(g,A)=>W.jsx("a",{className:"rf-underline rf-text-blue-500",target:"_blank",rel:"noreferrer",href:`https://jlcpcb.com/partdetail/${A}`,children:A}),Owo=g=>g?.map(({manufacturer:A,mpn:I})=>`${A}: ${I}`).join(", "),Wwo=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}},Vwo=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?Zwo("jlcpcb",e):""}}),g.hasManufacturerColumn&&A.push({key:"manufacturer_mpn_pairs",label:"Manufacturer / MPN",getCell:I=>Owo(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},jwo=({circuitJson:g})=>{const[A,I]=gA.useState(null),[e,t]=gA.useState(null);if(gA.useEffect(()=>{let C=!1;return(async()=>{try{t(null),I(null);const{convertCircuitJsonToBomRows:i}=await yS("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=Wwo(A??[]),B=Vwo(o);return A?W.jsx("div",{className:"rf-overflow-x-auto",children:W.jsxs("table",{className:"rf-w-full rf-text-left rf-text-sm",children:[W.jsx("thead",{children:W.jsx("tr",{className:"rf-border-b",children:B.map(C=>W.jsx("th",{className:"rf-p-2",children:C.label},C.key))})}),W.jsx("tbody",{children:A.map((C,Q)=>W.jsx("tr",{className:"rf-border-b",children:B.map(i=>W.jsx("td",{className:"rf-p-2",children:i.getCell(C)},i.key))},C.designator||`${Q}`))})]})}):W.jsx("div",{className:"rf-p-4 rf-text-sm rf-text-muted-foreground",children:"Loading BOM..."})},kBg=gA.forwardRef(({className:g,type:A,...I},e)=>W.jsx("input",{type:A,className:dB("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}));kBg.displayName="Input";const zwo=({circuitJson:g,containerClassName:A,...I})=>{const e=gA.useRef(null),[t,o]=gA.useState(620);return gA.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)}},[]),W.jsx("div",{ref:e,className:A||"rf-w-full rf-h-full",children:W.jsx(_tg,{...I,circuitJson:g,height:t})})},Xwo='*,: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}',MBg=()=>{gA.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const A=document.createElement("style");A.setAttribute("data-styles","tscircuit-runframe"),A.textContent=Xwo,document.head.appendChild(A)},[])},$wo=g=>{gA.useEffect(()=>(g?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[g])};function TUI(g,A,I){const[e,t]=gA.useState(()=>{if(I!==void 0)return I;try{const o=window.localStorage.getItem(g);return o?JSON.parse(o):A}catch(o){return console.error("Error reading from localStorage:",o),A}});return gA.useEffect(()=>{try{window.localStorage.setItem(g,JSON.stringify(e))}catch(o){console.error("Error writing to localStorage:",o)}},[g,e]),[e,t]}const ZUI=g=>`hsl(${MR.indexOf(g)*137.5%360}, 70%, 50%)`,Auo=({phaseTimings:g})=>{if(!g)return null;const A=Object.values(g).reduce((I,e)=>I+e,0);return W.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[W.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:MR.map(I=>{const e=g[I]||0,t=e/A*100;return W.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${t}%`,backgroundColor:ZUI(I)},children:W.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)})}),W.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",A.toFixed(2),"ms"]})]})},guo=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)},Iuo=({renderLog:g,onRerunWithDebug:A})=>{const[I,e]=gA.useState("chronological"),[t,o]=gA.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 W.jsxs("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:[W.jsx("div",{className:"rf-mb-4",children:"No render log, make sure this tab is open when you render"}),A&&W.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[W.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=>W.jsx("option",{value:i.value,children:i.label},i.value))}),W.jsx($E,{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)=>MR.indexOf(i[0])-MR.indexOf(E[0])):C.sort((i,E)=>E[1]-i[1]);const Q=C.reduce((i,[E,n])=>i+n,0);return W.jsxs("div",{className:"rf-bg-white",children:[W.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mb-4",children:[W.jsx("div",{children:"Render Logs"}),W.jsxs("div",{className:"rf-flex rf-gap-4 rf-items-center",children:[A&&W.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[W.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=>W.jsx("option",{value:i.value,children:i.label},i.value))}),W.jsx($E,{onClick:()=>A(t),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]}),W.jsx("div",{className:"rf-flex rf-gap-2 rf-items-center",children:W.jsxs("select",{onChange:i=>{if(i.target.value){const E=g?.debugOutputs?.find(n=>n.name===i.target.value);if(E){const n=guo(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:[W.jsx("option",{value:"",children:"Download Debug Output"}),g?.debugOutputs?.map(i=>W.jsx("option",{value:i.name,children:i.name},i.name))]})}),W.jsxs("div",{className:"rf-flex rf-text-xs rf-items-center",children:[W.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),W.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:[W.jsx("option",{value:"chronological",children:"Phase Order"}),W.jsx("option",{value:"longest",children:"Duration"})]})]})]})]}),W.jsx(Auo,{phaseTimings:g.phaseTimings}),W.jsxs("table",{className:"rf-w-full rf-text-xs",children:[W.jsx("thead",{children:W.jsxs("tr",{children:[W.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),W.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),W.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),W.jsx("tbody",{children:C.map(([i,E])=>W.jsxs("tr",{children:[W.jsx("td",{className:"rf-p-2",children:MR.indexOf(i)}),W.jsx("td",{className:"rf-p-2",children:i}),W.jsx("td",{className:"rf-p-2",children:W.jsx("div",{className:"rf-w-8",children:W.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:ZUI(i),width:`${E/Q*100}%`}})})}),W.jsx("td",{className:"rf-p-2",children:W.jsxs("div",{className:"rf-flex w-full",children:[W.jsxs("span",{className:"rf-flex-grow",children:[E,"ms"]}),W.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(E/Q*100).toFixed(1),"%"]})]})})]},i))})]})]})};var euo=8,SBg=g=>Math.hypot(g.a,g.b)||1,tuo=g=>[g.label,g.inlineLabel].filter(Boolean).join(`
5631
+ `,wwo=()=>W.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:W.jsx("path",{d:"M20 6 9 17l-5-5"})}),uwo=({className:g})=>W.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:W.jsx("path",{d:"m6 9 6 6 6-6"})}),Gwo=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})`}})},mwo=({simulations:g,selectedSimulationExperimentId:A,onSelectSimulation:I})=>{const[e,t]=gA.useState(!1);if(g.length<=1)return null;const o=Gwo(g),C=o.find(({simulation:Q})=>Q.simulation_experiment_id===A)?.label??"Select simulation";return W.jsxs(W.Fragment,{children:[W.jsx("style",{children:ywo}),W.jsxs(YGA,{open:e,onOpenChange:t,modal:!1,children:[W.jsx(_GA,{asChild:!0,children:W.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:pBg,zIndex:dS.viewMenuIcon},children:[W.jsx("span",{style:{color:"#888888",flexShrink:0},children:"Simulation:"}),W.jsx("span",{style:{...LUI,minWidth:0},children:C}),W.jsx(uwo,{className:"sv-simulation-chevron"})]})}),W.jsx(QO,{children:W.jsx(ltA,{style:lwo,side:"bottom",align:"start",sideOffset:8,collisionPadding:10,children:o.map(({simulation:Q,label:i})=>{const E=Q.simulation_experiment_id===A;return W.jsxs(QF,{className:"sv-simulation-item",style:Dwo,title:i,onSelect:n=>n.preventDefault(),onPointerUp:()=>{I(Q.simulation_experiment_id),t(!1)},children:[W.jsx("span",{style:dwo,children:E&&W.jsx(wwo,{})}),W.jsx("span",{style:{...LUI,minWidth:0},children:i})]},Q.simulation_experiment_id)})})})]})]})},pwo=1200,kwo=1,Mwo=2,Swo=({circuitJson:g,containerStyle:A,colorOverrides:I,width:e,height:t,className:o,hideSchematic:B=!1,onSimulationChange:C,acSweepView:Q="magnitude"})=>{const[i,E]=gA.useState(null),[n,s]=gA.useState(!0),[r,a]=gA.useState(null),[c,h]=gA.useState(null),l=gA.useRef(null),D=gA.useRef(null),{containerWidth:d}=fUI(l),[y,w]=gA.useState(!1),{ref:u}=KtA({onSetTransform(j){D.current&&(D.current.style.transform=gN(j))}}),m=e&&t?e/t:B?Mwo:kwo,p=e||(t?t*m:d)||pwo,k=t||p/m;gA.useEffect(()=>{s(!0),a(null),E(g),s(!1)},[g]);const S=gA.useMemo(()=>i?i.filter(j=>j.type==="simulation_experiment"):[],[i]),[R,x]=gA.useState(null),N=(R&&S.some(j=>j.simulation_experiment_id===R)?R:S[0]?.simulation_experiment_id)??null;gA.useEffect(()=>{N!==R&&x(N)},[N,R]);const U=j=>{x(j),C?.(j)},K=gA.useMemo(()=>{if(!i||!p||!k||!N)return"";try{const j={circuitJson:i,simulation_experiment_id:N,ac_sweep_view:Q,width:p,height:k};return B?dUI(j):jdo({...j,schematicOptions:{colorOverrides:I}})}catch(j){return console.error("Failed to generate simulation SVG:",j),""}},[i,p,k,I,B,N,Q]);gA.useEffect(()=>{if(!K){h(null);return}try{const j=new Blob([K],{type:"image/svg+xml"}),Z=URL.createObjectURL(j);return h(Z),()=>{URL.revokeObjectURL(Z)}}catch(j){console.error("Failed to create SVG object URL:",j),h(null)}},[K]);const Y=gA.useMemo(()=>hwo(K,I),[K,I]),_=j=>{w(!0)},q=j=>{w(!0)};return gA.useEffect(()=>{const j=()=>{w(!1)},Z=()=>{w(!1)};return window.addEventListener("mouseup",j),window.addEventListener("touchend",Z),()=>{window.removeEventListener("mouseup",j),window.removeEventListener("touchend",Z)}},[]),n?W.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?W.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#fef2f2",minHeight:"300px",fontFamily:"sans-serif",fontSize:"16px",color:"#dc2626",...A},className:o,children:W.jsxs("div",{style:{textAlign:"center",padding:"20px"},children:[W.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:"Circuit Conversion Error"}),W.jsx("div",{style:{fontSize:"14px"},children:r})]})}):K?W.jsxs("div",{ref:j=>{l.current=j,u.current=j},style:{position:"relative",backgroundColor:Y,overflow:"hidden",minHeight:"300px",cursor:y?"grabbing":"grab",...A},className:o,onMouseDown:_,onTouchStart:q,children:[W.jsx(mwo,{simulations:S,selectedSimulationExperimentId:N,onSelectSimulation:U}),c?W.jsx("img",{ref:D,src:c,alt:"Circuit Simulation",style:{transformOrigin:"0 0",width:"100%",height:"100%",display:"block",objectFit:"contain"}}):W.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",minHeight:"300px",color:"#666",fontFamily:"sans-serif"},children:"Failed to render SVG"})]}):W.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"#f8fafc",minHeight:"300px",fontFamily:"sans-serif",gap:"12px",...A},className:o,children:[W.jsx("div",{style:{fontSize:"16px",color:"#475569",fontWeight:500},children:"No Simulation Found"}),W.jsxs("div",{style:{fontSize:"14px",color:"#64748b"},children:["Use"," ",W.jsx("code",{style:{backgroundColor:"#e2e8f0",padding:"2px 6px",borderRadius:"4px",fontFamily:"monospace",fontSize:"13px"},children:"<analogsimulation />"})," ","to create simulations"]})]})},fwo=()=>{const[g,A]=gA.useState(null),I=gA.useCallback(o=>{A({schematicComponentId:o})},[]),e=gA.useCallback(o=>{A(B=>B===o?null:B)},[]);return{controller:gA.useMemo(()=>({focusRequest:g,onFocusRequestHandled:e}),[g,e]),focusSchematicComponent:I}},YUI=g=>{const[A,I]=gA.useState(0),[e,t]=gA.useState(0);return gA.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}};ys("assembly-viewer");var _UI=()=>{ys.enable("assembly-viewer*")},Rwo=({circuitJson:g,containerStyle:A,debugGrid:I=!1,debug:e=!1})=>{e&&_UI();const t=gA.useRef(null),{ref:o}=KtA({onSetTransform(E){t.current&&(t.current.style.transform=nj(E))}}),{containerWidth:B,containerHeight:C}=YUI(o),Q=gA.useMemo(()=>!B||!C?"":U1g(g,{width:B,height:C||720}),[g,B,C]);gA.useMemo(()=>{if(!Q)return nP();const E=Q.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return MxA(E)}catch(n){return console.error(n),nP()}},[Q]);const i=gA.useMemo(()=>W.jsx("div",{ref:t,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:Q}}),[Q]);return W.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:i})},Nwo=({circuitJson:g,containerStyle:A,debugGrid:I=!1,debug:e=!1})=>{e&&_UI();const t=gA.useRef(null),{ref:o}=KtA({onSetTransform(E){t.current&&(t.current.style.transform=nj(E))}}),{containerWidth:B,containerHeight:C}=YUI(o),Q=gA.useMemo(()=>!B||!C?"":v1g(g,{width:B,height:C||720}),[g,B,C]);gA.useMemo(()=>{if(!Q)return nP();const E=Q.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return MxA(E)}catch(n){return console.error(n),nP()}},[Q]);const i=gA.useMemo(()=>W.jsx("div",{ref:t,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:Q}}),[Q]);return W.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:i})};const bUI=["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."],xwo=(()=>{let g=bUI[Math.floor(Math.random()*bUI.length)];return g=g.replace(/</g,"&lt;"),g=g.replace(/>/g,"&gt;"),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})(),$J=({onRunClicked:g})=>W.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:[W.jsx(Sso,{className:"rf-size-14 rf-mb-4"}),W.jsxs("p",{className:"rf-text-md rf-break-words rf-max-w-xl rf-text-center",children:["Tip: ",W.jsx("span",{dangerouslySetInnerHTML:{__html:xwo}})]}),g&&W.jsxs($E,{className:"rf-mt-4 rf-bg-blue-600 rf-hover:bg-blue-500",onClick:g,children:["Run Code",W.jsx(Uso,{className:"rf-w-3 rf-h-3 rf-ml-2"})]})]}),kmA=({text:g,onClick:A})=>W.jsx("span",{className:"rf-cursor-pointer rf-underline rf-text-blue-600 rf-mx-2",onClick:A,children:g}),MmA=g=>W.jsxs("div",{className:"rf-leading-5",children:[W.jsx("div",{className:"rf-py-2 rf-font-bold",children:g.column.name}),W.jsx("div",{children:g.field?.()??W.jsx("input",{type:"text",className:"rf-border rf-rounded rf-p-1 rf-w-full",onChange:A=>{g.onTextChange?.(A.target.value)}})})]}),Fwo=({open:g,children:A,title:I,onClose:e})=>g?W.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:W.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:[W.jsx("h2",{className:"rf-mt-0 rf-text-md rf-pb-4",children:I}),W.jsx("button",{type:"button",className:"rf-absolute rf-top-2 rf-right-4 rf-text-2xl rf-font-bold",onClick:e,children:"×"}),A]})}):null,Uwo=({elements:g})=>{const[A,I]=gA.useState({open:!1}),[e,t]=gA.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=>W.jsxs("div",{className:"rf-flex rf-items-center",children:[W.jsx(kmA,{text:E.primary_id,onClick:()=>t({focused_id:E.primary_id,id_search:void 0,selector_search:void 0})}),W.jsx("span",{className:"rf-flex-grow"}),W.jsx(kmA,{text:"(JSON)",onClick:()=>I({open:!0,element:E._og_elm,title:E.primary_id})})]}),renderHeaderCell:E=>W.jsx(MmA,{column:E,onTextChange:n=>t({id_search:n}),field:e.focused_id?()=>W.jsxs("div",{children:["Focus:"," ",W.jsx("span",{className:"rf-underline",children:e.focused_id}),W.jsx(kmA,{text:"(unfocus)",onClick:()=>t({focused_id:void 0})})]}):void 0})},{key:"type",name:"type",renderHeaderCell:E=>W.jsx(MmA,{column:E,field:()=>W.jsxs("select",{onChange:n=>t({component_type_filter:n.target.value}),className:"rf-border rf-rounded rf-p-1 rf-w-full",children:[W.jsx("option",{value:"any",children:"any"},"any"),W.jsx("option",{value:"source",children:"source"},"source"),W.jsx("option",{value:"source/pcb",children:"source/pcb"},"source/pcb"),W.jsx("option",{value:"source/schematic",children:"source/schematic"},"source/schematic"),o.map(n=>W.jsx("option",{value:n,children:n},n))]})})},{key:"name",name:"name",renderHeaderCell:E=>W.jsx(MmA,{column:E,onTextChange:n=>t({name_search:n})})},{key:"selector_path",name:"selector_path",renderHeaderCell:E=>W.jsx(MmA,{column:E,onTextChange:n=>t({selector_search:n})})},{key:"other_ids",name:"other_ids",renderCell:E=>W.jsx("div",{className:"rf-space-x-2",children:Object.entries(E.other_ids).map(([n,s])=>W.jsx(kmA,{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 W.jsxs("div",{className:"rf-font-mono rf-text-xs rf-bg-white",children:[W.jsx("div",{className:"rf-overflow-x-auto",children:W.jsxs("table",{className:"rf-table-auto rf-w-full rf-text-left",children:[W.jsx("thead",{children:W.jsx("tr",{children:Q.map(E=>W.jsx("th",{className:"rf-px-4 rf-py-2 rf-border-b",children:E.renderHeaderCell?E.renderHeaderCell(E):E.name},E.key))})}),W.jsx("tbody",{children:i.map((E,n)=>W.jsx("tr",{className:"rf-hover:bg-gray-100",children:Q.map(s=>W.jsx("td",{className:"rf-px-4 rf-py-2 rf-border-b",children:s.renderCell?s.renderCell(E):E[s.key]},s.key))},n))})]})}),W.jsx(Fwo,{open:A.open,onClose:()=>I({open:!1}),title:A.open?A.title:"",children:W.jsx("div",{className:"rf-bg-gray-800 rf-p-3 rf-text-white rf-rounded",children:W.jsx("pre",{className:"rf-whitespace-pre-wrap",children:A.open?JSON.stringify(A.element,null,2):""})})})]})};var Jwo=()=>{if(globalThis.tscircuitDynamicModules)return globalThis.tscircuitDynamicModules;const g={};return globalThis.tscircuitDynamicModules=g,g},Pwo=["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"],HUI=g=>{const A=g.indexOf("@",g.startsWith("@")?1:0);return A===-1?g:g.slice(0,A)},Kwo="https://jscdn.tscircuit.com";function vUI(){return typeof window<"u"&&window.TSCIRCUIT_JSCDN_BASE_URL||void 0}var Lwo=new Set(Pwo),Ywo=new Map([["@tscircuit/circuit-json-schematic-placement-analysis","dist/browser.js"]]);function _wo(g){if(!Lwo.has(HUI(g)))throw new Error(`Unsupported module: ${g}`)}var bwo=g=>{_wo(g);const A=HUI(g),I=g.length===A.length?"latest":g.slice(A.length+1),e=Ywo.get(A)??"+esm",t=vUI(),B=`${(t??Kwo).replace(/\/+$/,"")}/${A}/${I}/${e}`;return t?new URL(B,window.location.href).href:B},Hwo=g=>{const A=bwo(g);return vUI()?[A]:[A,`https://esm.run/${g}`]};function vwo(g=A=>import(A)){return async A=>{const I=Jwo();if(Object.hasOwn(I,A))return I[A];let e;for(const t of Hwo(A))try{const o=await g(t);return I[A]=o,o}catch(o){e=o}throw e}}var qwo=()=>globalThis.tscircuitDynamicImportResolver,qUI=vwo();async function Two(g){const A=qwo();return A?A(g,qUI):qUI(g)}var yS=Two;const Zwo=(g,A)=>W.jsx("a",{className:"rf-underline rf-text-blue-500",target:"_blank",rel:"noreferrer",href:`https://jlcpcb.com/partdetail/${A}`,children:A}),Owo=g=>g?.map(({manufacturer:A,mpn:I})=>`${A}: ${I}`).join(", "),Wwo=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}},Vwo=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?Zwo("jlcpcb",e):""}}),g.hasManufacturerColumn&&A.push({key:"manufacturer_mpn_pairs",label:"Manufacturer / MPN",getCell:I=>Owo(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},jwo=({circuitJson:g})=>{const[A,I]=gA.useState(null),[e,t]=gA.useState(null);if(gA.useEffect(()=>{let C=!1;return(async()=>{try{t(null),I(null);const{convertCircuitJsonToBomRows:i}=await yS("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=Wwo(A??[]),B=Vwo(o);return A?W.jsx("div",{className:"rf-overflow-x-auto",children:W.jsxs("table",{className:"rf-w-full rf-text-left rf-text-sm",children:[W.jsx("thead",{children:W.jsx("tr",{className:"rf-border-b",children:B.map(C=>W.jsx("th",{className:"rf-p-2",children:C.label},C.key))})}),W.jsx("tbody",{children:A.map((C,Q)=>W.jsx("tr",{className:"rf-border-b",children:B.map(i=>W.jsx("td",{className:"rf-p-2",children:i.getCell(C)},i.key))},C.designator||`${Q}`))})]})}):W.jsx("div",{className:"rf-p-4 rf-text-sm rf-text-muted-foreground",children:"Loading BOM..."})},kBg=gA.forwardRef(({className:g,type:A,...I},e)=>W.jsx("input",{type:A,className:dB("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}));kBg.displayName="Input";const zwo=({circuitJson:g,containerClassName:A,...I})=>{const e=gA.useRef(null),[t,o]=gA.useState(620);return gA.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)}},[]),W.jsx("div",{ref:e,className:A||"rf-w-full rf-h-full",children:W.jsx(_tg,{...I,circuitJson:g,height:t})})},Xwo='*,: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}',MBg=()=>{gA.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const A=document.createElement("style");A.setAttribute("data-styles","tscircuit-runframe"),A.textContent=Xwo,document.head.appendChild(A)},[])},$wo=g=>{gA.useEffect(()=>(g?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[g])};function TUI(g,A,I){const[e,t]=gA.useState(()=>{if(I!==void 0)return I;try{const o=window.localStorage.getItem(g);return o?JSON.parse(o):A}catch(o){return console.error("Error reading from localStorage:",o),A}});return gA.useEffect(()=>{try{window.localStorage.setItem(g,JSON.stringify(e))}catch(o){console.error("Error writing to localStorage:",o)}},[g,e]),[e,t]}const ZUI=g=>`hsl(${MR.indexOf(g)*137.5%360}, 70%, 50%)`,Auo=({phaseTimings:g})=>{if(!g)return null;const A=Object.values(g).reduce((I,e)=>I+e,0);return W.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[W.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:MR.map(I=>{const e=g[I]||0,t=e/A*100;return W.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${t}%`,backgroundColor:ZUI(I)},children:W.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)})}),W.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",A.toFixed(2),"ms"]})]})},guo=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)},Iuo=({renderLog:g,onRerunWithDebug:A})=>{const[I,e]=gA.useState("chronological"),[t,o]=gA.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 W.jsxs("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:[W.jsx("div",{className:"rf-mb-4",children:"No render log, make sure this tab is open when you render"}),A&&W.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[W.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=>W.jsx("option",{value:i.value,children:i.label},i.value))}),W.jsx($E,{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)=>MR.indexOf(i[0])-MR.indexOf(E[0])):C.sort((i,E)=>E[1]-i[1]);const Q=C.reduce((i,[E,n])=>i+n,0);return W.jsxs("div",{className:"rf-bg-white",children:[W.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mb-4",children:[W.jsx("div",{children:"Render Logs"}),W.jsxs("div",{className:"rf-flex rf-gap-4 rf-items-center",children:[A&&W.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[W.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=>W.jsx("option",{value:i.value,children:i.label},i.value))}),W.jsx($E,{onClick:()=>A(t),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]}),W.jsx("div",{className:"rf-flex rf-gap-2 rf-items-center",children:W.jsxs("select",{onChange:i=>{if(i.target.value){const E=g?.debugOutputs?.find(n=>n.name===i.target.value);if(E){const n=guo(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:[W.jsx("option",{value:"",children:"Download Debug Output"}),g?.debugOutputs?.map(i=>W.jsx("option",{value:i.name,children:i.name},i.name))]})}),W.jsxs("div",{className:"rf-flex rf-text-xs rf-items-center",children:[W.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),W.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:[W.jsx("option",{value:"chronological",children:"Phase Order"}),W.jsx("option",{value:"longest",children:"Duration"})]})]})]})]}),W.jsx(Auo,{phaseTimings:g.phaseTimings}),W.jsxs("table",{className:"rf-w-full rf-text-xs",children:[W.jsx("thead",{children:W.jsxs("tr",{children:[W.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),W.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),W.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),W.jsx("tbody",{children:C.map(([i,E])=>W.jsxs("tr",{children:[W.jsx("td",{className:"rf-p-2",children:MR.indexOf(i)}),W.jsx("td",{className:"rf-p-2",children:i}),W.jsx("td",{className:"rf-p-2",children:W.jsx("div",{className:"rf-w-8",children:W.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:ZUI(i),width:`${E/Q*100}%`}})})}),W.jsx("td",{className:"rf-p-2",children:W.jsxs("div",{className:"rf-flex w-full",children:[W.jsxs("span",{className:"rf-flex-grow",children:[E,"ms"]}),W.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(E/Q*100).toFixed(1),"%"]})]})})]},i))})]})]})};var euo=8,SBg=g=>Math.hypot(g.a,g.b)||1,tuo=g=>[g.label,g.inlineLabel].filter(Boolean).join(`
5632
5632
  `),_tA=(g,A)=>Math.hypot(g.x-A.x,g.y-A.y),OUI=(g,A,I)=>{const e=I.x-A.x,t=I.y-A.y,o=e*e+t*t;if(o===0)return _tA(g,A);const B=((g.x-A.x)*e+(g.y-A.y)*t)/o,C=Math.max(0,Math.min(1,B));return _tA(g,{x:A.x+e*C,y:A.y+t*C})},ouo=(g,A,I)=>{const e=I.x-A.x,t=I.y-A.y,o=Math.hypot(e,t);return o===0?_tA(g,A):Math.abs(t*g.x-e*g.y+I.x*A.y-I.y*A.x)/o},fBg=(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},RBg=(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(OUI(g,B,C)<=I)return!0}return!1},WUI=(g,A,I)=>Math.max(I,(g??2)*SBg(A)/2+4),A4=(g,A)=>KI(g,A),NBg=(g,A,I,e)=>_tA(g,A4(I,A))<=e,Buo=(g,A,I,e)=>{if(A.points.length===0)return!1;if(A.points.length===1)return NBg(g,A.points[0],I,e);const t=A.points.map(o=>A4(I,o));return RBg(g,t,WUI(A.strokeWidth,I,e))},Cuo=(g,A,I,e)=>{const{origin:t,directionVector:o}=A;if(o.x===0&&o.y===0)return!1;const B=A4(I,t),C=A4(I,{x:t.x+o.x,y:t.y+o.y});return ouo(g,B,C)<=WUI(A.strokeWidth,I,e)},Quo=(g,A,I,e)=>{const t=kHA(A,I).corners;return fBg(g,t)||RBg(g,t,e,!0)},iuo=(g,A,I,e)=>{const t=A4(I,A.center),o=A.radius*SBg(I);return _tA(g,t)<=o+e},Euo=(g,A,I,e)=>{if(A.points.length===0)return!1;if(A.points.length===1)return NBg(g,A.points[0],I,e);const t=A.points.map(o=>A4(I,o));return fBg(g,t)||RBg(g,t,e,!0)},nuo=(g,A,I,e)=>{const t=FAA(A),o=A4(I,t.shaftStart),B=A4(I,t.shaftEnd),C=Math.max(e,t.shaftWidth*SBg(I)/2+4);return OUI(g,o,B)<=C?!0:t.heads.some(Q=>{const i=[Q.tip,Q.leftWing,Q.rightWing].map(E=>A4(I,E));return fBg(g,i)})};function suo(g,A,I,e={}){const t=e.hitSlop??euo;for(let B=(g.points?.length??0)-1;B>=0;B-=1){const C=g.points?.[B];if(C?.label&&NBg(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&&Cuo(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&&Buo(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?tuo(C):"";if(!(!C||!Q)&&nuo(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&&Euo(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&&iuo(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&&Quo(I,C,A,t))return C.label}return null}const auo=aC[typeof document<"u"&&document.createElement!==void 0?"useLayoutEffect":"useEffect"],ruo=g=>{const A=gA.useRef(g);return gA.useEffect(()=>{A.current=g}),A};function cuo(){}function VUI(g,A,I={}){const e=luo(I.polyfill),t=ruo(A);return auo(()=>{let o=!1;const B=g&&"current"in g?g.current:g;if(!B)return cuo;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 huo(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 xBg;const luo=g=>xBg||(xBg=huo(g));var Duo=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=jIt(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=Ujg(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 jUI(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 duo=g=>g.slice().sort((A,I)=>I.width*I.height-A.width*A.height);function yuo(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 wuo(g){const{dimensionStart:A,dimensionEnd:I,screenDimensionStart:e,screenDimensionEnd:t,flipX:o,flipY:B}=g;return gA.useMemo(()=>yuo({dimensionStart:A,dimensionEnd:I,screenDimensionStart:e,screenDimensionEnd:t,flipX:o,flipY:B}),[A,I,e,t,o,B])}var uuo=({children:g,transform:A})=>{A||(A=nP());const[I,e]=gA.useState(!1),[t,o]=gA.useState(!1),[B,C]=gA.useState({x:0,y:0}),[Q,i]=gA.useState({x:0,y:0}),E=gA.useRef({x:0,y:0}),n=gA.useRef(null),s=gA.useRef(!1),a=n.current?.getBoundingClientRect(),c=gA.useCallback(()=>{s.current=!0,n.current?.focus()},[]),h=gA.useCallback(()=>{s.current=!1},[]);gA.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=wuo({dimensionStart:B,dimensionEnd:Q,screenDimensionStart:l,screenDimensionEnd:D,flipX:d.flipX,flipY:d.flipY});return W.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(ij(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&&W.jsxs(W.Fragment,{children:[y.show&&W.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)}),W.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)}),W.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:W.jsx("div",{style:{marginLeft:d.flipX?"-100%":4,paddingRight:4},children:Math.abs(B.y-Q.y).toFixed(2)})}),W.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:30},width:a?.width||"100%",height:a?.height||"100%",children:[W.jsx("defs",{children:W.jsx("marker",{id:"head",orient:"auto",markerWidth:"3",markerHeight:"4",refX:"2",refY:"2",children:W.jsx("path",{d:"M0,0 V4 L2,2 Z",fill:"red"})})}),W.jsx("line",{x1:l.x,y1:l.y,x2:D.x,y2:D.y,markerEnd:"url(#head)",strokeWidth:1.5,fill:"none",stroke:"red"}),W.jsx("line",{x1:l.x,y1:l.y,x2:D.x,y2:l.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"}),W.jsx("line",{x1:D.x,y1:l.y,x2:D.x,y2:D.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"})]}),W.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),")",W.jsx("br",{}),"(",Q.x.toFixed(2),",",Q.y.toFixed(2),")",W.jsx("br",{}),"dist:"," ",Math.sqrt((Q.x-B.x)**2+(Q.y-B.y)**2).toFixed(2)]})]})]})},zUI=({label:g,onClose:A})=>W.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:W.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:[W.jsx("div",{style:{fontWeight:600,marginBottom:8},children:"Object label"}),W.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",marginBottom:16},children:g}),W.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:W.jsx("button",{type:"button",onClick:A,children:"Close"})})]})}),XUI=(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)},eN=(g,A)=>{try{return FIt(g,A)}catch{return A}},Guo=({arrow:g,index:A,interactiveState:I})=>{const{realToScreen:e,onObjectClicked:t,setHoverTooltip:o}=I,[B,C]=gA.useState(!1),Q=gA.useMemo(()=>FAA(g),[g]),i=gA.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=gA.useMemo(()=>f0A(i.shaftStart,i.shaftEnd,{fontSize:n,strokeWidth:s,normalPadding:6,alongOffset:g.label?r:0}),[i,n,s,g.label,r]),c=gA.useMemo(()=>f0A(i.shaftStart,i.shaftEnd,{fontSize:n,strokeWidth:s,normalPadding:12,alongOffset:g.inlineLabel?-r:0}),[i,n,s,g.inlineLabel,r]),h=g.color||Gh[A%Gh.length]||"black",l=B?eN(.2,h):h,D=[g.label,g.inlineLabel].filter(Boolean).join(`
5633
5633
  `),d=g.label?c:a;gA.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})=>XUI(G,m,R.x,R.y,x.x,x.y)<p);C(S)};return W.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"},children:W.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:[W.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)=>W.jsx("polygon",{points:`${w.tip.x},${w.tip.y} ${w.leftWing.x},${w.leftWing.y} ${w.rightWing.x},${w.rightWing.y}`,fill:l},u))]})})},muo=({circle:g,interactiveState:A,index:I})=>{const e=Gh[I%Gh.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]=gA.useState(!1),D=KI(r,t),d=o*r.a;let y=B||e;return h&&(y=eN(.2,y),C=C&&eN(.2,C)),gA.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]),W.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})})},puo=({x:g,y:A,onSaveCamera:I,onLoadCamera:e,onClearCamera:t,onAddMark:o,onClearMarks:B,onClose:C})=>{const Q=gA.useRef(null);gA.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 W.jsxs("div",{ref:Q,style:i,children:[W.jsx("div",{style:E,onClick:()=>{I(),C()},onMouseEnter:n,onMouseLeave:s,children:"Save Camera Position"}),W.jsx("div",{style:E,onClick:()=>{e(),C()},onMouseEnter:n,onMouseLeave:s,children:"Load Camera Position"}),W.jsx("div",{style:E,onClick:()=>{t(),C()},onMouseEnter:n,onMouseLeave:s,children:"Clear Saved Camera Position"}),W.jsx("div",{style:E,onClick:()=>{o(),C()},onMouseEnter:n,onMouseLeave:s,children:"Add Mark"}),W.jsx("div",{style:E,onClick:()=>{B(),C()},onMouseEnter:n,onMouseLeave:s,children:"Clear Marks"})]})},kuo=({infiniteLine:g,index:A,interactiveState:I,size:e})=>{const{realToScreen:t,onObjectClicked:o,setHoverTooltip:B}=I,[C,Q]=gA.useState(!1),i=Mjg(t,e.width,e.height),E=kjg(g,i);if(!E)return null;const[n,s]=E,r=KI(t,n),a=KI(t,s),c=g.strokeColor??Gh[A%Gh.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 W.jsx("div",{style:{position:"absolute",top:0,left:0,width:e.width,height:e.height,pointerEvents:"none"},children:W.jsxs("svg",{style:{width:e.width,height:e.height,pointerEvents:"none"},children:[W.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})}),W.jsx("line",{x1:r.x,y1:r.y,x2:a.x,y2:a.y,stroke:C?eN(.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"})]})})},Muo=({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=gA.useMemo(()=>{if(!t)return!1;for(let m=0;m<h.length-1;m++)if(XUI(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??Gh[A%Gh.length];return gA.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]),W.jsx("div",{style:{position:"absolute",top:0,left:0,width:e.width,height:e.height,pointerEvents:"none"},children:W.jsxs("svg",{style:{width:e.width,height:e.height,overflow:"visible",pointerEvents:"none"},children:[W.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}),W.jsx("polyline",{points:h.map(m=>`${m.x},${m.y}`).join(" "),stroke:u?eN(.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"})]})})},Suo=({marker:g,transform:A})=>{const[I,e]=KI(A,[g.x,g.y]);return W.jsx("svg",{style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:900},children:W.jsxs("g",{transform:`translate(${I}, ${e})`,children:[W.jsx("circle",{r:7,fill:"rgba(255, 0, 0, 0.5)",stroke:"rgba(255, 0, 0, 0.8)",strokeWidth:2}),W.jsx("circle",{r:2,fill:"rgba(255, 0, 0, 0.9)"})]})})},fuo=({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]=gA.useState(!1),a=KI(i,g),c=10,h=`${t?`${t}
5634
5634
  `:""}x: ${g.x.toFixed(2)}, y: ${g.y.toFixed(2)}`;return gA.useEffect(()=>{if(s)return n?.({text:h,x:a.x,y:a.y-c/2}),()=>{n?.(null)}},[s,a.x,a.y,n,h]),W.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?eN(.2,e??Gh[I%Gh.length]):e??Gh[I%Gh.length]}`,cursor:"pointer",transition:"border-color 0.2s"},onMouseEnter:()=>r(!0),onMouseLeave:()=>{r(!1),n?.(null)},onClick:()=>E?.({type:"point",index:I,object:g})})},Ruo=({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]=gA.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=Gh[I%Gh.length],R=t!==void 0||o!==void 0?t||"transparent":k,x=o,N=E?eN(.2,R):R,U=x?E?eN(.2,x):x:void 0,K=B===void 0?void 0:B*C.a;return gA.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?W.jsx("div",{style:{position:"absolute",top:u,left:w,width:G,height:m,pointerEvents:"none"},children:W.jsx("svg",{width:G,height:m,style:{display:"block"},children:W.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},Nuo=({rect:g,interactiveState:A,index:I})=>{const e=Gh[I%Gh.length];let{fill:t,stroke:o}=g;const{activeLayers:B,activeStep:C,realToScreen:Q,onObjectClicked:i,setHoverTooltip:E}=A,[n,s]=gA.useState(!1),r=kHA(g,Q);let c=t!==void 0||o!==void 0?t||"transparent":e;return n&&(c=eN(.2,c),o=eN(.2,o)),gA.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]),W.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:W.jsx("div",{style:{width:"100%",height:"100%",backgroundColor:c,border:o?`2px solid ${n?eN(.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})})})},xuo=({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 W.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})},$UI=({text:g})=>W.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}),Ef=5,Fuo=(g,A)=>gA.useMemo(()=>(I,e)=>{const t=KI(g,I),o=KI(g,e),B=-Ef,C=A.width+Ef,Q=-Ef,i=A.height+Ef;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]),Uuo=(g,A)=>gA.useMemo(()=>I=>{const e=KI(g,I);return e.x>=-Ef&&e.x<=A.width+Ef&&e.y>=-Ef&&e.y<=A.height+Ef},[g,A]),Juo=({isPointOnScreen:g,doesLineIntersectViewport:A,filterLayerAndStep:I})=>gA.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]),Puo=({isPointOnScreen:g,filterLayerAndStep:A})=>gA.useMemo(()=>I=>A(I)?g(I):!1,[g,A]),Kuo=({realToScreen:g,isPointOnScreen:A,doesLineIntersectViewport:I,filterLayerAndStep:e})=>gA.useMemo(()=>t=>{if(!e(t))return!1;const{center:o}=t,[B,C,Q,i]=Njg(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]),Luo=({isPointOnScreen:g,filterLayerAndStep:A,realToScreen:I,size:e})=>gA.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=-Ef,n=e.width+Ef,s=-Ef,r=e.height+Ef;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]),Yuo=({isPointOnScreen:g,filterLayerAndStep:A})=>gA.useMemo(()=>I=>A(I)?g({x:I.x,y:I.y}):!1,[g,A]),_uo=({isPointOnScreen:g,doesLineIntersectViewport:A})=>gA.useMemo(()=>I=>{const e=FAA(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]),buo=({isPointOnScreen:g,doesLineIntersectViewport:A,filterLayerAndStep:I})=>gA.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]),Huo=1e3,vuo=({graphics:g,onObjectClicked:A,objectLimit:I,height:e=600,stepMetadata:t,alwaysShowToolbar:o=!1})=>{const[B,C]=gA.useState(null),[Q,i]=gA.useState(null),[E,n]=gA.useState(!0),[s,r]=gA.useState({width:600,height:e}),[a,c]=gA.useState(null),[h,l]=gA.useState(!1),[D,d]=gA.useState(null),[y,w]=gA.useState([]),[u,G]=gA.useState(null),[m,p]=gA.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=jUI(g),R=gA.useMemo(()=>{const og=Duo(g),dg=og.maxX-og.minX,Rg=og.maxY-og.minY;return{minX:og.minX-dg/10,minY:og.minY-Rg/10,maxX:og.maxX+dg/10,maxY:og.maxY+Rg/10}},[g]),x=gA.useCallback(()=>{const og=window.location.pathname,dg=window.location.search;return`saved-camera-position-${og}${dg}`},[]),N=gA.useCallback(()=>{const og=Math.max(R.maxX-R.minX,1),dg=Math.max(R.maxY-R.minY,1),Rg=Math.min(s.width/og,s.height/dg);return Tr(vQ(s.width/2,s.height/2),$u(Rg,-Rg),vQ(-(R.maxX+R.minX)/2,-(R.maxY+R.minY)/2))},[s,R]),U=gA.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=gA.useCallback(()=>U()?.transform||null,[U]),{transform:Y,ref:_,setTransform:q}=uUI({initialTransform:N()});VUI(_,og=>{r({width:og.contentRect.width,height:og.contentRect.height})}),gA.useEffect(()=>{const og=U();og?.markers&&w(og.markers)},[U]);const j=gA.useCallback(og=>{og.preventDefault();const dg=og.clientX,Rg=og.clientY,Qg=og.currentTarget.getBoundingClientRect(),_g=Qg.left,EI=Qg.top,GA=window.innerWidth,ng=window.innerHeight,pg=160,Ug=100;let mg=dg-_g,fg=Rg-EI;dg>GA/2&&(mg=mg-pg),Rg>ng/2&&(fg=fg-Ug),c({x:mg,y:fg,clientX:dg,clientY:Rg})},[]),Z=gA.useCallback((og,dg)=>{try{const Rg={transform:og,markers:dg};localStorage.setItem(x(),JSON.stringify(Rg))}catch(Rg){console.error("Error saving data:",Rg)}},[x]),O=gA.useCallback(()=>{Z(Y,y)},[Z,Y,y]),AA=gA.useCallback(()=>{try{const og=K();og&&q(og)}catch(og){console.error("Error loading camera position:",og)}},[K,q]),tA=gA.useCallback(()=>{try{const og=N();Z(og,y),q(og)}catch(og){console.error("Error clearing camera position:",og)}},[Z,N,q,y]),eA=gA.useCallback(()=>{if(a)try{const og={x:a.clientX,y:a.clientY},dg=_.current?.getBoundingClientRect();if(dg){const Rg=og.x-dg.left,Qg=og.y-dg.top,_g=ij(Y),[EI,GA]=KI(_g,[Rg,Qg]),ng={x:EI,y:GA},pg=[...y,ng];w(pg);const Ug=U();Ug?.transform&&Z(Ug.transform,pg)}}catch(og){console.error("Error adding marker:",og)}},[a,_,Y,y,Z]),QA=gA.useCallback(()=>{w([]);const og=U();og?.transform&&Z(og.transform,[])},[U,Z]),sA=gA.useCallback(og=>{switch(og.type){case"arrow":return[og.object.label,og.object.inlineLabel].filter(Boolean).join(`
@@ -5664,7 +5664,7 @@ test("${i} should solve problem correctly", () => {
5664
5664
  // Add more specific assertions based on expected output
5665
5665
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5666
5666
  })
5667
- `,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 W.jsxs("div",{className:`relative ${A}`,ref:t,children:[W.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&&W.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:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:B,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:C,children:"Download test.ts"})]})]})},AJI=g=>g.activeSubSolver?[g,...AJI(g.activeSubSolver)]:[g],Wuo=({solver:g})=>{const A=AJI(g);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((I,e)=>W.jsxs("div",{className:"flex items-center",children:[e>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(Ouo,{solver:I})]},I.getSolverName()))})},Vuo=({solver:g,triggerRender:A,animationSpeed:I=25,renderer:e,onRendererChange:t,onAnimationSpeedChange:o,onDownloadVisualization:B,onSolverStarted:C,onSolverCompleted:Q})=>{const[i,E]=gA.useReducer(m=>!m,!1),n=gA.useRef(void 0),s=gA.useRef(null),r="solver-debugger-last-iteration",[a,c]=gA.useState(null),h=gA.useRef(null),l=gA.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 gA.useEffect(()=>()=>{d()},[]),gA.useEffect(()=>{(g.solved||g.failed)&&i&&(d(),E())},[g.solved,g.failed,i]),gA.useEffect(()=>{i&&(d(),D())},[I,i]),gA.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)}},[]),W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsxs("div",{className:"flex items-center gap-2",ref:h,children:[W.jsxs("div",{className:"flex h-9 items-center space-x-1 rounded-md border border-slate-200 bg-white p-1 shadow-sm",children:[W.jsxs("div",{className:"relative",children:[W.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"&&W.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=>W.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&&W.jsx("span",{className:"ml-auto text-xs text-slate-500",children:"✓"})]},m))})]}),W.jsxs("div",{className:"relative",children:[W.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"&&W.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:W.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"})})]}),W.jsxs("div",{className:"relative",children:[W.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"&&W.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=>W.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,W.jsx("span",{className:"ml-auto text-xs text-slate-500",children:m.description}),I===m.value&&W.jsx("span",{className:"ml-2 text-xs text-slate-500",children:"✓"})]},m.value))})]})]}),W.jsx(Wuo,{solver:g})]})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.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"}),W.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"}),W.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"}),W.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"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",g.iterations]}),g.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(g.timeToSolve/1e3).toFixed(3),"s"]}),g.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),g.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),g.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",g.error]})]})},juo=g=>g!==null&&"pipelineDef"in g&&Array.isArray(g.pipelineDef),zuo=(g,A,I)=>{const e=g.currentPipelineStageIndex;return A<e?"Completed":A===e&&g.activeSubSolver?g.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Xuo=(g,A)=>{const e=g.pipelineDef[A].solverName,t=zuo(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}},$uo=({status:g})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${A[g]}`,children:g})},AGo=({progress:g})=>{if(g===0)return null;const A=Math.round(g*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},gJI=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)},gGo=g=>Object.entries(g).map(([A,I])=>`${A}: ${gJI(I)}`).join(", "),IGo=({stats:g})=>{if(!g||Object.keys(g).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(g),I=gGo(g);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:I}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([e,t])=>W.jsxs("div",{children:[e,": ",gJI(t)]},e))})]})},FBg=g=>{if(g===null||typeof g!="object")return g;if(Array.isArray(g))return g.map(FBg);const A={};for(const[I,e]of Object.entries(g))I.startsWith("_")||(A[I]=FBg(e));return A},eGo=(g,A)=>{try{if(typeof g.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const I=FBg(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)}`)}},tGo=({expanded:g})=>W.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:W.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"})}),IJI=g=>{let A=g;for(;A.activeSubSolver;)A=A.activeSubSolver;return A},eJI=({solver:g,onStepUntilPhase:A,onDownloadInput:I,isNested:e=!1,indentLevel:t=0,triggerRender:o})=>{const[B,C]=gA.useState(new Set),Q=g.pipelineDef.map((h,l)=>Xuo(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):eGo(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=IJI(g);for(;!g.solved&&!g.failed&&(g.step(),IJI(g)===h););o?.()}},c=t*24;return W.jsxs("div",{className:e?"":"border-t border-gray-200",children:[!e&&W.jsxs("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between",children:[W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Stages"}),W.jsxs("div",{className:"flex gap-2",children:[W.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"}),W.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"})]})]}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[!e&&W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stage"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:Q.map(h=>{const l=juo(h.solverInstance),D=B.has(h.name);return W.jsxs(aC.Fragment,{children:[W.jsxs("tr",{className:`border-b border-gray-100 ${h.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:c},children:[l?W.jsx("button",{onClick:()=>i(h.name),className:"text-gray-500 hover:text-gray-700",title:D?"Collapse":"Expand",children:W.jsx(tGo,{expanded:D})}):W.jsx("span",{className:"w-4"}),W.jsx("span",{className:"text-gray-400 w-6",children:String(h.index+1).padStart(2,"0")}),W.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:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.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"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:h.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx($uo,{status:h.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:h.firstIteration!==null?h.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:h.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(AGo,{progress:h.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(h.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(IGo,{stats:h.stats})}),W.jsx("td",{className:"px-4 py-2",children:h.solverInstance?W.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:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.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"})}),W.jsx("span",{children:"Input"})]}):null})]}),l&&D&&W.jsx("tr",{children:W.jsx("td",{colSpan:8,className:"p-0",children:W.jsx(eJI,{solver:h.solverInstance,onStepUntilPhase:A,onDownloadInput:I,isNested:!0,indentLevel:t+1,triggerRender:o})})})]},h.name)})})]})})]})};function oGo({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 W.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)=>W.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)=>W.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)=>W.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)=>W.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)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${l}`))]})}var BGo=class extends aC.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}},CGo=({solver:g,createSolver:A,animationSpeed:I=25,onSolverStarted:e,onSolverCompleted:t})=>{const[o,B]=gA.useReducer(D=>D+1,0),[C]=gA.useState(()=>{if(A)return A();if(!g)throw new Error("GenericSolverDebugger requires solver or createSolver");return g}),[Q,i]=gA.useState(()=>typeof window>"u"?"vector":window.localStorage.getItem("solver-utils-renderer")==="canvas"?"canvas":"vector"),[E,n]=gA.useState(I),s=gA.useMemo(()=>{try{return C.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(D){return console.error("Visualization error:",D),{points:[],lines:[],rects:[],circles:[]}}},[C,o]),r=gA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);gA.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)}},[]),gA.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 W.jsxs("div",{children:[W.jsx(Vuo,{solver:C,triggerRender:B,animationSpeed:E,renderer:Q,onRendererChange:l,onAnimationSpeedChange:n,onDownloadVisualization:h,onSolverStarted:e,onSolverCompleted:t}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(BGo,{fallback:W.jsx(oGo,{graphics:s}),children:Q==="canvas"?W.jsx(Zuo,{graphics:s}):W.jsx(vuo,{graphics:s})}),a&&W.jsx(eJI,{solver:C,onStepUntilPhase:c,triggerRender:B})]})};const QGo=()=>{gA.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)},[])},iGo=1e3,Jk=(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)},iGo)},UBg=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"},EGo=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]},EF="https://github.com/tscircuit/tscircuit-autorouter/issues/new",tJI="https://github.com/tscircuit/copper-pour-solver/issues/new",oJI="https://github.com/tscircuit/calculate-packing/issues/new",nGo="https://github.com/tscircuit/matchpack/issues/new",BJI="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",sGo={PackSolver2:oJI,LayoutPipelineSolver:nGo,AutoroutingPipelineSolver:EF,AssignableAutoroutingPipeline2:EF,AssignableAutoroutingPipeline3:EF,AutoroutingPipeline1_OriginalUnravel:EF,AutoroutingPipelineSolver3_HgPortPointPathing:EF,AutoroutingPipelineSolver4:EF,AutoroutingPipelineSolver5:EF,AutoroutingPipelineSolver7_MultiGraph:EF,AutoroutingPipelineSolver8:EF,CopperPourPipelineSolver:tJI,SchematicTracePipelineSolver:BJI},aGo=g=>g.toLowerCase().includes("pack")?Mso:g.toLowerCase().includes("rout")?ZNI:dso,CJI=g=>{const A=sGo[g];if(A)return A;const I=g.toLowerCase();return I.includes("autorout")?EF:I.includes("schematic")&&I.includes("trace")?BJI:I.includes("copperpour")?tJI:I.includes("pack")?oJI:null},rGo=g=>`${UBg(`${g.componentName}-${g.solverName}`)}-solver-input.json`,QJI=g=>{Jk(JSON.stringify(g.solverParams,null,2),{fileName:rGo(g),mimeType:"application/json"})},cGo=({solverEvent:g})=>{const A=CJI(g.solverName);return W.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:[W.jsxs($E,{type:"button",variant:"outline",size:"sm",onClick:()=>QJI(g),children:[W.jsx(EtA,{className:"rf-w-4 rf-h-4"}),"Download"]}),A?W.jsx($E,{asChild:!0,variant:"outline",size:"sm",children:W.jsxs("a",{href:A,target:"_blank",rel:"noopener noreferrer",children:[W.jsx(EGA,{className:"rf-w-4 rf-h-4"}),"Report"]})}):W.jsxs($E,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[W.jsx(EGA,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},hGo=({solverEvent:g})=>{const A=CJI(g.solverName);return A?W.jsx($E,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:W.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:W.jsx(EGA,{className:"rf-w-4 rf-h-4"})})}):W.jsx($E,{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:W.jsx(EGA,{className:"rf-w-4 rf-h-4"})})},lGo=({solverEvents:g=[]})=>{const[A,I]=gA.useState(null);QGo();const e=gA.useMemo(()=>{const C=new Map;for(const Q of g){const i=`${Q.componentName}-${Q.solverName}`;C.set(i,Q)}return C},[g]),t=gA.useMemo(()=>Array.from(e.keys()),[e]),o=A?e.get(A):null,B=gA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const C=qqA[o.solverName];if(!C)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(qqA).join(", ")}`,classFound:!1};try{return{instance:new C(...EGo(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?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.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."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.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 W.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=aGo(Q.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(E,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:Q.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:Q.solverName})]})]})})()},C)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?B.instance?W.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[W.jsx(cGo,{solverEvent:o}),W.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:W.jsx(zR,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:W.jsx(CGo,{solver:B.instance})})})]}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),B.error&&W.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:W.jsx("p",{className:`rf-text-sm ${B.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:B.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.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:[W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[W.jsx(hGo,{solverEvent:o}),W.jsx($E,{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:()=>QJI(o),children:W.jsx(EtA,{className:"rf-w-4 rf-h-4"})})]})]}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.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)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},DGo=new Map([["custom","Custom"],["fanout","Fanout"],["single_layer_fanout","Single layer fanout"],["tscircuit_simplify","Simplify"]]),dGo=new Set(["tscircuit","default","auto","auto_local"]);function yGo(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 wGo(g){const A=g.autorouterName?.trim(),I=A?.replace(/-/g,"_"),e=I&&DGo.get(I);if(e)return e;if(I&&!dGo.has(I))return A;const t=g.solverName?.trim();if(t)return yGo(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 JBg="#fbbf24";function uGo(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 iJI(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 GGo(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 EJI(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,...GGo(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 mGo(g){const A=[],I=[],e=g.endSimpleRouteJson;if(!e)return{lines:A,circles:I};const t=new Set(iJI(g));for(const o of e.traces??[])if(t.has(o.pcb_trace_id))for(const B of EJI(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:JBg,layer:i}),Q.route_type==="via"&&I.push({center:{x:Q.x,y:Q.y},radius:Q.outer_diameter/2,stroke:JBg,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 pGo(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 kGo=new Set(["pcb_trace","pcb_via","pcb_copper_pour","pcb_ground_plane","pcb_ground_plane_region","pcb_thermal_spoke","pcb_breakout_point"]);function MGo(g,A,I){const e=I==="input"?A.startSimpleRouteJson??A.errorSimpleRouteJson:A.endSimpleRouteJson,t=g.filter(i=>!kGo.has(i.type)&&!i.type.endsWith("_error")&&!i.type.endsWith("_warning"));if(!e)return t;const o=I==="input"?e.traces??[]:uGo(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=EJI(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}_${pGo(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 PBg=(g,A)=>g.phaseName||`Phase ${g.phaseOrdinal??A+1}`,nJI=g=>g.componentDisplayName?.match(/name="([^"]+)"/)?.[1]?.replace(/^\./,"")||g.componentDisplayName||g.subcircuit_id||"Board",sJI=g=>g.startSimpleRouteJson??g.endSimpleRouteJson??g.errorSimpleRouteJson,SGo={is_showing_autorouting:!0,is_showing_rats_nest:!1,is_showing_drc_errors:!1,is_showing_drc_warnings:!1,is_showing_pcb_groups:!1},fGo=({circuitJson:g,phases:A=[],isRunning:I=!1})=>{const[e,t]=gA.useState(null),[o,B]=gA.useState("output"),[C,Q]=gA.useState(!0),[i,E]=gA.useState(!1),n=gA.useRef(null),[s,r]=gA.useState(480),a=e?A.findIndex(N=>N.id===e.id&&sJI(N)===sJI(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=gA.useMemo(()=>!h||!u?null:MGo(g??[],h,w),[g,h,u,w]),m=gA.useMemo(()=>h&&w==="output"&&C?mGo(h):{lines:[],circles:[]},[h,w,C]);if(gA.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 W.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:[W.jsx(ZNI,{className:"rf-h-7 rf-w-7 rf-text-blue-500"}),W.jsx("h3",{className:"rf-text-base rf-font-medium",children:I?"Waiting for autorouting":"No autorouting captures"}),W.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=PBg(h,c),k=h.status==="running"&&I,S=!D,R=d?.connections.length,x=G?.filter(N=>N.type==="pcb_trace").length??0;return W.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:[W.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:[W.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:[W.jsx("span",{children:"Routing phases"}),W.jsx("span",{children:A.length})]}),W.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=iJI(N).length,Y=N.endSimpleRouteJson?`${K} ${K===1?"trace":"traces"} routed`:N.status==="error"?"Failed":N.status==="running"&&I?"Routing…":"No output";return W.jsxs("button",{type:"button","aria-pressed":U===c,title:`${nJI(N)} · ${Y}`,onClick:()=>t(N),className:dB("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:[W.jsx("span",{className:dB("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}),W.jsxs("span",{className:"rf-min-w-0 rf-flex-1",children:[W.jsxs("span",{className:"rf-flex rf-items-center rf-gap-1",children:[W.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:PBg(N,U),children:PBg(N,U)}),N.status==="complete"?W.jsx(jZ,{"aria-label":"Captured",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-green-600"}):N.status==="error"?W.jsx(vtg,{"aria-label":"Failed",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-red-500"}):I?W.jsx(Cf,{"aria-label":"Routing",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-animate-spin rf-text-blue-500"}):null]}),W.jsxs("span",{className:"rf-block rf-text-[11px] rf-leading-4 rf-text-gray-500",children:[wGo(N)," · ",Y]})]})]},N.id)})})]}),W.jsxs("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-flex-col",children:[W.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:[W.jsxs("h3",{className:"rf-mr-auto rf-flex rf-items-center rf-gap-2 rf-text-sm rf-font-medium",children:[p,W.jsxs("span",{className:"rf-text-xs rf-font-normal rf-text-gray-500",children:[c+1," of ",A.length]})]}),I&&W.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"}),W.jsx("div",{className:"rf-flex rf-rounded-md rf-bg-gray-100 rf-p-1","aria-label":"Phase snapshot",children:["input","output"].map(N=>W.jsx("button",{type:"button","aria-pressed":w===N,disabled:N==="input"?!y:!D,onClick:()=>B(N),className:dB("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))})]}),W.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:[W.jsxs("label",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx("input",{type:"checkbox",checked:C,disabled:w!=="output",onChange:N=>Q(N.target.checked),className:"rf-accent-blue-600"}),W.jsx("span",{"aria-hidden":"true",className:"rf-inline-block rf-h-0.5 rf-w-3",style:{backgroundColor:JBg}}),"Highlight changes (all layers)"]}),W.jsxs("span",{children:[w==="input"?"Before this phase":"After this phase"," ","· ",x," traces"]})]}),S&&W.jsx("div",{className:dB("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."}),W.jsx("div",{ref:n,className:"rf-relative rf-min-h-[360px] rf-flex-1","data-testid":"autorouting-pcb",children:G?W.jsx(_tg,{circuitJson:G,height:s,allowEditing:!1,clickToInteractEnabled:!1,initialState:SGo,debugGraphics:m}):W.jsx("div",{className:"rf-p-6 rf-text-sm rf-text-gray-500",children:"No PCB snapshot available for this capture."})}),W.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:[W.jsxs("span",{children:[R===void 0?"Input unavailable":`${R} input connections`,` · ${nJI(h)}`]}),W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4",children:[W.jsxs("button",{type:"button",disabled:!u,onClick:()=>Jk(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:[W.jsx(EtA,{className:"rf-h-3 rf-w-3"}),"Download SRJ"]}),W.jsxs("button",{type:"button","aria-expanded":i,onClick:()=>E(!i),className:"rf-flex rf-items-center rf-gap-1",children:[W.jsx(zZ,{className:dB("rf-h-3 rf-w-3",i&&"rf-rotate-90")}),"Inspect SRJ"]})]})]}),i&&W.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."})]})]})},aJI=({errorMessage:g,errorStack:A,circuitJsonErrors:I})=>{gA.useEffect(()=>{if(zF("TSCIRCUIT_TELEMETRY_DISABLED")!==!0&&g){const e=new Error(g);A&&(e.stack=A);try{CH.captureException(e)}catch{}}},[g,A]),gA.useEffect(()=>{if(zF("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{CH.captureException(t,{error_type:e.type})}catch{}}},[I])},RGo=g=>{gA.useEffect(()=>{try{F$I(g)}catch{}},[g.source,g.component,g.isWebEmbedded,g.activeTab])},rJI="0.0.3085",NGo={version:rJI},KBg={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},LBg=new Map,SmA=g=>{const A=LBg.get(g);return A?Object.fromEntries(Object.entries(A.stores).map(([I,e])=>[I,e.getState()])):{}},xGo=(g,A,I)=>{if(g===void 0)return{type:"untracked",connection:A.connect(I)};const e=LBg.get(I.name);if(e)return{type:"tracked",store:g,...e};const t={connection:A.connect(I),stores:{}};return LBg.set(I.name,t),{type:"tracked",store:g,...t}},cJI=(g,A={})=>(I,e,t)=>{const{enabled:o,anonymousActionType:B,store:C,...Q}=A;let i;try{i=(o??(KBg?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!i)return(KBg?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),g(I,e,t);const{connection:E,...n}=xGo(C,i,Q);let s=!0;t.setState=(c,h,l)=>{const D=I(c,h);if(!s)return D;const d=l===void 0?{type:B||"anonymous"}:typeof l=="string"?{type:l}:l;return C===void 0?(E?.send(d,e()),D):(E?.send({...d,type:`${C}/${d.type}`},{...SmA(Q.name),[C]:t.getState()}),D)};const r=(...c)=>{const h=s;s=!1,I(...c),s=h},a=g(t.setState,e,t);if(n.type==="untracked"?E?.init(a):(n.stores[n.store]=t,E?.init(Object.fromEntries(Object.entries(n.stores).map(([c,h])=>[c,c===n.store?a:h.getState()])))),t.dispatchFromDevtools&&typeof t.dispatch=="function"){let c=!1;const h=t.dispatch;t.dispatch=(...l)=>{(KBg?"production":void 0)!=="production"&&l[0].type==="__setState"&&!c&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),c=!0),h(...l)}}return E.subscribe(c=>{var h;switch(c.type){case"ACTION":if(typeof c.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return YBg(c.payload,l=>{if(l.type==="__setState"){if(C===void 0){r(l.state);return}Object.keys(l.state).length!==1&&console.error(`
5667
+ `,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 W.jsxs("div",{className:`relative ${A}`,ref:t,children:[W.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&&W.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:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:B,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:C,children:"Download test.ts"})]})]})},AJI=g=>g.activeSubSolver?[g,...AJI(g.activeSubSolver)]:[g],Wuo=({solver:g})=>{const A=AJI(g);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((I,e)=>W.jsxs("div",{className:"flex items-center",children:[e>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(Ouo,{solver:I})]},I.getSolverName()))})},Vuo=({solver:g,triggerRender:A,animationSpeed:I=25,renderer:e,onRendererChange:t,onAnimationSpeedChange:o,onDownloadVisualization:B,onSolverStarted:C,onSolverCompleted:Q})=>{const[i,E]=gA.useReducer(m=>!m,!1),n=gA.useRef(void 0),s=gA.useRef(null),r="solver-debugger-last-iteration",[a,c]=gA.useState(null),h=gA.useRef(null),l=gA.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 gA.useEffect(()=>()=>{d()},[]),gA.useEffect(()=>{(g.solved||g.failed)&&i&&(d(),E())},[g.solved,g.failed,i]),gA.useEffect(()=>{i&&(d(),D())},[I,i]),gA.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)}},[]),W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsxs("div",{className:"flex items-center gap-2",ref:h,children:[W.jsxs("div",{className:"flex h-9 items-center space-x-1 rounded-md border border-slate-200 bg-white p-1 shadow-sm",children:[W.jsxs("div",{className:"relative",children:[W.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"&&W.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=>W.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&&W.jsx("span",{className:"ml-auto text-xs text-slate-500",children:"✓"})]},m))})]}),W.jsxs("div",{className:"relative",children:[W.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"&&W.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:W.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"})})]}),W.jsxs("div",{className:"relative",children:[W.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"&&W.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=>W.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,W.jsx("span",{className:"ml-auto text-xs text-slate-500",children:m.description}),I===m.value&&W.jsx("span",{className:"ml-2 text-xs text-slate-500",children:"✓"})]},m.value))})]})]}),W.jsx(Wuo,{solver:g})]})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.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"}),W.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"}),W.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"}),W.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"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",g.iterations]}),g.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(g.timeToSolve/1e3).toFixed(3),"s"]}),g.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),g.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),g.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",g.error]})]})},juo=g=>g!==null&&"pipelineDef"in g&&Array.isArray(g.pipelineDef),zuo=(g,A,I)=>{const e=g.currentPipelineStageIndex;return A<e?"Completed":A===e&&g.activeSubSolver?g.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Xuo=(g,A)=>{const e=g.pipelineDef[A].solverName,t=zuo(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}},$uo=({status:g})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${A[g]}`,children:g})},AGo=({progress:g})=>{if(g===0)return null;const A=Math.round(g*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},gJI=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)},gGo=g=>Object.entries(g).map(([A,I])=>`${A}: ${gJI(I)}`).join(", "),IGo=({stats:g})=>{if(!g||Object.keys(g).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(g),I=gGo(g);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:I}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([e,t])=>W.jsxs("div",{children:[e,": ",gJI(t)]},e))})]})},FBg=g=>{if(g===null||typeof g!="object")return g;if(Array.isArray(g))return g.map(FBg);const A={};for(const[I,e]of Object.entries(g))I.startsWith("_")||(A[I]=FBg(e));return A},eGo=(g,A)=>{try{if(typeof g.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const I=FBg(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)}`)}},tGo=({expanded:g})=>W.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:W.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"})}),IJI=g=>{let A=g;for(;A.activeSubSolver;)A=A.activeSubSolver;return A},eJI=({solver:g,onStepUntilPhase:A,onDownloadInput:I,isNested:e=!1,indentLevel:t=0,triggerRender:o})=>{const[B,C]=gA.useState(new Set),Q=g.pipelineDef.map((h,l)=>Xuo(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):eGo(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=IJI(g);for(;!g.solved&&!g.failed&&(g.step(),IJI(g)===h););o?.()}},c=t*24;return W.jsxs("div",{className:e?"":"border-t border-gray-200",children:[!e&&W.jsxs("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between",children:[W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Stages"}),W.jsxs("div",{className:"flex gap-2",children:[W.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"}),W.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"})]})]}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[!e&&W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stage"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:Q.map(h=>{const l=juo(h.solverInstance),D=B.has(h.name);return W.jsxs(aC.Fragment,{children:[W.jsxs("tr",{className:`border-b border-gray-100 ${h.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:c},children:[l?W.jsx("button",{onClick:()=>i(h.name),className:"text-gray-500 hover:text-gray-700",title:D?"Collapse":"Expand",children:W.jsx(tGo,{expanded:D})}):W.jsx("span",{className:"w-4"}),W.jsx("span",{className:"text-gray-400 w-6",children:String(h.index+1).padStart(2,"0")}),W.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:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.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"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:h.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx($uo,{status:h.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:h.firstIteration!==null?h.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:h.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(AGo,{progress:h.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(h.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(IGo,{stats:h.stats})}),W.jsx("td",{className:"px-4 py-2",children:h.solverInstance?W.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:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.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"})}),W.jsx("span",{children:"Input"})]}):null})]}),l&&D&&W.jsx("tr",{children:W.jsx("td",{colSpan:8,className:"p-0",children:W.jsx(eJI,{solver:h.solverInstance,onStepUntilPhase:A,onDownloadInput:I,isNested:!0,indentLevel:t+1,triggerRender:o})})})]},h.name)})})]})})]})};function oGo({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 W.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)=>W.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)=>W.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)=>W.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)=>W.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)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${l}`))]})}var BGo=class extends aC.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}},CGo=({solver:g,createSolver:A,animationSpeed:I=25,onSolverStarted:e,onSolverCompleted:t})=>{const[o,B]=gA.useReducer(D=>D+1,0),[C]=gA.useState(()=>{if(A)return A();if(!g)throw new Error("GenericSolverDebugger requires solver or createSolver");return g}),[Q,i]=gA.useState(()=>typeof window>"u"?"vector":window.localStorage.getItem("solver-utils-renderer")==="canvas"?"canvas":"vector"),[E,n]=gA.useState(I),s=gA.useMemo(()=>{try{return C.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(D){return console.error("Visualization error:",D),{points:[],lines:[],rects:[],circles:[]}}},[C,o]),r=gA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);gA.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)}},[]),gA.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 W.jsxs("div",{children:[W.jsx(Vuo,{solver:C,triggerRender:B,animationSpeed:E,renderer:Q,onRendererChange:l,onAnimationSpeedChange:n,onDownloadVisualization:h,onSolverStarted:e,onSolverCompleted:t}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(BGo,{fallback:W.jsx(oGo,{graphics:s}),children:Q==="canvas"?W.jsx(Zuo,{graphics:s}):W.jsx(vuo,{graphics:s})}),a&&W.jsx(eJI,{solver:C,onStepUntilPhase:c,triggerRender:B})]})};const QGo=()=>{gA.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)},[])},iGo=1e3,Jk=(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)},iGo)},UBg=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"},EGo=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]},EF="https://github.com/tscircuit/tscircuit-autorouter/issues/new",tJI="https://github.com/tscircuit/copper-pour-solver/issues/new",oJI="https://github.com/tscircuit/calculate-packing/issues/new",nGo="https://github.com/tscircuit/matchpack/issues/new",BJI="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",sGo={PackSolver2:oJI,LayoutPipelineSolver:nGo,AutoroutingPipelineSolver:EF,AssignableAutoroutingPipeline2:EF,AssignableAutoroutingPipeline3:EF,AutoroutingPipeline1_OriginalUnravel:EF,AutoroutingPipelineSolver3_HgPortPointPathing:EF,AutoroutingPipelineSolver4:EF,AutoroutingPipelineSolver5:EF,AutoroutingPipelineSolver7_MultiGraph:EF,AutoroutingPipelineSolver8:EF,CopperPourPipelineSolver:tJI,SchematicTracePipelineSolver:BJI},aGo=g=>g.toLowerCase().includes("pack")?Mso:g.toLowerCase().includes("rout")?ZNI:dso,CJI=g=>{const A=sGo[g];if(A)return A;const I=g.toLowerCase();return I.includes("autorout")?EF:I.includes("schematic")&&I.includes("trace")?BJI:I.includes("copperpour")?tJI:I.includes("pack")?oJI:null},rGo=g=>`${UBg(`${g.componentName}-${g.solverName}`)}-solver-input.json`,QJI=g=>{Jk(JSON.stringify(g.solverParams,null,2),{fileName:rGo(g),mimeType:"application/json"})},cGo=({solverEvent:g})=>{const A=CJI(g.solverName);return W.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:[W.jsxs($E,{type:"button",variant:"outline",size:"sm",onClick:()=>QJI(g),children:[W.jsx(EtA,{className:"rf-w-4 rf-h-4"}),"Download"]}),A?W.jsx($E,{asChild:!0,variant:"outline",size:"sm",children:W.jsxs("a",{href:A,target:"_blank",rel:"noopener noreferrer",children:[W.jsx(EGA,{className:"rf-w-4 rf-h-4"}),"Report"]})}):W.jsxs($E,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[W.jsx(EGA,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},hGo=({solverEvent:g})=>{const A=CJI(g.solverName);return A?W.jsx($E,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:W.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:W.jsx(EGA,{className:"rf-w-4 rf-h-4"})})}):W.jsx($E,{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:W.jsx(EGA,{className:"rf-w-4 rf-h-4"})})},lGo=({solverEvents:g=[]})=>{const[A,I]=gA.useState(null);QGo();const e=gA.useMemo(()=>{const C=new Map;for(const Q of g){const i=`${Q.componentName}-${Q.solverName}`;C.set(i,Q)}return C},[g]),t=gA.useMemo(()=>Array.from(e.keys()),[e]),o=A?e.get(A):null,B=gA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const C=qqA[o.solverName];if(!C)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(qqA).join(", ")}`,classFound:!1};try{return{instance:new C(...EGo(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?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.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."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.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 W.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=aGo(Q.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(E,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:Q.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:Q.solverName})]})]})})()},C)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?B.instance?W.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[W.jsx(cGo,{solverEvent:o}),W.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:W.jsx(zR,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:W.jsx(CGo,{solver:B.instance})})})]}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),B.error&&W.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:W.jsx("p",{className:`rf-text-sm ${B.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:B.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.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:[W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[W.jsx(hGo,{solverEvent:o}),W.jsx($E,{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:()=>QJI(o),children:W.jsx(EtA,{className:"rf-w-4 rf-h-4"})})]})]}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.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)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},DGo=new Map([["custom","Custom"],["fanout","Fanout"],["single_layer_fanout","Single layer fanout"],["tscircuit_simplify","Simplify"]]),dGo=new Set(["tscircuit","default","auto","auto_local"]);function yGo(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 wGo(g){const A=g.autorouterName?.trim(),I=A?.replace(/-/g,"_"),e=I&&DGo.get(I);if(e)return e;if(I&&!dGo.has(I))return A;const t=g.solverName?.trim();if(t)return yGo(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 JBg="#fbbf24";function uGo(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 iJI(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 GGo(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 EJI(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,...GGo(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 mGo(g){const A=[],I=[],e=g.endSimpleRouteJson;if(!e)return{lines:A,circles:I};const t=new Set(iJI(g));for(const o of e.traces??[])if(t.has(o.pcb_trace_id))for(const B of EJI(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:JBg,layer:i}),Q.route_type==="via"&&I.push({center:{x:Q.x,y:Q.y},radius:Q.outer_diameter/2,stroke:JBg,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 pGo(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 kGo=new Set(["pcb_trace","pcb_via","pcb_copper_pour","pcb_ground_plane","pcb_ground_plane_region","pcb_thermal_spoke","pcb_breakout_point"]);function MGo(g,A,I){const e=I==="input"?A.startSimpleRouteJson??A.errorSimpleRouteJson:A.endSimpleRouteJson,t=g.filter(i=>!kGo.has(i.type)&&!i.type.endsWith("_error")&&!i.type.endsWith("_warning"));if(!e)return t;const o=I==="input"?e.traces??[]:uGo(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=EJI(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}_${pGo(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 PBg=(g,A)=>g.phaseName||`Phase ${g.phaseOrdinal??A+1}`,nJI=g=>g.componentDisplayName?.match(/name="([^"]+)"/)?.[1]?.replace(/^\./,"")||g.componentDisplayName||g.subcircuit_id||"Board",sJI=g=>g.startSimpleRouteJson??g.endSimpleRouteJson??g.errorSimpleRouteJson,SGo={is_showing_autorouting:!0,is_showing_rats_nest:!1,is_showing_drc_errors:!1,is_showing_drc_warnings:!1,is_showing_pcb_groups:!1},fGo=({circuitJson:g,phases:A=[],isRunning:I=!1})=>{const[e,t]=gA.useState(null),[o,B]=gA.useState("output"),[C,Q]=gA.useState(!0),[i,E]=gA.useState(!1),n=gA.useRef(null),[s,r]=gA.useState(480),a=e?A.findIndex(N=>N.id===e.id&&sJI(N)===sJI(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=gA.useMemo(()=>!h||!u?null:MGo(g??[],h,w),[g,h,u,w]),m=gA.useMemo(()=>h&&w==="output"&&C?mGo(h):{lines:[],circles:[]},[h,w,C]);if(gA.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 W.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:[W.jsx(ZNI,{className:"rf-h-7 rf-w-7 rf-text-blue-500"}),W.jsx("h3",{className:"rf-text-base rf-font-medium",children:I?"Waiting for autorouting":"No autorouting captures"}),W.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=PBg(h,c),k=h.status==="running"&&I,S=!D,R=d?.connections.length,x=G?.filter(N=>N.type==="pcb_trace").length??0;return W.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:[W.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:[W.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:[W.jsx("span",{children:"Routing phases"}),W.jsx("span",{children:A.length})]}),W.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=iJI(N).length,Y=N.endSimpleRouteJson?`${K} ${K===1?"trace":"traces"} routed`:N.status==="error"?"Failed":N.status==="running"&&I?"Routing…":"No output";return W.jsxs("button",{type:"button","aria-pressed":U===c,title:`${nJI(N)} · ${Y}`,onClick:()=>t(N),className:dB("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:[W.jsx("span",{className:dB("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}),W.jsxs("span",{className:"rf-min-w-0 rf-flex-1",children:[W.jsxs("span",{className:"rf-flex rf-items-center rf-gap-1",children:[W.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:PBg(N,U),children:PBg(N,U)}),N.status==="complete"?W.jsx(jZ,{"aria-label":"Captured",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-green-600"}):N.status==="error"?W.jsx(vtg,{"aria-label":"Failed",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-text-red-500"}):I?W.jsx(Cf,{"aria-label":"Routing",className:"rf-h-3 rf-w-3 rf-shrink-0 rf-animate-spin rf-text-blue-500"}):null]}),W.jsxs("span",{className:"rf-block rf-text-[11px] rf-leading-4 rf-text-gray-500",children:[wGo(N)," · ",Y]})]})]},N.id)})})]}),W.jsxs("div",{className:"rf-flex rf-min-w-0 rf-flex-1 rf-flex-col",children:[W.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:[W.jsxs("h3",{className:"rf-mr-auto rf-flex rf-items-center rf-gap-2 rf-text-sm rf-font-medium",children:[p,W.jsxs("span",{className:"rf-text-xs rf-font-normal rf-text-gray-500",children:[c+1," of ",A.length]})]}),I&&W.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"}),W.jsx("div",{className:"rf-flex rf-rounded-md rf-bg-gray-100 rf-p-1","aria-label":"Phase snapshot",children:["input","output"].map(N=>W.jsx("button",{type:"button","aria-pressed":w===N,disabled:N==="input"?!y:!D,onClick:()=>B(N),className:dB("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))})]}),W.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:[W.jsxs("label",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx("input",{type:"checkbox",checked:C,disabled:w!=="output",onChange:N=>Q(N.target.checked),className:"rf-accent-blue-600"}),W.jsx("span",{"aria-hidden":"true",className:"rf-inline-block rf-h-0.5 rf-w-3",style:{backgroundColor:JBg}}),"Highlight changes (all layers)"]}),W.jsxs("span",{children:[w==="input"?"Before this phase":"After this phase"," ","· ",x," traces"]})]}),S&&W.jsx("div",{className:dB("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."}),W.jsx("div",{ref:n,className:"rf-relative rf-min-h-[360px] rf-flex-1","data-testid":"autorouting-pcb",children:G?W.jsx(_tg,{circuitJson:G,height:s,allowEditing:!1,clickToInteractEnabled:!1,initialState:SGo,debugGraphics:m}):W.jsx("div",{className:"rf-p-6 rf-text-sm rf-text-gray-500",children:"No PCB snapshot available for this capture."})}),W.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:[W.jsxs("span",{children:[R===void 0?"Input unavailable":`${R} input connections`,` · ${nJI(h)}`]}),W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-4",children:[W.jsxs("button",{type:"button",disabled:!u,onClick:()=>Jk(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:[W.jsx(EtA,{className:"rf-h-3 rf-w-3"}),"Download SRJ"]}),W.jsxs("button",{type:"button","aria-expanded":i,onClick:()=>E(!i),className:"rf-flex rf-items-center rf-gap-1",children:[W.jsx(zZ,{className:dB("rf-h-3 rf-w-3",i&&"rf-rotate-90")}),"Inspect SRJ"]})]})]}),i&&W.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."})]})]})},aJI=({errorMessage:g,errorStack:A,circuitJsonErrors:I})=>{gA.useEffect(()=>{if(zF("TSCIRCUIT_TELEMETRY_DISABLED")!==!0&&g){const e=new Error(g);A&&(e.stack=A);try{CH.captureException(e)}catch{}}},[g,A]),gA.useEffect(()=>{if(zF("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{CH.captureException(t,{error_type:e.type})}catch{}}},[I])},RGo=g=>{gA.useEffect(()=>{try{F$I(g)}catch{}},[g.source,g.component,g.isWebEmbedded,g.activeTab])},rJI="0.0.3086",NGo={version:rJI},KBg={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},LBg=new Map,SmA=g=>{const A=LBg.get(g);return A?Object.fromEntries(Object.entries(A.stores).map(([I,e])=>[I,e.getState()])):{}},xGo=(g,A,I)=>{if(g===void 0)return{type:"untracked",connection:A.connect(I)};const e=LBg.get(I.name);if(e)return{type:"tracked",store:g,...e};const t={connection:A.connect(I),stores:{}};return LBg.set(I.name,t),{type:"tracked",store:g,...t}},cJI=(g,A={})=>(I,e,t)=>{const{enabled:o,anonymousActionType:B,store:C,...Q}=A;let i;try{i=(o??(KBg?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!i)return(KBg?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),g(I,e,t);const{connection:E,...n}=xGo(C,i,Q);let s=!0;t.setState=(c,h,l)=>{const D=I(c,h);if(!s)return D;const d=l===void 0?{type:B||"anonymous"}:typeof l=="string"?{type:l}:l;return C===void 0?(E?.send(d,e()),D):(E?.send({...d,type:`${C}/${d.type}`},{...SmA(Q.name),[C]:t.getState()}),D)};const r=(...c)=>{const h=s;s=!1,I(...c),s=h},a=g(t.setState,e,t);if(n.type==="untracked"?E?.init(a):(n.stores[n.store]=t,E?.init(Object.fromEntries(Object.entries(n.stores).map(([c,h])=>[c,c===n.store?a:h.getState()])))),t.dispatchFromDevtools&&typeof t.dispatch=="function"){let c=!1;const h=t.dispatch;t.dispatch=(...l)=>{(KBg?"production":void 0)!=="production"&&l[0].type==="__setState"&&!c&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),c=!0),h(...l)}}return E.subscribe(c=>{var h;switch(c.type){case"ACTION":if(typeof c.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return YBg(c.payload,l=>{if(l.type==="__setState"){if(C===void 0){r(l.state);return}Object.keys(l.state).length!==1&&console.error(`
5668
5668
  [zustand devtools middleware] Unsupported __setState action format.
5669
5669
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5670
5670
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
@@ -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:W.jsx("div",{className:"rf-relative rf-w-full",children:I==="initial"&&W.jsx(sMo,{onCancel:A,packageReleaseId:o??"",signIn:B??(()=>{}),isLoggedIn:C})})})})}),DMo=({isOpen:g,onClose:A,stage:I,setStage:e,signIn:t,isLoggedIn:o})=>{const B=nF(C=>C.circuitJson);return W.jsx(lMo,{signIn:t,isOpen:g,onClose:A,stage:I,setStage:e,circuitJson:B,isLoggedIn:o??!1})},dMo=()=>{const[g,A]=gA.useState(!1),[I,e]=gA.useState("initial");return{isOpen:g,stage:I,open:()=>A(!0),close:()=>{A(!1),e("initial")},setStage:e,OrderDialog:DMo}};async function x4I(){const g=await fetch(`${g4}/files/list`),{file_list:A}=await g.json(),I=new Map;for(const e of A){const o=await(await fetch(`${g4}/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 yMo="https://api.tscircuit.com/bug_reports/view?bug_report_id=",wMo=g=>`${yMo}${g}`,uMo=g=>{const[A,I]=gA.useState(!1),[e,t]=gA.useState(!1),[o,B]=gA.useState(null),[C,Q]=gA.useState(null),[i,E]=gA.useState([]),n=gA.useRef(null),[s,r]=gA.useState(null),[a,c]=gA.useState(0),h=g?.onLoginRequired,l=gA.useMemo(()=>nQA()?!0:typeof document>"u"?!1:document.cookie.split(";").some(u=>u.trim().startsWith("session=")),[A]);gA.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]),gA.useEffect(()=>{A&&!s&&x4I().then(u=>{c(u.size)}).catch(u=>{console.error("Failed to fetch file count",u),c(0)})},[A,s]);const D=gA.useCallback(()=>{B(null),r(null),Q(null),E([]),n.current&&(n.current.value=""),I(!0)},[]),d=gA.useCallback(()=>{I(!1)},[]),y=gA.useCallback(async()=>{t(!0),B(null),Q(null),E([]);const u=JY(),G=n.current?.value||"";try{const m=await x4I();if(m.size===0){rQ.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 q=_ instanceof FY?`HTTP ${_.response.status}`:_ instanceof Error?_.message:"Upload failed";x.push({filePath:K,message:q}),E([...x])}}Q(null);const N=wMo(S);r({bugReportUrl:N})}catch(m){if(console.error("Failed to submit bug report",m),m instanceof FY)if(m.response.status===401)if(l){const p="Your session has expired. Please sign in again to continue.";B(p),rQ.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),rQ.error(p),setTimeout(()=>{h&&(d(),h())},1e3)}else{const p=`Failed to submit bug report (${m.response.status})`;B(p),rQ.error(p)}else if(m instanceof Error)B(m.message),rQ.error(m.message);else{const p="Failed to submit bug report";B(p),rQ.error(p)}}finally{t(!1)}},[l,h]);return{BugReportDialog:gA.useMemo(()=>{const u=C?Math.round(C.current/C.total*100):0;return W.jsx(GJI,{open:A,onOpenChange:G=>{G?(B(null),r(null),Q(null),E([]),I(!0)):e||d()},children:W.jsxs(vBg,{children:[W.jsxs(qBg,{children:[W.jsx(ZBg,{children:s?"Bug Report Created":"Report Bug"}),W.jsx(OBg,{asChild:!0,children:s?W.jsxs("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:[W.jsx("p",{children:"Bug report created successfully."}),i.length>0&&W.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:[W.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)=>W.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${G.filePath}: ${G.message}`,children:[W.jsx("span",{className:"rf-font-medium rf-break-all",children:G.filePath.split("/").pop()}),W.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:G.message})]},m))]}),W.jsx("div",{children:W.jsx("a",{className:"rf-text-blue-600 hover:rf-underline",href:s.bugReportUrl,target:"_blank",rel:"noreferrer",children:"View bug report"})}),W.jsxs("p",{children:["Please share this link privately with tscircuit staff so we can help debug. Join the",W.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"}),"."]})]}):W.jsx("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:C?W.jsxs("div",{className:"rf-space-y-2 rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-flex rf-justify-between rf-text-xs",children:[W.jsx("span",{children:"Uploading files..."}),W.jsxs("span",{children:[C.current,"/",C.total]})]}),W.jsx("div",{className:"rf-w-full rf-h-2 rf-bg-gray-200 rf-rounded-full rf-overflow-hidden",children:W.jsx("div",{className:"rf-h-full rf-bg-blue-500 rf-transition-all rf-duration-150",style:{width:`${u}%`}})}),W.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&&W.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)=>W.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${G.filePath}: ${G.message}`,children:[W.jsx("span",{className:"rf-font-medium rf-break-all",children:G.filePath.split("/").pop()}),W.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:G.message})]},m))})]}):W.jsxs(W.Fragment,{children:[W.jsxs("p",{children:["Reporting a bug will upload your entire project",a>0?` (${a} file${a===1?"":"s"})`:""," ","to tscircuit support."]}),W.jsxs("div",{className:"rf-space-y-2",children:[W.jsx("label",{htmlFor:"bug-description",className:"rf-block rf-font-medium",children:"Description (optional)"}),W.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})]}),W.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",W.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&&W.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&&W.jsx("p",{className:"rf-text-red-600",children:o})]})})})]}),W.jsx(TBg,{children:s?W.jsx("button",{type:"button",className:VZ(),onClick:()=>{d()},children:"Close"}):W.jsxs(W.Fragment,{children:[W.jsx(WBg,{disabled:e,onClick:()=>{e||d()},children:"Cancel"}),!l&&h?W.jsx("button",{type:"button",className:VZ(),onClick:G=>{G.preventDefault(),d(),h()},children:"Sign In"}):W.jsx("button",{type:"button",className:Ff(VZ(),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 GMo({open:g,onOpenChange:A,onExport:I}){const[e,t]=gA.useState(!1),o=()=>{I({includeSilkscreen:e}),A(!1)},B=()=>{A(!1)};return W.jsx(pO,{open:g,onOpenChange:A,children:W.jsxs(Mb,{children:[W.jsxs(Sb,{children:[W.jsx(fb,{children:"LightBurn Export Options"}),W.jsx(MO,{children:"Configure export settings for PCB laser ablation with LightBurn"})]}),W.jsx("div",{className:"rf-flex rf-flex-col rf-gap-4 rf-py-4",children:W.jsxs("div",{className:"rf-flex rf-items-center rf-space-x-2",children:[W.jsx(vtA,{id:"includeSilkscreen",checked:e,onCheckedChange:C=>t(C===!0)}),W.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"})]})}),W.jsxs(kO,{children:[W.jsx($E,{variant:"outline",onClick:B,children:"Cancel"}),W.jsx($E,{onClick:o,children:"Export"})]})]})})}const mMo=/#(\d+)/,pMo=g=>{const A=g.match(mMo);if(!A)return null;const I=Number.parseInt(A[1],10);return Number.isFinite(I)?I:null},kMo=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},MMo=g=>{if(!g)return null;let A=null,I=-1,e=-1;for(const[t,o]of Object.entries(g)){const B=pMo(t),C=kMo(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 SMo=Object.defineProperty,fMo=(g,A)=>SMo(g,"name",{value:A,configurable:!0});function xCg(g,[A,I]){return Math.min(I,Math.max(A,g))}fMo(xCg,"clamp");var RMo=Object.defineProperty,NMo=(g,A)=>RMo(g,"name",{value:A,configurable:!0}),F4I=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"}),xMo=gA.forwardRef(NMo(function(A,I){return W.jsx(iE.span,{...A,ref:I,style:{...F4I,...A.style}})},"VisuallyHidden")),FMo=Object.defineProperty,vE=(g,A)=>FMo(g,"name",{value:A,configurable:!0}),U4I={ItemAligned:"item-aligned",Popper:"popper"},UMo={RTL:"rtl"},JMo=[" ","Enter","ArrowUp","ArrowDown"],PMo=[" ","Enter"],fO="Select",[zmA,XmA,KMo]=aCA(fO),[Fb,TgB]=dM(fO,[KMo,IO]),FCg=IO(),[LMo,mL]=Fb(fO),[YMo,_Mo]=Fb(fO);function J4I(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=FCg(A),[l,D]=gA.useState(null),[d,y]=gA.useState(null),[w,u]=gA.useState(!1),G=tV(i),[m,p]=NN({prop:e,defaultProp:t??!1,onChange:o,caller:fO}),[k,S]=NN({prop:B,defaultProp:C,onChange:Q,caller:fO}),R=gA.useRef(null),x=gA.useRef(!1),[N,U]=gA.useState(null),K=vE(QA=>{U({value:QA,hasConsumerStoppedPropagation:x.current}),S(QA)},"handleUserSelect"),Y=gA.useRef(k);gA.useEffect(()=>{const QA=a?l?.ownerDocument.getElementById(a):l?.form;if(QA instanceof HTMLFormElement){const sA=vE(()=>S(Y.current),"reset");return QA.addEventListener("reset",sA),()=>QA.removeEventListener("reset",sA)}},[a,l,S]);const _=l?!!a||!!l.closest("form"):!0,[q,j]=gA.useState(new Set),Z=wM(),O=Array.from(q).map(QA=>QA.props.value).join(";"),AA=gA.useCallback(QA=>{j(sA=>new Set(sA).add(QA))},[]),tA=gA.useCallback(QA=>{j(sA=>{const dA=new Set(sA);return dA.delete(QA),dA})},[]),eA={required:r,trigger:l,onTriggerChange:D,valueNode:d,onValueNodeChange:y,valueNodeHasChildren:w,onValueNodeHasChildrenChange:u,contentId:Z,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:q,nativeSelectKey:O,isFormControl:_};return W.jsx(pGA,{...h,children:W.jsx(LMo,{scope:A,...eA,children:W.jsx(zmA.Provider,{scope:A,children:W.jsx(YMo,{scope:A,onNativeOptionAdd:AA,onNativeOptionRemove:tA,children:j4I(c)?c(eA):I})})})})}vE(J4I,"SelectProvider");var bMo=vE(g=>{const{__scopeSelect:A,children:I,...e}=g;return W.jsx(J4I,{__scopeSelect:A,...e,internal_do_not_use_render:({isFormControl:t})=>W.jsxs(W.Fragment,{children:[I,t?W.jsx(ESo,{__scopeSelect:A}):null]})})},"Select"),HMo="SelectTrigger",P4I=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,disabled:t=!1,...o}=A,B=FCg(e),C=mL(HMo,e),Q=C.disabled||t,i=$i(I,C.onTriggerChange),E=XmA(e),n=gA.useRef("touch"),[s,r,a]=PCg(h=>{const l=E().filter(y=>!y.disabled),D=l.find(y=>y.value===C.value),d=KCg(l,h,D);d!==void 0&&C.onUserSelect(d.value)}),c=vE(h=>{Q||(C.onOpenChange(!0),a()),h&&(C.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})},"handleOpen");return W.jsx(log,{asChild:!0,...B,children:W.jsx(iE.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":$tA(C.value)?"":void 0,...o,ref:i,onClick:_o(o.onClick,h=>{h.currentTarget.focus(),n.current!=="mouse"&&c(h)}),onPointerDown:_o(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:_o(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===" ")&&JMo.includes(h.key)&&(c(),h.preventDefault())})})})},"SelectTrigger")),vMo="SelectValue",qMo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,className:t,style:o,children:B,placeholder:C="",...Q}=A,i=mL(vMo,e),{onValueNodeHasChildrenChange:E}=i,n=B!==void 0,s=$i(I,i.onValueNodeChange);Eh(()=>{E(n)},[E,n]);const r=$tA(i.value);return W.jsx(iE.span,{...Q,asChild:r?!1:Q.asChild,ref:s,style:{pointerEvents:"none"},children:W.jsx(gA.Fragment,{children:r?C:B},r?"placeholder":"value")})},"SelectValue")),TMo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,children:t,...o}=A;return W.jsx(iE.span,{"aria-hidden":!0,...o,ref:I,children:t||"▼"})},"SelectIcon")),ZMo="SelectPortal",[OMo,WMo]=Fb(ZMo,{forceMount:void 0}),VMo=vE(g=>{const{__scopeSelect:A,forceMount:I,...e}=g;return W.jsx(OMo,{scope:g.__scopeSelect,forceMount:I,children:W.jsx(dog,{asChild:!0,...e})})},"SelectPortal"),Ub="SelectContent",K4I=gA.forwardRef(vE(function(A,I){const e=WMo(Ub,A.__scopeSelect),{forceMount:t=e.forceMount,...o}=A,B=mL(Ub,A.__scopeSelect),[C,Q]=gA.useState();return Eh(()=>{Q(new DocumentFragment)},[]),W.jsx(xf,{present:t||B.open,children:({present:i})=>i?W.jsx(XMo,{...o,ref:I}):W.jsx(jMo,{...o,fragment:C})})},"SelectContent")),jMo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,children:t,fragment:o}=A;return o?RN.createPortal(W.jsx(L4I,{scope:e,children:W.jsx(zmA.Slot,{scope:e,children:W.jsx("div",{ref:I,children:t})})}),o):null},"SelectContentFragment")),tN=10,[L4I,Jb]=Fb(Ub),zMo=fN("SelectContent.RemoveScroll"),XMo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e}=A,{position:t=U4I.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=mL(Ub,e),[y,w]=gA.useState(null),[u,G]=gA.useState(null),m=$i(I,w),[p,k]=gA.useState(null),[S,R]=gA.useState(null),x=XmA(e),[N,U]=gA.useState(!1),K=gA.useRef(!1),Y=gA.useRef(!1),_=gA.useRef(!1);gA.useEffect(()=>{if(y)return wog(y)},[y]),ntA();const q=gA.useCallback(hA=>{const[nA,...aA]=x().map(rA=>rA.ref.current),[SA]=aA.slice(-1),xA=document.activeElement;for(const rA of hA)if(rA===xA||(rA?.scrollIntoView({block:"nearest"}),rA===nA&&u&&(u.scrollTop=0),rA===SA&&u&&(u.scrollTop=u.scrollHeight),rA?.focus(),document.activeElement!==xA))return},[x,u]),j=gA.useCallback(()=>q([p,y]),[q,p,y]);gA.useEffect(()=>{N&&j()},[N,j]);const{onOpenChange:Z,triggerPointerDownPosRef:O}=d;gA.useEffect(()=>{if(y){let hA={x:0,y:0};const nA=vE(SA=>{hA={x:Math.abs(Math.round(SA.pageX)-(O.current?.x??0)),y:Math.abs(Math.round(SA.pageY)-(O.current?.y??0))}},"handlePointerMove"),aA=vE(SA=>{hA.x<=10&&hA.y<=10?SA.preventDefault():SA.composedPath().includes(y)||Z(!1),document.removeEventListener("pointermove",nA),O.current=null},"handlePointerUp");return O.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,Z,O]),gA.useEffect(()=>{const hA=vE(()=>Z(!1),"close");return window.addEventListener("blur",hA),window.addEventListener("resize",hA),()=>{window.removeEventListener("blur",hA),window.removeEventListener("resize",hA)}},[Z]);const[AA,tA]=PCg(hA=>{const nA=x().filter(xA=>!xA.disabled),aA=nA.find(xA=>xA.ref.current===document.activeElement),SA=KCg(nA,hA,aA);SA&&setTimeout(()=>SA.ref.current?.focus())}),eA=gA.useCallback((hA,nA,aA)=>{const SA=!Y.current;SA&&(Y.current=!0);const xA=!K.current&&!aA;d.value!==void 0&&d.value===nA||xA?(k(hA),xA&&(K.current=!0)):SA&&k(hA)},[d.value]),QA=gA.useCallback(()=>y?.focus(),[y]),sA=gA.useCallback((hA,nA,aA)=>{if(!hA)return;const SA=!_.current;SA&&(_.current=!0);const xA=!K.current&&!aA;(d.value!==void 0&&d.value===nA||xA||SA)&&R(hA)},[d.value]),dA=t===U4I.Popper?Y4I:$Mo,CA=dA===Y4I?{side:Q,sideOffset:i,align:E,alignOffset:n,arrowPadding:s,collisionBoundary:r,collisionPadding:a,sticky:c,hideWhenDetached:h,avoidCollisions:l}:{};return W.jsx(L4I,{scope:e,content:y,viewport:u,onViewportChange:G,itemRefCallback:eA,selectedItem:p,onItemLeave:QA,itemTextRefCallback:sA,focusSelectedItem:j,selectedItemText:S,position:t,isPositioned:N,searchRef:AA,children:W.jsx(UGA,{as:zMo,allowPinchZoom:!0,children:W.jsx(Xtg,{asChild:!0,trapped:d.open,onMountAutoFocus:hA=>{hA.preventDefault()},onUnmountAutoFocus:_o(o,hA=>{d.trigger?.focus({preventScroll:!0}),hA.preventDefault()}),children:W.jsx(sGA,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:B,onPointerDownOutside:C,onFocusOutside:hA=>hA.preventDefault(),onDismiss:()=>d.onOpenChange(!1),children:W.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:_o(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(xA=>!xA.disabled).map(xA=>xA.ref.current);if(["ArrowUp","End"].includes(hA.key)&&(SA=SA.slice().reverse()),["ArrowUp","ArrowDown"].includes(hA.key)){const xA=hA.target,rA=SA.indexOf(xA);SA=SA.slice(rA+1)}setTimeout(()=>q(SA)),hA.preventDefault()}})})})})})})},"SelectContentImpl")),$Mo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,onPlaced:t,...o}=A,B=mL(Ub,e),C=Jb(Ub,e),[Q,i]=gA.useState(null),[E,n]=gA.useState(null),s=$i(I,n),r=XmA(e),a=gA.useRef(!1),c=gA.useRef(!0),{viewport:h,selectedItem:l,selectedItemText:D,focusSelectedItem:d}=C,y=gA.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!==UMo.RTL){const aA=S.left-p.left,SA=k.left-aA,xA=m.left-SA,rA=m.width+xA,NA=Math.max(rA,p.width),RA=window.innerWidth-tN,UA=xCg(SA,[tN,Math.max(tN,RA-NA)]);Q.style.minWidth=rA+"px",Q.style.left=UA+"px"}else{const aA=p.right-S.right,SA=window.innerWidth-k.right-aA,xA=window.innerWidth-m.right-SA,rA=m.width+xA,NA=Math.max(rA,p.width),RA=window.innerWidth-tN,UA=xCg(SA,[tN,Math.max(tN,RA-NA)]);Q.style.minWidth=rA+"px",Q.style.right=UA+"px"}const R=r(),x=window.innerHeight-tN*2,N=h.scrollHeight,U=window.getComputedStyle(E),K=parseInt(U.borderTopWidth,10),Y=parseInt(U.paddingTop,10),_=parseInt(U.borderBottomWidth,10),q=parseInt(U.paddingBottom,10),j=K+Y+N+q+_,Z=Math.min(l.offsetHeight*5,j),O=window.getComputedStyle(h),AA=parseInt(O.paddingTop,10),tA=parseInt(O.paddingBottom,10),eA=m.top+m.height/2-tN,QA=x-eA,sA=l.offsetHeight/2,dA=l.offsetTop+sA,CA=K+Y+dA,hA=j-CA;if(CA<=eA){const aA=R.length>0&&l===R[R.length-1].ref.current;Q.style.bottom="0px";const SA=E.clientHeight-h.offsetTop-h.offsetHeight,xA=Math.max(QA,sA+(aA?tA:0)+SA+_),rA=CA+xA;Q.style.height=rA+"px"}else{const aA=R.length>0&&l===R[0].ref.current;Q.style.top="0px";const xA=Math.max(eA,K+h.offsetTop+(aA?AA:0)+sA)+hA;Q.style.height=xA+"px",h.scrollTop=CA-eA+h.offsetTop}Q.style.margin=`${tN}px 0`,Q.style.minHeight=Z+"px",Q.style.maxHeight=x+"px",t?.(),requestAnimationFrame(()=>a.current=!0)}},[r,B.trigger,B.valueNode,Q,E,h,l,D,B.dir,t]);Eh(()=>y(),[y]);const[w,u]=gA.useState();Eh(()=>{E&&u(window.getComputedStyle(E).zIndex)},[E]);const G=gA.useCallback(m=>{m&&c.current===!0&&(y(),d?.(),c.current=!1)},[y,d]);return W.jsx(ASo,{scope:e,contentWrapper:Q,shouldExpandOnScrollRef:a,onScrollButtonChange:G,children:W.jsx("div",{ref:i,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:W.jsx(iE.div,{...o,ref:s,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})},"SelectItemAlignedPosition")),Y4I=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,align:t="start",collisionPadding:o=tN,...B}=A,C=FCg(e);return W.jsx(Dog,{...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")),[ASo,UCg]=Fb(Ub,{}),_4I="SelectViewport",gSo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,nonce:t,...o}=A,B=Jb(_4I,e),C=UCg(_4I,e),Q=$i(I,B.onViewportChange),i=gA.useRef(0);return W.jsxs(W.Fragment,{children:[W.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}),W.jsx(zmA.Slot,{scope:e,children:W.jsx(iE.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:Q,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:_o(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-tN*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")),ISo="SelectGroup",[ZgB,eSo]=Fb(ISo),tSo="SelectLabel",b4I=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,...t}=A,o=eSo(tSo,e);return W.jsx(iE.div,{id:o.id,...t,ref:I})},"SelectLabel")),JCg="SelectItem",[oSo,H4I]=Fb(JCg),v4I=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,value:t,disabled:o=!1,textValue:B,...C}=A,Q=mL(JCg,e),i=Jb(JCg,e),E=Q.value===t,[n,s]=gA.useState(B??""),[r,a]=gA.useState(!1),c=uM(y=>i.itemRefCallback?.(y,t,o)),h=$i(I,c),l=wM(),D=gA.useRef("touch");function d(y){Q.hasConsumerStoppedPropagationRef.current=y.isPropagationStopped(),Q.onUserSelect(t),Q.onOpenChange(!1)}return vE(d,"handleSelect"),W.jsx(oSo,{scope:e,value:t,disabled:o,textId:l,isSelected:E,onItemTextChange:gA.useCallback(y=>{s(w=>w||(y?.textContent??"").trim())},[]),children:W.jsx(zmA.ItemSlot,{scope:e,value:t,disabled:o,textValue:n,children:W.jsx(iE.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:_o(C.onFocus,()=>a(!0)),onBlur:_o(C.onBlur,()=>a(!1)),onClick:_o(C.onClick,y=>{o||D.current!=="mouse"&&d(y)}),onPointerUp:_o(C.onPointerUp,y=>{o||D.current==="mouse"&&d(y)}),onPointerDown:_o(C.onPointerDown,y=>{D.current=y.pointerType}),onPointerMove:_o(C.onPointerMove,y=>{D.current=y.pointerType,o?i.onItemLeave?.():D.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:_o(C.onPointerLeave,y=>{y.currentTarget===document.activeElement&&i.onItemLeave?.()}),onKeyDown:_o(C.onKeyDown,y=>{o||y.target!==y.currentTarget||i.searchRef?.current!==""&&y.key===" "||(PMo.includes(y.key)&&d(y),y.key===" "&&y.preventDefault())})})})})},"SelectItem")),$mA="SelectItemText",BSo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,className:t,style:o,...B}=A,C=mL($mA,e),Q=Jb($mA,e),i=H4I($mA,e),E=_Mo($mA,e),[n,s]=gA.useState(null),r=uM(d=>Q.itemTextRefCallback?.(d,i.value,i.disabled)),a=$i(I,s,i.onItemTextChange,r),c=n?.textContent,h=gA.useMemo(()=>W.jsx("option",{value:i.value,disabled:i.disabled,children:c},i.value),[i.disabled,i.value,c]),{onNativeOptionAdd:l,onNativeOptionRemove:D}=E;return Eh(()=>(l(h),()=>D(h)),[l,D,h]),W.jsxs(W.Fragment,{children:[W.jsx(iE.span,{id:i.textId,...B,ref:a}),i.isSelected&&C.valueNode&&!C.valueNodeHasChildren&&!$tA(C.value)?RN.createPortal(B.children,C.valueNode):null]})},"SelectItemText")),CSo="SelectItemIndicator",QSo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,...t}=A;return H4I(CSo,e).isSelected?W.jsx(iE.span,{"aria-hidden":!0,...t,ref:I}):null},"SelectItemIndicator")),q4I="SelectScrollUpButton",T4I=gA.forwardRef(vE(function(A,I){const e=Jb(q4I,A.__scopeSelect),t=UCg(q4I,A.__scopeSelect),[o,B]=gA.useState(!1),C=$i(I,t.onScrollButtonChange);return Eh(()=>{if(e.viewport&&e.isPositioned){let Q=function(){const E=i.scrollTop>0;B(E)};vE(Q,"handleScroll");const i=e.viewport;return Q(),i.addEventListener("scroll",Q),()=>i.removeEventListener("scroll",Q)}},[e.viewport,e.isPositioned]),o?W.jsx(W4I,{...A,ref:C,onAutoScroll:()=>{const{viewport:Q,selectedItem:i}=e;Q&&i&&(Q.scrollTop=Q.scrollTop-i.offsetHeight)}}):null},"SelectScrollUpButton")),Z4I="SelectScrollDownButton",O4I=gA.forwardRef(vE(function(A,I){const e=Jb(Z4I,A.__scopeSelect),t=UCg(Z4I,A.__scopeSelect),[o,B]=gA.useState(!1),C=$i(I,t.onScrollButtonChange);return Eh(()=>{if(e.viewport&&e.isPositioned){let Q=function(){const E=i.scrollHeight-i.clientHeight,n=Math.ceil(i.scrollTop)<E;B(n)};vE(Q,"handleScroll");const i=e.viewport;return Q(),i.addEventListener("scroll",Q),()=>i.removeEventListener("scroll",Q)}},[e.viewport,e.isPositioned]),o?W.jsx(W4I,{...A,ref:C,onAutoScroll:()=>{const{viewport:Q,selectedItem:i}=e;Q&&i&&(Q.scrollTop=Q.scrollTop+i.offsetHeight)}}):null},"SelectScrollDownButton")),W4I=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,onAutoScroll:t,...o}=A,B=Jb("SelectScrollButton",e),C=gA.useRef(null),Q=XmA(e),i=gA.useCallback(()=>{C.current!==null&&(window.clearInterval(C.current),C.current=null)},[]);return gA.useEffect(()=>()=>i(),[i]),Eh(()=>{Q().find(n=>n.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[Q]),W.jsx(iE.div,{"aria-hidden":!0,...o,ref:I,style:{flexShrink:0,...o.style},onPointerDown:_o(o.onPointerDown,()=>{C.current===null&&(C.current=window.setInterval(t,50))}),onPointerMove:_o(o.onPointerMove,()=>{B.onItemLeave?.(),C.current===null&&(C.current=window.setInterval(t,50))}),onPointerLeave:_o(o.onPointerLeave,()=>{i()})})},"SelectScrollButtonImpl")),V4I=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,...t}=A;return W.jsx(iE.div,{"aria-hidden":!0,...t,ref:I})},"SelectSeparator")),iSo="SelectBubbleInput",ESo=gA.forwardRef(vE(function({__scopeSelect:A,...I},e){const t=mL(iSo,A),{value:o,onValueChange:B,required:C,disabled:Q,name:i,autoComplete:E,form:n,userSelection:s}=t,{nativeOptions:r,nativeSelectKey:a}=t,c=gA.useRef(null),h=$i(e,c),l=o??"",D=gA.useRef(l),d=gA.useRef(s),y=gA.useRef(!1),w=Array.from(r).some(u=>(u.props.value??"")==="");return gA.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]),W.jsxs(iE.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:{...F4I,...I.style},ref:h,defaultValue:l,children:[$tA(o)&&!w?W.jsx("option",{value:""}):null,Array.from(r)]},a)},"SelectBubbleInput"));function j4I(g){return typeof g=="function"}vE(j4I,"isFunction");function $tA(g){return g===""||g===void 0}vE($tA,"shouldShowPlaceholder");function PCg(g){const A=uM(g),I=gA.useRef(""),e=gA.useRef(0),t=gA.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))}vE(Q,"updateSearch"),Q(C)},[A]),o=gA.useCallback(()=>{I.current="",window.clearTimeout(e.current)},[]);return gA.useEffect(()=>()=>window.clearTimeout(e.current),[]),[I,t,o]}vE(PCg,"useTypeaheadSearch");function KCg(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=z4I(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}vE(KCg,"findNextItem");function z4I(g,A){return g.map((I,e)=>g[(A+e)%g.length])}vE(z4I,"wrapArray");const nSo=bMo,sSo=qMo,X4I=gA.forwardRef(({className:g,children:A,...I},e)=>W.jsxs(P4I,{ref:e,className:dB("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,W.jsx(TMo,{asChild:!0,children:W.jsx(nGA,{className:"rf-h-4 rf-w-4 rf-opacity-50"})})]}));X4I.displayName=P4I.displayName;const $4I=gA.forwardRef(({className:g,...A},I)=>W.jsx(T4I,{ref:I,className:dB("rf-flex rf-cursor-default rf-items-center rf-justify-center rf-py-1",g),...A,children:W.jsx(yso,{className:"rf-h-4 rf-w-4"})}));$4I.displayName=T4I.displayName;const API=gA.forwardRef(({className:g,...A},I)=>W.jsx(O4I,{ref:I,className:dB("rf-flex rf-cursor-default rf-items-center rf-justify-center rf-py-1",g),...A,children:W.jsx(nGA,{className:"rf-h-4 rf-w-4"})}));API.displayName=O4I.displayName;const gPI=gA.forwardRef(({className:g,children:A,position:I="popper",...e},t)=>W.jsx(VMo,{children:W.jsxs(K4I,{ref:t,className:dB("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:[W.jsx($4I,{}),W.jsx(gSo,{className:dB("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}),W.jsx(API,{})]})}));gPI.displayName=K4I.displayName;const aSo=gA.forwardRef(({className:g,...A},I)=>W.jsx(b4I,{ref:I,className:dB("rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-font-semibold",g),...A}));aSo.displayName=b4I.displayName;const IPI=gA.forwardRef(({className:g,children:A,...I},e)=>W.jsxs(v4I,{ref:e,className:dB("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:[W.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:W.jsx(QSo,{children:W.jsx(jZ,{className:"rf-h-4 rf-w-4"})})}),W.jsx(BSo,{children:A})]}));IPI.displayName=v4I.displayName;const rSo=gA.forwardRef(({className:g,...A},I)=>W.jsx(V4I,{ref:I,className:dB("-rf-mx-1 rf-my-1 rf-h-px rf-bg-muted",g),...A}));rSo.displayName=V4I.displayName;const ePI="Component Box (3MF)",LCg=g=>`${g.toFixed(1)} mm`;function cSo({open:g,onOpenChange:A,circuitJson:I,projectName:e}){MBg();const[t,o]=gA.useState(""),[B,C]=gA.useState(null),[Q,i]=gA.useState(null),[E,n]=gA.useState(!1),[s,r]=gA.useState(null);gA.useEffect(()=>()=>{Q&&URL.revokeObjectURL(Q)},[Q]),gA.useEffect(()=>{if(!g||t!==ePI)return;let c=!1;return n(!0),C(null),r(null),Fpo(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 W.jsx(pO,{open:g,onOpenChange:a,children:W.jsxs(Mb,{className:"rf-max-h-[90vh] rf-max-w-3xl rf-overflow-y-auto",children:[W.jsxs(Sb,{children:[W.jsx(fb,{children:"Export Accessory"}),W.jsx(MO,{children:"Generate a printable accessory from the components in this circuit."})]}),W.jsxs("div",{className:"rf-grid rf-gap-5 md:rf-grid-cols-[220px_1fr]",children:[W.jsxs("div",{className:"rf-space-y-2",children:[W.jsx("label",{htmlFor:"accessory-select",className:"rf-text-sm rf-font-medium",children:"Accessory"}),W.jsxs(nSo,{value:t,onValueChange:c=>o(c),children:[W.jsx(X4I,{id:"accessory-select",children:W.jsx(sSo,{placeholder:"Choose an accessory"})}),W.jsx(gPI,{children:W.jsx(IPI,{value:ePI,children:"Component Box"})})]}),W.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."})]}),W.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:[W.jsxs("div",{className:"rf-flex rf-min-h-56 rf-items-center rf-justify-center",children:[!t&&W.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:[W.jsx(xso,{className:"rf-h-10 rf-w-10 rf-stroke-1"}),W.jsx("p",{className:"rf-text-sm",children:"Choose an accessory to generate its preview."})]}),E&&W.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:[W.jsx(Cf,{className:"rf-h-8 rf-w-8 rf-animate-spin"}),W.jsx("p",{className:"rf-text-sm",children:"Generating component box…"})]}),s&&!E&&W.jsxs("div",{className:"rf-p-8 rf-text-center",children:[W.jsx("p",{className:"rf-text-sm rf-font-medium rf-text-red-600",children:"Could not generate the preview"}),W.jsx("p",{className:"rf-mt-1 rf-text-xs rf-text-red-500",children:s})]}),Q&&B&&!E&&W.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&&W.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:[W.jsxs("span",{children:[B.compartments.length," compartments"]}),W.jsxs("span",{children:[LCg(B.dimensions.width)," ×"," ",LCg(B.dimensions.depth)," ×"," ",LCg(B.dimensions.height)]})]})]})]}),W.jsxs(kO,{children:[W.jsx($E,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),W.jsxs($E,{disabled:!B||E,onClick:()=>{B&&jJI({generatedBox:B,projectName:e})},children:[W.jsx(EtA,{}),"Download 3MF"]})]})]})})}const hSo=g=>{const A=_Bg(aA=>aA.lastRunEvalVersion),I=nF(aA=>aA.currentMainComponentPath),[e,t]=gA.useState(null),[o,B]=gA.useState(!1),[C,Q]=gA.useState(!0),[i,E]=gA.useState(!1),[n,s]=gA.useState(null),[r,a]=gA.useState(null),[c,h]=gA.useState(!1),[l,D]=gA.useState(null),[d,y]=gA.useState(null),[w,u]=gA.useState(!1),[G,m]=gA.useState(!1),[p,k]=gA.useState(!1),[S,R]=gA.useState(!1),[x,N]=gA.useState(null),U=dMo(),K=nF(aA=>aA.pushEvent),Y=nF(aA=>aA.recentEvents),_=gA.useMemo(()=>Date.now(),[]);_Go(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))}}),gA.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"),xA=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))),xA&&(E(!1),s(null),D("Snippet saved successfully."),u(!1))},[Y,i]);const q=async()=>{E(!0),s(Date.now()),D(null),u(!1),await K({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:e})},Z=nF(aA=>aA.circuitJson)??g.circuitJson,O=gA.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]),[AA,tA]=gA.useState(!1),[eA,QA]=gA.useState(!1),{BugReportDialog:sA,openBugReportDialog:dA}=uMo({onLoginRequired:g.onLoginRequired}),CA=async aA=>{x&&(await zJI({circuitJson:x.circuitJson,projectName:x.projectName,options:aA}),N(null))},hA=gA.useMemo(()=>MMo(g.autoroutingLog),[g.autoroutingLog]),nA=aA=>{if(!Z){rQ.error("No Circuit JSON to export");return}const SA=hA?.value.simpleRouteJson;if(aA==="LightBurn"){N({circuitJson:Z,projectName:O}),k(!0);return}qpo({exportName:aA,circuitJson:Z,simpleRouteJson:SA,projectName:O})};return W.jsxs(W.Fragment,{children:[W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1 rf-flex-shrink-0",children:[W.jsxs(HGA,{children:[W.jsx(vGA,{asChild:!0,children:W.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"File"})}),W.jsxs(ytA,{className:"rf-z-[101]",children:[!g.isWebEmbedded&&W.jsxs(W.Fragment,{children:[W.jsx(s0,{className:"rf-text-xs",onSelect:q,disabled:i,children:i?"Saving...":"Push"}),parseInt(window.location.port)>5e3&&W.jsx(s0,{className:"rf-text-xs",onSelect:()=>{U.open()},children:"Order"}),W.jsx(s0,{className:"rf-text-xs",onSelect:()=>tA(!0),disabled:i,children:"Import"}),W.jsx(s0,{className:"rf-text-xs",onSelect:()=>{if(!nQA()){rQ.error("Requires tscircuit token");return}QA(!0)},children:"AI Review"})]}),!g.isWebEmbedded&&g.onLoginRequired&&W.jsx(s0,{className:"rf-text-xs",onSelect:()=>{g.onLoginRequired?.()},children:"Sign In"}),!g.isWebEmbedded&&W.jsxs(dtA,{children:[W.jsx(iO,{className:"rf-text-xs",children:"Report Bug"}),W.jsx(DtA,{children:W.jsxs(EO,{children:[W.jsx(s0,{className:"rf-text-xs",onSelect:()=>{dA()},children:"Report Entire Circuit"}),W.jsx(s0,{className:"rf-text-xs",disabled:!hA||!g.onReportAutoroutingLog,onSelect:()=>{!hA||!g.onReportAutoroutingLog||g.onReportAutoroutingLog(hA.key,{simpleRouteJson:hA.value.simpleRouteJson})},children:"Report Autorouter Bug"})]})})]}),W.jsxs(dtA,{children:[W.jsx(iO,{className:"rf-text-xs",disabled:G,children:G?"Exporting...":"Export"}),W.jsx(DtA,{children:W.jsx(EO,{children:vpo.map((aA,SA)=>W.jsx(s0,{onSelect:()=>nA(aA.name),disabled:G||aA.name==="Simple Route JSON"&&!hA,children:W.jsx("span",{className:"rf-text-xs",children:aA.name})},SA))})})]}),W.jsx(s0,{className:"rf-text-xs",disabled:G,onSelect:()=>{if(!Z){rQ.error("No Circuit JSON to export");return}R(!0)},children:"Export Accessory…"}),!g.isWebEmbedded&&W.jsxs(dtA,{children:[W.jsx(iO,{className:"rf-text-xs",children:"Advanced"}),W.jsx(DtA,{children:W.jsxs(EO,{children:[W.jsx(s0,{className:"rf-flex rf-items-center rf-gap-2",children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(vtA,{id:"load-latest-eval",checked:g.shouldLoadLatestEval,onCheckedChange:aA=>{g.onChangeShouldLoadLatestEval?.(aA===!0)}}),W.jsx("label",{htmlFor:"load-latest-eval",className:"rf-text-xs rf-cursor-pointer",children:"Force Latest @tscircuit/eval"})]})}),A&&W.jsx(s0,{className:"rf-flex rf-items-center rf-gap-2",children:W.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:W.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/eval@",A]})})}),W.jsx(s0,{className:"rf-flex rf-items-center rf-gap-2",children:W.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:W.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/runframe@",NGo.version]})})}),W.jsx(s0,{className:"rf-flex rf-items-center rf-gap-2",onClick:()=>{window.open("/api/admin","_blank")},children:W.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:W.jsx("span",{className:"rf-text-xs",children:"CLI Admin Panel"})})})]})})]})]}),W.jsx(GJI,{open:w,onOpenChange:u,children:W.jsxs(vBg,{children:[W.jsxs(qBg,{children:[W.jsx(ZBg,{children:"Error Saving Snippet"}),W.jsx(OBg,{children:d})]}),W.jsx(TBg,{children:W.jsx(WBg,{onClick:()=>u(!1),children:"Dismiss"})})]})}),W.jsx(YGo,{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})]}),W.jsxs(HGA,{children:[W.jsx(vGA,{asChild:!0,children:W.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"View"})}),W.jsx(ytA,{className:"rf-z-[101]",children:W.jsxs(dtA,{children:[W.jsx(iO,{className:"rf-text-xs",children:"Schematic"}),W.jsx(DtA,{children:W.jsxs(EO,{children:[W.jsx(s0,{className:"rf-flex rf-items-center rf-gap-2",onSelect:aA=>aA.preventDefault(),children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(vtA,{id:"show-schematic-ports",checked:g.showSchematicPorts,onCheckedChange:aA=>{g.onChangeShowSchematicPorts?.(aA===!0)}}),W.jsx("label",{htmlFor:"show-schematic-ports",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Ports"})]})}),W.jsx(s0,{className:"rf-flex rf-items-center rf-gap-2",onSelect:aA=>aA.preventDefault(),children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(vtA,{id:"show-schematic-grid",checked:g.showSchematicDebugGrid,onCheckedChange:aA=>{g.onChangeShowSchematicDebugGrid?.(aA===!0)}}),W.jsx("label",{htmlFor:"show-schematic-grid",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Grid"})]})})]})})]})})]})]}),sA,W.jsx(GMo,{open:p,onOpenChange:k,onExport:CA}),Z&&W.jsx(cSo,{open:S,onOpenChange:R,circuitJson:Z,projectName:O}),W.jsx(WJI,{isOpen:AA,onClose:()=>tA(!1)}),W.jsx(fko,{isOpen:eA,onClose:()=>QA(!1),packageName:e}),W.jsx(mwI,{position:"top-center",reverseOrder:!1,containerStyle:{zIndex:1e5},toastOptions:{className:"rf-break-all",style:{zIndex:1e5}}}),W.jsx(U.OrderDialog,{isOpen:U.isOpen,onClose:U.close,stage:U.stage,setStage:U.setStage})]})};var lSo=Object.defineProperty,Zy=(g,A)=>lSo(g,"name",{value:A,configurable:!0}),[YCg,OgB]=dM("Tooltip",[IO]),_Cg=IO(),DSo="TooltipProvider",dSo=700,bCg="tooltip.open",[ySo,HCg]=YCg(DSo),wSo=Zy(g=>{const{__scopeTooltip:A,delayDuration:I=dSo,skipDelayDuration:e=300,disableHoverableContent:t=!1,children:o}=g,B=gA.useRef(!0),C=gA.useRef(!1),Q=gA.useRef(0);return gA.useEffect(()=>{const i=Q.current;return()=>window.clearTimeout(i)},[]),W.jsx(ySo,{scope:A,isOpenDelayedRef:B,delayDuration:I,onOpen:gA.useCallback(()=>{e<=0||(window.clearTimeout(Q.current),B.current=!1)},[e]),onClose:gA.useCallback(()=>{e<=0||(window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>B.current=!0,e))},[e]),isPointerInTransitRef:C,onPointerInTransitChange:gA.useCallback(i=>{C.current=i},[]),disableHoverableContent:t,children:o})},"TooltipProvider"),vCg="Tooltip",[uSo,ApA]=YCg(vCg),GSo=Zy(g=>{const{__scopeTooltip:A,children:I,open:e,defaultOpen:t,onOpenChange:o,disableHoverableContent:B,delayDuration:C}=g,Q=HCg(vCg,g.__scopeTooltip),i=_Cg(A),[E,n]=gA.useState(null),[s,r]=gA.useState(void 0),a=wM(),c=gA.useRef(0),h=B??Q.disableHoverableContent,l=C??Q.delayDuration,D=gA.useRef(!1),[d,y]=NN({prop:e,defaultProp:t??!1,onChange:Zy(k=>{k?(Q.onOpen(),document.dispatchEvent(new CustomEvent(bCg))):Q.onClose(),o?.(k)},"onChange"),caller:vCg}),w=gA.useMemo(()=>d?D.current?"delayed-open":"instant-open":"closed",[d]),u=gA.useCallback(()=>{window.clearTimeout(c.current),c.current=0,D.current=!1,y(!0)},[y]),G=gA.useCallback(()=>{window.clearTimeout(c.current),c.current=0,y(!1)},[y]),m=gA.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>{D.current=!0,y(!0),c.current=0},l)},[l,y]);gA.useEffect(()=>()=>{c.current&&(window.clearTimeout(c.current),c.current=0)},[]);const p=s??a;return W.jsx(pGA,{...i,children:W.jsx(uSo,{scope:A,contentId:p,setContentId:r,open:d,stateAttribute:w,trigger:E,onTriggerChange:n,onTriggerEnter:gA.useCallback(()=>{Q.isOpenDelayedRef.current?m():u()},[Q.isOpenDelayedRef,m,u]),onTriggerLeave:gA.useCallback(()=>{h?G():(window.clearTimeout(c.current),c.current=0)},[G,h]),onOpen:u,onClose:G,disableHoverableContent:h,children:I})})},"Tooltip"),tPI="TooltipTrigger",mSo=gA.forwardRef(Zy(function(A,I){const{__scopeTooltip:e,"aria-describedby":t,...o}=A,B=ApA(tPI,e),C=HCg(tPI,e),Q=_Cg(e),i=gA.useRef(null),E=$i(I,i,B.onTriggerChange),n=gA.useRef(!1),s=gA.useRef(!1),r=gA.useCallback(()=>n.current=!1,[]);return gA.useEffect(()=>()=>document.removeEventListener("pointerup",r),[r]),W.jsx(log,{asChild:!0,...Q,children:W.jsx(iE.button,{"aria-describedby":B.open?aPI(t,B.contentId):t,"data-state":B.stateAttribute,...o,ref:E,onPointerMove:_o(A.onPointerMove,a=>{a.pointerType!=="touch"&&!s.current&&!C.isPointerInTransitRef.current&&(B.onTriggerEnter(),s.current=!0)}),onPointerLeave:_o(A.onPointerLeave,()=>{B.onTriggerLeave(),s.current=!1}),onPointerDown:_o(A.onPointerDown,()=>{B.open&&B.onClose(),n.current=!0,document.addEventListener("pointerup",r,{once:!0})}),onFocus:_o(A.onFocus,()=>{n.current||B.onOpen()}),onBlur:_o(A.onBlur,B.onClose),onClick:_o(A.onClick,B.onClose)})})},"TooltipTrigger")),pSo="TooltipPortal",[WgB,kSo]=YCg(pSo,{forceMount:void 0}),AoA="TooltipContent",oPI=gA.forwardRef(Zy(function(A,I){const e=kSo(AoA,A.__scopeTooltip),{forceMount:t=e.forceMount,side:o="top",...B}=A,C=ApA(AoA,A.__scopeTooltip);return W.jsx(xf,{present:t||C.open,children:C.disableHoverableContent?W.jsx(BPI,{side:o,...B,ref:I}):W.jsx(MSo,{side:o,...B,ref:I})})},"TooltipContent")),MSo=gA.forwardRef(Zy(function(A,I){const e=ApA(AoA,A.__scopeTooltip),t=HCg(AoA,A.__scopeTooltip),o=gA.useRef(null),B=$i(I,o),[C,Q]=gA.useState(null),{trigger:i,onClose:E}=e,n=o.current,{onPointerInTransitChange:s}=t,r=gA.useCallback(()=>{Q(null),s(!1)},[s]),a=gA.useCallback((c,h)=>{const l=c.currentTarget,D={x:c.clientX,y:c.clientY},d=CPI(D,l.getBoundingClientRect()),y=QPI(D,d),w=iPI(h.getBoundingClientRect()),u=nPI([...y,...w]);Q(u),s(!0)},[s]);return gA.useEffect(()=>()=>r(),[r]),gA.useEffect(()=>{if(i&&n){const c=Zy(l=>a(l,n),"handleTriggerLeave"),h=Zy(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]),gA.useEffect(()=>{if(C){const c=Zy(h=>{const l=h.target,D={x:h.clientX,y:h.clientY},d=i?.contains(l)||n?.contains(l),y=!EPI(D,C);d?r():y&&(r(),E())},"handleTrackPointerGrace");return document.addEventListener("pointermove",c),()=>document.removeEventListener("pointermove",c)}},[i,n,C,E,r]),W.jsx(BPI,{...A,ref:B})},"TooltipContentHoverable")),SSo=K0g("TooltipContent"),BPI=gA.forwardRef(Zy(function(A,I){const{__scopeTooltip:e,children:t,"aria-label":o,id:B,onEscapeKeyDown:C,onPointerDownOutside:Q,...i}=A,E=ApA(AoA,e),n=_Cg(e),{onClose:s}=E,[r,a]=gA.useState(null),c=$i(I,a);gog(r),gA.useEffect(()=>(document.addEventListener(bCg,s),()=>document.removeEventListener(bCg,s)),[s]),gA.useEffect(()=>{if(E.trigger){const l=Zy(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 Eh(()=>(h(B),()=>{h(void 0)}),[B,h]),W.jsx(sGA,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:C,onPointerDownOutside:Q,onFocusOutside:l=>l.preventDefault(),onDismiss:s,children:W.jsxs(Dog,{"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:[W.jsx(SSo,{children:t}),o?W.jsx(xMo,{id:E.contentId,role:"tooltip",children:o}):null]})})},"TooltipContentImpl"));function CPI(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")}}Zy(CPI,"getExitSideFromRect");function QPI(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}Zy(QPI,"getPaddedExitPoints");function iPI(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}]}Zy(iPI,"getPointsFromRect");function EPI(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}Zy(EPI,"isPointInPolygon");function nPI(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),sPI(A)}Zy(nPI,"getHull");function sPI(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)}Zy(sPI,"getHullPresorted");function aPI(...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}Zy(aPI,"concatAriaDescribedby");const fSo=wSo,RSo=GSo,NSo=mSo,rPI=gA.forwardRef(({className:g,sideOffset:A=4,...I},e)=>W.jsx(oPI,{ref:e,sideOffset:A,className:dB("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}));rPI.displayName=oPI.displayName;const xSo="24b58135-86c7-4e4b-bf6e-cca862bc4b26",cPI="runframe-crisp-chat-script",FSo="tscircuit.com",goA=g=>{window.$crisp=window.$crisp||[],window.$crisp.push(g)},USo=()=>{if(window.$crisp=window.$crisp||[],window.CRISP_WEBSITE_ID=xSo,window.__RUNFRAME_CRISP_CONFIGURED__||(window.__RUNFRAME_CRISP_CONFIGURED__=!0,goA(["do","chat:hide"]),goA(["on","chat:closed",()=>goA(["do","chat:hide"])])),!document.getElementById(cPI)){const g=document.createElement("script");g.id=cPI,g.src="https://client.crisp.chat/l.js",g.async=!0,document.head.appendChild(g)}},JSo=()=>{USo(),goA(["do","chat:show"]),goA(["do","chat:open"])},PSo=({isCli:g,hostname:A=typeof window<"u"?window.location.hostname:void 0}={})=>A?.toLowerCase()===FSo?!1:!!g,KSo=()=>W.jsx(fSo,{children:W.jsxs(RSo,{children:[W.jsx(NSo,{asChild:!0,children:W.jsx($E,{type:"button",variant:"ghost",size:"icon","aria-label":"Get Support or Give Feedback",onClick:JSo,className:"rf-h-8 rf-w-8",children:W.jsx(Rso,{className:"rf-h-4 rf-w-4 rf-text-gray-500"})})}),W.jsx(rPI,{side:"bottom",children:"Get Support or Give Feedback"})]})}),aF="rf-h-[620px] rf-min-h-full rf-max-h-full",hPI=["assembly","pinout","analog_simulation","bom","circuit_json","errors","render_log","autorouting","solvers"],qCg=g=>g instanceof Error?g.message:"An unknown error occurred",LSo=({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:q,showToggleFullScreen:j=!0,defaultToFullScreen:Z=!1,activeEffectName:O,allowSelectingVersion:AA=zF("TSCIRCUIT_ALLOW_SELECTING_EVAL_VERSION")!==!1,showFileMenu:tA=!1,isWebEmbedded:eA=!1,isCli:QA=!1,projectName:sA,schematicSvgOptions:dA,hideSchematicInAnalogSimulation:CA=!1,onRerunWithDebug:hA,solverEvents:nA,autoroutingPhases:aA,onPcbBoundsSelected:SA})=>{MBg();const{versions:xA,latestVersion:rA,lastRunEvalVersion:NA,search:RA,setSearch:UA,selectVersion:vA}=FGo(AA),KA=gA.useMemo(()=>B?B.filter(Jg=>Jg&&"error_type"in Jg||Jg.type.includes("error")):null,[B]),kA=gA.useMemo(()=>B?B.filter(Jg=>Jg&&"warning_type"in Jg||Jg.type.includes("warning")):null,[B]),YA=gA.useMemo(()=>B?B.some(Jg=>Jg.type==="schematic_group"):!0,[B]),DA=gA.useMemo(()=>B?.some(Jg=>Jg.type==="pcb_panel"),[B]),bA=(!x||x.includes("schematic"))&&YA&&!DA,{controller:WA,focusSchematicComponent:Eg}=fwo(),{controller:LA,focusPcbComponent:uA}=Qso(),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=bA?({source_component_id:Jg})=>{const AI=B?.find(Og=>Og.type==="schematic_component"&&Og.source_component_id===Jg);AI?.type==="schematic_component"&&(Eg(AI.schematic_component_id),YI("schematic"))}:void 0,og=gA.useMemo(()=>!B||!G||KA?.length?!1:B.some(AI=>AI.type==="simulation_experiment")&&!nye(B),[B,KA,G]),dg=gA.useMemo(()=>KA?.find(Jg=>Jg.type.startsWith("simulation_")),[KA]);aJI({errorMessage:t,errorStack:o,circuitJsonErrors:KA});const Rg=gA.useMemo(()=>reo(N),[N]),Qg=[...["pcb","schematic","cad",...hPI].filter(Jg=>(!x||x.includes(Jg))&&(Jg!=="render_log"||s)),...i?["code"]:[],...Rg.map(Jg=>Jg.tabId)],_g=S??R,EI=_g&&Qg.includes(_g)?_g:x?.find(Jg=>Qg.includes(Jg))??Qg[0]??"pcb",[GA,ng]=TUI("runframe-active-tab",EI,S),pg=Qg.includes(GA)?GA:EI;gA.useEffect(()=>{GA!==pg&&(ng(pg),r?.(pg))},[GA,pg,ng,r]);const Ug=Rg.find(Jg=>Jg.tabId===pg);RGo({source:"runframe",component:"CircuitJsonPreview",isWebEmbedded:eA,activeTab:pg});const[mg,fg]=gA.useState(null),[Kg,gg]=gA.useState(Z),[ag,wg]=gA.useState(K),[Hg,II]=gA.useState(Y),BI=_?K:ag,$g=q?Y:Hg,pI=_??wg,DI=q??II;$wo(Kg);const YI=gA.useCallback(Jg=>{ng(Jg),r?.(Jg)},[r,ng]),Ae=()=>{gg(!Kg)};gA.useEffect(()=>{t&&(pg!=="errors"&&fg(pg),YI("errors"))},[t]),gA.useEffect(()=>{(pg==="code"||pg==="errors")&&B&&!t&&YI(mg&&Qg.includes(mg)?mg:EI)},[B]);const JA=gA.useCallback(Jg=>{window.TSCIRCUIT_3D_OBJECT_REF=Jg===null?void 0:Jg},[]);return W.jsx("div",{className:dB("flex flex-col relative rf-overflow-x-hidden rf-h-full",h),children:W.jsx("div",{className:dB("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:W.jsxs(_NA,{value:pg,onValueChange:YI,className:"rf-flex-grow rf-flex rf-flex-col rf-h-full",children:[W.jsxs("div",{className:dB("rf-flex rf-flex-wrap rf-items-center rf-gap-2 rf-p-2 rf-pb-0 rf-shrink-0",l),children:[W.jsxs("div",{className:dB("rf-flex rf-flex-1 rf-min-w-0 rf-items-center",(D||tA)&&"rf-basis-48"),children:[D,tA&&!D&&W.jsx(hSo,{isWebEmbedded:eA,circuitJson:B,projectName:sA,autoroutingLog:w,onReportAutoroutingLog:u,showSchematicDebugGrid:BI,onChangeShowSchematicDebugGrid:pI,showSchematicPorts:$g,onChangeShowSchematicPorts:DI}),!D&&!tA&&G&&W.jsx(Cf,{className:"rf-w-4 rf-h-4 rf-animate-spin"})]}),a&&a.progress!==1&&!t&&W.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:[W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0 rf-flex-1",title:O??a.lastRenderEvent?.phase??"",children:O??a.lastRenderEvent?.phase}),W.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:W.jsx(Cf,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),W.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&&PSo({isCli:QA})&&W.jsx(KSo,{}),W.jsxs("div",{className:"rf-flex rf-min-w-0 rf-max-w-full rf-items-center rf-gap-2 rf-ml-auto",children:[Q&&W.jsxs(hQA,{className:"rf-min-w-0 rf-justify-start rf-overflow-x-auto",children:[i&&W.jsx(KN,{value:"code",children:"Code"}),!x||x.includes("pcb")?W.jsxs(KN,{value:"pcb",className:"rf-whitespace-nowrap",children:[B&&W.jsx("span",{className:dB("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")?W.jsxs(KN,{value:"schematic",className:dB("rf-whitespace-nowrap",B&&!YA&&"rf-opacity-50"),disabled:B?!YA||DA:!1,children:[B&&W.jsx("span",{className:dB("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")?W.jsxs(KN,{value:"cad",children:[B&&W.jsx("span",{className:dB("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)&&W.jsx(KN,{value:pg,children:Ug?.tabName??wug(pg)}),W.jsxs(HGA,{children:[W.jsx(vGA,{asChild:!0,children:W.jsxs("button",{type:"button","aria-label":"More views",className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[W.jsx(mso,{className:"rf-w-4 rf-h-4"}),(KA&&KA.length>0||t)&&W.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"})]})}),W.jsxs(ytA,{className:"rf-*:text-xs rf-z-[101]",children:[Rg.map(Jg=>W.jsxs(s0,{onSelect:()=>YI(Jg.tabId),children:[pg===Jg.tabId?W.jsx(jZ,{className:"rf-w-3 rf-h-3"}):W.jsx(qtg,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),W.jsx("div",{className:"rf-pr-2",children:Jg.tabName})]},Jg.tabId)),hPI.filter(Jg=>!x||x.includes(Jg)).map(Jg=>W.jsxs(s0,{onSelect:()=>YI(Jg),children:[pg!==Jg&&W.jsx(qtg,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),pg===Jg&&W.jsx(jZ,{className:"rf-w-3 rf-h-3"}),W.jsx("div",{className:"rf-pr-2",children:wug(Jg)}),Jg==="errors"&&(KA&&KA.length>0||t)&&W.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:KA?.length}),Jg==="solvers"&&nA&&nA.length>0&&W.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)),W.jsx(s0,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:W.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",rJI.split(".").map((Jg,AI)=>AI===2?parseInt(Jg)+1:Jg).join(".")]})}),AA?W.jsxs(dtA,{onOpenChange:Jg=>!Jg&&UA(""),children:[W.jsx(iO,{className:"rf-text-xs rf-opacity-60",children:W.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",NA??rA??"latest"]})}),W.jsx(DtA,{children:W.jsxs(EO,{className:"rf-*:text-xs rf-w-40 rf-max-h-[200px] rf-overflow-y-auto",children:[W.jsx("div",{className:"rf-p-1",children:W.jsx(kBg,{value:RA,onChange:Jg=>UA(Jg.target.value),placeholder:"Search...",className:"rf-h-7 rf-text-xs"})}),W.jsx(lxI,{}),W.jsx(s0,{onSelect:()=>vA(null),children:rA?`${rA} (latest)`:"latest"}),xA.map(Jg=>W.jsx(s0,{onSelect:()=>vA(Jg),children:Jg},Jg))]})})]}):NA&&W.jsx(s0,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:W.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",NA]})})]})]})]}),j&&W.jsx($E,{onClick:Ae,"aria-label":Kg?"Exit fullscreen":"Enter fullscreen",variant:"ghost",className:"rf-shrink-0",children:Kg?W.jsx(Nso,{size:16}):W.jsx(kso,{size:16})})]})]}),i&&W.jsx(yy,{value:"code",className:"rf-flex-grow rf-min-h-0 rf-overflow-hidden",children:W.jsx("div",{className:"rf-h-full",children:E})}),(!x||x.includes("pcb"))&&W.jsx(yy,{value:"pcb",className:"rf-min-h-0",children:W.jsx("div",{className:"rf-overflow-hidden rf-h-full",children:W.jsx(zR,{fallbackRender:({error:Jg})=>W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:qCg(Jg)})]})}),children:B?W.jsx(zwo,{controller:LA,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)}}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("assembly"))&&W.jsx(yy,{value:"assembly",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallback:W.jsx("div",{children:"Error loading Assembly"}),children:B?W.jsx(Rwo,{circuitJson:B,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("pinout"))&&W.jsx(yy,{value:"pinout",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallback:W.jsx("div",{children:"Error loading Pinout Viewer"}),children:B?W.jsx(Nwo,{circuitJson:B,containerStyle:{height:"100%"}}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("schematic"))&&W.jsx(yy,{value:"schematic",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto rf-bg-white",aF),children:W.jsx(zR,{fallbackRender:({error:Jg})=>W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:qCg(Jg)})]})}),children:B?W.jsx(awo,{platformConfig:g,onViewPcbComponent:OA,controller:WA,circuitJson:B,containerStyle:{height:"100%"},debugGrid:BI,showSchematicPorts:$g,css:dA?.css,className:dA?.className}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("cad"))&&W.jsx(yy,{value:"cad",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallbackRender:({error:Jg,resetErrorBoundary:AI})=>W.jsx(iso,{error:Jg,resetErrorBoundary:AI}),children:B?W.jsx(seo,{ref:JA,circuitJson:B,autoRotateDisabled:U,onViewSchematicComponent:$A},`cad-${Kg}`):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("analog_simulation"))&&W.jsx(yy,{value:"analog_simulation",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallback:W.jsx("div",{children:"Error loading Analog Simulation"}),children:B?dg?W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error running analog simulation"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:dg.message})]})}):og?W.jsx("div",{className:"rf-flex rf-h-full rf-min-h-[300px] rf-items-center rf-justify-center rf-bg-slate-50",children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-text-sm rf-text-slate-600",children:[W.jsx(Cf,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Running analog simulation..."]})}):W.jsx(Swo,{circuitJson:B,hideSchematic:CA,containerStyle:{height:"100%"}}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("bom"))&&W.jsx(yy,{value:"bom",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallbackRender:({error:Jg})=>W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:qCg(Jg)})]})}),children:B?W.jsx(jwo,{circuitJson:B}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("circuit_json"))&&W.jsx(yy,{value:"circuit_json",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallback:W.jsx("div",{children:"Error loading JSON viewer"}),children:B?W.jsx(Uwo,{elements:B}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("errors"))&&W.jsx(yy,{value:"errors",className:"rf-h-full rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-hidden",aF),children:t||KA&&KA.length>0||B?W.jsx(xco,{code:A,fsMap:I,circuitJsonErrors:KA,circuitJsonWarnings:kA,errorMessage:t,errorStack:o,circuitJson:B,evalVersion:NA,autoroutingLog:w,onReportAutoroutingLog:u}):W.jsx($J,{onRunClicked:e})})}),s&&(!x||x.includes("render_log"))&&W.jsx(yy,{value:"render_log",className:"rf-min-h-0",children:W.jsx(Iuo,{renderLog:a,onRerunWithDebug:hA})}),(!x||x.includes("autorouting"))&&W.jsx(yy,{value:"autorouting",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallback:W.jsx("div",{className:"rf-p-4",children:"Error loading autorouting captures"}),children:W.jsx(fGo,{circuitJson:B,phases:aA,isRunning:G})})})}),(!x||x.includes("solvers"))&&W.jsx(yy,{value:"solvers",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-hidden",aF),children:W.jsx(zR,{fallback:W.jsx("div",{children:"Error loading Solvers view"}),children:W.jsx(lGo,{solverEvents:nA})})})}),Rg.map(Jg=>W.jsx(ceo,{tab:Jg,active:pg===Jg.tabId,isFullScreen:Kg},Jg.tabId))]})})})};hOI.createRoot(document.getElementById("root")).render(W.jsx("div",{style:{height:"100vh"},children:W.jsx(LSo,{defaultActiveTab:"cad",autoRotate3dViewerDisabled:!0,showRightHeaderContent:!1,circuitJson:window.CIRCUIT_JSON||{},...window.CIRCUIT_JSON_PREVIEW_PROPS||{}})}));const Pb=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));var YSo=0,rF=class{_nodeId;hasExplicitNodeId;_sourceLocation;_dirty=!1;_parent;_revision=0;constructor(g={}){this.hasExplicitNodeId=g.nodeId!==void 0,this._nodeId=g.nodeId??lPI(g.sourceLocation,this.constructor.name)??`altium-node-${(++YSo).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=lPI(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 lPI(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 Kb=class extends Error{code;constructor(g,A="ALTIUM_ERROR",I){super(g,I),this.name=new.target.name,this.code=A}},pL=class extends Kb{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}},Iu=class extends Kb{constructor(g,A){super(g,"ALTIUM_FORMAT_DETECTION",A)}},zQ=class extends Kb{byteOffset;constructor(g,A={}){super(g,"ALTIUM_CORRUPT_CONTAINER",{cause:A.cause}),this.byteOffset=A.byteOffset}},_So=class extends Kb{constructor(g,A){super(g,"ALTIUM_UNSUPPORTED_VERSION",A)}},TCg=class extends Kb{constructor(g,A){super(g,"ALTIUM_UNSUPPORTED_FEATURE",A)}},Qc=class extends Kb{constructor(g,A){super(g,"ALTIUM_SERIALIZATION",A)}},Rh=class extends Kb{byteOffset;constructor(g,A,I){super(g,"ALTIUM_TRUNCATED_RECORD",I),this.byteOffset=A}},bSo=class extends rF{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 HSo(this.stream.content,g)}getChildren(){return[this.record,this.stream]}getString(){return this.record.getString()}};async function HSo(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 cQA(i=>{if(t+=i.byteLength,t>I)throw new zQ(`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 zQ?C:new zQ(`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 eu(g){if(!Number.isFinite(g))return g;const A=(g%360+360)%360;return Object.is(A,-0)?0:A}function ZCg(g,A,I=1e-9){return Math.abs(g.x-A.x)<=I&&Math.abs(g.y-A.y)<=I}function vSo(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 qSo(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 TSo(g){const A=qSo(g);return Math.abs(A)<=Number.EPSILON?"degenerate":A<0?"clockwise":"counterclockwise"}var OCg=class extends rF{terminator;constructor(g={}){super(g),this.terminator=g.terminator??""}},oN=class extends rF{type="field";_key;_value;constructor(g){super(g),DPI(g.key),dPI(g.value??""),this._key=g.key,this._value=g.value??""}get key(){return this._key}set key(g){DPI(g),g!==this._key&&(this._key=g,this.markDirty())}get value(){return this._value}set value(g){dPI(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 DPI(g){if(g.length===0||/[=|\r\n]/u.test(g))throw new Error(`Invalid Altium field key: ${JSON.stringify(g)}`)}function dPI(g){if(/[|\r\n]/u.test(g))throw new Error(`Altium field values cannot contain record delimiters: ${JSON.stringify(g)}`)}var ZSo={cm:1e4/25.4,in:1e3,inch:1e3,inches:1e3,mil:1,mils:1,mm:1e3/25.4},OSo=/^([+-]?(?:\d+\.\d*|\d+|\.\d+)(?:e[+-]?\d+)?)([a-z]+)?$/iu,IoA=class c7I{unit;value;#C;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.#C=A.raw??`${jSo(A.value)}${A.unit===void 0?"":A.unit}`}static parse(A){const I=OSo.exec(A.trim());if(!I?.[1])return;const e=Number(I[1]);if(Number.isFinite(e))return new c7I({raw:A,unit:I[2],value:e})}get normalizedUnit(){return this.unit?.toLowerCase()}get raw(){return this.#C}toMils(){return this.normalizedUnit===void 0?this.value:this.value*(ZSo[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 RO(g){return g===void 0?void 0:IoA.parse(g)}function eoA(g){return RO(g)?.toMils()}function WSo(g,A="mil"){if(g instanceof IoA)return g;if(typeof g=="string"){const I=IoA.parse(g);if(!I)throw new TypeError(`Invalid Altium measurement ${JSON.stringify(g)}`);return I}return typeof g=="number"?new IoA({unit:A,value:g}):new IoA(g)}function VSo(g,A="mil"){return WSo(g,A).toString()}function jSo(g){return Object.is(g,-0)?"-0":String(g)}var bn=class extends OCg{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 RO(this.getCaseInsensitive(g))}get recordKind(){return this.get("RECORD")}get fields(){return this.items.filter(g=>g instanceof oN)}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):$So(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||!zSo(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 oN({key:g,value:A}).setParent(this);this.items.push(e),this.markDirty()}return this}setMeasurement(g,A,I="mil"){return this.set(g,VSo(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(eu(A)))}insertField(g,A,I={}){const e=new oN({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 oN&&B.key===I.beforeKey)),t===void 0&&I.afterKey!==void 0){const B=this.items.findLastIndex(C=>C instanceof oN&&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 oN&&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 zSo(g){return/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/iu.test(g.trim())}var XSo=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 $So(g){const A=[];for(const I of g){const e=XSo.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 Hi(g,...A){for(const I of A){const e=eoA(g.getCaseInsensitive(I));if(e!==void 0)return e}}function r0(g,A,I){const e=Hi(g,...A),t=Hi(g,...I);return e===void 0||t===void 0?void 0:{x:e,y:t}}function toA(g,A,I){const e=Hi(g,...A),t=Hi(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 A2o(g,...A){for(const I of A){const e=g.getNumber(I);if(e!==void 0)return e}}var gpA=class extends bn{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 r0(this,["X","LOCATION.X"],["Y","LOCATION.Y"])}get rotation(){return eu(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 Hi(this,"HEIGHT")}getOwnedPrimitives(g){return g.getRecordsOwnedByComponent(this)}getBounds(g,A){return g.getComponentBounds(this,A)}},IpA=class extends bn{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")}},g2o=65535,yPI=new WeakMap,I2o=class{constructor(g){this.document=g,this.components=g.getRecordsByKind("Component").filter(A=>A instanceof gpA),this.nets=g.getRecordsByKind("Net").filter(A=>A instanceof IpA),this.polygons=g.getRecordsByKind("Polygon"),this.rules=[...g.getRecordsByKind("Rule"),...g.getRecordsByKind("DXPRule")],this.componentTargets=tpA(this.components),this.netTargets=tpA(this.nets),this.polygonTargets=tpA(this.polygons),this.ruleTargets=tpA(this.rules);for(const A of g.records){jCg(this.byKind,A.recordKind??"Unknown",A);const I=A.getDecoded("LAYER");I!==void 0&&jCg(this.byLayer,I.toUpperCase(),A),opA(this.byComponent,A,"COMPONENT"),opA(this.byNet,A,"NET"),opA(this.byPolygon,A,"POLYGON"),opA(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 Yb(g)?this.componentTargets.get(g):void 0}getNet(g){return Yb(g)?this.netTargets.get(g):void 0}getPolygon(g){return Yb(g)?this.polygonTargets.get(g):void 0}getRule(g){return Yb(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=Lb(I,e);o!==void 0&&!t.has(o)&&g.push({field:e,index:o,record:I})}return g}};function yr(g){const A=yPI.get(g);if(A?.revision===g.revision)return A.index;const I=new I2o(g);return yPI.set(g,{index:I,revision:g.revision}),I}function wPI(g,A){return yr(g).getComponent(A)}function uPI(g,A){return yr(g).getNet(A)}function GPI(g,A){return yr(g).getPolygon(A)}function mPI(g,A){return yr(g).getRule(A)}function WCg(g,A){return A instanceof gpA?kL(yr(g).components,A):Lb(A,"COMPONENT")}function VCg(g,A){return A instanceof IpA?kL(yr(g).nets,A):Lb(A,"NET")}function e2o(g,A){return A.recordKind==="Polygon"?kL(yr(g).polygons,A):Lb(A,"POLYGON")}function t2o(g,A){return A.recordKind==="Rule"||A.recordKind==="DXPRule"?kL(yr(g).rules,A):Lb(A,"RULE")??Lb(A,"RULEINDEX")}function pPI(g,A){const I=WCg(g,A);return I===void 0?void 0:yr(g).getComponent(I)}function kPI(g,A){const I=VCg(g,A);return I===void 0?void 0:yr(g).getNet(I)}function MPI(g,A){const I=e2o(g,A);return I===void 0?void 0:yr(g).getPolygon(I)}function SPI(g,A){const I=t2o(g,A);return I===void 0?void 0:yr(g).getRule(I)}function epA(g,A){const I=typeof A=="number"?A:kL(yr(g).components,A);return I===void 0?[]:[...yr(g).byComponent.get(I)??[]]}function fPI(g,A){const I=typeof A=="number"?A:kL(yr(g).nets,A);return I===void 0?[]:[...yr(g).byNet.get(I)??[]]}function RPI(g,A){const I=typeof A=="number"?A:kL(yr(g).polygons,A);return I===void 0?[]:[...yr(g).byPolygon.get(I)??[]]}function NPI(g,A){const I=typeof A=="number"?A:kL(yr(g).rules,A);return I===void 0?[]:[...yr(g).byRule.get(I)??[]]}function tpA(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&&Yb(o)&&A.set(o,e)}),A}function kL(g,A){if(g.some(t=>t.getNumber("ID")!==void 0)){const t=A.getNumber("ID");return t!==void 0&&Yb(t)?t:void 0}const e=g.indexOf(A);return e>=0?e:void 0}function opA(g,A,I){const e=Lb(A,I);e!==void 0&&jCg(g,e,A)}function jCg(g,A,I){const e=g.get(A);e?e.push(I):g.set(A,[I])}function Lb(g,A){const I=g.getNumber(A);return I!==void 0&&Yb(I)?I:void 0}function Yb(g){return Number.isInteger(g)&&g>=0&&g<g2o}var xPI=1e5,o2o=1e4;function zCg(g){return QpA(B2o(g))}function B2o(g){return FPI(KPI(g))}function FPI(g){const A=[];for(let I=0;I<xPI;I++){const e=_b(g,`VX${I}`),t=_b(g,`VY${I}`);if(e===void 0||t===void 0)break;const o=$Cg(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=_b(g,`CX${I}`),Q=_b(g,`CY${I}`),i=_b(g,`R${I}`),E=$Cg(g,`SA${I}`),n=$Cg(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 BpA(g){const A=KPI(g),I=[],e=LPI(A.get("HOLECOUNT"),o2o);for(let t=0;t<e;t++){const o=LPI(A.get(`HOLE${t}COUNT`),xPI),B=[];for(let C=0;C<o;C++){const Q=_b(A,`HOLE${t}VX${C}`),i=_b(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(QpA(B))}return{holes:I,outline:QpA(FPI(A)),record:g}}function UPI(g){const A=g.board?zCg(g.board):QpA([]),I=g.records.filter(e=>e.recordKind==="BoardRegion"||e.recordKind==="Region");return{cutouts:I.filter(e=>CpA(e)==="BOARD_CUTOUT").map(BpA),layerStackRegions:I.filter(e=>CpA(e)==="LAYER_STACK_REGION").map(BpA),outline:A,polygonCutouts:I.filter(e=>CpA(e)==="POLYGON_CUTOUT").map(BpA)}}function CpA(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 QpA(g){const A=[];for(const t of g){if(!t.arc){PPI(A,t.position);continue}for(const o of C2o(t.position,t.arc))PPI(A,o)}const I=A[0],e=A.at(-1);return{bounds:vSo(A),isExplicitlyClosed:I!==void 0&&e!==void 0&&ZCg(I,e,1e-4),points:A,vertices:g,winding:TSo(A)}}function C2o(g,A){const I=XCg(A.center,A.radiusMils,A.startAngleDegrees),e=XCg(A.center,A.radiusMils,A.endAngleDegrees),t=Q2o(A.endAngleDegrees-A.startAngleDegrees)||360,o=JPI(g,I)<=JPI(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(XCg(A.center,A.radiusMils,B+C*E/Q));return i}function XCg(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 Q2o(g){return(g%360+360)%360}function JPI(g,A){const I=g.x-A.x,e=g.y-A.y;return I*I+e*e}function PPI(g,A){const I=g.at(-1);I&&ZCg(I,A,1e-4)||g.push(A)}function KPI(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 _b(g,A){return eoA(g.get(A.toUpperCase()))}function $Cg(g,A){const I=Number(g.get(A.toUpperCase()));return Number.isFinite(I)?I:void 0}function LPI(g,A){const I=Number(g??0);return Number.isInteger(I)?Math.min(Math.max(I,0),A):0}var YPI=class extends bn{type="dimension-record";constructor(g={}){super(g)}get dimensionKind(){return xt(this,"DIMENSIONKIND","KIND")}get start(){return this.referencePoints[0]??r0(this,["X1"],["Y1"])}get end(){return this.referencePoints[1]??r0(this,["X2"],["Y2"])}get dimensionLineAnchor(){return r0(this,["X1"],["Y1"])}get referencePoints(){return _PI({pointInfix:"POINT",prefix:"REFERENCE",record:this})}get textPoints(){const g=r0(this,["TEXTX"],["TEXTY"]);return g?[g]:_PI({pointInfix:"",prefix:"TEXT",record:this})}get unit(){return xt(this,"TEXTDIMENSIONUNIT","DIMENSIONUNIT","UNIT")}get precision(){return A2o(this,"TEXTPRECISION","PRECISION")??Hi(this,"TEXTPRECISION","PRECISION")}get prefix(){return xt(this,"TEXTPREFIX","PREFIX")}get suffix(){return xt(this,"TEXTSUFFIX","SUFFIX")}get lineWidthMils(){return Hi(this,"LINEWIDTH","ARROWLINEWIDTH","WIDTH")}get textHeightMils(){return Hi(this,"TEXTHEIGHT","HEIGHT")}};function _PI({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=r0(I,[`${A}${C}${g}X`],[`${A}${C}${g}Y`]);if(!Q)break;e.push(Q)}return e}var i2o=class extends bn{type="coordinate-record";get position(){return r0(this,["X","LOCATION.X"],["Y","LOCATION.Y"])}};function E2o(g){return g.replace(/[\s_-]/gu,"").toUpperCase()}function NO(g){return eoA(g)}function Zc(g,A,I=0){return NO(g.getCaseInsensitive(A))??I}function n2o(g){return zCg(g).points}function s2o(g){if(!(g instanceof YPI))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=a2o({dimension:A,measuredDistanceMils:B}),c=A.textHeightMils??50,h=bPI({fallbackMils:10,fieldName:"TEXTGAP",record:g});return{arrowSize:bPI({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 a2o({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}=r2o({measuredDistanceMils:A,normalizedUnit:t}),C=g.prefix??"",Q=g.suffix??` ${B}`;return`${C}${o.toFixed(e)}${Q}`}function r2o({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 bPI({fallbackMils:g,fieldName:A,record:I}){return I.getAltiumMeasurement(A)?.toMils()??g}var AQg=E2o;function c2o(g,A){const I=l2o(g,A),e=g.getNumber("PADMODE")??0,t=h2o(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=Zc(g,"HOLESIZE"),n=NO(g.getCaseInsensitive("SLOTLENGTH"))??(i==="SLOT"?NO(g.getCaseInsensitive("HOLEWIDTH")):void 0)??E;return{cornerRadius:C,height:t.height,holeOffsetX:Zc(g,`LAYER${I}HOLEXOFFSET`,Zc(g,`PADXOFFSET${I}`)),holeOffsetY:Zc(g,`LAYER${I}HOLEYOFFSET`,Zc(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:Zc(g,"X"),y:Zc(g,"Y")}}function h2o(g,A,I){if(!(AQg(g.getCaseInsensitive("LAYER")??"")==="MULTILAYER")||I===0||A===0)return{height:C4(g,["YSIZE","TOPYSIZE"])??C4(g,["XSIZE","TOPXSIZE"])??20,shape:ipA(g,["SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:C4(g,["XSIZE","TOPXSIZE"])??20};if(A===31){const B=C4(g,["BOTTOMXSIZE","BOTXSIZE","XSIZE","TOPXSIZE"])??20;return{height:C4(g,["BOTTOMYSIZE","BOTYSIZE","YSIZE","TOPYSIZE"])??B,shape:ipA(g,["BOTTOMSHAPE","BOTSHAPE","SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:B}}if(I===2&&A>=2){const B=C4(g,[`LAYER${A}XSIZE`,"MIDXSIZE","XSIZE"])??20;return{height:C4(g,[`LAYER${A}YSIZE`,"MIDYSIZE","YSIZE"])??B,shape:ipA(g,[`LAYER${A}SHAPE`,"MIDSHAPE","SHAPE"])?.toUpperCase()??"ROUND",width:B}}const o=C4(g,["MIDXSIZE","XSIZE","TOPXSIZE"])??20;return{height:C4(g,["MIDYSIZE","YSIZE","TOPYSIZE"])??o,shape:ipA(g,["MIDSHAPE","SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:o}}function l2o(g,A){const I=A?.length===1?AQg(A[0]??""):AQg(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 C4(g,A){for(const I of A){const e=NO(g.getCaseInsensitive(I));if(e!==void 0)return e}}function ipA(g,A){for(const I of A){const e=g.getCaseInsensitive(I);if(e!==void 0)return e}}function gQg(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 D2o(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 IQg(g,A){return{minX:g.minX-A,minY:g.minY-A,maxX:g.maxX+A,maxY:g.maxY+A}}function d2o(g,A){const I=g.recordKind;if(I==="Dimension"){const e=s2o(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=gQg([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?IQg(Q,Math.max(e.arrowSize,e.textHeight)):void 0}if(I==="Track"){const e=gQg([{x:Zc(g,"X1"),y:Zc(g,"Y1")},{x:Zc(g,"X2"),y:Zc(g,"Y2")}]),t=Zc(g,"WIDTH");return e&&t>0?IQg(e,t/2):e}if(I==="Pad"){const e=c2o(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=Zc(g,"X"),t=Zc(g,"Y"),o=NO(g.getCaseInsensitive("DIAMETER"))??NO(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=Zc(g,"LOCATION.X"),t=Zc(g,"LOCATION.Y"),o=Zc(g,"RADIUS"),B=Zc(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 gQg(n2o(g));if(I==="Text"){const e=Zc(g,"X"),t=Zc(g,"Y"),o=Zc(g,"HEIGHT",30);return IQg({minX:e,minY:t,maxX:e,maxY:t},o)}if(I==="Fill"){const e=Zc(g,"X1"),t=Zc(g,"Y1"),o=Zc(g,"X2"),B=Zc(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 HPI=new WeakMap,y2o=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=WCg(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=VCg(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 epA(this.document,g)){const t=VCg(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=WCg(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 vPI(g){const A=HPI.get(g);if(A?.revision===g.revision)return A.graph;const I=new y2o(g);return HPI.set(g,{graph:I,revision:g.revision}),I}function qPI(g,A,I){let e;for(const t of epA(g,A))e=D2o(e,d2o(t,I));return e}var w2o=class extends rF{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 bSo({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 vPI(this)}get boardGeometry(){return UPI(this)}get polygons(){return this.propertyRecords.get("Polygons6")??[]}get rules(){return this.propertyRecords.get("Rules6")??[]}getComponentByIndex(g){return wPI(this,g)}getNetByIndex(g){return uPI(this,g)}getPolygonByIndex(g){return GPI(this,g)}getRuleByIndex(g){return mPI(this,g)}getComponentForRecord(g){return pPI(this,g)}getNetForRecord(g){return kPI(this,g)}getPolygonForRecord(g){return MPI(this,g)}getRuleForRecord(g){return SPI(this,g)}getRecordsOwnedByComponent(g){return epA(this,g)}getRecordsOnNet(g){return fPI(this,g)}getRecordsForPolygon(g){return RPI(this,g)}getRecordsForRule(g){return NPI(this,g)}getRecordsByLayer(g){return[...this.index.byLayer.get(g.toUpperCase())??[]]}getComponentBounds(g,A){return qPI(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=>eQg(e.getNumber("ROTX"),g.getNumber("MODEL.3D.ROTX"))&&eQg(e.getNumber("ROTY"),g.getNumber("MODEL.3D.ROTY"))&&eQg(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]),gA.useEffect(()=>{A&&!s&&x4I().then(u=>{c(u.size)}).catch(u=>{console.error("Failed to fetch file count",u),c(0)})},[A,s]);const D=gA.useCallback(()=>{B(null),r(null),Q(null),E([]),n.current&&(n.current.value=""),I(!0)},[]),d=gA.useCallback(()=>{I(!1)},[]),y=gA.useCallback(async()=>{t(!0),B(null),Q(null),E([]);const u=JY(),G=n.current?.value||"";try{const m=await x4I();if(m.size===0){rQ.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 q=_ instanceof FY?`HTTP ${_.response.status}`:_ instanceof Error?_.message:"Upload failed";x.push({filePath:K,message:q}),E([...x])}}Q(null);const N=wMo(S);r({bugReportUrl:N})}catch(m){if(console.error("Failed to submit bug report",m),m instanceof FY)if(m.response.status===401)if(l){const p="Your session has expired. Please sign in again to continue.";B(p),rQ.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),rQ.error(p),setTimeout(()=>{h&&(d(),h())},1e3)}else{const p=`Failed to submit bug report (${m.response.status})`;B(p),rQ.error(p)}else if(m instanceof Error)B(m.message),rQ.error(m.message);else{const p="Failed to submit bug report";B(p),rQ.error(p)}}finally{t(!1)}},[l,h]);return{BugReportDialog:gA.useMemo(()=>{const u=C?Math.round(C.current/C.total*100):0;return W.jsx(GJI,{open:A,onOpenChange:G=>{G?(B(null),r(null),Q(null),E([]),I(!0)):e||d()},children:W.jsxs(vBg,{children:[W.jsxs(qBg,{children:[W.jsx(ZBg,{children:s?"Bug Report Created":"Report Bug"}),W.jsx(OBg,{asChild:!0,children:s?W.jsxs("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:[W.jsx("p",{children:"Bug report created successfully."}),i.length>0&&W.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:[W.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)=>W.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${G.filePath}: ${G.message}`,children:[W.jsx("span",{className:"rf-font-medium rf-break-all",children:G.filePath.split("/").pop()}),W.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:G.message})]},m))]}),W.jsx("div",{children:W.jsx("a",{className:"rf-text-blue-600 hover:rf-underline",href:s.bugReportUrl,target:"_blank",rel:"noreferrer",children:"View bug report"})}),W.jsxs("p",{children:["Please share this link privately with tscircuit staff so we can help debug. Join the",W.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"}),"."]})]}):W.jsx("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:C?W.jsxs("div",{className:"rf-space-y-2 rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-flex rf-justify-between rf-text-xs",children:[W.jsx("span",{children:"Uploading files..."}),W.jsxs("span",{children:[C.current,"/",C.total]})]}),W.jsx("div",{className:"rf-w-full rf-h-2 rf-bg-gray-200 rf-rounded-full rf-overflow-hidden",children:W.jsx("div",{className:"rf-h-full rf-bg-blue-500 rf-transition-all rf-duration-150",style:{width:`${u}%`}})}),W.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&&W.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)=>W.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${G.filePath}: ${G.message}`,children:[W.jsx("span",{className:"rf-font-medium rf-break-all",children:G.filePath.split("/").pop()}),W.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:G.message})]},m))})]}):W.jsxs(W.Fragment,{children:[W.jsxs("p",{children:["Reporting a bug will upload your entire project",a>0?` (${a} file${a===1?"":"s"})`:""," ","to tscircuit support."]}),W.jsxs("div",{className:"rf-space-y-2",children:[W.jsx("label",{htmlFor:"bug-description",className:"rf-block rf-font-medium",children:"Description (optional)"}),W.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})]}),W.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",W.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&&W.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&&W.jsx("p",{className:"rf-text-red-600",children:o})]})})})]}),W.jsx(TBg,{children:s?W.jsx("button",{type:"button",className:VZ(),onClick:()=>{d()},children:"Close"}):W.jsxs(W.Fragment,{children:[W.jsx(WBg,{disabled:e,onClick:()=>{e||d()},children:"Cancel"}),!l&&h?W.jsx("button",{type:"button",className:VZ(),onClick:G=>{G.preventDefault(),d(),h()},children:"Sign In"}):W.jsx("button",{type:"button",className:Ff(VZ(),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 GMo({open:g,onOpenChange:A,onExport:I}){const[e,t]=gA.useState(!1),o=()=>{I({includeSilkscreen:e}),A(!1)},B=()=>{A(!1)};return W.jsx(pO,{open:g,onOpenChange:A,children:W.jsxs(Mb,{children:[W.jsxs(Sb,{children:[W.jsx(fb,{children:"LightBurn Export Options"}),W.jsx(MO,{children:"Configure export settings for PCB laser ablation with LightBurn"})]}),W.jsx("div",{className:"rf-flex rf-flex-col rf-gap-4 rf-py-4",children:W.jsxs("div",{className:"rf-flex rf-items-center rf-space-x-2",children:[W.jsx(vtA,{id:"includeSilkscreen",checked:e,onCheckedChange:C=>t(C===!0)}),W.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"})]})}),W.jsxs(kO,{children:[W.jsx($E,{variant:"outline",onClick:B,children:"Cancel"}),W.jsx($E,{onClick:o,children:"Export"})]})]})})}const mMo=/#(\d+)/,pMo=g=>{const A=g.match(mMo);if(!A)return null;const I=Number.parseInt(A[1],10);return Number.isFinite(I)?I:null},kMo=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},MMo=g=>{if(!g)return null;let A=null,I=-1,e=-1;for(const[t,o]of Object.entries(g)){const B=pMo(t),C=kMo(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 SMo=Object.defineProperty,fMo=(g,A)=>SMo(g,"name",{value:A,configurable:!0});function xCg(g,[A,I]){return Math.min(I,Math.max(A,g))}fMo(xCg,"clamp");var RMo=Object.defineProperty,NMo=(g,A)=>RMo(g,"name",{value:A,configurable:!0}),F4I=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"}),xMo=gA.forwardRef(NMo(function(A,I){return W.jsx(iE.span,{...A,ref:I,style:{...F4I,...A.style}})},"VisuallyHidden")),FMo=Object.defineProperty,vE=(g,A)=>FMo(g,"name",{value:A,configurable:!0}),U4I={ItemAligned:"item-aligned",Popper:"popper"},UMo={RTL:"rtl"},JMo=[" ","Enter","ArrowUp","ArrowDown"],PMo=[" ","Enter"],fO="Select",[zmA,XmA,KMo]=aCA(fO),[Fb,TgB]=dM(fO,[KMo,IO]),FCg=IO(),[LMo,mL]=Fb(fO),[YMo,_Mo]=Fb(fO);function J4I(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=FCg(A),[l,D]=gA.useState(null),[d,y]=gA.useState(null),[w,u]=gA.useState(!1),G=tV(i),[m,p]=NN({prop:e,defaultProp:t??!1,onChange:o,caller:fO}),[k,S]=NN({prop:B,defaultProp:C,onChange:Q,caller:fO}),R=gA.useRef(null),x=gA.useRef(!1),[N,U]=gA.useState(null),K=vE(QA=>{U({value:QA,hasConsumerStoppedPropagation:x.current}),S(QA)},"handleUserSelect"),Y=gA.useRef(k);gA.useEffect(()=>{const QA=a?l?.ownerDocument.getElementById(a):l?.form;if(QA instanceof HTMLFormElement){const sA=vE(()=>S(Y.current),"reset");return QA.addEventListener("reset",sA),()=>QA.removeEventListener("reset",sA)}},[a,l,S]);const _=l?!!a||!!l.closest("form"):!0,[q,j]=gA.useState(new Set),Z=wM(),O=Array.from(q).map(QA=>QA.props.value).join(";"),AA=gA.useCallback(QA=>{j(sA=>new Set(sA).add(QA))},[]),tA=gA.useCallback(QA=>{j(sA=>{const dA=new Set(sA);return dA.delete(QA),dA})},[]),eA={required:r,trigger:l,onTriggerChange:D,valueNode:d,onValueNodeChange:y,valueNodeHasChildren:w,onValueNodeHasChildrenChange:u,contentId:Z,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:q,nativeSelectKey:O,isFormControl:_};return W.jsx(pGA,{...h,children:W.jsx(LMo,{scope:A,...eA,children:W.jsx(zmA.Provider,{scope:A,children:W.jsx(YMo,{scope:A,onNativeOptionAdd:AA,onNativeOptionRemove:tA,children:j4I(c)?c(eA):I})})})})}vE(J4I,"SelectProvider");var bMo=vE(g=>{const{__scopeSelect:A,children:I,...e}=g;return W.jsx(J4I,{__scopeSelect:A,...e,internal_do_not_use_render:({isFormControl:t})=>W.jsxs(W.Fragment,{children:[I,t?W.jsx(ESo,{__scopeSelect:A}):null]})})},"Select"),HMo="SelectTrigger",P4I=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,disabled:t=!1,...o}=A,B=FCg(e),C=mL(HMo,e),Q=C.disabled||t,i=$i(I,C.onTriggerChange),E=XmA(e),n=gA.useRef("touch"),[s,r,a]=PCg(h=>{const l=E().filter(y=>!y.disabled),D=l.find(y=>y.value===C.value),d=KCg(l,h,D);d!==void 0&&C.onUserSelect(d.value)}),c=vE(h=>{Q||(C.onOpenChange(!0),a()),h&&(C.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})},"handleOpen");return W.jsx(log,{asChild:!0,...B,children:W.jsx(iE.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":$tA(C.value)?"":void 0,...o,ref:i,onClick:_o(o.onClick,h=>{h.currentTarget.focus(),n.current!=="mouse"&&c(h)}),onPointerDown:_o(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:_o(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===" ")&&JMo.includes(h.key)&&(c(),h.preventDefault())})})})},"SelectTrigger")),vMo="SelectValue",qMo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,className:t,style:o,children:B,placeholder:C="",...Q}=A,i=mL(vMo,e),{onValueNodeHasChildrenChange:E}=i,n=B!==void 0,s=$i(I,i.onValueNodeChange);Eh(()=>{E(n)},[E,n]);const r=$tA(i.value);return W.jsx(iE.span,{...Q,asChild:r?!1:Q.asChild,ref:s,style:{pointerEvents:"none"},children:W.jsx(gA.Fragment,{children:r?C:B},r?"placeholder":"value")})},"SelectValue")),TMo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,children:t,...o}=A;return W.jsx(iE.span,{"aria-hidden":!0,...o,ref:I,children:t||"▼"})},"SelectIcon")),ZMo="SelectPortal",[OMo,WMo]=Fb(ZMo,{forceMount:void 0}),VMo=vE(g=>{const{__scopeSelect:A,forceMount:I,...e}=g;return W.jsx(OMo,{scope:g.__scopeSelect,forceMount:I,children:W.jsx(dog,{asChild:!0,...e})})},"SelectPortal"),Ub="SelectContent",K4I=gA.forwardRef(vE(function(A,I){const e=WMo(Ub,A.__scopeSelect),{forceMount:t=e.forceMount,...o}=A,B=mL(Ub,A.__scopeSelect),[C,Q]=gA.useState();return Eh(()=>{Q(new DocumentFragment)},[]),W.jsx(xf,{present:t||B.open,children:({present:i})=>i?W.jsx(XMo,{...o,ref:I}):W.jsx(jMo,{...o,fragment:C})})},"SelectContent")),jMo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,children:t,fragment:o}=A;return o?RN.createPortal(W.jsx(L4I,{scope:e,children:W.jsx(zmA.Slot,{scope:e,children:W.jsx("div",{ref:I,children:t})})}),o):null},"SelectContentFragment")),tN=10,[L4I,Jb]=Fb(Ub),zMo=fN("SelectContent.RemoveScroll"),XMo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e}=A,{position:t=U4I.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=mL(Ub,e),[y,w]=gA.useState(null),[u,G]=gA.useState(null),m=$i(I,w),[p,k]=gA.useState(null),[S,R]=gA.useState(null),x=XmA(e),[N,U]=gA.useState(!1),K=gA.useRef(!1),Y=gA.useRef(!1),_=gA.useRef(!1);gA.useEffect(()=>{if(y)return wog(y)},[y]),ntA();const q=gA.useCallback(hA=>{const[nA,...aA]=x().map(rA=>rA.ref.current),[SA]=aA.slice(-1),xA=document.activeElement;for(const rA of hA)if(rA===xA||(rA?.scrollIntoView({block:"nearest"}),rA===nA&&u&&(u.scrollTop=0),rA===SA&&u&&(u.scrollTop=u.scrollHeight),rA?.focus(),document.activeElement!==xA))return},[x,u]),j=gA.useCallback(()=>q([p,y]),[q,p,y]);gA.useEffect(()=>{N&&j()},[N,j]);const{onOpenChange:Z,triggerPointerDownPosRef:O}=d;gA.useEffect(()=>{if(y){let hA={x:0,y:0};const nA=vE(SA=>{hA={x:Math.abs(Math.round(SA.pageX)-(O.current?.x??0)),y:Math.abs(Math.round(SA.pageY)-(O.current?.y??0))}},"handlePointerMove"),aA=vE(SA=>{hA.x<=10&&hA.y<=10?SA.preventDefault():SA.composedPath().includes(y)||Z(!1),document.removeEventListener("pointermove",nA),O.current=null},"handlePointerUp");return O.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,Z,O]),gA.useEffect(()=>{const hA=vE(()=>Z(!1),"close");return window.addEventListener("blur",hA),window.addEventListener("resize",hA),()=>{window.removeEventListener("blur",hA),window.removeEventListener("resize",hA)}},[Z]);const[AA,tA]=PCg(hA=>{const nA=x().filter(xA=>!xA.disabled),aA=nA.find(xA=>xA.ref.current===document.activeElement),SA=KCg(nA,hA,aA);SA&&setTimeout(()=>SA.ref.current?.focus())}),eA=gA.useCallback((hA,nA,aA)=>{const SA=!Y.current;SA&&(Y.current=!0);const xA=!K.current&&!aA;d.value!==void 0&&d.value===nA||xA?(k(hA),xA&&(K.current=!0)):SA&&k(hA)},[d.value]),QA=gA.useCallback(()=>y?.focus(),[y]),sA=gA.useCallback((hA,nA,aA)=>{if(!hA)return;const SA=!_.current;SA&&(_.current=!0);const xA=!K.current&&!aA;(d.value!==void 0&&d.value===nA||xA||SA)&&R(hA)},[d.value]),dA=t===U4I.Popper?Y4I:$Mo,CA=dA===Y4I?{side:Q,sideOffset:i,align:E,alignOffset:n,arrowPadding:s,collisionBoundary:r,collisionPadding:a,sticky:c,hideWhenDetached:h,avoidCollisions:l}:{};return W.jsx(L4I,{scope:e,content:y,viewport:u,onViewportChange:G,itemRefCallback:eA,selectedItem:p,onItemLeave:QA,itemTextRefCallback:sA,focusSelectedItem:j,selectedItemText:S,position:t,isPositioned:N,searchRef:AA,children:W.jsx(UGA,{as:zMo,allowPinchZoom:!0,children:W.jsx(Xtg,{asChild:!0,trapped:d.open,onMountAutoFocus:hA=>{hA.preventDefault()},onUnmountAutoFocus:_o(o,hA=>{d.trigger?.focus({preventScroll:!0}),hA.preventDefault()}),children:W.jsx(sGA,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:B,onPointerDownOutside:C,onFocusOutside:hA=>hA.preventDefault(),onDismiss:()=>d.onOpenChange(!1),children:W.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:_o(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(xA=>!xA.disabled).map(xA=>xA.ref.current);if(["ArrowUp","End"].includes(hA.key)&&(SA=SA.slice().reverse()),["ArrowUp","ArrowDown"].includes(hA.key)){const xA=hA.target,rA=SA.indexOf(xA);SA=SA.slice(rA+1)}setTimeout(()=>q(SA)),hA.preventDefault()}})})})})})})},"SelectContentImpl")),$Mo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,onPlaced:t,...o}=A,B=mL(Ub,e),C=Jb(Ub,e),[Q,i]=gA.useState(null),[E,n]=gA.useState(null),s=$i(I,n),r=XmA(e),a=gA.useRef(!1),c=gA.useRef(!0),{viewport:h,selectedItem:l,selectedItemText:D,focusSelectedItem:d}=C,y=gA.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!==UMo.RTL){const aA=S.left-p.left,SA=k.left-aA,xA=m.left-SA,rA=m.width+xA,NA=Math.max(rA,p.width),RA=window.innerWidth-tN,UA=xCg(SA,[tN,Math.max(tN,RA-NA)]);Q.style.minWidth=rA+"px",Q.style.left=UA+"px"}else{const aA=p.right-S.right,SA=window.innerWidth-k.right-aA,xA=window.innerWidth-m.right-SA,rA=m.width+xA,NA=Math.max(rA,p.width),RA=window.innerWidth-tN,UA=xCg(SA,[tN,Math.max(tN,RA-NA)]);Q.style.minWidth=rA+"px",Q.style.right=UA+"px"}const R=r(),x=window.innerHeight-tN*2,N=h.scrollHeight,U=window.getComputedStyle(E),K=parseInt(U.borderTopWidth,10),Y=parseInt(U.paddingTop,10),_=parseInt(U.borderBottomWidth,10),q=parseInt(U.paddingBottom,10),j=K+Y+N+q+_,Z=Math.min(l.offsetHeight*5,j),O=window.getComputedStyle(h),AA=parseInt(O.paddingTop,10),tA=parseInt(O.paddingBottom,10),eA=m.top+m.height/2-tN,QA=x-eA,sA=l.offsetHeight/2,dA=l.offsetTop+sA,CA=K+Y+dA,hA=j-CA;if(CA<=eA){const aA=R.length>0&&l===R[R.length-1].ref.current;Q.style.bottom="0px";const SA=E.clientHeight-h.offsetTop-h.offsetHeight,xA=Math.max(QA,sA+(aA?tA:0)+SA+_),rA=CA+xA;Q.style.height=rA+"px"}else{const aA=R.length>0&&l===R[0].ref.current;Q.style.top="0px";const xA=Math.max(eA,K+h.offsetTop+(aA?AA:0)+sA)+hA;Q.style.height=xA+"px",h.scrollTop=CA-eA+h.offsetTop}Q.style.margin=`${tN}px 0`,Q.style.minHeight=Z+"px",Q.style.maxHeight=x+"px",t?.(),requestAnimationFrame(()=>a.current=!0)}},[r,B.trigger,B.valueNode,Q,E,h,l,D,B.dir,t]);Eh(()=>y(),[y]);const[w,u]=gA.useState();Eh(()=>{E&&u(window.getComputedStyle(E).zIndex)},[E]);const G=gA.useCallback(m=>{m&&c.current===!0&&(y(),d?.(),c.current=!1)},[y,d]);return W.jsx(ASo,{scope:e,contentWrapper:Q,shouldExpandOnScrollRef:a,onScrollButtonChange:G,children:W.jsx("div",{ref:i,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:W.jsx(iE.div,{...o,ref:s,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})},"SelectItemAlignedPosition")),Y4I=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,align:t="start",collisionPadding:o=tN,...B}=A,C=FCg(e);return W.jsx(Dog,{...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")),[ASo,UCg]=Fb(Ub,{}),_4I="SelectViewport",gSo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,nonce:t,...o}=A,B=Jb(_4I,e),C=UCg(_4I,e),Q=$i(I,B.onViewportChange),i=gA.useRef(0);return W.jsxs(W.Fragment,{children:[W.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}),W.jsx(zmA.Slot,{scope:e,children:W.jsx(iE.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:Q,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:_o(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-tN*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")),ISo="SelectGroup",[ZgB,eSo]=Fb(ISo),tSo="SelectLabel",b4I=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,...t}=A,o=eSo(tSo,e);return W.jsx(iE.div,{id:o.id,...t,ref:I})},"SelectLabel")),JCg="SelectItem",[oSo,H4I]=Fb(JCg),v4I=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,value:t,disabled:o=!1,textValue:B,...C}=A,Q=mL(JCg,e),i=Jb(JCg,e),E=Q.value===t,[n,s]=gA.useState(B??""),[r,a]=gA.useState(!1),c=uM(y=>i.itemRefCallback?.(y,t,o)),h=$i(I,c),l=wM(),D=gA.useRef("touch");function d(y){Q.hasConsumerStoppedPropagationRef.current=y.isPropagationStopped(),Q.onUserSelect(t),Q.onOpenChange(!1)}return vE(d,"handleSelect"),W.jsx(oSo,{scope:e,value:t,disabled:o,textId:l,isSelected:E,onItemTextChange:gA.useCallback(y=>{s(w=>w||(y?.textContent??"").trim())},[]),children:W.jsx(zmA.ItemSlot,{scope:e,value:t,disabled:o,textValue:n,children:W.jsx(iE.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:_o(C.onFocus,()=>a(!0)),onBlur:_o(C.onBlur,()=>a(!1)),onClick:_o(C.onClick,y=>{o||D.current!=="mouse"&&d(y)}),onPointerUp:_o(C.onPointerUp,y=>{o||D.current==="mouse"&&d(y)}),onPointerDown:_o(C.onPointerDown,y=>{D.current=y.pointerType}),onPointerMove:_o(C.onPointerMove,y=>{D.current=y.pointerType,o?i.onItemLeave?.():D.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:_o(C.onPointerLeave,y=>{y.currentTarget===document.activeElement&&i.onItemLeave?.()}),onKeyDown:_o(C.onKeyDown,y=>{o||y.target!==y.currentTarget||i.searchRef?.current!==""&&y.key===" "||(PMo.includes(y.key)&&d(y),y.key===" "&&y.preventDefault())})})})})},"SelectItem")),$mA="SelectItemText",BSo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,className:t,style:o,...B}=A,C=mL($mA,e),Q=Jb($mA,e),i=H4I($mA,e),E=_Mo($mA,e),[n,s]=gA.useState(null),r=uM(d=>Q.itemTextRefCallback?.(d,i.value,i.disabled)),a=$i(I,s,i.onItemTextChange,r),c=n?.textContent,h=gA.useMemo(()=>W.jsx("option",{value:i.value,disabled:i.disabled,children:c},i.value),[i.disabled,i.value,c]),{onNativeOptionAdd:l,onNativeOptionRemove:D}=E;return Eh(()=>(l(h),()=>D(h)),[l,D,h]),W.jsxs(W.Fragment,{children:[W.jsx(iE.span,{id:i.textId,...B,ref:a}),i.isSelected&&C.valueNode&&!C.valueNodeHasChildren&&!$tA(C.value)?RN.createPortal(B.children,C.valueNode):null]})},"SelectItemText")),CSo="SelectItemIndicator",QSo=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,...t}=A;return H4I(CSo,e).isSelected?W.jsx(iE.span,{"aria-hidden":!0,...t,ref:I}):null},"SelectItemIndicator")),q4I="SelectScrollUpButton",T4I=gA.forwardRef(vE(function(A,I){const e=Jb(q4I,A.__scopeSelect),t=UCg(q4I,A.__scopeSelect),[o,B]=gA.useState(!1),C=$i(I,t.onScrollButtonChange);return Eh(()=>{if(e.viewport&&e.isPositioned){let Q=function(){const E=i.scrollTop>0;B(E)};vE(Q,"handleScroll");const i=e.viewport;return Q(),i.addEventListener("scroll",Q),()=>i.removeEventListener("scroll",Q)}},[e.viewport,e.isPositioned]),o?W.jsx(W4I,{...A,ref:C,onAutoScroll:()=>{const{viewport:Q,selectedItem:i}=e;Q&&i&&(Q.scrollTop=Q.scrollTop-i.offsetHeight)}}):null},"SelectScrollUpButton")),Z4I="SelectScrollDownButton",O4I=gA.forwardRef(vE(function(A,I){const e=Jb(Z4I,A.__scopeSelect),t=UCg(Z4I,A.__scopeSelect),[o,B]=gA.useState(!1),C=$i(I,t.onScrollButtonChange);return Eh(()=>{if(e.viewport&&e.isPositioned){let Q=function(){const E=i.scrollHeight-i.clientHeight,n=Math.ceil(i.scrollTop)<E;B(n)};vE(Q,"handleScroll");const i=e.viewport;return Q(),i.addEventListener("scroll",Q),()=>i.removeEventListener("scroll",Q)}},[e.viewport,e.isPositioned]),o?W.jsx(W4I,{...A,ref:C,onAutoScroll:()=>{const{viewport:Q,selectedItem:i}=e;Q&&i&&(Q.scrollTop=Q.scrollTop+i.offsetHeight)}}):null},"SelectScrollDownButton")),W4I=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,onAutoScroll:t,...o}=A,B=Jb("SelectScrollButton",e),C=gA.useRef(null),Q=XmA(e),i=gA.useCallback(()=>{C.current!==null&&(window.clearInterval(C.current),C.current=null)},[]);return gA.useEffect(()=>()=>i(),[i]),Eh(()=>{Q().find(n=>n.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[Q]),W.jsx(iE.div,{"aria-hidden":!0,...o,ref:I,style:{flexShrink:0,...o.style},onPointerDown:_o(o.onPointerDown,()=>{C.current===null&&(C.current=window.setInterval(t,50))}),onPointerMove:_o(o.onPointerMove,()=>{B.onItemLeave?.(),C.current===null&&(C.current=window.setInterval(t,50))}),onPointerLeave:_o(o.onPointerLeave,()=>{i()})})},"SelectScrollButtonImpl")),V4I=gA.forwardRef(vE(function(A,I){const{__scopeSelect:e,...t}=A;return W.jsx(iE.div,{"aria-hidden":!0,...t,ref:I})},"SelectSeparator")),iSo="SelectBubbleInput",ESo=gA.forwardRef(vE(function({__scopeSelect:A,...I},e){const t=mL(iSo,A),{value:o,onValueChange:B,required:C,disabled:Q,name:i,autoComplete:E,form:n,userSelection:s}=t,{nativeOptions:r,nativeSelectKey:a}=t,c=gA.useRef(null),h=$i(e,c),l=o??"",D=gA.useRef(l),d=gA.useRef(s),y=gA.useRef(!1),w=Array.from(r).some(u=>(u.props.value??"")==="");return gA.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]),W.jsxs(iE.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:{...F4I,...I.style},ref:h,defaultValue:l,children:[$tA(o)&&!w?W.jsx("option",{value:""}):null,Array.from(r)]},a)},"SelectBubbleInput"));function j4I(g){return typeof g=="function"}vE(j4I,"isFunction");function $tA(g){return g===""||g===void 0}vE($tA,"shouldShowPlaceholder");function PCg(g){const A=uM(g),I=gA.useRef(""),e=gA.useRef(0),t=gA.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))}vE(Q,"updateSearch"),Q(C)},[A]),o=gA.useCallback(()=>{I.current="",window.clearTimeout(e.current)},[]);return gA.useEffect(()=>()=>window.clearTimeout(e.current),[]),[I,t,o]}vE(PCg,"useTypeaheadSearch");function KCg(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=z4I(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}vE(KCg,"findNextItem");function z4I(g,A){return g.map((I,e)=>g[(A+e)%g.length])}vE(z4I,"wrapArray");const nSo=bMo,sSo=qMo,X4I=gA.forwardRef(({className:g,children:A,...I},e)=>W.jsxs(P4I,{ref:e,className:dB("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,W.jsx(TMo,{asChild:!0,children:W.jsx(nGA,{className:"rf-h-4 rf-w-4 rf-opacity-50"})})]}));X4I.displayName=P4I.displayName;const $4I=gA.forwardRef(({className:g,...A},I)=>W.jsx(T4I,{ref:I,className:dB("rf-flex rf-cursor-default rf-items-center rf-justify-center rf-py-1",g),...A,children:W.jsx(yso,{className:"rf-h-4 rf-w-4"})}));$4I.displayName=T4I.displayName;const API=gA.forwardRef(({className:g,...A},I)=>W.jsx(O4I,{ref:I,className:dB("rf-flex rf-cursor-default rf-items-center rf-justify-center rf-py-1",g),...A,children:W.jsx(nGA,{className:"rf-h-4 rf-w-4"})}));API.displayName=O4I.displayName;const gPI=gA.forwardRef(({className:g,children:A,position:I="popper",...e},t)=>W.jsx(VMo,{children:W.jsxs(K4I,{ref:t,className:dB("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:[W.jsx($4I,{}),W.jsx(gSo,{className:dB("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}),W.jsx(API,{})]})}));gPI.displayName=K4I.displayName;const aSo=gA.forwardRef(({className:g,...A},I)=>W.jsx(b4I,{ref:I,className:dB("rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-font-semibold",g),...A}));aSo.displayName=b4I.displayName;const IPI=gA.forwardRef(({className:g,children:A,...I},e)=>W.jsxs(v4I,{ref:e,className:dB("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:[W.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:W.jsx(QSo,{children:W.jsx(jZ,{className:"rf-h-4 rf-w-4"})})}),W.jsx(BSo,{children:A})]}));IPI.displayName=v4I.displayName;const rSo=gA.forwardRef(({className:g,...A},I)=>W.jsx(V4I,{ref:I,className:dB("-rf-mx-1 rf-my-1 rf-h-px rf-bg-muted",g),...A}));rSo.displayName=V4I.displayName;const ePI="Component Box (3MF)",LCg=g=>`${g.toFixed(1)} mm`;function cSo({open:g,onOpenChange:A,circuitJson:I,projectName:e}){MBg();const[t,o]=gA.useState(""),[B,C]=gA.useState(null),[Q,i]=gA.useState(null),[E,n]=gA.useState(!1),[s,r]=gA.useState(null);gA.useEffect(()=>()=>{Q&&URL.revokeObjectURL(Q)},[Q]),gA.useEffect(()=>{if(!g||t!==ePI)return;let c=!1;return n(!0),C(null),r(null),Fpo(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 W.jsx(pO,{open:g,onOpenChange:a,children:W.jsxs(Mb,{className:"rf-max-h-[90vh] rf-max-w-3xl rf-overflow-y-auto",children:[W.jsxs(Sb,{children:[W.jsx(fb,{children:"Export Accessory"}),W.jsx(MO,{children:"Generate a printable accessory from the components in this circuit."})]}),W.jsxs("div",{className:"rf-grid rf-gap-5 md:rf-grid-cols-[220px_1fr]",children:[W.jsxs("div",{className:"rf-space-y-2",children:[W.jsx("label",{htmlFor:"accessory-select",className:"rf-text-sm rf-font-medium",children:"Accessory"}),W.jsxs(nSo,{value:t,onValueChange:c=>o(c),children:[W.jsx(X4I,{id:"accessory-select",children:W.jsx(sSo,{placeholder:"Choose an accessory"})}),W.jsx(gPI,{children:W.jsx(IPI,{value:ePI,children:"Component Box"})})]}),W.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."})]}),W.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:[W.jsxs("div",{className:"rf-flex rf-min-h-56 rf-items-center rf-justify-center",children:[!t&&W.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:[W.jsx(xso,{className:"rf-h-10 rf-w-10 rf-stroke-1"}),W.jsx("p",{className:"rf-text-sm",children:"Choose an accessory to generate its preview."})]}),E&&W.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:[W.jsx(Cf,{className:"rf-h-8 rf-w-8 rf-animate-spin"}),W.jsx("p",{className:"rf-text-sm",children:"Generating component box…"})]}),s&&!E&&W.jsxs("div",{className:"rf-p-8 rf-text-center",children:[W.jsx("p",{className:"rf-text-sm rf-font-medium rf-text-red-600",children:"Could not generate the preview"}),W.jsx("p",{className:"rf-mt-1 rf-text-xs rf-text-red-500",children:s})]}),Q&&B&&!E&&W.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&&W.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:[W.jsxs("span",{children:[B.compartments.length," compartments"]}),W.jsxs("span",{children:[LCg(B.dimensions.width)," ×"," ",LCg(B.dimensions.depth)," ×"," ",LCg(B.dimensions.height)]})]})]})]}),W.jsxs(kO,{children:[W.jsx($E,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),W.jsxs($E,{disabled:!B||E,onClick:()=>{B&&jJI({generatedBox:B,projectName:e})},children:[W.jsx(EtA,{}),"Download 3MF"]})]})]})})}const hSo=g=>{const A=_Bg(aA=>aA.lastRunEvalVersion),I=nF(aA=>aA.currentMainComponentPath),[e,t]=gA.useState(null),[o,B]=gA.useState(!1),[C,Q]=gA.useState(!0),[i,E]=gA.useState(!1),[n,s]=gA.useState(null),[r,a]=gA.useState(null),[c,h]=gA.useState(!1),[l,D]=gA.useState(null),[d,y]=gA.useState(null),[w,u]=gA.useState(!1),[G,m]=gA.useState(!1),[p,k]=gA.useState(!1),[S,R]=gA.useState(!1),[x,N]=gA.useState(null),U=dMo(),K=nF(aA=>aA.pushEvent),Y=nF(aA=>aA.recentEvents),_=gA.useMemo(()=>Date.now(),[]);_Go(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))}}),gA.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"),xA=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))),xA&&(E(!1),s(null),D("Snippet saved successfully."),u(!1))},[Y,i]);const q=async()=>{E(!0),s(Date.now()),D(null),u(!1),await K({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:e})},Z=nF(aA=>aA.circuitJson)??g.circuitJson,O=gA.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]),[AA,tA]=gA.useState(!1),[eA,QA]=gA.useState(!1),{BugReportDialog:sA,openBugReportDialog:dA}=uMo({onLoginRequired:g.onLoginRequired}),CA=async aA=>{x&&(await zJI({circuitJson:x.circuitJson,projectName:x.projectName,options:aA}),N(null))},hA=gA.useMemo(()=>MMo(g.autoroutingLog),[g.autoroutingLog]),nA=aA=>{if(!Z){rQ.error("No Circuit JSON to export");return}const SA=hA?.value.simpleRouteJson;if(aA==="LightBurn"){N({circuitJson:Z,projectName:O}),k(!0);return}qpo({exportName:aA,circuitJson:Z,simpleRouteJson:SA,projectName:O})};return W.jsxs(W.Fragment,{children:[W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1 rf-flex-shrink-0",children:[W.jsxs(HGA,{children:[W.jsx(vGA,{asChild:!0,children:W.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"File"})}),W.jsxs(ytA,{className:"rf-z-[101]",children:[!g.isWebEmbedded&&W.jsxs(W.Fragment,{children:[W.jsx(s0,{className:"rf-text-xs",onSelect:q,disabled:i,children:i?"Saving...":"Push"}),parseInt(window.location.port)>5e3&&W.jsx(s0,{className:"rf-text-xs",onSelect:()=>{U.open()},children:"Order"}),W.jsx(s0,{className:"rf-text-xs",onSelect:()=>tA(!0),disabled:i,children:"Import"}),W.jsx(s0,{className:"rf-text-xs",onSelect:()=>{if(!nQA()){rQ.error("Requires tscircuit token");return}QA(!0)},children:"AI Review"})]}),!g.isWebEmbedded&&g.onLoginRequired&&W.jsx(s0,{className:"rf-text-xs",onSelect:()=>{g.onLoginRequired?.()},children:"Sign In"}),!g.isWebEmbedded&&W.jsxs(dtA,{children:[W.jsx(iO,{className:"rf-text-xs",children:"Report Bug"}),W.jsx(DtA,{children:W.jsxs(EO,{children:[W.jsx(s0,{className:"rf-text-xs",onSelect:()=>{dA()},children:"Report Entire Circuit"}),W.jsx(s0,{className:"rf-text-xs",disabled:!hA||!g.onReportAutoroutingLog,onSelect:()=>{!hA||!g.onReportAutoroutingLog||g.onReportAutoroutingLog(hA.key,{simpleRouteJson:hA.value.simpleRouteJson})},children:"Report Autorouter Bug"})]})})]}),W.jsxs(dtA,{children:[W.jsx(iO,{className:"rf-text-xs",disabled:G,children:G?"Exporting...":"Export"}),W.jsx(DtA,{children:W.jsx(EO,{children:vpo.map((aA,SA)=>W.jsx(s0,{onSelect:()=>nA(aA.name),disabled:G||aA.name==="Simple Route JSON"&&!hA,children:W.jsx("span",{className:"rf-text-xs",children:aA.name})},SA))})})]}),W.jsx(s0,{className:"rf-text-xs",disabled:G,onSelect:()=>{if(!Z){rQ.error("No Circuit JSON to export");return}R(!0)},children:"Export Accessory…"}),!g.isWebEmbedded&&W.jsxs(dtA,{children:[W.jsx(iO,{className:"rf-text-xs",children:"Advanced"}),W.jsx(DtA,{children:W.jsxs(EO,{children:[W.jsx(s0,{className:"rf-flex rf-items-center rf-gap-2",children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(vtA,{id:"load-latest-eval",checked:g.shouldLoadLatestEval,onCheckedChange:aA=>{g.onChangeShouldLoadLatestEval?.(aA===!0)}}),W.jsx("label",{htmlFor:"load-latest-eval",className:"rf-text-xs rf-cursor-pointer",children:"Force Latest @tscircuit/eval"})]})}),A&&W.jsx(s0,{className:"rf-flex rf-items-center rf-gap-2",children:W.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:W.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/eval@",A]})})}),W.jsx(s0,{className:"rf-flex rf-items-center rf-gap-2",children:W.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:W.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/runframe@",NGo.version]})})}),W.jsx(s0,{className:"rf-flex rf-items-center rf-gap-2",onClick:()=>{window.open("/api/admin","_blank")},children:W.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:W.jsx("span",{className:"rf-text-xs",children:"CLI Admin Panel"})})})]})})]})]}),W.jsx(GJI,{open:w,onOpenChange:u,children:W.jsxs(vBg,{children:[W.jsxs(qBg,{children:[W.jsx(ZBg,{children:"Error Saving Snippet"}),W.jsx(OBg,{children:d})]}),W.jsx(TBg,{children:W.jsx(WBg,{onClick:()=>u(!1),children:"Dismiss"})})]})}),W.jsx(YGo,{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})]}),W.jsxs(HGA,{children:[W.jsx(vGA,{asChild:!0,children:W.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"View"})}),W.jsx(ytA,{className:"rf-z-[101]",children:W.jsxs(dtA,{children:[W.jsx(iO,{className:"rf-text-xs",children:"Schematic"}),W.jsx(DtA,{children:W.jsxs(EO,{children:[W.jsx(s0,{className:"rf-flex rf-items-center rf-gap-2",onSelect:aA=>aA.preventDefault(),children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(vtA,{id:"show-schematic-ports",checked:g.showSchematicPorts,onCheckedChange:aA=>{g.onChangeShowSchematicPorts?.(aA===!0)}}),W.jsx("label",{htmlFor:"show-schematic-ports",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Ports"})]})}),W.jsx(s0,{className:"rf-flex rf-items-center rf-gap-2",onSelect:aA=>aA.preventDefault(),children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(vtA,{id:"show-schematic-grid",checked:g.showSchematicDebugGrid,onCheckedChange:aA=>{g.onChangeShowSchematicDebugGrid?.(aA===!0)}}),W.jsx("label",{htmlFor:"show-schematic-grid",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Grid"})]})})]})})]})})]})]}),sA,W.jsx(GMo,{open:p,onOpenChange:k,onExport:CA}),Z&&W.jsx(cSo,{open:S,onOpenChange:R,circuitJson:Z,projectName:O}),W.jsx(WJI,{isOpen:AA,onClose:()=>tA(!1)}),W.jsx(fko,{isOpen:eA,onClose:()=>QA(!1),packageName:e}),W.jsx(mwI,{position:"top-center",reverseOrder:!1,containerStyle:{zIndex:1e5},toastOptions:{className:"rf-break-all",style:{zIndex:1e5}}}),W.jsx(U.OrderDialog,{isOpen:U.isOpen,onClose:U.close,stage:U.stage,setStage:U.setStage})]})};var lSo=Object.defineProperty,Zy=(g,A)=>lSo(g,"name",{value:A,configurable:!0}),[YCg,OgB]=dM("Tooltip",[IO]),_Cg=IO(),DSo="TooltipProvider",dSo=700,bCg="tooltip.open",[ySo,HCg]=YCg(DSo),wSo=Zy(g=>{const{__scopeTooltip:A,delayDuration:I=dSo,skipDelayDuration:e=300,disableHoverableContent:t=!1,children:o}=g,B=gA.useRef(!0),C=gA.useRef(!1),Q=gA.useRef(0);return gA.useEffect(()=>{const i=Q.current;return()=>window.clearTimeout(i)},[]),W.jsx(ySo,{scope:A,isOpenDelayedRef:B,delayDuration:I,onOpen:gA.useCallback(()=>{e<=0||(window.clearTimeout(Q.current),B.current=!1)},[e]),onClose:gA.useCallback(()=>{e<=0||(window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>B.current=!0,e))},[e]),isPointerInTransitRef:C,onPointerInTransitChange:gA.useCallback(i=>{C.current=i},[]),disableHoverableContent:t,children:o})},"TooltipProvider"),vCg="Tooltip",[uSo,ApA]=YCg(vCg),GSo=Zy(g=>{const{__scopeTooltip:A,children:I,open:e,defaultOpen:t,onOpenChange:o,disableHoverableContent:B,delayDuration:C}=g,Q=HCg(vCg,g.__scopeTooltip),i=_Cg(A),[E,n]=gA.useState(null),[s,r]=gA.useState(void 0),a=wM(),c=gA.useRef(0),h=B??Q.disableHoverableContent,l=C??Q.delayDuration,D=gA.useRef(!1),[d,y]=NN({prop:e,defaultProp:t??!1,onChange:Zy(k=>{k?(Q.onOpen(),document.dispatchEvent(new CustomEvent(bCg))):Q.onClose(),o?.(k)},"onChange"),caller:vCg}),w=gA.useMemo(()=>d?D.current?"delayed-open":"instant-open":"closed",[d]),u=gA.useCallback(()=>{window.clearTimeout(c.current),c.current=0,D.current=!1,y(!0)},[y]),G=gA.useCallback(()=>{window.clearTimeout(c.current),c.current=0,y(!1)},[y]),m=gA.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>{D.current=!0,y(!0),c.current=0},l)},[l,y]);gA.useEffect(()=>()=>{c.current&&(window.clearTimeout(c.current),c.current=0)},[]);const p=s??a;return W.jsx(pGA,{...i,children:W.jsx(uSo,{scope:A,contentId:p,setContentId:r,open:d,stateAttribute:w,trigger:E,onTriggerChange:n,onTriggerEnter:gA.useCallback(()=>{Q.isOpenDelayedRef.current?m():u()},[Q.isOpenDelayedRef,m,u]),onTriggerLeave:gA.useCallback(()=>{h?G():(window.clearTimeout(c.current),c.current=0)},[G,h]),onOpen:u,onClose:G,disableHoverableContent:h,children:I})})},"Tooltip"),tPI="TooltipTrigger",mSo=gA.forwardRef(Zy(function(A,I){const{__scopeTooltip:e,"aria-describedby":t,...o}=A,B=ApA(tPI,e),C=HCg(tPI,e),Q=_Cg(e),i=gA.useRef(null),E=$i(I,i,B.onTriggerChange),n=gA.useRef(!1),s=gA.useRef(!1),r=gA.useCallback(()=>n.current=!1,[]);return gA.useEffect(()=>()=>document.removeEventListener("pointerup",r),[r]),W.jsx(log,{asChild:!0,...Q,children:W.jsx(iE.button,{"aria-describedby":B.open?aPI(t,B.contentId):t,"data-state":B.stateAttribute,...o,ref:E,onPointerMove:_o(A.onPointerMove,a=>{a.pointerType!=="touch"&&!s.current&&!C.isPointerInTransitRef.current&&(B.onTriggerEnter(),s.current=!0)}),onPointerLeave:_o(A.onPointerLeave,()=>{B.onTriggerLeave(),s.current=!1}),onPointerDown:_o(A.onPointerDown,()=>{B.open&&B.onClose(),n.current=!0,document.addEventListener("pointerup",r,{once:!0})}),onFocus:_o(A.onFocus,()=>{n.current||B.onOpen()}),onBlur:_o(A.onBlur,B.onClose),onClick:_o(A.onClick,B.onClose)})})},"TooltipTrigger")),pSo="TooltipPortal",[WgB,kSo]=YCg(pSo,{forceMount:void 0}),AoA="TooltipContent",oPI=gA.forwardRef(Zy(function(A,I){const e=kSo(AoA,A.__scopeTooltip),{forceMount:t=e.forceMount,side:o="top",...B}=A,C=ApA(AoA,A.__scopeTooltip);return W.jsx(xf,{present:t||C.open,children:C.disableHoverableContent?W.jsx(BPI,{side:o,...B,ref:I}):W.jsx(MSo,{side:o,...B,ref:I})})},"TooltipContent")),MSo=gA.forwardRef(Zy(function(A,I){const e=ApA(AoA,A.__scopeTooltip),t=HCg(AoA,A.__scopeTooltip),o=gA.useRef(null),B=$i(I,o),[C,Q]=gA.useState(null),{trigger:i,onClose:E}=e,n=o.current,{onPointerInTransitChange:s}=t,r=gA.useCallback(()=>{Q(null),s(!1)},[s]),a=gA.useCallback((c,h)=>{const l=c.currentTarget,D={x:c.clientX,y:c.clientY},d=CPI(D,l.getBoundingClientRect()),y=QPI(D,d),w=iPI(h.getBoundingClientRect()),u=nPI([...y,...w]);Q(u),s(!0)},[s]);return gA.useEffect(()=>()=>r(),[r]),gA.useEffect(()=>{if(i&&n){const c=Zy(l=>a(l,n),"handleTriggerLeave"),h=Zy(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]),gA.useEffect(()=>{if(C){const c=Zy(h=>{const l=h.target,D={x:h.clientX,y:h.clientY},d=i?.contains(l)||n?.contains(l),y=!EPI(D,C);d?r():y&&(r(),E())},"handleTrackPointerGrace");return document.addEventListener("pointermove",c),()=>document.removeEventListener("pointermove",c)}},[i,n,C,E,r]),W.jsx(BPI,{...A,ref:B})},"TooltipContentHoverable")),SSo=K0g("TooltipContent"),BPI=gA.forwardRef(Zy(function(A,I){const{__scopeTooltip:e,children:t,"aria-label":o,id:B,onEscapeKeyDown:C,onPointerDownOutside:Q,...i}=A,E=ApA(AoA,e),n=_Cg(e),{onClose:s}=E,[r,a]=gA.useState(null),c=$i(I,a);gog(r),gA.useEffect(()=>(document.addEventListener(bCg,s),()=>document.removeEventListener(bCg,s)),[s]),gA.useEffect(()=>{if(E.trigger){const l=Zy(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 Eh(()=>(h(B),()=>{h(void 0)}),[B,h]),W.jsx(sGA,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:C,onPointerDownOutside:Q,onFocusOutside:l=>l.preventDefault(),onDismiss:s,children:W.jsxs(Dog,{"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:[W.jsx(SSo,{children:t}),o?W.jsx(xMo,{id:E.contentId,role:"tooltip",children:o}):null]})})},"TooltipContentImpl"));function CPI(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")}}Zy(CPI,"getExitSideFromRect");function QPI(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}Zy(QPI,"getPaddedExitPoints");function iPI(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}]}Zy(iPI,"getPointsFromRect");function EPI(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}Zy(EPI,"isPointInPolygon");function nPI(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),sPI(A)}Zy(nPI,"getHull");function sPI(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)}Zy(sPI,"getHullPresorted");function aPI(...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}Zy(aPI,"concatAriaDescribedby");const fSo=wSo,RSo=GSo,NSo=mSo,rPI=gA.forwardRef(({className:g,sideOffset:A=4,...I},e)=>W.jsx(oPI,{ref:e,sideOffset:A,className:dB("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}));rPI.displayName=oPI.displayName;const xSo="24b58135-86c7-4e4b-bf6e-cca862bc4b26",cPI="runframe-crisp-chat-script",FSo="tscircuit.com",goA=g=>{window.$crisp=window.$crisp||[],window.$crisp.push(g)},USo=()=>{if(window.$crisp=window.$crisp||[],window.CRISP_WEBSITE_ID=xSo,window.__RUNFRAME_CRISP_CONFIGURED__||(window.__RUNFRAME_CRISP_CONFIGURED__=!0,goA(["do","chat:hide"]),goA(["on","chat:closed",()=>goA(["do","chat:hide"])])),!document.getElementById(cPI)){const g=document.createElement("script");g.id=cPI,g.src="https://client.crisp.chat/l.js",g.async=!0,document.head.appendChild(g)}},JSo=()=>{USo(),goA(["do","chat:show"]),goA(["do","chat:open"])},PSo=({isCli:g,hostname:A=typeof window<"u"?window.location.hostname:void 0}={})=>A?.toLowerCase()===FSo?!1:!!g,KSo=()=>W.jsx(fSo,{children:W.jsxs(RSo,{children:[W.jsx(NSo,{asChild:!0,children:W.jsx($E,{type:"button",variant:"ghost",size:"icon","aria-label":"Get Support or Give Feedback",onClick:JSo,className:"rf-h-8 rf-w-8",children:W.jsx(Rso,{className:"rf-h-4 rf-w-4 rf-text-gray-500"})})}),W.jsx(rPI,{side:"bottom",children:"Get Support or Give Feedback"})]})}),aF="rf-h-[620px] rf-min-h-full rf-max-h-full",hPI=["assembly","pinout","analog_simulation","bom","circuit_json","errors","render_log","autorouting","solvers"],qCg=g=>g instanceof Error?g.message:"An unknown error occurred",LSo=({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:q,showToggleFullScreen:j=!0,defaultToFullScreen:Z=!1,activeEffectName:O,allowSelectingVersion:AA=zF("TSCIRCUIT_ALLOW_SELECTING_EVAL_VERSION")!==!1,showFileMenu:tA=!1,isWebEmbedded:eA=!1,isCli:QA=!1,projectName:sA,schematicSvgOptions:dA,hideSchematicInAnalogSimulation:CA=!1,onRerunWithDebug:hA,solverEvents:nA,autoroutingPhases:aA,onPcbBoundsSelected:SA})=>{MBg();const{versions:xA,latestVersion:rA,lastRunEvalVersion:NA,search:RA,setSearch:UA,selectVersion:vA}=FGo(AA),KA=gA.useMemo(()=>B?B.filter(Jg=>Jg&&"error_type"in Jg||Jg.type.includes("error")):null,[B]),kA=gA.useMemo(()=>B?B.filter(Jg=>Jg&&"warning_type"in Jg||Jg.type.includes("warning")):null,[B]),YA=gA.useMemo(()=>B?B.some(Jg=>Jg.type==="schematic_group"):!0,[B]),DA=gA.useMemo(()=>B?.some(Jg=>Jg.type==="pcb_panel"),[B]),bA=(!x||x.includes("schematic"))&&YA&&!DA,{controller:WA,focusSchematicComponent:Eg}=fwo(),{controller:LA,focusPcbComponent:uA}=Qso(),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=bA?({source_component_id:Jg})=>{const AI=B?.find(Og=>Og.type==="schematic_component"&&Og.source_component_id===Jg);AI?.type==="schematic_component"&&(Eg(AI.schematic_component_id),YI("schematic"))}:void 0,og=gA.useMemo(()=>!B||!G||KA?.length?!1:B.some(AI=>AI.type==="simulation_experiment")&&!nye(B),[B,KA,G]),dg=gA.useMemo(()=>KA?.find(Jg=>Jg.type.startsWith("simulation_")),[KA]);aJI({errorMessage:t,errorStack:o,circuitJsonErrors:KA});const Rg=gA.useMemo(()=>reo(N),[N]),Qg=[...["pcb","schematic","cad",...hPI].filter(Jg=>(!x||x.includes(Jg))&&(Jg!=="render_log"||s)),...i?["code"]:[],...Rg.map(Jg=>Jg.tabId)],_g=S??R,EI=_g&&Qg.includes(_g)?_g:x?.find(Jg=>Qg.includes(Jg))??Qg[0]??"pcb",[GA,ng]=TUI("runframe-active-tab",EI,S),pg=Qg.includes(GA)?GA:EI;gA.useEffect(()=>{GA!==pg&&(ng(pg),r?.(pg))},[GA,pg,ng,r]);const Ug=Rg.find(Jg=>Jg.tabId===pg);RGo({source:"runframe",component:"CircuitJsonPreview",isWebEmbedded:eA,activeTab:pg});const[mg,fg]=gA.useState(null),[Kg,gg]=gA.useState(Z),[ag,wg]=gA.useState(K),[Hg,II]=gA.useState(Y),BI=_?K:ag,$g=q?Y:Hg,pI=_??wg,DI=q??II;$wo(Kg);const YI=gA.useCallback(Jg=>{ng(Jg),r?.(Jg)},[r,ng]),Ae=()=>{gg(!Kg)};gA.useEffect(()=>{t&&(pg!=="errors"&&fg(pg),YI("errors"))},[t]),gA.useEffect(()=>{(pg==="code"||pg==="errors")&&B&&!t&&YI(mg&&Qg.includes(mg)?mg:EI)},[B]);const JA=gA.useCallback(Jg=>{window.TSCIRCUIT_3D_OBJECT_REF=Jg===null?void 0:Jg},[]);return W.jsx("div",{className:dB("flex flex-col relative rf-overflow-x-hidden rf-h-full",h),children:W.jsx("div",{className:dB("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:W.jsxs(_NA,{value:pg,onValueChange:YI,className:"rf-flex-grow rf-flex rf-flex-col rf-h-full",children:[W.jsxs("div",{className:dB("rf-flex rf-flex-wrap rf-items-center rf-gap-2 rf-p-2 rf-pb-0 rf-shrink-0",l),children:[W.jsxs("div",{className:dB("rf-flex rf-flex-1 rf-min-w-0 rf-items-center",(D||tA)&&"rf-basis-48"),children:[D,tA&&!D&&W.jsx(hSo,{isWebEmbedded:eA,circuitJson:B,projectName:sA,autoroutingLog:w,onReportAutoroutingLog:u,showSchematicDebugGrid:BI,onChangeShowSchematicDebugGrid:pI,showSchematicPorts:$g,onChangeShowSchematicPorts:DI}),!D&&!tA&&G&&W.jsx(Cf,{className:"rf-w-4 rf-h-4 rf-animate-spin"})]}),a&&a.progress!==1&&!t&&W.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:[W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0 rf-flex-1",title:O??a.lastRenderEvent?.phase??"",children:O??a.lastRenderEvent?.phase}),W.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:W.jsx(Cf,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),W.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&&PSo({isCli:QA})&&W.jsx(KSo,{}),W.jsxs("div",{className:"rf-flex rf-min-w-0 rf-max-w-full rf-items-center rf-gap-2 rf-ml-auto",children:[Q&&W.jsxs(hQA,{className:"rf-min-w-0 rf-justify-start rf-overflow-x-auto rf-overflow-y-hidden",children:[i&&W.jsx(KN,{value:"code",children:"Code"}),!x||x.includes("pcb")?W.jsxs(KN,{value:"pcb",className:"rf-whitespace-nowrap",children:[B&&W.jsx("span",{className:dB("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")?W.jsxs(KN,{value:"schematic",className:dB("rf-whitespace-nowrap",B&&!YA&&"rf-opacity-50"),disabled:B?!YA||DA:!1,children:[B&&W.jsx("span",{className:dB("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")?W.jsxs(KN,{value:"cad",children:[B&&W.jsx("span",{className:dB("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)&&W.jsx(KN,{value:pg,children:Ug?.tabName??wug(pg)}),W.jsxs(HGA,{children:[W.jsx(vGA,{asChild:!0,children:W.jsxs("button",{type:"button","aria-label":"More views",className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[W.jsx(mso,{className:"rf-w-4 rf-h-4"}),(KA&&KA.length>0||t)&&W.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"})]})}),W.jsxs(ytA,{className:"rf-*:text-xs rf-z-[101]",children:[Rg.map(Jg=>W.jsxs(s0,{onSelect:()=>YI(Jg.tabId),children:[pg===Jg.tabId?W.jsx(jZ,{className:"rf-w-3 rf-h-3"}):W.jsx(qtg,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),W.jsx("div",{className:"rf-pr-2",children:Jg.tabName})]},Jg.tabId)),hPI.filter(Jg=>!x||x.includes(Jg)).map(Jg=>W.jsxs(s0,{onSelect:()=>YI(Jg),children:[pg!==Jg&&W.jsx(qtg,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),pg===Jg&&W.jsx(jZ,{className:"rf-w-3 rf-h-3"}),W.jsx("div",{className:"rf-pr-2",children:wug(Jg)}),Jg==="errors"&&(KA&&KA.length>0||t)&&W.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:KA?.length}),Jg==="solvers"&&nA&&nA.length>0&&W.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)),W.jsx(s0,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:W.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",rJI.split(".").map((Jg,AI)=>AI===2?parseInt(Jg)+1:Jg).join(".")]})}),AA?W.jsxs(dtA,{onOpenChange:Jg=>!Jg&&UA(""),children:[W.jsx(iO,{className:"rf-text-xs rf-opacity-60",children:W.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",NA??rA??"latest"]})}),W.jsx(DtA,{children:W.jsxs(EO,{className:"rf-*:text-xs rf-w-40 rf-max-h-[200px] rf-overflow-y-auto",children:[W.jsx("div",{className:"rf-p-1",children:W.jsx(kBg,{value:RA,onChange:Jg=>UA(Jg.target.value),placeholder:"Search...",className:"rf-h-7 rf-text-xs"})}),W.jsx(lxI,{}),W.jsx(s0,{onSelect:()=>vA(null),children:rA?`${rA} (latest)`:"latest"}),xA.map(Jg=>W.jsx(s0,{onSelect:()=>vA(Jg),children:Jg},Jg))]})})]}):NA&&W.jsx(s0,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:W.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",NA]})})]})]})]}),j&&W.jsx($E,{onClick:Ae,"aria-label":Kg?"Exit fullscreen":"Enter fullscreen",variant:"ghost",className:"rf-shrink-0",children:Kg?W.jsx(Nso,{size:16}):W.jsx(kso,{size:16})})]})]}),i&&W.jsx(yy,{value:"code",className:"rf-flex-grow rf-min-h-0 rf-overflow-hidden",children:W.jsx("div",{className:"rf-h-full",children:E})}),(!x||x.includes("pcb"))&&W.jsx(yy,{value:"pcb",className:"rf-min-h-0",children:W.jsx("div",{className:"rf-overflow-hidden rf-h-full",children:W.jsx(zR,{fallbackRender:({error:Jg})=>W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:qCg(Jg)})]})}),children:B?W.jsx(zwo,{controller:LA,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)}}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("assembly"))&&W.jsx(yy,{value:"assembly",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallback:W.jsx("div",{children:"Error loading Assembly"}),children:B?W.jsx(Rwo,{circuitJson:B,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("pinout"))&&W.jsx(yy,{value:"pinout",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallback:W.jsx("div",{children:"Error loading Pinout Viewer"}),children:B?W.jsx(Nwo,{circuitJson:B,containerStyle:{height:"100%"}}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("schematic"))&&W.jsx(yy,{value:"schematic",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto rf-bg-white",aF),children:W.jsx(zR,{fallbackRender:({error:Jg})=>W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:qCg(Jg)})]})}),children:B?W.jsx(awo,{platformConfig:g,onViewPcbComponent:OA,controller:WA,circuitJson:B,containerStyle:{height:"100%"},debugGrid:BI,showSchematicPorts:$g,css:dA?.css,className:dA?.className}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("cad"))&&W.jsx(yy,{value:"cad",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallbackRender:({error:Jg,resetErrorBoundary:AI})=>W.jsx(iso,{error:Jg,resetErrorBoundary:AI}),children:B?W.jsx(seo,{ref:JA,circuitJson:B,autoRotateDisabled:U,onViewSchematicComponent:$A},`cad-${Kg}`):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("analog_simulation"))&&W.jsx(yy,{value:"analog_simulation",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallback:W.jsx("div",{children:"Error loading Analog Simulation"}),children:B?dg?W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error running analog simulation"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:dg.message})]})}):og?W.jsx("div",{className:"rf-flex rf-h-full rf-min-h-[300px] rf-items-center rf-justify-center rf-bg-slate-50",children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-text-sm rf-text-slate-600",children:[W.jsx(Cf,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Running analog simulation..."]})}):W.jsx(Swo,{circuitJson:B,hideSchematic:CA,containerStyle:{height:"100%"}}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("bom"))&&W.jsx(yy,{value:"bom",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallbackRender:({error:Jg})=>W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:qCg(Jg)})]})}),children:B?W.jsx(jwo,{circuitJson:B}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("circuit_json"))&&W.jsx(yy,{value:"circuit_json",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallback:W.jsx("div",{children:"Error loading JSON viewer"}),children:B?W.jsx(Uwo,{elements:B}):W.jsx($J,{onRunClicked:e})})})}),(!x||x.includes("errors"))&&W.jsx(yy,{value:"errors",className:"rf-h-full rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-hidden",aF),children:t||KA&&KA.length>0||B?W.jsx(xco,{code:A,fsMap:I,circuitJsonErrors:KA,circuitJsonWarnings:kA,errorMessage:t,errorStack:o,circuitJson:B,evalVersion:NA,autoroutingLog:w,onReportAutoroutingLog:u}):W.jsx($J,{onRunClicked:e})})}),s&&(!x||x.includes("render_log"))&&W.jsx(yy,{value:"render_log",className:"rf-min-h-0",children:W.jsx(Iuo,{renderLog:a,onRerunWithDebug:hA})}),(!x||x.includes("autorouting"))&&W.jsx(yy,{value:"autorouting",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-auto",aF),children:W.jsx(zR,{fallback:W.jsx("div",{className:"rf-p-4",children:"Error loading autorouting captures"}),children:W.jsx(fGo,{circuitJson:B,phases:aA,isRunning:G})})})}),(!x||x.includes("solvers"))&&W.jsx(yy,{value:"solvers",className:"rf-min-h-0",children:W.jsx("div",{className:dB("rf-overflow-hidden",aF),children:W.jsx(zR,{fallback:W.jsx("div",{children:"Error loading Solvers view"}),children:W.jsx(lGo,{solverEvents:nA})})})}),Rg.map(Jg=>W.jsx(ceo,{tab:Jg,active:pg===Jg.tabId,isFullScreen:Kg},Jg.tabId))]})})})};hOI.createRoot(document.getElementById("root")).render(W.jsx("div",{style:{height:"100vh"},children:W.jsx(LSo,{defaultActiveTab:"cad",autoRotate3dViewerDisabled:!0,showRightHeaderContent:!1,circuitJson:window.CIRCUIT_JSON||{},...window.CIRCUIT_JSON_PREVIEW_PROPS||{}})}));const Pb=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));var YSo=0,rF=class{_nodeId;hasExplicitNodeId;_sourceLocation;_dirty=!1;_parent;_revision=0;constructor(g={}){this.hasExplicitNodeId=g.nodeId!==void 0,this._nodeId=g.nodeId??lPI(g.sourceLocation,this.constructor.name)??`altium-node-${(++YSo).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=lPI(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 lPI(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 Kb=class extends Error{code;constructor(g,A="ALTIUM_ERROR",I){super(g,I),this.name=new.target.name,this.code=A}},pL=class extends Kb{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}},Iu=class extends Kb{constructor(g,A){super(g,"ALTIUM_FORMAT_DETECTION",A)}},zQ=class extends Kb{byteOffset;constructor(g,A={}){super(g,"ALTIUM_CORRUPT_CONTAINER",{cause:A.cause}),this.byteOffset=A.byteOffset}},_So=class extends Kb{constructor(g,A){super(g,"ALTIUM_UNSUPPORTED_VERSION",A)}},TCg=class extends Kb{constructor(g,A){super(g,"ALTIUM_UNSUPPORTED_FEATURE",A)}},Qc=class extends Kb{constructor(g,A){super(g,"ALTIUM_SERIALIZATION",A)}},Rh=class extends Kb{byteOffset;constructor(g,A,I){super(g,"ALTIUM_TRUNCATED_RECORD",I),this.byteOffset=A}},bSo=class extends rF{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 HSo(this.stream.content,g)}getChildren(){return[this.record,this.stream]}getString(){return this.record.getString()}};async function HSo(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 cQA(i=>{if(t+=i.byteLength,t>I)throw new zQ(`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 zQ?C:new zQ(`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 eu(g){if(!Number.isFinite(g))return g;const A=(g%360+360)%360;return Object.is(A,-0)?0:A}function ZCg(g,A,I=1e-9){return Math.abs(g.x-A.x)<=I&&Math.abs(g.y-A.y)<=I}function vSo(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 qSo(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 TSo(g){const A=qSo(g);return Math.abs(A)<=Number.EPSILON?"degenerate":A<0?"clockwise":"counterclockwise"}var OCg=class extends rF{terminator;constructor(g={}){super(g),this.terminator=g.terminator??""}},oN=class extends rF{type="field";_key;_value;constructor(g){super(g),DPI(g.key),dPI(g.value??""),this._key=g.key,this._value=g.value??""}get key(){return this._key}set key(g){DPI(g),g!==this._key&&(this._key=g,this.markDirty())}get value(){return this._value}set value(g){dPI(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 DPI(g){if(g.length===0||/[=|\r\n]/u.test(g))throw new Error(`Invalid Altium field key: ${JSON.stringify(g)}`)}function dPI(g){if(/[|\r\n]/u.test(g))throw new Error(`Altium field values cannot contain record delimiters: ${JSON.stringify(g)}`)}var ZSo={cm:1e4/25.4,in:1e3,inch:1e3,inches:1e3,mil:1,mils:1,mm:1e3/25.4},OSo=/^([+-]?(?:\d+\.\d*|\d+|\.\d+)(?:e[+-]?\d+)?)([a-z]+)?$/iu,IoA=class c7I{unit;value;#C;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.#C=A.raw??`${jSo(A.value)}${A.unit===void 0?"":A.unit}`}static parse(A){const I=OSo.exec(A.trim());if(!I?.[1])return;const e=Number(I[1]);if(Number.isFinite(e))return new c7I({raw:A,unit:I[2],value:e})}get normalizedUnit(){return this.unit?.toLowerCase()}get raw(){return this.#C}toMils(){return this.normalizedUnit===void 0?this.value:this.value*(ZSo[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 RO(g){return g===void 0?void 0:IoA.parse(g)}function eoA(g){return RO(g)?.toMils()}function WSo(g,A="mil"){if(g instanceof IoA)return g;if(typeof g=="string"){const I=IoA.parse(g);if(!I)throw new TypeError(`Invalid Altium measurement ${JSON.stringify(g)}`);return I}return typeof g=="number"?new IoA({unit:A,value:g}):new IoA(g)}function VSo(g,A="mil"){return WSo(g,A).toString()}function jSo(g){return Object.is(g,-0)?"-0":String(g)}var bn=class extends OCg{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 RO(this.getCaseInsensitive(g))}get recordKind(){return this.get("RECORD")}get fields(){return this.items.filter(g=>g instanceof oN)}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):$So(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||!zSo(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 oN({key:g,value:A}).setParent(this);this.items.push(e),this.markDirty()}return this}setMeasurement(g,A,I="mil"){return this.set(g,VSo(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(eu(A)))}insertField(g,A,I={}){const e=new oN({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 oN&&B.key===I.beforeKey)),t===void 0&&I.afterKey!==void 0){const B=this.items.findLastIndex(C=>C instanceof oN&&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 oN&&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 zSo(g){return/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/iu.test(g.trim())}var XSo=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 $So(g){const A=[];for(const I of g){const e=XSo.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 Hi(g,...A){for(const I of A){const e=eoA(g.getCaseInsensitive(I));if(e!==void 0)return e}}function r0(g,A,I){const e=Hi(g,...A),t=Hi(g,...I);return e===void 0||t===void 0?void 0:{x:e,y:t}}function toA(g,A,I){const e=Hi(g,...A),t=Hi(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 A2o(g,...A){for(const I of A){const e=g.getNumber(I);if(e!==void 0)return e}}var gpA=class extends bn{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 r0(this,["X","LOCATION.X"],["Y","LOCATION.Y"])}get rotation(){return eu(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 Hi(this,"HEIGHT")}getOwnedPrimitives(g){return g.getRecordsOwnedByComponent(this)}getBounds(g,A){return g.getComponentBounds(this,A)}},IpA=class extends bn{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")}},g2o=65535,yPI=new WeakMap,I2o=class{constructor(g){this.document=g,this.components=g.getRecordsByKind("Component").filter(A=>A instanceof gpA),this.nets=g.getRecordsByKind("Net").filter(A=>A instanceof IpA),this.polygons=g.getRecordsByKind("Polygon"),this.rules=[...g.getRecordsByKind("Rule"),...g.getRecordsByKind("DXPRule")],this.componentTargets=tpA(this.components),this.netTargets=tpA(this.nets),this.polygonTargets=tpA(this.polygons),this.ruleTargets=tpA(this.rules);for(const A of g.records){jCg(this.byKind,A.recordKind??"Unknown",A);const I=A.getDecoded("LAYER");I!==void 0&&jCg(this.byLayer,I.toUpperCase(),A),opA(this.byComponent,A,"COMPONENT"),opA(this.byNet,A,"NET"),opA(this.byPolygon,A,"POLYGON"),opA(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 Yb(g)?this.componentTargets.get(g):void 0}getNet(g){return Yb(g)?this.netTargets.get(g):void 0}getPolygon(g){return Yb(g)?this.polygonTargets.get(g):void 0}getRule(g){return Yb(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=Lb(I,e);o!==void 0&&!t.has(o)&&g.push({field:e,index:o,record:I})}return g}};function yr(g){const A=yPI.get(g);if(A?.revision===g.revision)return A.index;const I=new I2o(g);return yPI.set(g,{index:I,revision:g.revision}),I}function wPI(g,A){return yr(g).getComponent(A)}function uPI(g,A){return yr(g).getNet(A)}function GPI(g,A){return yr(g).getPolygon(A)}function mPI(g,A){return yr(g).getRule(A)}function WCg(g,A){return A instanceof gpA?kL(yr(g).components,A):Lb(A,"COMPONENT")}function VCg(g,A){return A instanceof IpA?kL(yr(g).nets,A):Lb(A,"NET")}function e2o(g,A){return A.recordKind==="Polygon"?kL(yr(g).polygons,A):Lb(A,"POLYGON")}function t2o(g,A){return A.recordKind==="Rule"||A.recordKind==="DXPRule"?kL(yr(g).rules,A):Lb(A,"RULE")??Lb(A,"RULEINDEX")}function pPI(g,A){const I=WCg(g,A);return I===void 0?void 0:yr(g).getComponent(I)}function kPI(g,A){const I=VCg(g,A);return I===void 0?void 0:yr(g).getNet(I)}function MPI(g,A){const I=e2o(g,A);return I===void 0?void 0:yr(g).getPolygon(I)}function SPI(g,A){const I=t2o(g,A);return I===void 0?void 0:yr(g).getRule(I)}function epA(g,A){const I=typeof A=="number"?A:kL(yr(g).components,A);return I===void 0?[]:[...yr(g).byComponent.get(I)??[]]}function fPI(g,A){const I=typeof A=="number"?A:kL(yr(g).nets,A);return I===void 0?[]:[...yr(g).byNet.get(I)??[]]}function RPI(g,A){const I=typeof A=="number"?A:kL(yr(g).polygons,A);return I===void 0?[]:[...yr(g).byPolygon.get(I)??[]]}function NPI(g,A){const I=typeof A=="number"?A:kL(yr(g).rules,A);return I===void 0?[]:[...yr(g).byRule.get(I)??[]]}function tpA(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&&Yb(o)&&A.set(o,e)}),A}function kL(g,A){if(g.some(t=>t.getNumber("ID")!==void 0)){const t=A.getNumber("ID");return t!==void 0&&Yb(t)?t:void 0}const e=g.indexOf(A);return e>=0?e:void 0}function opA(g,A,I){const e=Lb(A,I);e!==void 0&&jCg(g,e,A)}function jCg(g,A,I){const e=g.get(A);e?e.push(I):g.set(A,[I])}function Lb(g,A){const I=g.getNumber(A);return I!==void 0&&Yb(I)?I:void 0}function Yb(g){return Number.isInteger(g)&&g>=0&&g<g2o}var xPI=1e5,o2o=1e4;function zCg(g){return QpA(B2o(g))}function B2o(g){return FPI(KPI(g))}function FPI(g){const A=[];for(let I=0;I<xPI;I++){const e=_b(g,`VX${I}`),t=_b(g,`VY${I}`);if(e===void 0||t===void 0)break;const o=$Cg(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=_b(g,`CX${I}`),Q=_b(g,`CY${I}`),i=_b(g,`R${I}`),E=$Cg(g,`SA${I}`),n=$Cg(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 BpA(g){const A=KPI(g),I=[],e=LPI(A.get("HOLECOUNT"),o2o);for(let t=0;t<e;t++){const o=LPI(A.get(`HOLE${t}COUNT`),xPI),B=[];for(let C=0;C<o;C++){const Q=_b(A,`HOLE${t}VX${C}`),i=_b(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(QpA(B))}return{holes:I,outline:QpA(FPI(A)),record:g}}function UPI(g){const A=g.board?zCg(g.board):QpA([]),I=g.records.filter(e=>e.recordKind==="BoardRegion"||e.recordKind==="Region");return{cutouts:I.filter(e=>CpA(e)==="BOARD_CUTOUT").map(BpA),layerStackRegions:I.filter(e=>CpA(e)==="LAYER_STACK_REGION").map(BpA),outline:A,polygonCutouts:I.filter(e=>CpA(e)==="POLYGON_CUTOUT").map(BpA)}}function CpA(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 QpA(g){const A=[];for(const t of g){if(!t.arc){PPI(A,t.position);continue}for(const o of C2o(t.position,t.arc))PPI(A,o)}const I=A[0],e=A.at(-1);return{bounds:vSo(A),isExplicitlyClosed:I!==void 0&&e!==void 0&&ZCg(I,e,1e-4),points:A,vertices:g,winding:TSo(A)}}function C2o(g,A){const I=XCg(A.center,A.radiusMils,A.startAngleDegrees),e=XCg(A.center,A.radiusMils,A.endAngleDegrees),t=Q2o(A.endAngleDegrees-A.startAngleDegrees)||360,o=JPI(g,I)<=JPI(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(XCg(A.center,A.radiusMils,B+C*E/Q));return i}function XCg(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 Q2o(g){return(g%360+360)%360}function JPI(g,A){const I=g.x-A.x,e=g.y-A.y;return I*I+e*e}function PPI(g,A){const I=g.at(-1);I&&ZCg(I,A,1e-4)||g.push(A)}function KPI(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 _b(g,A){return eoA(g.get(A.toUpperCase()))}function $Cg(g,A){const I=Number(g.get(A.toUpperCase()));return Number.isFinite(I)?I:void 0}function LPI(g,A){const I=Number(g??0);return Number.isInteger(I)?Math.min(Math.max(I,0),A):0}var YPI=class extends bn{type="dimension-record";constructor(g={}){super(g)}get dimensionKind(){return xt(this,"DIMENSIONKIND","KIND")}get start(){return this.referencePoints[0]??r0(this,["X1"],["Y1"])}get end(){return this.referencePoints[1]??r0(this,["X2"],["Y2"])}get dimensionLineAnchor(){return r0(this,["X1"],["Y1"])}get referencePoints(){return _PI({pointInfix:"POINT",prefix:"REFERENCE",record:this})}get textPoints(){const g=r0(this,["TEXTX"],["TEXTY"]);return g?[g]:_PI({pointInfix:"",prefix:"TEXT",record:this})}get unit(){return xt(this,"TEXTDIMENSIONUNIT","DIMENSIONUNIT","UNIT")}get precision(){return A2o(this,"TEXTPRECISION","PRECISION")??Hi(this,"TEXTPRECISION","PRECISION")}get prefix(){return xt(this,"TEXTPREFIX","PREFIX")}get suffix(){return xt(this,"TEXTSUFFIX","SUFFIX")}get lineWidthMils(){return Hi(this,"LINEWIDTH","ARROWLINEWIDTH","WIDTH")}get textHeightMils(){return Hi(this,"TEXTHEIGHT","HEIGHT")}};function _PI({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=r0(I,[`${A}${C}${g}X`],[`${A}${C}${g}Y`]);if(!Q)break;e.push(Q)}return e}var i2o=class extends bn{type="coordinate-record";get position(){return r0(this,["X","LOCATION.X"],["Y","LOCATION.Y"])}};function E2o(g){return g.replace(/[\s_-]/gu,"").toUpperCase()}function NO(g){return eoA(g)}function Zc(g,A,I=0){return NO(g.getCaseInsensitive(A))??I}function n2o(g){return zCg(g).points}function s2o(g){if(!(g instanceof YPI))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=a2o({dimension:A,measuredDistanceMils:B}),c=A.textHeightMils??50,h=bPI({fallbackMils:10,fieldName:"TEXTGAP",record:g});return{arrowSize:bPI({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 a2o({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}=r2o({measuredDistanceMils:A,normalizedUnit:t}),C=g.prefix??"",Q=g.suffix??` ${B}`;return`${C}${o.toFixed(e)}${Q}`}function r2o({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 bPI({fallbackMils:g,fieldName:A,record:I}){return I.getAltiumMeasurement(A)?.toMils()??g}var AQg=E2o;function c2o(g,A){const I=l2o(g,A),e=g.getNumber("PADMODE")??0,t=h2o(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=Zc(g,"HOLESIZE"),n=NO(g.getCaseInsensitive("SLOTLENGTH"))??(i==="SLOT"?NO(g.getCaseInsensitive("HOLEWIDTH")):void 0)??E;return{cornerRadius:C,height:t.height,holeOffsetX:Zc(g,`LAYER${I}HOLEXOFFSET`,Zc(g,`PADXOFFSET${I}`)),holeOffsetY:Zc(g,`LAYER${I}HOLEYOFFSET`,Zc(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:Zc(g,"X"),y:Zc(g,"Y")}}function h2o(g,A,I){if(!(AQg(g.getCaseInsensitive("LAYER")??"")==="MULTILAYER")||I===0||A===0)return{height:C4(g,["YSIZE","TOPYSIZE"])??C4(g,["XSIZE","TOPXSIZE"])??20,shape:ipA(g,["SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:C4(g,["XSIZE","TOPXSIZE"])??20};if(A===31){const B=C4(g,["BOTTOMXSIZE","BOTXSIZE","XSIZE","TOPXSIZE"])??20;return{height:C4(g,["BOTTOMYSIZE","BOTYSIZE","YSIZE","TOPYSIZE"])??B,shape:ipA(g,["BOTTOMSHAPE","BOTSHAPE","SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:B}}if(I===2&&A>=2){const B=C4(g,[`LAYER${A}XSIZE`,"MIDXSIZE","XSIZE"])??20;return{height:C4(g,[`LAYER${A}YSIZE`,"MIDYSIZE","YSIZE"])??B,shape:ipA(g,[`LAYER${A}SHAPE`,"MIDSHAPE","SHAPE"])?.toUpperCase()??"ROUND",width:B}}const o=C4(g,["MIDXSIZE","XSIZE","TOPXSIZE"])??20;return{height:C4(g,["MIDYSIZE","YSIZE","TOPYSIZE"])??o,shape:ipA(g,["MIDSHAPE","SHAPE","TOPSHAPE"])?.toUpperCase()??"ROUND",width:o}}function l2o(g,A){const I=A?.length===1?AQg(A[0]??""):AQg(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 C4(g,A){for(const I of A){const e=NO(g.getCaseInsensitive(I));if(e!==void 0)return e}}function ipA(g,A){for(const I of A){const e=g.getCaseInsensitive(I);if(e!==void 0)return e}}function gQg(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 D2o(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 IQg(g,A){return{minX:g.minX-A,minY:g.minY-A,maxX:g.maxX+A,maxY:g.maxY+A}}function d2o(g,A){const I=g.recordKind;if(I==="Dimension"){const e=s2o(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=gQg([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?IQg(Q,Math.max(e.arrowSize,e.textHeight)):void 0}if(I==="Track"){const e=gQg([{x:Zc(g,"X1"),y:Zc(g,"Y1")},{x:Zc(g,"X2"),y:Zc(g,"Y2")}]),t=Zc(g,"WIDTH");return e&&t>0?IQg(e,t/2):e}if(I==="Pad"){const e=c2o(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=Zc(g,"X"),t=Zc(g,"Y"),o=NO(g.getCaseInsensitive("DIAMETER"))??NO(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=Zc(g,"LOCATION.X"),t=Zc(g,"LOCATION.Y"),o=Zc(g,"RADIUS"),B=Zc(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 gQg(n2o(g));if(I==="Text"){const e=Zc(g,"X"),t=Zc(g,"Y"),o=Zc(g,"HEIGHT",30);return IQg({minX:e,minY:t,maxX:e,maxY:t},o)}if(I==="Fill"){const e=Zc(g,"X1"),t=Zc(g,"Y1"),o=Zc(g,"X2"),B=Zc(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 HPI=new WeakMap,y2o=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=WCg(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=VCg(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 epA(this.document,g)){const t=VCg(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=WCg(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 vPI(g){const A=HPI.get(g);if(A?.revision===g.revision)return A.graph;const I=new y2o(g);return HPI.set(g,{graph:I,revision:g.revision}),I}function qPI(g,A,I){let e;for(const t of epA(g,A))e=D2o(e,d2o(t,I));return e}var w2o=class extends rF{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 bSo({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 vPI(this)}get boardGeometry(){return UPI(this)}get polygons(){return this.propertyRecords.get("Polygons6")??[]}get rules(){return this.propertyRecords.get("Rules6")??[]}getComponentByIndex(g){return wPI(this,g)}getNetByIndex(g){return uPI(this,g)}getPolygonByIndex(g){return GPI(this,g)}getRuleByIndex(g){return mPI(this,g)}getComponentForRecord(g){return pPI(this,g)}getNetForRecord(g){return kPI(this,g)}getPolygonForRecord(g){return MPI(this,g)}getRuleForRecord(g){return SPI(this,g)}getRecordsOwnedByComponent(g){return epA(this,g)}getRecordsOnNet(g){return fPI(this,g)}getRecordsForPolygon(g){return RPI(this,g)}getRecordsForRule(g){return NPI(this,g)}getRecordsByLayer(g){return[...this.index.byLayer.get(g.toUpperCase())??[]]}getComponentBounds(g,A){return qPI(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=>eQg(e.getNumber("ROTX"),g.getNumber("MODEL.3D.ROTX"))&&eQg(e.getNumber("ROTY"),g.getNumber("MODEL.3D.ROTY"))&&eQg(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 eQg(g,A){return g!==void 0&&A!==void 0&&Math.abs(g-A)<Number.EPSILON}function tQg(g,A){if(A!==void 0)return{encoding:A,text:A==="utf-16le"?npA(g,!0):A==="utf-16be"?npA(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${npA(g.subarray(2),!0)}`};if(g[0]===254&&g[1]===255)return{encoding:"utf-16be-bom",text:`\uFEFF${npA(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 EpA(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 G2o(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 npA(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 u2o=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 G2o(g){const A=[];for(const I of g){const e=u2o.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 m2o(g){const A=new Map(g.fields.map(o=>[o.key.toUpperCase(),o.value])),I=[...oQg(A,"LAYER_V8_","v8"),...oQg(A,"LAYERV7_","v7")];I.length===0&&I.push(...oQg(A,"LAYER","legacy"));const e=A.has("V9_MASTERSTACK_ID")?"V9_MASTERSTACK_":"LAYERMASTERSTACK_V8",t=k2o(A);return{entries:I.sort((o,B)=>o.index-B.index),id:tu(A,`${e}ID`),impedanceProfiles:p2o(A,t),isFlex:Om(tu(A,`${e}ISFLEX`)),layerPairs:S2o(A),name:tu(A,`${e}NAME`),style:tu(A,`${e}STYLE`)??tu(A,"LAYERSTACKSTYLE"),subStacks:M2o(A),traceImpedanceConfigurations:t}}function p2o(g,A){return[...ooA(g,/^V9_IMPEDANCEPROFILE(\d+)_ID$/u)].sort((I,e)=>I-e).map(I=>{const e=`V9_IMPEDANCEPROFILE${I}_`,t=tu(g,`${e}ID`);return{displayName:tu(g,`${e}DISPLAY_NAME`),id:t,index:I,isDifferentialPair:Om(tu(g,`${e}ISDIFFPAIR`)),name:tu(g,`${e}NAME`),targetImpedanceOhms:ML(tu(g,`${e}IMPEDANCE`)),traceConfigurations:A.filter(({profileId:o})=>t!==void 0&&o?.toUpperCase()===t.toUpperCase())}})}function k2o(g){return[...ooA(g,/^V9_TRACEIMPEDANCE(\d+)_PROFILE_ID$/u)].sort((A,I)=>A-I).map(A=>{const I=`V9_TRACEIMPEDANCE${A}_`,e=o=>tu(g,`${I}${o}`),t=o=>eoA(e(o));return{calculatedImpedanceOhms:ML(e("CALC_IMPEDANCE")),differentialPairGapMils:t("DIFF_PAIR_GAP"),differentialPairMaximumGapMils:t("DIFF_PAIR_MAXGAP"),differentialPairMinimumGapMils:t("DIFF_PAIR_MINGAP"),enabled:Om(e("ENABLED")),etchFactor:ML(e("ETCH_FACTOR")),impedanceErrorPercent:ML(e("IMPEDANCE_ERR")),index:A,layerId:e("LAYER_V7ID"),profileId:e("PROFILE_ID"),propagationSpeed:ML(e("PROPAGATION_SPEED")),referenceBottomLayerId:e("REF_BOT_V7ID"),referenceTopLayerId:e("REF_TOP_V7ID"),subStackId:e("SUBSTACK_ID"),traceGapLocked:Om(e("TRACEGAP_LOCKED")),traceMaximumWidthMils:t("TRACE_MAXWIDTH"),traceMinimumWidthMils:t("TRACE_MINWIDTH"),traceWidthLocked:Om(e("TRACEWIDTH_LOCKED")),traceWidthMils:t("TRACE_WIDTH")}})}function M2o(g){const A=ooA(g,/^V9_SUBSTACK(\d+)_ID$/u),I=A.size>0?"v9":"v8";return[...I==="v9"?A:ooA(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=>tu(g,`${o}${C}`);return{id:B("ID"),index:t,isFlex:Om(B("ISFLEX")),name:B("NAME"),service:Om(B("SERVICE")),showBottomDielectric:Om(B("SHOWBOTTOMDIELECTRIC")),showTopDielectric:Om(B("SHOWTOPDIELECTRIC")),source:I,type:ML(B("TYPE")),usedByPrimitives:Om(B("USEDBYPRIMS"))}})}function S2o(g){return[...ooA(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:Om(tu(g,`${e}DRILLDRAWING`)),drillGuide:Om(tu(g,`${e}DRILLGUIDE`)),highLayer:tu(g,`${e}HIGH`),index:I,lowLayer:tu(g,`${e}LOW`),subStackIds:o}})}function ooA(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 oQg(g,A,I){const e=new Set,t=I==="legacy"?/^LAYER(\d+)NAME$/u:new RegExp(`^${f2o(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=>tu(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=Om(C("USEDBYPRIMS")),Q.mechanicalEnabled=Om(C("MECHENABLED")),Q.copperThickness=RO(C("COPTHICK")??""),Q.dielectricType=C("DIELTYPE"),Q.dielectricConstant=ML(C("DIELCONST")),Q.dielectricHeight=RO(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=Om(C("MECHENABLED")),Q.copperThickness=RO(C("COPTHICK")??""),Q.dielectricType=C("DIELTYPE"),Q.dielectricConstant=ML(C("DIELCONST")),Q.dielectricHeight=RO(C("DIELHEIGHT")??""),Q.dielectricMaterial=C("DIELMATERIAL"),Q)})}function tu(g,A){return g.get(A.toUpperCase())}function Om(g){if(g!==void 0){if(/^(?:T|TRUE|1)$/iu.test(g))return!0;if(/^(?:F|FALSE|0)$/iu.test(g))return!1}}function ML(g){if(g===void 0)return;const A=Number(g);return Number.isFinite(A)?A:void 0}function f2o(g){return g.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}var TPI=class extends bn{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 r0(this,["ORIGINX","ORIGIN.X"],["ORIGINY","ORIGIN.Y"])}get sheetOrigin(){return r0(this,["SHEETX"],["SHEETY"])}get sheetSize(){return toA(this,["SHEETWIDTH"],["SHEETHEIGHT"])}get uniqueId(){return xt(this,"UNIQUEID")}get grid(){return{dotGrid:this.getBoolean("DOTGRID"),electricalGridEnabled:this.getBoolean("ELECTRICALGRIDENABLED"),electricalGridRangeMils:Hi(this,"ELECTRICALGRIDRANGE"),largeVisibleGridMultiplier:this.getNumber("BIGVISIBLEGRIDMULTFACTOR"),largeVisibleGridSize:this.getNumber("BIGVISIBLEGRIDSIZE"),snapEnabled:this.getBoolean("GRIDSNAPENABLED"),snapSizeMils:Hi(this,"GRIDSIZE"),visibleGridMultiplier:this.getNumber("VISIBLEGRIDMULTFACTOR"),visibleGridSize:this.getNumber("VISIBLEGRIDSIZE")}}get outline(){return zCg(this)}get layerStack(){return m2o(this)}},BQg=class extends bn{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}},R2o=class extends BQg{type="signal-class-record"},ZPI=class extends bn{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 Hi(this,"TRACKWIDTH")}get gridSizeMils(){return Hi(this,"GRIDSIZE")}},CQg=class extends bn{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 Hi(this,"GAP","GENERICCLEARANCE","CLEARANCE")}get verticalClearanceMils(){if(this.category==="clearance")return Hi(this,"VERTICALGAP")}get widthConstraint(){if(this.normalizedRuleKind==="WIDTH")return SL(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=N2o(I[1],I[2]),t=g.get(e)??{layer:e},o=Hi(this,A.key);o!==void 0&&(I[3].endsWith("GAP")?(t.gap??={},WPI(t.gap,I[3],o)):WPI(t,I[3],o),g.set(e,t))}return[...g.values()]}get viaDiameterConstraint(){if(this.normalizedRuleKind==="ROUTINGVIAS")return SL(this,["MINWIDTH"],["WIDTH","PREFEREDWIDTH"],["MAXWIDTH"])}get viaHoleConstraint(){if(this.normalizedRuleKind==="ROUTINGVIAS")return SL(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=x2o(I[1],I[2]),t=g.get(e)??{layer:e};I[3]?t.enabled=F2o(A.value):t.mode=A.value,g.set(e,t)}return[...g.values()]}get differentialPairGap(){if(this.normalizedRuleKind==="DIFFPAIRSROUTING")return SL(this,["MINLIMIT"],["MOSTFREQGAP","PREFEREDGAP","PREFERREDGAP"],["MAXLIMIT"])}get maximumUncoupledLengthMils(){if(this.normalizedRuleKind==="DIFFPAIRSROUTING")return Hi(this,"MAXUNCOUPLEDLENGTH")}get matchedLengthToleranceMils(){if(["LENGTH","MATCHEDLENGTHS"].includes(this.normalizedRuleKind??""))return Hi(this,"TOLERANCE")}get impedanceConstraint(){if(this.normalizedRuleKind!=="WIDTH")return;const g={maximum:this.getNumber("MAXIMP"),minimum:this.getNumber("MINIMP"),preferred:this.getNumber("FAVIMP")};return spA(g)?g:void 0}get thermalRelief(){if(!["PLANECONNECT","POLYGONCONNECT"].includes(this.normalizedRuleKind??""))return;const g={airGapMils:Hi(this,"AIRGAPWIDTH","RELIEFAIRGAP"),angle:xt(this,"POLYGONRELIEFANGLE"),conductorWidthMils:Hi(this,"RELIEFCONDUCTORWIDTH"),connectionStyle:xt(this,"CONNECTSTYLE","PLANECONNECTSTYLE"),expansionMils:Hi(this,"RELIEFEXPANSION"),spokeCount:this.getNumber("RELIEFENTRIES")};return spA(g)?g:void 0}get maskExpansionMils(){if(["PASTEMASKEXPANSION","SOLDERMASKEXPANSION"].includes(this.normalizedRuleKind??""))return Hi(this,"EXPANSION")}get heightConstraint(){if(this.normalizedRuleKind==="HEIGHT")return SL(this,["MINHEIGHT"],["PREFHEIGHT","PREFEREDHEIGHT"],["MAXHEIGHT"])}get holeSizeConstraint(){if(this.normalizedRuleKind==="HOLESIZE")return SL(this,["MINLIMIT"],[],["MAXLIMIT"])}get minimumSolderMaskSliverMils(){if(this.normalizedRuleKind==="MINIMUMSOLDERMASKSLIVER")return Hi(this,"MINSOLDERMASKWIDTH")}get minimumSilkClearanceMils(){if(["SILKTOBOARDREGIONCLEARANCE","SILKTOSILKCLEARANCE","SILKTOSOLDERMASKCLEARANCE"].includes(this.normalizedRuleKind??""))return Hi(this,"MINSILKSCREENTOMASKGAP","SILKTOSILKCLEARANCE")}get testPointSettings(){if(!this.normalizedRuleKind?.includes("TESTPOINT"))return;const g={allowBottom:this.getBoolean("ALLOWSIDEBOTTOM"),allowTop:this.getBoolean("ALLOWSIDETOP"),gridMils:Hi(this,"TESTPOINTGRID"),holeSize:SL(this,["MINHOLESIZE"],["PREFEREDHOLESIZE","PREFERREDHOLESIZE"],["MAXHOLESIZE"]),padSize:SL(this,["MINSIZE"],["PREFEREDSIZE","PREFERREDSIZE"],["MAXSIZE"]),underComponent:this.getBoolean("TESTPOINTUNDERCOMPONENT"),useGrid:this.getBoolean("USEGRID")};return spA(g)?g:void 0}get normalizedRuleKind(){return this.ruleKind?.toUpperCase()}},OPI=class extends CQg{type="dxp-rule-record"};function SL(g,A,I,e){const t={maximumMils:Hi(g,...e),minimumMils:Hi(g,...A),preferredMils:Hi(g,...I)};return spA(t)?t:void 0}function WPI(g,A,I){A.startsWith("MIN")?g.minimumMils=I:A.startsWith("MAX")?g.maximumMils=I:g.preferredMils=I}function N2o(g,A){return g==="TOPLAYER"?"TOP":g==="BOTTOMLAYER"?"BOTTOM":`MID-LAYER${A??""}`}function x2o(g,A){return g==="TOP LAYER"?"TOP":g==="BOTTOM LAYER"?"BOTTOM":`MID-LAYER${A??""}`}function F2o(g){if(/^(?:TRUE|T|1)$/iu.test(g))return!0;if(/^(?:FALSE|F|0)$/iu.test(g))return!1}function spA(g){return Object.values(g).some(A=>A!==void 0)}var U2o=class extends rF{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():EpA(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 bn)}get board(){return this.records.find(g=>g instanceof TPI)}get components(){return this.records.filter(g=>g instanceof gpA)}get nets(){return this.records.filter(g=>g instanceof IpA)}get classes(){return this.records.filter(g=>g instanceof BQg)}get index(){return yr(this)}get connectivity(){return vPI(this)}get boardGeometry(){return UPI(this)}get polygons(){return this.records.filter(g=>g instanceof ZPI)}get rules(){return this.records.filter(g=>g instanceof CQg||g instanceof OPI)}getComponentByIndex(g){return wPI(this,g)}getNetByIndex(g){return uPI(this,g)}getPolygonByIndex(g){return GPI(this,g)}getRuleByIndex(g){return mPI(this,g)}getComponentForRecord(g){return pPI(this,g)}getNetForRecord(g){return kPI(this,g)}getPolygonForRecord(g){return MPI(this,g)}getRuleForRecord(g){return SPI(this,g)}getRecordsOwnedByComponent(g){return epA(this,g)}getRecordsOnNet(g){return fPI(this,g)}getRecordsForPolygon(g){return RPI(this,g)}getRecordsForRule(g){return NPI(this,g)}getRecordsByLayer(g){return[...this.index.byLayer.get(g.toUpperCase())??[]]}getComponentBounds(g,A){return qPI(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("")}},J2o=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,${v2o(this.getPngBytes(g))}`}getPngBytes(g={}){const A=this.getPayload(g);return A.nativePngBytes?.slice()??b2o(A.bitmapBytes)}getPayload(g){return Object.keys(g).length>0?VPI(this.compressedBytes,g):(this.decodedPayload??=VPI(this.compressedBytes),this.decodedPayload)}};function P2o(g,A){if(!g||A.length===0)return[];const I=K2o(g.content),e=new Set(I);return A.flatMap((t,o)=>{const B=zPI(t.fileName),C=I.find(Q=>e.has(Q)&&zPI(Q.name)===B)??I.find(Q=>e.has(Q));return C?(e.delete(C),[new J2o({compressedBytes:C.compressedBytes,index:o,name:C.name,record:t,storage:g})]):[]})}function K2o(g){if(g.byteLength<4)throw new zQ("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 zQ("Schematic image storage header exceeds the stream");const t=[];for(;e<g.byteLength;){if(e+4>g.byteLength)throw new zQ("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 zQ(`Invalid schematic image storage frame length ${o}`);if(B+2>C||g[B]!==208)throw new zQ("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 zQ("Schematic image storage entry name is truncated");const n=A.getUint32(E,!0),s=E+4,r=s+n;if(r>C)throw new zQ("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 VPI(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 cQA(a=>{if(B+=a.byteLength,B>o)throw new zQ(`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 zQ?s:new zQ(`Schematic image zlib decompression failed: ${s instanceof Error?s.message:String(s)}`)}const Q=jPI(C);if(Q.byteLength<6||Q[0]!==66||Q[1]!==77)throw new zQ("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 zQ(`Embedded schematic bitmap declares invalid size ${E}`);if(E>Q.byteLength)throw new zQ("Embedded schematic bitmap payload is truncated");const n=L2o(Q,E,e,t);return{bitmapBytes:Q.slice(0,E),...n}}function L2o(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=_2o(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 Y2o(r,E)?{enhancedMetafileBytes:r}:{}}function Y2o(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 _2o(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 b2o(g){if(g.byteLength<54||g[0]!==66||g[1]!==77)throw new zQ("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 zQ(`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 zQ("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,jPI([new Uint8Array([137,80,78,71,13,10,26,10]),QQg("IHDR",h),QQg("IDAT",Dug(a,{level:6})),QQg("IEND",new Uint8Array)])}function QQg(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,H2o(e.subarray(4,8+A.byteLength))),e}function H2o(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 jPI(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 zPI(g){return g?.replace(/\\/gu,"/").split("/").at(-1)?.toLowerCase()}function v2o(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 An=class extends bn{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=tKI(this,"LOCATION.X"),A=tKI(this,"LOCATION.Y");return g===void 0||A===void 0?void 0:{x:g,y:A}}},XPI=class extends An{type="schematic-component-record";get libraryReference(){return xt(this,"LIBREFERENCE")}},iQg=class extends An{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")}},EQg=class extends An{type="schematic-label-record";get text(){return xt(this,"TEXT")}},q2o=class extends An{type="schematic-bezier-record"},T2o=class extends An{type="schematic-polyline-record"},Z2o=class extends An{type="schematic-polygon-record"},O2o=class extends An{type="schematic-ellipse-record"},W2o=class extends An{type="schematic-rounded-rectangle-record"},V2o=class extends An{type="schematic-elliptical-arc-record"},j2o=class extends An{type="schematic-arc-record"},z2o=class extends An{type="schematic-line-record"},X2o=class extends An{type="schematic-rectangle-record"},$PI=class extends An{type="schematic-sheet-symbol-record";get fileName(){return xt(this,"FILENAME")}},$2o=class extends An{type="schematic-sheet-entry-record";get name(){return xt(this,"NAME")}},nQg=class extends An{type="schematic-power-port-record";get text(){return xt(this,"TEXT")}},sQg=class extends An{type="schematic-port-record";get name(){return xt(this,"NAME")}},aQg=class extends An{type="schematic-net-label-record";get text(){return xt(this,"TEXT")}},Afo=class extends An{type="schematic-bus-record"},gfo=class extends An{type="schematic-bus-entry-record"},AKI=class extends An{type="schematic-wire-record"},Ifo=class extends An{type="schematic-no-erc-record"},efo=class extends An{type="schematic-text-frame-record";get text(){return xt(this,"TEXT")}},tfo=class extends An{type="schematic-junction-record"},gKI=class extends An{type="schematic-image-record";get fileName(){return xt(this,"FILENAME")}},ofo=class extends An{type="schematic-sheet-record"},IKI=class extends An{type="schematic-sheet-name-record"},eKI=class extends An{type="schematic-sheet-file-name-record"},Bfo=class extends An{type="schematic-designator-record";get text(){return xt(this,"TEXT")}},Cfo=class extends An{type="schematic-template-record";get fileName(){return xt(this,"FILENAME")}},Qfo=class extends An{type="schematic-parameter-record";get name(){return xt(this,"NAME")}get text(){return xt(this,"TEXT")}},ifo=class extends An{type="schematic-implementation-list-record"},Efo=class extends An{type="schematic-implementation-record";get modelName(){return xt(this,"MODELNAME")}get modelType(){return xt(this,"MODELTYPE")}},nfo=class extends An{type="schematic-implementation-map-record"},sfo=class extends An{type="schematic-implementation-parameter-record"},afo=class extends An{type="schematic-note-record";get text(){return xt(this,"TEXT")}};function tKI(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 oKI=new WeakMap,BKI=new WeakMap,rfo=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}},cfo=class{constructor(g){this.document=g;const A=new yfo,I=new Map,e=new Map;for(const C of g.wires){const Q=Dfo(C);for(const i of Q){const E=apA(i);A.add(E),e.set(E,i),iKI(I,E,C)}for(let i=1;i<Q.length;i++){const E=Q[i-1],n=Q[i];E&&n&&A.union(apA(E),apA(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=apA(Q);A.add(i),e.set(i,Q),iKI(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=dfo(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){EKI(n,Q);for(const s of E.slice(1)){EKI(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 rQg(this.document).getOwnedRecords(g).filter(A=>A instanceof iQg)}};function rQg(g){const A=oKI.get(g);if(A?.revision===g.revision)return A.index;const I=new rfo(g);return oKI.set(g,{index:I,revision:g.revision}),I}function hfo(g){const A=BKI.get(g);if(A?.revision===g.revision)return A.graph;const I=new cfo(g);return BKI.set(g,{graph:I,revision:g.revision}),I}function lfo(g){const A=rQg(g);return g.sheetSymbols.map(I=>{const e=A.getOwnedRecords(I),t=e.find(B=>B instanceof IKI),o=e.find(B=>B instanceof eKI);return{fileName:o?.getDecoded("TEXT"),fileNameRecord:o,name:t?.getDecoded("TEXT"),nameRecord:t,symbol:I}})}function Dfo(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=CKI(g,`X${t}`),B=CKI(g,`Y${t}`);if(o===void 0||B===void 0)break;e.push({x:o,y:B})}return e}function dfo(g){if(g instanceof aQg||g instanceof EQg||g instanceof nQg)return g.getDecoded("TEXT");if(g instanceof sQg)return g.getDecoded("NAME")}function CKI(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 apA(g){return`${QKI(g.x)},${QKI(g.y)}`}function QKI(g){return g.toFixed(6).replace(/\.?0+$/u,"")}function iKI(g,A,I){const e=g.get(A);e?e.push(I):g.set(A,[I])}function EKI(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 yfo=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)}},rpA=class extends rF{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=P2o(this.compoundFile?.getStream("/Storage"),this.records.filter(A=>A instanceof gKI)),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 bn&&g.getCaseInsensitive("HEADER")!==void 0)}get records(){return this.lines.filter(g=>g instanceof bn&&g.recordKind!==void 0)}get index(){return rQg(this)}get netGraph(){return hfo(this)}get components(){return this.records.filter(g=>g instanceof XPI)}get pins(){return this.records.filter(g=>g instanceof iQg)}get wires(){return this.records.filter(g=>g instanceof AKI)}get labels(){return this.records.filter(g=>g instanceof EQg)}get netLabels(){return this.records.filter(g=>g instanceof aQg)}get ports(){return this.records.filter(g=>g instanceof sQg)}get powerPorts(){return this.records.filter(g=>g instanceof nQg)}get sheetSymbols(){return this.records.filter(g=>g instanceof $PI)}get sheetLinks(){return lfo(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 EpA(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("")}},nKI=class extends rF{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}},cQg=class extends nKI{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[]}},sKI=class h7I extends nKI{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 h7I)}get streams(){return this.entries.filter(A=>A instanceof cQg)}getChildren(){return[...this.entries]}},wfo=class extends rF{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 sKI&&A(e)};return A(this.root),g}get streams(){return this.entries.filter(g=>g instanceof cQg)}getStream(g){const A=ufo(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 ufo(g){return(Array.isArray(g)?g:g.split(/[\\/]/u)).filter(Boolean)}var hQg=class extends OCg{},BoA=class extends hQg{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}`}},lQg=class extends hQg{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}`}},aKI=class extends hQg{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}},Gfo=class extends aKI{type="ini-raw-line"},cpA=class extends rF{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():EpA(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 lQg&&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=rKI(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 lQg({key:A,terminator:rKI(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 mfo(g){return new cpA({lines:hpA(g),originalSource:g})}function hpA(g){return pfo(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 aKI({...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 lQg({...B,afterEquals:c,beforeEquals:r,key:s,leading:E,value:a.slice(c.length)})}return new Gfo({...B,raw:A})})}function pfo(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]===`