@tscircuit/runframe 0.0.670 → 0.0.672

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.
@@ -1261,7 +1261,7 @@ var useErrorTelemetry = ({
1261
1261
  };
1262
1262
 
1263
1263
  // package.json
1264
- var version = "0.0.669";
1264
+ var version = "0.0.671";
1265
1265
 
1266
1266
  // lib/components/RunFrame/runner-store/use-runner-store.ts
1267
1267
  import { create } from "zustand";
package/dist/preview.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  linkify,
9
9
  useOrderDialog,
10
10
  useOrderDialogCli
11
- } from "./chunk-EVHC54FA.js";
11
+ } from "./chunk-7NMCDFO5.js";
12
12
  export {
13
13
  BomTable,
14
14
  CadViewer,
package/dist/runner.js CHANGED
@@ -37,7 +37,7 @@ import {
37
37
  useOrderDialogCli,
38
38
  useRunFrameStore,
39
39
  useRunnerStore
40
- } from "./chunk-EVHC54FA.js";
40
+ } from "./chunk-7NMCDFO5.js";
41
41
 
42
42
  // lib/components/RunFrame/RunFrame.tsx
43
43
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";
@@ -13074,13 +13074,13 @@ ${l.join(`
13074
13074
  `)!==-1&&(i=i.replace(/\r\n/g,`
13075
13075
  `)),i.indexOf(`\\
13076
13076
  `)!==-1&&(i=i.replace(/\\\n/g,""));const t=i.split(`
13077
- `);let n="",r="",a=0,o=[];const s=typeof"".trimLeft=="function";for(let u=0,A=t.length;u<A;u++)if(n=t[u],n=s?n.trimLeft():n.trim(),a=n.length,a!==0&&(r=n.charAt(0),r!=="#"))if(r==="v"){const f=n.split(/\s+/);switch(f[0]){case"v":e.vertices.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),f.length>=7?e.colors.push(parseFloat(f[4]),parseFloat(f[5]),parseFloat(f[6])):e.colors.push(void 0,void 0,void 0);break;case"vn":e.normals.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3]));break;case"vt":e.uvs.push(parseFloat(f[1]),parseFloat(f[2]));break}}else if(r==="f"){const p=n.substr(1).trim().split(/\s+/),v=[];for(let B=0,b=p.length;B<b;B++){const w=p[B];if(w.length>0){const R=w.split("/");v.push(R)}}const x=v[0];for(let B=1,b=v.length-1;B<b;B++){const w=v[B],R=v[B+1];e.addFace(x[0],w[0],R[0],x[1],w[1],R[1],x[2],w[2],R[2])}}else if(r==="l"){const f=n.substring(1).trim().split(" ");let p=[];const v=[];if(n.indexOf("/")===-1)p=f;else for(let x=0,B=f.length;x<B;x++){const b=f[x].split("/");b[0]!==""&&p.push(b[0]),b[1]!==""&&v.push(b[1])}e.addLineGeometry(p,v)}else if(r==="p"){const p=n.substr(1).trim().split(" ");e.addPointGeometry(p)}else if((o=nHt.exec(n))!==null){const f=(" "+o[0].substr(1).trim()).substr(1);e.startObject(f)}else if(rHt.test(n))e.object.startMaterial(n.substring(7).trim(),e.materialLibraries);else if(iHt.test(n))e.materialLibraries.push(n.substring(7).trim());else if(aHt.test(n))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(r==="s"){if(o=n.split(" "),o.length>1){const p=o[1].trim().toLowerCase();e.object.smooth=p!=="0"&&p!=="off"}else e.object.smooth=!0;const f=e.object.currentMaterial();f&&(f.smooth=e.object.smooth)}else{if(n==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+n+'"')}e.finalize();const l=new O2;if(l.materialLibraries=[].concat(e.materialLibraries),!(e.objects.length===1&&e.objects[0].geometry.vertices.length===0)===!0)for(let u=0,A=e.objects.length;u<A;u++){const f=e.objects[u],p=f.geometry,v=f.materials,x=p.type==="Line",B=p.type==="Points";let b=!1;if(p.vertices.length===0)continue;const w=new Bp;w.setAttribute("position",new xA(p.vertices,3)),p.normals.length>0&&w.setAttribute("normal",new xA(p.normals,3)),p.colors.length>0&&(b=!0,w.setAttribute("color",new xA(p.colors,3))),p.hasUVIndices===!0&&w.setAttribute("uv",new xA(p.uvs,2));const R=[];for(let V=0,Y=v.length;V<Y;V++){const J=v[V],q=J.name+"_"+J.smooth+"_"+b;let $=e.materials[q];if(this.materials!==null){if($=this.materials.create(J.name),x&&$&&!($ instanceof f_)){const X=new f_;z_.prototype.copy.call(X,$),X.color.copy($.color),$=X}else if(B&&$&&!($ instanceof j2)){const X=new j2({size:10,sizeAttenuation:!1});z_.prototype.copy.call(X,$),X.color.copy($.color),X.map=$.map,$=X}}$===void 0&&(x?$=new f_:B?$=new j2({size:1,sizeAttenuation:!1}):$=new pF,$.name=J.name,$.flatShading=!J.smooth,$.vertexColors=b,e.materials[q]=$),R.push($)}let G;if(R.length>1){for(let V=0,Y=v.length;V<Y;V++){const J=v[V];w.addGroup(J.groupStart,J.groupCount,V)}x?G=new Db(w,R):B?G=new BN(w,R):G=new RC(w,R)}else x?G=new Db(w,R[0]):B?G=new BN(w,R[0]):G=new RC(w,R[0]);G.name=f.name,l.add(G)}else if(e.vertices.length>0){const u=new j2({size:1,sizeAttenuation:!1}),A=new Bp;A.setAttribute("position",new xA(e.vertices,3)),e.colors.length>0&&e.colors[0]!==void 0&&(A.setAttribute("color",new xA(e.colors,3)),u.vertexColors=!0);const f=new BN(A,u);l.add(f)}return l}};typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function lHt(i){const[e,t]=vt.useState(null);return vt.useEffect(()=>{if(!i)return;const n=window.TSCIRCUIT_OBJ_LOADER_CACHE;let r=!1;async function a(){var s;try{const l=await fetch(i);if(!l.ok)throw new Error(`Failed to fetch "${i}": ${l.status} ${l.statusText}`);const c=await l.text(),u=(s=c.match(/newmtl[\s\S]*?endmtl/g))==null?void 0:s.join(`
13078
- `).replace(/d 0\./g,"d 1."),A=c.replace(/newmtl[\s\S]*?endmtl/g,""),f=new eHt;f.setMaterialOptions({invertTrProperty:!0});const p=f.parse(u.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"test.mtl"),v=new sHt;return v.setMaterials(p),v.parse(A)}catch(l){return l}}function o(){if(n.has(i)){const l=n.get(i);return l.result?Promise.resolve(l.result.clone()):l.promise.then(c=>c instanceof Error?c:c.clone())}const s=a().then(l=>(l instanceof Error||n.set(i,{...n.get(i),result:l}),l));return n.set(i,{promise:s,result:null}),s}return o().then(s=>{r||t(s)}).catch(s=>{console.error(s)}),()=>{r=!0}},[i]),e}function cHt({url:i,position:e,rotation:t,onHover:n,onUnhover:r,isHovered:a}){const o=lHt(i);if(!o)return ft.jsx(bO,{isHovered:a,onHover:n,onUnhover:r,children:ft.jsxs("mesh",{position:e,children:[ft.jsx("boxGeometry",{args:[.5,.5,.5]}),ft.jsx("meshStandardMaterial",{transparent:!0,color:"red",opacity:.25})]})});if(o instanceof Error)throw o;return ft.jsx(bO,{isHovered:a,onHover:n,onUnhover:r,children:ft.jsx("primitive",{rotation:t,position:e,object:o})})}var uHt=A1(rLe()),lLe=({jscadPlan:i,positionOffset:e,rotationOffset:t,onHover:n,onUnhover:r,isHovered:a})=>{const{threeGeom:o,material:s}=vt.useMemo(()=>{const l=RIe.executeJscadOperations(uHt.default,i),c=qdt(l),u=new hD({vertexColors:!0,side:Fx});return{threeGeom:c,material:u}},[i]);return vt.useMemo(()=>{if(a){const l=new Tc(s.color.getHex());s.emissive.copy(l),s.emissive.setRGB(0,0,1),s.emissiveIntensity=.2}else s.emissiveIntensity=0},[a,s]),o?ft.jsx(bO,{isHovered:a,onHover:n,onUnhover:r,position:e,children:ft.jsx("mesh",{geometry:o,material:s,position:e,rotation:t})}):null},{createJSCADRoot:AHt}=alt(RIe.jscadPlanner),dHt=({positionOffset:i,footprint:e,rotationOffset:t,onHover:n,onUnhover:r,isHovered:a})=>{const o=vt.useMemo(()=>{if(!e)return null;const s=[];return AHt(s).render(ft.jsx(X1t,{footprint:e})),s},[e]);return o?ft.jsx(ft.Fragment,{children:o.map((s,l)=>ft.jsx(lLe,{positionOffset:i,rotationOffset:t,jscadPlan:s,onHover:n,onUnhover:r,isHovered:a},l))}):null},fHt=(...i)=>i,cLe=({cad_component:i,circuitJson:e})=>{const[t,n]=vt.useState(!1),[r,a]=vt.useState(null),o=vt.useCallback(f=>{f!=null&&f.mousePosition?(n(!0),a(f.mousePosition)):(n(!1),a(null))},[]),s=vt.useCallback(()=>{n(!1),a(null)},[]),l=vt.useMemo(()=>{var f;return(f=Zy(e).source_component.getUsing({source_component_id:i.source_component_id}))==null?void 0:f.name},[e,i.source_component_id]),c=i.model_obj_url??i.model_stl_url,u=i.rotation?fHt(i.rotation.x*Math.PI/180,i.rotation.y*Math.PI/180,i.rotation.z*Math.PI/180):void 0;let A=null;return c?A=ft.jsx(cHt,{url:c,position:i.position?[i.position.x,i.position.y,i.position.z]:void 0,rotation:u,onHover:o,onUnhover:s,isHovered:t},i.cad_component_id):i.model_jscad?A=ft.jsx(lLe,{jscadPlan:i.model_jscad,rotationOffset:u,onHover:o,onUnhover:s,isHovered:t},i.cad_component_id):i.footprinter_string&&(A=ft.jsx(dHt,{positionOffset:i.position?[i.position.x,i.position.y,i.position.z]:void 0,rotationOffset:u,footprint:i.footprinter_string,onHover:o,onUnhover:s,isHovered:t})),ft.jsxs(ft.Fragment,{children:[A,t&&r?ft.jsx(Z5e,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(50%, 50%, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:l??"<unknown>"}):null]})},hHt={version:"0.0.297"};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new wB(0,0,0));function pHt(i,e){const t=new rx().setFromEuler(new wB(i.x,i.y,i.z)),n=new ti(0,0,1);return n.applyQuaternion(t),n.multiplyScalar(e)}var gHt=({})=>{const i=vt.useRef();return vt.useRef({lastRotation:new wB}),qT((e,t)=>{if(!i.current)return;const n=window.TSCI_MAIN_CAMERA_ROTATION,r=pHt(n,2);e.camera.position.copy(r),e.camera.lookAt(0,0,0)}),ft.jsxs("mesh",{ref:i,rotation:[Math.PI/2,0,0],children:[ft.jsx("boxGeometry",{args:[1,1,1]}),ft.jsx("meshStandardMaterial",{color:"white"}),ft.jsx(xM,{position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),ft.jsx(xM,{position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),ft.jsx(xM,{position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),ft.jsx(xM,{position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),ft.jsx(xM,{position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),ft.jsx(xM,{position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"}),ft.jsx("lineSegments",{args:[new ij(new A9(1,1,1))],material:new f_({color:0,linewidth:2})})]})},mHt=()=>(qT(({camera:i})=>{window.TSCI_MAIN_CAMERA_ROTATION=i.rotation}),ft.jsx(ft.Fragment,{})),uLe=vt.forwardRef(({children:i,initialCameraPosition:e=[5,5,5],autoRotateDisabled:t,clickToInteractEnabled:n=!1,boardDimensions:r},a)=>{const[o,s]=vt.useState(!n),l=vt.useMemo(()=>{if(!r)return 10;const c=r.width??0,u=r.height??0,f=Math.max(c,u)*1.5;return f>10?f:10},[r]);return ft.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ft.jsx("div",{style:{position:"absolute",top:0,left:0,width:120,height:120},children:ft.jsxs(K5e,{camera:{up:[0,0,1],position:[1,1,1]},style:{zIndex:10},children:[ft.jsx("ambientLight",{intensity:Math.PI/2}),ft.jsx(gHt,{})]})}),ft.jsxs(K5e,{scene:{up:[0,0,1]},camera:{up:[0,0,1],position:e},children:[ft.jsx(mHt,{}),o&&ft.jsx(cxt,{autoRotate:!t,autoRotateSpeed:1}),ft.jsx("ambientLight",{intensity:Math.PI/2}),ft.jsx("pointLight",{position:[-10,-10,10],decay:0,intensity:Math.PI/4}),ft.jsx(Axt,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:1,sectionSize:l,args:[l,l]}),ft.jsx("object3D",{ref:a,children:i})]}),ft.jsxs("div",{style:{position:"absolute",right:24,bottom:24,fontFamily:"sans-serif",color:"white",WebkitTextStroke:"0.5px rgba(0, 0, 0, 0.5)",fontSize:11},children:["@",hHt.version]}),n&&!o&&ft.jsx("button",{type:"button",onClick:()=>s(!0),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&s(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center"},children:ft.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:"Click to Interact"})})]})}),ALe=i=>vt.useMemo(()=>{if(!i)return[];const e=new VGt;return e.add(i),e.render(),e.getCircuitJson()},[i]);function yHt(i){return new Promise((e,t)=>{const n=new FileReader;n.onload=()=>{e(n.result)},n.onerror=t,n.readAsDataURL(i)})}var vHt=i=>{const[e,t]=vt.useState([]),[n,r]=vt.useState(!0);return vt.useEffect(()=>{if(!i)return;(async()=>{r(!0);const s=(Array.isArray(i)?i:[i]).map(async l=>{const c=r6t.serialize({binary:!0},[l]),u=new Blob(c);return{stlUrl:await yHt(u),color:l.color}});try{const l=await Promise.all(s);t(l)}catch(l){console.error("Error generating STLs:",l),t([])}finally{r(!1)}})()},[i]),{stls:e,loading:n}},CHt=A1(_R()),IHt=A1(N4()),pv=.01,__={copper:[.9,.6,.2],fr4Green:[5/255,163/255,46/255],fr4GreenSolderWithMask:[0/255,152/255,19/255],fr1Copper:[.8,.4,.2],fr1CopperSolderWithMask:[.9,.6,.2]},_w=.001,mQ=32,EHt=.035,SO=50,Jce={fr1:__.fr1Copper,fr4:__.fr4Green},dLe={fr1:__.fr1CopperSolderWithMask,fr4:__.fr4GreenSolderWithMask},_Ht=A1(EO()),xHt=A1(_R()),BHt=A1(BO()),fLe=i=>{let e=0;for(let n=0;n<i.length;n++){const r=(n+1)%i.length;e+=i[n][0]*i[r][1],e-=i[r][0]*i[n][1]}return e/2<=0},hLe=(i,e=1.2)=>{const{outline:t}=i;let n=t.map(o=>[o.x,o.y]);fLe(n)&&(n=n.reverse());const r=(0,xHt.polygon)({points:n});let a=(0,_Ht.extrudeLinear)({height:e},r);return a=(0,BHt.translate)([0,0,-e/2],a),a},bHt=i=>{const e=Zy(i).pcb_board.list()[0];if(!e)return console.warn("No pcb_board found for simplified geometry"),[];let t;const n=1.2;e.outline&&e.outline.length>0?t=hLe({outline:e.outline},n):t=(0,CHt.cuboid)({size:[e.width,e.height,n],center:[e.center.x,e.center.y,0]});const r=Jce[e.material]??__.fr4Green;return[(0,IHt.colorize)(r,t)]},GM=A1(BO()),jx=A1(_R()),xR=A1(N4()),LM=A1(zce()),kC=A1(_R()),QO=A1(N4()),cb=A1(zce()),eE=.05,pLe=(i,e)=>{if(i.shape||(i.shape="circle"),i.shape==="circle")return(0,QO.colorize)(__.copper,(0,cb.subtract)((0,cb.union)((0,kC.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2,height:e.pcbThickness}),(0,kC.cylinder)({center:[i.x,i.y,e.pcbThickness/2+eE/2+pv],radius:i.outer_diameter/2,height:eE}),(0,kC.cylinder)({center:[i.x,i.y,-e.pcbThickness/2-eE/2-pv],radius:i.outer_diameter/2,height:eE})),(0,kC.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2-pv,height:1.5})));if(i.shape==="circular_hole_with_rect_pad"){const t=i.rect_pad_width||i.hole_diameter,n=i.rect_pad_height||i.hole_diameter;return(0,QO.colorize)(__.copper,(0,cb.subtract)((0,cb.union)((0,kC.cuboid)({center:[i.x,i.y,1.2/2],size:[t,n,eE]}),(0,kC.cuboid)({center:[i.x,i.y,-1.2/2],size:[t,n,eE]}),(0,kC.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2,height:1.2})),(0,kC.cylinder)({center:[i.x,i.y,0],radius:Math.max(i.hole_diameter/2-pv,.01),height:1.5})))}if(i.shape==="pill"){const t=i.hole_height>i.hole_width,n=t?i.hole_height:i.hole_width,r=t?i.hole_width:i.hole_height,a=t?i.outer_height||r+.2:i.outer_width||n+.2,o=t?i.outer_width||n+.2:i.outer_height||r+.2,s=r/2,l=o/2,c=Math.abs(n-r),u=Math.abs(a-o),A=(0,kC.cuboid)({center:[i.x,i.y,0],size:t?[r,c,e.pcbThickness]:[c,r,e.pcbThickness]}),f=(0,kC.cylinder)({center:t?[i.x,i.y-c/2,0]:[i.x-c/2,i.y,0],radius:s,height:e.pcbThickness}),p=(0,kC.cylinder)({center:t?[i.x,i.y+c/2,0]:[i.x+c/2,i.y,0],radius:s,height:e.pcbThickness}),v=(0,cb.union)(A,f,p),x=e.pcbThickness/2+eE/2+pv,B=(0,kC.cuboid)({center:[i.x,i.y,x],size:t?[o,u,eE]:[u,o,eE]}),b=(0,kC.cylinder)({center:t?[i.x,i.y-u/2,x]:[i.x-u/2,i.y,x],radius:l,height:eE}),w=(0,kC.cylinder)({center:t?[i.x,i.y+u/2,x]:[i.x+u/2,i.y,x],radius:l,height:eE}),R=(0,cb.union)(B,b,w),G=-e.pcbThickness/2-eE/2-pv,V=(0,kC.cuboid)({center:[i.x,i.y,G],size:t?[o,u,eE]:[u,o,eE]}),Y=(0,kC.cylinder)({center:t?[i.x,i.y-u/2,G]:[i.x-u/2,i.y,G],radius:l,height:eE}),J=(0,kC.cylinder)({center:t?[i.x,i.y+u/2,G]:[i.x+u/2,i.y,G],radius:l,height:eE}),q=(0,cb.union)(V,Y,J),$=(0,kC.cuboid)({center:[i.x,i.y,0],size:t?[r-2*pv,c,e.pcbThickness+2*pv]:[c,r-2*pv,e.pcbThickness+2*pv]}),X=(0,kC.cylinder)({center:t?[i.x,i.y-c/2,0]:[i.x-c/2,i.y,0],radius:s-pv,height:e.pcbThickness+2*pv}),de=(0,kC.cylinder)({center:t?[i.x,i.y+c/2,0]:[i.x+c/2,i.y,0],radius:s-pv,height:e.pcbThickness+2*pv}),ue=(0,cb.union)($,X,de);return(0,QO.colorize)(__.copper,(0,cb.subtract)((0,cb.union)(v,R,q),ue))}if(i.shape==="pill_hole_with_rect_pad"){const t=i.hole_height>i.hole_width,n=t?i.hole_height:i.hole_width,r=t?i.hole_width:i.hole_height,a=r/2,o=Math.abs(n-r),s=i.rect_pad_width||n+.2,l=i.rect_pad_height||r+.2,c=(0,kC.cuboid)({center:[i.x,i.y,0],size:t?[r,o,1.2]:[o,r,1.2]}),u=(0,kC.cylinder)({center:t?[i.x,i.y-o/2,0]:[i.x-o/2,i.y,0],radius:a,height:1.2}),A=(0,kC.cylinder)({center:t?[i.x,i.y+o/2,0]:[i.x+o/2,i.y,0],radius:a,height:1.2}),f=(0,kC.cuboid)({center:[i.x,i.y,1.2/2],size:[s,l,eE]}),p=(0,kC.cuboid)({center:[i.x,i.y,-1.2/2],size:[s,l,eE]}),v=(0,cb.union)((0,kC.cuboid)({center:[i.x,i.y,0],size:t?[r-eE,o,1.5]:[o,r-eE,1.5]}),(0,kC.cylinder)({center:t?[i.x,i.y-o/2,0]:[i.x-o/2,i.y,0],radius:a-eE,height:1.5}),(0,kC.cylinder)({center:t?[i.x,i.y+o/2,0]:[i.x+o/2,i.y,0],radius:a-eE,height:1.5}));return(0,QO.colorize)(__.copper,(0,cb.subtract)((0,cb.union)(c,u,A,f,p),v))}else throw new Error(`Unsupported plated hole shape: ${i.shape}`)},wO=A1(EO()),gLe=A1(Yce()),SHt=A1(Pce());function mLe(i,e){return Array.isArray(e)?[i.a*e[0]+i.c*e[1]+i.e,i.b*e[0]+i.d*e[1]+i.f]:{x:i.a*e.x+i.c*e.y+i.e,y:i.b*e.x+i.d*e.y+i.f}}function O9(i,e=0){return{a:1,c:0,e:i,b:0,d:1,f:e}}function yLe(...i){i=Array.isArray(i[0])?i[0]:i;const e=(t,n)=>({a:t.a*n.a+t.c*n.b,c:t.a*n.c+t.c*n.d,e:t.a*n.e+t.c*n.f+t.e,b:t.b*n.a+t.d*n.b,d:t.b*n.c+t.d*n.d,f:t.b*n.e+t.d*n.f+t.f});switch(i.length){case 0:throw new Error("no matrices provided");case 1:return i[0];case 2:return e(i[0],i[1]);default:{const[t,n,...r]=i,a=e(t,n);return yLe(a,...r)}}}function vLe(...i){return yLe(...i)}var{cos:QHt,sin:wHt}=Math;function CLe(i,e,t){const n=QHt(i),r=wHt(i);return{a:n,c:-r,e:0,b:r,d:n,f:0}}function MHt(i,e){function t(){this.constructor=i}t.prototype=e.prototype,i.prototype=new t}function MO(i,e,t,n){var r=Error.call(this,i);return Object.setPrototypeOf&&Object.setPrototypeOf(r,MO.prototype),r.expected=e,r.found=t,r.location=n,r.name="SyntaxError",r}MHt(MO,Error);function Zce(i,e,t){return t=t||" ",i.length>e?i:(e-=i.length,t+=t.repeat(e),i+t.slice(0,e))}MO.prototype.format=function(i){var e="Error: "+this.message;if(this.location){var t=null,n;for(n=0;n<i.length;n++)if(i[n].source===this.location.source){t=i[n].text.split(/\r\n|\n|\r/g);break}var r=this.location.start,a=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(r):r,o=this.location.source+":"+a.line+":"+a.column;if(t){var s=this.location.end,l=Zce("",a.line.toString().length," "),c=t[r.line-1],u=r.line===s.line?s.column:c.length+1,A=u-r.column||1;e+=`
13077
+ `);let n="",r="",a=0,o=[];const s=typeof"".trimLeft=="function";for(let u=0,A=t.length;u<A;u++)if(n=t[u],n=s?n.trimLeft():n.trim(),a=n.length,a!==0&&(r=n.charAt(0),r!=="#"))if(r==="v"){const f=n.split(/\s+/);switch(f[0]){case"v":e.vertices.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),f.length>=7?e.colors.push(parseFloat(f[4]),parseFloat(f[5]),parseFloat(f[6])):e.colors.push(void 0,void 0,void 0);break;case"vn":e.normals.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3]));break;case"vt":e.uvs.push(parseFloat(f[1]),parseFloat(f[2]));break}}else if(r==="f"){const p=n.substr(1).trim().split(/\s+/),v=[];for(let B=0,b=p.length;B<b;B++){const w=p[B];if(w.length>0){const R=w.split("/");v.push(R)}}const x=v[0];for(let B=1,b=v.length-1;B<b;B++){const w=v[B],R=v[B+1];e.addFace(x[0],w[0],R[0],x[1],w[1],R[1],x[2],w[2],R[2])}}else if(r==="l"){const f=n.substring(1).trim().split(" ");let p=[];const v=[];if(n.indexOf("/")===-1)p=f;else for(let x=0,B=f.length;x<B;x++){const b=f[x].split("/");b[0]!==""&&p.push(b[0]),b[1]!==""&&v.push(b[1])}e.addLineGeometry(p,v)}else if(r==="p"){const p=n.substr(1).trim().split(" ");e.addPointGeometry(p)}else if((o=nHt.exec(n))!==null){const f=(" "+o[0].substr(1).trim()).substr(1);e.startObject(f)}else if(rHt.test(n))e.object.startMaterial(n.substring(7).trim(),e.materialLibraries);else if(iHt.test(n))e.materialLibraries.push(n.substring(7).trim());else if(aHt.test(n))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(r==="s"){if(o=n.split(" "),o.length>1){const p=o[1].trim().toLowerCase();e.object.smooth=p!=="0"&&p!=="off"}else e.object.smooth=!0;const f=e.object.currentMaterial();f&&(f.smooth=e.object.smooth)}else{if(n==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+n+'"')}e.finalize();const l=new O2;if(l.materialLibraries=[].concat(e.materialLibraries),!(e.objects.length===1&&e.objects[0].geometry.vertices.length===0)===!0)for(let u=0,A=e.objects.length;u<A;u++){const f=e.objects[u],p=f.geometry,v=f.materials,x=p.type==="Line",B=p.type==="Points";let b=!1;if(p.vertices.length===0)continue;const w=new Bp;w.setAttribute("position",new xA(p.vertices,3)),p.normals.length>0&&w.setAttribute("normal",new xA(p.normals,3)),p.colors.length>0&&(b=!0,w.setAttribute("color",new xA(p.colors,3))),p.hasUVIndices===!0&&w.setAttribute("uv",new xA(p.uvs,2));const R=[];for(let V=0,Y=v.length;V<Y;V++){const J=v[V],q=J.name+"_"+J.smooth+"_"+b;let $=e.materials[q];if(this.materials!==null){if($=this.materials.create(J.name),x&&$&&!($ instanceof f_)){const X=new f_;z_.prototype.copy.call(X,$),X.color.copy($.color),$=X}else if(B&&$&&!($ instanceof j2)){const X=new j2({size:10,sizeAttenuation:!1});z_.prototype.copy.call(X,$),X.color.copy($.color),X.map=$.map,$=X}}$===void 0&&(x?$=new f_:B?$=new j2({size:1,sizeAttenuation:!1}):$=new pF,$.name=J.name,$.flatShading=!J.smooth,$.vertexColors=b,e.materials[q]=$),R.push($)}let G;if(R.length>1){for(let V=0,Y=v.length;V<Y;V++){const J=v[V];w.addGroup(J.groupStart,J.groupCount,V)}x?G=new Db(w,R):B?G=new BN(w,R):G=new RC(w,R)}else x?G=new Db(w,R[0]):B?G=new BN(w,R[0]):G=new RC(w,R[0]);G.name=f.name,l.add(G)}else if(e.vertices.length>0){const u=new j2({size:1,sizeAttenuation:!1}),A=new Bp;A.setAttribute("position",new xA(e.vertices,3)),e.colors.length>0&&e.colors[0]!==void 0&&(A.setAttribute("color",new xA(e.colors,3)),u.vertexColors=!0);const f=new BN(A,u);l.add(f)}return l}};typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function lHt(i){const[e,t]=vt.useState(null);return vt.useEffect(()=>{if(!i)return;const n=i.replace(/&cachebust_origin=$/,""),r=window.TSCIRCUIT_OBJ_LOADER_CACHE;let a=!1;async function o(){var l;try{const c=await fetch(n);if(!c.ok)throw new Error(`Failed to fetch "${n}": ${c.status} ${c.statusText}`);const u=await c.text(),A=(l=u.match(/newmtl[\s\S]*?endmtl/g))==null?void 0:l.join(`
13078
+ `).replace(/d 0\./g,"d 1."),f=u.replace(/newmtl[\s\S]*?endmtl/g,""),p=new eHt;p.setMaterialOptions({invertTrProperty:!0});const v=p.parse(A.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"test.mtl"),x=new sHt;return x.setMaterials(v),x.parse(f)}catch(c){return c}}function s(){if(r.has(n)){const c=r.get(n);return c.result?Promise.resolve(c.result.clone()):c.promise.then(u=>u instanceof Error?u:u.clone())}const l=o().then(c=>(c instanceof Error||r.set(n,{...r.get(n),result:c}),c));return r.set(n,{promise:l,result:null}),l}return s().then(l=>{a||t(l)}).catch(l=>{console.error(l)}),()=>{a=!0}},[i]),e}function cHt({url:i,position:e,rotation:t,onHover:n,onUnhover:r,isHovered:a}){const o=lHt(i);if(!o)return ft.jsx(bO,{isHovered:a,onHover:n,onUnhover:r,children:ft.jsxs("mesh",{position:e,children:[ft.jsx("boxGeometry",{args:[.5,.5,.5]}),ft.jsx("meshStandardMaterial",{transparent:!0,color:"red",opacity:.25})]})});if(o instanceof Error)throw o;return ft.jsx(bO,{isHovered:a,onHover:n,onUnhover:r,children:ft.jsx("primitive",{rotation:t,position:e,object:o})})}var uHt=A1(rLe()),lLe=({jscadPlan:i,positionOffset:e,rotationOffset:t,onHover:n,onUnhover:r,isHovered:a})=>{const{threeGeom:o,material:s}=vt.useMemo(()=>{const l=RIe.executeJscadOperations(uHt.default,i),c=qdt(l),u=new hD({vertexColors:!0,side:Fx});return{threeGeom:c,material:u}},[i]);return vt.useMemo(()=>{if(a){const l=new Tc(s.color.getHex());s.emissive.copy(l),s.emissive.setRGB(0,0,1),s.emissiveIntensity=.2}else s.emissiveIntensity=0},[a,s]),o?ft.jsx(bO,{isHovered:a,onHover:n,onUnhover:r,position:e,children:ft.jsx("mesh",{geometry:o,material:s,position:e,rotation:t})}):null},{createJSCADRoot:AHt}=alt(RIe.jscadPlanner),dHt=({positionOffset:i,footprint:e,rotationOffset:t,onHover:n,onUnhover:r,isHovered:a})=>{const o=vt.useMemo(()=>{if(!e)return null;const s=[];return AHt(s).render(ft.jsx(X1t,{footprint:e})),s},[e]);return o?ft.jsx(ft.Fragment,{children:o.map((s,l)=>ft.jsx(lLe,{positionOffset:i,rotationOffset:t,jscadPlan:s,onHover:n,onUnhover:r,isHovered:a},l))}):null},fHt=(...i)=>i,cLe=({cad_component:i,circuitJson:e})=>{const[t,n]=vt.useState(!1),[r,a]=vt.useState(null),o=vt.useCallback(f=>{f!=null&&f.mousePosition?(n(!0),a(f.mousePosition)):(n(!1),a(null))},[]),s=vt.useCallback(()=>{n(!1),a(null)},[]),l=vt.useMemo(()=>{var f;return(f=Zy(e).source_component.getUsing({source_component_id:i.source_component_id}))==null?void 0:f.name},[e,i.source_component_id]),c=i.model_obj_url??i.model_stl_url,u=i.rotation?fHt(i.rotation.x*Math.PI/180,i.rotation.y*Math.PI/180,i.rotation.z*Math.PI/180):void 0;let A=null;return c?A=ft.jsx(cHt,{url:c,position:i.position?[i.position.x,i.position.y,i.position.z]:void 0,rotation:u,onHover:o,onUnhover:s,isHovered:t},i.cad_component_id):i.model_jscad?A=ft.jsx(lLe,{jscadPlan:i.model_jscad,rotationOffset:u,onHover:o,onUnhover:s,isHovered:t},i.cad_component_id):i.footprinter_string&&(A=ft.jsx(dHt,{positionOffset:i.position?[i.position.x,i.position.y,i.position.z]:void 0,rotationOffset:u,footprint:i.footprinter_string,onHover:o,onUnhover:s,isHovered:t})),ft.jsxs(ft.Fragment,{children:[A,t&&r?ft.jsx(Z5e,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:l??"<unknown>"}):null]})},hHt={version:"0.0.299"};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new wB(0,0,0));function pHt(i,e){const t=new rx().setFromEuler(new wB(i.x,i.y,i.z)),n=new ti(0,0,1);return n.applyQuaternion(t),n.multiplyScalar(e)}var gHt=({})=>{const i=vt.useRef();return vt.useRef({lastRotation:new wB}),qT((e,t)=>{if(!i.current)return;const n=window.TSCI_MAIN_CAMERA_ROTATION,r=pHt(n,2);e.camera.position.copy(r),e.camera.lookAt(0,0,0)}),ft.jsxs("mesh",{ref:i,rotation:[Math.PI/2,0,0],children:[ft.jsx("boxGeometry",{args:[1,1,1]}),ft.jsx("meshStandardMaterial",{color:"white"}),ft.jsx(xM,{position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),ft.jsx(xM,{position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),ft.jsx(xM,{position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),ft.jsx(xM,{position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),ft.jsx(xM,{position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),ft.jsx(xM,{position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"}),ft.jsx("lineSegments",{args:[new ij(new A9(1,1,1))],material:new f_({color:0,linewidth:2})})]})},mHt=()=>(qT(({camera:i})=>{window.TSCI_MAIN_CAMERA_ROTATION=i.rotation}),ft.jsx(ft.Fragment,{})),uLe=vt.forwardRef(({children:i,initialCameraPosition:e=[5,5,5],autoRotateDisabled:t,clickToInteractEnabled:n=!1,boardDimensions:r},a)=>{const[o,s]=vt.useState(!n),l=vt.useMemo(()=>{if(!r)return 10;const c=r.width??0,u=r.height??0,f=Math.max(c,u)*1.5;return f>10?f:10},[r]);return ft.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ft.jsx("div",{style:{position:"absolute",top:0,left:0,width:120,height:120},children:ft.jsxs(K5e,{camera:{up:[0,0,1],position:[1,1,1]},style:{zIndex:10},children:[ft.jsx("ambientLight",{intensity:Math.PI/2}),ft.jsx(gHt,{})]})}),ft.jsxs(K5e,{scene:{up:[0,0,1]},camera:{up:[0,0,1],position:e},children:[ft.jsx(mHt,{}),o&&ft.jsx(cxt,{autoRotate:!t,autoRotateSpeed:1}),ft.jsx("ambientLight",{intensity:Math.PI/2}),ft.jsx("pointLight",{position:[-10,-10,10],decay:0,intensity:Math.PI/4}),ft.jsx(Axt,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:1,sectionSize:l,args:[l,l]}),ft.jsx("object3D",{ref:a,children:i})]}),ft.jsxs("div",{style:{position:"absolute",right:24,bottom:24,fontFamily:"sans-serif",color:"white",WebkitTextStroke:"0.5px rgba(0, 0, 0, 0.5)",fontSize:11},children:["@",hHt.version]}),n&&!o&&ft.jsx("button",{type:"button",onClick:()=>s(!0),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&s(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center"},children:ft.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:"Click to Interact"})})]})}),ALe=i=>vt.useMemo(()=>{if(!i)return[];const e=new VGt;return e.add(i),e.render(),e.getCircuitJson()},[i]);function yHt(i){return new Promise((e,t)=>{const n=new FileReader;n.onload=()=>{e(n.result)},n.onerror=t,n.readAsDataURL(i)})}var vHt=i=>{const[e,t]=vt.useState([]),[n,r]=vt.useState(!0);return vt.useEffect(()=>{if(!i)return;(async()=>{r(!0);const s=(Array.isArray(i)?i:[i]).map(async l=>{const c=r6t.serialize({binary:!0},[l]),u=new Blob(c);return{stlUrl:await yHt(u),color:l.color}});try{const l=await Promise.all(s);t(l)}catch(l){console.error("Error generating STLs:",l),t([])}finally{r(!1)}})()},[i]),{stls:e,loading:n}},CHt=A1(_R()),IHt=A1(N4()),pv=.01,__={copper:[.9,.6,.2],fr4Green:[5/255,163/255,46/255],fr4GreenSolderWithMask:[0/255,152/255,19/255],fr1Copper:[.8,.4,.2],fr1CopperSolderWithMask:[.9,.6,.2]},_w=.001,mQ=32,EHt=.035,SO=50,Jce={fr1:__.fr1Copper,fr4:__.fr4Green},dLe={fr1:__.fr1CopperSolderWithMask,fr4:__.fr4GreenSolderWithMask},_Ht=A1(EO()),xHt=A1(_R()),BHt=A1(BO()),fLe=i=>{let e=0;for(let n=0;n<i.length;n++){const r=(n+1)%i.length;e+=i[n][0]*i[r][1],e-=i[r][0]*i[n][1]}return e/2<=0},hLe=(i,e=1.2)=>{const{outline:t}=i;let n=t.map(o=>[o.x,o.y]);fLe(n)&&(n=n.reverse());const r=(0,xHt.polygon)({points:n});let a=(0,_Ht.extrudeLinear)({height:e},r);return a=(0,BHt.translate)([0,0,-e/2],a),a},bHt=i=>{const e=Zy(i).pcb_board.list()[0];if(!e)return console.warn("No pcb_board found for simplified geometry"),[];let t;const n=1.2;e.outline&&e.outline.length>0?t=hLe({outline:e.outline},n):t=(0,CHt.cuboid)({size:[e.width,e.height,n],center:[e.center.x,e.center.y,0]});const r=Jce[e.material]??__.fr4Green;return[(0,IHt.colorize)(r,t)]},GM=A1(BO()),jx=A1(_R()),xR=A1(N4()),LM=A1(zce()),kC=A1(_R()),QO=A1(N4()),cb=A1(zce()),eE=.05,pLe=(i,e)=>{if(i.shape||(i.shape="circle"),i.shape==="circle")return(0,QO.colorize)(__.copper,(0,cb.subtract)((0,cb.union)((0,kC.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2,height:e.pcbThickness}),(0,kC.cylinder)({center:[i.x,i.y,e.pcbThickness/2+eE/2+pv],radius:i.outer_diameter/2,height:eE}),(0,kC.cylinder)({center:[i.x,i.y,-e.pcbThickness/2-eE/2-pv],radius:i.outer_diameter/2,height:eE})),(0,kC.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2-pv,height:1.5})));if(i.shape==="circular_hole_with_rect_pad"){const t=i.rect_pad_width||i.hole_diameter,n=i.rect_pad_height||i.hole_diameter;return(0,QO.colorize)(__.copper,(0,cb.subtract)((0,cb.union)((0,kC.cuboid)({center:[i.x,i.y,1.2/2],size:[t,n,eE]}),(0,kC.cuboid)({center:[i.x,i.y,-1.2/2],size:[t,n,eE]}),(0,kC.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2,height:1.2})),(0,kC.cylinder)({center:[i.x,i.y,0],radius:Math.max(i.hole_diameter/2-pv,.01),height:1.5})))}if(i.shape==="pill"){const t=i.hole_height>i.hole_width,n=t?i.hole_height:i.hole_width,r=t?i.hole_width:i.hole_height,a=t?i.outer_height||r+.2:i.outer_width||n+.2,o=t?i.outer_width||n+.2:i.outer_height||r+.2,s=r/2,l=o/2,c=Math.abs(n-r),u=Math.abs(a-o),A=(0,kC.cuboid)({center:[i.x,i.y,0],size:t?[r,c,e.pcbThickness]:[c,r,e.pcbThickness]}),f=(0,kC.cylinder)({center:t?[i.x,i.y-c/2,0]:[i.x-c/2,i.y,0],radius:s,height:e.pcbThickness}),p=(0,kC.cylinder)({center:t?[i.x,i.y+c/2,0]:[i.x+c/2,i.y,0],radius:s,height:e.pcbThickness}),v=(0,cb.union)(A,f,p),x=e.pcbThickness/2+eE/2+pv,B=(0,kC.cuboid)({center:[i.x,i.y,x],size:t?[o,u,eE]:[u,o,eE]}),b=(0,kC.cylinder)({center:t?[i.x,i.y-u/2,x]:[i.x-u/2,i.y,x],radius:l,height:eE}),w=(0,kC.cylinder)({center:t?[i.x,i.y+u/2,x]:[i.x+u/2,i.y,x],radius:l,height:eE}),R=(0,cb.union)(B,b,w),G=-e.pcbThickness/2-eE/2-pv,V=(0,kC.cuboid)({center:[i.x,i.y,G],size:t?[o,u,eE]:[u,o,eE]}),Y=(0,kC.cylinder)({center:t?[i.x,i.y-u/2,G]:[i.x-u/2,i.y,G],radius:l,height:eE}),J=(0,kC.cylinder)({center:t?[i.x,i.y+u/2,G]:[i.x+u/2,i.y,G],radius:l,height:eE}),q=(0,cb.union)(V,Y,J),$=(0,kC.cuboid)({center:[i.x,i.y,0],size:t?[r-2*pv,c,e.pcbThickness+2*pv]:[c,r-2*pv,e.pcbThickness+2*pv]}),X=(0,kC.cylinder)({center:t?[i.x,i.y-c/2,0]:[i.x-c/2,i.y,0],radius:s-pv,height:e.pcbThickness+2*pv}),de=(0,kC.cylinder)({center:t?[i.x,i.y+c/2,0]:[i.x+c/2,i.y,0],radius:s-pv,height:e.pcbThickness+2*pv}),ue=(0,cb.union)($,X,de);return(0,QO.colorize)(__.copper,(0,cb.subtract)((0,cb.union)(v,R,q),ue))}if(i.shape==="pill_hole_with_rect_pad"){const t=i.hole_height>i.hole_width,n=t?i.hole_height:i.hole_width,r=t?i.hole_width:i.hole_height,a=r/2,o=Math.abs(n-r),s=i.rect_pad_width||n+.2,l=i.rect_pad_height||r+.2,c=(0,kC.cuboid)({center:[i.x,i.y,0],size:t?[r,o,1.2]:[o,r,1.2]}),u=(0,kC.cylinder)({center:t?[i.x,i.y-o/2,0]:[i.x-o/2,i.y,0],radius:a,height:1.2}),A=(0,kC.cylinder)({center:t?[i.x,i.y+o/2,0]:[i.x+o/2,i.y,0],radius:a,height:1.2}),f=(0,kC.cuboid)({center:[i.x,i.y,1.2/2],size:[s,l,eE]}),p=(0,kC.cuboid)({center:[i.x,i.y,-1.2/2],size:[s,l,eE]}),v=(0,cb.union)((0,kC.cuboid)({center:[i.x,i.y,0],size:t?[r-eE,o,1.5]:[o,r-eE,1.5]}),(0,kC.cylinder)({center:t?[i.x,i.y-o/2,0]:[i.x-o/2,i.y,0],radius:a-eE,height:1.5}),(0,kC.cylinder)({center:t?[i.x,i.y+o/2,0]:[i.x+o/2,i.y,0],radius:a-eE,height:1.5}));return(0,QO.colorize)(__.copper,(0,cb.subtract)((0,cb.union)(c,u,A,f,p),v))}else throw new Error(`Unsupported plated hole shape: ${i.shape}`)},wO=A1(EO()),gLe=A1(Yce()),SHt=A1(Pce());function mLe(i,e){return Array.isArray(e)?[i.a*e[0]+i.c*e[1]+i.e,i.b*e[0]+i.d*e[1]+i.f]:{x:i.a*e.x+i.c*e.y+i.e,y:i.b*e.x+i.d*e.y+i.f}}function O9(i,e=0){return{a:1,c:0,e:i,b:0,d:1,f:e}}function yLe(...i){i=Array.isArray(i[0])?i[0]:i;const e=(t,n)=>({a:t.a*n.a+t.c*n.b,c:t.a*n.c+t.c*n.d,e:t.a*n.e+t.c*n.f+t.e,b:t.b*n.a+t.d*n.b,d:t.b*n.c+t.d*n.d,f:t.b*n.e+t.d*n.f+t.f});switch(i.length){case 0:throw new Error("no matrices provided");case 1:return i[0];case 2:return e(i[0],i[1]);default:{const[t,n,...r]=i,a=e(t,n);return yLe(a,...r)}}}function vLe(...i){return yLe(...i)}var{cos:QHt,sin:wHt}=Math;function CLe(i,e,t){const n=QHt(i),r=wHt(i);return{a:n,c:-r,e:0,b:r,d:n,f:0}}function MHt(i,e){function t(){this.constructor=i}t.prototype=e.prototype,i.prototype=new t}function MO(i,e,t,n){var r=Error.call(this,i);return Object.setPrototypeOf&&Object.setPrototypeOf(r,MO.prototype),r.expected=e,r.found=t,r.location=n,r.name="SyntaxError",r}MHt(MO,Error);function Zce(i,e,t){return t=t||" ",i.length>e?i:(e-=i.length,t+=t.repeat(e),i+t.slice(0,e))}MO.prototype.format=function(i){var e="Error: "+this.message;if(this.location){var t=null,n;for(n=0;n<i.length;n++)if(i[n].source===this.location.source){t=i[n].text.split(/\r\n|\n|\r/g);break}var r=this.location.start,a=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(r):r,o=this.location.source+":"+a.line+":"+a.column;if(t){var s=this.location.end,l=Zce("",a.line.toString().length," "),c=t[r.line-1],u=r.line===s.line?s.column:c.length+1,A=u-r.column||1;e+=`
13079
13079
  --> `+o+`
13080
13080
  `+l+` |
13081
13081
  `+a.line+" | "+c+`
13082
13082
  `+l+" | "+Zce("",r.column-1," ")+Zce("",A,"^")}else e+=`
13083
- at `+o}return e},MO.buildMessage=function(i,e){var t={literal:function(c){return'"'+r(c.text)+'"'},class:function(c){var u=c.parts.map(function(A){return Array.isArray(A)?a(A[0])+"-"+a(A[1]):a(A)});return"["+(c.inverted?"^":"")+u.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(c){return c.description}};function n(c){return c.charCodeAt(0).toString(16).toUpperCase()}function r(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+n(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+n(u)})}function a(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+n(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+n(u)})}function o(c){return t[c.type](c)}function s(c){var u=c.map(o),A,f;if(u.sort(),u.length>0){for(A=1,f=1;A<u.length;A++)u[A-1]!==u[A]&&(u[f]=u[A],f++);u.length=f}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function l(c){return c?'"'+r(c)+'"':"end of input"}return"Expected "+s(i)+" but "+l(e)+" found."};function DHt(i){var A,f,p,v;const e=(0,SHt.vectorText)({height:i.font_size*.45,input:i.text});let t=i.ccw_rotation??0;e.forEach(x=>{x.length===29?(e.splice(e.indexOf(x),1,x.slice(0,15)),e.splice(e.indexOf(x),0,x.slice(14,29))):x.length===17&&(e.splice(e.indexOf(x),1,x.slice(0,10)),e.splice(e.indexOf(x),0,x.slice(9,17)))});const n=e.flatMap(x=>x),r={minX:Math.min(...n.map(x=>x[0])),maxX:Math.max(...n.map(x=>x[0])),minY:Math.min(...n.map(x=>x[1])),maxY:Math.max(...n.map(x=>x[1]))},a=(r.minX+r.maxX)/2,o=(r.minY+r.maxY)/2;let s=-a,l=-o;(A=i.anchor_alignment)!=null&&A.includes("right")?s=-r.maxX:(f=i.anchor_alignment)!=null&&f.includes("left")&&(s=-r.minX),(p=i.anchor_alignment)!=null&&p.includes("top")?l=-r.maxY:(v=i.anchor_alignment)!=null&&v.includes("bottom")&&(l=-r.minY);const c=[];if(i.layer==="bottom"&&(c.push(O9(a,o),{a:-1,b:0,c:0,d:1,e:0,f:0},O9(-a,-o)),t=-t),t){const x=t*Math.PI/180;c.push(O9(a,o),CLe(x),O9(-a,-o))}let u=e;if(c.length>0){const x=vLe(...c);u=e.map(B=>B.map(([b,w])=>{const{x:R,y:G}=mLe(x,{x:b,y:w});return[R,G]}))}return{textOutlines:u,xOffset:s,yOffset:l}}var RHt=A1(_R()),NHt=A1(Yce()),THt=A1(EO()),UHt=A1(BO()),PHt=A1(N4());function kHt(i,e){if(i.route.length<2)return;const t=i.route.map(c=>[c.x,c.y]),n=(0,RHt.line)(t),r=i.stroke_width||.1,a=(0,NHt.expand)({delta:r/2,corners:"round"},n),o=i.layer==="bottom"?-1:1,s=o*e.pcbThickness/2+o*pv*1.5;let l=(0,UHt.translate)([0,0,s],(0,THt.extrudeLinear)({height:.012},a));return l=(0,PHt.colorize)([1,1,1],l),l}var ILe=["initializing","processing_plated_holes","processing_holes","processing_cutouts","processing_pads","processing_traces","processing_vias","processing_silkscreen_text","processing_silkscreen_paths","finalizing","done"],FHt=class{constructor(i,e){Je(this,"circuitJson");Je(this,"board");Je(this,"plated_holes");Je(this,"holes");Je(this,"pads");Je(this,"traces");Je(this,"pcb_vias");Je(this,"silkscreenTexts");Je(this,"silkscreenPaths");Je(this,"pcb_cutouts");Je(this,"boardGeom",null);Je(this,"platedHoleGeoms",[]);Je(this,"holeGeoms",[]);Je(this,"padGeoms",[]);Je(this,"traceGeoms",[]);Je(this,"viaGeoms",[]);Je(this,"silkscreenTextGeoms",[]);Je(this,"silkscreenPathGeoms",[]);Je(this,"state","initializing");Je(this,"currentIndex",0);Je(this,"ctx");Je(this,"onCompleteCallback");Je(this,"finalGeoms",[]);this.circuitJson=i,this.onCompleteCallback=e,this.board=Zy(i).pcb_board.list()[0],this.plated_holes=Zy(i).pcb_plated_hole.list(),this.holes=Zy(i).pcb_hole.list(),this.pads=Zy(i).pcb_smtpad.list(),this.traces=Zy(i).pcb_trace.list(),this.pcb_vias=Zy(i).pcb_via.list(),this.silkscreenTexts=Zy(i).pcb_silkscreen_text.list(),this.silkscreenPaths=Zy(i).pcb_silkscreen_path.list(),this.pcb_cutouts=Zy(i).pcb_cutout.list(),this.ctx={pcbThickness:1.2},this.initializeBoard()}getHoleToCut(i,e){const t=pv/10;for(const n of this.pcb_vias)if(Math.abs(n.x-i)<t&&Math.abs(n.y-e)<t&&n.hole_diameter)return{diameter:n.hole_diameter};for(const n of this.plated_holes)if(n.shape==="circle"&&Math.abs(n.x-i)<t&&Math.abs(n.y-e)<t&&n.hole_diameter)return{diameter:n.hole_diameter};return null}initializeBoard(){this.board.outline&&this.board.outline.length>0?this.boardGeom=hLe({outline:this.board.outline},this.ctx.pcbThickness):this.boardGeom=(0,jx.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.state="processing_plated_holes",this.currentIndex=0}goToNextState(){const i=ILe.indexOf(this.state);i!==-1&&(this.state=ILe[i+1],this.currentIndex=0)}step(i=1){if(this.state==="done"||!this.boardGeom)return!0;for(let e=0;e<i&&this.state!=="done";e++)switch(this.state){case"processing_plated_holes":this.currentIndex<this.plated_holes.length?(this.processPlatedHole(this.plated_holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_holes":this.currentIndex<this.holes.length?(this.processHole(this.holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_pads":this.currentIndex<this.pads.length?(this.processPad(this.pads[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_traces":this.currentIndex<this.traces.length?(this.processTrace(this.traces[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_vias":this.currentIndex<this.pcb_vias.length?(this.processVia(this.pcb_vias[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_text":this.currentIndex<this.silkscreenTexts.length?(this.processSilkscreenText(this.silkscreenTexts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_paths":this.currentIndex<this.silkscreenPaths.length?(this.processSilkscreenPath(this.silkscreenPaths[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_cutouts":this.currentIndex<this.pcb_cutouts.length?(this.processCutout(this.pcb_cutouts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"finalizing":this.finalize(),this.state="done";break}return this.state==="done"}processCutout(i){if(!this.boardGeom)return;let e=null;const t=this.ctx.pcbThickness*1.5;switch(i.shape){case"rect":if(e=(0,jx.cuboid)({center:[i.center.x,i.center.y,0],size:[i.width,i.height,t]}),i.rotation){const a=i.rotation*Math.PI/180;e=(0,GM.rotateZ)(a,e)}break;case"circle":e=(0,jx.cylinder)({center:[i.center.x,i.center.y,0],radius:i.radius,height:t});break;case"polygon":let n=i.points.map(a=>[a.x,a.y]);if(n.length<3){console.warn(`PCB Cutout [${i.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}fLe(n)&&(n=n.reverse());const r=(0,jx.polygon)({points:n});e=(0,wO.extrudeLinear)({height:t},r),e=(0,GM.translate)([0,0,-t/2],e);break}e&&(this.boardGeom=(0,LM.subtract)(this.boardGeom,e))}processPlatedHole(i,e={}){if(this.boardGeom){if(i.shape==="circle"||i.shape==="circular_hole_with_rect_pad"){const t=(0,jx.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2+pv,height:this.ctx.pcbThickness*1.5});e.dontCutBoard||(this.boardGeom=(0,LM.subtract)(this.boardGeom,t));const n=pLe(i,this.ctx);this.platedHoleGeoms.push(n)}else if(i.shape==="pill"||i.shape==="pill_hole_with_rect_pad"){const t=i.hole_height>i.hole_width,n=t?i.hole_height:i.hole_width,r=t?i.hole_width:i.hole_height,a=r/2,o=Math.abs(n-r),s=(0,LM.union)((0,jx.cuboid)({center:[i.x,i.y,0],size:t?[r,o,this.ctx.pcbThickness*1.5]:[o,r,this.ctx.pcbThickness*1.5]}),(0,jx.cylinder)({center:t?[i.x,i.y-o/2,0]:[i.x-o/2,i.y,0],radius:a,height:this.ctx.pcbThickness*1.5}),(0,jx.cylinder)({center:t?[i.x,i.y+o/2,0]:[i.x+o/2,i.y,0],radius:a,height:this.ctx.pcbThickness*1.5}));e.dontCutBoard||(this.boardGeom=(0,LM.subtract)(this.boardGeom,s));const l=pLe(i,this.ctx);this.platedHoleGeoms.push(l)}}}processHole(i){if(this.boardGeom&&(i.hole_shape==="round"||i.hole_shape==="circle")){const e=(0,jx.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2+pv,height:this.ctx.pcbThickness*1.5});this.boardGeom=(0,LM.subtract)(this.boardGeom,e)}}processPad(i){const e=i.layer==="bottom"?-1:1,t=e*this.ctx.pcbThickness/2+e*pv*2;if(i.shape==="rect"){const n=(0,xR.colorize)(__.copper,(0,jx.cuboid)({center:[i.x,i.y,t],size:[i.width,i.height,pv]}));this.padGeoms.push(n)}else if(i.shape==="rotated_rect"){let n=(0,jx.cuboid)({center:[0,0,0],size:[i.width,i.height,pv]});const r=i.ccw_rotation*Math.PI/180;n=(0,GM.rotateZ)(r,n);const a=(0,GM.translate)([i.x,i.y,t],n),o=(0,xR.colorize)(__.copper,a);this.padGeoms.push(o)}else if(i.shape==="circle"){const n=(0,xR.colorize)(__.copper,(0,jx.cylinder)({center:[i.x,i.y,t],radius:i.radius,height:pv}));this.padGeoms.push(n)}}processTrace(i){const{route:e}=i;if(e.length<2)return;let t=[],n=null,r=.1;const a=()=>{if(t.length>=2&&n){const o=n==="bottom"?-1:1,s=o*this.ctx.pcbThickness/2+o*pv,l=(0,jx.line)(t),c=(0,gLe.expand)({delta:r/2,corners:"round"},l);let u=(0,GM.translate)([0,0,s],(0,wO.extrudeLinear)({height:pv},c));const A=t[0],f=t[t.length-1],p=this.getHoleToCut(A[0],A[1]);if(p){const B=(0,jx.cylinder)({center:[A[0],A[1],s+pv/2],radius:p.diameter/2+pv,height:pv});u=(0,LM.subtract)(u,B)}const v=this.getHoleToCut(f[0],f[1]);if(v){const B=(0,jx.cylinder)({center:[f[0],f[1],s+pv/2],radius:v.diameter/2+pv,height:pv});u=(0,LM.subtract)(u,B)}const x=dLe[this.board.material]??__.fr4GreenSolderWithMask;u=(0,xR.colorize)(x,u),this.traceGeoms.push(u)}t=[],n=null};for(let o=0;o<e.length;o++){const s=e[o];if(s.route_type==="wire")n===null?(n=s.layer,r=s.width,t.push([s.x,s.y])):s.layer===n?t.push([s.x,s.y]):(t.push([s.x,s.y]),a(),n=s.layer,r=s.width,e[o-1]?t.push([s.x,s.y]):t.push([s.x,s.y]));else if(s.route_type==="via"){t.push([s.x,s.y]),a();const l=e[o+1];l&&l.route_type==="wire"&&(n=l.layer,r=l.width,t.push([s.x,s.y]))}}a()}processVia(i){this.processPlatedHole({x:i.x,y:i.y,hole_diameter:i.hole_diameter,outer_diameter:i.outer_diameter,shape:"circle",layers:["top","bottom"],type:"pcb_plated_hole",pcb_plated_hole_id:`via_${i.pcb_via_id}`},{dontCutBoard:!0})}processSilkscreenText(i){const{textOutlines:e,xOffset:t,yOffset:n}=DHt(i);for(const r of e){const a=r.map(A=>[A[0]+t+i.anchor_position.x,A[1]+n+i.anchor_position.y]),o=(0,jx.line)(a),s=i.font_size||.25,l=Math.min(Math.max(.01,s*.1),s*.05),c=(0,gLe.expand)({delta:l,corners:"round"},o);let u;i.layer==="bottom"?u=(0,GM.translate)([0,0,-this.ctx.pcbThickness/2-pv],(0,wO.extrudeLinear)({height:.012},c)):u=(0,GM.translate)([0,0,this.ctx.pcbThickness/2+pv],(0,wO.extrudeLinear)({height:.012},c)),u=(0,xR.colorize)([1,1,1],u),this.silkscreenTextGeoms.push(u)}}processSilkscreenPath(i){const e=kHt(i,this.ctx);e&&this.silkscreenPathGeoms.push(e)}finalize(){if(!this.boardGeom)return;const i=Jce[this.board.material]??__.fr4Green;this.boardGeom=(0,xR.colorize)(i,this.boardGeom),this.finalGeoms=[this.boardGeom,...this.platedHoleGeoms,...this.padGeoms,...this.traceGeoms,...this.viaGeoms,...this.silkscreenTextGeoms,...this.silkscreenPathGeoms],this.onCompleteCallback&&this.onCompleteCallback(this.finalGeoms)}getGeoms(){return this.finalGeoms}},GHt=i=>{const[e,t]=vt.useState(null),n=vt.useRef(!1);return vt.useEffect(()=>{let r=!1;if(!i){t(null);return}if(!i.some(l=>l.type==="pcb_board")){t(null);return}const a=bHt(i);t(a);const o=new FHt(i,l=>{});return(async()=>{if(!n.current){n.current=!0;try{let l=!1;for(;!l&&!r;)l=o.step(1),l||await new Promise(c=>setTimeout(c,0));r||t(o.getGeoms())}catch(l){console.error("Error during board geometry building:",l)}finally{n.current=!1}}})(),()=>{r=!0}},[i]),e},ELe=({error:i,cad_component:e})=>{const[t,n]=vt.useState(!1),[r,a]=vt.useState(null),o=vt.useCallback(c=>{c!=null&&c.mousePosition?(n(!0),a(c.mousePosition)):(n(!1),a(null))},[]),s=vt.useCallback(()=>{n(!1),a(null)},[]);let l=[0,0,0];return e!=null&&e.position&&(l=[e.position.x,e.position.y,e.position.z],l=l.map(c=>Number.isNaN(c)?0:c)),ft.jsxs(ft.Fragment,{children:[ft.jsx(bO,{isHovered:t,onHover:o,onUnhover:s,position:l,children:ft.jsxs("group",{position:l,children:[ft.jsxs("mesh",{renderOrder:-99999,rotation:[Math.PI/4,Math.PI/4,0],ref:c=>{c&&(c.renderOrder=999999)},children:[ft.jsx("boxGeometry",{args:[.5,.5,.5]}),ft.jsx("meshStandardMaterial",{depthTest:!1,transparent:!0,color:"red",opacity:.5})]}),ft.jsxs(xM,{scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:[i.toString().slice(0,50),"..."]})]})}),t&&r?ft.jsx(Z5e,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(50%, 50%, 0)",backgroundColor:"white",padding:"6px",borderRadius:"4px",color:"red",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:i.toString()}):null]})};function LHt({stlUrl:i,mtlUrl:e,color:t,opacity:n=1}){const r=Oie($zt,i),a=vt.useRef();return ft.jsxs("mesh",{ref:a,children:[ft.jsx("primitive",{object:r,attach:"geometry"}),ft.jsx("meshStandardMaterial",{color:t,transparent:n!==1,opacity:n})]})}var _Le=class extends Qg.Component{constructor(i){super(i),this.state={hasError:!1,error:null}}static getDerivedStateFromError(i){return{hasError:!0,error:i}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},OHt=vt.forwardRef(({soup:i,circuitJson:e,children:t,autoRotateDisabled:n,clickToInteractEnabled:r},a)=>{const o=ALe(t),s=vt.useMemo(()=>i??e??o,[i,e,o]),l=GHt(s),c=vt.useMemo(()=>{if(!s)return[5,5,5];try{const p=Zy(s).pcb_board.list()[0];if(!p)return[5,5,5];const{width:v,height:x}=p;if(!v&&!x)return[5,5,5];const B=5,b=Math.max(v,B),w=Math.max(x,B),R=Math.max(b,w);return[R/2,R/2,R]}catch(p){return console.error(p),[5,5,5]}},[s]),u=vt.useMemo(()=>{if(s)try{const p=Zy(s).pcb_board.list()[0];return p?{width:p.width??0,height:p.height??0}:void 0}catch(p){console.error(p);return}},[s]),{stls:A}=vHt(l),f=Zy(s).cad_component.list();return ft.jsxs(uLe,{ref:a,autoRotateDisabled:n,initialCameraPosition:c,clickToInteractEnabled:r,boardDimensions:u,children:[A.map(({stlUrl:p,color:v},x)=>ft.jsx(LHt,{stlUrl:p,color:v,opacity:x===0?.95:1},p)),f.map(p=>ft.jsx(_Le,{fallback:({error:v})=>ft.jsx(ELe,{cad_component:p,error:v}),children:ft.jsx(cLe,{cad_component:p,circuitJson:s},p.cad_component_id)},p.cad_component_id))]})});function L4(i){const e=new Bp;if(e.setAttribute("position",new xA(i.vertProperties,3)),e.setIndex(new dk(i.triVerts,1)),i.runIndex&&i.runIndex.length>1&&i.runOriginalID)for(let t=0;t<i.runIndex.length-1;t++){const n=i.runIndex[t],r=i.runIndex[t+1]-n;e.addGroup(n,r,0)}else e.addGroup(0,i.triVerts.length,0);return e}function xLe(i){return i&&i.route_type==="wire"&&typeof i.layer=="string"&&typeof i.width=="number"}function BLe({layer:i,circuitJson:e,boardData:t,traceColor:n,traceTextureResolution:r}){const a=Zy(e).pcb_trace.list(),o=Zy(e).pcb_via.list(),s=Zy(e).pcb_plated_hole.list(),l=a.filter(v=>v.route.some(x=>xLe(x)&&x.layer===i));if(l.length===0)return null;const c=document.createElement("canvas"),u=Math.floor(t.width*r),A=Math.floor(t.height*r);c.width=u,c.height=A;const f=c.getContext("2d");if(!f)return null;i==="bottom"&&(f.translate(0,A),f.scale(1,-1)),l.forEach(v=>{let x=!0;f.beginPath(),f.strokeStyle=n,f.lineCap="round",f.lineJoin="round";let B=0;for(const b of v.route){if(!xLe(b)||b.layer!==i){x||f.stroke(),x=!0;continue}const w=b.x,R=b.y;B=b.width*r,f.lineWidth=B;const G=(w-t.center.x+t.width/2)*r,V=(-(R-t.center.y)+t.height/2)*r;x?(f.moveTo(G,V),x=!1):f.lineTo(G,V)}x||f.stroke()}),f.globalCompositeOperation="destination-out",f.fillStyle="black",o.forEach(v=>{const x=(v.x-t.center.x+t.width/2)*r,B=(-(v.y-t.center.y)+t.height/2)*r,b=v.outer_diameter/2*r;f.beginPath(),f.arc(x,B,b,0,2*Math.PI,!1),f.fill()}),s.forEach(v=>{if(v.layers.includes(i)&&v.shape==="circle"){const x=(v.x-t.center.x+t.width/2)*r,B=(-(v.y-t.center.y)+t.height/2)*r,b=v.outer_diameter/2*r;f.beginPath(),f.arc(x,B,b,0,2*Math.PI,!1),f.fill()}}),f.globalCompositeOperation="source-over";const p=new KK(c);return p.generateMipmaps=!0,p.minFilter=Qb,p.magFilter=Q1,p.anisotropy=16,p.needsUpdate=!0,p}var zHt=A1(Pce());function bLe({layer:i,circuitJson:e,boardData:t,silkscreenColor:n="rgb(255,255,255)",traceTextureResolution:r}){const a=Zy(e).pcb_silkscreen_text.list(),o=Zy(e).pcb_silkscreen_path.list(),s=a.filter(v=>v.layer===i),l=o.filter(v=>v.layer===i);if(s.length===0&&l.length===0)return null;const c=document.createElement("canvas"),u=Math.floor(t.width*r),A=Math.floor(t.height*r);c.width=u,c.height=A;const f=c.getContext("2d");if(!f)return null;i==="bottom"&&(f.translate(0,A),f.scale(1,-1)),f.strokeStyle=n,f.fillStyle=n,l.forEach(v=>{v.route.length<2||(f.beginPath(),f.lineWidth=(v.stroke_width||.1)*r,f.lineCap="round",f.lineJoin="round",v.route.forEach((x,B)=>{const b=(x.x-t.center.x+t.width/2)*r,w=(-(x.y-t.center.y)+t.height/2)*r;B===0?f.moveTo(b,w):f.lineTo(b,w)}),f.stroke())}),s.forEach(v=>{const x=v.font_size||.25,B=Math.min(Math.max(.01,x*.1),x*.05)*r;f.lineWidth=B,f.lineCap="butt",f.lineJoin="miter";const b=(0,zHt.vectorText)({height:x*.45,input:v.text}),w=[];b.forEach(ge=>{ge.length===29?(w.push(ge.slice(0,15)),w.push(ge.slice(14,29))):ge.length===17?(w.push(ge.slice(0,10)),w.push(ge.slice(9,17))):w.push(ge)});const R=w.flat(),G={minX:R.length>0?Math.min(...R.map(ge=>ge[0])):0,maxX:R.length>0?Math.max(...R.map(ge=>ge[0])):0,minY:R.length>0?Math.min(...R.map(ge=>ge[1])):0,maxY:R.length>0?Math.max(...R.map(ge=>ge[1])):0},V=(G.minX+G.maxX)/2,Y=(G.minY+G.maxY)/2;let J=-V,q=-Y;const $=v.anchor_alignment||"center";$.includes("left")?J=-G.minX:$.includes("right")&&(J=-G.maxX),$.includes("top")?q=-G.maxY:$.includes("bottom")&&(q=-G.minY);const X=[];let de=v.ccw_rotation??0;if(v.layer==="bottom"&&(X.push(O9(V,Y),{a:-1,b:0,c:0,d:1,e:0,f:0},O9(-V,-Y)),de=-de),de){const ge=de*Math.PI/180;X.push(O9(V,Y),CLe(ge),O9(-V,-Y))}const ue=X.length>0?vLe(...X):void 0;w.forEach(ge=>{f.beginPath(),ge.forEach((be,Qe)=>{let ve={x:be[0],y:be[1]};ue&&(ve=mLe(ue,ve));const Be=ve.x+J+v.anchor_position.x,Ie=ve.y+q+v.anchor_position.y,Ne=(Be-t.center.x+t.width/2)*r,Ue=(-(Ie-t.center.y)+t.height/2)*r;Qe===0?f.moveTo(Ne,Ue):f.lineTo(Ne,Ue)}),f.stroke()})});const p=new KK(c);return p.generateMipmaps=!0,p.minFilter=Qb,p.magFilter=Q1,p.anisotropy=16,p.needsUpdate=!0,p}function HHt({Manifold:i,x:e,y:t,diameter:n,thickness:r,segments:a=32}){return i.cylinder(r*1.2,n/2,n/2,a,!0).translate([e,t,0])}function SLe({Manifold:i,x:e,y:t,outerDiameter:n,thickness:r,zOffset:a=.001,segments:o=32}){const s=n/2+a;return i.cylinder(r*1.2,s,s,o,!0).translate([e,t,0])}function YHt(i){return(i.shape==="circle"||i.hole_shape==="circle")&&typeof i.hole_diameter=="number"}function VHt(i,e,t,n){const r=[];return Zy(e).pcb_hole.list().forEach(o=>{if(YHt(o)){const s=HHt({Manifold:i,x:o.x,y:o.y,diameter:o.hole_diameter,thickness:t,segments:mQ});n.push(s),r.push(s)}}),{nonPlatedHoleBoardDrills:r}}var QLe=new Tc(...__.copper);function KHt(i,e,t,n){const r=[],a=Zy(e).pcb_plated_hole.list(),o=[];return a.forEach((s,l)=>{if(s.shape==="circle"){const c=SLe({Manifold:i,x:s.x,y:s.y,outerDiameter:s.outer_diameter,thickness:t,zOffset:_w,segments:mQ});n.push(c),r.push(c);const u=t+2*_w;let A=i.cylinder(u,s.outer_diameter/2,s.outer_diameter/2,mQ,!0);n.push(A);const f=i.cylinder(u*1.05,s.hole_diameter/2,s.hole_diameter/2,mQ,!0);n.push(f);const p=A.subtract(f);n.push(p);const v=p.translate([s.x,s.y,0]);n.push(v);const x=L4(v.getMesh());o.push({key:`ph-${s.pcb_plated_hole_id||l}`,geometry:x,color:QLe})}else if(s.shape==="pill"){const c=s.hole_width,u=s.hole_height,A=u>c,f=A?u:c,p=A?c:u,v=.4,x=A?s.outer_height??p+v/2:s.outer_width??f+v/2,B=A?s.outer_width??f+v/2:s.outer_height??p+v/2,b=(ge,be,Qe)=>{const ve=be/2,Be=ge-be;let Ie;if(Be<1e-9)Ie=i.cylinder(Qe,ve,ve,mQ,!0);else{const Ne=i.cube([Math.max(0,Be),be,Qe],!0),Ue=i.cylinder(Qe,ve,ve,mQ,!0).translate([-Be/2,0,0]),Le=i.cylinder(Qe,ve,ve,mQ,!0).translate([Be/2,0,0]);Ie=i.union([Ne,Ue,Le]),n.push(Ne,Ue,Le)}return n.push(Ie),Ie},w=f+2*_w,R=p+2*_w,G=t*1.2;let V=b(w,R,G);if(A){const ge=V.rotate([0,0,90]);n.push(ge),V=ge}const Y=V.translate([s.x,s.y,0]);n.push(Y),r.push(Y);const J=t+2*_w,q=b(x,B,J),$=b(f,p,J*1.05);let X=q.subtract($);if(n.push(X),A){const ge=X.rotate([0,0,90]);n.push(ge),X=ge}const de=X.translate([s.x,s.y,0]);n.push(de);const ue=L4(de.getMesh());o.push({key:`ph-${s.pcb_plated_hole_id||l}`,geometry:ue,color:QLe})}}),{platedHoleBoardDrills:r,platedHoleCopperGeoms:o}}function jHt({Manifold:i,x:e,y:t,outerDiameter:n,holeDiameter:r,thickness:a,zOffset:o=.001,segments:s=32}){const l=a+2*o;let c=i.cylinder(l,n/2,-1,s,!0);const u=i.cylinder(l*1.05,r/2,-1,s,!0);return c.subtract(u).translate([e,t,0])}var JHt=new Tc(...__.copper);function ZHt(i,e,t,n){const r=[],a=Zy(e).pcb_via.list(),o=[];return a.forEach((s,l)=>{if(typeof s.outer_diameter=="number"){const c=SLe({Manifold:i,x:s.x,y:s.y,outerDiameter:s.outer_diameter,thickness:t,zOffset:_w,segments:mQ});n.push(c),r.push(c)}if(typeof s.outer_diameter=="number"&&typeof s.hole_diameter=="number"){const c=jHt({Manifold:i,x:s.x,y:s.y,outerDiameter:s.outer_diameter,holeDiameter:s.hole_diameter,thickness:t,zOffset:_w,segments:mQ});n.push(c);const u=L4(c.getMesh());o.push({key:`via-${s.pcb_via_id||l}`,geometry:u,color:JHt})}}),{viaBoardDrills:r,viaCopperGeoms:o}}function qHt({Manifold:i,pad:e,padBaseThickness:t}){return e.shape==="rect"?i.cube([e.width,e.height,t],!0):e.shape==="circle"&&e.radius?i.cylinder(t,e.radius,-1,32,!0):null}var WHt=new Tc(...__.copper);function XHt(i,e,t,n){const r=[];return Zy(e).pcb_smtpad.list().forEach((o,s)=>{const l=EHt,c=o.layer==="bottom"?-t/2-l/2-_w:t/2+l/2+_w;let u=qHt({Manifold:i,pad:o,padBaseThickness:l});if(u){n.push(u);const A=u.translate([o.x,o.y,c]);n.push(A);const f=L4(A.getMesh());r.push({key:`pad-${o.pcb_smtpad_id||s}`,geometry:f,color:WHt})}}),{smtPadGeoms:r}}var $Ht=i=>{let e=0;for(let n=0;n<i.length;n++){const r=(n+1)%i.length;i[n]&&i[r]&&(e+=i[n][0]*i[r][1],e-=i[r][0]*i[n][1])}return e/2<=0};function eYt(i,e,t,n,r){let a;if(t.outline&&t.outline.length>=3){let o=t.outline.map(l=>[l.x,l.y]);$Ht(o)&&(o=o.reverse());const s=e.ofPolygons([o]);r.push(s),a=i.extrude(s,n,void 0,void 0,void 0,!0),r.push(a)}else t.outline&&t.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),a=i.cube([t.width,t.height,n],!0),r.push(a),a=a.translate([t.center.x,t.center.y,0]),r.push(a);return a}var tYt=i=>{let e=0;for(let n=0;n<i.length;n++){const r=(n+1)%i.length;i[n]&&i[r]&&(e+=i[n][0]*i[r][1],e-=i[r][0]*i[n][1])}return e/2<=0};function nYt(i,e,t,n,r){const a=[],o=Zy(t).pcb_cutout.list();for(const s of o){let l;const c=n*1.5;switch(s.shape){case"rect":if(l=i.cube([s.width,s.height,c],!0),r.push(l),s.rotation){s.rotation*Math.PI/180;const f=l.rotate([0,0,s.rotation]);r.push(f),l=f}l=l.translate([s.center.x,s.center.y,0]),r.push(l);break;case"circle":l=i.cylinder(c,s.radius,-1,mQ,!0),r.push(l),l=l.translate([s.center.x,s.center.y,0]),r.push(l);break;case"polygon":if(s.points.length<3){console.warn(`PCB Cutout [${s.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);continue}let u=s.points.map(f=>[f.x,f.y]);tYt(u)&&(u=u.reverse());const A=e.ofPolygons([u]);r.push(A),l=i.extrude(A,c,0,0,[1,1],!0),r.push(l);break;default:console.warn(`Unsupported cutout shape: ${s.shape} for cutout ${s.pcb_cutout_id}`);continue}l&&a.push(l)}return{cutoutOps:a}}var iYt=(i,e)=>{const[t,n]=vt.useState(null),[r,a]=vt.useState(null),[o,s]=vt.useState(null),[l,c]=vt.useState(null),[u,A]=vt.useState(!0),f=vt.useRef([]),p=vt.useMemo(()=>{const v=Zy(e).pcb_board.list();return v.length===0?null:v[0]},[e]);return vt.useEffect(()=>{if(!i||!p){n(null),a(null),s(null),Zy(e).pcb_board.list().length===0&&c("No pcb_board found in circuitJson."),A(!1);return}if((p.width===0||!p.width)&&(p.height===0||!p.height)&&(!p.outline||p.outline.length<3)){n({platedHoles:[],smtPads:[],vias:[]}),a({}),s(p.thickness??0),A(!1);return}A(!0),c(null);const v=i.Manifold,x=i.CrossSection;f.current.forEach(R=>R.delete()),f.current=[];let B=null;const b={},w={};try{const R=p.thickness||1.6;s(R);let G=eYt(v,x,p,R,f.current);const V=[],{nonPlatedHoleBoardDrills:Y}=VHt(v,e,R,f.current);V.push(...Y);const{platedHoleBoardDrills:J,platedHoleCopperGeoms:q}=KHt(v,e,R,f.current);V.push(...J),b.platedHoles=q;const{viaBoardDrills:$,viaCopperGeoms:X}=ZHt(v,e,R,f.current);if(V.push(...$),b.vias=X,V.length>0){const ve=v.union(V);f.current.push(ve);const Be=G.subtract(ve);f.current.push(Be),G=Be}const{cutoutOps:de}=nYt(v,x,e,R,f.current);if(de.length>0){const ve=v.union(de);f.current.push(ve);const Be=G.subtract(ve);f.current.push(Be),G=Be}if(B=G,B){const ve=B.getMesh(),Be=L4(ve),Ie=Jce[p.material]??__.fr4Green;b.board={geometry:Be,color:new Tc(Ie[0],Ie[1],Ie[2])}}const{smtPadGeoms:ue}=XHt(v,e,R,f.current);b.smtPads=ue,n(b);const ge=dLe[p.material]??__.fr4GreenSolderWithMask,be=`rgb(${Math.round(ge[0]*255)}, ${Math.round(ge[1]*255)}, ${Math.round(ge[2]*255)})`;w.topTrace=BLe({layer:"top",circuitJson:e,boardData:p,traceColor:be,traceTextureResolution:SO}),w.bottomTrace=BLe({layer:"bottom",circuitJson:e,boardData:p,traceColor:be,traceTextureResolution:SO});const Qe="rgb(255,255,255)";w.topSilkscreen=bLe({layer:"top",circuitJson:e,boardData:p,silkscreenColor:Qe,traceTextureResolution:SO}),w.bottomSilkscreen=bLe({layer:"bottom",circuitJson:e,boardData:p,silkscreenColor:Qe,traceTextureResolution:SO}),a(w)}catch(R){console.error("Error processing geometry with Manifold in hook:",R),c(R.message||"An unknown error occurred while processing geometry in hook."),n(null),a(null)}finally{A(!1)}return()=>{f.current.forEach(R=>R.delete()),f.current=[]}},[i,e,p]),{geoms:t,textures:r,pcbThickness:o,error:l,isLoading:u,boardData:p}};function rYt(i){const e=[];if(!i)return e;if(i.board&&i.board.geometry){const n=new RC(i.board.geometry,new hD({color:i.board.color,side:Fx,flatShading:!0}));n.name="board-geom",e.push(n)}const t=n=>{n&&n.forEach(r=>{const a=new RC(r.geometry,new hD({color:r.color,side:Fx,flatShading:!0}));a.name=r.key,e.push(a)})};return t(i.platedHoles),t(i.smtPads),t(i.vias),e}function aYt(i,e,t){const n=[];if(!i||!e||t===null)return n;const r=(c,u,A,f)=>{if(!c)return null;const p=new jS(e.width,e.height),v=new VS({map:c,transparent:!0,side:Fx,depthWrite:!1}),x=new RC(p,v);return x.position.set(e.center.x,e.center.y,u),A&&x.rotation.set(Math.PI,0,0),x.name=`${A?"bottom":"top"}-${f}-texture-plane`,x},a=r(i.topTrace,t/2+.015,!1,"trace");a&&n.push(a);const o=r(i.topSilkscreen,t/2+.017,!1,"silkscreen");o&&n.push(o);const s=r(i.bottomTrace,-t/2-.015,!0,"trace");s&&n.push(s);const l=r(i.bottomSilkscreen,-t/2-.017,!0,"silkscreen");return l&&n.push(l),n}var oYt="https://cdn.jsdelivr.net/npm/manifold-3d@3.1.1",sYt=({circuitJson:i,autoRotateDisabled:e,clickToInteractEnabled:t,children:n})=>{const r=ALe(n),a=vt.useMemo(()=>i??r,[i,r]),[o,s]=vt.useState(null),[l,c]=vt.useState(null);vt.useEffect(()=>{(async()=>{try{const Y=`${oYt}/manifold.wasm`,q=await a6t({locateFile:($,X)=>$==="manifold.wasm"?Y:X+$});q.setup(),s(q)}catch(Y){console.error("Failed to load Manifold from CDN:",Y),c(`Failed to load Manifold module: ${Y instanceof Error?Y.message:"Unknown error"}`)}})()},[]);const{geoms:u,textures:A,pcbThickness:f,error:p,isLoading:v,boardData:x}=iYt(o,a),B=vt.useMemo(()=>rYt(u),[u]),b=vt.useMemo(()=>aYt(A,x,f),[A,x,f]),w=vt.useMemo(()=>Zy(a).cad_component.list(),[a]),R=vt.useMemo(()=>{if(!x)return;const{width:V=0,height:Y=0}=x;return{width:V,height:Y}},[x]),G=vt.useMemo(()=>{if(!x)return[5,5,5];const{width:V=0,height:Y=0}=x,J=Math.max(V,1),q=Math.max(Y,1),$=Math.max(J,q,5);return[$*.75,$*.75,$*.75]},[x]);return l?ft.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",l]}):o?p?ft.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",p]}):v?ft.jsx("div",{style:{padding:"1em"},children:"Processing board geometry..."}):ft.jsxs(uLe,{initialCameraPosition:G,autoRotateDisabled:e,clickToInteractEnabled:t,boardDimensions:R,children:[B.map((V,Y)=>ft.jsx("primitive",{object:V},`${V.name}-${Y}`)),b.map((V,Y)=>ft.jsx("primitive",{object:V},`${V.name}-${Y}`)),w.map(V=>ft.jsx(_Le,{fallback:({error:Y})=>ft.jsx(ELe,{cad_component:V,error:Y}),children:ft.jsx(cLe,{cad_component:V,circuitJson:a})},V.cad_component_id))]}):ft.jsx("div",{style:{padding:"1em"},children:"Loading Manifold module..."})},lYt=sYt,cYt=({containerRef:i})=>{const[e,t]=vt.useState(!1),[n,r]=vt.useState({x:0,y:0}),a=vt.useRef(null),o=vt.useRef(null),s=vt.useCallback(p=>{p.preventDefault();const v=typeof p.clientX=="number"?p.clientX:0,x=typeof p.clientY=="number"?p.clientY:0;if(!o.current)return;const{x:B,y:b}=o.current,w=Math.abs(v-B),R=Math.abs(x-b),G=10;if(w>G||R>G){o.current=null;return}r({x:v,y:x}),t(!0),o.current=null},[r,t]),l=vt.useCallback(p=>{if(p.touches.length===1){const v=p.touches[0];v?o.current={x:v.clientX,y:v.clientY}:o.current=null}else o.current=null},[]),c=vt.useCallback(p=>{if(!o.current||p.touches.length!==1)return;const v=p.touches[0];if(v){const x=Math.abs(v.clientX-o.current.x),B=Math.abs(v.clientY-o.current.y),b=10;(x>b||B>b)&&(o.current=null)}else o.current=null},[]),u=vt.useCallback(()=>{setTimeout(()=>{o.current&&(o.current=null)},0)},[]),A=vt.useCallback(p=>{const v=p.target;a.current&&!a.current.contains(v)&&t(!1)},[]);return vt.useEffect(()=>{if(e)return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[e,A]),{menuVisible:e,menuPos:n,menuRef:a,contextMenuEventHandlers:{onMouseDown:p=>{p.button===2?o.current={x:p.clientX,y:p.clientY}:o.current=null},onContextMenu:s,onTouchStart:l,onTouchMove:c,onTouchEnd:u},setMenuVisible:t}},uYt=i=>{const[e,t]=vt.useState("jscad"),n=vt.useRef(null),{menuVisible:r,menuPos:a,menuRef:o,contextMenuEventHandlers:s,setMenuVisible:l}=cYt({containerRef:n}),c=A=>{t(A),l(!1)};vt.useEffect(()=>{const A=window.localStorage.getItem("cadViewerEngine");(A==="jscad"||A==="manifold")&&t(A)},[]),vt.useEffect(()=>{window.localStorage.setItem("cadViewerEngine",e)},[e]);const u=i.circuitJson?JSON.stringify(i.circuitJson):void 0;return ft.jsxs("div",{ref:n,style:{width:"100%",height:"100%",position:"relative"},...s,children:[e==="jscad"?ft.jsx(OHt,{...i}):ft.jsx(lYt,{...i}),ft.jsxs("div",{style:{position:"absolute",right:8,top:8,background:"#222",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:12,opacity:.7,userSelect:"none"},children:["Engine: ",ft.jsx("b",{children:e==="jscad"?"JSCAD":"Manifold"})]}),r&&ft.jsx("div",{ref:o,style:{position:"fixed",top:a.y,left:a.x,background:"#23272f",color:"#f5f6fa",borderRadius:6,boxShadow:"0 6px 24px 0 rgba(0,0,0,0.18)",zIndex:1e3,minWidth:200,border:"1px solid #353945",padding:0,fontSize:15,fontWeight:500,transition:"opacity 0.1s"},children:ft.jsxs("div",{style:{padding:"12px 18px",cursor:"pointer",display:"flex",alignItems:"center",gap:10,color:"#f5f6fa",fontWeight:500,borderRadius:6,transition:"background 0.1s"},onClick:()=>c(e==="jscad"?"manifold":"jscad"),onMouseOver:A=>A.currentTarget.style.background="#2d313a",onMouseOut:A=>A.currentTarget.style.background="transparent",children:["Switch to ",e==="jscad"?"Manifold":"JSCAD"," Engine",ft.jsx("span",{style:{fontSize:12,marginLeft:"auto",opacity:.5,fontWeight:400},children:e==="jscad"?"experimental":"default"})]})})]},u)},AYt=A1(Zzt());A1(rLe()),(0,AYt.default)("tscircuit:3d-viewer:convert-circuit-json-to-3d-svg");const dYt=({error:i})=>ft.jsx("div",{"data-testid":"error-container",className:"rf-error-container rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ft.jsxs("div",{className:"rf-p-4",children:[ft.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error Loading 3D Viewer"}),ft.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-700",children:i.message}),ft.jsx("details",{style:{whiteSpace:"pre-wrap"},className:"rf-text-xs rf-font-mono rf-text-red-600 rf-mt-2",children:i.stack})]})}),fYt=vt.createContext(null),qce={didCatch:!1,error:null};class BR extends vt.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=qce}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(e!==null){for(var t,n,r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];(t=(n=this.props).onReset)===null||t===void 0||t.call(n,{args:a,reason:"imperative-api"}),this.setState(qce)}}componentDidCatch(e,t){var n,r;(n=(r=this.props).onError)===null||n===void 0||n.call(r,e,t)}componentDidUpdate(e,t){const{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&t.error!==null&&hYt(e.resetKeys,r)){var a,o;(a=(o=this.props).onReset)===null||a===void 0||a.call(o,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(qce)}}render(){const{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:a,error:o}=this.state;let s=e;if(a){const l={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof t=="function")s=t(l);else if(n)s=vt.createElement(n,l);else if(r!==void 0)s=r;else throw o}return vt.createElement(fYt.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},s)}}function hYt(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return i.length!==e.length||i.some((t,n)=>!Object.is(t,e[n]))}function pYt(i,e){if(i==null)return{};var t={},n=Object.keys(i),r,a;for(a=0;a<n.length;a++)r=n[a],!(e.indexOf(r)>=0)&&(t[r]=i[r]);return t}var gYt=["color"],mYt=vt.forwardRef(function(i,e){var t=i.color,n=t===void 0?"currentColor":t,r=pYt(i,gYt);return vt.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},r,{ref:e}),vt.createElement("path",{d:"M7.49933 0.25C3.49635 0.25 0.25 3.49593 0.25 7.50024C0.25 10.703 2.32715 13.4206 5.2081 14.3797C5.57084 14.446 5.70302 14.2222 5.70302 14.0299C5.70302 13.8576 5.69679 13.4019 5.69323 12.797C3.67661 13.235 3.25112 11.825 3.25112 11.825C2.92132 10.9874 2.44599 10.7644 2.44599 10.7644C1.78773 10.3149 2.49584 10.3238 2.49584 10.3238C3.22353 10.375 3.60629 11.0711 3.60629 11.0711C4.25298 12.1788 5.30335 11.8588 5.71638 11.6732C5.78225 11.205 5.96962 10.8854 6.17658 10.7043C4.56675 10.5209 2.87415 9.89918 2.87415 7.12104C2.87415 6.32925 3.15677 5.68257 3.62053 5.17563C3.54576 4.99226 3.29697 4.25521 3.69174 3.25691C3.69174 3.25691 4.30015 3.06196 5.68522 3.99973C6.26337 3.83906 6.8838 3.75895 7.50022 3.75583C8.1162 3.75895 8.73619 3.83906 9.31523 3.99973C10.6994 3.06196 11.3069 3.25691 11.3069 3.25691C11.7026 4.25521 11.4538 4.99226 11.3795 5.17563C11.8441 5.68257 12.1245 6.32925 12.1245 7.12104C12.1245 9.9063 10.4292 10.5192 8.81452 10.6985C9.07444 10.9224 9.30633 11.3648 9.30633 12.0413C9.30633 13.0102 9.29742 13.7922 9.29742 14.0299C9.29742 14.2239 9.42828 14.4496 9.79591 14.3788C12.6746 13.4179 14.75 10.7025 14.75 7.50024C14.75 3.49593 11.5036 0.25 7.49933 0.25Z",fill:n,fillRule:"evenodd",clipRule:"evenodd"}))});/**
13083
+ at `+o}return e},MO.buildMessage=function(i,e){var t={literal:function(c){return'"'+r(c.text)+'"'},class:function(c){var u=c.parts.map(function(A){return Array.isArray(A)?a(A[0])+"-"+a(A[1]):a(A)});return"["+(c.inverted?"^":"")+u.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(c){return c.description}};function n(c){return c.charCodeAt(0).toString(16).toUpperCase()}function r(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+n(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+n(u)})}function a(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+n(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+n(u)})}function o(c){return t[c.type](c)}function s(c){var u=c.map(o),A,f;if(u.sort(),u.length>0){for(A=1,f=1;A<u.length;A++)u[A-1]!==u[A]&&(u[f]=u[A],f++);u.length=f}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function l(c){return c?'"'+r(c)+'"':"end of input"}return"Expected "+s(i)+" but "+l(e)+" found."};function DHt(i){var A,f,p,v;const e=(0,SHt.vectorText)({height:i.font_size*.45,input:i.text});let t=i.ccw_rotation??0;e.forEach(x=>{x.length===29?(e.splice(e.indexOf(x),1,x.slice(0,15)),e.splice(e.indexOf(x),0,x.slice(14,29))):x.length===17&&(e.splice(e.indexOf(x),1,x.slice(0,10)),e.splice(e.indexOf(x),0,x.slice(9,17)))});const n=e.flatMap(x=>x),r={minX:Math.min(...n.map(x=>x[0])),maxX:Math.max(...n.map(x=>x[0])),minY:Math.min(...n.map(x=>x[1])),maxY:Math.max(...n.map(x=>x[1]))},a=(r.minX+r.maxX)/2,o=(r.minY+r.maxY)/2;let s=-a,l=-o;(A=i.anchor_alignment)!=null&&A.includes("right")?s=-r.maxX:(f=i.anchor_alignment)!=null&&f.includes("left")&&(s=-r.minX),(p=i.anchor_alignment)!=null&&p.includes("top")?l=-r.maxY:(v=i.anchor_alignment)!=null&&v.includes("bottom")&&(l=-r.minY);const c=[];if(i.layer==="bottom"&&(c.push(O9(a,o),{a:-1,b:0,c:0,d:1,e:0,f:0},O9(-a,-o)),t=-t),t){const x=t*Math.PI/180;c.push(O9(a,o),CLe(x),O9(-a,-o))}let u=e;if(c.length>0){const x=vLe(...c);u=e.map(B=>B.map(([b,w])=>{const{x:R,y:G}=mLe(x,{x:b,y:w});return[R,G]}))}return{textOutlines:u,xOffset:s,yOffset:l}}var RHt=A1(_R()),NHt=A1(Yce()),THt=A1(EO()),UHt=A1(BO()),PHt=A1(N4());function kHt(i,e){if(i.route.length<2)return;const t=i.route.map(c=>[c.x,c.y]),n=(0,RHt.line)(t),r=i.stroke_width||.1,a=(0,NHt.expand)({delta:r/2,corners:"round"},n),o=i.layer==="bottom"?-1:1,s=o*e.pcbThickness/2+o*pv*1.5;let l=(0,UHt.translate)([0,0,s],(0,THt.extrudeLinear)({height:.012},a));return l=(0,PHt.colorize)([1,1,1],l),l}var ILe=["initializing","processing_plated_holes","processing_holes","processing_cutouts","processing_pads","processing_traces","processing_vias","processing_silkscreen_text","processing_silkscreen_paths","finalizing","done"],FHt=class{constructor(i,e){Je(this,"circuitJson");Je(this,"board");Je(this,"plated_holes");Je(this,"holes");Je(this,"pads");Je(this,"traces");Je(this,"pcb_vias");Je(this,"silkscreenTexts");Je(this,"silkscreenPaths");Je(this,"pcb_cutouts");Je(this,"boardGeom",null);Je(this,"platedHoleGeoms",[]);Je(this,"holeGeoms",[]);Je(this,"padGeoms",[]);Je(this,"traceGeoms",[]);Je(this,"viaGeoms",[]);Je(this,"silkscreenTextGeoms",[]);Je(this,"silkscreenPathGeoms",[]);Je(this,"state","initializing");Je(this,"currentIndex",0);Je(this,"ctx");Je(this,"onCompleteCallback");Je(this,"finalGeoms",[]);this.circuitJson=i,this.onCompleteCallback=e,this.board=Zy(i).pcb_board.list()[0],this.plated_holes=Zy(i).pcb_plated_hole.list(),this.holes=Zy(i).pcb_hole.list(),this.pads=Zy(i).pcb_smtpad.list(),this.traces=Zy(i).pcb_trace.list(),this.pcb_vias=Zy(i).pcb_via.list(),this.silkscreenTexts=Zy(i).pcb_silkscreen_text.list(),this.silkscreenPaths=Zy(i).pcb_silkscreen_path.list(),this.pcb_cutouts=Zy(i).pcb_cutout.list(),this.ctx={pcbThickness:1.2},this.initializeBoard()}getHoleToCut(i,e){const t=pv/10;for(const n of this.pcb_vias)if(Math.abs(n.x-i)<t&&Math.abs(n.y-e)<t&&n.hole_diameter)return{diameter:n.hole_diameter};for(const n of this.plated_holes)if(n.shape==="circle"&&Math.abs(n.x-i)<t&&Math.abs(n.y-e)<t&&n.hole_diameter)return{diameter:n.hole_diameter};return null}initializeBoard(){this.board.outline&&this.board.outline.length>0?this.boardGeom=hLe({outline:this.board.outline},this.ctx.pcbThickness):this.boardGeom=(0,jx.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.state="processing_plated_holes",this.currentIndex=0}goToNextState(){const i=ILe.indexOf(this.state);i!==-1&&(this.state=ILe[i+1],this.currentIndex=0)}step(i=1){if(this.state==="done"||!this.boardGeom)return!0;for(let e=0;e<i&&this.state!=="done";e++)switch(this.state){case"processing_plated_holes":this.currentIndex<this.plated_holes.length?(this.processPlatedHole(this.plated_holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_holes":this.currentIndex<this.holes.length?(this.processHole(this.holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_pads":this.currentIndex<this.pads.length?(this.processPad(this.pads[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_traces":this.currentIndex<this.traces.length?(this.processTrace(this.traces[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_vias":this.currentIndex<this.pcb_vias.length?(this.processVia(this.pcb_vias[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_text":this.currentIndex<this.silkscreenTexts.length?(this.processSilkscreenText(this.silkscreenTexts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_silkscreen_paths":this.currentIndex<this.silkscreenPaths.length?(this.processSilkscreenPath(this.silkscreenPaths[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_cutouts":this.currentIndex<this.pcb_cutouts.length?(this.processCutout(this.pcb_cutouts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"finalizing":this.finalize(),this.state="done";break}return this.state==="done"}processCutout(i){if(!this.boardGeom)return;let e=null;const t=this.ctx.pcbThickness*1.5;switch(i.shape){case"rect":if(e=(0,jx.cuboid)({center:[i.center.x,i.center.y,0],size:[i.width,i.height,t]}),i.rotation){const a=i.rotation*Math.PI/180;e=(0,GM.rotateZ)(a,e)}break;case"circle":e=(0,jx.cylinder)({center:[i.center.x,i.center.y,0],radius:i.radius,height:t});break;case"polygon":let n=i.points.map(a=>[a.x,a.y]);if(n.length<3){console.warn(`PCB Cutout [${i.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}fLe(n)&&(n=n.reverse());const r=(0,jx.polygon)({points:n});e=(0,wO.extrudeLinear)({height:t},r),e=(0,GM.translate)([0,0,-t/2],e);break}e&&(this.boardGeom=(0,LM.subtract)(this.boardGeom,e))}processPlatedHole(i,e={}){if(this.boardGeom){if(i.shape==="circle"||i.shape==="circular_hole_with_rect_pad"){const t=(0,jx.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2+pv,height:this.ctx.pcbThickness*1.5});e.dontCutBoard||(this.boardGeom=(0,LM.subtract)(this.boardGeom,t));const n=pLe(i,this.ctx);this.platedHoleGeoms.push(n)}else if(i.shape==="pill"||i.shape==="pill_hole_with_rect_pad"){const t=i.hole_height>i.hole_width,n=t?i.hole_height:i.hole_width,r=t?i.hole_width:i.hole_height,a=r/2,o=Math.abs(n-r),s=(0,LM.union)((0,jx.cuboid)({center:[i.x,i.y,0],size:t?[r,o,this.ctx.pcbThickness*1.5]:[o,r,this.ctx.pcbThickness*1.5]}),(0,jx.cylinder)({center:t?[i.x,i.y-o/2,0]:[i.x-o/2,i.y,0],radius:a,height:this.ctx.pcbThickness*1.5}),(0,jx.cylinder)({center:t?[i.x,i.y+o/2,0]:[i.x+o/2,i.y,0],radius:a,height:this.ctx.pcbThickness*1.5}));e.dontCutBoard||(this.boardGeom=(0,LM.subtract)(this.boardGeom,s));const l=pLe(i,this.ctx);this.platedHoleGeoms.push(l)}}}processHole(i){if(this.boardGeom&&(i.hole_shape==="round"||i.hole_shape==="circle")){const e=(0,jx.cylinder)({center:[i.x,i.y,0],radius:i.hole_diameter/2+pv,height:this.ctx.pcbThickness*1.5});this.boardGeom=(0,LM.subtract)(this.boardGeom,e)}}processPad(i){const e=i.layer==="bottom"?-1:1,t=e*this.ctx.pcbThickness/2+e*pv*2;if(i.shape==="rect"){const n=(0,xR.colorize)(__.copper,(0,jx.cuboid)({center:[i.x,i.y,t],size:[i.width,i.height,pv]}));this.padGeoms.push(n)}else if(i.shape==="rotated_rect"){let n=(0,jx.cuboid)({center:[0,0,0],size:[i.width,i.height,pv]});const r=i.ccw_rotation*Math.PI/180;n=(0,GM.rotateZ)(r,n);const a=(0,GM.translate)([i.x,i.y,t],n),o=(0,xR.colorize)(__.copper,a);this.padGeoms.push(o)}else if(i.shape==="circle"){const n=(0,xR.colorize)(__.copper,(0,jx.cylinder)({center:[i.x,i.y,t],radius:i.radius,height:pv}));this.padGeoms.push(n)}}processTrace(i){const{route:e}=i;if(e.length<2)return;let t=[],n=null,r=.1;const a=()=>{if(t.length>=2&&n){const o=n==="bottom"?-1:1,s=o*this.ctx.pcbThickness/2+o*pv,l=(0,jx.line)(t),c=(0,gLe.expand)({delta:r/2,corners:"round"},l);let u=(0,GM.translate)([0,0,s],(0,wO.extrudeLinear)({height:pv},c));const A=t[0],f=t[t.length-1],p=this.getHoleToCut(A[0],A[1]);if(p){const B=(0,jx.cylinder)({center:[A[0],A[1],s+pv/2],radius:p.diameter/2+pv,height:pv});u=(0,LM.subtract)(u,B)}const v=this.getHoleToCut(f[0],f[1]);if(v){const B=(0,jx.cylinder)({center:[f[0],f[1],s+pv/2],radius:v.diameter/2+pv,height:pv});u=(0,LM.subtract)(u,B)}const x=dLe[this.board.material]??__.fr4GreenSolderWithMask;u=(0,xR.colorize)(x,u),this.traceGeoms.push(u)}t=[],n=null};for(let o=0;o<e.length;o++){const s=e[o];if(s.route_type==="wire")n===null?(n=s.layer,r=s.width,t.push([s.x,s.y])):s.layer===n?t.push([s.x,s.y]):(t.push([s.x,s.y]),a(),n=s.layer,r=s.width,e[o-1]?t.push([s.x,s.y]):t.push([s.x,s.y]));else if(s.route_type==="via"){t.push([s.x,s.y]),a();const l=e[o+1];l&&l.route_type==="wire"&&(n=l.layer,r=l.width,t.push([s.x,s.y]))}}a()}processVia(i){this.processPlatedHole({x:i.x,y:i.y,hole_diameter:i.hole_diameter,outer_diameter:i.outer_diameter,shape:"circle",layers:["top","bottom"],type:"pcb_plated_hole",pcb_plated_hole_id:`via_${i.pcb_via_id}`},{dontCutBoard:!0})}processSilkscreenText(i){const{textOutlines:e,xOffset:t,yOffset:n}=DHt(i);for(const r of e){const a=r.map(A=>[A[0]+t+i.anchor_position.x,A[1]+n+i.anchor_position.y]),o=(0,jx.line)(a),s=i.font_size||.25,l=Math.min(Math.max(.01,s*.1),s*.05),c=(0,gLe.expand)({delta:l,corners:"round"},o);let u;i.layer==="bottom"?u=(0,GM.translate)([0,0,-this.ctx.pcbThickness/2-pv],(0,wO.extrudeLinear)({height:.012},c)):u=(0,GM.translate)([0,0,this.ctx.pcbThickness/2+pv],(0,wO.extrudeLinear)({height:.012},c)),u=(0,xR.colorize)([1,1,1],u),this.silkscreenTextGeoms.push(u)}}processSilkscreenPath(i){const e=kHt(i,this.ctx);e&&this.silkscreenPathGeoms.push(e)}finalize(){if(!this.boardGeom)return;const i=Jce[this.board.material]??__.fr4Green;this.boardGeom=(0,xR.colorize)(i,this.boardGeom),this.finalGeoms=[this.boardGeom,...this.platedHoleGeoms,...this.padGeoms,...this.traceGeoms,...this.viaGeoms,...this.silkscreenTextGeoms,...this.silkscreenPathGeoms],this.onCompleteCallback&&this.onCompleteCallback(this.finalGeoms)}getGeoms(){return this.finalGeoms}},GHt=i=>{const[e,t]=vt.useState(null),n=vt.useRef(!1);return vt.useEffect(()=>{let r=!1;if(!i){t(null);return}if(!i.some(l=>l.type==="pcb_board")){t(null);return}const a=bHt(i);t(a);const o=new FHt(i,l=>{});return(async()=>{if(!n.current){n.current=!0;try{let l=!1;for(;!l&&!r;)l=o.step(1),l||await new Promise(c=>setTimeout(c,0));r||t(o.getGeoms())}catch(l){console.error("Error during board geometry building:",l)}finally{n.current=!1}}})(),()=>{r=!0}},[i]),e},ELe=({error:i,cad_component:e})=>{const[t,n]=vt.useState(!1),[r,a]=vt.useState(null),o=vt.useCallback(c=>{c!=null&&c.mousePosition?(n(!0),a(c.mousePosition)):(n(!1),a(null))},[]),s=vt.useCallback(()=>{n(!1),a(null)},[]);let l=[0,0,0];return e!=null&&e.position&&(l=[e.position.x,e.position.y,e.position.z],l=l.map(c=>Number.isNaN(c)?0:c)),ft.jsxs(ft.Fragment,{children:[ft.jsx(bO,{isHovered:t,onHover:o,onUnhover:s,position:l,children:ft.jsxs("group",{position:l,children:[ft.jsxs("mesh",{renderOrder:-99999,rotation:[Math.PI/4,Math.PI/4,0],ref:c=>{c&&(c.renderOrder=999999)},children:[ft.jsx("boxGeometry",{args:[.5,.5,.5]}),ft.jsx("meshStandardMaterial",{depthTest:!1,transparent:!0,color:"red",opacity:.5})]}),ft.jsxs(xM,{scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:[i.toString().slice(0,50),"..."]})]})}),t&&r?ft.jsx(Z5e,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"6px",borderRadius:"4px",color:"red",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:i.toString()}):null]})};function LHt({stlUrl:i,mtlUrl:e,color:t,opacity:n=1}){const r=Oie($zt,i),a=vt.useRef();return ft.jsxs("mesh",{ref:a,children:[ft.jsx("primitive",{object:r,attach:"geometry"}),ft.jsx("meshStandardMaterial",{color:t,transparent:n!==1,opacity:n})]})}var _Le=class extends Qg.Component{constructor(i){super(i),this.state={hasError:!1,error:null}}static getDerivedStateFromError(i){return{hasError:!0,error:i}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},OHt=vt.forwardRef(({soup:i,circuitJson:e,children:t,autoRotateDisabled:n,clickToInteractEnabled:r},a)=>{const o=ALe(t),s=vt.useMemo(()=>i??e??o,[i,e,o]),l=GHt(s),c=vt.useMemo(()=>{if(!s)return[5,5,5];try{const p=Zy(s).pcb_board.list()[0];if(!p)return[5,5,5];const{width:v,height:x}=p;if(!v&&!x)return[5,5,5];const B=5,b=Math.max(v,B),w=Math.max(x,B),R=Math.max(b,w);return[R/2,R/2,R]}catch(p){return console.error(p),[5,5,5]}},[s]),u=vt.useMemo(()=>{if(s)try{const p=Zy(s).pcb_board.list()[0];return p?{width:p.width??0,height:p.height??0}:void 0}catch(p){console.error(p);return}},[s]),{stls:A}=vHt(l),f=Zy(s).cad_component.list();return ft.jsxs(uLe,{ref:a,autoRotateDisabled:n,initialCameraPosition:c,clickToInteractEnabled:r,boardDimensions:u,children:[A.map(({stlUrl:p,color:v},x)=>ft.jsx(LHt,{stlUrl:p,color:v,opacity:x===0?.95:1},p)),f.map(p=>ft.jsx(_Le,{fallback:({error:v})=>ft.jsx(ELe,{cad_component:p,error:v}),children:ft.jsx(cLe,{cad_component:p,circuitJson:s},p.cad_component_id)},p.cad_component_id))]})});function L4(i){const e=new Bp;if(e.setAttribute("position",new xA(i.vertProperties,3)),e.setIndex(new dk(i.triVerts,1)),i.runIndex&&i.runIndex.length>1&&i.runOriginalID)for(let t=0;t<i.runIndex.length-1;t++){const n=i.runIndex[t],r=i.runIndex[t+1]-n;e.addGroup(n,r,0)}else e.addGroup(0,i.triVerts.length,0);return e}function xLe(i){return i&&i.route_type==="wire"&&typeof i.layer=="string"&&typeof i.width=="number"}function BLe({layer:i,circuitJson:e,boardData:t,traceColor:n,traceTextureResolution:r}){const a=Zy(e).pcb_trace.list(),o=Zy(e).pcb_via.list(),s=Zy(e).pcb_plated_hole.list(),l=a.filter(v=>v.route.some(x=>xLe(x)&&x.layer===i));if(l.length===0)return null;const c=document.createElement("canvas"),u=Math.floor(t.width*r),A=Math.floor(t.height*r);c.width=u,c.height=A;const f=c.getContext("2d");if(!f)return null;i==="bottom"&&(f.translate(0,A),f.scale(1,-1)),l.forEach(v=>{let x=!0;f.beginPath(),f.strokeStyle=n,f.lineCap="round",f.lineJoin="round";let B=0;for(const b of v.route){if(!xLe(b)||b.layer!==i){x||f.stroke(),x=!0;continue}const w=b.x,R=b.y;B=b.width*r,f.lineWidth=B;const G=(w-t.center.x+t.width/2)*r,V=(-(R-t.center.y)+t.height/2)*r;x?(f.moveTo(G,V),x=!1):f.lineTo(G,V)}x||f.stroke()}),f.globalCompositeOperation="destination-out",f.fillStyle="black",o.forEach(v=>{const x=(v.x-t.center.x+t.width/2)*r,B=(-(v.y-t.center.y)+t.height/2)*r,b=v.outer_diameter/2*r;f.beginPath(),f.arc(x,B,b,0,2*Math.PI,!1),f.fill()}),s.forEach(v=>{if(v.layers.includes(i)&&v.shape==="circle"){const x=(v.x-t.center.x+t.width/2)*r,B=(-(v.y-t.center.y)+t.height/2)*r,b=v.outer_diameter/2*r;f.beginPath(),f.arc(x,B,b,0,2*Math.PI,!1),f.fill()}}),f.globalCompositeOperation="source-over";const p=new KK(c);return p.generateMipmaps=!0,p.minFilter=Qb,p.magFilter=Q1,p.anisotropy=16,p.needsUpdate=!0,p}var zHt=A1(Pce());function bLe({layer:i,circuitJson:e,boardData:t,silkscreenColor:n="rgb(255,255,255)",traceTextureResolution:r}){const a=Zy(e).pcb_silkscreen_text.list(),o=Zy(e).pcb_silkscreen_path.list(),s=a.filter(v=>v.layer===i),l=o.filter(v=>v.layer===i);if(s.length===0&&l.length===0)return null;const c=document.createElement("canvas"),u=Math.floor(t.width*r),A=Math.floor(t.height*r);c.width=u,c.height=A;const f=c.getContext("2d");if(!f)return null;i==="bottom"&&(f.translate(0,A),f.scale(1,-1)),f.strokeStyle=n,f.fillStyle=n,l.forEach(v=>{v.route.length<2||(f.beginPath(),f.lineWidth=(v.stroke_width||.1)*r,f.lineCap="round",f.lineJoin="round",v.route.forEach((x,B)=>{const b=(x.x-t.center.x+t.width/2)*r,w=(-(x.y-t.center.y)+t.height/2)*r;B===0?f.moveTo(b,w):f.lineTo(b,w)}),f.stroke())}),s.forEach(v=>{const x=v.font_size||.25,B=Math.min(Math.max(.01,x*.1),x*.05)*r;f.lineWidth=B,f.lineCap="butt",f.lineJoin="miter";const b=(0,zHt.vectorText)({height:x*.45,input:v.text}),w=[];b.forEach(ge=>{ge.length===29?(w.push(ge.slice(0,15)),w.push(ge.slice(14,29))):ge.length===17?(w.push(ge.slice(0,10)),w.push(ge.slice(9,17))):w.push(ge)});const R=w.flat(),G={minX:R.length>0?Math.min(...R.map(ge=>ge[0])):0,maxX:R.length>0?Math.max(...R.map(ge=>ge[0])):0,minY:R.length>0?Math.min(...R.map(ge=>ge[1])):0,maxY:R.length>0?Math.max(...R.map(ge=>ge[1])):0},V=(G.minX+G.maxX)/2,Y=(G.minY+G.maxY)/2;let J=-V,q=-Y;const $=v.anchor_alignment||"center";$.includes("left")?J=-G.minX:$.includes("right")&&(J=-G.maxX),$.includes("top")?q=-G.maxY:$.includes("bottom")&&(q=-G.minY);const X=[];let de=v.ccw_rotation??0;if(v.layer==="bottom"&&(X.push(O9(V,Y),{a:-1,b:0,c:0,d:1,e:0,f:0},O9(-V,-Y)),de=-de),de){const ge=de*Math.PI/180;X.push(O9(V,Y),CLe(ge),O9(-V,-Y))}const ue=X.length>0?vLe(...X):void 0;w.forEach(ge=>{f.beginPath(),ge.forEach((be,Qe)=>{let ve={x:be[0],y:be[1]};ue&&(ve=mLe(ue,ve));const Be=ve.x+J+v.anchor_position.x,Ie=ve.y+q+v.anchor_position.y,Ne=(Be-t.center.x+t.width/2)*r,Ue=(-(Ie-t.center.y)+t.height/2)*r;Qe===0?f.moveTo(Ne,Ue):f.lineTo(Ne,Ue)}),f.stroke()})});const p=new KK(c);return p.generateMipmaps=!0,p.minFilter=Qb,p.magFilter=Q1,p.anisotropy=16,p.needsUpdate=!0,p}function HHt({Manifold:i,x:e,y:t,diameter:n,thickness:r,segments:a=32}){return i.cylinder(r*1.2,n/2,n/2,a,!0).translate([e,t,0])}function SLe({Manifold:i,x:e,y:t,outerDiameter:n,thickness:r,zOffset:a=.001,segments:o=32}){const s=n/2+a;return i.cylinder(r*1.2,s,s,o,!0).translate([e,t,0])}function YHt(i){return(i.shape==="circle"||i.hole_shape==="circle")&&typeof i.hole_diameter=="number"}function VHt(i,e,t,n){const r=[];return Zy(e).pcb_hole.list().forEach(o=>{if(YHt(o)){const s=HHt({Manifold:i,x:o.x,y:o.y,diameter:o.hole_diameter,thickness:t,segments:mQ});n.push(s),r.push(s)}}),{nonPlatedHoleBoardDrills:r}}var QLe=new Tc(...__.copper);function KHt(i,e,t,n){const r=[],a=Zy(e).pcb_plated_hole.list(),o=[];return a.forEach((s,l)=>{if(s.shape==="circle"){const c=SLe({Manifold:i,x:s.x,y:s.y,outerDiameter:s.outer_diameter,thickness:t,zOffset:_w,segments:mQ});n.push(c),r.push(c);const u=t+2*_w;let A=i.cylinder(u,s.outer_diameter/2,s.outer_diameter/2,mQ,!0);n.push(A);const f=i.cylinder(u*1.05,s.hole_diameter/2,s.hole_diameter/2,mQ,!0);n.push(f);const p=A.subtract(f);n.push(p);const v=p.translate([s.x,s.y,0]);n.push(v);const x=L4(v.getMesh());o.push({key:`ph-${s.pcb_plated_hole_id||l}`,geometry:x,color:QLe})}else if(s.shape==="pill"){const c=s.hole_width,u=s.hole_height,A=u>c,f=A?u:c,p=A?c:u,v=.4,x=A?s.outer_height??p+v/2:s.outer_width??f+v/2,B=A?s.outer_width??f+v/2:s.outer_height??p+v/2,b=(ge,be,Qe)=>{const ve=be/2,Be=ge-be;let Ie;if(Be<1e-9)Ie=i.cylinder(Qe,ve,ve,mQ,!0);else{const Ne=i.cube([Math.max(0,Be),be,Qe],!0),Ue=i.cylinder(Qe,ve,ve,mQ,!0).translate([-Be/2,0,0]),Le=i.cylinder(Qe,ve,ve,mQ,!0).translate([Be/2,0,0]);Ie=i.union([Ne,Ue,Le]),n.push(Ne,Ue,Le)}return n.push(Ie),Ie},w=f+2*_w,R=p+2*_w,G=t*1.2;let V=b(w,R,G);if(A){const ge=V.rotate([0,0,90]);n.push(ge),V=ge}const Y=V.translate([s.x,s.y,0]);n.push(Y),r.push(Y);const J=t+2*_w,q=b(x,B,J),$=b(f,p,J*1.05);let X=q.subtract($);if(n.push(X),A){const ge=X.rotate([0,0,90]);n.push(ge),X=ge}const de=X.translate([s.x,s.y,0]);n.push(de);const ue=L4(de.getMesh());o.push({key:`ph-${s.pcb_plated_hole_id||l}`,geometry:ue,color:QLe})}}),{platedHoleBoardDrills:r,platedHoleCopperGeoms:o}}function jHt({Manifold:i,x:e,y:t,outerDiameter:n,holeDiameter:r,thickness:a,zOffset:o=.001,segments:s=32}){const l=a+2*o;let c=i.cylinder(l,n/2,-1,s,!0);const u=i.cylinder(l*1.05,r/2,-1,s,!0);return c.subtract(u).translate([e,t,0])}var JHt=new Tc(...__.copper);function ZHt(i,e,t,n){const r=[],a=Zy(e).pcb_via.list(),o=[];return a.forEach((s,l)=>{if(typeof s.outer_diameter=="number"){const c=SLe({Manifold:i,x:s.x,y:s.y,outerDiameter:s.outer_diameter,thickness:t,zOffset:_w,segments:mQ});n.push(c),r.push(c)}if(typeof s.outer_diameter=="number"&&typeof s.hole_diameter=="number"){const c=jHt({Manifold:i,x:s.x,y:s.y,outerDiameter:s.outer_diameter,holeDiameter:s.hole_diameter,thickness:t,zOffset:_w,segments:mQ});n.push(c);const u=L4(c.getMesh());o.push({key:`via-${s.pcb_via_id||l}`,geometry:u,color:JHt})}}),{viaBoardDrills:r,viaCopperGeoms:o}}function qHt({Manifold:i,pad:e,padBaseThickness:t}){return e.shape==="rect"?i.cube([e.width,e.height,t],!0):e.shape==="circle"&&e.radius?i.cylinder(t,e.radius,-1,32,!0):null}var WHt=new Tc(...__.copper);function XHt(i,e,t,n){const r=[];return Zy(e).pcb_smtpad.list().forEach((o,s)=>{const l=EHt,c=o.layer==="bottom"?-t/2-l/2-_w:t/2+l/2+_w;let u=qHt({Manifold:i,pad:o,padBaseThickness:l});if(u){n.push(u);const A=u.translate([o.x,o.y,c]);n.push(A);const f=L4(A.getMesh());r.push({key:`pad-${o.pcb_smtpad_id||s}`,geometry:f,color:WHt})}}),{smtPadGeoms:r}}var $Ht=i=>{let e=0;for(let n=0;n<i.length;n++){const r=(n+1)%i.length;i[n]&&i[r]&&(e+=i[n][0]*i[r][1],e-=i[r][0]*i[n][1])}return e/2<=0};function eYt(i,e,t,n,r){let a;if(t.outline&&t.outline.length>=3){let o=t.outline.map(l=>[l.x,l.y]);$Ht(o)&&(o=o.reverse());const s=e.ofPolygons([o]);r.push(s),a=i.extrude(s,n,void 0,void 0,void 0,!0),r.push(a)}else t.outline&&t.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),a=i.cube([t.width,t.height,n],!0),r.push(a),a=a.translate([t.center.x,t.center.y,0]),r.push(a);return a}var tYt=i=>{let e=0;for(let n=0;n<i.length;n++){const r=(n+1)%i.length;i[n]&&i[r]&&(e+=i[n][0]*i[r][1],e-=i[r][0]*i[n][1])}return e/2<=0};function nYt(i,e,t,n,r){const a=[],o=Zy(t).pcb_cutout.list();for(const s of o){let l;const c=n*1.5;switch(s.shape){case"rect":if(l=i.cube([s.width,s.height,c],!0),r.push(l),s.rotation){s.rotation*Math.PI/180;const f=l.rotate([0,0,s.rotation]);r.push(f),l=f}l=l.translate([s.center.x,s.center.y,0]),r.push(l);break;case"circle":l=i.cylinder(c,s.radius,-1,mQ,!0),r.push(l),l=l.translate([s.center.x,s.center.y,0]),r.push(l);break;case"polygon":if(s.points.length<3){console.warn(`PCB Cutout [${s.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);continue}let u=s.points.map(f=>[f.x,f.y]);tYt(u)&&(u=u.reverse());const A=e.ofPolygons([u]);r.push(A),l=i.extrude(A,c,0,0,[1,1],!0),r.push(l);break;default:console.warn(`Unsupported cutout shape: ${s.shape} for cutout ${s.pcb_cutout_id}`);continue}l&&a.push(l)}return{cutoutOps:a}}var iYt=(i,e)=>{const[t,n]=vt.useState(null),[r,a]=vt.useState(null),[o,s]=vt.useState(null),[l,c]=vt.useState(null),[u,A]=vt.useState(!0),f=vt.useRef([]),p=vt.useMemo(()=>{const v=Zy(e).pcb_board.list();return v.length===0?null:v[0]},[e]);return vt.useEffect(()=>{if(!i||!p){n(null),a(null),s(null),Zy(e).pcb_board.list().length===0&&c("No pcb_board found in circuitJson."),A(!1);return}if((p.width===0||!p.width)&&(p.height===0||!p.height)&&(!p.outline||p.outline.length<3)){n({platedHoles:[],smtPads:[],vias:[]}),a({}),s(p.thickness??0),A(!1);return}A(!0),c(null);const v=i.Manifold,x=i.CrossSection;f.current.forEach(R=>R.delete()),f.current=[];let B=null;const b={},w={};try{const R=p.thickness||1.6;s(R);let G=eYt(v,x,p,R,f.current);const V=[],{nonPlatedHoleBoardDrills:Y}=VHt(v,e,R,f.current);V.push(...Y);const{platedHoleBoardDrills:J,platedHoleCopperGeoms:q}=KHt(v,e,R,f.current);V.push(...J),b.platedHoles=q;const{viaBoardDrills:$,viaCopperGeoms:X}=ZHt(v,e,R,f.current);if(V.push(...$),b.vias=X,V.length>0){const ve=v.union(V);f.current.push(ve);const Be=G.subtract(ve);f.current.push(Be),G=Be}const{cutoutOps:de}=nYt(v,x,e,R,f.current);if(de.length>0){const ve=v.union(de);f.current.push(ve);const Be=G.subtract(ve);f.current.push(Be),G=Be}if(B=G,B){const ve=B.getMesh(),Be=L4(ve),Ie=Jce[p.material]??__.fr4Green;b.board={geometry:Be,color:new Tc(Ie[0],Ie[1],Ie[2])}}const{smtPadGeoms:ue}=XHt(v,e,R,f.current);b.smtPads=ue,n(b);const ge=dLe[p.material]??__.fr4GreenSolderWithMask,be=`rgb(${Math.round(ge[0]*255)}, ${Math.round(ge[1]*255)}, ${Math.round(ge[2]*255)})`;w.topTrace=BLe({layer:"top",circuitJson:e,boardData:p,traceColor:be,traceTextureResolution:SO}),w.bottomTrace=BLe({layer:"bottom",circuitJson:e,boardData:p,traceColor:be,traceTextureResolution:SO});const Qe="rgb(255,255,255)";w.topSilkscreen=bLe({layer:"top",circuitJson:e,boardData:p,silkscreenColor:Qe,traceTextureResolution:SO}),w.bottomSilkscreen=bLe({layer:"bottom",circuitJson:e,boardData:p,silkscreenColor:Qe,traceTextureResolution:SO}),a(w)}catch(R){console.error("Error processing geometry with Manifold in hook:",R),c(R.message||"An unknown error occurred while processing geometry in hook."),n(null),a(null)}finally{A(!1)}return()=>{f.current.forEach(R=>R.delete()),f.current=[]}},[i,e,p]),{geoms:t,textures:r,pcbThickness:o,error:l,isLoading:u,boardData:p}};function rYt(i){const e=[];if(!i)return e;if(i.board&&i.board.geometry){const n=new RC(i.board.geometry,new hD({color:i.board.color,side:Fx,flatShading:!0}));n.name="board-geom",e.push(n)}const t=n=>{n&&n.forEach(r=>{const a=new RC(r.geometry,new hD({color:r.color,side:Fx,flatShading:!0}));a.name=r.key,e.push(a)})};return t(i.platedHoles),t(i.smtPads),t(i.vias),e}function aYt(i,e,t){const n=[];if(!i||!e||t===null)return n;const r=(c,u,A,f)=>{if(!c)return null;const p=new jS(e.width,e.height),v=new VS({map:c,transparent:!0,side:Fx,depthWrite:!1}),x=new RC(p,v);return x.position.set(e.center.x,e.center.y,u),A&&x.rotation.set(Math.PI,0,0),x.name=`${A?"bottom":"top"}-${f}-texture-plane`,x},a=r(i.topTrace,t/2+.015,!1,"trace");a&&n.push(a);const o=r(i.topSilkscreen,t/2+.017,!1,"silkscreen");o&&n.push(o);const s=r(i.bottomTrace,-t/2-.015,!0,"trace");s&&n.push(s);const l=r(i.bottomSilkscreen,-t/2-.017,!0,"silkscreen");return l&&n.push(l),n}var oYt="https://cdn.jsdelivr.net/npm/manifold-3d@3.1.1",sYt=({circuitJson:i,autoRotateDisabled:e,clickToInteractEnabled:t,children:n})=>{const r=ALe(n),a=vt.useMemo(()=>i??r,[i,r]),[o,s]=vt.useState(null),[l,c]=vt.useState(null);vt.useEffect(()=>{(async()=>{try{const Y=`${oYt}/manifold.wasm`,q=await a6t({locateFile:($,X)=>$==="manifold.wasm"?Y:X+$});q.setup(),s(q)}catch(Y){console.error("Failed to load Manifold from CDN:",Y),c(`Failed to load Manifold module: ${Y instanceof Error?Y.message:"Unknown error"}`)}})()},[]);const{geoms:u,textures:A,pcbThickness:f,error:p,isLoading:v,boardData:x}=iYt(o,a),B=vt.useMemo(()=>rYt(u),[u]),b=vt.useMemo(()=>aYt(A,x,f),[A,x,f]),w=vt.useMemo(()=>Zy(a).cad_component.list(),[a]),R=vt.useMemo(()=>{if(!x)return;const{width:V=0,height:Y=0}=x;return{width:V,height:Y}},[x]),G=vt.useMemo(()=>{if(!x)return[5,5,5];const{width:V=0,height:Y=0}=x,J=Math.max(V,1),q=Math.max(Y,1),$=Math.max(J,q,5);return[$*.75,$*.75,$*.75]},[x]);return l?ft.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",l]}):o?p?ft.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",p]}):v?ft.jsx("div",{style:{padding:"1em"},children:"Processing board geometry..."}):ft.jsxs(uLe,{initialCameraPosition:G,autoRotateDisabled:e,clickToInteractEnabled:t,boardDimensions:R,children:[B.map((V,Y)=>ft.jsx("primitive",{object:V},`${V.name}-${Y}`)),b.map((V,Y)=>ft.jsx("primitive",{object:V},`${V.name}-${Y}`)),w.map(V=>ft.jsx(_Le,{fallback:({error:Y})=>ft.jsx(ELe,{cad_component:V,error:Y}),children:ft.jsx(cLe,{cad_component:V,circuitJson:a})},V.cad_component_id))]}):ft.jsx("div",{style:{padding:"1em"},children:"Loading Manifold module..."})},lYt=sYt,cYt=({containerRef:i})=>{const[e,t]=vt.useState(!1),[n,r]=vt.useState({x:0,y:0}),a=vt.useRef(null),o=vt.useRef(null),s=vt.useCallback(p=>{p.preventDefault();const v=typeof p.clientX=="number"?p.clientX:0,x=typeof p.clientY=="number"?p.clientY:0;if(!o.current)return;const{x:B,y:b}=o.current,w=Math.abs(v-B),R=Math.abs(x-b),G=10;if(w>G||R>G){o.current=null;return}r({x:v,y:x}),t(!0),o.current=null},[r,t]),l=vt.useCallback(p=>{if(p.touches.length===1){const v=p.touches[0];v?o.current={x:v.clientX,y:v.clientY}:o.current=null}else o.current=null},[]),c=vt.useCallback(p=>{if(!o.current||p.touches.length!==1)return;const v=p.touches[0];if(v){const x=Math.abs(v.clientX-o.current.x),B=Math.abs(v.clientY-o.current.y),b=10;(x>b||B>b)&&(o.current=null)}else o.current=null},[]),u=vt.useCallback(()=>{setTimeout(()=>{o.current&&(o.current=null)},0)},[]),A=vt.useCallback(p=>{const v=p.target;a.current&&!a.current.contains(v)&&t(!1)},[]);return vt.useEffect(()=>{if(e)return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[e,A]),{menuVisible:e,menuPos:n,menuRef:a,contextMenuEventHandlers:{onMouseDown:p=>{p.button===2?o.current={x:p.clientX,y:p.clientY}:o.current=null},onContextMenu:s,onTouchStart:l,onTouchMove:c,onTouchEnd:u},setMenuVisible:t}},uYt=i=>{const[e,t]=vt.useState("jscad"),n=vt.useRef(null),{menuVisible:r,menuPos:a,menuRef:o,contextMenuEventHandlers:s,setMenuVisible:l}=cYt({containerRef:n}),c=A=>{t(A),l(!1)};vt.useEffect(()=>{const A=window.localStorage.getItem("cadViewerEngine");(A==="jscad"||A==="manifold")&&t(A)},[]),vt.useEffect(()=>{window.localStorage.setItem("cadViewerEngine",e)},[e]);const u=i.circuitJson?JSON.stringify(i.circuitJson):void 0;return ft.jsxs("div",{ref:n,style:{width:"100%",height:"100%",position:"relative"},...s,children:[e==="jscad"?ft.jsx(OHt,{...i}):ft.jsx(lYt,{...i}),ft.jsxs("div",{style:{position:"absolute",right:8,top:8,background:"#222",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:12,opacity:.7,userSelect:"none"},children:["Engine: ",ft.jsx("b",{children:e==="jscad"?"JSCAD":"Manifold"})]}),r&&ft.jsx("div",{ref:o,style:{position:"fixed",top:a.y,left:a.x,background:"#23272f",color:"#f5f6fa",borderRadius:6,boxShadow:"0 6px 24px 0 rgba(0,0,0,0.18)",zIndex:1e3,minWidth:200,border:"1px solid #353945",padding:0,fontSize:15,fontWeight:500,transition:"opacity 0.1s"},children:ft.jsxs("div",{style:{padding:"12px 18px",cursor:"pointer",display:"flex",alignItems:"center",gap:10,color:"#f5f6fa",fontWeight:500,borderRadius:6,transition:"background 0.1s"},onClick:()=>c(e==="jscad"?"manifold":"jscad"),onMouseOver:A=>A.currentTarget.style.background="#2d313a",onMouseOut:A=>A.currentTarget.style.background="transparent",children:["Switch to ",e==="jscad"?"Manifold":"JSCAD"," Engine",ft.jsx("span",{style:{fontSize:12,marginLeft:"auto",opacity:.5,fontWeight:400},children:e==="jscad"?"experimental":"default"})]})})]},u)},AYt=A1(Zzt());A1(rLe()),(0,AYt.default)("tscircuit:3d-viewer:convert-circuit-json-to-3d-svg");const dYt=({error:i})=>ft.jsx("div",{"data-testid":"error-container",className:"rf-error-container rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ft.jsxs("div",{className:"rf-p-4",children:[ft.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error Loading 3D Viewer"}),ft.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-700",children:i.message}),ft.jsx("details",{style:{whiteSpace:"pre-wrap"},className:"rf-text-xs rf-font-mono rf-text-red-600 rf-mt-2",children:i.stack})]})}),fYt=vt.createContext(null),qce={didCatch:!1,error:null};class BR extends vt.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=qce}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(e!==null){for(var t,n,r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];(t=(n=this.props).onReset)===null||t===void 0||t.call(n,{args:a,reason:"imperative-api"}),this.setState(qce)}}componentDidCatch(e,t){var n,r;(n=(r=this.props).onError)===null||n===void 0||n.call(r,e,t)}componentDidUpdate(e,t){const{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&t.error!==null&&hYt(e.resetKeys,r)){var a,o;(a=(o=this.props).onReset)===null||a===void 0||a.call(o,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(qce)}}render(){const{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:a,error:o}=this.state;let s=e;if(a){const l={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof t=="function")s=t(l);else if(n)s=vt.createElement(n,l);else if(r!==void 0)s=r;else throw o}return vt.createElement(fYt.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},s)}}function hYt(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return i.length!==e.length||i.some((t,n)=>!Object.is(t,e[n]))}function pYt(i,e){if(i==null)return{};var t={},n=Object.keys(i),r,a;for(a=0;a<n.length;a++)r=n[a],!(e.indexOf(r)>=0)&&(t[r]=i[r]);return t}var gYt=["color"],mYt=vt.forwardRef(function(i,e){var t=i.color,n=t===void 0?"currentColor":t,r=pYt(i,gYt);return vt.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},r,{ref:e}),vt.createElement("path",{d:"M7.49933 0.25C3.49635 0.25 0.25 3.49593 0.25 7.50024C0.25 10.703 2.32715 13.4206 5.2081 14.3797C5.57084 14.446 5.70302 14.2222 5.70302 14.0299C5.70302 13.8576 5.69679 13.4019 5.69323 12.797C3.67661 13.235 3.25112 11.825 3.25112 11.825C2.92132 10.9874 2.44599 10.7644 2.44599 10.7644C1.78773 10.3149 2.49584 10.3238 2.49584 10.3238C3.22353 10.375 3.60629 11.0711 3.60629 11.0711C4.25298 12.1788 5.30335 11.8588 5.71638 11.6732C5.78225 11.205 5.96962 10.8854 6.17658 10.7043C4.56675 10.5209 2.87415 9.89918 2.87415 7.12104C2.87415 6.32925 3.15677 5.68257 3.62053 5.17563C3.54576 4.99226 3.29697 4.25521 3.69174 3.25691C3.69174 3.25691 4.30015 3.06196 5.68522 3.99973C6.26337 3.83906 6.8838 3.75895 7.50022 3.75583C8.1162 3.75895 8.73619 3.83906 9.31523 3.99973C10.6994 3.06196 11.3069 3.25691 11.3069 3.25691C11.7026 4.25521 11.4538 4.99226 11.3795 5.17563C11.8441 5.68257 12.1245 6.32925 12.1245 7.12104C12.1245 9.9063 10.4292 10.5192 8.81452 10.6985C9.07444 10.9224 9.30633 11.3648 9.30633 12.0413C9.30633 13.0102 9.29742 13.7922 9.29742 14.0299C9.29742 14.2239 9.42828 14.4496 9.79591 14.3788C12.6746 13.4179 14.75 10.7025 14.75 7.50024C14.75 3.49593 11.5036 0.25 7.49933 0.25Z",fill:n,fillRule:"evenodd",clipRule:"evenodd"}))});/**
13084
13084
  * @license lucide-react v0.488.0 - ISC
13085
13085
  *
13086
13086
  * This source code is licensed under the ISC license.
@@ -13717,7 +13717,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}return YAe}BXt();function LHe(i,e,t,n=
13717
13717
  &:hover {
13718
13718
  background-color: rgba(255, 255, 255, 0.1);
13719
13719
  }
13720
- `,onClick:n=>{n.stopPropagation(),t()},children:[ft.jsx("input",{type:"checkbox",checked:e}),ft.jsx("span",{style:{color:"#eee"},children:i})]}),Xtn=({children:i,elements:e})=>{const[t,n]=qE(q=>[q.is_mouse_over_container,q.setIsMouseOverContainer]),[r,a]=vt.useState(!1),[o,s]=vt.useState(!1),[l,c]=vt.useState(!1),[u,A]=qE(q=>[q.selected_layer,q.selectLayer]),[f,p,v,x,B,b]=qE(q=>[q.in_move_footprint_mode,q.in_draw_trace_mode,q.is_showing_rats_nest,q.is_showing_multiple_traces_length,q.is_showing_autorouting,q.is_showing_drc_errors]),w=qE(q=>q.setEditMode),R=qE(q=>q.setIsShowingRatsNest),G=qE(q=>q.setIsShowingMultipleTracesLength),V=qE(q=>q.setIsShowingAutorouting),Y=qE(q=>q.setIsShowingDrcErrors);$9("1",()=>A("top")),$9("2",()=>A("bottom")),$9("3",()=>A("inner1")),$9("4",()=>A("inner2")),$9("5",()=>A("inner3")),$9("6",()=>A("inner4")),$9("7",()=>A("inner5")),$9("8",()=>A("inner6"));const J=(e==null?void 0:e.filter(q=>q.type.includes("error")).length)??0;return ft.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>{n(!0)},onMouseLeave:q=>{n(!1),s(!1)},children:[i,ft.jsxs("div",{style:{position:"absolute",bottom:4,right:8,pointerEvents:"none",color:"white",fontSize:11,opacity:t?.5:0,transition:"opacity 1s",transitionDelay:"2s",fontFamily:"sans-serif"},children:["@tscircuit/pcb-viewer@",qtn.version]}),ft.jsxs("div",{style:{position:"absolute",opacity:t?1:0,top:16,left:16,transition:t?"opacity 100ms linear":"opacity 1s linear",zIndex:Zx.toolbarOverlay,color:"red",display:"flex",fontSize:12,height:100,fontFamily:"sans-serif"},children:[ft.jsxs(ZR,{onClick:()=>{s(!o)},onMouseLeave:()=>{o&&s(!1)},children:[ft.jsxs("div",{children:["layer:"," ",ft.jsx("span",{style:{marginLeft:2,fontWeight:500,color:JR[u]},children:u})]}),o&&ft.jsx("div",{style:{marginTop:4,minWidth:120},children:Bde.map(q=>q.replace(/-/g,"")).map(q=>ft.jsx(Wtn,{name:q,selected:q===u,onClick:()=>{A(q.replace(/-/,""))}},q))})]}),ft.jsxs(ZR,{style:J>0?{color:"red"}:{},onClick:()=>c(!l),onMouseLeave:()=>c(!1),children:[ft.jsxs("div",{children:[J," errors"]}),l&&ft.jsx("div",{style:{display:"grid",gridTemplateColumns:"100px 300px"},children:e==null?void 0:e.filter(q=>q.type.includes("error")).map((q,$)=>ft.jsxs(vt.Fragment,{children:[ft.jsx("div",{children:q.error_type}),ft.jsx("div",{children:q.message})]},$))})]}),ft.jsx(ZR,{style:{},onClick:()=>{w(p?"off":"draw_trace")},children:ft.jsxs("div",{children:[p?"✖ ":"","Edit Traces"]})}),ft.jsx(ZR,{style:{},onClick:()=>{w(f?"off":"move_footprint")},children:ft.jsxs("div",{children:[f?"✖ ":"","Move Components"]})}),ft.jsx(ZR,{style:{},onClick:()=>{R(!v)},children:ft.jsxs("div",{children:[v?"✖ ":"","Rats Nest"]})}),ft.jsx(ZR,{onClick:()=>{a(!r)},children:ft.jsxs("div",{children:[ft.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["View"," ",ft.jsx("span",{style:{fontSize:"8px",transform:r?"rotate(180deg)":"rotate(0)",transition:"transform 0.1s ease",display:"inline-block"},children:"▼"})]}),r&&ft.jsxs("div",{style:{marginTop:4,minWidth:120},children:[ft.jsx(Dde,{label:"Show All Trace Lengths",checked:x,onClick:()=>{G(!x)}}),ft.jsx(Dde,{label:"Show Autorouting Animation",checked:B,onClick:()=>{V(!B)}}),ft.jsx(Dde,{label:"Show DRC Errors",checked:b,onClick:()=>{Y(!b)}})]})]})})]})]})},$tn=i=>{const{transform:e,elements:t}=i,[n,r]=vt.useMemo(()=>{const c=i.elements.flatMap(A=>utn(A,i.elements)),u=vw(i.elements);return[c,u]},[i.elements]),[a,o]=vt.useState({drawingObjectIdsWithMouseOver:new Set,primitiveIdsInMousedOverNet:[]}),s=vt.useMemo(()=>ltn({primitivesWithoutInteractionMetadata:n,drawingObjectIdsWithMouseOver:a.drawingObjectIdsWithMouseOver,primitiveIdsInMousedOverNet:a.primitiveIdsInMousedOverNet}),[n,a]),l=vt.useCallback(c=>{var f,p;const u=[];for(const v of c)if(v._element){const x=r.getNetConnectedToId("pcb_port_id"in v._element?(f=v._element)==null?void 0:f.pcb_port_id:"pcb_trace_id"in v._element?(p=v._element)==null?void 0:p.pcb_trace_id:"");u.push(...r.getIdsConnectedToNet(x))}const A=new Set(c.map(v=>v._pcb_drawing_object_id));o({drawingObjectIdsWithMouseOver:A,primitiveIdsInMousedOverNet:u})},[r]);return ft.jsx(Jtn,{elements:t,transform:e,primitives:n,onMouseHoverOverPrimitives:l,children:ft.jsx(Dtn,{disabled:!i.allowEditing,transform:e,soup:t,cancelPanDrag:i.cancelPanDrag,onCreateEditEvent:i.onCreateEditEvent,onModifyEditEvent:i.onModifyEditEvent,children:ft.jsx(Utn,{disabled:!i.allowEditing,transform:e,soup:t,cancelPanDrag:i.cancelPanDrag,onCreateEditEvent:i.onCreateEditEvent,onModifyEditEvent:i.onModifyEditEvent,children:ft.jsx(wtn,{transform:e,focusOnHover:i.focusOnHover,children:ft.jsx(Xtn,{elements:t,children:ft.jsx(Ftn,{transform:e,elements:t,children:ft.jsx(Ztn,{transform:e,soup:t,children:ft.jsx(Stn,{transform:e,debugGraphics:i.debugGraphics,children:ft.jsx(Qtn,{transform:e,elements:t,children:ft.jsx(btn,{transform:e,primitives:s,width:i.width,height:i.height,grid:i.grid})})})})})})})})})})},enn=Yd(Gh(400,300),c_(40,-40)),tnn=({circuitJson:i,debugGraphics:e,height:t=600,initialState:n,allowEditing:r=!0,editEvents:a,onEditEventsChanged:o,focusOnHover:s=!1,clickToInteractEnabled:l=!1})=>{const[c,u]=vt.useState(!l),[A,f]=wde(),[p,v]=vt.useState(enn),{ref:x,setTransform:B,cancelDrag:b}=stn({transform:p,onSetTransform:v,enabled:c});let[w,R]=vt.useState([]);w=a??w;const G=vt.useRef(!1),V=vt.useRef(null),Y=`${(i==null?void 0:i.length)||0}_${(i==null?void 0:i.editCount)||0}`,J=()=>{const ue=(f==null?void 0:f.width)>0?f:{width:500,height:500},{center:ge,width:be,height:Qe}=$.some(Ie=>Ie.type.startsWith("pcb_"))?Wen($.filter(Ie=>Ie.type.startsWith("pcb_"))):{center:{x:0,y:0},width:.001,height:.001},ve=Math.min((ue.width??0)/be,(ue.height??0)/Qe,100)*.75,Be=Yd(Gh((ue.width??0)/2,(ue.height??0)/2),c_(ve,-ve,0,0),Gh(-ge.x,-ge.y));B(Be)};vt.useEffect(()=>{f!=null&&f.width&&i&&i.length!==0&&(G.current||(J(),G.current=!0))},[i,f]);const q=vt.useMemo(()=>(i==null?void 0:i.filter(ue=>ue.type.startsWith("pcb_")||ue.type.startsWith("source_")))??[],[Y]),$=vt.useMemo(()=>uWt({circuitJson:q,editEvents:w}),[q,w]),X=ue=>{R([...w,ue]),o==null||o([...w,ue])},de=ue=>{const ge=w.map(be=>be.edit_event_id===ue.edit_event_id?{...be,...ue}:be);R(ge),o==null||o(ge)};return ft.jsxs("div",{ref:x,style:{position:"relative"},children:[ft.jsx("div",{ref:A,children:ft.jsxs($en,{initialState:n,children:[ft.jsx($tn,{transform:p,height:t,width:f.width,allowEditing:r,focusOnHover:s,cancelPanDrag:b,onCreateEditEvent:X,onModifyEditEvent:de,grid:{spacing:1,view_window:{left:0,right:f.width||500,top:t,bottom:0}},elements:$,debugGraphics:e},f.width),ft.jsx(ttn,{})]})}),l&&!c&&ft.jsx("div",{onClick:()=>{u(!0),J()},onTouchStart:ue=>{const ge=ue.touches[0];V.current={x:ge.clientX,y:ge.clientY}},onTouchEnd:ue=>{const ge=ue.changedTouches[0],be=V.current;if(!be)return;const Qe=Math.abs(ge.clientX-be.x),ve=Math.abs(ge.clientY-be.y);Qe<10&&ve<10&&(ue.preventDefault(),u(!0),J()),V.current=null},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:Zx.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",touchAction:"pan-x pan-y pinch-zoom"},children:ft.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})})]})};const nnn=({containerClassName:i,...e})=>{const t=vt.useRef(null),[n,r]=vt.useState(620);return vt.useLayoutEffect(()=>{const a=()=>{if(t.current){const s=t.current.clientHeight,l=window.innerHeight;r(Math.min(Math.max(s,620),l))}};a();const o=new ResizeObserver(a);return t.current&&o.observe(t.current),window.addEventListener("resize",a),()=>{o.disconnect(),window.removeEventListener("resize",a)}},[]),ft.jsx("div",{ref:t,className:i||"rf-w-full rf-h-full",children:ft.jsx(tnn,{...e,height:n})})},inn='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[500px\\]{max-height:500px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-min-h-0{min-height:0}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[95\\%\\]{width:95%}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis}.rf-truncate,.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-b{border-bottom-width:1px}.rf-border-t{border-top-width:1px}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-text-left{text-align:left}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',rnn=()=>{vt.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=inn,document.head.appendChild(e)},[])},ann=i=>{vt.useEffect(()=>(i?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[i])},tKe=i=>`hsl(${zb.indexOf(i)*137.5%360}, 70%, 50%)`,onn=({phaseTimings:i})=>{if(!i)return null;const e=Object.values(i).reduce((t,n)=>t+n,0);return ft.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[ft.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:zb.map(t=>{const n=i[t]||0,r=n/e*100;return ft.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${r}%`,backgroundColor:tKe(t)},children:ft.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",n.toFixed(1),"ms"]})},t)})}),ft.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},snn=({renderLog:i})=>{const[e,t]=vt.useState("chronological");if(!i)return ft.jsx("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:"No render log, make sure this tab is open when you render (TODO add a rerender button here)"});const n=Object.entries((i==null?void 0:i.phaseTimings)??{});e==="chronological"?n.sort((a,o)=>zb.indexOf(a[0])-zb.indexOf(o[0])):n.sort((a,o)=>o[1]-a[1]);const r=n.reduce((a,[o,s])=>a+s,0);return ft.jsxs("div",{className:"rf-bg-white",children:[ft.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[ft.jsx("div",{children:"Render Logs"}),ft.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[ft.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),ft.jsxs("select",{value:e,onChange:a=>t(a.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[ft.jsx("option",{value:"chronological",children:"Phase Order"}),ft.jsx("option",{value:"longest",children:"Duration"})]})]})]}),ft.jsx(onn,{phaseTimings:i.phaseTimings}),ft.jsxs("table",{className:"rf-w-full rf-text-xs",children:[ft.jsx("thead",{children:ft.jsxs("tr",{children:[ft.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),ft.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),ft.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),ft.jsx("tbody",{children:n.map(([a,o])=>ft.jsxs("tr",{children:[ft.jsx("td",{className:"rf-p-2",children:zb.indexOf(a)}),ft.jsx("td",{className:"rf-p-2",children:a}),ft.jsx("td",{className:"rf-p-2",children:ft.jsx("div",{className:"rf-w-8",children:ft.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:tKe(a),width:`${o/r*100}%`}})})}),ft.jsx("td",{className:"rf-p-2",children:ft.jsxs("div",{className:"rf-flex w-full",children:[ft.jsxs("span",{className:"rf-flex-grow",children:[o,"ms"]}),ft.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(o/r*100).toFixed(1),"%"]})]})})]},a))})]})]})},lnn=({errorMessage:i,errorStack:e,circuitJsonErrors:t})=>{vt.useEffect(()=>{if(i){const n=new Error(i);e&&(n.stack=e);try{VU.captureException(n)}catch{}}},[i,e]),vt.useEffect(()=>{if(t&&t.length>0)for(const n of t){const r=new Error(n.message||"Circuit JSON Error");n.stack&&(r.stack=n.stack);try{VU.captureException(r,{error_type:n.type})}catch{}}},[t])},cnn="0.0.669",Rde={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Nde=new Map,Wz=i=>{const e=Nde.get(i);return e?Object.fromEntries(Object.entries(e.stores).map(([t,n])=>[t,n.getState()])):{}},unn=(i,e,t)=>{if(i===void 0)return{type:"untracked",connection:e.connect(t)};const n=Nde.get(t.name);if(n)return{type:"tracked",store:i,...n};const r={connection:e.connect(t),stores:{}};return Nde.set(t.name,r),{type:"tracked",store:i,...r}},Ann=(i,e={})=>(t,n,r)=>{const{enabled:a,anonymousActionType:o,store:s,...l}=e;let c;try{c=(a??(Rde?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(Rde?"production":void 0)!=="production"&&a&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),i(t,n,r);const{connection:u,...A}=unn(s,c,l);let f=!0;r.setState=(x,B,b)=>{const w=t(x,B);if(!f)return w;const R=b===void 0?{type:o||"anonymous"}:typeof b=="string"?{type:b}:b;return s===void 0?(u==null||u.send(R,n()),w):(u==null||u.send({...R,type:`${s}/${R.type}`},{...Wz(l.name),[s]:r.getState()}),w)};const p=(...x)=>{const B=f;f=!1,t(...x),f=B},v=i(r.setState,n,r);if(A.type==="untracked"?u==null||u.init(v):(A.stores[A.store]=r,u==null||u.init(Object.fromEntries(Object.entries(A.stores).map(([x,B])=>[x,x===A.store?v:B.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let x=!1;const B=r.dispatch;r.dispatch=(...b)=>{(Rde?"production":void 0)!=="production"&&b[0].type==="__setState"&&!x&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),x=!0),B(...b)}}return u.subscribe(x=>{var B;switch(x.type){case"ACTION":if(typeof x.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Tde(x.payload,b=>{if(b.type==="__setState"){if(s===void 0){p(b.state);return}Object.keys(b.state).length!==1&&console.error(`
13720
+ `,onClick:n=>{n.stopPropagation(),t()},children:[ft.jsx("input",{type:"checkbox",checked:e}),ft.jsx("span",{style:{color:"#eee"},children:i})]}),Xtn=({children:i,elements:e})=>{const[t,n]=qE(q=>[q.is_mouse_over_container,q.setIsMouseOverContainer]),[r,a]=vt.useState(!1),[o,s]=vt.useState(!1),[l,c]=vt.useState(!1),[u,A]=qE(q=>[q.selected_layer,q.selectLayer]),[f,p,v,x,B,b]=qE(q=>[q.in_move_footprint_mode,q.in_draw_trace_mode,q.is_showing_rats_nest,q.is_showing_multiple_traces_length,q.is_showing_autorouting,q.is_showing_drc_errors]),w=qE(q=>q.setEditMode),R=qE(q=>q.setIsShowingRatsNest),G=qE(q=>q.setIsShowingMultipleTracesLength),V=qE(q=>q.setIsShowingAutorouting),Y=qE(q=>q.setIsShowingDrcErrors);$9("1",()=>A("top")),$9("2",()=>A("bottom")),$9("3",()=>A("inner1")),$9("4",()=>A("inner2")),$9("5",()=>A("inner3")),$9("6",()=>A("inner4")),$9("7",()=>A("inner5")),$9("8",()=>A("inner6"));const J=(e==null?void 0:e.filter(q=>q.type.includes("error")).length)??0;return ft.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>{n(!0)},onMouseLeave:q=>{n(!1),s(!1)},children:[i,ft.jsxs("div",{style:{position:"absolute",bottom:4,right:8,pointerEvents:"none",color:"white",fontSize:11,opacity:t?.5:0,transition:"opacity 1s",transitionDelay:"2s",fontFamily:"sans-serif"},children:["@tscircuit/pcb-viewer@",qtn.version]}),ft.jsxs("div",{style:{position:"absolute",opacity:t?1:0,top:16,left:16,transition:t?"opacity 100ms linear":"opacity 1s linear",zIndex:Zx.toolbarOverlay,color:"red",display:"flex",fontSize:12,height:100,fontFamily:"sans-serif"},children:[ft.jsxs(ZR,{onClick:()=>{s(!o)},onMouseLeave:()=>{o&&s(!1)},children:[ft.jsxs("div",{children:["layer:"," ",ft.jsx("span",{style:{marginLeft:2,fontWeight:500,color:JR[u]},children:u})]}),o&&ft.jsx("div",{style:{marginTop:4,minWidth:120},children:Bde.map(q=>q.replace(/-/g,"")).map(q=>ft.jsx(Wtn,{name:q,selected:q===u,onClick:()=>{A(q.replace(/-/,""))}},q))})]}),ft.jsxs(ZR,{style:J>0?{color:"red"}:{},onClick:()=>c(!l),onMouseLeave:()=>c(!1),children:[ft.jsxs("div",{children:[J," errors"]}),l&&ft.jsx("div",{style:{display:"grid",gridTemplateColumns:"100px 300px"},children:e==null?void 0:e.filter(q=>q.type.includes("error")).map((q,$)=>ft.jsxs(vt.Fragment,{children:[ft.jsx("div",{children:q.error_type}),ft.jsx("div",{children:q.message})]},$))})]}),ft.jsx(ZR,{style:{},onClick:()=>{w(p?"off":"draw_trace")},children:ft.jsxs("div",{children:[p?"✖ ":"","Edit Traces"]})}),ft.jsx(ZR,{style:{},onClick:()=>{w(f?"off":"move_footprint")},children:ft.jsxs("div",{children:[f?"✖ ":"","Move Components"]})}),ft.jsx(ZR,{style:{},onClick:()=>{R(!v)},children:ft.jsxs("div",{children:[v?"✖ ":"","Rats Nest"]})}),ft.jsx(ZR,{onClick:()=>{a(!r)},children:ft.jsxs("div",{children:[ft.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["View"," ",ft.jsx("span",{style:{fontSize:"8px",transform:r?"rotate(180deg)":"rotate(0)",transition:"transform 0.1s ease",display:"inline-block"},children:"▼"})]}),r&&ft.jsxs("div",{style:{marginTop:4,minWidth:120},children:[ft.jsx(Dde,{label:"Show All Trace Lengths",checked:x,onClick:()=>{G(!x)}}),ft.jsx(Dde,{label:"Show Autorouting Animation",checked:B,onClick:()=>{V(!B)}}),ft.jsx(Dde,{label:"Show DRC Errors",checked:b,onClick:()=>{Y(!b)}})]})]})})]})]})},$tn=i=>{const{transform:e,elements:t}=i,[n,r]=vt.useMemo(()=>{const c=i.elements.flatMap(A=>utn(A,i.elements)),u=vw(i.elements);return[c,u]},[i.elements]),[a,o]=vt.useState({drawingObjectIdsWithMouseOver:new Set,primitiveIdsInMousedOverNet:[]}),s=vt.useMemo(()=>ltn({primitivesWithoutInteractionMetadata:n,drawingObjectIdsWithMouseOver:a.drawingObjectIdsWithMouseOver,primitiveIdsInMousedOverNet:a.primitiveIdsInMousedOverNet}),[n,a]),l=vt.useCallback(c=>{var f,p;const u=[];for(const v of c)if(v._element){const x=r.getNetConnectedToId("pcb_port_id"in v._element?(f=v._element)==null?void 0:f.pcb_port_id:"pcb_trace_id"in v._element?(p=v._element)==null?void 0:p.pcb_trace_id:"");u.push(...r.getIdsConnectedToNet(x))}const A=new Set(c.map(v=>v._pcb_drawing_object_id));o({drawingObjectIdsWithMouseOver:A,primitiveIdsInMousedOverNet:u})},[r]);return ft.jsx(Jtn,{elements:t,transform:e,primitives:n,onMouseHoverOverPrimitives:l,children:ft.jsx(Dtn,{disabled:!i.allowEditing,transform:e,soup:t,cancelPanDrag:i.cancelPanDrag,onCreateEditEvent:i.onCreateEditEvent,onModifyEditEvent:i.onModifyEditEvent,children:ft.jsx(Utn,{disabled:!i.allowEditing,transform:e,soup:t,cancelPanDrag:i.cancelPanDrag,onCreateEditEvent:i.onCreateEditEvent,onModifyEditEvent:i.onModifyEditEvent,children:ft.jsx(wtn,{transform:e,focusOnHover:i.focusOnHover,children:ft.jsx(Xtn,{elements:t,children:ft.jsx(Ftn,{transform:e,elements:t,children:ft.jsx(Ztn,{transform:e,soup:t,children:ft.jsx(Stn,{transform:e,debugGraphics:i.debugGraphics,children:ft.jsx(Qtn,{transform:e,elements:t,children:ft.jsx(btn,{transform:e,primitives:s,width:i.width,height:i.height,grid:i.grid})})})})})})})})})})},enn=Yd(Gh(400,300),c_(40,-40)),tnn=({circuitJson:i,debugGraphics:e,height:t=600,initialState:n,allowEditing:r=!0,editEvents:a,onEditEventsChanged:o,focusOnHover:s=!1,clickToInteractEnabled:l=!1})=>{const[c,u]=vt.useState(!l),[A,f]=wde(),[p,v]=vt.useState(enn),{ref:x,setTransform:B,cancelDrag:b}=stn({transform:p,onSetTransform:v,enabled:c});let[w,R]=vt.useState([]);w=a??w;const G=vt.useRef(!1),V=vt.useRef(null),Y=`${(i==null?void 0:i.length)||0}_${(i==null?void 0:i.editCount)||0}`,J=()=>{const ue=(f==null?void 0:f.width)>0?f:{width:500,height:500},{center:ge,width:be,height:Qe}=$.some(Ie=>Ie.type.startsWith("pcb_"))?Wen($.filter(Ie=>Ie.type.startsWith("pcb_"))):{center:{x:0,y:0},width:.001,height:.001},ve=Math.min((ue.width??0)/be,(ue.height??0)/Qe,100)*.75,Be=Yd(Gh((ue.width??0)/2,(ue.height??0)/2),c_(ve,-ve,0,0),Gh(-ge.x,-ge.y));B(Be)};vt.useEffect(()=>{f!=null&&f.width&&i&&i.length!==0&&(G.current||(J(),G.current=!0))},[i,f]);const q=vt.useMemo(()=>(i==null?void 0:i.filter(ue=>ue.type.startsWith("pcb_")||ue.type.startsWith("source_")))??[],[Y]),$=vt.useMemo(()=>uWt({circuitJson:q,editEvents:w}),[q,w]),X=ue=>{R([...w,ue]),o==null||o([...w,ue])},de=ue=>{const ge=w.map(be=>be.edit_event_id===ue.edit_event_id?{...be,...ue}:be);R(ge),o==null||o(ge)};return ft.jsxs("div",{ref:x,style:{position:"relative"},children:[ft.jsx("div",{ref:A,children:ft.jsxs($en,{initialState:n,children:[ft.jsx($tn,{transform:p,height:t,width:f.width,allowEditing:r,focusOnHover:s,cancelPanDrag:b,onCreateEditEvent:X,onModifyEditEvent:de,grid:{spacing:1,view_window:{left:0,right:f.width||500,top:t,bottom:0}},elements:$,debugGraphics:e},f.width),ft.jsx(ttn,{})]})}),l&&!c&&ft.jsx("div",{onClick:()=>{u(!0),J()},onTouchStart:ue=>{const ge=ue.touches[0];V.current={x:ge.clientX,y:ge.clientY}},onTouchEnd:ue=>{const ge=ue.changedTouches[0],be=V.current;if(!be)return;const Qe=Math.abs(ge.clientX-be.x),ve=Math.abs(ge.clientY-be.y);Qe<10&&ve<10&&(ue.preventDefault(),u(!0),J()),V.current=null},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:Zx.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",touchAction:"pan-x pan-y pinch-zoom"},children:ft.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})})]})};const nnn=({containerClassName:i,...e})=>{const t=vt.useRef(null),[n,r]=vt.useState(620);return vt.useLayoutEffect(()=>{const a=()=>{if(t.current){const s=t.current.clientHeight,l=window.innerHeight;r(Math.min(Math.max(s,620),l))}};a();const o=new ResizeObserver(a);return t.current&&o.observe(t.current),window.addEventListener("resize",a),()=>{o.disconnect(),window.removeEventListener("resize",a)}},[]),ft.jsx("div",{ref:t,className:i||"rf-w-full rf-h-full",children:ft.jsx(tnn,{...e,height:n})})},inn='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[500px\\]{max-height:500px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-min-h-0{min-height:0}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[95\\%\\]{width:95%}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis}.rf-truncate,.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-b{border-bottom-width:1px}.rf-border-t{border-top-width:1px}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-text-left{text-align:left}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',rnn=()=>{vt.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=inn,document.head.appendChild(e)},[])},ann=i=>{vt.useEffect(()=>(i?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[i])},tKe=i=>`hsl(${zb.indexOf(i)*137.5%360}, 70%, 50%)`,onn=({phaseTimings:i})=>{if(!i)return null;const e=Object.values(i).reduce((t,n)=>t+n,0);return ft.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[ft.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:zb.map(t=>{const n=i[t]||0,r=n/e*100;return ft.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${r}%`,backgroundColor:tKe(t)},children:ft.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",n.toFixed(1),"ms"]})},t)})}),ft.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},snn=({renderLog:i})=>{const[e,t]=vt.useState("chronological");if(!i)return ft.jsx("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:"No render log, make sure this tab is open when you render (TODO add a rerender button here)"});const n=Object.entries((i==null?void 0:i.phaseTimings)??{});e==="chronological"?n.sort((a,o)=>zb.indexOf(a[0])-zb.indexOf(o[0])):n.sort((a,o)=>o[1]-a[1]);const r=n.reduce((a,[o,s])=>a+s,0);return ft.jsxs("div",{className:"rf-bg-white",children:[ft.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[ft.jsx("div",{children:"Render Logs"}),ft.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[ft.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),ft.jsxs("select",{value:e,onChange:a=>t(a.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[ft.jsx("option",{value:"chronological",children:"Phase Order"}),ft.jsx("option",{value:"longest",children:"Duration"})]})]})]}),ft.jsx(onn,{phaseTimings:i.phaseTimings}),ft.jsxs("table",{className:"rf-w-full rf-text-xs",children:[ft.jsx("thead",{children:ft.jsxs("tr",{children:[ft.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),ft.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),ft.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),ft.jsx("tbody",{children:n.map(([a,o])=>ft.jsxs("tr",{children:[ft.jsx("td",{className:"rf-p-2",children:zb.indexOf(a)}),ft.jsx("td",{className:"rf-p-2",children:a}),ft.jsx("td",{className:"rf-p-2",children:ft.jsx("div",{className:"rf-w-8",children:ft.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:tKe(a),width:`${o/r*100}%`}})})}),ft.jsx("td",{className:"rf-p-2",children:ft.jsxs("div",{className:"rf-flex w-full",children:[ft.jsxs("span",{className:"rf-flex-grow",children:[o,"ms"]}),ft.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(o/r*100).toFixed(1),"%"]})]})})]},a))})]})]})},lnn=({errorMessage:i,errorStack:e,circuitJsonErrors:t})=>{vt.useEffect(()=>{if(i){const n=new Error(i);e&&(n.stack=e);try{VU.captureException(n)}catch{}}},[i,e]),vt.useEffect(()=>{if(t&&t.length>0)for(const n of t){const r=new Error(n.message||"Circuit JSON Error");n.stack&&(r.stack=n.stack);try{VU.captureException(r,{error_type:n.type})}catch{}}},[t])},cnn="0.0.671",Rde={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Nde=new Map,Wz=i=>{const e=Nde.get(i);return e?Object.fromEntries(Object.entries(e.stores).map(([t,n])=>[t,n.getState()])):{}},unn=(i,e,t)=>{if(i===void 0)return{type:"untracked",connection:e.connect(t)};const n=Nde.get(t.name);if(n)return{type:"tracked",store:i,...n};const r={connection:e.connect(t),stores:{}};return Nde.set(t.name,r),{type:"tracked",store:i,...r}},Ann=(i,e={})=>(t,n,r)=>{const{enabled:a,anonymousActionType:o,store:s,...l}=e;let c;try{c=(a??(Rde?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(Rde?"production":void 0)!=="production"&&a&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),i(t,n,r);const{connection:u,...A}=unn(s,c,l);let f=!0;r.setState=(x,B,b)=>{const w=t(x,B);if(!f)return w;const R=b===void 0?{type:o||"anonymous"}:typeof b=="string"?{type:b}:b;return s===void 0?(u==null||u.send(R,n()),w):(u==null||u.send({...R,type:`${s}/${R.type}`},{...Wz(l.name),[s]:r.getState()}),w)};const p=(...x)=>{const B=f;f=!1,t(...x),f=B},v=i(r.setState,n,r);if(A.type==="untracked"?u==null||u.init(v):(A.stores[A.store]=r,u==null||u.init(Object.fromEntries(Object.entries(A.stores).map(([x,B])=>[x,x===A.store?v:B.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let x=!1;const B=r.dispatch;r.dispatch=(...b)=>{(Rde?"production":void 0)!=="production"&&b[0].type==="__setState"&&!x&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),x=!0),B(...b)}}return u.subscribe(x=>{var B;switch(x.type){case"ACTION":if(typeof x.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Tde(x.payload,b=>{if(b.type==="__setState"){if(s===void 0){p(b.state);return}Object.keys(b.state).length!==1&&console.error(`
13721
13721
  [zustand devtools middleware] Unsupported __setState action format.
13722
13722
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
13723
13723
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }