@tscircuit/runframe 0.0.1540 → 0.0.1541
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.
|
@@ -5131,7 +5131,7 @@ ${a.join(`
|
|
|
5131
5131
|
${E}polygon: ${C.polygon.vertices}
|
|
5132
5132
|
`:a+=`
|
|
5133
5133
|
`,C.children.length>0&&c.push(C.children)}return a}};A.exports=s}}),wue=at({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(e,A){var t=pue(),i=mue(),o=class{constructor(n){this.polygonTree=new i,this.rootnode=new t(null),n&&this.addPolygons(n)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(n,s=!1){this.rootnode.clipTo(n,s)}allPolygons(){const n=[];return this.polygonTree.getPolygons(n),n}addPolygons(n){const s=new Array(n.length);for(let r=0;r<n.length;r++)s[r]=this.polygonTree.addChild(n[r]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};A.exports=o}}),XQA=at({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(e,A){A.exports={Tree:wue()}}}),Due=at({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(e,A){var t=Xn(),i=zQA(),{Tree:o}=XQA(),n=(s,r)=>{if(!i(s,r))return t.create();const a=new o(t.toPolygons(s)),g=new o(t.toPolygons(r));a.invert(),g.clipTo(a),g.invert(),a.clipTo(g),g.clipTo(a),a.addPolygons(g.allPolygons()),a.invert();const c=a.allPolygons();return t.create(c)};A.exports=n}}),IzA=at({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(e,A){var t=Hn(),i=iH(),o=Due(),n=(...s)=>{s=t(s);let r=s.shift();return s.forEach(a=>{r=o(r,a)}),r=i(r),r};A.exports=n}}),Sue=at({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(e,A){var t=Hn(),i=Xn(),o=Cx(),n=VQA(),s=jQA(),r=IzA(),a=(...g)=>{g=t(g);const c=g.map(B=>s({z0:-1,z1:1},B)),I=r(c),l=o(I);return n(l,i.toPolygons(I))};A.exports=a}}),bue=at({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(e,A){var t=Hn(),i=eH(),o=zn(),n=Xn(),s=Sue(),r=IzA(),a=(...g)=>{if(g=t(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only intersect of the types are supported");const c=g[0];return o.isA(c)?s(g):n.isA(c)?r(g):c};A.exports=a}}),_ue=at({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(e,A){var t=Do(),i=Cx(),o=Xn(),n=g=>g.sort((c,I)=>c-I).filter((c,I,l)=>!I||c!==l[I-1]),s=(g,c,I)=>{const l=`${c}`,B=g.get(l);B===void 0?g.set(l,[I]):B.push(I)},r=(g,c)=>{const I=`${c}`;return g.get(I)},a=g=>{const c=i(g),I=o.toPolygons(g),l=I.length,B=new Map,C=t.create();I.forEach((d,f)=>{d.vertices.forEach(m=>{s(B,t.snap(C,m,c),f)})});const E=I.map(d=>{let f=[];return d.vertices.forEach(m=>{f=f.concat(r(B,t.snap(C,m,c)))}),{e:1,d:n(f)}});B.clear();let Q=0;const h=E.length;for(let d=0;d<h;d++){const f=E[d];if(f.e>0){const m=new Array(l);m[d]=!0;do Q=0,m.forEach((D,w)=>{const b=E[w];if(b.e>0){b.e=-1;for(let k=0;k<b.d.length;k++)m[b.d[k]]=!0;Q++}});while(Q>0);f.indexes=m}}const u=[];for(let d=0;d<h;d++)if(E[d].indexes){const f=[];E[d].indexes.forEach((m,D)=>f.push(I[D])),u.push(o.create(f))}return u};A.exports=a}}),xue=at({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(e,A){var t=Hn(),i=Xn(),o=_ue(),n=(...s)=>{if(s=t(s),s.length===0)throw new Error("wrong number of arguments");const r=s.map(a=>i.isA(a)?o(a):a);return r.length===1?r[0]:r};A.exports=n}}),kue=at({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(e,A){var t=Xn(),i=zQA(),{Tree:o}=XQA(),n=(s,r)=>{if(!i(s,r))return t.clone(s);const a=new o(t.toPolygons(s)),g=new o(t.toPolygons(r));a.invert(),a.clipTo(g),g.clipTo(a,!0),a.addPolygons(g.allPolygons()),a.invert();const c=a.allPolygons();return t.create(c)};A.exports=n}}),lzA=at({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(e,A){var t=Hn(),i=iH(),o=kue(),n=(...s)=>{s=t(s);let r=s.shift();return s.forEach(a=>{r=o(r,a)}),r=i(r),r};A.exports=n}}),Fue=at({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(e,A){var t=Hn(),i=Xn(),o=Cx(),n=VQA(),s=jQA(),r=lzA(),a=(...g)=>{g=t(g);const c=g.map(B=>s({z0:-1,z1:1},B)),I=r(c),l=o(I);return n(l,i.toPolygons(I))};A.exports=a}}),Gue=at({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(e,A){var t=Hn(),i=eH(),o=zn(),n=Xn(),s=Fue(),r=lzA(),a=(...g)=>{if(g=t(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only subtract of the types are supported");const c=g[0];return o.isA(c)?s(g):n.isA(c)?r(g):c};A.exports=a}}),BzA=at({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(e,A){var t=Xn(),i=zQA(),{Tree:o}=XQA(),n=(r,a)=>{if(!i(r,a))return s(r,a);const g=new o(t.toPolygons(r)),c=new o(t.toPolygons(a));g.clipTo(c,!1),c.clipTo(g),c.invert(),c.clipTo(g),c.invert();const I=g.allPolygons().concat(c.allPolygons());return t.create(I)},s=(r,a)=>{let g=t.toPolygons(r);return g=g.concat(t.toPolygons(a)),t.create(g)};A.exports=n}}),CzA=at({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(e,A){var t=Hn(),i=iH(),o=BzA(),n=(...s)=>{s=t(s);let r;for(r=1;r<s.length;r+=2)s.push(o(s[r-1],s[r]));let a=s[r-1];return a=i(a),a};A.exports=n}}),QzA=at({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(e,A){var t=Hn(),i=Xn(),o=Cx(),n=VQA(),s=jQA(),r=CzA(),a=(...g)=>{g=t(g);const c=g.map(B=>s({z0:-1,z1:1},B)),I=r(c),l=o(I);return n(l,i.toPolygons(I))};A.exports=a}}),$QA=at({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(e,A){var t=Hn(),i=eH(),o=zn(),n=Xn(),s=QzA(),r=CzA(),a=(...g)=>{if(g=t(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only unions of the same type are supported");const c=g[0];return o.isA(c)?s(g):n.isA(c)?r(g):c};A.exports=a}}),ON=at({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(e,A){A.exports={intersect:bue(),scission:xue(),subtract:Gue(),union:$QA()}}}),$8=at({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(e,A){var{EPS:t,TAU:i}=wr(),o=PjA(),n=KQA(),s=ys(),r=j8(),a=(g,c)=>{const I={delta:1,corners:"edge",closed:!1,segments:16};let{delta:l,corners:B,closed:C,segments:E}=Object.assign({},I,g);if(Math.abs(l)<t)return c;let Q=g.closed?r(c):1;Q===0&&(Q=1);const h=Q>0&&l>=0||Q<0&&l<0;l=Math.abs(l);let u=null,d=[];const f=[],m=s.create(),D=c.length;for(let w=0;w<D;w++){const b=(w+1)%D,k=c[w],_=c[b];h?s.subtract(m,k,_):s.subtract(m,_,k),s.normal(m,m),s.normalize(m,m),s.scale(m,m,l);const N=s.add(s.create(),k,m),M=s.add(s.create(),_,m),H=[N,M];if(u!=null&&(C||!C&&b!==0)){const T=o(u[0],u[1],H[0],H[1]);T?(d.pop(),H[0]=T):f.push({c:k,s0:u,s1:H})}u=[N,M],!(b===0&&!C)&&(d.push(H[0]),d.push(H[1]))}if(C&&u!=null){const w=d[0],b=d[1],k=o(u[0],u[1],w,b);if(k)d[0]=k,d.pop();else{const _=c[0],N=[w,b];f.push({c:_,s0:u,s1:N})}}if(B==="edge"){const w=new Map;d.forEach((_,N)=>w.set(_,N));const b=n.create(),k=n.create();f.forEach(_=>{n.fromPoints(b,_.s0[0],_.s0[1]),n.fromPoints(k,_.s1[0],_.s1[1]);const N=n.intersectPointOfLines(b,k);if(Number.isFinite(N[0])&&Number.isFinite(N[1])){const M=_.s0[1],H=w.get(M);d[H]=N,d[(H+1)%d.length]=void 0}else{const M=_.s1[0],H=w.get(M);d[H]=void 0}}),d=d.filter(_=>_!==void 0)}if(B==="round"){let w=Math.floor(E/4);const b=s.create();f.forEach(k=>{let _=s.angle(s.subtract(b,k.s1[0],k.c));if(_-=s.angle(s.subtract(b,k.s0[1],k.c)),h&&_<0&&(_=_+Math.PI,_<0&&(_=_+Math.PI)),!h&&_>0&&(_=_-Math.PI,_>0&&(_=_-Math.PI)),_!==0){w=Math.floor(E*(Math.abs(_)/i));const N=_/w,M=s.angle(s.subtract(b,k.s0[1],k.c)),H=[];for(let T=1;T<w;T++){const Y=M+N*T,O=s.fromAngleRadians(s.create(),Y);s.scale(O,O,l),s.add(O,O,k.c),H.push(O)}if(H.length>0){const T=k.s0[1];let Y=d.findIndex(O=>s.equals(T,O));Y=(Y+1)%d.length,d.splice(Y,0,...H)}}else{const N=k.s1[0],M=d.findIndex(H=>s.equals(N,H));d.splice(M,1)}})}return d};A.exports=a}}),Rue=at({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(e,A){var t=zn(),i=$8(),o=(n,s)=>{const r={delta:1,corners:"edge",segments:16},{delta:a,corners:g,segments:c}=Object.assign({},r,n);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const B=t.toOutlines(s).map(C=>(n={delta:a,corners:g,closed:!0,segments:c},i(n,C))).reduce((C,E)=>C.concat(t.toSides(t.fromPoints(E))),[]);return t.create(B)};A.exports=o}}),Mue=at({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(e,A){var t=Vg(),i=Do(),o=Xn(),n=ar(),s=(r,a)=>{i.dot(n.plane(a),r)>0&&(a=n.invert(a));const c=[a],I=n.transform(t.fromTranslation(t.create(),r),a),l=a.vertices.length;for(let B=0;B<l;B++){const C=B<l-1?B+1:0,E=n.create([a.vertices[B],I.vertices[B],I.vertices[C],a.vertices[C]]);c.push(E)}return c.push(n.invert(I)),o.create(c)};A.exports=s}}),Nue=at({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(e,A){var{EPS:t,TAU:i}=wr(),o=Vg(),n=Do(),s=gzA(),r=Xn(),a=ar(),g=ezA(),c=iH(),I=BzA(),l=Mue(),B=(h,u,d)=>{const f=u.toString();if(h.has(f))h.get(f)[1].push(d);else{const m=[u,[d]];h.set(f,m)}},C=(h,u,d)=>{const f=u[0].toString(),m=u[1].toString(),D=f<m?`${f},${m}`:`${m},${f}`;if(h.has(D))h.get(D)[1].push(d);else{const w=[u,[d]];h.set(D,w)}},E=(h,u)=>{h.findIndex(f=>f===u)<0&&h.push(u)},Q=(h,u)=>{const d={delta:1,segments:12},{delta:f,segments:m}=Object.assign({},d,h);let D=r.create();const w=new Map,b=new Map,k=n.create(),_=n.create();return r.toPolygons(u).forEach((M,H)=>{const T=n.scale(n.create(),a.plane(M),2*f),Y=a.transform(o.fromTranslation(o.create(),n.scale(n.create(),T,-.5)),M),O=l(T,Y);D=I(D,O);const W=M.vertices;for(let $=0;$<W.length;$++){B(w,W[$],a.plane(M));const iA=($+1)%W.length,gA=[W[$],W[iA]];C(b,gA,a.plane(M))}}),b.forEach(M=>{const H=M[0],T=M[1],Y=H[0],O=H[1],W=n.subtract(n.create(),O,Y);n.normalize(W,W);const $=T[0],iA=n.cross(n.create(),$,W);let gA=[];for(let KA=0;KA<m;KA++)E(gA,KA*i/m);for(let KA=0,EA=T.length;KA<EA;KA++){const kA=T[KA],dA=n.dot(iA,kA),qA=n.dot($,kA);let PA=Math.atan2(dA,qA);PA<0&&(PA+=i),E(gA,PA),PA=Math.atan2(-dA,-qA),PA<0&&(PA+=i),E(gA,PA)}gA=gA.sort(s);const tA=gA.length;let nA,rA;const QA=[],DA=[],RA=[];for(let KA=-1;KA<tA;KA++){const EA=gA[KA<0?KA+tA:KA],kA=Math.sin(EA),dA=Math.cos(EA);n.scale(k,$,dA*f),n.scale(_,iA,kA*f),n.add(k,k,_);const qA=n.add(n.create(),Y,k),PA=n.add(n.create(),O,k);let nt=!1;if(KA>=0&&n.distance(qA,nA)<t&&(nt=!0),!nt){if(KA>=0){QA.push(qA),DA.push(PA);const fA=[rA,PA,qA,nA],et=a.create(fA);RA.push(et)}nA=qA,rA=PA}}DA.reverse(),RA.push(a.create(QA)),RA.push(a.create(DA));const NA=r.create(RA);D=I(D,NA)}),w.forEach(M=>{const H=M[0],T=M[1],Y=T[0];let O=null,W=0;for(let tA=1;tA<T.length;tA++){const nA=T[tA],rA=n.cross(k,Y,nA),QA=n.length(rA);QA>.05&&QA>W&&(W=QA,O=nA)}O||(O=n.orthogonal(k,Y));const $=n.cross(k,Y,O);n.normalize($,$);const iA=n.cross(_,$,Y),gA=g({center:[H[0],H[1],H[2]],radius:f,segments:m,axes:[Y,$,iA]});D=I(D,gA)}),c(D)};A.exports=Q}}),vue=at({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(e,A){var t=Xn(),i=$QA(),o=Nue(),n=(s,r)=>{const a={delta:1,corners:"round",segments:12},{delta:g,corners:c,segments:I}=Object.assign({},a,s);if(c!=="round")throw new Error('corners must be "round" for 3D geometries');if(t.toPolygons(r).length===0)throw new Error("the given geometry cannot be empty");s={delta:g,corners:c,segments:I};const B=o(s,r);return i(r,B)};A.exports=n}}),Lue=at({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(e,A){var t=j8(),i=ys(),o=zn(),n=_g(),s=$8(),r=c=>{let{external:I,internal:l}=c;t(I)<0?I=I.reverse():l=l.reverse();const B=n.fromPoints({closed:!0},I),C=n.fromPoints({closed:!0},l),E=o.toSides(o.fromPoints(n.toPoints(B))),Q=o.toSides(o.fromPoints(n.toPoints(C)));return E.push(...Q),o.create(E)},a=(c,I,l,B)=>{const{points:C,external:E,internal:Q}=c,h=Math.floor(I/2),u=[],d=[];if(l==="round"&&h>0){const m=Math.PI/h,D=C[C.length-1],w=i.angle(i.subtract(i.create(),E[E.length-1],D)),b=C[0],k=i.angle(i.subtract(i.create(),Q[0],b));for(let _=1;_<h;_++){let N=w+m*_,M=i.fromAngleRadians(i.create(),N);i.scale(M,M,B),i.add(M,M,D),u.push(M),N=k+m*_,M=i.fromAngleRadians(i.create(),N),i.scale(M,M,B),i.add(M,M,b),d.push(M)}}const f=[];return f.push(...E,...u,...Q.reverse(),...d),o.fromPoints(f)},g=(c,I)=>{c=Object.assign({},{delta:1,corners:"edge",segments:16},c);const{delta:B,corners:C,segments:E}=c;if(B<=0)throw new Error("the given delta must be positive for paths");if(!(C==="edge"||C==="chamfer"||C==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const Q=I.isClosed,h=n.toPoints(I);if(h.length===0)throw new Error("the given geometry cannot be empty");const u={points:h,external:s({delta:B,corners:C,segments:E,closed:Q},h),internal:s({delta:-B,corners:C,segments:E,closed:Q},h)};return I.isClosed?r(u):a(u,E,C,B)};A.exports=g}}),AEA=at({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(e,A){var t=Hn(),i=zn(),o=Xn(),n=_g(),s=Rue(),r=vue(),a=Lue(),g=(c,...I)=>{if(I=t(I),I.length===0)throw new Error("wrong number of arguments");const l=I.map(B=>n.isA(B)?a(c,B):i.isA(B)?s(c,B):o.isA(B)?r(c,B):B);return l.length===1?l[0]:l};A.exports=g}}),Uue=at({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(e,A){var t=zn(),i=UQA(),o=$8(),n=(s,r)=>{const a={delta:1,corners:"edge",segments:0},{delta:g,corners:c,segments:I}=Object.assign({},a,s);if(!(c==="edge"||c==="chamfer"||c==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const l=t.toOutlines(r),C=l.map(E=>(s={delta:l.reduce((u,d)=>u+i.arePointsInside(E,i.create(d)),0)%2===0?g:-g,corners:c,closed:!0,segments:I},o(s,E))).reduce((E,Q)=>E.concat(t.toSides(t.fromPoints(Q))),[]);return t.create(C)};A.exports=n}}),Hue=at({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(e,A){var t=_g(),i=$8(),o=(n,s)=>{const r={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:a,corners:g,closed:c,segments:I}=Object.assign({},r,n);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');n={delta:a,corners:g,closed:c,segments:I};const l=i(n,t.toPoints(s));return t.fromPoints({closed:c},l)};A.exports=o}}),Yue=at({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(e,A){var t=Hn(),i=zn(),o=_g(),n=Uue(),s=Hue(),r=(a,...g)=>{if(g=t(g),g.length===0)throw new Error("wrong number of arguments");const c=g.map(I=>o.isA(I)?s(a,I):i.isA(I)?n(a,I):I);return c.length===1?c[0]:c};A.exports=r}}),EzA=at({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(e,A){A.exports={expand:AEA(),offset:Yue()}}}),AW=at({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(e,A){var t=Vg(),i=Do(),o=zn(),n=qN(),s=X8(),r=(a,g)=>{const c={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:I,twistAngle:l,twistSteps:B,repair:C}=Object.assign({},c,a);if(B<1)throw new Error("twistSteps must be 1 or more");l===0&&(B=1);const E=i.clone(I),Q=o.toSides(g);if(Q.length===0)throw new Error("the given geometry cannot be empty");const h=n.fromSides(Q);E[2]<0&&n.reverse(h,h);const u=t.create(),d=(f,m,D)=>{const w=m/B*l,b=i.scale(i.create(),E,m/B);return t.multiply(u,t.fromZRotation(u,w),t.fromTranslation(t.create(),b)),n.transform(u,D)};return a={numberOfSlices:B+1,capStart:!0,capEnd:!0,repair:C,callback:d},s(a,h)};A.exports=r}}),Jue=at({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(e,A){var t=zn(),i=_g(),o=AW(),n=(s,r)=>{if(!r.isClosed)throw new Error("extruded path must be closed");const a=i.toPoints(r),g=t.fromPoints(a);return o(s,g)};A.exports=n}}),Tue=at({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(e,A){var t=Hn(),i=zn(),o=_g(),n=AW(),s=Jue(),r=(a,...g)=>{const c={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:I,twistAngle:l,twistSteps:B,repair:C}=Object.assign({},c,a);if(g=t(g),g.length===0)throw new Error("wrong number of arguments");a={offset:[0,0,I],twistAngle:l,twistSteps:B,repair:C};const E=g.map(Q=>o.isA(Q)?s(a,Q):i.isA(Q)?n(a,Q):Q);return E.length===1?E[0]:E};A.exports=r}}),Kue=at({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(e,A){var t=_g(),i=AEA(),o=AW(),n=(s,r)=>{const a={size:1,height:1},{size:g,height:c}=Object.assign({},a,s);if(s.delta=g,s.offset=[0,0,c],t.toPoints(r).length===0)throw new Error("the given geometry cannot be empty");const l=i(s,r);return o(s,l)};A.exports=n}}),Pue=at({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(e,A){var{area:t}=XU(),i=zn(),o=_g(),n=AEA(),s=AW(),r=(a,g)=>{const c={size:1,height:1},{size:I,height:l}=Object.assign({},c,a);a.delta=I,a.offset=[0,0,l];const B=i.toOutlines(g);if(B.length===0)throw new Error("the given geometry cannot be empty");const E=B.map(h=>(t(h)<0&&h.reverse(),n(a,o.fromPoints({closed:!0},h)))).reduce((h,u)=>h.concat(i.toSides(u)),[]),Q=i.create(E);return s(a,Q)};A.exports=r}}),que=at({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(e,A){var t=Hn(),i=zn(),o=_g(),n=Kue(),s=Pue(),r=(a,...g)=>{const c={size:1,height:1},{size:I,height:l}=Object.assign({},c,a);if(g=t(g),g.length===0)throw new Error("wrong number of arguments");if(I<=0)throw new Error("size must be positive");if(l<=0)throw new Error("height must be positive");const B=g.map(C=>o.isA(C)?n(a,C):i.isA(C)?s(a,C):C);return B.length===1?B[0]:B};A.exports=r}}),Oue=at({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(e,A){var{TAU:t}=wr(),i=Vg(),o=zn(),n=X8(),s=qN(),r=(a,g)=>{const c={angle:t,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:I,startAngle:l,pitch:B,height:C,endOffset:E,segmentsPerRotation:Q}=Object.assign({},c,a);if(C!=0&&(B=C/(I/t)),Q<3)throw new Error("The number of segments per rotation needs to be at least 3.");const u=o.toSides(g);if(u.length===0)throw new Error("The given geometry cannot be empty");const d=u.filter(_=>_[0][0]>=0);let f=s.fromSides(u);d.length===0&&(f=s.reverse(f));const m=Math.round(Q/t*Math.abs(I)),D=m>=2?m:2,w=i.create(),b=i.create(),k=(_,N,M)=>{const H=l+I/D*N,T=E/D*N,Y=(H-l)/t*B;return i.multiply(w,i.fromTranslation(i.create(),[T,0,Y*Math.sign(I)]),i.fromXRotation(i.create(),-t/4*Math.sign(I))),i.multiply(b,i.fromZRotation(i.create(),H),w),s.transform(b,M)};return n({numberOfSlices:D+1,callback:k},f)};A.exports=r}}),Wue=at({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(e,A){var t=Hn(),i=TQA(),o=oD(),n=Vg(),s=zn(),r=Xn(),a=ar(),g=Cx(),c=QzA(),I=(B,C)=>{const E=o.fromNormalAndPoint(o.create(),B.axis,B.origin);if(Number.isNaN(E[0])||Number.isNaN(E[1])||Number.isNaN(E[2])||Number.isNaN(E[3]))throw new Error("project: invalid axis or origin");const Q=g(C),h=Q*Q*Math.sqrt(3)/4;if(Q===0)return s.create();const u=r.toPolygons(C);let d=[];for(let m=0;m<u.length;m++){const D=u[m].vertices.map(k=>o.projectionOfPoint(E,k)),w=a.create(D),b=a.plane(w);i(E,b)&&(a.measureArea(w)<h||d.push(w))}if(!i(E,[0,0,1])){const m=n.fromVectorRotation(n.create(),E,[0,0,1]);d=d.map(D=>a.transform(m,D))}d=d.sort((m,D)=>a.measureArea(D)-a.measureArea(m));const f=d.map(m=>s.fromPoints(m.vertices));return c(f)},l=(B,...C)=>{const E={axis:[0,0,1],origin:[0,0,0]},{axis:Q,origin:h}=Object.assign({},E,B);if(C=t(C),C.length===0)throw new Error("wrong number of arguments");B={axis:Q,origin:h};const u=C.map(d=>r.isA(d)?I(B,d):d);return u.length===1?u[0]:u};A.exports=l}}),oH=at({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(e,A){A.exports={extrudeFromSlices:X8(),extrudeLinear:Tue(),extrudeRectangular:que(),extrudeRotate:szA(),extrudeHelical:Oue(),project:Wue(),slice:qN()}}}),tEA=at({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(e,A){var t=ys(),i=s=>{let r=t.fromValues(1/0,1/0);s.forEach(c=>{(c[1]<r[1]||c[1]===r[1]&&c[0]<r[0])&&(r=c)});const a=[];s.forEach(c=>{const I=n(c[1]-r[1],c[0]-r[0]),l=t.squaredDistance(c,r);a.push({point:c,angle:I,distSq:l})}),a.sort((c,I)=>c.angle!==I.angle?c.angle-I.angle:c.distSq-I.distSq);const g=[];return a.forEach(c=>{let I=g.length;for(;I>1&&o(g[I-2],g[I-1],c.point)<=Number.EPSILON;)g.pop(),I=g.length;g.push(c.point)}),g},o=(s,r,a)=>(r[0]-s[0])*(a[1]-s[1])-(r[1]-s[1])*(a[0]-s[0]),n=(s,r)=>s===0&&r===0?-1/0:-r/s;A.exports=i}}),eEA=at({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(e,A){var t=zn(),i=Xn(),o=_g(),n=s=>{const r=new Set,a=[],g=c=>{const I=c.toString();r.has(I)||(a.push(c),r.add(I))};return s.forEach(c=>{t.isA(c)?t.toPoints(c).forEach(g):i.isA(c)?i.toPoints(c).forEach(I=>I.forEach(g)):o.isA(c)&&o.toPoints(c).forEach(g)}),a};A.exports=n}}),Zue=at({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(e,A){var t=Hn(),i=_g(),o=tEA(),n=eEA(),s=(...r)=>{r=t(r);const a=n(r),g=o(a);return i.fromPoints({closed:!0},g)};A.exports=s}}),Vue=at({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(e,A){var t=Hn(),i=zn(),o=tEA(),n=eEA(),s=(...r)=>{r=t(r);const a=n(r),g=o(a);return g.length<3?i.create():i.fromPoints(g)};A.exports=s}}),hzA=at({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(e,A){var t=ar(),i=QjA(),o=n=>i(n,{skipTriangulation:!0}).map(a=>{const g=a.map(c=>n[c]);return t.create(g)});A.exports=o}}),jue=at({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(e,A){var t=Hn(),i=Xn(),o=eEA(),n=hzA(),s=(...r)=>{r=t(r);const a=o(r);return a.length===0?i.create():i.create(n(a))};A.exports=s}}),uzA=at({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(e,A){var t=Hn(),i=eH(),o=zn(),n=Xn(),s=_g(),r=Zue(),a=Vue(),g=jue(),c=(...I)=>{if(I=t(I),I.length===0)throw new Error("wrong number of arguments");if(!i(I))throw new Error("only hulls of the same type are supported");const l=I[0];return s.isA(l)?r(I):o.isA(l)?a(I):n.isA(l)?g(I):l};A.exports=c}}),zue=at({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(e,A){var t=Hn(),i=$QA(),o=uzA(),n=(...s)=>{if(s=t(s),s.length<2)throw new Error("wrong number of arguments");const r=[];for(let a=1;a<s.length;a++)r.push(o(s[a-1],s[a]));return i(r)};A.exports=n}}),Xue=at({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(e,A){A.exports={hull:uzA(),hullChain:zue(),hullPoints2:tEA(),hullPoints3:hzA()}}}),dzA=at({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(e,A){var t=Do(),i=ar(),o=(s,r)=>{const a=Math.abs(i.measureArea(r));return Number.isFinite(a)&&a>s},n=(s,r)=>{let a=r.map(c=>{const I=c.vertices.map(C=>t.snap(t.create(),C,s)),l=[];for(let C=0;C<I.length;C++){const E=(C+1)%I.length;t.equals(I[C],I[E])||l.push(I[C])}const B=i.create(l);return c.color&&(B.color=c.color),B});const g=s*s*Math.sqrt(3)/4;return a=a.filter(c=>o(g,c)),a};A.exports=n}}),$ue=at({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(e,A){var t=TQA(),i=Do(),o=ar(),n=h=>{const u=o.toPoints(h),d=[];for(let f=0;f<u.length;f++){const m=(f+1)%u.length,D={v1:u[f],v2:u[m]};d.push(D)}for(let f=0;f<d.length;f++){const m=(f+1)%u.length;d[f].next=d[m],d[m].prev=d[f]}return d},s=(h,u)=>{const d=`${u.v1}:${u.v2}`;h.set(d,u)},r=(h,u)=>{const d=`${u.v1}:${u.v2}`;h.delete(d)},a=(h,u)=>{const d=`${u.v2}:${u.v1}`;return h.get(d)},g=(h,u,d)=>{let f=h.prev.v1,m=h.prev.v2,D=u.next.v2;const w=l(f,m,D,d);f=u.prev.v1,m=u.prev.v2,D=h.next.v2;const b=l(f,m,D,d);return[w,b]},c=i.create(),I=i.create(),l=(h,u,d,f)=>{const m=i.subtract(c,u,h),D=i.subtract(I,d,u);return i.cross(m,m,D),i.dot(m,f)},B=h=>{let u;const d=[];for(;h.next;){const f=h.next;d.push(h.v1),h.v1=null,h.v2=null,h.next=null,h.prev=null,h=f}return d.length>0&&(u=o.create(d)),u},C=h=>{if(h.length<2)return h;const u=h[0].plane,d=h.slice(),f=new Map;for(;d.length>0;){const D=d.shift(),w=n(D);for(let b=0;b<w.length;b++){const k=w[b],_=a(f,k);if(_){const N=g(k,_,u);if(N[0]>=0&&N[1]>=0){const M=_.next,H=k.next;k.prev.next=_.next,k.next.prev=_.prev,_.prev.next=k.next,_.next.prev=k.prev,k.v1=null,k.v2=null,k.next=null,k.prev=null,r(f,_),_.v1=null,_.v2=null,_.next=null,_.prev=null;const T=(Y,O,W)=>{const $={v1:W.v1,v2:O.v2,next:O.next,prev:W.prev};W.prev.next=$,O.next.prev=$,r(Y,O),O.v1=null,O.v2=null,O.next=null,O.prev=null,r(Y,W),W.v1=null,W.v2=null,W.next=null,W.prev=null};N[0]===0&&T(f,M,M.prev),N[1]===0&&T(f,H,H.prev)}}else k.next&&s(f,k)}}const m=[];return f.forEach(D=>{const w=B(D);w&&m.push(w)}),f.clear(),m},E=(h,u)=>Math.abs(h[3]-u[3])<15e-8?t(h,u):!1,Q=(h,u)=>{const d=[];u.forEach(m=>{const D=d.find(w=>E(w[0],o.plane(m)));D?D[1].push(m):d.push([o.plane(m),[m]])});let f=[];return d.forEach(m=>{const D=m[1],w=C(D);f=f.concat(w)}),f};A.exports=Q}}),Ade=at({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(e,A){var t=wr(),i=Do(),o=ar(),n=g=>`${g}`,s=(g,c,I,l,B,C)=>{const E=n(l),Q=n(B),h=`${E}/${Q}`,u=`${Q}/${E}`;if(g.has(u))return r(g,c,I,B,l,null),null;const d={vertex0:l,vertex1:B,polygonindex:C};return g.has(h)?g.get(h).push(d):g.set(h,[d]),c.has(E)?c.get(E).push(h):c.set(E,[h]),I.has(Q)?I.get(Q).push(h):I.set(Q,[h]),h},r=(g,c,I,l,B,C)=>{const E=n(l),Q=n(B),h=`${E}/${Q}`;let u=-1;const d=g.get(h);for(let f=0;f<d.length;f++){const m=d[f];let D=n(m.vertex0);if(D===E&&(D=n(m.vertex1),D===Q&&!(C!==null&&m.polygonindex!==C))){u=f;break}}d.splice(u,1),d.length===0&&g.delete(h),u=c.get(E).indexOf(h),c.get(E).splice(u,1),c.get(E).length===0&&c.delete(E),u=I.get(Q).indexOf(h),I.get(Q).splice(u,1),I.get(Q).length===0&&I.delete(Q)},a=g=>{const c=new Map;for(let I=0;I<g.length;I++){const l=g[I],B=l.vertices.length;if(B>=3){let C=l.vertices[0],E=n(C);for(let Q=0;Q<B;Q++){let h=Q+1;h===B&&(h=0);const u=l.vertices[h],d=n(u),f=`${E}/${d}`,m=`${d}/${E}`;if(c.has(m)){const D=c.get(m);D.splice(-1,1),D.length===0&&c.delete(m)}else{const D={vertex0:C,vertex1:u,polygonindex:I};c.has(f)?c.get(f).push(D):c.set(f,[D])}C=u,E=d}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(c.size>0){const I=new Map,l=new Map,B=new Map;for(const[E,Q]of c)B.set(E,!0),Q.forEach(h=>{const u=n(h.vertex0),d=n(h.vertex1);I.has(u)?I.get(u).push(E):I.set(u,[E]),l.has(d)?l.get(d).push(E):l.set(d,[E])});const C=g.slice(0);for(;c.size!==0;){for(const Q of c.keys())B.set(Q,!0);let E=!1;for(;;){const Q=Array.from(B.keys());if(Q.length===0)break;const h=Q[0];let u=!0;if(c.has(h)){const f=c.get(h)[0];for(let m=0;m<2;m++){const D=m===0?f.vertex0:f.vertex1,w=m===0?f.vertex1:f.vertex0,b=n(D),k=n(w);let _=[];m===0?l.has(b)&&(_=l.get(b)):I.has(b)&&(_=I.get(b));for(let N=0;N<_.length;N++){const M=_[N],H=c.get(M)[0],T=m===0?H.vertex0:H.vertex1;if(m===0?H.vertex1:H.vertex0,n(T)===k){r(c,I,l,D,w,null),r(c,I,l,w,D,null),u=!1,m=2,E=!0;break}else{const O=D,W=w,$=T,iA=i.subtract(i.create(),$,O),gA=i.dot(i.subtract(i.create(),W,O),iA)/i.dot(iA,iA);if(gA>0&&gA<1){const tA=i.scale(i.create(),iA,gA);if(i.add(tA,tA,O),i.squaredDistance(tA,W)<t.EPS*t.EPS){const rA=H.polygonindex,QA=C[rA],DA=n(H.vertex1);let RA=-1;for(let dA=0;dA<QA.vertices.length;dA++)if(n(QA.vertices[dA])===DA){RA=dA;break}const NA=QA.vertices.slice(0);NA.splice(RA,0,w);const KA=o.create(NA);C[rA]=KA,r(c,I,l,H.vertex0,H.vertex1,rA);const EA=s(c,I,l,H.vertex0,w,rA),kA=s(c,I,l,w,H.vertex1,rA);EA!==null&&B.set(EA,!0),kA!==null&&B.set(kA,!0),u=!1,m=2,E=!0;break}}}}}}u&&B.delete(h)}if(!E)break}g=C}return c.clear(),g};A.exports=a}}),tde=at({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(e,A){var t=Do(),i=ar(),o=(s,r,a)=>{const g=r.vertices.length;if(g>3){if(g>4){const l=[0,0,0];r.vertices.forEach(B=>t.add(l,l,B)),t.snap(l,t.divide(l,l,[g,g,g]),s);for(let B=0;B<g;B++){const C=i.create([l,r.vertices[B],r.vertices[(B+1)%g]]);r.color&&(C.color=r.color),a.push(C)}return}const c=i.create([r.vertices[0],r.vertices[1],r.vertices[2]]),I=i.create([r.vertices[0],r.vertices[2],r.vertices[3]]);r.color&&(c.color=r.color,I.color=r.color),a.push(c,I);return}a.push(r)},n=(s,r)=>{const a=[];return r.forEach(g=>{o(s,g,a)}),a};A.exports=n}}),ede=at({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(e,A){var t=Hn(),i=Cx(),o=zn(),n=Xn(),s=_g(),r=dzA(),a=$ue(),g=Ade(),c=tde(),I=(E,Q)=>Q,l=(E,Q)=>Q,B=(E,Q)=>{const h={snap:!1,simplify:!1,triangulate:!1},{snap:u,simplify:d,triangulate:f}=Object.assign({},h,E),m=i(Q);let D=n.toPolygons(Q);u&&(D=r(m,D)),d&&(D=a(m,D)),f&&(D=g(D),D=c(m,D));const w=Object.assign({},Q);return w.polygons=D,w},C=(E,...Q)=>{if(Q=t(Q),Q.length===0)throw new Error("wrong number of arguments");const h=Q.map(u=>{if(s.isA(u))return I(E,u);if(o.isA(u))return l(E,u);if(n.isA(u))return B(E,u);throw new Error("invalid geometry")});return h.length===1?h[0]:h};A.exports=C}}),ide=at({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(e,A){var t=Hn(),i=ys(),o=zn(),n=Xn(),s=_g(),r=Cx(),a=dzA(),g=B=>{const C=r(B),Q=s.toPoints(B).map(h=>i.snap(i.create(),h,C));return s.create(Q)},c=B=>{const C=r(B);let Q=o.toSides(B).map(h=>[i.snap(i.create(),h[0],C),i.snap(i.create(),h[1],C)]);return Q=Q.filter(h=>!i.equals(h[0],h[1])),o.create(Q)},I=B=>{const C=r(B),E=n.toPolygons(B),Q=a(C,E);return n.create(Q)},l=(...B)=>{if(B=t(B),B.length===0)throw new Error("wrong number of arguments");const C=B.map(E=>s.isA(E)?g(E):o.isA(E)?c(E):n.isA(E)?I(E):E);return C.length===1?C[0]:C};A.exports=l}}),ode=at({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(e,A){A.exports={generalize:ede(),snap:ide(),retessellate:iH()}}}),nde=at({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(e,A){var t=(i,o,n)=>{for(i=i.slice();i.length<n;)i.push(o);return i};A.exports=t}}),sde=at({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(e,A){var t=Hn(),i=nde(),o=PQA(),{translate:n}=OF(),s=c=>{if(!Array.isArray(c.modes)||c.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(c.modes=i(c.modes,"none",3),c.modes.filter(I=>["center","max","min","none"].includes(I)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(c.relativeTo)||c.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(c.relativeTo=i(c.relativeTo,0,3),c.relativeTo.filter(I=>Number.isFinite(I)||I==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof c.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return c},r=(c,I,l)=>{for(let B=0;B<3;B++)c[B]==null&&(I[B]==="center"?c[B]=(l[0][B]+l[1][B])/2:I[B]==="max"?c[B]=l[1][B]:I[B]==="min"&&(c[B]=l[0][B]));return c},a=(c,I,l)=>{const B=o(c),C=[0,0,0];for(let E=0;E<3;E++)I[E]==="center"?C[E]=l[E]-(B[0][E]+B[1][E])/2:I[E]==="max"?C[E]=l[E]-B[1][E]:I[E]==="min"&&(C[E]=l[E]-B[0][E]);return n(C,c)},g=(c,...I)=>{c=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},c),c=s(c);let{modes:B,relativeTo:C,grouped:E}=c;if(I=t(I),I.length===0)throw new Error("align(): No geometries were provided to act upon");if(C.filter(Q=>Q==null).length){const Q=o(I);C=r(C,B,Q)}return E?I=a(I,B,C):I=I.map(Q=>a(Q,B,C)),I.length===1?I[0]:I};A.exports=g}}),tW=at({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(e,A){var t=Hn(),i=zn(),o=Xn(),n=_g(),s=PF(),{translate:r}=OF(),a=(B,C)=>{const E={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:Q,relativeTo:h}=Object.assign({},E,B),u=s(C),d=[0,0,0];return Q[0]&&(d[0]=h[0]-(u[0][0]+(u[1][0]-u[0][0])/2)),Q[1]&&(d[1]=h[1]-(u[0][1]+(u[1][1]-u[0][1])/2)),Q[2]&&(d[2]=h[2]-(u[0][2]+(u[1][2]-u[0][2])/2)),r(d,C)},g=(B,...C)=>{const E={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:Q,relativeTo:h}=Object.assign({},E,B);if(C=t(C),C.length===0)throw new Error("wrong number of arguments");if(h.length!==3)throw new Error("relativeTo must be an array of length 3");B={axes:Q,relativeTo:h};const u=C.map(d=>n.isA(d)||i.isA(d)||o.isA(d)?a(B,d):d);return u.length===1?u[0]:u},c=(...B)=>g({axes:[!0,!1,!1]},B),I=(...B)=>g({axes:[!1,!0,!1]},B),l=(...B)=>g({axes:[!1,!1,!0]},B);A.exports={center:g,centerX:c,centerY:I,centerZ:l}}}),eW=at({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(e,A){var t=Hn(),i=Vg(),o=zn(),n=Xn(),s=_g(),r=(I,...l)=>{if(!Array.isArray(I))throw new Error("factors must be an array");if(l=t(l),l.length===0)throw new Error("wrong number of arguments");for(I=I.slice();I.length<3;)I.push(1);if(I[0]<=0||I[1]<=0||I[2]<=0)throw new Error("factors must be positive");const B=i.fromScaling(i.create(),I),C=l.map(E=>s.isA(E)?s.transform(B,E):o.isA(E)?o.transform(B,E):n.isA(E)?n.transform(B,E):E);return C.length===1?C[0]:C},a=(I,...l)=>r([I,1,1],l),g=(I,...l)=>r([1,I,1],l),c=(I,...l)=>r([1,1,I],l);A.exports={scale:r,scaleX:a,scaleY:g,scaleZ:c}}}),rde=at({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(e,A){var t=Hn(),i=zn(),o=Xn(),n=_g(),s=(r,...a)=>{if(a=t(a),a.length===0)throw new Error("wrong number of arguments");const g=a.map(c=>n.isA(c)?n.transform(r,c):i.isA(c)?i.transform(r,c):o.isA(c)?o.transform(r,c):c);return g.length===1?g[0]:g};A.exports=s}}),WF=at({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(e,A){A.exports={align:sde(),center:tW().center,centerX:tW().centerX,centerY:tW().centerY,centerZ:tW().centerZ,mirror:AH().mirror,mirrorX:AH().mirrorX,mirrorY:AH().mirrorY,mirrorZ:AH().mirrorZ,rotate:tH().rotate,rotateX:tH().rotateX,rotateY:tH().rotateY,rotateZ:tH().rotateZ,scale:eW().scale,scaleX:eW().scaleX,scaleY:eW().scaleY,scaleZ:eW().scaleZ,transform:rde(),translate:OF().translate,translateX:OF().translateX,translateY:OF().translateY,translateZ:OF().translateZ}}}),iW=at({"node_modules/@jscad/modeling/src/index.js"(e,A){A.exports={colors:V8(),curves:ihe(),geometries:HQA(),maths:_he(),measurements:vhe(),primitives:Qx(),text:ZQA(),utils:czA(),booleans:ON(),expansions:EzA(),extrusions:oH(),hulls:Xue(),modifiers:ode(),transforms:WF()}}}),pzA=at({"node_modules/jscad-planner/dist/index.cjs"(e,A){var t=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,s=(l,B)=>{for(var C in B)t(l,C,{get:B[C],enumerable:!0})},r=(l,B,C,E)=>{if(B&&typeof B=="object"||typeof B=="function")for(let Q of o(B))!n.call(l,Q)&&Q!==C&&t(l,Q,{get:()=>B[Q],enumerable:!(E=i(B,Q))||E.enumerable});return l},a=l=>r(t({},"__esModule",{value:!0}),l),g={};s(g,{executeJscadOperations:()=>I,jscadPlanner:()=>c}),A.exports=a(g);var c={booleans:{intersect:(...l)=>({type:"intersect",shapes:l}),subtract:(...l)=>({type:"subtract",shapes:l}),union:(...l)=>({type:"union",shapes:l})},hulls:{hull:(...l)=>({type:"hull",shapes:l.flat()}),hullChain:(...l)=>({type:"hullChain",shapes:l.flat()})},colors:{colorize:(l,B)=>({type:"colorize",color:l,shape:B})},primitives:{cube:l=>({type:"cube",...l}),sphere:l=>({type:"sphere",...l}),cylinder:l=>({type:"cylinder",...l}),polygon:l=>({type:"polygon",...l}),cuboid:l=>({type:"cuboid",...l}),roundedCuboid:l=>({type:"roundedCuboid",...l})},transforms:{rotate:(l,B)=>({type:"rotate",angles:l,shape:B}),scale:(l,B)=>({type:"scale",factors:l,shape:B}),translate:(l,B)=>({type:"translate",vector:l,shape:B})},extrusions:{extrudeLinear:(l,B)=>({type:"extrudeLinear",options:l,shape:B}),extrudeRotate:(l,B)=>({type:"extrudeRotate",options:l,shape:B})},maths:{vec2:{create:(l,B)=>[l,B],fromValues:(l,B)=>[l,B]},vec3:{create:(l,B,C)=>[l,B,C],fromValues:(l,B,C)=>[l,B,C]}},geometries:{geom2:{create:l=>({type:"createGeom2",points:l})},geom3:{create:l=>({type:"createGeom3",polygons:l})},path2:{create:l=>({type:"createPath2",points:l})}},measurements:{measureBoundingBox:l=>({type:"measureBoundingBox",shape:l}),measureArea:l=>({type:"measureArea",shape:l}),measureVolume:l=>({type:"measureVolume",shape:l})},utils:{degToRad:l=>l*Math.PI/180,radToDeg:l=>l*180/Math.PI}},I=(l,B)=>{if(Array.isArray(B)&&B.length===1)return I(l,B[0]);if(Array.isArray(B))throw new Error("executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually");const C=h=>I(l,h),{type:E,...Q}=B;switch(E){case"intersect":return l.booleans.intersect(...B.shapes.map(C));case"subtract":return l.booleans.subtract(...B.shapes.map(C));case"union":return l.booleans.union(...B.shapes.map(C));case"hull":return l.hulls.hull(...B.shapes.map(C));case"hullChain":return l.hulls.hullChain(...B.shapes.map(C));case"colorize":return l.colors.colorize(B.color,C(B.shape));case"cube":return l.primitives.cube(Q);case"sphere":return l.primitives.sphere(Q);case"cylinder":return l.primitives.cylinder(Q);case"polygon":return l.primitives.polygon(Q);case"cuboid":return l.primitives.cuboid(Q);case"roundedCuboid":return l.primitives.roundedCuboid(Q);case"rotate":return l.transforms.rotate(B.angles,C(B.shape));case"scale":return l.transforms.scale(B.factors,C(B.shape));case"translate":return l.transforms.translate(B.vector,C(B.shape));case"extrudeLinear":return l.extrusions.extrudeLinear(B.options,C(B.shape));case"extrudeRotate":return l.extrusions.extrudeRotate(B.options,C(B.shape));case"createGeom2":return l.geometries.geom2.create(B.points);case"createGeom3":return l.geometries.geom3.create(B.polygons);case"createPath2":return l.geometries.path2.create(B.points);case"measureBoundingBox":return l.measurements.measureBoundingBox(C(B.shape));case"measureArea":return l.measurements.measureArea(C(B.shape));case"measureVolume":return l.measurements.measureVolume(C(B.shape));case"degToRad":return l.utils.degToRad(B.degrees);case"radToDeg":return l.utils.radToDeg(B.radians);default:throw B.type===void 0?new Error(`Operation type is undefined. This usually means the operation object is malformed or not properly initialized. Operation: ${JSON.stringify(B,null,2).slice(0,200)}...`):new Error(`Unsupported operation type: ${B.type}. Operation: ${JSON.stringify(B,null,2)}`)}}}}),ade=at({"node_modules/ms/index.js"(e,A){var t=1e3,i=t*60,o=i*60,n=o*24,s=n*7,r=n*365.25;A.exports=function(l,B){B=B||{};var C=typeof l;if(C==="string"&&l.length>0)return a(l);if(C==="number"&&isFinite(l))return B.long?c(l):g(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function a(l){if(l=String(l),!(l.length>100)){var B=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(B){var C=parseFloat(B[1]),E=(B[2]||"ms").toLowerCase();switch(E){case"years":case"year":case"yrs":case"yr":case"y":return C*r;case"weeks":case"week":case"w":return C*s;case"days":case"day":case"d":return C*n;case"hours":case"hour":case"hrs":case"hr":case"h":return C*o;case"minutes":case"minute":case"mins":case"min":case"m":return C*i;case"seconds":case"second":case"secs":case"sec":case"s":return C*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return C;default:return}}}}function g(l){var B=Math.abs(l);return B>=n?Math.round(l/n)+"d":B>=o?Math.round(l/o)+"h":B>=i?Math.round(l/i)+"m":B>=t?Math.round(l/t)+"s":l+"ms"}function c(l){var B=Math.abs(l);return B>=n?I(l,B,n,"day"):B>=o?I(l,B,o,"hour"):B>=i?I(l,B,i,"minute"):B>=t?I(l,B,t,"second"):l+" ms"}function I(l,B,C,E){var Q=B>=C*1.5;return Math.round(l/C)+" "+E+(Q?"s":"")}}}),gde=at({"node_modules/debug/src/common.js"(e,A){function t(i){n.debug=n,n.default=n,n.coerce=I,n.disable=g,n.enable=r,n.enabled=c,n.humanize=ade(),n.destroy=l,Object.keys(i).forEach(B=>{n[B]=i[B]}),n.names=[],n.skips=[],n.formatters={};function o(B){let C=0;for(let E=0;E<B.length;E++)C=(C<<5)-C+B.charCodeAt(E),C|=0;return n.colors[Math.abs(C)%n.colors.length]}n.selectColor=o;function n(B){let C,E=null,Q,h;function u(...d){if(!u.enabled)return;const f=u,m=Number(new Date),D=m-(C||m);f.diff=D,f.prev=C,f.curr=m,C=m,d[0]=n.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let w=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(k,_)=>{if(k==="%%")return"%";w++;const N=n.formatters[_];if(typeof N=="function"){const M=d[w];k=N.call(f,M),d.splice(w,1),w--}return k}),n.formatArgs.call(f,d),(f.log||n.log).apply(f,d)}return u.namespace=B,u.useColors=n.useColors(),u.color=n.selectColor(B),u.extend=s,u.destroy=n.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(Q!==n.namespaces&&(Q=n.namespaces,h=n.enabled(B)),h),set:d=>{E=d}}),typeof n.init=="function"&&n.init(u),u}function s(B,C){const E=n(this.namespace+(typeof C>"u"?":":C)+B);return E.log=this.log,E}function r(B){n.save(B),n.namespaces=B,n.names=[],n.skips=[];const C=(typeof B=="string"?B:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const E of C)E[0]==="-"?n.skips.push(E.slice(1)):n.names.push(E)}function a(B,C){let E=0,Q=0,h=-1,u=0;for(;E<B.length;)if(Q<C.length&&(C[Q]===B[E]||C[Q]==="*"))C[Q]==="*"?(h=Q,u=E,Q++):(E++,Q++);else if(h!==-1)Q=h+1,u++,E=u;else return!1;for(;Q<C.length&&C[Q]==="*";)Q++;return Q===C.length}function g(){const B=[...n.names,...n.skips.map(C=>"-"+C)].join(",");return n.enable(""),B}function c(B){for(const C of n.skips)if(a(B,C))return!1;for(const C of n.names)if(a(B,C))return!0;return!1}function I(B){return B instanceof Error?B.stack||B.message:B}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}A.exports=t}}),cde=at({"node_modules/debug/src/browser.js"(e,A){e.formatArgs=i,e.save=o,e.load=n,e.useColors=t,e.storage=s(),e.destroy=(()=>{let a=!1;return()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let a;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(a=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(a[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function i(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+A.exports.humanize(this.diff),!this.useColors)return;const g="color: "+this.color;a.splice(1,0,g,"color: inherit");let c=0,I=0;a[0].replace(/%[a-zA-Z%]/g,l=>{l!=="%%"&&(c++,l==="%c"&&(I=c))}),a.splice(I,0,g)}e.log=console.debug||console.log||(()=>{});function o(a){try{a?e.storage.setItem("debug",a):e.storage.removeItem("debug")}catch{}}function n(){let a;try{a=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch{}return!a&&typeof kQA<"u"&&"env"in kQA&&(a=kQA.env.DEBUG),a}function s(){try{return localStorage}catch{}}A.exports=gde()(e);var{formatters:r}=A.exports;r.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}}}),fzA={boardBody:!0,topCopper:!0,bottomCopper:!0,adhesive:!1,solderPaste:!1,topSilkscreen:!0,bottomSilkscreen:!0,topMask:!0,bottomMask:!0,throughHoleModels:!0,smtModels:!0,translucentModels:!0,modelsNotInPosFile:!1,modelsMarkedDNP:!1,modelBoundingBoxes:!1,threedAxis:!1,backgroundStart:!0,backgroundEnd:!0},yzA=AA.createContext(void 0),Ide=({children:e})=>{const[A,t]=AA.useState(fzA),i=AA.useCallback((s,r)=>{t(a=>({...a,[s]:r}))},[]),o=AA.useCallback(()=>{t(fzA)},[]),n=AA.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:o}),[A,i,o]);return Z.jsx(yzA.Provider,{value:n,children:e})},WN=()=>{const e=AA.useContext(yzA);if(!e)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return e},iEA=1.2;function mzA(e){return AA.useMemo(()=>{if(!e)return iEA;try{return xi(e).pcb_board.list()[0]?.thickness??iEA}catch{return iEA}},[e])}var wzA=AA.createContext(null),Ku=()=>{const e=AA.useContext(wzA);if(!e)throw new Error("useThree must be used within a ThreeProvider");return e},nH=(e,A=[])=>{const{addFrameListener:t,removeFrameListener:i}=Ku();no.useEffect(()=>(t(e),()=>i(e)),[t,i,...A])},sH={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},DzA=({children:e,position:A,style:t})=>{const{camera:i,renderer:o}=Ku(),n=AA.useRef(document.createElement("div")),[s,r]=AA.useState(null);return AA.useEffect(()=>{const a=o?.domElement.parentNode;if(a)return a.style.position!=="relative"&&a.style.position!=="absolute"&&(a.style.position="relative"),a.appendChild(n.current),r(CK.createPortal(e,n.current)),()=>{a.contains(n.current)&&a.removeChild(n.current)}},[o,e]),nH(()=>{if(!i||!n.current||!o)return;const a=new Rt(...A);a.project(i);const g=o.domElement.getBoundingClientRect(),c=Math.round((a.x+1)/2*g.width),I=Math.round((-a.y+1)/2*g.height);n.current.style.position="absolute",n.current.style.left=`${c}px`,n.current.style.top=`${I}px`,n.current.style.pointerEvents="none",n.current.style.zIndex=sH.htmlElements.toString(),t&&Object.assign(n.current.style,t)},[i,o,A,t]),s},SzA={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},Mr=e=>{let A=typeof e=="number"?"mm":e.replace(/^[^a-zA-Z]+/g,"").toLowerCase();A||(A="mm");const t=typeof e=="number"?e:Number.parseFloat(e.split(A)[0]);if(A in SzA)return t*SzA[A];throw new Error(`Unsupported unit: ${A}`)},Fl=Mr,bzA={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,ms:1,s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},oEA=new Set;for(const[e,A]of Object.entries(bzA)){oEA.add(e);for(const t of Object.keys(A.variants))oEA.add(t)}function lde(e){for(const[A,t]of Object.entries(bzA))if(e in t.variants)return{baseUnit:t.baseUnit,conversionFactor:t.variants[e]};return{baseUnit:e,conversionFactor:1}}var _zA={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12};function Wm(e){if(e==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof e=="string"&&e.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(e),parsedUnit:null,unitOfValue:null};if(typeof e=="number")return{value:e,parsedUnit:null,unitOfValue:null};if(typeof e=="object"&&"x"in e&&"y"in e){const{parsedUnit:r,unitOfValue:a}=Wm(e.x),g=Wm(e.x),c=Wm(e.y);return g.value===null||c.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:c.value}}}const t=e.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!t)throw new Error(`Could not determine unit: "${e}"`);const i=t.split("").reverse().join(""),o=e.slice(0,-i.length);if(i in _zA&&!oEA.has(i)){const r=_zA[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(o)*r}}const{baseUnit:n,conversionFactor:s}=lde(i);return{parsedUnit:i,unitOfValue:n,value:s*Number.parseFloat(o)}}var nEA=v().or(GA()).transform(e=>Wm(e).value),xzA=v().or(GA()).transform(e=>Wm(e).value).transform(e=>Number.parseFloat(e.toPrecision(12))),Bde=v().or(GA()).transform(e=>Wm(e).value),ZN=v().or(GA()).transform(e=>Wm(e).value),At=v().or(GA()).transform(e=>Wm(e).value),oW=v().or(GA()).transform(e=>Wm(e).value),be=At,sEA=v().or(GA()).transform(e=>Wm(e).value),rEA=v().or(GA()).transform(e=>Wm(e).value),VN=rEA,Cde=v().datetime(),Td=v().or(GA()).transform(e=>typeof e=="number"?e:e.endsWith("deg")?Number.parseFloat(e.split("deg")[0]):e.endsWith("rad")?Number.parseFloat(e.split("rad")[0])*180/Math.PI:Number.parseFloat(e)),Qde=GA().or(v().endsWith("mAh")).transform(e=>{if(typeof e=="string"){const A=e.replace("mAh",""),t=Number.parseFloat(A);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return e}).describe("Battery capacity in mAh"),vo=FA({x:be,y:be}),aEA=FA({x:be,y:be,z:be}),kzA=FA({width:GA(),height:GA()}),Ede=e=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:e},()=>A[Math.floor(Math.random()*A.length)]).join("")},Ai=e=>v().optional().default(()=>`${e}_${Ede(10)}`),ZF=Tt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]);Tt(["top_silkscreen","bottom_silkscreen","top_copper","bottom_copper","top_soldermask","bottom_soldermask","top_fabrication_note","bottom_fabrication_note","inner1_copper","inner2_copper","inner3_copper","inner4_copper","inner5_copper","inner6_copper"]);var hde=Tt(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),Gl=FA({type:BA("source_component"),ftype:v().optional(),source_component_id:v(),name:v(),manufacturer_part_number:v().optional(),supplier_part_numbers:qr(hde,dt(v())).optional(),display_value:v().optional(),are_pins_interchangeable:$A().optional(),internally_connected_source_port_ids:dt(dt(v())).optional(),source_group_id:v().optional(),subcircuit_id:v().optional()}),FzA=Gl.extend({ftype:BA("simple_capacitor"),capacitance:xzA,max_voltage_rating:ZN.optional(),display_capacitance:v().optional(),max_decoupling_trace_length:be.optional()}),GzA=Gl.extend({ftype:BA("simple_resistor"),resistance:nEA,display_resistance:v().optional()}),gEA=Gl.extend({ftype:BA("simple_diode")}),ude=Gl.extend({ftype:BA("simple_fiducial")}),RzA=gEA.extend({ftype:BA("simple_led"),color:v().optional(),wavelength:v().optional()}),dde=Gl.extend({ftype:BA("simple_ground")}),MzA=Gl.extend({ftype:BA("simple_chip")}),NzA=Gl.extend({ftype:BA("simple_power_source"),voltage:ZN}),pde=Gl.extend({ftype:BA("simple_fuse"),current_rating_amps:GA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:GA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),vzA=Gl.extend({ftype:BA("simple_battery"),capacity:Qde}),LzA=Gl.extend({ftype:BA("simple_inductor"),inductance:Bde,max_current_rating:GA().optional()}),UzA=Gl.extend({ftype:BA("simple_push_button")}),HzA=Gl.extend({ftype:BA("simple_potentiometer"),max_resistance:nEA}),fde=Gl.extend({ftype:BA("simple_crystal"),frequency:GA().describe("Frequency in Hz"),load_capacitance:GA().optional().describe("Load capacitance in pF")}),YzA=Gl.extend({ftype:BA("simple_pin_header"),pin_count:GA(),gender:Tt(["male","female"]).optional().default("male")}),JzA=Gl.extend({ftype:BA("simple_pinout")}),TzA=Gl.extend({ftype:BA("simple_resonator"),load_capacitance:xzA,equivalent_series_resistance:nEA.optional(),frequency:oW}),KzA=Gl.extend({ftype:BA("simple_transistor"),transistor_type:Tt(["npn","pnp"])}),PzA=Gl.extend({ftype:BA("simple_test_point"),footprint_variant:Tt(["pad","through_hole"]).optional(),pad_shape:Tt(["rect","circle"]).optional(),pad_diameter:He([GA(),v()]).optional(),hole_diameter:He([GA(),v()]).optional(),width:He([GA(),v()]).optional(),height:He([GA(),v()]).optional()}),qzA=Gl.extend({ftype:BA("simple_mosfet"),channel_type:Tt(["n","p"]),mosfet_mode:Tt(["enhancement","depletion"])}),OzA=Gl.extend({ftype:BA("simple_op_amp")}),WzA=Gl.extend({ftype:BA("simple_switch")}),ZzA=FA({type:BA("source_project_metadata"),name:v().optional(),software_used_string:v().optional(),project_url:v().optional(),created_at:Cde.optional()}),yde=FA({type:BA("source_missing_property_error"),source_missing_property_error_id:Ai("source_missing_property_error"),source_component_id:v(),property_name:v(),subcircuit_id:v().optional(),error_type:BA("source_missing_property_error").default("source_missing_property_error"),message:v()}).describe("The source code is missing a property"),mde=FA({type:BA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Ai("source_failed_to_create_component_error"),error_type:BA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:v().optional(),subcircuit_id:v().optional(),parent_source_component_id:v().optional(),message:v(),pcb_center:FA({x:GA().optional(),y:GA().optional()}).optional(),schematic_center:FA({x:GA().optional(),y:GA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),VzA=FA({type:BA("source_trace_not_connected_error"),source_trace_not_connected_error_id:Ai("source_trace_not_connected_error"),error_type:BA("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:v(),subcircuit_id:v().optional(),source_group_id:v().optional(),source_trace_id:v().optional(),connected_source_port_ids:dt(v()).optional(),selectors_not_found:dt(v()).optional()}).describe("Occurs when a source trace selector does not match any ports"),wde=FA({type:BA("source_property_ignored_warning"),source_property_ignored_warning_id:Ai("source_property_ignored_warning"),source_component_id:v(),property_name:v(),subcircuit_id:v().optional(),error_type:BA("source_property_ignored_warning").default("source_property_ignored_warning"),message:v()}).describe("The source property was ignored"),jzA=FA({type:BA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Ai("source_pin_missing_trace_warning"),warning_type:BA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:v(),source_component_id:v(),source_port_id:v(),subcircuit_id:v().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),Dde=Gl.extend({ftype:BA("simple_voltage_probe")}),Sde=Gl.extend({ftype:BA("interconnect")}),bde=He([GzA,FzA,gEA,ude,RzA,dde,MzA,NzA,vzA,LzA,UzA,HzA,fde,YzA,JzA,TzA,WzA,KzA,PzA,qzA,OzA,pde,Dde,Sde,ZzA,yde,mde,VzA,wde,jzA]),_de=FA({type:BA("source_port"),pin_number:GA().optional(),port_hints:dt(v()).optional(),name:v(),source_port_id:v(),source_component_id:v().optional(),source_group_id:v().optional(),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional(),must_be_connected:$A().optional()}),xde=FA({type:BA("source_component_internal_connection"),source_component_internal_connection_id:v(),source_component_id:v(),source_port_ids:dt(v()),subcircuit_id:v().optional()}),kde=FA({type:BA("source_trace"),source_trace_id:v(),connected_source_port_ids:dt(v()),connected_source_net_ids:dt(v()),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional(),max_length:GA().optional(),min_trace_thickness:GA().optional(),display_name:v().optional()}),Fde=FA({type:BA("source_group"),source_group_id:v(),subcircuit_id:v().optional(),parent_subcircuit_id:v().optional(),parent_source_group_id:v().optional(),is_subcircuit:$A().optional(),show_as_schematic_box:$A().optional(),name:v().optional(),was_automatically_named:$A().optional()}),Gde=FA({type:BA("source_net"),source_net_id:v(),name:v(),member_source_group_ids:dt(v()),is_power:$A().optional(),is_ground:$A().optional(),is_digital_signal:$A().optional(),is_analog_signal:$A().optional(),is_positive_voltage_source:$A().optional(),trace_width:GA().optional(),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional()}),Rde=FA({type:BA("source_board"),source_board_id:v(),source_group_id:v(),title:v().optional()}).describe("Defines a board in the source domain"),Mde=FA({type:BA("source_pcb_ground_plane"),source_pcb_ground_plane_id:v(),source_group_id:v(),source_net_id:v(),subcircuit_id:v().optional()}).describe("Defines a ground plane in the source domain"),Nde=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],zzA=Tt(Nde),Wr=zzA.or(FA({name:zzA})).transform(e=>typeof e=="string"?e:e.name),nD=Tt(["top","bottom"]),vde=FA({type:BA("source_manually_placed_via"),source_manually_placed_via_id:v(),source_group_id:v(),source_net_id:v(),subcircuit_id:v().optional(),source_trace_id:v().optional()}).describe("Defines a via that is manually placed in the source domain"),Lde=FA({type:BA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:Ai("source_pin_must_be_connected_error"),error_type:BA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),message:v(),source_component_id:v(),source_port_id:v(),subcircuit_id:v().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),Ude=FA({type:BA("unknown_error_finding_part"),unknown_error_finding_part_id:Ai("unknown_error_finding_part"),error_type:BA("unknown_error_finding_part").default("unknown_error_finding_part"),message:v(),source_component_id:v().optional(),subcircuit_id:v().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),Hde=FA({type:BA("schematic_box"),schematic_component_id:v().optional(),width:be,height:be,is_dashed:$A().default(!1),x:be,y:be,subcircuit_id:v().optional()}).describe("Draws a box on the schematic"),Yde=FA({type:BA("schematic_path"),schematic_component_id:v(),fill_color:Tt(["red","blue"]).optional(),is_filled:$A().optional(),points:dt(vo),subcircuit_id:v().optional()}),Jde=qr(FA({left_margin:At.optional(),right_margin:At.optional(),top_margin:At.optional(),bottom_margin:At.optional()})),Tde=FA({left_size:GA(),right_size:GA(),top_size:GA().optional(),bottom_size:GA().optional()}),Kde=FA({left_side:FA({pins:dt(GA()),direction:Tt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:FA({pins:dt(GA()),direction:Tt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:FA({pins:dt(GA()),direction:Tt(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:FA({pins:dt(GA()),direction:Tt(["left-to-right","right-to-left"]).optional()}).optional()}),Pde=He([Tde,Kde]),qde=FA({type:BA("schematic_component"),size:kzA,center:vo,source_component_id:v().optional(),schematic_component_id:v(),pin_spacing:At.optional(),pin_styles:Jde.optional(),box_width:At.optional(),symbol_name:v().optional(),port_arrangement:Pde.optional(),port_labels:qr(v()).optional(),symbol_display_value:v().optional(),subcircuit_id:v().optional(),schematic_group_id:v().optional(),is_schematic_group:$A().optional(),source_group_id:v().optional(),is_box_with_pins:$A().optional().default(!0)}),Ode=FA({type:BA("schematic_line"),schematic_line_id:Ai("schematic_line"),schematic_component_id:v(),x1:be,y1:be,x2:be,y2:be,stroke_width:be.nullable().optional(),color:v().default("#000000"),is_dashed:$A().default(!1),subcircuit_id:v().optional()}).describe("Draws a styled line on the schematic"),Wde=FA({type:BA("schematic_rect"),schematic_rect_id:Ai("schematic_rect"),schematic_component_id:v(),center:vo,width:be,height:be,rotation:Td.default(0),stroke_width:be.nullable().optional(),color:v().default("#000000"),is_filled:$A().default(!1),fill_color:v().optional(),is_dashed:$A().default(!1),subcircuit_id:v().optional()}).describe("Draws a styled rectangle on the schematic"),Zde=FA({type:BA("schematic_circle"),schematic_circle_id:Ai("schematic_circle"),schematic_component_id:v(),center:vo,radius:be,stroke_width:be.nullable().optional(),color:v().default("#000000"),is_filled:$A().default(!1),fill_color:v().optional(),is_dashed:$A().default(!1),subcircuit_id:v().optional()}).describe("Draws a styled circle on the schematic"),Vde=FA({type:BA("schematic_arc"),schematic_arc_id:Ai("schematic_arc"),schematic_component_id:v(),center:vo,radius:be,start_angle_degrees:Td,end_angle_degrees:Td,direction:Tt(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:be.nullable().optional(),color:v().default("#000000"),is_dashed:$A().default(!1),subcircuit_id:v().optional()}).describe("Draws a styled arc on the schematic"),jde=FA({type:BA("schematic_trace"),schematic_trace_id:v(),source_trace_id:v().optional(),junctions:dt(FA({x:GA(),y:GA()})),edges:dt(FA({from:FA({x:GA(),y:GA()}),to:FA({x:GA(),y:GA()}),is_crossing:$A().optional(),from_schematic_port_id:v().optional(),to_schematic_port_id:v().optional()})),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional()}),zde=Tt(["center","left","right","top","bottom"]),Xde=FA({type:BA("schematic_text"),schematic_component_id:v().optional(),schematic_text_id:v(),text:v(),font_size:GA().default(.18),position:FA({x:be,y:be}),rotation:GA().default(0),anchor:He([zde.describe("legacy"),ZF]).default("center"),color:v().default("#000000"),subcircuit_id:v().optional()}),$de=FA({type:BA("schematic_port"),schematic_port_id:v(),source_port_id:v(),schematic_component_id:v().optional(),center:vo,facing_direction:Tt(["up","down","left","right"]).optional(),distance_from_component_edge:GA().optional(),side_of_component:Tt(["top","bottom","left","right"]).optional(),true_ccw_index:GA().optional(),pin_number:GA().optional(),display_pin_label:v().optional(),subcircuit_id:v().optional(),is_connected:$A().optional(),has_input_arrow:$A().optional(),has_output_arrow:$A().optional()}).describe("Defines a port on a schematic component"),Ape=FA({type:BA("schematic_net_label"),schematic_net_label_id:Ai("schematic_net_label"),schematic_trace_id:v().optional(),source_trace_id:v().optional(),source_net_id:v(),center:vo,anchor_position:vo.optional(),anchor_side:Tt(["top","bottom","left","right"]),text:v(),symbol_name:v().optional(),is_movable:$A().optional(),subcircuit_id:v().optional()}),tpe=FA({type:BA("schematic_error"),schematic_error_id:v(),error_type:BA("schematic_port_not_found").default("schematic_port_not_found"),message:v(),subcircuit_id:v().optional()}).describe("Defines a schematic error on the schematic"),epe=FA({type:BA("schematic_layout_error"),schematic_layout_error_id:Ai("schematic_layout_error"),error_type:BA("schematic_layout_error").default("schematic_layout_error"),message:v(),source_group_id:v(),schematic_group_id:v(),subcircuit_id:v().optional()}).describe("Error emitted when schematic layout fails for a group"),cEA=FA({type:BA("schematic_debug_object"),label:v().optional(),subcircuit_id:v().optional()}),ipe=cEA.extend({shape:BA("rect"),center:vo,size:kzA}),ope=cEA.extend({shape:BA("line"),start:vo,end:vo}),npe=cEA.extend({shape:BA("point"),center:vo}),spe=yE("shape",[ipe,ope,npe]),rpe=FA({type:BA("schematic_voltage_probe"),schematic_voltage_probe_id:v(),source_component_id:v().optional(),name:v().optional(),position:vo,schematic_trace_id:v(),voltage:ZN.optional(),subcircuit_id:v().optional(),color:v().optional(),label_alignment:ZF.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),ape=FA({type:BA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Ai("schematic_manual_edit_conflict_warning"),warning_type:BA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:v(),schematic_component_id:v(),schematic_group_id:v().optional(),subcircuit_id:v().optional(),source_component_id:v()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),gpe=FA({type:BA("schematic_group"),schematic_group_id:Ai("schematic_group"),source_group_id:v(),is_subcircuit:$A().optional(),subcircuit_id:v().optional(),width:At,height:At,center:vo,schematic_component_ids:dt(v()),show_as_schematic_box:$A().optional(),name:v().optional(),description:v().optional()}).describe("Defines a group of components on the schematic"),cpe=FA({type:BA("schematic_table"),schematic_table_id:Ai("schematic_table"),anchor_position:vo,column_widths:dt(be),row_heights:dt(be),cell_padding:be.optional(),border_width:be.optional(),subcircuit_id:v().optional(),schematic_component_id:v().optional(),anchor:ZF.optional()}).describe("Defines a table on the schematic"),Ipe=FA({type:BA("schematic_table_cell"),schematic_table_cell_id:Ai("schematic_table_cell"),schematic_table_id:v(),start_row_index:GA(),end_row_index:GA(),start_column_index:GA(),end_column_index:GA(),text:v().optional(),center:vo,width:be,height:be,horizontal_align:Tt(["left","center","right"]).optional(),vertical_align:Tt(["top","middle","bottom"]).optional(),font_size:be.optional(),subcircuit_id:v().optional()}).describe("Defines a cell within a schematic_table"),lpe=FA({type:BA("schematic_sheet"),schematic_sheet_id:Ai("schematic_sheet"),name:v().optional(),subcircuit_id:v().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),Bpe=FA({x:be,y:be,bulge:GA().optional()}),XzA=FA({vertices:dt(Bpe)}),Cpe=FA({outer_ring:XzA,inner_rings:dt(XzA).default([])}),Qpe=FA({x:be,y:be,via:$A().optional(),via_to_layer:Wr.optional()});dt(Qpe);var Epe=FA({x:be,y:be,via:$A().optional(),to_layer:Wr.optional(),trace_width:be.optional()}),hpe=FA({type:BA("pcb_component"),pcb_component_id:Ai("pcb_component"),source_component_id:v(),center:vo,layer:Wr,rotation:Td,display_offset_x:v().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:v().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:At,height:At,do_not_place:$A().optional(),subcircuit_id:v().optional(),pcb_group_id:v().optional(),position_mode:Tt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:v().optional(),positioned_relative_to_pcb_board_id:v().optional(),obstructs_within_bounds:$A().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),$zA=FA({type:BA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_component_id:v().optional(),hole_shape:BA("circle"),hole_diameter:GA(),x:be,y:be,is_covered_with_solder_mask:$A().optional(),soldermask_margin:GA().optional()});$zA.describe("Defines a circular hole on the PCB");var AXA=FA({type:BA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_component_id:v().optional(),hole_shape:BA("rect"),hole_width:GA(),hole_height:GA(),x:be,y:be,is_covered_with_solder_mask:$A().optional(),soldermask_margin:GA().optional()});AXA.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square.");var tXA=FA({type:BA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_component_id:v().optional(),hole_shape:Tt(["circle","square"]),hole_diameter:GA(),x:be,y:be,is_covered_with_solder_mask:$A().optional(),soldermask_margin:GA().optional()});tXA.describe("Defines a circular or square hole on the PCB");var eXA=FA({type:BA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_component_id:v().optional(),hole_shape:BA("oval"),hole_width:GA(),hole_height:GA(),x:be,y:be,is_covered_with_solder_mask:$A().optional(),soldermask_margin:GA().optional()});eXA.describe("Defines an oval hole on the PCB");var iXA=FA({type:BA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_component_id:v().optional(),hole_shape:BA("pill"),hole_width:GA(),hole_height:GA(),x:be,y:be,is_covered_with_solder_mask:$A().optional(),soldermask_margin:GA().optional()});iXA.describe("Defines a pill-shaped hole on the PCB");var oXA=FA({type:BA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_component_id:v().optional(),hole_shape:BA("rotated_pill"),hole_width:GA(),hole_height:GA(),x:be,y:be,ccw_rotation:Td,is_covered_with_solder_mask:$A().optional(),soldermask_margin:GA().optional()});oXA.describe("Defines a rotated pill-shaped hole on the PCB");var upe=tXA.or(eXA).or(iXA).or(oXA).or($zA).or(AXA),dpe=FA({type:BA("pcb_plated_hole"),shape:BA("circle"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),outer_diameter:GA(),hole_diameter:GA(),is_covered_with_solder_mask:$A().optional(),x:be,y:be,layers:dt(Wr),port_hints:dt(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:GA().optional()}),ppe=FA({type:BA("pcb_plated_hole"),shape:Tt(["oval","pill"]),pcb_group_id:v().optional(),subcircuit_id:v().optional(),outer_width:GA(),outer_height:GA(),hole_width:GA(),hole_height:GA(),is_covered_with_solder_mask:$A().optional(),x:be,y:be,ccw_rotation:Td,layers:dt(Wr),port_hints:dt(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:GA().optional()}),fpe=FA({type:BA("pcb_plated_hole"),shape:BA("circular_hole_with_rect_pad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:BA("circle"),pad_shape:BA("rect"),hole_diameter:GA(),rect_pad_width:GA(),rect_pad_height:GA(),rect_border_radius:GA().optional(),hole_offset_x:be.default(0),hole_offset_y:be.default(0),is_covered_with_solder_mask:$A().optional(),x:be,y:be,layers:dt(Wr),port_hints:dt(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:GA().optional()}),ype=FA({type:BA("pcb_plated_hole"),shape:BA("pill_hole_with_rect_pad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:BA("pill"),pad_shape:BA("rect"),hole_width:GA(),hole_height:GA(),rect_pad_width:GA(),rect_pad_height:GA(),rect_border_radius:GA().optional(),hole_offset_x:be.default(0),hole_offset_y:be.default(0),is_covered_with_solder_mask:$A().optional(),x:be,y:be,layers:dt(Wr),port_hints:dt(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:GA().optional()}),mpe=FA({type:BA("pcb_plated_hole"),shape:BA("rotated_pill_hole_with_rect_pad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:BA("rotated_pill"),pad_shape:BA("rect"),hole_width:GA(),hole_height:GA(),hole_ccw_rotation:Td,rect_pad_width:GA(),rect_pad_height:GA(),rect_border_radius:GA().optional(),rect_ccw_rotation:Td,hole_offset_x:be.default(0),hole_offset_y:be.default(0),is_covered_with_solder_mask:$A().optional(),x:be,y:be,layers:dt(Wr),port_hints:dt(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:GA().optional()}),wpe=FA({type:BA("pcb_plated_hole"),shape:BA("hole_with_polygon_pad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:Tt(["circle","oval","pill","rotated_pill"]),hole_diameter:GA().optional(),hole_width:GA().optional(),hole_height:GA().optional(),pad_outline:dt(FA({x:be,y:be})).min(3),hole_offset_x:be.default(0),hole_offset_y:be.default(0),is_covered_with_solder_mask:$A().optional(),x:be,y:be,layers:dt(Wr),port_hints:dt(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:GA().optional()}),Dpe=He([dpe,ppe,fpe,ype,mpe,wpe]),Spe=FA({type:BA("pcb_port"),pcb_port_id:Ai("pcb_port"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),source_port_id:v(),pcb_component_id:v().optional(),x:be,y:be,layers:dt(Wr),is_board_pinout:$A().optional()}).describe("Defines a port on the PCB"),bpe=FA({type:BA("pcb_smtpad"),shape:BA("circle"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:be,y:be,radius:GA(),layer:Wr,port_hints:dt(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:$A().optional(),soldermask_margin:GA().optional()}),_pe=FA({type:BA("pcb_smtpad"),shape:BA("rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:be,y:be,width:GA(),height:GA(),rect_border_radius:GA().optional(),corner_radius:GA().optional(),layer:Wr,port_hints:dt(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:$A().optional(),soldermask_margin:GA().optional()}),xpe=FA({type:BA("pcb_smtpad"),shape:BA("rotated_rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:be,y:be,width:GA(),height:GA(),rect_border_radius:GA().optional(),corner_radius:GA().optional(),ccw_rotation:Td,layer:Wr,port_hints:dt(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:$A().optional(),soldermask_margin:GA().optional()}),kpe=FA({type:BA("pcb_smtpad"),shape:BA("pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:be,y:be,width:GA(),height:GA(),radius:GA(),layer:Wr,port_hints:dt(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:$A().optional(),soldermask_margin:GA().optional()}),Fpe=FA({type:BA("pcb_smtpad"),shape:BA("rotated_pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:be,y:be,width:GA(),height:GA(),radius:GA(),ccw_rotation:Td,layer:Wr,port_hints:dt(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:$A().optional(),soldermask_margin:GA().optional()}),Gpe=FA({type:BA("pcb_smtpad"),shape:BA("polygon"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),points:dt(vo),layer:Wr,port_hints:dt(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:$A().optional(),soldermask_margin:GA().optional()}),Rpe=yE("shape",[bpe,_pe,xpe,Fpe,kpe,Gpe]).describe("Defines an SMT pad on the PCB"),Mpe=FA({type:BA("pcb_solder_paste"),shape:BA("circle"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:be,y:be,radius:GA(),layer:Wr,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),Npe=FA({type:BA("pcb_solder_paste"),shape:BA("rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:be,y:be,width:GA(),height:GA(),layer:Wr,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),vpe=FA({type:BA("pcb_solder_paste"),shape:BA("pill"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:be,y:be,width:GA(),height:GA(),radius:GA(),layer:Wr,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),Lpe=FA({type:BA("pcb_solder_paste"),shape:BA("rotated_rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:be,y:be,width:GA(),height:GA(),ccw_rotation:be,layer:Wr,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),Upe=FA({type:BA("pcb_solder_paste"),shape:BA("oval"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:be,y:be,width:GA(),height:GA(),layer:Wr,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),Hpe=He([Mpe,Npe,vpe,Lpe,Upe]).describe("Defines solderpaste on the PCB"),Ype=FA({type:BA("pcb_text"),pcb_text_id:Ai("pcb_text"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),text:v(),center:vo,layer:Wr,width:At,height:At,lines:GA(),align:Tt(["bottom-left"])}).describe("Defines text on the PCB"),Jpe=FA({route_type:BA("wire"),x:be,y:be,width:be,start_pcb_port_id:v().optional(),end_pcb_port_id:v().optional(),layer:Wr}),Tpe=FA({route_type:BA("via"),x:be,y:be,hole_diameter:be.optional(),outer_diameter:be.optional(),from_layer:v(),to_layer:v()}),Kpe=He([Jpe,Tpe]),Ppe=FA({type:BA("pcb_trace"),source_trace_id:v().optional(),pcb_component_id:v().optional(),pcb_trace_id:Ai("pcb_trace"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),route_thickness_mode:Tt(["constant","interpolated"]).default("constant").optional(),route_order_index:GA().optional(),should_round_corners:$A().optional(),trace_length:GA().optional(),highlight_color:v().optional(),route:dt(Kpe)}).describe("Defines a trace on the PCB"),qpe=FA({type:BA("pcb_trace_error"),pcb_trace_error_id:Ai("pcb_trace_error"),error_type:BA("pcb_trace_error").default("pcb_trace_error"),message:v(),center:vo.optional(),pcb_trace_id:v(),source_trace_id:v(),pcb_component_ids:dt(v()),pcb_port_ids:dt(v()),subcircuit_id:v().optional()}).describe("Defines a trace error on the PCB"),Ope=FA({type:BA("pcb_trace_missing_error"),pcb_trace_missing_error_id:Ai("pcb_trace_missing_error"),error_type:BA("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:v(),center:vo.optional(),source_trace_id:v(),pcb_component_ids:dt(v()),pcb_port_ids:dt(v()),subcircuit_id:v().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),Wpe=FA({type:BA("pcb_port_not_matched_error"),pcb_error_id:Ai("pcb_error"),error_type:BA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:v(),pcb_component_ids:dt(v()),subcircuit_id:v().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Zpe=FA({type:BA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Ai("pcb_port_not_connected_error"),error_type:BA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:v(),pcb_port_ids:dt(v()),pcb_component_ids:dt(v()),subcircuit_id:v().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),Vpe=FA({type:BA("pcb_net"),pcb_net_id:Ai("pcb_net"),source_net_id:v().optional(),highlight_color:v().optional()}).describe("Defines a net on the PCB"),jpe=FA({type:BA("pcb_via"),pcb_via_id:Ai("pcb_via"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional(),x:be,y:be,outer_diameter:be.default("0.6mm"),hole_diameter:be.default("0.25mm"),from_layer:Wr.optional(),to_layer:Wr.optional(),layers:dt(Wr),pcb_trace_id:v().optional(),net_is_assignable:$A().optional(),net_assigned:$A().optional(),is_tented:$A().optional()}).describe("Defines a via on the PCB"),zpe=FA({type:BA("pcb_board"),pcb_board_id:Ai("pcb_board"),pcb_panel_id:v().optional(),is_subcircuit:$A().optional(),subcircuit_id:v().optional(),width:At.optional(),height:At.optional(),center:vo,display_offset_x:v().optional().describe("How to display the x offset for this board, usually corresponding with how the user specified it"),display_offset_y:v().optional().describe("How to display the y offset for this board, usually corresponding with how the user specified it"),thickness:At.optional().default(1.4),num_layers:GA().optional().default(4),outline:dt(vo).optional(),shape:Tt(["rect","polygon"]).optional(),material:Tt(["fr4","fr1"]).default("fr4"),anchor_position:vo.optional(),anchor_alignment:ZF.optional(),position_mode:Tt(["relative_to_panel_anchor","none"]).optional()}).describe("Defines the board outline of the PCB"),Xpe=FA({type:BA("pcb_panel"),pcb_panel_id:Ai("pcb_panel"),width:At,height:At,center:vo,covered_with_solder_mask:$A().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),$pe=FA({type:BA("pcb_placement_error"),pcb_placement_error_id:Ai("pcb_placement_error"),error_type:BA("pcb_placement_error").default("pcb_placement_error"),message:v(),subcircuit_id:v().optional()}).describe("Defines a placement error on the PCB"),Afe=FA({type:BA("pcb_trace_hint"),pcb_trace_hint_id:Ai("pcb_trace_hint"),pcb_port_id:v(),pcb_component_id:v(),route:dt(Epe),subcircuit_id:v().optional()}).describe("A hint that can be used during generation of a PCB trace"),tfe=FA({type:BA("pcb_silkscreen_line"),pcb_silkscreen_line_id:Ai("pcb_silkscreen_line"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),stroke_width:be.default("0.1mm"),x1:be,y1:be,x2:be,y2:be,layer:nD}).describe("Defines a silkscreen line on the PCB"),efe=FA({type:BA("pcb_silkscreen_path"),pcb_silkscreen_path_id:Ai("pcb_silkscreen_path"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:nD,route:dt(vo),stroke_width:At}).describe("Defines a silkscreen path on the PCB"),ife=FA({type:BA("pcb_silkscreen_text"),pcb_silkscreen_text_id:Ai("pcb_silkscreen_text"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),font:BA("tscircuit2024").default("tscircuit2024"),font_size:be.default("0.2mm"),pcb_component_id:v(),text:v(),is_knockout:$A().default(!1).optional(),knockout_padding:FA({left:At,top:At,bottom:At,right:At}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:GA().optional(),layer:Wr,is_mirrored:$A().default(!1).optional(),anchor_position:vo.default({x:0,y:0}),anchor_alignment:ZF.default("center")}).describe("Defines silkscreen text on the PCB"),ofe=FA({type:BA("pcb_copper_text"),pcb_copper_text_id:Ai("pcb_copper_text"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),font:BA("tscircuit2024").default("tscircuit2024"),font_size:be.default("0.2mm"),pcb_component_id:v(),text:v(),is_knockout:$A().default(!1).optional(),knockout_padding:FA({left:At,top:At,bottom:At,right:At}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:GA().optional(),layer:Wr,is_mirrored:$A().default(!1).optional(),anchor_position:vo.default({x:0,y:0}),anchor_alignment:ZF.default("center")}).describe("Defines copper text on the PCB"),nfe=FA({type:BA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Ai("pcb_silkscreen_rect"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:vo,width:At,height:At,layer:Wr,stroke_width:At.default("1mm"),corner_radius:At.optional(),is_filled:$A().default(!0).optional(),has_stroke:$A().optional(),is_stroke_dashed:$A().optional(),ccw_rotation:GA().optional()}).describe("Defines a silkscreen rect on the PCB"),sfe=FA({type:BA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Ai("pcb_silkscreen_circle"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:vo,radius:At,layer:nD,stroke_width:At.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),rfe=FA({type:BA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Ai("pcb_silkscreen_oval"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:vo,radius_x:be,radius_y:be,layer:nD,ccw_rotation:Td.optional()}).describe("Defines a silkscreen oval on the PCB"),afe=FA({type:BA("pcb_silkscreen_pill"),pcb_silkscreen_pill_id:Ai("pcb_silkscreen_pill"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:vo,width:At,height:At,layer:Wr,ccw_rotation:GA().optional()}).describe("Defines a silkscreen pill on the PCB"),gfe=FA({type:BA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Ai("pcb_fabrication_note_text"),subcircuit_id:v().optional(),pcb_group_id:v().optional(),font:BA("tscircuit2024").default("tscircuit2024"),font_size:be.default("1mm"),pcb_component_id:v(),text:v(),layer:nD,anchor_position:vo.default({x:0,y:0}),anchor_alignment:Tt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:v().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),cfe=FA({type:BA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Ai("pcb_fabrication_note_path"),pcb_component_id:v(),subcircuit_id:v().optional(),layer:Wr,route:dt(vo),stroke_width:At,color:v().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),Ife=FA({type:BA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Ai("pcb_fabrication_note_rect"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:vo,width:At,height:At,layer:nD,stroke_width:At.default("0.1mm"),corner_radius:At.optional(),is_filled:$A().optional(),has_stroke:$A().optional(),is_stroke_dashed:$A().optional(),color:v().optional()}).describe("Defines a fabrication note rectangle on the PCB"),lfe=FA({type:BA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Ai("pcb_fabrication_note_dimension"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:nD,from:vo,to:vo,text:v().optional(),text_ccw_rotation:GA().optional(),offset:At.optional(),offset_distance:At.optional(),offset_direction:FA({x:GA(),y:GA()}).optional(),font:BA("tscircuit2024").default("tscircuit2024"),font_size:At.default("1mm"),color:v().optional(),arrow_size:At.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),Bfe=FA({type:BA("pcb_note_text"),pcb_note_text_id:Ai("pcb_note_text"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),font:BA("tscircuit2024").default("tscircuit2024"),font_size:be.default("1mm"),text:v().optional(),anchor_position:vo.default({x:0,y:0}),anchor_alignment:Tt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:v().optional()}).describe("Defines a documentation note in text on the PCB"),Cfe=FA({type:BA("pcb_note_rect"),pcb_note_rect_id:Ai("pcb_note_rect"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),text:v().optional(),center:vo,width:At,height:At,stroke_width:At.default("0.1mm"),corner_radius:At.optional(),is_filled:$A().optional(),has_stroke:$A().optional(),is_stroke_dashed:$A().optional(),color:v().optional()}).describe("Defines a rectangular documentation note on the PCB"),Qfe=FA({type:BA("pcb_note_path"),pcb_note_path_id:Ai("pcb_note_path"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),text:v().optional(),route:dt(vo),stroke_width:At.default("0.1mm"),color:v().optional()}).describe("Defines a polyline documentation note on the PCB"),Efe=FA({type:BA("pcb_note_line"),pcb_note_line_id:Ai("pcb_note_line"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),text:v().optional(),x1:be,y1:be,x2:be,y2:be,stroke_width:be.default("0.1mm"),color:v().optional(),is_dashed:$A().optional()}).describe("Defines a straight documentation note line on the PCB"),hfe=FA({type:BA("pcb_note_dimension"),pcb_note_dimension_id:Ai("pcb_note_dimension"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),from:vo,to:vo,text:v().optional(),text_ccw_rotation:GA().optional(),offset_distance:At.optional(),offset_direction:FA({x:GA(),y:GA()}).optional(),font:BA("tscircuit2024").default("tscircuit2024"),font_size:At.default("1mm"),color:v().optional(),arrow_size:At.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),ufe=FA({type:BA("pcb_footprint_overlap_error"),pcb_error_id:Ai("pcb_error"),error_type:BA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:v(),pcb_smtpad_ids:dt(v()).optional(),pcb_plated_hole_ids:dt(v()).optional(),pcb_hole_ids:dt(v()).optional(),pcb_keepout_ids:dt(v()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),dfe=FA({type:BA("pcb_keepout"),shape:BA("rect"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:vo,width:be,height:be,pcb_keepout_id:v(),layers:dt(v()),description:v().optional()}).or(FA({type:BA("pcb_keepout"),shape:BA("circle"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:vo,radius:be,pcb_keepout_id:v(),layers:dt(v()),description:v().optional()})),nW=FA({type:BA("pcb_cutout"),pcb_cutout_id:Ai("pcb_cutout"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_board_id:v().optional(),pcb_panel_id:v().optional()}),pfe=nW.extend({shape:BA("rect"),center:vo,width:At,height:At,rotation:Td.optional(),corner_radius:At.optional()}),ffe=nW.extend({shape:BA("circle"),center:vo,radius:At}),yfe=nW.extend({shape:BA("polygon"),points:dt(vo)}),mfe=nW.extend({shape:BA("path"),route:dt(vo),slot_width:At,slot_length:At.optional(),space_between_slots:At.optional(),slot_corner_radius:At.optional()}),wfe=yE("shape",[pfe,ffe,yfe,mfe]).describe("Defines a cutout on the PCB, removing board material."),Dfe=FA({type:BA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Ai("pcb_missing_footprint_error"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),error_type:BA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:v(),message:v()}).describe("Defines a missing footprint error on the PCB"),Sfe=FA({type:BA("external_footprint_load_error"),external_footprint_load_error_id:Ai("external_footprint_load_error"),pcb_component_id:v(),source_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),footprinter_string:v().optional(),error_type:BA("external_footprint_load_error").default("external_footprint_load_error"),message:v()}).describe("Defines an error when an external footprint fails to load"),bfe=FA({type:BA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Ai("circuit_json_footprint_load_error"),pcb_component_id:v(),source_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),error_type:BA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:v(),circuit_json:dt(Og()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),_fe=FA({type:BA("pcb_group"),pcb_group_id:Ai("pcb_group"),source_group_id:v(),is_subcircuit:$A().optional(),subcircuit_id:v().optional(),width:At.optional(),height:At.optional(),center:vo,display_offset_x:v().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:v().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:dt(vo).optional(),anchor_position:vo.optional(),anchor_alignment:ZF.default("center"),position_mode:Tt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:v().optional(),positioned_relative_to_pcb_board_id:v().optional(),pcb_component_ids:dt(v()),child_layout_mode:Tt(["packed","none"]).optional(),name:v().optional(),description:v().optional(),layout_mode:v().optional(),autorouter_configuration:FA({trace_clearance:At}).optional(),autorouter_used_string:v().optional()}).describe("Defines a group of components on the PCB"),xfe=FA({type:BA("pcb_autorouting_error"),pcb_error_id:Ai("pcb_autorouting_error"),error_type:BA("pcb_autorouting_error").default("pcb_autorouting_error"),message:v(),subcircuit_id:v().optional()}).describe("The autorouting has failed to route a portion of the board"),kfe=FA({type:BA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Ai("pcb_manual_edit_conflict_warning"),warning_type:BA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:v(),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),source_component_id:v()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),Ffe=FA({type:BA("pcb_breakout_point"),pcb_breakout_point_id:Ai("pcb_breakout_point"),pcb_group_id:v(),subcircuit_id:v().optional(),source_trace_id:v().optional(),source_port_id:v().optional(),source_net_id:v().optional(),x:be,y:be}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),Gfe=FA({type:BA("pcb_ground_plane"),pcb_ground_plane_id:Ai("pcb_ground_plane"),source_pcb_ground_plane_id:v(),source_net_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional()}).describe("Defines a ground plane on the PCB"),Rfe=FA({type:BA("pcb_ground_plane_region"),pcb_ground_plane_region_id:Ai("pcb_ground_plane_region"),pcb_ground_plane_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:Wr,points:dt(vo)}).describe("Defines a polygon region of a ground plane"),Mfe=FA({type:BA("pcb_thermal_spoke"),pcb_thermal_spoke_id:Ai("pcb_thermal_spoke"),pcb_ground_plane_id:v(),shape:v(),spoke_count:GA(),spoke_thickness:be,spoke_inner_diameter:be,spoke_outer_diameter:be,pcb_plated_hole_id:v().optional(),subcircuit_id:v().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),IEA=FA({type:BA("pcb_copper_pour"),pcb_copper_pour_id:Ai("pcb_copper_pour"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:Wr,source_net_id:v().optional(),covered_with_solder_mask:$A().optional().default(!0)}),Nfe=IEA.extend({shape:BA("rect"),center:vo,width:At,height:At,rotation:Td.optional()}),vfe=IEA.extend({shape:BA("brep"),brep_shape:Cpe}),Lfe=IEA.extend({shape:BA("polygon"),points:dt(vo)}),Ufe=yE("shape",[Nfe,vfe,Lfe]).describe("Defines a copper pour on the PCB."),Hfe=FA({type:BA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Ai("pcb_component_outside_board_error"),error_type:BA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:v(),pcb_component_id:v(),pcb_board_id:v(),component_center:vo,component_bounds:FA({min_x:GA(),max_x:GA(),min_y:GA(),max_y:GA()}),subcircuit_id:v().optional(),source_component_id:v().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),Yfe=FA({type:BA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Ai("pcb_component_invalid_layer_error"),error_type:BA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:v(),pcb_component_id:v().optional(),source_component_id:v(),layer:Wr,subcircuit_id:v().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),Jfe=FA({type:BA("pcb_via_clearance_error"),pcb_error_id:Ai("pcb_error"),error_type:BA("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:v(),pcb_via_ids:dt(v()).min(2),minimum_clearance:be.optional(),actual_clearance:be.optional(),pcb_center:FA({x:GA().optional(),y:GA().optional()}).optional(),subcircuit_id:v().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),Tfe=FA({type:BA("pcb_courtyard_rect"),pcb_courtyard_rect_id:Ai("pcb_courtyard_rect"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:vo,width:At,height:At,layer:nD,color:v().optional()}).describe("Defines a courtyard rectangle on the PCB"),Kfe=FA({type:BA("pcb_courtyard_outline"),pcb_courtyard_outline_id:Ai("pcb_courtyard_outline"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:nD,outline:dt(vo).min(2),stroke_width:At.default("0.1mm"),is_closed:$A().optional(),is_stroke_dashed:$A().optional(),color:v().optional()}).describe("Defines a courtyard outline on the PCB"),Pfe=FA({type:BA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Ai("pcb_courtyard_polygon"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:nD,points:dt(vo).min(3),color:v().optional()}).describe("Defines a courtyard polygon on the PCB"),qfe=FA({type:BA("cad_component"),cad_component_id:v(),pcb_component_id:v(),source_component_id:v(),position:aEA,rotation:aEA.optional(),size:aEA.optional(),layer:Wr.optional(),subcircuit_id:v().optional(),footprinter_string:v().optional(),model_obj_url:v().optional(),model_stl_url:v().optional(),model_3mf_url:v().optional(),model_gltf_url:v().optional(),model_glb_url:v().optional(),model_step_url:v().optional(),model_wrl_url:v().optional(),model_unit_to_mm_scale_factor:GA().optional(),model_jscad:Og().optional(),show_as_translucent_model:$A().optional()}).describe("Defines a component on the PCB"),nXA=Tt(["sinewave","square","triangle","sawtooth"]),Ofe=He([v(),GA()]).transform(e=>typeof e=="string"?e.endsWith("%")?parseFloat(e.slice(0,-1))/100:parseFloat(e):e).pipe(GA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),Wfe=FA({type:BA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:BA(!0).optional().default(!0),positive_source_port_id:v().optional(),negative_source_port_id:v().optional(),positive_source_net_id:v().optional(),negative_source_net_id:v().optional(),voltage:ZN}).describe("Defines a DC voltage source for simulation"),Zfe=FA({type:BA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:BA(!1),terminal1_source_port_id:v().optional(),terminal2_source_port_id:v().optional(),terminal1_source_net_id:v().optional(),terminal2_source_net_id:v().optional(),voltage:ZN.optional(),frequency:oW.optional(),peak_to_peak_voltage:ZN.optional(),wave_shape:nXA.optional(),phase:Td.optional(),duty_cycle:Ofe.optional()}).describe("Defines an AC voltage source for simulation"),Vfe=He([Wfe,Zfe]).describe("Defines a voltage source for simulation"),jfe=He([v(),GA()]).transform(e=>typeof e=="string"?e.endsWith("%")?parseFloat(e.slice(0,-1))/100:parseFloat(e):e).pipe(GA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),zfe=FA({type:BA("simulation_current_source"),simulation_current_source_id:Ai("simulation_current_source"),is_dc_source:BA(!0).optional().default(!0),positive_source_port_id:v().optional(),negative_source_port_id:v().optional(),positive_source_net_id:v().optional(),negative_source_net_id:v().optional(),current:sEA}).describe("Defines a DC current source for simulation"),Xfe=FA({type:BA("simulation_current_source"),simulation_current_source_id:Ai("simulation_current_source"),is_dc_source:BA(!1),terminal1_source_port_id:v().optional(),terminal2_source_port_id:v().optional(),terminal1_source_net_id:v().optional(),terminal2_source_net_id:v().optional(),current:sEA.optional(),frequency:oW.optional(),peak_to_peak_current:sEA.optional(),wave_shape:nXA.optional(),phase:Td.optional(),duty_cycle:jfe.optional()}).describe("Defines an AC current source for simulation"),$fe=He([zfe,Xfe]).describe("Defines a current source for simulation"),A0e=He([BA("spice_dc_sweep"),BA("spice_dc_operating_point"),BA("spice_transient_analysis"),BA("spice_ac_analysis")]),t0e=FA({type:BA("simulation_experiment"),simulation_experiment_id:Ai("simulation_experiment"),name:v(),experiment_type:A0e,time_per_step:rEA.optional(),start_time_ms:VN.optional(),end_time_ms:VN.optional()}).describe("Defines a simulation experiment configuration"),e0e=FA({type:BA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Ai("simulation_transient_voltage_graph"),simulation_experiment_id:v(),timestamps_ms:dt(GA()).optional(),voltage_levels:dt(GA()),source_component_id:v().optional(),subcircuit_connectivity_map_key:v().optional(),time_per_step:rEA,start_time_ms:VN,end_time_ms:VN,name:v().optional(),color:v().optional()}).describe("Stores voltage measurements over time for a simulation"),i0e=FA({type:BA("simulation_switch"),simulation_switch_id:Ai("simulation_switch"),source_component_id:v().optional(),closes_at:VN.optional(),opens_at:VN.optional(),starts_closed:$A().optional(),switching_frequency:oW.optional()}).describe("Defines a switch for simulation timing control"),o0e=FA({type:BA("simulation_voltage_probe"),simulation_voltage_probe_id:Ai("simulation_voltage_probe"),source_component_id:v().optional(),name:v().optional(),signal_input_source_port_id:v().optional(),signal_input_source_net_id:v().optional(),reference_input_source_port_id:v().optional(),reference_input_source_net_id:v().optional(),subcircuit_id:v().optional(),color:v().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((e,A)=>{if(e.reference_input_source_port_id||e.reference_input_source_net_id){const i=!!e.signal_input_source_port_id||!!e.reference_input_source_port_id,o=!!e.signal_input_source_net_id||!!e.reference_input_source_net_id;i&&o?A.addIssue({code:Oe.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!e.signal_input_source_port_id||!e.reference_input_source_port_id)&&A.addIssue({code:Oe.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):o&&(!e.signal_input_source_net_id||!e.reference_input_source_net_id)&&A.addIssue({code:Oe.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!e.signal_input_source_port_id==!!e.signal_input_source_net_id&&A.addIssue({code:Oe.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),n0e=FA({type:BA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Ai("simulation_unknown_experiment_error"),error_type:BA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:v(),simulation_experiment_id:v().optional(),subcircuit_id:v().optional()}).describe("An unknown error occurred during the simulation experiment."),s0e=FA({type:BA("simulation_op_amp"),simulation_op_amp_id:Ai("simulation_op_amp"),source_component_id:v().optional(),inverting_input_source_port_id:v(),non_inverting_input_source_port_id:v(),output_source_port_id:v(),positive_supply_source_port_id:v(),negative_supply_source_port_id:v()}).describe("Defines a simple ideal operational amplifier for simulation");He([kde,_de,xde,bde,Gde,Fde,MzA,FzA,gEA,RzA,GzA,NzA,vzA,LzA,YzA,JzA,TzA,WzA,KzA,PzA,qzA,OzA,HzA,UzA,Mde,vde,Rde,ZzA,VzA,jzA,Lde,Ude,hpe,upe,Dfe,Sfe,bfe,kfe,Dpe,dfe,Spe,Vpe,Ype,Ppe,jpe,Rpe,Hpe,zpe,Xpe,_fe,Afe,tfe,efe,ife,afe,ofe,nfe,sfe,rfe,qpe,Ope,$pe,Wpe,Zpe,Jfe,cfe,gfe,Ife,lfe,Bfe,Cfe,Qfe,Efe,hfe,xfe,ufe,Ffe,wfe,Gfe,Rfe,Mfe,Ufe,Hfe,Yfe,Tfe,Kfe,Pfe,Hde,Xde,Ode,Wde,Zde,Vde,qde,$de,jde,Yde,tpe,epe,Ape,spe,rpe,ape,gpe,lpe,cpe,Ipe,qfe,Vfe,$fe,t0e,e0e,i0e,o0e,n0e,s0e]);var r0e=Object.defineProperty,a0e=(e,A)=>{for(var t in A)r0e(e,t,{get:A[t],enumerable:!0})},ib={};a0e(ib,{axial:()=>Fye,bga:()=>Y0e,breakoutheaders:()=>Pye,cap:()=>Q0e,dfn:()=>lye,diode:()=>C0e,dip:()=>I0e,electrolytic:()=>bDe,hc49:()=>Oye,jst:()=>Vwe,led:()=>E0e,lqfp:()=>Tye,m2host:()=>ZDe,melf:()=>owe,micromelf:()=>awe,minimelf:()=>jme,mlp:()=>V0e,ms012:()=>dye,ms013:()=>fye,msop:()=>nDe,pad:()=>Wye,pinrow:()=>Qye,platedhole:()=>HDe,potentiometer:()=>wDe,pushbutton:()=>vye,qfn:()=>O0e,qfp:()=>Z0e,quad:()=>zN,radial:()=>Mye,res:()=>L0e,sma:()=>lwe,smb:()=>pwe,smbf:()=>xDe,smc:()=>wwe,smf:()=>Ewe,smtpad:()=>LDe,sod110:()=>zwe,sod123:()=>bye,sod123f:()=>_me,sod123fl:()=>Gme,sod123w:()=>ame,sod128:()=>Yme,sod323:()=>lme,sod323f:()=>wme,sod323fl:()=>IDe,sod323w:()=>rDe,sod523:()=>Xye,sod723:()=>vme,sod80:()=>ome,sod882:()=>pme,sod882d:()=>Awe,sod923:()=>Eme,soic:()=>T0e,solderjumper:()=>EDe,son:()=>QDe,sop8:()=>eme,sot:()=>JDe,sot223:()=>_we,sot23:()=>nye,sot23w:()=>Lwe,sot25:()=>gye,sot323:()=>RDe,sot343:()=>PDe,sot363:()=>tye,sot457:()=>dDe,sot563:()=>hye,sot723:()=>mye,sot886:()=>iye,sot89:()=>Ome,sot963:()=>fDe,ssop:()=>z0e,stampboard:()=>Uye,stampreceiver:()=>Jye,to220:()=>Zme,to92:()=>jye,to92l:()=>jDe,to92s:()=>Kwe,tqfp:()=>W0e,tssop:()=>$0e,vssop:()=>eDe});var Zi=(e,A,t)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:e,y:A},anchor_alignment:"center"}),Vi=FA({norefdes:$A().optional().describe("disable reference designator label"),invert:$A().optional().describe("hint to invert the orientation of the 3D model"),faceup:$A().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:$A().optional().describe("omit all silkscreen elements from the footprint")}),$n=(e,A,t,i,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:t,hole_diameter:Mr(i),outer_diameter:Mr(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[e.toString()]}),ob=(e,A,t,i,o,n,s,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:A,y:t,hole_diameter:Mr(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:Mr(o),rect_pad_height:Mr(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[e.toString()],hole_offset_x:s,hole_offset_y:r}),sXA=Array.from({length:9},(e,A)=>Math.cos(A/8*Math.PI-Math.PI)).map(e=>({x:e,y:-Math.sqrt(1-e**2)}));function Ex(e){return typeof e=="string"?e.trim().toLowerCase().endsWith("mil")?parseFloat(e)*.0254:parseFloat(e):Number(e)}var sW=He([v(),GA()]).transform(e=>Ex(e)),g0e=e=>Vi.extend({fn:v(),num_pins:GA().optional().default(6),wide:$A().optional(),narrow:$A().optional(),w:sW.optional(),p:sW.default(e.p??"2.54mm"),id:sW.optional(),od:sW.optional(),nosquareplating:$A().optional().default(!1).describe("do not use rectangular pad for pin 1")}).transform(A=>(!A.id&&!A.od?Math.abs(A.p-1.27)<.01?(A.id=Ex("0.55mm"),A.od=Ex("0.95mm")):(A.id=Ex("0.8mm"),A.od=Ex("1.6mm")):A.id?A.od||(A.od=A.id*(1.5/1)):A.id=A.od*(1/1.5),A.w||(A.wide?A.w=Ex("600mil"):A.narrow?A.w=Ex("300mil"):A.w=Ex(e.w??"300mil")),A)),c0e=g0e({}),rXA=(e,A,t,i,o)=>{const n=e/2,s=A<=n,r=n-1,a=i,g=a*r;return s?{x:-t/2,y:g/2-(A-1)*a}:{x:t/2,y:-g/2+(A-n-1)*a}},I0e=e=>{const A=c0e.parse(e),t=[];for(let g=0;g<A.num_pins;g++){const{x:c,y:I}=rXA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating);if(g===0&&!A.nosquareplating){t.push(ob(g+1,c,I,A.id??"0.8mm",A.od??"1mm",A.od??"1mm"));continue}t.push($n(g+1,c,I,A.id??"0.8mm",A.od??"1mm"))}(A.num_pins/2-1)*A.p+A.od;const o=A.w-A.od-1,n=(A.num_pins/2-1)*A.p+A.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/2,y:-n/2},{x:-o/2,y:n/2},...sXA.map(({x:g,y:c})=>({x:g*o/6,y:c*o/6+n/2})),{x:o/2,y:n/2},{x:o/2,y:-n/2},{x:-o/2,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1},r=[];for(let g=0;g<A.num_pins;g++){const c=g<A.num_pins/2,I=.6,{y:l}=rXA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating),B=c?-A.w/2-A.od/2-I:A.w/2+A.od/2+I,C=l;r.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${g+1}`,layer:"top",pcb_component_id:`pin_${g+1}`,text:`{pin${g+1}}`,anchor_position:{x:B,y:C},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Zi(0,n/2+.5,.4);return{circuitJson:[...t,s,a,...r],parameters:A}},yi=(e,A,t,i,o)=>({type:"pcb_smtpad",x:A,y:t,width:i,height:o,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(e)?e.map(n=>n.toString()):[e.toString()]}),aXA=[{imperial:"01005",metric:"0402",p_mm_min:.5,pw_mm_min:.4,ph_mm_min:.3,w_mm_min:.58,h_mm_min:.21},{imperial:"0504",metric:"1310",p_mm_min:1.1,pw_mm_min:.65,ph_mm_min:1.3,w_mm_min:.58,h_mm_min:.21},{imperial:"1812",metric:"4532",p_mm_min:4.275,pw_mm_min:1.125,ph_mm_min:3.4,w_mm_min:5.4,h_mm_min:3.4},{imperial:"0201",metric:"0603",p_mm_min:.66,pw_mm_min:.46,ph_mm_min:.4,w_mm_min:.9,h_mm_min:.3},{imperial:"0402",metric:"1005",p_mm_min:1.02,pw_mm_min:.54,ph_mm_min:.64,w_mm_min:1.56,h_mm_min:.64},{imperial:"0603",metric:"1608",p_mm_min:1.65,pw_mm_min:.8,ph_mm_min:.95,w_mm_min:2.45,h_mm_min:.95},{imperial:"0805",metric:"2012",p_mm_min:1.825,pw_mm_min:1.025,ph_mm_min:1.4,w_mm_min:2.8499999999999996,h_mm_min:1.4},{imperial:"1206",metric:"3216",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:1.75,w_mm_min:4.05,h_mm_min:1.75},{imperial:"1210",metric:"3225",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:2.65,w_mm_min:4.05,h_mm_min:2.65},{imperial:"2010",metric:"5025",p_mm_min:4.625,pw_mm_min:1.225,ph_mm_min:2.65,w_mm_min:5.85,h_mm_min:2.65},{imperial:"2512",metric:"6332",p_mm_min:5.925,pw_mm_min:1.225,ph_mm_min:3.35,w_mm_min:7.15,h_mm_min:3.35}],l0e=Object.fromEntries(aXA.map(e=>[e.metric,e])),B0e=Object.fromEntries(aXA.map(e=>[e.imperial,e]));Vi.extend({tht:$A(),p:At.optional(),pw:At.optional(),ph:At.optional(),metric:be.optional(),imperial:be.optional(),w:At.optional(),h:At.optional(),textbottom:$A().optional()});var rW=e=>{let{tht:A,p:t,pw:i,ph:o,metric:n,imperial:s,w:r,h:a,textbottom:g}=e;if(typeof r=="string"&&(r=Fl(r)),typeof a=="string"&&(a=Fl(a)),typeof t=="string"&&(t=Fl(t)),typeof i=="string"&&(i=Fl(i)),typeof o=="string"&&(o=Fl(o)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let c;if(n&&(c=l0e[n]),s&&(c=B0e[s]),c&&(r=c.w_mm_min,a=c.h_mm_min,t=c.p_mm_min,i=c.pw_mm_min,o=c.ph_mm_min),t===void 0||i===void 0||o===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:t/2,y:o/2+.4},{x:-t/2-i/2-.2,y:o/2+.4},{x:-t/2-i/2-.2,y:-o/2-.4},{x:t/2,y:-o/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},l=g?-o/2-.9:o/2+.9,B=Zi(0,l,.2);return A?[$n(1,-t/2,0,i,i*1/.8),$n(2,t/2,0,i,i*1/.8),I,B]:[yi(["1","left"],-t/2,0,i,o),yi(["2","right"],t/2,0,i,o),I,B]},C0e=e=>({circuitJson:rW(e),parameters:e}),Q0e=e=>({circuitJson:rW(e),parameters:e}),E0e=e=>({circuitJson:rW(e),parameters:e}),jN=e=>{const{padSpacing:A,padWidth:t,padHeight:i,padPitch:o,numRows:n,textbottom:s}=e,r=[],a=(n-1)*(o/2);for(let b=0;b<n;b++)r.push(a-b*o);const g=[];r.forEach((b,k)=>{g.push(yi(k+1,-A/2,b,t,i))}),r.slice().reverse().forEach((b,k)=>{g.push(yi(k+n+1,A/2,b,t,i))});const c=Math.max(...r)+i/2+.4,I=Math.min(...r)-i/2-.4,l=-A/2-t/2-.4,B=A/2+t/2+.4,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B*.5,y:c},{x:l*.5,y:c}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B*.5,y:I},{x:l*.5,y:I}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},Q=-A/2,h=Math.max(...r),u=.2,d=Q-t/2-.1,f=h+i/2+.1,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:[{x:d,y:f},{x:d-u,y:f},{x:d,y:f+u},{x:d,y:f}],stroke_width:.1},D=s?I-.9:c+.9,w=Zi(0,D,.2);return[...g,C,E,m,w]},h0e=Vi.extend({pw:v().default("0.5mm"),ph:v().default("0.4mm"),p:v().default("0.7mm"),textbottom:$A().optional()}),u0e=1,d0e=e=>{const A=h0e.parse(e),t=Fl(A.pw),i=Fl(A.ph),o=Fl(A.p);return jN({padSpacing:u0e,padWidth:t,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},p0e=Vi.extend({pw:v().default("0.5mm"),ph:v().default("0.32mm"),p:v().default("0.5mm"),textbottom:$A().optional()}),f0e=1,y0e=e=>{const A=p0e.parse(e),t=Fl(A.pw),i=Fl(A.ph),o=Fl(A.p);return jN({padSpacing:f0e,padWidth:t,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},m0e=Vi.extend({pw:v().default("0.9mm"),ph:v().default("0.4mm"),p:v().default("0.8mm"),textbottom:$A().optional()}),w0e=1.7,D0e=e=>{const A=m0e.parse(e),t=Fl(A.pw),i=Fl(A.ph),o=Fl(A.p);return jN({padSpacing:w0e,padWidth:t,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},S0e=Vi.extend({pw:v().default("0.9mm"),ph:v().default("0.4mm"),p:v().default("0.8mm"),textbottom:$A().optional()}),b0e=1.7,_0e=e=>{const A=S0e.parse(e),t=Fl(A.pw),i=Fl(A.ph),o=Fl(A.p);return jN({padSpacing:b0e,padWidth:t,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},x0e=Vi.extend({pw:v().default("0.7mm"),ph:v().default("0.64mm"),p:v().default("0.94mm"),textbottom:$A().optional()}),k0e=1.4,F0e=e=>{const A=x0e.parse(e),t=Fl(A.pw),i=Fl(A.ph),o=Fl(A.p);return jN({padSpacing:k0e,padWidth:t,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},G0e=Vi.extend({pw:v().default("0.9mm"),ph:v().default("0.9mm"),p:v().default("1.34mm"),textbottom:$A().optional()}),R0e=3,M0e=e=>{const A=G0e.parse(e),t=Fl(A.pw),i=Fl(A.ph),o=Fl(A.p);return jN({padSpacing:R0e,padWidth:t,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},N0e=e=>{const A=e.array??e.x;if(typeof A=="number")return Number.isNaN(A)?void 0:A;if(typeof A=="string"){const t=Number.parseInt(A,10);return Number.isNaN(t)?void 0:t}if(typeof e.imperial=="string"){const i=e.imperial.match(/(?:array|x)(2|4)$/)?.[1];if(i)return Number.parseInt(i,10)}},v0e=e=>e?(typeof e=="number"?`${e}`:e).split("_")[0]:void 0,L0e=e=>{const A=N0e(e),t=v0e(e.imperial);return A===2&&t==="0402"?{circuitJson:d0e(e),parameters:e}:A===4&&t==="0402"?{circuitJson:y0e(e),parameters:e}:A===2&&t==="0603"?{circuitJson:D0e(e),parameters:e}:A===4&&t==="0603"?{circuitJson:_0e(e),parameters:e}:A===2&&t==="0606"?{circuitJson:F0e(e),parameters:e}:A===4&&t==="1206"?{circuitJson:M0e(e),parameters:e}:{circuitJson:rW(e),parameters:e}},gXA=(e,{x:A,y:t,radius:i})=>({type:"pcb_smtpad",x:A,y:t,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(e)?e.map(o=>o.toString()):[e.toString()]}),cXA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",IXA=v().transform(e=>{const[A,t]=e.split(/[x ]/);return{x:parseFloat(A),y:parseFloat(t)}}).pipe(FA({x:GA(),y:GA()})),U0e=v().or(dt(Og())).transform(e=>Array.isArray(e)?e:(e.startsWith("(")&&e.endsWith(")")&&(e=e.slice(1,-1)),e.split(",").map(A=>{const t=Number(A);return isNaN(t)?A:t}))).pipe(dt(v().or(GA()))),H0e=Vi.extend({fn:v(),num_pins:GA().optional().default(64),grid:IXA.optional(),p:be.default("0.8mm"),w:At.optional(),h:At.optional(),ball:At.optional().describe("ball diameter"),pad:At.optional().describe("pad width/height"),circularpads:$A().optional().describe("use circular pads"),tlorigin:$A().optional(),blorigin:$A().optional(),trorigin:$A().optional(),brorigin:$A().optional(),missing:U0e.default([])}).transform(e=>{let A="tl";if(e.blorigin&&(A="bl"),e.trorigin&&(A="tr"),e.brorigin&&(A="br"),!e.grid){const i=Math.ceil(Math.sqrt(e.num_pins));e.grid={x:i,y:i}}return e.missing&&(e.missing=e.missing.map(i=>{if(typeof i=="number")return i;if(i==="center")return"center";if(i==="topleft")return"topleft";const o=i.match(/([A-Z]+)(\d+)/);if(!o)return i;const n=cXA.indexOf(o[1]),s=Number.parseInt(o[2])-1;return n*e.grid.x+s+1})),{...e,origin:A}}),Y0e=e=>{const A=H0e.parse(e);let{num_pins:t,grid:i,p:o,w:n,h:s,ball:r,pad:a,missing:g}=A;r??=.75/1.27*o,a??=r*.8;const c=[],I=(g??[]).filter(m=>typeof m=="number"),l=i.x*i.y-t;if(g.length===0&&l>0&&(Math.sqrt(l)%1===0?g.push("center"):l===1&&g.push("topleft")),g?.includes("center")){const m=Math.floor(Math.sqrt(l)),D=Math.floor((i.x-m)/2),w=Math.floor((i.y-m)/2);for(let b=w;b<w+m;b++)for(let k=D;k<D+m;k++)I.push(b*i.x+k+1)}g?.includes("topleft")&&I.push(1);const B=new Set(I);let C=0;for(let m=0;m<i.y;m++)for(let D=0;D<i.x;D++){const w=(D-(i.x-1)/2)*o,b=(m-(i.y-1)/2)*o;let k=D,_=m;switch(A.origin){case"bl":k=D,_=i.y-1-m;break;case"br":k=i.x-1-D,_=i.y-1-m;break;case"tr":k=i.x-1-D,_=m;break}let N=_*i.x+k+1;if(B.has(N)){C++;continue}N-=C;const M=[N,`${cXA[_]}${k+1}`];c.push(A.circularpads?gXA(M,{x:w,y:b,radius:a/2}):yi(M,w,b,a,a))}const E=Zi(0,i.y*o/2,.2),Q=o/6;let h;const u=i.x*o/2,d=i.y*o/2;switch(A.origin){case"bl":h=[{x:-u,y:-d},{x:-u,y:-d-Q},{x:-u-Q,y:-d},{x:-u,y:-d}];break;case"br":h=[{x:u,y:-d},{x:u,y:-d-Q},{x:u+Q,y:-d},{x:u,y:-d}];break;case"tr":h=[{x:u,y:d},{x:u,y:d+Q},{x:u+Q,y:d},{x:u,y:d}];break;default:h=[{x:-u,y:d},{x:-u,y:d+Q},{x:-u-Q,y:d},{x:-u,y:d}];break}const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:h,stroke_width:.05};return{circuitJson:[...c,E,f],parameters:A}},aW=(e,A,t,i,o)=>({type:"pcb_smtpad",x:A,y:t,width:i,height:o,radius:o/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(e)?e.map(n=>n.toString()):[e.toString()]}),sD=e=>Vi.extend({fn:v(),num_pins:GA().optional().default(8),w:At.default(At.parse(e.w??"5.3mm")),p:At.default(At.parse(e.p??"1.27mm")),pw:At.default(At.parse(e.pw??"0.6mm")),pl:At.default(At.parse(e.pl??"1.0mm")),legsoutside:$A().optional().default(e.legsoutside??!1),pillpads:$A().optional().default(e.pillpads??!1),silkscreen_stroke_width:GA().optional().default(.1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=At.parse("0.6mm"),A.pl=At.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),J0e=sD({}),lEA=e=>{e.widthincludeslegs!==void 0&&(e.legsoutside=!e.widthincludeslegs);const{num_pins:A,pn:t,w:i,p:o,pl:n,legsoutside:s}=e,r=A/2,a=t<=r,g=r-1,c=o,I=c*g,l=s?n/2:-n/2;return a?{x:-i/2-l,y:I/2-(t-1)*c}:{x:i/2+l,y:-I/2+(t-r-1)*c}},T0e=e=>{const A=J0e.parse(e);return{circuitJson:hx(A),parameters:A}},hx=e=>{const A=[];for(let r=0;r<e.num_pins;r++){const{x:a,y:g}=lEA({num_pins:e.num_pins,pn:r+1,w:e.w,p:e.p,pl:e.pl,legsoutside:e.legsoutside});e.pillpads?A.push(aW(r+1,a,g,e.pl,e.pw)):A.push(yi(r+1,a,g,e.pl,e.pw))}const t=Math.min(1,e.p/2),i=e.w-(e.legsoutside?0:e.pl*2)-.2,o=(e.num_pins/2-1)*e.p+e.pw+t,n=Zi(0,o/2+.4,o/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:e.silkscreen_stroke_width??.1,route:[{x:-i/2,y:-o/2},{x:-i/2,y:o/2},...sXA.map(({x:r,y:a})=>({x:r*i/6,y:a*i/6+o/2})),{x:i/2,y:o/2},{x:i/2,y:-o/2},{x:-i/2,y:-o/2}]};return[...A,s,n]},lXA=Tt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),K0e=({num_pins:e,cw:A,ccw:t,startingpin:i})=>{const o=[],n=e/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=n:r.bottomside&&r.leftpin?s=n+1:r.bottomside&&r.rightpin?s=n*2:r.rightside&&r.bottompin?s=n*2+1:r.rightside&&r.toppin?s=n*3:r.topside&&r.rightpin?s=n*3+1:r.topside&&r.leftpin&&(s=n*4),o.push(-1);for(let a=0;a<e;a++)o[s]=a+1,t||!A?(s++,s>e&&(s=1)):(s--,s<1&&(s=e));return o},BEA=Vi.extend({fn:v(),cc:$A().default(!0).optional(),ccw:$A().default(!0).optional(),startingpin:v().or(dt(lXA)).transform(e=>typeof e=="string"?e.slice(1,-1).split(","):e).pipe(dt(lXA)).optional(),num_pins:GA().optional().default(64),w:At.optional(),h:At.optional(),p:At.default(At.parse("0.5mm")),pw:At.optional(),pl:At.optional(),thermalpad:He([BA(!0),IXA]).optional(),legsoutside:$A().default(!1)}),CEA=e=>{e.w&&!e.h?e.h=e.w:!e.w&&e.h&&(e.w=e.h);const A=e.num_pins/4;if(!e.p&&!e.pw&&!e.pl&&e.w){const t=A+4;e.p=e.w/t}return!e.p&&e.w&&e.h&&e.pw&&e.pl&&(e.p=(e.w-e.pl*2)/(A-1)),!e.w&&!e.h&&e.p&&(e.w=e.p*(A+4),e.h=e.w),e.p&&!e.pw&&!e.pl?(e.pw=e.p/2,e.pl=e.p/2):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e},BXA=BEA.transform(CEA),P0e=["left","bottom","right","top"],q0e=e=>{const{pin_count:A,pn:t,w:i,h:o,p:n,pl:s,legsoutside:r}=e,a=A/4,g=P0e[Math.floor((t-1)/a)],c=(t-1)%a,I=n*(a-1),l=n*(a-1),B=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-B+.1,y:l/2-c*n,o:"vert"};case"bottom":return{x:-I/2+c*n,y:-o/2-B+.1,o:"horz"};case"right":return{x:i/2+B-.1,y:-l/2+c*n,o:"vert"};case"top":return{x:I/2-c*n,y:o/2+B-.1,o:"horz"};default:throw new Error("Invalid pin number")}},zN=e=>{const A=BXA.parse(e),t=[],i=K0e(A),o=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:c}=q0e({pin_count:A.num_pins,pn:r+1,w:A.w,h:A.h,p:A.p??.5,pl:A.pl,legsoutside:A.legsoutside});let I=A.pw,l=A.pl;c==="vert"&&([I,l]=[l,I]);const B=i[r+1];t.push(yi(B,a,g,I,l))}if(A.thermalpad)if(typeof A.thermalpad=="boolean"){const r=A.p*(o-1)+A.pw,a=A.p*(o-1)+A.pw;t.push(yi(["thermalpad"],0,0,r,a))}else t.push(yi(["thermalpad"],0,0,A.thermalpad.x,A.thermalpad.y));const n=[];for(const[r,a,g]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const c=A.w/2*a,I=A.h/2*g;let l="none",B=c,C=I;const E=A.pw*2;i[1]===1&&r==="top-left"?l="in1":i[o*4]===1&&r==="top-left"||i[o*3+1]===1&&r==="top-right"?l="in2":i[o*3]===1&&r==="top-right"||i[o]===1&&r==="bottom-left"?l="in1":i[o+1]===1&&r==="bottom-left"?l="in2":i[o*2]===1&&r==="bottom-right"?l="in1":i[o*2+1]===1&&r==="bottom-right"&&(l="in2");const Q=l==="in1"?1:-1;if(A.legsoutside){const h=l==="in1"?A.pl/2:A.pw/2,u=l==="in1"?A.pw/2:A.pl/2;B+=h*a*Q,C-=u*g*Q}(l==="none"||A.legsoutside)&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:c-E*a,y:I},{x:c,y:I},{x:c,y:I-E*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(l==="in1"||l==="in2")&&!A.legsoutside&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:c-E*a,y:I},{x:c-E*a/2,y:I}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:c,y:I-E*g/2},{x:c,y:I-E*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(l==="in1"||l==="in2")&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:B-.2*-a,y:C+.2*Q},{x:B,y:C},{x:B+.2*Q*-a,y:C+.2},{x:B-.2*-a,y:C+.2*Q}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Zi(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...t,...n,s],parameters:A}};BEA.extend({}).transform(CEA);var O0e=e=>(e.legsoutside=!1,e.pl||(e.pl=.875),e.pw||(e.pw=.25),zN(e)),W0e=e=>{if(e.legsoutside=!0,!e.p)switch(e.num_pins){case 32:e.p=.8;break;case 44:case 48:e.p=.5;break;case 64:case 80:case 100:e.p=.5;break;case 144:e.p=.5;break}if(!e.pl)switch(e.num_pins){case 32:case 44:case 48:case 64:case 80:case 100:e.pl=1.475;break;case 144:e.pl=1.6;break}if(!e.pw)switch(e.num_pins){case 32:e.pw=.55;break;case 44:case 48:case 64:case 80:case 100:e.pw=.3;break;case 144:e.pw=.25;break}return zN(e)},Z0e=e=>{e.legsoutside=!0;const A=BXA.parse(e);if(!e.p)switch(e.num_pins){case 44:case 64:e.p=.8;break;case 52:e.w===14?e.p=1:e.p=.65;break;case 208:e.p=.5;break}if(!e.pl)switch(e.num_pins){case 44:case 52:case 64:e.pl=2.25;break;case 208:e.pl=1.65;break;default:e.pl=A.pl*4;break}if(!e.pw)switch(e.num_pins){case 44:case 64:e.pw=.5;break;case 52:e.w===14?e.pw=.45:e.pw=.55;break;case 208:e.pw=.3;break;default:e.pw=A.pw;break}return zN(e)};BEA.extend({}).transform(CEA);var V0e=e=>(e.legsoutside=!1,e.thermalpad===void 0&&(e.thermalpad=!0),zN(e)),j0e=sD({w:"3.9mm",p:"1.27mm"}),z0e=e=>{const A=j0e.parse(e);return{circuitJson:hx(A),parameters:A}},X0e=sD({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),$0e=e=>{const A=X0e.parse(e);return{circuitJson:hx(A),parameters:A}},Aye=sD({}),tye=e=>{const A=Aye.parse({fn:"sot363",num_pins:6,w:2.56,p:.65,pw:.4,pl:.65,legoutside:!0});return{circuitJson:hx(A),parameters:A}},eye=Vi.extend({fn:v(),num_pins:BA(6).default(6),w:v().default("1.01mm"),h:v().default("1.45mm"),p:v().default("0.5mm"),pl:v().default("0.33mm"),pw:v().default("0.27mm"),string:v().optional()}),iye=e=>{const A=eye.parse({fn:"sot886",...e}),t=At.parse(A.w),i=At.parse(A.h),o=At.parse(A.p),n=At.parse(A.pl),s=At.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:E}=CXA(B+1,t,o,n);r.push(yi(B+1,C,E,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:i/2},{x:t/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:-i/2},{x:t/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},c=CXA(1,t,o,n),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-n/2-.3,y:c.y},{x:c.x-n/2-.45,y:c.y+.15},{x:c.x-n/2-.45,y:c.y-.15},{x:c.x-n/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Zi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},CXA=(e,A,t,i)=>{const o=A/2-i/2;return e<=3?{x:-o,y:t-(e-1)*t}:{x:o,y:-t+(e-4)*t}},QXA=Vi.extend({fn:v(),num_pins:GA().default(3),w:v().default("1.92mm"),h:v().default("2.74mm"),pl:v().default("1.32mm"),pw:v().default("0.6mm"),p:v().default("0.95mm"),string:v().optional()}),oye=sD({p:"0.95mm",w:"1.6mm",legsoutside:!0}),nye=e=>{const A=e.string?.match(/^sot23_(\d+)/),t=A?Number.parseInt(A[1],10):3;if(t===6||t===8){const o=oye.parse({...e,num_pins:t});return{circuitJson:hx(o),parameters:o}}const i=QXA.parse({...e,num_pins:t});if(i.num_pins===3)return{circuitJson:rye(i),parameters:i};if(i.num_pins===5)return{circuitJson:hXA(i),parameters:i};throw new Error("Invalid number of pins")},sye=e=>{const{pn:A,p:t}=e;return A===1?{x:-1.155,y:t}:A===2?{x:-1.155,y:-t}:{x:1.15,y:0}},rye=e=>{const A=[];for(let i=0;i<e.num_pins;i++){const{x:o,y:n}=sye({num_pins:e.num_pins,pn:i+1,w:Number.parseFloat(e.w),h:Number.parseFloat(e.h),pl:Number.parseFloat(e.pl),p:Number.parseFloat(e.p)});A.push(yi(i+1,o,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}const t=Zi(0,Number.parseInt(e.h),.3);return[...A,t]},EXA=e=>{const{p:A,h:t,pn:i}=e;if(i===1)return{x:-t/2-.5,y:A};if(i===2)return{x:-t/2-.5,y:0};if(i===3)return{x:-t/2-.5,y:-A};if(i===4)return{x:t/2+.5,y:-A};if(i===5)return{x:t/2+.5,y:A};throw new Error("Invalid pin number")},hXA=e=>{const A=[];for(let I=1;I<=e.num_pins;I++){const{x:l,y:B}=EXA({h:Number.parseFloat(e.h),p:Number.parseFloat(e.p),pn:I});A.push(yi(I,l,B,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}const t=(e.num_pins+1)/2*Number.parseFloat(e.p),i=Number.parseFloat(e.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t/3,y:i/2+Number.parseFloat(e.p)/1.3},{x:t/3,y:i/2+Number.parseFloat(e.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t/3,y:-i/2-Number.parseFloat(e.p)/1.3},{x:t/3,y:-i/2-Number.parseFloat(e.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Zi(0,i+.3,.3),r=EXA({h:Number.parseFloat(e.h),p:Number.parseFloat(e.p),pn:1});r.x=r.x-Number.parseFloat(e.pw)*1.5;const a=.3,g=.4,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,o,n,c]},aye=QXA.extend({}),gye=e=>{const A=aye.parse({...e,num_pins:5});return{circuitJson:hXA(A),parameters:A}},cye=[{name:"top-left",dx:-1,dy:1},{name:"top-right",dx:1,dy:1},{name:"bottom-left",dx:-1,dy:-1},{name:"bottom-right",dx:1,dy:-1}],Iye=sD({}),lye=e=>{const A=Iye.parse(e),t=[];for(let I=0;I<A.num_pins;I++){const{x:l,y:B}=lEA({num_pins:A.num_pins,pn:I+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});t.push(yi(I+1,l,B,A.pl??"1mm",A.pw??"0.6mm"))}const i=Math.min(1,A.p/2),o=A.w+i,n=(A.num_pins/2-1)*A.p+A.pw+i,s=[];for(const I of cye){const{dx:l,dy:B}=I;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:l*o/2-l*A.p,y:B*n/2},{x:l*o/2,y:B*n/2},{x:l*o/2,y:B*n/2-B*A.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const r=A.p/4,a=-o/2-r/2,g=n/2-A.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:a,y:g},{x:a-r,y:g+r},{x:a-r,y:g-r},{x:a,y:g}],stroke_width:.1});const c=Zi(0,n/2+.4,n/12);return{circuitJson:[...t,c,...s],parameters:A}},QEA=({fs:e,pn:A,anchor_x:t,anchor_y:i,textalign:o="center",orthogonal:n=!1,verticallyinverted:s=!1,layer:r="top"})=>{let a=0;n&&s?a=270:s?a=180:n?a=90:a=0;let g="center";return o==="left"&&(s?g="center_right":g="center_left"),o==="right"&&(s?g="center_left":g="center_right"),r==="bottom"&&(g==="center_left"?g="center_right":g==="center_right"&&(g="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:e,pcb_component_id:"pcb_component_1",text:`{PIN${A}}`,layer:r,anchor_position:{x:t,y:i},anchor_alignment:g,ccw_rotation:a}};function Bye({pinlabeltextalignleft:e,pinlabeltextalignright:A,pinlabelorthogonal:t}){let i="top";return t?i="left":i="top",e&&(t?i="bottom":i="right"),A&&(t?i="top":i="left"),i}var Cye=Vi.extend({fn:v(),num_pins:GA().optional().default(6),rows:He([v(),GA()]).transform(e=>Number(e)).optional().default(1).describe("number of rows"),p:At.default("0.1in").describe("pitch"),id:At.default("1.0mm").describe("inner diameter"),od:At.default("1.5mm").describe("outer diameter"),male:$A().optional().describe("for male pin headers"),female:$A().optional().describe("for female pin headers"),smd:$A().optional().describe("surface mount device"),surfacemount:$A().optional().describe("surface mount device (verbose)"),rightangle:$A().optional().describe("right angle"),pw:At.optional().default("1.0mm").describe("pad width for SMD"),pl:At.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:$A().optional().default(!1),pinlabeltextaligncenter:$A().optional().default(!1),pinlabeltextalignright:$A().optional().default(!1),pinlabelverticallyinverted:$A().optional().default(!1),pinlabelorthogonal:$A().optional().default(!1),nosquareplating:$A().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:$A().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:$A().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:$A().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(e=>{const A=Bye(e);return{...e,pinlabelAnchorSide:A,male:e.male??!e.female,female:e.female??!1,smd:e.smd??e.surfacemount??!1,rightangle:e.rightangle??!1}}).superRefine((e,A)=>{e.male&&e.female&&A.addIssue({code:Oe.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),Qye=e=>{const A=Cye.parse(e),{p:t,id:i,od:o,rows:n,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:c,pinlabeltextalignright:I,nopinlabels:l,doublesidedpinlabel:B,bottomsidepinlabel:C}=A;let E="center";c?E="left":I&&(E="right");const Q=[],h=Math.ceil(s/n),u=-t,d=({xoff:b,yoff:k,od:_,anchorSide:N,smd:M,pw:H,pl:T})=>{let Y=0,O=0;if(M){const W=_/5;switch(N){case"right":Y=H/2+W;break;case"top":O=T/2+W;break;case"bottom":O=-(T/2+W);break;case"left":Y=-(H/2+W);break}}else{const W=_*.75;switch(N){case"right":Y=W;break;case"top":O=W;break;case"bottom":O=-W;break;case"left":Y=-W;break}}return{anchor_x:b+Y,anchor_y:k+O}},f=(b,k,_)=>{A.smd?Q.push(yi(b,k,_,A.pw,A.pl)):b===1&&!A.nosquareplating?Q.push(ob(b,k,_,i,o,o,0,0)):Q.push($n(b,k,_,i,o));const{anchor_x:N,anchor_y:M}=d({xoff:k,yoff:_,od:o,anchorSide:r,smd:A.smd,pw:A.pw,pl:A.pl});l||(C?Q.push(QEA({fs:o/5,pn:b,anchor_x:N,anchor_y:M,textalign:E,orthogonal:g,verticallyinverted:a,layer:"bottom"})):Q.push(QEA({fs:o/5,pn:b,anchor_x:N,anchor_y:M,textalign:E,orthogonal:g,verticallyinverted:a,layer:"top"})),B&&Q.push(QEA({fs:o/5,pn:b,anchor_x:N,anchor_y:M,textalign:E,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},m=new Set,D=n>2&&h>2;if(n===1){const b=-((s-1)/2)*t;for(let k=0;k<s;k++){const _=k+1,N=b+k*t,M=`${N},0`;if(m.has(M))throw new Error(`Overlap at ${M}`);m.add(M),f(_,N,0)}}else if(D){const b=-((h-1)/2)*t;let k=1;for(let _=0;_<n&&k<=s;_++)for(let N=0;N<h&&k<=s;N++){const M=b+N*t,H=_*u,T=`${M},${H}`;if(m.has(T))throw new Error(`Overlap at ${T}`);m.add(T),f(k++,M,H)}}else{const b=-((h-1)/2)*t;let k=1,_=0,N=n-1,M=0,H=h-1;for(;k<=s&&_<=N&&M<=H;){for(let T=_;T<=N&&k<=s;T++){const Y=b+M*t,O=T*u,W=`${Y},${O}`;if(m.has(W))throw new Error(`Overlap at ${W}`);m.add(W),f(k++,Y,O)}M++;for(let T=M;T<=H&&k<=s;T++){const Y=b+T*t,O=N*u,W=`${Y},${O}`;if(m.has(W))throw new Error(`Overlap at ${W}`);m.add(W),f(k++,Y,O)}if(N--,M<=H){for(let T=N;T>=_&&k<=s;T--){const Y=b+H*t,O=T*u,W=`${Y},${O}`;if(m.has(W))throw new Error(`Overlap at ${W}`);m.add(W),f(k++,Y,O)}H--}if(_<=N){for(let T=H;T>=M&&k<=s;T--){const Y=b+T*t,O=_*u,W=`${Y},${O}`;if(m.has(W))throw new Error(`Overlap at ${W}`);m.add(W),f(k++,Y,O)}_++}}if(k-1<s)throw new Error(`Missing pins: assigned ${k-1}, expected ${s}`)}const w=Zi(0,t,.5);return{circuitJson:[...Q,w],parameters:A}},Eye=Vi.extend({fn:v(),num_pins:BA(6).default(6),w:v().default("2.1mm"),h:v().default("2.45mm"),p:v().default("0.5mm"),pl:v().default("0.675mm"),pw:v().default("0.35mm"),string:v().optional()}),hye=e=>{const A=Eye.parse({...e,fn:"sot563"}),t=At.parse(A.w),i=At.parse(A.h),o=At.parse(A.p),n=At.parse(A.pl),s=At.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:E}=uXA(B+1,t,o,n);r.push(yi(B+1,C,E,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:i/2},{x:t/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:-i/2},{x:t/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},c=uXA(1,t,o,n),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-n/2-.3,y:c.y},{x:c.x-n/2-.45,y:c.y+.15},{x:c.x-n/2-.45,y:c.y-.15},{x:c.x-n/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Zi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},uXA=(e,A,t,i)=>{const o=A/2-i/2;return e<=3?{x:-o,y:t-(e-1)*t}:{x:o,y:-t+(e-4)*t}},uye=sD({p:"1.27mm",w:"3.9mm",legsoutside:!0}),dye=e=>{const A=uye.parse({...e,num_pins:8});return{circuitJson:hx(A),parameters:A}},pye=sD({p:"1.27mm",w:"7.5mm",legsoutside:!0}),fye=e=>{const A=pye.parse({...e,num_pins:16});return{circuitJson:hx(A),parameters:A}},yye=Vi.extend({fn:v(),num_pins:BA(3).default(3),w:v().default("1.2mm"),h:v().default("1.2mm"),pw:v().default("0.40mm"),pl:v().default("0.45mm"),p:v().default("0.575mm")}),mye=e=>{const A=yye.parse(e),t=Dye(A),i=Zi(0,At.parse(A.h),.2);return{circuitJson:[...t,i],parameters:A}},wye=e=>{const{pn:A,p:t}=e;return A===1?{x:t,y:0}:A===2?{x:-t,y:-.4}:{x:-t,y:.4}},Dye=e=>{const A=[];for(let t=0;t<3;t++){const{x:i,y:o}=wye({num_pins:e.num_pins,pn:t+1,w:Number.parseFloat(e.w),h:Number.parseFloat(e.h),pl:Number.parseFloat(e.pl),p:Number.parseFloat(e.p)});A.push(yi(t+1,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Sye=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("2.36mm"),h:v().default("1.22mm"),pl:v().default("0.9mm"),pw:v().default("1.2mm"),p:v().default("3.30mm")}),bye=e=>{const A=Sye.parse(e),t=Zi(0,At.parse(A.h)/4+.4,.3);return{circuitJson:xye(A).concat(t),parameters:A}},_ye=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},xye=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=_ye({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},kye=Vi.extend({fn:v(),p:At.optional().default("2.54mm"),id:At.optional().default("0.7mm"),od:At.optional().default("1.4mm")}),Fye=e=>{const A=kye.parse(e),{p:t,id:i,od:o}=A,n=[$n(1,-t/2,0,i,o),$n(2,t/2,0,i,o)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2+o+i/2,y:0},{x:t/2-o-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},r=Zi(0,1.5,.5);return{circuitJson:[...n,s,r],parameters:A}},Gye=(e,A,t,i,o,n=.1)=>{const s=[],r=[],a=Math.max(1,Math.ceil(Math.PI*t/n)),g=Math.PI/a;for(let c=0;c<=a;c++){const I=c*g,l=e+Math.cos(I)*t,B=A+Math.sin(I)*t;l<e-i&&B>=A-o/2&&B<=A+o/2||s.push({x:l,y:B})}for(let c=0;c<=a;c++){const I=Math.PI+c*g,l=e+Math.cos(I)*t,B=A+Math.sin(I)*t;l<e-i&&B>=A-o/2&&B<=A+o/2||r.push({x:l,y:B})}return{topArc:s,bottomArc:r}},Rye=Vi.extend({fn:v(),p:At.optional().default("5mm"),id:At.optional().default("0.8mm"),od:At.optional().default("1.6mm"),ceramic:$A().optional(),electrolytic:$A().optional(),polarized:$A().optional()}),Mye=e=>{const A=Rye.parse(e),{p:t,id:i,od:o}=A;i===.8&&o===1.6&&(A.id=t===5?.8:t*.25,A.od=t===5?1.6:t*.5);const n=[$n(1,-t/2,0,A.id,A.od),$n(2,t/2,0,A.id,A.od)],s=t+.1,{topArc:r,bottomArc:a}=Gye(0,0,s,A.od/2,A.od),g=.02*t,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:g,pcb_silkscreen_path_id:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:g,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:s},{x:0,y:-s}],stroke_width:g,pcb_silkscreen_path_id:""},B=.1*t,C=-(t+B+.04*t),E=s-B-.08*t,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C-B,y:E},{x:C+B,y:E}],stroke_width:g,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C,y:E-B},{x:C,y:E+B}],stroke_width:g,pcb_silkscreen_path_id:""},u=Zi(0,s+.12*t,.1*t),d=[...n,c,I,l,u];return(A.electrolytic===!0||A.polarized===!0)&&d.push(Q,h),{circuitJson:d,parameters:A}},gW=(e,A={})=>({type:"pcb_silkscreen_path",layer:A.layer||"top",pcb_component_id:A.pcb_component_id||"",pcb_silkscreen_path_id:A.pcb_silkscreen_path_id||"",route:e,stroke_width:A.stroke_width||.1}),Nye=Vi.extend({fn:BA("pushbutton"),w:At.default(4.5),h:At.default(6.5),id:At.default(1),od:At.default(1.2)}),vye=e=>{const A=Nye.parse(e),t=A.w,i=A.h,o=A.id,n=[$n(1,-t/2,i/2,o,o*1.5),$n(2,-t/2,-i/2,o,o*1.5),$n(3,t/2,-i/2,o,o*1.5),$n(4,t/2,i/2,o,o*1.5)],s=[gW([{x:-t/2,y:-i/2},{x:-t/2,y:i/2}]),gW([{x:t/2,y:-i/2},{x:t/2,y:i/2}]),gW([{x:-t/2,y:0},{x:-t/5,y:0},{x:t/5*1/Math.sqrt(2),y:i/8}]),gW([{x:t/2,y:0},{x:t/5,y:0}])],r=Zi(0,i/2+.4,.5);return{circuitJson:[...n,...s,r],parameters:A}},dXA=Vi.extend({fn:v(),w:At.default("22.58mm"),h:At.optional(),left:At.optional().default(20),right:At.optional().default(20),top:At.optional().default(2),bottom:At.optional().default(2),p:At.default(At.parse("2.54mm")),pw:At.default(At.parse("1.6mm")),pl:At.default(At.parse("2.4mm")),innerhole:$A().default(!1),innerholeedgedistance:At.default(At.parse("1.61mm")),silkscreenlabels:$A().default(!1),silkscreenlabelmargin:At.default(At.parse("0.1mm"))}),Lye=e=>{const A=dXA.parse(e);return A.left&&A.right?Math.max(A.left,A.right)*A.p:A.left?A.left*A.p:A.right?A.right*A.p:51},cW=(e,A,t)=>{let i=[];return t==="right"&&(i=[{x:e+1/2,y:A},{x:e-1/2,y:A+.6/2},{x:e-1/2,y:A-.6/2},{x:e+1/2,y:A}]),t==="left"&&(i=[{x:e-1/2,y:A},{x:e+1/2,y:A+.6/2},{x:e+1/2,y:A-.6/2},{x:e-1/2,y:A}]),t==="top"&&(i=[{x:e,y:A+1/2},{x:e-.6/2,y:A-1/2},{x:e+.6/2,y:A-1/2},{x:e,y:A+1/2}]),t==="bottom"&&(i=[{x:e,y:A-1/2},{x:e-.6/2,y:A+1/2},{x:e+.6/2,y:A+1/2},{x:e,y:A-1/2}]),i},Uye=e=>{const A=dXA.parse(e),t=A.h??Lye(A),i=[],o=[],n=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),I=`pin${g}`.length*.7/2;if(A.right){const E=-((A.right-1)/2)*A.p;for(let Q=0;Q<A.right;Q++){if(Q===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=cW(A.w/2-A.pl*1.4,E+Q*A.p,"right")),i.push(yi(Q+1+A.left+(A.bottom??0),A.w/2-A.pl/2,E+Q*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=Q+1+A.left+(A.bottom??0),u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl-(I+A.silkscreenlabelmargin),y:E+Q*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push($n(Q+1+A.left+(A.bottom??0)+g,A.w/2,E+Q*A.p,r,a)),o.push($n(Q+1+A.left+(A.bottom??0)+g*2,A.w/2-A.innerholeedgedistance,E+Q*A.p,r,a)))}}if(A.left){const E=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++){if(Q===0&&!A.silkscreenlabels&&(s=cW(-A.w/2+A.pl*1.4,E-Q*A.p,"left")),i.push(yi(Q+1,-A.w/2+A.pl/2,E-Q*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=Q+1,u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl+(I+A.silkscreenlabelmargin),y:E-Q*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push($n(Q+1+g,-A.w/2,E-Q*A.p,r,a)),o.push($n(Q+1+g*2,-A.w/2+A.innerholeedgedistance,E-Q*A.p,r,a)))}}if(A.top){const E=(A.top-1)/2*A.p;for(let Q=0;Q<A.top;Q++){if(Q===0&&!A.left&&!A.bottom&&!A.right&&!A.silkscreenlabels&&(s=cW(E-Q*A.p,t/2-A.pl*1.4,"top")),i.push(yi(Q+1+A.left+A.right+(A.bottom??0),E-Q*A.p,t/2-A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=Q+1+A.left+A.right+(A.bottom??0),u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:E-Q*A.p,y:t/2-A.pl-(I+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(o.push($n(Q+1+A.left+A.right+(A.bottom??0)+g,E-Q*A.p,t/2,r,a)),o.push($n(Q+1+A.left+A.right+(A.bottom??0)+g*2,E-Q*A.p,t/2-A.innerholeedgedistance,r,a)))}}if(A.bottom){const E=-((A.bottom-1)/2)*A.p;for(let Q=0;Q<A.bottom;Q++){if(Q===0&&!A.left&&!A.silkscreenlabels&&(s=cW(E+Q*A.p,-t/2+A.pl*1.4,"bottom")),i.push(yi(Q+1+A.left,E+Q*A.p,-t/2+A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=Q+1+A.left,u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:E+Q*A.p,y:-t/2+A.pl+(I+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(o.push($n(Q+1+A.left+g,E+Q*A.p,-t/2,r,a)),o.push($n(Q+1+A.left+g*2,E+Q*A.p,-t/2+A.innerholeedgedistance,r,a)))}}const l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2,y:t/2},{x:A.w/2,y:t/2},{x:A.w/2,y:-t/2},{x:-A.w/2,y:-t/2},{x:-A.w/2,y:t/2}],stroke_width:.1,layer:"top"},C=Zi(0,t/1.8,t/25);return{circuitJson:[...i,...o,...n,B,...A.silkscreenlabels?[]:[l],C],parameters:A}},pXA=Vi.extend({fn:v(),w:At.default("22.58mm"),h:At.optional(),left:At.optional().default(20),right:At.optional().default(20),top:At.optional().default(2),bottom:At.optional().default(2),p:At.default(At.parse("2.54mm")),pw:At.default(At.parse("1.6mm")),pl:At.default(At.parse("3.2mm")),innerhole:$A().default(!1),innerholeedgedistance:At.default(At.parse("1.61mm"))}),Hye=e=>{const A=pXA.parse(e);return A.left&&A.right?Math.max(A.left,A.right)*A.p:A.left?A.left*A.p:A.right?A.right*A.p:51},Yye=(e,A,t,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:e+n,y:A},{x:e-n,y:A+s},{x:e-n,y:A-s},{x:e+n,y:A}],right:[{x:e-n,y:A},{x:e+n,y:A+s},{x:e+n,y:A-s},{x:e-n,y:A}],top:[{x:e,y:A-n},{x:e-s,y:A+n},{x:e+s,y:A+n},{x:e,y:A-n}],bottom:[{x:e,y:A+n},{x:e-s,y:A-n},{x:e+s,y:A-n},{x:e,y:A+n}]}[t]},Jye=e=>{const A=pXA.parse(e),t=A.h??Hye(A),i=[],o=[],n=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],c=1;if(A.left){const C=(A.left-1)/2*A.p;for(let E=0;E<A.left;E++)E===0&&(g=Yye(-A.w/2-A.pl/2,C-E*A.p,"left")),i.push(yi(c,-A.w/2+A.pl/2,C-E*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:C-E*A.p},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&n.push($n(c+a,-A.w/2+A.innerholeedgedistance,C-E*A.p,s,r))}if(A.bottom){const C=(A.bottom-1)/2*A.p;for(let E=A.bottom-1;E>=0;E--)i.push(yi(c,C-E*A.p,-t/2+A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C-E*A.p,y:-t/2+A.pl/2-3.2},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&n.push($n(c+a,C-E*A.p,-t/2+A.innerholeedgedistance,s,r))}if(A.right){const C=-((A.right-1)/2)*A.p;for(let E=0;E<A.right;E++)i.push(yi(c,A.w/2-A.pl/2,C+E*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:C+E*A.p},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&n.push($n(c+a,A.w/2-A.innerholeedgedistance,C+E*A.p,s,r))}if(A.top){const C=-((A.top-1)/2)*A.p;for(let E=A.top-1;E>=0;E--)i.push(yi(c,C+E*A.p,t/2-A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C+E*A.p,y:t/2-A.pl/2+3.2},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&n.push($n(c+a,C+E*A.p,t/2-A.innerholeedgedistance,s,r))}const I={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:g,stroke_width:.1},l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-A.pl/3,y:t/2+A.pl/3},{x:A.w/2+A.pl/3,y:t/2+A.pl/3},{x:A.w/2+A.pl/3,y:-t/2-A.pl/3},{x:-A.w/2-A.pl/3,y:-t/2-A.pl/3},{x:-A.w/2-A.pl/3,y:t/2+A.pl/3}],stroke_width:.1,layer:"top"},B=Zi(0,t/1.8,t/25);return{circuitJson:[...n,...i,...o,l,I,B],parameters:A}},Tye=e=>(e.legsoutside=!0,e.pl||(e.pl=1.5),e.pw||(e.pw=.3),zN(e)),fXA=Vi.extend({fn:v(),w:At.default("10mm"),h:At.optional(),left:At.optional().default(20),right:At.optional().default(20),top:At.optional().default(0),bottom:At.optional().default(0),p:At.default(At.parse("2.54mm")),id:At.optional().default(At.parse("1mm")),od:At.optional().default(At.parse("1.5mm"))}),Kye=e=>{const A=fXA.parse(e);return A.left&&A.right?Math.max(A.left,A.right)*A.p:A.left?A.left*A.p:A.right?A.right*A.p:51},IW=(e,A,t,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:e+n,y:A},{x:e-n,y:A+s},{x:e-n,y:A-s},{x:e+n,y:A}],right:[{x:e-n,y:A},{x:e+n,y:A+s},{x:e+n,y:A-s},{x:e-n,y:A}],top:[{x:e,y:A-n},{x:e-s,y:A+n},{x:e+s,y:A+n},{x:e,y:A-n}],bottom:[{x:e,y:A+n},{x:e-s,y:A-n},{x:e+s,y:A-n},{x:e,y:A+n}]}[t]},Pye=e=>{const A=fXA.parse(e),t=A.h??Kye(A),i=[],o=A.id,n=A.od;let s=[];if(A.right){const c=-((A.right-1)/2)*A.p;for(let I=0;I<A.right;I++)I===0&&!A.left&&!A.bottom&&(s=IW(A.w/2+n*1.4,c+I*A.p,"right")),i.push($n(I+1+A.left+(A.bottom??0),A.w/2,c+I*A.p,o,n))}if(A.left){const c=-((A.left-1)/2)*A.p;for(let I=0;I<A.left;I++)I===A.left-1&&(s=IW(-A.w/2-n*1.4,c+I*A.p,"left")),i.push($n(I+1,-A.w/2,c+I*A.p,o,n))}if(A.top){const c=-((A.top-1)/2)*A.p;for(let I=0;I<A.top;I++)I===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=IW(c+I*A.p,t/2+n*1.4,"top")),i.push($n(I+1+A.right+(A.bottom??0)+A.left,c+I*A.p,t/2,o,n))}if(A.bottom){const c=-((A.bottom-1)/2)*A.p;for(let I=0;I<A.bottom;I++)I===0&&!A.left&&(s=IW(c+I*A.p,-t/2-n*1.4,"bottom")),i.push($n(I+1+A.left,c+I*A.p,-t/2,o,n))}const r={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-n,y:t/2+n},{x:A.w/2+n,y:t/2+n},{x:A.w/2+n,y:-t/2-n},{x:-A.w/2-n,y:-t/2-n},{x:-A.w/2-n,y:t/2+n}],stroke_width:.1,layer:"top"},g=Zi(0,t/1.7,t/25);return{circuitJson:[...i,a,g,r],parameters:A}},yXA=(e,A,t,i)=>Array.from({length:25},(o,n)=>{const s=n/24*Math.PI-Math.PI/2;return{x:e+(i==="right"?1:-1)*Math.cos(s)*t,y:A+Math.sin(s)*t}}),qye=Vi.extend({fn:v(),p:At.optional().default("4.88mm"),id:At.optional().default("0.8mm"),od:At.optional().default("1.5mm"),w:At.optional().default("5.6mm"),h:At.optional().default("3.5mm")}),Oye=e=>{const A=qye.parse(e),{p:t,id:i,od:o,w:n,h:s}=A,r=s/2,a=[$n(1,-t/2,0,i,o),$n(2,t/2,0,i,o)],g=yXA(-n/2,0,r,"left"),c=yXA(n/2,0,r,"right"),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...g,...g.slice(1).reverse(),{x:-n/2,y:-s/2},{x:n/2,y:-s/2},...c,{x:n/2,y:s/2},{x:-n/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},l=Zi(0,t/4,.5);return{circuitJson:[...a,I,l],parameters:A}};Vi.extend({w:At,h:At});var Wye=e=>{const{w:A,h:t}=e,i=Mr(A),o=Mr(t);return{circuitJson:[yi(1,0,0,i,o),Zi(0,o/2+.5,.2)],parameters:e}},rH=(e,A,t,i,o,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:A,y:t,outer_width:Mr(o),outer_height:Mr(n),hole_width:Mr(i),hole_height:Mr(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[e.toString()],ccw_rotation:0}),Zye=Vi.extend({fn:v(),num_pins:He([BA(3),BA(2)]).default(3),p:v().default("1.27mm"),id:v().default("0.72mm"),od:v().default("0.95mm"),w:v().default("4.5mm"),h:v().default("4.5mm"),inline:$A().default(!1),string:v().optional()}),Vye=(e,A,t)=>Array.from({length:25},(i,o)=>{const n=o/24*Math.PI;return{x:e+Math.cos(n)*t,y:A+Math.sin(n)*t}}),jye=e=>{const A=e.string?.match(/^to92_(\d+)/),t=A?Number.parseInt(A[1],10):3,i=Zye.parse({...e,num_pins:t}),{p:o,id:n,od:s,w:r,h:a,inline:g}=i,c=Number.parseFloat(a)/2,I=Number.parseFloat(o),l=Number.parseFloat(n),B=Number.parseFloat(s),C=B,E=B*(1.5/1.05);let Q=[];if(i.num_pins===3)g?Q=[ob(1,-I,c-I,l,B,E,0,0),rH(2,0,c-I,l,C,E),rH(3,I,c-I,l,C,E)]:Q=[ob(1,-I,c-I,l,B,B,0,0),$n(2,0,c,l,B),$n(3,I,c-I,l,B)];else if(i.num_pins===2)Q=[ob(1,-I,c-I,l,C,E,0,0),rH(2,I,c-I,l,C,E)];else throw new Error("Invalid number of pins for TO-92");const h=Number.parseFloat(r)/2,u=Vye(0,c,h),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...u,{x:-h,y:0},{x:h,y:0},u[0]],stroke_width:.1,pcb_silkscreen_path_id:""},f=Zi(0,c+1,.5);return{circuitJson:[...Q,d,f],parameters:i}},zye=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("2.15mm"),h:v().default("1.20mm"),pl:v().default("0.5mm"),pw:v().default("0.6mm"),p:v().default("1.4mm")}),Xye=e=>{const A=zye.parse(e),t=Zi(0,At.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Ame(A).concat(i,t),parameters:A}},$ye=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Ame=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=$ye({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},tme=sD({}),eme=e=>{const A=tme.parse(e),t=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=lEA({num_pins:A.num_pins,pn:s+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});t.push(yi(s+1,r,a,A.pl??"1.5mm",A.pw??"0.6mm"))}const i=(A.num_pins/2-1)*A.p+A.pw,o=Zi(0,i/2-.5,i/12),n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-A.w/3,y:i/2+.2},{x:A.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...t,o,n],parameters:A}},ime=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("5.0mm"),h:v().default("2.30mm"),pl:v().default("1.25mm"),pw:v().default("2mm"),p:v().default("3.75mm")}),ome=e=>{const A=ime.parse(e),t=Zi(0,At.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2+.5,y:At.parse(A.h)/2+.5},{x:-At.parse(A.w)/2-.5,y:At.parse(A.h)/2+.5},{x:-At.parse(A.w)/2-.5,y:-At.parse(A.h)/2-.5},{x:At.parse(A.p)/2+.5,y:-At.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:sme(A).concat(i,t),parameters:A}},nme=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},sme=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=nme({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},rme=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("4.4mm"),h:v().default("2.1mm"),pl:v().default("1.2mm"),pw:v().default("1.2mm"),p:v().default("2.9mm")}),ame=e=>{const A=rme.parse(e),t=Zi(0,At.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:cme(A).concat(i,t),parameters:A}},gme=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},cme=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=gme({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Ime=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("3.30mm"),h:v().default("1.80mm"),pl:v().default("0.60mm"),pw:v().default("0.45mm"),p:v().default("2.1mm")}),lme=e=>{const A=Ime.parse(e),t=Zi(0,At.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Cme(A).concat(i,t),parameters:A}},Bme=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Cme=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=Bme({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Qme=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("1.4mm"),h:v().default("0.9mm"),pl:v().default("0.36mm"),pw:v().default("0.25mm"),p:v().default("0.85mm")}),Eme=e=>{const A=Qme.parse(e),t=Zi(0,At.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2+.15,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.15,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.15,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2+.15,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ume(A).concat(i,t),parameters:A}},hme=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},ume=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=hme({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},dme=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("1.3mm"),h:v().default("0.9mm"),pl:v().default("0.4mm"),pw:v().default("0.7mm"),p:v().default("0.7mm")}),pme=e=>{const A=dme.parse(e),t=Zi(0,At.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2+.2,y:At.parse(A.h)/2+.2},{x:-At.parse(A.w)/2-.2,y:At.parse(A.h)/2+.2},{x:-At.parse(A.w)/2-.2,y:-At.parse(A.h)/2-.2},{x:At.parse(A.p)/2+.2,y:-At.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:yme(A).concat(i,t),parameters:A}},fme=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},yme=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=fme({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},mme=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("3,05mm"),h:v().default("1.65mm"),pl:v().default("0.6mm"),pw:v().default("0.6mm"),pad_spacing:v().default("2.2mm")}),wme=e=>{const A=mme.parse(e),t=Zi(0,At.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.pad_spacing)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:-At.parse(A.h)/2},{x:At.parse(A.pad_spacing)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Sme(A).concat(i,t),parameters:A}},Dme=e=>{const{pn:A,pad_spacing:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Sme=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=Dme({pn:t,pad_spacing:Number.parseFloat(e.pad_spacing)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},bme=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("4.4mm"),h:v().default("2.1mm"),pl:v().default("1.2mm"),pw:v().default("1.2mm"),p:v().default("2.9mm")}),_me=e=>{const A=bme.parse(e),t=Zi(0,At.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:kme(A).concat(i,t),parameters:A}},xme=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},kme=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=xme({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Fme=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("4.4mm"),h:v().default("2.1mm"),pl:v().default("0.91mm"),pw:v().default("1.22mm"),p:v().default("3.146mm")}),Gme=e=>{const A=Fme.parse(e),t=Zi(0,At.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Mme(A).concat(i,t),parameters:A}},Rme=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Mme=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=Rme({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Nme=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("1.80mm"),h:v().default("1.00mm"),pl:v().default("0.66mm"),pw:v().default("0.5mm"),p:v().default("0.8mm")}),vme=e=>{const A=Nme.parse(e),t=Zi(0,At.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.1,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.1,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Ume(A).concat(i,t),parameters:A}},Lme=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Ume=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=Lme({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Hme=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("6.2mm"),h:v().default("3.4mm"),pl:v().default("1.4mm"),pw:v().default("2.1mm"),p:v().default("4.4mm")}),Yme=e=>{const A=Hme.parse(e),t=Zi(0,At.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Tme(A).concat(i,t),parameters:A}},Jme=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Tme=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=Jme({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Kme=Vi.extend({fn:v(),num_pins:He([BA(3),BA(5)]).default(3),w:v().default("4.20mm"),h:v().default("4.80mm"),pl:v().default("1.3mm"),pw:v().default("0.9mm"),p:v().default("1.5mm"),string:v().optional()}),Pme=e=>{const A=[],t=Number.parseFloat(e.p),i=Number.parseFloat(e.pw),o=Number.parseFloat(e.w),n=Number.parseFloat(e.pl),s=.175,r=(n-(n+s))/2;A.push(yi(1,-o/2+r,t,n,i),yi(2,-o/2,0,n+s,i),yi(3,-o/2+r,-t,n,i));const a=Zi(0,0,.3),g=Number.parseFloat(e.w)/2-1,c=Number.parseFloat(e.h)/2,I={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-g,y:c},{x:g,y:c},{x:g,y:c/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},l={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-g,y:-c},{x:g,y:-c},{x:g,y:-c/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,I,l,a]},qme=e=>{const A=[];Number.parseFloat(e.p),Number.parseFloat(e.pw),Number.parseFloat(e.w),A.push(yi(1,-1.85,-1.5,1.5,.7),yi(2,-1.85,1.5,1.5,.7),yi(3,0,0,.8,2),yi(4,1.85,-1.5,1.5,.7),yi(5,1.85,1.5,1.5,.7));const t=Zi(0,Number.parseFloat(e.h)/2+.5,.3),i=Number.parseFloat(e.w)/2-1,o=Number.parseFloat(e.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i,y:o}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o},{x:i,y:-o}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,t]},Ome=e=>{const A=e.string?.match(/^sot89_(\d+)/),t=A?Number.parseInt(A[1],10):3,i=Kme.parse({...e,num_pins:t});if(i.num_pins===3)return{circuitJson:Pme(i),parameters:i};if(i.num_pins===5)return{circuitJson:qme(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},Wme=Vi.extend({fn:v(),p:At.optional().default("5.0mm"),id:At.optional().default("1.0mm"),od:At.optional().default("1.9mm"),w:At.optional().default("13mm"),h:At.optional().default("7mm"),num_pins:GA().optional(),string:v().optional()}),Zme=e=>{const A=Wme.parse(e),{fn:t,id:i,od:o,w:n,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,c=n/2,I=s/2,l=2.5,B=n*.4,C=Math.max(l,B/(a-1)),E=Array.from({length:a},(m,D)=>{const w=a%2===0?(D-a/2+.5)*C:(D-Math.floor(a/2))*C;return $n(D+1,w,g,i,o)}),Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:-I},{x:c,y:-I},{x:c,y:I},{x:-c,y:I},{x:-c,y:-I}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-I+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:h},{x:c,y:h}],stroke_width:.1,pcb_silkscreen_path_id:""},d=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/6,y:h},{x:-n/6,y:I}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:n/6,y:h},{x:n/6,y:I}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Zi(0,s/2+.6,.5);return{circuitJson:[...E,Q,u,...d,f],parameters:{...A,p:C}}},Vme=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("5.40mm"),h:v().default("2.30mm"),pl:v().default("1.30mm"),pw:v().default("1.70mm"),p:v().default("3.5mm")}),jme=e=>{const A=Vme.parse(e),t=Zi(0,At.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Xme(A).concat(i,t),parameters:A}},zme=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Xme=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=zme({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},$me=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("1.90mm"),h:v().default("1.33mm"),pl:v().default("0.5mm"),pw:v().default("0.7mm"),p:v().default("0.8mm")}),Awe=e=>{const A=$me.parse(e),t=Zi(0,At.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2+.1,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2+.1,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ewe(A).concat(i,t),parameters:A}},twe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},ewe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=twe({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},iwe=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("7.0mm"),h:v().default("3.35mm"),pl:v().default("1.50mm"),pw:v().default("2.70mm"),p:v().default("4.8mm")}),owe=e=>{const A=iwe.parse(e),t=Zi(0,At.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:swe(A).concat(i,t),parameters:A}},nwe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},swe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=nwe({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},rwe=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("3.0mm"),h:v().default("1.80mm"),pl:v().default("0.80mm"),pw:v().default("1.20mm"),p:v().default("1.6mm")}),awe=e=>{const A=rwe.parse(e),t=Zi(0,At.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.1,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.1,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:cwe(A).concat(i,t),parameters:A}},gwe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},cwe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=gwe({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Iwe=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("7.10mm"),h:v().default("3.40mm"),pl:v().default("2.45mm"),pw:v().default("1.80mm"),p:v().default("4.05mm")}),lwe=e=>{const A=Iwe.parse(e),t=Zi(0,At.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.5,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.5,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Cwe(A).concat(i,t),parameters:A}},Bwe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Cwe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=Bwe({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Qwe=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("4.80mm"),h:v().default("2.10mm"),pl:v().default("1.30mm"),pw:v().default("1.40mm"),p:v().default("2.9mm")}),Ewe=e=>{const A=Qwe.parse(e),t=Zi(0,At.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:uwe(A).concat(i,t),parameters:A}},hwe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},uwe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=hwe({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},dwe=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("7.30mm"),h:v().default("4.40mm"),pl:v().default("2.50mm"),pw:v().default("2.30mm"),p:v().default("4.30mm")}),pwe=e=>{const A=dwe.parse(e),t=Zi(0,At.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.1,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.1,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ywe(A).concat(i,t),parameters:A}},fwe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},ywe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=fwe({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},mwe=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("10.70mm"),h:v().default("6.60mm"),pl:v().default("3.30mm"),pw:v().default("2.50mm"),p:v().default("6.80mm")}),wwe=e=>{const A=mwe.parse(e),t=Zi(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2-.8},{x:-At.parse(A.w)/2-.8,y:At.parse(A.h)/2-.8},{x:-At.parse(A.w)/2-.8,y:-At.parse(A.h)/2+.8},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Swe(A).concat(i,t),parameters:A}},Dwe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Swe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=Dwe({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},bwe=Vi.extend({fn:v(),num_pins:GA().default(4),w:v().default("8.50mm"),h:v().default("6.90mm"),pl:v().default("2mm"),pw:v().default("1.5mm"),p:v().default("2.30mm"),string:v().optional()}),_we=e=>{const A=e.string?.match(/^sot223_(\d+)/),t=A?Number.parseInt(A[1],10):4;if(t===8){const o=Fwe.parse({...e,num_pins:t});return{circuitJson:hx(o),parameters:o}}const i=bwe.parse({...e,num_pins:t});if(i.num_pins===4)return{circuitJson:kwe(i),parameters:i};if(i.num_pins===5)return{circuitJson:Rwe(i),parameters:i};if(i.num_pins===6)return{circuitJson:Nwe(i),parameters:i};throw new Error("Invalid number of pins")},xwe=e=>{const{pn:A,w:t,p:i}=e;return A===1?{x:-t/2+1.1,y:i}:A===2?{x:-t/2+1.1,y:0}:A===3?{x:-t/2+1.1,y:-i}:{x:t/2-1.1,y:0}},kwe=e=>{const A=[];for(let r=0;r<e.num_pins;r++){const{x:a,y:g}=xwe({num_pins:e.num_pins,pn:r+1,w:Number.parseFloat(e.w),h:Number.parseFloat(e.h),pl:Number.parseFloat(e.pl),p:Number.parseFloat(e.p)}),c=r===3?3.8:Number.parseFloat(e.pw);A.push(yi(r+1,a,g,Number.parseFloat(e.pl),c))}const t=Zi(0,0,.3),i=Number.parseFloat(e.w)/2-2.4,o=Number.parseFloat(e.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i,y:o},{x:i,y:o/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o},{x:i,y:-o},{x:i,y:-o/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,t]},Fwe=sD({p:"0.90mm",w:"2.8mm",legsoutside:!0}),Gwe=e=>{const{p:A,pn:t,w:i}=e;if(t===1)return{x:-i/2+1.2,y:A/2+A};if(t===2)return{x:-i/2+1.2,y:A/2};if(t===3)return{x:-i/2+1.2,y:-A/2};if(t===4)return{x:-i/2+1.2,y:-A/2-A};if(t===5)return{x:i/2-1,y:0};throw new Error("Invalid pin number")},Rwe=e=>{const A=[];for(let r=1;r<=e.num_pins;r++){const{x:a,y:g}=Gwe({h:Number.parseFloat(e.h),p:1.5,pn:r,w:Number.parseFloat(e.w)});let c=Number.parseFloat(e.pw),I=Number.parseFloat(e.pl);r===5?(c=3.4,I=1.8):(c=1,I=2.2),A.push(yi(r,a,g,I,c))}const t=Number.parseFloat(e.w)/2-2.4,i=Number.parseFloat(e.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t,y:i},{x:t,y:i},{x:t,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t,y:-i},{x:t,y:-i},{x:t,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Zi(0,0,.3);return[...A,o,n,s]},Mwe=e=>{const{p:A,pn:t,w:i}=e;if(t===1)return{x:-i/2+1.2,y:2*A};if(t===2)return{x:-i/2+1.2,y:A};if(t===3)return{x:-i/2+1.2,y:0};if(t===4)return{x:-i/2+1.2,y:-A};if(t===5)return{x:-i/2+1.2,y:-2*A};if(t===6)return{x:i/2-1.175,y:0};throw new Error("Invalid pin number")},Nwe=e=>{const A=[];for(let r=1;r<=e.num_pins;r++){const{x:a,y:g}=Mwe({h:Number.parseFloat(e.h),p:1.3,pn:r,w:8.7});let c=Number.parseFloat(e.pw),I=Number.parseFloat(e.pl);r===6?(c=3.4,I=2.15):(c=.6,I=2.2),A.push(yi(r,a,g,I,c))}const t=Number.parseFloat(e.w)/2-2.4,i=Number.parseFloat(e.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t,y:i},{x:t,y:i},{x:t,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t,y:-i},{x:t,y:-i},{x:t,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Zi(0,0,.3);return[...A,o,n,s]},vwe=Vi.extend({fn:v(),num_pins:GA().default(3),w:v().default("3.40mm"),h:v().default("3.30mm"),pl:v().default("1mm"),pw:v().default("0.7mm"),p:v().default("1.2mm"),string:v().optional()}),Lwe=e=>{const A=e.string?.match(/^sot23w_(\d+)/),t=A?Number.parseInt(A[1],3):3,i=vwe.parse({...e,num_pins:t});if(i.num_pins===3)return{circuitJson:Hwe(i),parameters:i};throw new Error("Invalid number of pins")},Uwe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t,y:.95}:A===2?{x:-t,y:-.95}:{x:t,y:0}},Hwe=e=>{const A=[];for(let r=0;r<e.num_pins;r++){const{x:a,y:g}=Uwe({num_pins:e.num_pins,pn:r+1,w:Number.parseFloat(e.w),h:Number.parseFloat(e.h),pl:Number.parseFloat(e.pl),p:Number.parseFloat(e.p)});A.push(yi(r+1,a,g,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}const t=Zi(0,Number.parseInt(e.h)/2+1,.3),i=Number.parseFloat(e.w)/2-1,o=Number.parseFloat(e.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i+.3,y:o},{x:i+.3,y:o/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o},{x:i+.3,y:-o},{x:i+.3,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,t]},Ywe=Vi.extend({fn:v(),num_pins:He([BA(3),BA(2)]).default(3),p:v().default("1.27mm"),id:v().default("0.72mm"),od:v().default("0.95mm"),w:v().default("2.5mm"),h:v().default("4.2mm"),string:v().optional()}),Jwe=e=>{const{p:A,id:t,od:i,w:o,h:n}=e,s=Number.parseFloat(n)/2,r=Number.parseFloat(A);return[$n(1,-r,s-r,t,i),$n(2,0,s-r,t,i),$n(3,r,s-r,t,i)]},Twe=e=>{const{p:A,id:t,od:i,h:o}=e,n=Number.parseFloat(o)/2,s=Number.parseFloat(A);return[$n(1,-s,n-s,t,i),$n(2,s,n-s,t,i)]},Kwe=e=>{const A=e.string?.match(/^to92s_(\d+)/),t=A?Number.parseInt(A[1],10):3,i=Ywe.parse({...e,num_pins:t});let o=[];if(i.num_pins===3)o=Jwe(i);else if(i.num_pins===2)o=Twe(i);else throw new Error("Invalid number of pins for TO-92");const n=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n,y:n-s},{x:-1.9,y:0},{x:1.9,y:0},{x:n,y:n-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-n,y:n-s}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Zi(0,n+1,.5);return{circuitJson:[...o,r,a],parameters:i}},Pwe=Vi.extend({fn:v(),p:At.optional(),id:At.optional(),pw:At.optional(),pl:At.optional(),w:At.optional(),h:At.optional(),sh:He([$A(),v(),GA()]).optional().transform(e=>{if(typeof e=="string"){const A=Number(e);return Number.isNaN(A)?!0:A}return e}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:$A().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:v().optional()}),qwe={ph:{p:At.parse("2.2mm"),id:At.parse("0.70mm"),pw:At.parse("1.20mm"),pl:At.parse("1.20mm"),w:At.parse("6mm"),h:At.parse("5mm")},sh:{p:At.parse("1mm"),pw:At.parse("0.6mm"),pl:At.parse("1.55mm"),w:At.parse("5.8mm"),h:At.parse("7.8mm")}};function Owe(e){return e.sh?"sh":(e.ph,"ph")}function Wwe(e,A,t,i,o,n){const s=[];if(e==="ph"){const r=t/2;s.push(ob(1,-r,2,i,o,n)),s.push(ob(2,r,2,i,o,n))}else{const r=-((A-1)/2)*t;for(let g=0;g<A;g++){const c=r+g*t;console.log("x si",c),s.push(yi(g+1,c,-1.325,o,n))}const a=(A-1)/2*t+1.3;console.log("offset",a),s.push(yi(A+1,-a,1.22,1.2,1.8)),s.push(yi(A+2,a,1.22,1.2,1.8))}return s}function Zwe(e,A,t){return e==="ph"?{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-3,y:3},{x:3,y:3},{x:3,y:-2},{x:-3,y:-2},{x:-3,y:3}],stroke_width:.1,pcb_silkscreen_path_id:""}:{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[],stroke_width:.1,pcb_silkscreen_path_id:""}}var Vwe=e=>{const A=Pwe.parse(e),t=Owe(A),i=qwe[t],o=A.p??i.p,n=A.id??i.id,s=A.pw??i.pw,r=A.pl??i.pl,a=A.w??i.w,g=A.h??i.h;let c=t==="sh"?4:2;if(t==="sh"){const E=(typeof e.string=="string"?e.string:"").match(/sh(\d+)/);if(E&&E[1]){const Q=parseInt(E[1],10);Number.isNaN(Q)||(c=Q)}else typeof A.sh=="number"&&(c=A.sh)}const I=Wwe(t,c,o,n,s,r),l=Zwe(t),B=Zi(0,g/2+1,.5);return{circuitJson:[...I,l,B],parameters:{...A,p:o,id:n,pw:s,pl:r,w:a,h:g,num_pins:c,sh:t==="sh",ph:t==="ph"}}},jwe=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("3.30mm"),h:v().default("1.70mm"),pl:v().default("0.80mm"),pw:v().default("1mm"),p:v().default("1.90mm")}),zwe=e=>{const A=jwe.parse(e),t=Zi(0,At.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:$we(A).concat(i,t),parameters:A}},Xwe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},$we=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=Xwe({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},ADe=e=>{switch(e){case 8:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"};case 10:return{w:"3.10mm",h:"3.33mm",p:"0.5mm",pl:"1.45mm",pw:"0.3mm"};default:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"}}},tDe=Vi.extend({fn:v(),num_pins:He([BA(8),BA(10)]).default(8),w:v().optional(),h:v().optional(),p:v().optional(),pl:v().optional(),pw:v().optional(),string:v().optional()}),eDe=e=>{const A=tDe.parse(e),t=ADe(A.num_pins),i=At.parse(A.w||t.w),o=At.parse(A.h||t.h),n=At.parse(A.p||t.p),s=At.parse(A.pl||t.pl),r=At.parse(A.pw||t.pw),a=[],g=A.num_pins/2;for(let u=0;u<A.num_pins;u++){const{x:d,y:f}=mXA(A.num_pins,u+1,i,n),m=u<g?u+1:A.num_pins-(u-g);a.push(yi(m,d,f,s,r))}const c=i,I=o,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:I/2},{x:c/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:-I/2},{x:c/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=mXA(A.num_pins,1,c,n),E={x:C.x-.8,y:C.y},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:E.x-.4,y:E.y},{x:E.x-.7,y:E.y+.3},{x:E.x-.7,y:E.y-.3},{x:E.x-.4,y:E.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Zi(0,I/2+.5,.3);return{circuitJson:[...a,l,B,h,Q],parameters:A}},mXA=(e,A,t,i)=>{const o=e/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*At.parse(e===8?"1.8mm":"2.2mm"),y:r*i}},iDe=e=>{switch(e){case 10:return{w:"3.10mm",h:"3.32mm",p:"0.5mm",pl:"1.63mm",pw:"0.33mm"};case 12:return{w:"3mm",h:"4mm",p:"0.65mm",pl:"0.88mm",pw:"0.4mm"};case 16:return{w:"3.10mm",h:"4mm",p:"0.5mm",pl:"0.88mm",pw:"0.3mm"};default:return{w:"3.10mm",h:"3.32mm",p:"0.65mm",pl:"1.63mm",pw:"0.4mm"}}},oDe=Vi.extend({fn:v(),num_pins:He([BA(8),BA(10),BA(12),BA(16)]).default(8),w:v().optional(),h:v().optional(),p:v().optional(),pl:v().optional(),pw:v().optional(),string:v().optional()}),wXA=(e,A,t,i)=>{const o=e/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*At.parse("2mm"),y:r*i}},nDe=e=>{const A=oDe.parse(e),t=iDe(A.num_pins),i=At.parse(A.w||t.w),o=At.parse(A.h||t.h),n=At.parse(A.p||t.p),s=At.parse(A.pl||t.pl),r=At.parse(A.pw||t.pw),a=[];for(let h=0;h<A.num_pins;h++){const{x:u,y:d}=wXA(A.num_pins,h+1,i,n);a.push(yi(h+1,u,d,s,r))}const g=i,c=o,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:c/2},{x:g/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-c/2},{x:g/2,y:-c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B=wXA(A.num_pins,1,g,n),C={x:B.x-.8,y:B.y},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:C.x-.4,y:C.y},{x:C.x-.7,y:C.y+.3},{x:C.x-.7,y:C.y-.3},{x:C.x-.4,y:C.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},Q=Zi(0,c/2+.5,.3);return{circuitJson:[...a,I,l,Q,E],parameters:A}},sDe=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("3.8mm"),h:v().default("1.65mm"),pl:v().default("1.2mm"),pw:v().default("1.2mm"),pad_spacing:v().default("2.6mm")}),rDe=e=>{const A=sDe.parse(e),t=Zi(0,At.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.pad_spacing)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:-At.parse(A.h)/2},{x:At.parse(A.pad_spacing)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gDe(A).concat(i,t),parameters:A}},aDe=e=>{const{pn:A,pad_spacing:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},gDe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=aDe({pn:t,pad_spacing:Number.parseFloat(e.pad_spacing)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},cDe=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("3.20mm"),h:v().default("1.65mm"),pl:v().default("0.8mm"),pw:v().default("0.9mm"),pad_spacing:v().default("2.1mm")}),IDe=e=>{const A=cDe.parse(e),t=Zi(0,At.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.pad_spacing)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.2,y:-At.parse(A.h)/2},{x:At.parse(A.pad_spacing)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:BDe(A).concat(i,t),parameters:A}},lDe=e=>{const{pn:A,pad_spacing:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},BDe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=lDe({pn:t,pad_spacing:Number.parseFloat(e.pad_spacing)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},CDe=Vi.extend({fn:v(),num_pins:He([BA(6),BA(8)]).default(8),w:v().default("3mm"),h:v().default("3mm"),p:v().default("0.5mm"),pl:v().default("0.52mm"),pw:v().default("0.35mm"),epw:v().default("1.40mm"),eph:v().default("1.60mm"),string:v().optional(),ep:$A().default(!1)}),QDe=e=>{e.string&&e.string.includes("_ep")&&(e.ep=!0);const A=e.string?.match(/^son_(\d+)/),t=A?Number.parseInt(A[1],10):e.num_pins||8,i=CDe.parse({...e,num_pins:t}),o=At.parse(i.w),n=At.parse(i.h),s=At.parse(i.p),r=At.parse(i.pl),a=At.parse(i.pw),g=At.parse(i.epw),c=At.parse(i.eph),I=[];for(let f=0;f<i.num_pins;f++){const{x:m,y:D}=DXA(i.num_pins,f+1,o,s);I.push(yi(f+1,m,D,r,a))}i.ep&&I.push(yi(i.num_pins+1,0,0,g,c));const l=o,B=n,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:B/2},{x:l/2,y:B/2}],stroke_width:.05,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-B/2},{x:l/2,y:-B/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q=DXA(i.num_pins,1,l,s),h={x:Q.x-.4,y:Q.y},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:h.x-.4,y:h.y},{x:h.x-.7,y:h.y+.3},{x:h.x-.7,y:h.y-.3},{x:h.x-.4,y:h.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Zi(0,B/2+.5,.3);return{circuitJson:[...I,C,E,d,u],parameters:i}},DXA=(e,A,t,i)=>{const o=e/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*At.parse("1.4mm"),y:r*i}},EDe=e=>{const{num_pins:A,bridged:t,p:i=2.54,pw:o=1.5,ph:n=1.5}=e,s=At.parse(i),r=At.parse(o),a=At.parse(n),g=Math.min(a/4,.5),c=[];for(let f=0;f<A;f++)c.push(yi(f+1,f*s,0,r,a));let I=[];if(t){const f=t.split("").map(Number);if(f.length>1)for(let m=0;m<f.length-1;m++){const D=f[m],w=f[m+1];if(typeof D=="number"&&typeof w=="number"&&!isNaN(D)&&!isNaN(w)){const b=(D-1)*s,k=(w-1)*s,_=Math.sign(k-b),N=b+_*(r/2),M=k-_*(r/2);I.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${D}}`,x:N,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${w}}`,x:M,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const l=(A-1)*s+r+.7,B=a+1,C=(A-1)*s/2,E=0,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:C-l/2,y:E-B/2},{x:C+l/2,y:E-B/2},{x:C+l/2,y:E+B/2},{x:C-l/2,y:E+B/2},{x:C-l/2,y:E-B/2}],stroke_width:.15},u=E+B/2+.6,d=Zi(C,u,.4);return{circuitJson:[...c,...I,Q,d],parameters:e}},SXA={fn:BA("sot457"),num_pins:BA(6).default(6),pillh:v().default("0.45mm"),pillw:v().default("1.45mm"),pl:v(),pw:v(),p:v(),wave:$A().optional(),reflow:$A().optional()},hDe=Vi.extend({...SXA,h:v().default("2.5mm"),w:v().default("2.7mm"),pl:v().default("0.8mm"),pw:v().default("0.55mm"),p:v().default("0.95mm")}),uDe=Vi.extend({...SXA,h:v().default("3mm"),w:v().default("4mm"),pillr:v().default("0.225mm"),pl:v().default("1.45mm"),pw:v().default("1.5mm"),p:v().default("1.475mm")}).transform(e=>({...e,wave:e.wave??(e.reflow===void 0?!0:!e.reflow),reflow:e.reflow??(e.wave===void 0?!1:!e.wave)})),nb=e=>Number.parseFloat(e.replace("mm","")),bXA=({pitch:e,width:A,pinNumber:t})=>{const n={1:{x:-A/2-.1,y:e},2:{x:-A/2-.1,y:0},3:{x:-A/2-.1,y:-e},4:{x:A/2+.1,y:-e},5:{x:A/2+.1,y:0},6:{x:A/2+.1,y:e}}[t];if(!n)throw new Error(`Invalid pin number: ${t}`);return n},_XA=e=>{const A=[],t=nb(e.p),i=nb(e.pl),o=nb(e.pw),n=nb(e.w),s=nb(e.h);if(e.wave){const C={1:({padWidth:E,padHeight:Q})=>yi(1,-t,t,Q,E),2:({padWidth:E,padHeight:Q})=>yi(2,-t,-t,Q,E),3:({padWidth:E,padHeight:Q})=>aW(3,-t,0,nb(e.pillw),nb(e.pillh)),4:({padWidth:E,padHeight:Q})=>aW(4,t,0,nb(e.pillw),nb(e.pillh)),5:({padWidth:E,padHeight:Q})=>yi(5,t,t,Q,E),6:({padWidth:E,padHeight:Q})=>yi(6,t,-t,Q,E)};for(let E=1;E<=e.num_pins;E++){const Q=C[E];Q&&A.push(Q({padWidth:i,padHeight:o}))}}else for(let C=1;C<=e.num_pins;C++){const{x:E,y:Q}=bXA({pitch:t,width:n,pinNumber:C});A.push(yi(C,E,Q,i,o))}const r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:s/2+t/1.3},{x:n/3,y:s/2+t/1.3}],stroke_width:.05},a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-s/2-t/1.3},{x:n/3,y:-s/2-t/1.3}],stroke_width:.05},g=Zi(0,s+.5,.3),c=bXA({pitch:t,width:n,pinNumber:1}),I=e.wave?1:.5,l=e.wave?.7:.3;c.x-=e.wave?o:o*1.7;const B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:c.x+I/2,y:c.y},{x:c.x-I/2,y:c.y+l/2},{x:c.x-I/2,y:c.y-l/2},{x:c.x+I/2,y:c.y}],stroke_width:.05};return[g,r,a,B,...A]},dDe=e=>{if(e.wave){const t=uDe.parse({...e,fn:"sot457"});return{circuitJson:_XA(t),parameters:t}}const A=hDe.parse(e);return{circuitJson:_XA(A),parameters:A}},pDe=Vi.extend({fn:v(),num_pins:BA(6).default(6),w:v().default("1.1mm"),h:v().default("1.45mm"),p:v().default("0.35mm"),pl:v().default("0.2mm"),pw:v().default("0.2mm"),string:v().optional()}),fDe=e=>{const A=pDe.parse({...e,fn:"sot963"}),t=At.parse(A.w),i=At.parse(A.h),o=At.parse(A.p),n=At.parse(A.pl),s=At.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:E}=xXA(B+1,t,o,n);r.push(yi(B+1,C,E,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:i/2},{x:t/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:-i/2},{x:t/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},c=xXA(1,t,o,n),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-n/2-.3,y:c.y},{x:c.x-n/2-.45,y:c.y+.15},{x:c.x-n/2-.45,y:c.y-.15},{x:c.x-n/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Zi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},xXA=(e,A,t,i)=>{const o=A/2-i/2;return e<=3?{x:-o,y:t-(e-1)*t}:{x:o,y:-t+(e-4)*t}},yDe=Vi.extend({fn:v(),num_pins:He([BA(3),BA(2)]).default(3),p:v().default("3.8mm"),id:v().default("1.25mm"),od:v().default("2.35mm"),ca:v().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:v().default("5.35mm"),h:v().default("4mm"),string:v().optional()}),mDe=e=>{const{p:A,id:t,od:i,h:o,ca:n}=e,s=Number.parseFloat(o),r=Number.parseFloat(n);return[$n(1,0,r/4+.3,t,i),$n(2,s,0,t,i),$n(3,0,-r/4-.3,t,i)]},wDe=e=>{const A=e.string?.match(/^potentiometer_(\d+)/),t=A?Number.parseInt(A[1],10):3,i=yDe.parse({...e,num_pins:t});let o=[];i.num_pins===3&&(o=mDe(i));const n=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),r=Number.parseFloat(i.od)/2+.35,a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:n-1.75},{x:0,y:n},{x:s,y:n},{x:s,y:r}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-r},{x:s,y:-n},{x:0,y:-n},{x:0,y:-n+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},c=Number.parseFloat(i.w)/2,I=Zi(c,n+1,.5);return{circuitJson:[...o,a,g,I],parameters:i}},DDe=Vi.extend({fn:v(),p:At.optional().default("7.5mm"),id:At.optional().default("1mm"),od:At.optional().default("2mm"),d:At.optional().default("10.5mm")}),SDe=(e,A,t,i,o)=>{const n=[],s=[];for(let r=0;r<=50;r++){const a=r/50*Math.PI,g=e+Math.cos(a)*t,c=A+Math.sin(a)*t;g<e-i&&c>=A-o/2&&c<=A+o/2||n.push({x:g,y:c})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=e+Math.cos(a)*t,c=A+Math.sin(a)*t;g<e-i&&c>=A-o/2&&c<=A+o/2||s.push({x:g,y:c})}return{topArc:n,bottomArc:s}},bDe=e=>{const A=DDe.parse(e),{p:t,id:i,od:o,d:n}=A,s=[$n(1,-t/2,0,i,o),$n(2,t/2,0,i,o)],{topArc:r,bottomArc:a}=SDe(0,0,n/2+.1,o/2,o),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:n/2+.1},{x:0,y:-(n/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},l=-(n/2+.5),B=o/2+1.5,C=.5,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l-C,y:B},{x:l+C,y:B}],stroke_width:.1,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l,y:B-C},{x:l,y:B+C}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Zi(0,n/2+1,.5);return{circuitJson:[...s,g,c,I,E,Q,h],parameters:A}},_De=Vi.extend({fn:v(),num_pins:BA(2).default(2),w:v().default("6.5mm"),h:v().default("3mm"),pl:v().default("1.75mm"),pw:v().default("2.40mm"),p:v().default("4.75mm")}),xDe=e=>{const A=_De.parse(e),t=Zi(0,At.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:At.parse(A.p)/2,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.3,y:At.parse(A.h)/2},{x:-At.parse(A.w)/2-.3,y:-At.parse(A.h)/2},{x:At.parse(A.p)/2,y:-At.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:FDe(A).concat(i,t),parameters:A}},kDe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},FDe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:o}=kDe({pn:t,p:Number.parseFloat(e.p)});A.push(yi(t,i,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},GDe=Vi.extend({fn:v(),num_pins:GA().default(3),w:v().default("2.45mm"),h:v().default("2.40mm"),pl:v().default("1.225mm"),pw:v().default("0.5mm"),p:v().default("0.95mm"),string:v().optional()}),RDe=e=>{const A=e.string?.match(/^sot323_(\d+)/),t=A?Number.parseInt(A[1],3):3,i=GDe.parse({...e,num_pins:t});if(i.num_pins===3)return{circuitJson:NDe(i),parameters:i};throw new Error("Invalid number of pins")},MDe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t,y:.65}:A===2?{x:-t,y:-.65}:{x:t,y:0}},NDe=e=>{const A=[];for(let r=0;r<e.num_pins;r++){const{x:a,y:g}=MDe({num_pins:e.num_pins,pn:r+1,w:Number.parseFloat(e.w),h:Number.parseFloat(e.h),pl:Number.parseFloat(e.pl),p:Number.parseFloat(e.p)});A.push(yi(r+1,a,g,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}const t=Zi(0,Number.parseInt(e.h)/2+1,.3),i=Number.parseFloat(e.w)/2-Number.parseFloat(e.pl),o=Number.parseFloat(e.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o+.3},{x:i,y:o+.3},{x:i,y:o/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o-.3},{x:i,y:-o-.3},{x:i,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,t]},vDe=Vi.extend({fn:v(),circle:$A().optional(),rect:$A().optional(),square:$A().optional(),pill:$A().optional(),d:At.optional(),pd:At.optional(),diameter:At.optional(),r:At.optional(),pr:At.optional(),radius:At.optional(),w:At.optional(),pw:At.optional(),width:At.optional(),h:At.optional(),ph:At.optional(),height:At.optional(),s:At.optional(),size:At.optional(),string:v().optional()}).transform(e=>{let A="rect";e.circle&&(A="circle"),e.square&&(A="square"),e.rect&&(A="rect"),e.pill&&(A="pill");let t,i,o;return A==="circle"?e.r!==void 0?t=Mr(e.r):e.pr!==void 0?t=Mr(e.pr):e.radius!==void 0?t=Mr(e.radius):e.d!==void 0?t=Mr(e.d)/2:e.pd!==void 0?t=Mr(e.pd)/2:e.diameter!==void 0?t=Mr(e.diameter)/2:t=Mr("1mm")/2:(e.w!==void 0?i=Mr(e.w):e.pw!==void 0?i=Mr(e.pw):e.width!==void 0?i=Mr(e.width):e.s!==void 0?i=Mr(e.s):e.size!==void 0?i=Mr(e.size):i=Mr("1mm"),e.h!==void 0?o=Mr(e.h):e.ph!==void 0?o=Mr(e.ph):e.height!==void 0?o=Mr(e.height):A==="square"||A==="rect"?o=i:o=Mr("1mm")),{fn:e.fn,shape:A,radius:t,width:i,height:o}}),LDe=e=>{const A=vDe.parse(e),{shape:t,radius:i,width:o,height:n}=A;let s,r;return t==="circle"?(s=gXA(1,{x:0,y:0,radius:i}),r=i+.5):t==="pill"?(s=aW(1,0,0,o,n),r=Math.max(o,n)/2+.5):(s=yi(1,0,0,o,n),r=n/2+.5),{circuitJson:[s,Zi(0,r,.2)],parameters:A}},UDe=Vi.extend({fn:v(),d:At.optional(),hd:At.optional(),r:At.optional(),hr:At.optional(),pd:At.optional(),pr:At.optional(),squarepad:$A().optional().default(!1)}).transform(e=>{let A;e.d!==void 0?A=Mr(e.d):e.hd!==void 0?A=Mr(e.hd):e.r!==void 0?A=Mr(e.r)*2:e.hr!==void 0?A=Mr(e.hr)*2:A=Mr("1mm");let t;return e.pd!==void 0?t=Mr(e.pd):e.pr!==void 0?t=Mr(e.pr)*2:t=A*(1.5/1),{fn:e.fn,d:A,pd:t,squarepad:e.squarepad??!1}}),HDe=e=>{const A=UDe.parse(e),{d:t,pd:i,squarepad:o}=A;return{circuitJson:[o?ob(1,0,0,t,i,i):$n(1,0,0,t,i),Zi(0,i/2+.5,.2)],parameters:A}},YDe=Vi.extend({fn:v(),num_pins:BA(6).default(6),h:v().default("1.6mm"),pl:v().default("1mm"),pw:v().default("0.7mm"),p:v().default("0.95mm")}),JDe=e=>{const A=YDe.parse(e);return{circuitJson:TDe(A),parameters:A}},kXA=e=>{const{p:A,h:t,pn:i}=e;if(i===1)return{x:-t/2-.5,y:A};if(i===2)return{x:-t/2-.5,y:0};if(i===3)return{x:-t/2-.5,y:-A};if(i===4)return{x:t/2+.5,y:-A};if(i===5)return{x:t/2+.5,y:0};if(i===6)return{x:t/2+.5,y:A};throw new Error("Invalid pin number")},TDe=e=>{const A=[];for(let I=1;I<=e.num_pins;I++){const{x:l,y:B}=kXA({h:Number.parseFloat(e.h),p:Number.parseFloat(e.p),pn:I});A.push(yi(I,l,B,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}const t=e.num_pins/2*Number.parseFloat(e.p),i=Number.parseFloat(e.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t/3,y:i/2+Number.parseFloat(e.p)/1.3},{x:t/3,y:i/2+Number.parseFloat(e.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t/3,y:-i/2-Number.parseFloat(e.p)/1.3},{x:t/3,y:-i/2-Number.parseFloat(e.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Zi(0,i+.3,.3),r=kXA({h:Number.parseFloat(e.h),p:Number.parseFloat(e.p),pn:1});r.x=r.x-Number.parseFloat(e.pw)*1.5;const a=.7,g=.3,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,o,n,c]},KDe=Vi.extend({fn:v(),num_pins:GA().default(4),w:v().default("3.2mm"),h:v().default("2.6mm"),pl:v().default("1.35mm"),pw:v().default("0.50mm"),p:v().default("0.6mm"),string:v().optional()}),PDe=e=>{const A=e.string?.match(/^sot343_(\d+)/),t=A?Number.parseInt(A[1],4):4,i=KDe.parse({...e,num_pins:t});if(i.num_pins===4)return{circuitJson:ODe(i),parameters:i};throw new Error("Invalid number of pins")},qDe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t*1.92,y:-.65}:A===2?{x:-t*1.92,y:.65}:A===3?{x:t,y:.65}:A===4?{x:t,y:-.65}:{x:0,y:0}},ODe=e=>{const A=[],t=Number.parseFloat(e.w),i=Number.parseFloat(e.h),o=Number.parseFloat(e.pl),n=Number.parseFloat(e.pw),s=Number.parseFloat(e.p);let r=1/0,a=-1/0,g=1/0,c=-1/0;for(let d=0;d<e.num_pins;d++){const{x:f,y:m}=qDe({num_pins:e.num_pins,pn:d+1,p:s});A.push(yi(d+1,f,m,o,n)),f<r&&(r=f),f>a&&(a=f),m<g&&(g=m),m>c&&(c=m)}const I=(r+a)/2,l=c-g,B=i*.3,C=l/2+B;let E=t*.8;i<=2.6&&(E/=2);const Q=Zi(I,C+.5,.3),h={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:I-E/2,y:C},{x:I+E/2,y:C}],type:"pcb_silkscreen_path",stroke_width:.1},u={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_bottom",route:[{x:I-E/2,y:-C},{x:I+E/2,y:-C}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,h,u,Q]},WDe=Vi.extend({fn:v()}),ZDe=e=>{const A=WDe.parse(e),t=[],i=.5-.15,o=1.5,s=.5/2,r=75,a=-37/2;for(let w=0;w<r;w++){const b=w+1;if(b>=24&&b<=31)continue;const k=a-w*s,_=b%2===0,N=o+(_?.25:0),H=.5-N/2,T=yi(b,H,k,N,i);T.layer=_?"bottom":"top",t.push(T)}const g=46*.0254,c=137*.0254,I=261*.0254,l={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-c/2+o/2,y:a-I},width:c,height:g},B={x:-.5,y:a},C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:B.x-.4,y:B.y},{x:B.x-.7,y:B.y+.3},{x:B.x-.7,y:B.y-.3},{x:B.x-.4,y:B.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let E=1/0,Q=-1/0,h=1/0,u=-1/0;const d=(w,b,k=0,_=0)=>{E=Math.min(E,w-k/2),Q=Math.max(Q,w+k/2),h=Math.min(h,b-_/2),u=Math.max(u,b+_/2)};for(const w of t)d(w.x,w.y,w.width,w.height);d(l.center.x,l.center.y,l.width,l.height);for(const w of C.route)d(w.x,w.y);const f=(E+Q)/2,m=(h+u)/2,D=w=>{typeof w.x=="number"&&(w.x-=f),typeof w.y=="number"&&(w.y-=m),w.center&&(w.center.x-=f,w.center.y-=m),Array.isArray(w.route)&&(w.route=w.route.map(b=>({x:b.x-f,y:b.y-m})))};for(const w of t)D(w);return D(l),D(C),{circuitJson:[...t,l,C],parameters:A}},VDe=Vi.extend({fn:v(),num_pins:GA().default(3),inline:$A().default(!1),p:v().default("1.27mm"),id:v().default("0.75mm"),od:v().default("1.3mm"),w:v().default("4.8mm"),h:v().default("4.0mm")}),jDe=e=>{const A=VDe.parse(e),t=Number.parseFloat(A.p),i=Number.parseFloat(A.w),o=Number.parseFloat(A.h),n=A.inline?1.05:Number.parseFloat(A.od),s=A.inline?1.5:n,r=[ob(1,0,0,A.id,n,s,0,0),A.inline?rH(2,t,0,A.id,n,s):$n(2,t,t,A.id,n),A.inline?rH(3,t*2,0,A.id,n,s):$n(3,t*2,0,A.id,n)],a=i/2,g=A.inline?t-.09:t,c=.2,I=c+a-o,l=Array.from({length:32},(E,Q)=>{const h=Math.PI*Q/31;return{x:g+a*Math.cos(h),y:c+a*Math.sin(h)}}),B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",stroke_width:.12,route:[...l,{x:g-a,y:I},{x:g+a,y:I},l[0]]},C=Zi(g,c+a+1,.5);return{circuitJson:[...r,B,C],parameters:A}};function zDe(e){return e!=null}var XDe=(e,A)=>{if(!A)return e;const t=e.filter(c=>c.type==="pcb_smtpad"||c.type==="pcb_plated_hole"||c.type==="pcb_thtpad");if(t.length===0)return e;let i=1/0,o=-1/0,n=1/0,s=-1/0;const r=(c,I,l=0,B=0)=>{const C=c-l/2,E=c+l/2,Q=I-B/2,h=I+B/2;i=Math.min(i,C),o=Math.max(o,E),n=Math.min(n,Q),s=Math.max(s,h)};for(const c of t)if(c.type==="pcb_smtpad"){const I=c.shape==="circle"?c.radius*2:c.width,l=c.shape==="circle"?c.radius*2:c.height;r(c.x,c.y,I,l)}else if(c.type==="pcb_plated_hole"){const I=c.outer_diameter??c.hole_diameter;r(c.x,c.y,I,I)}else if(c.type==="pcb_thtpad"){const I=c.diameter;r(c.x,c.y,I,I)}let a=0,g=0;switch(A){case"center":a=(i+o)/2,g=(n+s)/2;break;case"bottomleft":a=i,g=n;break;case"bottomcenter":case"centerbottom":a=(i+o)/2,g=n;break;case"topcenter":case"centertop":a=(i+o)/2,g=s;break;case"leftcenter":case"centerleft":a=i,g=(n+s)/2;break;case"rightcenter":case"centerright":a=o,g=(n+s)/2;break;case"pin1":const c=t.find(I=>I.port_hints?.[0]==="1")||t[0];a=c.x,g=c.y;break}if(a===0&&g===0)return e;for(const c of e){if(typeof c.x=="number"&&(c.x-=a),typeof c.y=="number"&&(c.y-=g),c.center&&typeof c.center.x=="number"&&(c.center.x-=a,c.center.y-=g),c.type==="pcb_silkscreen_path")for(const I of c.route)I.x-=a,I.y-=g;c.type==="pcb_silkscreen_text"&&c.anchor_position&&(c.anchor_position.x-=a,c.anchor_position.y-=g)}return e},$De=(e,A)=>{const t=e.filter(i=>i.type==="pcb_silkscreen_text");if(t.length===0)return e;for(const i of t)A.norefdes&&(i.text="");return e},ASe=(e,A)=>A.nosilkscreen?e.filter(t=>t.type!=="pcb_silkscreen_path"&&t.type!=="pcb_silkscreen_text"):e,tSe=e=>{let A=lW();const i=e.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(o=>{const n=o.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!n)return null;const[,s,r]=n;if(!s)return null;const a=s.toLowerCase();return r?.includes("?")?null:{fn:a,v:r}}).filter(zDe);for(const{fn:o,v:n}of i)A=A[o](n);return A.setString(e),A},eSe=()=>Object.keys(ib),lW=()=>{const e=new Proxy({},{get:(A,t)=>{if(t==="soup"||t==="circuitJson"){if("fn"in A&&ib[A.fn])return()=>{const{circuitJson:i}=ib[A.fn](A),o=ASe(i,A),n=$De(o,A);return XDe(n,A.origin)};if(!ib[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>{throw new Error(`No function found for footprinter, make sure to specify .dip, .lr, .p, etc. Got "${t}"`)}}if(t==="json"){if(!ib[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>ib[A.fn](A).parameters}return t==="getFootprintNames"?()=>Object.keys(ib):t==="params"?()=>A:t==="setString"?i=>(A.string=i,e):i=>(Object.keys(A).length===0?`${t}${i}`in ib?(A[`${t}${i}`]=!0,A.fn=`${t}${i}`):(A[t]=!0,A.fn=t,t==="res"||t==="cap"?i&&(typeof i=="string"&&i.includes("_metric")?A.metric=i.split("_metric")[0]:A.imperial=i):A.num_pins=Number.isNaN(Number.parseFloat(i))?void 0:Number.parseFloat(i)):!i&&["w","h","p"].includes(t)||(A[t]=i??!0),e)}});return e};lW.string=tSe,lW.getFootprintNames=eSe;var iSe=lW,FXA=Symbol("Fragment");function EEA(e,A,...t){const i=t.length?t:A?.children!==void 0?[A.children]:[],o=[],n=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of n)s==null||s===!1||(Array.isArray(s)?o.push(...s):o.push(s));return{type:e,props:(A&&A.children!==void 0?{...A,children:void 0}:A)||{},children:o}}var ue=Symbol("Cuboid"),GXA=Symbol("Cube"),If=Symbol("Cylinder"),RXA=Symbol("Sphere"),aH=Symbol("RoundedCuboid"),eo=Symbol("Translate"),GQ=Symbol("Rotate"),xE=Symbol("Union"),VF=Symbol("Subtract"),pc=Symbol("Hull"),Fs=Symbol("Colorize"),gH=Symbol("Polygon"),cH=Symbol("ExtrudeLinear"),lf=Symbol("RoundedCylinder"),Xo=FXA,tt=(e,A,t)=>EEA(e,A),We=(e,A,t)=>EEA(e,A),aB=({center:e,width:A,length:t,height:i,heightAboveSurface:o=.15,color:n="#555",taperRatio:s=.12,faceRatio:r=.75,straightHeightRatio:a=.5,includeNotch:g=!0,notchRadius:c,notchPosition:I,notchRotation:l=[0,0,0],notchLength:B=.5,notchWidth:C=.25,chamferSize:E=0})=>{const Q=i*a,h=i-Q,u=Math.min(A,t)*s,d=Math.max(A-u,A*r),f=Math.max(t-u,t*r),m=Math.min(A,t)*.12,D=c??m,w={x:0,y:t/2-D*.25,z:i},b=I??w,k=We(xE,{children:[We(pc,{children:[tt(eo,{z:.005,children:tt(ue,{size:[d,f,.01]})}),tt(eo,{z:Q,children:tt(ue,{size:[A,t,.01]})})]}),We(pc,{children:[tt(eo,{z:Q,children:tt(ue,{size:[A,t,.01]})}),tt(eo,{z:Q+h,children:tt(ue,{size:[d,f,.01]})})]})]}),_=(M,H)=>tt(eo,{offset:{x:M,y:H,z:0},children:tt(GQ,{rotation:[0,0,Math.PI/4],children:tt(ue,{size:[E*Math.SQRT2,E*Math.SQRT2,i*3]})})});let N=k;if(E>0){const M=A/2,H=t/2;N=We(VF,{children:[k,_(M,H),_(-M,H),_(M,-H),_(-M,-H)]})}return tt(Fs,{color:n,children:tt(eo,{offset:e,children:tt(eo,{offset:{x:0,y:0,z:o},children:g?We(VF,{children:[N,tt(eo,{offset:b,children:tt(GQ,{rotation:l,children:tt(If,{radius:D,height:C})})})]}):N})})})},oSe=e=>Array.from({length:e},(A,t)=>t);function hEA(e,A){if(e.length<2)throw new Error("Stroke must have at least two points");const t=Array.isArray(e[0])?e.map(([c,I])=>({x:c,y:I})):e,i=A/2,o=[],n=[];function s(c,I){const l=I.x-c.x,B=I.y-c.y,C=Math.sqrt(l*l+B*B);return{x:-B/C,y:l/C}}function r(c,I,l){const B={x:c.x+I.x*i*l,y:c.y+I.y*i*l};l>0?o.push(B):n.unshift(B)}const a=s(t[0],t[1]);r(t[0],a,1),r(t[0],a,-1);for(let c=1;c<t.length-1;c++){const I=t[c-1],l=t[c],B=t[c+1],C=s(I,l),E=s(l,B),Q=C.x+E.x,h=C.y+E.y,u=Math.sqrt(Q*Q+h*h);if(u/2>2*i)r(l,C,1),r(l,E,1),r(l,C,-1),r(l,E,-1);else{const f=1/u;r(l,{x:Q*f,y:h*f},1),r(l,{x:Q*f,y:h*f},-1)}}const g=s(t[t.length-2],t[t.length-1]);return r(t[t.length-1],g,1),r(t[t.length-1],g,-1),[...o,...n]}var nSe=e=>{const A=Math.min(...e.map(r=>r.x)),t=Math.max(...e.map(r=>r.x)),i=Math.min(...e.map(r=>r.y)),s=5.47/(Math.max(...e.map(r=>r.y))-i);return e.map(r=>({x:(r.x-A-(t-A)/2)*s,y:(r.y-i)*s}))},sSe=nSe([{x:20,y:105},{x:20,y:109},{x:20,y:102},{x:26,y:102},{x:26,y:109},{x:24,y:111},{x:24,y:118},{x:22,y:118},{x:22,y:111},{x:20,y:109}]),MXA=5.47,BW=.5,rSe=({x:e,y:A,z:t})=>{const i=e>0;return We(Xo,{children:[tt(eo,{offset:{x:e+.25/2,y:A,z:t},children:tt(GQ,{rotation:["-90deg",0,"90deg"],children:tt(cH,{height:.25,children:tt(gH,{points:sSe.slice().reverse().map(o=>[o.x,o.y])})})})}),tt(eo,{offset:{x:e,y:A+(i?1:-1),z:t},children:tt(GQ,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:tt(cH,{height:2,children:tt(gH,{points:hEA([[0,0],[-1,0],[-1,-1]],.25).map(o=>[o.x,o.y])})})})})]})},aSe=({numPins:e=8,pitch:A=2.54,bodyWidth:t=6.4,rowSpacing:i})=>{const o=Math.floor(e/2),n=i??(t>=7?t:t+1.22),s=t>=7?n-1.22:t;return We(Xo,{children:[oSe(e).map(r=>{const a=r%o,g=(Math.floor(r/o)-.5)*2;return tt(rSe,{x:g*n/2,y:a*A-(o-1)/2*A,z:MXA/2+BW})}),tt(aB,{width:s,length:o*A+.5,height:MXA-BW,heightAboveSurface:BW,center:{x:0,y:0,z:BW}})]})};function gSe(e,{height:A,padContactLength:t,curveLength:i,bodyDistance:o,steepness:n=10}){i||(i=o*.3);let s=o-t-i;s<0&&(i+=s,s=0);const r=t*.75,a=t+i+(o-t-i)*.25;if(e<=r)return 0;if(e>=a)return A;const g=(e-r)/(a-r);return A/(1+Math.exp(-n*(g-.5)))}var tn=e=>{const{thickness:A,width:t,padContactLength:i,bodyDistance:o,height:n,rotation:s}=e,r=15,a=Array.from({length:r}).map((c,I)=>I/(r-1)*o).map(c=>[c,gSe(c,e)]),g=hEA(a,A);return tt(Fs,{color:"#fff",children:tt(eo,{offset:{z:0,y:0,x:0,...e.position},children:tt(GQ,{rotation:["90deg",0,s??0],children:tt(eo,{offset:{x:0,y:0,z:-t/2},children:tt(cH,{height:t,children:tt(gH,{points:g.map(c=>[c.x,c.y])})})})})})})},cSe=({pinCount:e,leadLength:A,leadWidth:t,pitch:i,bodyWidth:o})=>{const n=Math.ceil(e/2),s=i*e/2+t/2,r=(n-1)*i/2,a=.25;return We(Xo,{children:[Array.from({length:n}).map((g,c)=>tt(tn,{position:{x:-o/2-A,y:c*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:n}).map((g,c)=>tt(tn,{rotation:Math.PI,position:{x:o/2+A,y:c*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),tt(aB,{center:{x:0,y:0,z:a/2},width:o-t-1,length:s,height:1.5})]})},ISe=({pinCount:e,padContactLength:A=.4,leadWidth:t=.2,pitch:i=.65,bodyWidth:o=3})=>{const n=Math.ceil(e/2),s=(n-1)*i/2,r=.2;return We(Xo,{children:[Array.from({length:n}).map((a,g)=>tt(tn,{position:{x:-o/2-A-.3,y:g*i-s,z:r/2},width:t,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Array.from({length:n}).map((a,g)=>tt(tn,{rotation:Math.PI,position:{x:o/2+A+.3,y:g*i-s,z:r/2},width:t,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),tt(aB,{center:{x:0,y:0,z:r/2},width:o,length:o,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},uEA=1,dEA=.5,XN=.5,IH=.2,lSe=uEA-IH*2,NXA=({color:e="#333"})=>We(Xo,{children:[tt(ue,{size:[lSe,dEA,XN],offset:[0,0,XN/2],color:e}),tt(ue,{size:[IH,XN,dEA],offset:[uEA/2-IH/2,0,XN/2],color:"#ccc"}),tt(ue,{size:[IH,XN,dEA],offset:[-uEA/2+IH/2,0,XN/2],color:"#ccc"})]}),pEA=1.6,BSe=pEA-.3*2,CW=.3,fEA=.85,$N=.6,vXA=({color:e="#333"})=>We(Xo,{children:[tt(ue,{size:[BSe,fEA,$N],offset:[0,0,$N/2],color:e}),tt(ue,{size:[CW,fEA,$N],offset:[pEA/2-CW/2,0,$N/2],color:"#ccc"}),tt(ue,{size:[CW,fEA,$N],offset:[-pEA/2+CW/2,0,$N/2],color:"#ccc"})]}),yEA=2,mEA=1.25,Av=.55,lH=.5,CSe=yEA-lH*2,LXA=({color:e="#333"})=>We(Xo,{children:[tt(ue,{size:[CSe,mEA,Av],offset:[0,0,Av/2],color:e}),tt(ue,{size:[lH,mEA,Av],offset:[yEA/2-lH/2,0,Av/2],color:"#ccc"}),tt(ue,{size:[lH,mEA,Av],offset:[-yEA/2+lH/2,0,Av/2],color:"#ccc"})]}),QSe=({pinCount:e,pitch:A,leadWidth:t,padContactLength:i,bodyWidth:o})=>{const n=e/4;A||(A=ESe(e,o)),i||(i=hSe(e)),t||(t=uSe(e,o)),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+2*i,g=a,c=.8,I=.15,l=(g-o)/2+.5;return We(Xo,{children:[Array.from({length:n}).map((B,C)=>tt(tn,{position:{x:-g/2-.4,y:C*A-r,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:n}).map((B,C)=>tt(tn,{rotation:Math.PI,position:{x:g/2+.4,y:C*A-r,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:n}).map((B,C)=>tt(tn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.4,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:n}).map((B,C)=>tt(tn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.4,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),tt(aB,{center:{x:0,y:0,z:0},width:o,length:s,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:o/2-1.5,z:1.5},notchRadius:1.5/2})]})},ESe=(e,A)=>{switch(e){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},hSe=e=>{switch(e){case 32:return .6;case 40:return .6;case 52:case 64:return .65;case 208:return 1.65;default:return .6}},uSe=(e,A)=>{switch(e){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},dSe=({numberOfPins:e,pitch:A=2.54,longSidePinLength:t=6,invert:i,faceup:o,rows:n=1})=>{const a=Math.ceil(e/n),g=2.54,c=a*A,I=n>1?(n-1)*g+.63*3:.63*3,l=3,B=-((a-1)/2)*A,C=n>1?-((n-1)*g)/2:0,E=Q=>i||o?-Q+2:Q;return We(Xo,{children:[tt(ue,{color:"#222",size:[c,I,2],center:[0,C,E(2/2)]}),Array.from({length:e},(Q,h)=>{const u=Math.floor(h/a),d=h%a,f=B+d*A,m=-u*g;return We(Xo,{children:[!o&&tt(Fs,{color:"gold",children:We(pc,{children:[tt(ue,{color:"gold",size:[.63,.63,l*.9],center:[f,m,E(2*.9+2/2)]}),tt(ue,{color:"gold",size:[.63/1.8,.63/1.8,l],center:[f,m,E(2+2/2)]})]})}),tt(Fs,{color:"gold",children:We(pc,{children:[tt(ue,{color:"gold",size:[.63,.63,t*.9],center:[f,m,E(-t/2*.9)]}),tt(ue,{color:"gold",size:[.63/1.8,.63/1.8,t],center:[f,m,E(-t/2)]})]})})]})})]})},pSe=e=>{const A=["left","bottom","right","top"],{pin_count:t,pn:i,w:o,h:n,p:s,pl:r}=e,a=t/4,g=A[Math.floor((i-1)/a)],c=(i-1)%a,I=s*(a-1),l=s*(a-1),B=-r/2;switch(g){case"left":return{x:-o/2-B,y:l/2-c*s,o:"vert"};case"bottom":return{x:-I/2+c*s,y:-n/2-B,o:"horz"};case"right":return{x:o/2+B,y:-l/2+c*s,o:"vert"};case"top":return{x:I/2-c*s,y:n/2+B,o:"horz"};default:throw new Error("Invalid pin number")}},fSe=({num_pins:e,cw:A,ccw:t,startingpin:i})=>{const o=[],n=e/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=n:r.bottomside&&r.leftpin?s=n+1:r.bottomside&&r.rightpin?s=n*2:r.rightside&&r.bottompin?s=n*2+1:r.rightside&&r.toppin?s=n*3:r.topside&&r.rightpin?s=n*3+1:r.topside&&r.leftpin&&(s=n*4),o.push(-1);for(let a=0;a<e;a++)o[s]=a+1,s++,s>e&&(s=1);return o},ySe=({num_pins:e=16,bodyWidth:A=9,bodyLength:t=9,bodyThickness:i=.8,thermalPadSize:o,padWidth:n=.25,padLength:s=.25,pitch:r=.5,thermalPadThickness:a=.05})=>{const g=fSe({num_pins:e,cw:!0,ccw:!0}),c=[];for(let I=0;I<e;I++){const{x:l,y:B,o:C}=pSe({pin_count:e,pn:I+1,w:A,h:t,p:r,pl:s});let E=n,Q=s;C==="vert"&&([E,Q]=[Q,E]);const h=g[I+1];c.push({pn:h,x:l,y:B,pw:E,pl:Q})}return We(Xo,{children:[tt(Fs,{color:"grey",children:tt(ue,{center:{x:0,y:0,z:i/2},size:[A,t,i]})}),c.map((I,l)=>tt(ue,{center:{x:I.x,y:I.y,z:a/2},size:[I.pw,I.pl,a]})),o?.length!==void 0&&o?.width!==void 0&&tt(ue,{center:{x:0,y:0,z:a/2},size:[o.width,o.length,a]})]})},mSe=ySe,wSe=()=>{const a=1.1999999999999997;return We(Xo,{children:[tt(tn,{rotation:Math.PI,position:{x:2.8/2+a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),tt(tn,{rotation:Math.PI,position:{x:2.8/2+a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),tt(tn,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),tt(tn,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),tt(tn,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),tt(aB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},DSe=wSe,SSe=({fullWidth:e=2.9,fullLength:A=2.8})=>{const c=(e-1.92)/2+.3;return We(Xo,{children:[tt(tn,{rotation:Math.PI,position:{x:e/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),tt(tn,{position:{x:-e/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),tt(tn,{position:{x:-e/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),tt(aB,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},wEA=.6,DEA=.3,tv=.33,BH=.1,bSe=wEA-BH*2,UXA=({color:e="#333"})=>We(Xo,{children:[tt(ue,{size:[bSe,DEA,tv],offset:[0,0,tv/2],color:e}),tt(ue,{size:[BH,DEA,tv],offset:[wEA/2-BH/2,0,tv/2],color:"#ccc"}),tt(ue,{size:[BH,DEA,tv],offset:[-wEA/2+BH/2,0,tv/2],color:"#ccc"})]}),SEA=.4,bEA=.2,ev=.13,CH=.07,_Se=SEA-CH*2,HXA=({color:e="#333"})=>We(Xo,{children:[tt(ue,{size:[_Se,bEA,ev],offset:[0,0,ev/2],color:e}),tt(ue,{size:[CH,bEA,ev],offset:[SEA/2-CH/2,0,ev/2],color:"#ccc"}),tt(ue,{size:[CH,bEA,ev],offset:[-SEA/2+CH/2,0,ev/2],color:"#ccc"})]}),_EA=3.2,xEA=1.6,iv=.9,QH=.5,xSe=_EA-QH*2,YXA=({color:e="#333"})=>We(Xo,{children:[tt(ue,{size:[xSe,xEA,iv],offset:[0,0,iv/2],color:e}),tt(ue,{size:[QH,xEA,iv],offset:[_EA/2-QH/2,0,iv/2],color:"#ccc"}),tt(ue,{size:[QH,xEA,iv],offset:[-_EA/2+QH/2,0,iv/2],color:"#ccc"})]}),kEA=3.2,FEA=2.5,ov=1,EH=.6,kSe=kEA-EH*2,JXA=({color:e="#333"})=>We(Xo,{children:[tt(ue,{size:[kSe,FEA,ov],offset:[0,0,ov/2],color:e}),tt(ue,{size:[EH,FEA,ov],offset:[kEA/2-EH/2,0,ov/2],color:"#ccc"}),tt(ue,{size:[EH,FEA,ov],offset:[-kEA/2+EH/2,0,ov/2],color:"#ccc"})]}),GEA=5,REA=2.5,nv=1.4,hH=.6,FSe=GEA-hH*2,TXA=({color:e="#333"})=>We(Xo,{children:[tt(ue,{size:[FSe,REA,nv],offset:[0,0,nv/2],color:e}),tt(ue,{size:[hH,REA,nv],offset:[GEA/2-hH/2,0,nv/2],color:"#ccc"}),tt(ue,{size:[hH,REA,nv],offset:[-GEA/2+hH/2,0,nv/2],color:"#ccc"})]}),MEA=6.3,NEA=3.2,sv=1.8,uH=.8,GSe=MEA-uH*2,KXA=({color:e="#333"})=>We(Xo,{children:[tt(ue,{size:[GSe,NEA,sv],offset:[0,0,sv/2],color:e}),tt(ue,{size:[uH,NEA,sv],offset:[MEA/2-uH/2,0,sv/2],color:"#ccc"}),tt(ue,{size:[uH,NEA,sv],offset:[-MEA/2+uH/2,0,sv/2],color:"#ccc"})]}),RSe=({numberOfPins:e,pitch:A=2.54,legsLength:t=3,outerDiameter:i=.945,innerDiameter:o=.945,rows:n=1})=>{const s=o/1.5,r=s*2+i,a=5,g=Math.ceil(e/n),c=2.54,I=(g-1)*A+i+A/2,l=n>1?(n-1)*c+r:r,B=s*1.6,C=-((g-1)/2)*A,E=n>1?-((n-1)*c)/2:0,Q=tt(Fs,{color:"#1a1a1a",children:We(VF,{children:[tt(ue,{color:"#000",size:[I,l,a],center:[0,E,a/2]}),Array.from({length:e},(h,u)=>{const d=Math.floor(u/g),f=u%g,m=C+f*A,D=-d*c;return o?tt(If,{height:a+.1,radius:o/2,center:[m,D,a/2],color:"#222"},u):tt(ue,{size:[B,B,a],center:[m,D,a/2]},u)})]})});return We(Xo,{children:[Q,Array.from({length:e},(h,u)=>{const d=Math.floor(u/g),f=u%g,m=C+f*A,D=-d*c;return We(Fs,{color:"silver",children:[We(pc,{children:[tt(ue,{color:"silver",size:[s,s,t*.9],center:[m,D,-t/2*.9]}),tt(ue,{color:"silver",size:[s/1.8,s/1.8,t],center:[m,D,-t/2]})]}),tt(ue,{color:"silver",size:[B,B,B*.5],center:[m,D,B/2*.5]})]},u)})]})},MSe=({width:e,length:A,innerDiameter:t=1})=>{const i=e,o=A,n=e*.7,s=t/2.5;return We(Xo,{children:[tt(aH,{color:"#1a1a1f",center:[0,0,n/2],size:[o,o,n],roundRadius:.3}),tt(aH,{color:"#f2f2f2",center:[0,0,n+n*.1/2.5],size:[o,o,n*.1],roundRadius:.14}),tt(If,{color:"#1a1a1f",height:n*.8,radius:i/3,center:[0,0,n+n*.8/2]}),tt(If,{color:"#1a1a1f",height:n*.2,radius:t/2,center:[o/3,o/3,n+n*.1/2]}),tt(If,{color:"#1a1a1f",height:n*.2,radius:t/2,center:[-o/3,-o/3,n+n*.1/2]}),tt(If,{color:"#1a1a1f",height:n*.2,radius:t/2,center:[-o/3,o/3,n+n*.1/2]}),tt(If,{color:"#1a1a1f",height:n*.2,radius:t/2,center:[o/3,-o/3,n+n*.1/2]}),tt(QW,{thickness:t/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:-o/2,z:-n*1.2}}),tt(QW,{thickness:t/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),tt(QW,{thickness:t/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),tt(QW,{thickness:t/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2+t/3.6,y:-o/2,z:-n*1.2}})]})},QW=e=>{const{thickness:A,width:t,horizontalLength:i,verticalLength:o,rotation:n=0,position:s}=e,r=[[0,i],[-o/3,i/3],[-o/5,i/4],[0,0]],a=hEA(r,A);return tt(Fs,{color:"#f2f2f2",children:tt(eo,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:tt(GQ,{rotation:[0,55,n],children:tt(cH,{height:t,children:tt(gH,{points:a.map(g=>[g.y,g.x])})})})})})},NSe=({pinCount:e,leadLength:A,leadWidth:t,pitch:i,bodyWidth:o})=>{const n=Math.ceil(e/2),s=(n-1)*i/2,r=.25,a=1,g=.8,c=A*0,I=i*(n-1)+t+.2,l=o*.55;return We(Xo,{children:[Array.from({length:n}).map((B,C)=>tt(tn,{position:{x:-o/2-c,y:C*i-s,z:r/2},width:t,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:n}).map((B,C)=>tt(tn,{rotation:Math.PI,position:{x:o/2+c,y:C*i-s,z:r/2},width:t,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),tt(aB,{center:{x:0,y:0,z:r/2},width:l,length:I,height:a})]})},vSe=({pinCount:e,pitch:A,leadWidth:t,leadLength:i,bodyWidth:o,bodyLength:n})=>{const s=e===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},r=isNaN(parseFloat(A))?s.pitch:parseFloat(A),a=isNaN(parseFloat(t))?s.leadWidth:parseFloat(t)*.8,g=isNaN(parseFloat(o))?2.6:parseFloat(o)*.8,c=isNaN(parseFloat(n))?2+Number(r)*1.4:parseFloat(n),I=e/2,l=(I-1)*r/2,B=.15,C=.8,E=4.5,Q=(E-g)/2,h=Q*.5;return We(Xo,{children:[Array.from({length:I}).map((u,d)=>tt(tn,{position:{x:-E/2,y:l-d*r,z:B/2},width:a,thickness:B,padContactLength:h+.05,bodyDistance:Q+.1,height:C})),Array.from({length:I}).map((u,d)=>tt(tn,{rotation:Math.PI,position:{x:E/2,y:l-d*r,z:B/2},width:a,thickness:B,padContactLength:h+.05,bodyDistance:Q+.1,height:C})),tt(aB,{center:{x:0,y:0,z:B/2},width:g,length:c,height:1})]})},LSe=()=>We(Xo,{children:[tt(ue,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),tt(ue,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),tt(Fs,{color:"#222",children:We(xE,{children:[tt(eo,{z:.3/2,children:tt(ue,{size:[1.65,.8,.3]})}),We(pc,{children:[tt(eo,{z:.3,children:tt(ue,{size:[1.65,.8,.01]})}),tt(eo,{z:.6,children:tt(ue,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),USe=()=>We(Xo,{children:[tt(ue,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),tt(ue,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),tt(Fs,{color:"#222",children:tt(eo,{z:.47/2+.02,children:tt(ue,{size:[.98,.58,.47]})})}),tt(ue,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),tt(ue,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),tt(ue,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),tt(ue,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),HSe=()=>{const g=tt(Fs,{color:"#1a1a1a",children:We(xE,{children:[We(pc,{children:[tt(eo,{z:.13,children:tt(ue,{size:[4,3,.03]})}),tt(eo,{z:1.15,children:tt(ue,{size:[4.4,3.4,.01]})})]}),We(pc,{children:[tt(eo,{z:1.15,children:tt(ue,{size:[4.4,3.4,.01]})}),tt(eo,{z:2.3,children:tt(ue,{size:[4,3,.01]})})]})]})}),c=({xDir:I})=>{const C=I*1.78,E=I*(3.4/2-.2/2+1),Q=I*(3.4/2-.2/2),h=Math.abs(Q-E),u=(E+Q)/2;return tt(Fs,{color:"#c0c0c0",children:We(xE,{children:[tt(ue,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),tt(ue,{size:[.2,1.45,1.14],center:[E,0,1.14/2+.2]}),tt(ue,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return We(Xo,{children:[tt(c,{xDir:1}),tt(c,{xDir:-1}),g]})},YSe=()=>{const g=tt(Fs,{color:"#1a1a1a",children:We(xE,{children:[We(pc,{children:[tt(eo,{z:.13,children:tt(ue,{size:[4,3,.03]})}),tt(eo,{z:1.15,children:tt(ue,{size:[4.4,3.4,.01]})})]}),We(pc,{children:[tt(eo,{z:1.15,children:tt(ue,{size:[4.4,3.4,.01]})}),tt(eo,{z:2.3,children:tt(ue,{size:[4,3,.01]})})]})]})}),c=({xDir:I})=>{const C=I*1.78,E=I*(3.4/2-.2/2+1),Q=I*(3.4/2-.2/2),h=Math.abs(Q-E),u=(E+Q)/2;return tt(Fs,{color:"#c0c0c0",children:We(xE,{children:[tt(ue,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),tt(ue,{size:[.2,1.45,1.14],center:[E,0,1.14/2+.2]}),tt(ue,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return We(Xo,{children:[tt(c,{xDir:1}),tt(c,{xDir:-1}),g]})},JSe=()=>{const g=tt(Fs,{color:"#1a1a1a",children:We(xE,{children:[We(pc,{children:[tt(eo,{z:.21000000000000002,children:tt(ue,{size:[6.3999999999999995,5.6,.03]})}),tt(eo,{z:1.15,children:tt(ue,{size:[6.8,6,.01]})})]}),We(pc,{children:[tt(eo,{z:1.15,children:tt(ue,{size:[6.8,6,.01]})}),tt(eo,{z:2.3,children:tt(ue,{size:[6.3999999999999995,5.6,.01]})})]})]})}),c=({xDir:I})=>{const C=I*3.08,E=I*(6/2-.2/2+1),Q=I*(6/2-.2/2),h=Math.abs(Q-E),u=(E+Q)/2;return tt(Fs,{color:"#c0c0c0",children:We(xE,{children:[tt(ue,{size:[2.3*.8,2.95,.2],center:[C,0,.2/2]}),tt(ue,{size:[.2,2.95,1.14],center:[E,0,1.14/2+.2]}),tt(ue,{size:[h,2.95,.2],center:[u,0,.2/2+1.14]})]})})};return We(Xo,{children:[tt(c,{xDir:1}),tt(c,{xDir:-1}),g]})},TSe=()=>{const I=tt(Fs,{color:"#222",children:We(xE,{children:[tt(eo,{z:.27,children:tt(ue,{size:[2.9,1.9,.54]})}),We(pc,{children:[tt(eo,{z:.54,children:tt(ue,{size:[2.9,1.9,.01]})}),tt(eo,{z:1.08,children:tt(ue,{size:[2.6999999999999997,1.7,.01]})})]})]})});return We(Xo,{children:[tt(ue,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),tt(ue,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),I]})},KSe=()=>We(Xo,{children:[tt(ue,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),tt(ue,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),tt(Fs,{color:"#222",children:We(xE,{children:[tt(eo,{z:.55/2,children:tt(ue,{size:[2.7,1.6,.55]})}),We(pc,{children:[tt(eo,{z:.55,children:tt(ue,{size:[2.7,1.6,.01]})}),tt(eo,{z:1.1,children:tt(ue,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),PSe=()=>We(Xo,{children:[tt(ue,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),tt(ue,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),tt(Fs,{color:"#222",children:We(xE,{children:[tt(eo,{z:.2/2,children:tt(ue,{size:[2.75,1.8,.2]})}),We(pc,{children:[tt(eo,{z:.2,children:tt(ue,{size:[2.75,1.8,.01]})}),tt(eo,{z:1,children:tt(ue,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),tt(ue,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),qSe=()=>We(Xo,{children:[tt(ue,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),tt(ue,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),tt(Fs,{color:"#222",children:We(xE,{children:[We(pc,{children:[tt(eo,{z:.2,children:tt(ue,{size:[2.6-.1/2,1.7-.1/2,.01]})}),tt(eo,{z:.01,children:tt(ue,{size:[2.6-.1,1.7-.1,.01]})})]}),We(pc,{children:[tt(eo,{z:.2,children:tt(ue,{size:[2.6,1.7,.01]})}),tt(eo,{z:1,children:tt(ue,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),tt(ue,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),OSe=()=>We(Xo,{children:[tt(ue,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),tt(ue,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),tt(Fs,{color:"#222",children:We(xE,{children:[We(pc,{children:[tt(eo,{z:.2,children:tt(ue,{size:[3.8-.05/2,2.5-.05/2,.01]})}),tt(eo,{z:.01,children:tt(ue,{size:[3.8-.05,2.5-.05,.01]})})]}),We(pc,{children:[tt(eo,{z:.2,children:tt(ue,{size:[3.8,2.5,.01]})}),tt(eo,{z:1,children:tt(ue,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),tt(ue,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),WSe=()=>We(Xo,{children:[tt(ue,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),tt(ue,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),tt(Fs,{color:"#222",children:We(xE,{children:[tt(eo,{z:.14/2,children:tt(ue,{size:[.8,.6,.14]})}),We(pc,{children:[tt(eo,{z:.14,children:tt(ue,{size:[.8,.6,.01]})}),tt(eo,{z:.37,children:tt(ue,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),ZSe=()=>{const c=3.0999999999999996;return We(Xo,{children:[tt(tn,{rotation:Math.PI,position:{x:6.6/2+c/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),tt(tn,{position:{x:-6.6/2-c/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),tt(tn,{position:{x:-6.6/2-c/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),tt(tn,{position:{x:-6.6/2-c/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),tt(aB,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},VSe=()=>We(Xo,{children:[Array.from({length:16}).map((B,C)=>tt(tn,{position:{x:-10.5/2,y:C*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((B,C)=>tt(tn,{rotation:Math.PI,position:{x:10.5/2,y:C*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((B,C)=>tt(tn,{rotation:Math.PI/2,position:{x:C*.5-3.75,y:-10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((B,C)=>tt(tn,{rotation:-Math.PI/2,position:{x:C*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),tt(aB,{center:{x:0,y:0,z:0},width:9,length:9,height:1.2,chamferSize:.7,taperRatio:.05,notchPosition:{x:-3.5,y:3.5,z:1.2},notchRadius:1.2/2})]}),jSe=VSe,zSe=()=>{const g=.7999999999999998;return We(Xo,{children:[tt(tn,{rotation:Math.PI,position:{x:2.05/2+g/4,y:0,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),tt(tn,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),tt(tn,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),tt(aB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},XSe=({pinCount:e,pitch:A,leadWidth:t,padContactLength:i,bodyWidth:o})=>{const n=e/4;if(n!==Math.floor(n))throw new Error(`LQFP pinCount must be divisible by 4, got ${e}`);A||(A=.5),i||(i=.6),t||(t=.22),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+3.3*i,g=a,c=.8,I=.2,l=(g-o)/2+.4;return We(Xo,{children:[Array.from({length:n}).map((B,C)=>tt(tn,{position:{x:-g/2-.36,y:C*A-r,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:n}).map((B,C)=>tt(tn,{rotation:Math.PI,position:{x:g/2+.36,y:C*A-r,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:n}).map((B,C)=>tt(tn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.36,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:n}).map((B,C)=>tt(tn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.36,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),tt(aB,{center:{x:0,y:0,z:0},width:o,length:s,height:1.5,heightAboveSurface:.1,taperRatio:.04,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:s/2-1.5,z:1.5},notchRadius:1.5/2})]})},$Se=()=>{const i=.20900000000000002,o=.1,n=.3,s=.1,r=.2;return We(Xo,{children:[tt(Fs,{color:"#222",children:We(xE,{children:[tt(ue,{size:[.85,1.2,i],center:[0,0,i/2]}),We(pc,{children:[tt(eo,{z:i,children:tt(ue,{size:[.85,1.2,.01]})}),tt(eo,{z:.38,children:tt(ue,{size:[.85-o,1.2-o,.01]})})]})]})}),tt(ue,{color:"#ccc",size:[n,.25,s],center:[.55,0,s/2]}),tt(ue,{color:"#ccc",size:[n,r,s],center:[-.55,.4,s/2]}),tt(ue,{color:"#ccc",size:[n,r,s],center:[-.55,-.4,s/2]})]})},Abe=({num_pins:e,bodyWidth:A=5.3,bodyLength:t=5.3,bodyThickness:i=1,thermalPadSize:o,padWidth:n=t/5.3*.6,padLength:s=t/5.3*1,pitch:r=.5,thermalPadThickness:a=.2})=>{const g=[],c=Math.floor(e/2),I=r*(c-1);for(let l=0;l<e;l++){const B=l<c?"left":"right",C=l%c,E=I/2-C*r,Q=s,h=n,u=B==="left"?-A/2+Q/2:A/2-Q/2,d=l+1;g.push({pinNumber:d,x:u,y:E,padSizeX:Q,padSizeY:h})}return We(Xo,{children:[tt(aB,{center:{x:0,y:0,z:0},width:A,length:t,height:i,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(A/2-s),y:t/2-s,z:i}}),g.map((l,B)=>tt(ue,{center:[l.x,l.y,a/2],size:[l.padSizeX,l.padSizeY,a]})),o?.length!==void 0&&o?.width!==void 0&&tt(ue,{center:[0,0,a/2],size:[o.width,o.length,a]})]})},tbe=({bodyLength:e=10.2,bodyWidth:A=4.65,bodyHeight:t=13.46,leadSpacing:i=5,leadDiameter:o=.8,leadLength:n=12.7,color:s="#ddd",leadColor:r="#b87333"})=>{const a=e/2,g=A/2,c=a-g,I=i/2,l=.85;return We(Xo,{children:[We(Fs,{color:s,children:[We(pc,{children:[tt(lf,{height:t,roundRadius:.5,radius:g,center:[-c,0,t]}),tt(lf,{height:t,roundRadius:.5,radius:g,center:[c,0,t]})]}),We(pc,{children:[tt(lf,{height:l,roundRadius:.1,radius:g+.85,center:[-c,0,t/2+l/2]}),tt(lf,{height:l,roundRadius:.1,radius:g+.85,center:[c,0,t/2+l/2]})]})]}),We(Fs,{color:r,children:[tt(If,{height:n+t/2,radius:o/2,center:[-I+.06,0,-(n/2)+t/2]}),tt(If,{height:n+t/2,radius:o/2,center:[I-.06,0,-(n/2)+t/2]})]})]})},ebe=({bodyLength:e=1.4,bodyDiameter:A=1.1,color:t="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:o="#111"})=>We(Xo,{children:[tt(Fs,{color:t,children:We(GQ,{rotation:[0,"90deg",0],children:[tt(aH,{size:[A,A,e-.2],roundRadius:.2,center:[-A/2,0,.05]}),tt(If,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-e/2+.2/2]})]})}),tt(Fs,{color:o,children:tt(GQ,{rotation:[0,"90deg",0],children:tt(aH,{size:[A*1.01,A*1.01,e/3],roundRadius:.2,center:[-A/2,0,-e/4+.1]})})}),tt(Fs,{color:i,children:tt(GQ,{rotation:[0,"90deg",0],children:tt(lf,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-e/2]})})}),tt(Fs,{color:i,children:tt(GQ,{rotation:[0,"90deg",0],children:tt(lf,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,e/2]})})})]}),ibe=({bodyLength:e=3.5,bodyDiameter:A=1.5,color:t="#3a3a3aff",contactColor:i="#c6c6c6"})=>We(Xo,{children:[tt(Fs,{color:t,children:tt(GQ,{rotation:[0,"90deg",0],children:tt(lf,{height:e,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),tt(Fs,{color:i,children:tt(GQ,{rotation:[0,"90deg",0],children:tt(lf,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-e/2]})})}),tt(Fs,{color:i,children:tt(GQ,{rotation:[0,"90deg",0],children:tt(lf,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,e/2]})})})]}),obe=({bodyLength:e=3.9,bodyDiameter:A=2.5,color:t="#3a3a3aff",contactColor:i="#c6c6c6"})=>We(Xo,{children:[tt(Fs,{color:t,children:tt(GQ,{rotation:[0,"90deg",0],children:tt(lf,{height:e,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),tt(Fs,{color:i,children:tt(GQ,{rotation:[0,"90deg",0],children:tt(lf,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-e/2]})})}),tt(Fs,{color:i,children:tt(GQ,{rotation:[0,"90deg",0],children:tt(lf,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,e/2]})})})]}),nbe=({pinCount:e,padContactLength:A=.6,leadWidth:t=.41,pitch:i=1.27})=>{if(e%2!==0)throw new Error("MS012 pinCount must be even");const o=e/2,n=4.9,s=3.9,r=(o-1)*i/2,a=.2;return We(Xo,{children:[Array.from({length:o}).map((g,c)=>tt(tn,{position:{x:-s/2-A-.3,y:c*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,c)=>tt(tn,{rotation:Math.PI,position:{x:s/2+A+.3,y:c*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),tt(aB,{center:{x:0,y:0,z:a/2},width:s,length:n,height:1.55,notchPosition:{x:-.95,y:n/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},sbe=({pinCount:e=16,padContactLength:A=.6,leadWidth:t=.41,pitch:i=1.27})=>{if(e!==16)throw new Error("MS013 only supports 16 pins");const o=e/2,n=7.5,s=10.3,r=(o-1)*i/2,a=.2;return We(Xo,{children:[Array.from({length:o}).map((g,c)=>tt(tn,{position:{x:-n/2-A-.3,y:c*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,c)=>tt(tn,{rotation:Math.PI,position:{x:n/2+A+.3,y:c*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),tt(aB,{center:{x:0,y:0,z:a/2},width:n,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},rbe=()=>{const E=7.050000000000001,Q=24.95+6.5/2;return tt(eo,{center:[0,0,1],children:We(Xo,{children:[We(GQ,{rotation:[0,55,-55],children:[We(VF,{children:[tt(ue,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[Q,0,1.3-2]}),tt(If,{color:"black",center:[Q,0,1.3-2],radius:3/2,height:1.3*1.2})]}),tt(Fs,{color:"#222",children:tt(aB,{width:9.9,length:9.9,height:4.5,center:{x:20,y:0,z:-2.4},includeNotch:!1,straightHeightRatio:.3,taperRatio:.04,heightAboveSurface:1})})]}),tt(GQ,{rotation:[0,55,55],children:Array.from({length:3}).map((h,u)=>{const d=E,f=(u-1)*2.7,m=-.5-.6;return We(Fs,{color:"gold",children:[We(pc,{children:[tt(eo,{center:[15.05-4.5/2+.1,f,m],children:tt(ue,{size:[4.5,.81+1,.5]})}),tt(eo,{center:[15.05-4.5/2-1+.1,f,m],children:tt(ue,{size:[4.5,.81,.5]})})]}),tt(eo,{center:[d,f,m],children:tt(ue,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},abe=()=>{const g=1.1999999999999997;return We(Xo,{children:[tt(tn,{rotation:Math.PI,position:{x:2.8/2+g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),tt(tn,{rotation:Math.PI,position:{x:2.8/2+g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),tt(tn,{rotation:Math.PI,position:{x:2.8/2+g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),tt(tn,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),tt(tn,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),tt(tn,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),tt(aB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2,straightHeightRatio:.6,notchPosition:{x:-.4,y:1.2/2+.4,z:1.2+.05},notchRadius:.1})]})},gbe=()=>We(Xo,{children:[tt(aB,{center:{x:0,y:0,z:0},width:.8,length:1,height:.37,heightAboveSurface:0,color:"#1a1a1a",taperRatio:.15,straightHeightRatio:0,notchPosition:{x:-.8/4,y:.7/2.2,z:.37+.1}}),[0,1,2].map(g=>{const c=-.35+g*.35;return tt(ue,{center:[-.8/2+.19/2-.1,c,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(g=>{const c=-.35+g*.35;return tt(ue,{center:[.8/2-.19/2+.1,c,.12/2],size:[.19,.15,.12]})})]}),cbe=()=>{const s="#222",a=[.43,.4,1.32],g=[.43,.4,.25],c=[0,0,-.66],I=[0,0,-1.32],l=[0,1.28,-2.72],B=[0,1.28,-8.9],C=-7.5;return We(eo,{center:[0,1,10.5],children:[tt(Fs,{color:s,children:We(VF,{children:[tt(eo,{center:[0,0,2.25],children:tt(If,{radius:2.4,height:4.5})}),tt(eo,{center:[0,-1.8499999999999999,2.25],children:tt(ue,{size:[2.4*2,1.1,4.5+.2]})})]})}),tt(eo,{center:c,children:tt(ue,{size:a})}),We(pc,{children:[tt(eo,{center:I,children:tt(ue,{size:g})}),tt(eo,{center:l,children:tt(ue,{size:g})})]}),tt(eo,{center:B,children:tt(ue,{size:[.43,.4,12.2]})}),tt(eo,{center:[1.3,0,C],children:tt(ue,{size:[.43,.4,15]})}),tt(eo,{center:[-1.3,0,C],children:tt(ue,{size:[.43,.4,15]})})]})},Ibe=()=>We(Xo,{children:[tt(tn,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),tt(tn,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),tt(tn,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),tt(tn,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),tt(tn,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),tt(tn,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),tt(aB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:1.1,straightHeightRatio:.6,notchPosition:{x:-.375,y:1.1/2+.2,z:1.1},heightAboveSurface:.1})]}),lbe=Ibe,Bbe=()=>We(Xo,{children:[tt(aB,{center:{x:0,y:0,z:.05},width:1,length:1.45,height:.5,heightAboveSurface:0,color:"#1a1a1a",taperRatio:0,includeNotch:!1}),[0,1,2].map(r=>{const a=-.5+r*.5;return tt(ue,{center:[-1/2+.3/2,a,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(r=>{const a=-.5+r*.5;return tt(ue,{center:[1/2-.3/2,a,.05/2],size:[.3,.2,.05]})})]}),Cbe=()=>We(Xo,{children:[tt(tn,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),tt(tn,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),tt(Fs,{color:"#222",children:tt(aB,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),tt(ue,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),Qbe=()=>We(Xo,{children:[tt(ue,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),tt(ue,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),tt(Fs,{color:"#222",children:We(xE,{children:[tt(eo,{z:.175/2,children:tt(ue,{size:[1.7,1.25,.175]})}),We(pc,{children:[tt(eo,{z:.175,children:tt(ue,{size:[1.7,1.25,.01]})}),tt(eo,{z:.725,children:tt(ue,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),tt(ue,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),Ebe=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return We(Xo,{children:[tt(ue,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),tt(ue,{color:"#ccc",size:[.4,.325,.13],center:[r,0,.13/2]}),tt(Fs,{color:"#222",children:tt(aB,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),tt(ue,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},hbe=({footprint:e})=>{const A=iSe.string(e).json();switch(A.fn){case"dip":return tt(aSe,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"tssop":return tt(cSe,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return tt(ISe,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return tt(vSe,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return tt(QSe,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return tt(jSe,{});case"lqfp":return tt(XSe,{pinCount:A.num_pins});case"qfn":{const o=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return tt(mSe,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:o?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"dfn":{const o=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return tt(Abe,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:o?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"pinrow":{const o=e.match(/_rows(\d+)/),n=o&&o[1]?parseInt(o[1],10):1;if(A.male)return tt(dSe,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:n});if(A.female)return tt(RSe,{numberOfPins:A.num_pins,pitch:A.p,rows:n})}case"cap":switch(A.imperial){case"0402":return tt(NXA,{color:"#856c4d"});case"0603":return tt(vXA,{color:"#856c4d"});case"0805":return tt(LXA,{color:"#856c4d"});case"0201":return tt(UXA,{color:"#856c4d"});case"01005":return tt(HXA,{color:"#856c4d"});case"1206":return tt(YXA,{color:"#856c4d"});case"1210":return tt(JXA,{color:"#856c4d"});case"2010":return tt(TXA,{color:"#856c4d"});case"2512":return tt(KXA,{color:"#856c4d"})}case"sot235":return tt(DSe,{});case"sot457":return tt(abe,{});case"sot223":return tt(ZSe,{});case"sot23w":return tt(SSe,{});case"sot323":return tt(zSe,{});case"sod323f":return tt(Qbe,{});case"sod323fl":return tt(Ebe,{});case"sot363":return tt(lbe,{});case"sot886":return tt(Bbe,{});case"sot963":return tt(gbe,{});case"pushbutton":return tt(MSe,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return tt(NSe,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return tt(LSe,{});case"sod882":return tt(USe,{});case"sma":return tt(HSe,{});case"smb":return tt(YSe,{});case"smc":return tt(JSe,{});case"smf":return tt(TSe,{});case"sod123f":return tt(KSe,{});case"sod123fl":return tt(PSe,{});case"sod123w":return tt(qSe,{});case"sod128":return tt(OSe,{});case"sod323":return tt(Cbe,{});case"sod923":return tt(WSe,{});case"hc49":return tt(tbe,{});case"micromelf":return tt(ebe,{});case"minimelf":return tt(ibe,{});case"melf":return tt(obe,{});case"ms012":return tt(nbe,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return tt(sbe,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return tt($Se,{});case"to220":return tt(rbe,{});case"to92":return tt(cbe,{})}const t=e.match(/_color\(([^)]+)\)/),i=t?t[1]:void 0;switch(A.imperial){case"0402":return tt(NXA,{color:i});case"0603":return tt(vXA,{color:i});case"0805":return tt(LXA,{color:i});case"0201":return tt(UXA,{color:i});case"01005":return tt(HXA,{color:i});case"1206":return tt(YXA,{color:i});case"1210":return tt(JXA,{color:i});case"2010":return tt(TXA,{color:i});case"2512":return tt(KXA,{color:i})}return null},ube=e=>e&&typeof e=="object"&&"type"in e,rv=e=>{if(typeof e=="number")return e;if(typeof e=="string"){const A=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(e);if(A)return parseFloat(A[1])*Math.PI/180;const t=Number(e);if(!Number.isNaN(t))return t}return 0},dbe=e=>Array.isArray(e)?[Number(e[0])||0,Number(e[1])||0,Number(e[2])||0]:typeof e=="object"&&e?[Number(e.x)||0,Number(e.y)||0,Number(e.z)||0]:[0,0,0];function rD(e,A,t){const{jscad:{primitives:i,booleans:o,hulls:n,geometries:s,extrusions:r,transforms:a}}=t;if(e==null||e===!1)return[];if(Array.isArray(e))return e.flatMap(l=>rD(l,A,t));if(!ube(e))return[];const{type:g,props:c,children:I}=e;if(g===FXA)return(I??[]).flatMap(l=>rD(l,A,t));if(g===Fs){const l=c?.color;return(I??[]).flatMap(B=>rD(B,l??A,t))}if(g===eo){const l=dbe(c?.offset??c?.center??{x:c?.x,y:c?.y,z:c?.z});return(I??[]).flatMap(C=>rD(C,A,t)).map(({geom:C,color:E})=>({geom:a.translate(l,C),color:E??A}))}if(g===GQ){const l=Array.isArray(c?.rotation)?[rv(c.rotation[0]),rv(c.rotation[1]),rv(c.rotation[2])]:[rv(c?.x??0),rv(c?.y??0),rv(c?.z??0)];return(I??[]).flatMap(C=>rD(C,A,t)).map(({geom:C,color:E})=>({geom:a.rotateZ(l[2],a.rotateY(l[1],a.rotateX(l[0],C))),color:E}))}if(g===xE||g===VF||g===pc){const l=(I??[]).flatMap(C=>rD(C,A,t)).map(C=>C.geom);if(l.length===0)return[];let B;return g===xE?B=o.union(l):g===VF?B=o.subtract(l[0],l.slice(1)):B=n.hull(l),[{geom:B,color:A}]}if(g===gH){const l=c?.points??[];return[{geom:s.geom2.fromPoints(l),color:A??c?.color}]}if(g===cH){const l=(I??[]).flatMap(Q=>rD(Q,A,t)).map(Q=>Q.geom);if(l.length===0)return[];const B=l.length>1?o.union(l):l[0],C=c?.height??c?.h??1;let E=r.extrudeLinear({height:C},B);if(E.polygons)for(const Q of E.polygons)!Q.plane||!Q.vertices||Q.vertices.length<3||Q.vertices.reverse();return[{geom:E,color:A??c?.color}]}if(g===ue||g===GXA||g===If||g===RXA||g===aH||g===lf){let l;if(g===ue){const B=c?.size??[1,1,1],C=c?.offset,E=c?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);l=i.cuboid({size:B,center:E})}else if(g===GXA){const B=c?.size??1,C=c?.offset,E=c?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);l=i.cube({size:B,center:E})}else if(g===If){const B=c?.height??1,C=c?.radius??1,E=c?.center??[0,0,0];l=i.cylinder({height:B,radius:C,center:E})}else if(g===RXA){const B=c?.radius??1,C=c?.center??[0,0,0];l=i.sphere({radius:B,center:C})}else if(g===lf){const B=c?.height??1,C=c?.radius??1,E=c?.roundRadius??.1,Q=c?.center??[0,0,0];l=i.roundedCylinder({height:B,radius:C,roundRadius:E,center:Q})}else{const B=c?.size??[1,1,1],C=c?.roundRadius??.1,E=c?.center??[0,0,0];l=i.roundedCuboid({size:B,roundRadius:C,center:E})}return[{geom:l,color:A??c?.color}]}if(typeof g=="function"){const l=g(c??{});return rD(l,A,t)}return(I??[]).flatMap(l=>rD(l,A,t))}function pbe(e,A){return{geometries:rD(e,void 0,{jscad:A})}}function PXA(e){if(e.polygons){const A=[],t=[],i=[];let o=0;for(const s of e.polygons){for(const a of s.vertices)a.index=o,A.push(a[0],a[1],a[2]),e.color&&e.color.length>=3?i.push(e.color[0],e.color[1],e.color[2]):i.push(1,1,1),o++;const r=s.vertices[0].index;for(let a=2;a<s.vertices.length;a++){const g=s.vertices[a-1].index,c=s.vertices[a].index;t.push(r,g,c)}}const n=new Dg;if(n.setAttribute("position",new hc(new Float32Array(A),3)),n.setIndex(t),i.length>0&&n.setAttribute("color",new hc(new Float32Array(i),3)),e.transforms){const s=new gs;s.fromArray(e.transforms),n.applyMatrix4(s)}return n.computeVertexNormals(),n}if(e.sides){const A=[],t=[];for(const o of e.sides)A.push(o[0][0],o[0][1],0),e.color&&e.color.length>=3?t.push(e.color[0],e.color[1],e.color[2]):t.push(1,1,1);const i=new Dg;if(i.setAttribute("position",new hc(new Float32Array(A),3)),t.length>0&&i.setAttribute("color",new hc(new Float32Array(t),3)),e.transforms){const o=new gs;o.fromArray(e.transforms),i.applyMatrix4(o)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Dg}function fbe(e,A){const t=EEA(hbe,{footprint:e});return pbe(t,A)}var ybe=Or(iW()),qXA=AA.createContext(null),mbe=()=>{const e=AA.useContext(qXA);if(!e)throw new Error("useHover must be used within a HoverProvider");return e},wbe=({children:e})=>{const{camera:A,renderer:t}=Ku(),[i,o]=AA.useState([]),n=AA.useMemo(()=>new NRt,[]),s=AA.useMemo(()=>new ho,[]),r=AA.useRef(i);r.current=i;const a=AA.useRef(null),g=AA.useCallback(C=>{o(E=>[...E,C])},[]),c=AA.useCallback(C=>{if(a.current){let E=!1,Q=a.current.object;for(;Q;){if(Q===C){E=!0;break}Q=Q.parent}E&&(a.current.onUnhover(),a.current=null)}o(E=>E.filter(Q=>Q.object!==C))},[]),I=AA.useCallback(C=>{let E=C;for(;E;){const Q=r.current.find(h=>h.object===E);if(Q)return Q;E=E.parent}},[]),l=AA.useCallback(C=>{if(!t.domElement)return;const E=t.domElement.getBoundingClientRect();s.x=(C.clientX-E.left)/E.width*2-1,s.y=-((C.clientY-E.top)/E.height)*2+1,n.setFromCamera(s,A);const Q=r.current.map(u=>u.object);if(Q.length===0){a.current&&(a.current.onUnhover(),a.current=null);return}const h=n.intersectObjects(Q,!0);if(h.length>0){const u=h[0],d=I(u.object);if(d){const f={mousePosition:[u.point.x,u.point.y,u.point.z]};a.current!==d?(a.current?.onUnhover(),d.onHover(f),a.current=d):d.onHover(f)}else a.current&&(a.current.onUnhover(),a.current=null)}else a.current&&(a.current.onUnhover(),a.current=null)},[A,t,n,s,I]);AA.useEffect(()=>{const C=t.domElement;return C.addEventListener("mousemove",l),()=>{C.removeEventListener("mousemove",l)}},[t,l]);const B=AA.useMemo(()=>({addHoverable:g,removeHoverable:c}),[g,c]);return Z.jsx(qXA.Provider,{value:B,children:e})},Dbe=({children:e,object:A,onHover:t,onUnhover:i,isHovered:o})=>{const{addHoverable:n,removeHoverable:s}=mbe();return AA.useEffect(()=>A?(n({object:A,onHover:t,onUnhover:i}),()=>{s(A)}):void 0,[A,t,i,n,s]),Z.jsx(Z.Fragment,{children:e})},dH=Dbe,Sbe=({positionOffset:e,footprint:A,rotationOffset:t,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=Ku(),g=AA.useMemo(()=>{if(!A)return null;const{geometries:c}=fbe(A,ybe),I=new ef;for(const l of c.flat(1/0)){const B=l.geom;if(!B||!B.polygons&&!B.sides)continue;const C=new Pi(l.color);C.convertLinearToSRGB();const E={...B,color:[C.r,C.g,C.b]},Q=PXA(E),h=new mh({vertexColors:!0,side:jB,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new sn(Q,h);I.add(u)}return I},[A,r]);return AA.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),AA.useEffect(()=>{g&&(e&&g.position.fromArray(e),t&&g.rotation.fromArray(t),s!==void 0&&g.scale.setScalar(s))},[g,e?.[0],e?.[1],e?.[2],t?.[0],t?.[1],t?.[2],s]),AA.useEffect(()=>{g&&g.traverse(c=>{c instanceof sn&&c.material instanceof mh&&(n?(c.material.emissive.setHex(255),c.material.emissiveIntensity=.2):c.material.emissiveIntensity=0)})},[n,g]),g?Z.jsx(dH,{isHovered:n,onHover:i,onUnhover:o,object:g}):null},OXA=new WeakMap,bbe=()=>{const e=new ZI;return e.name="fallback-environment-map",e.mapping=WK,e},_be=e=>{if(!e)return null;const A=e,t=OXA.get(A);if(t)return t;let i;if(e instanceof DP){const o=new A7(e);i=o.fromScene(YNt(),.04).texture,o.dispose()}else i=bbe();return OXA.set(A,i),i},WXA=1.25;function ZXA({gltfUrl:e,position:A,rotation:t,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=Ku(),[c,I]=AA.useState(null),[l,B]=AA.useState(null);if(AA.useEffect(()=>{if(!e)return;const C=new TNt;let E=!0;return C.load(e,Q=>{if(!E)return;const h=Q.scene;h.traverse(u=>{if(u instanceof sn&&u.material){const d=f=>{f.transparent=r,f.opacity=r?.5:1,f.depthWrite=!r,f.needsUpdate=!0};Array.isArray(u.material)?u.material.forEach(d):d(u.material)}}),I(h)},void 0,Q=>{if(!E)return;console.error(`An error happened loading ${e}`,Q);const h=Q instanceof Error?Q:new Error(`Failed to load glTF model from ${e}`);B(h)}),()=>{E=!1}},[e,r]),AA.useEffect(()=>{c&&(A&&c.position.fromArray(A),t&&c.rotation.fromArray(t),s!==void 0&&c.scale.setScalar(s))},[c,A?.[0],A?.[1],A?.[2],t?.[0],t?.[1],t?.[2],s]),AA.useEffect(()=>{if(!(!g||!c))return g.add(c),()=>{g.remove(c)}},[g,c]),AA.useEffect(()=>{if(!c||!a)return;const C=_be(a);if(!C)return;const E=[],Q=h=>{h instanceof mh&&(E.push({material:h,envMap:h.envMap??null,envMapIntensity:h.envMapIntensity??1}),h.envMap=C,(typeof h.envMapIntensity!="number"||h.envMapIntensity<WXA)&&(h.envMapIntensity=WXA),h.needsUpdate=!0)};return c.traverse(h=>{if(!(h instanceof sn))return;const u=h.material;Array.isArray(u)?u.forEach(Q):u&&Q(u)}),()=>{E.forEach(({material:h,envMap:u,envMapIntensity:d})=>{h.envMap=u,h.envMapIntensity=d,h.needsUpdate=!0})}},[c,a]),AA.useEffect(()=>{c&&c.traverse(C=>{C instanceof sn&&C.material instanceof mh&&(n?(C.material.emissive.setHex(255),C.material.emissiveIntensity=.2):C.material.emissiveIntensity=0)})},[n,c]),l)throw l;return c?Z.jsx(dH,{isHovered:n,onHover:i,onUnhover:o,object:c}):null}var xbe=Or(pzA()),kbe=Or(iW()),Fbe=({jscadPlan:e,positionOffset:A,rotationOffset:t,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=Ku(),{threeGeom:g,material:c}=AA.useMemo(()=>{const l=(0,xbe.executeJscadOperations)(kbe.default,e);if(!l||!l.polygons&&!l.sides)return{threeGeom:null,material:null};const B=PXA(l),C=new mh({vertexColors:!0,side:jB,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:B,material:C}},[e,r]),I=AA.useMemo(()=>g?new sn(g,c):null,[g,c]);return AA.useEffect(()=>{if(!(!I||!a))return a.add(I),()=>{a.remove(I)}},[a,I]),AA.useEffect(()=>{I&&(A&&I.position.fromArray(A),t&&I.rotation.fromArray(t),s!==void 0&&I.scale.setScalar(s))},[I,A?.[0],A?.[1],A?.[2],t?.[0],t?.[1],t?.[2],s]),AA.useMemo(()=>{if(c)if(n){const l=new Pi(c.color.getHex());c.emissive.copy(l),c.emissive.setRGB(0,0,1),c.emissiveIntensity=.2}else c.emissiveIntensity=0},[n,c]),g?Z.jsx(dH,{isHovered:n,onHover:i,onUnhover:o,object:I}):null};function Gbe(e){return e.replace(/(DEF|USE)\s+([^\s]+)/g,(A,t,i)=>`${t} ${i.replace(/-/g,"_")}`)}async function Rbe(e){const A=await fetch(e);if(!A.ok)throw new Error(`Failed to fetch "${e}": ${A.status} ${A.statusText}`);const t=await A.text();return new bvt().parse(Gbe(t),e)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function Mbe(e){const[A,t]=AA.useState(null);return AA.useEffect(()=>{if(!e)return;const i=e.replace(/&cachebust_origin=$/,""),o=window.TSCIRCUIT_OBJ_LOADER_CACHE;let n=!1;async function s(){try{if(i.endsWith(".wrl"))return await Rbe(i);const a=await fetch(i);if(!a.ok)throw new Error(`Failed to fetch "${i}": ${a.status} ${a.statusText}`);const g=await a.text(),c=g.match(/newmtl[\s\S]*?endmtl/g),I=new vvt;if(c?.length){const l=c.join(`
|
|
5134
|
-
`).replace(/d 0\./g,"d 1."),B=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new wvt;C.setMaterialOptions({invertTrProperty:!0});const E=C.parse(l.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return I.setMaterials(E),I.parse(B)}return I.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(o.has(i)){const g=o.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(c=>c instanceof Error?c:c.clone())}const a=s().then(g=>(g instanceof Error||o.set(i,{...o.get(i),result:g}),g));return o.set(i,{promise:a,result:null}),a}return r().then(a=>{n||t(a)}).catch(a=>{console.error(a)}),()=>{n=!0}},[e]),A}function Nbe({url:e,position:A,rotation:t,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const a=Mbe(e),{rootObject:g}=Ku(),c=AA.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(I=>{if(I instanceof sn&&I.material){const l=B=>{B.transparent=r,B.opacity=r?.5:1,B.depthWrite=!r,B.needsUpdate=!0};Array.isArray(I.material)?I.material.forEach(l):l(I.material)}}),a):new sn(new km(.5,.5,.5),new mh({transparent:!0,color:"red",opacity:.25})),[a,r]);if(AA.useEffect(()=>{if(!(!g||!c))return g.add(c),()=>{g.remove(c)}},[g,c]),AA.useEffect(()=>{c&&(A&&(Array.isArray(A)?c.position.fromArray(A):c.position.copy(A)),t&&(Array.isArray(t)?c.rotation.fromArray(t):c.rotation.copy(t)),s!==void 0&&c.scale.setScalar(s))},[c,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(t)?t[0]:t?.x,Array.isArray(t)?t[1]:t?.y,Array.isArray(t)?t[2]:t?.z,s]),a instanceof Error)throw a;return Z.jsx(dH,{isHovered:n,onHover:i,onUnhover:o,object:c})}var vEA,vbe="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function Lbe(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&"default"in e&&typeof e.default=="function")return e.default;throw new Error("Unable to resolve occt-import-js factory export")}async function Ube(){if(!vEA){const e=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");vEA=Lbe(e)({locateFile:t=>`${vbe}/${t}`})}return vEA}function Hbe(e){const A=new ef;for(const t of e){const i=t.attributes.position?.array??[],o=t.index?.array??[];if(!i.length||!o.length)continue;const n=new Dg;n.setAttribute("position",new qn(i,3));const s=t.attributes.normal?.array??[];s.length?n.setAttribute("normal",new qn(s,3)):n.computeVertexNormals(),n.setIndex(o);const r=new mh({color:t.color?new Pi(t.color[0],t.color[1],t.color[2]):new Pi(.82,.82,.82)}),a=new sn(n,r);a.name=t.name,A.add(a)}return A}async function Ybe(e){const A=await fetch(e);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const t=await A.arrayBuffer(),o=(await Ube()).ReadStepFile(new Uint8Array(t),null);if(!o.success||!o.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const n=Hbe(o.meshes),s=new w$,r=await new Promise((a,g)=>{s.parse(n,c=>{c instanceof ArrayBuffer?a(c):g(new Error("GLTFExporter did not return binary output"))},c=>{g(c)},{binary:!0})});return URL.createObjectURL(new Blob([r],{type:"model/gltf-binary"}))}var VXA="step-glb-cache:";function Jbe(e){const A=new Uint8Array(e),t=32768;let i="";for(let o=0;o<A.length;o+=t){const n=A.subarray(o,o+t);i+=String.fromCharCode(...n)}return btoa(i)}function Tbe(e){const A=atob(e),t=new Uint8Array(A.length);for(let i=0;i<A.length;i+=1)t[i]=A.charCodeAt(i);return t.buffer}function Kbe(e){try{const A=localStorage.getItem(`${VXA}${e}`);return A?Tbe(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function Pbe(e,A){try{const t=Jbe(A);localStorage.setItem(`${VXA}${e}`,t)}catch(t){console.warn("Failed to write STEP GLB cache",t)}}var qbe=({stepUrl:e,position:A,rotation:t,scale:i,onHover:o,onUnhover:n,isHovered:s,isTranslucent:r})=>{const[a,g]=AA.useState(null);return AA.useEffect(()=>{let c=!0,I=null;const l=Kbe(e);return l?(I=URL.createObjectURL(new Blob([l],{type:"model/gltf-binary"})),g(I),()=>{c=!1,I&&URL.revokeObjectURL(I)}):(Ybe(e).then(B=>{if(!c){URL.revokeObjectURL(B);return}I=B,g(B),fetch(B).then(C=>C.arrayBuffer()).then(C=>{Pbe(e,C)}).catch(C=>{console.warn("Failed to cache STEP GLB",C)})}).catch(B=>{console.error("Failed to convert STEP file to GLB",B),c&&g(null)}),()=>{c=!1,I&&URL.revokeObjectURL(I)})},[e]),a?Z.jsx(ZXA,{gltfUrl:a,position:A,rotation:t,scale:i,onHover:o,onUnhover:n,isHovered:s,isTranslucent:r}):null},LEA=(...e)=>e,jXA=({cad_component:e,circuitJson:A})=>{const t=mzA(A),[i,o]=AA.useState(!1),{visibility:n}=WN(),[s,r]=AA.useState(null),a=AA.useCallback(f=>{f?.mousePosition?(o(!0),r(f.mousePosition)):(o(!1),r(null))},[]),g=AA.useCallback(()=>{o(!1),r(null)},[]),c=AA.useMemo(()=>xi(A).source_component.getUsing({source_component_id:e.source_component_id})?.name,[A,e.source_component_id]),I=AA.useMemo(()=>A.filter(m=>m.type==="pcb_plated_hole"&&m.pcb_component_id===e.pcb_component_id).length>0,[A,e.pcb_component_id]),l=e.model_obj_url??e.model_wrl_url??e.model_stl_url,B=e.model_glb_url??e.model_gltf_url,C=e.model_step_url,Q=A.find(f=>f.type==="pcb_component"&&f.source_component_id===e.source_component_id)?.layer??"top",h=AA.useMemo(()=>{const f=e.rotation?LEA(e.rotation.x*Math.PI/180,e.rotation.y*Math.PI/180,e.rotation.z*Math.PI/180):LEA(0,0,0);return Q==="bottom"?LEA(f[0]+Math.PI,f[1],-f[2]):f},[e.rotation,Q]),u=AA.useMemo(()=>{if(!e.position)return;const f=.55;let m;return Q==="top"?m=t/2:Q==="bottom"?m=-(t/2)-f:m=e.position.z,[e.position.x,e.position.y,m]},[e.position,Q,t]);let d=null;if(l?d=Z.jsx(Nbe,{url:l,position:u,rotation:h,scale:e.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:e.show_as_translucent_model},e.cad_component_id):B?d=Z.jsx(ZXA,{gltfUrl:B,position:u,rotation:h,scale:e.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:e.show_as_translucent_model},e.cad_component_id):C&&!e.model_jscad&&!e.footprinter_string?d=Z.jsx(qbe,{stepUrl:C,position:u,rotation:h,scale:e.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:e.show_as_translucent_model}):e.model_jscad?d=Z.jsx(Fbe,{jscadPlan:e.model_jscad,positionOffset:u,rotationOffset:h,scale:e.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:e.show_as_translucent_model},e.cad_component_id):e.footprinter_string&&(d=Z.jsx(Sbe,{positionOffset:u,rotationOffset:h,footprint:e.footprinter_string,scale:e.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:e.show_as_translucent_model})),e.show_as_translucent_model){if(!n.translucentModels)return null}else if(I&&!n.throughHoleModels||!I&&!n.smtModels)return null;return Z.jsxs(Z.Fragment,{children:[d,i&&s?Z.jsx(DzA,{position:s,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:c??"<unknown>"}):null]})},zXA={version:"0.0.501"};function Obe(e){e.querySelectorAll("canvas").forEach(A=>A.remove())}var Wbe=e=>{e.outputColorSpace=fm,e.toneMapping=KxA,e.toneMappingExposure=1},XXA="cadViewerCameraStateSession",$XA=(e,A)=>{try{const t={position:e.position.toArray(),quaternion:e.quaternion.toArray(),up:e.up.toArray(),fov:e.fov??50,target:A.target.toArray()};sessionStorage.setItem(XXA,JSON.stringify(t))}catch(t){console.warn("Failed to save camera:",t)}},UEA=(e,A)=>{try{const t=sessionStorage.getItem(XXA);if(!t)return!1;const i=JSON.parse(t);if(e.position.fromArray(i.position),e.quaternion.fromArray(i.quaternion),e.up.fromArray(i.up),"fov"in e){const o=e;o.fov=i.fov,o.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),e.updateMatrixWorld(),!0}catch(t){return console.warn("Failed to restore camera:",t),!1}},A6A=AA.createContext(void 0),Zbe=({children:e,defaultTarget:A,initialCameraPosition:t})=>{const i=AA.useRef(null),o=AA.useRef(null),[n,s]=AA.useState(null),[r,a]=AA.useState("perspective"),[g,c]=AA.useState(t??null),[I,l]=AA.useState(new Af(0,0,0)),B=AA.useMemo(()=>{const[h,u,d]=t??[5,-5,5],f=Math.hypot(h-A.x,u-A.y,d-A.z);return f>0?f:5},[t,A]),C=AA.useCallback(h=>{const u=[A.x,A.y,A.z],d=o.current,f=i.current;let m=B;switch(d&&f&&(m=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const D=m/Math.sqrt(2);return{position:[A.x,A.y-D,A.z+D],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+m],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-m,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+m,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-m,A.z],target:u,up:[0,0,1]};default:return null}},[B,A,o,i]),E=AA.useCallback(h=>{i.current=h},[]),Q=AA.useMemo(()=>({controlsRef:i,mainCameraRef:o,defaultTarget:A,baseDistance:B,controller:n,setController:s,getPresetConfig:C,handleControlsChange:E,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:c,cameraRotation:I,setCameraRotation:l,saveCameraToSession:$XA,loadCameraFromSession:UEA}),[A,B,n,C,E,r,g,I]);return Z.jsx(A6A.Provider,{value:Q,children:e})},ux=()=>{const e=AA.useContext(A6A);if(!e)throw new Error("useCameraController must be used within a CameraControllerProvider");return e},Vbe=AA.forwardRef(({children:e,scene:A,camera:t,style:i,onCreated:o},n)=>{const{cameraType:s}=ux(),r=AA.useRef(null),[a,g]=AA.useState(null),c=AA.useRef([]),I=AA.useRef(void 0);I.current=o;const l=AA.useRef(null),B=AA.useCallback(h=>{c.current.push(h)},[]),C=AA.useCallback(h=>{c.current=c.current.filter(u=>u!==h)},[]),E=AA.useMemo(()=>new eF,[]);A?.up&&E.up.set(A.up.x,A.up.y,A.up.z);const Q=AA.useRef(new wg);return AA.useImperativeHandle(n,()=>Q.current),AA.useEffect(()=>{if(!r.current)return;Obe(r.current);const h=new DP({antialias:!0,alpha:!0});Wbe(h),h.setSize(r.current.clientWidth,r.current.clientHeight),h.setPixelRatio(window.devicePixelRatio),r.current.appendChild(h.domElement);const u=r.current.clientWidth/r.current.clientHeight,d=s==="perspective"?new fE(75,u,.1,1e3):new X2(-10*u,10*u,10,-10,-1e3,1e3);l.current?(d.position.copy(l.current.position),d.quaternion.copy(l.current.quaternion),d.up.copy(l.current.up)):(t?.up&&d.up.set(t.up[0],t.up[1],t.up[2]),t?.position&&d.position.set(t.position[0],t.position[1],t.position[2]),d.lookAt(0,0,0)),E.add(Q.current),window.__TSCIRCUIT_THREE_OBJECT=Q.current,g({scene:E,camera:d,renderer:h,rootObject:Q.current,addFrameListener:B,removeFrameListener:C}),I.current?.({camera:d,renderer:h});let f;const m=new DRt,D=()=>{const b=m.getElapsedTime(),k=m.getDelta();c.current.forEach(_=>_(b,k)),h.render(E,d),f=requestAnimationFrame(D)};D();const w=()=>{if(r.current){const b=r.current.clientWidth/r.current.clientHeight;d instanceof fE?d.aspect=b:d instanceof X2&&(d.left=-10*b,d.right=10*b,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),h.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",w),()=>{l.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",w),cancelAnimationFrame(f),r.current&&h.domElement&&r.current.removeChild(h.domElement),h.dispose(),E.remove(Q.current),window.__TSCIRCUIT_THREE_OBJECT===Q.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[E,B,C,s]),Z.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&Z.jsx(wzA.Provider,{value:a,children:Z.jsx(wbe,{children:e})})})}),jbe=({autoRotate:e,autoRotateSpeed:A,onStart:t,panSpeed:i,rotateSpeed:o,zoomSpeed:n,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:c,renderer:I}=Ku(),l=AA.useMemo(()=>!c||!I?null:new Uvt(c,I.domElement),[c,I]);return AA.useEffect(()=>(g?.(l??null),()=>g?.(null)),[l,g]),AA.useEffect(()=>{if(!l)return;const B=()=>{g?.(l)};return l.addEventListener("change",B),()=>{l.removeEventListener("change",B)}},[l,g]),AA.useEffect(()=>{l&&(l.autoRotate=e||!1,l.autoRotateSpeed=A||1,i!==void 0&&(l.panSpeed=i),o!==void 0&&(l.rotateSpeed=o),n!==void 0&&(l.zoomSpeed=n),s!==void 0&&(l.enableDamping=s),r!==void 0&&(l.dampingFactor=r),l.zoomToCursor=!0,l.mouseButtons={LEFT:Q_.ROTATE,MIDDLE:Q_.PAN,RIGHT:null},a&&(l.target.set(a[0],a[1],a[2]),l.update()))},[l,e,A,i,o,n,s,r,a]),AA.useEffect(()=>{if(!(!l||!t))return l.addEventListener("start",t),()=>{l.removeEventListener("start",t)}},[l,t]),AA.useEffect(()=>{if(l)return()=>{l.dispose()}},[l]),nH(()=>{l?.update()},[l]),null},zbe=`
|
|
5134
|
+
`).replace(/d 0\./g,"d 1."),B=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new wvt;C.setMaterialOptions({invertTrProperty:!0});const E=C.parse(l.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return I.setMaterials(E),I.parse(B)}return I.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(o.has(i)){const g=o.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(c=>c instanceof Error?c:c.clone())}const a=s().then(g=>(g instanceof Error||o.set(i,{...o.get(i),result:g}),g));return o.set(i,{promise:a,result:null}),a}return r().then(a=>{n||t(a)}).catch(a=>{console.error(a)}),()=>{n=!0}},[e]),A}function Nbe({url:e,position:A,rotation:t,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const a=Mbe(e),{rootObject:g}=Ku(),c=AA.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(I=>{if(I instanceof sn&&I.material){const l=B=>{B.transparent=r,B.opacity=r?.5:1,B.depthWrite=!r,B.needsUpdate=!0};Array.isArray(I.material)?I.material.forEach(l):l(I.material)}}),a):new sn(new km(.5,.5,.5),new mh({transparent:!0,color:"red",opacity:.25})),[a,r]);if(AA.useEffect(()=>{if(!(!g||!c))return g.add(c),()=>{g.remove(c)}},[g,c]),AA.useEffect(()=>{c&&(A&&(Array.isArray(A)?c.position.fromArray(A):c.position.copy(A)),t&&(Array.isArray(t)?c.rotation.fromArray(t):c.rotation.copy(t)),s!==void 0&&c.scale.setScalar(s))},[c,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(t)?t[0]:t?.x,Array.isArray(t)?t[1]:t?.y,Array.isArray(t)?t[2]:t?.z,s]),a instanceof Error)throw a;return Z.jsx(dH,{isHovered:n,onHover:i,onUnhover:o,object:c})}var vEA,vbe="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function Lbe(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&"default"in e&&typeof e.default=="function")return e.default;throw new Error("Unable to resolve occt-import-js factory export")}async function Ube(){if(!vEA){const e=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");vEA=Lbe(e)({locateFile:t=>`${vbe}/${t}`})}return vEA}function Hbe(e){const A=new ef;for(const t of e){const i=t.attributes.position?.array??[],o=t.index?.array??[];if(!i.length||!o.length)continue;const n=new Dg;n.setAttribute("position",new qn(i,3));const s=t.attributes.normal?.array??[];s.length?n.setAttribute("normal",new qn(s,3)):n.computeVertexNormals(),n.setIndex(o);const r=new mh({color:t.color?new Pi(t.color[0],t.color[1],t.color[2]):new Pi(.82,.82,.82)}),a=new sn(n,r);a.name=t.name,A.add(a)}return A}async function Ybe(e){const A=await fetch(e);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const t=await A.arrayBuffer(),o=(await Ube()).ReadStepFile(new Uint8Array(t),null);if(!o.success||!o.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const n=Hbe(o.meshes),s=new w$,r=await new Promise((a,g)=>{s.parse(n,c=>{c instanceof ArrayBuffer?a(c):g(new Error("GLTFExporter did not return binary output"))},c=>{g(c)},{binary:!0})});return URL.createObjectURL(new Blob([r],{type:"model/gltf-binary"}))}var VXA="step-glb-cache:";function Jbe(e){const A=new Uint8Array(e),t=32768;let i="";for(let o=0;o<A.length;o+=t){const n=A.subarray(o,o+t);i+=String.fromCharCode(...n)}return btoa(i)}function Tbe(e){const A=atob(e),t=new Uint8Array(A.length);for(let i=0;i<A.length;i+=1)t[i]=A.charCodeAt(i);return t.buffer}function Kbe(e){try{const A=localStorage.getItem(`${VXA}${e}`);return A?Tbe(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function Pbe(e,A){try{const t=Jbe(A);localStorage.setItem(`${VXA}${e}`,t)}catch(t){console.warn("Failed to write STEP GLB cache",t)}}var qbe=({stepUrl:e,position:A,rotation:t,scale:i,onHover:o,onUnhover:n,isHovered:s,isTranslucent:r})=>{const[a,g]=AA.useState(null);return AA.useEffect(()=>{let c=!0,I=null;const l=Kbe(e);return l?(I=URL.createObjectURL(new Blob([l],{type:"model/gltf-binary"})),g(I),()=>{c=!1,I&&URL.revokeObjectURL(I)}):(Ybe(e).then(B=>{if(!c){URL.revokeObjectURL(B);return}I=B,g(B),fetch(B).then(C=>C.arrayBuffer()).then(C=>{Pbe(e,C)}).catch(C=>{console.warn("Failed to cache STEP GLB",C)})}).catch(B=>{console.error("Failed to convert STEP file to GLB",B),c&&g(null)}),()=>{c=!1,I&&URL.revokeObjectURL(I)})},[e]),a?Z.jsx(ZXA,{gltfUrl:a,position:A,rotation:t,scale:i,onHover:o,onUnhover:n,isHovered:s,isTranslucent:r}):null},LEA=(...e)=>e,jXA=({cad_component:e,circuitJson:A})=>{const t=mzA(A),[i,o]=AA.useState(!1),{visibility:n}=WN(),[s,r]=AA.useState(null),a=AA.useCallback(f=>{f?.mousePosition?(o(!0),r(f.mousePosition)):(o(!1),r(null))},[]),g=AA.useCallback(()=>{o(!1),r(null)},[]),c=AA.useMemo(()=>xi(A).source_component.getUsing({source_component_id:e.source_component_id})?.name,[A,e.source_component_id]),I=AA.useMemo(()=>A.filter(m=>m.type==="pcb_plated_hole"&&m.pcb_component_id===e.pcb_component_id).length>0,[A,e.pcb_component_id]),l=e.model_obj_url??e.model_wrl_url??e.model_stl_url,B=e.model_glb_url??e.model_gltf_url,C=e.model_step_url,Q=A.find(f=>f.type==="pcb_component"&&f.source_component_id===e.source_component_id)?.layer??"top",h=AA.useMemo(()=>{const f=e.rotation?LEA(e.rotation.x*Math.PI/180,e.rotation.y*Math.PI/180,e.rotation.z*Math.PI/180):LEA(0,0,0);return Q==="bottom"?LEA(f[0]+Math.PI,f[1],-f[2]):f},[e.rotation,Q]),u=AA.useMemo(()=>{if(!e.position)return;const f=.55;let m;return Q==="top"?m=t/2:Q==="bottom"?m=-(t/2)-f:m=e.position.z,[e.position.x,e.position.y,m]},[e.position,Q,t]);let d=null;if(l?d=Z.jsx(Nbe,{url:l,position:u,rotation:h,scale:e.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:e.show_as_translucent_model},e.cad_component_id):B?d=Z.jsx(ZXA,{gltfUrl:B,position:u,rotation:h,scale:e.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:e.show_as_translucent_model},e.cad_component_id):C&&!e.model_jscad&&!e.footprinter_string?d=Z.jsx(qbe,{stepUrl:C,position:u,rotation:h,scale:e.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:e.show_as_translucent_model}):e.model_jscad?d=Z.jsx(Fbe,{jscadPlan:e.model_jscad,positionOffset:u,rotationOffset:h,scale:e.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:e.show_as_translucent_model},e.cad_component_id):e.footprinter_string&&(d=Z.jsx(Sbe,{positionOffset:u,rotationOffset:h,footprint:e.footprinter_string,scale:e.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:e.show_as_translucent_model})),e.show_as_translucent_model){if(!n.translucentModels)return null}else if(I&&!n.throughHoleModels||!I&&!n.smtModels)return null;return Z.jsxs(Z.Fragment,{children:[d,i&&s?Z.jsx(DzA,{position:s,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:c??"<unknown>"}):null]})},zXA={version:"0.0.502"};function Obe(e){e.querySelectorAll("canvas").forEach(A=>A.remove())}var Wbe=e=>{e.outputColorSpace=fm,e.toneMapping=KxA,e.toneMappingExposure=1},XXA="cadViewerCameraStateSession",$XA=(e,A)=>{try{const t={position:e.position.toArray(),quaternion:e.quaternion.toArray(),up:e.up.toArray(),fov:e.fov??50,target:A.target.toArray()};sessionStorage.setItem(XXA,JSON.stringify(t))}catch(t){console.warn("Failed to save camera:",t)}},UEA=(e,A)=>{try{const t=sessionStorage.getItem(XXA);if(!t)return!1;const i=JSON.parse(t);if(e.position.fromArray(i.position),e.quaternion.fromArray(i.quaternion),e.up.fromArray(i.up),"fov"in e){const o=e;o.fov=i.fov,o.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),e.updateMatrixWorld(),!0}catch(t){return console.warn("Failed to restore camera:",t),!1}},A6A=AA.createContext(void 0),Zbe=({children:e,defaultTarget:A,initialCameraPosition:t})=>{const i=AA.useRef(null),o=AA.useRef(null),[n,s]=AA.useState(null),[r,a]=AA.useState("perspective"),[g,c]=AA.useState(t??null),[I,l]=AA.useState(new Af(0,0,0)),B=AA.useMemo(()=>{const[h,u,d]=t??[5,-5,5],f=Math.hypot(h-A.x,u-A.y,d-A.z);return f>0?f:5},[t,A]),C=AA.useCallback(h=>{const u=[A.x,A.y,A.z],d=o.current,f=i.current;let m=B;switch(d&&f&&(m=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const D=m/Math.sqrt(2);return{position:[A.x,A.y-D,A.z+D],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+m],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-m,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+m,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-m,A.z],target:u,up:[0,0,1]};default:return null}},[B,A,o,i]),E=AA.useCallback(h=>{i.current=h},[]),Q=AA.useMemo(()=>({controlsRef:i,mainCameraRef:o,defaultTarget:A,baseDistance:B,controller:n,setController:s,getPresetConfig:C,handleControlsChange:E,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:c,cameraRotation:I,setCameraRotation:l,saveCameraToSession:$XA,loadCameraFromSession:UEA}),[A,B,n,C,E,r,g,I]);return Z.jsx(A6A.Provider,{value:Q,children:e})},ux=()=>{const e=AA.useContext(A6A);if(!e)throw new Error("useCameraController must be used within a CameraControllerProvider");return e},Vbe=AA.forwardRef(({children:e,scene:A,camera:t,style:i,onCreated:o},n)=>{const{cameraType:s}=ux(),r=AA.useRef(null),[a,g]=AA.useState(null),c=AA.useRef([]),I=AA.useRef(void 0);I.current=o;const l=AA.useRef(null),B=AA.useCallback(h=>{c.current.push(h)},[]),C=AA.useCallback(h=>{c.current=c.current.filter(u=>u!==h)},[]),E=AA.useMemo(()=>new eF,[]);A?.up&&E.up.set(A.up.x,A.up.y,A.up.z);const Q=AA.useRef(new wg);return AA.useImperativeHandle(n,()=>Q.current),AA.useEffect(()=>{if(!r.current)return;Obe(r.current);const h=new DP({antialias:!0,alpha:!0});Wbe(h),h.setSize(r.current.clientWidth,r.current.clientHeight),h.setPixelRatio(window.devicePixelRatio),r.current.appendChild(h.domElement);const u=r.current.clientWidth/r.current.clientHeight,d=s==="perspective"?new fE(75,u,.1,1e3):new X2(-10*u,10*u,10,-10,-1e3,1e3);l.current?(d.position.copy(l.current.position),d.quaternion.copy(l.current.quaternion),d.up.copy(l.current.up)):(t?.up&&d.up.set(t.up[0],t.up[1],t.up[2]),t?.position&&d.position.set(t.position[0],t.position[1],t.position[2]),d.lookAt(0,0,0)),E.add(Q.current),window.__TSCIRCUIT_THREE_OBJECT=Q.current,g({scene:E,camera:d,renderer:h,rootObject:Q.current,addFrameListener:B,removeFrameListener:C}),I.current?.({camera:d,renderer:h});let f;const m=new DRt,D=()=>{const b=m.getElapsedTime(),k=m.getDelta();c.current.forEach(_=>_(b,k)),h.render(E,d),f=requestAnimationFrame(D)};D();const w=()=>{if(r.current){const b=r.current.clientWidth/r.current.clientHeight;d instanceof fE?d.aspect=b:d instanceof X2&&(d.left=-10*b,d.right=10*b,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),h.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",w),()=>{l.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",w),cancelAnimationFrame(f),r.current&&h.domElement&&r.current.removeChild(h.domElement),h.dispose(),E.remove(Q.current),window.__TSCIRCUIT_THREE_OBJECT===Q.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[E,B,C,s]),Z.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&Z.jsx(wzA.Provider,{value:a,children:Z.jsx(wbe,{children:e})})})}),jbe=({autoRotate:e,autoRotateSpeed:A,onStart:t,panSpeed:i,rotateSpeed:o,zoomSpeed:n,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:c,renderer:I}=Ku(),l=AA.useMemo(()=>!c||!I?null:new Uvt(c,I.domElement),[c,I]);return AA.useEffect(()=>(g?.(l??null),()=>g?.(null)),[l,g]),AA.useEffect(()=>{if(!l)return;const B=()=>{g?.(l)};return l.addEventListener("change",B),()=>{l.removeEventListener("change",B)}},[l,g]),AA.useEffect(()=>{l&&(l.autoRotate=e||!1,l.autoRotateSpeed=A||1,i!==void 0&&(l.panSpeed=i),o!==void 0&&(l.rotateSpeed=o),n!==void 0&&(l.zoomSpeed=n),s!==void 0&&(l.enableDamping=s),r!==void 0&&(l.dampingFactor=r),l.zoomToCursor=!0,l.mouseButtons={LEFT:Q_.ROTATE,MIDDLE:Q_.PAN,RIGHT:null},a&&(l.target.set(a[0],a[1],a[2]),l.update()))},[l,e,A,i,o,n,s,r,a]),AA.useEffect(()=>{if(!(!l||!t))return l.addEventListener("start",t),()=>{l.removeEventListener("start",t)}},[l,t]),AA.useEffect(()=>{if(l)return()=>{l.dispose()}},[l]),nH(()=>{l?.update()},[l]),null},zbe=`
|
|
5135
5135
|
varying vec3 worldPosition;
|
|
5136
5136
|
void main() {
|
|
5137
5137
|
worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
@@ -5165,12 +5165,12 @@ ${a.join(`
|
|
|
5165
5165
|
gl_FragColor = vec4(color, max(g1, g2) * a);
|
|
5166
5166
|
if (gl_FragColor.a <= 0.0) discard;
|
|
5167
5167
|
}
|
|
5168
|
-
`,$be=({rotation:e,infiniteGrid:A,cellSize:t=1,sectionSize:i=10})=>{const{scene:o,camera:n}=Ku(),s=1e3,r=AA.useMemo(()=>{const a=new Fm(s,s);a.rotateX(-Math.PI/2);const g=new Fw({vertexShader:zbe,fragmentShader:Xbe,uniforms:{cellSize:{value:t},sectionSize:{value:i},gridColor:{value:new Pi(15658734)},sectionColor:{value:new Pi(13421823)},fadeDistance:{value:100},fadeStrength:{value:1.5}},transparent:!0,side:jB}),c=new sn(a,g);return e&&c.rotation.fromArray(e),c},[s,t,i,e]);return nH(()=>{A&&r.position.set(n.position.x,n.position.y,0)}),AA.useEffect(()=>{if(!(!o||!r))return o.add(r),()=>{o.remove(r),r.geometry.dispose(),Array.isArray(r.material)?r.material.forEach(a=>a.dispose()):r.material.dispose()}},[o,r]),null},A_e=()=>{const{scene:e}=Ku(),A=AA.useMemo(()=>new lGA(16777215,Math.PI/2),[]),t=AA.useMemo(()=>{const i=new w7(16777215,Math.PI/4);return i.position.set(-10,-10,10),i.decay=0,i},[]);return AA.useEffect(()=>{if(e)return e.add(A),e.add(t),()=>{e.remove(A),e.remove(t)}},[e,A,t]),null},t_e=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,e_e=()=>{const{controlsRef:e,mainCameraRef:A,defaultTarget:t,setController:i,getPresetConfig:o}=ux(),n=AA.useRef(null),s=AA.useRef(new Md),r=AA.useRef(new Rt),a=AA.useRef(new Rt),g=AA.useRef(new Md),c=AA.useRef(new Md),I=AA.useRef(new wg),l=AA.useRef(new wg),B=AA.useCallback(({position:E,target:Q,up:h,durationMs:u=600})=>{if(!A.current)return;const d=e.current?.target??t,f=new Rt(E[0],E[1],E[2]),m=Q?new Rt(Q[0],Q[1],Q[2]):t.clone(),D=new Rt(...h??[0,0,1]).normalize(),w=l.current;w.position.copy(f),w.up.copy(D),w.lookAt(m);const b=w.quaternion.clone(),k=A.current.quaternion.clone(),_=A.current.position.clone(),N=d.clone(),M=I.current;M.up.set(0,0,1),M.position.copy(_),M.lookAt(N);const H=M.quaternion.clone();M.up.set(0,0,1),M.position.copy(f),M.lookAt(m);const T=M.quaternion.clone(),Y=H.clone().invert().multiply(k).normalize(),O=T.clone().invert().multiply(b).normalize();n.current={fromPosition:_,toPosition:f,fromTarget:N,toTarget:m,toQuaternion:b,rollFrom:Y,rollTo:O,startTime:performance.now(),duration:u}},[A,e,t]),C=AA.useCallback(E=>{if(E==="Custom")return;const Q=o(E);Q&&B(Q)},[B,o]);return AA.useEffect(()=>A.current?(i({animateTo:B,animateToPreset:C}),()=>{i(null)}):void 0,[B,C,A,i]),nH(()=>{if(!A.current||!n.current)return;const{fromPosition:E,toPosition:Q,fromTarget:h,toTarget:u,toQuaternion:d,rollFrom:f,rollTo:m,startTime:D,duration:w}=n.current,b=performance.now()-D,k=w<=0?1:Math.min(b/w,1),_=t_e(k);A.current.position.lerpVectors(E,Q,_);const N=r.current;N.copy(h).lerp(u,_);const M=I.current;M.up.set(0,0,1),M.position.copy(A.current.position),M.lookAt(N);const H=s.current;H.copy(M.quaternion);const T=g.current;T.copy(f);const Y=c.current;Y.copy(m),f.dot(m)<0&&(Y.x*=-1,Y.y*=-1,Y.z*=-1,Y.w*=-1),Y.normalize(),T.slerp(Y,_),A.current.quaternion.copy(H).multiply(T).normalize();const O=a.current;O.set(0,1,0).applyQuaternion(A.current.quaternion).normalize(),A.current.up.copy(O),e.current?.target.copy(N),A.current.updateMatrixWorld(),e.current?.update(),k>=1&&(A.current.position.copy(Q),A.current.quaternion.copy(d),A.current.up.set(0,0,1),A.current.updateMatrixWorld(),e.current?.target.copy(u),e.current?.update(),n.current=null)}),null},i_e=()=>{const{controlsRef:e}=ux(),A=AA.useRef(null),t=AA.useRef(!1),i=AA.useRef(null),o=AA.useCallback(s=>{A.current=s,!t.current&&e.current&&UEA(s,e.current)&&(t.current=!0)},[e]),n=AA.useCallback(()=>{if(!(!A.current||!e.current)){if(!t.current&&UEA(A.current,e.current)){t.current=!0;return}clearTimeout(i.current),i.current=setTimeout(()=>{A.current&&e.current&&$XA(A.current,e.current)},150)}},[e]);return{handleCameraCreated:o,handleControlsChange:n}};function o_e(e,A){const t=new Md().setFromEuler(new Af(e.x,e.y,e.z)),i=new Rt(0,0,1);return i.applyQuaternion(t),i.multiplyScalar(A)}var n_e=()=>{const{mainCameraRef:e}=ux(),A=AA.useRef(null),t=AA.useRef(null),i=AA.useRef(null),o=AA.useRef(null),n=AA.useRef(null),s=AA.useRef(null);return AA.useEffect(()=>{if(!A.current)return;const r=document.createElement("canvas");t.current=r,A.current.appendChild(r);const a=new DP({canvas:r,antialias:!0,alpha:!0});a.setSize(120,120),a.setPixelRatio(window.devicePixelRatio),i.current=a;const g=new eF;o.current=g;const c=new fE(75,1,.1,1e3);c.up.set(0,0,1),n.current=c;const I=new lGA(16777215,Math.PI/2);g.add(I);const l=new ef;l.rotation.fromArray([Math.PI/2,0,0]);const B=1,C=new sn(new km(B,B,B),new mh({color:"white"}));l.add(C);const E=new iL(new TGt(new km(B,B,B)),new iF({color:0,linewidth:2}));l.add(E),g.add(l);const Q=.51,h=(k,_,N)=>{const M=new K$;return M.text=k,M.position.fromArray(_),N&&M.rotation.fromArray(N),M.color="black",M.fontSize=.25,M.anchorX="center",M.anchorY="middle",M.depthOffset=0,M.font=null,M.sync(),M},u=h("Front",[0,0,Q]),d=h("Back",[0,0,-Q],[0,Math.PI,0]),f=h("Right",[Q,0,0],[0,Math.PI/2,0]),m=h("Left",[-Q,0,0],[0,-Math.PI/2,0]),D=h("Top",[0,Q,0],[-Math.PI/2,0,0]),w=h("Bottom",[0,-Q,0],[Math.PI/2,0,0]);l.add(u),l.add(d),l.add(f),l.add(m),l.add(D),l.add(w);const b=()=>{if(e.current){const k=o_e(e.current.rotation??new Af(0,0,0),2);k.equals(c.position)||(c.position.copy(k),c.lookAt(0,0,0))}a.render(g,c),s.current=requestAnimationFrame(b)};return b(),()=>{s.current&&cancelAnimationFrame(s.current),u.dispose(),d.dispose(),f.dispose(),m.dispose(),D.dispose(),w.dispose(),C.geometry.dispose(),C.material.dispose(),E.geometry.dispose(),E.material.dispose(),g.clear(),a.dispose(),t.current&&A.current&&A.current.removeChild(t.current)}},[e]),Z.jsx("div",{ref:A,style:{position:"absolute",top:0,left:0,width:120,height:120,zIndex:sH.orientationCube}})},s_e=()=>{const{camera:e}=Ku(),{setCameraRotation:A}=ux();return nH(()=>{e&&A(e.rotation)}),null},t6A=AA.forwardRef(({children:e,initialCameraPosition:A=[5,-5,5],autoRotateDisabled:t,clickToInteractEnabled:i=!1,boardDimensions:o,boardCenter:n,onUserInteraction:s,onCameraControllerReady:r},a)=>{const[g,c]=AA.useState(!i),{mainCameraRef:I,handleControlsChange:l,controller:B}=ux(),{handleCameraCreated:C,handleControlsChange:E}=i_e();AA.useEffect(()=>{r&&r(B)},[B,r]);const Q=AA.useMemo(()=>{if(!o)return 10;const u=o.width??0,d=o.height??0,m=Math.max(u,d)*1.5;return m>10?m:10},[o]),h=AA.useMemo(()=>{if(n)return[n.x,n.y,0]},[n]);return Z.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Z.jsx(n_e,{}),Z.jsxs(Vbe,{ref:a,scene:{up:new Rt(0,0,1)},camera:{up:[0,0,1],position:A},onCreated:({camera:u})=>{I.current=u,C(u)},children:[Z.jsx(e_e,{}),Z.jsx(s_e,{}),g&&Z.jsx(jbe,{autoRotate:!t,autoRotateSpeed:1,onStart:s,rotateSpeed:.5,panSpeed:.75,zoomSpeed:.5,enableDamping:!0,dampingFactor:.1,target:h,onControlsChange:u=>{l(u),E()}}),Z.jsx(A_e,{}),Z.jsx($be,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:3,sectionSize:Q,args:[Q,Q]}),e]}),Z.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:["@",zXA.version]}),i&&!g&&Z.jsx("button",{type:"button",onClick:()=>c(!0),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&c(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:sH.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center"},children:Z.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"})})]})}),e6A=e=>AA.useMemo(()=>{if(!e)return[];const A=new bre;return A.add(e),A.render(),A.getCircuitJson()},[e]),r_e=e=>{const[A,t]=AA.useState([]),[i,o]=AA.useState(!0);return AA.useEffect(()=>{if(!e)return;(async()=>{o(!0);const r=(Array.isArray(e)?e:[e]).map(async(a,g)=>{const c=xle.serialize({binary:!0},[a]),l=await new Blob(c).arrayBuffer(),C=a.layerType||(g===0?"board":void 0);return{stlData:l,color:a.color,layerType:C}});try{const a=await Promise.all(r);t(a)}catch(a){console.error("Error generating STLs:",a),t([])}finally{o(!1)}})()},[e]),{stls:A,loading:i}},a_e=Or(Qx()),g_e=Or(V8()),To=.01,Za={traces:.001,copper:.002},$o={copper:[.9,.6,.2],fr4Tan:[.6,.43,.28],fr4SolderMaskGreen:[.02,.1,.04],fr4TracesWithMaskGreen:[0,.5,.25],fr4TracesWithoutMaskTan:[.6,.43,.28],fr1Tan:[.8,.4,.2],fr1TracesWithMaskCopper:[.9,.6,.2],fr1SolderMaskGreen:[.02,.1,.04]},Bf=.001,XB=32,pH=.035,fc=150,EW=.6,HEA={fr1:$o.fr1Tan,fr4:$o.fr4Tan},i6A={fr1:$o.fr1SolderMaskGreen,fr4:$o.fr4SolderMaskGreen},c_e=Or(oH()),I_e=Or(Qx()),l_e=Or(WF()),B_e=Or(EzA()),o6A=e=>{let A=0;for(let i=0;i<e.length;i++){const o=(i+1)%e.length;A+=e[i][0]*e[o][1],A-=e[o][0]*e[i][1]}return A/2<=0},YEA=(e,A=1.2,t={})=>{const{xyOutset:i=0}=t,{outline:o}=e;let n=o.map(a=>[a.x,a.y]);o6A(n)&&(n=n.reverse());let s=(0,I_e.polygon)({points:n});i!==0&&(s=(0,B_e.expand)({delta:i,corners:"edge"},s));let r=(0,c_e.extrudeLinear)({height:A},s);return r=(0,l_e.translate)([0,0,-A/2],r),r},C_e=e=>{const A=e.filter(a=>a.type==="pcb_panel"),t=xi(e).pcb_board.list();let i,o=1.2;if(A.length>0)i=A[0],o=t.find(g=>g.pcb_panel_id===i.pcb_panel_id)?.thickness??1.2;else{if(i=t.filter(g=>!g.pcb_panel_id)[0],!i)return console.warn("No pcb_board or pcb_panel found for simplified geometry"),[];o=i.thickness??1.2}let n;"outline"in i&&i.outline&&i.outline.length>0?n=YEA({outline:i.outline},o):n=(0,a_e.cuboid)({size:[i.width??10,i.height??10,o],center:[i.center.x,i.center.y,0]});const s="material"in i&&i.material?i.material:A.length>0?t.find(a=>a.pcb_panel_id===i.pcb_panel_id)?.material??"fr4":"fr4",r=HEA[s]??$o.fr4Tan;return[(0,g_e.colorize)(r,n)]},kE=Or(WF()),xg=Or(Qx()),Pu=Or(V8()),kg=Or(ON()),gr=Or(Qx()),aD=Or(V8()),ga=Or(ON()),n6A=Or(WF()),fH=Or(oH()),Kd=Or(WF()),Q_e=1e-5;function d0(e,A,t){if(typeof t!="number"||!Number.isFinite(t)||t<=0)return 0;const i=e/2,o=A/2,n=Math.min(i,o)-2*Q_e;return Math.max(0,Math.min(t,n))}function UC(e){if(!(!e||typeof e!="object"))return e.corner_radius??e.cornerRadius??e.rect_pad_border_radius??e.rectPadBorderRadius??e.rect_border_radius??e.rectBorderRadius??void 0}var dx=Or(Qx()),E_e=Or(oH()),hW=Or(WF()),h_e=Or(ON()),u_e=64,d_e=(e,A,t)=>{const i=(0,dx.ellipse)({center:[0,0],radius:[Math.max(e/2,To/2),Math.max(A/2,To/2)],segments:u_e}),o=(0,E_e.extrudeLinear)({height:t},i);return(0,hW.translate)([0,0,-t/2],o)},p_e=(e,A,t)=>{const i=Math.max(e,To),o=Math.max(A,To);if(Math.abs(i-o)<1e-6)return(0,dx.cylinder)({center:[0,0,0],radius:i/2,height:t});const n=i>=o,s=n?i:o,r=n?o:i,a=Math.max(s-r,0),g=(0,dx.cuboid)({center:[0,0,0],size:n?[a,r,t]:[r,a,t]});if(a<=1e-6)return(0,dx.cylinder)({center:[0,0,0],radius:r/2,height:t});const c=a/2,I=(0,dx.cylinder)({center:n?[-c,0,0]:[0,-c,0],radius:r/2,height:t}),l=(0,dx.cylinder)({center:n?[c,0,0]:[0,c,0],radius:r/2,height:t});return(0,h_e.union)(g,I,l)},uW=(e,A,t={})=>{const i=e.hole_shape||"circle",o=t.sizeDelta??0,n=e.hole_offset_x||0,s=e.hole_offset_y||0,r=[e.x+n,e.y+s,0];if(i==="circle"){const B=Math.max((e.hole_diameter??0)+o,To),C=Math.max(B/2,To/2);return(0,dx.cylinder)({center:r,radius:C,height:A})}const a=e.hole_width??e.hole_diameter,g=e.hole_height??e.hole_diameter;if(!a||!g)return null;const c=Math.max(a+o,To),I=Math.max(g+o,To);if(i==="oval"){const B=d_e(c,I,A);return(0,hW.translate)([r[0],r[1],0],B)}if(i==="pill"||i==="rotated_pill"){let B=p_e(c,I,A);if(!B)return null;const C=e.ccw_rotation||0;return C&&(B=(0,hW.rotateZ)(C*Math.PI/180,B)),(0,hW.translate)(r,B)}const l=Math.max((e.hole_diameter??a??g??To)+o,To);return(0,dx.cylinder)({center:r,radius:l/2,height:A})},p0=.02,dW=64,jF=(e,A)=>A?(0,ga.intersect)(A,e):e,av=({width:e,height:A,thickness:t,center:i,borderRadius:o})=>{const n=d0(e,A,o);if(n<=0)return(0,gr.cuboid)({center:i,size:[e,A,t]});const s=(0,gr.roundedRectangle)({size:[e,A],roundRadius:n,segments:dW}),r=(0,fH.extrudeLinear)({height:t},s),a=i[2]-t/2;return(0,Kd.translate)([i[0],i[1],a],r)},yH=(e,A,t={})=>{const{clipGeom:i}=t;e.shape||(e.shape="circle");const o=A.pcbThickness+2*p0+4*To,n=A.pcbThickness/2+Za.copper,s=-A.pcbThickness/2-Za.copper,r=n-s;if(e.shape==="circle"){const a=e.outer_diameter??Math.max(e.hole_diameter,0),g=r+.01,c=(0,gr.cylinder)({center:[e.x,e.y,0],radius:a/2,height:g}),I=jF(c,i),l=(0,gr.cylinder)({center:[e.x,e.y,0],radius:Math.max(e.hole_diameter/2,.01),height:o});return(0,aD.colorize)($o.copper,(0,ga.subtract)(I,l))}if(e.shape==="oval"){const a=e.outer_width||e.hole_width||0,g=e.outer_height||e.hole_height||0,c=e.hole_width||0,I=e.hole_height||0,l=(()=>{const E=(0,gr.cylinder)({center:[0,0,0],radius:1,height:r+.01,segments:64}),Q=(0,n6A.scale)([a/2,g/2,1],E);return(0,Kd.translate)([e.x,e.y,0],Q)})(),B=jF(l,i),C=(()=>{const E=(0,gr.cylinder)({center:[0,0,0],radius:1,height:o,segments:64}),Q=(0,n6A.scale)([Math.max(c/2,.01),Math.max(I/2,.01),1],E);return(0,Kd.translate)([e.x,e.y,0],Q)})();return(0,aD.colorize)($o.copper,(0,ga.subtract)(B,C))}if(e.shape==="circular_hole_with_rect_pad"){const a=e.hole_offset_x||0,g=e.hole_offset_y||0,c=e.rect_pad_width||e.hole_diameter,I=e.rect_pad_height||e.hole_diameter,l=UC(e),B=jF((0,ga.union)(av({width:c,height:I,thickness:p0,center:[e.x,e.y,n],borderRadius:l}),av({width:c,height:I,thickness:p0,center:[e.x,e.y,s],borderRadius:l}),(()=>{const h=Math.max(r-p0*2,To),f=(n+s)/2,m=(0,gr.roundedRectangle)({size:[c,I],roundRadius:l||0,segments:dW}),D=(0,fH.extrudeLinear)({height:h},m);return(0,Kd.translate)([e.x,e.y,f-h/2],D)})(),(0,gr.cylinder)({center:[e.x+(a||0),e.y+(g||0),0],radius:e.hole_diameter/2,height:r})),i),C=(0,gr.cylinder)({center:[e.x+(a||0),e.y+(g||0),0],radius:Math.max(e.hole_diameter/2-To,.01),height:o}),E=(0,gr.cylinder)({center:[e.x+(a||0),e.y+(g||0),0],radius:e.hole_diameter/2,height:r});let Q=(0,ga.union)((0,ga.subtract)(B,E),E);return t.clipGeom?(Q=(0,ga.subtract)(Q,C),Q=(0,ga.intersect)(Q,t.clipGeom),(0,aD.colorize)($o.copper,Q)):(0,aD.colorize)($o.copper,(0,ga.subtract)(Q,C))}if(e.shape==="pill"){const a=(e.ccw_rotation||0)*Math.PI/180,g=_=>{if(!a)return _;const N=(0,Kd.translate)([-e.x,-e.y,0],_),M=(0,Kd.rotate)([0,0,a],N);return(0,Kd.translate)([e.x,e.y,0],M)},c=e.hole_height>e.hole_width,I=c?e.hole_height:e.hole_width,l=c?e.hole_width:e.hole_height,B=c?e.outer_height||l+.2:e.outer_width||I+.2,C=c?e.outer_width||I+.2:e.outer_height||l+.2,E=l/2,Q=Math.abs(I-l),h=r+.01,d=((_,N,M)=>{const H=N/2,T=Math.abs(_-N);if(T<=1e-6)return(0,gr.cylinder)({center:[e.x,e.y,0],radius:H,height:M});const Y=(0,gr.cuboid)({center:[e.x,e.y,0],size:c?[N,T,M]:[T,N,M]}),O=(0,gr.cylinder)({center:c?[e.x,e.y-T/2,0]:[e.x-T/2,e.y,0],radius:H,height:M}),W=(0,gr.cylinder)({center:c?[e.x,e.y+T/2,0]:[e.x+T/2,e.y,0],radius:H,height:M});return(0,ga.union)(Y,O,W)})(B,C,h),f=(0,gr.cuboid)({center:[e.x,e.y,0],size:c?[l-2*To,Q,o]:[Q,l-2*To,o]}),m=(0,gr.cylinder)({center:c?[e.x,e.y-Q/2,0]:[e.x-Q/2,e.y,0],radius:E-To,height:o}),D=(0,gr.cylinder)({center:c?[e.x,e.y+Q/2,0]:[e.x+Q/2,e.y,0],radius:E-To,height:o}),w=(0,ga.union)(f,m,D),b=jF(g(d),i),k=g(w);return(0,aD.colorize)($o.copper,(0,ga.subtract)(b,k))}if(e.shape==="pill_hole_with_rect_pad"){if(e.hole_shape&&e.hole_shape!=="pill"||e.pad_shape&&e.pad_shape!=="rect")throw new Error("Invalid hole_shape or pad_shape for pill_hole_with_rect_pad");const a=e.hole_offset_x||0,g=e.hole_offset_y||0,c=e.hole_height>e.hole_width,I=c?e.hole_height:e.hole_width,l=c?e.hole_width:e.hole_height,B=l/2,C=Math.abs(I-l),E=e.rect_pad_width||I+.2,Q=e.rect_pad_height||l+.2,h=UC(e),u=.03,d=(0,ga.union)((0,gr.cuboid)({center:[e.x+a,e.y+g,0],size:c?[l+2*u,C+2*u,r]:[C+2*u,l+2*u,r]}),(0,gr.cylinder)({center:c?[e.x+a,e.y+g-C/2,0]:[e.x+a-C/2,e.y+g,0],radius:B+u,height:r}),(0,gr.cylinder)({center:c?[e.x+a,e.y+g+C/2,0]:[e.x+a+C/2,e.y+g,0],radius:B+u,height:r})),f=(0,ga.union)((0,gr.cuboid)({center:[e.x+a,e.y+g,0],size:c?[l,C,o*1.1]:[C,l,o*1.1]}),(0,gr.cylinder)({center:c?[e.x+a,e.y+g-C/2,0]:[e.x+a-C/2,e.y+g,0],radius:B,height:o*1.1}),(0,gr.cylinder)({center:c?[e.x+a,e.y+g+C/2,0]:[e.x+a+C/2,e.y+g,0],radius:B,height:o*1.1})),m=av({width:E,height:Q,thickness:p0,center:[e.x,e.y,n],borderRadius:h}),D=av({width:E,height:Q,thickness:p0,center:[e.x,e.y,s],borderRadius:h}),w=(()=>{const T=Math.max(r-p0*2,To),W=(n+s)/2,$=(0,gr.roundedRectangle)({size:[E,Q],roundRadius:h||0,segments:dW}),iA=(0,fH.extrudeLinear)({height:T},$);return(0,Kd.translate)([e.x,e.y,W-T/2],iA)})(),b=(0,ga.subtract)(m,f),k=(0,ga.subtract)(D,f),_=(0,ga.subtract)(w,f),N=(0,ga.union)((0,gr.cuboid)({center:[e.x+a,e.y+g,0],size:c?[l-2*To,C-2*To,o*1.1]:[C-2*To,l-2*To,o*1.1]}),(0,gr.cylinder)({center:c?[e.x+a,e.y+g-C/2,0]:[e.x+a-C/2,e.y+g,0],radius:B-To,height:o*1.1}),(0,gr.cylinder)({center:c?[e.x+a,e.y+g+C/2,0]:[e.x+a+C/2,e.y+g,0],radius:B-To,height:o*1.1})),M=(0,ga.subtract)(d,N),H=jF((0,ga.union)(b,k,_,M),i);return(0,aD.colorize)($o.copper,H)}else if(e.shape==="rotated_pill_hole_with_rect_pad"){if(e.hole_shape&&e.hole_shape!=="rotated_pill"||e.pad_shape&&e.pad_shape!=="rect")throw new Error("Invalid hole_shape or pad_shape for rotated_pill_hole_with_rect_pad");const a=e.hole_offset_x||0,g=e.hole_offset_y||0,c=e.hole_width,I=e.hole_height,l=c>=I,B=l?c:I,C=l?I:c,E=C/2,Q=Math.abs(B-C),h=e.rect_pad_width||c+.2,u=e.rect_pad_height||I+.2,d=UC(e),f=.03,m=(e.hole_ccw_rotation||0)*Math.PI/180,D=(e.rect_ccw_rotation||0)*Math.PI/180,w=gA=>{const tA=a*Math.cos(m)-g*Math.sin(m),nA=a*Math.sin(m)+g*Math.cos(m),rA=(0,Kd.rotate)([0,0,m],gA);return(0,Kd.translate)([e.x+tA,e.y+nA,0],rA)},b=gA=>{if(!D)return gA;const tA=(0,Kd.translate)([-e.x,-e.y,0],gA),nA=(0,Kd.rotate)([0,0,D],tA);return(0,Kd.translate)([e.x,e.y,0],nA)},k=w((0,ga.union)((0,gr.cuboid)({center:[0,0,0],size:l?[Q+2*f,C+2*f,r]:[C+2*f,Q+2*f,r]}),(0,gr.cylinder)({center:l?[-Q/2,0,0]:[0,-Q/2,0],radius:E+f,height:r}),(0,gr.cylinder)({center:l?[Q/2,0,0]:[0,Q/2,0],radius:E+f,height:r}))),_=w((0,ga.union)((0,gr.cuboid)({center:[0,0,0],size:l?[Q,C,o*1.1]:[C,Q,o*1.1]}),(0,gr.cylinder)({center:l?[-Q/2,0,0]:[0,-Q/2,0],radius:E,height:o*1.1}),(0,gr.cylinder)({center:l?[Q/2,0,0]:[0,Q/2,0],radius:E,height:o*1.1}))),N=b(av({width:h,height:u,thickness:p0,center:[e.x,e.y,n],borderRadius:d})),M=b(av({width:h,height:u,thickness:p0,center:[e.x,e.y,s],borderRadius:d})),H=b((()=>{const gA=Math.max(r-p0*2,To),rA=(n+s)/2,QA=(0,gr.roundedRectangle)({size:[h,u],roundRadius:d||0,segments:dW}),DA=(0,fH.extrudeLinear)({height:gA},QA);return(0,Kd.translate)([e.x,e.y,rA-gA/2],DA)})()),T=(0,ga.subtract)(N,_),Y=(0,ga.subtract)(M,_),O=(0,ga.subtract)(H,_),W=w((0,ga.union)((0,gr.cuboid)({center:[0,0,0],size:l?[Q-2*To,C-2*To,o*1.1]:[C-2*To,Q-2*To,o*1.1]}),(0,gr.cylinder)({center:l?[-Q/2,0,0]:[0,-Q/2,0],radius:E-To,height:o*1.1}),(0,gr.cylinder)({center:l?[Q/2,0,0]:[0,Q/2,0],radius:E-To,height:o*1.1}))),$=(0,ga.subtract)(k,W),iA=jF((0,ga.union)(T,Y,O,$),i);return(0,aD.colorize)($o.copper,iA)}else if(e.shape==="hole_with_polygon_pad"){const a=e.pad_outline;if(!Array.isArray(a)||a.length<3)throw new Error(`Invalid pad_outline for plated hole at (${e.x}, ${e.y})`);const g=a.map(f=>[f.x,f.y]),c=(0,gr.polygon)({points:g}),I=(n+s)/2,l=(f,m)=>{const D=Math.max(f,To),w=(0,fH.extrudeLinear)({height:D},c);return(0,Kd.translate)([e.x,e.y,m-D/2],w)},B=l(Math.max(r-p0*2,To),I),C=l(p0,n),E=l(p0,s),Q=jF((0,ga.union)(B,C,E),i),h=uW(e,r);if(!h)return(0,aD.colorize)($o.copper,Q);const u=uW(e,o,{sizeDelta:-2*To})||h;let d=(0,ga.union)((0,ga.subtract)(Q,h),h);return t.clipGeom?(d=(0,ga.subtract)(d,u),d=(0,ga.intersect)(d,t.clipGeom),(0,aD.colorize)($o.copper,d)):(0,aD.colorize)($o.copper,(0,ga.subtract)(d,u))}else throw new Error(`Unsupported plated hole shape: ${e.shape}`)},pW=Or(oH()),s6A=Or(ON()),f_e=Or(WF()),mH=Or(Qx());function y_e({x:e,y:A,outerDiameter:t,holeDiameter:i,thickness:o}){if(t<=i)throw new Error(`Invalid via geometry: outerDiameter (${t}) must be > holeDiameter (${i})`);const n=To,s=To,r=Math.min(t/2,i/2+s),a=(0,mH.cylinder)({center:[0,0,0],radius:r,height:o,segments:XB}),g=(0,mH.cylinder)({center:[0,0,o/2],radius:t/2,height:n,segments:XB}),c=(0,mH.cylinder)({center:[0,0,-o/2],radius:t/2,height:n,segments:XB}),I=(0,s6A.union)([a,g,c]),l=o+n*2,B=(0,mH.cylinder)({center:[0,0,0],radius:i/2,height:l,segments:XB}),C=(0,s6A.subtract)(I,B);return(0,f_e.translate)([e,A,0],C)}function m_e({x:e,y:A,holeDiameter:t,thickness:i}){const o=i*1.5,n=t/2+To;return(0,mH.cylinder)({center:[e,A,0],radius:n,height:o,segments:XB})}var r6A=64,w_e=1,JEA=.05,a6A=(e,A,t,i)=>{const o=d0(e,A,i);if(o<=0)return(0,xg.cuboid)({center:[0,0,0],size:[e,A,t]});const n=(0,xg.roundedRectangle)({size:[e,A],roundRadius:o,segments:r6A}),s=(0,pW.extrudeLinear)({height:t},n);return(0,kE.translate)([0,0,-t/2],s)},g6A=["initializing","processing_pads","processing_copper_pours","processing_plated_holes","processing_holes","processing_cutouts","processing_vias","finalizing","done"],D_e=class{circuitJson;board;plated_holes;holes;pads;traces;pcb_vias;pcb_cutouts;boardGeom=null;platedHoleGeoms=[];padGeoms=[];viaGeoms=[];copperPourGeoms=[];boardClipGeom=null;state="initializing";currentIndex=0;ctx;onCompleteCallback;finalGeoms=[];getHoleToCut(e,A){const t=To/10;for(const i of this.pcb_vias)if(Math.abs(i.x-e)<t&&Math.abs(i.y-A)<t&&i.hole_diameter)return{diameter:i.hole_diameter};for(const i of this.plated_holes)if(i.shape==="circle"&&Math.abs(i.x-e)<t&&Math.abs(i.y-A)<t&&i.hole_diameter)return{diameter:i.hole_diameter};return null}constructor(e,A){this.circuitJson=e,this.onCompleteCallback=A;const t=e.filter(o=>o.type==="pcb_panel"),i=xi(e).pcb_board.list();if(t.length>0){const o=t[0],n=i.find(s=>s.pcb_panel_id===o.pcb_panel_id);this.board={type:"pcb_board",pcb_board_id:o.pcb_panel_id,center:o.center,width:o.width,height:o.height,thickness:n?.thickness??1.4,material:n?.material??"fr4",num_layers:n?.num_layers??2}}else{const o=i.filter(n=>!n.pcb_panel_id);this.board=o[0]}this.plated_holes=xi(e).pcb_plated_hole.list(),this.holes=xi(e).pcb_hole.list(),this.pads=xi(e).pcb_smtpad.list(),this.traces=xi(e).pcb_trace.list(),this.pcb_vias=xi(e).pcb_via.list(),this.pcb_cutouts=xi(e).pcb_cutout.list(),this.ctx={pcbThickness:this.board.thickness??1.2},this.initializeBoard()}initializeBoard(){const e=this.ctx.pcbThickness+2*w_e;this.board.outline&&this.board.outline.length>0?(this.boardGeom=YEA({outline:this.board.outline},this.ctx.pcbThickness),this.boardClipGeom=YEA({outline:this.board.outline},e,{xyOutset:JEA})):(this.boardGeom=(0,xg.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.boardClipGeom=(0,xg.cuboid)({size:[this.board.width+2*JEA,this.board.height+2*JEA,e],center:[this.board.center.x,this.board.center.y,0]})),this.state="processing_pads",this.currentIndex=0}goToNextState(){const e=g6A.indexOf(this.state);e!==-1&&(this.state=g6A[e+1],this.currentIndex=0)}step(e=1){if(this.state==="done"||!this.boardGeom)return!0;for(let A=0;A<e&&this.state!=="done";A++)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_vias":this.currentIndex<this.pcb_vias.length?(this.processVia(this.pcb_vias[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(e){if(!this.boardGeom)return;let A=null;const t=this.ctx.pcbThickness*1.5;switch(e.shape){case"rect":{const i=d0(e.width,e.height,UC(e));if(i>0){const o=(0,xg.roundedRectangle)({size:[e.width,e.height],roundRadius:i,segments:r6A});A=(0,pW.extrudeLinear)({height:t},o),A=(0,kE.translate)([0,0,-t/2],A)}else A=(0,xg.cuboid)({center:[0,0,0],size:[e.width,e.height,t]});if(e.rotation){const o=e.rotation*Math.PI/180;A=(0,kE.rotateZ)(o,A)}A=(0,kE.translate)([e.center.x,e.center.y,0],A);break}case"circle":A=(0,xg.cylinder)({center:[e.center.x,e.center.y,0],radius:e.radius,height:t});break;case"polygon":{let i=e.points.map(n=>[n.x,n.y]);if(i.length<3){console.warn(`PCB Cutout [${e.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}o6A(i)&&(i=i.reverse());const o=(0,xg.polygon)({points:i});A=(0,pW.extrudeLinear)({height:t},o),A=(0,kE.translate)([0,0,-t/2],A);break}}A&&(this.boardGeom=(0,kg.subtract)(this.boardGeom,A))}processPlatedHole(e,A={}){if(this.boardGeom){if(e.shape==="circle"||e.shape==="circular_hole_with_rect_pad"){let t=null;if(e.shape==="circular_hole_with_rect_pad"){if(e.hole_shape&&e.hole_shape!=="circle"||e.pad_shape&&e.pad_shape!=="rect")return;t=(0,xg.cylinder)({center:[e.x+(e.hole_offset_x||0),e.y+(e.hole_offset_y||0),0],radius:e.hole_diameter/2+To,height:this.ctx.pcbThickness*1.5})}else t=(0,xg.cylinder)({center:[e.x,e.y,0],radius:e.hole_diameter/2+To,height:this.ctx.pcbThickness*1.5});A.dontCutBoard||(this.boardGeom=(0,kg.subtract)(this.boardGeom,t)),this.padGeoms=this.padGeoms.map(o=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(o,t)));const i=yH(e,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(i)}else if(e.shape==="pill"||e.shape==="oval"){const t=e.hole_height>e.hole_width,i=t?e.hole_height:e.hole_width,o=t?e.hole_width:e.hole_height,n=o/2,s=Math.abs(i-o);let r;if(r=(0,kg.union)((0,xg.cuboid)({center:[e.x,e.y,0],size:t?[o,s,this.ctx.pcbThickness*1.5]:[s,o,this.ctx.pcbThickness*1.5]}),(0,xg.cylinder)({center:t?[e.x,e.y-s/2,0]:[e.x-s/2,e.y,0],radius:n,height:this.ctx.pcbThickness*1.5}),(0,xg.cylinder)({center:t?[e.x,e.y+s/2,0]:[e.x+s/2,e.y,0],radius:n,height:this.ctx.pcbThickness*1.5})),e.ccw_rotation){const g=e.ccw_rotation*Math.PI/180;r=(0,kE.translate)([e.x,e.y,0],(0,kE.rotateZ)(g,(0,kE.translate)([-e.x,-e.y,0],r)))}A.dontCutBoard||(this.boardGeom=(0,kg.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(g,r)));const a=yH(e,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(a)}else if(e.shape==="pill_hole_with_rect_pad"){if(e.hole_shape&&e.hole_shape!=="pill"||e.pad_shape&&e.pad_shape!=="rect")return;const t=e.hole_height>e.hole_width,i=t?e.hole_height:e.hole_width,o=t?e.hole_width:e.hole_height,n=o/2,s=Math.abs(i-o);let r;r=(0,kg.union)((0,xg.cuboid)({center:[e.x+(e.hole_offset_x||0),e.y+(e.hole_offset_y||0),0],size:t?[o,s,this.ctx.pcbThickness*1.5]:[s,o,this.ctx.pcbThickness*1.5]}),(0,xg.cylinder)({center:t?[e.x+(e.hole_offset_x||0),e.y+(e.hole_offset_y||0)-s/2,0]:[e.x+(e.hole_offset_x||0)-s/2,e.y+(e.hole_offset_y||0),0],radius:n,height:this.ctx.pcbThickness*1.5}),(0,xg.cylinder)({center:t?[e.x+(e.hole_offset_x||0),e.y+(e.hole_offset_y||0)+s/2,0]:[e.x+(e.hole_offset_x||0)+s/2,e.y+(e.hole_offset_y||0),0],radius:n,height:this.ctx.pcbThickness*1.5})),A.dontCutBoard||(this.boardGeom=(0,kg.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(g,r)));const a=yH(e,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(a)}else if(e.shape==="rotated_pill_hole_with_rect_pad"){if(e.hole_shape&&e.hole_shape!=="rotated_pill"||e.pad_shape&&e.pad_shape!=="rect")return;const t=e.hole_width,i=e.hole_height,o=t>=i,n=o?t:i,s=o?i:t,r=s/2,a=Math.abs(n-s),g=e.hole_offset_x||0,c=e.hole_offset_y||0;let I=(0,kg.union)((0,xg.cuboid)({center:[0,0,0],size:o?[a,s,this.ctx.pcbThickness*1.5]:[s,a,this.ctx.pcbThickness*1.5]}),(0,xg.cylinder)({center:o?[-a/2,0,0]:[0,-a/2,0],radius:r,height:this.ctx.pcbThickness*1.5}),(0,xg.cylinder)({center:o?[a/2,0,0]:[0,a/2,0],radius:r,height:this.ctx.pcbThickness*1.5}));const l=(e.hole_ccw_rotation||0)*Math.PI/180,B=g*Math.cos(l)-c*Math.sin(l),C=g*Math.sin(l)+c*Math.cos(l);I=(0,kE.rotateZ)(l,I);const E=(0,kE.translate)([e.x+B,e.y+C,0],I);A.dontCutBoard||(this.boardGeom=(0,kg.subtract)(this.boardGeom,E)),this.padGeoms=this.padGeoms.map(h=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(h,E)));const Q=yH(e,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(Q)}else if(e.shape==="hole_with_polygon_pad"){const t=e.pad_outline;if(!Array.isArray(t)||t.length<3)return;const i=this.ctx.pcbThickness*1.5,o=uW(e,i,{sizeDelta:2*To}),n=uW(e,i,{sizeDelta:-2*To});if(!o||!n)return;A.dontCutBoard||(this.boardGeom=(0,kg.subtract)(this.boardGeom,o)),this.padGeoms=this.padGeoms.map(r=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(r,o))),this.platedHoleGeoms=this.platedHoleGeoms.map(r=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(r,n)));const s=yH(e,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(s)}}}processHole(e){if(!this.boardGeom)return;const A=this.ctx.pcbThickness*1.5;if(e.hole_shape==="circle"){const t=(0,xg.cylinder)({center:[e.x,e.y,0],radius:e.hole_diameter/2+To,height:A});this.boardGeom=(0,kg.subtract)(this.boardGeom,t),this.padGeoms=this.padGeoms.map(o=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(o,t)));const i=(0,xg.cylinder)({center:[e.x,e.y,0],radius:e.hole_diameter/2+To/2,height:A});this.platedHoleGeoms=this.platedHoleGeoms.map(o=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(o,i)))}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"||e.hole_shape==="oval"){const t=e.hole_width??e.hole_diameter,i=e.hole_height??e.hole_diameter,o=e.ccw_rotation??e.rotation??0,n=.02,s=(g,c,I,l)=>{if(g<=0||c<=0)return null;if(l)return(0,kE.translate)([0,0,-I/2],(0,pW.extrudeLinear)({height:I},(0,xg.ellipse)({radius:[g/2,c/2]})));const B=Math.min(g,c)/2,C=Math.abs(g-c);return g>c?(0,kg.union)((0,xg.cuboid)({center:[0,0,0],size:[C,c,I]}),(0,xg.cylinder)({center:[-C/2,0,0],radius:B,height:I}),(0,xg.cylinder)({center:[C/2,0,0],radius:B,height:I})):(0,kg.union)((0,xg.cuboid)({center:[0,0,0],size:[g,C,I]}),(0,xg.cylinder)({center:[0,-C/2,0],radius:B,height:I}),(0,xg.cylinder)({center:[0,C/2,0],radius:B,height:I}))};let r=s(t,i,A,e.hole_shape==="oval"),a=s(t-2*n,i-2*n,A,e.hole_shape==="oval");if(r&&o!==0&&(r=(0,kE.rotateZ)(o*Math.PI/180,r)),a&&o!==0&&(a=(0,kE.rotateZ)(o*Math.PI/180,a)),r){const g=(0,kE.translate)([e.x,e.y,0],r);this.boardGeom=(0,kg.subtract)(this.boardGeom,g),this.padGeoms=this.padGeoms.map(c=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(c,g)))}if(a){const g=(0,kE.translate)([e.x,e.y,0],a);this.platedHoleGeoms=this.platedHoleGeoms.map(c=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(c,g)))}}}processPad(e){const A=e.layer==="bottom"?-1:1,t=A*this.ctx.pcbThickness/2+A*Za.copper,i=UC(e);if(e.shape==="rect"){const o=a6A(e.width,e.height,To,i);let s=(0,kE.translate)([e.x,e.y,t],o);this.boardClipGeom&&(s=(0,kg.intersect)(this.boardClipGeom,s)),s=(0,Pu.colorize)($o.copper,s),this.padGeoms.push(s)}else if(e.shape==="rotated_rect"){let o=a6A(e.width,e.height,To,i);const n=e.ccw_rotation*Math.PI/180;o=(0,kE.rotateZ)(n,o);let r=(0,kE.translate)([e.x,e.y,t],o);this.boardClipGeom&&(r=(0,kg.intersect)(this.boardClipGeom,r)),r=(0,Pu.colorize)($o.copper,r),this.padGeoms.push(r)}else if(e.shape==="circle"){let o=(0,xg.cylinder)({center:[e.x,e.y,t],radius:e.radius,height:To});this.boardClipGeom&&(o=(0,kg.intersect)(this.boardClipGeom,o)),o=(0,Pu.colorize)($o.copper,o),this.padGeoms.push(o)}}processVia(e){if(this.boardGeom){if(typeof e.outer_diameter=="number"&&typeof e.hole_diameter=="number"){const A=y_e({x:e.x,y:e.y,outerDiameter:e.outer_diameter,holeDiameter:e.hole_diameter,thickness:this.ctx.pcbThickness});let t=A;this.boardClipGeom&&(t=(0,kg.intersect)(this.boardClipGeom,A),t=(0,Pu.colorize)($o.copper,t)),this.viaGeoms.push(t)}if(typeof e.hole_diameter=="number"){const A=m_e({x:e.x,y:e.y,holeDiameter:e.hole_diameter,thickness:this.ctx.pcbThickness});this.boardGeom=(0,kg.subtract)(this.boardGeom,A),this.padGeoms=this.padGeoms.map(t=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(t,A)))}}}finalize(){if(!this.boardGeom)return;const e=HEA[this.board.material]??$o.fr4Tan;this.boardGeom=(0,Pu.colorize)(e,this.boardGeom),this.finalGeoms=[this.boardGeom,...this.platedHoleGeoms,...this.padGeoms,...this.viaGeoms,...this.copperPourGeoms],this.onCompleteCallback&&this.onCompleteCallback(this.finalGeoms)}getGeoms(){return this.finalGeoms}},S_e=e=>{const[A,t]=AA.useState(null),i=AA.useRef(!1);return AA.useEffect(()=>{let o=!1;if(!e){t(null);return}if(!e.some(g=>g.type==="pcb_board"||g.type==="pcb_panel")){t(null);return}const s=C_e(e);t(s);const r=new D_e(e,g=>{});return(async()=>{if(!i.current){i.current=!0;try{let g=!1;for(;!g&&!o;)g=r.step(1),g||await new Promise(c=>setTimeout(c,0));o||t(r.getGeoms())}catch(g){console.error("Error during board geometry building:",g)}finally{i.current=!1}}})(),()=>{o=!0}},[e]),A},b_e=({children:e,parent:A,position:t,rotation:i,scale:o,color:n,fontSize:s,anchorX:r,anchorY:a,depthOffset:g})=>{const{rootObject:c}=Ku(),I=AA.useMemo(()=>{const l=new K$;return l.text=e,t&&l.position.fromArray(t),i&&l.rotation.fromArray(i),o&&l.scale.fromArray(o),l.color=n||"white",l.fontSize=s||1,l.anchorX=r||"center",l.anchorY=a||"middle",l.depthOffset=g||0,l.font=null,l.sync(),l},[e,t,i,o,n,s,r,a,g]);return AA.useEffect(()=>{const l=A||c;if(!(!l||!I))return l.add(I),()=>{l.remove(I),I.dispose()}},[c,A,I]),null},c6A=({error:e,cad_component:A})=>{const{rootObject:t}=Ku(),[i,o]=AA.useState(!1),[n,s]=AA.useState(null),r=AA.useCallback(I=>{I?.mousePosition?(o(!0),s(I.mousePosition)):(o(!1),s(null))},[]),a=AA.useCallback(()=>{o(!1),s(null)},[]),g=AA.useMemo(()=>A?.position?[A.position.x,A.position.y,A.position.z].map(l=>Number.isNaN(l)?0:l):[0,0,0],[A]),c=AA.useMemo(()=>{const I=new ef;return I.position.fromArray(g),I},[g]);return AA.useEffect(()=>{if(t)return t.add(c),()=>{t.remove(c)}},[t,c]),Z.jsxs(Z.Fragment,{children:[Z.jsxs(dH,{isHovered:i,onHover:r,onUnhover:a,object:c,children:[Z.jsx(__e,{parent:c}),Z.jsx(b_e,{parent:c,scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:`${e.toString().slice(0,50)}...`})]}),i&&n?Z.jsx(DzA,{position:n,style:{fontFamily:"sans-serif",transform:"translate3d(-1rem, 0rem, 0)",backgroundColor:"white",padding:"6px",borderRadius:"4px",color:"red",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:e.toString()}):null]})},__e=({parent:e})=>{const A=AA.useMemo(()=>{const t=new sn(new km(.5,.5,.5),new mh({depthTest:!1,transparent:!0,color:"red",opacity:.5}));return t.renderOrder=999999,t.rotation.fromArray([Math.PI/4,Math.PI/4,0]),t},[]);return AA.useEffect(()=>(e.add(A),()=>{e.remove(A)}),[e,A]),null};function x_e({stlUrl:e,stlData:A,mtlUrl:t,color:i,opacity:o=1}){const{rootObject:n}=Ku(),[s,r]=AA.useState(null);AA.useEffect(()=>{const g=new mvt;if(A){try{const c=g.parse(A);r(c)}catch(c){console.error("Failed to parse STL data",c),r(null)}return}e&&g.load(e,c=>{r(c)})},[e,A]);const a=AA.useMemo(()=>{if(!s)return null;const g=new mh({color:Array.isArray(i)?new Pi(i[0],i[1],i[2]):i,transparent:o!==1,opacity:o});return new sn(s,g)},[s,i,o]);return AA.useEffect(()=>{if(!(!n||!a))return n.add(a),()=>{n.remove(a),a.geometry.dispose(),Array.isArray(a.material)?a.material.forEach(g=>g.dispose()):a.material.dispose()}},[n,a]),null}function k_e({stlData:e,color:A,opacity:t=1,layerType:i}){const{visibility:o}=WN();let n=!0;return i==="board"?n=o.boardBody:i==="top-copper"?n=o.topCopper:i==="bottom-copper"?n=o.bottomCopper:i==="top-silkscreen"?n=o.topSilkscreen:i==="bottom-silkscreen"&&(n=o.bottomSilkscreen),n?Z.jsx(x_e,{stlData:e,color:A,opacity:t}):null}var I6A=class extends no.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},F_e=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,o=e[0].y;for(let n=1;n<e.length;n++){const s=e[n];s.x<A&&(A=s.x),s.y<t&&(t=s.y),s.x>i&&(i=s.x),s.y>o&&(o=s.y)}return{minX:A,minY:t,maxX:i,maxY:o}};function zF(e){if(e.outline&&e.outline.length>=3){const s=F_e(e.outline);return{...s,width:s.maxX-s.minX,height:s.maxY-s.minY,centerX:(s.minX+s.maxX)/2,centerY:(s.minY+s.maxY)/2}}const A=e.width??0,t=e.height??0,i=e.center?.x??0,o=e.center?.y??0;return{...{minX:i-A/2,maxX:i+A/2,minY:o-t/2,maxY:o+t/2},width:A,height:t,centerX:i,centerY:o}}function fW({layer:e,circuitJson:A,boardData:t,soldermaskColor:i,traceTextureResolution:o}){const n=zF(t),s=document.createElement("canvas"),r=Math.floor(n.width*o),a=Math.floor(n.height*o);s.width=r,s.height=a;const g=s.getContext("2d");if(!g)return null;e==="bottom"&&(g.translate(0,a),g.scale(1,-1));const c=f=>(f-n.minX)*o,I=f=>(n.maxY-f)*o;if(g.fillStyle=i,t.outline&&t.outline.length>=3){g.beginPath();const f=t.outline[0];g.moveTo(c(f.x),I(f.y));for(let m=1;m<t.outline.length;m++){const D=t.outline[m];g.lineTo(c(D.x),I(D.y))}g.closePath(),g.fill()}else g.fillRect(0,0,r,a);g.globalCompositeOperation="destination-out",g.fillStyle="black",xi(A).pcb_smtpad.list().filter(f=>f.layer===e).forEach(f=>{if(f.shape==="polygon"&&f.points){g.beginPath(),f.points.forEach((k,_)=>{const N=c(k.x),M=I(k.y);_===0?g.moveTo(N,M):g.lineTo(N,M)}),g.closePath(),g.fill();return}if(f.x===void 0||f.y===void 0)return;if(Number.isNaN(f.x)||Number.isNaN(f.y)){console.warn(`[soldermask-texture] Skipping pad ${f.pcb_smtpad_id} with NaN coordinates`);return}const m=f.x,D=f.y,w=c(m),b=I(D);if(f.shape==="rect"){const k=f.width*o,_=f.height*o,N=UC(f),M=d0(f.width,f.height,N)*o;M>0?(g.beginPath(),g.roundRect(w-k/2,b-_/2,k,_,M),g.fill()):g.fillRect(w-k/2,b-_/2,k,_)}else if(f.shape==="circle"){const k=(f.radius??f.width/2)*o;g.beginPath(),g.arc(w,b,k,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const k=f.width*o,_=f.height*o,N=UC(f),M=d0(f.width,f.height,N)*o;g.beginPath(),g.roundRect(w-k/2,b-_/2,k,_,M),g.fill()}else if(f.shape==="rotated_rect"){const k=f.width*o,_=f.height*o,N=UC(f),M=d0(f.width,f.height,N)*o,T=-(f.ccw_rotation||0)*(Math.PI/180);g.save(),g.translate(w,b),g.rotate(T),g.beginPath(),g.roundRect(-k/2,-_/2,k,_,M),g.fill(),g.restore()}}),xi(A).pcb_via.list().forEach(f=>{const m=c(f.x),D=I(f.y),w=f.outer_diameter/2*o;g.beginPath(),g.arc(m,D,w,0,2*Math.PI),g.fill()}),xi(A).pcb_plated_hole.list().forEach(f=>{if(!f.layers?.includes(e))return;const m=f.x,D=f.y,w=c(m),b=I(D);if(f.shape==="circle"){const _=f.outer_diameter/2*o;g.beginPath(),g.arc(w,b,_,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const k=(f.outer_width??f.outer_diameter??f.hole_width)*o,_=(f.outer_height??f.outer_diameter??f.hole_height)*o,N=Math.min(k,_)/2,H=-(f.ccw_rotation||0);H?(g.save(),g.translate(w,b),g.rotate(H*Math.PI/180),g.beginPath(),g.roundRect(-k/2,-_/2,k,_,N),g.fill(),g.restore()):(g.beginPath(),g.roundRect(w-k/2,b-_/2,k,_,N),g.fill())}else if(f.shape==="oval"){const k=(f.outer_width??f.outer_diameter??f.hole_width)*o,_=(f.outer_height??f.outer_diameter??f.hole_height)*o,N=k/2,M=_/2,T=-(f.ccw_rotation||0);T?(g.save(),g.translate(w,b),g.rotate(T*Math.PI/180),g.beginPath(),g.ellipse(0,0,N,M,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(w,b,N,M,0,0,2*Math.PI),g.fill())}else if(f.shape==="hole_with_polygon_pad"){const k=f.hole_shape||"circle",_=f.hole_offset_x||0,N=f.hole_offset_y||0,M=c(f.x+_),H=I(f.y+N);if(k==="pill"||k==="rotated_pill"){const T=(f.outer_width??f.outer_diameter??f.hole_width)*o,Y=(f.outer_height??f.outer_diameter??f.hole_height)*o,O=Math.min(T,Y)/2,$=-(f.ccw_rotation||0);$?(g.save(),g.translate(M,H),g.rotate($*Math.PI/180),g.beginPath(),g.roundRect(-T/2,-Y/2,T,Y,O),g.fill(),g.restore()):(g.beginPath(),g.roundRect(M-T/2,H-Y/2,T,Y,O),g.fill())}else if(k==="oval"){const T=(f.outer_width??f.outer_diameter??f.hole_width)*o,Y=(f.outer_height??f.outer_diameter??f.hole_height)*o,O=T/2,W=Y/2,iA=-(f.ccw_rotation||0);iA?(g.save(),g.translate(M,H),g.rotate(iA*Math.PI/180),g.beginPath(),g.ellipse(0,0,O,W,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(M,H,O,W,0,0,2*Math.PI),g.fill())}else if(k==="circle"){const Y=(f.outer_diameter??f.hole_diameter??0)*o/2;g.beginPath(),g.arc(M,H,Y,0,2*Math.PI),g.fill()}f.pad_outline&&f.pad_outline.length>=3&&(g.beginPath(),f.pad_outline.forEach((T,Y)=>{const O=c(f.x+T.x),W=I(f.y+T.y);Y===0?g.moveTo(O,W):g.lineTo(O,W)}),g.closePath(),g.fill())}else if(f.shape==="circular_hole_with_rect_pad"){const k=(f.rect_pad_width??f.hole_diameter??0)*o,_=(f.rect_pad_height??f.hole_diameter??0)*o,N=UC(f),M=d0(f.rect_pad_width??f.hole_diameter??0,f.rect_pad_height??f.hole_diameter??0,N)*o;M>0?(g.beginPath(),g.roundRect(w-k/2,b-_/2,k,_,M),g.fill()):g.fillRect(w-k/2,b-_/2,k,_)}else if(f.shape==="pill_hole_with_rect_pad"){const k=(f.rect_pad_width??f.hole_width??0)*o,_=(f.rect_pad_height??f.hole_height??0)*o,N=UC(f),M=d0(f.rect_pad_width??f.hole_width??0,f.rect_pad_height??f.hole_height??0,N)*o,T=-(f.ccw_rotation||0);T?(g.save(),g.translate(w,b),g.rotate(T*Math.PI/180),g.beginPath(),g.roundRect(-k/2,-_/2,k,_,M),g.fill(),g.restore()):(g.beginPath(),g.roundRect(w-k/2,b-_/2,k,_,M),g.fill())}else if(f.shape==="rotated_pill_hole_with_rect_pad"){const k=(f.rect_pad_width??f.hole_width??0)*o,_=(f.rect_pad_height??f.hole_height??0)*o,N=UC(f),M=d0(f.rect_pad_width??f.hole_width??0,f.rect_pad_height??f.hole_height??0,N)*o,T=-(f.rect_ccw_rotation||0);T?(g.save(),g.translate(w,b),g.rotate(T*Math.PI/180),g.beginPath(),g.roundRect(-k/2,-_/2,k,_,M),g.fill(),g.restore()):(g.beginPath(),g.roundRect(w-k/2,b-_/2,k,_,M),g.fill())}}),xi(A).pcb_hole.list().forEach(f=>{const m=f.x,D=f.y,w=c(m),b=I(D),k=f.hole_shape;if(k==="circle"&&typeof f.hole_diameter=="number"){const _=f.hole_diameter/2*o;g.beginPath(),g.arc(w,b,_,0,2*Math.PI),g.fill()}else if(k==="pill"&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const _=f.hole_width*o,N=f.hole_height*o,M=Math.min(_,N)/2;g.beginPath(),g.roundRect(w-_/2,b-N/2,_,N,M),g.fill()}else if(k==="rotated_pill"&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const _=f.hole_width*o,N=f.hole_height*o,M=Math.min(_,N)/2,T=-(f.ccw_rotation||0)*(Math.PI/180);T?(g.save(),g.translate(w,b),g.rotate(T),g.beginPath(),g.roundRect(-_/2,-N/2,_,N,M),g.fill(),g.restore()):(g.beginPath(),g.roundRect(w-_/2,b-N/2,_,N,M),g.fill())}else if(k==="oval"&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const _=f.hole_width*o,N=f.hole_height*o,M=_/2,H=N/2;g.beginPath(),g.ellipse(w,b,M,H,0,0,2*Math.PI),g.fill()}}),xi(A).pcb_copper_pour.list().forEach(f=>{if(f.layer===e&&f.covered_with_solder_mask===!1)if(f.shape==="rect"){const m=c(f.center.x),D=I(f.center.y),w=f.width*o,b=f.height*o;g.fillRect(m-w/2,D-b/2,w,b)}else f.shape==="polygon"&&f.points&&(g.beginPath(),f.points.forEach((m,D)=>{const w=c(m.x),b=I(m.y);D===0?g.moveTo(w,b):g.lineTo(w,b)}),g.closePath(),g.fill())}),xi(A).pcb_cutout.list().forEach(f=>{switch(f.shape){case"rect":{const m=c(f.center.x),D=I(f.center.y),w=f.width*o,b=f.height*o,k=UC(f),_=d0(f.width,f.height,k);if(f.rotation){g.save(),g.translate(m,D);const N=-f.rotation*(Math.PI/180);g.rotate(N),_>0?(g.beginPath(),g.roundRect(-w/2,-b/2,w,b,_*o),g.fill()):g.fillRect(-w/2,-b/2,w,b),g.restore()}else _>0?(g.beginPath(),g.roundRect(m-w/2,D-b/2,w,b,_*o),g.fill()):g.fillRect(m-w/2,D-b/2,w,b);break}case"circle":{const m=c(f.center.x),D=I(f.center.y),w=f.radius*o;g.beginPath(),g.arc(m,D,w,0,2*Math.PI),g.fill();break}case"polygon":{if(!f.points||f.points.length<3){console.warn(`PCB Cutout [${f.pcb_cutout_id}] polygon has fewer than 3 points, skipping in soldermask texture.`);break}g.beginPath(),f.points.forEach((m,D)=>{const w=c(m.x),b=I(m.y);D===0?g.moveTo(w,b):g.lineTo(w,b)}),g.closePath(),g.fill();break}default:console.warn(`Unsupported cutout shape: ${f.shape} for cutout ${f.pcb_cutout_id} in soldermask texture.`)}}),g.globalCompositeOperation="source-over";const d=new CM(s);return d.generateMipmaps=!0,d.minFilter=Lu,d.magFilter=nB,d.anisotropy=16,d.needsUpdate=!0,d}var G_e=Or(ZQA());function l6A(e,A){return Array.isArray(A)?[e.a*A[0]+e.c*A[1]+e.e,e.b*A[0]+e.d*A[1]+e.f]:{x:e.a*A.x+e.c*A.y+e.e,y:e.b*A.x+e.d*A.y+e.f}}function px(e,A=0){return{a:1,c:0,e,b:0,d:1,f:A}}function B6A(...e){e=Array.isArray(e[0])?e[0]:e;const A=(t,i)=>({a:t.a*i.a+t.c*i.b,c:t.a*i.c+t.c*i.d,e:t.a*i.e+t.c*i.f+t.e,b:t.b*i.a+t.d*i.b,d:t.b*i.c+t.d*i.d,f:t.b*i.e+t.d*i.f+t.f});switch(e.length){case 0:throw new Error("no matrices provided");case 1:return e[0];case 2:return A(e[0],e[1]);default:{const[t,i,...o]=e,n=A(t,i);return B6A(n,...o)}}}function C6A(...e){return B6A(...e)}var{cos:R_e,sin:M_e}=Math;function Q6A(e,A,t){const i=R_e(e),o=M_e(e);return{a:i,c:-o,e:0,b:o,d:i,f:0}}function N_e(e,A){function t(){this.constructor=e}t.prototype=A.prototype,e.prototype=new t}function yW(e,A,t,i){var o=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(o,yW.prototype),o.expected=A,o.found=t,o.location=i,o.name="SyntaxError",o}N_e(yW,Error);function TEA(e,A,t){return t=t||" ",e.length>A?e:(A-=e.length,t+=t.repeat(A),e+t.slice(0,A))}yW.prototype.format=function(e){var A="Error: "+this.message;if(this.location){var t=null,i;for(i=0;i<e.length;i++)if(e[i].source===this.location.source){t=e[i].text.split(/\r\n|\n|\r/g);break}var o=this.location.start,n=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(o):o,s=this.location.source+":"+n.line+":"+n.column;if(t){var r=this.location.end,a=TEA("",n.line.toString().length," "),g=t[o.line-1],c=o.line===r.line?r.column:g.length+1,I=c-o.column||1;A+=`
|
|
5168
|
+
`,$be=({rotation:e,infiniteGrid:A,cellSize:t=1,sectionSize:i=10})=>{const{scene:o,camera:n}=Ku(),s=1e3,r=AA.useMemo(()=>{const a=new Fm(s,s);a.rotateX(-Math.PI/2);const g=new Fw({vertexShader:zbe,fragmentShader:Xbe,uniforms:{cellSize:{value:t},sectionSize:{value:i},gridColor:{value:new Pi(15658734)},sectionColor:{value:new Pi(13421823)},fadeDistance:{value:100},fadeStrength:{value:1.5}},transparent:!0,side:jB}),c=new sn(a,g);return e&&c.rotation.fromArray(e),c},[s,t,i,e]);return nH(()=>{A&&r.position.set(n.position.x,n.position.y,0)}),AA.useEffect(()=>{if(!(!o||!r))return o.add(r),()=>{o.remove(r),r.geometry.dispose(),Array.isArray(r.material)?r.material.forEach(a=>a.dispose()):r.material.dispose()}},[o,r]),null},A_e=()=>{const{scene:e}=Ku(),A=AA.useMemo(()=>new lGA(16777215,Math.PI/2),[]),t=AA.useMemo(()=>{const i=new w7(16777215,Math.PI/4);return i.position.set(-10,-10,10),i.decay=0,i},[]);return AA.useEffect(()=>{if(e)return e.add(A),e.add(t),()=>{e.remove(A),e.remove(t)}},[e,A,t]),null},t_e=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,e_e=()=>{const{controlsRef:e,mainCameraRef:A,defaultTarget:t,setController:i,getPresetConfig:o}=ux(),n=AA.useRef(null),s=AA.useRef(new Md),r=AA.useRef(new Rt),a=AA.useRef(new Rt),g=AA.useRef(new Md),c=AA.useRef(new Md),I=AA.useRef(new wg),l=AA.useRef(new wg),B=AA.useCallback(({position:E,target:Q,up:h,durationMs:u=600})=>{if(!A.current)return;const d=e.current?.target??t,f=new Rt(E[0],E[1],E[2]),m=Q?new Rt(Q[0],Q[1],Q[2]):t.clone(),D=new Rt(...h??[0,0,1]).normalize(),w=l.current;w.position.copy(f),w.up.copy(D),w.lookAt(m);const b=w.quaternion.clone(),k=A.current.quaternion.clone(),_=A.current.position.clone(),N=d.clone(),M=I.current;M.up.set(0,0,1),M.position.copy(_),M.lookAt(N);const H=M.quaternion.clone();M.up.set(0,0,1),M.position.copy(f),M.lookAt(m);const T=M.quaternion.clone(),Y=H.clone().invert().multiply(k).normalize(),O=T.clone().invert().multiply(b).normalize();n.current={fromPosition:_,toPosition:f,fromTarget:N,toTarget:m,toQuaternion:b,rollFrom:Y,rollTo:O,startTime:performance.now(),duration:u}},[A,e,t]),C=AA.useCallback(E=>{if(E==="Custom")return;const Q=o(E);Q&&B(Q)},[B,o]);return AA.useEffect(()=>A.current?(i({animateTo:B,animateToPreset:C}),()=>{i(null)}):void 0,[B,C,A,i]),nH(()=>{if(!A.current||!n.current)return;const{fromPosition:E,toPosition:Q,fromTarget:h,toTarget:u,toQuaternion:d,rollFrom:f,rollTo:m,startTime:D,duration:w}=n.current,b=performance.now()-D,k=w<=0?1:Math.min(b/w,1),_=t_e(k);A.current.position.lerpVectors(E,Q,_);const N=r.current;N.copy(h).lerp(u,_);const M=I.current;M.up.set(0,0,1),M.position.copy(A.current.position),M.lookAt(N);const H=s.current;H.copy(M.quaternion);const T=g.current;T.copy(f);const Y=c.current;Y.copy(m),f.dot(m)<0&&(Y.x*=-1,Y.y*=-1,Y.z*=-1,Y.w*=-1),Y.normalize(),T.slerp(Y,_),A.current.quaternion.copy(H).multiply(T).normalize();const O=a.current;O.set(0,1,0).applyQuaternion(A.current.quaternion).normalize(),A.current.up.copy(O),e.current?.target.copy(N),A.current.updateMatrixWorld(),e.current?.update(),k>=1&&(A.current.position.copy(Q),A.current.quaternion.copy(d),A.current.up.set(0,0,1),A.current.updateMatrixWorld(),e.current?.target.copy(u),e.current?.update(),n.current=null)}),null},i_e=()=>{const{controlsRef:e}=ux(),A=AA.useRef(null),t=AA.useRef(!1),i=AA.useRef(null),o=AA.useCallback(s=>{A.current=s,!t.current&&e.current&&UEA(s,e.current)&&(t.current=!0)},[e]),n=AA.useCallback(()=>{if(!(!A.current||!e.current)){if(!t.current&&UEA(A.current,e.current)){t.current=!0;return}clearTimeout(i.current),i.current=setTimeout(()=>{A.current&&e.current&&$XA(A.current,e.current)},150)}},[e]);return{handleCameraCreated:o,handleControlsChange:n}};function o_e(e,A){const t=new Md().setFromEuler(new Af(e.x,e.y,e.z)),i=new Rt(0,0,1);return i.applyQuaternion(t),i.multiplyScalar(A)}var n_e=()=>{const{mainCameraRef:e}=ux(),A=AA.useRef(null),t=AA.useRef(null),i=AA.useRef(null),o=AA.useRef(null),n=AA.useRef(null),s=AA.useRef(null);return AA.useEffect(()=>{if(!A.current)return;const r=document.createElement("canvas");t.current=r,A.current.appendChild(r);const a=new DP({canvas:r,antialias:!0,alpha:!0});a.setSize(120,120),a.setPixelRatio(window.devicePixelRatio),i.current=a;const g=new eF;o.current=g;const c=new fE(75,1,.1,1e3);c.up.set(0,0,1),n.current=c;const I=new lGA(16777215,Math.PI/2);g.add(I);const l=new ef;l.rotation.fromArray([Math.PI/2,0,0]);const B=1,C=new sn(new km(B,B,B),new mh({color:"white"}));l.add(C);const E=new iL(new TGt(new km(B,B,B)),new iF({color:0,linewidth:2}));l.add(E),g.add(l);const Q=.51,h=(k,_,N)=>{const M=new K$;return M.text=k,M.position.fromArray(_),N&&M.rotation.fromArray(N),M.color="black",M.fontSize=.25,M.anchorX="center",M.anchorY="middle",M.depthOffset=0,M.font=null,M.sync(),M},u=h("Front",[0,0,Q]),d=h("Back",[0,0,-Q],[0,Math.PI,0]),f=h("Right",[Q,0,0],[0,Math.PI/2,0]),m=h("Left",[-Q,0,0],[0,-Math.PI/2,0]),D=h("Top",[0,Q,0],[-Math.PI/2,0,0]),w=h("Bottom",[0,-Q,0],[Math.PI/2,0,0]);l.add(u),l.add(d),l.add(f),l.add(m),l.add(D),l.add(w);const b=()=>{if(e.current){const k=o_e(e.current.rotation??new Af(0,0,0),2);k.equals(c.position)||(c.position.copy(k),c.lookAt(0,0,0))}a.render(g,c),s.current=requestAnimationFrame(b)};return b(),()=>{s.current&&cancelAnimationFrame(s.current),u.dispose(),d.dispose(),f.dispose(),m.dispose(),D.dispose(),w.dispose(),C.geometry.dispose(),C.material.dispose(),E.geometry.dispose(),E.material.dispose(),g.clear(),a.dispose(),t.current&&A.current&&A.current.removeChild(t.current)}},[e]),Z.jsx("div",{ref:A,style:{position:"absolute",top:0,left:0,width:120,height:120,zIndex:sH.orientationCube}})},s_e=()=>{const{camera:e}=Ku(),{setCameraRotation:A}=ux();return nH(()=>{e&&A(e.rotation)}),null},t6A=AA.forwardRef(({children:e,initialCameraPosition:A=[5,-5,5],autoRotateDisabled:t,clickToInteractEnabled:i=!1,boardDimensions:o,boardCenter:n,onUserInteraction:s,onCameraControllerReady:r},a)=>{const[g,c]=AA.useState(!i),{mainCameraRef:I,handleControlsChange:l,controller:B}=ux(),{handleCameraCreated:C,handleControlsChange:E}=i_e();AA.useEffect(()=>{r&&r(B)},[B,r]);const Q=AA.useMemo(()=>{if(!o)return 10;const u=o.width??0,d=o.height??0,m=Math.max(u,d)*1.5;return m>10?m:10},[o]),h=AA.useMemo(()=>{if(n)return[n.x,n.y,0]},[n]);return Z.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Z.jsx(n_e,{}),Z.jsxs(Vbe,{ref:a,scene:{up:new Rt(0,0,1)},camera:{up:[0,0,1],position:A},onCreated:({camera:u})=>{I.current=u,C(u)},children:[Z.jsx(e_e,{}),Z.jsx(s_e,{}),g&&Z.jsx(jbe,{autoRotate:!t,autoRotateSpeed:1,onStart:s,rotateSpeed:.5,panSpeed:.75,zoomSpeed:.5,enableDamping:!0,dampingFactor:.1,target:h,onControlsChange:u=>{l(u),E()}}),Z.jsx(A_e,{}),Z.jsx($be,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:3,sectionSize:Q,args:[Q,Q]}),e]}),Z.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:["@",zXA.version]}),i&&!g&&Z.jsx("button",{type:"button",onClick:()=>c(!0),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&c(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:sH.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center"},children:Z.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"})})]})}),e6A=e=>AA.useMemo(()=>{if(!e)return[];const A=new bre;return A.add(e),A.render(),A.getCircuitJson()},[e]),r_e=e=>{const[A,t]=AA.useState([]),[i,o]=AA.useState(!0);return AA.useEffect(()=>{if(!e)return;(async()=>{o(!0);const r=(Array.isArray(e)?e:[e]).map(async(a,g)=>{const c=xle.serialize({binary:!0},[a]),l=await new Blob(c).arrayBuffer(),C=a.layerType||(g===0?"board":void 0);return{stlData:l,color:a.color,layerType:C}});try{const a=await Promise.all(r);t(a)}catch(a){console.error("Error generating STLs:",a),t([])}finally{o(!1)}})()},[e]),{stls:A,loading:i}},a_e=Or(Qx()),g_e=Or(V8()),To=.01,Za={traces:.001,copper:.002},$o={copper:[.9,.6,.2],fr4Tan:[.6,.43,.28],fr4SolderMaskGreen:[.02,.1,.04],fr4TracesWithMaskGreen:[0,.5,.25],fr4TracesWithoutMaskTan:[.6,.43,.28],fr1Tan:[.8,.4,.2],fr1TracesWithMaskCopper:[.9,.6,.2],fr1SolderMaskGreen:[.02,.1,.04]},Bf=.001,XB=32,pH=.035,fc=150,EW=.6,HEA={fr1:$o.fr1Tan,fr4:$o.fr4Tan},i6A={fr1:$o.fr1SolderMaskGreen,fr4:$o.fr4SolderMaskGreen},c_e=Or(oH()),I_e=Or(Qx()),l_e=Or(WF()),B_e=Or(EzA()),o6A=e=>{let A=0;for(let i=0;i<e.length;i++){const o=(i+1)%e.length;A+=e[i][0]*e[o][1],A-=e[o][0]*e[i][1]}return A/2<=0},YEA=(e,A=1.2,t={})=>{const{xyOutset:i=0}=t,{outline:o}=e;let n=o.map(a=>[a.x,a.y]);o6A(n)&&(n=n.reverse());let s=(0,I_e.polygon)({points:n});i!==0&&(s=(0,B_e.expand)({delta:i,corners:"edge"},s));let r=(0,c_e.extrudeLinear)({height:A},s);return r=(0,l_e.translate)([0,0,-A/2],r),r},C_e=e=>{const A=e.filter(a=>a.type==="pcb_panel"),t=xi(e).pcb_board.list();let i,o=1.2;if(A.length>0)i=A[0],o=t.find(g=>g.pcb_panel_id===i.pcb_panel_id)?.thickness??1.2;else{if(i=t.filter(g=>!g.pcb_panel_id)[0],!i)return console.warn("No pcb_board or pcb_panel found for simplified geometry"),[];o=i.thickness??1.2}let n;"outline"in i&&i.outline&&i.outline.length>0?n=YEA({outline:i.outline},o):n=(0,a_e.cuboid)({size:[i.width??10,i.height??10,o],center:[i.center.x,i.center.y,0]});const s="material"in i&&i.material?i.material:A.length>0?t.find(a=>a.pcb_panel_id===i.pcb_panel_id)?.material??"fr4":"fr4",r=HEA[s]??$o.fr4Tan;return[(0,g_e.colorize)(r,n)]},kE=Or(WF()),xg=Or(Qx()),Pu=Or(V8()),kg=Or(ON()),gr=Or(Qx()),aD=Or(V8()),ga=Or(ON()),n6A=Or(WF()),fH=Or(oH()),Kd=Or(WF()),Q_e=1e-5;function d0(e,A,t){if(typeof t!="number"||!Number.isFinite(t)||t<=0)return 0;const i=e/2,o=A/2,n=Math.min(i,o)-2*Q_e;return Math.max(0,Math.min(t,n))}function UC(e){if(!(!e||typeof e!="object"))return e.corner_radius??e.cornerRadius??e.rect_pad_border_radius??e.rectPadBorderRadius??e.rect_border_radius??e.rectBorderRadius??void 0}var dx=Or(Qx()),E_e=Or(oH()),hW=Or(WF()),h_e=Or(ON()),u_e=64,d_e=(e,A,t)=>{const i=(0,dx.ellipse)({center:[0,0],radius:[Math.max(e/2,To/2),Math.max(A/2,To/2)],segments:u_e}),o=(0,E_e.extrudeLinear)({height:t},i);return(0,hW.translate)([0,0,-t/2],o)},p_e=(e,A,t)=>{const i=Math.max(e,To),o=Math.max(A,To);if(Math.abs(i-o)<1e-6)return(0,dx.cylinder)({center:[0,0,0],radius:i/2,height:t});const n=i>=o,s=n?i:o,r=n?o:i,a=Math.max(s-r,0),g=(0,dx.cuboid)({center:[0,0,0],size:n?[a,r,t]:[r,a,t]});if(a<=1e-6)return(0,dx.cylinder)({center:[0,0,0],radius:r/2,height:t});const c=a/2,I=(0,dx.cylinder)({center:n?[-c,0,0]:[0,-c,0],radius:r/2,height:t}),l=(0,dx.cylinder)({center:n?[c,0,0]:[0,c,0],radius:r/2,height:t});return(0,h_e.union)(g,I,l)},uW=(e,A,t={})=>{const i=e.hole_shape||"circle",o=t.sizeDelta??0,n=e.hole_offset_x||0,s=e.hole_offset_y||0,r=[e.x+n,e.y+s,0];if(i==="circle"){const B=Math.max((e.hole_diameter??0)+o,To),C=Math.max(B/2,To/2);return(0,dx.cylinder)({center:r,radius:C,height:A})}const a=e.hole_width??e.hole_diameter,g=e.hole_height??e.hole_diameter;if(!a||!g)return null;const c=Math.max(a+o,To),I=Math.max(g+o,To);if(i==="oval"){const B=d_e(c,I,A);return(0,hW.translate)([r[0],r[1],0],B)}if(i==="pill"||i==="rotated_pill"){let B=p_e(c,I,A);if(!B)return null;const C=e.ccw_rotation||0;return C&&(B=(0,hW.rotateZ)(C*Math.PI/180,B)),(0,hW.translate)(r,B)}const l=Math.max((e.hole_diameter??a??g??To)+o,To);return(0,dx.cylinder)({center:r,radius:l/2,height:A})},p0=.02,dW=64,jF=(e,A)=>A?(0,ga.intersect)(A,e):e,av=({width:e,height:A,thickness:t,center:i,borderRadius:o})=>{const n=d0(e,A,o);if(n<=0)return(0,gr.cuboid)({center:i,size:[e,A,t]});const s=(0,gr.roundedRectangle)({size:[e,A],roundRadius:n,segments:dW}),r=(0,fH.extrudeLinear)({height:t},s),a=i[2]-t/2;return(0,Kd.translate)([i[0],i[1],a],r)},yH=(e,A,t={})=>{const{clipGeom:i}=t;e.shape||(e.shape="circle");const o=A.pcbThickness+2*p0+4*To,n=A.pcbThickness/2+Za.copper,s=-A.pcbThickness/2-Za.copper,r=n-s;if(e.shape==="circle"){const a=e.outer_diameter??Math.max(e.hole_diameter,0),g=r+.01,c=(0,gr.cylinder)({center:[e.x,e.y,0],radius:a/2,height:g}),I=jF(c,i),l=(0,gr.cylinder)({center:[e.x,e.y,0],radius:Math.max(e.hole_diameter/2,.01),height:o});return(0,aD.colorize)($o.copper,(0,ga.subtract)(I,l))}if(e.shape==="oval"){const a=e.outer_width||e.hole_width||0,g=e.outer_height||e.hole_height||0,c=e.hole_width||0,I=e.hole_height||0,l=(()=>{const E=(0,gr.cylinder)({center:[0,0,0],radius:1,height:r+.01,segments:64}),Q=(0,n6A.scale)([a/2,g/2,1],E);return(0,Kd.translate)([e.x,e.y,0],Q)})(),B=jF(l,i),C=(()=>{const E=(0,gr.cylinder)({center:[0,0,0],radius:1,height:o,segments:64}),Q=(0,n6A.scale)([Math.max(c/2,.01),Math.max(I/2,.01),1],E);return(0,Kd.translate)([e.x,e.y,0],Q)})();return(0,aD.colorize)($o.copper,(0,ga.subtract)(B,C))}if(e.shape==="circular_hole_with_rect_pad"){const a=e.hole_offset_x||0,g=e.hole_offset_y||0,c=e.rect_pad_width||e.hole_diameter,I=e.rect_pad_height||e.hole_diameter,l=UC(e),B=jF((0,ga.union)(av({width:c,height:I,thickness:p0,center:[e.x,e.y,n],borderRadius:l}),av({width:c,height:I,thickness:p0,center:[e.x,e.y,s],borderRadius:l}),(()=>{const h=Math.max(r-p0*2,To),f=(n+s)/2,m=(0,gr.roundedRectangle)({size:[c,I],roundRadius:l||0,segments:dW}),D=(0,fH.extrudeLinear)({height:h},m);return(0,Kd.translate)([e.x,e.y,f-h/2],D)})(),(0,gr.cylinder)({center:[e.x+(a||0),e.y+(g||0),0],radius:e.hole_diameter/2,height:r})),i),C=(0,gr.cylinder)({center:[e.x+(a||0),e.y+(g||0),0],radius:Math.max(e.hole_diameter/2-To,.01),height:o}),E=(0,gr.cylinder)({center:[e.x+(a||0),e.y+(g||0),0],radius:e.hole_diameter/2,height:r});let Q=(0,ga.union)((0,ga.subtract)(B,E),E);return t.clipGeom?(Q=(0,ga.subtract)(Q,C),Q=(0,ga.intersect)(Q,t.clipGeom),(0,aD.colorize)($o.copper,Q)):(0,aD.colorize)($o.copper,(0,ga.subtract)(Q,C))}if(e.shape==="pill"){const a=(e.ccw_rotation||0)*Math.PI/180,g=_=>{if(!a)return _;const N=(0,Kd.translate)([-e.x,-e.y,0],_),M=(0,Kd.rotate)([0,0,a],N);return(0,Kd.translate)([e.x,e.y,0],M)},c=e.hole_height>e.hole_width,I=c?e.hole_height:e.hole_width,l=c?e.hole_width:e.hole_height,B=c?e.outer_height||l+.2:e.outer_width||I+.2,C=c?e.outer_width||I+.2:e.outer_height||l+.2,E=l/2,Q=Math.abs(I-l),h=r+.01,d=((_,N,M)=>{const H=N/2,T=Math.abs(_-N);if(T<=1e-6)return(0,gr.cylinder)({center:[e.x,e.y,0],radius:H,height:M});const Y=(0,gr.cuboid)({center:[e.x,e.y,0],size:c?[N,T,M]:[T,N,M]}),O=(0,gr.cylinder)({center:c?[e.x,e.y-T/2,0]:[e.x-T/2,e.y,0],radius:H,height:M}),W=(0,gr.cylinder)({center:c?[e.x,e.y+T/2,0]:[e.x+T/2,e.y,0],radius:H,height:M});return(0,ga.union)(Y,O,W)})(B,C,h),f=(0,gr.cuboid)({center:[e.x,e.y,0],size:c?[l-2*To,Q,o]:[Q,l-2*To,o]}),m=(0,gr.cylinder)({center:c?[e.x,e.y-Q/2,0]:[e.x-Q/2,e.y,0],radius:E-To,height:o}),D=(0,gr.cylinder)({center:c?[e.x,e.y+Q/2,0]:[e.x+Q/2,e.y,0],radius:E-To,height:o}),w=(0,ga.union)(f,m,D),b=jF(g(d),i),k=g(w);return(0,aD.colorize)($o.copper,(0,ga.subtract)(b,k))}if(e.shape==="pill_hole_with_rect_pad"){if(e.hole_shape&&e.hole_shape!=="pill"||e.pad_shape&&e.pad_shape!=="rect")throw new Error("Invalid hole_shape or pad_shape for pill_hole_with_rect_pad");const a=e.hole_offset_x||0,g=e.hole_offset_y||0,c=e.hole_height>e.hole_width,I=c?e.hole_height:e.hole_width,l=c?e.hole_width:e.hole_height,B=l/2,C=Math.abs(I-l),E=e.rect_pad_width||I+.2,Q=e.rect_pad_height||l+.2,h=UC(e),u=.03,d=(0,ga.union)((0,gr.cuboid)({center:[e.x+a,e.y+g,0],size:c?[l+2*u,C+2*u,r]:[C+2*u,l+2*u,r]}),(0,gr.cylinder)({center:c?[e.x+a,e.y+g-C/2,0]:[e.x+a-C/2,e.y+g,0],radius:B+u,height:r}),(0,gr.cylinder)({center:c?[e.x+a,e.y+g+C/2,0]:[e.x+a+C/2,e.y+g,0],radius:B+u,height:r})),f=(0,ga.union)((0,gr.cuboid)({center:[e.x+a,e.y+g,0],size:c?[l,C,o*1.1]:[C,l,o*1.1]}),(0,gr.cylinder)({center:c?[e.x+a,e.y+g-C/2,0]:[e.x+a-C/2,e.y+g,0],radius:B,height:o*1.1}),(0,gr.cylinder)({center:c?[e.x+a,e.y+g+C/2,0]:[e.x+a+C/2,e.y+g,0],radius:B,height:o*1.1})),m=av({width:E,height:Q,thickness:p0,center:[e.x,e.y,n],borderRadius:h}),D=av({width:E,height:Q,thickness:p0,center:[e.x,e.y,s],borderRadius:h}),w=(()=>{const T=Math.max(r-p0*2,To),W=(n+s)/2,$=(0,gr.roundedRectangle)({size:[E,Q],roundRadius:h||0,segments:dW}),iA=(0,fH.extrudeLinear)({height:T},$);return(0,Kd.translate)([e.x,e.y,W-T/2],iA)})(),b=(0,ga.subtract)(m,f),k=(0,ga.subtract)(D,f),_=(0,ga.subtract)(w,f),N=(0,ga.union)((0,gr.cuboid)({center:[e.x+a,e.y+g,0],size:c?[l-2*To,C-2*To,o*1.1]:[C-2*To,l-2*To,o*1.1]}),(0,gr.cylinder)({center:c?[e.x+a,e.y+g-C/2,0]:[e.x+a-C/2,e.y+g,0],radius:B-To,height:o*1.1}),(0,gr.cylinder)({center:c?[e.x+a,e.y+g+C/2,0]:[e.x+a+C/2,e.y+g,0],radius:B-To,height:o*1.1})),M=(0,ga.subtract)(d,N),H=jF((0,ga.union)(b,k,_,M),i);return(0,aD.colorize)($o.copper,H)}else if(e.shape==="rotated_pill_hole_with_rect_pad"){if(e.hole_shape&&e.hole_shape!=="rotated_pill"||e.pad_shape&&e.pad_shape!=="rect")throw new Error("Invalid hole_shape or pad_shape for rotated_pill_hole_with_rect_pad");const a=e.hole_offset_x||0,g=e.hole_offset_y||0,c=e.hole_width,I=e.hole_height,l=c>=I,B=l?c:I,C=l?I:c,E=C/2,Q=Math.abs(B-C),h=e.rect_pad_width||c+.2,u=e.rect_pad_height||I+.2,d=UC(e),f=.03,m=(e.hole_ccw_rotation||0)*Math.PI/180,D=(e.rect_ccw_rotation||0)*Math.PI/180,w=gA=>{const tA=a*Math.cos(m)-g*Math.sin(m),nA=a*Math.sin(m)+g*Math.cos(m),rA=(0,Kd.rotate)([0,0,m],gA);return(0,Kd.translate)([e.x+tA,e.y+nA,0],rA)},b=gA=>{if(!D)return gA;const tA=(0,Kd.translate)([-e.x,-e.y,0],gA),nA=(0,Kd.rotate)([0,0,D],tA);return(0,Kd.translate)([e.x,e.y,0],nA)},k=w((0,ga.union)((0,gr.cuboid)({center:[0,0,0],size:l?[Q+2*f,C+2*f,r]:[C+2*f,Q+2*f,r]}),(0,gr.cylinder)({center:l?[-Q/2,0,0]:[0,-Q/2,0],radius:E+f,height:r}),(0,gr.cylinder)({center:l?[Q/2,0,0]:[0,Q/2,0],radius:E+f,height:r}))),_=w((0,ga.union)((0,gr.cuboid)({center:[0,0,0],size:l?[Q,C,o*1.1]:[C,Q,o*1.1]}),(0,gr.cylinder)({center:l?[-Q/2,0,0]:[0,-Q/2,0],radius:E,height:o*1.1}),(0,gr.cylinder)({center:l?[Q/2,0,0]:[0,Q/2,0],radius:E,height:o*1.1}))),N=b(av({width:h,height:u,thickness:p0,center:[e.x,e.y,n],borderRadius:d})),M=b(av({width:h,height:u,thickness:p0,center:[e.x,e.y,s],borderRadius:d})),H=b((()=>{const gA=Math.max(r-p0*2,To),rA=(n+s)/2,QA=(0,gr.roundedRectangle)({size:[h,u],roundRadius:d||0,segments:dW}),DA=(0,fH.extrudeLinear)({height:gA},QA);return(0,Kd.translate)([e.x,e.y,rA-gA/2],DA)})()),T=(0,ga.subtract)(N,_),Y=(0,ga.subtract)(M,_),O=(0,ga.subtract)(H,_),W=w((0,ga.union)((0,gr.cuboid)({center:[0,0,0],size:l?[Q-2*To,C-2*To,o*1.1]:[C-2*To,Q-2*To,o*1.1]}),(0,gr.cylinder)({center:l?[-Q/2,0,0]:[0,-Q/2,0],radius:E-To,height:o*1.1}),(0,gr.cylinder)({center:l?[Q/2,0,0]:[0,Q/2,0],radius:E-To,height:o*1.1}))),$=(0,ga.subtract)(k,W),iA=jF((0,ga.union)(T,Y,O,$),i);return(0,aD.colorize)($o.copper,iA)}else if(e.shape==="hole_with_polygon_pad"){const a=e.pad_outline;if(!Array.isArray(a)||a.length<3)throw new Error(`Invalid pad_outline for plated hole at (${e.x}, ${e.y})`);const g=a.map(f=>[f.x,f.y]),c=(0,gr.polygon)({points:g}),I=(n+s)/2,l=(f,m)=>{const D=Math.max(f,To),w=(0,fH.extrudeLinear)({height:D},c);return(0,Kd.translate)([e.x,e.y,m-D/2],w)},B=l(Math.max(r-p0*2,To),I),C=l(p0,n),E=l(p0,s),Q=jF((0,ga.union)(B,C,E),i),h=uW(e,r);if(!h)return(0,aD.colorize)($o.copper,Q);const u=uW(e,o,{sizeDelta:-2*To})||h;let d=(0,ga.union)((0,ga.subtract)(Q,h),h);return t.clipGeom?(d=(0,ga.subtract)(d,u),d=(0,ga.intersect)(d,t.clipGeom),(0,aD.colorize)($o.copper,d)):(0,aD.colorize)($o.copper,(0,ga.subtract)(d,u))}else throw new Error(`Unsupported plated hole shape: ${e.shape}`)},pW=Or(oH()),s6A=Or(ON()),f_e=Or(WF()),mH=Or(Qx());function y_e({x:e,y:A,outerDiameter:t,holeDiameter:i,thickness:o}){if(t<=i)throw new Error(`Invalid via geometry: outerDiameter (${t}) must be > holeDiameter (${i})`);const n=To,s=To,r=Math.min(t/2,i/2+s),a=(0,mH.cylinder)({center:[0,0,0],radius:r,height:o,segments:XB}),g=(0,mH.cylinder)({center:[0,0,o/2],radius:t/2,height:n,segments:XB}),c=(0,mH.cylinder)({center:[0,0,-o/2],radius:t/2,height:n,segments:XB}),I=(0,s6A.union)([a,g,c]),l=o+n*2,B=(0,mH.cylinder)({center:[0,0,0],radius:i/2,height:l,segments:XB}),C=(0,s6A.subtract)(I,B);return(0,f_e.translate)([e,A,0],C)}function m_e({x:e,y:A,holeDiameter:t,thickness:i}){const o=i*1.5,n=t/2+To;return(0,mH.cylinder)({center:[e,A,0],radius:n,height:o,segments:XB})}var r6A=64,w_e=1,JEA=.05,a6A=(e,A,t,i)=>{const o=d0(e,A,i);if(o<=0)return(0,xg.cuboid)({center:[0,0,0],size:[e,A,t]});const n=(0,xg.roundedRectangle)({size:[e,A],roundRadius:o,segments:r6A}),s=(0,pW.extrudeLinear)({height:t},n);return(0,kE.translate)([0,0,-t/2],s)},g6A=["initializing","processing_pads","processing_copper_pours","processing_plated_holes","processing_holes","processing_cutouts","processing_vias","finalizing","done"],D_e=class{circuitJson;board;plated_holes;holes;pads;traces;pcb_vias;pcb_cutouts;boardGeom=null;platedHoleGeoms=[];padGeoms=[];viaGeoms=[];copperPourGeoms=[];boardClipGeom=null;state="initializing";currentIndex=0;ctx;onCompleteCallback;finalGeoms=[];getHoleToCut(e,A){const t=To/10;for(const i of this.pcb_vias)if(Math.abs(i.x-e)<t&&Math.abs(i.y-A)<t&&i.hole_diameter)return{diameter:i.hole_diameter};for(const i of this.plated_holes)if(i.shape==="circle"&&Math.abs(i.x-e)<t&&Math.abs(i.y-A)<t&&i.hole_diameter)return{diameter:i.hole_diameter};return null}constructor(e,A){this.circuitJson=e,this.onCompleteCallback=A;const t=e.filter(o=>o.type==="pcb_panel"),i=xi(e).pcb_board.list();if(t.length>0){const o=t[0],n=i.find(s=>s.pcb_panel_id===o.pcb_panel_id);this.board={type:"pcb_board",pcb_board_id:o.pcb_panel_id,center:o.center,width:o.width,height:o.height,thickness:n?.thickness??1.4,material:n?.material??"fr4",num_layers:n?.num_layers??2}}else{const o=i.filter(n=>!n.pcb_panel_id);this.board=o[0]}this.plated_holes=xi(e).pcb_plated_hole.list(),this.holes=xi(e).pcb_hole.list(),this.pads=xi(e).pcb_smtpad.list(),this.traces=xi(e).pcb_trace.list(),this.pcb_vias=xi(e).pcb_via.list(),this.pcb_cutouts=xi(e).pcb_cutout.list(),this.ctx={pcbThickness:this.board.thickness??1.2},this.initializeBoard()}initializeBoard(){const e=this.ctx.pcbThickness+2*w_e;this.board.outline&&this.board.outline.length>0?(this.boardGeom=YEA({outline:this.board.outline},this.ctx.pcbThickness),this.boardClipGeom=YEA({outline:this.board.outline},e,{xyOutset:JEA})):(this.boardGeom=(0,xg.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.boardClipGeom=(0,xg.cuboid)({size:[this.board.width+2*JEA,this.board.height+2*JEA,e],center:[this.board.center.x,this.board.center.y,0]})),this.state="processing_pads",this.currentIndex=0}goToNextState(){const e=g6A.indexOf(this.state);e!==-1&&(this.state=g6A[e+1],this.currentIndex=0)}step(e=1){if(this.state==="done"||!this.boardGeom)return!0;for(let A=0;A<e&&this.state!=="done";A++)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_vias":this.currentIndex<this.pcb_vias.length?(this.processVia(this.pcb_vias[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(e){if(!this.boardGeom)return;let A=null;const t=this.ctx.pcbThickness*1.5;switch(e.shape){case"rect":{const i=d0(e.width,e.height,UC(e));if(i>0){const o=(0,xg.roundedRectangle)({size:[e.width,e.height],roundRadius:i,segments:r6A});A=(0,pW.extrudeLinear)({height:t},o),A=(0,kE.translate)([0,0,-t/2],A)}else A=(0,xg.cuboid)({center:[0,0,0],size:[e.width,e.height,t]});if(e.rotation){const o=e.rotation*Math.PI/180;A=(0,kE.rotateZ)(o,A)}A=(0,kE.translate)([e.center.x,e.center.y,0],A);break}case"circle":A=(0,xg.cylinder)({center:[e.center.x,e.center.y,0],radius:e.radius,height:t});break;case"polygon":{let i=e.points.map(n=>[n.x,n.y]);if(i.length<3){console.warn(`PCB Cutout [${e.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}o6A(i)&&(i=i.reverse());const o=(0,xg.polygon)({points:i});A=(0,pW.extrudeLinear)({height:t},o),A=(0,kE.translate)([0,0,-t/2],A);break}}A&&(this.boardGeom=(0,kg.subtract)(this.boardGeom,A))}processPlatedHole(e,A={}){if(this.boardGeom){if(e.shape==="circle"||e.shape==="circular_hole_with_rect_pad"){let t=null;if(e.shape==="circular_hole_with_rect_pad"){if(e.hole_shape&&e.hole_shape!=="circle"||e.pad_shape&&e.pad_shape!=="rect")return;t=(0,xg.cylinder)({center:[e.x+(e.hole_offset_x||0),e.y+(e.hole_offset_y||0),0],radius:e.hole_diameter/2+To,height:this.ctx.pcbThickness*1.5})}else t=(0,xg.cylinder)({center:[e.x,e.y,0],radius:e.hole_diameter/2+To,height:this.ctx.pcbThickness*1.5});A.dontCutBoard||(this.boardGeom=(0,kg.subtract)(this.boardGeom,t)),this.padGeoms=this.padGeoms.map(o=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(o,t)));const i=yH(e,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(i)}else if(e.shape==="pill"||e.shape==="oval"){const t=e.hole_height>e.hole_width,i=t?e.hole_height:e.hole_width,o=t?e.hole_width:e.hole_height,n=o/2,s=Math.abs(i-o);let r;if(r=(0,kg.union)((0,xg.cuboid)({center:[e.x,e.y,0],size:t?[o,s,this.ctx.pcbThickness*1.5]:[s,o,this.ctx.pcbThickness*1.5]}),(0,xg.cylinder)({center:t?[e.x,e.y-s/2,0]:[e.x-s/2,e.y,0],radius:n,height:this.ctx.pcbThickness*1.5}),(0,xg.cylinder)({center:t?[e.x,e.y+s/2,0]:[e.x+s/2,e.y,0],radius:n,height:this.ctx.pcbThickness*1.5})),e.ccw_rotation){const g=e.ccw_rotation*Math.PI/180;r=(0,kE.translate)([e.x,e.y,0],(0,kE.rotateZ)(g,(0,kE.translate)([-e.x,-e.y,0],r)))}A.dontCutBoard||(this.boardGeom=(0,kg.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(g,r)));const a=yH(e,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(a)}else if(e.shape==="pill_hole_with_rect_pad"){if(e.hole_shape&&e.hole_shape!=="pill"||e.pad_shape&&e.pad_shape!=="rect")return;const t=e.hole_height>e.hole_width,i=t?e.hole_height:e.hole_width,o=t?e.hole_width:e.hole_height,n=o/2,s=Math.abs(i-o);let r;r=(0,kg.union)((0,xg.cuboid)({center:[e.x+(e.hole_offset_x||0),e.y+(e.hole_offset_y||0),0],size:t?[o,s,this.ctx.pcbThickness*1.5]:[s,o,this.ctx.pcbThickness*1.5]}),(0,xg.cylinder)({center:t?[e.x+(e.hole_offset_x||0),e.y+(e.hole_offset_y||0)-s/2,0]:[e.x+(e.hole_offset_x||0)-s/2,e.y+(e.hole_offset_y||0),0],radius:n,height:this.ctx.pcbThickness*1.5}),(0,xg.cylinder)({center:t?[e.x+(e.hole_offset_x||0),e.y+(e.hole_offset_y||0)+s/2,0]:[e.x+(e.hole_offset_x||0)+s/2,e.y+(e.hole_offset_y||0),0],radius:n,height:this.ctx.pcbThickness*1.5})),A.dontCutBoard||(this.boardGeom=(0,kg.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(g,r)));const a=yH(e,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(a)}else if(e.shape==="rotated_pill_hole_with_rect_pad"){if(e.hole_shape&&e.hole_shape!=="rotated_pill"||e.pad_shape&&e.pad_shape!=="rect")return;const t=e.hole_width,i=e.hole_height,o=t>=i,n=o?t:i,s=o?i:t,r=s/2,a=Math.abs(n-s),g=e.hole_offset_x||0,c=e.hole_offset_y||0;let I=(0,kg.union)((0,xg.cuboid)({center:[0,0,0],size:o?[a,s,this.ctx.pcbThickness*1.5]:[s,a,this.ctx.pcbThickness*1.5]}),(0,xg.cylinder)({center:o?[-a/2,0,0]:[0,-a/2,0],radius:r,height:this.ctx.pcbThickness*1.5}),(0,xg.cylinder)({center:o?[a/2,0,0]:[0,a/2,0],radius:r,height:this.ctx.pcbThickness*1.5}));const l=(e.hole_ccw_rotation||0)*Math.PI/180,B=g*Math.cos(l)-c*Math.sin(l),C=g*Math.sin(l)+c*Math.cos(l);I=(0,kE.rotateZ)(l,I);const E=(0,kE.translate)([e.x+B,e.y+C,0],I);A.dontCutBoard||(this.boardGeom=(0,kg.subtract)(this.boardGeom,E)),this.padGeoms=this.padGeoms.map(h=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(h,E)));const Q=yH(e,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(Q)}else if(e.shape==="hole_with_polygon_pad"){const t=e.pad_outline;if(!Array.isArray(t)||t.length<3)return;const i=this.ctx.pcbThickness*1.5,o=uW(e,i,{sizeDelta:2*To}),n=uW(e,i,{sizeDelta:-2*To});if(!o||!n)return;A.dontCutBoard||(this.boardGeom=(0,kg.subtract)(this.boardGeom,o)),this.padGeoms=this.padGeoms.map(r=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(r,o))),this.platedHoleGeoms=this.platedHoleGeoms.map(r=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(r,n)));const s=yH(e,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(s)}}}processHole(e){if(!this.boardGeom)return;const A=this.ctx.pcbThickness*1.5;if(e.hole_shape==="circle"){const t=(0,xg.cylinder)({center:[e.x,e.y,0],radius:e.hole_diameter/2+To,height:A});this.boardGeom=(0,kg.subtract)(this.boardGeom,t),this.padGeoms=this.padGeoms.map(o=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(o,t)));const i=(0,xg.cylinder)({center:[e.x,e.y,0],radius:e.hole_diameter/2+To/2,height:A});this.platedHoleGeoms=this.platedHoleGeoms.map(o=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(o,i)))}else if(e.hole_shape==="pill"||e.hole_shape==="rotated_pill"||e.hole_shape==="oval"){const t=e.hole_width??e.hole_diameter,i=e.hole_height??e.hole_diameter,o=e.ccw_rotation??e.rotation??0,n=.02,s=(g,c,I,l)=>{if(g<=0||c<=0)return null;if(l)return(0,kE.translate)([0,0,-I/2],(0,pW.extrudeLinear)({height:I},(0,xg.ellipse)({radius:[g/2,c/2]})));const B=Math.min(g,c)/2,C=Math.abs(g-c);return g>c?(0,kg.union)((0,xg.cuboid)({center:[0,0,0],size:[C,c,I]}),(0,xg.cylinder)({center:[-C/2,0,0],radius:B,height:I}),(0,xg.cylinder)({center:[C/2,0,0],radius:B,height:I})):(0,kg.union)((0,xg.cuboid)({center:[0,0,0],size:[g,C,I]}),(0,xg.cylinder)({center:[0,-C/2,0],radius:B,height:I}),(0,xg.cylinder)({center:[0,C/2,0],radius:B,height:I}))};let r=s(t,i,A,e.hole_shape==="oval"),a=s(t-2*n,i-2*n,A,e.hole_shape==="oval");if(r&&o!==0&&(r=(0,kE.rotateZ)(o*Math.PI/180,r)),a&&o!==0&&(a=(0,kE.rotateZ)(o*Math.PI/180,a)),r){const g=(0,kE.translate)([e.x,e.y,0],r);this.boardGeom=(0,kg.subtract)(this.boardGeom,g),this.padGeoms=this.padGeoms.map(c=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(c,g)))}if(a){const g=(0,kE.translate)([e.x,e.y,0],a);this.platedHoleGeoms=this.platedHoleGeoms.map(c=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(c,g)))}}}processPad(e){const A=e.layer==="bottom"?-1:1,t=A*this.ctx.pcbThickness/2+A*Za.copper,i=UC(e);if(e.shape==="rect"){const o=a6A(e.width,e.height,To,i);let s=(0,kE.translate)([e.x,e.y,t],o);this.boardClipGeom&&(s=(0,kg.intersect)(this.boardClipGeom,s)),s=(0,Pu.colorize)($o.copper,s),this.padGeoms.push(s)}else if(e.shape==="rotated_rect"){let o=a6A(e.width,e.height,To,i);const n=e.ccw_rotation*Math.PI/180;o=(0,kE.rotateZ)(n,o);let r=(0,kE.translate)([e.x,e.y,t],o);this.boardClipGeom&&(r=(0,kg.intersect)(this.boardClipGeom,r)),r=(0,Pu.colorize)($o.copper,r),this.padGeoms.push(r)}else if(e.shape==="circle"){let o=(0,xg.cylinder)({center:[e.x,e.y,t],radius:e.radius,height:To});this.boardClipGeom&&(o=(0,kg.intersect)(this.boardClipGeom,o)),o=(0,Pu.colorize)($o.copper,o),this.padGeoms.push(o)}}processVia(e){if(this.boardGeom){if(typeof e.outer_diameter=="number"&&typeof e.hole_diameter=="number"){const A=y_e({x:e.x,y:e.y,outerDiameter:e.outer_diameter,holeDiameter:e.hole_diameter,thickness:this.ctx.pcbThickness});let t=A;this.boardClipGeom&&(t=(0,kg.intersect)(this.boardClipGeom,A),t=(0,Pu.colorize)($o.copper,t)),this.viaGeoms.push(t)}if(typeof e.hole_diameter=="number"){const A=m_e({x:e.x,y:e.y,holeDiameter:e.hole_diameter,thickness:this.ctx.pcbThickness});this.boardGeom=(0,kg.subtract)(this.boardGeom,A),this.padGeoms=this.padGeoms.map(t=>(0,Pu.colorize)($o.copper,(0,kg.subtract)(t,A)))}}}finalize(){if(!this.boardGeom)return;const e=HEA[this.board.material]??$o.fr4Tan;this.boardGeom=(0,Pu.colorize)(e,this.boardGeom),this.finalGeoms=[this.boardGeom,...this.platedHoleGeoms,...this.padGeoms,...this.viaGeoms,...this.copperPourGeoms],this.onCompleteCallback&&this.onCompleteCallback(this.finalGeoms)}getGeoms(){return this.finalGeoms}},S_e=e=>{const[A,t]=AA.useState(null),i=AA.useRef(!1);return AA.useEffect(()=>{let o=!1;if(!e){t(null);return}if(!e.some(g=>g.type==="pcb_board"||g.type==="pcb_panel")){t(null);return}const s=C_e(e);t(s);const r=new D_e(e,g=>{});return(async()=>{if(!i.current){i.current=!0;try{let g=!1;for(;!g&&!o;)g=r.step(1),g||await new Promise(c=>setTimeout(c,0));o||t(r.getGeoms())}catch(g){console.error("Error during board geometry building:",g)}finally{i.current=!1}}})(),()=>{o=!0}},[e]),A},b_e=({children:e,parent:A,position:t,rotation:i,scale:o,color:n,fontSize:s,anchorX:r,anchorY:a,depthOffset:g})=>{const{rootObject:c}=Ku(),I=AA.useMemo(()=>{const l=new K$;return l.text=e,t&&l.position.fromArray(t),i&&l.rotation.fromArray(i),o&&l.scale.fromArray(o),l.color=n||"white",l.fontSize=s||1,l.anchorX=r||"center",l.anchorY=a||"middle",l.depthOffset=g||0,l.font=null,l.sync(),l},[e,t,i,o,n,s,r,a,g]);return AA.useEffect(()=>{const l=A||c;if(!(!l||!I))return l.add(I),()=>{l.remove(I),I.dispose()}},[c,A,I]),null},c6A=({error:e,cad_component:A})=>{const{rootObject:t}=Ku(),[i,o]=AA.useState(!1),[n,s]=AA.useState(null),r=AA.useCallback(I=>{I?.mousePosition?(o(!0),s(I.mousePosition)):(o(!1),s(null))},[]),a=AA.useCallback(()=>{o(!1),s(null)},[]),g=AA.useMemo(()=>A?.position?[A.position.x,A.position.y,A.position.z].map(l=>Number.isNaN(l)?0:l):[0,0,0],[A]),c=AA.useMemo(()=>{const I=new ef;return I.position.fromArray(g),I},[g]);return AA.useEffect(()=>{if(t)return t.add(c),()=>{t.remove(c)}},[t,c]),Z.jsxs(Z.Fragment,{children:[Z.jsxs(dH,{isHovered:i,onHover:r,onUnhover:a,object:c,children:[Z.jsx(__e,{parent:c}),Z.jsx(b_e,{parent:c,scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:`${e.toString().slice(0,50)}...`})]}),i&&n?Z.jsx(DzA,{position:n,style:{fontFamily:"sans-serif",transform:"translate3d(-1rem, 0rem, 0)",backgroundColor:"white",padding:"6px",borderRadius:"4px",color:"red",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:e.toString()}):null]})},__e=({parent:e})=>{const A=AA.useMemo(()=>{const t=new sn(new km(.5,.5,.5),new mh({depthTest:!1,transparent:!0,color:"red",opacity:.5}));return t.renderOrder=999999,t.rotation.fromArray([Math.PI/4,Math.PI/4,0]),t},[]);return AA.useEffect(()=>(e.add(A),()=>{e.remove(A)}),[e,A]),null};function x_e({stlUrl:e,stlData:A,mtlUrl:t,color:i,opacity:o=1}){const{rootObject:n}=Ku(),[s,r]=AA.useState(null);AA.useEffect(()=>{const g=new mvt;if(A){try{const c=g.parse(A);r(c)}catch(c){console.error("Failed to parse STL data",c),r(null)}return}e&&g.load(e,c=>{r(c)})},[e,A]);const a=AA.useMemo(()=>{if(!s)return null;const g=new mh({color:Array.isArray(i)?new Pi(i[0],i[1],i[2]):i,transparent:o!==1,opacity:o});return new sn(s,g)},[s,i,o]);return AA.useEffect(()=>{if(!(!n||!a))return n.add(a),()=>{n.remove(a),a.geometry.dispose(),Array.isArray(a.material)?a.material.forEach(g=>g.dispose()):a.material.dispose()}},[n,a]),null}function k_e({stlData:e,color:A,opacity:t=1,layerType:i}){const{visibility:o}=WN();let n=!0;return i==="board"?n=o.boardBody:i==="top-copper"?n=o.topCopper:i==="bottom-copper"?n=o.bottomCopper:i==="top-silkscreen"?n=o.topSilkscreen:i==="bottom-silkscreen"&&(n=o.bottomSilkscreen),n?Z.jsx(x_e,{stlData:e,color:A,opacity:t}):null}var I6A=class extends no.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},F_e=e=>{if(e.length===0)return null;let A=e[0].x,t=e[0].y,i=e[0].x,o=e[0].y;for(let n=1;n<e.length;n++){const s=e[n];s.x<A&&(A=s.x),s.y<t&&(t=s.y),s.x>i&&(i=s.x),s.y>o&&(o=s.y)}return{minX:A,minY:t,maxX:i,maxY:o}};function zF(e){if(e.outline&&e.outline.length>=3){const s=F_e(e.outline);return{...s,width:s.maxX-s.minX,height:s.maxY-s.minY,centerX:(s.minX+s.maxX)/2,centerY:(s.minY+s.maxY)/2}}const A=e.width??0,t=e.height??0,i=e.center?.x??0,o=e.center?.y??0;return{...{minX:i-A/2,maxX:i+A/2,minY:o-t/2,maxY:o+t/2},width:A,height:t,centerX:i,centerY:o}}Or(Qx()),Or(ON());function G_e(e,A,t,i){if(!t||Math.abs(t)<1e-9)return[];const o=4*Math.atan(t),n=A[0]-e[0],s=A[1]-e[1],r=Math.sqrt(n*n+s*s);if(r<1e-9)return[];const a=Math.abs(r/(2*Math.sin(o/2))),g=Math.sqrt(Math.max(0,a*a-r/2*(r/2))),c=[(e[0]+A[0])/2,(e[1]+A[1])/2],I=n/r,B=-(s/r),C=I,E=c[0]+B*g*Math.sign(t),Q=c[1]+C*g*Math.sign(t),h=Math.atan2(e[1]-Q,e[0]-E),u=[],d=Math.max(2,Math.ceil(i*Math.abs(o)/(Math.PI*2)*4)),f=o/d;for(let m=1;m<d;m++){const D=h+f*m;u.push([E+a*Math.cos(D),Q+a*Math.sin(D)])}return u}function l6A(e,A){const t=[],i=e.vertices;for(let o=0;o<i.length;o++){const n=i[o],s=i[(o+1)%i.length];if(t.push([n.x,n.y]),n.bulge){const r=G_e([n.x,n.y],[s.x,s.y],n.bulge,A);t.push(...r)}}return t}function B6A({ctx:e,points:A,canvasXFromPcb:t,canvasYFromPcb:i}){A.length<3||(e.beginPath(),A.forEach((o,n)=>{const s=t(o[0]),r=i(o[1]);n===0?e.moveTo(s,r):e.lineTo(s,r)}),e.closePath(),e.fill())}function R_e({ctx:e,pour:A,canvasXFromPcb:t,canvasYFromPcb:i}){const o=A.brep_shape;if(!o||!o.outer_ring)return;const n=l6A(o.outer_ring,32);if(n.length>=3&&B6A({ctx:e,points:n,canvasXFromPcb:t,canvasYFromPcb:i}),o.inner_rings&&o.inner_rings.length>0){e.globalCompositeOperation="destination-out";for(const s of o.inner_rings){const r=l6A(s,32);r.length>=3&&B6A({ctx:e,points:r,canvasXFromPcb:t,canvasYFromPcb:i})}e.globalCompositeOperation="source-over"}}function fW({layer:e,circuitJson:A,boardData:t,traceTextureResolution:i=fc}){const o=A.filter(h=>h.type==="pcb_copper_pour"),n=e==="top"?"top_copper":"bottom_copper",s=o.filter(h=>h.layer===e);if(s.length===0)return null;const r=zF(t),a=document.createElement("canvas"),g=Math.floor(r.width*i),c=Math.floor(r.height*i);a.width=g,a.height=c;const I=a.getContext("2d");if(!I)return null;e==="bottom"&&(I.translate(0,c),I.scale(1,-1));const l=h=>(h-r.minX)*i,B=h=>(r.maxY-h)*i,C=s.filter(h=>h.shape==="rect"||h.shape==="polygon"),E=s.filter(h=>h.shape==="brep");if(C.length>0){const h=new RBe(I);h.setCameraBounds({minX:r.minX,maxX:r.maxX,minY:r.minY,maxY:r.maxY});const u=C.filter(D=>D.covered_with_solder_mask!==!1),d=C.filter(D=>D.covered_with_solder_mask===!1),f=`rgb(${$o.fr4TracesWithMaskGreen.map(D=>D*255).join(",")})`,m=`rgb(${$o.copper.map(D=>D*255).join(",")})`;u.length>0&&(h.configure({colorOverrides:{copper:{top:f,bottom:f,inner1:f,inner2:f,inner3:f,inner4:f,inner5:f,inner6:f}}}),h.drawElements(u,{layers:[n]})),d.length>0&&(h.configure({colorOverrides:{copper:{top:m,bottom:m,inner1:m,inner2:m,inner3:m,inner4:m,inner5:m,inner6:m}}}),h.drawElements(d,{layers:[n]}))}for(const h of E){const d=h.covered_with_solder_mask!==!1?$o.fr4TracesWithMaskGreen:$o.copper,f=`rgb(${d[0]*255}, ${d[1]*255}, ${d[2]*255})`;I.fillStyle=f,R_e({ctx:I,pour:h,canvasXFromPcb:l,canvasYFromPcb:B})}const Q=new CM(a);return Q.generateMipmaps=!0,Q.minFilter=Lu,Q.magFilter=nB,Q.anisotropy=16,Q.needsUpdate=!0,Q}function Cf(e,A){const{texture:t,yOffset:i,isBottomLayer:o,textureType:n,usePolygonOffset:s=!1,renderOrder:r=0,isFaux:a=!1}=e;if(!t)return null;const g=zF(A),c=new Fm(g.width,g.height),I=new Nd({map:t,transparent:!0,side:jB,depthWrite:n==="panel-outlines",polygonOffset:s,polygonOffsetFactor:s?-4:0,polygonOffsetUnits:s?-4:0,opacity:a?EW:1}),l=new sn(c,I);return l.position.set(g.centerX,g.centerY,i),o&&l.rotation.set(Math.PI,0,0),l.name=`${o?"bottom":"top"}-${n}-texture-plane`,l.renderOrder=r,l}function M_e(e,A,t,i=!1){const o=[];if(!e||!A||t===null)return o;const n=Cf({texture:e.topTrace,yOffset:t/2+Za.traces,isBottomLayer:!1,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);n&&o.push(n);const s=Cf({texture:e.topTraceWithMask,yOffset:t/2+Za.traces,isBottomLayer:!1,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);s&&o.push(s);const r=Cf({texture:e.topSilkscreen,yOffset:t/2+.003,isBottomLayer:!1,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);r&&o.push(r);const a=Cf({texture:e.bottomTrace,yOffset:-t/2-Za.traces,isBottomLayer:!0,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);a&&o.push(a);const g=Cf({texture:e.bottomTraceWithMask,yOffset:-t/2-Za.traces,isBottomLayer:!0,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);g&&o.push(g);const c=Cf({texture:e.bottomSilkscreen,yOffset:-t/2-.003,isBottomLayer:!0,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);c&&o.push(c);const I=Cf({texture:e.topSoldermask,yOffset:t/2+.001,isBottomLayer:!1,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);I&&o.push(I);const l=Cf({texture:e.bottomSoldermask,yOffset:-t/2-.001,isBottomLayer:!0,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);l&&o.push(l);const B=Cf({texture:e.topCopperText,yOffset:t/2+Za.copper,isBottomLayer:!1,textureType:"copper-text",usePolygonOffset:!0,renderOrder:2,isFaux:i},A);B&&o.push(B);const C=Cf({texture:e.bottomCopperText,yOffset:-t/2-Za.copper,isBottomLayer:!0,textureType:"copper-text",usePolygonOffset:!0,renderOrder:2,isFaux:i},A);C&&o.push(C);const E=Cf({texture:e.topCopper,yOffset:t/2+Za.copper,isBottomLayer:!1,textureType:"copper",usePolygonOffset:!0,renderOrder:2,isFaux:i},A);E&&o.push(E);const Q=Cf({texture:e.bottomCopper,yOffset:-t/2-Za.copper,isBottomLayer:!0,textureType:"copper",usePolygonOffset:!0,renderOrder:2,isFaux:i},A);Q&&o.push(Q);const h=Cf({texture:e.topPanelOutlines,yOffset:t/2+.004,isBottomLayer:!1,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);h&&o.push(h);const u=Cf({texture:e.bottomPanelOutlines,yOffset:-t/2-.004,isBottomLayer:!0,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);return u&&o.push(u),o}var N_e=Or(ZQA());function C6A(e,A){return Array.isArray(A)?[e.a*A[0]+e.c*A[1]+e.e,e.b*A[0]+e.d*A[1]+e.f]:{x:e.a*A.x+e.c*A.y+e.e,y:e.b*A.x+e.d*A.y+e.f}}function px(e,A=0){return{a:1,c:0,e,b:0,d:1,f:A}}function Q6A(...e){e=Array.isArray(e[0])?e[0]:e;const A=(t,i)=>({a:t.a*i.a+t.c*i.b,c:t.a*i.c+t.c*i.d,e:t.a*i.e+t.c*i.f+t.e,b:t.b*i.a+t.d*i.b,d:t.b*i.c+t.d*i.d,f:t.b*i.e+t.d*i.f+t.f});switch(e.length){case 0:throw new Error("no matrices provided");case 1:return e[0];case 2:return A(e[0],e[1]);default:{const[t,i,...o]=e,n=A(t,i);return Q6A(n,...o)}}}function E6A(...e){return Q6A(...e)}var{cos:v_e,sin:L_e}=Math;function h6A(e,A,t){const i=v_e(e),o=L_e(e);return{a:i,c:-o,e:0,b:o,d:i,f:0}}function U_e(e,A){function t(){this.constructor=e}t.prototype=A.prototype,e.prototype=new t}function yW(e,A,t,i){var o=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(o,yW.prototype),o.expected=A,o.found=t,o.location=i,o.name="SyntaxError",o}U_e(yW,Error);function TEA(e,A,t){return t=t||" ",e.length>A?e:(A-=e.length,t+=t.repeat(A),e+t.slice(0,A))}yW.prototype.format=function(e){var A="Error: "+this.message;if(this.location){var t=null,i;for(i=0;i<e.length;i++)if(e[i].source===this.location.source){t=e[i].text.split(/\r\n|\n|\r/g);break}var o=this.location.start,n=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(o):o,s=this.location.source+":"+n.line+":"+n.column;if(t){var r=this.location.end,a=TEA("",n.line.toString().length," "),g=t[o.line-1],c=o.line===r.line?r.column:g.length+1,I=c-o.column||1;A+=`
|
|
5169
5169
|
--> `+s+`
|
|
5170
5170
|
`+a+` |
|
|
5171
5171
|
`+n.line+" | "+g+`
|
|
5172
5172
|
`+a+" | "+TEA("",o.column-1," ")+TEA("",I,"^")}else A+=`
|
|
5173
|
-
at `+s}return A},yW.buildMessage=function(e,A){var t={literal:function(g){return'"'+o(g.text)+'"'},class:function(g){var c=g.parts.map(function(I){return Array.isArray(I)?n(I[0])+"-"+n(I[1]):n(I)});return"["+(g.inverted?"^":"")+c.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(g){return g.description}};function i(g){return g.charCodeAt(0).toString(16).toUpperCase()}function o(g){return 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(c){return"\\x0"+i(c)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(c){return"\\x"+i(c)})}function n(g){return g.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(c){return"\\x0"+i(c)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(c){return"\\x"+i(c)})}function s(g){return t[g.type](g)}function r(g){var c=g.map(s),I,l;if(c.sort(),c.length>0){for(I=1,l=1;I<c.length;I++)c[I-1]!==c[I]&&(c[l]=c[I],l++);c.length=l}switch(c.length){case 1:return c[0];case 2:return c[0]+" or "+c[1];default:return c.slice(0,-1).join(", ")+", or "+c[c.length-1]}}function a(g){return g?'"'+o(g)+'"':"end of input"}return"Expected "+r(e)+" but "+a(A)+" found."};var E6A=25.4,v_e=E6A/1e3,L_e=/^\s*(-?\d*(?:\.\d+)?)(?:\s*(mm|mil|inch|in|"))?\s*$/i;function U_e(e){if(!e)return;const A=e.trim().toLowerCase();return A==='"'||A==="inch"?"in":A}function RQ(e){if(e==null)return;if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string")return;const A=e.trim();if(A.length===0)return;const t=A.match(L_e);if(!t){const r=Number.parseFloat(A);return Number.isFinite(r)?r:void 0}const[,i,o]=t,n=Number.parseFloat(i||"0");if(!Number.isFinite(n))return;switch(U_e(o)){case"mil":return n*v_e;case"in":return n*E6A;case"mm":case void 0:return n;default:return n}}function Zm(e,A){const t=RQ(e);return t===void 0?A:t}function h6A(e){let A=e;if(A.startsWith("#")&&(A=A.slice(1)),A.length===6){const t=parseInt(A.slice(0,2),16),i=parseInt(A.slice(2,4),16),o=parseInt(A.slice(4,6),16);return`rgb(${t}, ${i}, ${o})`}return e.startsWith("rgb")?e:"rgb(255, 243, 204)"}function mW({layer:e,circuitJson:A,boardData:t,silkscreenColor:i="rgb(255,255,255)",traceTextureResolution:o}){const n=xi(A).pcb_silkscreen_text.list(),s=xi(A).pcb_silkscreen_path.list(),r=xi(A).pcb_silkscreen_line.list(),a=xi(A).pcb_silkscreen_rect.list(),g=xi(A).pcb_silkscreen_circle.list(),c=xi(A).pcb_fabrication_note_rect.list(),I=xi(A).pcb_note_line.list(),l=n.filter(N=>N.layer===e),B=s.filter(N=>N.layer===e),C=r.filter(N=>N.layer===e),E=a.filter(N=>N.layer===e),Q=g.filter(N=>N.layer===e),h=c.filter(N=>N.layer===e),u=I.filter(N=>N.layer===e);if(l.length===0&&B.length===0&&C.length===0&&E.length===0&&Q.length===0&&h.length===0&&u.length===0)return null;const d=zF(t),f=document.createElement("canvas"),m=Math.floor(d.width*o),D=Math.floor(d.height*o);f.width=m,f.height=D;const w=f.getContext("2d");if(!w)return null;e==="bottom"&&(w.translate(0,D),w.scale(1,-1)),w.strokeStyle=i,w.fillStyle=i;const b=N=>(N-d.minX)*o,k=N=>(d.maxY-N)*o;C.forEach(N=>{const M=RQ(N.x1)??0,H=RQ(N.y1)??0,T=RQ(N.x2)??0,Y=RQ(N.y2)??0;M===T&&H===Y||(w.beginPath(),w.lineWidth=Zm(N.stroke_width,.1)*o,w.lineCap="round",w.moveTo(b(M),k(H)),w.lineTo(b(T),k(Y)),w.stroke())}),u.forEach(N=>{const M=RQ(N.x1)??0,H=RQ(N.y1)??0,T=RQ(N.x2)??0,Y=RQ(N.y2)??0;if(M===T&&H===Y)return;w.save();let O=i;N.color?O=h6A(N.color):O="rgb(255, 243, 204)",w.strokeStyle=O,w.beginPath(),w.lineWidth=Zm(N.stroke_width,.1)*o,w.lineCap="round";const W=N.is_dashed??!1;if(W){const $=Math.max(w.lineWidth*2,1);w.setLineDash([$,$])}w.moveTo(b(M),k(H)),w.lineTo(b(T),k(Y)),w.stroke(),W&&w.setLineDash([]),w.restore()}),B.forEach(N=>{N.route.length<2||(w.beginPath(),w.lineWidth=Zm(N.stroke_width,.1)*o,w.lineCap="round",w.lineJoin="round",N.route.forEach((M,H)=>{const T=b(RQ(M.x)??0),Y=k(RQ(M.y)??0);H===0?w.moveTo(T,Y):w.lineTo(T,Y)}),w.stroke())}),Q.forEach(N=>{const M=Zm(N.radius,0);if(M<=0)return;const H=Zm(N.stroke_width,.12),T=H>0,Y=RQ(N.center?.x)??0,O=RQ(N.center?.y)??0,W=b(Y),$=k(O),iA=M*o;if(w.save(),w.translate(W,$),T){const gA=iA+H/2*o,tA=Math.max(0,iA-H/2*o);tA>0?(w.beginPath(),w.arc(0,0,gA,0,2*Math.PI),w.arc(0,0,tA,0,2*Math.PI,!0),w.fill("evenodd")):(w.beginPath(),w.arc(0,0,gA,0,2*Math.PI),w.fill())}else w.beginPath(),w.arc(0,0,iA,0,2*Math.PI),w.fill();w.restore()}),E.forEach(N=>{const M=Zm(N.width,0),H=Zm(N.height,0);if(M<=0||H<=0)return;const T=RQ(N.center?.x)??0,Y=RQ(N.center?.y)??0,O=b(T),W=k(Y),$=UC(N),iA=typeof $=="string"?RQ($):$,gA=d0(M,H,iA);w.save(),w.translate(O,W);const tA=M/2*o,nA=H/2*o,rA=Math.min(gA*o,tA,nA),QA=N.stroke_width??!1,DA=N.is_filled??!0,RA=N.is_stroke_dashed??!1,NA=QA?Zm(N.stroke_width,.1)*o:0;if(((EA,kA,dA,qA,PA)=>{if(w.beginPath(),PA<=0)w.rect(EA,kA,dA,qA);else{const nt=PA,fA=EA+dA,et=kA+qA;w.moveTo(EA+nt,kA),w.lineTo(fA-nt,kA),w.quadraticCurveTo(fA,kA,fA,kA+nt),w.lineTo(fA,et-nt),w.quadraticCurveTo(fA,et,fA-nt,et),w.lineTo(EA+nt,et),w.quadraticCurveTo(EA,et,EA,et-nt),w.lineTo(EA,kA+nt),w.quadraticCurveTo(EA,kA,EA+nt,kA),w.closePath()}})(-tA,-nA,tA*2,nA*2,rA),DA&&w.fill(),QA&&NA>0){if(w.lineWidth=NA,RA){const EA=Math.max(NA*2,1);w.setLineDash([EA,EA])}w.stroke(),RA&&w.setLineDash([])}w.restore()}),h.forEach(N=>{const M=Zm(N.width,0),H=Zm(N.height,0);if(M<=0||H<=0)return;const T=RQ(N.center?.x)??0,Y=RQ(N.center?.y)??0,O=b(T),W=k(Y),$=UC(N),iA=typeof $=="string"?RQ($):$,gA=d0(M,H,iA);w.save(),w.translate(O,W);const tA=M/2*o,nA=H/2*o,rA=Math.min(gA*o,tA,nA),QA=N.has_stroke??!1,DA=N.is_filled??!0,RA=N.is_stroke_dashed??!1,NA=QA?Zm(N.stroke_width,.1)*o:0;let KA=i,EA=i;if(N.color){const dA=h6A(N.color);KA=dA,EA=dA}else KA="rgb(255, 243, 204)",EA="rgb(255, 243, 204)";if(((dA,qA,PA,nt,fA)=>{if(w.beginPath(),fA<=0)w.rect(dA,qA,PA,nt);else{const et=fA,WA=dA+PA,JA=qA+nt;w.moveTo(dA+et,qA),w.lineTo(WA-et,qA),w.quadraticCurveTo(WA,qA,WA,qA+et),w.lineTo(WA,JA-et),w.quadraticCurveTo(WA,JA,WA-et,JA),w.lineTo(dA+et,JA),w.quadraticCurveTo(dA,JA,dA,JA-et),w.lineTo(dA,qA+et),w.quadraticCurveTo(dA,qA,dA+et,qA),w.closePath()}})(-tA,-nA,tA*2,nA*2,rA),DA&&(w.fillStyle=KA,w.fill()),QA&&NA>0){if(w.strokeStyle=EA,w.lineWidth=NA,RA){const dA=Math.max(NA*2,1);w.setLineDash([dA,dA])}w.stroke(),RA&&w.setLineDash([])}w.restore()}),l.forEach(N=>{const M=N.font_size||.25,H=Math.min(Math.max(.01,M*.1),M*.05)*o;w.lineWidth=H,w.lineCap="butt",w.lineJoin="miter";const T=(0,G_e.vectorText)({height:M*.45,input:N.text}),Y=[];T.forEach(RA=>{RA.length===29?(Y.push(RA.slice(0,15)),Y.push(RA.slice(14,29))):RA.length===17?(Y.push(RA.slice(0,10)),Y.push(RA.slice(9,17))):Y.push(RA)});const O=Y.flat(),W={minX:O.length>0?Math.min(...O.map(RA=>RA[0])):0,maxX:O.length>0?Math.max(...O.map(RA=>RA[0])):0,minY:O.length>0?Math.min(...O.map(RA=>RA[1])):0,maxY:O.length>0?Math.max(...O.map(RA=>RA[1])):0},$=(W.minX+W.maxX)/2,iA=(W.minY+W.maxY)/2;let gA=-$,tA=-iA;const nA=N.anchor_alignment||"center";nA.includes("left")?gA=-W.minX:nA.includes("right")&&(gA=-W.maxX),nA.includes("top")?tA=-W.maxY:nA.includes("bottom")&&(tA=-W.minY);const rA=[];let QA=N.ccw_rotation??0;if(N.layer==="bottom"&&(rA.push(px($,iA),{a:-1,b:0,c:0,d:1,e:0,f:0},px(-$,-iA)),QA=-QA),QA){const RA=QA*Math.PI/180;rA.push(px($,iA),Q6A(RA),px(-$,-iA))}const DA=rA.length>0?C6A(...rA):void 0;Y.forEach(RA=>{w.beginPath(),RA.forEach((NA,KA)=>{let EA={x:NA[0],y:NA[1]};DA&&(EA=l6A(DA,EA));const kA=EA.x+gA+N.anchor_position.x,dA=EA.y+tA+N.anchor_position.y,qA=b(kA),PA=k(dA);KA===0?w.moveTo(qA,PA):w.lineTo(qA,PA)}),w.stroke()})});const _=new CM(f);return _.generateMipmaps=!0,_.minFilter=Lu,_.magFilter=nB,_.anisotropy=16,_.needsUpdate=!0,_}function u6A(e){return e&&e.route_type==="wire"&&typeof e.layer=="string"&&typeof e.width=="number"}function gv({layer:e,circuitJson:A,boardData:t,traceColor:i,traceTextureResolution:o}){const n=xi(A).pcb_trace.list(),s=xi(A).pcb_via.list(),r=xi(A).pcb_plated_hole.list(),a=n.filter(E=>E.route.some(Q=>u6A(Q)&&Q.layer===e));if(a.length===0)return null;const g=zF(t),c=document.createElement("canvas"),I=Math.floor(g.width*o),l=Math.floor(g.height*o);c.width=I,c.height=l;const B=c.getContext("2d");if(!B)return null;e==="bottom"&&(B.translate(0,l),B.scale(1,-1)),a.forEach(E=>{let Q=!0;B.beginPath(),B.strokeStyle=i,B.lineCap="round",B.lineJoin="round";let h=0;for(const u of E.route){if(!u6A(u)||u.layer!==e){Q||B.stroke(),Q=!0;continue}const d=u.x,f=u.y;h=u.width*o,B.lineWidth=h;const m=(d-g.minX)*o,D=(g.maxY-f)*o;Q?(B.moveTo(m,D),Q=!1):B.lineTo(m,D)}Q||B.stroke()}),B.globalCompositeOperation="destination-out",B.fillStyle="black",s.forEach(E=>{const Q=(E.x-g.minX)*o,h=(g.maxY-E.y)*o,u=E.outer_diameter/2*o;B.beginPath(),B.arc(Q,h,u,0,2*Math.PI,!1),B.fill()}),r.forEach(E=>{if(E.layers.includes(e)&&E.shape==="circle"){const Q=(E.x-g.minX)*o,h=(g.maxY-E.y)*o,u=E.outer_diameter/2*o;B.beginPath(),B.arc(Q,h,u,0,2*Math.PI,!1),B.fill()}else if(E.layers.includes(e)&&E.shape==="rotated_pill_hole_with_rect_pad"){const Q=(E.x-g.minX)*o,h=(g.maxY-E.y)*o,u=(E.rect_pad_width??E.hole_width??0)*o,d=(E.rect_pad_height??E.hole_height??0)*o,m=-(E.rect_ccw_rotation||0);m?(B.save(),B.translate(Q,h),B.rotate(m*Math.PI/180),B.beginPath(),B.rect(-u/2,-d/2,u,d),B.fill(),B.restore()):(B.beginPath(),B.rect(Q-u/2,h-d/2,u,d),B.fill())}}),B.globalCompositeOperation="source-over";const C=new CM(c);return C.generateMipmaps=!0,C.minFilter=Lu,C.magFilter=nB,C.anisotropy=16,C.needsUpdate=!0,C}var H_e=Or(ZQA());function wW(e,A){if(e===void 0)return A;if(typeof e=="number")return e;const t=parseFloat(e.replace(/mm$/,""));return isNaN(t)?A:t}function Y_e(e){return e.layer==="bottom"?e.is_mirrored!==!1:e.is_mirrored===!0}function J_e(e){const A=e.flat();if(A.length===0)return{minX:0,maxX:0,minY:0,maxY:0,width:0,height:0,centerX:0,centerY:0};const t=Math.min(...A.map(s=>s[0])),i=Math.max(...A.map(s=>s[0])),o=Math.min(...A.map(s=>s[1])),n=Math.max(...A.map(s=>s[1]));return{minX:t,maxX:i,minY:o,maxY:n,width:i-t,height:n-o,centerX:(t+i)/2,centerY:(o+n)/2}}function T_e(e){const A=[];return e.forEach(t=>{t.length===29?(A.push(t.slice(0,15)),A.push(t.slice(14,29))):t.length===17?(A.push(t.slice(0,10)),A.push(t.slice(9,17))):A.push(t)}),A}function K_e(e,A){let t=-e.centerX,i=-e.centerY;return A.includes("left")?t=-e.minX:A.includes("right")&&(t=-e.maxX),A.includes("top")?i=-e.maxY:A.includes("bottom")&&(i=-e.minY),{x:t,y:i}}function P_e(e,A){const t=[];let i=e.ccw_rotation??0;if(Y_e(e)&&(t.push(px(A.centerX,A.centerY),{a:-1,b:0,c:0,d:1,e:0,f:0},px(-A.centerX,-A.centerY)),i=-i),i){const s=i*Math.PI/180;t.push(px(A.centerX,A.centerY),Q6A(s),px(-A.centerX,-A.centerY))}return{matrix:t.length>0?C6A(...t):void 0,rotationDeg:i}}function d6A(e,A,t,i,o,n,s){A.forEach(r=>{e.beginPath(),r.forEach((a,g)=>{let c={x:a[0],y:a[1]};t&&(c=l6A(t,c));const I=c.x+i.x+o.x,l=c.y+i.y+o.y,B=n(I),C=s(l);g===0?e.moveTo(B,C):e.lineTo(B,C)}),e.stroke()})}function q_e(e,A,t,i,o,n){e.save(),e.translate(A,t),e.rotate(-n),e.fillRect(-i/2,-o/2,i,o),e.restore()}function O_e(e,A,t,i,o,n,s,r,a,g){const c=typeof A.font_size=="number"?A.font_size:.2,I={left:wW(A.knockout_padding?.left,c*.5),right:wW(A.knockout_padding?.right,c*.5),top:wW(A.knockout_padding?.top,c*.3),bottom:wW(A.knockout_padding?.bottom,c*.3)},l=i.width+I.left+I.right,B=i.height+I.top+I.bottom,C=s(A.anchor_position.x),E=r(A.anchor_position.y),Q=l*a,h=B*a;e.fillStyle=g;const u=n*Math.PI/180;q_e(e,C,E,Q,h,u);const d={x:-i.centerX,y:-i.centerY};e.globalCompositeOperation="destination-out",d6A(e,t,o,d,A.anchor_position,s,r),e.globalCompositeOperation="source-over"}function DW({layer:e,circuitJson:A,boardData:t,copperColor:i="rgb(230, 153, 51)",traceTextureResolution:o}){const s=A.filter(E=>E.type==="pcb_copper_text").filter(E=>E.layer===e);if(s.length===0)return null;const r=zF(t),a=document.createElement("canvas"),g=Math.floor(r.width*o),c=Math.floor(r.height*o);a.width=g,a.height=c;const I=a.getContext("2d");if(!I)return null;e==="bottom"&&(I.translate(0,c),I.scale(1,-1)),I.strokeStyle=i,I.fillStyle=i;const l=E=>(E-r.minX)*o,B=E=>(r.maxY-E)*o;s.forEach(E=>{const Q=typeof E.font_size=="number"?E.font_size:.2,h=Math.max(.02,Q*.08)*o;I.lineWidth=h,I.lineCap="round",I.lineJoin="round";const u=(0,H_e.vectorText)({height:Q*.45,input:E.text}),d=T_e(u),f=J_e(d),{matrix:m,rotationDeg:D}=P_e(E,f);if(E.is_knockout)O_e(I,E,d,f,m,D,l,B,o,i);else{const w=E.anchor_alignment||"center",b=K_e(f,w);d6A(I,d,m,b,E.anchor_position,l,B)}});const C=new CM(a);return C.generateMipmaps=!0,C.minFilter=Lu,C.magFilter=nB,C.anisotropy=16,C.needsUpdate=!0,C}function SW({layer:e,circuitJson:A,panelData:t,outlineColor:i="black",traceTextureResolution:o}){const n=xi(A).pcb_board.list().filter(B=>B.pcb_panel_id===t.pcb_board_id);if(n.length===0)return null;const s=document.createElement("canvas"),r=Math.floor(t.width*o),a=Math.floor(t.height*o);s.width=r,s.height=a;const g=s.getContext("2d");if(!g)return null;e==="bottom"&&(g.translate(0,a),g.scale(1,-1)),g.strokeStyle=i,g.lineWidth=.05*o;const c=B=>(B-t.center.x+t.width/2)*o,I=B=>(-(B-t.center.y)+t.height/2)*o;n.forEach(B=>{if(B.outline&&B.outline.length>=2)g.beginPath(),B.outline.forEach((C,E)=>{const Q=c(C.x),h=I(C.y);E===0?g.moveTo(Q,h):g.lineTo(Q,h)}),g.closePath(),g.stroke();else{const C=B.width,E=B.height,{x:Q,y:h}=B.center,u=c(Q-C/2),d=I(h+E/2);g.strokeRect(u,d,C*o,E*o)}});const l=new CM(s);return l.generateMipmaps=!0,l.minFilter=Lu,l.magFilter=nB,l.anisotropy=16,l.needsUpdate=!0,l}Or(Qx()),Or(ON());function W_e(e,A,t,i){if(!t||Math.abs(t)<1e-9)return[];const o=4*Math.atan(t),n=A[0]-e[0],s=A[1]-e[1],r=Math.sqrt(n*n+s*s);if(r<1e-9)return[];const a=Math.abs(r/(2*Math.sin(o/2))),g=Math.sqrt(Math.max(0,a*a-r/2*(r/2))),c=[(e[0]+A[0])/2,(e[1]+A[1])/2],I=n/r,B=-(s/r),C=I,E=c[0]+B*g*Math.sign(t),Q=c[1]+C*g*Math.sign(t),h=Math.atan2(e[1]-Q,e[0]-E),u=[],d=Math.max(2,Math.ceil(i*Math.abs(o)/(Math.PI*2)*4)),f=o/d;for(let m=1;m<d;m++){const D=h+f*m;u.push([E+a*Math.cos(D),Q+a*Math.sin(D)])}return u}function p6A(e,A){const t=[],i=e.vertices;for(let o=0;o<i.length;o++){const n=i[o],s=i[(o+1)%i.length];if(t.push([n.x,n.y]),n.bulge){const r=W_e([n.x,n.y],[s.x,s.y],n.bulge,A);t.push(...r)}}return t}function f6A({ctx:e,points:A,canvasXFromPcb:t,canvasYFromPcb:i}){A.length<3||(e.beginPath(),A.forEach((o,n)=>{const s=t(o[0]),r=i(o[1]);n===0?e.moveTo(s,r):e.lineTo(s,r)}),e.closePath(),e.fill())}function Z_e({ctx:e,pour:A,canvasXFromPcb:t,canvasYFromPcb:i}){const o=A.brep_shape;if(!o||!o.outer_ring)return;const n=p6A(o.outer_ring,32);if(n.length>=3&&f6A({ctx:e,points:n,canvasXFromPcb:t,canvasYFromPcb:i}),o.inner_rings&&o.inner_rings.length>0){e.globalCompositeOperation="destination-out";for(const s of o.inner_rings){const r=p6A(s,32);r.length>=3&&f6A({ctx:e,points:r,canvasXFromPcb:t,canvasYFromPcb:i})}e.globalCompositeOperation="source-over"}}function bW({layer:e,circuitJson:A,boardData:t,traceTextureResolution:i=fc}){const o=A.filter(h=>h.type==="pcb_copper_pour"),n=e==="top"?"top_copper":"bottom_copper",s=o.filter(h=>h.layer===e);if(s.length===0)return null;const r=zF(t),a=document.createElement("canvas"),g=Math.floor(r.width*i),c=Math.floor(r.height*i);a.width=g,a.height=c;const I=a.getContext("2d");if(!I)return null;e==="bottom"&&(I.translate(0,c),I.scale(1,-1));const l=h=>(h-r.minX)*i,B=h=>(r.maxY-h)*i,C=s.filter(h=>h.shape==="rect"||h.shape==="polygon"),E=s.filter(h=>h.shape==="brep");if(C.length>0){const h=new RBe(I);h.setCameraBounds({minX:r.minX,maxX:r.maxX,minY:r.minY,maxY:r.maxY});const u=C.filter(D=>D.covered_with_solder_mask!==!1),d=C.filter(D=>D.covered_with_solder_mask===!1),f=`rgb(${$o.fr4TracesWithMaskGreen.map(D=>D*255).join(",")})`,m=`rgb(${$o.copper.map(D=>D*255).join(",")})`;u.length>0&&(h.configure({colorOverrides:{copper:{top:f,bottom:f,inner1:f,inner2:f,inner3:f,inner4:f,inner5:f,inner6:f}}}),h.drawElements(u,{layers:[n]})),d.length>0&&(h.configure({colorOverrides:{copper:{top:m,bottom:m,inner1:m,inner2:m,inner3:m,inner4:m,inner5:m,inner6:m}}}),h.drawElements(d,{layers:[n]}))}for(const h of E){const d=h.covered_with_solder_mask!==!1?$o.fr4TracesWithMaskGreen:$o.copper,f=`rgb(${d[0]*255}, ${d[1]*255}, ${d[2]*255})`;I.fillStyle=f,Z_e({ctx:I,pour:h,canvasXFromPcb:l,canvasYFromPcb:B})}const Q=new CM(a);return Q.generateMipmaps=!0,Q.minFilter=Lu,Q.magFilter=nB,Q.anisotropy=16,Q.needsUpdate=!0,Q}function Cf(e,A){const{texture:t,yOffset:i,isBottomLayer:o,textureType:n,usePolygonOffset:s=!1,renderOrder:r=0,isFaux:a=!1}=e;if(!t)return null;const g=zF(A),c=new Fm(g.width,g.height),I=new Nd({map:t,transparent:!0,side:jB,depthWrite:n==="panel-outlines",polygonOffset:s,polygonOffsetFactor:s?-4:0,polygonOffsetUnits:s?-4:0,opacity:a?EW:1}),l=new sn(c,I);return l.position.set(g.centerX,g.centerY,i),o&&l.rotation.set(Math.PI,0,0),l.name=`${o?"bottom":"top"}-${n}-texture-plane`,l.renderOrder=r,l}function V_e(e,A,t,i=!1){const o=[];if(!e||!A||t===null)return o;const n=Cf({texture:e.topTrace,yOffset:t/2+Za.traces,isBottomLayer:!1,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);n&&o.push(n);const s=Cf({texture:e.topTraceWithMask,yOffset:t/2+Za.traces,isBottomLayer:!1,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);s&&o.push(s);const r=Cf({texture:e.topSilkscreen,yOffset:t/2+.003,isBottomLayer:!1,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);r&&o.push(r);const a=Cf({texture:e.bottomTrace,yOffset:-t/2-Za.traces,isBottomLayer:!0,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);a&&o.push(a);const g=Cf({texture:e.bottomTraceWithMask,yOffset:-t/2-Za.traces,isBottomLayer:!0,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);g&&o.push(g);const c=Cf({texture:e.bottomSilkscreen,yOffset:-t/2-.003,isBottomLayer:!0,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);c&&o.push(c);const I=Cf({texture:e.topSoldermask,yOffset:t/2+.001,isBottomLayer:!1,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);I&&o.push(I);const l=Cf({texture:e.bottomSoldermask,yOffset:-t/2-.001,isBottomLayer:!0,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);l&&o.push(l);const B=Cf({texture:e.topCopperText,yOffset:t/2+Za.copper,isBottomLayer:!1,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);B&&o.push(B);const C=Cf({texture:e.bottomCopperText,yOffset:-t/2-Za.copper,isBottomLayer:!0,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);C&&o.push(C);const E=Cf({texture:e.topCopper,yOffset:t/2+Za.copper,isBottomLayer:!1,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);E&&o.push(E);const Q=Cf({texture:e.bottomCopper,yOffset:-t/2-Za.copper,isBottomLayer:!0,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);Q&&o.push(Q);const h=Cf({texture:e.topPanelOutlines,yOffset:t/2+.004,isBottomLayer:!1,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);h&&o.push(h);const u=Cf({texture:e.bottomPanelOutlines,yOffset:-t/2-.004,isBottomLayer:!0,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);return u&&o.push(u),o}function j_e({circuitJson:e,pcbThickness:A,isFaux:t=!1}){const{rootObject:i}=Ku(),{visibility:o}=WN(),n=AA.useMemo(()=>{const r=e.filter(c=>c.type==="pcb_panel"),a=xi(e).pcb_board.list();if(r.length>0){const c=r[0],I=a.find(l=>l.pcb_panel_id===c.pcb_panel_id);return{type:"pcb_board",pcb_board_id:c.pcb_panel_id,center:c.center,width:c.width,height:c.height,thickness:I?.thickness??1.4,material:I?.material??"fr4",num_layers:I?.num_layers??2}}const g=a.filter(c=>!c.pcb_panel_id);return g.length>0?g[0]:null},[e]),s=AA.useMemo(()=>{if(!n||!n.width||!n.height)return null;const r=i6A[n.material]??$o.fr4SolderMaskGreen,a=`rgb(${Math.round(r[0]*255)}, ${Math.round(r[1]*255)}, ${Math.round(r[2]*255)})`,g="rgb(255,255,255)",c=$o.fr4TracesWithMaskGreen,I=`rgb(${Math.round(c[0]*255)}, ${Math.round(c[1]*255)}, ${Math.round(c[2]*255)})`;return{topSoldermask:fW({layer:"top",circuitJson:e,boardData:n,soldermaskColor:a,traceTextureResolution:fc}),bottomSoldermask:fW({layer:"bottom",circuitJson:e,boardData:n,soldermaskColor:a,traceTextureResolution:fc}),topSilkscreen:mW({layer:"top",circuitJson:e,boardData:n,silkscreenColor:g,traceTextureResolution:fc}),bottomSilkscreen:mW({layer:"bottom",circuitJson:e,boardData:n,silkscreenColor:g,traceTextureResolution:fc}),topTraceWithMask:gv({layer:"top",circuitJson:e,boardData:n,traceColor:I,traceTextureResolution:fc}),bottomTraceWithMask:gv({layer:"bottom",circuitJson:e,boardData:n,traceColor:I,traceTextureResolution:fc}),topCopperText:DW({layer:"top",circuitJson:e,boardData:n,copperColor:`rgb(${Math.round($o.copper[0]*255)}, ${Math.round($o.copper[1]*255)}, ${Math.round($o.copper[2]*255)})`,traceTextureResolution:fc}),bottomCopperText:DW({layer:"bottom",circuitJson:e,boardData:n,copperColor:`rgb(${Math.round($o.copper[0]*255)}, ${Math.round($o.copper[1]*255)}, ${Math.round($o.copper[2]*255)})`,traceTextureResolution:fc}),topPanelOutlines:SW({layer:"top",circuitJson:e,panelData:n,traceTextureResolution:fc}),bottomPanelOutlines:SW({layer:"bottom",circuitJson:e,panelData:n,traceTextureResolution:fc}),topCopper:bW({layer:"top",circuitJson:e,boardData:n,traceTextureResolution:fc}),bottomCopper:bW({layer:"bottom",circuitJson:e,boardData:n,traceTextureResolution:fc})}},[e,n]);return AA.useEffect(()=>{if(!i||!n||!s)return;const r=[],a=(c,I,l,B,C=!1,E=!1)=>{if(!c)return null;const Q=zF(n),h=new Fm(Q.width,Q.height),u=new Nd({map:c,transparent:!0,side:jB,depthWrite:E,polygonOffset:C,polygonOffsetFactor:C?-1:0,polygonOffsetUnits:C?-1:0,opacity:t?EW:1}),d=new sn(h,u);return d.position.set(Q.centerX,Q.centerY,I),l&&d.rotation.set(Math.PI,0,0),d.name=B,d},g=.001;if(o.topMask){const c=a(s.topSoldermask,A/2+g,!1,"jscad-top-soldermask",!0);c&&(r.push(c),i.add(c))}if(o.bottomMask){const c=a(s.bottomSoldermask,-A/2-g,!0,"jscad-bottom-soldermask",!0);c&&(r.push(c),i.add(c))}if(o.topCopper&&o.topMask){const c=a(s.topTraceWithMask,A/2+Za.traces+.004,!1,"jscad-top-trace-with-mask");c&&(r.push(c),i.add(c))}if(o.bottomCopper&&o.bottomMask){const c=a(s.bottomTraceWithMask,-A/2-Za.traces-.005,!0,"jscad-bottom-trace-with-mask");c&&(r.push(c),i.add(c))}if(o.topSilkscreen){const c=a(s.topSilkscreen,A/2+g+.002,!1,"jscad-top-silkscreen");c&&(r.push(c),i.add(c))}if(o.bottomSilkscreen){const c=a(s.bottomSilkscreen,-A/2-g-.002,!0,"jscad-bottom-silkscreen");c&&(r.push(c),i.add(c))}if(o.topCopper){const c=a(s.topCopperText,A/2+Za.copper,!1,"jscad-top-copper-text");c&&(r.push(c),i.add(c))}if(o.bottomCopper){const c=a(s.bottomCopperText,-A/2-Za.copper,!0,"jscad-bottom-copper-text");c&&(r.push(c),i.add(c))}if(o.topCopper){const c=a(s.topCopper,A/2+Za.copper,!1,"jscad-top-copper-pour");c&&(r.push(c),i.add(c))}if(o.bottomCopper){const c=a(s.bottomCopper,-A/2-Za.copper,!0,"jscad-bottom-copper-pour");c&&(r.push(c),i.add(c))}if(o.boardBody){const c=a(s.topPanelOutlines,A/2+g+.003,!1,"jscad-top-panel-outlines",!1,!0);c&&(r.push(c),i.add(c));const I=a(s.bottomPanelOutlines,-A/2-g-.003,!0,"jscad-bottom-panel-outlines",!1,!0);I&&(r.push(I),i.add(I))}return()=>{r.forEach(c=>{c.parent===i&&i.remove(c),c.geometry.dispose(),c.material instanceof tf&&c.material.dispose()})}},[i,n,s,A,o]),null}function z_e(e){const A=xi(e).cad_component.list(),t=xi(e).pcb_smtpad.list(),i=xi(e).pcb_hole.list(),o=xi(e).pcb_plated_hole.list(),n=xi(e).pcb_via.list();if(A.length===0&&t.length===0&&i.length===0&&o.length===0&&n.length===0)return null;const s=[...i,...o,...n,...t],r=mL(s);let a=r.minX,g=r.maxX,c=r.minY,I=r.maxY;for(const u of A)if(u.position){const d=u.position.x,f=u.position.y;a=Math.min(a,d),g=Math.max(g,d),c=Math.min(c,f),I=Math.max(I,f)}a===1/0&&(a=-10,g=10,c=-10,I=10);const l=2,B=Math.max(Math.abs(a),Math.abs(g))+l,C=Math.max(Math.abs(c),Math.abs(I))+l,E=Math.max(2*B,10),Q=Math.max(2*C,10);return{type:"pcb_board",pcb_board_id:"faux-board",center:{x:0,y:0},width:E,height:Q,thickness:1.4,material:"fr4",num_layers:2}}function y6A(e){if(xi(e).pcb_board.list().length>0)return e;const t=z_e(e);if(!t)return e;const o=t.thickness/2;return[...e.map(s=>{if(s.type==="cad_component"){const r=s;if(r.position){const a=r.position.z??0;return{...r,position:{...r.position,z:a+o}}}}return s}),t]}var X_e=AA.forwardRef(({circuitJson:e,children:A,autoRotateDisabled:t,clickToInteractEnabled:i,onUserInteraction:o,onCameraControllerReady:n},s)=>{const r=e6A(A),a=AA.useMemo(()=>y6A(e??r),[e,r]),g=S_e(a),c=AA.useMemo(()=>{if(!a)return[5,-5,5];try{const h=xi(a).pcb_board.list()[0];if(!h)return[5,-5,5];const{width:u,height:d}=h;if(!u&&!d)return[5,-5,5];const f=5,m=Math.max(u,f),D=Math.max(d,f),w=Math.max(m,D);return[w*.4,-w*.7,w*.9]}catch(h){return console.error(h),[5,-5,5]}},[a]),I=AA.useMemo(()=>{if(!a)return!1;try{const h=xi(a).pcb_board.list()[0];return!!h&&h.pcb_board_id==="faux-board"}catch{return!1}},[a]),l=AA.useMemo(()=>{if(a)try{const h=xi(a).pcb_board.list()[0];return h?{width:h.width??0,height:h.height??0}:void 0}catch(h){console.error(h);return}},[a]),B=AA.useMemo(()=>{if(a)try{const h=xi(a).pcb_board.list()[0];return!h||!h.center?void 0:{x:h.center.x,y:h.center.y}}catch(h){console.error(h);return}},[a]),C=mzA(a),{stls:E}=r_e(g),Q=xi(a).cad_component.list();return Z.jsxs(t6A,{ref:s,autoRotateDisabled:t,initialCameraPosition:c,clickToInteractEnabled:i,boardDimensions:l,boardCenter:B,onUserInteraction:o,onCameraControllerReady:n,children:[E.map(({stlData:h,color:u,layerType:d},f)=>Z.jsx(k_e,{stlData:h,color:u,opacity:f===0?I?.8:.95:1,layerType:d},`board-${f}`)),Z.jsx(j_e,{circuitJson:a,pcbThickness:C,isFaux:I}),Q.map(h=>Z.jsx(I6A,{fallback:({error:u})=>Z.jsx(c6A,{cad_component:h,error:u}),children:Z.jsx(jXA,{cad_component:h,circuitJson:a},h.cad_component_id)},h.cad_component_id))]})}),$_e=e=>{let A=0;for(let i=0;i<e.length;i++){const o=(i+1)%e.length;e[i]&&e[o]&&(A+=e[i][0]*e[o][1],A-=e[o][0]*e[i][1])}return A/2<=0};function Axe(e,A,t,i,o){let n,s=null;if(t.outline&&t.outline.length>=3){let r=t.outline.map(g=>[g.x,g.y]);$_e(r)&&(r=r.reverse());const a=A.ofPolygons([r]);o.push(a),s=a,n=e.extrude(a,i,void 0,void 0,void 0,!0),o.push(n)}else t.outline&&t.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),n=e.cube([t.width,t.height,i],!0),o.push(n),n=n.translate([t.center.x,t.center.y,0]),o.push(n);return{boardOp:n,outlineCrossSection:s}}var txe=64;function Pd({Manifold:e,width:A,height:t,thickness:i,borderRadius:o}){const n=d0(A,t,o);if(n<=0)return e.cube([A,t,i],!0);const s=[],r=A-2*n,a=t-2*n;return r>0&&s.push(e.cube([r,t,i],!0)),a>0&&s.push(e.cube([A,a,i],!0)),[[A/2-n,t/2-n],[-A/2+n,t/2-n],[-A/2+n,-t/2+n],[A/2-n,-t/2+n]].forEach(([c,I])=>{s.push(e.cylinder(i,n,n,txe,!0).translate([c,I,0]))}),e.union(s)}function exe({Manifold:e,pad:A,padBaseThickness:t}){if(A.shape==="rect"){const i=UC(A);return Pd({Manifold:e,width:A.width,height:A.height,thickness:t,borderRadius:i})}else if(A.shape==="rotated_rect"){const i=UC(A);let o=Pd({Manifold:e,width:A.width,height:A.height,thickness:t,borderRadius:i});const n=A.ccw_rotation??0;return n&&(o=o.rotate([0,0,n])),o}else if(A.shape==="circle"&&A.radius)return e.cylinder(t,A.radius,-1,32,!0);return null}var ixe=e=>{let A=0;for(let i=0;i<e.length;i++){const o=(i+1)%e.length;e[i]&&e[o]&&(A+=e[i][0]*e[o][1],A-=e[o][0]*e[i][1])}return A/2<=0};function oxe(e,A,t,i,o){const n=[],s=xi(t).pcb_cutout.list();for(const r of s){let a;const g=i*1.5;switch(r.shape){case"rect":{const l=UC(r);if(typeof l=="number"&&l>0?a=Pd({Manifold:e,width:r.width,height:r.height,thickness:g,borderRadius:l}):a=e.cube([r.width,r.height,g],!0),o.push(a),r.rotation){const B=a.rotate([0,0,r.rotation]);o.push(B),a=B}a=a.translate([r.center.x,r.center.y,0]),o.push(a);break}case"circle":a=e.cylinder(g,r.radius,-1,XB,!0),o.push(a),a=a.translate([r.center.x,r.center.y,0]),o.push(a);break;case"polygon":if(r.points.length<3){console.warn(`PCB Cutout [${r.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);continue}let c=r.points.map(l=>[l.x,l.y]);ixe(c)&&(c=c.reverse());const I=A.ofPolygons([c]);o.push(I),a=e.extrude(I,g,0,0,[1,1],!0),o.push(a);break;default:console.warn(`Unsupported cutout shape: ${r.shape} for cutout ${r.pcb_cutout_id}`);continue}a&&n.push(a)}return{cutoutOps:n}}function m6A({Manifold:e,x:A,y:t,diameter:i,thickness:o,segments:n=32}){return e.cylinder(o*1.2,i/2,i/2,n,!0).translate([A,t,0])}function w6A({Manifold:e,x:A,y:t,holeDiameter:i,thickness:o,zOffset:n=.001,segments:s=32}){const r=i/2+n;return e.cylinder(o*1.2,r,r,s,!0).translate([A,t,0])}function nxe(e,A,t,i,o){const n=[],s=xi(t).pcb_hole.list(),r=(g,c,I)=>{const l=Pd({Manifold:e,width:g,height:c,thickness:I,borderRadius:Math.min(g,c)/2});return o.push(l),l},a=(g,c,I)=>{const l=[];for(let B=0;B<I;B++){const C=2*Math.PI*B/I;l.push([g/2*Math.cos(C),c/2*Math.sin(C)])}return l};return s.forEach(g=>{const c=g.hole_shape,I=g.x,l=g.y,B=i*1.2,C=g.ccw_rotation??g.rotation??0,E=g.hole_width??g.hole_diameter,Q=g.hole_height??g.hole_diameter;let h=null;if(c==="circle"){h=m6A({Manifold:e,x:I,y:l,diameter:g.hole_diameter,thickness:i,segments:XB}),n.push(h),o.push(h);return}if(c==="pill"||c==="rotated_pill")h=r(E,Q,B);else if(c==="oval"){let u=a(E,Q,XB),d=0;for(let m=0;m<u.length;m++){const D=(m+1)%u.length;d+=u[m][0]*u[D][1],d-=u[D][0]*u[m][1]}d<=0&&(u=u.reverse());const f=A.ofPolygons([u]);o.push(f),h=e.extrude(f,B,0,0,[1,1],!0),o.push(h)}if(h){if(C!==0){const d=h.rotate([0,0,C]);o.push(d),h=d}const u=h.translate([I,l,0]);o.push(u),n.push(u)}}),{nonPlatedHoleBoardDrills:n}}function Vm(e){const A=new Dg;if(A.setAttribute("position",new qn(e.vertProperties,3)),A.setIndex(new P6(e.triVerts,1)),e.runIndex&&e.runIndex.length>1&&e.runOriginalID)for(let t=0;t<e.runIndex.length-1;t++){const i=e.runIndex[t],o=e.runIndex[t+1]-i;A.addGroup(i,o,0)}else A.addGroup(0,e.triVerts.length,0);return A}var wH=e=>{let A=0;for(let i=0;i<e.length;i++){const o=(i+1)%e.length;e[i]&&e[o]&&(A+=e[i][0]*e[o][1],A-=e[o][0]*e[i][1])}return A/2<=0},_W=(e,A,t)=>{const i=[];for(let o=0;o<t;o++){const n=2*Math.PI*o/t;i.push([e/2*Math.cos(n),A/2*Math.sin(n)])}return i},XF=new Pi(...$o.copper),xW=.05;function sxe(e,A,t,i,o,n){const s=[],r=xi(t).pcb_plated_hole.list(),a=[],g=[],c=(C,E,Q)=>{const h=Pd({Manifold:e,width:C,height:E,thickness:Q,borderRadius:Math.min(C,E)/2});return o.push(h),h},I=({padOutline:C,thickness:E})=>{if(!Array.isArray(C)||C.length<3)return null;let Q=C.map(d=>[d.x,d.y]);wH(Q)&&(Q=Q.reverse());const h=A.ofPolygons([Q]);o.push(h);const u=e.extrude(h,E,0,0,[1,1],!0);return o.push(u),u},l=({ph:C,depth:E,sizeDelta:Q=0})=>{if(C.shape!=="hole_with_polygon_pad")return null;const u=C.pad_outline;if(!Array.isArray(u)||u.length<3)return null;const d=C.hole_shape||"circle",f=C.hole_offset_x||0,m=C.hole_offset_y||0;let D=null;if(d==="circle"){const w=Math.max((C.hole_diameter??0)+Q,To),b=Math.max(w/2,To/2);D=e.cylinder(E,b,b,XB,!0),o.push(D)}else{const w=C.hole_width??C.hole_diameter,b=C.hole_height??C.hole_diameter;if(!w||!b)return null;const k=Math.max(w+Q,To),_=Math.max(b+Q,To);if(d==="oval"){let N=_W(k,_,XB);wH(N)&&(N=N.reverse());const M=A.ofPolygons([N]);o.push(M),D=e.extrude(M,E,0,0,[1,1],!0),o.push(D)}else(d==="pill"||d==="rotated_pill")&&(D=Pd({Manifold:e,width:k,height:_,thickness:E,borderRadius:Math.min(k,_)/2}),o.push(D))}if(!D)return null;if(f||m){const w=D.translate([f,m,0]);o.push(w),D=w}return D};r.forEach((C,E)=>{if(C.shape==="circle"){const Q=w6A({Manifold:e,x:C.x,y:C.y,holeDiameter:C.hole_diameter*1.02,thickness:i,zOffset:Bf,segments:XB});o.push(Q),s.push(Q);const h=i+2*Bf,u=e.cylinder(h,C.outer_diameter/2,C.outer_diameter/2,XB,!0);o.push(u);const d=e.cylinder(h*1.05,C.hole_diameter/2,C.hole_diameter/2,XB,!0);o.push(d);const f=u.subtract(d);o.push(f);const m=f.translate([C.x,C.y,0]);o.push(m);let D=m;if(n){const b=e.intersection([m,n]);o.push(b),D=b}g.push(D);const w=Vm(D.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:w,color:XF})}else if(C.shape==="pill"){const Q=C.hole_width,h=C.hole_height,u=.4,d=C.outer_width??Q+u,f=C.outer_height??h+u,m=Q+2*Bf,D=h+2*Bf,w=i*1.2;let b=c(m,D,w);if(C.ccw_rotation){const W=b.rotate([0,0,C.ccw_rotation]);o.push(W),b=W}const k=b.translate([C.x,C.y,0]);o.push(k),s.push(k);const _=i+2*Bf,N=c(d,f,_),M=c(Q,h,_*1.05);let H=N.subtract(M);if(o.push(H),C.ccw_rotation){const W=H.rotate([0,0,C.ccw_rotation]);o.push(W),H=W}const T=H.translate([C.x,C.y,0]);o.push(T);let Y=T;if(n){const W=e.intersection([T,n]);o.push(W),Y=W}g.push(Y);const O=Vm(Y.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:O,color:XF})}else if(C.shape==="pill_hole_with_rect_pad"){if(C.hole_shape&&C.hole_shape!=="pill"||C.pad_shape&&C.pad_shape!=="rect")return;const Q=C.hole_width,h=C.hole_height,u=C.hole_offset_x||0,d=C.hole_offset_y||0,f=C.rect_pad_width,m=C.rect_pad_height,D=UC(C),w=pH,b=Q+2*Bf,k=h+2*Bf,_=i*1.2,M=c(b,k,_).translate([u,d,0]).translate([C.x,C.y,0]);o.push(M),s.push(M);const H=Pd({Manifold:e,width:f,height:m,thickness:i-2*w-2*Za.copper+.1,borderRadius:D});o.push(H);const T=Pd({Manifold:e,width:f,height:m,thickness:w,borderRadius:D}).translate([0,0,i/2/2+Za.copper]),Y=Pd({Manifold:e,width:f,height:m,thickness:w,borderRadius:D}).translate([0,0,-i/2/2-Za.copper]);o.push(T,Y);const O=c(Q,h,i*1.02).translate([u,d,0]);o.push(O);const W=e.union([H,T,Y,O]);o.push(W);const $=c(Math.max(Q-2*xW,.01),Math.max(h-2*xW,.01),i*1.2).translate([u,d,0]);o.push($);const iA=W.subtract($);o.push(iA);const gA=iA.translate([C.x,C.y,0]);o.push(gA);let tA=gA;if(n){const rA=e.intersection([gA,n]);o.push(rA),tA=rA}g.push(tA);const nA=Vm(tA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:nA,color:XF})}else if(C.shape==="rotated_pill_hole_with_rect_pad"){if(C.hole_shape&&C.hole_shape!=="rotated_pill"||C.pad_shape&&C.pad_shape!=="rect")return;const Q=C.hole_width,h=C.hole_height,u=C.hole_offset_x||0,d=C.hole_offset_y||0,f=C.rect_pad_width,m=C.rect_pad_height,D=UC(C),w=pH,b=Q+2*Bf,k=h+2*Bf,_=i*1.2;let N=c(b,k,_).translate([u,d,0]);if(C.hole_ccw_rotation){const rA=N.rotate([0,0,C.hole_ccw_rotation]);o.push(rA),N=rA}const M=N.translate([C.x,C.y,0]);o.push(M),s.push(M);let H=Pd({Manifold:e,width:f,height:m,thickness:i-2*w-2*Za.copper+.1,borderRadius:D});if(o.push(H),C.rect_ccw_rotation){const rA=H.rotate([0,0,C.rect_ccw_rotation]);o.push(rA),H=rA}let T=Pd({Manifold:e,width:f,height:m,thickness:w,borderRadius:D}).translate([0,0,i/2/2+Za.copper]);if(C.rect_ccw_rotation){const rA=T.rotate([0,0,C.rect_ccw_rotation]);o.push(rA),T=rA}let Y=Pd({Manifold:e,width:f,height:m,thickness:w,borderRadius:D}).translate([0,0,-i/2/2-Za.copper]);if(C.rect_ccw_rotation){const rA=Y.rotate([0,0,C.rect_ccw_rotation]);o.push(rA),Y=rA}o.push(T,Y);let O=c(Q,h,i*1.02).translate([u,d,0]);if(C.hole_ccw_rotation){const rA=O.rotate([0,0,C.hole_ccw_rotation]);o.push(rA),O=rA}o.push(O);const W=e.union([H,T,Y,O]);o.push(W);let $=c(Math.max(Q-2*xW,.01),Math.max(h-2*xW,.01),i*1.2).translate([u,d,0]);if(C.hole_ccw_rotation){const rA=$.rotate([0,0,C.hole_ccw_rotation]);o.push(rA),$=rA}o.push($);const iA=W.subtract($);o.push(iA);const gA=iA.translate([C.x,C.y,0]);o.push(gA);let tA=gA;if(n){const rA=e.intersection([gA,n]);o.push(rA),tA=rA}g.push(tA);const nA=Vm(tA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:nA,color:XF})}else if(C.shape==="hole_with_polygon_pad"){const Q=C.pad_outline;if(!Array.isArray(Q)||Q.length<3)return;const h=l({ph:C,depth:i*1.2,sizeDelta:2*To});if(!h)return;const u=h.translate([C.x,C.y,0]);o.push(u),s.push(u);const d=pH,f=Math.max(i-2*d-2*Za.copper+.1,To),m=I({padOutline:Q,thickness:f}),D=I({padOutline:Q,thickness:d}),w=I({padOutline:Q,thickness:d});if(!m||!D||!w)return;const b=D.translate([0,0,i/2/2+Za.copper]),k=w.translate([0,0,-i/2/2-Za.copper]);o.push(b,k);const _=l({ph:C,depth:i*1.02});if(!_)return;const N=l({ph:C,depth:i*1.2,sizeDelta:-2*To})||_,M=e.union([m,b,k,_]);o.push(M);const H=M.subtract(N);o.push(H);const T=H.translate([C.x,C.y,0]);o.push(T);let Y=T;if(n){const W=e.intersection([T,n]);o.push(W),Y=W}g.push(Y);const O=Vm(Y.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:O,color:XF})}else if(C.shape==="oval"){const Q=C.hole_width,h=C.hole_height,u=C.outer_width??Q+.4,d=C.outer_height??h+.4,f=Q+2*Bf,m=h+2*Bf,D=i*1.2;let w=_W(f,m,XB);wH(w)&&(w=w.reverse());const b=A.ofPolygons([w]);o.push(b);let k=e.extrude(b,D,0,0,[1,1],!0);if(o.push(k),C.ccw_rotation){const nA=k.rotate([0,0,C.ccw_rotation]);o.push(nA),k=nA}const _=k.translate([C.x,C.y,0]);o.push(_),s.push(_);const N=i+2*Bf;let M=_W(u,d,XB);wH(M)&&(M=M.reverse());const H=A.ofPolygons([M]);o.push(H);const T=e.extrude(H,N,0,0,[1,1],!0);o.push(T);let Y=_W(Q,h,XB);wH(Y)&&(Y=Y.reverse());const O=A.ofPolygons([Y]);o.push(O);const W=e.extrude(O,N*1.05,0,0,[1,1],!0);o.push(W);let $=T.subtract(W);if(o.push($),C.ccw_rotation){const nA=$.rotate([0,0,C.ccw_rotation]);o.push(nA),$=nA}const iA=$.translate([C.x,C.y,0]);o.push(iA);let gA=iA;if(n){const nA=e.intersection([iA,n]);o.push(nA),gA=nA}g.push(gA);const tA=Vm(gA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:tA,color:XF})}else if(C.shape==="circular_hole_with_rect_pad"){if(C.hole_shape&&C.hole_shape!=="circle"||C.pad_shape&&C.pad_shape!=="rect")return;const Q=C.hole_offset_x||0,h=C.hole_offset_y||0,u=m6A({Manifold:e,x:C.x+Q,y:C.y+h,diameter:C.hole_diameter,thickness:i,segments:XB});o.push(u),s.push(u);const d=C.rect_pad_width??C.hole_diameter,f=C.rect_pad_height??C.hole_diameter,m=UC(C),D=pH,w=C.hole_diameter/2,b=Pd({Manifold:e,width:d,height:f,thickness:i-2*D-2*Za.copper+.1,borderRadius:m});o.push(b);const k=Pd({Manifold:e,width:d,height:f,thickness:D,borderRadius:m}).translate([0,0,i/2/2+Za.copper]),_=Pd({Manifold:e,width:d,height:f,thickness:D,borderRadius:m}).translate([0,0,-i/2/2-Za.copper]);o.push(k,_);const N=e.cylinder(i*1.02,w,w,XB,!0).translate([Q,h,0]);o.push(N);const M=e.union([b,k,_,N]);o.push(M);const H=e.cylinder(i*1.2,Math.max(w-To,.01),Math.max(w-To,.01),XB,!0).translate([Q,h,0]);o.push(H);const T=M.subtract(H);o.push(T);const Y=T.translate([C.x,C.y,0]);o.push(Y);let O=Y;if(n){const $=e.intersection([Y,n]);o.push($),O=$}g.push(O);const W=Vm(O.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:W,color:XF})}});let B;return g.length>0&&(B=e.union(g),o.push(B)),{platedHoleBoardDrills:s,platedHoleCopperGeoms:a,platedHoleSubtractOp:B}}var rxe=new Pi(...$o.copper);function axe(e,A,t,i,o,n){const s=[];return xi(A).pcb_smtpad.list().forEach((a,g)=>{const c=pH,I=a.layer==="bottom"?-t/2-Za.copper:t/2+Za.copper;let l=exe({Manifold:e,pad:a,padBaseThickness:c});if(l){i.push(l);const B=l.translate([a.x,a.y,I]);i.push(B);let C=B;if(o&&(C=B.subtract(o),i.push(C)),n){const Q=e.intersection([C,n]);i.push(Q),C=Q}const E=Vm(C.getMesh());s.push({key:`smt_pad-${a.layer||"top"}-${a.pcb_smtpad_id||g}`,geometry:E,color:rxe})}}),{smtPadGeoms:s}}function gxe({Manifold:e,x:A,y:t,outerDiameter:i,holeDiameter:o,thickness:n,zOffset:s=.001,segments:r=32}){const a=s,g=s;if(i<o)throw new Error(`Invalid via geometry: outerDiameter (${i}) must be >= holeDiameter (${o})`);const c=Math.min(i/2,o/2+g),I=e.cylinder(n,c,-1,r,!0),l=e.cylinder(a,i/2,-1,r,!0).translate([0,0,n/2]),B=e.cylinder(a,i/2,-1,r,!0).translate([0,0,-n/2]),C=e.union([I,l,B]),E=n+a*2,Q=e.cylinder(E,o/2,-1,r,!0);return C.subtract(Q).translate([A,t,0])}var cxe=new Pi(...$o.copper);function Ixe(e,A,t,i,o){const n=[],s=xi(A).pcb_via.list(),r=[];return s.forEach((a,g)=>{if(typeof a.hole_diameter=="number"){const c=w6A({Manifold:e,x:a.x,y:a.y,holeDiameter:a.hole_diameter,thickness:t,zOffset:Bf,segments:XB});i.push(c),n.push(c)}if(typeof a.outer_diameter=="number"&&typeof a.hole_diameter=="number"){const c=gxe({Manifold:e,x:a.x,y:a.y,outerDiameter:a.outer_diameter,holeDiameter:a.hole_diameter,thickness:t,zOffset:Bf,segments:XB});i.push(c);let I=c;if(o){const B=e.intersection([c,o]);i.push(B),I=B}const l=Vm(I.getMesh());r.push({key:`via-${a.pcb_via_id||g}`,geometry:l,color:cxe})}}),{viaBoardDrills:n,viaCopperGeoms:r}}var lxe=(e,A)=>{const[t,i]=AA.useState(null),[o,n]=AA.useState(null),[s,r]=AA.useState(null),[a,g]=AA.useState(null),[c,I]=AA.useState(!0),l=AA.useRef([]),B=AA.useMemo(()=>{const E=A.filter(u=>u.type==="pcb_panel"),Q=xi(A).pcb_board.list();if(E.length>0){const u=E[0],d=Q.find(f=>f.pcb_panel_id===u.pcb_panel_id);return{type:"pcb_board",pcb_board_id:u.pcb_panel_id,center:u.center,width:u.width,height:u.height,thickness:d?.thickness??1.4,material:d?.material??"fr4",num_layers:d?.num_layers??2}}const h=Q.filter(u=>!u.pcb_panel_id);return h.length>0?h[0]:null},[A]),C=AA.useMemo(()=>{const E=xi(A).pcb_board.list();return E.length>0&&E[0].pcb_board_id==="faux-board"},[A]);return AA.useEffect(()=>{if(!e||!B){i(null),n(null),r(null),I(!1);return}if((B.width===0||!B.width)&&(B.height===0||!B.height)&&(!B.outline||B.outline.length<3)){i({platedHoles:[],smtPads:[],vias:[]}),n({}),r(B.thickness??0),I(!1);return}I(!0),g(null);const E=e.Manifold,Q=e.CrossSection,h=m=>{if(!(!m||typeof m.delete!="function"))try{m.delete()}catch(D){(!(D instanceof Error)||!D.message?.includes("Manifold instance already deleted"))&&console.warn("Failed to delete Manifold instance",D)}};l.current.forEach(h),l.current=[];let u=null;const d={},f={};try{const m=B.thickness||1.4;r(m);const{boardOp:D,outlineCrossSection:w}=Axe(E,Q,B,m,l.current);let b=D;const _=m+2*1;let N=null;const M=.01;if(w){let qA=w;if(M>0){const nt=w.offset(M);l.current.push(nt),qA=nt}const PA=E.extrude(qA,_,void 0,void 0,void 0,!0);l.current.push(PA),N=PA}else{const qA=(B.width||0)+2*M,PA=(B.height||0)+2*M,nt=E.cube([qA,PA,_],!0);l.current.push(nt);const fA=nt.translate([B.center.x,B.center.y,0]);l.current.push(fA),N=fA}const H=[];let T=null;const{nonPlatedHoleBoardDrills:Y}=nxe(E,Q,A,m,l.current);H.push(...Y);const{platedHoleBoardDrills:O,platedHoleCopperGeoms:W,platedHoleSubtractOp:$}=sxe(E,Q,A,m,l.current,N);H.push(...O),d.platedHoles=W;const{viaBoardDrills:iA,viaCopperGeoms:gA}=Ixe(E,A,m,l.current,N);if(H.push(...iA),d.vias=gA,H.length>0){T=E.union(H),l.current.push(T);const qA=$?E.union([T,$]):T;l.current.push(qA);const PA=b.subtract(qA);if(l.current.push(PA),b=PA,$){const nt=$.subtract(T);l.current.push(nt);const fA=nt.getMesh(),et=Vm(fA);d.platedHoles=[{key:"plated-holes-union",geometry:et,color:new Pi($o.copper[0],$o.copper[1],$o.copper[2])}]}}const{cutoutOps:tA}=oxe(E,Q,A,m,l.current);if(tA.length>0){const qA=E.union(tA);l.current.push(qA);const PA=b.subtract(qA);l.current.push(PA),b=PA}if(u=b,u){const qA=u.getMesh(),PA=Vm(qA),nt=HEA[B.material]??$o.fr4Tan;d.board={geometry:PA,color:new Pi(nt[0],nt[1],nt[2]),material:B.material,isFaux:C}}const{smtPadGeoms:nA}=axe(E,A,m,l.current,T,N);d.smtPads=nA,i(d);const rA=$o.fr4TracesWithoutMaskTan,QA=`rgb(${Math.round(rA[0]*255)}, ${Math.round(rA[1]*255)}, ${Math.round(rA[2]*255)})`;f.topTrace=gv({layer:"top",circuitJson:A,boardData:B,traceColor:QA,traceTextureResolution:fc}),f.bottomTrace=gv({layer:"bottom",circuitJson:A,boardData:B,traceColor:QA,traceTextureResolution:fc});const DA=$o.fr4TracesWithMaskGreen,RA=`rgb(${Math.round(DA[0]*255)}, ${Math.round(DA[1]*255)}, ${Math.round(DA[2]*255)})`;f.topTraceWithMask=gv({layer:"top",circuitJson:A,boardData:B,traceColor:RA,traceTextureResolution:fc}),f.bottomTraceWithMask=gv({layer:"bottom",circuitJson:A,boardData:B,traceColor:RA,traceTextureResolution:fc});const NA="rgb(255,255,255)";f.topSilkscreen=mW({layer:"top",circuitJson:A,boardData:B,silkscreenColor:NA,traceTextureResolution:fc}),f.bottomSilkscreen=mW({layer:"bottom",circuitJson:A,boardData:B,silkscreenColor:NA,traceTextureResolution:fc});const KA=i6A[B.material]??$o.fr4SolderMaskGreen,EA=`rgb(${Math.round(KA[0]*255)}, ${Math.round(KA[1]*255)}, ${Math.round(KA[2]*255)})`;f.topSoldermask=fW({layer:"top",circuitJson:A,boardData:B,soldermaskColor:EA,traceTextureResolution:fc}),f.bottomSoldermask=fW({layer:"bottom",circuitJson:A,boardData:B,soldermaskColor:EA,traceTextureResolution:fc});const kA=$o.copper,dA=`rgb(${Math.round(kA[0]*255)}, ${Math.round(kA[1]*255)}, ${Math.round(kA[2]*255)})`;f.topCopperText=DW({layer:"top",circuitJson:A,boardData:B,copperColor:dA,traceTextureResolution:fc}),f.bottomCopperText=DW({layer:"bottom",circuitJson:A,boardData:B,copperColor:dA,traceTextureResolution:fc}),f.topPanelOutlines=SW({layer:"top",circuitJson:A,panelData:B,traceTextureResolution:fc}),f.bottomPanelOutlines=SW({layer:"bottom",circuitJson:A,panelData:B,traceTextureResolution:fc}),f.topCopper=bW({layer:"top",circuitJson:A,boardData:B,traceTextureResolution:fc}),f.bottomCopper=bW({layer:"bottom",circuitJson:A,boardData:B,traceTextureResolution:fc}),n(f)}catch(m){console.error("Error processing geometry with Manifold in hook:",m),g(m.message||"An unknown error occurred while processing geometry in hook."),i(null),n(null)}finally{I(!1)}return()=>{l.current.forEach(h),l.current=[]}},[e,A,B]),{geoms:t,textures:o,pcbThickness:s,error:a,isLoading:c,boardData:B,isFauxBoard:C}},Bxe=jB,Cxe=({material:e,color:A,side:t=Bxe,isFaux:i=!1})=>e==="fr4"?new Gm({color:A,side:t,metalness:0,roughness:.8,specularIntensity:.2,ior:1.45,sheen:0,clearcoat:0,transparent:i,opacity:i?EW:1,flatShading:!0}):new mh({color:A,side:t,flatShading:!0,metalness:.1,roughness:.8,transparent:!0,opacity:i?EW:.9});function Qxe(e){const A=[];if(!e)return A;if(e.board&&e.board.geometry){const i=new sn(e.board.geometry,Cxe({material:e.board.material,color:e.board.color,side:jB,isFaux:e.board.isFaux}));i.name="board-geom",A.push(i)}const t=i=>{i&&i.forEach(o=>{const n=new sn(o.geometry,new mh({color:o.color,side:jB,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}));n.name=o.key,A.push(n)})};return t(e.platedHoles),t(e.smtPads),t(e.vias),A}var Exe=({geometryMeshes:e,textureMeshes:A})=>{const{rootObject:t}=Ku(),{visibility:i}=WN();return AA.useEffect(()=>{if(t)return e.forEach(o=>{let n=!0;o.name==="board-geom"?n=i.boardBody:o.name.includes("smt_pad")?o.name.includes("smt_pad-top")?n=i.topCopper:o.name.includes("smt_pad-bottom")?n=i.bottomCopper:n=i.topCopper||i.bottomCopper:(o.name.includes("plated_hole")||o.name.includes("via"))&&(n=i.topCopper||i.bottomCopper),n&&t.add(o)}),A.forEach(o=>{let n=!0;o.name.includes("top-trace-texture-plane")&&!o.name.includes("with-mask")?n=i.topCopper&&!i.topMask:o.name.includes("top-trace-with-mask")?n=i.topCopper&&i.topMask:o.name.includes("bottom-trace-texture-plane")&&!o.name.includes("with-mask")?n=i.bottomCopper&&!i.bottomMask:o.name.includes("bottom-trace-with-mask")?n=i.bottomCopper&&i.bottomMask:o.name.includes("top-silkscreen")?n=i.topSilkscreen:o.name.includes("bottom-silkscreen")?n=i.bottomSilkscreen:o.name.includes("top-soldermask")?n=i.topMask:o.name.includes("bottom-soldermask")?n=i.bottomMask:o.name.includes("top-copper-text")?n=i.topCopper:o.name.includes("bottom-copper-text")?n=i.bottomCopper:o.name.includes("top-copper")?n=i.topCopper:o.name.includes("bottom-copper")?n=i.bottomCopper:o.name.includes("panel-outlines")&&(n=i.boardBody),n&&t.add(o)}),()=>{e.forEach(o=>{o.parent===t&&t.remove(o)}),A.forEach(o=>{o.parent===t&&t.remove(o)})}},[t,e,A,i]),null},hxe="https://cdn.jsdelivr.net/npm/manifold-3d@3.2.1",uxe=({circuitJson:e,autoRotateDisabled:A,clickToInteractEnabled:t,onUserInteraction:i,children:o,onCameraControllerReady:n})=>{const s=e6A(o),r=AA.useMemo(()=>y6A(e??s),[e,s]),[a,g]=AA.useState(null),[c,I]=AA.useState(null);AA.useEffect(()=>{if(window.ManifoldModule&&typeof window.ManifoldModule=="object"&&window.ManifoldModule.setup){g(window.ManifoldModule);return}const k=async Y=>{try{const O=await Y();O.setup(),window.ManifoldModule=O,g(O)}catch(O){console.error("Failed to initialize Manifold:",O),I(`Failed to initialize Manifold: ${O instanceof Error?O.message:"Unknown error"}`)}},_=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(_){window.ManifoldModule=_,k(window.ManifoldModule);return}const N="manifoldLoaded",M=()=>{const Y=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(Y)window.ManifoldModule=Y,k(window.ManifoldModule);else{const O="ManifoldModule not found on window after script load.";console.error(O),I(O)}};window.addEventListener(N,M,{once:!0});const H=document.createElement("script");H.type="module",H.innerHTML=`
|
|
5173
|
+
at `+s}return A},yW.buildMessage=function(e,A){var t={literal:function(g){return'"'+o(g.text)+'"'},class:function(g){var c=g.parts.map(function(I){return Array.isArray(I)?n(I[0])+"-"+n(I[1]):n(I)});return"["+(g.inverted?"^":"")+c.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(g){return g.description}};function i(g){return g.charCodeAt(0).toString(16).toUpperCase()}function o(g){return 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(c){return"\\x0"+i(c)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(c){return"\\x"+i(c)})}function n(g){return g.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(c){return"\\x0"+i(c)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(c){return"\\x"+i(c)})}function s(g){return t[g.type](g)}function r(g){var c=g.map(s),I,l;if(c.sort(),c.length>0){for(I=1,l=1;I<c.length;I++)c[I-1]!==c[I]&&(c[l]=c[I],l++);c.length=l}switch(c.length){case 1:return c[0];case 2:return c[0]+" or "+c[1];default:return c.slice(0,-1).join(", ")+", or "+c[c.length-1]}}function a(g){return g?'"'+o(g)+'"':"end of input"}return"Expected "+r(e)+" but "+a(A)+" found."};function mW(e,A){if(e===void 0)return A;if(typeof e=="number")return e;const t=parseFloat(e.replace(/mm$/,""));return isNaN(t)?A:t}function H_e(e){return e.layer==="bottom"?e.is_mirrored!==!1:e.is_mirrored===!0}function Y_e(e){const A=e.flat();if(A.length===0)return{minX:0,maxX:0,minY:0,maxY:0,width:0,height:0,centerX:0,centerY:0};const t=Math.min(...A.map(s=>s[0])),i=Math.max(...A.map(s=>s[0])),o=Math.min(...A.map(s=>s[1])),n=Math.max(...A.map(s=>s[1]));return{minX:t,maxX:i,minY:o,maxY:n,width:i-t,height:n-o,centerX:(t+i)/2,centerY:(o+n)/2}}function J_e(e){const A=[];return e.forEach(t=>{t.length===29?(A.push(t.slice(0,15)),A.push(t.slice(14,29))):t.length===17?(A.push(t.slice(0,10)),A.push(t.slice(9,17))):A.push(t)}),A}function T_e(e,A){let t=-e.centerX,i=-e.centerY;return A.includes("left")?t=-e.minX:A.includes("right")&&(t=-e.maxX),A.includes("top")?i=-e.maxY:A.includes("bottom")&&(i=-e.minY),{x:t,y:i}}function K_e(e,A){const t=[];let i=e.ccw_rotation??0;if(H_e(e)&&(t.push(px(A.centerX,A.centerY),{a:-1,b:0,c:0,d:1,e:0,f:0},px(-A.centerX,-A.centerY)),i=-i),i){const s=i*Math.PI/180;t.push(px(A.centerX,A.centerY),h6A(s),px(-A.centerX,-A.centerY))}return{matrix:t.length>0?E6A(...t):void 0,rotationDeg:i}}function u6A(e,A,t,i,o,n,s){A.forEach(r=>{e.beginPath(),r.forEach((a,g)=>{let c={x:a[0],y:a[1]};t&&(c=C6A(t,c));const I=c.x+i.x+o.x,l=c.y+i.y+o.y,B=n(I),C=s(l);g===0?e.moveTo(B,C):e.lineTo(B,C)}),e.stroke()})}function P_e(e,A,t,i,o,n){e.save(),e.translate(A,t),e.rotate(-n),e.fillRect(-i/2,-o/2,i,o),e.restore()}function q_e(e,A,t,i,o,n,s,r,a,g){const c=typeof A.font_size=="number"?A.font_size:.2,I={left:mW(A.knockout_padding?.left,c*.5),right:mW(A.knockout_padding?.right,c*.5),top:mW(A.knockout_padding?.top,c*.3),bottom:mW(A.knockout_padding?.bottom,c*.3)},l=i.width+I.left+I.right,B=i.height+I.top+I.bottom,C=s(A.anchor_position.x),E=r(A.anchor_position.y),Q=l*a,h=B*a;e.fillStyle=g;const u=n*Math.PI/180;P_e(e,C,E,Q,h,u);const d={x:-i.centerX,y:-i.centerY};e.globalCompositeOperation="destination-out",u6A(e,t,o,d,A.anchor_position,s,r),e.globalCompositeOperation="source-over"}function wW({layer:e,circuitJson:A,boardData:t,copperColor:i="rgb(230, 153, 51)",traceTextureResolution:o}){const s=A.filter(E=>E.type==="pcb_copper_text").filter(E=>E.layer===e);if(s.length===0)return null;const r=zF(t),a=document.createElement("canvas"),g=Math.floor(r.width*o),c=Math.floor(r.height*o);a.width=g,a.height=c;const I=a.getContext("2d");if(!I)return null;e==="bottom"&&(I.translate(0,c),I.scale(1,-1)),I.strokeStyle=i,I.fillStyle=i;const l=E=>(E-r.minX)*o,B=E=>(r.maxY-E)*o;s.forEach(E=>{const Q=typeof E.font_size=="number"?E.font_size:.2,h=Math.max(.02,Q*.08)*o;I.lineWidth=h,I.lineCap="round",I.lineJoin="round";const u=(0,N_e.vectorText)({height:Q*.45,input:E.text}),d=J_e(u),f=Y_e(d),{matrix:m,rotationDeg:D}=K_e(E,f);if(E.is_knockout)q_e(I,E,d,f,m,D,l,B,o,i);else{const w=E.anchor_alignment||"center",b=T_e(f,w);u6A(I,d,m,b,E.anchor_position,l,B)}});const C=new CM(a);return C.generateMipmaps=!0,C.minFilter=Lu,C.magFilter=nB,C.anisotropy=16,C.needsUpdate=!0,C}function DW({layer:e,circuitJson:A,panelData:t,outlineColor:i="black",traceTextureResolution:o}){const n=xi(A).pcb_board.list().filter(B=>B.pcb_panel_id===t.pcb_board_id);if(n.length===0)return null;const s=document.createElement("canvas"),r=Math.floor(t.width*o),a=Math.floor(t.height*o);s.width=r,s.height=a;const g=s.getContext("2d");if(!g)return null;e==="bottom"&&(g.translate(0,a),g.scale(1,-1)),g.strokeStyle=i,g.lineWidth=.05*o;const c=B=>(B-t.center.x+t.width/2)*o,I=B=>(-(B-t.center.y)+t.height/2)*o;n.forEach(B=>{if(B.outline&&B.outline.length>=2)g.beginPath(),B.outline.forEach((C,E)=>{const Q=c(C.x),h=I(C.y);E===0?g.moveTo(Q,h):g.lineTo(Q,h)}),g.closePath(),g.stroke();else{const C=B.width,E=B.height,{x:Q,y:h}=B.center,u=c(Q-C/2),d=I(h+E/2);g.strokeRect(u,d,C*o,E*o)}});const l=new CM(s);return l.generateMipmaps=!0,l.minFilter=Lu,l.magFilter=nB,l.anisotropy=16,l.needsUpdate=!0,l}var O_e=Or(ZQA()),d6A=25.4,W_e=d6A/1e3,Z_e=/^\s*(-?\d*(?:\.\d+)?)(?:\s*(mm|mil|inch|in|"))?\s*$/i;function V_e(e){if(!e)return;const A=e.trim().toLowerCase();return A==='"'||A==="inch"?"in":A}function RQ(e){if(e==null)return;if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string")return;const A=e.trim();if(A.length===0)return;const t=A.match(Z_e);if(!t){const r=Number.parseFloat(A);return Number.isFinite(r)?r:void 0}const[,i,o]=t,n=Number.parseFloat(i||"0");if(!Number.isFinite(n))return;switch(V_e(o)){case"mil":return n*W_e;case"in":return n*d6A;case"mm":case void 0:return n;default:return n}}function Zm(e,A){const t=RQ(e);return t===void 0?A:t}function p6A(e){let A=e;if(A.startsWith("#")&&(A=A.slice(1)),A.length===6){const t=parseInt(A.slice(0,2),16),i=parseInt(A.slice(2,4),16),o=parseInt(A.slice(4,6),16);return`rgb(${t}, ${i}, ${o})`}return e.startsWith("rgb")?e:"rgb(255, 243, 204)"}function SW({layer:e,circuitJson:A,boardData:t,silkscreenColor:i="rgb(255,255,255)",traceTextureResolution:o}){const n=xi(A).pcb_silkscreen_text.list(),s=xi(A).pcb_silkscreen_path.list(),r=xi(A).pcb_silkscreen_line.list(),a=xi(A).pcb_silkscreen_rect.list(),g=xi(A).pcb_silkscreen_circle.list(),c=xi(A).pcb_fabrication_note_rect.list(),I=xi(A).pcb_note_line.list(),l=n.filter(N=>N.layer===e),B=s.filter(N=>N.layer===e),C=r.filter(N=>N.layer===e),E=a.filter(N=>N.layer===e),Q=g.filter(N=>N.layer===e),h=c.filter(N=>N.layer===e),u=I.filter(N=>N.layer===e);if(l.length===0&&B.length===0&&C.length===0&&E.length===0&&Q.length===0&&h.length===0&&u.length===0)return null;const d=zF(t),f=document.createElement("canvas"),m=Math.floor(d.width*o),D=Math.floor(d.height*o);f.width=m,f.height=D;const w=f.getContext("2d");if(!w)return null;e==="bottom"&&(w.translate(0,D),w.scale(1,-1)),w.strokeStyle=i,w.fillStyle=i;const b=N=>(N-d.minX)*o,k=N=>(d.maxY-N)*o;C.forEach(N=>{const M=RQ(N.x1)??0,H=RQ(N.y1)??0,T=RQ(N.x2)??0,Y=RQ(N.y2)??0;M===T&&H===Y||(w.beginPath(),w.lineWidth=Zm(N.stroke_width,.1)*o,w.lineCap="round",w.moveTo(b(M),k(H)),w.lineTo(b(T),k(Y)),w.stroke())}),u.forEach(N=>{const M=RQ(N.x1)??0,H=RQ(N.y1)??0,T=RQ(N.x2)??0,Y=RQ(N.y2)??0;if(M===T&&H===Y)return;w.save();let O=i;N.color?O=p6A(N.color):O="rgb(255, 243, 204)",w.strokeStyle=O,w.beginPath(),w.lineWidth=Zm(N.stroke_width,.1)*o,w.lineCap="round";const W=N.is_dashed??!1;if(W){const $=Math.max(w.lineWidth*2,1);w.setLineDash([$,$])}w.moveTo(b(M),k(H)),w.lineTo(b(T),k(Y)),w.stroke(),W&&w.setLineDash([]),w.restore()}),B.forEach(N=>{N.route.length<2||(w.beginPath(),w.lineWidth=Zm(N.stroke_width,.1)*o,w.lineCap="round",w.lineJoin="round",N.route.forEach((M,H)=>{const T=b(RQ(M.x)??0),Y=k(RQ(M.y)??0);H===0?w.moveTo(T,Y):w.lineTo(T,Y)}),w.stroke())}),Q.forEach(N=>{const M=Zm(N.radius,0);if(M<=0)return;const H=Zm(N.stroke_width,.12),T=H>0,Y=RQ(N.center?.x)??0,O=RQ(N.center?.y)??0,W=b(Y),$=k(O),iA=M*o;if(w.save(),w.translate(W,$),T){const gA=iA+H/2*o,tA=Math.max(0,iA-H/2*o);tA>0?(w.beginPath(),w.arc(0,0,gA,0,2*Math.PI),w.arc(0,0,tA,0,2*Math.PI,!0),w.fill("evenodd")):(w.beginPath(),w.arc(0,0,gA,0,2*Math.PI),w.fill())}else w.beginPath(),w.arc(0,0,iA,0,2*Math.PI),w.fill();w.restore()}),E.forEach(N=>{const M=Zm(N.width,0),H=Zm(N.height,0);if(M<=0||H<=0)return;const T=RQ(N.center?.x)??0,Y=RQ(N.center?.y)??0,O=b(T),W=k(Y),$=UC(N),iA=typeof $=="string"?RQ($):$,gA=d0(M,H,iA);w.save(),w.translate(O,W);const tA=M/2*o,nA=H/2*o,rA=Math.min(gA*o,tA,nA),QA=N.stroke_width??!1,DA=N.is_filled??!0,RA=N.is_stroke_dashed??!1,NA=QA?Zm(N.stroke_width,.1)*o:0;if(((EA,kA,dA,qA,PA)=>{if(w.beginPath(),PA<=0)w.rect(EA,kA,dA,qA);else{const nt=PA,fA=EA+dA,et=kA+qA;w.moveTo(EA+nt,kA),w.lineTo(fA-nt,kA),w.quadraticCurveTo(fA,kA,fA,kA+nt),w.lineTo(fA,et-nt),w.quadraticCurveTo(fA,et,fA-nt,et),w.lineTo(EA+nt,et),w.quadraticCurveTo(EA,et,EA,et-nt),w.lineTo(EA,kA+nt),w.quadraticCurveTo(EA,kA,EA+nt,kA),w.closePath()}})(-tA,-nA,tA*2,nA*2,rA),DA&&w.fill(),QA&&NA>0){if(w.lineWidth=NA,RA){const EA=Math.max(NA*2,1);w.setLineDash([EA,EA])}w.stroke(),RA&&w.setLineDash([])}w.restore()}),h.forEach(N=>{const M=Zm(N.width,0),H=Zm(N.height,0);if(M<=0||H<=0)return;const T=RQ(N.center?.x)??0,Y=RQ(N.center?.y)??0,O=b(T),W=k(Y),$=UC(N),iA=typeof $=="string"?RQ($):$,gA=d0(M,H,iA);w.save(),w.translate(O,W);const tA=M/2*o,nA=H/2*o,rA=Math.min(gA*o,tA,nA),QA=N.has_stroke??!1,DA=N.is_filled??!0,RA=N.is_stroke_dashed??!1,NA=QA?Zm(N.stroke_width,.1)*o:0;let KA=i,EA=i;if(N.color){const dA=p6A(N.color);KA=dA,EA=dA}else KA="rgb(255, 243, 204)",EA="rgb(255, 243, 204)";if(((dA,qA,PA,nt,fA)=>{if(w.beginPath(),fA<=0)w.rect(dA,qA,PA,nt);else{const et=fA,WA=dA+PA,JA=qA+nt;w.moveTo(dA+et,qA),w.lineTo(WA-et,qA),w.quadraticCurveTo(WA,qA,WA,qA+et),w.lineTo(WA,JA-et),w.quadraticCurveTo(WA,JA,WA-et,JA),w.lineTo(dA+et,JA),w.quadraticCurveTo(dA,JA,dA,JA-et),w.lineTo(dA,qA+et),w.quadraticCurveTo(dA,qA,dA+et,qA),w.closePath()}})(-tA,-nA,tA*2,nA*2,rA),DA&&(w.fillStyle=KA,w.fill()),QA&&NA>0){if(w.strokeStyle=EA,w.lineWidth=NA,RA){const dA=Math.max(NA*2,1);w.setLineDash([dA,dA])}w.stroke(),RA&&w.setLineDash([])}w.restore()}),l.forEach(N=>{const M=N.font_size||.25,H=Math.min(Math.max(.01,M*.1),M*.05)*o;w.lineWidth=H,w.lineCap="butt",w.lineJoin="miter";const T=(0,O_e.vectorText)({height:M*.45,input:N.text}),Y=[];T.forEach(RA=>{RA.length===29?(Y.push(RA.slice(0,15)),Y.push(RA.slice(14,29))):RA.length===17?(Y.push(RA.slice(0,10)),Y.push(RA.slice(9,17))):Y.push(RA)});const O=Y.flat(),W={minX:O.length>0?Math.min(...O.map(RA=>RA[0])):0,maxX:O.length>0?Math.max(...O.map(RA=>RA[0])):0,minY:O.length>0?Math.min(...O.map(RA=>RA[1])):0,maxY:O.length>0?Math.max(...O.map(RA=>RA[1])):0},$=(W.minX+W.maxX)/2,iA=(W.minY+W.maxY)/2;let gA=-$,tA=-iA;const nA=N.anchor_alignment||"center";nA.includes("left")?gA=-W.minX:nA.includes("right")&&(gA=-W.maxX),nA.includes("top")?tA=-W.maxY:nA.includes("bottom")&&(tA=-W.minY);const rA=[];let QA=N.ccw_rotation??0;if(N.layer==="bottom"&&(rA.push(px($,iA),{a:-1,b:0,c:0,d:1,e:0,f:0},px(-$,-iA)),QA=-QA),QA){const RA=QA*Math.PI/180;rA.push(px($,iA),h6A(RA),px(-$,-iA))}const DA=rA.length>0?E6A(...rA):void 0;Y.forEach(RA=>{w.beginPath(),RA.forEach((NA,KA)=>{let EA={x:NA[0],y:NA[1]};DA&&(EA=C6A(DA,EA));const kA=EA.x+gA+N.anchor_position.x,dA=EA.y+tA+N.anchor_position.y,qA=b(kA),PA=k(dA);KA===0?w.moveTo(qA,PA):w.lineTo(qA,PA)}),w.stroke()})});const _=new CM(f);return _.generateMipmaps=!0,_.minFilter=Lu,_.magFilter=nB,_.anisotropy=16,_.needsUpdate=!0,_}function bW({layer:e,circuitJson:A,boardData:t,soldermaskColor:i,traceTextureResolution:o}){const n=zF(t),s=document.createElement("canvas"),r=Math.floor(n.width*o),a=Math.floor(n.height*o);s.width=r,s.height=a;const g=s.getContext("2d");if(!g)return null;e==="bottom"&&(g.translate(0,a),g.scale(1,-1));const c=f=>(f-n.minX)*o,I=f=>(n.maxY-f)*o;if(g.fillStyle=i,t.outline&&t.outline.length>=3){g.beginPath();const f=t.outline[0];g.moveTo(c(f.x),I(f.y));for(let m=1;m<t.outline.length;m++){const D=t.outline[m];g.lineTo(c(D.x),I(D.y))}g.closePath(),g.fill()}else g.fillRect(0,0,r,a);g.globalCompositeOperation="destination-out",g.fillStyle="black",xi(A).pcb_smtpad.list().filter(f=>f.layer===e).forEach(f=>{if(f.shape==="polygon"&&f.points){g.beginPath(),f.points.forEach((k,_)=>{const N=c(k.x),M=I(k.y);_===0?g.moveTo(N,M):g.lineTo(N,M)}),g.closePath(),g.fill();return}if(f.x===void 0||f.y===void 0)return;if(Number.isNaN(f.x)||Number.isNaN(f.y)){console.warn(`[soldermask-texture] Skipping pad ${f.pcb_smtpad_id} with NaN coordinates`);return}const m=f.x,D=f.y,w=c(m),b=I(D);if(f.shape==="rect"){const k=f.width*o,_=f.height*o,N=UC(f),M=d0(f.width,f.height,N)*o;M>0?(g.beginPath(),g.roundRect(w-k/2,b-_/2,k,_,M),g.fill()):g.fillRect(w-k/2,b-_/2,k,_)}else if(f.shape==="circle"){const k=(f.radius??f.width/2)*o;g.beginPath(),g.arc(w,b,k,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const k=f.width*o,_=f.height*o,N=UC(f),M=d0(f.width,f.height,N)*o;g.beginPath(),g.roundRect(w-k/2,b-_/2,k,_,M),g.fill()}else if(f.shape==="rotated_rect"){const k=f.width*o,_=f.height*o,N=UC(f),M=d0(f.width,f.height,N)*o,T=-(f.ccw_rotation||0)*(Math.PI/180);g.save(),g.translate(w,b),g.rotate(T),g.beginPath(),g.roundRect(-k/2,-_/2,k,_,M),g.fill(),g.restore()}}),xi(A).pcb_via.list().forEach(f=>{const m=c(f.x),D=I(f.y),w=f.outer_diameter/2*o;g.beginPath(),g.arc(m,D,w,0,2*Math.PI),g.fill()}),xi(A).pcb_plated_hole.list().forEach(f=>{if(!f.layers?.includes(e))return;const m=f.x,D=f.y,w=c(m),b=I(D);if(f.shape==="circle"){const _=f.outer_diameter/2*o;g.beginPath(),g.arc(w,b,_,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const k=(f.outer_width??f.outer_diameter??f.hole_width)*o,_=(f.outer_height??f.outer_diameter??f.hole_height)*o,N=Math.min(k,_)/2,H=-(f.ccw_rotation||0);H?(g.save(),g.translate(w,b),g.rotate(H*Math.PI/180),g.beginPath(),g.roundRect(-k/2,-_/2,k,_,N),g.fill(),g.restore()):(g.beginPath(),g.roundRect(w-k/2,b-_/2,k,_,N),g.fill())}else if(f.shape==="oval"){const k=(f.outer_width??f.outer_diameter??f.hole_width)*o,_=(f.outer_height??f.outer_diameter??f.hole_height)*o,N=k/2,M=_/2,T=-(f.ccw_rotation||0);T?(g.save(),g.translate(w,b),g.rotate(T*Math.PI/180),g.beginPath(),g.ellipse(0,0,N,M,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(w,b,N,M,0,0,2*Math.PI),g.fill())}else if(f.shape==="hole_with_polygon_pad"){const k=f.hole_shape||"circle",_=f.hole_offset_x||0,N=f.hole_offset_y||0,M=c(f.x+_),H=I(f.y+N);if(k==="pill"||k==="rotated_pill"){const T=(f.outer_width??f.outer_diameter??f.hole_width)*o,Y=(f.outer_height??f.outer_diameter??f.hole_height)*o,O=Math.min(T,Y)/2,$=-(f.ccw_rotation||0);$?(g.save(),g.translate(M,H),g.rotate($*Math.PI/180),g.beginPath(),g.roundRect(-T/2,-Y/2,T,Y,O),g.fill(),g.restore()):(g.beginPath(),g.roundRect(M-T/2,H-Y/2,T,Y,O),g.fill())}else if(k==="oval"){const T=(f.outer_width??f.outer_diameter??f.hole_width)*o,Y=(f.outer_height??f.outer_diameter??f.hole_height)*o,O=T/2,W=Y/2,iA=-(f.ccw_rotation||0);iA?(g.save(),g.translate(M,H),g.rotate(iA*Math.PI/180),g.beginPath(),g.ellipse(0,0,O,W,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(M,H,O,W,0,0,2*Math.PI),g.fill())}else if(k==="circle"){const Y=(f.outer_diameter??f.hole_diameter??0)*o/2;g.beginPath(),g.arc(M,H,Y,0,2*Math.PI),g.fill()}f.pad_outline&&f.pad_outline.length>=3&&(g.beginPath(),f.pad_outline.forEach((T,Y)=>{const O=c(f.x+T.x),W=I(f.y+T.y);Y===0?g.moveTo(O,W):g.lineTo(O,W)}),g.closePath(),g.fill())}else if(f.shape==="circular_hole_with_rect_pad"){const k=(f.rect_pad_width??f.hole_diameter??0)*o,_=(f.rect_pad_height??f.hole_diameter??0)*o,N=UC(f),M=d0(f.rect_pad_width??f.hole_diameter??0,f.rect_pad_height??f.hole_diameter??0,N)*o;M>0?(g.beginPath(),g.roundRect(w-k/2,b-_/2,k,_,M),g.fill()):g.fillRect(w-k/2,b-_/2,k,_)}else if(f.shape==="pill_hole_with_rect_pad"){const k=(f.rect_pad_width??f.hole_width??0)*o,_=(f.rect_pad_height??f.hole_height??0)*o,N=UC(f),M=d0(f.rect_pad_width??f.hole_width??0,f.rect_pad_height??f.hole_height??0,N)*o,T=-(f.ccw_rotation||0);T?(g.save(),g.translate(w,b),g.rotate(T*Math.PI/180),g.beginPath(),g.roundRect(-k/2,-_/2,k,_,M),g.fill(),g.restore()):(g.beginPath(),g.roundRect(w-k/2,b-_/2,k,_,M),g.fill())}else if(f.shape==="rotated_pill_hole_with_rect_pad"){const k=(f.rect_pad_width??f.hole_width??0)*o,_=(f.rect_pad_height??f.hole_height??0)*o,N=UC(f),M=d0(f.rect_pad_width??f.hole_width??0,f.rect_pad_height??f.hole_height??0,N)*o,T=-(f.rect_ccw_rotation||0);T?(g.save(),g.translate(w,b),g.rotate(T*Math.PI/180),g.beginPath(),g.roundRect(-k/2,-_/2,k,_,M),g.fill(),g.restore()):(g.beginPath(),g.roundRect(w-k/2,b-_/2,k,_,M),g.fill())}}),xi(A).pcb_hole.list().forEach(f=>{const m=f.x,D=f.y,w=c(m),b=I(D),k=f.hole_shape;if(k==="circle"&&typeof f.hole_diameter=="number"){const _=f.hole_diameter/2*o;g.beginPath(),g.arc(w,b,_,0,2*Math.PI),g.fill()}else if(k==="pill"&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const _=f.hole_width*o,N=f.hole_height*o,M=Math.min(_,N)/2;g.beginPath(),g.roundRect(w-_/2,b-N/2,_,N,M),g.fill()}else if(k==="rotated_pill"&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const _=f.hole_width*o,N=f.hole_height*o,M=Math.min(_,N)/2,T=-(f.ccw_rotation||0)*(Math.PI/180);T?(g.save(),g.translate(w,b),g.rotate(T),g.beginPath(),g.roundRect(-_/2,-N/2,_,N,M),g.fill(),g.restore()):(g.beginPath(),g.roundRect(w-_/2,b-N/2,_,N,M),g.fill())}else if(k==="oval"&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const _=f.hole_width*o,N=f.hole_height*o,M=_/2,H=N/2;g.beginPath(),g.ellipse(w,b,M,H,0,0,2*Math.PI),g.fill()}}),xi(A).pcb_copper_pour.list().forEach(f=>{if(f.layer===e&&f.covered_with_solder_mask===!1)if(f.shape==="rect"){const m=c(f.center.x),D=I(f.center.y),w=f.width*o,b=f.height*o;g.fillRect(m-w/2,D-b/2,w,b)}else f.shape==="polygon"&&f.points&&(g.beginPath(),f.points.forEach((m,D)=>{const w=c(m.x),b=I(m.y);D===0?g.moveTo(w,b):g.lineTo(w,b)}),g.closePath(),g.fill())}),xi(A).pcb_cutout.list().forEach(f=>{switch(f.shape){case"rect":{const m=c(f.center.x),D=I(f.center.y),w=f.width*o,b=f.height*o,k=UC(f),_=d0(f.width,f.height,k);if(f.rotation){g.save(),g.translate(m,D);const N=-f.rotation*(Math.PI/180);g.rotate(N),_>0?(g.beginPath(),g.roundRect(-w/2,-b/2,w,b,_*o),g.fill()):g.fillRect(-w/2,-b/2,w,b),g.restore()}else _>0?(g.beginPath(),g.roundRect(m-w/2,D-b/2,w,b,_*o),g.fill()):g.fillRect(m-w/2,D-b/2,w,b);break}case"circle":{const m=c(f.center.x),D=I(f.center.y),w=f.radius*o;g.beginPath(),g.arc(m,D,w,0,2*Math.PI),g.fill();break}case"polygon":{if(!f.points||f.points.length<3){console.warn(`PCB Cutout [${f.pcb_cutout_id}] polygon has fewer than 3 points, skipping in soldermask texture.`);break}g.beginPath(),f.points.forEach((m,D)=>{const w=c(m.x),b=I(m.y);D===0?g.moveTo(w,b):g.lineTo(w,b)}),g.closePath(),g.fill();break}default:console.warn(`Unsupported cutout shape: ${f.shape} for cutout ${f.pcb_cutout_id} in soldermask texture.`)}}),g.globalCompositeOperation="source-over";const d=new CM(s);return d.generateMipmaps=!0,d.minFilter=Lu,d.magFilter=nB,d.anisotropy=16,d.needsUpdate=!0,d}function f6A(e){return e&&e.route_type==="wire"&&typeof e.layer=="string"&&typeof e.width=="number"}function gv({layer:e,circuitJson:A,boardData:t,traceColor:i,traceTextureResolution:o}){const n=xi(A).pcb_trace.list(),s=xi(A).pcb_via.list(),r=xi(A).pcb_plated_hole.list(),a=n.filter(E=>E.route.some(Q=>f6A(Q)&&Q.layer===e));if(a.length===0)return null;const g=zF(t),c=document.createElement("canvas"),I=Math.floor(g.width*o),l=Math.floor(g.height*o);c.width=I,c.height=l;const B=c.getContext("2d");if(!B)return null;e==="bottom"&&(B.translate(0,l),B.scale(1,-1)),a.forEach(E=>{let Q=!0;B.beginPath(),B.strokeStyle=i,B.lineCap="round",B.lineJoin="round";let h=0;for(const u of E.route){if(!f6A(u)||u.layer!==e){Q||B.stroke(),Q=!0;continue}const d=u.x,f=u.y;h=u.width*o,B.lineWidth=h;const m=(d-g.minX)*o,D=(g.maxY-f)*o;Q?(B.moveTo(m,D),Q=!1):B.lineTo(m,D)}Q||B.stroke()}),B.globalCompositeOperation="destination-out",B.fillStyle="black",s.forEach(E=>{const Q=(E.x-g.minX)*o,h=(g.maxY-E.y)*o,u=E.outer_diameter/2*o;B.beginPath(),B.arc(Q,h,u,0,2*Math.PI,!1),B.fill()}),r.forEach(E=>{if(E.layers.includes(e)&&E.shape==="circle"){const Q=(E.x-g.minX)*o,h=(g.maxY-E.y)*o,u=E.outer_diameter/2*o;B.beginPath(),B.arc(Q,h,u,0,2*Math.PI,!1),B.fill()}else if(E.layers.includes(e)&&E.shape==="rotated_pill_hole_with_rect_pad"){const Q=(E.x-g.minX)*o,h=(g.maxY-E.y)*o,u=(E.rect_pad_width??E.hole_width??0)*o,d=(E.rect_pad_height??E.hole_height??0)*o,m=-(E.rect_ccw_rotation||0);m?(B.save(),B.translate(Q,h),B.rotate(m*Math.PI/180),B.beginPath(),B.rect(-u/2,-d/2,u,d),B.fill(),B.restore()):(B.beginPath(),B.rect(Q-u/2,h-d/2,u,d),B.fill())}}),B.globalCompositeOperation="source-over";const C=new CM(c);return C.generateMipmaps=!0,C.minFilter=Lu,C.magFilter=nB,C.anisotropy=16,C.needsUpdate=!0,C}function j_e({circuitJson:e,pcbThickness:A,isFaux:t=!1}){const{rootObject:i}=Ku(),{visibility:o}=WN(),n=AA.useMemo(()=>{const r=e.filter(c=>c.type==="pcb_panel"),a=xi(e).pcb_board.list();if(r.length>0){const c=r[0],I=a.find(l=>l.pcb_panel_id===c.pcb_panel_id);return{type:"pcb_board",pcb_board_id:c.pcb_panel_id,center:c.center,width:c.width,height:c.height,thickness:I?.thickness??1.4,material:I?.material??"fr4",num_layers:I?.num_layers??2}}const g=a.filter(c=>!c.pcb_panel_id);return g.length>0?g[0]:null},[e]),s=AA.useMemo(()=>{if(!n||!n.width||!n.height)return null;const r=i6A[n.material]??$o.fr4SolderMaskGreen,a=`rgb(${Math.round(r[0]*255)}, ${Math.round(r[1]*255)}, ${Math.round(r[2]*255)})`,g="rgb(255,255,255)",c=$o.fr4TracesWithMaskGreen,I=`rgb(${Math.round(c[0]*255)}, ${Math.round(c[1]*255)}, ${Math.round(c[2]*255)})`;return{topSoldermask:bW({layer:"top",circuitJson:e,boardData:n,soldermaskColor:a,traceTextureResolution:fc}),bottomSoldermask:bW({layer:"bottom",circuitJson:e,boardData:n,soldermaskColor:a,traceTextureResolution:fc}),topSilkscreen:SW({layer:"top",circuitJson:e,boardData:n,silkscreenColor:g,traceTextureResolution:fc}),bottomSilkscreen:SW({layer:"bottom",circuitJson:e,boardData:n,silkscreenColor:g,traceTextureResolution:fc}),topTraceWithMask:gv({layer:"top",circuitJson:e,boardData:n,traceColor:I,traceTextureResolution:fc}),bottomTraceWithMask:gv({layer:"bottom",circuitJson:e,boardData:n,traceColor:I,traceTextureResolution:fc}),topCopperText:wW({layer:"top",circuitJson:e,boardData:n,copperColor:`rgb(${Math.round($o.copper[0]*255)}, ${Math.round($o.copper[1]*255)}, ${Math.round($o.copper[2]*255)})`,traceTextureResolution:fc}),bottomCopperText:wW({layer:"bottom",circuitJson:e,boardData:n,copperColor:`rgb(${Math.round($o.copper[0]*255)}, ${Math.round($o.copper[1]*255)}, ${Math.round($o.copper[2]*255)})`,traceTextureResolution:fc}),topPanelOutlines:DW({layer:"top",circuitJson:e,panelData:n,traceTextureResolution:fc}),bottomPanelOutlines:DW({layer:"bottom",circuitJson:e,panelData:n,traceTextureResolution:fc}),topCopper:fW({layer:"top",circuitJson:e,boardData:n,traceTextureResolution:fc}),bottomCopper:fW({layer:"bottom",circuitJson:e,boardData:n,traceTextureResolution:fc})}},[e,n]);return AA.useEffect(()=>{if(!i||!n||!s)return;const r=[],a=(c,I,l,B,C=!1,E=!1)=>{if(!c)return null;const Q=zF(n),h=new Fm(Q.width,Q.height),u=new Nd({map:c,transparent:!0,side:jB,depthWrite:E,polygonOffset:C,polygonOffsetUnits:C?-.8:0,opacity:t?EW:1}),d=new sn(h,u);return d.position.set(Q.centerX,Q.centerY,I),l&&d.rotation.set(Math.PI,0,0),d.name=B,d},g=.001;if(o.topMask){const c=a(s.topSoldermask,A/2+g,!1,"jscad-top-soldermask",!0);c&&(r.push(c),i.add(c))}if(o.bottomMask){const c=a(s.bottomSoldermask,-A/2-g,!0,"jscad-bottom-soldermask",!0);c&&(r.push(c),i.add(c))}if(o.topCopper&&o.topMask){const c=a(s.topTraceWithMask,A/2+Za.traces+.004,!1,"jscad-top-trace-with-mask");c&&(r.push(c),i.add(c))}if(o.bottomCopper&&o.bottomMask){const c=a(s.bottomTraceWithMask,-A/2-Za.traces-.005,!0,"jscad-bottom-trace-with-mask");c&&(r.push(c),i.add(c))}if(o.topSilkscreen){const c=a(s.topSilkscreen,A/2+g+.002,!1,"jscad-top-silkscreen");c&&(r.push(c),i.add(c))}if(o.bottomSilkscreen){const c=a(s.bottomSilkscreen,-A/2-g-.002,!0,"jscad-bottom-silkscreen");c&&(r.push(c),i.add(c))}if(o.topCopper){const c=a(s.topCopperText,A/2+Za.copper,!1,"jscad-top-copper-text",!0);c&&(r.push(c),i.add(c))}if(o.bottomCopper){const c=a(s.bottomCopperText,-A/2-Za.copper,!0,"jscad-bottom-copper-text",!0);c&&(r.push(c),i.add(c))}if(o.topCopper){const c=a(s.topCopper,A/2+Za.copper,!1,"jscad-top-copper-pour",!0);c&&(r.push(c),i.add(c))}if(o.bottomCopper){const c=a(s.bottomCopper,-A/2-Za.copper,!0,"jscad-bottom-copper-pour",!0);c&&(r.push(c),i.add(c))}if(o.boardBody){const c=a(s.topPanelOutlines,A/2+g+.003,!1,"jscad-top-panel-outlines",!1,!0);c&&(r.push(c),i.add(c));const I=a(s.bottomPanelOutlines,-A/2-g-.003,!0,"jscad-bottom-panel-outlines",!1,!0);I&&(r.push(I),i.add(I))}return()=>{r.forEach(c=>{c.parent===i&&i.remove(c),c.geometry.dispose(),c.material instanceof tf&&c.material.dispose()})}},[i,n,s,A,o]),null}function z_e(e){const A=xi(e).cad_component.list(),t=xi(e).pcb_smtpad.list(),i=xi(e).pcb_hole.list(),o=xi(e).pcb_plated_hole.list(),n=xi(e).pcb_via.list();if(A.length===0&&t.length===0&&i.length===0&&o.length===0&&n.length===0)return null;const s=[...i,...o,...n,...t],r=mL(s);let a=r.minX,g=r.maxX,c=r.minY,I=r.maxY;for(const u of A)if(u.position){const d=u.position.x,f=u.position.y;a=Math.min(a,d),g=Math.max(g,d),c=Math.min(c,f),I=Math.max(I,f)}a===1/0&&(a=-10,g=10,c=-10,I=10);const l=2,B=Math.max(Math.abs(a),Math.abs(g))+l,C=Math.max(Math.abs(c),Math.abs(I))+l,E=Math.max(2*B,10),Q=Math.max(2*C,10);return{type:"pcb_board",pcb_board_id:"faux-board",center:{x:0,y:0},width:E,height:Q,thickness:1.4,material:"fr4",num_layers:2}}function y6A(e){if(xi(e).pcb_board.list().length>0)return e;const t=z_e(e);if(!t)return e;const o=t.thickness/2;return[...e.map(s=>{if(s.type==="cad_component"){const r=s;if(r.position){const a=r.position.z??0;return{...r,position:{...r.position,z:a+o}}}}return s}),t]}var X_e=AA.forwardRef(({circuitJson:e,children:A,autoRotateDisabled:t,clickToInteractEnabled:i,onUserInteraction:o,onCameraControllerReady:n},s)=>{const r=e6A(A),a=AA.useMemo(()=>y6A(e??r),[e,r]),g=S_e(a),c=AA.useMemo(()=>{if(!a)return[5,-5,5];try{const h=xi(a).pcb_board.list()[0];if(!h)return[5,-5,5];const{width:u,height:d}=h;if(!u&&!d)return[5,-5,5];const f=5,m=Math.max(u,f),D=Math.max(d,f),w=Math.max(m,D);return[w*.4,-w*.7,w*.9]}catch(h){return console.error(h),[5,-5,5]}},[a]),I=AA.useMemo(()=>{if(!a)return!1;try{const h=xi(a).pcb_board.list()[0];return!!h&&h.pcb_board_id==="faux-board"}catch{return!1}},[a]),l=AA.useMemo(()=>{if(a)try{const h=xi(a).pcb_board.list()[0];return h?{width:h.width??0,height:h.height??0}:void 0}catch(h){console.error(h);return}},[a]),B=AA.useMemo(()=>{if(a)try{const h=xi(a).pcb_board.list()[0];return!h||!h.center?void 0:{x:h.center.x,y:h.center.y}}catch(h){console.error(h);return}},[a]),C=mzA(a),{stls:E}=r_e(g),Q=xi(a).cad_component.list();return Z.jsxs(t6A,{ref:s,autoRotateDisabled:t,initialCameraPosition:c,clickToInteractEnabled:i,boardDimensions:l,boardCenter:B,onUserInteraction:o,onCameraControllerReady:n,children:[E.map(({stlData:h,color:u,layerType:d},f)=>Z.jsx(k_e,{stlData:h,color:u,opacity:f===0?I?.8:.95:1,layerType:d},`board-${f}`)),Z.jsx(j_e,{circuitJson:a,pcbThickness:C,isFaux:I}),Q.map(h=>Z.jsx(I6A,{fallback:({error:u})=>Z.jsx(c6A,{cad_component:h,error:u}),children:Z.jsx(jXA,{cad_component:h,circuitJson:a},h.cad_component_id)},h.cad_component_id))]})}),$_e=e=>{let A=0;for(let i=0;i<e.length;i++){const o=(i+1)%e.length;e[i]&&e[o]&&(A+=e[i][0]*e[o][1],A-=e[o][0]*e[i][1])}return A/2<=0};function Axe(e,A,t,i,o){let n,s=null;if(t.outline&&t.outline.length>=3){let r=t.outline.map(g=>[g.x,g.y]);$_e(r)&&(r=r.reverse());const a=A.ofPolygons([r]);o.push(a),s=a,n=e.extrude(a,i,void 0,void 0,void 0,!0),o.push(n)}else t.outline&&t.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),n=e.cube([t.width,t.height,i],!0),o.push(n),n=n.translate([t.center.x,t.center.y,0]),o.push(n);return{boardOp:n,outlineCrossSection:s}}var txe=64;function Pd({Manifold:e,width:A,height:t,thickness:i,borderRadius:o}){const n=d0(A,t,o);if(n<=0)return e.cube([A,t,i],!0);const s=[],r=A-2*n,a=t-2*n;return r>0&&s.push(e.cube([r,t,i],!0)),a>0&&s.push(e.cube([A,a,i],!0)),[[A/2-n,t/2-n],[-A/2+n,t/2-n],[-A/2+n,-t/2+n],[A/2-n,-t/2+n]].forEach(([c,I])=>{s.push(e.cylinder(i,n,n,txe,!0).translate([c,I,0]))}),e.union(s)}function exe({Manifold:e,pad:A,padBaseThickness:t}){if(A.shape==="rect"){const i=UC(A);return Pd({Manifold:e,width:A.width,height:A.height,thickness:t,borderRadius:i})}else if(A.shape==="rotated_rect"){const i=UC(A);let o=Pd({Manifold:e,width:A.width,height:A.height,thickness:t,borderRadius:i});const n=A.ccw_rotation??0;return n&&(o=o.rotate([0,0,n])),o}else if(A.shape==="circle"&&A.radius)return e.cylinder(t,A.radius,-1,32,!0);return null}var ixe=e=>{let A=0;for(let i=0;i<e.length;i++){const o=(i+1)%e.length;e[i]&&e[o]&&(A+=e[i][0]*e[o][1],A-=e[o][0]*e[i][1])}return A/2<=0};function oxe(e,A,t,i,o){const n=[],s=xi(t).pcb_cutout.list();for(const r of s){let a;const g=i*1.5;switch(r.shape){case"rect":{const l=UC(r);if(typeof l=="number"&&l>0?a=Pd({Manifold:e,width:r.width,height:r.height,thickness:g,borderRadius:l}):a=e.cube([r.width,r.height,g],!0),o.push(a),r.rotation){const B=a.rotate([0,0,r.rotation]);o.push(B),a=B}a=a.translate([r.center.x,r.center.y,0]),o.push(a);break}case"circle":a=e.cylinder(g,r.radius,-1,XB,!0),o.push(a),a=a.translate([r.center.x,r.center.y,0]),o.push(a);break;case"polygon":if(r.points.length<3){console.warn(`PCB Cutout [${r.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);continue}let c=r.points.map(l=>[l.x,l.y]);ixe(c)&&(c=c.reverse());const I=A.ofPolygons([c]);o.push(I),a=e.extrude(I,g,0,0,[1,1],!0),o.push(a);break;default:console.warn(`Unsupported cutout shape: ${r.shape} for cutout ${r.pcb_cutout_id}`);continue}a&&n.push(a)}return{cutoutOps:n}}function m6A({Manifold:e,x:A,y:t,diameter:i,thickness:o,segments:n=32}){return e.cylinder(o*1.2,i/2,i/2,n,!0).translate([A,t,0])}function w6A({Manifold:e,x:A,y:t,holeDiameter:i,thickness:o,zOffset:n=.001,segments:s=32}){const r=i/2+n;return e.cylinder(o*1.2,r,r,s,!0).translate([A,t,0])}function nxe(e,A,t,i,o){const n=[],s=xi(t).pcb_hole.list(),r=(g,c,I)=>{const l=Pd({Manifold:e,width:g,height:c,thickness:I,borderRadius:Math.min(g,c)/2});return o.push(l),l},a=(g,c,I)=>{const l=[];for(let B=0;B<I;B++){const C=2*Math.PI*B/I;l.push([g/2*Math.cos(C),c/2*Math.sin(C)])}return l};return s.forEach(g=>{const c=g.hole_shape,I=g.x,l=g.y,B=i*1.2,C=g.ccw_rotation??g.rotation??0,E=g.hole_width??g.hole_diameter,Q=g.hole_height??g.hole_diameter;let h=null;if(c==="circle"){h=m6A({Manifold:e,x:I,y:l,diameter:g.hole_diameter,thickness:i,segments:XB}),n.push(h),o.push(h);return}if(c==="pill"||c==="rotated_pill")h=r(E,Q,B);else if(c==="oval"){let u=a(E,Q,XB),d=0;for(let m=0;m<u.length;m++){const D=(m+1)%u.length;d+=u[m][0]*u[D][1],d-=u[D][0]*u[m][1]}d<=0&&(u=u.reverse());const f=A.ofPolygons([u]);o.push(f),h=e.extrude(f,B,0,0,[1,1],!0),o.push(h)}if(h){if(C!==0){const d=h.rotate([0,0,C]);o.push(d),h=d}const u=h.translate([I,l,0]);o.push(u),n.push(u)}}),{nonPlatedHoleBoardDrills:n}}function Vm(e){const A=new Dg;if(A.setAttribute("position",new qn(e.vertProperties,3)),A.setIndex(new P6(e.triVerts,1)),e.runIndex&&e.runIndex.length>1&&e.runOriginalID)for(let t=0;t<e.runIndex.length-1;t++){const i=e.runIndex[t],o=e.runIndex[t+1]-i;A.addGroup(i,o,0)}else A.addGroup(0,e.triVerts.length,0);return A}var wH=e=>{let A=0;for(let i=0;i<e.length;i++){const o=(i+1)%e.length;e[i]&&e[o]&&(A+=e[i][0]*e[o][1],A-=e[o][0]*e[i][1])}return A/2<=0},_W=(e,A,t)=>{const i=[];for(let o=0;o<t;o++){const n=2*Math.PI*o/t;i.push([e/2*Math.cos(n),A/2*Math.sin(n)])}return i},XF=new Pi(...$o.copper),xW=.05;function sxe(e,A,t,i,o,n){const s=[],r=xi(t).pcb_plated_hole.list(),a=[],g=[],c=(C,E,Q)=>{const h=Pd({Manifold:e,width:C,height:E,thickness:Q,borderRadius:Math.min(C,E)/2});return o.push(h),h},I=({padOutline:C,thickness:E})=>{if(!Array.isArray(C)||C.length<3)return null;let Q=C.map(d=>[d.x,d.y]);wH(Q)&&(Q=Q.reverse());const h=A.ofPolygons([Q]);o.push(h);const u=e.extrude(h,E,0,0,[1,1],!0);return o.push(u),u},l=({ph:C,depth:E,sizeDelta:Q=0})=>{if(C.shape!=="hole_with_polygon_pad")return null;const u=C.pad_outline;if(!Array.isArray(u)||u.length<3)return null;const d=C.hole_shape||"circle",f=C.hole_offset_x||0,m=C.hole_offset_y||0;let D=null;if(d==="circle"){const w=Math.max((C.hole_diameter??0)+Q,To),b=Math.max(w/2,To/2);D=e.cylinder(E,b,b,XB,!0),o.push(D)}else{const w=C.hole_width??C.hole_diameter,b=C.hole_height??C.hole_diameter;if(!w||!b)return null;const k=Math.max(w+Q,To),_=Math.max(b+Q,To);if(d==="oval"){let N=_W(k,_,XB);wH(N)&&(N=N.reverse());const M=A.ofPolygons([N]);o.push(M),D=e.extrude(M,E,0,0,[1,1],!0),o.push(D)}else(d==="pill"||d==="rotated_pill")&&(D=Pd({Manifold:e,width:k,height:_,thickness:E,borderRadius:Math.min(k,_)/2}),o.push(D))}if(!D)return null;if(f||m){const w=D.translate([f,m,0]);o.push(w),D=w}return D};r.forEach((C,E)=>{if(C.shape==="circle"){const Q=w6A({Manifold:e,x:C.x,y:C.y,holeDiameter:C.hole_diameter*1.02,thickness:i,zOffset:Bf,segments:XB});o.push(Q),s.push(Q);const h=i+2*Bf,u=e.cylinder(h,C.outer_diameter/2,C.outer_diameter/2,XB,!0);o.push(u);const d=e.cylinder(h*1.05,C.hole_diameter/2,C.hole_diameter/2,XB,!0);o.push(d);const f=u.subtract(d);o.push(f);const m=f.translate([C.x,C.y,0]);o.push(m);let D=m;if(n){const b=e.intersection([m,n]);o.push(b),D=b}g.push(D);const w=Vm(D.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:w,color:XF})}else if(C.shape==="pill"){const Q=C.hole_width,h=C.hole_height,u=.4,d=C.outer_width??Q+u,f=C.outer_height??h+u,m=Q+2*Bf,D=h+2*Bf,w=i*1.2;let b=c(m,D,w);if(C.ccw_rotation){const W=b.rotate([0,0,C.ccw_rotation]);o.push(W),b=W}const k=b.translate([C.x,C.y,0]);o.push(k),s.push(k);const _=i+2*Bf,N=c(d,f,_),M=c(Q,h,_*1.05);let H=N.subtract(M);if(o.push(H),C.ccw_rotation){const W=H.rotate([0,0,C.ccw_rotation]);o.push(W),H=W}const T=H.translate([C.x,C.y,0]);o.push(T);let Y=T;if(n){const W=e.intersection([T,n]);o.push(W),Y=W}g.push(Y);const O=Vm(Y.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:O,color:XF})}else if(C.shape==="pill_hole_with_rect_pad"){if(C.hole_shape&&C.hole_shape!=="pill"||C.pad_shape&&C.pad_shape!=="rect")return;const Q=C.hole_width,h=C.hole_height,u=C.hole_offset_x||0,d=C.hole_offset_y||0,f=C.rect_pad_width,m=C.rect_pad_height,D=UC(C),w=pH,b=Q+2*Bf,k=h+2*Bf,_=i*1.2,M=c(b,k,_).translate([u,d,0]).translate([C.x,C.y,0]);o.push(M),s.push(M);const H=Pd({Manifold:e,width:f,height:m,thickness:i-2*w-2*Za.copper+.1,borderRadius:D});o.push(H);const T=Pd({Manifold:e,width:f,height:m,thickness:w,borderRadius:D}).translate([0,0,i/2/2+Za.copper]),Y=Pd({Manifold:e,width:f,height:m,thickness:w,borderRadius:D}).translate([0,0,-i/2/2-Za.copper]);o.push(T,Y);const O=c(Q,h,i*1.02).translate([u,d,0]);o.push(O);const W=e.union([H,T,Y,O]);o.push(W);const $=c(Math.max(Q-2*xW,.01),Math.max(h-2*xW,.01),i*1.2).translate([u,d,0]);o.push($);const iA=W.subtract($);o.push(iA);const gA=iA.translate([C.x,C.y,0]);o.push(gA);let tA=gA;if(n){const rA=e.intersection([gA,n]);o.push(rA),tA=rA}g.push(tA);const nA=Vm(tA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:nA,color:XF})}else if(C.shape==="rotated_pill_hole_with_rect_pad"){if(C.hole_shape&&C.hole_shape!=="rotated_pill"||C.pad_shape&&C.pad_shape!=="rect")return;const Q=C.hole_width,h=C.hole_height,u=C.hole_offset_x||0,d=C.hole_offset_y||0,f=C.rect_pad_width,m=C.rect_pad_height,D=UC(C),w=pH,b=Q+2*Bf,k=h+2*Bf,_=i*1.2;let N=c(b,k,_).translate([u,d,0]);if(C.hole_ccw_rotation){const rA=N.rotate([0,0,C.hole_ccw_rotation]);o.push(rA),N=rA}const M=N.translate([C.x,C.y,0]);o.push(M),s.push(M);let H=Pd({Manifold:e,width:f,height:m,thickness:i-2*w-2*Za.copper+.1,borderRadius:D});if(o.push(H),C.rect_ccw_rotation){const rA=H.rotate([0,0,C.rect_ccw_rotation]);o.push(rA),H=rA}let T=Pd({Manifold:e,width:f,height:m,thickness:w,borderRadius:D}).translate([0,0,i/2/2+Za.copper]);if(C.rect_ccw_rotation){const rA=T.rotate([0,0,C.rect_ccw_rotation]);o.push(rA),T=rA}let Y=Pd({Manifold:e,width:f,height:m,thickness:w,borderRadius:D}).translate([0,0,-i/2/2-Za.copper]);if(C.rect_ccw_rotation){const rA=Y.rotate([0,0,C.rect_ccw_rotation]);o.push(rA),Y=rA}o.push(T,Y);let O=c(Q,h,i*1.02).translate([u,d,0]);if(C.hole_ccw_rotation){const rA=O.rotate([0,0,C.hole_ccw_rotation]);o.push(rA),O=rA}o.push(O);const W=e.union([H,T,Y,O]);o.push(W);let $=c(Math.max(Q-2*xW,.01),Math.max(h-2*xW,.01),i*1.2).translate([u,d,0]);if(C.hole_ccw_rotation){const rA=$.rotate([0,0,C.hole_ccw_rotation]);o.push(rA),$=rA}o.push($);const iA=W.subtract($);o.push(iA);const gA=iA.translate([C.x,C.y,0]);o.push(gA);let tA=gA;if(n){const rA=e.intersection([gA,n]);o.push(rA),tA=rA}g.push(tA);const nA=Vm(tA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:nA,color:XF})}else if(C.shape==="hole_with_polygon_pad"){const Q=C.pad_outline;if(!Array.isArray(Q)||Q.length<3)return;const h=l({ph:C,depth:i*1.2,sizeDelta:2*To});if(!h)return;const u=h.translate([C.x,C.y,0]);o.push(u),s.push(u);const d=pH,f=Math.max(i-2*d-2*Za.copper+.1,To),m=I({padOutline:Q,thickness:f}),D=I({padOutline:Q,thickness:d}),w=I({padOutline:Q,thickness:d});if(!m||!D||!w)return;const b=D.translate([0,0,i/2/2+Za.copper]),k=w.translate([0,0,-i/2/2-Za.copper]);o.push(b,k);const _=l({ph:C,depth:i*1.02});if(!_)return;const N=l({ph:C,depth:i*1.2,sizeDelta:-2*To})||_,M=e.union([m,b,k,_]);o.push(M);const H=M.subtract(N);o.push(H);const T=H.translate([C.x,C.y,0]);o.push(T);let Y=T;if(n){const W=e.intersection([T,n]);o.push(W),Y=W}g.push(Y);const O=Vm(Y.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:O,color:XF})}else if(C.shape==="oval"){const Q=C.hole_width,h=C.hole_height,u=C.outer_width??Q+.4,d=C.outer_height??h+.4,f=Q+2*Bf,m=h+2*Bf,D=i*1.2;let w=_W(f,m,XB);wH(w)&&(w=w.reverse());const b=A.ofPolygons([w]);o.push(b);let k=e.extrude(b,D,0,0,[1,1],!0);if(o.push(k),C.ccw_rotation){const nA=k.rotate([0,0,C.ccw_rotation]);o.push(nA),k=nA}const _=k.translate([C.x,C.y,0]);o.push(_),s.push(_);const N=i+2*Bf;let M=_W(u,d,XB);wH(M)&&(M=M.reverse());const H=A.ofPolygons([M]);o.push(H);const T=e.extrude(H,N,0,0,[1,1],!0);o.push(T);let Y=_W(Q,h,XB);wH(Y)&&(Y=Y.reverse());const O=A.ofPolygons([Y]);o.push(O);const W=e.extrude(O,N*1.05,0,0,[1,1],!0);o.push(W);let $=T.subtract(W);if(o.push($),C.ccw_rotation){const nA=$.rotate([0,0,C.ccw_rotation]);o.push(nA),$=nA}const iA=$.translate([C.x,C.y,0]);o.push(iA);let gA=iA;if(n){const nA=e.intersection([iA,n]);o.push(nA),gA=nA}g.push(gA);const tA=Vm(gA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:tA,color:XF})}else if(C.shape==="circular_hole_with_rect_pad"){if(C.hole_shape&&C.hole_shape!=="circle"||C.pad_shape&&C.pad_shape!=="rect")return;const Q=C.hole_offset_x||0,h=C.hole_offset_y||0,u=m6A({Manifold:e,x:C.x+Q,y:C.y+h,diameter:C.hole_diameter,thickness:i,segments:XB});o.push(u),s.push(u);const d=C.rect_pad_width??C.hole_diameter,f=C.rect_pad_height??C.hole_diameter,m=UC(C),D=pH,w=C.hole_diameter/2,b=Pd({Manifold:e,width:d,height:f,thickness:i-2*D-2*Za.copper+.1,borderRadius:m});o.push(b);const k=Pd({Manifold:e,width:d,height:f,thickness:D,borderRadius:m}).translate([0,0,i/2/2+Za.copper]),_=Pd({Manifold:e,width:d,height:f,thickness:D,borderRadius:m}).translate([0,0,-i/2/2-Za.copper]);o.push(k,_);const N=e.cylinder(i*1.02,w,w,XB,!0).translate([Q,h,0]);o.push(N);const M=e.union([b,k,_,N]);o.push(M);const H=e.cylinder(i*1.2,Math.max(w-To,.01),Math.max(w-To,.01),XB,!0).translate([Q,h,0]);o.push(H);const T=M.subtract(H);o.push(T);const Y=T.translate([C.x,C.y,0]);o.push(Y);let O=Y;if(n){const $=e.intersection([Y,n]);o.push($),O=$}g.push(O);const W=Vm(O.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||E}`,geometry:W,color:XF})}});let B;return g.length>0&&(B=e.union(g),o.push(B)),{platedHoleBoardDrills:s,platedHoleCopperGeoms:a,platedHoleSubtractOp:B}}var rxe=new Pi(...$o.copper);function axe(e,A,t,i,o,n){const s=[];return xi(A).pcb_smtpad.list().forEach((a,g)=>{const c=pH,I=a.layer==="bottom"?-t/2-Za.copper:t/2+Za.copper;let l=exe({Manifold:e,pad:a,padBaseThickness:c});if(l){i.push(l);const B=l.translate([a.x,a.y,I]);i.push(B);let C=B;if(o&&(C=B.subtract(o),i.push(C)),n){const Q=e.intersection([C,n]);i.push(Q),C=Q}const E=Vm(C.getMesh());s.push({key:`smt_pad-${a.layer||"top"}-${a.pcb_smtpad_id||g}`,geometry:E,color:rxe})}}),{smtPadGeoms:s}}function gxe({Manifold:e,x:A,y:t,outerDiameter:i,holeDiameter:o,thickness:n,zOffset:s=.001,segments:r=32}){const a=s,g=s;if(i<o)throw new Error(`Invalid via geometry: outerDiameter (${i}) must be >= holeDiameter (${o})`);const c=Math.min(i/2,o/2+g),I=e.cylinder(n,c,-1,r,!0),l=e.cylinder(a,i/2,-1,r,!0).translate([0,0,n/2]),B=e.cylinder(a,i/2,-1,r,!0).translate([0,0,-n/2]),C=e.union([I,l,B]),E=n+a*2,Q=e.cylinder(E,o/2,-1,r,!0);return C.subtract(Q).translate([A,t,0])}var cxe=new Pi(...$o.copper);function Ixe(e,A,t,i,o){const n=[],s=xi(A).pcb_via.list(),r=[];return s.forEach((a,g)=>{if(typeof a.hole_diameter=="number"){const c=w6A({Manifold:e,x:a.x,y:a.y,holeDiameter:a.hole_diameter,thickness:t,zOffset:Bf,segments:XB});i.push(c),n.push(c)}if(typeof a.outer_diameter=="number"&&typeof a.hole_diameter=="number"){const c=gxe({Manifold:e,x:a.x,y:a.y,outerDiameter:a.outer_diameter,holeDiameter:a.hole_diameter,thickness:t,zOffset:Bf,segments:XB});i.push(c);let I=c;if(o){const B=e.intersection([c,o]);i.push(B),I=B}const l=Vm(I.getMesh());r.push({key:`via-${a.pcb_via_id||g}`,geometry:l,color:cxe})}}),{viaBoardDrills:n,viaCopperGeoms:r}}var lxe=(e,A)=>{const[t,i]=AA.useState(null),[o,n]=AA.useState(null),[s,r]=AA.useState(null),[a,g]=AA.useState(null),[c,I]=AA.useState(!0),l=AA.useRef([]),B=AA.useMemo(()=>{const E=A.filter(u=>u.type==="pcb_panel"),Q=xi(A).pcb_board.list();if(E.length>0){const u=E[0],d=Q.find(f=>f.pcb_panel_id===u.pcb_panel_id);return{type:"pcb_board",pcb_board_id:u.pcb_panel_id,center:u.center,width:u.width,height:u.height,thickness:d?.thickness??1.4,material:d?.material??"fr4",num_layers:d?.num_layers??2}}const h=Q.filter(u=>!u.pcb_panel_id);return h.length>0?h[0]:null},[A]),C=AA.useMemo(()=>{const E=xi(A).pcb_board.list();return E.length>0&&E[0].pcb_board_id==="faux-board"},[A]);return AA.useEffect(()=>{if(!e||!B){i(null),n(null),r(null),I(!1);return}if((B.width===0||!B.width)&&(B.height===0||!B.height)&&(!B.outline||B.outline.length<3)){i({platedHoles:[],smtPads:[],vias:[]}),n({}),r(B.thickness??0),I(!1);return}I(!0),g(null);const E=e.Manifold,Q=e.CrossSection,h=m=>{if(!(!m||typeof m.delete!="function"))try{m.delete()}catch(D){(!(D instanceof Error)||!D.message?.includes("Manifold instance already deleted"))&&console.warn("Failed to delete Manifold instance",D)}};l.current.forEach(h),l.current=[];let u=null;const d={},f={};try{const m=B.thickness||1.4;r(m);const{boardOp:D,outlineCrossSection:w}=Axe(E,Q,B,m,l.current);let b=D;const _=m+2*1;let N=null;const M=.01;if(w){let qA=w;if(M>0){const nt=w.offset(M);l.current.push(nt),qA=nt}const PA=E.extrude(qA,_,void 0,void 0,void 0,!0);l.current.push(PA),N=PA}else{const qA=(B.width||0)+2*M,PA=(B.height||0)+2*M,nt=E.cube([qA,PA,_],!0);l.current.push(nt);const fA=nt.translate([B.center.x,B.center.y,0]);l.current.push(fA),N=fA}const H=[];let T=null;const{nonPlatedHoleBoardDrills:Y}=nxe(E,Q,A,m,l.current);H.push(...Y);const{platedHoleBoardDrills:O,platedHoleCopperGeoms:W,platedHoleSubtractOp:$}=sxe(E,Q,A,m,l.current,N);H.push(...O),d.platedHoles=W;const{viaBoardDrills:iA,viaCopperGeoms:gA}=Ixe(E,A,m,l.current,N);if(H.push(...iA),d.vias=gA,H.length>0){T=E.union(H),l.current.push(T);const qA=$?E.union([T,$]):T;l.current.push(qA);const PA=b.subtract(qA);if(l.current.push(PA),b=PA,$){const nt=$.subtract(T);l.current.push(nt);const fA=nt.getMesh(),et=Vm(fA);d.platedHoles=[{key:"plated-holes-union",geometry:et,color:new Pi($o.copper[0],$o.copper[1],$o.copper[2])}]}}const{cutoutOps:tA}=oxe(E,Q,A,m,l.current);if(tA.length>0){const qA=E.union(tA);l.current.push(qA);const PA=b.subtract(qA);l.current.push(PA),b=PA}if(u=b,u){const qA=u.getMesh(),PA=Vm(qA),nt=HEA[B.material]??$o.fr4Tan;d.board={geometry:PA,color:new Pi(nt[0],nt[1],nt[2]),material:B.material,isFaux:C}}const{smtPadGeoms:nA}=axe(E,A,m,l.current,T,N);d.smtPads=nA,i(d);const rA=$o.fr4TracesWithoutMaskTan,QA=`rgb(${Math.round(rA[0]*255)}, ${Math.round(rA[1]*255)}, ${Math.round(rA[2]*255)})`;f.topTrace=gv({layer:"top",circuitJson:A,boardData:B,traceColor:QA,traceTextureResolution:fc}),f.bottomTrace=gv({layer:"bottom",circuitJson:A,boardData:B,traceColor:QA,traceTextureResolution:fc});const DA=$o.fr4TracesWithMaskGreen,RA=`rgb(${Math.round(DA[0]*255)}, ${Math.round(DA[1]*255)}, ${Math.round(DA[2]*255)})`;f.topTraceWithMask=gv({layer:"top",circuitJson:A,boardData:B,traceColor:RA,traceTextureResolution:fc}),f.bottomTraceWithMask=gv({layer:"bottom",circuitJson:A,boardData:B,traceColor:RA,traceTextureResolution:fc});const NA="rgb(255,255,255)";f.topSilkscreen=SW({layer:"top",circuitJson:A,boardData:B,silkscreenColor:NA,traceTextureResolution:fc}),f.bottomSilkscreen=SW({layer:"bottom",circuitJson:A,boardData:B,silkscreenColor:NA,traceTextureResolution:fc});const KA=i6A[B.material]??$o.fr4SolderMaskGreen,EA=`rgb(${Math.round(KA[0]*255)}, ${Math.round(KA[1]*255)}, ${Math.round(KA[2]*255)})`;f.topSoldermask=bW({layer:"top",circuitJson:A,boardData:B,soldermaskColor:EA,traceTextureResolution:fc}),f.bottomSoldermask=bW({layer:"bottom",circuitJson:A,boardData:B,soldermaskColor:EA,traceTextureResolution:fc});const kA=$o.copper,dA=`rgb(${Math.round(kA[0]*255)}, ${Math.round(kA[1]*255)}, ${Math.round(kA[2]*255)})`;f.topCopperText=wW({layer:"top",circuitJson:A,boardData:B,copperColor:dA,traceTextureResolution:fc}),f.bottomCopperText=wW({layer:"bottom",circuitJson:A,boardData:B,copperColor:dA,traceTextureResolution:fc}),f.topPanelOutlines=DW({layer:"top",circuitJson:A,panelData:B,traceTextureResolution:fc}),f.bottomPanelOutlines=DW({layer:"bottom",circuitJson:A,panelData:B,traceTextureResolution:fc}),f.topCopper=fW({layer:"top",circuitJson:A,boardData:B,traceTextureResolution:fc}),f.bottomCopper=fW({layer:"bottom",circuitJson:A,boardData:B,traceTextureResolution:fc}),n(f)}catch(m){console.error("Error processing geometry with Manifold in hook:",m),g(m.message||"An unknown error occurred while processing geometry in hook."),i(null),n(null)}finally{I(!1)}return()=>{l.current.forEach(h),l.current=[]}},[e,A,B]),{geoms:t,textures:o,pcbThickness:s,error:a,isLoading:c,boardData:B,isFauxBoard:C}},Bxe=jB,Cxe=({material:e,color:A,side:t=Bxe,isFaux:i=!1})=>e==="fr4"?new Gm({color:A,side:t,metalness:0,roughness:.8,specularIntensity:.2,ior:1.45,sheen:0,clearcoat:0,transparent:i,opacity:i?EW:1,flatShading:!0}):new mh({color:A,side:t,flatShading:!0,metalness:.1,roughness:.8,transparent:!0,opacity:i?EW:.9});function Qxe(e){const A=[];if(!e)return A;if(e.board&&e.board.geometry){const i=new sn(e.board.geometry,Cxe({material:e.board.material,color:e.board.color,side:jB,isFaux:e.board.isFaux}));i.name="board-geom",A.push(i)}const t=i=>{i&&i.forEach(o=>{const n=new sn(o.geometry,new mh({color:o.color,side:jB,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}));n.name=o.key,A.push(n)})};return t(e.platedHoles),t(e.smtPads),t(e.vias),A}var Exe=({geometryMeshes:e,textureMeshes:A})=>{const{rootObject:t}=Ku(),{visibility:i}=WN();return AA.useEffect(()=>{if(t)return e.forEach(o=>{let n=!0;o.name==="board-geom"?n=i.boardBody:o.name.includes("smt_pad")?o.name.includes("smt_pad-top")?n=i.topCopper:o.name.includes("smt_pad-bottom")?n=i.bottomCopper:n=i.topCopper||i.bottomCopper:(o.name.includes("plated_hole")||o.name.includes("via"))&&(n=i.topCopper||i.bottomCopper),n&&t.add(o)}),A.forEach(o=>{let n=!0;o.name.includes("top-trace-texture-plane")&&!o.name.includes("with-mask")?n=i.topCopper&&!i.topMask:o.name.includes("top-trace-with-mask")?n=i.topCopper&&i.topMask:o.name.includes("bottom-trace-texture-plane")&&!o.name.includes("with-mask")?n=i.bottomCopper&&!i.bottomMask:o.name.includes("bottom-trace-with-mask")?n=i.bottomCopper&&i.bottomMask:o.name.includes("top-silkscreen")?n=i.topSilkscreen:o.name.includes("bottom-silkscreen")?n=i.bottomSilkscreen:o.name.includes("top-soldermask")?n=i.topMask:o.name.includes("bottom-soldermask")?n=i.bottomMask:o.name.includes("top-copper-text")?n=i.topCopper:o.name.includes("bottom-copper-text")?n=i.bottomCopper:o.name.includes("top-copper")?n=i.topCopper:o.name.includes("bottom-copper")?n=i.bottomCopper:o.name.includes("panel-outlines")&&(n=i.boardBody),n&&t.add(o)}),()=>{e.forEach(o=>{o.parent===t&&t.remove(o)}),A.forEach(o=>{o.parent===t&&t.remove(o)})}},[t,e,A,i]),null},hxe="https://cdn.jsdelivr.net/npm/manifold-3d@3.2.1",uxe=({circuitJson:e,autoRotateDisabled:A,clickToInteractEnabled:t,onUserInteraction:i,children:o,onCameraControllerReady:n})=>{const s=e6A(o),r=AA.useMemo(()=>y6A(e??s),[e,s]),[a,g]=AA.useState(null),[c,I]=AA.useState(null);AA.useEffect(()=>{if(window.ManifoldModule&&typeof window.ManifoldModule=="object"&&window.ManifoldModule.setup){g(window.ManifoldModule);return}const k=async Y=>{try{const O=await Y();O.setup(),window.ManifoldModule=O,g(O)}catch(O){console.error("Failed to initialize Manifold:",O),I(`Failed to initialize Manifold: ${O instanceof Error?O.message:"Unknown error"}`)}},_=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(_){window.ManifoldModule=_,k(window.ManifoldModule);return}const N="manifoldLoaded",M=()=>{const Y=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(Y)window.ManifoldModule=Y,k(window.ManifoldModule);else{const O="ManifoldModule not found on window after script load.";console.error(O),I(O)}};window.addEventListener(N,M,{once:!0});const H=document.createElement("script");H.type="module",H.innerHTML=`
|
|
5174
5174
|
try {
|
|
5175
5175
|
const { default: ManifoldModule } = await import('${hxe}/manifold.js');
|
|
5176
5176
|
window.ManifoldModule = ManifoldModule;
|
|
@@ -5179,7 +5179,7 @@ try {
|
|
|
5179
5179
|
} finally {
|
|
5180
5180
|
window.dispatchEvent(new CustomEvent('${N}'));
|
|
5181
5181
|
}
|
|
5182
|
-
`.trim();const T=Y=>{const O="Failed to load Manifold loader script.";console.error(O,Y),I(O),window.removeEventListener(N,M)};return H.addEventListener("error",T),document.body.appendChild(H),()=>{window.removeEventListener(N,M),H.removeEventListener("error",T)}},[]);const{geoms:l,textures:B,pcbThickness:C,error:E,isLoading:Q,boardData:h,isFauxBoard:u}=lxe(a,r),d=AA.useMemo(()=>Qxe(l),[l]),f=AA.useMemo(()=>V_e(B,h,C,u),[B,h,C,u]),m=AA.useMemo(()=>xi(r).cad_component.list(),[r]),D=AA.useMemo(()=>{if(!h)return;const{width:k=0,height:_=0}=h;return{width:k,height:_}},[h]),w=AA.useMemo(()=>{if(!h)return;const{center:k}=h;if(k)return{x:k.x,y:k.y}},[h]),b=AA.useMemo(()=>{if(!h)return[5,-5,5];const{width:k=0,height:_=0}=h,N=Math.max(k,1),M=Math.max(_,1),H=Math.max(N,M,5);return[H*.4,-H*.7,H*.9]},[h]);return c?Z.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",c]}):a?E?Z.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",E]}):Q?Z.jsx("div",{style:{padding:"1em"},children:"Processing board geometry..."}):Z.jsxs(t6A,{initialCameraPosition:b,autoRotateDisabled:A,clickToInteractEnabled:t,boardDimensions:D,boardCenter:w,onUserInteraction:i,onCameraControllerReady:n,children:[Z.jsx(Exe,{geometryMeshes:d,textureMeshes:f}),m.map(k=>Z.jsx(I6A,{fallback:({error:_})=>Z.jsx(c6A,{cad_component:k,error:_}),children:Z.jsx(jXA,{cad_component:k,circuitJson:r})},k.cad_component_id))]}):Z.jsx("div",{style:{padding:"1em"},children:"Loading Manifold module..."})},dxe=uxe,pxe=({containerRef:e})=>{const[A,t]=AA.useState(!1),[i,o]=AA.useState({x:0,y:0}),n=AA.useRef(null),s=AA.useRef(null),r=AA.useRef(null),a=AA.useRef(!1),g=()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},c=AA.useCallback(Q=>{Q.preventDefault();const h=typeof Q.clientX=="number"?Q.clientX:0,u=typeof Q.clientY=="number"?Q.clientY:0;if(a.current){a.current=!1;return}if(!s.current)return;const{x:d,y:f}=s.current,m=Math.abs(h-d),D=Math.abs(u-f),w=10;if(m>w||D>w){s.current=null;return}o({x:h,y:u}),t(!0),s.current=null},[o,t]),I=AA.useCallback(Q=>{if(Q.touches.length===1){const h=Q.touches[0];h?(s.current={x:h.clientX,y:h.clientY},g(),r.current=window.setTimeout(()=>{if(s.current){if(e.current){const u=e.current.getBoundingClientRect();o({x:u.left+u.width/2,y:u.top+u.height/2}),t(!0),a.current=!0}s.current=null}},600)):s.current=null}else s.current=null,g()},[e]),l=AA.useCallback(Q=>{if(!s.current||Q.touches.length!==1)return;const h=Q.touches[0];if(h){const u=Math.abs(h.clientX-s.current.x),d=Math.abs(h.clientY-s.current.y),f=10;(u>f||d>f)&&(s.current=null,g())}else s.current=null,g()},[]),B=AA.useCallback(()=>{g(),setTimeout(()=>{s.current&&(s.current=null)},0)},[]),C=AA.useCallback(Q=>{const h=Q.target;n.current&&n.current.contains(h)||h.closest?.("[data-radix-popper-content-wrapper], [data-radix-dropdown-menu-content], [data-radix-dropdown-menu-sub-content]")||t(!1)},[]);return AA.useEffect(()=>{if(A)return document.addEventListener("mousedown",C),document.addEventListener("touchstart",C),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("touchstart",C)}},[A,C]),{menuVisible:A,menuPos:i,menuRef:n,contextMenuEventHandlers:{onMouseDown:Q=>{Q.button===2?s.current={x:Q.clientX,y:Q.clientY}:s.current=null},onContextMenu:c,onTouchStart:I,onTouchMove:l,onTouchEnd:B},setMenuVisible:t}};function fxe({setAutoRotate:e,setAutoRotateUserToggled:A,setCameraPreset:t,closeMenu:i,cameraControllerRef:o,isAnimatingRef:n,lastPresetSelectTime:s}){return{handleCameraPresetSelect:AA.useCallback(a=>{e(!1),A(!0),t(a),i(),s.current=Date.now(),a!=="Custom"&&(n.current=!0,o.current?.animateToPreset(a),setTimeout(()=>{n.current=!1},600))},[e,A,t,i,o,n,s])}}var yxe=()=>AA.useCallback(()=>{const e=window.__TSCIRCUIT_THREE_OBJECT;if(!e)return;new w$().parse(e,t=>{const i=new Blob([t instanceof ArrayBuffer?t:JSON.stringify(t)],{type:"model/gltf+json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download="scene.gltf",n.click(),URL.revokeObjectURL(o)},t=>{console.error("Failed to export GLTF",t)})},[]),cv=new Map,KEA=new Set,D6A=!1,PEA=0,qEA=0,kW=null,S6A=!1,mxe=20,wxe=e=>{const A=e.toLowerCase().split("+"),t=A[A.length-1],i=A.slice(0,-1);return{key:t,ctrl:i.includes("ctrl"),cmd:i.includes("cmd"),shift:i.includes("shift"),alt:i.includes("alt")}},Dxe=(e,A)=>{const t=wxe(A),i=e.key.toLowerCase()===t.key,o=t.ctrl===e.ctrlKey,n=t.cmd===e.metaKey,s=t.shift===e.shiftKey,r=t.alt===e.altKey;return i&&o&&n&&s&&r},Sxe=e=>{if(!e||typeof e!="object")return!1;const A=e,t=A.tagName,i=["INPUT","TEXTAREA","SELECT"];if(i.includes(t))return!0;const o=A.getAttribute?.("contenteditable");if(o==="true"||o==="")return!0;let n=A.parentElement;for(let s=0;s<mxe&&n;s++){const r=n.tagName;if(i.includes(r))return!0;const a=n.getAttribute?.("contenteditable");if(a==="true"||a==="")return!0;n=n.parentElement}return!1},bxe=()=>{if(typeof document>"u")return!1;const e=document.activeElement;if(!e)return!1;const A=e.tagName;if(A==="INPUT"||A==="TEXTAREA"||A==="SELECT")return!0;const t=e.getAttribute("contenteditable");return t==="true"||t===""},_xe=()=>{if(!kW)return!0;const e=kW.getBoundingClientRect();return PEA>=e.left&&PEA<=e.right&&qEA>=e.top&&qEA<=e.bottom},xxe=()=>{S6A||typeof window>"u"||(window.addEventListener("mousemove",e=>{PEA=e.clientX,qEA=e.clientY}),S6A=!0)},kxe=e=>{Sxe(e.target)||bxe()||kW&&!_xe()||cv.forEach(A=>{Dxe(e,A.shortcut)&&(e.preventDefault(),A.invoke())})},b6A=()=>{const e=Array.from(cv.values());KEA.forEach(A=>A(e))},Fxe=()=>{D6A||typeof window>"u"||(window.addEventListener("keydown",kxe),D6A=!0)},Gxe=e=>{cv.set(e.id,e),b6A(),Fxe()},Rxe=e=>{cv.delete(e)&&b6A()},Mxe=e=>(KEA.add(e),e(Array.from(cv.values())),()=>{KEA.delete(e)}),FW=(e,A,t)=>{const i=AA.useRef(A);i.current=A;const o=AA.useMemo(()=>({shortcut:t.shortcut,description:t.description}),[t.shortcut,t.description]);AA.useEffect(()=>{const n={id:e,...o,invoke:()=>i.current()};return Gxe(n),()=>{Rxe(e)}},[e,o])},Nxe=()=>{const[e,A]=AA.useState(()=>Array.from(cv.values()));return AA.useEffect(()=>Mxe(A),[]),e},vxe=e=>{kW=e,xxe()},Lxe=()=>({showToast:(e,A=2e3)=>{Ts(e,{duration:A})}}),Uxe=({children:e})=>Z.jsxs(Z.Fragment,{children:[e,Z.jsx(Z9A,{position:"bottom-right"})]});function ca(e,A,{checkForDefaultPrevented:t=!0}={}){return function(o){if(e?.(o),t===!1||!o.defaultPrevented)return A?.(o)}}function _6A(e,A){if(typeof e=="function")return e(A);e!=null&&(e.current=A)}function GW(...e){return A=>{let t=!1;const i=e.map(o=>{const n=_6A(o,A);return!t&&typeof n=="function"&&(t=!0),n});if(t)return()=>{for(let o=0;o<i.length;o++){const n=i[o];typeof n=="function"?n():_6A(e[o],null)}}}}function Qf(...e){return AA.useCallback(GW(...e),e)}function DH(e,A=[]){let t=[];function i(n,s){const r=AA.createContext(s),a=t.length;t=[...t,s];const g=I=>{const{scope:l,children:B,...C}=I,E=l?.[e]?.[a]||r,Q=AA.useMemo(()=>C,Object.values(C));return Z.jsx(E.Provider,{value:Q,children:B})};g.displayName=n+"Provider";function c(I,l){const B=l?.[e]?.[a]||r,C=AA.useContext(B);if(C)return C;if(s!==void 0)return s;throw new Error(`\`${I}\` must be used within \`${n}\``)}return[g,c]}const o=()=>{const n=t.map(s=>AA.createContext(s));return function(r){const a=r?.[e]||n;return AA.useMemo(()=>({[`__scope${e}`]:{...r,[e]:a}}),[r,a])}};return o.scopeName=e,[i,Hxe(o,...A)]}function Hxe(...e){const A=e[0];if(e.length===1)return A;const t=()=>{const i=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(n){const s=i.reduce((r,{useScope:a,scopeName:g})=>{const I=a(n)[`__scope${g}`];return{...r,...I}},{});return AA.useMemo(()=>({[`__scope${A.scopeName}`]:s}),[s])}};return t.scopeName=A.scopeName,t}var fx=globalThis?.document?AA.useLayoutEffect:()=>{},Yxe=a2[" useInsertionEffect ".trim().toString()]||fx;function OEA({prop:e,defaultProp:A,onChange:t=()=>{},caller:i}){const[o,n,s]=Jxe({defaultProp:A,onChange:t}),r=e!==void 0,a=r?e:o;{const c=AA.useRef(e!==void 0);AA.useEffect(()=>{const I=c.current;I!==r&&console.warn(`${i} is changing from ${I?"controlled":"uncontrolled"} to ${r?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=r},[r,i])}const g=AA.useCallback(c=>{if(r){const I=Txe(c)?c(e):c;I!==e&&s.current?.(I)}else n(c)},[r,e,n,s]);return[a,g]}function Jxe({defaultProp:e,onChange:A}){const[t,i]=AA.useState(e),o=AA.useRef(t),n=AA.useRef(A);return Yxe(()=>{n.current=A},[A]),AA.useEffect(()=>{o.current!==t&&(n.current?.(t),o.current=t)},[t,o]),[t,i,n]}function Txe(e){return typeof e=="function"}function RW(e){const A=Kxe(e),t=AA.forwardRef((i,o)=>{const{children:n,...s}=i,r=AA.Children.toArray(n),a=r.find(qxe);if(a){const g=a.props.children,c=r.map(I=>I===a?AA.Children.count(g)>1?AA.Children.only(null):AA.isValidElement(g)?g.props.children:null:I);return Z.jsx(A,{...s,ref:o,children:AA.isValidElement(g)?AA.cloneElement(g,void 0,c):null})}return Z.jsx(A,{...s,ref:o,children:n})});return t.displayName=`${e}.Slot`,t}function Kxe(e){const A=AA.forwardRef((t,i)=>{const{children:o,...n}=t;if(AA.isValidElement(o)){const s=Wxe(o),r=Oxe(n,o.props);return o.type!==AA.Fragment&&(r.ref=i?GW(i,s):s),AA.cloneElement(o,r)}return AA.Children.count(o)>1?AA.Children.only(null):null});return A.displayName=`${e}.SlotClone`,A}var Pxe=Symbol("radix.slottable");function qxe(e){return AA.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Pxe}function Oxe(e,A){const t={...A};for(const i in A){const o=e[i],n=A[i];/^on[A-Z]/.test(i)?o&&n?t[i]=(...r)=>{const a=n(...r);return o(...r),a}:o&&(t[i]=o):i==="style"?t[i]={...o,...n}:i==="className"&&(t[i]=[o,n].filter(Boolean).join(" "))}return{...e,...t}}function Wxe(e){let A=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning;return t?e.ref:(A=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var Zxe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],qd=Zxe.reduce((e,A)=>{const t=RW(`Primitive.${A}`),i=AA.forwardRef((o,n)=>{const{asChild:s,...r}=o,a=s?t:A;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),Z.jsx(a,{...r,ref:n})});return i.displayName=`Primitive.${A}`,{...e,[A]:i}},{});function x6A(e,A){e&&g2.flushSync(()=>e.dispatchEvent(A))}function k6A(e){const A=e+"CollectionProvider",[t,i]=DH(A),[o,n]=t(A,{collectionRef:{current:null},itemMap:new Map}),s=E=>{const{scope:Q,children:h}=E,u=no.useRef(null),d=no.useRef(new Map).current;return Z.jsx(o,{scope:Q,itemMap:d,collectionRef:u,children:h})};s.displayName=A;const r=e+"CollectionSlot",a=RW(r),g=no.forwardRef((E,Q)=>{const{scope:h,children:u}=E,d=n(r,h),f=Qf(Q,d.collectionRef);return Z.jsx(a,{ref:f,children:u})});g.displayName=r;const c=e+"CollectionItemSlot",I="data-radix-collection-item",l=RW(c),B=no.forwardRef((E,Q)=>{const{scope:h,children:u,...d}=E,f=no.useRef(null),m=Qf(Q,f),D=n(c,h);return no.useEffect(()=>(D.itemMap.set(f,{ref:f,...d}),()=>{D.itemMap.delete(f)})),Z.jsx(l,{[I]:"",ref:m,children:u})});B.displayName=c;function C(E){const Q=n(e+"CollectionConsumer",E);return no.useCallback(()=>{const u=Q.collectionRef.current;if(!u)return[];const d=Array.from(u.querySelectorAll(`[${I}]`));return Array.from(Q.itemMap.values()).sort((D,w)=>d.indexOf(D.ref.current)-d.indexOf(w.ref.current))},[Q.collectionRef,Q.itemMap])}return[{Provider:s,Slot:g,ItemSlot:B},C,i]}var Vxe=AA.createContext(void 0);function F6A(e){const A=AA.useContext(Vxe);return e||A||"ltr"}function gD(e){const A=AA.useRef(e);return AA.useEffect(()=>{A.current=e}),AA.useMemo(()=>(...t)=>A.current?.(...t),[])}function jxe(e,A=globalThis?.document){const t=gD(e);AA.useEffect(()=>{const i=o=>{o.key==="Escape"&&t(o)};return A.addEventListener("keydown",i,{capture:!0}),()=>A.removeEventListener("keydown",i,{capture:!0})},[t,A])}var zxe="DismissableLayer",WEA="dismissableLayer.update",Xxe="dismissableLayer.pointerDownOutside",$xe="dismissableLayer.focusOutside",G6A,R6A=AA.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),M6A=AA.forwardRef((e,A)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:n,onInteractOutside:s,onDismiss:r,...a}=e,g=AA.useContext(R6A),[c,I]=AA.useState(null),l=c?.ownerDocument??globalThis?.document,[,B]=AA.useState({}),C=Qf(A,w=>I(w)),E=Array.from(g.layers),[Q]=[...g.layersWithOutsidePointerEventsDisabled].slice(-1),h=E.indexOf(Q),u=c?E.indexOf(c):-1,d=g.layersWithOutsidePointerEventsDisabled.size>0,f=u>=h,m=eke(w=>{const b=w.target,k=[...g.branches].some(_=>_.contains(b));!f||k||(o?.(w),s?.(w),w.defaultPrevented||r?.())},l),D=ike(w=>{const b=w.target;[...g.branches].some(_=>_.contains(b))||(n?.(w),s?.(w),w.defaultPrevented||r?.())},l);return jxe(w=>{u===g.layers.size-1&&(i?.(w),!w.defaultPrevented&&r&&(w.preventDefault(),r()))},l),AA.useEffect(()=>{if(c)return t&&(g.layersWithOutsidePointerEventsDisabled.size===0&&(G6A=l.body.style.pointerEvents,l.body.style.pointerEvents="none"),g.layersWithOutsidePointerEventsDisabled.add(c)),g.layers.add(c),N6A(),()=>{t&&g.layersWithOutsidePointerEventsDisabled.size===1&&(l.body.style.pointerEvents=G6A)}},[c,l,t,g]),AA.useEffect(()=>()=>{c&&(g.layers.delete(c),g.layersWithOutsidePointerEventsDisabled.delete(c),N6A())},[c,g]),AA.useEffect(()=>{const w=()=>B({});return document.addEventListener(WEA,w),()=>document.removeEventListener(WEA,w)},[]),Z.jsx(qd.div,{...a,ref:C,style:{pointerEvents:d?f?"auto":"none":void 0,...e.style},onFocusCapture:ca(e.onFocusCapture,D.onFocusCapture),onBlurCapture:ca(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:ca(e.onPointerDownCapture,m.onPointerDownCapture)})});M6A.displayName=zxe;var Ake="DismissableLayerBranch",tke=AA.forwardRef((e,A)=>{const t=AA.useContext(R6A),i=AA.useRef(null),o=Qf(A,i);return AA.useEffect(()=>{const n=i.current;if(n)return t.branches.add(n),()=>{t.branches.delete(n)}},[t.branches]),Z.jsx(qd.div,{...e,ref:o})});tke.displayName=Ake;function eke(e,A=globalThis?.document){const t=gD(e),i=AA.useRef(!1),o=AA.useRef(()=>{});return AA.useEffect(()=>{const n=r=>{if(r.target&&!i.current){let a=function(){v6A(Xxe,t,g,{discrete:!0})};const g={originalEvent:r};r.pointerType==="touch"?(A.removeEventListener("click",o.current),o.current=a,A.addEventListener("click",o.current,{once:!0})):a()}else A.removeEventListener("click",o.current);i.current=!1},s=window.setTimeout(()=>{A.addEventListener("pointerdown",n)},0);return()=>{window.clearTimeout(s),A.removeEventListener("pointerdown",n),A.removeEventListener("click",o.current)}},[A,t]),{onPointerDownCapture:()=>i.current=!0}}function ike(e,A=globalThis?.document){const t=gD(e),i=AA.useRef(!1);return AA.useEffect(()=>{const o=n=>{n.target&&!i.current&&v6A($xe,t,{originalEvent:n},{discrete:!1})};return A.addEventListener("focusin",o),()=>A.removeEventListener("focusin",o)},[A,t]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function N6A(){const e=new CustomEvent(WEA);document.dispatchEvent(e)}function v6A(e,A,t,{discrete:i}){const o=t.originalEvent.target,n=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:t});A&&o.addEventListener(e,A,{once:!0}),i?x6A(o,n):o.dispatchEvent(n)}var ZEA=0;function oke(){AA.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??L6A()),document.body.insertAdjacentElement("beforeend",e[1]??L6A()),ZEA++,()=>{ZEA===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(A=>A.remove()),ZEA--}},[])}function L6A(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var VEA="focusScope.autoFocusOnMount",jEA="focusScope.autoFocusOnUnmount",U6A={bubbles:!1,cancelable:!0},nke="FocusScope",H6A=AA.forwardRef((e,A)=>{const{loop:t=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:n,...s}=e,[r,a]=AA.useState(null),g=gD(o),c=gD(n),I=AA.useRef(null),l=Qf(A,E=>a(E)),B=AA.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;AA.useEffect(()=>{if(i){let E=function(d){if(B.paused||!r)return;const f=d.target;r.contains(f)?I.current=f:yx(I.current,{select:!0})},Q=function(d){if(B.paused||!r)return;const f=d.relatedTarget;f!==null&&(r.contains(f)||yx(I.current,{select:!0}))},h=function(d){if(document.activeElement===document.body)for(const m of d)m.removedNodes.length>0&&yx(r)};document.addEventListener("focusin",E),document.addEventListener("focusout",Q);const u=new MutationObserver(h);return r&&u.observe(r,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",Q),u.disconnect()}}},[i,r,B.paused]),AA.useEffect(()=>{if(r){T6A.add(B);const E=document.activeElement;if(!r.contains(E)){const h=new CustomEvent(VEA,U6A);r.addEventListener(VEA,g),r.dispatchEvent(h),h.defaultPrevented||(ske(Ike(Y6A(r)),{select:!0}),document.activeElement===E&&yx(r))}return()=>{r.removeEventListener(VEA,g),setTimeout(()=>{const h=new CustomEvent(jEA,U6A);r.addEventListener(jEA,c),r.dispatchEvent(h),h.defaultPrevented||yx(E??document.body,{select:!0}),r.removeEventListener(jEA,c),T6A.remove(B)},0)}}},[r,g,c,B]);const C=AA.useCallback(E=>{if(!t&&!i||B.paused)return;const Q=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,h=document.activeElement;if(Q&&h){const u=E.currentTarget,[d,f]=rke(u);d&&f?!E.shiftKey&&h===f?(E.preventDefault(),t&&yx(d,{select:!0})):E.shiftKey&&h===d&&(E.preventDefault(),t&&yx(f,{select:!0})):h===u&&E.preventDefault()}},[t,i,B.paused]);return Z.jsx(qd.div,{tabIndex:-1,...s,ref:l,onKeyDown:C})});H6A.displayName=nke;function ske(e,{select:A=!1}={}){const t=document.activeElement;for(const i of e)if(yx(i,{select:A}),document.activeElement!==t)return}function rke(e){const A=Y6A(e),t=J6A(A,e),i=J6A(A.reverse(),e);return[t,i]}function Y6A(e){const A=[],t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const o=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||o?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;t.nextNode();)A.push(t.currentNode);return A}function J6A(e,A){for(const t of e)if(!ake(t,{upTo:A}))return t}function ake(e,{upTo:A}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(A!==void 0&&e===A)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function gke(e){return e instanceof HTMLInputElement&&"select"in e}function yx(e,{select:A=!1}={}){if(e&&e.focus){const t=document.activeElement;e.focus({preventScroll:!0}),e!==t&&gke(e)&&A&&e.select()}}var T6A=cke();function cke(){let e=[];return{add(A){const t=e[0];A!==t&&t?.pause(),e=K6A(e,A),e.unshift(A)},remove(A){e=K6A(e,A),e[0]?.resume()}}}function K6A(e,A){const t=[...e],i=t.indexOf(A);return i!==-1&&t.splice(i,1),t}function Ike(e){return e.filter(A=>A.tagName!=="A")}var lke=a2[" useId ".trim().toString()]||(()=>{}),Bke=0;function SH(e){const[A,t]=AA.useState(lke());return fx(()=>{t(i=>i??String(Bke++))},[e]),A?`radix-${A}`:""}var Cke=["top","right","bottom","left"],mx=Math.min,f0=Math.max,MW=Math.round,NW=Math.floor,cD=e=>({x:e,y:e}),Qke={left:"right",right:"left",bottom:"top",top:"bottom"},Eke={start:"end",end:"start"};function zEA(e,A,t){return f0(e,mx(A,t))}function sb(e,A){return typeof e=="function"?e(A):e}function rb(e){return e.split("-")[0]}function Iv(e){return e.split("-")[1]}function XEA(e){return e==="x"?"y":"x"}function $EA(e){return e==="y"?"height":"width"}var hke=new Set(["top","bottom"]);function ID(e){return hke.has(rb(e))?"y":"x"}function AhA(e){return XEA(ID(e))}function uke(e,A,t){t===void 0&&(t=!1);const i=Iv(e),o=AhA(e),n=$EA(o);let s=o==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return A.reference[n]>A.floating[n]&&(s=vW(s)),[s,vW(s)]}function dke(e){const A=vW(e);return[thA(e),A,thA(A)]}function thA(e){return e.replace(/start|end/g,A=>Eke[A])}var P6A=["left","right"],q6A=["right","left"],pke=["top","bottom"],fke=["bottom","top"];function yke(e,A,t){switch(e){case"top":case"bottom":return t?A?q6A:P6A:A?P6A:q6A;case"left":case"right":return A?pke:fke;default:return[]}}function mke(e,A,t,i){const o=Iv(e);let n=yke(rb(e),t==="start",i);return o&&(n=n.map(s=>s+"-"+o),A&&(n=n.concat(n.map(thA)))),n}function vW(e){return e.replace(/left|right|bottom|top/g,A=>Qke[A])}function wke(e){return{top:0,right:0,bottom:0,left:0,...e}}function O6A(e){return typeof e!="number"?wke(e):{top:e,right:e,bottom:e,left:e}}function LW(e){const{x:A,y:t,width:i,height:o}=e;return{width:i,height:o,top:t,left:A,right:A+i,bottom:t+o,x:A,y:t}}function W6A(e,A,t){let{reference:i,floating:o}=e;const n=ID(A),s=AhA(A),r=$EA(s),a=rb(A),g=n==="y",c=i.x+i.width/2-o.width/2,I=i.y+i.height/2-o.height/2,l=i[r]/2-o[r]/2;let B;switch(a){case"top":B={x:c,y:i.y-o.height};break;case"bottom":B={x:c,y:i.y+i.height};break;case"right":B={x:i.x+i.width,y:I};break;case"left":B={x:i.x-o.width,y:I};break;default:B={x:i.x,y:i.y}}switch(Iv(A)){case"start":B[s]-=l*(t&&g?-1:1);break;case"end":B[s]+=l*(t&&g?-1:1);break}return B}async function Dke(e,A){var t;A===void 0&&(A={});const{x:i,y:o,platform:n,rects:s,elements:r,strategy:a}=e,{boundary:g="clippingAncestors",rootBoundary:c="viewport",elementContext:I="floating",altBoundary:l=!1,padding:B=0}=sb(A,e),C=O6A(B),Q=r[l?I==="floating"?"reference":"floating":I],h=LW(await n.getClippingRect({element:(t=await(n.isElement==null?void 0:n.isElement(Q)))==null||t?Q:Q.contextElement||await(n.getDocumentElement==null?void 0:n.getDocumentElement(r.floating)),boundary:g,rootBoundary:c,strategy:a})),u=I==="floating"?{x:i,y:o,width:s.floating.width,height:s.floating.height}:s.reference,d=await(n.getOffsetParent==null?void 0:n.getOffsetParent(r.floating)),f=await(n.isElement==null?void 0:n.isElement(d))?await(n.getScale==null?void 0:n.getScale(d))||{x:1,y:1}:{x:1,y:1},m=LW(n.convertOffsetParentRelativeRectToViewportRelativeRect?await n.convertOffsetParentRelativeRectToViewportRelativeRect({elements:r,rect:u,offsetParent:d,strategy:a}):u);return{top:(h.top-m.top+C.top)/f.y,bottom:(m.bottom-h.bottom+C.bottom)/f.y,left:(h.left-m.left+C.left)/f.x,right:(m.right-h.right+C.right)/f.x}}var Ske=async(e,A,t)=>{const{placement:i="bottom",strategy:o="absolute",middleware:n=[],platform:s}=t,r=n.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(A));let g=await s.getElementRects({reference:e,floating:A,strategy:o}),{x:c,y:I}=W6A(g,i,a),l=i,B={},C=0;for(let Q=0;Q<r.length;Q++){var E;const{name:h,fn:u}=r[Q],{x:d,y:f,data:m,reset:D}=await u({x:c,y:I,initialPlacement:i,placement:l,strategy:o,middlewareData:B,rects:g,platform:{...s,detectOverflow:(E=s.detectOverflow)!=null?E:Dke},elements:{reference:e,floating:A}});c=d??c,I=f??I,B={...B,[h]:{...B[h],...m}},D&&C<=50&&(C++,typeof D=="object"&&(D.placement&&(l=D.placement),D.rects&&(g=D.rects===!0?await s.getElementRects({reference:e,floating:A,strategy:o}):D.rects),{x:c,y:I}=W6A(g,l,a)),Q=-1)}return{x:c,y:I,placement:l,strategy:o,middlewareData:B}},bke=e=>({name:"arrow",options:e,async fn(A){const{x:t,y:i,placement:o,rects:n,platform:s,elements:r,middlewareData:a}=A,{element:g,padding:c=0}=sb(e,A)||{};if(g==null)return{};const I=O6A(c),l={x:t,y:i},B=AhA(o),C=$EA(B),E=await s.getDimensions(g),Q=B==="y",h=Q?"top":"left",u=Q?"bottom":"right",d=Q?"clientHeight":"clientWidth",f=n.reference[C]+n.reference[B]-l[B]-n.floating[C],m=l[B]-n.reference[B],D=await(s.getOffsetParent==null?void 0:s.getOffsetParent(g));let w=D?D[d]:0;(!w||!await(s.isElement==null?void 0:s.isElement(D)))&&(w=r.floating[d]||n.floating[C]);const b=f/2-m/2,k=w/2-E[C]/2-1,_=mx(I[h],k),N=mx(I[u],k),M=_,H=w-E[C]-N,T=w/2-E[C]/2+b,Y=zEA(M,T,H),O=!a.arrow&&Iv(o)!=null&&T!==Y&&n.reference[C]/2-(T<M?_:N)-E[C]/2<0,W=O?T<M?T-M:T-H:0;return{[B]:l[B]+W,data:{[B]:Y,centerOffset:T-Y-W,...O&&{alignmentOffset:W}},reset:O}}}),_ke=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(A){var t,i;const{placement:o,middlewareData:n,rects:s,initialPlacement:r,platform:a,elements:g}=A,{mainAxis:c=!0,crossAxis:I=!0,fallbackPlacements:l,fallbackStrategy:B="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:E=!0,...Q}=sb(e,A);if((t=n.arrow)!=null&&t.alignmentOffset)return{};const h=rb(o),u=ID(r),d=rb(r)===r,f=await(a.isRTL==null?void 0:a.isRTL(g.floating)),m=l||(d||!E?[vW(r)]:dke(r)),D=C!=="none";!l&&D&&m.push(...mke(r,E,C,f));const w=[r,...m],b=await a.detectOverflow(A,Q),k=[];let _=((i=n.flip)==null?void 0:i.overflows)||[];if(c&&k.push(b[h]),I){const T=uke(o,s,f);k.push(b[T[0]],b[T[1]])}if(_=[..._,{placement:o,overflows:k}],!k.every(T=>T<=0)){var N,M;const T=(((N=n.flip)==null?void 0:N.index)||0)+1,Y=w[T];if(Y&&(!(I==="alignment"?u!==ID(Y):!1)||_.every($=>ID($.placement)===u?$.overflows[0]>0:!0)))return{data:{index:T,overflows:_},reset:{placement:Y}};let O=(M=_.filter(W=>W.overflows[0]<=0).sort((W,$)=>W.overflows[1]-$.overflows[1])[0])==null?void 0:M.placement;if(!O)switch(B){case"bestFit":{var H;const W=(H=_.filter($=>{if(D){const iA=ID($.placement);return iA===u||iA==="y"}return!0}).map($=>[$.placement,$.overflows.filter(iA=>iA>0).reduce((iA,gA)=>iA+gA,0)]).sort(($,iA)=>$[1]-iA[1])[0])==null?void 0:H[0];W&&(O=W);break}case"initialPlacement":O=r;break}if(o!==O)return{reset:{placement:O}}}return{}}}};function Z6A(e,A){return{top:e.top-A.height,right:e.right-A.width,bottom:e.bottom-A.height,left:e.left-A.width}}function V6A(e){return Cke.some(A=>e[A]>=0)}var xke=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(A){const{rects:t,platform:i}=A,{strategy:o="referenceHidden",...n}=sb(e,A);switch(o){case"referenceHidden":{const s=await i.detectOverflow(A,{...n,elementContext:"reference"}),r=Z6A(s,t.reference);return{data:{referenceHiddenOffsets:r,referenceHidden:V6A(r)}}}case"escaped":{const s=await i.detectOverflow(A,{...n,altBoundary:!0}),r=Z6A(s,t.floating);return{data:{escapedOffsets:r,escaped:V6A(r)}}}default:return{}}}}},j6A=new Set(["left","top"]);async function kke(e,A){const{placement:t,platform:i,elements:o}=e,n=await(i.isRTL==null?void 0:i.isRTL(o.floating)),s=rb(t),r=Iv(t),a=ID(t)==="y",g=j6A.has(s)?-1:1,c=n&&a?-1:1,I=sb(A,e);let{mainAxis:l,crossAxis:B,alignmentAxis:C}=typeof I=="number"?{mainAxis:I,crossAxis:0,alignmentAxis:null}:{mainAxis:I.mainAxis||0,crossAxis:I.crossAxis||0,alignmentAxis:I.alignmentAxis};return r&&typeof C=="number"&&(B=r==="end"?C*-1:C),a?{x:B*c,y:l*g}:{x:l*g,y:B*c}}var Fke=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(A){var t,i;const{x:o,y:n,placement:s,middlewareData:r}=A,a=await kke(A,e);return s===((t=r.offset)==null?void 0:t.placement)&&(i=r.arrow)!=null&&i.alignmentOffset?{}:{x:o+a.x,y:n+a.y,data:{...a,placement:s}}}}},Gke=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(A){const{x:t,y:i,placement:o,platform:n}=A,{mainAxis:s=!0,crossAxis:r=!1,limiter:a={fn:h=>{let{x:u,y:d}=h;return{x:u,y:d}}},...g}=sb(e,A),c={x:t,y:i},I=await n.detectOverflow(A,g),l=ID(rb(o)),B=XEA(l);let C=c[B],E=c[l];if(s){const h=B==="y"?"top":"left",u=B==="y"?"bottom":"right",d=C+I[h],f=C-I[u];C=zEA(d,C,f)}if(r){const h=l==="y"?"top":"left",u=l==="y"?"bottom":"right",d=E+I[h],f=E-I[u];E=zEA(d,E,f)}const Q=a.fn({...A,[B]:C,[l]:E});return{...Q,data:{x:Q.x-t,y:Q.y-i,enabled:{[B]:s,[l]:r}}}}}},Rke=function(e){return e===void 0&&(e={}),{options:e,fn(A){const{x:t,y:i,placement:o,rects:n,middlewareData:s}=A,{offset:r=0,mainAxis:a=!0,crossAxis:g=!0}=sb(e,A),c={x:t,y:i},I=ID(o),l=XEA(I);let B=c[l],C=c[I];const E=sb(r,A),Q=typeof E=="number"?{mainAxis:E,crossAxis:0}:{mainAxis:0,crossAxis:0,...E};if(a){const d=l==="y"?"height":"width",f=n.reference[l]-n.floating[d]+Q.mainAxis,m=n.reference[l]+n.reference[d]-Q.mainAxis;B<f?B=f:B>m&&(B=m)}if(g){var h,u;const d=l==="y"?"width":"height",f=j6A.has(rb(o)),m=n.reference[I]-n.floating[d]+(f&&((h=s.offset)==null?void 0:h[I])||0)+(f?0:Q.crossAxis),D=n.reference[I]+n.reference[d]+(f?0:((u=s.offset)==null?void 0:u[I])||0)-(f?Q.crossAxis:0);C<m?C=m:C>D&&(C=D)}return{[l]:B,[I]:C}}}},Mke=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(A){var t,i;const{placement:o,rects:n,platform:s,elements:r}=A,{apply:a=()=>{},...g}=sb(e,A),c=await s.detectOverflow(A,g),I=rb(o),l=Iv(o),B=ID(o)==="y",{width:C,height:E}=n.floating;let Q,h;I==="top"||I==="bottom"?(Q=I,h=l===(await(s.isRTL==null?void 0:s.isRTL(r.floating))?"start":"end")?"left":"right"):(h=I,Q=l==="end"?"top":"bottom");const u=E-c.top-c.bottom,d=C-c.left-c.right,f=mx(E-c[Q],u),m=mx(C-c[h],d),D=!A.middlewareData.shift;let w=f,b=m;if((t=A.middlewareData.shift)!=null&&t.enabled.x&&(b=d),(i=A.middlewareData.shift)!=null&&i.enabled.y&&(w=u),D&&!l){const _=f0(c.left,0),N=f0(c.right,0),M=f0(c.top,0),H=f0(c.bottom,0);B?b=C-2*(_!==0||N!==0?_+N:f0(c.left,c.right)):w=E-2*(M!==0||H!==0?M+H:f0(c.top,c.bottom))}await a({...A,availableWidth:b,availableHeight:w});const k=await s.getDimensions(r.floating);return C!==k.width||E!==k.height?{reset:{rects:!0}}:{}}}};function UW(){return typeof window<"u"}function lv(e){return z6A(e)?(e.nodeName||"").toLowerCase():"#document"}function y0(e){var A;return(e==null||(A=e.ownerDocument)==null?void 0:A.defaultView)||window}function lD(e){var A;return(A=(z6A(e)?e.ownerDocument:e.document)||window.document)==null?void 0:A.documentElement}function z6A(e){return UW()?e instanceof Node||e instanceof y0(e).Node:!1}function jm(e){return UW()?e instanceof Element||e instanceof y0(e).Element:!1}function BD(e){return UW()?e instanceof HTMLElement||e instanceof y0(e).HTMLElement:!1}function X6A(e){return!UW()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof y0(e).ShadowRoot}var Nke=new Set(["inline","contents"]);function bH(e){const{overflow:A,overflowX:t,overflowY:i,display:o}=zm(e);return/auto|scroll|overlay|hidden|clip/.test(A+i+t)&&!Nke.has(o)}var vke=new Set(["table","td","th"]);function Lke(e){return vke.has(lv(e))}var Uke=[":popover-open",":modal"];function HW(e){return Uke.some(A=>{try{return e.matches(A)}catch{return!1}})}var Hke=["transform","translate","scale","rotate","perspective"],Yke=["transform","translate","scale","rotate","perspective","filter"],Jke=["paint","layout","strict","content"];function ehA(e){const A=ihA(),t=jm(e)?zm(e):e;return Hke.some(i=>t[i]?t[i]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!A&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!A&&(t.filter?t.filter!=="none":!1)||Yke.some(i=>(t.willChange||"").includes(i))||Jke.some(i=>(t.contain||"").includes(i))}function Tke(e){let A=wx(e);for(;BD(A)&&!Bv(A);){if(ehA(A))return A;if(HW(A))return null;A=wx(A)}return null}function ihA(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var Kke=new Set(["html","body","#document"]);function Bv(e){return Kke.has(lv(e))}function zm(e){return y0(e).getComputedStyle(e)}function YW(e){return jm(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wx(e){if(lv(e)==="html")return e;const A=e.assignedSlot||e.parentNode||X6A(e)&&e.host||lD(e);return X6A(A)?A.host:A}function $6A(e){const A=wx(e);return Bv(A)?e.ownerDocument?e.ownerDocument.body:e.body:BD(A)&&bH(A)?A:$6A(A)}function _H(e,A,t){var i;A===void 0&&(A=[]),t===void 0&&(t=!0);const o=$6A(e),n=o===((i=e.ownerDocument)==null?void 0:i.body),s=y0(o);if(n){const r=ohA(s);return A.concat(s,s.visualViewport||[],bH(o)?o:[],r&&t?_H(r):[])}return A.concat(o,_H(o,[],t))}function ohA(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function A7A(e){const A=zm(e);let t=parseFloat(A.width)||0,i=parseFloat(A.height)||0;const o=BD(e),n=o?e.offsetWidth:t,s=o?e.offsetHeight:i,r=MW(t)!==n||MW(i)!==s;return r&&(t=n,i=s),{width:t,height:i,$:r}}function nhA(e){return jm(e)?e:e.contextElement}function Cv(e){const A=nhA(e);if(!BD(A))return cD(1);const t=A.getBoundingClientRect(),{width:i,height:o,$:n}=A7A(A);let s=(n?MW(t.width):t.width)/i,r=(n?MW(t.height):t.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!r||!Number.isFinite(r))&&(r=1),{x:s,y:r}}var Pke=cD(0);function t7A(e){const A=y0(e);return!ihA()||!A.visualViewport?Pke:{x:A.visualViewport.offsetLeft,y:A.visualViewport.offsetTop}}function qke(e,A,t){return A===void 0&&(A=!1),!t||A&&t!==y0(e)?!1:A}function $F(e,A,t,i){A===void 0&&(A=!1),t===void 0&&(t=!1);const o=e.getBoundingClientRect(),n=nhA(e);let s=cD(1);A&&(i?jm(i)&&(s=Cv(i)):s=Cv(e));const r=qke(n,t,i)?t7A(n):cD(0);let a=(o.left+r.x)/s.x,g=(o.top+r.y)/s.y,c=o.width/s.x,I=o.height/s.y;if(n){const l=y0(n),B=i&&jm(i)?y0(i):i;let C=l,E=ohA(C);for(;E&&i&&B!==C;){const Q=Cv(E),h=E.getBoundingClientRect(),u=zm(E),d=h.left+(E.clientLeft+parseFloat(u.paddingLeft))*Q.x,f=h.top+(E.clientTop+parseFloat(u.paddingTop))*Q.y;a*=Q.x,g*=Q.y,c*=Q.x,I*=Q.y,a+=d,g+=f,C=y0(E),E=ohA(C)}}return LW({width:c,height:I,x:a,y:g})}function JW(e,A){const t=YW(e).scrollLeft;return A?A.left+t:$F(lD(e)).left+t}function e7A(e,A){const t=e.getBoundingClientRect(),i=t.left+A.scrollLeft-JW(e,t),o=t.top+A.scrollTop;return{x:i,y:o}}function Oke(e){let{elements:A,rect:t,offsetParent:i,strategy:o}=e;const n=o==="fixed",s=lD(i),r=A?HW(A.floating):!1;if(i===s||r&&n)return t;let a={scrollLeft:0,scrollTop:0},g=cD(1);const c=cD(0),I=BD(i);if((I||!I&&!n)&&((lv(i)!=="body"||bH(s))&&(a=YW(i)),BD(i))){const B=$F(i);g=Cv(i),c.x=B.x+i.clientLeft,c.y=B.y+i.clientTop}const l=s&&!I&&!n?e7A(s,a):cD(0);return{width:t.width*g.x,height:t.height*g.y,x:t.x*g.x-a.scrollLeft*g.x+c.x+l.x,y:t.y*g.y-a.scrollTop*g.y+c.y+l.y}}function Wke(e){return Array.from(e.getClientRects())}function Zke(e){const A=lD(e),t=YW(e),i=e.ownerDocument.body,o=f0(A.scrollWidth,A.clientWidth,i.scrollWidth,i.clientWidth),n=f0(A.scrollHeight,A.clientHeight,i.scrollHeight,i.clientHeight);let s=-t.scrollLeft+JW(e);const r=-t.scrollTop;return zm(i).direction==="rtl"&&(s+=f0(A.clientWidth,i.clientWidth)-o),{width:o,height:n,x:s,y:r}}var i7A=25;function Vke(e,A){const t=y0(e),i=lD(e),o=t.visualViewport;let n=i.clientWidth,s=i.clientHeight,r=0,a=0;if(o){n=o.width,s=o.height;const c=ihA();(!c||c&&A==="fixed")&&(r=o.offsetLeft,a=o.offsetTop)}const g=JW(i);if(g<=0){const c=i.ownerDocument,I=c.body,l=getComputedStyle(I),B=c.compatMode==="CSS1Compat"&&parseFloat(l.marginLeft)+parseFloat(l.marginRight)||0,C=Math.abs(i.clientWidth-I.clientWidth-B);C<=i7A&&(n-=C)}else g<=i7A&&(n+=g);return{width:n,height:s,x:r,y:a}}var jke=new Set(["absolute","fixed"]);function zke(e,A){const t=$F(e,!0,A==="fixed"),i=t.top+e.clientTop,o=t.left+e.clientLeft,n=BD(e)?Cv(e):cD(1),s=e.clientWidth*n.x,r=e.clientHeight*n.y,a=o*n.x,g=i*n.y;return{width:s,height:r,x:a,y:g}}function o7A(e,A,t){let i;if(A==="viewport")i=Vke(e,t);else if(A==="document")i=Zke(lD(e));else if(jm(A))i=zke(A,t);else{const o=t7A(e);i={x:A.x-o.x,y:A.y-o.y,width:A.width,height:A.height}}return LW(i)}function n7A(e,A){const t=wx(e);return t===A||!jm(t)||Bv(t)?!1:zm(t).position==="fixed"||n7A(t,A)}function Xke(e,A){const t=A.get(e);if(t)return t;let i=_H(e,[],!1).filter(r=>jm(r)&&lv(r)!=="body"),o=null;const n=zm(e).position==="fixed";let s=n?wx(e):e;for(;jm(s)&&!Bv(s);){const r=zm(s),a=ehA(s);!a&&r.position==="fixed"&&(o=null),(n?!a&&!o:!a&&r.position==="static"&&!!o&&jke.has(o.position)||bH(s)&&!a&&n7A(e,s))?i=i.filter(c=>c!==s):o=r,s=wx(s)}return A.set(e,i),i}function $ke(e){let{element:A,boundary:t,rootBoundary:i,strategy:o}=e;const s=[...t==="clippingAncestors"?HW(A)?[]:Xke(A,this._c):[].concat(t),i],r=s[0],a=s.reduce((g,c)=>{const I=o7A(A,c,o);return g.top=f0(I.top,g.top),g.right=mx(I.right,g.right),g.bottom=mx(I.bottom,g.bottom),g.left=f0(I.left,g.left),g},o7A(A,r,o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function AFe(e){const{width:A,height:t}=A7A(e);return{width:A,height:t}}function tFe(e,A,t){const i=BD(A),o=lD(A),n=t==="fixed",s=$F(e,!0,n,A);let r={scrollLeft:0,scrollTop:0};const a=cD(0);function g(){a.x=JW(o)}if(i||!i&&!n)if((lv(A)!=="body"||bH(o))&&(r=YW(A)),i){const B=$F(A,!0,n,A);a.x=B.x+A.clientLeft,a.y=B.y+A.clientTop}else o&&g();n&&!i&&o&&g();const c=o&&!i&&!n?e7A(o,r):cD(0),I=s.left+r.scrollLeft-a.x-c.x,l=s.top+r.scrollTop-a.y-c.y;return{x:I,y:l,width:s.width,height:s.height}}function shA(e){return zm(e).position==="static"}function s7A(e,A){if(!BD(e)||zm(e).position==="fixed")return null;if(A)return A(e);let t=e.offsetParent;return lD(e)===t&&(t=t.ownerDocument.body),t}function r7A(e,A){const t=y0(e);if(HW(e))return t;if(!BD(e)){let o=wx(e);for(;o&&!Bv(o);){if(jm(o)&&!shA(o))return o;o=wx(o)}return t}let i=s7A(e,A);for(;i&&Lke(i)&&shA(i);)i=s7A(i,A);return i&&Bv(i)&&shA(i)&&!ehA(i)?t:i||Tke(e)||t}var eFe=async function(e){const A=this.getOffsetParent||r7A,t=this.getDimensions,i=await t(e.floating);return{reference:tFe(e.reference,await A(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function iFe(e){return zm(e).direction==="rtl"}var oFe={convertOffsetParentRelativeRectToViewportRelativeRect:Oke,getDocumentElement:lD,getClippingRect:$ke,getOffsetParent:r7A,getElementRects:eFe,getClientRects:Wke,getDimensions:AFe,getScale:Cv,isElement:jm,isRTL:iFe};function a7A(e,A){return e.x===A.x&&e.y===A.y&&e.width===A.width&&e.height===A.height}function nFe(e,A){let t=null,i;const o=lD(e);function n(){var r;clearTimeout(i),(r=t)==null||r.disconnect(),t=null}function s(r,a){r===void 0&&(r=!1),a===void 0&&(a=1),n();const g=e.getBoundingClientRect(),{left:c,top:I,width:l,height:B}=g;if(r||A(),!l||!B)return;const C=NW(I),E=NW(o.clientWidth-(c+l)),Q=NW(o.clientHeight-(I+B)),h=NW(c),d={rootMargin:-C+"px "+-E+"px "+-Q+"px "+-h+"px",threshold:f0(0,mx(1,a))||1};let f=!0;function m(D){const w=D[0].intersectionRatio;if(w!==a){if(!f)return s();w?s(!1,w):i=setTimeout(()=>{s(!1,1e-7)},1e3)}w===1&&!a7A(g,e.getBoundingClientRect())&&s(),f=!1}try{t=new IntersectionObserver(m,{...d,root:o.ownerDocument})}catch{t=new IntersectionObserver(m,d)}t.observe(e)}return s(!0),n}function sFe(e,A,t,i){i===void 0&&(i={});const{ancestorScroll:o=!0,ancestorResize:n=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:r=typeof IntersectionObserver=="function",animationFrame:a=!1}=i,g=nhA(e),c=o||n?[...g?_H(g):[],..._H(A)]:[];c.forEach(h=>{o&&h.addEventListener("scroll",t,{passive:!0}),n&&h.addEventListener("resize",t)});const I=g&&r?nFe(g,t):null;let l=-1,B=null;s&&(B=new ResizeObserver(h=>{let[u]=h;u&&u.target===g&&B&&(B.unobserve(A),cancelAnimationFrame(l),l=requestAnimationFrame(()=>{var d;(d=B)==null||d.observe(A)})),t()}),g&&!a&&B.observe(g),B.observe(A));let C,E=a?$F(e):null;a&&Q();function Q(){const h=$F(e);E&&!a7A(E,h)&&t(),E=h,C=requestAnimationFrame(Q)}return t(),()=>{var h;c.forEach(u=>{o&&u.removeEventListener("scroll",t),n&&u.removeEventListener("resize",t)}),I?.(),(h=B)==null||h.disconnect(),B=null,a&&cancelAnimationFrame(C)}}var rFe=Fke,aFe=Gke,gFe=_ke,cFe=Mke,IFe=xke,g7A=bke,lFe=Rke,BFe=(e,A,t)=>{const i=new Map,o={platform:oFe,...t},n={...o.platform,_c:i};return Ske(e,A,{...o,platform:n})},CFe=typeof document<"u",QFe=function(){},TW=CFe?AA.useLayoutEffect:QFe;function KW(e,A){if(e===A)return!0;if(typeof e!=typeof A)return!1;if(typeof e=="function"&&e.toString()===A.toString())return!0;let t,i,o;if(e&&A&&typeof e=="object"){if(Array.isArray(e)){if(t=e.length,t!==A.length)return!1;for(i=t;i--!==0;)if(!KW(e[i],A[i]))return!1;return!0}if(o=Object.keys(e),t=o.length,t!==Object.keys(A).length)return!1;for(i=t;i--!==0;)if(!{}.hasOwnProperty.call(A,o[i]))return!1;for(i=t;i--!==0;){const n=o[i];if(!(n==="_owner"&&e.$$typeof)&&!KW(e[n],A[n]))return!1}return!0}return e!==e&&A!==A}function c7A(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function I7A(e,A){const t=c7A(e);return Math.round(A*t)/t}function rhA(e){const A=AA.useRef(e);return TW(()=>{A.current=e}),A}function EFe(e){e===void 0&&(e={});const{placement:A="bottom",strategy:t="absolute",middleware:i=[],platform:o,elements:{reference:n,floating:s}={},transform:r=!0,whileElementsMounted:a,open:g}=e,[c,I]=AA.useState({x:0,y:0,strategy:t,placement:A,middlewareData:{},isPositioned:!1}),[l,B]=AA.useState(i);KW(l,i)||B(i);const[C,E]=AA.useState(null),[Q,h]=AA.useState(null),u=AA.useCallback($=>{$!==D.current&&(D.current=$,E($))},[]),d=AA.useCallback($=>{$!==w.current&&(w.current=$,h($))},[]),f=n||C,m=s||Q,D=AA.useRef(null),w=AA.useRef(null),b=AA.useRef(c),k=a!=null,_=rhA(a),N=rhA(o),M=rhA(g),H=AA.useCallback(()=>{if(!D.current||!w.current)return;const $={placement:A,strategy:t,middleware:l};N.current&&($.platform=N.current),BFe(D.current,w.current,$).then(iA=>{const gA={...iA,isPositioned:M.current!==!1};T.current&&!KW(b.current,gA)&&(b.current=gA,g2.flushSync(()=>{I(gA)}))})},[l,A,t,N,M]);TW(()=>{g===!1&&b.current.isPositioned&&(b.current.isPositioned=!1,I($=>({...$,isPositioned:!1})))},[g]);const T=AA.useRef(!1);TW(()=>(T.current=!0,()=>{T.current=!1}),[]),TW(()=>{if(f&&(D.current=f),m&&(w.current=m),f&&m){if(_.current)return _.current(f,m,H);H()}},[f,m,H,_,k]);const Y=AA.useMemo(()=>({reference:D,floating:w,setReference:u,setFloating:d}),[u,d]),O=AA.useMemo(()=>({reference:f,floating:m}),[f,m]),W=AA.useMemo(()=>{const $={position:t,left:0,top:0};if(!O.floating)return $;const iA=I7A(O.floating,c.x),gA=I7A(O.floating,c.y);return r?{...$,transform:"translate("+iA+"px, "+gA+"px)",...c7A(O.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:iA,top:gA}},[t,r,O.floating,c.x,c.y]);return AA.useMemo(()=>({...c,update:H,refs:Y,elements:O,floatingStyles:W}),[c,H,Y,O,W])}var hFe=e=>{function A(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:e,fn(t){const{element:i,padding:o}=typeof e=="function"?e(t):e;return i&&A(i)?i.current!=null?g7A({element:i.current,padding:o}).fn(t):{}:i?g7A({element:i,padding:o}).fn(t):{}}}},uFe=(e,A)=>({...rFe(e),options:[e,A]}),dFe=(e,A)=>({...aFe(e),options:[e,A]}),pFe=(e,A)=>({...lFe(e),options:[e,A]}),fFe=(e,A)=>({...gFe(e),options:[e,A]}),yFe=(e,A)=>({...cFe(e),options:[e,A]}),mFe=(e,A)=>({...IFe(e),options:[e,A]}),wFe=(e,A)=>({...hFe(e),options:[e,A]}),DFe="Arrow",l7A=AA.forwardRef((e,A)=>{const{children:t,width:i=10,height:o=5,...n}=e;return Z.jsx(qd.svg,{...n,ref:A,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?t:Z.jsx("polygon",{points:"0,0 30,0 15,10"})})});l7A.displayName=DFe;var SFe=l7A;function bFe(e){const[A,t]=AA.useState(void 0);return fx(()=>{if(e){t({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const n=o[0];let s,r;if("borderBoxSize"in n){const a=n.borderBoxSize,g=Array.isArray(a)?a[0]:a;s=g.inlineSize,r=g.blockSize}else s=e.offsetWidth,r=e.offsetHeight;t({width:s,height:r})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else t(void 0)},[e]),A}var ahA="Popper",[B7A,C7A]=DH(ahA),[_Fe,Q7A]=B7A(ahA),E7A=e=>{const{__scopePopper:A,children:t}=e,[i,o]=AA.useState(null);return Z.jsx(_Fe,{scope:A,anchor:i,onAnchorChange:o,children:t})};E7A.displayName=ahA;var h7A="PopperAnchor",u7A=AA.forwardRef((e,A)=>{const{__scopePopper:t,virtualRef:i,...o}=e,n=Q7A(h7A,t),s=AA.useRef(null),r=Qf(A,s),a=AA.useRef(null);return AA.useEffect(()=>{const g=a.current;a.current=i?.current||s.current,g!==a.current&&n.onAnchorChange(a.current)}),i?null:Z.jsx(qd.div,{...o,ref:r})});u7A.displayName=h7A;var ghA="PopperContent",[xFe,kFe]=B7A(ghA),d7A=AA.forwardRef((e,A)=>{const{__scopePopper:t,side:i="bottom",sideOffset:o=0,align:n="center",alignOffset:s=0,arrowPadding:r=0,avoidCollisions:a=!0,collisionBoundary:g=[],collisionPadding:c=0,sticky:I="partial",hideWhenDetached:l=!1,updatePositionStrategy:B="optimized",onPlaced:C,...E}=e,Q=Q7A(ghA,t),[h,u]=AA.useState(null),d=Qf(A,NA=>u(NA)),[f,m]=AA.useState(null),D=bFe(f),w=D?.width??0,b=D?.height??0,k=i+(n!=="center"?"-"+n:""),_=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},N=Array.isArray(g)?g:[g],M=N.length>0,H={padding:_,boundary:N.filter(GFe),altBoundary:M},{refs:T,floatingStyles:Y,placement:O,isPositioned:W,middlewareData:$}=EFe({strategy:"fixed",placement:k,whileElementsMounted:(...NA)=>sFe(...NA,{animationFrame:B==="always"}),elements:{reference:Q.anchor},middleware:[uFe({mainAxis:o+b,alignmentAxis:s}),a&&dFe({mainAxis:!0,crossAxis:!1,limiter:I==="partial"?pFe():void 0,...H}),a&&fFe({...H}),yFe({...H,apply:({elements:NA,rects:KA,availableWidth:EA,availableHeight:kA})=>{const{width:dA,height:qA}=KA.reference,PA=NA.floating.style;PA.setProperty("--radix-popper-available-width",`${EA}px`),PA.setProperty("--radix-popper-available-height",`${kA}px`),PA.setProperty("--radix-popper-anchor-width",`${dA}px`),PA.setProperty("--radix-popper-anchor-height",`${qA}px`)}}),f&&wFe({element:f,padding:r}),RFe({arrowWidth:w,arrowHeight:b}),l&&mFe({strategy:"referenceHidden",...H})]}),[iA,gA]=y7A(O),tA=gD(C);fx(()=>{W&&tA?.()},[W,tA]);const nA=$.arrow?.x,rA=$.arrow?.y,QA=$.arrow?.centerOffset!==0,[DA,RA]=AA.useState();return fx(()=>{h&&RA(window.getComputedStyle(h).zIndex)},[h]),Z.jsx("div",{ref:T.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:W?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:DA,"--radix-popper-transform-origin":[$.transformOrigin?.x,$.transformOrigin?.y].join(" "),...$.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:Z.jsx(xFe,{scope:t,placedSide:iA,onArrowChange:m,arrowX:nA,arrowY:rA,shouldHideArrow:QA,children:Z.jsx(qd.div,{"data-side":iA,"data-align":gA,...E,ref:d,style:{...E.style,animation:W?void 0:"none"}})})})});d7A.displayName=ghA;var p7A="PopperArrow",FFe={top:"bottom",right:"left",bottom:"top",left:"right"},f7A=AA.forwardRef(function(A,t){const{__scopePopper:i,...o}=A,n=kFe(p7A,i),s=FFe[n.placedSide];return Z.jsx("span",{ref:n.onArrowChange,style:{position:"absolute",left:n.arrowX,top:n.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[n.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[n.placedSide],visibility:n.shouldHideArrow?"hidden":void 0},children:Z.jsx(SFe,{...o,ref:t,style:{...o.style,display:"block"}})})});f7A.displayName=p7A;function GFe(e){return e!==null}var RFe=e=>({name:"transformOrigin",options:e,fn(A){const{placement:t,rects:i,middlewareData:o}=A,s=o.arrow?.centerOffset!==0,r=s?0:e.arrowWidth,a=s?0:e.arrowHeight,[g,c]=y7A(t),I={start:"0%",center:"50%",end:"100%"}[c],l=(o.arrow?.x??0)+r/2,B=(o.arrow?.y??0)+a/2;let C="",E="";return g==="bottom"?(C=s?I:`${l}px`,E=`${-a}px`):g==="top"?(C=s?I:`${l}px`,E=`${i.floating.height+a}px`):g==="right"?(C=`${-a}px`,E=s?I:`${B}px`):g==="left"&&(C=`${i.floating.width+a}px`,E=s?I:`${B}px`),{data:{x:C,y:E}}}});function y7A(e){const[A,t="center"]=e.split("-");return[A,t]}var m7A=E7A,MFe=u7A,NFe=d7A,vFe=f7A,LFe="Portal",w7A=AA.forwardRef((e,A)=>{const{container:t,...i}=e,[o,n]=AA.useState(!1);fx(()=>n(!0),[]);const s=t||o&&globalThis?.document?.body;return s?CK.createPortal(Z.jsx(qd.div,{...i,ref:A}),s):null});w7A.displayName=LFe;function UFe(e,A){return AA.useReducer((t,i)=>A[t][i]??t,e)}var xH=e=>{const{present:A,children:t}=e,i=HFe(A),o=typeof t=="function"?t({present:i.isPresent}):AA.Children.only(t),n=Qf(i.ref,YFe(o));return typeof t=="function"||i.isPresent?AA.cloneElement(o,{ref:n}):null};xH.displayName="Presence";function HFe(e){const[A,t]=AA.useState(),i=AA.useRef(null),o=AA.useRef(e),n=AA.useRef("none"),s=e?"mounted":"unmounted",[r,a]=UFe(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return AA.useEffect(()=>{const g=PW(i.current);n.current=r==="mounted"?g:"none"},[r]),fx(()=>{const g=i.current,c=o.current;if(c!==e){const l=n.current,B=PW(g);e?a("MOUNT"):B==="none"||g?.display==="none"?a("UNMOUNT"):a(c&&l!==B?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,a]),fx(()=>{if(A){let g;const c=A.ownerDocument.defaultView??window,I=B=>{const E=PW(i.current).includes(CSS.escape(B.animationName));if(B.target===A&&E&&(a("ANIMATION_END"),!o.current)){const Q=A.style.animationFillMode;A.style.animationFillMode="forwards",g=c.setTimeout(()=>{A.style.animationFillMode==="forwards"&&(A.style.animationFillMode=Q)})}},l=B=>{B.target===A&&(n.current=PW(i.current))};return A.addEventListener("animationstart",l),A.addEventListener("animationcancel",I),A.addEventListener("animationend",I),()=>{c.clearTimeout(g),A.removeEventListener("animationstart",l),A.removeEventListener("animationcancel",I),A.removeEventListener("animationend",I)}}else a("ANIMATION_END")},[A,a]),{isPresent:["mounted","unmountSuspended"].includes(r),ref:AA.useCallback(g=>{i.current=g?getComputedStyle(g):null,t(g)},[])}}function PW(e){return e?.animationName||"none"}function YFe(e){let A=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning;return t?e.ref:(A=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var chA="rovingFocusGroup.onEntryFocus",JFe={bubbles:!1,cancelable:!0},kH="RovingFocusGroup",[IhA,D7A,TFe]=k6A(kH),[KFe,S7A]=DH(kH,[TFe]),[PFe,qFe]=KFe(kH),b7A=AA.forwardRef((e,A)=>Z.jsx(IhA.Provider,{scope:e.__scopeRovingFocusGroup,children:Z.jsx(IhA.Slot,{scope:e.__scopeRovingFocusGroup,children:Z.jsx(OFe,{...e,ref:A})})}));b7A.displayName=kH;var OFe=AA.forwardRef((e,A)=>{const{__scopeRovingFocusGroup:t,orientation:i,loop:o=!1,dir:n,currentTabStopId:s,defaultCurrentTabStopId:r,onCurrentTabStopIdChange:a,onEntryFocus:g,preventScrollOnEntryFocus:c=!1,...I}=e,l=AA.useRef(null),B=Qf(A,l),C=F6A(n),[E,Q]=OEA({prop:s,defaultProp:r??null,onChange:a,caller:kH}),[h,u]=AA.useState(!1),d=gD(g),f=D7A(t),m=AA.useRef(!1),[D,w]=AA.useState(0);return AA.useEffect(()=>{const b=l.current;if(b)return b.addEventListener(chA,d),()=>b.removeEventListener(chA,d)},[d]),Z.jsx(PFe,{scope:t,orientation:i,dir:C,loop:o,currentTabStopId:E,onItemFocus:AA.useCallback(b=>Q(b),[Q]),onItemShiftTab:AA.useCallback(()=>u(!0),[]),onFocusableItemAdd:AA.useCallback(()=>w(b=>b+1),[]),onFocusableItemRemove:AA.useCallback(()=>w(b=>b-1),[]),children:Z.jsx(qd.div,{tabIndex:h||D===0?-1:0,"data-orientation":i,...I,ref:B,style:{outline:"none",...e.style},onMouseDown:ca(e.onMouseDown,()=>{m.current=!0}),onFocus:ca(e.onFocus,b=>{const k=!m.current;if(b.target===b.currentTarget&&k&&!h){const _=new CustomEvent(chA,JFe);if(b.currentTarget.dispatchEvent(_),!_.defaultPrevented){const N=f().filter(O=>O.focusable),M=N.find(O=>O.active),H=N.find(O=>O.id===E),Y=[M,H,...N].filter(Boolean).map(O=>O.ref.current);k7A(Y,c)}}m.current=!1}),onBlur:ca(e.onBlur,()=>u(!1))})})}),_7A="RovingFocusGroupItem",x7A=AA.forwardRef((e,A)=>{const{__scopeRovingFocusGroup:t,focusable:i=!0,active:o=!1,tabStopId:n,children:s,...r}=e,a=SH(),g=n||a,c=qFe(_7A,t),I=c.currentTabStopId===g,l=D7A(t),{onFocusableItemAdd:B,onFocusableItemRemove:C,currentTabStopId:E}=c;return AA.useEffect(()=>{if(i)return B(),()=>C()},[i,B,C]),Z.jsx(IhA.ItemSlot,{scope:t,id:g,focusable:i,active:o,children:Z.jsx(qd.span,{tabIndex:I?0:-1,"data-orientation":c.orientation,...r,ref:A,onMouseDown:ca(e.onMouseDown,Q=>{i?c.onItemFocus(g):Q.preventDefault()}),onFocus:ca(e.onFocus,()=>c.onItemFocus(g)),onKeyDown:ca(e.onKeyDown,Q=>{if(Q.key==="Tab"&&Q.shiftKey){c.onItemShiftTab();return}if(Q.target!==Q.currentTarget)return;const h=VFe(Q,c.orientation,c.dir);if(h!==void 0){if(Q.metaKey||Q.ctrlKey||Q.altKey||Q.shiftKey)return;Q.preventDefault();let d=l().filter(f=>f.focusable).map(f=>f.ref.current);if(h==="last")d.reverse();else if(h==="prev"||h==="next"){h==="prev"&&d.reverse();const f=d.indexOf(Q.currentTarget);d=c.loop?jFe(d,f+1):d.slice(f+1)}setTimeout(()=>k7A(d))}}),children:typeof s=="function"?s({isCurrentTabStop:I,hasTabStop:E!=null}):s})})});x7A.displayName=_7A;var WFe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ZFe(e,A){return A!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function VFe(e,A,t){const i=ZFe(e.key,t);if(!(A==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(A==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return WFe[i]}function k7A(e,A=!1){const t=document.activeElement;for(const i of e)if(i===t||(i.focus({preventScroll:A}),document.activeElement!==t))return}function jFe(e,A){return e.map((t,i)=>e[(A+i)%e.length])}var zFe=b7A,XFe=x7A,$Fe=function(e){if(typeof document>"u")return null;var A=Array.isArray(e)?e[0]:e;return A.ownerDocument.body},Qv=new WeakMap,qW=new WeakMap,OW={},lhA=0,F7A=function(e){return e&&(e.host||F7A(e.parentNode))},AGe=function(e,A){return A.map(function(t){if(e.contains(t))return t;var i=F7A(t);return i&&e.contains(i)?i:(console.error("aria-hidden",t,"in not contained inside",e,". Doing nothing"),null)}).filter(function(t){return!!t})},tGe=function(e,A,t,i){var o=AGe(A,Array.isArray(e)?e:[e]);OW[t]||(OW[t]=new WeakMap);var n=OW[t],s=[],r=new Set,a=new Set(o),g=function(I){!I||r.has(I)||(r.add(I),g(I.parentNode))};o.forEach(g);var c=function(I){!I||a.has(I)||Array.prototype.forEach.call(I.children,function(l){if(r.has(l))c(l);else try{var B=l.getAttribute(i),C=B!==null&&B!=="false",E=(Qv.get(l)||0)+1,Q=(n.get(l)||0)+1;Qv.set(l,E),n.set(l,Q),s.push(l),E===1&&C&&qW.set(l,!0),Q===1&&l.setAttribute(t,"true"),C||l.setAttribute(i,"true")}catch(h){console.error("aria-hidden: cannot operate on ",l,h)}})};return c(A),r.clear(),lhA++,function(){s.forEach(function(I){var l=Qv.get(I)-1,B=n.get(I)-1;Qv.set(I,l),n.set(I,B),l||(qW.has(I)||I.removeAttribute(i),qW.delete(I)),B||I.removeAttribute(t)}),lhA--,lhA||(Qv=new WeakMap,Qv=new WeakMap,qW=new WeakMap,OW={})}},eGe=function(e,A,t){t===void 0&&(t="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),o=$Fe(e);return o?(i.push.apply(i,Array.from(o.querySelectorAll("[aria-live], script"))),tGe(i,o,t,"aria-hidden")):function(){return null}},CD=function(){return CD=Object.assign||function(A){for(var t,i=1,o=arguments.length;i<o;i++){t=arguments[i];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(A[n]=t[n])}return A},CD.apply(this,arguments)};function G7A(e,A){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&A.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)A.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]]);return t}function iGe(e,A,t){for(var i=0,o=A.length,n;i<o;i++)(n||!(i in A))&&(n||(n=Array.prototype.slice.call(A,0,i)),n[i]=A[i]);return e.concat(n||Array.prototype.slice.call(A))}var WW="right-scroll-bar-position",ZW="width-before-scroll-bar",oGe="with-scroll-bars-hidden",nGe="--removed-body-scroll-bar-size";function BhA(e,A){return typeof e=="function"?e(A):e&&(e.current=A),e}function sGe(e,A){var t=AA.useState(function(){return{value:e,callback:A,facade:{get current(){return t.value},set current(i){var o=t.value;o!==i&&(t.value=i,t.callback(i,o))}}}})[0];return t.callback=A,t.facade}var rGe=typeof window<"u"?AA.useLayoutEffect:AA.useEffect,R7A=new WeakMap;function aGe(e,A){var t=sGe(null,function(i){return e.forEach(function(o){return BhA(o,i)})});return rGe(function(){var i=R7A.get(t);if(i){var o=new Set(i),n=new Set(e),s=t.current;o.forEach(function(r){n.has(r)||BhA(r,null)}),n.forEach(function(r){o.has(r)||BhA(r,s)})}R7A.set(t,e)},[e]),t}function gGe(e){return e}function cGe(e,A){A===void 0&&(A=gGe);var t=[],i=!1,o={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return t.length?t[t.length-1]:e},useMedium:function(n){var s=A(n,i);return t.push(s),function(){t=t.filter(function(r){return r!==s})}},assignSyncMedium:function(n){for(i=!0;t.length;){var s=t;t=[],s.forEach(n)}t={push:function(r){return n(r)},filter:function(){return t}}},assignMedium:function(n){i=!0;var s=[];if(t.length){var r=t;t=[],r.forEach(n),s=t}var a=function(){var c=s;s=[],c.forEach(n)},g=function(){return Promise.resolve().then(a)};g(),t={push:function(c){s.push(c),g()},filter:function(c){return s=s.filter(c),t}}}};return o}function IGe(e){e===void 0&&(e={});var A=cGe(null);return A.options=CD({async:!0,ssr:!1},e),A}var M7A=function(e){var A=e.sideCar,t=G7A(e,["sideCar"]);if(!A)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=A.read();if(!i)throw new Error("Sidecar medium not found");return AA.createElement(i,CD({},t))};M7A.isSideCarExport=!0;function lGe(e,A){return e.useMedium(A),M7A}var N7A=IGe(),ChA=function(){},VW=AA.forwardRef(function(e,A){var t=AA.useRef(null),i=AA.useState({onScrollCapture:ChA,onWheelCapture:ChA,onTouchMoveCapture:ChA}),o=i[0],n=i[1],s=e.forwardProps,r=e.children,a=e.className,g=e.removeScrollBar,c=e.enabled,I=e.shards,l=e.sideCar,B=e.noRelative,C=e.noIsolation,E=e.inert,Q=e.allowPinchZoom,h=e.as,u=h===void 0?"div":h,d=e.gapMode,f=G7A(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),m=l,D=aGe([t,A]),w=CD(CD({},f),o);return AA.createElement(AA.Fragment,null,c&&AA.createElement(m,{sideCar:N7A,removeScrollBar:g,shards:I,noRelative:B,noIsolation:C,inert:E,setCallbacks:n,allowPinchZoom:!!Q,lockRef:t,gapMode:d}),s?AA.cloneElement(AA.Children.only(r),CD(CD({},w),{ref:D})):AA.createElement(u,CD({},w,{className:a,ref:D}),r))});VW.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},VW.classNames={fullWidth:ZW,zeroRight:WW};var BGe=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function CGe(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var A=BGe();return A&&e.setAttribute("nonce",A),e}function QGe(e,A){e.styleSheet?e.styleSheet.cssText=A:e.appendChild(document.createTextNode(A))}function EGe(e){var A=document.head||document.getElementsByTagName("head")[0];A.appendChild(e)}var hGe=function(){var e=0,A=null;return{add:function(t){e==0&&(A=CGe())&&(QGe(A,t),EGe(A)),e++},remove:function(){e--,!e&&A&&(A.parentNode&&A.parentNode.removeChild(A),A=null)}}},uGe=function(){var e=hGe();return function(A,t){AA.useEffect(function(){return e.add(A),function(){e.remove()}},[A&&t])}},v7A=function(){var e=uGe(),A=function(t){var i=t.styles,o=t.dynamic;return e(i,o),null};return A},dGe={left:0,top:0,right:0,gap:0},QhA=function(e){return parseInt(e||"",10)||0},pGe=function(e){var A=window.getComputedStyle(document.body),t=A[e==="padding"?"paddingLeft":"marginLeft"],i=A[e==="padding"?"paddingTop":"marginTop"],o=A[e==="padding"?"paddingRight":"marginRight"];return[QhA(t),QhA(i),QhA(o)]},fGe=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return dGe;var A=pGe(e),t=document.documentElement.clientWidth,i=window.innerWidth;return{left:A[0],top:A[1],right:A[2],gap:Math.max(0,i-t+A[2]-A[0])}},yGe=v7A(),Ev="data-scroll-locked",mGe=function(e,A,t,i){var o=e.left,n=e.top,s=e.right,r=e.gap;return t===void 0&&(t="margin"),`
|
|
5182
|
+
`.trim();const T=Y=>{const O="Failed to load Manifold loader script.";console.error(O,Y),I(O),window.removeEventListener(N,M)};return H.addEventListener("error",T),document.body.appendChild(H),()=>{window.removeEventListener(N,M),H.removeEventListener("error",T)}},[]);const{geoms:l,textures:B,pcbThickness:C,error:E,isLoading:Q,boardData:h,isFauxBoard:u}=lxe(a,r),d=AA.useMemo(()=>Qxe(l),[l]),f=AA.useMemo(()=>M_e(B,h,C,u),[B,h,C,u]),m=AA.useMemo(()=>xi(r).cad_component.list(),[r]),D=AA.useMemo(()=>{if(!h)return;const{width:k=0,height:_=0}=h;return{width:k,height:_}},[h]),w=AA.useMemo(()=>{if(!h)return;const{center:k}=h;if(k)return{x:k.x,y:k.y}},[h]),b=AA.useMemo(()=>{if(!h)return[5,-5,5];const{width:k=0,height:_=0}=h,N=Math.max(k,1),M=Math.max(_,1),H=Math.max(N,M,5);return[H*.4,-H*.7,H*.9]},[h]);return c?Z.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",c]}):a?E?Z.jsxs("div",{style:{color:"red",padding:"1em",border:"1px solid red",margin:"1em"},children:["Error: ",E]}):Q?Z.jsx("div",{style:{padding:"1em"},children:"Processing board geometry..."}):Z.jsxs(t6A,{initialCameraPosition:b,autoRotateDisabled:A,clickToInteractEnabled:t,boardDimensions:D,boardCenter:w,onUserInteraction:i,onCameraControllerReady:n,children:[Z.jsx(Exe,{geometryMeshes:d,textureMeshes:f}),m.map(k=>Z.jsx(I6A,{fallback:({error:_})=>Z.jsx(c6A,{cad_component:k,error:_}),children:Z.jsx(jXA,{cad_component:k,circuitJson:r})},k.cad_component_id))]}):Z.jsx("div",{style:{padding:"1em"},children:"Loading Manifold module..."})},dxe=uxe,pxe=({containerRef:e})=>{const[A,t]=AA.useState(!1),[i,o]=AA.useState({x:0,y:0}),n=AA.useRef(null),s=AA.useRef(null),r=AA.useRef(null),a=AA.useRef(!1),g=()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},c=AA.useCallback(Q=>{Q.preventDefault();const h=typeof Q.clientX=="number"?Q.clientX:0,u=typeof Q.clientY=="number"?Q.clientY:0;if(a.current){a.current=!1;return}if(!s.current)return;const{x:d,y:f}=s.current,m=Math.abs(h-d),D=Math.abs(u-f),w=10;if(m>w||D>w){s.current=null;return}o({x:h,y:u}),t(!0),s.current=null},[o,t]),I=AA.useCallback(Q=>{if(Q.touches.length===1){const h=Q.touches[0];h?(s.current={x:h.clientX,y:h.clientY},g(),r.current=window.setTimeout(()=>{if(s.current){if(e.current){const u=e.current.getBoundingClientRect();o({x:u.left+u.width/2,y:u.top+u.height/2}),t(!0),a.current=!0}s.current=null}},600)):s.current=null}else s.current=null,g()},[e]),l=AA.useCallback(Q=>{if(!s.current||Q.touches.length!==1)return;const h=Q.touches[0];if(h){const u=Math.abs(h.clientX-s.current.x),d=Math.abs(h.clientY-s.current.y),f=10;(u>f||d>f)&&(s.current=null,g())}else s.current=null,g()},[]),B=AA.useCallback(()=>{g(),setTimeout(()=>{s.current&&(s.current=null)},0)},[]),C=AA.useCallback(Q=>{const h=Q.target;n.current&&n.current.contains(h)||h.closest?.("[data-radix-popper-content-wrapper], [data-radix-dropdown-menu-content], [data-radix-dropdown-menu-sub-content]")||t(!1)},[]);return AA.useEffect(()=>{if(A)return document.addEventListener("mousedown",C),document.addEventListener("touchstart",C),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("touchstart",C)}},[A,C]),{menuVisible:A,menuPos:i,menuRef:n,contextMenuEventHandlers:{onMouseDown:Q=>{Q.button===2?s.current={x:Q.clientX,y:Q.clientY}:s.current=null},onContextMenu:c,onTouchStart:I,onTouchMove:l,onTouchEnd:B},setMenuVisible:t}};function fxe({setAutoRotate:e,setAutoRotateUserToggled:A,setCameraPreset:t,closeMenu:i,cameraControllerRef:o,isAnimatingRef:n,lastPresetSelectTime:s}){return{handleCameraPresetSelect:AA.useCallback(a=>{e(!1),A(!0),t(a),i(),s.current=Date.now(),a!=="Custom"&&(n.current=!0,o.current?.animateToPreset(a),setTimeout(()=>{n.current=!1},600))},[e,A,t,i,o,n,s])}}var yxe=()=>AA.useCallback(()=>{const e=window.__TSCIRCUIT_THREE_OBJECT;if(!e)return;new w$().parse(e,t=>{const i=new Blob([t instanceof ArrayBuffer?t:JSON.stringify(t)],{type:"model/gltf+json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download="scene.gltf",n.click(),URL.revokeObjectURL(o)},t=>{console.error("Failed to export GLTF",t)})},[]),cv=new Map,KEA=new Set,D6A=!1,PEA=0,qEA=0,kW=null,S6A=!1,mxe=20,wxe=e=>{const A=e.toLowerCase().split("+"),t=A[A.length-1],i=A.slice(0,-1);return{key:t,ctrl:i.includes("ctrl"),cmd:i.includes("cmd"),shift:i.includes("shift"),alt:i.includes("alt")}},Dxe=(e,A)=>{const t=wxe(A),i=e.key.toLowerCase()===t.key,o=t.ctrl===e.ctrlKey,n=t.cmd===e.metaKey,s=t.shift===e.shiftKey,r=t.alt===e.altKey;return i&&o&&n&&s&&r},Sxe=e=>{if(!e||typeof e!="object")return!1;const A=e,t=A.tagName,i=["INPUT","TEXTAREA","SELECT"];if(i.includes(t))return!0;const o=A.getAttribute?.("contenteditable");if(o==="true"||o==="")return!0;let n=A.parentElement;for(let s=0;s<mxe&&n;s++){const r=n.tagName;if(i.includes(r))return!0;const a=n.getAttribute?.("contenteditable");if(a==="true"||a==="")return!0;n=n.parentElement}return!1},bxe=()=>{if(typeof document>"u")return!1;const e=document.activeElement;if(!e)return!1;const A=e.tagName;if(A==="INPUT"||A==="TEXTAREA"||A==="SELECT")return!0;const t=e.getAttribute("contenteditable");return t==="true"||t===""},_xe=()=>{if(!kW)return!0;const e=kW.getBoundingClientRect();return PEA>=e.left&&PEA<=e.right&&qEA>=e.top&&qEA<=e.bottom},xxe=()=>{S6A||typeof window>"u"||(window.addEventListener("mousemove",e=>{PEA=e.clientX,qEA=e.clientY}),S6A=!0)},kxe=e=>{Sxe(e.target)||bxe()||kW&&!_xe()||cv.forEach(A=>{Dxe(e,A.shortcut)&&(e.preventDefault(),A.invoke())})},b6A=()=>{const e=Array.from(cv.values());KEA.forEach(A=>A(e))},Fxe=()=>{D6A||typeof window>"u"||(window.addEventListener("keydown",kxe),D6A=!0)},Gxe=e=>{cv.set(e.id,e),b6A(),Fxe()},Rxe=e=>{cv.delete(e)&&b6A()},Mxe=e=>(KEA.add(e),e(Array.from(cv.values())),()=>{KEA.delete(e)}),FW=(e,A,t)=>{const i=AA.useRef(A);i.current=A;const o=AA.useMemo(()=>({shortcut:t.shortcut,description:t.description}),[t.shortcut,t.description]);AA.useEffect(()=>{const n={id:e,...o,invoke:()=>i.current()};return Gxe(n),()=>{Rxe(e)}},[e,o])},Nxe=()=>{const[e,A]=AA.useState(()=>Array.from(cv.values()));return AA.useEffect(()=>Mxe(A),[]),e},vxe=e=>{kW=e,xxe()},Lxe=()=>({showToast:(e,A=2e3)=>{Ts(e,{duration:A})}}),Uxe=({children:e})=>Z.jsxs(Z.Fragment,{children:[e,Z.jsx(Z9A,{position:"bottom-right"})]});function ca(e,A,{checkForDefaultPrevented:t=!0}={}){return function(o){if(e?.(o),t===!1||!o.defaultPrevented)return A?.(o)}}function _6A(e,A){if(typeof e=="function")return e(A);e!=null&&(e.current=A)}function GW(...e){return A=>{let t=!1;const i=e.map(o=>{const n=_6A(o,A);return!t&&typeof n=="function"&&(t=!0),n});if(t)return()=>{for(let o=0;o<i.length;o++){const n=i[o];typeof n=="function"?n():_6A(e[o],null)}}}}function Qf(...e){return AA.useCallback(GW(...e),e)}function DH(e,A=[]){let t=[];function i(n,s){const r=AA.createContext(s),a=t.length;t=[...t,s];const g=I=>{const{scope:l,children:B,...C}=I,E=l?.[e]?.[a]||r,Q=AA.useMemo(()=>C,Object.values(C));return Z.jsx(E.Provider,{value:Q,children:B})};g.displayName=n+"Provider";function c(I,l){const B=l?.[e]?.[a]||r,C=AA.useContext(B);if(C)return C;if(s!==void 0)return s;throw new Error(`\`${I}\` must be used within \`${n}\``)}return[g,c]}const o=()=>{const n=t.map(s=>AA.createContext(s));return function(r){const a=r?.[e]||n;return AA.useMemo(()=>({[`__scope${e}`]:{...r,[e]:a}}),[r,a])}};return o.scopeName=e,[i,Hxe(o,...A)]}function Hxe(...e){const A=e[0];if(e.length===1)return A;const t=()=>{const i=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(n){const s=i.reduce((r,{useScope:a,scopeName:g})=>{const I=a(n)[`__scope${g}`];return{...r,...I}},{});return AA.useMemo(()=>({[`__scope${A.scopeName}`]:s}),[s])}};return t.scopeName=A.scopeName,t}var fx=globalThis?.document?AA.useLayoutEffect:()=>{},Yxe=a2[" useInsertionEffect ".trim().toString()]||fx;function OEA({prop:e,defaultProp:A,onChange:t=()=>{},caller:i}){const[o,n,s]=Jxe({defaultProp:A,onChange:t}),r=e!==void 0,a=r?e:o;{const c=AA.useRef(e!==void 0);AA.useEffect(()=>{const I=c.current;I!==r&&console.warn(`${i} is changing from ${I?"controlled":"uncontrolled"} to ${r?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=r},[r,i])}const g=AA.useCallback(c=>{if(r){const I=Txe(c)?c(e):c;I!==e&&s.current?.(I)}else n(c)},[r,e,n,s]);return[a,g]}function Jxe({defaultProp:e,onChange:A}){const[t,i]=AA.useState(e),o=AA.useRef(t),n=AA.useRef(A);return Yxe(()=>{n.current=A},[A]),AA.useEffect(()=>{o.current!==t&&(n.current?.(t),o.current=t)},[t,o]),[t,i,n]}function Txe(e){return typeof e=="function"}function RW(e){const A=Kxe(e),t=AA.forwardRef((i,o)=>{const{children:n,...s}=i,r=AA.Children.toArray(n),a=r.find(qxe);if(a){const g=a.props.children,c=r.map(I=>I===a?AA.Children.count(g)>1?AA.Children.only(null):AA.isValidElement(g)?g.props.children:null:I);return Z.jsx(A,{...s,ref:o,children:AA.isValidElement(g)?AA.cloneElement(g,void 0,c):null})}return Z.jsx(A,{...s,ref:o,children:n})});return t.displayName=`${e}.Slot`,t}function Kxe(e){const A=AA.forwardRef((t,i)=>{const{children:o,...n}=t;if(AA.isValidElement(o)){const s=Wxe(o),r=Oxe(n,o.props);return o.type!==AA.Fragment&&(r.ref=i?GW(i,s):s),AA.cloneElement(o,r)}return AA.Children.count(o)>1?AA.Children.only(null):null});return A.displayName=`${e}.SlotClone`,A}var Pxe=Symbol("radix.slottable");function qxe(e){return AA.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Pxe}function Oxe(e,A){const t={...A};for(const i in A){const o=e[i],n=A[i];/^on[A-Z]/.test(i)?o&&n?t[i]=(...r)=>{const a=n(...r);return o(...r),a}:o&&(t[i]=o):i==="style"?t[i]={...o,...n}:i==="className"&&(t[i]=[o,n].filter(Boolean).join(" "))}return{...e,...t}}function Wxe(e){let A=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning;return t?e.ref:(A=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var Zxe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],qd=Zxe.reduce((e,A)=>{const t=RW(`Primitive.${A}`),i=AA.forwardRef((o,n)=>{const{asChild:s,...r}=o,a=s?t:A;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),Z.jsx(a,{...r,ref:n})});return i.displayName=`Primitive.${A}`,{...e,[A]:i}},{});function x6A(e,A){e&&g2.flushSync(()=>e.dispatchEvent(A))}function k6A(e){const A=e+"CollectionProvider",[t,i]=DH(A),[o,n]=t(A,{collectionRef:{current:null},itemMap:new Map}),s=E=>{const{scope:Q,children:h}=E,u=no.useRef(null),d=no.useRef(new Map).current;return Z.jsx(o,{scope:Q,itemMap:d,collectionRef:u,children:h})};s.displayName=A;const r=e+"CollectionSlot",a=RW(r),g=no.forwardRef((E,Q)=>{const{scope:h,children:u}=E,d=n(r,h),f=Qf(Q,d.collectionRef);return Z.jsx(a,{ref:f,children:u})});g.displayName=r;const c=e+"CollectionItemSlot",I="data-radix-collection-item",l=RW(c),B=no.forwardRef((E,Q)=>{const{scope:h,children:u,...d}=E,f=no.useRef(null),m=Qf(Q,f),D=n(c,h);return no.useEffect(()=>(D.itemMap.set(f,{ref:f,...d}),()=>{D.itemMap.delete(f)})),Z.jsx(l,{[I]:"",ref:m,children:u})});B.displayName=c;function C(E){const Q=n(e+"CollectionConsumer",E);return no.useCallback(()=>{const u=Q.collectionRef.current;if(!u)return[];const d=Array.from(u.querySelectorAll(`[${I}]`));return Array.from(Q.itemMap.values()).sort((D,w)=>d.indexOf(D.ref.current)-d.indexOf(w.ref.current))},[Q.collectionRef,Q.itemMap])}return[{Provider:s,Slot:g,ItemSlot:B},C,i]}var Vxe=AA.createContext(void 0);function F6A(e){const A=AA.useContext(Vxe);return e||A||"ltr"}function gD(e){const A=AA.useRef(e);return AA.useEffect(()=>{A.current=e}),AA.useMemo(()=>(...t)=>A.current?.(...t),[])}function jxe(e,A=globalThis?.document){const t=gD(e);AA.useEffect(()=>{const i=o=>{o.key==="Escape"&&t(o)};return A.addEventListener("keydown",i,{capture:!0}),()=>A.removeEventListener("keydown",i,{capture:!0})},[t,A])}var zxe="DismissableLayer",WEA="dismissableLayer.update",Xxe="dismissableLayer.pointerDownOutside",$xe="dismissableLayer.focusOutside",G6A,R6A=AA.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),M6A=AA.forwardRef((e,A)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:n,onInteractOutside:s,onDismiss:r,...a}=e,g=AA.useContext(R6A),[c,I]=AA.useState(null),l=c?.ownerDocument??globalThis?.document,[,B]=AA.useState({}),C=Qf(A,w=>I(w)),E=Array.from(g.layers),[Q]=[...g.layersWithOutsidePointerEventsDisabled].slice(-1),h=E.indexOf(Q),u=c?E.indexOf(c):-1,d=g.layersWithOutsidePointerEventsDisabled.size>0,f=u>=h,m=eke(w=>{const b=w.target,k=[...g.branches].some(_=>_.contains(b));!f||k||(o?.(w),s?.(w),w.defaultPrevented||r?.())},l),D=ike(w=>{const b=w.target;[...g.branches].some(_=>_.contains(b))||(n?.(w),s?.(w),w.defaultPrevented||r?.())},l);return jxe(w=>{u===g.layers.size-1&&(i?.(w),!w.defaultPrevented&&r&&(w.preventDefault(),r()))},l),AA.useEffect(()=>{if(c)return t&&(g.layersWithOutsidePointerEventsDisabled.size===0&&(G6A=l.body.style.pointerEvents,l.body.style.pointerEvents="none"),g.layersWithOutsidePointerEventsDisabled.add(c)),g.layers.add(c),N6A(),()=>{t&&g.layersWithOutsidePointerEventsDisabled.size===1&&(l.body.style.pointerEvents=G6A)}},[c,l,t,g]),AA.useEffect(()=>()=>{c&&(g.layers.delete(c),g.layersWithOutsidePointerEventsDisabled.delete(c),N6A())},[c,g]),AA.useEffect(()=>{const w=()=>B({});return document.addEventListener(WEA,w),()=>document.removeEventListener(WEA,w)},[]),Z.jsx(qd.div,{...a,ref:C,style:{pointerEvents:d?f?"auto":"none":void 0,...e.style},onFocusCapture:ca(e.onFocusCapture,D.onFocusCapture),onBlurCapture:ca(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:ca(e.onPointerDownCapture,m.onPointerDownCapture)})});M6A.displayName=zxe;var Ake="DismissableLayerBranch",tke=AA.forwardRef((e,A)=>{const t=AA.useContext(R6A),i=AA.useRef(null),o=Qf(A,i);return AA.useEffect(()=>{const n=i.current;if(n)return t.branches.add(n),()=>{t.branches.delete(n)}},[t.branches]),Z.jsx(qd.div,{...e,ref:o})});tke.displayName=Ake;function eke(e,A=globalThis?.document){const t=gD(e),i=AA.useRef(!1),o=AA.useRef(()=>{});return AA.useEffect(()=>{const n=r=>{if(r.target&&!i.current){let a=function(){v6A(Xxe,t,g,{discrete:!0})};const g={originalEvent:r};r.pointerType==="touch"?(A.removeEventListener("click",o.current),o.current=a,A.addEventListener("click",o.current,{once:!0})):a()}else A.removeEventListener("click",o.current);i.current=!1},s=window.setTimeout(()=>{A.addEventListener("pointerdown",n)},0);return()=>{window.clearTimeout(s),A.removeEventListener("pointerdown",n),A.removeEventListener("click",o.current)}},[A,t]),{onPointerDownCapture:()=>i.current=!0}}function ike(e,A=globalThis?.document){const t=gD(e),i=AA.useRef(!1);return AA.useEffect(()=>{const o=n=>{n.target&&!i.current&&v6A($xe,t,{originalEvent:n},{discrete:!1})};return A.addEventListener("focusin",o),()=>A.removeEventListener("focusin",o)},[A,t]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function N6A(){const e=new CustomEvent(WEA);document.dispatchEvent(e)}function v6A(e,A,t,{discrete:i}){const o=t.originalEvent.target,n=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:t});A&&o.addEventListener(e,A,{once:!0}),i?x6A(o,n):o.dispatchEvent(n)}var ZEA=0;function oke(){AA.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??L6A()),document.body.insertAdjacentElement("beforeend",e[1]??L6A()),ZEA++,()=>{ZEA===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(A=>A.remove()),ZEA--}},[])}function L6A(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var VEA="focusScope.autoFocusOnMount",jEA="focusScope.autoFocusOnUnmount",U6A={bubbles:!1,cancelable:!0},nke="FocusScope",H6A=AA.forwardRef((e,A)=>{const{loop:t=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:n,...s}=e,[r,a]=AA.useState(null),g=gD(o),c=gD(n),I=AA.useRef(null),l=Qf(A,E=>a(E)),B=AA.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;AA.useEffect(()=>{if(i){let E=function(d){if(B.paused||!r)return;const f=d.target;r.contains(f)?I.current=f:yx(I.current,{select:!0})},Q=function(d){if(B.paused||!r)return;const f=d.relatedTarget;f!==null&&(r.contains(f)||yx(I.current,{select:!0}))},h=function(d){if(document.activeElement===document.body)for(const m of d)m.removedNodes.length>0&&yx(r)};document.addEventListener("focusin",E),document.addEventListener("focusout",Q);const u=new MutationObserver(h);return r&&u.observe(r,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",Q),u.disconnect()}}},[i,r,B.paused]),AA.useEffect(()=>{if(r){T6A.add(B);const E=document.activeElement;if(!r.contains(E)){const h=new CustomEvent(VEA,U6A);r.addEventListener(VEA,g),r.dispatchEvent(h),h.defaultPrevented||(ske(Ike(Y6A(r)),{select:!0}),document.activeElement===E&&yx(r))}return()=>{r.removeEventListener(VEA,g),setTimeout(()=>{const h=new CustomEvent(jEA,U6A);r.addEventListener(jEA,c),r.dispatchEvent(h),h.defaultPrevented||yx(E??document.body,{select:!0}),r.removeEventListener(jEA,c),T6A.remove(B)},0)}}},[r,g,c,B]);const C=AA.useCallback(E=>{if(!t&&!i||B.paused)return;const Q=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,h=document.activeElement;if(Q&&h){const u=E.currentTarget,[d,f]=rke(u);d&&f?!E.shiftKey&&h===f?(E.preventDefault(),t&&yx(d,{select:!0})):E.shiftKey&&h===d&&(E.preventDefault(),t&&yx(f,{select:!0})):h===u&&E.preventDefault()}},[t,i,B.paused]);return Z.jsx(qd.div,{tabIndex:-1,...s,ref:l,onKeyDown:C})});H6A.displayName=nke;function ske(e,{select:A=!1}={}){const t=document.activeElement;for(const i of e)if(yx(i,{select:A}),document.activeElement!==t)return}function rke(e){const A=Y6A(e),t=J6A(A,e),i=J6A(A.reverse(),e);return[t,i]}function Y6A(e){const A=[],t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const o=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||o?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;t.nextNode();)A.push(t.currentNode);return A}function J6A(e,A){for(const t of e)if(!ake(t,{upTo:A}))return t}function ake(e,{upTo:A}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(A!==void 0&&e===A)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function gke(e){return e instanceof HTMLInputElement&&"select"in e}function yx(e,{select:A=!1}={}){if(e&&e.focus){const t=document.activeElement;e.focus({preventScroll:!0}),e!==t&&gke(e)&&A&&e.select()}}var T6A=cke();function cke(){let e=[];return{add(A){const t=e[0];A!==t&&t?.pause(),e=K6A(e,A),e.unshift(A)},remove(A){e=K6A(e,A),e[0]?.resume()}}}function K6A(e,A){const t=[...e],i=t.indexOf(A);return i!==-1&&t.splice(i,1),t}function Ike(e){return e.filter(A=>A.tagName!=="A")}var lke=a2[" useId ".trim().toString()]||(()=>{}),Bke=0;function SH(e){const[A,t]=AA.useState(lke());return fx(()=>{t(i=>i??String(Bke++))},[e]),A?`radix-${A}`:""}var Cke=["top","right","bottom","left"],mx=Math.min,f0=Math.max,MW=Math.round,NW=Math.floor,cD=e=>({x:e,y:e}),Qke={left:"right",right:"left",bottom:"top",top:"bottom"},Eke={start:"end",end:"start"};function zEA(e,A,t){return f0(e,mx(A,t))}function sb(e,A){return typeof e=="function"?e(A):e}function rb(e){return e.split("-")[0]}function Iv(e){return e.split("-")[1]}function XEA(e){return e==="x"?"y":"x"}function $EA(e){return e==="y"?"height":"width"}var hke=new Set(["top","bottom"]);function ID(e){return hke.has(rb(e))?"y":"x"}function AhA(e){return XEA(ID(e))}function uke(e,A,t){t===void 0&&(t=!1);const i=Iv(e),o=AhA(e),n=$EA(o);let s=o==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return A.reference[n]>A.floating[n]&&(s=vW(s)),[s,vW(s)]}function dke(e){const A=vW(e);return[thA(e),A,thA(A)]}function thA(e){return e.replace(/start|end/g,A=>Eke[A])}var P6A=["left","right"],q6A=["right","left"],pke=["top","bottom"],fke=["bottom","top"];function yke(e,A,t){switch(e){case"top":case"bottom":return t?A?q6A:P6A:A?P6A:q6A;case"left":case"right":return A?pke:fke;default:return[]}}function mke(e,A,t,i){const o=Iv(e);let n=yke(rb(e),t==="start",i);return o&&(n=n.map(s=>s+"-"+o),A&&(n=n.concat(n.map(thA)))),n}function vW(e){return e.replace(/left|right|bottom|top/g,A=>Qke[A])}function wke(e){return{top:0,right:0,bottom:0,left:0,...e}}function O6A(e){return typeof e!="number"?wke(e):{top:e,right:e,bottom:e,left:e}}function LW(e){const{x:A,y:t,width:i,height:o}=e;return{width:i,height:o,top:t,left:A,right:A+i,bottom:t+o,x:A,y:t}}function W6A(e,A,t){let{reference:i,floating:o}=e;const n=ID(A),s=AhA(A),r=$EA(s),a=rb(A),g=n==="y",c=i.x+i.width/2-o.width/2,I=i.y+i.height/2-o.height/2,l=i[r]/2-o[r]/2;let B;switch(a){case"top":B={x:c,y:i.y-o.height};break;case"bottom":B={x:c,y:i.y+i.height};break;case"right":B={x:i.x+i.width,y:I};break;case"left":B={x:i.x-o.width,y:I};break;default:B={x:i.x,y:i.y}}switch(Iv(A)){case"start":B[s]-=l*(t&&g?-1:1);break;case"end":B[s]+=l*(t&&g?-1:1);break}return B}async function Dke(e,A){var t;A===void 0&&(A={});const{x:i,y:o,platform:n,rects:s,elements:r,strategy:a}=e,{boundary:g="clippingAncestors",rootBoundary:c="viewport",elementContext:I="floating",altBoundary:l=!1,padding:B=0}=sb(A,e),C=O6A(B),Q=r[l?I==="floating"?"reference":"floating":I],h=LW(await n.getClippingRect({element:(t=await(n.isElement==null?void 0:n.isElement(Q)))==null||t?Q:Q.contextElement||await(n.getDocumentElement==null?void 0:n.getDocumentElement(r.floating)),boundary:g,rootBoundary:c,strategy:a})),u=I==="floating"?{x:i,y:o,width:s.floating.width,height:s.floating.height}:s.reference,d=await(n.getOffsetParent==null?void 0:n.getOffsetParent(r.floating)),f=await(n.isElement==null?void 0:n.isElement(d))?await(n.getScale==null?void 0:n.getScale(d))||{x:1,y:1}:{x:1,y:1},m=LW(n.convertOffsetParentRelativeRectToViewportRelativeRect?await n.convertOffsetParentRelativeRectToViewportRelativeRect({elements:r,rect:u,offsetParent:d,strategy:a}):u);return{top:(h.top-m.top+C.top)/f.y,bottom:(m.bottom-h.bottom+C.bottom)/f.y,left:(h.left-m.left+C.left)/f.x,right:(m.right-h.right+C.right)/f.x}}var Ske=async(e,A,t)=>{const{placement:i="bottom",strategy:o="absolute",middleware:n=[],platform:s}=t,r=n.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(A));let g=await s.getElementRects({reference:e,floating:A,strategy:o}),{x:c,y:I}=W6A(g,i,a),l=i,B={},C=0;for(let Q=0;Q<r.length;Q++){var E;const{name:h,fn:u}=r[Q],{x:d,y:f,data:m,reset:D}=await u({x:c,y:I,initialPlacement:i,placement:l,strategy:o,middlewareData:B,rects:g,platform:{...s,detectOverflow:(E=s.detectOverflow)!=null?E:Dke},elements:{reference:e,floating:A}});c=d??c,I=f??I,B={...B,[h]:{...B[h],...m}},D&&C<=50&&(C++,typeof D=="object"&&(D.placement&&(l=D.placement),D.rects&&(g=D.rects===!0?await s.getElementRects({reference:e,floating:A,strategy:o}):D.rects),{x:c,y:I}=W6A(g,l,a)),Q=-1)}return{x:c,y:I,placement:l,strategy:o,middlewareData:B}},bke=e=>({name:"arrow",options:e,async fn(A){const{x:t,y:i,placement:o,rects:n,platform:s,elements:r,middlewareData:a}=A,{element:g,padding:c=0}=sb(e,A)||{};if(g==null)return{};const I=O6A(c),l={x:t,y:i},B=AhA(o),C=$EA(B),E=await s.getDimensions(g),Q=B==="y",h=Q?"top":"left",u=Q?"bottom":"right",d=Q?"clientHeight":"clientWidth",f=n.reference[C]+n.reference[B]-l[B]-n.floating[C],m=l[B]-n.reference[B],D=await(s.getOffsetParent==null?void 0:s.getOffsetParent(g));let w=D?D[d]:0;(!w||!await(s.isElement==null?void 0:s.isElement(D)))&&(w=r.floating[d]||n.floating[C]);const b=f/2-m/2,k=w/2-E[C]/2-1,_=mx(I[h],k),N=mx(I[u],k),M=_,H=w-E[C]-N,T=w/2-E[C]/2+b,Y=zEA(M,T,H),O=!a.arrow&&Iv(o)!=null&&T!==Y&&n.reference[C]/2-(T<M?_:N)-E[C]/2<0,W=O?T<M?T-M:T-H:0;return{[B]:l[B]+W,data:{[B]:Y,centerOffset:T-Y-W,...O&&{alignmentOffset:W}},reset:O}}}),_ke=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(A){var t,i;const{placement:o,middlewareData:n,rects:s,initialPlacement:r,platform:a,elements:g}=A,{mainAxis:c=!0,crossAxis:I=!0,fallbackPlacements:l,fallbackStrategy:B="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:E=!0,...Q}=sb(e,A);if((t=n.arrow)!=null&&t.alignmentOffset)return{};const h=rb(o),u=ID(r),d=rb(r)===r,f=await(a.isRTL==null?void 0:a.isRTL(g.floating)),m=l||(d||!E?[vW(r)]:dke(r)),D=C!=="none";!l&&D&&m.push(...mke(r,E,C,f));const w=[r,...m],b=await a.detectOverflow(A,Q),k=[];let _=((i=n.flip)==null?void 0:i.overflows)||[];if(c&&k.push(b[h]),I){const T=uke(o,s,f);k.push(b[T[0]],b[T[1]])}if(_=[..._,{placement:o,overflows:k}],!k.every(T=>T<=0)){var N,M;const T=(((N=n.flip)==null?void 0:N.index)||0)+1,Y=w[T];if(Y&&(!(I==="alignment"?u!==ID(Y):!1)||_.every($=>ID($.placement)===u?$.overflows[0]>0:!0)))return{data:{index:T,overflows:_},reset:{placement:Y}};let O=(M=_.filter(W=>W.overflows[0]<=0).sort((W,$)=>W.overflows[1]-$.overflows[1])[0])==null?void 0:M.placement;if(!O)switch(B){case"bestFit":{var H;const W=(H=_.filter($=>{if(D){const iA=ID($.placement);return iA===u||iA==="y"}return!0}).map($=>[$.placement,$.overflows.filter(iA=>iA>0).reduce((iA,gA)=>iA+gA,0)]).sort(($,iA)=>$[1]-iA[1])[0])==null?void 0:H[0];W&&(O=W);break}case"initialPlacement":O=r;break}if(o!==O)return{reset:{placement:O}}}return{}}}};function Z6A(e,A){return{top:e.top-A.height,right:e.right-A.width,bottom:e.bottom-A.height,left:e.left-A.width}}function V6A(e){return Cke.some(A=>e[A]>=0)}var xke=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(A){const{rects:t,platform:i}=A,{strategy:o="referenceHidden",...n}=sb(e,A);switch(o){case"referenceHidden":{const s=await i.detectOverflow(A,{...n,elementContext:"reference"}),r=Z6A(s,t.reference);return{data:{referenceHiddenOffsets:r,referenceHidden:V6A(r)}}}case"escaped":{const s=await i.detectOverflow(A,{...n,altBoundary:!0}),r=Z6A(s,t.floating);return{data:{escapedOffsets:r,escaped:V6A(r)}}}default:return{}}}}},j6A=new Set(["left","top"]);async function kke(e,A){const{placement:t,platform:i,elements:o}=e,n=await(i.isRTL==null?void 0:i.isRTL(o.floating)),s=rb(t),r=Iv(t),a=ID(t)==="y",g=j6A.has(s)?-1:1,c=n&&a?-1:1,I=sb(A,e);let{mainAxis:l,crossAxis:B,alignmentAxis:C}=typeof I=="number"?{mainAxis:I,crossAxis:0,alignmentAxis:null}:{mainAxis:I.mainAxis||0,crossAxis:I.crossAxis||0,alignmentAxis:I.alignmentAxis};return r&&typeof C=="number"&&(B=r==="end"?C*-1:C),a?{x:B*c,y:l*g}:{x:l*g,y:B*c}}var Fke=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(A){var t,i;const{x:o,y:n,placement:s,middlewareData:r}=A,a=await kke(A,e);return s===((t=r.offset)==null?void 0:t.placement)&&(i=r.arrow)!=null&&i.alignmentOffset?{}:{x:o+a.x,y:n+a.y,data:{...a,placement:s}}}}},Gke=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(A){const{x:t,y:i,placement:o,platform:n}=A,{mainAxis:s=!0,crossAxis:r=!1,limiter:a={fn:h=>{let{x:u,y:d}=h;return{x:u,y:d}}},...g}=sb(e,A),c={x:t,y:i},I=await n.detectOverflow(A,g),l=ID(rb(o)),B=XEA(l);let C=c[B],E=c[l];if(s){const h=B==="y"?"top":"left",u=B==="y"?"bottom":"right",d=C+I[h],f=C-I[u];C=zEA(d,C,f)}if(r){const h=l==="y"?"top":"left",u=l==="y"?"bottom":"right",d=E+I[h],f=E-I[u];E=zEA(d,E,f)}const Q=a.fn({...A,[B]:C,[l]:E});return{...Q,data:{x:Q.x-t,y:Q.y-i,enabled:{[B]:s,[l]:r}}}}}},Rke=function(e){return e===void 0&&(e={}),{options:e,fn(A){const{x:t,y:i,placement:o,rects:n,middlewareData:s}=A,{offset:r=0,mainAxis:a=!0,crossAxis:g=!0}=sb(e,A),c={x:t,y:i},I=ID(o),l=XEA(I);let B=c[l],C=c[I];const E=sb(r,A),Q=typeof E=="number"?{mainAxis:E,crossAxis:0}:{mainAxis:0,crossAxis:0,...E};if(a){const d=l==="y"?"height":"width",f=n.reference[l]-n.floating[d]+Q.mainAxis,m=n.reference[l]+n.reference[d]-Q.mainAxis;B<f?B=f:B>m&&(B=m)}if(g){var h,u;const d=l==="y"?"width":"height",f=j6A.has(rb(o)),m=n.reference[I]-n.floating[d]+(f&&((h=s.offset)==null?void 0:h[I])||0)+(f?0:Q.crossAxis),D=n.reference[I]+n.reference[d]+(f?0:((u=s.offset)==null?void 0:u[I])||0)-(f?Q.crossAxis:0);C<m?C=m:C>D&&(C=D)}return{[l]:B,[I]:C}}}},Mke=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(A){var t,i;const{placement:o,rects:n,platform:s,elements:r}=A,{apply:a=()=>{},...g}=sb(e,A),c=await s.detectOverflow(A,g),I=rb(o),l=Iv(o),B=ID(o)==="y",{width:C,height:E}=n.floating;let Q,h;I==="top"||I==="bottom"?(Q=I,h=l===(await(s.isRTL==null?void 0:s.isRTL(r.floating))?"start":"end")?"left":"right"):(h=I,Q=l==="end"?"top":"bottom");const u=E-c.top-c.bottom,d=C-c.left-c.right,f=mx(E-c[Q],u),m=mx(C-c[h],d),D=!A.middlewareData.shift;let w=f,b=m;if((t=A.middlewareData.shift)!=null&&t.enabled.x&&(b=d),(i=A.middlewareData.shift)!=null&&i.enabled.y&&(w=u),D&&!l){const _=f0(c.left,0),N=f0(c.right,0),M=f0(c.top,0),H=f0(c.bottom,0);B?b=C-2*(_!==0||N!==0?_+N:f0(c.left,c.right)):w=E-2*(M!==0||H!==0?M+H:f0(c.top,c.bottom))}await a({...A,availableWidth:b,availableHeight:w});const k=await s.getDimensions(r.floating);return C!==k.width||E!==k.height?{reset:{rects:!0}}:{}}}};function UW(){return typeof window<"u"}function lv(e){return z6A(e)?(e.nodeName||"").toLowerCase():"#document"}function y0(e){var A;return(e==null||(A=e.ownerDocument)==null?void 0:A.defaultView)||window}function lD(e){var A;return(A=(z6A(e)?e.ownerDocument:e.document)||window.document)==null?void 0:A.documentElement}function z6A(e){return UW()?e instanceof Node||e instanceof y0(e).Node:!1}function jm(e){return UW()?e instanceof Element||e instanceof y0(e).Element:!1}function BD(e){return UW()?e instanceof HTMLElement||e instanceof y0(e).HTMLElement:!1}function X6A(e){return!UW()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof y0(e).ShadowRoot}var Nke=new Set(["inline","contents"]);function bH(e){const{overflow:A,overflowX:t,overflowY:i,display:o}=zm(e);return/auto|scroll|overlay|hidden|clip/.test(A+i+t)&&!Nke.has(o)}var vke=new Set(["table","td","th"]);function Lke(e){return vke.has(lv(e))}var Uke=[":popover-open",":modal"];function HW(e){return Uke.some(A=>{try{return e.matches(A)}catch{return!1}})}var Hke=["transform","translate","scale","rotate","perspective"],Yke=["transform","translate","scale","rotate","perspective","filter"],Jke=["paint","layout","strict","content"];function ehA(e){const A=ihA(),t=jm(e)?zm(e):e;return Hke.some(i=>t[i]?t[i]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!A&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!A&&(t.filter?t.filter!=="none":!1)||Yke.some(i=>(t.willChange||"").includes(i))||Jke.some(i=>(t.contain||"").includes(i))}function Tke(e){let A=wx(e);for(;BD(A)&&!Bv(A);){if(ehA(A))return A;if(HW(A))return null;A=wx(A)}return null}function ihA(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var Kke=new Set(["html","body","#document"]);function Bv(e){return Kke.has(lv(e))}function zm(e){return y0(e).getComputedStyle(e)}function YW(e){return jm(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wx(e){if(lv(e)==="html")return e;const A=e.assignedSlot||e.parentNode||X6A(e)&&e.host||lD(e);return X6A(A)?A.host:A}function $6A(e){const A=wx(e);return Bv(A)?e.ownerDocument?e.ownerDocument.body:e.body:BD(A)&&bH(A)?A:$6A(A)}function _H(e,A,t){var i;A===void 0&&(A=[]),t===void 0&&(t=!0);const o=$6A(e),n=o===((i=e.ownerDocument)==null?void 0:i.body),s=y0(o);if(n){const r=ohA(s);return A.concat(s,s.visualViewport||[],bH(o)?o:[],r&&t?_H(r):[])}return A.concat(o,_H(o,[],t))}function ohA(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function A7A(e){const A=zm(e);let t=parseFloat(A.width)||0,i=parseFloat(A.height)||0;const o=BD(e),n=o?e.offsetWidth:t,s=o?e.offsetHeight:i,r=MW(t)!==n||MW(i)!==s;return r&&(t=n,i=s),{width:t,height:i,$:r}}function nhA(e){return jm(e)?e:e.contextElement}function Cv(e){const A=nhA(e);if(!BD(A))return cD(1);const t=A.getBoundingClientRect(),{width:i,height:o,$:n}=A7A(A);let s=(n?MW(t.width):t.width)/i,r=(n?MW(t.height):t.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!r||!Number.isFinite(r))&&(r=1),{x:s,y:r}}var Pke=cD(0);function t7A(e){const A=y0(e);return!ihA()||!A.visualViewport?Pke:{x:A.visualViewport.offsetLeft,y:A.visualViewport.offsetTop}}function qke(e,A,t){return A===void 0&&(A=!1),!t||A&&t!==y0(e)?!1:A}function $F(e,A,t,i){A===void 0&&(A=!1),t===void 0&&(t=!1);const o=e.getBoundingClientRect(),n=nhA(e);let s=cD(1);A&&(i?jm(i)&&(s=Cv(i)):s=Cv(e));const r=qke(n,t,i)?t7A(n):cD(0);let a=(o.left+r.x)/s.x,g=(o.top+r.y)/s.y,c=o.width/s.x,I=o.height/s.y;if(n){const l=y0(n),B=i&&jm(i)?y0(i):i;let C=l,E=ohA(C);for(;E&&i&&B!==C;){const Q=Cv(E),h=E.getBoundingClientRect(),u=zm(E),d=h.left+(E.clientLeft+parseFloat(u.paddingLeft))*Q.x,f=h.top+(E.clientTop+parseFloat(u.paddingTop))*Q.y;a*=Q.x,g*=Q.y,c*=Q.x,I*=Q.y,a+=d,g+=f,C=y0(E),E=ohA(C)}}return LW({width:c,height:I,x:a,y:g})}function JW(e,A){const t=YW(e).scrollLeft;return A?A.left+t:$F(lD(e)).left+t}function e7A(e,A){const t=e.getBoundingClientRect(),i=t.left+A.scrollLeft-JW(e,t),o=t.top+A.scrollTop;return{x:i,y:o}}function Oke(e){let{elements:A,rect:t,offsetParent:i,strategy:o}=e;const n=o==="fixed",s=lD(i),r=A?HW(A.floating):!1;if(i===s||r&&n)return t;let a={scrollLeft:0,scrollTop:0},g=cD(1);const c=cD(0),I=BD(i);if((I||!I&&!n)&&((lv(i)!=="body"||bH(s))&&(a=YW(i)),BD(i))){const B=$F(i);g=Cv(i),c.x=B.x+i.clientLeft,c.y=B.y+i.clientTop}const l=s&&!I&&!n?e7A(s,a):cD(0);return{width:t.width*g.x,height:t.height*g.y,x:t.x*g.x-a.scrollLeft*g.x+c.x+l.x,y:t.y*g.y-a.scrollTop*g.y+c.y+l.y}}function Wke(e){return Array.from(e.getClientRects())}function Zke(e){const A=lD(e),t=YW(e),i=e.ownerDocument.body,o=f0(A.scrollWidth,A.clientWidth,i.scrollWidth,i.clientWidth),n=f0(A.scrollHeight,A.clientHeight,i.scrollHeight,i.clientHeight);let s=-t.scrollLeft+JW(e);const r=-t.scrollTop;return zm(i).direction==="rtl"&&(s+=f0(A.clientWidth,i.clientWidth)-o),{width:o,height:n,x:s,y:r}}var i7A=25;function Vke(e,A){const t=y0(e),i=lD(e),o=t.visualViewport;let n=i.clientWidth,s=i.clientHeight,r=0,a=0;if(o){n=o.width,s=o.height;const c=ihA();(!c||c&&A==="fixed")&&(r=o.offsetLeft,a=o.offsetTop)}const g=JW(i);if(g<=0){const c=i.ownerDocument,I=c.body,l=getComputedStyle(I),B=c.compatMode==="CSS1Compat"&&parseFloat(l.marginLeft)+parseFloat(l.marginRight)||0,C=Math.abs(i.clientWidth-I.clientWidth-B);C<=i7A&&(n-=C)}else g<=i7A&&(n+=g);return{width:n,height:s,x:r,y:a}}var jke=new Set(["absolute","fixed"]);function zke(e,A){const t=$F(e,!0,A==="fixed"),i=t.top+e.clientTop,o=t.left+e.clientLeft,n=BD(e)?Cv(e):cD(1),s=e.clientWidth*n.x,r=e.clientHeight*n.y,a=o*n.x,g=i*n.y;return{width:s,height:r,x:a,y:g}}function o7A(e,A,t){let i;if(A==="viewport")i=Vke(e,t);else if(A==="document")i=Zke(lD(e));else if(jm(A))i=zke(A,t);else{const o=t7A(e);i={x:A.x-o.x,y:A.y-o.y,width:A.width,height:A.height}}return LW(i)}function n7A(e,A){const t=wx(e);return t===A||!jm(t)||Bv(t)?!1:zm(t).position==="fixed"||n7A(t,A)}function Xke(e,A){const t=A.get(e);if(t)return t;let i=_H(e,[],!1).filter(r=>jm(r)&&lv(r)!=="body"),o=null;const n=zm(e).position==="fixed";let s=n?wx(e):e;for(;jm(s)&&!Bv(s);){const r=zm(s),a=ehA(s);!a&&r.position==="fixed"&&(o=null),(n?!a&&!o:!a&&r.position==="static"&&!!o&&jke.has(o.position)||bH(s)&&!a&&n7A(e,s))?i=i.filter(c=>c!==s):o=r,s=wx(s)}return A.set(e,i),i}function $ke(e){let{element:A,boundary:t,rootBoundary:i,strategy:o}=e;const s=[...t==="clippingAncestors"?HW(A)?[]:Xke(A,this._c):[].concat(t),i],r=s[0],a=s.reduce((g,c)=>{const I=o7A(A,c,o);return g.top=f0(I.top,g.top),g.right=mx(I.right,g.right),g.bottom=mx(I.bottom,g.bottom),g.left=f0(I.left,g.left),g},o7A(A,r,o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function AFe(e){const{width:A,height:t}=A7A(e);return{width:A,height:t}}function tFe(e,A,t){const i=BD(A),o=lD(A),n=t==="fixed",s=$F(e,!0,n,A);let r={scrollLeft:0,scrollTop:0};const a=cD(0);function g(){a.x=JW(o)}if(i||!i&&!n)if((lv(A)!=="body"||bH(o))&&(r=YW(A)),i){const B=$F(A,!0,n,A);a.x=B.x+A.clientLeft,a.y=B.y+A.clientTop}else o&&g();n&&!i&&o&&g();const c=o&&!i&&!n?e7A(o,r):cD(0),I=s.left+r.scrollLeft-a.x-c.x,l=s.top+r.scrollTop-a.y-c.y;return{x:I,y:l,width:s.width,height:s.height}}function shA(e){return zm(e).position==="static"}function s7A(e,A){if(!BD(e)||zm(e).position==="fixed")return null;if(A)return A(e);let t=e.offsetParent;return lD(e)===t&&(t=t.ownerDocument.body),t}function r7A(e,A){const t=y0(e);if(HW(e))return t;if(!BD(e)){let o=wx(e);for(;o&&!Bv(o);){if(jm(o)&&!shA(o))return o;o=wx(o)}return t}let i=s7A(e,A);for(;i&&Lke(i)&&shA(i);)i=s7A(i,A);return i&&Bv(i)&&shA(i)&&!ehA(i)?t:i||Tke(e)||t}var eFe=async function(e){const A=this.getOffsetParent||r7A,t=this.getDimensions,i=await t(e.floating);return{reference:tFe(e.reference,await A(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function iFe(e){return zm(e).direction==="rtl"}var oFe={convertOffsetParentRelativeRectToViewportRelativeRect:Oke,getDocumentElement:lD,getClippingRect:$ke,getOffsetParent:r7A,getElementRects:eFe,getClientRects:Wke,getDimensions:AFe,getScale:Cv,isElement:jm,isRTL:iFe};function a7A(e,A){return e.x===A.x&&e.y===A.y&&e.width===A.width&&e.height===A.height}function nFe(e,A){let t=null,i;const o=lD(e);function n(){var r;clearTimeout(i),(r=t)==null||r.disconnect(),t=null}function s(r,a){r===void 0&&(r=!1),a===void 0&&(a=1),n();const g=e.getBoundingClientRect(),{left:c,top:I,width:l,height:B}=g;if(r||A(),!l||!B)return;const C=NW(I),E=NW(o.clientWidth-(c+l)),Q=NW(o.clientHeight-(I+B)),h=NW(c),d={rootMargin:-C+"px "+-E+"px "+-Q+"px "+-h+"px",threshold:f0(0,mx(1,a))||1};let f=!0;function m(D){const w=D[0].intersectionRatio;if(w!==a){if(!f)return s();w?s(!1,w):i=setTimeout(()=>{s(!1,1e-7)},1e3)}w===1&&!a7A(g,e.getBoundingClientRect())&&s(),f=!1}try{t=new IntersectionObserver(m,{...d,root:o.ownerDocument})}catch{t=new IntersectionObserver(m,d)}t.observe(e)}return s(!0),n}function sFe(e,A,t,i){i===void 0&&(i={});const{ancestorScroll:o=!0,ancestorResize:n=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:r=typeof IntersectionObserver=="function",animationFrame:a=!1}=i,g=nhA(e),c=o||n?[...g?_H(g):[],..._H(A)]:[];c.forEach(h=>{o&&h.addEventListener("scroll",t,{passive:!0}),n&&h.addEventListener("resize",t)});const I=g&&r?nFe(g,t):null;let l=-1,B=null;s&&(B=new ResizeObserver(h=>{let[u]=h;u&&u.target===g&&B&&(B.unobserve(A),cancelAnimationFrame(l),l=requestAnimationFrame(()=>{var d;(d=B)==null||d.observe(A)})),t()}),g&&!a&&B.observe(g),B.observe(A));let C,E=a?$F(e):null;a&&Q();function Q(){const h=$F(e);E&&!a7A(E,h)&&t(),E=h,C=requestAnimationFrame(Q)}return t(),()=>{var h;c.forEach(u=>{o&&u.removeEventListener("scroll",t),n&&u.removeEventListener("resize",t)}),I?.(),(h=B)==null||h.disconnect(),B=null,a&&cancelAnimationFrame(C)}}var rFe=Fke,aFe=Gke,gFe=_ke,cFe=Mke,IFe=xke,g7A=bke,lFe=Rke,BFe=(e,A,t)=>{const i=new Map,o={platform:oFe,...t},n={...o.platform,_c:i};return Ske(e,A,{...o,platform:n})},CFe=typeof document<"u",QFe=function(){},TW=CFe?AA.useLayoutEffect:QFe;function KW(e,A){if(e===A)return!0;if(typeof e!=typeof A)return!1;if(typeof e=="function"&&e.toString()===A.toString())return!0;let t,i,o;if(e&&A&&typeof e=="object"){if(Array.isArray(e)){if(t=e.length,t!==A.length)return!1;for(i=t;i--!==0;)if(!KW(e[i],A[i]))return!1;return!0}if(o=Object.keys(e),t=o.length,t!==Object.keys(A).length)return!1;for(i=t;i--!==0;)if(!{}.hasOwnProperty.call(A,o[i]))return!1;for(i=t;i--!==0;){const n=o[i];if(!(n==="_owner"&&e.$$typeof)&&!KW(e[n],A[n]))return!1}return!0}return e!==e&&A!==A}function c7A(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function I7A(e,A){const t=c7A(e);return Math.round(A*t)/t}function rhA(e){const A=AA.useRef(e);return TW(()=>{A.current=e}),A}function EFe(e){e===void 0&&(e={});const{placement:A="bottom",strategy:t="absolute",middleware:i=[],platform:o,elements:{reference:n,floating:s}={},transform:r=!0,whileElementsMounted:a,open:g}=e,[c,I]=AA.useState({x:0,y:0,strategy:t,placement:A,middlewareData:{},isPositioned:!1}),[l,B]=AA.useState(i);KW(l,i)||B(i);const[C,E]=AA.useState(null),[Q,h]=AA.useState(null),u=AA.useCallback($=>{$!==D.current&&(D.current=$,E($))},[]),d=AA.useCallback($=>{$!==w.current&&(w.current=$,h($))},[]),f=n||C,m=s||Q,D=AA.useRef(null),w=AA.useRef(null),b=AA.useRef(c),k=a!=null,_=rhA(a),N=rhA(o),M=rhA(g),H=AA.useCallback(()=>{if(!D.current||!w.current)return;const $={placement:A,strategy:t,middleware:l};N.current&&($.platform=N.current),BFe(D.current,w.current,$).then(iA=>{const gA={...iA,isPositioned:M.current!==!1};T.current&&!KW(b.current,gA)&&(b.current=gA,g2.flushSync(()=>{I(gA)}))})},[l,A,t,N,M]);TW(()=>{g===!1&&b.current.isPositioned&&(b.current.isPositioned=!1,I($=>({...$,isPositioned:!1})))},[g]);const T=AA.useRef(!1);TW(()=>(T.current=!0,()=>{T.current=!1}),[]),TW(()=>{if(f&&(D.current=f),m&&(w.current=m),f&&m){if(_.current)return _.current(f,m,H);H()}},[f,m,H,_,k]);const Y=AA.useMemo(()=>({reference:D,floating:w,setReference:u,setFloating:d}),[u,d]),O=AA.useMemo(()=>({reference:f,floating:m}),[f,m]),W=AA.useMemo(()=>{const $={position:t,left:0,top:0};if(!O.floating)return $;const iA=I7A(O.floating,c.x),gA=I7A(O.floating,c.y);return r?{...$,transform:"translate("+iA+"px, "+gA+"px)",...c7A(O.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:iA,top:gA}},[t,r,O.floating,c.x,c.y]);return AA.useMemo(()=>({...c,update:H,refs:Y,elements:O,floatingStyles:W}),[c,H,Y,O,W])}var hFe=e=>{function A(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:e,fn(t){const{element:i,padding:o}=typeof e=="function"?e(t):e;return i&&A(i)?i.current!=null?g7A({element:i.current,padding:o}).fn(t):{}:i?g7A({element:i,padding:o}).fn(t):{}}}},uFe=(e,A)=>({...rFe(e),options:[e,A]}),dFe=(e,A)=>({...aFe(e),options:[e,A]}),pFe=(e,A)=>({...lFe(e),options:[e,A]}),fFe=(e,A)=>({...gFe(e),options:[e,A]}),yFe=(e,A)=>({...cFe(e),options:[e,A]}),mFe=(e,A)=>({...IFe(e),options:[e,A]}),wFe=(e,A)=>({...hFe(e),options:[e,A]}),DFe="Arrow",l7A=AA.forwardRef((e,A)=>{const{children:t,width:i=10,height:o=5,...n}=e;return Z.jsx(qd.svg,{...n,ref:A,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?t:Z.jsx("polygon",{points:"0,0 30,0 15,10"})})});l7A.displayName=DFe;var SFe=l7A;function bFe(e){const[A,t]=AA.useState(void 0);return fx(()=>{if(e){t({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const n=o[0];let s,r;if("borderBoxSize"in n){const a=n.borderBoxSize,g=Array.isArray(a)?a[0]:a;s=g.inlineSize,r=g.blockSize}else s=e.offsetWidth,r=e.offsetHeight;t({width:s,height:r})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else t(void 0)},[e]),A}var ahA="Popper",[B7A,C7A]=DH(ahA),[_Fe,Q7A]=B7A(ahA),E7A=e=>{const{__scopePopper:A,children:t}=e,[i,o]=AA.useState(null);return Z.jsx(_Fe,{scope:A,anchor:i,onAnchorChange:o,children:t})};E7A.displayName=ahA;var h7A="PopperAnchor",u7A=AA.forwardRef((e,A)=>{const{__scopePopper:t,virtualRef:i,...o}=e,n=Q7A(h7A,t),s=AA.useRef(null),r=Qf(A,s),a=AA.useRef(null);return AA.useEffect(()=>{const g=a.current;a.current=i?.current||s.current,g!==a.current&&n.onAnchorChange(a.current)}),i?null:Z.jsx(qd.div,{...o,ref:r})});u7A.displayName=h7A;var ghA="PopperContent",[xFe,kFe]=B7A(ghA),d7A=AA.forwardRef((e,A)=>{const{__scopePopper:t,side:i="bottom",sideOffset:o=0,align:n="center",alignOffset:s=0,arrowPadding:r=0,avoidCollisions:a=!0,collisionBoundary:g=[],collisionPadding:c=0,sticky:I="partial",hideWhenDetached:l=!1,updatePositionStrategy:B="optimized",onPlaced:C,...E}=e,Q=Q7A(ghA,t),[h,u]=AA.useState(null),d=Qf(A,NA=>u(NA)),[f,m]=AA.useState(null),D=bFe(f),w=D?.width??0,b=D?.height??0,k=i+(n!=="center"?"-"+n:""),_=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},N=Array.isArray(g)?g:[g],M=N.length>0,H={padding:_,boundary:N.filter(GFe),altBoundary:M},{refs:T,floatingStyles:Y,placement:O,isPositioned:W,middlewareData:$}=EFe({strategy:"fixed",placement:k,whileElementsMounted:(...NA)=>sFe(...NA,{animationFrame:B==="always"}),elements:{reference:Q.anchor},middleware:[uFe({mainAxis:o+b,alignmentAxis:s}),a&&dFe({mainAxis:!0,crossAxis:!1,limiter:I==="partial"?pFe():void 0,...H}),a&&fFe({...H}),yFe({...H,apply:({elements:NA,rects:KA,availableWidth:EA,availableHeight:kA})=>{const{width:dA,height:qA}=KA.reference,PA=NA.floating.style;PA.setProperty("--radix-popper-available-width",`${EA}px`),PA.setProperty("--radix-popper-available-height",`${kA}px`),PA.setProperty("--radix-popper-anchor-width",`${dA}px`),PA.setProperty("--radix-popper-anchor-height",`${qA}px`)}}),f&&wFe({element:f,padding:r}),RFe({arrowWidth:w,arrowHeight:b}),l&&mFe({strategy:"referenceHidden",...H})]}),[iA,gA]=y7A(O),tA=gD(C);fx(()=>{W&&tA?.()},[W,tA]);const nA=$.arrow?.x,rA=$.arrow?.y,QA=$.arrow?.centerOffset!==0,[DA,RA]=AA.useState();return fx(()=>{h&&RA(window.getComputedStyle(h).zIndex)},[h]),Z.jsx("div",{ref:T.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:W?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:DA,"--radix-popper-transform-origin":[$.transformOrigin?.x,$.transformOrigin?.y].join(" "),...$.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:Z.jsx(xFe,{scope:t,placedSide:iA,onArrowChange:m,arrowX:nA,arrowY:rA,shouldHideArrow:QA,children:Z.jsx(qd.div,{"data-side":iA,"data-align":gA,...E,ref:d,style:{...E.style,animation:W?void 0:"none"}})})})});d7A.displayName=ghA;var p7A="PopperArrow",FFe={top:"bottom",right:"left",bottom:"top",left:"right"},f7A=AA.forwardRef(function(A,t){const{__scopePopper:i,...o}=A,n=kFe(p7A,i),s=FFe[n.placedSide];return Z.jsx("span",{ref:n.onArrowChange,style:{position:"absolute",left:n.arrowX,top:n.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[n.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[n.placedSide],visibility:n.shouldHideArrow?"hidden":void 0},children:Z.jsx(SFe,{...o,ref:t,style:{...o.style,display:"block"}})})});f7A.displayName=p7A;function GFe(e){return e!==null}var RFe=e=>({name:"transformOrigin",options:e,fn(A){const{placement:t,rects:i,middlewareData:o}=A,s=o.arrow?.centerOffset!==0,r=s?0:e.arrowWidth,a=s?0:e.arrowHeight,[g,c]=y7A(t),I={start:"0%",center:"50%",end:"100%"}[c],l=(o.arrow?.x??0)+r/2,B=(o.arrow?.y??0)+a/2;let C="",E="";return g==="bottom"?(C=s?I:`${l}px`,E=`${-a}px`):g==="top"?(C=s?I:`${l}px`,E=`${i.floating.height+a}px`):g==="right"?(C=`${-a}px`,E=s?I:`${B}px`):g==="left"&&(C=`${i.floating.width+a}px`,E=s?I:`${B}px`),{data:{x:C,y:E}}}});function y7A(e){const[A,t="center"]=e.split("-");return[A,t]}var m7A=E7A,MFe=u7A,NFe=d7A,vFe=f7A,LFe="Portal",w7A=AA.forwardRef((e,A)=>{const{container:t,...i}=e,[o,n]=AA.useState(!1);fx(()=>n(!0),[]);const s=t||o&&globalThis?.document?.body;return s?CK.createPortal(Z.jsx(qd.div,{...i,ref:A}),s):null});w7A.displayName=LFe;function UFe(e,A){return AA.useReducer((t,i)=>A[t][i]??t,e)}var xH=e=>{const{present:A,children:t}=e,i=HFe(A),o=typeof t=="function"?t({present:i.isPresent}):AA.Children.only(t),n=Qf(i.ref,YFe(o));return typeof t=="function"||i.isPresent?AA.cloneElement(o,{ref:n}):null};xH.displayName="Presence";function HFe(e){const[A,t]=AA.useState(),i=AA.useRef(null),o=AA.useRef(e),n=AA.useRef("none"),s=e?"mounted":"unmounted",[r,a]=UFe(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return AA.useEffect(()=>{const g=PW(i.current);n.current=r==="mounted"?g:"none"},[r]),fx(()=>{const g=i.current,c=o.current;if(c!==e){const l=n.current,B=PW(g);e?a("MOUNT"):B==="none"||g?.display==="none"?a("UNMOUNT"):a(c&&l!==B?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,a]),fx(()=>{if(A){let g;const c=A.ownerDocument.defaultView??window,I=B=>{const E=PW(i.current).includes(CSS.escape(B.animationName));if(B.target===A&&E&&(a("ANIMATION_END"),!o.current)){const Q=A.style.animationFillMode;A.style.animationFillMode="forwards",g=c.setTimeout(()=>{A.style.animationFillMode==="forwards"&&(A.style.animationFillMode=Q)})}},l=B=>{B.target===A&&(n.current=PW(i.current))};return A.addEventListener("animationstart",l),A.addEventListener("animationcancel",I),A.addEventListener("animationend",I),()=>{c.clearTimeout(g),A.removeEventListener("animationstart",l),A.removeEventListener("animationcancel",I),A.removeEventListener("animationend",I)}}else a("ANIMATION_END")},[A,a]),{isPresent:["mounted","unmountSuspended"].includes(r),ref:AA.useCallback(g=>{i.current=g?getComputedStyle(g):null,t(g)},[])}}function PW(e){return e?.animationName||"none"}function YFe(e){let A=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning;return t?e.ref:(A=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=A&&"isReactWarning"in A&&A.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var chA="rovingFocusGroup.onEntryFocus",JFe={bubbles:!1,cancelable:!0},kH="RovingFocusGroup",[IhA,D7A,TFe]=k6A(kH),[KFe,S7A]=DH(kH,[TFe]),[PFe,qFe]=KFe(kH),b7A=AA.forwardRef((e,A)=>Z.jsx(IhA.Provider,{scope:e.__scopeRovingFocusGroup,children:Z.jsx(IhA.Slot,{scope:e.__scopeRovingFocusGroup,children:Z.jsx(OFe,{...e,ref:A})})}));b7A.displayName=kH;var OFe=AA.forwardRef((e,A)=>{const{__scopeRovingFocusGroup:t,orientation:i,loop:o=!1,dir:n,currentTabStopId:s,defaultCurrentTabStopId:r,onCurrentTabStopIdChange:a,onEntryFocus:g,preventScrollOnEntryFocus:c=!1,...I}=e,l=AA.useRef(null),B=Qf(A,l),C=F6A(n),[E,Q]=OEA({prop:s,defaultProp:r??null,onChange:a,caller:kH}),[h,u]=AA.useState(!1),d=gD(g),f=D7A(t),m=AA.useRef(!1),[D,w]=AA.useState(0);return AA.useEffect(()=>{const b=l.current;if(b)return b.addEventListener(chA,d),()=>b.removeEventListener(chA,d)},[d]),Z.jsx(PFe,{scope:t,orientation:i,dir:C,loop:o,currentTabStopId:E,onItemFocus:AA.useCallback(b=>Q(b),[Q]),onItemShiftTab:AA.useCallback(()=>u(!0),[]),onFocusableItemAdd:AA.useCallback(()=>w(b=>b+1),[]),onFocusableItemRemove:AA.useCallback(()=>w(b=>b-1),[]),children:Z.jsx(qd.div,{tabIndex:h||D===0?-1:0,"data-orientation":i,...I,ref:B,style:{outline:"none",...e.style},onMouseDown:ca(e.onMouseDown,()=>{m.current=!0}),onFocus:ca(e.onFocus,b=>{const k=!m.current;if(b.target===b.currentTarget&&k&&!h){const _=new CustomEvent(chA,JFe);if(b.currentTarget.dispatchEvent(_),!_.defaultPrevented){const N=f().filter(O=>O.focusable),M=N.find(O=>O.active),H=N.find(O=>O.id===E),Y=[M,H,...N].filter(Boolean).map(O=>O.ref.current);k7A(Y,c)}}m.current=!1}),onBlur:ca(e.onBlur,()=>u(!1))})})}),_7A="RovingFocusGroupItem",x7A=AA.forwardRef((e,A)=>{const{__scopeRovingFocusGroup:t,focusable:i=!0,active:o=!1,tabStopId:n,children:s,...r}=e,a=SH(),g=n||a,c=qFe(_7A,t),I=c.currentTabStopId===g,l=D7A(t),{onFocusableItemAdd:B,onFocusableItemRemove:C,currentTabStopId:E}=c;return AA.useEffect(()=>{if(i)return B(),()=>C()},[i,B,C]),Z.jsx(IhA.ItemSlot,{scope:t,id:g,focusable:i,active:o,children:Z.jsx(qd.span,{tabIndex:I?0:-1,"data-orientation":c.orientation,...r,ref:A,onMouseDown:ca(e.onMouseDown,Q=>{i?c.onItemFocus(g):Q.preventDefault()}),onFocus:ca(e.onFocus,()=>c.onItemFocus(g)),onKeyDown:ca(e.onKeyDown,Q=>{if(Q.key==="Tab"&&Q.shiftKey){c.onItemShiftTab();return}if(Q.target!==Q.currentTarget)return;const h=VFe(Q,c.orientation,c.dir);if(h!==void 0){if(Q.metaKey||Q.ctrlKey||Q.altKey||Q.shiftKey)return;Q.preventDefault();let d=l().filter(f=>f.focusable).map(f=>f.ref.current);if(h==="last")d.reverse();else if(h==="prev"||h==="next"){h==="prev"&&d.reverse();const f=d.indexOf(Q.currentTarget);d=c.loop?jFe(d,f+1):d.slice(f+1)}setTimeout(()=>k7A(d))}}),children:typeof s=="function"?s({isCurrentTabStop:I,hasTabStop:E!=null}):s})})});x7A.displayName=_7A;var WFe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ZFe(e,A){return A!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function VFe(e,A,t){const i=ZFe(e.key,t);if(!(A==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(A==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return WFe[i]}function k7A(e,A=!1){const t=document.activeElement;for(const i of e)if(i===t||(i.focus({preventScroll:A}),document.activeElement!==t))return}function jFe(e,A){return e.map((t,i)=>e[(A+i)%e.length])}var zFe=b7A,XFe=x7A,$Fe=function(e){if(typeof document>"u")return null;var A=Array.isArray(e)?e[0]:e;return A.ownerDocument.body},Qv=new WeakMap,qW=new WeakMap,OW={},lhA=0,F7A=function(e){return e&&(e.host||F7A(e.parentNode))},AGe=function(e,A){return A.map(function(t){if(e.contains(t))return t;var i=F7A(t);return i&&e.contains(i)?i:(console.error("aria-hidden",t,"in not contained inside",e,". Doing nothing"),null)}).filter(function(t){return!!t})},tGe=function(e,A,t,i){var o=AGe(A,Array.isArray(e)?e:[e]);OW[t]||(OW[t]=new WeakMap);var n=OW[t],s=[],r=new Set,a=new Set(o),g=function(I){!I||r.has(I)||(r.add(I),g(I.parentNode))};o.forEach(g);var c=function(I){!I||a.has(I)||Array.prototype.forEach.call(I.children,function(l){if(r.has(l))c(l);else try{var B=l.getAttribute(i),C=B!==null&&B!=="false",E=(Qv.get(l)||0)+1,Q=(n.get(l)||0)+1;Qv.set(l,E),n.set(l,Q),s.push(l),E===1&&C&&qW.set(l,!0),Q===1&&l.setAttribute(t,"true"),C||l.setAttribute(i,"true")}catch(h){console.error("aria-hidden: cannot operate on ",l,h)}})};return c(A),r.clear(),lhA++,function(){s.forEach(function(I){var l=Qv.get(I)-1,B=n.get(I)-1;Qv.set(I,l),n.set(I,B),l||(qW.has(I)||I.removeAttribute(i),qW.delete(I)),B||I.removeAttribute(t)}),lhA--,lhA||(Qv=new WeakMap,Qv=new WeakMap,qW=new WeakMap,OW={})}},eGe=function(e,A,t){t===void 0&&(t="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),o=$Fe(e);return o?(i.push.apply(i,Array.from(o.querySelectorAll("[aria-live], script"))),tGe(i,o,t,"aria-hidden")):function(){return null}},CD=function(){return CD=Object.assign||function(A){for(var t,i=1,o=arguments.length;i<o;i++){t=arguments[i];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(A[n]=t[n])}return A},CD.apply(this,arguments)};function G7A(e,A){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&A.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)A.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]]);return t}function iGe(e,A,t){for(var i=0,o=A.length,n;i<o;i++)(n||!(i in A))&&(n||(n=Array.prototype.slice.call(A,0,i)),n[i]=A[i]);return e.concat(n||Array.prototype.slice.call(A))}var WW="right-scroll-bar-position",ZW="width-before-scroll-bar",oGe="with-scroll-bars-hidden",nGe="--removed-body-scroll-bar-size";function BhA(e,A){return typeof e=="function"?e(A):e&&(e.current=A),e}function sGe(e,A){var t=AA.useState(function(){return{value:e,callback:A,facade:{get current(){return t.value},set current(i){var o=t.value;o!==i&&(t.value=i,t.callback(i,o))}}}})[0];return t.callback=A,t.facade}var rGe=typeof window<"u"?AA.useLayoutEffect:AA.useEffect,R7A=new WeakMap;function aGe(e,A){var t=sGe(null,function(i){return e.forEach(function(o){return BhA(o,i)})});return rGe(function(){var i=R7A.get(t);if(i){var o=new Set(i),n=new Set(e),s=t.current;o.forEach(function(r){n.has(r)||BhA(r,null)}),n.forEach(function(r){o.has(r)||BhA(r,s)})}R7A.set(t,e)},[e]),t}function gGe(e){return e}function cGe(e,A){A===void 0&&(A=gGe);var t=[],i=!1,o={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return t.length?t[t.length-1]:e},useMedium:function(n){var s=A(n,i);return t.push(s),function(){t=t.filter(function(r){return r!==s})}},assignSyncMedium:function(n){for(i=!0;t.length;){var s=t;t=[],s.forEach(n)}t={push:function(r){return n(r)},filter:function(){return t}}},assignMedium:function(n){i=!0;var s=[];if(t.length){var r=t;t=[],r.forEach(n),s=t}var a=function(){var c=s;s=[],c.forEach(n)},g=function(){return Promise.resolve().then(a)};g(),t={push:function(c){s.push(c),g()},filter:function(c){return s=s.filter(c),t}}}};return o}function IGe(e){e===void 0&&(e={});var A=cGe(null);return A.options=CD({async:!0,ssr:!1},e),A}var M7A=function(e){var A=e.sideCar,t=G7A(e,["sideCar"]);if(!A)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=A.read();if(!i)throw new Error("Sidecar medium not found");return AA.createElement(i,CD({},t))};M7A.isSideCarExport=!0;function lGe(e,A){return e.useMedium(A),M7A}var N7A=IGe(),ChA=function(){},VW=AA.forwardRef(function(e,A){var t=AA.useRef(null),i=AA.useState({onScrollCapture:ChA,onWheelCapture:ChA,onTouchMoveCapture:ChA}),o=i[0],n=i[1],s=e.forwardProps,r=e.children,a=e.className,g=e.removeScrollBar,c=e.enabled,I=e.shards,l=e.sideCar,B=e.noRelative,C=e.noIsolation,E=e.inert,Q=e.allowPinchZoom,h=e.as,u=h===void 0?"div":h,d=e.gapMode,f=G7A(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),m=l,D=aGe([t,A]),w=CD(CD({},f),o);return AA.createElement(AA.Fragment,null,c&&AA.createElement(m,{sideCar:N7A,removeScrollBar:g,shards:I,noRelative:B,noIsolation:C,inert:E,setCallbacks:n,allowPinchZoom:!!Q,lockRef:t,gapMode:d}),s?AA.cloneElement(AA.Children.only(r),CD(CD({},w),{ref:D})):AA.createElement(u,CD({},w,{className:a,ref:D}),r))});VW.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},VW.classNames={fullWidth:ZW,zeroRight:WW};var BGe=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function CGe(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var A=BGe();return A&&e.setAttribute("nonce",A),e}function QGe(e,A){e.styleSheet?e.styleSheet.cssText=A:e.appendChild(document.createTextNode(A))}function EGe(e){var A=document.head||document.getElementsByTagName("head")[0];A.appendChild(e)}var hGe=function(){var e=0,A=null;return{add:function(t){e==0&&(A=CGe())&&(QGe(A,t),EGe(A)),e++},remove:function(){e--,!e&&A&&(A.parentNode&&A.parentNode.removeChild(A),A=null)}}},uGe=function(){var e=hGe();return function(A,t){AA.useEffect(function(){return e.add(A),function(){e.remove()}},[A&&t])}},v7A=function(){var e=uGe(),A=function(t){var i=t.styles,o=t.dynamic;return e(i,o),null};return A},dGe={left:0,top:0,right:0,gap:0},QhA=function(e){return parseInt(e||"",10)||0},pGe=function(e){var A=window.getComputedStyle(document.body),t=A[e==="padding"?"paddingLeft":"marginLeft"],i=A[e==="padding"?"paddingTop":"marginTop"],o=A[e==="padding"?"paddingRight":"marginRight"];return[QhA(t),QhA(i),QhA(o)]},fGe=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return dGe;var A=pGe(e),t=document.documentElement.clientWidth,i=window.innerWidth;return{left:A[0],top:A[1],right:A[2],gap:Math.max(0,i-t+A[2]-A[0])}},yGe=v7A(),Ev="data-scroll-locked",mGe=function(e,A,t,i){var o=e.left,n=e.top,s=e.right,r=e.gap;return t===void 0&&(t="margin"),`
|
|
5183
5183
|
.`.concat(oGe,` {
|
|
5184
5184
|
overflow: hidden `).concat(i,`;
|
|
5185
5185
|
padding-right: `).concat(r,"px ").concat(i,`;
|
|
@@ -5682,7 +5682,7 @@ test("${g} should solve problem correctly", () => {
|
|
|
5682
5682
|
// Add more specific assertions based on expected output
|
|
5683
5683
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5684
5684
|
})
|
|
5685
|
-
`,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:o,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},fct=e=>e.activeSubSolver?[e,...fct(e.activeSubSolver)]:[e],S9e=({solver:e})=>{const A=fct(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(D9e,{solver:t})]},t.constructor.name))})},b9e=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=AA.useReducer(E=>!E,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),o&&o(e))},c=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&e.solved&&o(e);return}e.step(),A()},t))},I=()=>{const E=e;if(E.getCurrentPhase&&!e.solved&&!e.failed){const Q=E.getCurrentPhase();for(;E.getCurrentPhase()===Q&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||n)return;const E=window.prompt("Step until which iteration?",`${e.iterations}`);if(E===null)return;const Q=Number(E);if(!Number.isFinite(Q)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<Q&&!e.solved&&!e.failed;)e.step();A(),e.solved&&o&&o(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,n]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(S9e,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:c,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),Z.jsx("button",{onClick:l,disabled:e.solved||e.failed||n,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&Z.jsx("button",{onClick:I,disabled:e.solved||e.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},_9e=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},x9e=(e,A)=>{const i=e.pipelineDef[A].solverName,o=_9e(e,A),n=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(o==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let c=0;o==="Completed"?c=1:o==="In Progress"&&n&&(c=n.progress??0);const I=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:n??null}},k9e=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},F9e=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},G9e=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),R9e=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=G9e(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>Z.jsxs("div",{children:[i,": ",String(o)]},i))})]})},tfA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(tfA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=tfA(i));return A},M9e=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=tfA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},N9e=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>x9e(e,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):M9e(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(k9e,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(F9e,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(R9e,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},v9e=class extends no.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function L9e({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],o=e.circles??[],n=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(Q,h)=>{typeof Q=="number"&&(Q<s&&(s=Q),Q>a&&(a=Q)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const Q of A)c(Q.x,Q.y);for(const Q of t){const h=Q.points??[];for(const u of h)c(u.x,u.y)}for(const Q of i){const h=Q.x??0,u=Q.y??0,d=Q.width??0,f=Q.height??0;c(h,u),c(h+d,u+f)}for(const Q of o){const h=Q.x??0,u=Q.y??0,d=Q.radius??1;c(h-d,u-d),c(h+d,u+d)}for(const Q of n)c(Q.x,Q.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),E=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${E}`,role:"img","aria-label":"Graphics fallback",children:[i.map((Q,h)=>Z.jsx("rect",{x:Q.x??0,y:Q.y??0,width:Q.width??0,height:Q.height??0,fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`rect-${h}`)),t.map((Q,h)=>Z.jsx("polyline",{fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1,points:(Q.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.fillColor??"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`circle-${h}`)),A.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.color??"black"},`point-${h}`)),n.map((Q,h)=>Z.jsx("text",{x:Q.x??0,y:Q.y??0,fontSize:Q.fontSize??10,fill:Q.color??"black",children:Q.text??""},`text-${h}`))]})}var U9e=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[o,n]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,o]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();n()}};return Z.jsxs("div",{children:[Z.jsx(b9e,{solver:e,triggerRender:n,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(v9e,{fallback:Z.jsx(L9e,{graphics:s}),children:Z.jsx(w9e,{graphics:s})}),a&&Z.jsx(N9e,{solver:e,onStepUntilPhase:g})]})};const H9e=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},Y9e=e=>e.toLowerCase().includes("pack")?YMe:e.toLowerCase().includes("rout")?OMe:FMe,J9e=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);H9e();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),o=AA.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=AA.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=orA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(orA).join(", ")}`,classFound:!1};try{const a=n.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[n]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const c=Y9e(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?Z.jsx(ED,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:Z.jsx(U9e,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&Z.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},yct=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{TK.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{TK.captureException(o,{error_type:i.type})}catch{}}},[t])},mct="0.0.1539",T9e={version:mct},efA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},ifA=new Map,E9=e=>{const A=ifA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},K9e=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=ifA.get(t.name);if(i)return{type:"tracked",store:e,...i};const o={connection:A.connect(t),stores:{}};return ifA.set(t.name,o),{type:"tracked",store:e,...o}},wct=(e,A={})=>(t,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(efA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(efA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,o);const{connection:c,...I}=K9e(r,g,a);let l=!0;o.setState=(E,Q,h)=>{const u=t(E,Q);if(!l)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...E9(a.name),[r]:o.getState()}),u)};const B=(...E)=>{const Q=l;l=!1,t(...E),l=Q},C=e(o.setState,i,o);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=o,c?.init(Object.fromEntries(Object.entries(I.stores).map(([E,Q])=>[E,E===I.store?C:Q.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let E=!1;const Q=o.dispatch;o.dispatch=(...h)=>{(efA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!E&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),E=!0),Q(...h)}}return c.subscribe(E=>{var Q;switch(E.type){case"ACTION":if(typeof E.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return ofA(E.payload,h=>{if(h.type==="__setState"){if(r===void 0){B(h.state);return}Object.keys(h.state).length!==1&&console.error(`
|
|
5685
|
+
`,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:o,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},fct=e=>e.activeSubSolver?[e,...fct(e.activeSubSolver)]:[e],S9e=({solver:e})=>{const A=fct(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(D9e,{solver:t})]},t.constructor.name))})},b9e=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=AA.useReducer(E=>!E,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),o&&o(e))},c=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&e.solved&&o(e);return}e.step(),A()},t))},I=()=>{const E=e;if(E.getCurrentPhase&&!e.solved&&!e.failed){const Q=E.getCurrentPhase();for(;E.getCurrentPhase()===Q&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||n)return;const E=window.prompt("Step until which iteration?",`${e.iterations}`);if(E===null)return;const Q=Number(E);if(!Number.isFinite(Q)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<Q&&!e.solved&&!e.failed;)e.step();A(),e.solved&&o&&o(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,n]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(S9e,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:c,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),Z.jsx("button",{onClick:l,disabled:e.solved||e.failed||n,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&Z.jsx("button",{onClick:I,disabled:e.solved||e.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},_9e=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},x9e=(e,A)=>{const i=e.pipelineDef[A].solverName,o=_9e(e,A),n=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(o==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let c=0;o==="Completed"?c=1:o==="In Progress"&&n&&(c=n.progress??0);const I=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:n??null}},k9e=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},F9e=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},G9e=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),R9e=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=G9e(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>Z.jsxs("div",{children:[i,": ",String(o)]},i))})]})},tfA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(tfA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=tfA(i));return A},M9e=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=tfA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},N9e=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>x9e(e,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):M9e(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(k9e,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(F9e,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(R9e,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},v9e=class extends no.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function L9e({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],o=e.circles??[],n=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(Q,h)=>{typeof Q=="number"&&(Q<s&&(s=Q),Q>a&&(a=Q)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const Q of A)c(Q.x,Q.y);for(const Q of t){const h=Q.points??[];for(const u of h)c(u.x,u.y)}for(const Q of i){const h=Q.x??0,u=Q.y??0,d=Q.width??0,f=Q.height??0;c(h,u),c(h+d,u+f)}for(const Q of o){const h=Q.x??0,u=Q.y??0,d=Q.radius??1;c(h-d,u-d),c(h+d,u+d)}for(const Q of n)c(Q.x,Q.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),E=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${E}`,role:"img","aria-label":"Graphics fallback",children:[i.map((Q,h)=>Z.jsx("rect",{x:Q.x??0,y:Q.y??0,width:Q.width??0,height:Q.height??0,fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`rect-${h}`)),t.map((Q,h)=>Z.jsx("polyline",{fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1,points:(Q.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.fillColor??"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`circle-${h}`)),A.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.color??"black"},`point-${h}`)),n.map((Q,h)=>Z.jsx("text",{x:Q.x??0,y:Q.y??0,fontSize:Q.fontSize??10,fill:Q.color??"black",children:Q.text??""},`text-${h}`))]})}var U9e=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[o,n]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,o]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();n()}};return Z.jsxs("div",{children:[Z.jsx(b9e,{solver:e,triggerRender:n,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(v9e,{fallback:Z.jsx(L9e,{graphics:s}),children:Z.jsx(w9e,{graphics:s})}),a&&Z.jsx(N9e,{solver:e,onStepUntilPhase:g})]})};const H9e=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},Y9e=e=>e.toLowerCase().includes("pack")?YMe:e.toLowerCase().includes("rout")?OMe:FMe,J9e=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);H9e();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),o=AA.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=AA.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=orA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(orA).join(", ")}`,classFound:!1};try{const a=n.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[n]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const c=Y9e(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?Z.jsx(ED,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:Z.jsx(U9e,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&Z.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},yct=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{TK.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{TK.captureException(o,{error_type:i.type})}catch{}}},[t])},mct="0.0.1540",T9e={version:mct},efA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},ifA=new Map,E9=e=>{const A=ifA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},K9e=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=ifA.get(t.name);if(i)return{type:"tracked",store:e,...i};const o={connection:A.connect(t),stores:{}};return ifA.set(t.name,o),{type:"tracked",store:e,...o}},wct=(e,A={})=>(t,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(efA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(efA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,o);const{connection:c,...I}=K9e(r,g,a);let l=!0;o.setState=(E,Q,h)=>{const u=t(E,Q);if(!l)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...E9(a.name),[r]:o.getState()}),u)};const B=(...E)=>{const Q=l;l=!1,t(...E),l=Q},C=e(o.setState,i,o);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=o,c?.init(Object.fromEntries(Object.entries(I.stores).map(([E,Q])=>[E,E===I.store?C:Q.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let E=!1;const Q=o.dispatch;o.dispatch=(...h)=>{(efA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!E&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),E=!0),Q(...h)}}return c.subscribe(E=>{var Q;switch(E.type){case"ACTION":if(typeof E.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return ofA(E.payload,h=>{if(h.type==="__setState"){if(r===void 0){B(h.state);return}Object.keys(h.state).length!==1&&console.error(`
|
|
5686
5686
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5687
5687
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5688
5688
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|