@tscircuit/runframe 0.0.1741 → 0.0.1742

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.
@@ -5382,7 +5382,7 @@ svg { font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; }
5382
5382
  50% { opacity: 0.2; }
5383
5383
  100% { opacity: 0.6; }
5384
5384
  }
5385
- `,n.appendChild(u)}})}};o();const s=new MutationObserver(o);return s.observe(n,{childList:!0,subtree:!1,characterData:!1}),()=>{s.disconnect()}},[t,e,A,i])},tle=["#8B0000","#2F4F4F","#191970","#006400","#FF4500","#800080","#2E8B57","#B8860B","#C71585","#008B8B"],Ozt=t=>{const{svgDivRef:A,circuitJson:e,circuitJsonKey:i,showGroups:n}=t;V.useEffect(()=>{if(A.current&&A.current.querySelectorAll(".schematic-group-overlay").forEach(r=>r.remove()),!A.current||!n||!e||e.length===0)return;const o=setTimeout(()=>{if(!A.current)return;const s=A.current.querySelector("svg");if(!s)return;s.querySelectorAll(".schematic-group-overlay").forEach(a=>a.remove());try{const a=YE(e).source_group?.list().filter(u=>!u.is_subcircuit)||[],g=YE(e).schematic_component?.list()||[],c=new Map;a.forEach(u=>{const d=u;if(d.parent_source_group_id){const f=c.get(d.parent_source_group_id)||[];f.push(u.source_group_id),c.set(d.parent_source_group_id,f)}});const I=u=>{const d=[],f=c.get(u)||[];for(const y of f)d.push(y),d.push(...I(y));return d},l=u=>{const d=a.find(f=>f.source_group_id===u);return d?.parent_source_group_id?1+l(d.parent_source_group_id):0},B=a.length>0&&a.some(u=>u.name&&u.name.trim()!=="");let C=[];if(B){const u=new Map;for(const d of g){const f=YE(e).source_component.get(d.source_component_id);f?.source_group_id&&(u.has(f.source_group_id)||u.set(f.source_group_id,[]),u.get(f.source_group_id).push(d))}a.forEach((d,f)=>{let y=u.get(d.source_group_id)||[];const w=I(d.source_group_id);for(const D of w){const S=u.get(D)||[];y=[...y,...S]}if(y.length>0){const D=l(d.source_group_id),S=I(d.source_group_id).length>0;if(d.name?.startsWith("unnamed_board"))return;C.push({id:d.source_group_id,name:d.name||`Group ${f+1}`,components:y,color:tle[f%tle.length],depthLevel:D,hasChildren:S,sourceGroupId:d.source_group_id})}})}const Q=s.viewBox.baseVal,h=s.getBoundingClientRect(),E=Math.min(h.width/Q.width,h.height/Q.height)||1;C.sort((u,d)=>u.depthLevel-d.depthLevel),C.forEach(u=>{if(u.components.length===0)return;const d=Wzt(u.components,s);if(!d)return;const f=Math.max(8,Math.min(25,15/Math.max(E,.3))),y=u.hasChildren?f*.6:0,w=f+y,D=Math.max(1,2/Math.max(E,.5)),S=u.depthLevel===0?D:D*.7,_=Math.max(4,8/Math.max(E,.5)),b=u.hasChildren?1.3:1,N=_*b,F=N*.5,L=document.createElementNS("http://www.w3.org/2000/svg","rect");L.setAttribute("class","schematic-group-overlay"),L.setAttribute("x",(d.minX-w).toString()),L.setAttribute("y",(d.minY-w).toString()),L.setAttribute("width",(d.maxX-d.minX+w*2).toString()),L.setAttribute("height",(d.maxY-d.minY+w*2).toString()),L.setAttribute("fill","none"),L.setAttribute("stroke",u.color),L.setAttribute("stroke-width",S.toString()),L.setAttribute("stroke-dasharray",`${N},${F}`),L.setAttribute("opacity","0.8"),L.setAttribute("rx","0"),L.setAttribute("ry","0");const Y=Math.max(6,Math.min(20,14/Math.max(E,.2))),J=u.depthLevel===0||u.depthLevel===1?0:u.depthLevel*.2,O=Y*(1-J),Z=Math.max(1,O*.2),X=u.name,eA=document.createElementNS("http://www.w3.org/2000/svg","text");eA.setAttribute("font-size",O.toString()),eA.setAttribute("font-family","Arial, sans-serif"),eA.textContent=X,s.appendChild(eA);const gA=eA.getBBox();s.removeChild(eA);const tA=gA.width+Z*2,iA=O+Z*2,sA=d.minX-w,aA=d.minY-w-iA,EA=document.createElementNS("http://www.w3.org/2000/svg","rect");EA.setAttribute("class","schematic-group-overlay"),EA.setAttribute("x",sA.toString()),EA.setAttribute("y",(aA-iA).toString()),EA.setAttribute("width",tA.toString()),EA.setAttribute("height",iA.toString()),EA.setAttribute("fill","transparent"),EA.setAttribute("rx","0"),EA.setAttribute("ry","0");const bA=document.createElementNS("http://www.w3.org/2000/svg","text");bA.setAttribute("class","schematic-group-overlay"),bA.setAttribute("x",(sA+Z).toString()),bA.setAttribute("y",(aA+iA-Z).toString()),bA.setAttribute("fill",u.color),bA.setAttribute("font-size",O.toString()),bA.setAttribute("font-family","Arial, sans-serif"),bA.setAttribute("font-weight",u.depthLevel===0?"600":"500"),bA.setAttribute("stroke",u.color),bA.setAttribute("stroke-width",Math.max(.2,O*.02).toString()),bA.textContent=X,s.appendChild(L),s.appendChild(EA),s.appendChild(bA)})}catch(a){console.error("Error creating group overlays:",a)}},10);return()=>clearTimeout(o)},[A,i,n])};function Wzt(t,A){let e=1/0,i=1/0,n=-1/0,o=-1/0;for(const r of t){let a=A.querySelector(`g[data-schematic-component-id="${r.schematic_component_id}"]`);if(a||(a=A.querySelector(`[data-schematic-component-id="${r.schematic_component_id}"]`)),a){const g=a.getBBox();e=Math.min(e,g.x),i=Math.min(i,g.y),n=Math.max(n,g.x+g.width),o=Math.max(o,g.y+g.height)}}return e===1/0?null:{minX:e,minY:i,maxX:n,maxY:o}}var Zzt=ba("schematic-viewer"),Vzt=()=>{ba.enable("schematic-viewer*")},jzt=Zzt,ile=t=>{const[A,e]=V.useState(0),[i,n]=V.useState(0);return V.useEffect(()=>{if(!t.current)return;const o=()=>{const r=t.current?.getBoundingClientRect();e(r?.width||0),n(r?.height||0)};o();const s=new ResizeObserver(o);return s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:A,containerHeight:i}},zzt=jzt.extend("useComponentDragging"),Xzt=({onEditEvent:t,editEvents:A=[],circuitJson:e,cancelDrag:i,svgToScreenProjection:n,realToSvgProjection:o,enabled:s=!1,snapToGrid:r=!1})=>{const[a,g]=V.useState(null),c=An(o,n),I=V.useRef(null),l=V.useRef(null),B=V.useRef(new Map);V.useEffect(()=>{A.forEach(D=>{"edit_event_type"in D&&D.edit_event_type==="edit_schematic_component_location"&&!D.in_progress&&B.current.set(D.schematic_component_id,{...D.new_center})})},[A]);const C=V.useCallback((D,S,_)=>{if(!s)return!1;const b=_.closest('[data-circuit-json-type="schematic_component"]');if(!b)return!1;const N=b.getAttribute("data-schematic-component-id");if(!N)return!1;i&&i();const F=YE(e).schematic_component.get(N);if(!F)return!1;I.current={x:D,y:S};let L;const Y=B.current.get(N);if(Y)L={...Y};else{const O=ele({editEvents:A,schematic_component_id:N});L={x:F.center.x+O.x,y:F.center.y+O.y},B.current.set(N,{...L})}const J={edit_event_id:Math.random().toString(36).substr(2,9),edit_event_type:"edit_schematic_component_location",schematic_component_id:N,original_center:L,new_center:{...L},in_progress:!0,created_at:Date.now(),_element:b};return l.current=J,g(J),!0},[i,s,e,A]),Q=V.useCallback(D=>{C(D.clientX,D.clientY,D.target)},[C]),h=V.useCallback(D=>{if(D.touches.length!==1)return;const S=D.touches[0];C(S.clientX,S.clientY,D.target)&&D.preventDefault()},[C]),E=V.useCallback((D,S)=>{if(!l.current||!I.current)return;const _={x:D-I.current.x,y:S-I.current.y},b={x:_.x/c.a,y:_.y/c.d};let N={x:l.current.original_center.x+b.x,y:l.current.original_center.y+b.y};if(r){const L=Y=>Math.round(Y*10)/10;N={x:L(N.x),y:L(N.y)}}const F={...l.current,new_center:N};l.current=F,g(F)},[c,r]),u=V.useCallback(D=>E(D.clientX,D.clientY),[E]),d=V.useCallback(D=>{if(D.touches.length!==1||!l.current)return;D.preventDefault();const S=D.touches[0];E(S.clientX,S.clientY)},[E]),f=V.useCallback(()=>{if(!l.current)return;const D={...l.current,in_progress:!1};B.current.set(D.schematic_component_id,{...D.new_center}),zzt("endDrag calling onEditEvent with new edit event",{newEditEvent:D}),t&&t(D),l.current=null,I.current=null,g(null)},[t]),y=V.useCallback(()=>f(),[f]),w=V.useCallback(()=>f(),[f]);return V.useEffect(()=>(window.addEventListener("mousemove",u),window.addEventListener("mouseup",y),window.addEventListener("touchmove",d,{passive:!1}),window.addEventListener("touchend",w),()=>{window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",y),window.removeEventListener("touchmove",d),window.removeEventListener("touchend",w)}),[u,y,d,w]),{handleMouseDown:Q,handleTouchStart:h,isDragging:!!l.current,activeEditEvent:a}},ES={schematicEditIcon:50,schematicGridIcon:49,spiceSimulationIcon:50,viewMenuIcon:48,viewMenu:55,viewMenuBackdrop:54,clickToInteractOverlay:100,schematicComponentHoverOutline:47,schematicPortHoverOutline:48},$zt=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return W.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Disable edit mode":"Enable edit mode",style:{position:"absolute",top:"16px",right:"64px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ES.schematicEditIcon},children:W.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[W.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),W.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})},AXt=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return W.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Hide grid":"Show grid",style:{position:"absolute",top:"56px",right:"64px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ES.schematicGridIcon},children:W.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:W.jsx("path",{d:"M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z"})})})},eXt=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return W.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Hide view menu":"Show view menu",style:{position:"absolute",top:"16px",right:"16px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ES.viewMenuIcon},children:W.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[W.jsx("circle",{cx:"12",cy:"12",r:"1"}),W.jsx("circle",{cx:"12",cy:"5",r:"1"}),W.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})},tXt={version:"2.0.57"},iXt=({circuitJson:t,circuitJsonKey:A,isVisible:e,onClose:i,showGroups:n,onToggleGroups:o,showGrid:s,onToggleGrid:r})=>{const a=V.useMemo(()=>{if(!t||t.length===0)return!1;try{if((YE(t).source_group?.list()||[]).length>0)return!0;const c=YE(t).schematic_component?.list()||[];if(c.length>1){const I=new Set;for(const l of c){const B=YE(t).source_component.get(l.source_component_id);B?.ftype&&I.add(B.ftype)}return I.size>1}return!1}catch(g){return console.error("Error checking for groups:",g),!1}},[A]);return e?W.jsxs(W.Fragment,{children:[W.jsx("div",{onClick:i,onTouchEnd:g=>{g.preventDefault(),i()},style:{position:"absolute",inset:0,backgroundColor:"transparent",zIndex:ES.viewMenuBackdrop}}),W.jsxs("div",{style:{position:"absolute",top:"56px",right:"16px",backgroundColor:"#ffffff",color:"#000000",border:"1px solid #ccc",borderRadius:"4px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",minWidth:"200px",zIndex:ES.viewMenu},children:[W.jsxs("div",{onClick:()=>{a&&o(!n)},onTouchEnd:g=>{g.preventDefault(),a&&o(!n)},style:{padding:"8px 12px",cursor:a?"pointer":"not-allowed",opacity:a?1:.5,fontSize:"13px",color:"#000000",fontFamily:"sans-serif",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:g=>{a&&(g.currentTarget.style.backgroundColor="#f0f0f0")},onMouseLeave:g=>{a&&(g.currentTarget.style.backgroundColor="transparent")},children:[W.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #000",borderRadius:"2px",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:"bold"},children:n&&"✓"}),"View Schematic Groups"]}),!a&&W.jsx("div",{style:{padding:"8px 12px",fontSize:"11px",color:"#666",fontStyle:"italic"},children:"No groups found in this schematic"}),W.jsxs("div",{onClick:()=>r(!s),onTouchEnd:g=>{g.preventDefault(),r(!s)},style:{padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:"#000000",fontFamily:"sans-serif",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="#f0f0f0"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent"},children:[W.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #000",borderRadius:"2px",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:"bold"},children:s&&"✓"}),"Show Grid"]}),W.jsxs("div",{style:{padding:"4px 8px",fontSize:"12px",color:"#999",borderTop:"1px solid #eee",textAlign:"center"},children:["v",String(tXt?.version)]})]})]}):null},nXt=()=>W.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:W.jsx("path",{d:"M3 12h2.5l2.5-9 4 18 4-9h5.5"})}),oXt=({onClick:t})=>W.jsx("div",{onClick:t,title:"Run SPICE simulation",style:{position:"absolute",top:"16px",right:"112px",backgroundColor:"#fff",color:"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ES.spiceSimulationIcon},children:W.jsx(nXt,{})});Pj.register(vzt,Rzt,Izt,czt,dzt,bzt,Ezt);var Wj=["#8884d8","#82ca9d","#ffc658","#ff7300","#387908"],nle=t=>{if(t===0)return"0s";const A=Math.abs(t);let e="s",i=1;return A<1e-12?(e="fs",i=1e15):A<1e-9?(e="ps",i=1e12):A<1e-6?(e="ns",i=1e9):A<.001?(e="us",i=1e6):A<1&&(e="ms",i=1e3),`${parseFloat((t*i).toPrecision(3))}${e}`},sXt=({plotData:t,nodes:A,isLoading:e,error:i,hasRun:n})=>{const o=V.useMemo(()=>{const a=A.some(c=>c.toLowerCase().startsWith("v(")),g=A.some(c=>c.toLowerCase().startsWith("i("));return a&&g?"Value":a?"Voltage (V)":g?"Current (A)":"Value"},[A]);if(e)return W.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:"Running simulation..."});if(!n)return W.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:'Click "Run" to start the simulation.'});if(i)return W.jsxs("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"red"},children:["Error: ",i]});if(t.length===0)return W.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:"No data to plot. Check simulation output or SPICE netlist."});const s={datasets:A.map((a,g)=>({label:a,data:t.map(c=>({x:Number(c.name),y:c[a]})),borderColor:Wj[g%Wj.length],backgroundColor:Wj[g%Wj.length],fill:!1,tension:.1}))},r={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"top",labels:{font:{family:"sans-serif"}}},title:{display:!1},tooltip:{callbacks:{title:a=>{if(a.length>0){const g=a[0];return nle(g.parsed.x)}return""}}}},scales:{x:{type:"linear",title:{display:!0,text:"Time",font:{family:"sans-serif"}},ticks:{callback:a=>nle(a),font:{family:"sans-serif"}}},y:{title:{display:!0,text:o,font:{family:"sans-serif"}},ticks:{font:{family:"sans-serif"}}}}};return W.jsx("div",{style:{position:"relative",height:"300px",width:"100%"},children:W.jsx(Pzt,{options:r,data:s})})},rXt=({spiceString:t,onClose:A,plotData:e,nodes:i,isLoading:n,error:o,simOptions:s,onSimOptionsChange:r,hasRun:a})=>{const[g,c]=V.useState(String(s.startTime)),[I,l]=V.useState(String(s.duration));V.useEffect(()=>{c(String(s.startTime)),l(String(s.duration))},[s.startTime,s.duration]);const B=()=>{r({...s,startTime:Number(g),duration:Number(I)})},C=i.filter(Q=>{const h=Q.toLowerCase().startsWith("v("),E=Q.toLowerCase().startsWith("i(");return!!(s.showVoltage&&h||s.showCurrent&&E)});return W.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1002,fontFamily:"sans-serif"},children:W.jsxs("div",{style:{backgroundColor:"white",padding:"24px",borderRadius:"12px",width:"90%",maxWidth:"900px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)"},children:[W.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:"1px solid #eee",paddingBottom:"16px"},children:[W.jsx("h2",{style:{margin:0,fontSize:"22px",fontWeight:600,color:"#333"},children:"SPICE Simulation"}),W.jsx("button",{onClick:A,style:{background:"none",border:"none",fontSize:"28px",cursor:"pointer",color:"#888",padding:0,lineHeight:1},children:"×"})]}),W.jsx("div",{children:W.jsx(sXt,{plotData:e,nodes:C,isLoading:n,error:o,hasRun:a})}),W.jsxs("div",{style:{marginTop:"16px",padding:"12px",backgroundColor:"#f7f7f7",borderRadius:"6px",display:"flex",flexWrap:"wrap",gap:"24px",alignItems:"center",fontSize:"14px"},children:[W.jsxs("div",{style:{display:"flex",gap:"16px"},children:[W.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[W.jsx("input",{type:"checkbox",checked:s.showVoltage,onChange:Q=>r({...s,showVoltage:Q.target.checked})}),"Voltage"]}),W.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[W.jsx("input",{type:"checkbox",checked:s.showCurrent,onChange:Q=>r({...s,showCurrent:Q.target.checked})}),"Current"]})]}),W.jsxs("div",{style:{display:"flex",gap:"16px",alignItems:"center"},children:[W.jsx("label",{htmlFor:"startTime",children:"Start Time (ms):"}),W.jsx("input",{id:"startTime",type:"number",value:g,onChange:Q=>c(Q.target.value),style:{width:"80px",padding:"4px 8px",borderRadius:"4px",border:"1px solid #ccc"}}),W.jsx("label",{htmlFor:"duration",children:"Duration (ms):"}),W.jsx("input",{id:"duration",type:"number",value:I,onChange:Q=>l(Q.target.value),style:{width:"80px",padding:"4px 8px",borderRadius:"4px",border:"1px solid #ccc"}}),W.jsx("button",{onClick:B,style:{padding:"4px 12px",borderRadius:"4px",border:"1px solid #ccc",backgroundColor:"#f0f0f0",cursor:"pointer"},children:a?"Rerun":"Run"})]})]}),W.jsxs("div",{style:{marginTop:"24px"},children:[W.jsx("h3",{style:{marginTop:0,marginBottom:"12px",fontSize:"18px",fontWeight:600,color:"#333"},children:"SPICE Netlist"}),W.jsx("pre",{style:{backgroundColor:"#fafafa",padding:"16px",borderRadius:"6px",maxHeight:"150px",overflowY:"auto",border:"1px solid #eee",color:"#333",fontSize:"13px",fontFamily:"monospace"},children:t})]})]})})},aXt="dmFyIGU9bnVsbCxzPWFzeW5jKCk9Pihhd2FpdCBpbXBvcnQoImh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vZWVjaXJjdWl0LWVuZ2luZUAxLjUuMi8rZXNtIikpLlNpbXVsYXRpb24sYz1hc3luYygpPT57aWYoZSYmZS5pc0luaXRpYWxpemVkKCkpcmV0dXJuO2xldCBpPWF3YWl0IHMoKTtlPW5ldyBpLGF3YWl0IGUuc3RhcnQoKX07c2VsZi5vbm1lc3NhZ2U9YXN5bmMgaT0+e3RyeXtpZihhd2FpdCBjKCksIWUpdGhyb3cgbmV3IEVycm9yKCJTaW11bGF0aW9uIG5vdCBpbml0aWFsaXplZCIpO2xldCB0PWkuZGF0YS5zcGljZVN0cmluZyxhPXQubWF0Y2goL3dyZGF0YVxzKyhcUyspXHMrKC4qKS9pKTtpZihhKXtsZXQgbz1gLnByb2JlICR7YVsyXS50cmltKCkuc3BsaXQoL1xzKy8pLmpvaW4oIiAiKX1gO3Q9dC5yZXBsYWNlKC93cmRhdGEuKi9pLG8pfWVsc2UgaWYoIXQubWF0Y2goL1wucHJvYmUvaSkpdGhyb3cgdC5tYXRjaCgvcGxvdFxzKyguKikvaSk/bmV3IEVycm9yKCJUaGUgJ3Bsb3QnIGNvbW1hbmQgaXMgbm90IHN1cHBvcnRlZCBmb3IgZGF0YSBleHRyYWN0aW9uLiBQbGVhc2UgdXNlICd3cmRhdGEgPGZpbGVuYW1lPiA8dmFyMT4gLi4uJyBvciAnLnByb2JlIDx2YXIxPiAuLi4nIGluc3RlYWQuIik6bmV3IEVycm9yKCJObyAnLnByb2JlJyBvciAnd3JkYXRhJyBjb21tYW5kIGZvdW5kIGluIFNQSUNFIGZpbGUuIFVzZSAnd3JkYXRhIDxmaWxlbmFtZT4gPHZhcjE+IC4uLicgdG8gc3BlY2lmeSBvdXRwdXQuIik7ZS5zZXROZXRMaXN0KHQpO2xldCBuPWF3YWl0IGUucnVuU2ltKCk7c2VsZi5wb3N0TWVzc2FnZSh7dHlwZToicmVzdWx0IixyZXN1bHQ6bn0pfWNhdGNoKHQpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixlcnJvcjp0Lm1lc3NhZ2V9KX19Owo=",Zj=null,gXt=()=>{if(typeof window>"u")return null;if(Zj)return Zj;try{const t=new Blob([atob(aXt)],{type:"application/javascript"});return Zj=URL.createObjectURL(t),Zj}catch(t){return console.error("Failed to create blob URL for worker",t),null}},cXt=t=>{const A={};if(t.dataType==="real")t.data.forEach(r=>{A[r.name]=r.values});else if(t.dataType==="complex")t.data.forEach(r=>{A[r.name]=r.values.map(a=>a.real)});else throw new Error("Unsupported data type in simulation result");const e=Object.keys(A).find(r=>r.toLowerCase()==="time"||r.toLowerCase()==="frequency");if(!e)throw new Error("No time or frequency data in simulation result");const i=A[e],n=Object.keys(A).filter(r=>r!==e),o=n;return{plotData:i.map((r,a)=>{const g={name:r.toExponential(2)};return n.forEach(c=>{g[c]=A[c][a]}),g}),nodes:o}},IXt=t=>{const[A,e]=V.useState([]),[i,n]=V.useState([]),[o,s]=V.useState(!0),[r,a]=V.useState(null);return V.useEffect(()=>{if(!t){s(!1),e([]),n([]),a(null);return}s(!0),a(null),e([]),n([]);const g=gXt();if(!g){a("Could not create SPICE simulation worker."),s(!1);return}const c=new Worker(g,{type:"module"});return c.onmessage=I=>{if(I.data.type==="result")try{const{plotData:l,nodes:B}=cXt(I.data.result);e(l),n(B)}catch(l){a(l.message||"Failed to parse simulation result"),console.error(l)}else I.data.type==="error"&&a(I.data.error);s(!1)},c.onerror=I=>{a(I.message),s(!1)},c.postMessage({spiceString:t}),()=>{c.terminate()}},[t]),{plotData:A,nodes:i,isLoading:o,error:r}},ryA=t=>{if(t===0)return"0";const A=Math.abs(t),e=i=>i.toPrecision(4);return A>=1?e(t):A>=.001?`${e(t*1e3)}m`:A>=1e-6?`${e(t*1e6)}u`:A>=1e-9?`${e(t*1e9)}n`:A>=1e-12?`${e(t*1e12)}p`:A>=1e-15?`${e(t*1e15)}f`:t.toExponential(3)},lXt=(t,A)=>{const i=VPA(t).toSpiceString(),o=i.split(`
5385
+ `,n.appendChild(u)}})}};o();const s=new MutationObserver(o);return s.observe(n,{childList:!0,subtree:!1,characterData:!1}),()=>{s.disconnect()}},[t,e,A,i])},tle=["#8B0000","#2F4F4F","#191970","#006400","#FF4500","#800080","#2E8B57","#B8860B","#C71585","#008B8B"],Ozt=t=>{const{svgDivRef:A,circuitJson:e,circuitJsonKey:i,showGroups:n}=t;V.useEffect(()=>{if(A.current&&A.current.querySelectorAll(".schematic-group-overlay").forEach(r=>r.remove()),!A.current||!n||!e||e.length===0)return;const o=setTimeout(()=>{if(!A.current)return;const s=A.current.querySelector("svg");if(!s)return;s.querySelectorAll(".schematic-group-overlay").forEach(a=>a.remove());try{const a=YE(e).source_group?.list().filter(u=>!u.is_subcircuit)||[],g=YE(e).schematic_component?.list()||[],c=new Map;a.forEach(u=>{const d=u;if(d.parent_source_group_id){const f=c.get(d.parent_source_group_id)||[];f.push(u.source_group_id),c.set(d.parent_source_group_id,f)}});const I=u=>{const d=[],f=c.get(u)||[];for(const y of f)d.push(y),d.push(...I(y));return d},l=u=>{const d=a.find(f=>f.source_group_id===u);return d?.parent_source_group_id?1+l(d.parent_source_group_id):0},B=a.length>0&&a.some(u=>u.name&&u.name.trim()!=="");let C=[];if(B){const u=new Map;for(const d of g){const f=YE(e).source_component.get(d.source_component_id);f?.source_group_id&&(u.has(f.source_group_id)||u.set(f.source_group_id,[]),u.get(f.source_group_id).push(d))}a.forEach((d,f)=>{let y=u.get(d.source_group_id)||[];const w=I(d.source_group_id);for(const D of w){const S=u.get(D)||[];y=[...y,...S]}if(y.length>0){const D=l(d.source_group_id),S=I(d.source_group_id).length>0;if(d.name?.startsWith("unnamed_board"))return;C.push({id:d.source_group_id,name:d.name||`Group ${f+1}`,components:y,color:tle[f%tle.length],depthLevel:D,hasChildren:S,sourceGroupId:d.source_group_id})}})}const Q=s.viewBox.baseVal,h=s.getBoundingClientRect(),E=Math.min(h.width/Q.width,h.height/Q.height)||1;C.sort((u,d)=>u.depthLevel-d.depthLevel),C.forEach(u=>{if(u.components.length===0)return;const d=Wzt(u.components,s);if(!d)return;const f=Math.max(8,Math.min(25,15/Math.max(E,.3))),y=u.hasChildren?f*.6:0,w=f+y,D=Math.max(1,2/Math.max(E,.5)),S=u.depthLevel===0?D:D*.7,_=Math.max(4,8/Math.max(E,.5)),b=u.hasChildren?1.3:1,N=_*b,F=N*.5,L=document.createElementNS("http://www.w3.org/2000/svg","rect");L.setAttribute("class","schematic-group-overlay"),L.setAttribute("x",(d.minX-w).toString()),L.setAttribute("y",(d.minY-w).toString()),L.setAttribute("width",(d.maxX-d.minX+w*2).toString()),L.setAttribute("height",(d.maxY-d.minY+w*2).toString()),L.setAttribute("fill","none"),L.setAttribute("stroke",u.color),L.setAttribute("stroke-width",S.toString()),L.setAttribute("stroke-dasharray",`${N},${F}`),L.setAttribute("opacity","0.8"),L.setAttribute("rx","0"),L.setAttribute("ry","0");const Y=Math.max(6,Math.min(20,14/Math.max(E,.2))),J=u.depthLevel===0||u.depthLevel===1?0:u.depthLevel*.2,O=Y*(1-J),Z=Math.max(1,O*.2),X=u.name,eA=document.createElementNS("http://www.w3.org/2000/svg","text");eA.setAttribute("font-size",O.toString()),eA.setAttribute("font-family","Arial, sans-serif"),eA.textContent=X,s.appendChild(eA);const gA=eA.getBBox();s.removeChild(eA);const tA=gA.width+Z*2,iA=O+Z*2,sA=d.minX-w,aA=d.minY-w-iA,EA=document.createElementNS("http://www.w3.org/2000/svg","rect");EA.setAttribute("class","schematic-group-overlay"),EA.setAttribute("x",sA.toString()),EA.setAttribute("y",(aA-iA).toString()),EA.setAttribute("width",tA.toString()),EA.setAttribute("height",iA.toString()),EA.setAttribute("fill","transparent"),EA.setAttribute("rx","0"),EA.setAttribute("ry","0");const bA=document.createElementNS("http://www.w3.org/2000/svg","text");bA.setAttribute("class","schematic-group-overlay"),bA.setAttribute("x",(sA+Z).toString()),bA.setAttribute("y",(aA+iA-Z).toString()),bA.setAttribute("fill",u.color),bA.setAttribute("font-size",O.toString()),bA.setAttribute("font-family","Arial, sans-serif"),bA.setAttribute("font-weight",u.depthLevel===0?"600":"500"),bA.setAttribute("stroke",u.color),bA.setAttribute("stroke-width",Math.max(.2,O*.02).toString()),bA.textContent=X,s.appendChild(L),s.appendChild(EA),s.appendChild(bA)})}catch(a){console.error("Error creating group overlays:",a)}},10);return()=>clearTimeout(o)},[A,i,n])};function Wzt(t,A){let e=1/0,i=1/0,n=-1/0,o=-1/0;for(const r of t){let a=A.querySelector(`g[data-schematic-component-id="${r.schematic_component_id}"]`);if(a||(a=A.querySelector(`[data-schematic-component-id="${r.schematic_component_id}"]`)),a){const g=a.getBBox();e=Math.min(e,g.x),i=Math.min(i,g.y),n=Math.max(n,g.x+g.width),o=Math.max(o,g.y+g.height)}}return e===1/0?null:{minX:e,minY:i,maxX:n,maxY:o}}var Zzt=ba("schematic-viewer"),Vzt=()=>{ba.enable("schematic-viewer*")},jzt=Zzt,ile=t=>{const[A,e]=V.useState(0),[i,n]=V.useState(0);return V.useEffect(()=>{if(!t.current)return;const o=()=>{const r=t.current?.getBoundingClientRect();e(r?.width||0),n(r?.height||0)};o();const s=new ResizeObserver(o);return s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:A,containerHeight:i}},zzt=jzt.extend("useComponentDragging"),Xzt=({onEditEvent:t,editEvents:A=[],circuitJson:e,cancelDrag:i,svgToScreenProjection:n,realToSvgProjection:o,enabled:s=!1,snapToGrid:r=!1})=>{const[a,g]=V.useState(null),c=An(o,n),I=V.useRef(null),l=V.useRef(null),B=V.useRef(new Map);V.useEffect(()=>{A.forEach(D=>{"edit_event_type"in D&&D.edit_event_type==="edit_schematic_component_location"&&!D.in_progress&&B.current.set(D.schematic_component_id,{...D.new_center})})},[A]);const C=V.useCallback((D,S,_)=>{if(!s)return!1;const b=_.closest('[data-circuit-json-type="schematic_component"]');if(!b)return!1;const N=b.getAttribute("data-schematic-component-id");if(!N)return!1;i&&i();const F=YE(e).schematic_component.get(N);if(!F)return!1;I.current={x:D,y:S};let L;const Y=B.current.get(N);if(Y)L={...Y};else{const O=ele({editEvents:A,schematic_component_id:N});L={x:F.center.x+O.x,y:F.center.y+O.y},B.current.set(N,{...L})}const J={edit_event_id:Math.random().toString(36).substr(2,9),edit_event_type:"edit_schematic_component_location",schematic_component_id:N,original_center:L,new_center:{...L},in_progress:!0,created_at:Date.now(),_element:b};return l.current=J,g(J),!0},[i,s,e,A]),Q=V.useCallback(D=>{C(D.clientX,D.clientY,D.target)},[C]),h=V.useCallback(D=>{if(D.touches.length!==1)return;const S=D.touches[0];C(S.clientX,S.clientY,D.target)&&D.preventDefault()},[C]),E=V.useCallback((D,S)=>{if(!l.current||!I.current)return;const _={x:D-I.current.x,y:S-I.current.y},b={x:_.x/c.a,y:_.y/c.d};let N={x:l.current.original_center.x+b.x,y:l.current.original_center.y+b.y};if(r){const L=Y=>Math.round(Y*10)/10;N={x:L(N.x),y:L(N.y)}}const F={...l.current,new_center:N};l.current=F,g(F)},[c,r]),u=V.useCallback(D=>E(D.clientX,D.clientY),[E]),d=V.useCallback(D=>{if(D.touches.length!==1||!l.current)return;D.preventDefault();const S=D.touches[0];E(S.clientX,S.clientY)},[E]),f=V.useCallback(()=>{if(!l.current)return;const D={...l.current,in_progress:!1};B.current.set(D.schematic_component_id,{...D.new_center}),zzt("endDrag calling onEditEvent with new edit event",{newEditEvent:D}),t&&t(D),l.current=null,I.current=null,g(null)},[t]),y=V.useCallback(()=>f(),[f]),w=V.useCallback(()=>f(),[f]);return V.useEffect(()=>(window.addEventListener("mousemove",u),window.addEventListener("mouseup",y),window.addEventListener("touchmove",d,{passive:!1}),window.addEventListener("touchend",w),()=>{window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",y),window.removeEventListener("touchmove",d),window.removeEventListener("touchend",w)}),[u,y,d,w]),{handleMouseDown:Q,handleTouchStart:h,isDragging:!!l.current,activeEditEvent:a}},ES={schematicEditIcon:50,schematicGridIcon:49,spiceSimulationIcon:50,viewMenuIcon:48,viewMenu:55,viewMenuBackdrop:54,clickToInteractOverlay:100,schematicComponentHoverOutline:47,schematicPortHoverOutline:48},$zt=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return W.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Disable edit mode":"Enable edit mode",style:{position:"absolute",top:"16px",right:"64px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ES.schematicEditIcon},children:W.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[W.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),W.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})},AXt=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return W.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Hide grid":"Show grid",style:{position:"absolute",top:"56px",right:"64px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ES.schematicGridIcon},children:W.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:W.jsx("path",{d:"M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z"})})})},eXt=({onClick:t,active:A})=>{const e=i=>{i.preventDefault(),t()};return W.jsx("div",{onClick:e,onTouchEnd:e,title:A?"Hide view menu":"Show view menu",style:{position:"absolute",top:"16px",right:"16px",backgroundColor:A?"#4CAF50":"#fff",color:A?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ES.viewMenuIcon},children:W.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[W.jsx("circle",{cx:"12",cy:"12",r:"1"}),W.jsx("circle",{cx:"12",cy:"5",r:"1"}),W.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})},tXt={version:"2.0.58"},iXt=({circuitJson:t,circuitJsonKey:A,isVisible:e,onClose:i,showGroups:n,onToggleGroups:o,showGrid:s,onToggleGrid:r})=>{const a=V.useMemo(()=>{if(!t||t.length===0)return!1;try{if((YE(t).source_group?.list()||[]).length>0)return!0;const c=YE(t).schematic_component?.list()||[];if(c.length>1){const I=new Set;for(const l of c){const B=YE(t).source_component.get(l.source_component_id);B?.ftype&&I.add(B.ftype)}return I.size>1}return!1}catch(g){return console.error("Error checking for groups:",g),!1}},[A]);return e?W.jsxs(W.Fragment,{children:[W.jsx("div",{onClick:i,onTouchEnd:g=>{g.preventDefault(),i()},style:{position:"absolute",inset:0,backgroundColor:"transparent",zIndex:ES.viewMenuBackdrop}}),W.jsxs("div",{style:{position:"absolute",top:"56px",right:"16px",backgroundColor:"#ffffff",color:"#000000",border:"1px solid #ccc",borderRadius:"4px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",minWidth:"200px",zIndex:ES.viewMenu},children:[W.jsxs("div",{onClick:()=>{a&&o(!n)},onTouchEnd:g=>{g.preventDefault(),a&&o(!n)},style:{padding:"8px 12px",cursor:a?"pointer":"not-allowed",opacity:a?1:.5,fontSize:"13px",color:"#000000",fontFamily:"sans-serif",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:g=>{a&&(g.currentTarget.style.backgroundColor="#f0f0f0")},onMouseLeave:g=>{a&&(g.currentTarget.style.backgroundColor="transparent")},children:[W.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #000",borderRadius:"2px",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:"bold"},children:n&&"✓"}),"View Schematic Groups"]}),!a&&W.jsx("div",{style:{padding:"8px 12px",fontSize:"11px",color:"#666",fontStyle:"italic"},children:"No groups found in this schematic"}),W.jsxs("div",{onClick:()=>r(!s),onTouchEnd:g=>{g.preventDefault(),r(!s)},style:{padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:"#000000",fontFamily:"sans-serif",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="#f0f0f0"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent"},children:[W.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #000",borderRadius:"2px",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:"bold"},children:s&&"✓"}),"Show Grid"]}),W.jsxs("div",{style:{padding:"4px 8px",fontSize:"12px",color:"#999",borderTop:"1px solid #eee",textAlign:"center"},children:["v",String(tXt?.version)]})]})]}):null},nXt=()=>W.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:W.jsx("path",{d:"M3 12h2.5l2.5-9 4 18 4-9h5.5"})}),oXt=({onClick:t})=>W.jsx("div",{onClick:t,title:"Run SPICE simulation",style:{position:"absolute",top:"16px",right:"112px",backgroundColor:"#fff",color:"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:ES.spiceSimulationIcon},children:W.jsx(nXt,{})});Pj.register(vzt,Rzt,Izt,czt,dzt,bzt,Ezt);var Wj=["#8884d8","#82ca9d","#ffc658","#ff7300","#387908"],nle=t=>{if(t===0)return"0s";const A=Math.abs(t);let e="s",i=1;return A<1e-12?(e="fs",i=1e15):A<1e-9?(e="ps",i=1e12):A<1e-6?(e="ns",i=1e9):A<.001?(e="us",i=1e6):A<1&&(e="ms",i=1e3),`${parseFloat((t*i).toPrecision(3))}${e}`},sXt=({plotData:t,nodes:A,isLoading:e,error:i,hasRun:n})=>{const o=V.useMemo(()=>{const a=A.some(c=>c.toLowerCase().startsWith("v(")),g=A.some(c=>c.toLowerCase().startsWith("i("));return a&&g?"Value":a?"Voltage (V)":g?"Current (A)":"Value"},[A]);if(e)return W.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:"Running simulation..."});if(!n)return W.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:'Click "Run" to start the simulation.'});if(i)return W.jsxs("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"red"},children:["Error: ",i]});if(t.length===0)return W.jsx("div",{style:{height:"300px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:"No data to plot. Check simulation output or SPICE netlist."});const s={datasets:A.map((a,g)=>({label:a,data:t.map(c=>({x:Number(c.name),y:c[a]})),borderColor:Wj[g%Wj.length],backgroundColor:Wj[g%Wj.length],fill:!1,tension:.1}))},r={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"top",labels:{font:{family:"sans-serif"}}},title:{display:!1},tooltip:{callbacks:{title:a=>{if(a.length>0){const g=a[0];return nle(g.parsed.x)}return""}}}},scales:{x:{type:"linear",title:{display:!0,text:"Time",font:{family:"sans-serif"}},ticks:{callback:a=>nle(a),font:{family:"sans-serif"}}},y:{title:{display:!0,text:o,font:{family:"sans-serif"}},ticks:{font:{family:"sans-serif"}}}}};return W.jsx("div",{style:{position:"relative",height:"300px",width:"100%"},children:W.jsx(Pzt,{options:r,data:s})})},rXt=({spiceString:t,onClose:A,plotData:e,nodes:i,isLoading:n,error:o,simOptions:s,onSimOptionsChange:r,hasRun:a})=>{const[g,c]=V.useState(String(s.startTime)),[I,l]=V.useState(String(s.duration));V.useEffect(()=>{c(String(s.startTime)),l(String(s.duration))},[s.startTime,s.duration]);const B=()=>{r({...s,startTime:Number(g),duration:Number(I)})},C=i.filter(Q=>{const h=Q.toLowerCase().startsWith("v("),E=Q.toLowerCase().startsWith("i(");return!!(s.showVoltage&&h||s.showCurrent&&E)});return W.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1002,fontFamily:"sans-serif"},children:W.jsxs("div",{style:{backgroundColor:"white",padding:"24px",borderRadius:"12px",width:"90%",maxWidth:"900px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)"},children:[W.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:"1px solid #eee",paddingBottom:"16px"},children:[W.jsx("h2",{style:{margin:0,fontSize:"22px",fontWeight:600,color:"#333"},children:"SPICE Simulation"}),W.jsx("button",{onClick:A,style:{background:"none",border:"none",fontSize:"28px",cursor:"pointer",color:"#888",padding:0,lineHeight:1},children:"×"})]}),W.jsx("div",{children:W.jsx(sXt,{plotData:e,nodes:C,isLoading:n,error:o,hasRun:a})}),W.jsxs("div",{style:{marginTop:"16px",padding:"12px",backgroundColor:"#f7f7f7",borderRadius:"6px",display:"flex",flexWrap:"wrap",gap:"24px",alignItems:"center",fontSize:"14px"},children:[W.jsxs("div",{style:{display:"flex",gap:"16px"},children:[W.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[W.jsx("input",{type:"checkbox",checked:s.showVoltage,onChange:Q=>r({...s,showVoltage:Q.target.checked})}),"Voltage"]}),W.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[W.jsx("input",{type:"checkbox",checked:s.showCurrent,onChange:Q=>r({...s,showCurrent:Q.target.checked})}),"Current"]})]}),W.jsxs("div",{style:{display:"flex",gap:"16px",alignItems:"center"},children:[W.jsx("label",{htmlFor:"startTime",children:"Start Time (ms):"}),W.jsx("input",{id:"startTime",type:"number",value:g,onChange:Q=>c(Q.target.value),style:{width:"80px",padding:"4px 8px",borderRadius:"4px",border:"1px solid #ccc"}}),W.jsx("label",{htmlFor:"duration",children:"Duration (ms):"}),W.jsx("input",{id:"duration",type:"number",value:I,onChange:Q=>l(Q.target.value),style:{width:"80px",padding:"4px 8px",borderRadius:"4px",border:"1px solid #ccc"}}),W.jsx("button",{onClick:B,style:{padding:"4px 12px",borderRadius:"4px",border:"1px solid #ccc",backgroundColor:"#f0f0f0",cursor:"pointer"},children:a?"Rerun":"Run"})]})]}),W.jsxs("div",{style:{marginTop:"24px"},children:[W.jsx("h3",{style:{marginTop:0,marginBottom:"12px",fontSize:"18px",fontWeight:600,color:"#333"},children:"SPICE Netlist"}),W.jsx("pre",{style:{backgroundColor:"#fafafa",padding:"16px",borderRadius:"6px",maxHeight:"150px",overflowY:"auto",border:"1px solid #eee",color:"#333",fontSize:"13px",fontFamily:"monospace"},children:t})]})]})})},aXt="dmFyIGU9bnVsbCxzPWFzeW5jKCk9Pihhd2FpdCBpbXBvcnQoImh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vZWVjaXJjdWl0LWVuZ2luZUAxLjUuMi8rZXNtIikpLlNpbXVsYXRpb24sYz1hc3luYygpPT57aWYoZSYmZS5pc0luaXRpYWxpemVkKCkpcmV0dXJuO2xldCBpPWF3YWl0IHMoKTtlPW5ldyBpLGF3YWl0IGUuc3RhcnQoKX07c2VsZi5vbm1lc3NhZ2U9YXN5bmMgaT0+e3RyeXtpZihhd2FpdCBjKCksIWUpdGhyb3cgbmV3IEVycm9yKCJTaW11bGF0aW9uIG5vdCBpbml0aWFsaXplZCIpO2xldCB0PWkuZGF0YS5zcGljZVN0cmluZyxhPXQubWF0Y2goL3dyZGF0YVxzKyhcUyspXHMrKC4qKS9pKTtpZihhKXtsZXQgbz1gLnByb2JlICR7YVsyXS50cmltKCkuc3BsaXQoL1xzKy8pLmpvaW4oIiAiKX1gO3Q9dC5yZXBsYWNlKC93cmRhdGEuKi9pLG8pfWVsc2UgaWYoIXQubWF0Y2goL1wucHJvYmUvaSkpdGhyb3cgdC5tYXRjaCgvcGxvdFxzKyguKikvaSk/bmV3IEVycm9yKCJUaGUgJ3Bsb3QnIGNvbW1hbmQgaXMgbm90IHN1cHBvcnRlZCBmb3IgZGF0YSBleHRyYWN0aW9uLiBQbGVhc2UgdXNlICd3cmRhdGEgPGZpbGVuYW1lPiA8dmFyMT4gLi4uJyBvciAnLnByb2JlIDx2YXIxPiAuLi4nIGluc3RlYWQuIik6bmV3IEVycm9yKCJObyAnLnByb2JlJyBvciAnd3JkYXRhJyBjb21tYW5kIGZvdW5kIGluIFNQSUNFIGZpbGUuIFVzZSAnd3JkYXRhIDxmaWxlbmFtZT4gPHZhcjE+IC4uLicgdG8gc3BlY2lmeSBvdXRwdXQuIik7ZS5zZXROZXRMaXN0KHQpO2xldCBuPWF3YWl0IGUucnVuU2ltKCk7c2VsZi5wb3N0TWVzc2FnZSh7dHlwZToicmVzdWx0IixyZXN1bHQ6bn0pfWNhdGNoKHQpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixlcnJvcjp0Lm1lc3NhZ2V9KX19Owo=",Zj=null,gXt=()=>{if(typeof window>"u")return null;if(Zj)return Zj;try{const t=new Blob([atob(aXt)],{type:"application/javascript"});return Zj=URL.createObjectURL(t),Zj}catch(t){return console.error("Failed to create blob URL for worker",t),null}},cXt=t=>{const A={};if(t.dataType==="real")t.data.forEach(r=>{A[r.name]=r.values});else if(t.dataType==="complex")t.data.forEach(r=>{A[r.name]=r.values.map(a=>a.real)});else throw new Error("Unsupported data type in simulation result");const e=Object.keys(A).find(r=>r.toLowerCase()==="time"||r.toLowerCase()==="frequency");if(!e)throw new Error("No time or frequency data in simulation result");const i=A[e],n=Object.keys(A).filter(r=>r!==e),o=n;return{plotData:i.map((r,a)=>{const g={name:r.toExponential(2)};return n.forEach(c=>{g[c]=A[c][a]}),g}),nodes:o}},IXt=t=>{const[A,e]=V.useState([]),[i,n]=V.useState([]),[o,s]=V.useState(!0),[r,a]=V.useState(null);return V.useEffect(()=>{if(!t){s(!1),e([]),n([]),a(null);return}s(!0),a(null),e([]),n([]);const g=gXt();if(!g){a("Could not create SPICE simulation worker."),s(!1);return}const c=new Worker(g,{type:"module"});return c.onmessage=I=>{if(I.data.type==="result")try{const{plotData:l,nodes:B}=cXt(I.data.result);e(l),n(B)}catch(l){a(l.message||"Failed to parse simulation result"),console.error(l)}else I.data.type==="error"&&a(I.data.error);s(!1)},c.onerror=I=>{a(I.message),s(!1)},c.postMessage({spiceString:t}),()=>{c.terminate()}},[t]),{plotData:A,nodes:i,isLoading:o,error:r}},ryA=t=>{if(t===0)return"0";const A=Math.abs(t),e=i=>i.toPrecision(4);return A>=1?e(t):A>=.001?`${e(t*1e3)}m`:A>=1e-6?`${e(t*1e6)}u`:A>=1e-9?`${e(t*1e9)}n`:A>=1e-12?`${e(t*1e12)}p`:A>=1e-15?`${e(t*1e15)}f`:t.toExponential(3)},lXt=(t,A)=>{const i=VPA(t).toSpiceString(),o=i.split(`
5386
5386
  `).filter(b=>b.trim()!=="").filter(b=>!b.startsWith("*")&&!b.startsWith(".")&&b.trim()!==""),s=new Set,r=new Set,a=new Set;for(const b of o){const N=b.trim().split(/\s+/);if(N.length<3)continue;const F=N[0],L=F[0].toUpperCase();let Y=[];if(["R","C","L","V","I","D"].includes(L))Y=N.slice(1,3),L==="V"&&a.add(F);else if(L==="Q"&&N.length>=4)Y=N.slice(1,4);else if(L==="M"&&N.length>=5)Y=N.slice(1,5);else if(L==="X")Y=N.slice(1,-1);else continue;Y.forEach(J=>s.add(J)),L==="C"&&Y.forEach(J=>r.add(J))}s.delete("0"),r.delete("0");const g=Array.from(r).map(b=>`.ic V(${b})=0`),c=[],I=Array.from(s).map(b=>`V(${b})`);c.push(...I);const l=Array.from(a).map(b=>`I(${b})`);c.push(...l);const B=c.length>0?`.probe ${c.join(" ")}`:"",C=A?.startTime??0,Q=A?.duration??20,h=C*.001,E=Q*.001,u=h+E,d=E/50,f=`.tran ${ryA(d)} ${ryA(u)} ${ryA(h)} UIC`,y=".end",w=i.split(`
5387
5387
  `);let D=-1;for(let b=w.length-1;b>=0;b--)if(w[b].trim().toLowerCase().startsWith(y)){D=b;break}const S=[...g,B,f].filter(Boolean);let _;if(D!==-1){const b=w.slice(0,D),N=w.slice(D);_=[...b,...S,...N]}else _=[...w,...S,y];return _.join(`
5388
5388
  `)},BXt=(t,A)=>{if(typeof window>"u")return A;try{const e=localStorage.getItem(t);return e!==null?JSON.parse(e):A}catch{return A}},CXt=(t,A)=>{if(!(typeof window>"u"))try{localStorage.setItem(t,JSON.stringify(A))}catch{}},ayA=V.createContext(null),QXt=5,hXt=(t,A)=>!t&&!A?!0:!t||!A?!1:t.minX===A.minX&&t.maxX===A.maxX&&t.minY===A.minY&&t.maxY===A.maxY,EXt=({children:t})=>{if(V.useContext(ayA))return W.jsx(W.Fragment,{children:t});const e=V.useRef({pointer:null,boundingBoxes:new Map,hoveringIds:new Set,subscribers:new Set,mouseDownPosition:null}),i=V.useCallback(()=>{for(const I of e.current.subscribers)I()},[]),n=V.useCallback(()=>{const I=e.current.pointer,l=new Set;if(I)for(const[C,Q]of e.current.boundingBoxes){const h=Q.bounds;h&&I.x>=h.minX&&I.x<=h.maxX&&I.y>=h.minY&&I.y<=h.maxY&&l.add(C)}const B=e.current.hoveringIds;l.size===B.size&&[...l].every(C=>B.has(C))||(e.current.hoveringIds=l,i())},[i]),o=V.useCallback((I,l)=>{e.current.boundingBoxes.set(I,l),n()},[n]),s=V.useCallback((I,l)=>{const B=e.current.boundingBoxes.get(I);B&&hXt(B.bounds,l.bounds)&&B.onClick===l.onClick||(e.current.boundingBoxes.set(I,l),n())},[n]),r=V.useCallback(I=>{e.current.boundingBoxes.delete(I)&&n()},[n]),a=V.useCallback(I=>(e.current.subscribers.add(I),()=>{e.current.subscribers.delete(I)}),[]),g=V.useCallback(I=>e.current.hoveringIds.has(I),[]);V.useEffect(()=>{const I=Q=>{const{clientX:h,clientY:E}=Q,u=e.current.pointer;u&&u.x===h&&u.y===E||(e.current.pointer={x:h,y:E},n())},l=()=>{e.current.pointer!==null&&(e.current.pointer=null,e.current.mouseDownPosition=null,n())},B=Q=>{e.current.mouseDownPosition={x:Q.clientX,y:Q.clientY}},C=Q=>{const{clientX:h,clientY:E}=Q,u=e.current.mouseDownPosition;if(u&&Math.sqrt(Math.pow(h-u.x,2)+Math.pow(E-u.y,2))>QXt){e.current.mouseDownPosition=null;return}e.current.mouseDownPosition=null;for(const d of e.current.boundingBoxes.values()){const f=d.bounds;f&&h>=f.minX&&h<=f.maxX&&E>=f.minY&&E<=f.maxY&&d.onClick?.(Q)}};return window.addEventListener("pointermove",I,{passive:!0}),window.addEventListener("pointerdown",I,{passive:!0}),window.addEventListener("pointerup",I,{passive:!0}),window.addEventListener("pointerleave",l),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),window.addEventListener("mousedown",B,{passive:!0}),window.addEventListener("click",C,{passive:!0}),()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerdown",I),window.removeEventListener("pointerup",I),window.removeEventListener("pointerleave",l),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l),window.removeEventListener("mousedown",B),window.removeEventListener("click",C)}},[n]);const c=V.useMemo(()=>({registerBoundingBox:o,updateBoundingBox:s,unregisterBoundingBox:r,subscribe:a,isHovering:g}),[o,s,r,a,g]);return W.jsx(ayA.Provider,{value:c,children:t})},ole=t=>{const A=V.useContext(ayA);if(!A)throw new Error("useMouseEventsOverBoundingBox must be used within a MouseTracker");const e=V.useId(),i=V.useRef(t);i.current=t;const n=V.useMemo(()=>s=>{i.current.onClick?.(s)},[]);return V.useEffect(()=>(A.registerBoundingBox(e,{bounds:i.current.bounds,onClick:i.current.onClick?n:void 0}),()=>{A.unregisterBoundingBox(e)}),[A,n,e]),V.useEffect(()=>{A.updateBoundingBox(e,{bounds:i.current.bounds,onClick:i.current.onClick?n:void 0})},[A,n,e,t.bounds?.minX,t.bounds?.maxX,t.bounds?.minY,t.bounds?.maxY,t.onClick]),{hovering:V.useSyncExternalStore(A.subscribe,()=>A.isHovering(e),()=>!1)}},uXt=(t,A)=>!t&&!A?!0:!t||!A?!1:Math.abs(t.bounds.minX-A.bounds.minX)<.5&&Math.abs(t.bounds.maxX-A.bounds.maxX)<.5&&Math.abs(t.bounds.minY-A.bounds.minY)<.5&&Math.abs(t.bounds.maxY-A.bounds.maxY)<.5&&Math.abs(t.rect.left-A.rect.left)<.5&&Math.abs(t.rect.top-A.rect.top)<.5&&Math.abs(t.rect.width-A.rect.width)<.5&&Math.abs(t.rect.height-A.rect.height)<.5,dXt=({componentId:t,svgDivRef:A,containerRef:e,onComponentClick:i,onHoverChange:n,showOutline:o,circuitJsonKey:s})=>{const[r,a]=V.useState(null),g=V.useRef(null),c=V.useCallback(()=>{g.current=null;const h=A.current,E=e.current;if(!h||!E){a(w=>w&&null);return}const u=h.querySelector(`[data-schematic-component-id="${t}"]`);if(!u){a(w=>w&&null);return}const d=u.getBoundingClientRect(),f=E.getBoundingClientRect(),y={bounds:{minX:d.left,maxX:d.right,minY:d.top,maxY:d.bottom},rect:{left:d.left-f.left,top:d.top-f.top,width:d.width,height:d.height}};a(w=>uXt(w,y)?w:y)},[t,e,A]),I=V.useCallback(()=>{g.current===null&&(g.current=window.requestAnimationFrame(c))},[c]);V.useEffect(()=>{I()},[I,s]),V.useEffect(()=>{I();const h=A.current,E=e.current;if(!h||!E)return;const u=typeof ResizeObserver<"u"?new ResizeObserver(()=>{I()}):null;u?.observe(E),u?.observe(h);const d=typeof MutationObserver<"u"?new MutationObserver(()=>{I()}):null;return d?.observe(h,{attributes:!0,attributeFilter:["style","transform"],subtree:!0,childList:!0}),window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{u?.disconnect(),d?.disconnect(),window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I),g.current!==null&&(cancelAnimationFrame(g.current),g.current=null)}},[I,A,e]);const l=V.useCallback(h=>{i&&i(t,h)},[t,i]),B=r?.bounds??null,{hovering:C}=ole({bounds:B,onClick:i?l:void 0});if(V.useEffect(()=>{n&&n(t,C)},[C,t,n]),!r||!C||!o)return null;const Q=r.rect;return W.jsx("div",{style:{position:"absolute",left:Q.left,top:Q.top,width:Q.width,height:Q.height,border:"1.5px solid rgba(51, 153, 255, 0.9)",pointerEvents:"none",zIndex:ES.schematicComponentHoverOutline}})},pXt=(t,A)=>!t&&!A?!0:!t||!A?!1:Math.abs(t.bounds.minX-A.bounds.minX)<.5&&Math.abs(t.bounds.maxX-A.bounds.maxX)<.5&&Math.abs(t.bounds.minY-A.bounds.minY)<.5&&Math.abs(t.bounds.maxY-A.bounds.maxY)<.5&&Math.abs(t.rect.left-A.rect.left)<.5&&Math.abs(t.rect.top-A.rect.top)<.5&&Math.abs(t.rect.width-A.rect.width)<.5&&Math.abs(t.rect.height-A.rect.height)<.5,fXt=({portId:t,portLabel:A,svgDivRef:e,containerRef:i,onPortClick:n,onHoverChange:o,showOutline:s,circuitJsonKey:r})=>{const[a,g]=V.useState(null),c=V.useRef(null),I=V.useCallback(()=>{c.current=null;const E=e.current,u=i.current;if(!E||!u){g(S=>S&&null);return}const d=E.querySelector(`[data-schematic-port-id="${t}"]`);if(!d){g(S=>S&&null);return}const f=d.getBoundingClientRect(),y=u.getBoundingClientRect(),w=4,D={bounds:{minX:f.left-w,maxX:f.right+w,minY:f.top-w,maxY:f.bottom+w},rect:{left:f.left-y.left-w,top:f.top-y.top-w,width:f.width+w*2,height:f.height+w*2}};g(S=>pXt(S,D)?S:D)},[t,i,e]),l=V.useCallback(()=>{c.current===null&&(c.current=window.requestAnimationFrame(I))},[I]);V.useEffect(()=>{l()},[l,r]),V.useEffect(()=>{l();const E=e.current,u=i.current;if(!E||!u)return;const d=typeof ResizeObserver<"u"?new ResizeObserver(()=>{l()}):null;d?.observe(u),d?.observe(E);const f=typeof MutationObserver<"u"?new MutationObserver(()=>{l()}):null;return f?.observe(E,{attributes:!0,attributeFilter:["style","transform"],subtree:!0,childList:!0}),window.addEventListener("scroll",l,!0),window.addEventListener("resize",l),()=>{d?.disconnect(),f?.disconnect(),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l),c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)}},[l,e,i]);const B=V.useCallback(E=>{n&&n(t,E)},[t,n]),C=a?.bounds??null,{hovering:Q}=ole({bounds:C,onClick:n?B:void 0});if(V.useEffect(()=>{o&&o(t,Q)},[Q,t,o]),!a||!s)return null;const h=a.rect;return W.jsxs(W.Fragment,{children:[W.jsx("div",{style:{position:"absolute",left:h.left,top:h.top,width:h.width,height:h.height,border:Q?"1.5px solid rgba(255, 153, 51, 0.9)":"1.5px solid rgba(255, 153, 51, 0.3)",backgroundColor:Q?"rgba(255, 153, 51, 0.15)":"rgba(255, 153, 51, 0.05)",borderRadius:"50%",pointerEvents:"none",zIndex:ES.schematicPortHoverOutline,transition:"border-color 0.15s, background-color 0.15s"}}),Q&&A&&W.jsx("div",{style:{position:"absolute",left:h.left+h.width/2,top:h.top-24,transform:"translateX(-50%)",backgroundColor:"rgba(0, 0, 0, 0.85)",color:"white",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"nowrap",pointerEvents:"none",zIndex:ES.schematicPortHoverOutline+1},children:A})]})},yXt=({circuitJson:t,containerStyle:A,editEvents:e=[],onEditEvent:i,defaultEditMode:n=!1,debugGrid:o=!1,editingEnabled:s=!1,debug:r=!1,clickToInteractEnabled:a=!1,colorOverrides:g,spiceSimulationEnabled:c=!1,disableGroups:I=!1,onSchematicComponentClicked:l,showSchematicPorts:B=!1,onSchematicPortClicked:C})=>{r&&Vzt();const[Q,h]=V.useState(!1),[E,u]=V.useState({showVoltage:!0,showCurrent:!1,startTime:0,duration:20}),d=hA=>`${hA?.length||0}_${hA?.editCount||0}`,f=V.useMemo(()=>d(t),[t]),y=V.useMemo(()=>{if(!c)return null;try{return lXt(t,E)}catch(hA){return console.error("Failed to generate SPICE string",hA),null}},[f,c,E.startTime,E.duration]),[w,D]=V.useState(!1);V.useEffect(()=>{D(!1)},[f]);const{plotData:S,nodes:_,isLoading:b,error:N}=IXt(w?y:null),[F,L]=V.useState(n),[Y,J]=V.useState(!0),[O,Z]=V.useState(!1),X=o||O,[eA,gA]=V.useState(!a),[tA,iA]=V.useState(!1),[sA,aA]=V.useState(()=>I?!1:BXt("schematic_viewer_show_groups",!1)),[EA,bA]=V.useState(!1),_A=V.useRef(new Set),LA=V.useCallback((hA,oe)=>{oe?_A.current.add(hA):_A.current.delete(hA),bA(_A.current.size>0)},[]),[QA,kA]=V.useState(!1),dA=V.useRef(new Set),qA=V.useCallback((hA,oe)=>{oe?dA.current.add(hA):dA.current.delete(hA),kA(dA.current.size>0)},[]),VA=V.useRef(null),ce=V.useRef(null),fA=V.useMemo(()=>{try{return YE(t).schematic_component?.list()?.map(hA=>hA.schematic_component_id)??[]}catch(hA){return console.error("Failed to derive schematic component ids",hA),[]}},[f,t]),ge=V.useMemo(()=>{if(!B)return[];try{return(YE(t).schematic_port?.list()??[]).map(oe=>{const Be=YE(t).source_port.get(oe.source_port_id),Le=(Be?.source_component_id?YE(t).source_component.get(Be.source_component_id):null)?.name??"?",Te=oe.display_pin_label??Be?.pin_number??Be?.name??"?";return{portId:oe.source_port_id,label:`${Le}.${Te}`}})}catch(hA){return console.error("Failed to derive schematic port info",hA),[]}},[f,t,B]),jA=hA=>{const oe=hA.touches[0];ce.current={x:oe.clientX,y:oe.clientY}},JA=hA=>{const oe=hA.changedTouches[0],Be=ce.current;if(!Be)return;const ye=Math.abs(oe.clientX-Be.x),Le=Math.abs(oe.clientY-Be.y);ye<10&&Le<10&&(hA.preventDefault(),gA(!0)),ce.current=null},[OA,vA]=V.useState([]),wA=V.useRef(t);V.useEffect(()=>{const hA=d(t),oe=d(wA.current);hA!==oe&&(vA([]),wA.current=t)},[t]);const{ref:RA,cancelDrag:MA,transform:KA}=lT({onSetTransform(hA){VA.current&&(VA.current.style.transform=Xd(hA))},enabled:eA&&!Q}),{containerWidth:ZA,containerHeight:ne}=ile(RA),SA=V.useMemo(()=>!ZA||!ne?"":dj(t,{width:ZA,height:ne||720,grid:X?{cellSize:1,labelCells:!0}:void 0,colorOverrides:g}),[f,ZA,ne,X]),CA=V.useMemo(()=>SA.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i)?.[1]??"transparent",[SA]),uA=V.useMemo(()=>{if(!SA)return xa();const hA=SA.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return Wq(hA)}catch(oe){return console.error(oe),xa()}},[SA]),TA=hA=>{vA(oe=>[...oe,hA]),i&&i(hA)},re=V.useMemo(()=>[...e,...OA],[e,OA]),{handleMouseDown:Qe,handleTouchStart:me,isDragging:_e,activeEditEvent:ke}=Xzt({onEditEvent:TA,cancelDrag:MA,realToSvgProjection:uA,svgToScreenProjection:KA,circuitJson:t,editEvents:re,enabled:F&&eA&&!Q,snapToGrid:Y});Kzt({svgDivRef:VA,editEvents:re,realToSvgProjection:uA,svgToScreenProjection:KA,activeEditEvent:ke}),qzt({svgDivRef:VA,circuitJson:t,activeEditEvent:ke,editEvents:re}),Ozt({svgDivRef:VA,circuitJson:t,circuitJsonKey:f,showGroups:sA&&!I});const Pe=V.useRef(me);V.useEffect(()=>{Pe.current=me},[me]);const lt=V.useMemo(()=>W.jsx("div",{ref:VA,style:{pointerEvents:a?eA?"auto":"none":"auto",transformOrigin:"0 0"},className:l?"schematic-component-clickable":void 0,onTouchStart:hA=>{F&&eA&&!Q&&Pe.current(hA)},dangerouslySetInnerHTML:{__html:SA}}),[SA,eA,a,F,Q]);return W.jsxs(EXt,{children:[l&&W.jsx("style",{children:".schematic-component-clickable [data-schematic-component-id]:hover { cursor: pointer !important; }"}),C&&W.jsx("style",{children:"[data-schematic-port-id]:hover { cursor: pointer !important; }"}),W.jsxs("div",{ref:RA,style:{position:"relative",backgroundColor:CA,overflow:"hidden",cursor:Q?"auto":_e?"grabbing":a&&!eA||EA&&l||QA&&C?"pointer":"grab",minHeight:"300px",...A},onWheelCapture:hA=>{Q&&hA.stopPropagation()},onMouseDown:hA=>{if(a&&!eA){hA.preventDefault(),hA.stopPropagation();return}Qe(hA)},onMouseDownCapture:hA=>{if(a&&!eA){hA.preventDefault(),hA.stopPropagation();return}},onTouchStart:hA=>{Q||jA(hA)},onTouchEnd:hA=>{Q||JA(hA)},children:[!eA&&a&&W.jsx("div",{onClick:hA=>{hA.preventDefault(),hA.stopPropagation(),gA(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:ES.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"all",touchAction:"pan-x pan-y pinch-zoom"},children:W.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",fontFamily:"sans-serif",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})}),W.jsx(eXt,{active:tA,onClick:()=>iA(!tA)}),s&&W.jsx($zt,{active:F,onClick:()=>L(!F)}),s&&F&&W.jsx(AXt,{active:Y,onClick:()=>J(!Y)}),W.jsx(iXt,{circuitJson:t,circuitJsonKey:f,isVisible:tA,onClose:()=>iA(!1),showGroups:sA,onToggleGroups:hA=>{I||(aA(hA),CXt("schematic_viewer_show_groups",hA))},showGrid:X,onToggleGrid:Z}),c&&W.jsx(oXt,{onClick:()=>h(!0)}),Q&&W.jsx(rXt,{spiceString:y,onClose:()=>h(!1),plotData:S,nodes:_,isLoading:b,error:N,simOptions:E,onSimOptionsChange:hA=>{D(!0),u(hA)},hasRun:w}),l&&fA.map(hA=>W.jsx(dXt,{componentId:hA,svgDivRef:VA,containerRef:RA,showOutline:!0,circuitJsonKey:f,onHoverChange:LA,onComponentClick:(oe,Be)=>{l?.({schematicComponentId:oe,event:Be})}},hA)),lt,B&&ge.map(({portId:hA,label:oe})=>W.jsx(fXt,{portId:hA,portLabel:oe,svgDivRef:VA,containerRef:RA,showOutline:!0,circuitJsonKey:f,onHoverChange:qA,onPortClick:C?(Be,ye)=>{C?.({schematicPortId:Be,event:ye})}:void 0},hA))]})]})},mXt=({circuitJson:t,containerStyle:A,colorOverrides:e,width:i,height:n,className:o})=>{const[s,r]=V.useState(null),[a,g]=V.useState(!0),[c,I]=V.useState(null),[l,B]=V.useState(null),C=V.useRef(null),Q=V.useRef(null),{containerWidth:h,containerHeight:E}=ile(C),[u,d]=V.useState(!1),{ref:f}=lT({onSetTransform(L){Q.current&&(Q.current.style.transform=Xd(L))}}),y=i||h||1e3,w=n||E||600;V.useEffect(()=>{g(!0),I(null),r(t),g(!1)},[t]);const D=V.useMemo(()=>s&&s.find(Y=>Y.type==="simulation_experiment")?.simulation_experiment_id||null,[s]),S=V.useMemo(()=>s?s.filter(L=>L.type==="simulation_transient_voltage_graph").map(L=>L.simulation_transient_voltage_graph_id):[],[s]),_=V.useMemo(()=>{if(!s||!y||!w||!D)return"";try{return Vge({circuitJson:s,simulation_experiment_id:D,simulation_transient_voltage_graph_ids:S,width:y,height:w,schematicOptions:{colorOverrides:e}})}catch(L){return console.error("Failed to generate fallback schematic SVG:",L),""}},[s,y,w,e,D,S]);V.useEffect(()=>{if(!_){B(null);return}try{const L=new Blob([_],{type:"image/svg+xml"}),Y=URL.createObjectURL(L);return B(Y),()=>{URL.revokeObjectURL(Y)}}catch(L){console.error("Failed to create SVG object URL:",L),B(null)}},[_]);const b=V.useMemo(()=>_?_.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i)?.[1]??"transparent":"transparent",[_]),N=L=>{d(!0)},F=L=>{d(!0)};return V.useEffect(()=>{const L=()=>{d(!1)},Y=()=>{d(!1)};return window.addEventListener("mouseup",L),window.addEventListener("touchend",Y),()=>{window.removeEventListener("mouseup",L),window.removeEventListener("touchend",Y)}},[]),a?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..."}):c?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:c})]})}):_?W.jsx("div",{ref:L=>{C.current=L,f.current=L},style:{position:"relative",backgroundColor:b,overflow:"hidden",minHeight:"300px",cursor:u?"grabbing":"grab",...A},className:o,onMouseDown:N,onTouchStart:F,children:l?W.jsx("img",{ref:Q,src:l,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"]})]})},sle=t=>{const[A,e]=V.useState(0),[i,n]=V.useState(0);return V.useEffect(()=>{if(!t.current)return;const o=()=>{const r=t.current?.getBoundingClientRect();e(r?.width||0),n(r?.height||0)};o();const s=new ResizeObserver(o);return s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:A,containerHeight:i}};ba("assembly-viewer");var rle=()=>{ba.enable("assembly-viewer*")},wXt=({circuitJson:t,containerStyle:A,debugGrid:e=!1,debug:i=!1})=>{i&&rle();const n=V.useRef(null),{ref:o}=lT({onSetTransform(c){n.current&&(n.current.style.transform=Xd(c))}}),{containerWidth:s,containerHeight:r}=sle(o),a=V.useMemo(()=>!s||!r?"":Dge(t,{width:s,height:r||720}),[t,s,r]);V.useMemo(()=>{if(!a)return xa();const c=a.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return Wq(c)}catch(I){return console.error(I),xa()}},[a]);const g=V.useMemo(()=>W.jsx("div",{ref:n,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:a}}),[a]);return W.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:g})},DXt=({circuitJson:t,containerStyle:A,debugGrid:e=!1,debug:i=!1})=>{i&&rle();const n=V.useRef(null),{ref:o}=lT({onSetTransform(c){n.current&&(n.current.style.transform=Xd(c))}}),{containerWidth:s,containerHeight:r}=sle(o),a=V.useMemo(()=>!s||!r?"":m0A(t,{width:s,height:r||720}),[t,s,r]);V.useMemo(()=>{if(!a)return xa();const c=a.match(/data-real-to-screen-transform="([^"]+)"/)?.[1];try{return Wq(c)}catch(I){return console.error(I),xa()}},[a]);const g=V.useMemo(()=>W.jsx("div",{ref:n,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:a}}),[a]);return W.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...A},children:g})};const ale=["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."],SXt=(()=>{let t=ale[Math.floor(Math.random()*ale.length)];return t=t.replace(/</g,"&lt;"),t=t.replace(/>/g,"&gt;"),t=t.replace(new RegExp('(?<!href=")(?<!\\()(?<!\\]\\()(https?:\\/\\/[^\\s\\)\\]]+)',"g"),(A,e)=>`<a class="rf-text-blue-500 rf-underline" href="${A}" target="_blank">${A}</a>`),t=t.replace(/\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/g,'<a class="rf-text-blue-500 rf-underline" href="$2" target="_blank">$1</a>'),t})(),tx=({onRunClicked:t})=>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(Qqt,{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:SXt}})]}),t&&W.jsxs(Ja,{className:"rf-mt-4 rf-bg-blue-600 rf-hover:bg-blue-500",onClick:t,children:["Run Code",W.jsx(ere,{className:"rf-w-3 rf-h-3 rf-ml-2"})]})]}),Vj=({text:t,onClick:A})=>W.jsx("span",{className:"rf-cursor-pointer rf-underline rf-text-blue-600 rf-mx-2",onClick:A,children:t}),jj=t=>W.jsxs("div",{className:"rf-leading-5",children:[W.jsx("div",{className:"rf-py-2 rf-font-bold",children:t.column.name}),W.jsx("div",{children:t.field?.()??W.jsx("input",{type:"text",className:"rf-border rf-rounded rf-p-1 rf-w-full",onChange:A=>{t.onTextChange?.(A.target.value)}})})]}),bXt=({open:t,children:A,title:e,onClose:i})=>t?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:i,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:n=>{n.preventDefault(),n.stopPropagation()},children:[W.jsx("h2",{className:"rf-mt-0 rf-text-md rf-pb-4",children:e}),W.jsx("button",{type:"button",className:"rf-absolute rf-top-2 rf-right-4 rf-text-2xl rf-font-bold",onClick:i,children:"×"}),A]})}):null,xXt=({elements:t})=>{const[A,e]=V.useState({open:!1}),[i,n]=V.useReducer((c,I)=>({...c,...I}),{}),o=[...new Set(t.map(c=>c.type))],s=t.map(c=>{const I=c[`${c.type}_id`],l=Object.fromEntries(Object.entries(c).filter(([C])=>!(C===`${c.type}_id`||!C.endsWith("_id")))),B=Object.fromEntries(Object.entries(c).filter(([C])=>!C.endsWith("_id")));return{primary_id:I,other_ids:l,...B,_og_elm:c}}),r=s.map(c=>{let I="";const l=B=>{const C=Object.keys(B.other_ids).find(E=>E.startsWith("source_"));if(!C)return`.${B.name}`;const Q=C.slice(0,-3),h=s.find(E=>E.type===Q&&E.primary_id===B.other_ids[C]);return h?"name"in h?`${l(h)} > .${B.name}`:`#${h.primary_id} > .${B.name}`:`??? > .${B.name}`};return"name"in c&&(I=l(c)),{...c,selector_path:I}}),a=[{key:"primary_id",name:"primary_id",renderCell:c=>W.jsxs("div",{className:"rf-flex rf-items-center",children:[W.jsx(Vj,{text:c.primary_id,onClick:()=>n({focused_id:c.primary_id,id_search:void 0,selector_search:void 0})}),W.jsx("span",{className:"rf-flex-grow"}),W.jsx(Vj,{text:"(JSON)",onClick:()=>e({open:!0,element:c._og_elm,title:c.primary_id})})]}),renderHeaderCell:c=>W.jsx(jj,{column:c,onTextChange:I=>n({id_search:I}),field:i.focused_id?()=>W.jsxs("div",{children:["Focus:"," ",W.jsx("span",{className:"rf-underline",children:i.focused_id}),W.jsx(Vj,{text:"(unfocus)",onClick:()=>n({focused_id:void 0})})]}):void 0})},{key:"type",name:"type",renderHeaderCell:c=>W.jsx(jj,{column:c,field:()=>W.jsxs("select",{onChange:I=>n({component_type_filter:I.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(I=>W.jsx("option",{value:I,children:I},I))]})})},{key:"name",name:"name",renderHeaderCell:c=>W.jsx(jj,{column:c,onTextChange:I=>n({name_search:I})})},{key:"selector_path",name:"selector_path",renderHeaderCell:c=>W.jsx(jj,{column:c,onTextChange:I=>n({selector_search:I})})},{key:"other_ids",name:"other_ids",renderCell:c=>W.jsx("div",{className:"rf-space-x-2",children:Object.entries(c.other_ids).map(([I,l])=>W.jsx(Vj,{text:l,onClick:()=>n({focused_id:l})},l))})}],g=r.filter(c=>i.name_search?c.name?.toLowerCase()?.includes(i.name_search.toLowerCase()):!0).filter(c=>!i.component_type_filter||i.component_type_filter==="any"?!0:i.component_type_filter==="source"?c.type.startsWith("source_"):i.component_type_filter==="source/pcb"?c.type.startsWith("source_")||c.type.startsWith("pcb_"):i.component_type_filter==="source/schematic"?c.type.startsWith("source_")||c.type.startsWith("schematic_"):c.type?.includes(i.component_type_filter)).filter(c=>i.selector_search?i.selector_search.split(" ").filter(l=>l.length>0).every(l=>c.selector_path?.includes(l)):!0).filter(c=>i.id_search?c.primary_id?.includes(i.id_search):!0).filter(c=>!!(!i.focused_id||c.primary_id===i.focused_id||Object.values(c.other_ids).includes(i.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:a.map(c=>W.jsx("th",{className:"rf-px-4 rf-py-2 rf-border-b",children:c.renderHeaderCell?c.renderHeaderCell(c):c.name},c.key))})}),W.jsx("tbody",{children:g.map((c,I)=>W.jsx("tr",{className:"rf-hover:bg-gray-100",children:a.map(l=>W.jsx("td",{className:"rf-px-4 rf-py-2 rf-border-b",children:l.renderCell?l.renderCell(c):c[l.key]},l.key))},I))})]})}),W.jsx(bXt,{open:A.open,onClose:()=>e({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):""})})})]})},_Xt=(t,A)=>t==="jlcpcb"?W.jsx("a",{className:"rf-underline rf-text-blue-500",target:"_blank",rel:"noreferrer",href:`https://jlcpcb.com/partdetail/${A}`,children:A}):A,kXt=({circuitJson:t})=>{const A=t.filter(i=>i.type==="source_component"),e=new Set;for(const i of A)if(i.supplier_part_numbers)for(const n of Object.keys(i.supplier_part_numbers))e.add(n);return 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.jsxs("tr",{className:"rf-border-b",children:[W.jsx("th",{className:"rf-p-2",children:"Name"}),Array.from(e).map(i=>W.jsx("th",{className:"rf-p-2 rf-capitalize",children:i},i))]})}),W.jsx("tbody",{children:A.map(i=>W.jsxs("tr",{className:"rf-border-b",children:[W.jsx("td",{className:"rf-p-2",children:i.name}),Array.from(e).map(n=>W.jsx("td",{className:"rf-p-2",children:_Xt(n,i.supplier_part_numbers?.[n]?.[0]||"")},n))]},i.source_component_id))})]})})},gyA=V.forwardRef(({className:t,type:A,...e},i)=>W.jsx("input",{type:A,className:hn("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",t),ref:i,...e}));gyA.displayName="Input";var gle={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,ms:1,s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},cyA=new Set;for(const[t,A]of Object.entries(gle)){cyA.add(t);for(const e of Object.keys(A.variants))cyA.add(e)}function vXt(t){for(const[A,e]of Object.entries(gle))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var cle={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12};function Kw(t){if(t==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:r,unitOfValue:a}=Kw(t.x),g=Kw(t.x),c=Kw(t.y);return g.value===null||c.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:c.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),n=t.slice(0,-i.length);if(i in cle&&!cyA.has(i)){const r=cle[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(n)*r}}const{baseUnit:o,conversionFactor:s}=vXt(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(n)}}var zj=U().or(WA()).transform(t=>Kw(t).value),IyA=U().or(WA()).transform(t=>Kw(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),Ile=U().or(WA()).transform(t=>Kw(t).value),ix=U().or(WA()).transform(t=>Kw(t).value),rn=U().or(WA()).transform(t=>Kw(t).value),FM=U().or(WA()).transform(t=>Kw(t).value),Et=rn,E2=U().or(WA()).transform(t=>Kw(t).value),MT=U().or(WA()).transform(t=>Kw(t).value),FXt=MT,MM=MT,lle=U().datetime(),cC=U().or(WA()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),Ble=WA().or(U().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const A=t.replace("mAh",""),e=Number.parseFloat(A);if(Number.isNaN(e))throw new Error("Invalid capacity");return e}return t}).describe("Battery capacity in mAh"),Bn=te({x:Et,y:Et}),MXt=Bn,nx=te({x:Et,y:Et,z:Et}),RXt=nx,lyA=te({width:WA(),height:WA()}),NXt=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},Wt=t=>U().optional().default(()=>`${t}_${NXt(10)}`),ox=Xe(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),GXt=Xe(["top_silkscreen","bottom_silkscreen","top_copper","bottom_copper","top_soldermask","bottom_soldermask","top_fabrication_note","bottom_fabrication_note","top_user_note","bottom_user_note","top_courtyard","bottom_courtyard","inner1_copper","inner2_copper","inner3_copper","inner4_copper","inner5_copper","inner6_copper","edge_cuts","drill"]),Cle=te({project_relative_path:U(),url:U(),mimetype:U()}),Xj=Bn.extend({rotation:cC.optional()}),ByA=te({size:Bn.optional(),thickness:Et.optional()}),Qle=te({font:ByA.optional()}),RT=te({value:U(),at:Xj.optional(),layer:U().optional(),uuid:U().optional(),hide:PA().optional(),effects:Qle.optional()}),hle=te({Reference:RT.optional(),Value:RT.optional(),Datasheet:RT.optional(),Description:RT.optional()}),Ele=te({through_hole:PA().optional(),smd:PA().optional(),exclude_from_pos_files:PA().optional(),exclude_from_bom:PA().optional()}),ule=te({name:U(),type:U(),shape:U().optional(),at:Xj.optional(),size:Bn.optional(),drill:Et.optional(),layers:Se(U()).optional(),removeUnusedLayers:PA().optional(),uuid:U().optional()}),dle=te({path:U(),offset:nx.optional(),scale:nx.optional(),rotate:nx.optional()}),ple=te({footprintName:U().optional(),version:Rt([WA(),U()]).optional(),generator:U().optional(),generatorVersion:Rt([WA(),U()]).optional(),layer:U().optional(),properties:hle.optional(),attributes:Ele.optional(),pads:Se(ule).optional(),embeddedFonts:PA().optional(),model:dle.optional()}),fle=te({hide:PA().optional()}),yle=te({offset:Et.optional(),hide:PA().optional()}),mle=te({font:ByA.optional(),justify:Rt([U(),Se(U())]).optional(),hide:PA().optional()}),Lk=te({value:U(),id:Rt([WA(),U()]).optional(),at:Xj.optional(),effects:mle.optional()}),wle=te({Reference:Lk.optional(),Value:Lk.optional(),Footprint:Lk.optional(),Datasheet:Lk.optional(),Description:Lk.optional(),ki_keywords:Lk.optional(),ki_fp_filters:Lk.optional()}),Dle=te({symbolName:U().optional(),extends:U().optional(),pinNumbers:fle.optional(),pinNames:yle.optional(),excludeFromSim:PA().optional(),inBom:PA().optional(),onBoard:PA().optional(),properties:wle.optional(),embeddedFonts:PA().optional()}),oc=te({error_type:U(),message:U(),is_fatal:PA().optional()}),Sle=Xe(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),_c=te({type:xA("source_component"),ftype:U().optional(),source_component_id:U(),name:U(),manufacturer_part_number:U().optional(),supplier_part_numbers:Sa(Sle,Se(U())).optional(),display_value:U().optional(),display_name:U().optional(),are_pins_interchangeable:PA().optional(),internally_connected_source_port_ids:Se(Se(U())).optional(),source_group_id:U().optional(),subcircuit_id:U().optional()}),CyA=_c.extend({ftype:xA("simple_capacitor"),capacitance:IyA,max_voltage_rating:ix.optional(),display_capacitance:U().optional(),max_decoupling_trace_length:Et.optional()}),QyA=_c.extend({ftype:xA("simple_resistor"),resistance:zj,display_resistance:U().optional()}),$j=_c.extend({ftype:xA("simple_diode")}),ble=_c.extend({ftype:xA("simple_fiducial")}),hyA=$j.extend({ftype:xA("simple_led"),color:U().optional(),wavelength:U().optional()}),xle=_c.extend({ftype:xA("simple_ground")}),EyA=_c.extend({ftype:xA("simple_chip")}),uyA=_c.extend({ftype:xA("simple_power_source"),voltage:ix}),_le=_c.extend({ftype:xA("simple_current_source"),current:E2,frequency:FM.optional(),peak_to_peak_current:E2.optional(),wave_shape:Xe(["sine","square","triangle","sawtooth","dc"]).optional().default("dc"),phase:WA().optional(),duty_cycle:WA().min(0).max(1).optional()}),kle=te({must_be_connected:PA().optional(),provides_power:PA().optional(),requires_power:PA().optional(),provides_ground:PA().optional(),requires_ground:PA().optional(),provides_voltage:Rt([U(),WA()]).optional(),requires_voltage:Rt([U(),WA()]).optional(),do_not_connect:PA().optional(),include_in_board_pinout:PA().optional(),can_use_internal_pullup:PA().optional(),is_using_internal_pullup:PA().optional(),needs_external_pullup:PA().optional(),can_use_internal_pulldown:PA().optional(),is_using_internal_pulldown:PA().optional(),needs_external_pulldown:PA().optional(),can_use_open_drain:PA().optional(),is_using_open_drain:PA().optional(),can_use_push_pull:PA().optional(),is_using_push_pull:PA().optional(),should_have_decoupling_capacitor:PA().optional(),recommended_decoupling_capacitor_capacitance:Rt([U(),WA()]).optional(),is_configured_for_i2c_sda:PA().optional(),is_configured_for_i2c_scl:PA().optional(),is_configured_for_spi_mosi:PA().optional(),is_configured_for_spi_miso:PA().optional(),is_configured_for_spi_sck:PA().optional(),is_configured_for_spi_cs:PA().optional(),is_configured_for_uart_tx:PA().optional(),is_configured_for_uart_rx:PA().optional(),supports_i2c_sda:PA().optional(),supports_i2c_scl:PA().optional(),supports_spi_mosi:PA().optional(),supports_spi_miso:PA().optional(),supports_spi_sck:PA().optional(),supports_spi_cs:PA().optional(),supports_uart_tx:PA().optional(),supports_uart_rx:PA().optional()}),LXt=_c.extend({ftype:xA("simple_fuse"),current_rating_amps:WA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:WA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),dyA=_c.extend({ftype:xA("simple_battery"),capacity:Ble}),pyA=_c.extend({ftype:xA("simple_inductor"),inductance:Ile,max_current_rating:WA().optional()}),fyA=_c.extend({ftype:xA("simple_push_button")}),yyA=_c.extend({ftype:xA("simple_potentiometer"),max_resistance:zj,display_max_resistance:U().optional()}),vle=_c.extend({ftype:xA("simple_crystal"),frequency:WA().describe("Frequency in Hz"),load_capacitance:WA().optional().describe("Load capacitance in pF"),pin_variant:Xe(["two_pin","four_pin"]).optional()}),myA=_c.extend({ftype:xA("simple_pin_header"),pin_count:WA(),gender:Xe(["male","female"]).optional().default("male")}),Fle=_c.extend({ftype:xA("simple_connector"),standard:Xe(["usb_c","m2"]).optional()}),wyA=_c.extend({ftype:xA("simple_pinout")}),DyA=_c.extend({ftype:xA("simple_resonator"),load_capacitance:IyA,equivalent_series_resistance:zj.optional(),frequency:FM}),SyA=_c.extend({ftype:xA("simple_transistor"),transistor_type:Xe(["npn","pnp"])}),byA=_c.extend({ftype:xA("simple_test_point"),footprint_variant:Xe(["pad","through_hole"]).optional(),pad_shape:Xe(["rect","circle"]).optional(),pad_diameter:Rt([WA(),U()]).optional(),hole_diameter:Rt([WA(),U()]).optional(),width:Rt([WA(),U()]).optional(),height:Rt([WA(),U()]).optional()}),xyA=_c.extend({ftype:xA("simple_mosfet"),channel_type:Xe(["n","p"]),mosfet_mode:Xe(["enhancement","depletion"])}),_yA=_c.extend({ftype:xA("simple_op_amp")}),kyA=_c.extend({ftype:xA("simple_switch")}),vyA=te({type:xA("source_project_metadata"),name:U().optional(),software_used_string:U().optional(),project_url:U().optional(),created_at:lle.optional()}),Mle=oc.extend({type:xA("source_missing_property_error"),source_missing_property_error_id:Wt("source_missing_property_error"),source_component_id:U(),property_name:U(),subcircuit_id:U().optional(),error_type:xA("source_missing_property_error").default("source_missing_property_error")}).describe("The source code is missing a property"),Rle=oc.extend({type:xA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Wt("source_failed_to_create_component_error"),error_type:xA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:U().optional(),subcircuit_id:U().optional(),parent_source_component_id:U().optional(),pcb_center:te({x:WA().optional(),y:WA().optional()}).optional(),schematic_center:te({x:WA().optional(),y:WA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),FyA=oc.extend({type:xA("source_invalid_component_property_error"),source_invalid_component_property_error_id:Wt("source_invalid_component_property_error"),source_component_id:U(),property_name:U(),property_value:bq().optional(),expected_format:U().optional(),subcircuit_id:U().optional(),error_type:xA("source_invalid_component_property_error").default("source_invalid_component_property_error")}).describe("The source component property is invalid"),MyA=oc.extend({type:xA("source_trace_not_connected_error"),source_trace_not_connected_error_id:Wt("source_trace_not_connected_error"),error_type:xA("source_trace_not_connected_error").default("source_trace_not_connected_error"),subcircuit_id:U().optional(),source_group_id:U().optional(),source_trace_id:U().optional(),connected_source_port_ids:Se(U()).optional(),selectors_not_found:Se(U()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Nle=te({type:xA("source_property_ignored_warning"),source_property_ignored_warning_id:Wt("source_property_ignored_warning"),source_component_id:U(),property_name:U(),subcircuit_id:U().optional(),error_type:xA("source_property_ignored_warning").default("source_property_ignored_warning"),message:U()}).describe("The source property was ignored"),RyA=te({type:xA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Wt("source_pin_missing_trace_warning"),warning_type:xA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:U(),source_component_id:U(),source_port_id:U(),subcircuit_id:U().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),Gle=_c.extend({ftype:xA("simple_voltage_probe")}),Lle=_c.extend({ftype:xA("interconnect")}),NyA=oc.extend({type:xA("source_i2c_misconfigured_error"),source_i2c_misconfigured_error_id:Wt("source_i2c_misconfigured_error"),error_type:xA("source_i2c_misconfigured_error").default("source_i2c_misconfigured_error"),source_port_ids:Se(U())}).describe("Error emitted when incompatible I2C pins (e.g. SDA and SCL) are connected to the same net"),Ule=_c.extend({ftype:xA("simple_voltage_source"),voltage:ix,frequency:FM.optional(),peak_to_peak_voltage:ix.optional(),wave_shape:Xe(["sinewave","square","triangle","sawtooth"]).optional(),phase:cC.optional(),duty_cycle:WA().optional().describe("Duty cycle as a fraction (0 to 1)")}),Hle=Rt([QyA,CyA,$j,ble,hyA,xle,EyA,uyA,_le,dyA,pyA,fyA,yyA,vle,myA,Fle,wyA,DyA,kyA,SyA,byA,xyA,_yA,LXt,Gle,Lle,Ule,vyA,Mle,FyA,Rle,MyA,Nle,RyA,NyA]),Yle=te({type:xA("source_port"),pin_number:WA().optional(),port_hints:Se(U()).optional(),name:U(),source_port_id:U(),source_component_id:U().optional(),source_group_id:U().optional(),most_frequently_referenced_by_name:U().optional(),subcircuit_id:U().optional(),subcircuit_connectivity_map_key:U().optional()}).merge(kle),Jle=te({type:xA("source_component_internal_connection"),source_component_internal_connection_id:U(),source_component_id:U(),source_port_ids:Se(U()),subcircuit_id:U().optional()}),Tle=te({type:xA("source_trace"),source_trace_id:U(),connected_source_port_ids:Se(U()),connected_source_net_ids:Se(U()),subcircuit_id:U().optional(),subcircuit_connectivity_map_key:U().optional(),max_length:WA().optional(),min_trace_thickness:WA().optional(),display_name:U().optional()}),Ple=te({type:xA("source_group"),source_group_id:U(),subcircuit_id:U().optional(),parent_subcircuit_id:U().optional(),parent_source_group_id:U().optional(),is_subcircuit:PA().optional(),show_as_schematic_box:PA().optional(),name:U().optional(),was_automatically_named:PA().optional()}),Kle=te({type:xA("source_net"),source_net_id:U(),name:U(),member_source_group_ids:Se(U()),is_power:PA().optional(),is_ground:PA().optional(),is_digital_signal:PA().optional(),is_analog_signal:PA().optional(),is_positive_voltage_source:PA().optional(),trace_width:WA().optional(),subcircuit_id:U().optional(),subcircuit_connectivity_map_key:U().optional()}),qle=te({type:xA("source_board"),source_board_id:U(),source_group_id:U(),title:U().optional()}).describe("Defines a board in the source domain"),Ole=oc.extend({type:xA("source_ambiguous_port_reference"),source_ambiguous_port_reference_id:Wt("source_ambiguous_port_reference"),error_type:xA("source_ambiguous_port_reference").default("source_ambiguous_port_reference"),source_port_id:U().optional(),source_component_id:U().optional()}).describe("Error emitted when a port hint matches multiple non-overlapping pads, making the port reference ambiguous"),Wle=te({type:xA("source_pcb_ground_plane"),source_pcb_ground_plane_id:U(),source_group_id:U(),source_net_id:U(),subcircuit_id:U().optional()}).describe("Defines a ground plane in the source domain"),Zle=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],GyA=Xe(Zle),Hr=GyA.or(te({name:GyA})).transform(t=>typeof t=="string"?t:t.name),Fm=Xe(["top","bottom"]),Vle=te({type:xA("source_manually_placed_via"),source_manually_placed_via_id:U(),source_group_id:U(),source_net_id:U(),subcircuit_id:U().optional(),source_trace_id:U().optional()}).describe("Defines a via that is manually placed in the source domain"),jle=te({type:xA("source_no_power_pin_defined_warning"),source_no_power_pin_defined_warning_id:Wt("source_no_power_pin_defined_warning"),warning_type:xA("source_no_power_pin_defined_warning").default("source_no_power_pin_defined_warning"),message:U(),source_component_id:U(),source_port_ids:Se(U()),subcircuit_id:U().optional()}).describe("Warning emitted when a chip has no source ports with requires_power=true"),zle=te({type:xA("source_no_ground_pin_defined_warning"),source_no_ground_pin_defined_warning_id:Wt("source_no_ground_pin_defined_warning"),warning_type:xA("source_no_ground_pin_defined_warning").default("source_no_ground_pin_defined_warning"),message:U(),source_component_id:U(),source_port_ids:Se(U()),subcircuit_id:U().optional()}).describe("Warning emitted when a chip has no source ports marked as ground pins"),Xle=te({type:xA("source_component_pins_underspecified_warning"),source_component_pins_underspecified_warning_id:Wt("source_component_pins_underspecified_warning"),warning_type:xA("source_component_pins_underspecified_warning").default("source_component_pins_underspecified_warning"),message:U(),source_component_id:U(),source_port_ids:Se(U()),subcircuit_id:U().optional()}).describe("Warning emitted when all ports on a source component are underspecified"),$le=oc.extend({type:xA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:Wt("source_pin_must_be_connected_error"),error_type:xA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),source_component_id:U(),source_port_id:U(),subcircuit_id:U().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),ABe=oc.extend({type:xA("unknown_error_finding_part"),unknown_error_finding_part_id:Wt("unknown_error_finding_part"),error_type:xA("unknown_error_finding_part").default("unknown_error_finding_part"),source_component_id:U().optional(),subcircuit_id:U().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),eBe=te({type:xA("schematic_box"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),width:Et,height:Et,is_dashed:PA().default(!1),x:Et,y:Et,subcircuit_id:U().optional()}).describe("Draws a box on the schematic"),tBe=te({type:xA("schematic_path"),schematic_path_id:Wt("schematic_path"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),fill_color:U().optional(),is_filled:PA().optional(),stroke_width:Et.nullable().optional(),stroke_color:U().optional(),points:Se(Bn),subcircuit_id:U().optional()}),iBe=Sa(te({left_margin:rn.optional(),right_margin:rn.optional(),top_margin:rn.optional(),bottom_margin:rn.optional()})),nBe=te({left_size:WA(),right_size:WA(),top_size:WA().optional(),bottom_size:WA().optional()}),oBe=te({left_side:te({pins:Se(WA()),direction:Xe(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:te({pins:Se(WA()),direction:Xe(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:te({pins:Se(WA()),direction:Xe(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:te({pins:Se(WA()),direction:Xe(["left-to-right","right-to-left"]).optional()}).optional()}),sBe=Rt([nBe,oBe]),rBe=te({type:xA("schematic_component"),size:lyA,center:Bn,source_component_id:U().optional(),schematic_component_id:U(),schematic_symbol_id:U().optional(),pin_spacing:rn.optional(),pin_styles:iBe.optional(),box_width:rn.optional(),symbol_name:U().optional(),port_arrangement:sBe.optional(),port_labels:Sa(U()).optional(),symbol_display_value:U().optional(),subcircuit_id:U().optional(),schematic_group_id:U().optional(),is_schematic_group:PA().optional(),source_group_id:U().optional(),is_box_with_pins:PA().optional().default(!0)}),UXt=te({kicad_symbol:Dle.optional()}).catchall(bq()),aBe=te({type:xA("schematic_symbol"),schematic_symbol_id:U(),name:U().optional(),metadata:UXt.optional()}).describe("Defines a named schematic symbol that can be referenced by components."),gBe=te({type:xA("schematic_line"),schematic_line_id:Wt("schematic_line"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),x1:Et,y1:Et,x2:Et,y2:Et,stroke_width:Et.nullable().optional(),color:U().default("#000000"),is_dashed:PA().default(!1),subcircuit_id:U().optional()}).describe("Draws a styled line on the schematic"),cBe=te({type:xA("schematic_rect"),schematic_rect_id:Wt("schematic_rect"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),center:Bn,width:Et,height:Et,rotation:cC.default(0),stroke_width:Et.nullable().optional(),color:U().default("#000000"),is_filled:PA().default(!1),fill_color:U().optional(),is_dashed:PA().default(!1),subcircuit_id:U().optional()}).describe("Draws a styled rectangle on the schematic"),IBe=te({type:xA("schematic_circle"),schematic_circle_id:Wt("schematic_circle"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),center:Bn,radius:Et,stroke_width:Et.nullable().optional(),color:U().default("#000000"),is_filled:PA().default(!1),fill_color:U().optional(),is_dashed:PA().default(!1),subcircuit_id:U().optional()}).describe("Draws a styled circle on the schematic"),lBe=te({type:xA("schematic_arc"),schematic_arc_id:Wt("schematic_arc"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),center:Bn,radius:Et,start_angle_degrees:cC,end_angle_degrees:cC,direction:Xe(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:Et.nullable().optional(),color:U().default("#000000"),is_dashed:PA().default(!1),subcircuit_id:U().optional()}).describe("Draws a styled arc on the schematic"),BBe=te({type:xA("schematic_trace"),schematic_trace_id:U(),source_trace_id:U().optional(),junctions:Se(te({x:WA(),y:WA()})),edges:Se(te({from:te({x:WA(),y:WA()}),to:te({x:WA(),y:WA()}),is_crossing:PA().optional(),from_schematic_port_id:U().optional(),to_schematic_port_id:U().optional()})),subcircuit_id:U().optional(),subcircuit_connectivity_map_key:U().optional()}),HXt=Xe(["center","left","right","top","bottom"]),CBe=te({type:xA("schematic_text"),schematic_component_id:U().optional(),schematic_symbol_id:U().optional(),schematic_text_id:U(),text:U(),font_size:WA().default(.18),position:te({x:Et,y:Et}),rotation:WA().default(0),anchor:Rt([HXt.describe("legacy"),ox]).default("center"),color:U().default("#000000"),subcircuit_id:U().optional()}),QBe=te({type:xA("schematic_port"),schematic_port_id:U(),source_port_id:U(),schematic_component_id:U().optional(),center:Bn,facing_direction:Xe(["up","down","left","right"]).optional(),distance_from_component_edge:WA().optional(),side_of_component:Xe(["top","bottom","left","right"]).optional(),true_ccw_index:WA().optional(),pin_number:WA().optional(),display_pin_label:U().optional(),subcircuit_id:U().optional(),is_connected:PA().optional(),has_input_arrow:PA().optional(),has_output_arrow:PA().optional(),is_drawn_with_inversion_circle:PA().optional()}).describe("Defines a port on a schematic component"),hBe=te({type:xA("schematic_net_label"),schematic_net_label_id:Wt("schematic_net_label"),schematic_trace_id:U().optional(),source_trace_id:U().optional(),source_net_id:U(),center:Bn,anchor_position:Bn.optional(),anchor_side:Xe(["top","bottom","left","right"]),text:U(),symbol_name:U().optional(),is_movable:PA().optional(),subcircuit_id:U().optional()}),EBe=oc.extend({type:xA("schematic_error"),schematic_error_id:U(),error_type:xA("schematic_port_not_found").default("schematic_port_not_found"),subcircuit_id:U().optional()}).describe("Defines a schematic error on the schematic"),uBe=oc.extend({type:xA("schematic_layout_error"),schematic_layout_error_id:Wt("schematic_layout_error"),error_type:xA("schematic_layout_error").default("schematic_layout_error"),source_group_id:U(),schematic_group_id:U(),subcircuit_id:U().optional()}).describe("Error emitted when schematic layout fails for a group"),Az=te({type:xA("schematic_debug_object"),label:U().optional(),subcircuit_id:U().optional()}),dBe=Az.extend({shape:xA("rect"),center:Bn,size:lyA}),pBe=Az.extend({shape:xA("line"),start:Bn,end:Bn}),fBe=Az.extend({shape:xA("point"),center:Bn}),yBe=Ef("shape",[dBe,pBe,fBe]),mBe=te({type:xA("schematic_voltage_probe"),schematic_voltage_probe_id:U(),source_component_id:U().optional(),name:U().optional(),position:Bn,schematic_trace_id:U(),voltage:ix.optional(),subcircuit_id:U().optional(),color:U().optional(),label_alignment:ox.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),wBe=te({type:xA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Wt("schematic_manual_edit_conflict_warning"),warning_type:xA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:U(),schematic_component_id:U(),schematic_group_id:U().optional(),subcircuit_id:U().optional(),source_component_id:U()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),DBe=te({type:xA("schematic_group"),schematic_group_id:Wt("schematic_group"),source_group_id:U(),is_subcircuit:PA().optional(),subcircuit_id:U().optional(),width:rn,height:rn,center:Bn,schematic_component_ids:Se(U()),show_as_schematic_box:PA().optional(),name:U().optional(),description:U().optional()}).describe("Defines a group of components on the schematic"),SBe=te({type:xA("schematic_table"),schematic_table_id:Wt("schematic_table"),anchor_position:Bn,column_widths:Se(Et),row_heights:Se(Et),cell_padding:Et.optional(),border_width:Et.optional(),subcircuit_id:U().optional(),schematic_component_id:U().optional(),anchor:ox.optional()}).describe("Defines a table on the schematic"),bBe=te({type:xA("schematic_table_cell"),schematic_table_cell_id:Wt("schematic_table_cell"),schematic_table_id:U(),start_row_index:WA(),end_row_index:WA(),start_column_index:WA(),end_column_index:WA(),text:U().optional(),center:Bn,width:Et,height:Et,horizontal_align:Xe(["left","center","right"]).optional(),vertical_align:Xe(["top","middle","bottom"]).optional(),font_size:Et.optional(),subcircuit_id:U().optional()}).describe("Defines a cell within a schematic_table"),xBe=te({type:xA("schematic_sheet"),schematic_sheet_id:Wt("schematic_sheet"),name:U().optional(),subcircuit_id:U().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),_Be=te({x:Et,y:Et,bulge:WA().optional()}),LyA=te({vertices:Se(_Be)}),kBe=te({outer_ring:LyA,inner_rings:Se(LyA).default([])}),vBe=te({x:Et,y:Et,via:PA().optional(),via_to_layer:Hr.optional()}),YXt=Se(vBe),FBe=te({x:Et,y:Et,via:PA().optional(),to_layer:Hr.optional(),trace_width:Et.optional()}),MBe=te({type:xA("pcb_component"),pcb_component_id:Wt("pcb_component"),source_component_id:U(),center:Bn,layer:Hr,rotation:cC,display_offset_x:U().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:U().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:rn,height:rn,do_not_place:PA().optional(),is_allowed_to_be_off_board:PA().optional(),subcircuit_id:U().optional(),pcb_group_id:U().optional(),position_mode:Xe(["packed","relative_to_group_anchor","relative_to_another_component","none"]).optional(),anchor_position:Bn.optional(),anchor_alignment:ox.optional(),positioned_relative_to_pcb_group_id:U().optional(),positioned_relative_to_pcb_board_id:U().optional(),cable_insertion_center:Bn.optional(),metadata:te({kicad_footprint:ple.optional()}).optional(),obstructs_within_bounds:PA().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),RBe=te({type:xA("pcb_hole"),pcb_hole_id:Wt("pcb_hole"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_component_id:U().optional(),hole_shape:xA("circle"),hole_diameter:WA(),x:Et,y:Et,is_covered_with_solder_mask:PA().optional(),soldermask_margin:WA().optional()}),JXt=RBe.describe("Defines a circular hole on the PCB"),NBe=te({type:xA("pcb_hole"),pcb_hole_id:Wt("pcb_hole"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_component_id:U().optional(),hole_shape:xA("rect"),hole_width:WA(),hole_height:WA(),x:Et,y:Et,is_covered_with_solder_mask:PA().optional(),soldermask_margin:WA().optional()}),TXt=NBe.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square."),GBe=te({type:xA("pcb_hole"),pcb_hole_id:Wt("pcb_hole"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_component_id:U().optional(),hole_shape:Xe(["circle","square"]),hole_diameter:WA(),x:Et,y:Et,is_covered_with_solder_mask:PA().optional(),soldermask_margin:WA().optional()}),PXt=GBe.describe("Defines a circular or square hole on the PCB"),LBe=te({type:xA("pcb_hole"),pcb_hole_id:Wt("pcb_hole"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_component_id:U().optional(),hole_shape:xA("oval"),hole_width:WA(),hole_height:WA(),x:Et,y:Et,is_covered_with_solder_mask:PA().optional(),soldermask_margin:WA().optional()}),KXt=LBe.describe("Defines an oval hole on the PCB"),UBe=te({type:xA("pcb_hole"),pcb_hole_id:Wt("pcb_hole"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_component_id:U().optional(),hole_shape:xA("pill"),hole_width:WA(),hole_height:WA(),x:Et,y:Et,is_covered_with_solder_mask:PA().optional(),soldermask_margin:WA().optional()}),qXt=UBe.describe("Defines a pill-shaped hole on the PCB"),HBe=te({type:xA("pcb_hole"),pcb_hole_id:Wt("pcb_hole"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_component_id:U().optional(),hole_shape:xA("rotated_pill"),hole_width:WA(),hole_height:WA(),x:Et,y:Et,ccw_rotation:cC,is_covered_with_solder_mask:PA().optional(),soldermask_margin:WA().optional()}),OXt=HBe.describe("Defines a rotated pill-shaped hole on the PCB"),YBe=GBe.or(LBe).or(UBe).or(HBe).or(RBe).or(NBe),WXt=te({type:xA("pcb_plated_hole"),shape:xA("circle"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),outer_diameter:WA(),hole_diameter:WA(),is_covered_with_solder_mask:PA().optional(),x:Et,y:Et,layers:Se(Hr),port_hints:Se(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),pcb_plated_hole_id:Wt("pcb_plated_hole"),soldermask_margin:WA().optional()}),ZXt=te({type:xA("pcb_plated_hole"),shape:Xe(["oval","pill"]),pcb_group_id:U().optional(),subcircuit_id:U().optional(),outer_width:WA(),outer_height:WA(),hole_width:WA(),hole_height:WA(),is_covered_with_solder_mask:PA().optional(),x:Et,y:Et,ccw_rotation:cC,layers:Se(Hr),port_hints:Se(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),pcb_plated_hole_id:Wt("pcb_plated_hole"),soldermask_margin:WA().optional()}),VXt=te({type:xA("pcb_plated_hole"),shape:xA("circular_hole_with_rect_pad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),hole_shape:xA("circle"),pad_shape:xA("rect"),hole_diameter:WA(),rect_pad_width:WA(),rect_pad_height:WA(),rect_border_radius:WA().optional(),hole_offset_x:Et.default(0),hole_offset_y:Et.default(0),is_covered_with_solder_mask:PA().optional(),x:Et,y:Et,layers:Se(Hr),port_hints:Se(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),pcb_plated_hole_id:Wt("pcb_plated_hole"),soldermask_margin:WA().optional(),rect_ccw_rotation:cC.optional()}),jXt=te({type:xA("pcb_plated_hole"),shape:xA("pill_hole_with_rect_pad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),hole_shape:xA("pill"),pad_shape:xA("rect"),hole_width:WA(),hole_height:WA(),rect_pad_width:WA(),rect_pad_height:WA(),rect_border_radius:WA().optional(),hole_offset_x:Et.default(0),hole_offset_y:Et.default(0),is_covered_with_solder_mask:PA().optional(),x:Et,y:Et,layers:Se(Hr),port_hints:Se(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),pcb_plated_hole_id:Wt("pcb_plated_hole"),soldermask_margin:WA().optional()}),zXt=te({type:xA("pcb_plated_hole"),shape:xA("rotated_pill_hole_with_rect_pad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),hole_shape:xA("rotated_pill"),pad_shape:xA("rect"),hole_width:WA(),hole_height:WA(),hole_ccw_rotation:cC,rect_pad_width:WA(),rect_pad_height:WA(),rect_border_radius:WA().optional(),rect_ccw_rotation:cC,hole_offset_x:Et.default(0),hole_offset_y:Et.default(0),is_covered_with_solder_mask:PA().optional(),x:Et,y:Et,layers:Se(Hr),port_hints:Se(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),pcb_plated_hole_id:Wt("pcb_plated_hole"),soldermask_margin:WA().optional()}),XXt=te({type:xA("pcb_plated_hole"),shape:xA("hole_with_polygon_pad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),hole_shape:Xe(["circle","oval","pill","rotated_pill"]),hole_diameter:WA().optional(),hole_width:WA().optional(),hole_height:WA().optional(),pad_outline:Se(te({x:Et,y:Et})).min(3),hole_offset_x:Et.default(0),hole_offset_y:Et.default(0),is_covered_with_solder_mask:PA().optional(),x:Et,y:Et,layers:Se(Hr),port_hints:Se(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),pcb_plated_hole_id:Wt("pcb_plated_hole"),soldermask_margin:WA().optional(),ccw_rotation:cC.optional()}),JBe=Rt([WXt,ZXt,VXt,jXt,zXt,XXt]),TBe=te({type:xA("pcb_port"),pcb_port_id:Wt("pcb_port"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),source_port_id:U(),pcb_component_id:U().optional(),x:Et,y:Et,layers:Se(Hr),is_board_pinout:PA().optional()}).describe("Defines a port on the PCB"),$Xt=te({type:xA("pcb_smtpad"),shape:xA("circle"),pcb_smtpad_id:Wt("pcb_smtpad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Et,y:Et,radius:WA(),layer:Hr,port_hints:Se(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),is_covered_with_solder_mask:PA().optional(),soldermask_margin:WA().optional()}),A6t=te({type:xA("pcb_smtpad"),shape:xA("rect"),pcb_smtpad_id:Wt("pcb_smtpad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Et,y:Et,width:WA(),height:WA(),rect_border_radius:WA().optional(),corner_radius:WA().optional(),layer:Hr,port_hints:Se(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),is_covered_with_solder_mask:PA().optional(),soldermask_margin:WA().optional(),soldermask_margin_left:WA().optional(),soldermask_margin_top:WA().optional(),soldermask_margin_right:WA().optional(),soldermask_margin_bottom:WA().optional()}),e6t=te({type:xA("pcb_smtpad"),shape:xA("rotated_rect"),pcb_smtpad_id:Wt("pcb_smtpad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Et,y:Et,width:WA(),height:WA(),rect_border_radius:WA().optional(),corner_radius:WA().optional(),ccw_rotation:cC,layer:Hr,port_hints:Se(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),is_covered_with_solder_mask:PA().optional(),soldermask_margin:WA().optional(),soldermask_margin_left:WA().optional(),soldermask_margin_top:WA().optional(),soldermask_margin_right:WA().optional(),soldermask_margin_bottom:WA().optional()}),PBe=te({type:xA("pcb_smtpad"),shape:xA("pill"),pcb_smtpad_id:Wt("pcb_smtpad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Et,y:Et,width:WA(),height:WA(),radius:WA(),layer:Hr,port_hints:Se(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),is_covered_with_solder_mask:PA().optional(),soldermask_margin:WA().optional()}),t6t=te({type:xA("pcb_smtpad"),shape:xA("rotated_pill"),pcb_smtpad_id:Wt("pcb_smtpad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Et,y:Et,width:WA(),height:WA(),radius:WA(),ccw_rotation:cC,layer:Hr,port_hints:Se(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),is_covered_with_solder_mask:PA().optional(),soldermask_margin:WA().optional()}),i6t=te({type:xA("pcb_smtpad"),shape:xA("polygon"),pcb_smtpad_id:Wt("pcb_smtpad"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),points:Se(Bn),layer:Hr,port_hints:Se(U()).optional(),pcb_component_id:U().optional(),pcb_port_id:U().optional(),is_covered_with_solder_mask:PA().optional(),soldermask_margin:WA().optional()}),KBe=Ef("shape",[$Xt,A6t,e6t,t6t,PBe,i6t]).describe("Defines an SMT pad on the PCB"),n6t=te({type:xA("pcb_solder_paste"),shape:xA("circle"),pcb_solder_paste_id:Wt("pcb_solder_paste"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Et,y:Et,radius:WA(),layer:Hr,pcb_component_id:U().optional(),pcb_smtpad_id:U().optional()}),o6t=te({type:xA("pcb_solder_paste"),shape:xA("rect"),pcb_solder_paste_id:Wt("pcb_solder_paste"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Et,y:Et,width:WA(),height:WA(),layer:Hr,pcb_component_id:U().optional(),pcb_smtpad_id:U().optional()}),s6t=te({type:xA("pcb_solder_paste"),shape:xA("pill"),pcb_solder_paste_id:Wt("pcb_solder_paste"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Et,y:Et,width:WA(),height:WA(),radius:WA(),layer:Hr,pcb_component_id:U().optional(),pcb_smtpad_id:U().optional()}),r6t=te({type:xA("pcb_solder_paste"),shape:xA("rotated_rect"),pcb_solder_paste_id:Wt("pcb_solder_paste"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Et,y:Et,width:WA(),height:WA(),ccw_rotation:Et,layer:Hr,pcb_component_id:U().optional(),pcb_smtpad_id:U().optional()}),a6t=te({type:xA("pcb_solder_paste"),shape:xA("oval"),pcb_solder_paste_id:Wt("pcb_solder_paste"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),x:Et,y:Et,width:WA(),height:WA(),layer:Hr,pcb_component_id:U().optional(),pcb_smtpad_id:U().optional()}),qBe=Rt([n6t,o6t,s6t,r6t,a6t]).describe("Defines solderpaste on the PCB"),OBe=te({type:xA("pcb_text"),pcb_text_id:Wt("pcb_text"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),text:U(),center:Bn,layer:Hr,width:rn,height:rn,lines:WA(),align:Xe(["bottom-left"])}).describe("Defines text on the PCB"),WBe=te({route_type:xA("wire"),x:Et,y:Et,width:Et,copper_pour_id:U().optional(),is_inside_copper_pour:PA().optional(),start_pcb_port_id:U().optional(),end_pcb_port_id:U().optional(),layer:Hr}),ZBe=te({route_type:xA("via"),x:Et,y:Et,copper_pour_id:U().optional(),is_inside_copper_pour:PA().optional(),hole_diameter:Et.optional(),outer_diameter:Et.optional(),from_layer:U(),to_layer:U()}),VBe=Rt([WBe,ZBe]),jBe=te({type:xA("pcb_trace"),source_trace_id:U().optional(),pcb_component_id:U().optional(),pcb_trace_id:Wt("pcb_trace"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),route_thickness_mode:Xe(["constant","interpolated"]).default("constant").optional(),route_order_index:WA().optional(),should_round_corners:PA().optional(),trace_length:WA().optional(),highlight_color:U().optional(),route:Se(VBe)}).describe("Defines a trace on the PCB"),zBe=oc.extend({type:xA("pcb_trace_error"),pcb_trace_error_id:Wt("pcb_trace_error"),error_type:xA("pcb_trace_error").default("pcb_trace_error"),center:Bn.optional(),pcb_trace_id:U(),source_trace_id:U(),pcb_component_ids:Se(U()),pcb_port_ids:Se(U()),subcircuit_id:U().optional()}).describe("Defines a trace error on the PCB"),XBe=oc.extend({type:xA("pcb_trace_missing_error"),pcb_trace_missing_error_id:Wt("pcb_trace_missing_error"),error_type:xA("pcb_trace_missing_error").default("pcb_trace_missing_error"),center:Bn.optional(),source_trace_id:U(),pcb_component_ids:Se(U()),pcb_port_ids:Se(U()),subcircuit_id:U().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),$Be=oc.extend({type:xA("pcb_port_not_matched_error"),pcb_error_id:Wt("pcb_error"),error_type:xA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),pcb_component_ids:Se(U()),subcircuit_id:U().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),ACe=oc.extend({type:xA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Wt("pcb_port_not_connected_error"),error_type:xA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),pcb_port_ids:Se(U()),pcb_component_ids:Se(U()),subcircuit_id:U().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),eCe=te({type:xA("pcb_net"),pcb_net_id:Wt("pcb_net"),source_net_id:U().optional(),highlight_color:U().optional()}).describe("Defines a net on the PCB"),tCe=te({type:xA("pcb_via"),pcb_via_id:Wt("pcb_via"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),subcircuit_connectivity_map_key:U().optional(),x:Et,y:Et,outer_diameter:Et.default("0.6mm"),hole_diameter:Et.default("0.25mm"),from_layer:Hr.optional(),to_layer:Hr.optional(),layers:Se(Hr),pcb_trace_id:U().optional(),net_is_assignable:PA().optional(),net_assigned:PA().optional(),is_tented:PA().optional()}).describe("Defines a via on the PCB"),iCe=te({type:xA("pcb_board"),pcb_board_id:Wt("pcb_board"),pcb_panel_id:U().optional(),carrier_pcb_board_id:U().optional(),is_subcircuit:PA().optional(),subcircuit_id:U().optional(),is_mounted_to_carrier_board:PA().optional(),width:rn.optional(),height:rn.optional(),center:Bn,display_offset_x:U().optional().describe("How to display the x offset for this board, usually corresponding with how the user specified it"),display_offset_y:U().optional().describe("How to display the y offset for this board, usually corresponding with how the user specified it"),thickness:rn.optional().default(1.4),num_layers:WA().optional().default(4),outline:Se(Bn).optional(),shape:Xe(["rect","polygon"]).optional(),material:Xe(["fr4","fr1"]).default("fr4"),anchor_position:Bn.optional(),anchor_alignment:ox.optional(),position_mode:Xe(["relative_to_panel_anchor","none"]).optional()}).describe("Defines the board outline of the PCB"),nCe=te({type:xA("pcb_panel"),pcb_panel_id:Wt("pcb_panel"),width:rn,height:rn,center:Bn,covered_with_solder_mask:PA().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),oCe=oc.extend({type:xA("pcb_placement_error"),pcb_placement_error_id:Wt("pcb_placement_error"),error_type:xA("pcb_placement_error").default("pcb_placement_error"),subcircuit_id:U().optional()}).describe("Defines a placement error on the PCB"),sCe=oc.extend({type:xA("pcb_panelization_placement_error"),pcb_panelization_placement_error_id:Wt("pcb_panelization_placement_error"),error_type:xA("pcb_panelization_placement_error").default("pcb_panelization_placement_error"),pcb_panel_id:U().optional(),pcb_board_id:U().optional(),subcircuit_id:U().optional()}).describe("Defines a panelization placement error on the PCB"),rCe=te({type:xA("pcb_trace_hint"),pcb_trace_hint_id:Wt("pcb_trace_hint"),pcb_port_id:U(),pcb_component_id:U(),route:Se(FBe),subcircuit_id:U().optional()}).describe("A hint that can be used during generation of a PCB trace"),aCe=te({type:xA("pcb_silkscreen_line"),pcb_silkscreen_line_id:Wt("pcb_silkscreen_line"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),stroke_width:Et.default("0.1mm"),x1:Et,y1:Et,x2:Et,y2:Et,layer:Fm}).describe("Defines a silkscreen line on the PCB"),gCe=te({type:xA("pcb_silkscreen_path"),pcb_silkscreen_path_id:Wt("pcb_silkscreen_path"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),layer:Fm,route:Se(Bn),stroke_width:rn}).describe("Defines a silkscreen path on the PCB"),cCe=te({type:xA("pcb_silkscreen_text"),pcb_silkscreen_text_id:Wt("pcb_silkscreen_text"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),font:xA("tscircuit2024").default("tscircuit2024"),font_size:Et.default("0.2mm"),pcb_component_id:U(),text:U(),is_knockout:PA().default(!1).optional(),knockout_padding:te({left:rn,top:rn,bottom:rn,right:rn}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:WA().optional(),layer:Hr,is_mirrored:PA().default(!1).optional(),anchor_position:Bn.default({x:0,y:0}),anchor_alignment:ox.default("center")}).describe("Defines silkscreen text on the PCB"),ICe=te({type:xA("pcb_copper_text"),pcb_copper_text_id:Wt("pcb_copper_text"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),font:xA("tscircuit2024").default("tscircuit2024"),font_size:Et.default("0.2mm"),pcb_component_id:U(),text:U(),is_knockout:PA().default(!1).optional(),knockout_padding:te({left:rn,top:rn,bottom:rn,right:rn}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:WA().optional(),layer:Hr,is_mirrored:PA().default(!1).optional(),anchor_position:Bn.default({x:0,y:0}),anchor_alignment:ox.default("center")}).describe("Defines copper text on the PCB"),lCe=te({type:xA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Wt("pcb_silkscreen_rect"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:Bn,width:rn,height:rn,layer:Hr,stroke_width:rn.default("1mm"),corner_radius:rn.optional(),is_filled:PA().default(!0).optional(),has_stroke:PA().optional(),is_stroke_dashed:PA().optional(),ccw_rotation:WA().optional()}).describe("Defines a silkscreen rect on the PCB"),BCe=te({type:xA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Wt("pcb_silkscreen_circle"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:Bn,radius:rn,layer:Fm,stroke_width:rn.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),CCe=te({type:xA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Wt("pcb_silkscreen_oval"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:Bn,radius_x:Et,radius_y:Et,layer:Fm,ccw_rotation:cC.optional()}).describe("Defines a silkscreen oval on the PCB"),QCe=te({type:xA("pcb_silkscreen_pill"),pcb_silkscreen_pill_id:Wt("pcb_silkscreen_pill"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:Bn,width:rn,height:rn,layer:Hr,ccw_rotation:WA().optional()}).describe("Defines a silkscreen pill on the PCB"),hCe=te({type:xA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Wt("pcb_fabrication_note_text"),subcircuit_id:U().optional(),pcb_group_id:U().optional(),font:xA("tscircuit2024").default("tscircuit2024"),font_size:Et.default("1mm"),pcb_component_id:U(),text:U(),layer:Fm,anchor_position:Bn.default({x:0,y:0}),anchor_alignment:Xe(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:U().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),ECe=te({type:xA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Wt("pcb_fabrication_note_path"),pcb_component_id:U(),subcircuit_id:U().optional(),layer:Hr,route:Se(Bn),stroke_width:rn,color:U().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),uCe=te({type:xA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Wt("pcb_fabrication_note_rect"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:Bn,width:rn,height:rn,layer:Fm,stroke_width:rn.default("0.1mm"),corner_radius:rn.optional(),is_filled:PA().optional(),has_stroke:PA().optional(),is_stroke_dashed:PA().optional(),color:U().optional()}).describe("Defines a fabrication note rectangle on the PCB"),dCe=te({type:xA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Wt("pcb_fabrication_note_dimension"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),layer:Fm,from:Bn,to:Bn,text:U().optional(),text_ccw_rotation:WA().optional(),offset:rn.optional(),offset_distance:rn.optional(),offset_direction:te({x:WA(),y:WA()}).optional(),font:xA("tscircuit2024").default("tscircuit2024"),font_size:rn.default("1mm"),color:U().optional(),arrow_size:rn.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),pCe=te({type:xA("pcb_note_text"),pcb_note_text_id:Wt("pcb_note_text"),pcb_component_id:U().optional(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),name:U().optional(),font:xA("tscircuit2024").default("tscircuit2024"),font_size:Et.default("1mm"),text:U().optional(),anchor_position:Bn.default({x:0,y:0}),anchor_alignment:Xe(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:U().optional()}).describe("Defines a documentation note in text on the PCB"),fCe=te({type:xA("pcb_note_rect"),pcb_note_rect_id:Wt("pcb_note_rect"),pcb_component_id:U().optional(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),name:U().optional(),text:U().optional(),center:Bn,width:rn,height:rn,stroke_width:rn.default("0.1mm"),corner_radius:rn.optional(),is_filled:PA().optional(),has_stroke:PA().optional(),is_stroke_dashed:PA().optional(),color:U().optional()}).describe("Defines a rectangular documentation note on the PCB"),yCe=te({type:xA("pcb_note_path"),pcb_note_path_id:Wt("pcb_note_path"),pcb_component_id:U().optional(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),name:U().optional(),text:U().optional(),route:Se(Bn),stroke_width:rn.default("0.1mm"),color:U().optional()}).describe("Defines a polyline documentation note on the PCB"),mCe=te({type:xA("pcb_note_line"),pcb_note_line_id:Wt("pcb_note_line"),pcb_component_id:U().optional(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),name:U().optional(),text:U().optional(),x1:Et,y1:Et,x2:Et,y2:Et,stroke_width:Et.default("0.1mm"),color:U().optional(),is_dashed:PA().optional()}).describe("Defines a straight documentation note line on the PCB"),wCe=te({type:xA("pcb_note_dimension"),pcb_note_dimension_id:Wt("pcb_note_dimension"),pcb_component_id:U().optional(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),name:U().optional(),from:Bn,to:Bn,text:U().optional(),text_ccw_rotation:WA().optional(),offset_distance:rn.optional(),offset_direction:te({x:WA(),y:WA()}).optional(),font:xA("tscircuit2024").default("tscircuit2024"),font_size:rn.default("1mm"),color:U().optional(),arrow_size:rn.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),DCe=oc.extend({type:xA("pcb_footprint_overlap_error"),pcb_error_id:Wt("pcb_error"),error_type:xA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),pcb_smtpad_ids:Se(U()).optional(),pcb_plated_hole_ids:Se(U()).optional(),pcb_hole_ids:Se(U()).optional(),pcb_keepout_ids:Se(U()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),SCe=oc.extend({type:xA("pcb_courtyard_overlap_error"),pcb_error_id:Wt("pcb_error"),error_type:xA("pcb_courtyard_overlap_error").default("pcb_courtyard_overlap_error"),pcb_component_ids:Kve([U(),U()])}).describe("Error emitted when the courtyard (CrtYd) of one PCB component overlaps with the courtyard of another"),bCe=te({type:xA("pcb_keepout"),shape:xA("rect"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:Bn,width:Et,height:Et,pcb_keepout_id:U(),layers:Se(U()),description:U().optional()}).or(te({type:xA("pcb_keepout"),shape:xA("circle"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:Bn,radius:Et,pcb_keepout_id:U(),layers:Se(U()),description:U().optional()})),ez=te({type:xA("pcb_cutout"),pcb_cutout_id:Wt("pcb_cutout"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),pcb_board_id:U().optional(),pcb_panel_id:U().optional()}),xCe=ez.extend({shape:xA("rect"),center:Bn,width:rn,height:rn,rotation:cC.optional(),corner_radius:rn.optional()}),_Ce=ez.extend({shape:xA("circle"),center:Bn,radius:rn}),kCe=ez.extend({shape:xA("polygon"),points:Se(Bn)}),vCe=ez.extend({shape:xA("path"),route:Se(Bn),slot_width:rn,slot_length:rn.optional(),space_between_slots:rn.optional(),slot_corner_radius:rn.optional()}),FCe=Ef("shape",[xCe,_Ce,kCe,vCe]).describe("Defines a cutout on the PCB, removing board material."),MCe=oc.extend({type:xA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Wt("pcb_missing_footprint_error"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),error_type:xA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:U()}).describe("Defines a missing footprint error on the PCB"),RCe=oc.extend({type:xA("external_footprint_load_error"),external_footprint_load_error_id:Wt("external_footprint_load_error"),pcb_component_id:U(),source_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),footprinter_string:U().optional(),error_type:xA("external_footprint_load_error").default("external_footprint_load_error")}).describe("Defines an error when an external footprint fails to load"),NCe=oc.extend({type:xA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Wt("circuit_json_footprint_load_error"),pcb_component_id:U(),source_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),error_type:xA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),circuit_json:Se(AI()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),GCe=te({type:xA("pcb_group"),pcb_group_id:Wt("pcb_group"),source_group_id:U(),is_subcircuit:PA().optional(),subcircuit_id:U().optional(),width:rn.optional(),height:rn.optional(),center:Bn,display_offset_x:U().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:U().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:Se(Bn).optional(),anchor_position:Bn.optional(),anchor_alignment:ox.default("center"),position_mode:Xe(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:U().optional(),positioned_relative_to_pcb_board_id:U().optional(),pcb_component_ids:Se(U()),child_layout_mode:Xe(["packed","none"]).optional(),name:U().optional(),description:U().optional(),layout_mode:U().optional(),autorouter_configuration:te({trace_clearance:rn}).optional(),autorouter_used_string:U().optional()}).describe("Defines a group of components on the PCB"),LCe=oc.extend({type:xA("pcb_autorouting_error"),pcb_error_id:Wt("pcb_autorouting_error"),error_type:xA("pcb_autorouting_error").default("pcb_autorouting_error"),subcircuit_id:U().optional()}).describe("The autorouting has failed to route a portion of the board"),UCe=te({type:xA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Wt("pcb_manual_edit_conflict_warning"),warning_type:xA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:U(),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),source_component_id:U()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),HCe=Xe(["x-","x+","y+","y-"]),YCe=te({type:xA("pcb_connector_not_in_accessible_orientation_warning"),pcb_connector_not_in_accessible_orientation_warning_id:Wt("pcb_connector_not_in_accessible_orientation_warning"),warning_type:xA("pcb_connector_not_in_accessible_orientation_warning").default("pcb_connector_not_in_accessible_orientation_warning"),message:U(),pcb_component_id:U(),source_component_id:U().optional(),pcb_board_id:U().optional(),facing_direction:HCe,recommended_facing_direction:HCe,subcircuit_id:U().optional()}).describe("Warning emitted when a connector PCB component is facing inward toward the board and should be reoriented to an outward-facing direction"),JCe=te({type:xA("pcb_breakout_point"),pcb_breakout_point_id:Wt("pcb_breakout_point"),pcb_group_id:U(),subcircuit_id:U().optional(),source_trace_id:U().optional(),source_port_id:U().optional(),source_net_id:U().optional(),x:Et,y:Et}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),TCe=te({type:xA("pcb_ground_plane"),pcb_ground_plane_id:Wt("pcb_ground_plane"),source_pcb_ground_plane_id:U(),source_net_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional()}).describe("Defines a ground plane on the PCB"),PCe=te({type:xA("pcb_ground_plane_region"),pcb_ground_plane_region_id:Wt("pcb_ground_plane_region"),pcb_ground_plane_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),layer:Hr,points:Se(Bn)}).describe("Defines a polygon region of a ground plane"),KCe=te({type:xA("pcb_thermal_spoke"),pcb_thermal_spoke_id:Wt("pcb_thermal_spoke"),pcb_ground_plane_id:U(),shape:U(),spoke_count:WA(),spoke_thickness:Et,spoke_inner_diameter:Et,spoke_outer_diameter:Et,pcb_plated_hole_id:U().optional(),subcircuit_id:U().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),UyA=te({type:xA("pcb_copper_pour"),pcb_copper_pour_id:Wt("pcb_copper_pour"),pcb_group_id:U().optional(),subcircuit_id:U().optional(),layer:Hr,source_net_id:U().optional(),covered_with_solder_mask:PA().optional().default(!0)}),qCe=UyA.extend({shape:xA("rect"),center:Bn,width:rn,height:rn,rotation:cC.optional()}),OCe=UyA.extend({shape:xA("brep"),brep_shape:kBe}),WCe=UyA.extend({shape:xA("polygon"),points:Se(Bn)}),ZCe=Ef("shape",[qCe,OCe,WCe]).describe("Defines a copper pour on the PCB."),VCe=oc.extend({type:xA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Wt("pcb_component_outside_board_error"),error_type:xA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),pcb_component_id:U(),pcb_board_id:U(),component_center:Bn,component_bounds:te({min_x:WA(),max_x:WA(),min_y:WA(),max_y:WA()}),subcircuit_id:U().optional(),source_component_id:U().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),jCe=oc.extend({type:xA("pcb_component_not_on_board_edge_error"),pcb_component_not_on_board_edge_error_id:Wt("pcb_component_not_on_board_edge_error"),error_type:xA("pcb_component_not_on_board_edge_error").default("pcb_component_not_on_board_edge_error"),pcb_component_id:U(),pcb_board_id:U(),component_center:Bn,pad_to_nearest_board_edge_distance:WA(),source_component_id:U().optional(),subcircuit_id:U().optional()}).describe("Error emitted when a component that must be placed on the board edge is centered away from the edge"),zCe=oc.extend({type:xA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Wt("pcb_component_invalid_layer_error"),error_type:xA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),pcb_component_id:U().optional(),source_component_id:U(),layer:Hr,subcircuit_id:U().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),XCe=oc.extend({type:xA("pcb_via_clearance_error"),pcb_error_id:Wt("pcb_error"),error_type:xA("pcb_via_clearance_error").default("pcb_via_clearance_error"),pcb_via_ids:Se(U()).min(2),minimum_clearance:Et.optional(),actual_clearance:Et.optional(),pcb_center:te({x:WA().optional(),y:WA().optional()}).optional(),subcircuit_id:U().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),$Ce=te({type:xA("pcb_courtyard_rect"),pcb_courtyard_rect_id:Wt("pcb_courtyard_rect"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:Bn,width:rn,height:rn,layer:Fm,ccw_rotation:cC.optional(),color:U().optional()}).describe("Defines a courtyard rectangle on the PCB"),AQe=te({type:xA("pcb_courtyard_outline"),pcb_courtyard_outline_id:Wt("pcb_courtyard_outline"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),layer:Fm,outline:Se(Bn).min(2)}).describe("Defines a courtyard outline on the PCB"),eQe=te({type:xA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Wt("pcb_courtyard_polygon"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),layer:Fm,points:Se(Bn).min(3),color:U().optional()}).describe("Defines a courtyard polygon on the PCB"),tQe=te({type:xA("pcb_courtyard_circle"),pcb_courtyard_circle_id:Wt("pcb_courtyard_circle"),pcb_component_id:U(),pcb_group_id:U().optional(),subcircuit_id:U().optional(),center:Bn,radius:rn,layer:Fm,color:U().optional()}).describe("Defines a courtyard circle on the PCB"),g6t=["obj","stl","3mf","gltf","glb","step","wrl"],iQe=["x+","x-","y+","y-","z+","z-"],c6t={obj:"z+",stl:"z+","3mf":"z+",gltf:"y+",glb:"y+",step:"z+",wrl:"y+"},nQe=te({type:xA("cad_component"),cad_component_id:U(),pcb_component_id:U(),source_component_id:U(),position:nx,rotation:nx.optional(),size:nx.optional(),layer:Hr.optional(),subcircuit_id:U().optional(),footprinter_string:U().optional(),model_obj_url:U().optional(),model_stl_url:U().optional(),model_3mf_url:U().optional(),model_gltf_url:U().optional(),model_glb_url:U().optional(),model_step_url:U().optional(),model_wrl_url:U().optional(),model_asset:Cle.optional(),model_unit_to_mm_scale_factor:WA().optional(),model_board_normal_direction:Xe(iQe).optional().describe(`The direction in the model's coordinate space that is considered "up" or "coming out of the board surface"`),model_origin_position:nx.optional(),model_origin_alignment:Xe(["unknown","center","center_of_component_on_board_surface","bottom_center_of_component"]).optional(),model_object_fit:Xe(["contain_within_bounds","fill_bounds"]).optional().default("contain_within_bounds"),model_jscad:AI().optional(),show_as_translucent_model:PA().optional(),anchor_alignment:Xe(["center","center_of_component_on_board_surface"]).optional().default("center")}).describe("Defines a component on the PCB"),HyA=Xe(["sinewave","square","triangle","sawtooth"]),I6t=Rt([U(),WA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(WA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),oQe=te({type:xA("simulation_voltage_source"),simulation_voltage_source_id:Wt("simulation_voltage_source"),is_dc_source:xA(!0).optional().default(!0),positive_source_port_id:U().optional(),negative_source_port_id:U().optional(),positive_source_net_id:U().optional(),negative_source_net_id:U().optional(),voltage:ix}).describe("Defines a DC voltage source for simulation"),sQe=te({type:xA("simulation_voltage_source"),simulation_voltage_source_id:Wt("simulation_voltage_source"),is_dc_source:xA(!1),terminal1_source_port_id:U().optional(),terminal2_source_port_id:U().optional(),terminal1_source_net_id:U().optional(),terminal2_source_net_id:U().optional(),voltage:ix.optional(),frequency:FM.optional(),peak_to_peak_voltage:ix.optional(),wave_shape:HyA.optional(),phase:cC.optional(),duty_cycle:I6t.optional()}).describe("Defines an AC voltage source for simulation"),rQe=Rt([oQe,sQe]).describe("Defines a voltage source for simulation"),l6t=Rt([U(),WA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(WA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),aQe=te({type:xA("simulation_current_source"),simulation_current_source_id:Wt("simulation_current_source"),is_dc_source:xA(!0).optional().default(!0),positive_source_port_id:U().optional(),negative_source_port_id:U().optional(),positive_source_net_id:U().optional(),negative_source_net_id:U().optional(),current:E2}).describe("Defines a DC current source for simulation"),gQe=te({type:xA("simulation_current_source"),simulation_current_source_id:Wt("simulation_current_source"),is_dc_source:xA(!1),terminal1_source_port_id:U().optional(),terminal2_source_port_id:U().optional(),terminal1_source_net_id:U().optional(),terminal2_source_net_id:U().optional(),current:E2.optional(),frequency:FM.optional(),peak_to_peak_current:E2.optional(),wave_shape:HyA.optional(),phase:cC.optional(),duty_cycle:l6t.optional()}).describe("Defines an AC current source for simulation"),cQe=Rt([aQe,gQe]).describe("Defines a current source for simulation"),IQe=Rt([xA("spice_dc_sweep"),xA("spice_dc_operating_point"),xA("spice_transient_analysis"),xA("spice_ac_analysis")]),lQe=te({type:xA("simulation_experiment"),simulation_experiment_id:Wt("simulation_experiment"),name:U(),experiment_type:IQe,time_per_step:MT.optional(),start_time_ms:MM.optional(),end_time_ms:MM.optional()}).describe("Defines a simulation experiment configuration"),BQe=te({type:xA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Wt("simulation_transient_voltage_graph"),simulation_experiment_id:U(),timestamps_ms:Se(WA()).optional(),voltage_levels:Se(WA()),source_component_id:U().optional(),subcircuit_connectivity_map_key:U().optional(),time_per_step:MT,start_time_ms:MM,end_time_ms:MM,name:U().optional(),color:U().optional()}).describe("Stores voltage measurements over time for a simulation"),CQe=te({type:xA("simulation_switch"),simulation_switch_id:Wt("simulation_switch"),source_component_id:U().optional(),closes_at:MM.optional(),opens_at:MM.optional(),starts_closed:PA().optional(),switching_frequency:FM.optional()}).describe("Defines a switch for simulation timing control"),QQe=te({type:xA("simulation_voltage_probe"),simulation_voltage_probe_id:Wt("simulation_voltage_probe"),source_component_id:U().optional(),name:U().optional(),signal_input_source_port_id:U().optional(),signal_input_source_net_id:U().optional(),reference_input_source_port_id:U().optional(),reference_input_source_net_id:U().optional(),subcircuit_id:U().optional(),color:U().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,n=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&n?A.addIssue({code:zt.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:zt.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):n&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:zt.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:zt.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),hQe=oc.extend({type:xA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Wt("simulation_unknown_experiment_error"),error_type:xA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),simulation_experiment_id:U().optional(),subcircuit_id:U().optional()}).describe("An unknown error occurred during the simulation experiment."),EQe=te({type:xA("simulation_op_amp"),simulation_op_amp_id:Wt("simulation_op_amp"),source_component_id:U().optional(),inverting_input_source_port_id:U(),non_inverting_input_source_port_id:U(),output_source_port_id:U(),positive_supply_source_port_id:U(),negative_supply_source_port_id:U()}).describe("Defines a simple ideal operational amplifier for simulation"),uQe=Rt([Tle,Yle,Jle,Hle,Kle,Ple,EyA,CyA,$j,hyA,QyA,uyA,dyA,pyA,myA,wyA,DyA,kyA,SyA,byA,xyA,_yA,yyA,fyA,Wle,Vle,qle,vyA,FyA,MyA,RyA,jle,zle,Xle,$le,ABe,NyA,Ole,MBe,YBe,MCe,RCe,NCe,UCe,YCe,JBe,bCe,TBe,eCe,OBe,jBe,tCe,KBe,qBe,iCe,nCe,GCe,rCe,aCe,gCe,cCe,QCe,ICe,lCe,BCe,CCe,zBe,XBe,oCe,sCe,$Be,ACe,XCe,ECe,hCe,uCe,dCe,pCe,fCe,yCe,mCe,wCe,LCe,DCe,SCe,JCe,FCe,TCe,PCe,KCe,ZCe,VCe,jCe,zCe,$Ce,AQe,eQe,tQe,eBe,CBe,gBe,cBe,IBe,lBe,rBe,aBe,QBe,BBe,tBe,EBe,uBe,hBe,yBe,mBe,wBe,DBe,xBe,SBe,bBe,nQe,rQe,cQe,lQe,BQe,CQe,QQe,hQe,EQe]),tz=uQe;const YyA=Object.freeze(Object.defineProperty({__proto__:null,all_layers:Zle,any_circuit_element:uQe,any_soup_element:tz,any_source_component:Hle,asset:Cle,base_circuit_json_error:oc,battery_capacity:Ble,brep_shape:kBe,cadModelDefaultDirectionMap:c6t,cad_component:nQe,cad_model_axis_directions:iQe,cad_model_formats:g6t,capacitance:IyA,circuit_json_footprint_load_error:NCe,current:E2,distance:Et,duration_ms:MT,experiment_type:IQe,external_footprint_load_error:RCe,frequency:FM,getZodPrefixedIdWithDefault:Wt,inductance:Ile,kicadAt:Xj,kicadEffects:Qle,kicadFont:ByA,kicadFootprintAttributes:Ele,kicadFootprintMetadata:ple,kicadFootprintModel:dle,kicadFootprintPad:ule,kicadFootprintProperties:hle,kicadProperty:RT,kicadSymbolEffects:mle,kicadSymbolMetadata:Dle,kicadSymbolPinNames:yle,kicadSymbolPinNumbers:fle,kicadSymbolProperties:wle,kicadSymbolProperty:Lk,layer_ref:Hr,layer_string:GyA,length:rn,ms:MM,ninePointAnchor:ox,pcbRenderLayer:GXt,pcb_autorouting_error:LCe,pcb_board:iCe,pcb_breakout_point:JCe,pcb_component:MBe,pcb_component_invalid_layer_error:zCe,pcb_component_not_on_board_edge_error:jCe,pcb_component_outside_board_error:VCe,pcb_connector_not_in_accessible_orientation_warning:YCe,pcb_copper_pour:ZCe,pcb_copper_pour_brep:OCe,pcb_copper_pour_polygon:WCe,pcb_copper_pour_rect:qCe,pcb_copper_text:ICe,pcb_courtyard_circle:tQe,pcb_courtyard_outline:AQe,pcb_courtyard_overlap_error:SCe,pcb_courtyard_polygon:eQe,pcb_courtyard_rect:$Ce,pcb_cutout:FCe,pcb_cutout_circle:_Ce,pcb_cutout_path:vCe,pcb_cutout_polygon:kCe,pcb_cutout_rect:xCe,pcb_fabrication_note_dimension:dCe,pcb_fabrication_note_path:ECe,pcb_fabrication_note_rect:uCe,pcb_fabrication_note_text:hCe,pcb_footprint_overlap_error:DCe,pcb_ground_plane:TCe,pcb_ground_plane_region:PCe,pcb_group:GCe,pcb_hole:YBe,pcb_hole_circle_or_square_shape:PXt,pcb_hole_circle_shape:JXt,pcb_hole_oval_shape:KXt,pcb_hole_pill_shape:qXt,pcb_hole_rect_shape:TXt,pcb_hole_rotated_pill_shape:OXt,pcb_keepout:bCe,pcb_manual_edit_conflict_warning:UCe,pcb_missing_footprint_error:MCe,pcb_net:eCe,pcb_note_dimension:wCe,pcb_note_line:mCe,pcb_note_path:yCe,pcb_note_rect:fCe,pcb_note_text:pCe,pcb_panel:nCe,pcb_panelization_placement_error:sCe,pcb_placement_error:oCe,pcb_plated_hole:JBe,pcb_port:TBe,pcb_port_not_connected_error:ACe,pcb_port_not_matched_error:$Be,pcb_route_hint:vBe,pcb_route_hints:YXt,pcb_silkscreen_circle:BCe,pcb_silkscreen_line:aCe,pcb_silkscreen_oval:CCe,pcb_silkscreen_path:gCe,pcb_silkscreen_pill:QCe,pcb_silkscreen_rect:lCe,pcb_silkscreen_text:cCe,pcb_smtpad:KBe,pcb_smtpad_pill:PBe,pcb_solder_paste:qBe,pcb_text:OBe,pcb_thermal_spoke:KCe,pcb_trace:jBe,pcb_trace_error:zBe,pcb_trace_hint:rCe,pcb_trace_missing_error:XBe,pcb_trace_route_point:VBe,pcb_trace_route_point_via:ZBe,pcb_trace_route_point_wire:WBe,pcb_via:tCe,pcb_via_clearance_error:XCe,point:Bn,point3:nx,point_with_bulge:_Be,port_arrangement:sBe,position:MXt,position3:RXt,resistance:zj,ring:LyA,rotation:cC,route_hint_point:FBe,schematic_arc:lBe,schematic_box:eBe,schematic_circle:IBe,schematic_component:rBe,schematic_component_port_arrangement_by_sides:oBe,schematic_component_port_arrangement_by_size:nBe,schematic_debug_line:pBe,schematic_debug_object:yBe,schematic_debug_object_base:Az,schematic_debug_point:fBe,schematic_debug_rect:dBe,schematic_error:EBe,schematic_group:DBe,schematic_layout_error:uBe,schematic_line:gBe,schematic_manual_edit_conflict_warning:wBe,schematic_net_label:hBe,schematic_path:tBe,schematic_pin_styles:iBe,schematic_port:QBe,schematic_rect:cBe,schematic_sheet:xBe,schematic_symbol:aBe,schematic_table:SBe,schematic_table_cell:bBe,schematic_text:CBe,schematic_trace:BBe,schematic_voltage_probe:mBe,simulation_ac_current_source:gQe,simulation_ac_voltage_source:sQe,simulation_current_source:cQe,simulation_dc_current_source:aQe,simulation_dc_voltage_source:oQe,simulation_experiment:lQe,simulation_op_amp:EQe,simulation_switch:CQe,simulation_transient_voltage_graph:BQe,simulation_unknown_experiment_error:hQe,simulation_voltage_probe:QQe,simulation_voltage_source:rQe,size:lyA,source_ambiguous_port_reference:Ole,source_board:qle,source_component_base:_c,source_component_internal_connection:Jle,source_component_pins_underspecified_warning:Xle,source_failed_to_create_component_error:Rle,source_group:Ple,source_i2c_misconfigured_error:NyA,source_interconnect:Lle,source_invalid_component_property_error:FyA,source_manually_placed_via:Vle,source_missing_property_error:Mle,source_net:Kle,source_no_ground_pin_defined_warning:zle,source_no_power_pin_defined_warning:jle,source_pcb_ground_plane:Wle,source_pin_attributes:kle,source_pin_missing_trace_warning:RyA,source_pin_must_be_connected_error:$le,source_port:Yle,source_project_metadata:vyA,source_property_ignored_warning:Nle,source_simple_battery:dyA,source_simple_capacitor:CyA,source_simple_chip:EyA,source_simple_connector:Fle,source_simple_crystal:vle,source_simple_current_source:_le,source_simple_diode:$j,source_simple_fiducial:ble,source_simple_ground:xle,source_simple_inductor:pyA,source_simple_led:hyA,source_simple_mosfet:xyA,source_simple_op_amp:_yA,source_simple_pin_header:myA,source_simple_pinout:wyA,source_simple_potentiometer:yyA,source_simple_power_source:uyA,source_simple_push_button:fyA,source_simple_resistor:QyA,source_simple_resonator:DyA,source_simple_switch:kyA,source_simple_test_point:byA,source_simple_transistor:SyA,source_simple_voltage_probe:Gle,source_simple_voltage_source:Ule,source_trace:Tle,source_trace_not_connected_error:MyA,supplier_name:Sle,time:FXt,timestamp:lle,unknown_error_finding_part:ABe,visible_layer:Fm,voltage:ix,wave_shape:HyA},Symbol.toStringTag,{value:"Module"})),NT=t=>typeof t=="number"&&!isNaN(t),RM=t=>typeof t=="string",ay=t=>typeof t=="function",iz=t=>RM(t)||ay(t)?t:null,JyA=t=>V.isValidElement(t)||RM(t)||ay(t)||NT(t);function B6t(t,A,e){e===void 0&&(e=300);const{scrollHeight:i,style:n}=t;requestAnimationFrame(()=>{n.minHeight="initial",n.height=i+"px",n.transition=`all ${e}ms`,requestAnimationFrame(()=>{n.height="0",n.padding="0",n.margin="0",setTimeout(A,e)})})}function nz(t){let{enter:A,exit:e,appendPosition:i=!1,collapse:n=!0,collapseDuration:o=300}=t;return function(s){let{children:r,position:a,preventExitTransition:g,done:c,nodeRef:I,isIn:l,playToast:B}=s;const C=i?`${A}--${a}`:A,Q=i?`${e}--${a}`:e,h=V.useRef(0);return V.useLayoutEffect(()=>{const E=I.current,u=C.split(" "),d=f=>{f.target===I.current&&(B(),E.removeEventListener("animationend",d),E.removeEventListener("animationcancel",d),h.current===0&&f.type!=="animationcancel"&&E.classList.remove(...u))};E.classList.add(...u),E.addEventListener("animationend",d),E.addEventListener("animationcancel",d)},[]),V.useEffect(()=>{const E=I.current,u=()=>{E.removeEventListener("animationend",u),n?B6t(E,c,o):c()};l||(g?u():(h.current=1,E.className+=` ${Q}`,E.addEventListener("animationend",u)))},[l]),Qn.createElement(Qn.Fragment,null,r)}}function dQe(t,A){return t!=null?{content:t.content,containerId:t.props.containerId,id:t.props.toastId,theme:t.props.theme,type:t.props.type,data:t.props.data||{},isLoading:t.props.isLoading,icon:t.props.icon,status:A}:{}}const ap=new Map;let GT=[];const TyA=new Set,C6t=t=>TyA.forEach(A=>A(t)),pQe=()=>ap.size>0;function fQe(t,A){var e;if(A)return!((e=ap.get(A))==null||!e.isToastActive(t));let i=!1;return ap.forEach(n=>{n.isToastActive(t)&&(i=!0)}),i}function yQe(t,A){JyA(t)&&(pQe()||GT.push({content:t,options:A}),ap.forEach(e=>{e.buildToast(t,A)}))}function mQe(t,A){ap.forEach(e=>{A!=null&&A!=null&&A.containerId?A?.containerId===e.id&&e.toggle(t,A?.id):e.toggle(t,A?.id)})}function Q6t(t){const{subscribe:A,getSnapshot:e,setProps:i}=V.useRef((function(o){const s=o.containerId||1;return{subscribe(r){const a=(function(c,I,l){let B=1,C=0,Q=[],h=[],E=[],u=I;const d=new Map,f=new Set,y=()=>{E=Array.from(d.values()),f.forEach(S=>S())},w=S=>{h=S==null?[]:h.filter(_=>_!==S),y()},D=S=>{const{toastId:_,onOpen:b,updateId:N,children:F}=S.props,L=N==null;S.staleId&&d.delete(S.staleId),d.set(_,S),h=[...h,S.props.toastId].filter(Y=>Y!==S.staleId),y(),l(dQe(S,L?"added":"updated")),L&&ay(b)&&b(V.isValidElement(F)&&F.props)};return{id:c,props:u,observe:S=>(f.add(S),()=>f.delete(S)),toggle:(S,_)=>{d.forEach(b=>{_!=null&&_!==b.props.toastId||ay(b.toggle)&&b.toggle(S)})},removeToast:w,toasts:d,clearQueue:()=>{C-=Q.length,Q=[]},buildToast:(S,_)=>{if((iA=>{let{containerId:sA,toastId:aA,updateId:EA}=iA;const bA=sA?sA!==c:c!==1,_A=d.has(aA)&&EA==null;return bA||_A})(_))return;const{toastId:b,updateId:N,data:F,staleId:L,delay:Y}=_,J=()=>{w(b)},O=N==null;O&&C++;const Z={...u,style:u.toastStyle,key:B++,...Object.fromEntries(Object.entries(_).filter(iA=>{let[sA,aA]=iA;return aA!=null})),toastId:b,updateId:N,data:F,closeToast:J,isIn:!1,className:iz(_.className||u.toastClassName),bodyClassName:iz(_.bodyClassName||u.bodyClassName),progressClassName:iz(_.progressClassName||u.progressClassName),autoClose:!_.isLoading&&(X=_.autoClose,eA=u.autoClose,X===!1||NT(X)&&X>0?X:eA),deleteToast(){const iA=d.get(b),{onClose:sA,children:aA}=iA.props;ay(sA)&&sA(V.isValidElement(aA)&&aA.props),l(dQe(iA,"removed")),d.delete(b),C--,C<0&&(C=0),Q.length>0?D(Q.shift()):y()}};var X,eA;Z.closeButton=u.closeButton,_.closeButton===!1||JyA(_.closeButton)?Z.closeButton=_.closeButton:_.closeButton===!0&&(Z.closeButton=!JyA(u.closeButton)||u.closeButton);let gA=S;V.isValidElement(S)&&!RM(S.type)?gA=V.cloneElement(S,{closeToast:J,toastProps:Z,data:F}):ay(S)&&(gA=S({closeToast:J,toastProps:Z,data:F}));const tA={content:gA,props:Z,staleId:L};u.limit&&u.limit>0&&C>u.limit&&O?Q.push(tA):NT(Y)?setTimeout(()=>{D(tA)},Y):D(tA)},setProps(S){u=S},setToggle:(S,_)=>{d.get(S).toggle=_},isToastActive:S=>h.some(_=>_===S),getSnapshot:()=>E}})(s,o,C6t);ap.set(s,a);const g=a.observe(r);return GT.forEach(c=>yQe(c.content,c.options)),GT=[],()=>{g(),ap.delete(s)}},setProps(r){var a;(a=ap.get(s))==null||a.setProps(r)},getSnapshot(){var r;return(r=ap.get(s))==null?void 0:r.getSnapshot()}}})(t)).current;i(t);const n=V.useSyncExternalStore(A,e,e);return{getToastToRender:function(o){if(!n)return[];const s=new Map;return t.newestOnTop&&n.reverse(),n.forEach(r=>{const{position:a}=r.props;s.has(a)||s.set(a,[]),s.get(a).push(r)}),Array.from(s,r=>o(r[0],r[1]))},isToastActive:fQe,count:n?.length}}function h6t(t){const[A,e]=V.useState(!1),[i,n]=V.useState(!1),o=V.useRef(null),s=V.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:r,pauseOnHover:a,closeToast:g,onClick:c,closeOnClick:I}=t;var l,B;function C(){e(!0)}function Q(){e(!1)}function h(d){const f=o.current;s.canDrag&&f&&(s.didMove=!0,A&&Q(),s.delta=t.draggableDirection==="x"?d.clientX-s.start:d.clientY-s.start,s.start!==d.clientX&&(s.canCloseOnClick=!1),f.style.transform=`translate3d(${t.draggableDirection==="x"?`${s.delta}px, var(--y)`:`0, calc(${s.delta}px + var(--y))`},0)`,f.style.opacity=""+(1-Math.abs(s.delta/s.removalDistance)))}function E(){document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",E);const d=o.current;if(s.canDrag&&s.didMove&&d){if(s.canDrag=!1,Math.abs(s.delta)>s.removalDistance)return n(!0),t.closeToast(),void t.collapseAll();d.style.transition="transform 0.2s, opacity 0.2s",d.style.removeProperty("transform"),d.style.removeProperty("opacity")}}(B=ap.get((l={id:t.toastId,containerId:t.containerId,fn:e}).containerId||1))==null||B.setToggle(l.id,l.fn),V.useEffect(()=>{if(t.pauseOnFocusLoss)return document.hasFocus()||Q(),window.addEventListener("focus",C),window.addEventListener("blur",Q),()=>{window.removeEventListener("focus",C),window.removeEventListener("blur",Q)}},[t.pauseOnFocusLoss]);const u={onPointerDown:function(d){if(t.draggable===!0||t.draggable===d.pointerType){s.didMove=!1,document.addEventListener("pointermove",h),document.addEventListener("pointerup",E);const f=o.current;s.canCloseOnClick=!0,s.canDrag=!0,f.style.transition="none",t.draggableDirection==="x"?(s.start=d.clientX,s.removalDistance=f.offsetWidth*(t.draggablePercent/100)):(s.start=d.clientY,s.removalDistance=f.offsetHeight*(t.draggablePercent===80?1.5*t.draggablePercent:t.draggablePercent)/100)}},onPointerUp:function(d){const{top:f,bottom:y,left:w,right:D}=o.current.getBoundingClientRect();d.nativeEvent.type!=="touchend"&&t.pauseOnHover&&d.clientX>=w&&d.clientX<=D&&d.clientY>=f&&d.clientY<=y?Q():C()}};return r&&a&&(u.onMouseEnter=Q,t.stacked||(u.onMouseLeave=C)),I&&(u.onClick=d=>{c&&c(d),s.canCloseOnClick&&g()}),{playToast:C,pauseToast:Q,isRunning:A,preventExitTransition:i,toastRef:o,eventHandlers:u}}function E6t(t){let{delay:A,isRunning:e,closeToast:i,type:n="default",hide:o,className:s,style:r,controlledProgress:a,progress:g,rtl:c,isIn:I,theme:l}=t;const B=o||a&&g===0,C={...r,animationDuration:`${A}ms`,animationPlayState:e?"running":"paused"};a&&(C.transform=`scaleX(${g})`);const Q=dw("Toastify__progress-bar",a?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${l}`,`Toastify__progress-bar--${n}`,{"Toastify__progress-bar--rtl":c}),h=ay(s)?s({rtl:c,type:n,defaultClassName:Q}):dw(Q,s),E={[a&&g>=1?"onTransitionEnd":"onAnimationEnd"]:a&&g<1?null:()=>{I&&i()}};return Qn.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":B},Qn.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${l} Toastify__progress-bar--${n}`}),Qn.createElement("div",{role:"progressbar","aria-hidden":B?"true":"false","aria-label":"notification timer",className:h,style:C,...E}))}let u6t=1;const wQe=()=>""+u6t++;function d6t(t){return t&&(RM(t.toastId)||NT(t.toastId))?t.toastId:wQe()}function LT(t,A){return yQe(t,A),A.toastId}function oz(t,A){return{...A,type:A&&A.type||t,toastId:d6t(A)}}function sz(t){return(A,e)=>LT(A,oz(t,e))}function sc(t,A){return LT(t,oz("default",A))}sc.loading=(t,A)=>LT(t,oz("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...A})),sc.promise=function(t,A,e){let i,{pending:n,error:o,success:s}=A;n&&(i=RM(n)?sc.loading(n,e):sc.loading(n.render,{...e,...n}));const r={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},a=(c,I,l)=>{if(I==null)return void sc.dismiss(i);const B={type:c,...r,...e,data:l},C=RM(I)?{render:I}:I;return i?sc.update(i,{...B,...C}):sc(C.render,{...B,...C}),l},g=ay(t)?t():t;return g.then(c=>a("success",s,c)).catch(c=>a("error",o,c)),g},sc.success=sz("success"),sc.info=sz("info"),sc.error=sz("error"),sc.warning=sz("warning"),sc.warn=sc.warning,sc.dark=(t,A)=>LT(t,oz("default",{theme:"dark",...A})),sc.dismiss=function(t){(function(A){var e;if(pQe()){if(A==null||RM(e=A)||NT(e))ap.forEach(i=>{i.removeToast(A)});else if(A&&("containerId"in A||"id"in A)){const i=ap.get(A.containerId);i?i.removeToast(A.id):ap.forEach(n=>{n.removeToast(A.id)})}}else GT=GT.filter(i=>A!=null&&i.options.toastId!==A)})(t)},sc.clearWaitingQueue=function(t){t===void 0&&(t={}),ap.forEach(A=>{!A.props.limit||t.containerId&&A.id!==t.containerId||A.clearQueue()})},sc.isActive=fQe,sc.update=function(t,A){A===void 0&&(A={});const e=((i,n)=>{var o;let{containerId:s}=n;return(o=ap.get(s||1))==null?void 0:o.toasts.get(i)})(t,A);if(e){const{props:i,content:n}=e,o={delay:100,...i,...A,toastId:A.toastId||t,updateId:wQe()};o.toastId!==t&&(o.staleId=t);const s=o.render||n;delete o.render,LT(s,o)}},sc.done=t=>{sc.update(t,{progress:1})},sc.onChange=function(t){return TyA.add(t),()=>{TyA.delete(t)}},sc.play=t=>mQe(!0,t),sc.pause=t=>mQe(!1,t);const p6t=typeof window<"u"?V.useLayoutEffect:V.useEffect,rz=t=>{let{theme:A,type:e,isLoading:i,...n}=t;return Qn.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:A==="colored"?"currentColor":`var(--toastify-icon-color-${e})`,...n})},PyA={info:function(t){return Qn.createElement(rz,{...t},Qn.createElement("path",{d:"M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"}))},warning:function(t){return Qn.createElement(rz,{...t},Qn.createElement("path",{d:"M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"}))},success:function(t){return Qn.createElement(rz,{...t},Qn.createElement("path",{d:"M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"}))},error:function(t){return Qn.createElement(rz,{...t},Qn.createElement("path",{d:"M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"}))},spinner:function(){return Qn.createElement("div",{className:"Toastify__spinner"})}},f6t=t=>{const{isRunning:A,preventExitTransition:e,toastRef:i,eventHandlers:n,playToast:o}=h6t(t),{closeButton:s,children:r,autoClose:a,onClick:g,type:c,hideProgressBar:I,closeToast:l,transition:B,position:C,className:Q,style:h,bodyClassName:E,bodyStyle:u,progressClassName:d,progressStyle:f,updateId:y,role:w,progress:D,rtl:S,toastId:_,deleteToast:b,isIn:N,isLoading:F,closeOnClick:L,theme:Y}=t,J=dw("Toastify__toast",`Toastify__toast-theme--${Y}`,`Toastify__toast--${c}`,{"Toastify__toast--rtl":S},{"Toastify__toast--close-on-click":L}),O=ay(Q)?Q({rtl:S,position:C,type:c,defaultClassName:J}):dw(J,Q),Z=(function(tA){let{theme:iA,type:sA,isLoading:aA,icon:EA}=tA,bA=null;const _A={theme:iA,type:sA};return EA===!1||(ay(EA)?bA=EA({..._A,isLoading:aA}):V.isValidElement(EA)?bA=V.cloneElement(EA,_A):aA?bA=PyA.spinner():(LA=>LA in PyA)(sA)&&(bA=PyA[sA](_A))),bA})(t),X=!!D||!a,eA={closeToast:l,type:c,theme:Y};let gA=null;return s===!1||(gA=ay(s)?s(eA):V.isValidElement(s)?V.cloneElement(s,eA):(function(tA){let{closeToast:iA,theme:sA,ariaLabel:aA="close"}=tA;return Qn.createElement("button",{className:`Toastify__close-button Toastify__close-button--${sA}`,type:"button",onClick:EA=>{EA.stopPropagation(),iA(EA)},"aria-label":aA},Qn.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},Qn.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))})(eA)),Qn.createElement(B,{isIn:N,done:b,position:C,preventExitTransition:e,nodeRef:i,playToast:o},Qn.createElement("div",{id:_,onClick:g,"data-in":N,className:O,...n,style:h,ref:i},Qn.createElement("div",{...N&&{role:w},className:ay(E)?E({type:c}):dw("Toastify__toast-body",E),style:u},Z!=null&&Qn.createElement("div",{className:dw("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!F})},Z),Qn.createElement("div",null,r)),gA,Qn.createElement(E6t,{...y&&!X?{key:`pb-${y}`}:{},rtl:S,theme:Y,delay:a,isRunning:A,isIn:N,closeToast:l,hide:I,type:c,style:f,className:d,controlledProgress:X,progress:D||0})))},az=function(t,A){return A===void 0&&(A=!1),{enter:`Toastify--animate Toastify__${t}-enter`,exit:`Toastify--animate Toastify__${t}-exit`,appendPosition:A}},y6t=nz(az("bounce",!0));nz(az("slide",!0)),nz(az("zoom")),nz(az("flip"));const m6t={position:"top-right",transition:y6t,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};function w6t(t){let A={...m6t,...t};const e=t.stacked,[i,n]=V.useState(!0),o=V.useRef(null),{getToastToRender:s,isToastActive:r,count:a}=Q6t(A),{className:g,style:c,rtl:I,containerId:l}=A;function B(Q){const h=dw("Toastify__toast-container",`Toastify__toast-container--${Q}`,{"Toastify__toast-container--rtl":I});return ay(g)?g({position:Q,rtl:I,defaultClassName:h}):dw(h,iz(g))}function C(){e&&(n(!0),sc.play())}return p6t(()=>{if(e){var Q;const h=o.current.querySelectorAll('[data-in="true"]'),E=12,u=(Q=A.position)==null?void 0:Q.includes("top");let d=0,f=0;Array.from(h).reverse().forEach((y,w)=>{const D=y;D.classList.add("Toastify__toast--stacked"),w>0&&(D.dataset.collapsed=`${i}`),D.dataset.pos||(D.dataset.pos=u?"top":"bot");const S=d*(i?.2:1)+(i?0:E*w);D.style.setProperty("--y",`${u?S:-1*S}px`),D.style.setProperty("--g",`${E}`),D.style.setProperty("--s",""+(1-(i?f:0))),d+=D.offsetHeight,f+=.025})}},[i,a,e]),Qn.createElement("div",{ref:o,className:"Toastify",id:l,onMouseEnter:()=>{e&&(n(!1),sc.pause())},onMouseLeave:C},s((Q,h)=>{const E=h.length?{...c}:{...c,pointerEvents:"none"};return Qn.createElement("div",{className:B(Q),style:E,key:`container-${Q}`},h.map(u=>{let{content:d,props:f}=u;return Qn.createElement(f6t,{...f,stacked:e,collapseAll:C,isIn:r(f.toastId,f.containerId),style:f.style,key:`toast-${f.key}`},d)}))}))}function D6t(){var t=':root{--toastify-color-light:#fff;--toastify-color-dark:#121212;--toastify-color-info:#3498db;--toastify-color-success:#07bc0c;--toastify-color-warning:#f1c40f;--toastify-color-error:#e74c3c;--toastify-color-transparent:hsla(0,0%,100%,.7);--toastify-icon-color-info:var(--toastify-color-info);--toastify-icon-color-success:var(--toastify-color-success);--toastify-icon-color-warning:var(--toastify-color-warning);--toastify-icon-color-error:var(--toastify-color-error);--toastify-toast-width:320px;--toastify-toast-offset:16px;--toastify-toast-top:max(var(--toastify-toast-offset),env(safe-area-inset-top));--toastify-toast-right:max(var(--toastify-toast-offset),env(safe-area-inset-right));--toastify-toast-left:max(var(--toastify-toast-offset),env(safe-area-inset-left));--toastify-toast-bottom:max(var(--toastify-toast-offset),env(safe-area-inset-bottom));--toastify-toast-background:#fff;--toastify-toast-min-height:64px;--toastify-toast-max-height:800px;--toastify-toast-bd-radius:6px;--toastify-font-family:sans-serif;--toastify-z-index:9999;--toastify-text-color-light:#757575;--toastify-text-color-dark:#fff;--toastify-text-color-info:#fff;--toastify-text-color-success:#fff;--toastify-text-color-warning:#fff;--toastify-text-color-error:#fff;--toastify-spinner-color:#616161;--toastify-spinner-color-empty-area:#e0e0e0;--toastify-color-progress-light:linear-gradient(90deg,#4cd964,#5ac8fa,#007aff,#34aadc,#5856d6,#ff2d55);--toastify-color-progress-dark:#bb86fc;--toastify-color-progress-info:var(--toastify-color-info);--toastify-color-progress-success:var(--toastify-color-success);--toastify-color-progress-warning:var(--toastify-color-warning);--toastify-color-progress-error:var(--toastify-color-error);--toastify-color-progress-bgo:0.2}.Toastify__toast-container{z-index:var(--toastify-z-index);-webkit-transform:translateZ(var(--toastify-z-index));position:fixed;padding:4px;width:var(--toastify-toast-width);box-sizing:border-box;color:#fff}.Toastify__toast-container--top-left{top:var(--toastify-toast-top);left:var(--toastify-toast-left)}.Toastify__toast-container--top-center{top:var(--toastify-toast-top);left:50%;transform:translateX(-50%)}.Toastify__toast-container--top-right{top:var(--toastify-toast-top);right:var(--toastify-toast-right)}.Toastify__toast-container--bottom-left{bottom:var(--toastify-toast-bottom);left:var(--toastify-toast-left)}.Toastify__toast-container--bottom-center{bottom:var(--toastify-toast-bottom);left:50%;transform:translateX(-50%)}.Toastify__toast-container--bottom-right{bottom:var(--toastify-toast-bottom);right:var(--toastify-toast-right)}@media only screen and (max-width:480px){.Toastify__toast-container{width:100vw;padding:0;left:env(safe-area-inset-left);margin:0}.Toastify__toast-container--top-center,.Toastify__toast-container--top-left,.Toastify__toast-container--top-right{top:env(safe-area-inset-top);transform:translateX(0)}.Toastify__toast-container--bottom-center,.Toastify__toast-container--bottom-left,.Toastify__toast-container--bottom-right{bottom:env(safe-area-inset-bottom);transform:translateX(0)}.Toastify__toast-container--rtl{right:env(safe-area-inset-right);left:auto}}.Toastify__toast{--y:0;position:relative;-ms-touch-action:none;touch-action:none;min-height:var(--toastify-toast-min-height);box-sizing:border-box;margin-bottom:1rem;padding:8px;border-radius:var(--toastify-toast-bd-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;max-height:var(--toastify-toast-max-height);font-family:var(--toastify-font-family);cursor:default;direction:ltr;z-index:0;overflow:hidden}.Toastify__toast--stacked{position:absolute;width:100%;transform:translate3d(0,var(--y),0) scale(var(--s));transition:transform .3s}.Toastify__toast--stacked[data-collapsed] .Toastify__close-button,.Toastify__toast--stacked[data-collapsed] .Toastify__toast-body{transition:opacity .1s}.Toastify__toast--stacked[data-collapsed=false]{overflow:visible}.Toastify__toast--stacked[data-collapsed=true]:not(:last-child)>*{opacity:0}.Toastify__toast--stacked:after{content:"";position:absolute;left:0;right:0;height:calc(var(--g) * 1px);bottom:100%}.Toastify__toast--stacked[data-pos=top]{top:0}.Toastify__toast--stacked[data-pos=bot]{bottom:0}.Toastify__toast--stacked[data-pos=bot].Toastify__toast--stacked:before{transform-origin:top}.Toastify__toast--stacked[data-pos=top].Toastify__toast--stacked:before{transform-origin:bottom}.Toastify__toast--stacked:before{content:"";position:absolute;left:0;right:0;bottom:0;height:100%;transform:scaleY(3);z-index:-1}.Toastify__toast--rtl{direction:rtl}.Toastify__toast--close-on-click{cursor:pointer}.Toastify__toast-body{margin:auto 0;-ms-flex:1 1 auto;flex:1 1 auto;padding:6px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.Toastify__toast-body>div:last-child{word-break:break-word;-ms-flex:1;flex:1}.Toastify__toast-icon{-webkit-margin-end:10px;margin-inline-end:10px;width:20px;-ms-flex-negative:0;flex-shrink:0;display:-ms-flexbox;display:flex}.Toastify--animate{animation-fill-mode:both;animation-duration:.5s}.Toastify--animate-icon{animation-fill-mode:both;animation-duration:.3s}@media only screen and (max-width:480px){.Toastify__toast{margin-bottom:0;border-radius:0}}.Toastify__toast-theme--dark{background:var(--toastify-color-dark);color:var(--toastify-text-color-dark)}.Toastify__toast-theme--colored.Toastify__toast--default,.Toastify__toast-theme--light{background:var(--toastify-color-light);color:var(--toastify-text-color-light)}.Toastify__toast-theme--colored.Toastify__toast--info{color:var(--toastify-text-color-info);background:var(--toastify-color-info)}.Toastify__toast-theme--colored.Toastify__toast--success{color:var(--toastify-text-color-success);background:var(--toastify-color-success)}.Toastify__toast-theme--colored.Toastify__toast--warning{color:var(--toastify-text-color-warning);background:var(--toastify-color-warning)}.Toastify__toast-theme--colored.Toastify__toast--error{color:var(--toastify-text-color-error);background:var(--toastify-color-error)}.Toastify__progress-bar-theme--light{background:var(--toastify-color-progress-light)}.Toastify__progress-bar-theme--dark{background:var(--toastify-color-progress-dark)}.Toastify__progress-bar--info{background:var(--toastify-color-progress-info)}.Toastify__progress-bar--success{background:var(--toastify-color-progress-success)}.Toastify__progress-bar--warning{background:var(--toastify-color-progress-warning)}.Toastify__progress-bar--error{background:var(--toastify-color-progress-error)}.Toastify__progress-bar-theme--colored.Toastify__progress-bar--error,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--info,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--success,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning{background:var(--toastify-color-transparent)}.Toastify__close-button{color:#fff;background:transparent;outline:none;border:none;padding:0;cursor:pointer;opacity:.7;transition:.3s ease;-ms-flex-item-align:start;align-self:flex-start;z-index:1}.Toastify__close-button--light{color:#000;opacity:.3}.Toastify__close-button>svg{fill:currentColor;height:16px;width:14px}.Toastify__close-button:focus,.Toastify__close-button:hover{opacity:1}@keyframes Toastify__trackProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.Toastify__progress-bar{position:absolute;bottom:0;left:0;width:100%;height:100%;z-index:var(--toastify-z-index);opacity:.7;transform-origin:left;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--animated{animation:Toastify__trackProgress linear 1 forwards}.Toastify__progress-bar--controlled{transition:transform .2s}.Toastify__progress-bar--rtl{right:0;left:auto;transform-origin:right;border-bottom-left-radius:0;border-bottom-right-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp{position:absolute;bottom:0;left:0;width:100%;height:5px;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp[data-hidden=true]{opacity:0}.Toastify__progress-bar--bg{opacity:var(--toastify-color-progress-bgo);width:100%;height:100%}.Toastify__spinner{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toastify-spinner-color-empty-area);border-right-color:var(--toastify-spinner-color);animation:Toastify__spin .65s linear infinite}@keyframes Toastify__bounceInRight{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(3000px,0,0)}60%{opacity:1;transform:translate3d(-25px,0,0)}75%{transform:translate3d(10px,0,0)}90%{transform:translate3d(-5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutRight{20%{opacity:1;transform:translate3d(-20px,var(--y),0)}to{opacity:0;transform:translate3d(2000px,var(--y),0)}}@keyframes Toastify__bounceInLeft{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(-3000px,0,0)}60%{opacity:1;transform:translate3d(25px,0,0)}75%{transform:translate3d(-10px,0,0)}90%{transform:translate3d(5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutLeft{20%{opacity:1;transform:translate3d(20px,var(--y),0)}to{opacity:0;transform:translate3d(-2000px,var(--y),0)}}@keyframes Toastify__bounceInUp{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,3000px,0)}60%{opacity:1;transform:translate3d(0,-20px,0)}75%{transform:translate3d(0,10px,0)}90%{transform:translate3d(0,-5px,0)}to{transform:translateZ(0)}}@keyframes Toastify__bounceOutUp{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,-2000px,0)}}@keyframes Toastify__bounceInDown{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,-3000px,0)}60%{opacity:1;transform:translate3d(0,25px,0)}75%{transform:translate3d(0,-10px,0)}90%{transform:translate3d(0,5px,0)}to{transform:none}}@keyframes Toastify__bounceOutDown{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,2000px,0)}}.Toastify__bounce-enter--bottom-left,.Toastify__bounce-enter--top-left{animation-name:Toastify__bounceInLeft}.Toastify__bounce-enter--bottom-right,.Toastify__bounce-enter--top-right{animation-name:Toastify__bounceInRight}.Toastify__bounce-enter--top-center{animation-name:Toastify__bounceInDown}.Toastify__bounce-enter--bottom-center{animation-name:Toastify__bounceInUp}.Toastify__bounce-exit--bottom-left,.Toastify__bounce-exit--top-left{animation-name:Toastify__bounceOutLeft}.Toastify__bounce-exit--bottom-right,.Toastify__bounce-exit--top-right{animation-name:Toastify__bounceOutRight}.Toastify__bounce-exit--top-center{animation-name:Toastify__bounceOutUp}.Toastify__bounce-exit--bottom-center{animation-name:Toastify__bounceOutDown}@keyframes Toastify__zoomIn{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:1}}@keyframes Toastify__zoomOut{0%{opacity:1}50%{opacity:0;transform:translate3d(0,var(--y),0) scale3d(.3,.3,.3)}to{opacity:0}}.Toastify__zoom-enter{animation-name:Toastify__zoomIn}.Toastify__zoom-exit{animation-name:Toastify__zoomOut}@keyframes Toastify__flipIn{0%{transform:perspective(400px) rotateX(90deg);animation-timing-function:ease-in;opacity:0}40%{transform:perspective(400px) rotateX(-20deg);animation-timing-function:ease-in}60%{transform:perspective(400px) rotateX(10deg);opacity:1}80%{transform:perspective(400px) rotateX(-5deg)}to{transform:perspective(400px)}}@keyframes Toastify__flipOut{0%{transform:translate3d(0,var(--y),0) perspective(400px)}30%{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(-20deg);opacity:1}to{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(90deg);opacity:0}}.Toastify__flip-enter{animation-name:Toastify__flipIn}.Toastify__flip-exit{animation-name:Toastify__flipOut}@keyframes Toastify__slideInRight{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInLeft{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInUp{0%{transform:translate3d(0,110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInDown{0%{transform:translate3d(0,-110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideOutRight{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(110%,var(--y),0)}}@keyframes Toastify__slideOutLeft{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(-110%,var(--y),0)}}@keyframes Toastify__slideOutDown{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,500px,0)}}@keyframes Toastify__slideOutUp{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,-500px,0)}}.Toastify__slide-enter--bottom-left,.Toastify__slide-enter--top-left{animation-name:Toastify__slideInLeft}.Toastify__slide-enter--bottom-right,.Toastify__slide-enter--top-right{animation-name:Toastify__slideInRight}.Toastify__slide-enter--top-center{animation-name:Toastify__slideInDown}.Toastify__slide-enter--bottom-center{animation-name:Toastify__slideInUp}.Toastify__slide-exit--bottom-left,.Toastify__slide-exit--top-left{animation-name:Toastify__slideOutLeft;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-right,.Toastify__slide-exit--top-right{animation-name:Toastify__slideOutRight;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-center{animation-name:Toastify__slideOutUp;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-center{animation-name:Toastify__slideOutDown;animation-timing-function:ease-in;animation-duration:.3s}@keyframes Toastify__spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}',A=document.createElement("style");A.innerText=t,document.head.appendChild(A)}var KyA={exports:{}},qyA,DQe;function SQe(){return DQe||(DQe=1,qyA={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),qyA}var OyA={exports:{}},WyA,bQe;function S6t(){return bQe||(bQe=1,WyA=function(A){return!A||typeof A=="string"?!1:A instanceof Array||Array.isArray(A)||A.length>=0&&(A.splice instanceof Function||Object.getOwnPropertyDescriptor(A,A.length-1)&&A.constructor.name!=="String")}),WyA}var xQe;function b6t(){if(xQe)return OyA.exports;xQe=1;var t=S6t(),A=Array.prototype.concat,e=Array.prototype.slice,i=OyA.exports=function(o){for(var s=[],r=0,a=o.length;r<a;r++){var g=o[r];t(g)?s=A.call(s,e.call(g)):s.push(g)}return s};return i.wrap=function(n){return function(){return n(i(arguments))}},OyA.exports}var _Qe;function x6t(){if(_Qe)return KyA.exports;_Qe=1;var t=SQe(),A=b6t(),e=Object.hasOwnProperty,i=Object.create(null);for(var n in t)e.call(t,n)&&(i[t[n]]=n);var o=KyA.exports={to:{},get:{}};o.get=function(a){var g=a.substring(0,3).toLowerCase(),c,I;switch(g){case"hsl":c=o.get.hsl(a),I="hsl";break;case"hwb":c=o.get.hwb(a),I="hwb";break;default:c=o.get.rgb(a),I="rgb";break}return c?{model:I,value:c}:null},o.get.rgb=function(a){if(!a)return null;var g=/^#([a-f0-9]{3,4})$/i,c=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,I=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,l=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,B=/^(\w+)$/,C=[0,0,0,1],Q,h,E;if(Q=a.match(c)){for(E=Q[2],Q=Q[1],h=0;h<3;h++){var u=h*2;C[h]=parseInt(Q.slice(u,u+2),16)}E&&(C[3]=parseInt(E,16)/255)}else if(Q=a.match(g)){for(Q=Q[1],E=Q[3],h=0;h<3;h++)C[h]=parseInt(Q[h]+Q[h],16);E&&(C[3]=parseInt(E+E,16)/255)}else if(Q=a.match(I)){for(h=0;h<3;h++)C[h]=parseInt(Q[h+1],0);Q[4]&&(Q[5]?C[3]=parseFloat(Q[4])*.01:C[3]=parseFloat(Q[4]))}else if(Q=a.match(l)){for(h=0;h<3;h++)C[h]=Math.round(parseFloat(Q[h+1])*2.55);Q[4]&&(Q[5]?C[3]=parseFloat(Q[4])*.01:C[3]=parseFloat(Q[4]))}else return(Q=a.match(B))?Q[1]==="transparent"?[0,0,0,0]:e.call(t,Q[1])?(C=t[Q[1]],C[3]=1,C):null:null;for(h=0;h<3;h++)C[h]=s(C[h],0,255);return C[3]=s(C[3],0,1),C},o.get.hsl=function(a){if(!a)return null;var g=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,c=a.match(g);if(c){var I=parseFloat(c[4]),l=(parseFloat(c[1])%360+360)%360,B=s(parseFloat(c[2]),0,100),C=s(parseFloat(c[3]),0,100),Q=s(isNaN(I)?1:I,0,1);return[l,B,C,Q]}return null},o.get.hwb=function(a){if(!a)return null;var g=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,c=a.match(g);if(c){var I=parseFloat(c[4]),l=(parseFloat(c[1])%360+360)%360,B=s(parseFloat(c[2]),0,100),C=s(parseFloat(c[3]),0,100),Q=s(isNaN(I)?1:I,0,1);return[l,B,C,Q]}return null},o.to.hex=function(){var a=A(arguments);return"#"+r(a[0])+r(a[1])+r(a[2])+(a[3]<1?r(Math.round(a[3]*255)):"")},o.to.rgb=function(){var a=A(arguments);return a.length<4||a[3]===1?"rgb("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+")":"rgba("+Math.round(a[0])+", "+Math.round(a[1])+", "+Math.round(a[2])+", "+a[3]+")"},o.to.rgb.percent=function(){var a=A(arguments),g=Math.round(a[0]/255*100),c=Math.round(a[1]/255*100),I=Math.round(a[2]/255*100);return a.length<4||a[3]===1?"rgb("+g+"%, "+c+"%, "+I+"%)":"rgba("+g+"%, "+c+"%, "+I+"%, "+a[3]+")"},o.to.hsl=function(){var a=A(arguments);return a.length<4||a[3]===1?"hsl("+a[0]+", "+a[1]+"%, "+a[2]+"%)":"hsla("+a[0]+", "+a[1]+"%, "+a[2]+"%, "+a[3]+")"},o.to.hwb=function(){var a=A(arguments),g="";return a.length>=4&&a[3]!==1&&(g=", "+a[3]),"hwb("+a[0]+", "+a[1]+"%, "+a[2]+"%"+g+")"},o.to.keyword=function(a){return i[a.slice(0,3)]};function s(a,g,c){return Math.min(Math.max(g,a),c)}function r(a){var g=Math.round(a).toString(16).toUpperCase();return g.length<2?"0"+g:g}return KyA.exports}var ZyA,kQe;function vQe(){if(kQe)return ZyA;kQe=1;const t=SQe(),A={};for(const n of Object.keys(t))A[t[n]]=n;const e={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};ZyA=e;for(const n of Object.keys(e)){if(!("channels"in e[n]))throw new Error("missing channels property: "+n);if(!("labels"in e[n]))throw new Error("missing channel labels property: "+n);if(e[n].labels.length!==e[n].channels)throw new Error("channel and label counts mismatch: "+n);const{channels:o,labels:s}=e[n];delete e[n].channels,delete e[n].labels,Object.defineProperty(e[n],"channels",{value:o}),Object.defineProperty(e[n],"labels",{value:s})}e.rgb.hsl=function(n){const o=n[0]/255,s=n[1]/255,r=n[2]/255,a=Math.min(o,s,r),g=Math.max(o,s,r),c=g-a;let I,l;g===a?I=0:o===g?I=(s-r)/c:s===g?I=2+(r-o)/c:r===g&&(I=4+(o-s)/c),I=Math.min(I*60,360),I<0&&(I+=360);const B=(a+g)/2;return g===a?l=0:B<=.5?l=c/(g+a):l=c/(2-g-a),[I,l*100,B*100]},e.rgb.hsv=function(n){let o,s,r,a,g;const c=n[0]/255,I=n[1]/255,l=n[2]/255,B=Math.max(c,I,l),C=B-Math.min(c,I,l),Q=function(h){return(B-h)/6/C+1/2};return C===0?(a=0,g=0):(g=C/B,o=Q(c),s=Q(I),r=Q(l),c===B?a=r-s:I===B?a=1/3+o-r:l===B&&(a=2/3+s-o),a<0?a+=1:a>1&&(a-=1)),[a*360,g*100,B*100]},e.rgb.hwb=function(n){const o=n[0],s=n[1];let r=n[2];const a=e.rgb.hsl(n)[0],g=1/255*Math.min(o,Math.min(s,r));return r=1-1/255*Math.max(o,Math.max(s,r)),[a,g*100,r*100]},e.rgb.cmyk=function(n){const o=n[0]/255,s=n[1]/255,r=n[2]/255,a=Math.min(1-o,1-s,1-r),g=(1-o-a)/(1-a)||0,c=(1-s-a)/(1-a)||0,I=(1-r-a)/(1-a)||0;return[g*100,c*100,I*100,a*100]};function i(n,o){return(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}return e.rgb.keyword=function(n){const o=A[n];if(o)return o;let s=1/0,r;for(const a of Object.keys(t)){const g=t[a],c=i(n,g);c<s&&(s=c,r=a)}return r},e.keyword.rgb=function(n){return t[n]},e.rgb.xyz=function(n){let o=n[0]/255,s=n[1]/255,r=n[2]/255;o=o>.04045?((o+.055)/1.055)**2.4:o/12.92,s=s>.04045?((s+.055)/1.055)**2.4:s/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;const a=o*.4124+s*.3576+r*.1805,g=o*.2126+s*.7152+r*.0722,c=o*.0193+s*.1192+r*.9505;return[a*100,g*100,c*100]},e.rgb.lab=function(n){const o=e.rgb.xyz(n);let s=o[0],r=o[1],a=o[2];s/=95.047,r/=100,a/=108.883,s=s>.008856?s**(1/3):7.787*s+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,a=a>.008856?a**(1/3):7.787*a+16/116;const g=116*r-16,c=500*(s-r),I=200*(r-a);return[g,c,I]},e.hsl.rgb=function(n){const o=n[0]/360,s=n[1]/100,r=n[2]/100;let a,g,c;if(s===0)return c=r*255,[c,c,c];r<.5?a=r*(1+s):a=r+s-r*s;const I=2*r-a,l=[0,0,0];for(let B=0;B<3;B++)g=o+1/3*-(B-1),g<0&&g++,g>1&&g--,6*g<1?c=I+(a-I)*6*g:2*g<1?c=a:3*g<2?c=I+(a-I)*(2/3-g)*6:c=I,l[B]=c*255;return l},e.hsl.hsv=function(n){const o=n[0];let s=n[1]/100,r=n[2]/100,a=s;const g=Math.max(r,.01);r*=2,s*=r<=1?r:2-r,a*=g<=1?g:2-g;const c=(r+s)/2,I=r===0?2*a/(g+a):2*s/(r+s);return[o,I*100,c*100]},e.hsv.rgb=function(n){const o=n[0]/60,s=n[1]/100;let r=n[2]/100;const a=Math.floor(o)%6,g=o-Math.floor(o),c=255*r*(1-s),I=255*r*(1-s*g),l=255*r*(1-s*(1-g));switch(r*=255,a){case 0:return[r,l,c];case 1:return[I,r,c];case 2:return[c,r,l];case 3:return[c,I,r];case 4:return[l,c,r];case 5:return[r,c,I]}},e.hsv.hsl=function(n){const o=n[0],s=n[1]/100,r=n[2]/100,a=Math.max(r,.01);let g,c;c=(2-s)*r;const I=(2-s)*a;return g=s*a,g/=I<=1?I:2-I,g=g||0,c/=2,[o,g*100,c*100]},e.hwb.rgb=function(n){const o=n[0]/360;let s=n[1]/100,r=n[2]/100;const a=s+r;let g;a>1&&(s/=a,r/=a);const c=Math.floor(6*o),I=1-r;g=6*o-c,(c&1)!==0&&(g=1-g);const l=s+g*(I-s);let B,C,Q;switch(c){default:case 6:case 0:B=I,C=l,Q=s;break;case 1:B=l,C=I,Q=s;break;case 2:B=s,C=I,Q=l;break;case 3:B=s,C=l,Q=I;break;case 4:B=l,C=s,Q=I;break;case 5:B=I,C=s,Q=l;break}return[B*255,C*255,Q*255]},e.cmyk.rgb=function(n){const o=n[0]/100,s=n[1]/100,r=n[2]/100,a=n[3]/100,g=1-Math.min(1,o*(1-a)+a),c=1-Math.min(1,s*(1-a)+a),I=1-Math.min(1,r*(1-a)+a);return[g*255,c*255,I*255]},e.xyz.rgb=function(n){const o=n[0]/100,s=n[1]/100,r=n[2]/100;let a,g,c;return a=o*3.2406+s*-1.5372+r*-.4986,g=o*-.9689+s*1.8758+r*.0415,c=o*.0557+s*-.204+r*1.057,a=a>.0031308?1.055*a**(1/2.4)-.055:a*12.92,g=g>.0031308?1.055*g**(1/2.4)-.055:g*12.92,c=c>.0031308?1.055*c**(1/2.4)-.055:c*12.92,a=Math.min(Math.max(0,a),1),g=Math.min(Math.max(0,g),1),c=Math.min(Math.max(0,c),1),[a*255,g*255,c*255]},e.xyz.lab=function(n){let o=n[0],s=n[1],r=n[2];o/=95.047,s/=100,r/=108.883,o=o>.008856?o**(1/3):7.787*o+16/116,s=s>.008856?s**(1/3):7.787*s+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;const a=116*s-16,g=500*(o-s),c=200*(s-r);return[a,g,c]},e.lab.xyz=function(n){const o=n[0],s=n[1],r=n[2];let a,g,c;g=(o+16)/116,a=s/500+g,c=g-r/200;const I=g**3,l=a**3,B=c**3;return g=I>.008856?I:(g-16/116)/7.787,a=l>.008856?l:(a-16/116)/7.787,c=B>.008856?B:(c-16/116)/7.787,a*=95.047,g*=100,c*=108.883,[a,g,c]},e.lab.lch=function(n){const o=n[0],s=n[1],r=n[2];let a;a=Math.atan2(r,s)*360/2/Math.PI,a<0&&(a+=360);const c=Math.sqrt(s*s+r*r);return[o,c,a]},e.lch.lab=function(n){const o=n[0],s=n[1],a=n[2]/360*2*Math.PI,g=s*Math.cos(a),c=s*Math.sin(a);return[o,g,c]},e.rgb.ansi16=function(n,o=null){const[s,r,a]=n;let g=o===null?e.rgb.hsv(n)[2]:o;if(g=Math.round(g/50),g===0)return 30;let c=30+(Math.round(a/255)<<2|Math.round(r/255)<<1|Math.round(s/255));return g===2&&(c+=60),c},e.hsv.ansi16=function(n){return e.rgb.ansi16(e.hsv.rgb(n),n[2])},e.rgb.ansi256=function(n){const o=n[0],s=n[1],r=n[2];return o===s&&s===r?o<8?16:o>248?231:Math.round((o-8)/247*24)+232:16+36*Math.round(o/255*5)+6*Math.round(s/255*5)+Math.round(r/255*5)},e.ansi16.rgb=function(n){let o=n%10;if(o===0||o===7)return n>50&&(o+=3.5),o=o/10.5*255,[o,o,o];const s=(~~(n>50)+1)*.5,r=(o&1)*s*255,a=(o>>1&1)*s*255,g=(o>>2&1)*s*255;return[r,a,g]},e.ansi256.rgb=function(n){if(n>=232){const g=(n-232)*10+8;return[g,g,g]}n-=16;let o;const s=Math.floor(n/36)/5*255,r=Math.floor((o=n%36)/6)/5*255,a=o%6/5*255;return[s,r,a]},e.rgb.hex=function(n){const s=(((Math.round(n[0])&255)<<16)+((Math.round(n[1])&255)<<8)+(Math.round(n[2])&255)).toString(16).toUpperCase();return"000000".substring(s.length)+s},e.hex.rgb=function(n){const o=n.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!o)return[0,0,0];let s=o[0];o[0].length===3&&(s=s.split("").map(I=>I+I).join(""));const r=parseInt(s,16),a=r>>16&255,g=r>>8&255,c=r&255;return[a,g,c]},e.rgb.hcg=function(n){const o=n[0]/255,s=n[1]/255,r=n[2]/255,a=Math.max(Math.max(o,s),r),g=Math.min(Math.min(o,s),r),c=a-g;let I,l;return c<1?I=g/(1-c):I=0,c<=0?l=0:a===o?l=(s-r)/c%6:a===s?l=2+(r-o)/c:l=4+(o-s)/c,l/=6,l%=1,[l*360,c*100,I*100]},e.hsl.hcg=function(n){const o=n[1]/100,s=n[2]/100,r=s<.5?2*o*s:2*o*(1-s);let a=0;return r<1&&(a=(s-.5*r)/(1-r)),[n[0],r*100,a*100]},e.hsv.hcg=function(n){const o=n[1]/100,s=n[2]/100,r=o*s;let a=0;return r<1&&(a=(s-r)/(1-r)),[n[0],r*100,a*100]},e.hcg.rgb=function(n){const o=n[0]/360,s=n[1]/100,r=n[2]/100;if(s===0)return[r*255,r*255,r*255];const a=[0,0,0],g=o%1*6,c=g%1,I=1-c;let l=0;switch(Math.floor(g)){case 0:a[0]=1,a[1]=c,a[2]=0;break;case 1:a[0]=I,a[1]=1,a[2]=0;break;case 2:a[0]=0,a[1]=1,a[2]=c;break;case 3:a[0]=0,a[1]=I,a[2]=1;break;case 4:a[0]=c,a[1]=0,a[2]=1;break;default:a[0]=1,a[1]=0,a[2]=I}return l=(1-s)*r,[(s*a[0]+l)*255,(s*a[1]+l)*255,(s*a[2]+l)*255]},e.hcg.hsv=function(n){const o=n[1]/100,s=n[2]/100,r=o+s*(1-o);let a=0;return r>0&&(a=o/r),[n[0],a*100,r*100]},e.hcg.hsl=function(n){const o=n[1]/100,r=n[2]/100*(1-o)+.5*o;let a=0;return r>0&&r<.5?a=o/(2*r):r>=.5&&r<1&&(a=o/(2*(1-r))),[n[0],a*100,r*100]},e.hcg.hwb=function(n){const o=n[1]/100,s=n[2]/100,r=o+s*(1-o);return[n[0],(r-o)*100,(1-r)*100]},e.hwb.hcg=function(n){const o=n[1]/100,r=1-n[2]/100,a=r-o;let g=0;return a<1&&(g=(r-a)/(1-a)),[n[0],a*100,g*100]},e.apple.rgb=function(n){return[n[0]/65535*255,n[1]/65535*255,n[2]/65535*255]},e.rgb.apple=function(n){return[n[0]/255*65535,n[1]/255*65535,n[2]/255*65535]},e.gray.rgb=function(n){return[n[0]/100*255,n[0]/100*255,n[0]/100*255]},e.gray.hsl=function(n){return[0,0,n[0]]},e.gray.hsv=e.gray.hsl,e.gray.hwb=function(n){return[0,100,n[0]]},e.gray.cmyk=function(n){return[0,0,0,n[0]]},e.gray.lab=function(n){return[n[0],0,0]},e.gray.hex=function(n){const o=Math.round(n[0]/100*255)&255,r=((o<<16)+(o<<8)+o).toString(16).toUpperCase();return"000000".substring(r.length)+r},e.rgb.gray=function(n){return[(n[0]+n[1]+n[2])/3/255*100]},ZyA}var VyA,FQe;function _6t(){if(FQe)return VyA;FQe=1;const t=vQe();function A(){const o={},s=Object.keys(t);for(let r=s.length,a=0;a<r;a++)o[s[a]]={distance:-1,parent:null};return o}function e(o){const s=A(),r=[o];for(s[o].distance=0;r.length;){const a=r.pop(),g=Object.keys(t[a]);for(let c=g.length,I=0;I<c;I++){const l=g[I],B=s[l];B.distance===-1&&(B.distance=s[a].distance+1,B.parent=a,r.unshift(l))}}return s}function i(o,s){return function(r){return s(o(r))}}function n(o,s){const r=[s[o].parent,o];let a=t[s[o].parent][o],g=s[o].parent;for(;s[g].parent;)r.unshift(s[g].parent),a=i(t[s[g].parent][g],a),g=s[g].parent;return a.conversion=r,a}return VyA=function(o){const s=e(o),r={},a=Object.keys(s);for(let g=a.length,c=0;c<g;c++){const I=a[c];s[I].parent!==null&&(r[I]=n(I,s))}return r},VyA}var jyA,MQe;function k6t(){if(MQe)return jyA;MQe=1;const t=vQe(),A=_6t(),e={},i=Object.keys(t);function n(s){const r=function(...a){const g=a[0];return g==null?g:(g.length>1&&(a=g),s(a))};return"conversion"in s&&(r.conversion=s.conversion),r}function o(s){const r=function(...a){const g=a[0];if(g==null)return g;g.length>1&&(a=g);const c=s(a);if(typeof c=="object")for(let I=c.length,l=0;l<I;l++)c[l]=Math.round(c[l]);return c};return"conversion"in s&&(r.conversion=s.conversion),r}return i.forEach(s=>{e[s]={},Object.defineProperty(e[s],"channels",{value:t[s].channels}),Object.defineProperty(e[s],"labels",{value:t[s].labels});const r=A(s);Object.keys(r).forEach(g=>{const c=r[g];e[s][g]=o(c),e[s][g].raw=n(c)})}),jyA=e,jyA}var zyA,RQe;function v6t(){if(RQe)return zyA;RQe=1;const t=x6t(),A=k6t(),e=["keyword","gray","hex"],i={};for(const l of Object.keys(A))i[[...A[l].labels].sort().join("")]=l;const n={};function o(l,B){if(!(this instanceof o))return new o(l,B);if(B&&B in e&&(B=null),B&&!(B in A))throw new Error("Unknown model: "+B);let C,Q;if(l==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(l instanceof o)this.model=l.model,this.color=[...l.color],this.valpha=l.valpha;else if(typeof l=="string"){const h=t.get(l);if(h===null)throw new Error("Unable to parse color from string: "+l);this.model=h.model,Q=A[this.model].channels,this.color=h.value.slice(0,Q),this.valpha=typeof h.value[Q]=="number"?h.value[Q]:1}else if(l.length>0){this.model=B||"rgb",Q=A[this.model].channels;const h=Array.prototype.slice.call(l,0,Q);this.color=I(h,Q),this.valpha=typeof l[Q]=="number"?l[Q]:1}else if(typeof l=="number")this.model="rgb",this.color=[l>>16&255,l>>8&255,l&255],this.valpha=1;else{this.valpha=1;const h=Object.keys(l);"alpha"in l&&(h.splice(h.indexOf("alpha"),1),this.valpha=typeof l.alpha=="number"?l.alpha:0);const E=h.sort().join("");if(!(E in i))throw new Error("Unable to parse color from object: "+JSON.stringify(l));this.model=i[E];const{labels:u}=A[this.model],d=[];for(C=0;C<u.length;C++)d.push(l[u[C]]);this.color=I(d)}if(n[this.model])for(Q=A[this.model].channels,C=0;C<Q;C++){const h=n[this.model][C];h&&(this.color[C]=h(this.color[C]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}o.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(l){let B=this.model in t.to?this:this.rgb();B=B.round(typeof l=="number"?l:1);const C=B.valpha===1?B.color:[...B.color,this.valpha];return t.to[B.model](C)},percentString(l){const B=this.rgb().round(typeof l=="number"?l:1),C=B.valpha===1?B.color:[...B.color,this.valpha];return t.to.rgb.percent(C)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const l={},{channels:B}=A[this.model],{labels:C}=A[this.model];for(let Q=0;Q<B;Q++)l[C[Q]]=this.color[Q];return this.valpha!==1&&(l.alpha=this.valpha),l},unitArray(){const l=this.rgb().color;return l[0]/=255,l[1]/=255,l[2]/=255,this.valpha!==1&&l.push(this.valpha),l},unitObject(){const l=this.rgb().object();return l.r/=255,l.g/=255,l.b/=255,this.valpha!==1&&(l.alpha=this.valpha),l},round(l){return l=Math.max(l||0,0),new o([...this.color.map(r(l)),this.valpha],this.model)},alpha(l){return l!==void 0?new o([...this.color,Math.max(0,Math.min(1,l))],this.model):this.valpha},red:a("rgb",0,g(255)),green:a("rgb",1,g(255)),blue:a("rgb",2,g(255)),hue:a(["hsl","hsv","hsl","hwb","hcg"],0,l=>(l%360+360)%360),saturationl:a("hsl",1,g(100)),lightness:a("hsl",2,g(100)),saturationv:a("hsv",1,g(100)),value:a("hsv",2,g(100)),chroma:a("hcg",1,g(100)),gray:a("hcg",2,g(100)),white:a("hwb",1,g(100)),wblack:a("hwb",2,g(100)),cyan:a("cmyk",0,g(100)),magenta:a("cmyk",1,g(100)),yellow:a("cmyk",2,g(100)),black:a("cmyk",3,g(100)),x:a("xyz",0,g(95.047)),y:a("xyz",1,g(100)),z:a("xyz",2,g(108.833)),l:a("lab",0,g(100)),a:a("lab",1),b:a("lab",2),keyword(l){return l!==void 0?new o(l):A[this.model].keyword(this.color)},hex(l){return l!==void 0?new o(l):t.to.hex(this.rgb().round().color)},hexa(l){if(l!==void 0)return new o(l);const B=this.rgb().round().color;let C=Math.round(this.valpha*255).toString(16).toUpperCase();return C.length===1&&(C="0"+C),t.to.hex(B)+C},rgbNumber(){const l=this.rgb().color;return(l[0]&255)<<16|(l[1]&255)<<8|l[2]&255},luminosity(){const l=this.rgb().color,B=[];for(const[C,Q]of l.entries()){const h=Q/255;B[C]=h<=.04045?h/12.92:((h+.055)/1.055)**2.4}return .2126*B[0]+.7152*B[1]+.0722*B[2]},contrast(l){const B=this.luminosity(),C=l.luminosity();return B>C?(B+.05)/(C+.05):(C+.05)/(B+.05)},level(l){const B=this.contrast(l);return B>=7?"AAA":B>=4.5?"AA":""},isDark(){const l=this.rgb().color;return(l[0]*2126+l[1]*7152+l[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const l=this.rgb();for(let B=0;B<3;B++)l.color[B]=255-l.color[B];return l},lighten(l){const B=this.hsl();return B.color[2]+=B.color[2]*l,B},darken(l){const B=this.hsl();return B.color[2]-=B.color[2]*l,B},saturate(l){const B=this.hsl();return B.color[1]+=B.color[1]*l,B},desaturate(l){const B=this.hsl();return B.color[1]-=B.color[1]*l,B},whiten(l){const B=this.hwb();return B.color[1]+=B.color[1]*l,B},blacken(l){const B=this.hwb();return B.color[2]+=B.color[2]*l,B},grayscale(){const l=this.rgb().color,B=l[0]*.3+l[1]*.59+l[2]*.11;return o.rgb(B,B,B)},fade(l){return this.alpha(this.valpha-this.valpha*l)},opaquer(l){return this.alpha(this.valpha+this.valpha*l)},rotate(l){const B=this.hsl();let C=B.color[0];return C=(C+l)%360,C=C<0?360+C:C,B.color[0]=C,B},mix(l,B){if(!l||!l.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof l);const C=l.rgb(),Q=this.rgb(),h=B===void 0?.5:B,E=2*h-1,u=C.alpha()-Q.alpha(),d=((E*u===-1?E:(E+u)/(1+E*u))+1)/2,f=1-d;return o.rgb(d*C.red()+f*Q.red(),d*C.green()+f*Q.green(),d*C.blue()+f*Q.blue(),C.alpha()*h+Q.alpha()*(1-h))}};for(const l of Object.keys(A)){if(e.includes(l))continue;const{channels:B}=A[l];o.prototype[l]=function(...C){return this.model===l?new o(this):C.length>0?new o(C,l):new o([...c(A[this.model][l].raw(this.color)),this.valpha],l)},o[l]=function(...C){let Q=C[0];return typeof Q=="number"&&(Q=I(C,B)),new o(Q,l)}}function s(l,B){return Number(l.toFixed(B))}function r(l){return function(B){return s(B,l)}}function a(l,B,C){l=Array.isArray(l)?l:[l];for(const Q of l)(n[Q]||(n[Q]=[]))[B]=C;return l=l[0],function(Q){let h;return Q!==void 0?(C&&(Q=C(Q)),h=this[l](),h.color[B]=Q,h):(h=this[l]().color[B],C&&(h=C(h)),h)}}function g(l){return function(B){return Math.max(0,Math.min(l,B))}}function c(l){return Array.isArray(l)?l:[l]}function I(l,B){for(let C=0;C<B;C++)typeof l[C]!="number"&&(l[C]=0);return l}return zyA=o,zyA}var F6t=v6t();const Ta=N0(F6t);function ai(t,A){return Array.isArray(A)?[t.a*A[0]+t.c*A[1]+t.e,t.b*A[0]+t.d*A[1]+t.f]:{x:t.a*A.x+t.c*A.y+t.e,y:t.b*A.x+t.d*A.y+t.f}}function M6t(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function UT(t){return typeof t>"u"}function Uk(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function gz(...t){t=Array.isArray(t[0])?t[0]:t;const A=(e,i)=>({a:e.a*i.a+e.c*i.b,c:e.a*i.c+e.c*i.d,e:e.a*i.e+e.c*i.f+e.e,b:e.b*i.a+e.d*i.b,d:e.b*i.c+e.d*i.d,f:e.b*i.e+e.d*i.f+e.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return A(t[0],t[1]);default:{const[e,i,...n]=t,o=A(e,i);return gz(o,...n)}}}function XyA(...t){return gz(...t)}const{cos:R6t,sin:N6t}=Math;function NQe(t,A,e){const i=R6t(t),n=N6t(t),o={a:i,c:-n,e:0,b:n,d:i,f:0};return UT(A)||UT(e)?o:gz([Uk(A,e),o,Uk(-A,-e)])}function G6t(t,A=void 0,e=void 0,i=void 0){UT(A)&&(A=t);const n={a:t,c:0,e:0,b:0,d:A,f:0};return UT(e)||UT(i)?n:gz([Uk(e,i),n,Uk(-e,-i)])}function cz(t){const{ctx:A,points:e,fill:i,stroke:n,strokeWidth:o=1,minStrokePx:s,realToCanvasMat:r,closePath:a=!1}=t;if(e.length<2)return;A.beginPath();const g=e.map(B=>ai(r,[B.x,B.y])),c=g[0];if(!c)return;const[I,l]=c;A.moveTo(I,l);for(let B=1;B<g.length;B++){const C=g[B];if(!C)continue;const[Q,h]=C;A.lineTo(Q,h)}if(a&&A.closePath(),i&&(A.fillStyle=i,A.fill()),n){const B=o*Math.abs(r.a),C=s===void 0?B:Math.max(B,s);A.strokeStyle=n,A.lineWidth=C,A.stroke()}}function eQ(t){const{ctx:A,center:e,width:i,height:n,fill:o,realToCanvasMat:s,borderRadius:r=0,ccwRotationDegrees:a=0,stroke:g,strokeWidth:c,isStrokeDashed:I=!1}=t,[l,B]=ai(s,[e.x,e.y]),C=i*Math.abs(s.a),Q=n*Math.abs(s.a),h=r*Math.abs(s.a),E=c?c*Math.abs(s.a):void 0;if(A.save(),A.translate(l,B),a!==0&&A.rotate(-a*(Math.PI/180)),A.beginPath(),h>0){const u=-C/2,d=-Q/2,f=Math.min(h,C/2,Q/2);A.moveTo(u+f,d),A.lineTo(u+C-f,d),A.arcTo(u+C,d,u+C,d+f,f),A.lineTo(u+C,d+Q-f),A.arcTo(u+C,d+Q,u+C-f,d+Q,f),A.lineTo(u+f,d+Q),A.arcTo(u,d+Q,u,d+Q-f,f),A.lineTo(u,d+f),A.arcTo(u,d,u+f,d,f)}else A.rect(-C/2,-Q/2,C,Q);o&&(A.fillStyle=o,A.fill()),g&&E&&(I?A.setLineDash([E*3,E*2]):A.setLineDash([]),A.strokeStyle=g,A.lineWidth=E,A.stroke()),A.restore()}function L6t(t){const{ctx:A,board:e,realToCanvasMat:i,colorMap:n,drawBoardMaterial:o,minBoardOutlineStrokePx:s}=t,{width:r,height:a,center:g,outline:c}=e;if(c&&Array.isArray(c)&&c.length>=3){o&&cz({ctx:A,points:c.map(I=>({x:I.x,y:I.y})),fill:n.substrate,realToCanvasMat:i,closePath:!0}),cz({ctx:A,points:c.map(I=>({x:I.x,y:I.y})),stroke:n.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0,minStrokePx:s});return}if(r!==void 0&&a!==void 0&&g){o&&eQ({ctx:A,center:g,width:r,height:a,fill:n.substrate,realToCanvasMat:i});const I=r/2,l=a/2,B=[{x:g.x-I,y:g.y-l},{x:g.x+I,y:g.y-l},{x:g.x+I,y:g.y+l},{x:g.x-I,y:g.y+l}];cz({ctx:A,points:B,stroke:n.boardOutline,strokeWidth:.1,realToCanvasMat:i,closePath:!0,minStrokePx:s})}}function Hk(t){const{ctx:A,points:e,fill:i,realToCanvasMat:n}=t;if(e.length<3)return;A.beginPath();const o=e.map(g=>ai(n,[g.x,g.y])),s=o[0];if(!s)return;const[r,a]=s;A.moveTo(r,a);for(let g=1;g<o.length;g++){const c=o[g];if(!c)continue;const[I,l]=c;A.lineTo(I,l)}A.closePath(),A.fillStyle=i,A.fill()}function U6t(t,A){return A.copper[t]??A.copper.top}function H6t(t){return t==="top"||t==="bottom"?.5:1}function Y6t(t,A,e,i,n){if(Math.abs(n)<1e-10)return null;const o=e-t,s=i-A,r=Math.hypot(o,s);if(r<1e-10)return null;const a=Math.abs(n)*(r/2),g=r/2,c=(a*a+g*g)/(2*a),I=c-a,l=(t+e)/2,B=(A+i)/2,C=-s/r,Q=o/r,h=n>0?-1:1,E=l+h*C*I,u=B+h*Q*I;return{centerX:E,centerY:u,radius:c}}function $yA(t,A,e,i,n,o,s){if(Math.abs(o)<1e-10){const[f,y]=ai(s,[i,n]);t.lineTo(f,y);return}const r=Y6t(A,e,i,n,o);if(!r){const[f,y]=ai(s,[i,n]);t.lineTo(f,y);return}const[a,g]=ai(s,[A,e]),[c,I]=ai(s,[i,n]),[l,B]=ai(s,[r.centerX,r.centerY]),C=Math.hypot(a-l,g-B),Q=Math.atan2(g-B,a-l),h=Math.atan2(I-B,c-l),u=s.a*s.d-s.b*s.c<0,d=o>0?!u:u;t.arc(l,B,C,Q,h,d)}function GQe(t,A,e){if(A.vertices.length<2)return;if(A.vertices.length===2){const s=A.vertices[0],r=A.vertices[1];if(s&&r&&Math.abs((s.bulge??0)-1)<1e-10&&Math.abs((r.bulge??0)-1)<1e-10){const[a,g]=ai(e,[s.x,s.y]);t.moveTo(a,g),$yA(t,s.x,s.y,r.x,r.y,1,e),$yA(t,r.x,r.y,s.x,s.y,1,e);return}}const i=A.vertices[0];if(!i)return;const[n,o]=ai(e,[i.x,i.y]);t.moveTo(n,o);for(let s=0;s<A.vertices.length;s++){const r=A.vertices[s],a=(s+1)%A.vertices.length,g=A.vertices[a];if(!r||!g)continue;const c=r.bulge??0;if(Math.abs(c)<1e-10){const[I,l]=ai(e,[g.x,g.y]);t.lineTo(I,l)}else $yA(t,r.x,r.y,g.x,g.y,c,e)}}function J6t(t){const{ctx:A,pour:e,realToCanvasMat:i,colorMap:n}=t,o=U6t(e.layer,n),s=H6t(e.layer);if(A.save(),A.globalAlpha=s,e.shape==="rect"){const[r,a]=ai(i,[e.center.x,e.center.y]),g=e.width*Math.abs(i.a),c=e.height*Math.abs(i.a);A.translate(r,a),e.rotation&&A.rotate(-e.rotation*(Math.PI/180)),A.beginPath(),A.rect(-g/2,-c/2,g,c),A.fillStyle=o,A.fill(),A.restore();return}if(e.shape==="polygon"){if(e.points&&e.points.length>=3){const r=e.points.map(I=>ai(i,[I.x,I.y])),a=r[0];if(!a){A.restore();return}A.beginPath();const[g,c]=a;A.moveTo(g,c);for(let I=1;I<r.length;I++){const l=r[I];if(!l)continue;const[B,C]=l;A.lineTo(B,C)}A.closePath(),A.fillStyle=o,A.fill()}A.restore();return}if(e.shape==="brep"){if(A.beginPath(),GQe(A,e.brep_shape.outer_ring,i),e.brep_shape.inner_rings)for(const r of e.brep_shape.inner_rings)GQe(A,r,i);A.fillStyle=o,A.fill("evenodd"),A.restore();return}A.restore()}var T6t=t=>hee[t]??(t===" "?sd.spaceWidthRatio:sd.glyphWidthRatio);function LQe(t,A,e){const i=T6t(t),n=A?sd.letterSpacingRatio:0,o=A?Eee[t]?.[A]??0:0;return e*(i+n+o)}function AmA(t,A){const e=A*sd.glyphWidthRatio,i=A*sd.letterSpacingRatio,n=A*sd.spaceWidthRatio,o=A*sd.strokeWidthRatio,s=A*sd.lineHeightRatio,r=t.replace(/\\n/g,`
@@ -5689,7 +5689,7 @@ test("${g} should solve problem correctly", () => {
5689
5689
  // Add more specific assertions based on expected output
5690
5690
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5691
5691
  })
5692
- `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&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:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},EEe=t=>t.activeSubSolver?[t,...EEe(t.activeSubSolver)]:[t],lni=({solver:t})=>{const A=EEe(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(Ini,{solver:e})]},e.constructor.name))})},Bni=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(lni,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,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:g,disabled:t.solved||t.failed||o,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:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,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"}),B&&W.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:C})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Cni=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Qni=(t,A)=>{const i=t.pipelineDef[A].solverName,n=Cni(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},hni=({status:t})=>{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[t]}`,children:t})},Eni=({progress:t})=>{if(t===0)return null;const A=Math.round(t*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,"%"]})]})},uni=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),dni=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=uni(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},FmA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(FmA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=FmA(i));return A},pni=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=FmA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},fni=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>Qni(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):pni(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[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:"Step"}),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:i.map(r=>W.jsxs("tr",{className:`border-b border-gray-100 ${r.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",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),W.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.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:r.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(hni,{status:r.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(Eni,{progress:r.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(dni,{stats:r.stats})}),W.jsx("td",{className:"px-4 py-2",children:r.solverInstance?W.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.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})]},r.name))})]})})]})},yni=class extends Qn.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function mni({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>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-${E}`)),e.map((h,E)=>W.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>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-${E}`)),A.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var wni=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=V.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);V.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return W.jsxs("div",{children:[W.jsx(Bni,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(yni,{fallback:W.jsx(mni,{graphics:s}),children:W.jsx(cni,{graphics:s})}),a&&W.jsx(fni,{solver:t,onStepUntilPhase:g})]})};const Dni=()=>{V.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},Sni=t=>t.toLowerCase().includes("pack")?Cqt:t.toLowerCase().includes("rout")?dqt:$Kt,bni=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);Dni();const i=V.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=V.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=V.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=WrA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(WrA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.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:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return W.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const c=Sni(a.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(c,{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:a.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?W.jsx(wm,{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(wni,{solver:s.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]})]}),s.error&&W.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.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 ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),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"})})})]})},uEe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{qW.captureException(i)}catch{}}},[t,A]),V.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{qW.captureException(n,{error_type:i.type})}catch{}}},[e])},dEe="0.0.1740",xni={version:dEe},Jz=k4A()(v4A(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),_ni=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=aG("eval-version-selection",null),g=Jz(B=>B.setLastRunEvalVersion),c=Jz(B=>B.lastRunEvalVersion);return V.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(B=>B.json()).then(B=>{if(Array.isArray(B?.versions)){let C=[...B.versions];B.tags?.latest&&(n(B.tags.latest),C=C.filter(Q=>Q!==B.tags.latest)),e(C)}}).catch(()=>{})},[t]),V.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:V.useMemo(()=>A.filter(B=>B.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:c,search:o,setSearch:s,selectVersion:B=>{a(B),s("")}}},kni=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=t.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),c=I=>{I.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:W.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[W.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),W.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:I=>r(I.target.value),onKeyDown:c}),W.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(I=>W.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===I?"bg-blue-50":""}`,onClick:()=>o(I),children:I},I)),g&&W.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),W.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},vni=t=>{const A=V.useRef(null),e=MI(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function Fni(t){const A=Mni(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(Nni);if(a){const g=a.props.children,c=r.map(I=>I===a?V.Children.count(g)>1?V.Children.only(null):V.isValidElement(g)?g.props.children:null:I);return W.jsx(A,{...s,ref:n,children:V.isValidElement(g)?V.cloneElement(g,void 0,c):null})}return W.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function Mni(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=Lni(n),r=Gni(o,n.props);return n.type!==V.Fragment&&(r.ref=i?_f(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var Rni=Symbol("radix.slottable");function Nni(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Rni}function Gni(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function Lni(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var Tz="Dialog",[pEe,fEe]=uw(Tz),[Uni,qw]=pEe(Tz),yEe=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=V.useRef(null),a=V.useRef(null),[g,c]=G_({prop:i,defaultProp:n??!1,onChange:o,caller:Tz});return W.jsx(Uni,{scope:A,triggerRef:r,contentRef:a,contentId:qE(),titleId:qE(),descriptionId:qE(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};yEe.displayName=Tz;var mEe="DialogTrigger",wEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(mEe,e),o=RI(A,n.triggerRef);return W.jsx(Ag.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":NmA(n.open),...i,ref:o,onClick:Vn(t.onClick,n.onOpenToggle)})});wEe.displayName=mEe;var MmA="DialogPortal",[Hni,DEe]=pEe(MmA,{forceMount:void 0}),SEe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=qw(MmA,A);return W.jsx(Hni,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(q0,{present:e||o.open,children:W.jsx($9,{asChild:!0,container:n,children:s})}))})};SEe.displayName=MmA;var Pz="DialogOverlay",bEe=V.forwardRef((t,A)=>{const e=DEe(Pz,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=qw(Pz,t.__scopeDialog);return o.modal?W.jsx(q0,{present:i||o.open,children:W.jsx(Jni,{...n,ref:A})}):null});bEe.displayName=Pz;var Yni=Fni("DialogOverlay.RemoveScroll"),Jni=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(Pz,e);return W.jsx(rj,{as:Yni,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(Ag.div,{"data-state":NmA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),TM="DialogContent",xEe=V.forwardRef((t,A)=>{const e=DEe(TM,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=qw(TM,t.__scopeDialog);return W.jsx(q0,{present:i||o.open,children:o.modal?W.jsx(Tni,{...n,ref:A}):W.jsx(Pni,{...n,ref:A})})});xEe.displayName=TM;var Tni=V.forwardRef((t,A)=>{const e=qw(TM,t.__scopeDialog),i=V.useRef(null),n=RI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return VfA(o)},[]),W.jsx(_Ee,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vn(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Vn(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Vn(t.onFocusOutside,o=>o.preventDefault())})}),Pni=V.forwardRef((t,A)=>{const e=qw(TM,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(_Ee,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),_Ee=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=qw(TM,e),a=V.useRef(null),g=RI(A,a);return kfA(),W.jsxs(W.Fragment,{children:[W.jsx(Y9,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(KJ,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":NmA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(qni,{titleId:r.titleId}),W.jsx(Wni,{contentRef:a,descriptionId:r.descriptionId})]})]})}),RmA="DialogTitle",kEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(RmA,e);return W.jsx(Ag.h2,{id:n.titleId,...i,ref:A})});kEe.displayName=RmA;var vEe="DialogDescription",FEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(vEe,e);return W.jsx(Ag.p,{id:n.descriptionId,...i,ref:A})});FEe.displayName=vEe;var MEe="DialogClose",REe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(MEe,e);return W.jsx(Ag.button,{type:"button",...i,ref:A,onClick:Vn(t.onClick,()=>n.onOpenChange(!1))})});REe.displayName=MEe;function NmA(t){return t?"open":"closed"}var NEe="DialogTitleWarning",[Kni,GEe]=Uat(NEe,{contentName:TM,titleName:RmA,docsSlug:"dialog"}),qni=({titleId:t})=>{const A=GEe(NEe),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5692
+ `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&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:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},EEe=t=>t.activeSubSolver?[t,...EEe(t.activeSubSolver)]:[t],lni=({solver:t})=>{const A=EEe(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(Ini,{solver:e})]},e.constructor.name))})},Bni=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(lni,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,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:g,disabled:t.solved||t.failed||o,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:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,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"}),B&&W.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:C})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Cni=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Qni=(t,A)=>{const i=t.pipelineDef[A].solverName,n=Cni(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},hni=({status:t})=>{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[t]}`,children:t})},Eni=({progress:t})=>{if(t===0)return null;const A=Math.round(t*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,"%"]})]})},uni=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),dni=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=uni(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},FmA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(FmA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=FmA(i));return A},pni=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=FmA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},fni=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>Qni(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):pni(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[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:"Step"}),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:i.map(r=>W.jsxs("tr",{className:`border-b border-gray-100 ${r.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",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),W.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.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:r.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(hni,{status:r.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(Eni,{progress:r.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(dni,{stats:r.stats})}),W.jsx("td",{className:"px-4 py-2",children:r.solverInstance?W.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.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})]},r.name))})]})})]})},yni=class extends Qn.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function mni({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>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-${E}`)),e.map((h,E)=>W.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>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-${E}`)),A.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var wni=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=V.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);V.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return W.jsxs("div",{children:[W.jsx(Bni,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(yni,{fallback:W.jsx(mni,{graphics:s}),children:W.jsx(cni,{graphics:s})}),a&&W.jsx(fni,{solver:t,onStepUntilPhase:g})]})};const Dni=()=>{V.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},Sni=t=>t.toLowerCase().includes("pack")?Cqt:t.toLowerCase().includes("rout")?dqt:$Kt,bni=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);Dni();const i=V.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=V.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=V.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=WrA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(WrA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.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:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return W.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const c=Sni(a.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(c,{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:a.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?W.jsx(wm,{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(wni,{solver:s.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]})]}),s.error&&W.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.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 ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),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"})})})]})},uEe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{qW.captureException(i)}catch{}}},[t,A]),V.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{qW.captureException(n,{error_type:i.type})}catch{}}},[e])},dEe="0.0.1741",xni={version:dEe},Jz=k4A()(v4A(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),_ni=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=aG("eval-version-selection",null),g=Jz(B=>B.setLastRunEvalVersion),c=Jz(B=>B.lastRunEvalVersion);return V.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(B=>B.json()).then(B=>{if(Array.isArray(B?.versions)){let C=[...B.versions];B.tags?.latest&&(n(B.tags.latest),C=C.filter(Q=>Q!==B.tags.latest)),e(C)}}).catch(()=>{})},[t]),V.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:V.useMemo(()=>A.filter(B=>B.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:c,search:o,setSearch:s,selectVersion:B=>{a(B),s("")}}},kni=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=t.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),c=I=>{I.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:W.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[W.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),W.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:I=>r(I.target.value),onKeyDown:c}),W.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(I=>W.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===I?"bg-blue-50":""}`,onClick:()=>o(I),children:I},I)),g&&W.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),W.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},vni=t=>{const A=V.useRef(null),e=MI(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function Fni(t){const A=Mni(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(Nni);if(a){const g=a.props.children,c=r.map(I=>I===a?V.Children.count(g)>1?V.Children.only(null):V.isValidElement(g)?g.props.children:null:I);return W.jsx(A,{...s,ref:n,children:V.isValidElement(g)?V.cloneElement(g,void 0,c):null})}return W.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function Mni(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=Lni(n),r=Gni(o,n.props);return n.type!==V.Fragment&&(r.ref=i?_f(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var Rni=Symbol("radix.slottable");function Nni(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Rni}function Gni(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function Lni(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var Tz="Dialog",[pEe,fEe]=uw(Tz),[Uni,qw]=pEe(Tz),yEe=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=V.useRef(null),a=V.useRef(null),[g,c]=G_({prop:i,defaultProp:n??!1,onChange:o,caller:Tz});return W.jsx(Uni,{scope:A,triggerRef:r,contentRef:a,contentId:qE(),titleId:qE(),descriptionId:qE(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};yEe.displayName=Tz;var mEe="DialogTrigger",wEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(mEe,e),o=RI(A,n.triggerRef);return W.jsx(Ag.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":NmA(n.open),...i,ref:o,onClick:Vn(t.onClick,n.onOpenToggle)})});wEe.displayName=mEe;var MmA="DialogPortal",[Hni,DEe]=pEe(MmA,{forceMount:void 0}),SEe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=qw(MmA,A);return W.jsx(Hni,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(q0,{present:e||o.open,children:W.jsx($9,{asChild:!0,container:n,children:s})}))})};SEe.displayName=MmA;var Pz="DialogOverlay",bEe=V.forwardRef((t,A)=>{const e=DEe(Pz,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=qw(Pz,t.__scopeDialog);return o.modal?W.jsx(q0,{present:i||o.open,children:W.jsx(Jni,{...n,ref:A})}):null});bEe.displayName=Pz;var Yni=Fni("DialogOverlay.RemoveScroll"),Jni=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(Pz,e);return W.jsx(rj,{as:Yni,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(Ag.div,{"data-state":NmA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),TM="DialogContent",xEe=V.forwardRef((t,A)=>{const e=DEe(TM,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=qw(TM,t.__scopeDialog);return W.jsx(q0,{present:i||o.open,children:o.modal?W.jsx(Tni,{...n,ref:A}):W.jsx(Pni,{...n,ref:A})})});xEe.displayName=TM;var Tni=V.forwardRef((t,A)=>{const e=qw(TM,t.__scopeDialog),i=V.useRef(null),n=RI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return VfA(o)},[]),W.jsx(_Ee,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vn(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Vn(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Vn(t.onFocusOutside,o=>o.preventDefault())})}),Pni=V.forwardRef((t,A)=>{const e=qw(TM,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(_Ee,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),_Ee=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=qw(TM,e),a=V.useRef(null),g=RI(A,a);return kfA(),W.jsxs(W.Fragment,{children:[W.jsx(Y9,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(KJ,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":NmA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(qni,{titleId:r.titleId}),W.jsx(Wni,{contentRef:a,descriptionId:r.descriptionId})]})]})}),RmA="DialogTitle",kEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(RmA,e);return W.jsx(Ag.h2,{id:n.titleId,...i,ref:A})});kEe.displayName=RmA;var vEe="DialogDescription",FEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(vEe,e);return W.jsx(Ag.p,{id:n.descriptionId,...i,ref:A})});FEe.displayName=vEe;var MEe="DialogClose",REe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=qw(MEe,e);return W.jsx(Ag.button,{type:"button",...i,ref:A,onClick:Vn(t.onClick,()=>n.onOpenChange(!1))})});REe.displayName=MEe;function NmA(t){return t?"open":"closed"}var NEe="DialogTitleWarning",[Kni,GEe]=Uat(NEe,{contentName:TM,titleName:RmA,docsSlug:"dialog"}),qni=({titleId:t})=>{const A=GEe(NEe),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5693
5693
 
5694
5694
  If you want to hide the \`${A.titleName}\`, you can wrap it with our VisuallyHidden component.
5695
5695