@tscircuit/runframe 0.0.1491 → 0.0.1492
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/standalone.min.js
CHANGED
|
@@ -5067,8 +5067,8 @@ ${a.join(`
|
|
|
5067
5067
|
`){h=H,u-=S.height*Q,P();continue}D=S.width*E,F.width+=D,h+=D,m!==" "&&(F.segments=F.segments.concat(S.segments))}for(F.segments.length&&P(),d=0,f=k.length;d<f;d++)F=k[d],_>F.width&&(x=_-F.width,l==="right"?F=o({x},F):l==="center"&&(F=o({x:x/2},F))),v=v.concat(F.segments);return v};A.exports=n}}),OlA=oe({"node_modules/@jscad/modeling/src/text/index.js"(t,A){A.exports={vectorChar:NZA(),vectorText:QIt()}}}),hL=oe({"node_modules/@jscad/modeling/src/utils/areAllShapesTheSameType.js"(t,A){var e=Kn(),i=qn(),o=Sg(),n=s=>{let r;for(const a of s){let g=0;if(e.isA(a)&&(g=1),i.isA(a)&&(g=2),o.isA(a)&&(g=3),r&&g!==r)return!1;r=g}return!0};A.exports=n}}),EIt=oe({"node_modules/@jscad/modeling/src/utils/degToRad.js"(t,A){var e=i=>i*.017453292519943295;A.exports=e}}),_ZA=oe({"node_modules/@jscad/modeling/src/utils/fnNumberSort.js"(t,A){var e=(i,o)=>i-o;A.exports=e}}),hIt=oe({"node_modules/@jscad/modeling/src/utils/insertSorted.js"(t,A){var e=(i,o,n)=>{let s=0,r=i.length;for(;r>s;){const a=Math.floor((s+r)/2),g=i[a];n(o,g)>0?s=a+1:r=a}i.splice(s,0,o)};A.exports=e}}),uIt=oe({"node_modules/@jscad/modeling/src/utils/radiusToSegments.js"(t,A){var{TAU:e}=Cr(),i=(o,n,s)=>{const r=n>0?o*e/n:0,a=s>0?e/s:0;return Math.ceil(Math.max(r,a,4))};A.exports=i}}),dIt=oe({"node_modules/@jscad/modeling/src/utils/radToDeg.js"(t,A){var e=i=>i*57.29577951308232;A.exports=e}}),vZA=oe({"node_modules/@jscad/modeling/src/utils/index.js"(t,A){A.exports={areAllShapesTheSameType:hL(),degToRad:EIt(),flatten:Fn(),fnNumberSort:_ZA(),insertSorted:hIt(),radiusToSegments:uIt(),radToDeg:dIt()}}}),WlA=oe({"node_modules/@jscad/modeling/src/operations/booleans/fromFakePolygons.js"(t,A){var e=ls(),i=Kn(),o=(s,r)=>{if(r.vertices.length<4)return null;const a=[],g=r.vertices.filter((B,l)=>B[2]>0?(a.push(l),!0):!1);if(g.length!==2)throw new Error("Assertion failed: fromFakePolygon: not enough points found");const I=g.map(B=>{const l=Math.round(B[0]/s)*s+0,C=Math.round(B[1]/s)*s+0;return e.fromValues(l,C)});if(e.equals(I[0],I[1]))return null;const c=a[1]-a[0];if(c===1||c===3)c===1&&I.reverse();else throw new Error("Assertion failed: fromFakePolygon: unknown index ordering");return I},n=(s,r)=>{const a=r.map(g=>o(s,g)).filter(g=>g!==null);return i.create(a)};A.exports=n}}),ZlA=oe({"node_modules/@jscad/modeling/src/operations/booleans/to3DWalls.js"(t,A){var e=uo(),i=Kn(),o=qn(),n=Xs(),s=(a,g,I)=>{const c=[e.fromVec2(e.create(),I[0],a),e.fromVec2(e.create(),I[1],a),e.fromVec2(e.create(),I[1],g),e.fromVec2(e.create(),I[0],g)];return n.create(c)},r=(a,g)=>{const c=i.toSides(g).map(l=>s(a.z0,a.z1,l));return o.create(c)};A.exports=r}}),pIt=oe({"node_modules/@jscad/modeling/src/maths/OrthoNormalBasis.js"(t,A){var e=Og(),i=ls(),o=uo(),n=function(s,r){arguments.length<2&&(r=o.orthogonal(o.create(),s)),this.v=o.normalize(o.create(),o.cross(o.create(),s,r)),this.u=o.cross(o.create(),this.v,s),this.plane=s,this.planeorigin=o.scale(o.create(),s,s[3])};n.prototype={getProjectionMatrix:function(){return e.fromValues(this.u[0],this.v[0],this.plane[0],0,this.u[1],this.v[1],this.plane[1],0,this.u[2],this.v[2],this.plane[2],0,0,0,-this.plane[3],1)},getInverseProjectionMatrix:function(){const s=o.scale(o.create(),this.plane,this.plane[3]);return e.fromValues(this.u[0],this.u[1],this.u[2],0,this.v[0],this.v[1],this.v[2],0,this.plane[0],this.plane[1],this.plane[2],0,s[0],s[1],s[2],1)},to2D:function(s){return i.fromValues(o.dot(s,this.u),o.dot(s,this.v))},to3D:function(s){const r=o.scale(o.create(),this.u,s[0]),a=o.scale(o.create(),this.v,s[1]),g=o.add(r,r,this.planeorigin);return o.add(a,a,g)}},A.exports=n}}),fIt=oe({"node_modules/@jscad/modeling/src/operations/modifiers/reTesselateCoplanarPolygons.js"(t,A){var{EPS:e}=Cr(),i=JlA(),o=ls(),n=pIt(),s=QZA(),{insertSorted:r,fnNumberSort:a}=vZA(),g=Xs(),I=c=>{if(c.length<2)return c;const B=[],l=c.length,C=g.plane(c[0]),Q=new n(C),E=[],h=[],u=new Map,d=new Map,f=new Map,m=10/e;for(let F=0;F<l;F++){const k=c[F];let v=[],_=k.vertices.length,H=-1;if(_>0){let P,J;for(let W=0;W<_;W++){let Z=Q.to2D(k.vertices[W]);const AA=Math.floor(Z[1]*m);let nA;f.has(AA)?nA=f.get(AA):f.has(AA+1)?nA=f.get(AA+1):f.has(AA-1)?nA=f.get(AA-1):(nA=Z[1],f.set(AA,Z[1])),Z=o.fromValues(Z[0],nA),v.push(Z);const gA=Z[1];(W===0||gA<P)&&(P=gA,H=W),(W===0||gA>J)&&(J=gA);let tA=d.get(gA);tA||(tA={},d.set(gA,tA)),tA[F]=!0}if(P>=J)v=[],_=0,H=-1;else{let W=u.get(P);W||(W=[],u.set(P,W)),W.push(F)}}v.reverse(),H=_-H-1,E.push(v),h.push(H)}const S=[];d.forEach((F,k)=>S.push(k)),S.sort(a);let D=[],x=[];for(let F=0;F<S.length;F++){const k=[],v=S[F],_=d.get(v);for(let P=0;P<D.length;++P){const J=D[P],W=J.polygonindex;if(_[W]){const Z=E[W],AA=Z.length;let nA=J.leftvertexindex,gA=J.rightvertexindex;for(;;){let iA=nA+1;if(iA>=AA&&(iA=0),Z[iA][1]!==v)break;nA=iA}let tA=gA-1;if(tA<0&&(tA=AA-1),Z[tA][1]===v&&(gA=tA),nA!==J.leftvertexindex&&nA===gA)D.splice(P,1),--P;else{J.leftvertexindex=nA,J.rightvertexindex=gA,J.topleft=Z[nA],J.topright=Z[gA];let iA=nA+1;iA>=AA&&(iA=0),J.bottomleft=Z[iA];let rA=gA-1;rA<0&&(rA=AA-1),J.bottomright=Z[rA]}}}let H;if(F>=S.length-1)D=[],H=null;else{H=Number(S[F+1]);const P=.5*(v+H),J=u.get(v);for(const W in J){const Z=J[W],AA=E[Z],nA=AA.length,gA=h[Z];let tA=gA;for(;;){let bA=tA+1;if(bA>=nA&&(bA=0),AA[bA][1]!==v||bA===gA)break;tA=bA}let iA=gA;for(;;){let bA=iA-1;if(bA<0&&(bA=nA-1),AA[bA][1]!==v||bA===tA)break;iA=bA}let rA=tA+1;rA>=nA&&(rA=0);let CA=iA-1;CA<0&&(CA=nA-1);const dA={polygonindex:Z,leftvertexindex:tA,rightvertexindex:iA,topleft:AA[tA],topright:AA[iA],bottomleft:AA[rA],bottomright:AA[CA]};r(D,dA,(bA,kA)=>{const YA=s(bA.topleft,bA.bottomleft,P),lA=s(kA.topleft,kA.bottomleft,P);return YA>lA?1:YA<lA?-1:0})}}for(const P in D){const J=D[P];let W=s(J.topleft,J.bottomleft,v);const Z=o.fromValues(W,v);W=s(J.topright,J.bottomright,v);const AA=o.fromValues(W,v);W=s(J.topleft,J.bottomleft,H);const nA=o.fromValues(W,H);W=s(J.topright,J.bottomright,H);const gA=o.fromValues(W,H),tA={topleft:Z,topright:AA,bottomleft:nA,bottomright:gA,leftline:i.fromPoints(i.create(),Z,nA),rightline:i.fromPoints(i.create(),gA,AA)};if(k.length>0){const iA=k[k.length-1],rA=o.distance(tA.topleft,iA.topright),CA=o.distance(tA.bottomleft,iA.bottomright);rA<e&&CA<e&&(tA.topleft=iA.topleft,tA.leftline=iA.leftline,tA.bottomleft=iA.bottomleft,k.splice(k.length-1,1))}k.push(tA)}if(F>0){const P=new Set,J=new Set;for(let W=0;W<k.length;W++){const Z=k[W];for(let AA=0;AA<x.length;AA++)if(!J.has(AA)){const nA=x[AA];if(o.distance(nA.bottomleft,Z.topleft)<e&&o.distance(nA.bottomright,Z.topright)<e){J.add(AA);const gA=i.direction(Z.leftline),tA=i.direction(nA.leftline),iA=gA[0]-tA[0],rA=i.direction(Z.rightline),CA=i.direction(nA.rightline),dA=rA[0]-CA[0],bA=Math.abs(iA)<e,kA=Math.abs(dA)<e,YA=bA||iA>=0,lA=kA||dA>=0;YA&&lA&&(Z.outpolygon=nA.outpolygon,Z.leftlinecontinues=bA,Z.rightlinecontinues=kA,P.add(AA));break}}}for(let W=0;W<x.length;W++)if(!P.has(W)){const Z=x[W];Z.outpolygon.rightpoints.push(Z.bottomright),o.distance(Z.bottomright,Z.bottomleft)>e&&Z.outpolygon.leftpoints.push(Z.bottomleft),Z.outpolygon.leftpoints.reverse();const nA=Z.outpolygon.rightpoints.concat(Z.outpolygon.leftpoints).map(tA=>Q.to3D(tA)),gA=g.fromPointsAndPlane(nA,C);gA.vertices.length&&B.push(gA)}}for(let P=0;P<k.length;P++){const J=k[P];J.outpolygon?(J.leftlinecontinues||J.outpolygon.leftpoints.push(J.topleft),J.rightlinecontinues||J.outpolygon.rightpoints.push(J.topright)):(J.outpolygon={leftpoints:[],rightpoints:[]},J.outpolygon.leftpoints.push(J.topleft),o.distance(J.topleft,J.topright)>e&&J.outpolygon.rightpoints.push(J.topright))}x=k}return B};A.exports=I}}),uL=oe({"node_modules/@jscad/modeling/src/operations/modifiers/retessellate.js"(t,A){var e=qn(),i=Xs(),{NEPS:o}=Cr(),n=fIt(),s=g=>{if(g.isRetesselated)return g;const I=e.toPolygons(g).map((C,Q)=>({vertices:C.vertices,plane:i.plane(C),index:Q})),c=r(I),B=[];c.forEach(C=>{if(Array.isArray(C)){const Q=n(C);B.push(...Q)}else B.push(C)});const l=e.create(B);return l.isRetesselated=!0,l},r=g=>{let I=[g];const c=[];for(let l=3;l>=0;l--){const C=[],Q=l===3?15e-9:o;I.forEach(E=>{E.sort(a(l,Q));let h=0;for(let u=1;u<E.length;u++)E[u].plane[l]-E[h].plane[l]>Q&&(u-h===1?c.push(E[h]):C.push(E.slice(h,u)),h=u);E.length-h===1?c.push(E[h]):C.push(E.slice(h))}),I=C}const B=[];return I.forEach(l=>{l[0]&&(B[l[0].index]=l)}),c.forEach(l=>{B[l.index]=l}),B},a=(g,I)=>(c,B)=>c.plane[g]-B.plane[g]>I?1:B.plane[g]-c.plane[g]>I?-1:0;A.exports=s}}),VlA=oe({"node_modules/@jscad/modeling/src/operations/booleans/mayOverlap.js"(t,A){var{EPS:e}=Cr(),i=BF(),o=(n,s)=>{if(n.polygons.length===0||s.polygons.length===0)return!1;const r=i(n),a=r[0],g=r[1],I=i(s),c=I[0],B=I[1];return!(c[0]-g[0]>e||a[0]-B[0]>e||c[1]-g[1]>e||a[1]-B[1]>e||c[2]-g[2]>e||a[2]-B[2]>e)};A.exports=o}}),yIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/trees/Node.js"(t,A){var e=Tm(),i=Xs(),o=class GwA{constructor(s){this.plane=null,this.front=null,this.back=null,this.polygontreenodes=[],this.parent=s}invert(){const s=[this];let r;for(let a=0;a<s.length;a++){r=s[a],r.plane&&(r.plane=e.flip(e.create(),r.plane)),r.front&&s.push(r.front),r.back&&s.push(r.back);const g=r.front;r.front=r.back,r.back=g}}clipPolygons(s,r){let a={node:this,polygontreenodes:s},g;const I=[];do{if(g=a.node,s=a.polygontreenodes,g.plane){const c=g.plane,B=[],l=[],C=r?B:l,Q=s.length;for(let h=0;h<Q;h++){const u=s[h];u.isRemoved()||u.splitByPlane(c,C,B,l,B)}g.front&&l.length>0&&I.push({node:g.front,polygontreenodes:l});const E=B.length;if(g.back&&E>0)I.push({node:g.back,polygontreenodes:B});else for(let h=0;h<E;h++)B[h].remove()}a=I.pop()}while(a!==void 0)}clipTo(s,r){let a=this;const g=[];do a.polygontreenodes.length>0&&s.rootnode.clipPolygons(a.polygontreenodes,r),a.front&&g.push(a.front),a.back&&g.push(a.back),a=g.pop();while(a!==void 0)}addPolygonTreeNodes(s){let r={node:this,polygontreenodes:s};const a=[];do{const g=r.node,I=r.polygontreenodes;if(I.length===0){r=a.pop();continue}if(!g.plane){let C=0;C=Math.floor(I.length/2);const Q=I[C].getPolygon();g.plane=i.plane(Q)}const c=[],B=[],l=I.length;for(let C=0;C<l;++C)I[C].splitByPlane(g.plane,g.polygontreenodes,B,c,B);c.length>0&&(g.front||(g.front=new GwA(g)),l===c.length&&B.length===0?g.front.polygontreenodes=c:a.push({node:g.front,polygontreenodes:c})),B.length>0&&(g.back||(g.back=new GwA(g)),l===B.length&&c.length===0?g.back.polygontreenodes=B:a.push({node:g.back,polygontreenodes:B})),r=a.pop()}while(r!==void 0)}};A.exports=o}}),wIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/trees/splitLineSegmentByPlane.js"(t,A){var e=uo(),i=(o,n,s)=>{const r=e.subtract(e.create(),s,n);let a=(o[3]-e.dot(o,n))/e.dot(o,r);return Number.isNaN(a)&&(a=0),a>1&&(a=1),a<0&&(a=0),e.scale(r,r,a),e.add(r,n,r),r};A.exports=i}}),mIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/trees/splitPolygonByPlane.js"(t,A){var{EPS:e}=Cr(),i=Tm(),o=uo(),n=Xs(),s=wIt(),r=(a,g)=>{const I={type:null,front:null,back:null},c=g.vertices,B=c.length,l=n.plane(g);if(i.equals(l,a))I.type=0;else{let C=!1,Q=!1;const E=[],h=-e;for(let u=0;u<B;u++){const d=o.dot(a,c[u])-a[3],f=d<h;E.push(f),d>e&&(C=!0),d<h&&(Q=!0)}if(!C&&!Q){const u=o.dot(a,l);I.type=u>=0?0:1}else if(!Q)I.type=2;else if(!C)I.type=3;else{I.type=4;const u=[],d=[];let f=E[0];for(let S=0;S<B;S++){const D=c[S];let x=S+1;x>=B&&(x=0);const F=E[x];if(f===F)f?d.push(D):u.push(D);else{const k=c[x],v=s(a,D,k);f?(d.push(D),d.push(v),u.push(v)):(u.push(D),u.push(v),d.push(v))}f=F}const m=e*e;if(d.length>=3){let S=d[d.length-1];for(let D=0;D<d.length;D++){const x=d[D];o.squaredDistance(x,S)<m&&(d.splice(D,1),D--),S=x}}if(u.length>=3){let S=u[u.length-1];for(let D=0;D<u.length;D++){const x=u[D];o.squaredDistance(x,S)<m&&(u.splice(D,1),D--),S=x}}u.length>=3&&(I.front=n.fromPointsAndPlane(u,l)),d.length>=3&&(I.back=n.fromPointsAndPlane(d,l))}}return I};A.exports=r}}),DIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/trees/PolygonTreeNode.js"(t,A){var{EPS:e}=Cr(),i=uo(),o=Xs(),n=mIt(),s=class $le{constructor(a,g){this.parent=a,this.children=[],this.polygon=g,this.removed=!1}addPolygons(a){if(!this.isRootNode())throw new Error("Assertion failed");const g=this;a.forEach(I=>{g.addChild(I)})}remove(){if(!this.removed){this.removed=!0,this.polygon=null;const a=this.parent.children,g=a.indexOf(this);if(g<0)throw new Error("Assertion failed");a.splice(g,1),this.parent.recursivelyInvalidatePolygon()}}isRemoved(){return this.removed}isRootNode(){return!this.parent}invert(){if(!this.isRootNode())throw new Error("Assertion failed");this.invertSub()}getPolygon(){if(!this.polygon)throw new Error("Assertion failed");return this.polygon}getPolygons(a){let g=[this];const I=[g];let c,B,l,C;for(c=0;c<I.length;++c)for(g=I[c],B=0,l=g.length;B<l;B++)C=g[B],C.polygon?a.push(C.polygon):C.children.length>0&&I.push(C.children)}splitByPlane(a,g,I,c,B){if(this.children.length){const l=[this.children];let C,Q,E,h,u;for(C=0;C<l.length;C++)for(u=l[C],Q=0,E=u.length;Q<E;Q++)h=u[Q],h.children.length>0?l.push(h.children):h._splitByPlane(a,g,I,c,B)}else this._splitByPlane(a,g,I,c,B)}_splitByPlane(a,g,I,c,B){const l=this.polygon;if(l){const C=o.measureBoundingSphere(l),Q=C[3]+e,E=C,h=i.dot(a,E)-a[3];if(h>Q)c.push(this);else if(h<-Q)B.push(this);else{const u=n(a,l);switch(u.type){case 0:g.push(this);break;case 1:I.push(this);break;case 2:c.push(this);break;case 3:B.push(this);break;case 4:if(u.front){const d=this.addChild(u.front);c.push(d)}if(u.back){const d=this.addChild(u.back);B.push(d)}break}}}}addChild(a){const g=new $le(this,a);return this.children.push(g),g}invertSub(){let a=[this];const g=[a];let I,c,B,l;for(I=0;I<g.length;I++)for(a=g[I],c=0,B=a.length;c<B;c++)l=a[c],l.polygon&&(l.polygon=o.invert(l.polygon)),l.children.length>0&&g.push(l.children)}recursivelyInvalidatePolygon(){this.polygon=null,this.parent&&this.parent.recursivelyInvalidatePolygon()}clear(){let a=[this];const g=[a];for(let I=0;I<g.length;++I){a=g[I];const c=a.length;for(let B=0;B<c;B++){const l=a[B];l.polygon&&(l.polygon=null),l.parent&&(l.parent=null),l.children.length>0&&g.push(l.children),l.children=[]}}}toString(){let a="",g=[this];const I=[g];let c,B,l,C;for(c=0;c<I.length;++c){g=I[c];const Q=" ".repeat(c);for(B=0,l=g.length;B<l;B++)C=g[B],a+=`${Q}PolygonTreeNode (${C.isRootNode()}): ${C.children.length}`,C.polygon?a+=`
|
|
5068
5068
|
${Q}polygon: ${C.polygon.vertices}
|
|
5069
5069
|
`:a+=`
|
|
5070
|
-
`,C.children.length>0&&I.push(C.children)}return a}};A.exports=s}}),SIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,A){var e=yIt(),i=DIt(),o=class{constructor(n){this.polygonTree=new i,this.rootnode=new e(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}}),jlA=oe({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,A){A.exports={Tree:SIt()}}}),bIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,A){var e=qn(),i=VlA(),{Tree:o}=jlA(),n=(s,r)=>{if(!i(s,r))return e.create();const a=new o(e.toPolygons(s)),g=new o(e.toPolygons(r));a.invert(),g.clipTo(a),g.invert(),a.clipTo(g),g.clipTo(a),a.addPolygons(g.allPolygons()),a.invert();const I=a.allPolygons();return e.create(I)};A.exports=n}}),UZA=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,A){var e=Fn(),i=uL(),o=bIt(),n=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=o(r,a)}),r=i(r),r};A.exports=n}}),xIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,A){var e=Fn(),i=qn(),o=_x(),n=WlA(),s=ZlA(),r=UZA(),a=(...g)=>{g=e(g);const I=g.map(l=>s({z0:-1,z1:1},l)),c=r(I),B=o(c);return n(B,i.toPolygons(c))};A.exports=a}}),kIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,A){var e=Fn(),i=hL(),o=Kn(),n=qn(),s=xIt(),r=UZA(),a=(...g)=>{if(g=e(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 I=g[0];return o.isA(I)?s(g):n.isA(I)?r(g):I};A.exports=a}}),GIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,A){var e=uo(),i=_x(),o=qn(),n=g=>g.sort((I,c)=>I-c).filter((I,c,B)=>!c||I!==B[c-1]),s=(g,I,c)=>{const B=`${I}`,l=g.get(B);l===void 0?g.set(B,[c]):l.push(c)},r=(g,I)=>{const c=`${I}`;return g.get(c)},a=g=>{const I=i(g),c=o.toPolygons(g),B=c.length,l=new Map,C=e.create();c.forEach((d,f)=>{d.vertices.forEach(m=>{s(l,e.snap(C,m,I),f)})});const Q=c.map(d=>{let f=[];return d.vertices.forEach(m=>{f=f.concat(r(l,e.snap(C,m,I)))}),{e:1,d:n(f)}});l.clear();let E=0;const h=Q.length;for(let d=0;d<h;d++){const f=Q[d];if(f.e>0){const m=new Array(B);m[d]=!0;do E=0,m.forEach((S,D)=>{const x=Q[D];if(x.e>0){x.e=-1;for(let F=0;F<x.d.length;F++)m[x.d[F]]=!0;E++}});while(E>0);f.indexes=m}}const u=[];for(let d=0;d<h;d++)if(Q[d].indexes){const f=[];Q[d].indexes.forEach((m,S)=>f.push(c[S])),u.push(o.create(f))}return u};A.exports=a}}),FIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,A){var e=Fn(),i=qn(),o=GIt(),n=(...s)=>{if(s=e(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}}),RIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,A){var e=qn(),i=VlA(),{Tree:o}=jlA(),n=(s,r)=>{if(!i(s,r))return e.clone(s);const a=new o(e.toPolygons(s)),g=new o(e.toPolygons(r));a.invert(),a.clipTo(g),g.clipTo(a,!0),a.addPolygons(g.allPolygons()),a.invert();const I=a.allPolygons();return e.create(I)};A.exports=n}}),LZA=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,A){var e=Fn(),i=uL(),o=RIt(),n=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=o(r,a)}),r=i(r),r};A.exports=n}}),MIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,A){var e=Fn(),i=qn(),o=_x(),n=WlA(),s=ZlA(),r=LZA(),a=(...g)=>{g=e(g);const I=g.map(l=>s({z0:-1,z1:1},l)),c=r(I),B=o(c);return n(B,i.toPolygons(c))};A.exports=a}}),NIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,A){var e=Fn(),i=hL(),o=Kn(),n=qn(),s=MIt(),r=LZA(),a=(...g)=>{if(g=e(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 I=g[0];return o.isA(I)?s(g):n.isA(I)?r(g):I};A.exports=a}}),HZA=oe({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,A){var e=qn(),i=VlA(),{Tree:o}=jlA(),n=(r,a)=>{if(!i(r,a))return s(r,a);const g=new o(e.toPolygons(r)),I=new o(e.toPolygons(a));g.clipTo(I,!1),I.clipTo(g),I.invert(),I.clipTo(g),I.invert();const c=g.allPolygons().concat(I.allPolygons());return e.create(c)},s=(r,a)=>{let g=e.toPolygons(r);return g=g.concat(e.toPolygons(a)),e.create(g)};A.exports=n}}),YZA=oe({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,A){var e=Fn(),i=uL(),o=HZA(),n=(...s)=>{s=e(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}}),JZA=oe({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,A){var e=Fn(),i=qn(),o=_x(),n=WlA(),s=ZlA(),r=YZA(),a=(...g)=>{g=e(g);const I=g.map(l=>s({z0:-1,z1:1},l)),c=r(I),B=o(c);return n(B,i.toPolygons(c))};A.exports=a}}),zlA=oe({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,A){var e=Fn(),i=hL(),o=Kn(),n=qn(),s=JZA(),r=YZA(),a=(...g)=>{if(g=e(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 I=g[0];return o.isA(I)?s(g):n.isA(I)?r(g):I};A.exports=a}}),s_=oe({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,A){A.exports={intersect:kIt(),scission:FIt(),subtract:NIt(),union:zlA()}}}),Y5=oe({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,A){var{EPS:e,TAU:i}=Cr(),o=EZA(),n=JlA(),s=ls(),r=U5(),a=(g,I)=>{const c={delta:1,corners:"edge",closed:!1,segments:16};let{delta:B,corners:l,closed:C,segments:Q}=Object.assign({},c,g);if(Math.abs(B)<e)return I;let E=g.closed?r(I):1;E===0&&(E=1);const h=E>0&&B>=0||E<0&&B<0;B=Math.abs(B);let u=null,d=[];const f=[],m=s.create(),S=I.length;for(let D=0;D<S;D++){const x=(D+1)%S,F=I[D],k=I[x];h?s.subtract(m,F,k):s.subtract(m,k,F),s.normal(m,m),s.normalize(m,m),s.scale(m,m,B);const v=s.add(s.create(),F,m),_=s.add(s.create(),k,m),H=[v,_];if(u!=null&&(C||!C&&x!==0)){const P=o(u[0],u[1],H[0],H[1]);P?(d.pop(),H[0]=P):f.push({c:F,s0:u,s1:H})}u=[v,_],!(x===0&&!C)&&(d.push(H[0]),d.push(H[1]))}if(C&&u!=null){const D=d[0],x=d[1],F=o(u[0],u[1],D,x);if(F)d[0]=F,d.pop();else{const k=I[0],v=[D,x];f.push({c:k,s0:u,s1:v})}}if(l==="edge"){const D=new Map;d.forEach((k,v)=>D.set(k,v));const x=n.create(),F=n.create();f.forEach(k=>{n.fromPoints(x,k.s0[0],k.s0[1]),n.fromPoints(F,k.s1[0],k.s1[1]);const v=n.intersectPointOfLines(x,F);if(Number.isFinite(v[0])&&Number.isFinite(v[1])){const _=k.s0[1],H=D.get(_);d[H]=v,d[(H+1)%d.length]=void 0}else{const _=k.s1[0],H=D.get(_);d[H]=void 0}}),d=d.filter(k=>k!==void 0)}if(l==="round"){let D=Math.floor(Q/4);const x=s.create();f.forEach(F=>{let k=s.angle(s.subtract(x,F.s1[0],F.c));if(k-=s.angle(s.subtract(x,F.s0[1],F.c)),h&&k<0&&(k=k+Math.PI,k<0&&(k=k+Math.PI)),!h&&k>0&&(k=k-Math.PI,k>0&&(k=k-Math.PI)),k!==0){D=Math.floor(Q*(Math.abs(k)/i));const v=k/D,_=s.angle(s.subtract(x,F.s0[1],F.c)),H=[];for(let P=1;P<D;P++){const J=_+v*P,W=s.fromAngleRadians(s.create(),J);s.scale(W,W,B),s.add(W,W,F.c),H.push(W)}if(H.length>0){const P=F.s0[1];let J=d.findIndex(W=>s.equals(P,W));J=(J+1)%d.length,d.splice(J,0,...H)}}else{const v=F.s1[0],_=d.findIndex(H=>s.equals(v,H));d.splice(_,1)}})}return d};A.exports=a}}),_It=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,A){var e=Kn(),i=Y5(),o=(n,s)=>{const r={delta:1,corners:"edge",segments:16},{delta:a,corners:g,segments:I}=Object.assign({},r,n);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const l=e.toOutlines(s).map(C=>(n={delta:a,corners:g,closed:!0,segments:I},i(n,C))).reduce((C,Q)=>C.concat(e.toSides(e.fromPoints(Q))),[]);return e.create(l)};A.exports=o}}),vIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,A){var e=Og(),i=uo(),o=qn(),n=Xs(),s=(r,a)=>{i.dot(n.plane(a),r)>0&&(a=n.invert(a));const I=[a],c=n.transform(e.fromTranslation(e.create(),r),a),B=a.vertices.length;for(let l=0;l<B;l++){const C=l<B-1?l+1:0,Q=n.create([a.vertices[l],c.vertices[l],c.vertices[C],a.vertices[C]]);I.push(Q)}return I.push(n.invert(c)),o.create(I)};A.exports=s}}),UIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,A){var{EPS:e,TAU:i}=Cr(),o=Og(),n=uo(),s=_ZA(),r=qn(),a=Xs(),g=xZA(),I=uL(),c=HZA(),B=vIt(),l=(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(),S=f<m?`${f},${m}`:`${m},${f}`;if(h.has(S))h.get(S)[1].push(d);else{const D=[u,[d]];h.set(S,D)}},Q=(h,u)=>{h.findIndex(f=>f===u)<0&&h.push(u)},E=(h,u)=>{const d={delta:1,segments:12},{delta:f,segments:m}=Object.assign({},d,h);let S=r.create();const D=new Map,x=new Map,F=n.create(),k=n.create();return r.toPolygons(u).forEach((_,H)=>{const P=n.scale(n.create(),a.plane(_),2*f),J=a.transform(o.fromTranslation(o.create(),n.scale(n.create(),P,-.5)),_),W=B(P,J);S=c(S,W);const Z=_.vertices;for(let AA=0;AA<Z.length;AA++){l(D,Z[AA],a.plane(_));const nA=(AA+1)%Z.length,gA=[Z[AA],Z[nA]];C(x,gA,a.plane(_))}}),x.forEach(_=>{const H=_[0],P=_[1],J=H[0],W=H[1],Z=n.subtract(n.create(),W,J);n.normalize(Z,Z);const AA=P[0],nA=n.cross(n.create(),AA,Z);let gA=[];for(let YA=0;YA<m;YA++)Q(gA,YA*i/m);for(let YA=0,lA=P.length;YA<lA;YA++){const RA=P[YA],uA=n.dot(nA,RA),KA=n.dot(AA,RA);let $A=Math.atan2(uA,KA);$A<0&&($A+=i),Q(gA,$A),$A=Math.atan2(-uA,-KA),$A<0&&($A+=i),Q(gA,$A)}gA=gA.sort(s);const tA=gA.length;let iA,rA;const CA=[],dA=[],bA=[];for(let YA=-1;YA<tA;YA++){const lA=gA[YA<0?YA+tA:YA],RA=Math.sin(lA),uA=Math.cos(lA);n.scale(F,AA,uA*f),n.scale(k,nA,RA*f),n.add(F,F,k);const KA=n.add(n.create(),J,F),$A=n.add(n.create(),W,F);let re=!1;if(YA>=0&&n.distance(KA,iA)<e&&(re=!0),!re){if(YA>=0){CA.push(KA),dA.push($A);const yA=[rA,$A,KA,iA],qA=a.create(yA);bA.push(qA)}iA=KA,rA=$A}}dA.reverse(),bA.push(a.create(CA)),bA.push(a.create(dA));const kA=r.create(bA);S=c(S,kA)}),D.forEach(_=>{const H=_[0],P=_[1],J=P[0];let W=null,Z=0;for(let tA=1;tA<P.length;tA++){const iA=P[tA],rA=n.cross(F,J,iA),CA=n.length(rA);CA>.05&&CA>Z&&(Z=CA,W=iA)}W||(W=n.orthogonal(F,J));const AA=n.cross(F,J,W);n.normalize(AA,AA);const nA=n.cross(k,AA,J),gA=g({center:[H[0],H[1],H[2]],radius:f,segments:m,axes:[J,AA,nA]});S=c(S,gA)}),I(S)};A.exports=E}}),LIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,A){var e=qn(),i=zlA(),o=UIt(),n=(s,r)=>{const a={delta:1,corners:"round",segments:12},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(I!=="round")throw new Error('corners must be "round" for 3D geometries');if(e.toPolygons(r).length===0)throw new Error("the given geometry cannot be empty");s={delta:g,corners:I,segments:c};const l=o(s,r);return i(r,l)};A.exports=n}}),HIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,A){var e=U5(),i=ls(),o=Kn(),n=Sg(),s=Y5(),r=I=>{let{external:c,internal:B}=I;e(c)<0?c=c.reverse():B=B.reverse();const l=n.fromPoints({closed:!0},c),C=n.fromPoints({closed:!0},B),Q=o.toSides(o.fromPoints(n.toPoints(l))),E=o.toSides(o.fromPoints(n.toPoints(C)));return Q.push(...E),o.create(Q)},a=(I,c,B,l)=>{const{points:C,external:Q,internal:E}=I,h=Math.floor(c/2),u=[],d=[];if(B==="round"&&h>0){const m=Math.PI/h,S=C[C.length-1],D=i.angle(i.subtract(i.create(),Q[Q.length-1],S)),x=C[0],F=i.angle(i.subtract(i.create(),E[0],x));for(let k=1;k<h;k++){let v=D+m*k,_=i.fromAngleRadians(i.create(),v);i.scale(_,_,l),i.add(_,_,S),u.push(_),v=F+m*k,_=i.fromAngleRadians(i.create(),v),i.scale(_,_,l),i.add(_,_,x),d.push(_)}}const f=[];return f.push(...Q,...u,...E.reverse(),...d),o.fromPoints(f)},g=(I,c)=>{I=Object.assign({},{delta:1,corners:"edge",segments:16},I);const{delta:l,corners:C,segments:Q}=I;if(l<=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 E=c.isClosed,h=n.toPoints(c);if(h.length===0)throw new Error("the given geometry cannot be empty");const u={points:h,external:s({delta:l,corners:C,segments:Q,closed:E},h),internal:s({delta:-l,corners:C,segments:Q,closed:E},h)};return c.isClosed?r(u):a(u,Q,C,l)};A.exports=g}}),XlA=oe({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,A){var e=Fn(),i=Kn(),o=qn(),n=Sg(),s=_It(),r=LIt(),a=HIt(),g=(I,...c)=>{if(c=e(c),c.length===0)throw new Error("wrong number of arguments");const B=c.map(l=>n.isA(l)?a(I,l):i.isA(l)?s(I,l):o.isA(l)?r(I,l):l);return B.length===1?B[0]:B};A.exports=g}}),YIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,A){var e=Kn(),i=vlA(),o=Y5(),n=(s,r)=>{const a={delta:1,corners:"edge",segments:0},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(!(I==="edge"||I==="chamfer"||I==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const B=e.toOutlines(r),C=B.map(Q=>(s={delta:B.reduce((u,d)=>u+i.arePointsInside(Q,i.create(d)),0)%2===0?g:-g,corners:I,closed:!0,segments:c},o(s,Q))).reduce((Q,E)=>Q.concat(e.toSides(e.fromPoints(E))),[]);return e.create(C)};A.exports=n}}),JIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,A){var e=Sg(),i=Y5(),o=(n,s)=>{const r={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:a,corners:g,closed:I,segments:c}=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:I,segments:c};const B=i(n,e.toPoints(s));return e.fromPoints({closed:I},B)};A.exports=o}}),TIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,A){var e=Fn(),i=Kn(),o=Sg(),n=YIt(),s=JIt(),r=(a,...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");const I=g.map(c=>o.isA(c)?s(a,c):i.isA(c)?n(a,c):c);return I.length===1?I[0]:I};A.exports=r}}),TZA=oe({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,A){A.exports={expand:XlA(),offset:TIt()}}}),J5=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,A){var e=Og(),i=uo(),o=Kn(),n=n_(),s=H5(),r=(a,g)=>{const I={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:c,twistAngle:B,twistSteps:l,repair:C}=Object.assign({},I,a);if(l<1)throw new Error("twistSteps must be 1 or more");B===0&&(l=1);const Q=i.clone(c),E=o.toSides(g);if(E.length===0)throw new Error("the given geometry cannot be empty");const h=n.fromSides(E);Q[2]<0&&n.reverse(h,h);const u=e.create(),d=(f,m,S)=>{const D=m/l*B,x=i.scale(i.create(),Q,m/l);return e.multiply(u,e.fromZRotation(u,D),e.fromTranslation(e.create(),x)),n.transform(u,S)};return a={numberOfSlices:l+1,capStart:!0,capEnd:!0,repair:C,callback:d},s(a,h)};A.exports=r}}),KIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,A){var e=Kn(),i=Sg(),o=J5(),n=(s,r)=>{if(!r.isClosed)throw new Error("extruded path must be closed");const a=i.toPoints(r),g=e.fromPoints(a);return o(s,g)};A.exports=n}}),qIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,A){var e=Fn(),i=Kn(),o=Sg(),n=J5(),s=KIt(),r=(a,...g)=>{const I={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:c,twistAngle:B,twistSteps:l,repair:C}=Object.assign({},I,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");a={offset:[0,0,c],twistAngle:B,twistSteps:l,repair:C};const Q=g.map(E=>o.isA(E)?s(a,E):i.isA(E)?n(a,E):E);return Q.length===1?Q[0]:Q};A.exports=r}}),PIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,A){var e=Sg(),i=XlA(),o=J5(),n=(s,r)=>{const a={size:1,height:1},{size:g,height:I}=Object.assign({},a,s);if(s.delta=g,s.offset=[0,0,I],e.toPoints(r).length===0)throw new Error("the given geometry cannot be empty");const B=i(s,r);return o(s,B)};A.exports=n}}),OIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,A){var{area:e}=lL(),i=Kn(),o=Sg(),n=XlA(),s=J5(),r=(a,g)=>{const I={size:1,height:1},{size:c,height:B}=Object.assign({},I,a);a.delta=c,a.offset=[0,0,B];const l=i.toOutlines(g);if(l.length===0)throw new Error("the given geometry cannot be empty");const Q=l.map(h=>(e(h)<0&&h.reverse(),n(a,o.fromPoints({closed:!0},h)))).reduce((h,u)=>h.concat(i.toSides(u)),[]),E=i.create(Q);return s(a,E)};A.exports=r}}),WIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,A){var e=Fn(),i=Kn(),o=Sg(),n=PIt(),s=OIt(),r=(a,...g)=>{const I={size:1,height:1},{size:c,height:B}=Object.assign({},I,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(c<=0)throw new Error("size must be positive");if(B<=0)throw new Error("height must be positive");const l=g.map(C=>o.isA(C)?n(a,C):i.isA(C)?s(a,C):C);return l.length===1?l[0]:l};A.exports=r}}),ZIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,A){var{TAU:e}=Cr(),i=Og(),o=Kn(),n=H5(),s=n_(),r=(a,g)=>{const I={angle:e,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:c,startAngle:B,pitch:l,height:C,endOffset:Q,segmentsPerRotation:E}=Object.assign({},I,a);if(C!=0&&(l=C/(c/e)),E<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(k=>k[0][0]>=0);let f=s.fromSides(u);d.length===0&&(f=s.reverse(f));const m=Math.round(E/e*Math.abs(c)),S=m>=2?m:2,D=i.create(),x=i.create(),F=(k,v,_)=>{const H=B+c/S*v,P=Q/S*v,J=(H-B)/e*l;return i.multiply(D,i.fromTranslation(i.create(),[P,0,J*Math.sign(c)]),i.fromXRotation(i.create(),-e/4*Math.sign(c))),i.multiply(x,i.fromZRotation(i.create(),H),D),s.transform(x,_)};return n({numberOfSlices:S+1,callback:F},f)};A.exports=r}}),VIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,A){var e=Fn(),i=YlA(),o=Tm(),n=Og(),s=Kn(),r=qn(),a=Xs(),g=_x(),I=JZA(),c=(l,C)=>{const Q=o.fromNormalAndPoint(o.create(),l.axis,l.origin);if(Number.isNaN(Q[0])||Number.isNaN(Q[1])||Number.isNaN(Q[2])||Number.isNaN(Q[3]))throw new Error("project: invalid axis or origin");const E=g(C),h=E*E*Math.sqrt(3)/4;if(E===0)return s.create();const u=r.toPolygons(C);let d=[];for(let m=0;m<u.length;m++){const S=u[m].vertices.map(F=>o.projectionOfPoint(Q,F)),D=a.create(S),x=a.plane(D);i(Q,x)&&(a.measureArea(D)<h||d.push(D))}if(!i(Q,[0,0,1])){const m=n.fromVectorRotation(n.create(),Q,[0,0,1]);d=d.map(S=>a.transform(m,S))}d=d.sort((m,S)=>a.measureArea(S)-a.measureArea(m));const f=d.map(m=>s.fromPoints(m.vertices));return I(f)},B=(l,...C)=>{const Q={axis:[0,0,1],origin:[0,0,0]},{axis:E,origin:h}=Object.assign({},Q,l);if(C=e(C),C.length===0)throw new Error("wrong number of arguments");l={axis:E,origin:h};const u=C.map(d=>r.isA(d)?c(l,d):d);return u.length===1?u[0]:u};A.exports=B}}),dL=oe({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,A){A.exports={extrudeFromSlices:H5(),extrudeLinear:qIt(),extrudeRectangular:WIt(),extrudeRotate:RZA(),extrudeHelical:ZIt(),project:VIt(),slice:n_()}}}),$lA=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,A){var e=ls(),i=s=>{let r=e.fromValues(1/0,1/0);s.forEach(I=>{(I[1]<r[1]||I[1]===r[1]&&I[0]<r[0])&&(r=I)});const a=[];s.forEach(I=>{const c=n(I[1]-r[1],I[0]-r[0]),B=e.squaredDistance(I,r);a.push({point:I,angle:c,distSq:B})}),a.sort((I,c)=>I.angle!==c.angle?I.angle-c.angle:I.distSq-c.distSq);const g=[];return a.forEach(I=>{let c=g.length;for(;c>1&&o(g[c-2],g[c-1],I.point)<=Number.EPSILON;)g.pop(),c=g.length;g.push(I.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}}),ACA=oe({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,A){var e=Kn(),i=qn(),o=Sg(),n=s=>{const r=new Set,a=[],g=I=>{const c=I.toString();r.has(c)||(a.push(I),r.add(c))};return s.forEach(I=>{e.isA(I)?e.toPoints(I).forEach(g):i.isA(I)?i.toPoints(I).forEach(c=>c.forEach(g)):o.isA(I)&&o.toPoints(I).forEach(g)}),a};A.exports=n}}),jIt=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,A){var e=Fn(),i=Sg(),o=$lA(),n=ACA(),s=(...r)=>{r=e(r);const a=n(r),g=o(a);return i.fromPoints({closed:!0},g)};A.exports=s}}),zIt=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,A){var e=Fn(),i=Kn(),o=$lA(),n=ACA(),s=(...r)=>{r=e(r);const a=n(r),g=o(a);return g.length<3?i.create():i.fromPoints(g)};A.exports=s}}),KZA=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,A){var e=Xs(),i=JWA(),o=n=>i(n,{skipTriangulation:!0}).map(a=>{const g=a.map(I=>n[I]);return e.create(g)});A.exports=o}}),XIt=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,A){var e=Fn(),i=qn(),o=ACA(),n=KZA(),s=(...r)=>{r=e(r);const a=o(r);return a.length===0?i.create():i.create(n(a))};A.exports=s}}),qZA=oe({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,A){var e=Fn(),i=hL(),o=Kn(),n=qn(),s=Sg(),r=jIt(),a=zIt(),g=XIt(),I=(...c)=>{if(c=e(c),c.length===0)throw new Error("wrong number of arguments");if(!i(c))throw new Error("only hulls of the same type are supported");const B=c[0];return s.isA(B)?r(c):o.isA(B)?a(c):n.isA(B)?g(c):B};A.exports=I}}),$It=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,A){var e=Fn(),i=zlA(),o=qZA(),n=(...s)=>{if(s=e(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}}),Act=oe({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,A){A.exports={hull:qZA(),hullChain:$It(),hullPoints2:$lA(),hullPoints3:KZA()}}}),PZA=oe({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,A){var e=uo(),i=Xs(),o=(s,r)=>{const a=Math.abs(i.measureArea(r));return Number.isFinite(a)&&a>s},n=(s,r)=>{let a=r.map(I=>{const c=I.vertices.map(C=>e.snap(e.create(),C,s)),B=[];for(let C=0;C<c.length;C++){const Q=(C+1)%c.length;e.equals(c[C],c[Q])||B.push(c[C])}const l=i.create(B);return I.color&&(l.color=I.color),l});const g=s*s*Math.sqrt(3)/4;return a=a.filter(I=>o(g,I)),a};A.exports=n}}),ect=oe({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,A){var e=YlA(),i=uo(),o=Xs(),n=h=>{const u=o.toPoints(h),d=[];for(let f=0;f<u.length;f++){const m=(f+1)%u.length,S={v1:u[f],v2:u[m]};d.push(S)}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,S=u.next.v2;const D=B(f,m,S,d);f=u.prev.v1,m=u.prev.v2,S=h.next.v2;const x=B(f,m,S,d);return[D,x]},I=i.create(),c=i.create(),B=(h,u,d,f)=>{const m=i.subtract(I,u,h),S=i.subtract(c,d,u);return i.cross(m,m,S),i.dot(m,f)},l=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 S=d.shift(),D=n(S);for(let x=0;x<D.length;x++){const F=D[x],k=a(f,F);if(k){const v=g(F,k,u);if(v[0]>=0&&v[1]>=0){const _=k.next,H=F.next;F.prev.next=k.next,F.next.prev=k.prev,k.prev.next=F.next,k.next.prev=F.prev,F.v1=null,F.v2=null,F.next=null,F.prev=null,r(f,k),k.v1=null,k.v2=null,k.next=null,k.prev=null;const P=(J,W,Z)=>{const AA={v1:Z.v1,v2:W.v2,next:W.next,prev:Z.prev};Z.prev.next=AA,W.next.prev=AA,r(J,W),W.v1=null,W.v2=null,W.next=null,W.prev=null,r(J,Z),Z.v1=null,Z.v2=null,Z.next=null,Z.prev=null};v[0]===0&&P(f,_,_.prev),v[1]===0&&P(f,H,H.prev)}}else F.next&&s(f,F)}}const m=[];return f.forEach(S=>{const D=l(S);D&&m.push(D)}),f.clear(),m},Q=(h,u)=>Math.abs(h[3]-u[3])<15e-8?e(h,u):!1,E=(h,u)=>{const d=[];u.forEach(m=>{const S=d.find(D=>Q(D[0],o.plane(m)));S?S[1].push(m):d.push([o.plane(m),[m]])});let f=[];return d.forEach(m=>{const S=m[1],D=C(S);f=f.concat(D)}),f};A.exports=E}}),tct=oe({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,A){var e=Cr(),i=uo(),o=Xs(),n=g=>`${g}`,s=(g,I,c,B,l,C)=>{const Q=n(B),E=n(l),h=`${Q}/${E}`,u=`${E}/${Q}`;if(g.has(u))return r(g,I,c,l,B,null),null;const d={vertex0:B,vertex1:l,polygonindex:C};return g.has(h)?g.get(h).push(d):g.set(h,[d]),I.has(Q)?I.get(Q).push(h):I.set(Q,[h]),c.has(E)?c.get(E).push(h):c.set(E,[h]),h},r=(g,I,c,B,l,C)=>{const Q=n(B),E=n(l),h=`${Q}/${E}`;let u=-1;const d=g.get(h);for(let f=0;f<d.length;f++){const m=d[f];let S=n(m.vertex0);if(S===Q&&(S=n(m.vertex1),S===E&&!(C!==null&&m.polygonindex!==C))){u=f;break}}d.splice(u,1),d.length===0&&g.delete(h),u=I.get(Q).indexOf(h),I.get(Q).splice(u,1),I.get(Q).length===0&&I.delete(Q),u=c.get(E).indexOf(h),c.get(E).splice(u,1),c.get(E).length===0&&c.delete(E)},a=g=>{const I=new Map;for(let c=0;c<g.length;c++){const B=g[c],l=B.vertices.length;if(l>=3){let C=B.vertices[0],Q=n(C);for(let E=0;E<l;E++){let h=E+1;h===l&&(h=0);const u=B.vertices[h],d=n(u),f=`${Q}/${d}`,m=`${d}/${Q}`;if(I.has(m)){const S=I.get(m);S.splice(-1,1),S.length===0&&I.delete(m)}else{const S={vertex0:C,vertex1:u,polygonindex:c};I.has(f)?I.get(f).push(S):I.set(f,[S])}C=u,Q=d}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(I.size>0){const c=new Map,B=new Map,l=new Map;for(const[Q,E]of I)l.set(Q,!0),E.forEach(h=>{const u=n(h.vertex0),d=n(h.vertex1);c.has(u)?c.get(u).push(Q):c.set(u,[Q]),B.has(d)?B.get(d).push(Q):B.set(d,[Q])});const C=g.slice(0);for(;I.size!==0;){for(const E of I.keys())l.set(E,!0);let Q=!1;for(;;){const E=Array.from(l.keys());if(E.length===0)break;const h=E[0];let u=!0;if(I.has(h)){const f=I.get(h)[0];for(let m=0;m<2;m++){const S=m===0?f.vertex0:f.vertex1,D=m===0?f.vertex1:f.vertex0,x=n(S),F=n(D);let k=[];m===0?B.has(x)&&(k=B.get(x)):c.has(x)&&(k=c.get(x));for(let v=0;v<k.length;v++){const _=k[v],H=I.get(_)[0],P=m===0?H.vertex0:H.vertex1;if(m===0?H.vertex1:H.vertex0,n(P)===F){r(I,c,B,S,D,null),r(I,c,B,D,S,null),u=!1,m=2,Q=!0;break}else{const W=S,Z=D,AA=P,nA=i.subtract(i.create(),AA,W),gA=i.dot(i.subtract(i.create(),Z,W),nA)/i.dot(nA,nA);if(gA>0&&gA<1){const tA=i.scale(i.create(),nA,gA);if(i.add(tA,tA,W),i.squaredDistance(tA,Z)<e.EPS*e.EPS){const rA=H.polygonindex,CA=C[rA],dA=n(H.vertex1);let bA=-1;for(let uA=0;uA<CA.vertices.length;uA++)if(n(CA.vertices[uA])===dA){bA=uA;break}const kA=CA.vertices.slice(0);kA.splice(bA,0,D);const YA=o.create(kA);C[rA]=YA,r(I,c,B,H.vertex0,H.vertex1,rA);const lA=s(I,c,B,H.vertex0,D,rA),RA=s(I,c,B,D,H.vertex1,rA);lA!==null&&l.set(lA,!0),RA!==null&&l.set(RA,!0),u=!1,m=2,Q=!0;break}}}}}}u&&l.delete(h)}if(!Q)break}g=C}return I.clear(),g};A.exports=a}}),ict=oe({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,A){var e=uo(),i=Xs(),o=(s,r,a)=>{const g=r.vertices.length;if(g>3){if(g>4){const B=[0,0,0];r.vertices.forEach(l=>e.add(B,B,l)),e.snap(B,e.divide(B,B,[g,g,g]),s);for(let l=0;l<g;l++){const C=i.create([B,r.vertices[l],r.vertices[(l+1)%g]]);r.color&&(C.color=r.color),a.push(C)}return}const I=i.create([r.vertices[0],r.vertices[1],r.vertices[2]]),c=i.create([r.vertices[0],r.vertices[2],r.vertices[3]]);r.color&&(I.color=r.color,c.color=r.color),a.push(I,c);return}a.push(r)},n=(s,r)=>{const a=[];return r.forEach(g=>{o(s,g,a)}),a};A.exports=n}}),oct=oe({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,A){var e=Fn(),i=_x(),o=Kn(),n=qn(),s=Sg(),r=PZA(),a=ect(),g=tct(),I=ict(),c=(Q,E)=>E,B=(Q,E)=>E,l=(Q,E)=>{const h={snap:!1,simplify:!1,triangulate:!1},{snap:u,simplify:d,triangulate:f}=Object.assign({},h,Q),m=i(E);let S=n.toPolygons(E);u&&(S=r(m,S)),d&&(S=a(m,S)),f&&(S=g(S),S=I(m,S));const D=Object.assign({},E);return D.polygons=S,D},C=(Q,...E)=>{if(E=e(E),E.length===0)throw new Error("wrong number of arguments");const h=E.map(u=>{if(s.isA(u))return c(Q,u);if(o.isA(u))return B(Q,u);if(n.isA(u))return l(Q,u);throw new Error("invalid geometry")});return h.length===1?h[0]:h};A.exports=C}}),nct=oe({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,A){var e=Fn(),i=ls(),o=Kn(),n=qn(),s=Sg(),r=_x(),a=PZA(),g=l=>{const C=r(l),E=s.toPoints(l).map(h=>i.snap(i.create(),h,C));return s.create(E)},I=l=>{const C=r(l);let E=o.toSides(l).map(h=>[i.snap(i.create(),h[0],C),i.snap(i.create(),h[1],C)]);return E=E.filter(h=>!i.equals(h[0],h[1])),o.create(E)},c=l=>{const C=r(l),Q=n.toPolygons(l),E=a(C,Q);return n.create(E)},B=(...l)=>{if(l=e(l),l.length===0)throw new Error("wrong number of arguments");const C=l.map(Q=>s.isA(Q)?g(Q):o.isA(Q)?I(Q):n.isA(Q)?c(Q):Q);return C.length===1?C[0]:C};A.exports=B}}),sct=oe({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,A){A.exports={generalize:oct(),snap:nct(),retessellate:uL()}}}),rct=oe({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,A){var e=(i,o,n)=>{for(i=i.slice();i.length<n;)i.push(o);return i};A.exports=e}}),act=oe({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,A){var e=Fn(),i=rct(),o=TlA(),{translate:n}=CF(),s=I=>{if(!Array.isArray(I.modes)||I.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(I.modes=i(I.modes,"none",3),I.modes.filter(c=>["center","max","min","none"].includes(c)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(I.relativeTo)||I.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(I.relativeTo=i(I.relativeTo,0,3),I.relativeTo.filter(c=>Number.isFinite(c)||c==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof I.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return I},r=(I,c,B)=>{for(let l=0;l<3;l++)I[l]==null&&(c[l]==="center"?I[l]=(B[0][l]+B[1][l])/2:c[l]==="max"?I[l]=B[1][l]:c[l]==="min"&&(I[l]=B[0][l]));return I},a=(I,c,B)=>{const l=o(I),C=[0,0,0];for(let Q=0;Q<3;Q++)c[Q]==="center"?C[Q]=B[Q]-(l[0][Q]+l[1][Q])/2:c[Q]==="max"?C[Q]=B[Q]-l[1][Q]:c[Q]==="min"&&(C[Q]=B[Q]-l[0][Q]);return n(C,I)},g=(I,...c)=>{I=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},I),I=s(I);let{modes:l,relativeTo:C,grouped:Q}=I;if(c=e(c),c.length===0)throw new Error("align(): No geometries were provided to act upon");if(C.filter(E=>E==null).length){const E=o(c);C=r(C,l,E)}return Q?c=a(c,l,C):c=c.map(E=>a(E,l,C)),c.length===1?c[0]:c};A.exports=g}}),T5=oe({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,A){var e=Fn(),i=Kn(),o=qn(),n=Sg(),s=BF(),{translate:r}=CF(),a=(l,C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,l),u=s(C),d=[0,0,0];return E[0]&&(d[0]=h[0]-(u[0][0]+(u[1][0]-u[0][0])/2)),E[1]&&(d[1]=h[1]-(u[0][1]+(u[1][1]-u[0][1])/2)),E[2]&&(d[2]=h[2]-(u[0][2]+(u[1][2]-u[0][2])/2)),r(d,C)},g=(l,...C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,l);if(C=e(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");l={axes:E,relativeTo:h};const u=C.map(d=>n.isA(d)||i.isA(d)||o.isA(d)?a(l,d):d);return u.length===1?u[0]:u},I=(...l)=>g({axes:[!0,!1,!1]},l),c=(...l)=>g({axes:[!1,!0,!1]},l),B=(...l)=>g({axes:[!1,!1,!0]},l);A.exports={center:g,centerX:I,centerY:c,centerZ:B}}}),K5=oe({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,A){var e=Fn(),i=Og(),o=Kn(),n=qn(),s=Sg(),r=(c,...B)=>{if(!Array.isArray(c))throw new Error("factors must be an array");if(B=e(B),B.length===0)throw new Error("wrong number of arguments");for(c=c.slice();c.length<3;)c.push(1);if(c[0]<=0||c[1]<=0||c[2]<=0)throw new Error("factors must be positive");const l=i.fromScaling(i.create(),c),C=B.map(Q=>s.isA(Q)?s.transform(l,Q):o.isA(Q)?o.transform(l,Q):n.isA(Q)?n.transform(l,Q):Q);return C.length===1?C[0]:C},a=(c,...B)=>r([c,1,1],B),g=(c,...B)=>r([1,c,1],B),I=(c,...B)=>r([1,1,c],B);A.exports={scale:r,scaleX:a,scaleY:g,scaleZ:I}}}),gct=oe({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,A){var e=Fn(),i=Kn(),o=qn(),n=Sg(),s=(r,...a)=>{if(a=e(a),a.length===0)throw new Error("wrong number of arguments");const g=a.map(I=>n.isA(I)?n.transform(r,I):i.isA(I)?i.transform(r,I):o.isA(I)?o.transform(r,I):I);return g.length===1?g[0]:g};A.exports=s}}),QF=oe({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,A){A.exports={align:act(),center:T5().center,centerX:T5().centerX,centerY:T5().centerY,centerZ:T5().centerZ,mirror:QL().mirror,mirrorX:QL().mirrorX,mirrorY:QL().mirrorY,mirrorZ:QL().mirrorZ,rotate:EL().rotate,rotateX:EL().rotateX,rotateY:EL().rotateY,rotateZ:EL().rotateZ,scale:K5().scale,scaleX:K5().scaleX,scaleY:K5().scaleY,scaleZ:K5().scaleZ,transform:gct(),translate:CF().translate,translateX:CF().translateX,translateY:CF().translateY,translateZ:CF().translateZ}}}),q5=oe({"node_modules/@jscad/modeling/src/index.js"(t,A){A.exports={colors:v5(),curves:ngt(),geometries:UlA(),maths:Ggt(),measurements:Lgt(),primitives:vx(),text:OlA(),utils:vZA(),booleans:s_(),expansions:TZA(),extrusions:dL(),hulls:Act(),modifiers:sct(),transforms:QF()}}}),OZA=oe({"node_modules/jscad-planner/dist/index.cjs"(t,A){var e=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,s=(B,l)=>{for(var C in l)e(B,C,{get:l[C],enumerable:!0})},r=(B,l,C,Q)=>{if(l&&typeof l=="object"||typeof l=="function")for(let E of o(l))!n.call(B,E)&&E!==C&&e(B,E,{get:()=>l[E],enumerable:!(Q=i(l,E))||Q.enumerable});return B},a=B=>r(e({},"__esModule",{value:!0}),B),g={};s(g,{executeJscadOperations:()=>c,jscadPlanner:()=>I}),A.exports=a(g);var I={booleans:{intersect:(...B)=>({type:"intersect",shapes:B}),subtract:(...B)=>({type:"subtract",shapes:B}),union:(...B)=>({type:"union",shapes:B})},hulls:{hull:(...B)=>({type:"hull",shapes:B.flat()}),hullChain:(...B)=>({type:"hullChain",shapes:B.flat()})},colors:{colorize:(B,l)=>({type:"colorize",color:B,shape:l})},primitives:{cube:B=>({type:"cube",...B}),sphere:B=>({type:"sphere",...B}),cylinder:B=>({type:"cylinder",...B}),polygon:B=>({type:"polygon",...B}),cuboid:B=>({type:"cuboid",...B}),roundedCuboid:B=>({type:"roundedCuboid",...B})},transforms:{rotate:(B,l)=>({type:"rotate",angles:B,shape:l}),scale:(B,l)=>({type:"scale",factors:B,shape:l}),translate:(B,l)=>({type:"translate",vector:B,shape:l})},extrusions:{extrudeLinear:(B,l)=>({type:"extrudeLinear",options:B,shape:l}),extrudeRotate:(B,l)=>({type:"extrudeRotate",options:B,shape:l})},maths:{vec2:{create:(B,l)=>[B,l],fromValues:(B,l)=>[B,l]},vec3:{create:(B,l,C)=>[B,l,C],fromValues:(B,l,C)=>[B,l,C]}},geometries:{geom2:{create:B=>({type:"createGeom2",points:B})},geom3:{create:B=>({type:"createGeom3",polygons:B})},path2:{create:B=>({type:"createPath2",points:B})}},measurements:{measureBoundingBox:B=>({type:"measureBoundingBox",shape:B}),measureArea:B=>({type:"measureArea",shape:B}),measureVolume:B=>({type:"measureVolume",shape:B})},utils:{degToRad:B=>B*Math.PI/180,radToDeg:B=>B*180/Math.PI}},c=(B,l)=>{if(Array.isArray(l)&&l.length===1)return c(B,l[0]);if(Array.isArray(l))throw new Error("executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually");const C=h=>c(B,h),{type:Q,...E}=l;switch(Q){case"intersect":return B.booleans.intersect(...l.shapes.map(C));case"subtract":return B.booleans.subtract(...l.shapes.map(C));case"union":return B.booleans.union(...l.shapes.map(C));case"hull":return B.hulls.hull(...l.shapes.map(C));case"hullChain":return B.hulls.hullChain(...l.shapes.map(C));case"colorize":return B.colors.colorize(l.color,C(l.shape));case"cube":return B.primitives.cube(E);case"sphere":return B.primitives.sphere(E);case"cylinder":return B.primitives.cylinder(E);case"polygon":return B.primitives.polygon(E);case"cuboid":return B.primitives.cuboid(E);case"roundedCuboid":return B.primitives.roundedCuboid(E);case"rotate":return B.transforms.rotate(l.angles,C(l.shape));case"scale":return B.transforms.scale(l.factors,C(l.shape));case"translate":return B.transforms.translate(l.vector,C(l.shape));case"extrudeLinear":return B.extrusions.extrudeLinear(l.options,C(l.shape));case"extrudeRotate":return B.extrusions.extrudeRotate(l.options,C(l.shape));case"createGeom2":return B.geometries.geom2.create(l.points);case"createGeom3":return B.geometries.geom3.create(l.polygons);case"createPath2":return B.geometries.path2.create(l.points);case"measureBoundingBox":return B.measurements.measureBoundingBox(C(l.shape));case"measureArea":return B.measurements.measureArea(C(l.shape));case"measureVolume":return B.measurements.measureVolume(C(l.shape));case"degToRad":return B.utils.degToRad(l.degrees);case"radToDeg":return B.utils.radToDeg(l.radians);default:throw l.type===void 0?new Error(`Operation type is undefined. This usually means the operation object is malformed or not properly initialized. Operation: ${JSON.stringify(l,null,2).slice(0,200)}...`):new Error(`Unsupported operation type: ${l.type}. Operation: ${JSON.stringify(l,null,2)}`)}}}}),Ict=oe({"node_modules/ms/index.js"(t,A){var e=1e3,i=e*60,o=i*60,n=o*24,s=n*7,r=n*365.25;A.exports=function(B,l){l=l||{};var C=typeof B;if(C==="string"&&B.length>0)return a(B);if(C==="number"&&isFinite(B))return l.long?I(B):g(B);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(B))};function a(B){if(B=String(B),!(B.length>100)){var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(B);if(l){var C=parseFloat(l[1]),Q=(l[2]||"ms").toLowerCase();switch(Q){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*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return C;default:return}}}}function g(B){var l=Math.abs(B);return l>=n?Math.round(B/n)+"d":l>=o?Math.round(B/o)+"h":l>=i?Math.round(B/i)+"m":l>=e?Math.round(B/e)+"s":B+"ms"}function I(B){var l=Math.abs(B);return l>=n?c(B,l,n,"day"):l>=o?c(B,l,o,"hour"):l>=i?c(B,l,i,"minute"):l>=e?c(B,l,e,"second"):B+" ms"}function c(B,l,C,Q){var E=l>=C*1.5;return Math.round(B/C)+" "+Q+(E?"s":"")}}}),cct=oe({"node_modules/debug/src/common.js"(t,A){function e(i){n.debug=n,n.default=n,n.coerce=c,n.disable=g,n.enable=r,n.enabled=I,n.humanize=Ict(),n.destroy=B,Object.keys(i).forEach(l=>{n[l]=i[l]}),n.names=[],n.skips=[],n.formatters={};function o(l){let C=0;for(let Q=0;Q<l.length;Q++)C=(C<<5)-C+l.charCodeAt(Q),C|=0;return n.colors[Math.abs(C)%n.colors.length]}n.selectColor=o;function n(l){let C,Q=null,E,h;function u(...d){if(!u.enabled)return;const f=u,m=Number(new Date),S=m-(C||m);f.diff=S,f.prev=C,f.curr=m,C=m,d[0]=n.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let D=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(F,k)=>{if(F==="%%")return"%";D++;const v=n.formatters[k];if(typeof v=="function"){const _=d[D];F=v.call(f,_),d.splice(D,1),D--}return F}),n.formatArgs.call(f,d),(f.log||n.log).apply(f,d)}return u.namespace=l,u.useColors=n.useColors(),u.color=n.selectColor(l),u.extend=s,u.destroy=n.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>Q!==null?Q:(E!==n.namespaces&&(E=n.namespaces,h=n.enabled(l)),h),set:d=>{Q=d}}),typeof n.init=="function"&&n.init(u),u}function s(l,C){const Q=n(this.namespace+(typeof C>"u"?":":C)+l);return Q.log=this.log,Q}function r(l){n.save(l),n.namespaces=l,n.names=[],n.skips=[];const C=(typeof l=="string"?l:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const Q of C)Q[0]==="-"?n.skips.push(Q.slice(1)):n.names.push(Q)}function a(l,C){let Q=0,E=0,h=-1,u=0;for(;Q<l.length;)if(E<C.length&&(C[E]===l[Q]||C[E]==="*"))C[E]==="*"?(h=E,u=Q,E++):(Q++,E++);else if(h!==-1)E=h+1,u++,Q=u;else return!1;for(;E<C.length&&C[E]==="*";)E++;return E===C.length}function g(){const l=[...n.names,...n.skips.map(C=>"-"+C)].join(",");return n.enable(""),l}function I(l){for(const C of n.skips)if(a(l,C))return!1;for(const C of n.names)if(a(l,C))return!0;return!1}function c(l){return l instanceof Error?l.stack||l.message:l}function B(){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=e}}),Bct=oe({"node_modules/debug/src/browser.js"(t,A){t.formatArgs=i,t.save=o,t.load=n,t.useColors=e,t.storage=s(),t.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`."))}})(),t.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 e(){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 I=0,c=0;a[0].replace(/%[a-zA-Z%]/g,B=>{B!=="%%"&&(I++,B==="%c"&&(c=I))}),a.splice(c,0,g)}t.log=console.debug||console.log||(()=>{});function o(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function n(){let a;try{a=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!a&&typeof xlA<"u"&&"env"in xlA&&(a=xlA.env.DEBUG),a}function s(){try{return localStorage}catch{}}A.exports=cct()(t);var{formatters:r}=A.exports;r.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}}}),WZA={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},ZZA=j.createContext(void 0),lct=({children:t})=>{const[A,e]=j.useState(WZA),i=j.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),o=j.useCallback(()=>{e(WZA)},[]),n=j.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:o}),[A,i,o]);return O.jsx(ZZA.Provider,{value:n,children:t})},r_=()=>{const t=j.useContext(ZZA);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},VZA=j.createContext(null),Ru=()=>{const t=j.useContext(VZA);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},pL=(t,A=[])=>{const{addFrameListener:e,removeFrameListener:i}=Ru();Xi.useEffect(()=>(e(t),()=>i(t)),[e,i,...A])},fL={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},jZA=({children:t,position:A,style:e})=>{const{camera:i,renderer:o}=Ru(),n=j.useRef(document.createElement("div")),[s,r]=j.useState(null);return j.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(E3.createPortal(t,n.current)),()=>{a.contains(n.current)&&a.removeChild(n.current)}},[o,t]),pL(()=>{if(!i||!n.current||!o)return;const a=new Me(...A);a.project(i);const g=o.domElement.getBoundingClientRect(),I=Math.round((a.x+1)/2*g.width),c=Math.round((-a.y+1)/2*g.height);n.current.style.position="absolute",n.current.style.left=`${I}px`,n.current.style.top=`${c}px`,n.current.style.pointerEvents="none",n.current.style.zIndex=fL.htmlElements.toString(),e&&Object.assign(n.current.style,e)},[i,o,A,e]),s},zZA={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},mr=t=>{let A=typeof t=="number"?"mm":t.replace(/^[^a-zA-Z]+/g,"").toLowerCase();A||(A="mm");const e=typeof t=="number"?t:Number.parseFloat(t.split(A)[0]);if(A in zZA)return e*zZA[A];throw new Error(`Unsupported unit: ${A}`)},mB=mr,XZA={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}}},eCA=new Set;for(const[t,A]of Object.entries(XZA)){eCA.add(t);for(const e of Object.keys(A.variants))eCA.add(e)}function Cct(t){for(const[A,e]of Object.entries(XZA))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,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 _w(t){if(t==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:r,unitOfValue:a}=_w(t.x),g=_w(t.x),I=_w(t.y);return g.value===null||I.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:I.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),o=t.slice(0,-i.length);if(i in $ZA&&!eCA.has(i)){const r=$ZA[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(o)*r}}const{baseUnit:n,conversionFactor:s}=Cct(i);return{parsedUnit:i,unitOfValue:n,value:s*Number.parseFloat(o)}}var tCA=Y().or(WA()).transform(t=>_w(t).value),AVA=Y().or(WA()).transform(t=>_w(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),Qct=Y().or(WA()).transform(t=>_w(t).value),a_=Y().or(WA()).transform(t=>_w(t).value),Ae=Y().or(WA()).transform(t=>_w(t).value),P5=Y().or(WA()).transform(t=>_w(t).value),mt=Ae,iCA=Y().or(WA()).transform(t=>_w(t).value),oCA=Y().or(WA()).transform(t=>_w(t).value),g_=oCA,Ect=Y().datetime(),Gd=Y().or(WA()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),hct=WA().or(Y().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const A=t.replace("mAh",""),e=Number.parseFloat(A);if(Number.isNaN(e))throw new Error("Invalid capacity");return e}return t}).describe("Battery capacity in mAh"),Go=OA({x:mt,y:mt}),nCA=OA({x:mt,y:mt,z:mt}),eVA=OA({width:WA(),height:WA()}),uct=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},Vt=t=>Y().optional().default(()=>`${t}_${uct(10)}`),EF=Bt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]);Bt(["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 dct=Bt(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),DB=OA({type:GA("source_component"),ftype:Y().optional(),source_component_id:Y(),name:Y(),manufacturer_part_number:Y().optional(),supplier_part_numbers:La(dct,be(Y())).optional(),display_value:Y().optional(),are_pins_interchangeable:ce().optional(),internally_connected_source_port_ids:be(be(Y())).optional(),source_group_id:Y().optional(),subcircuit_id:Y().optional()}),tVA=DB.extend({ftype:GA("simple_capacitor"),capacitance:AVA,max_voltage_rating:a_.optional(),display_capacitance:Y().optional(),max_decoupling_trace_length:mt.optional()}),iVA=DB.extend({ftype:GA("simple_resistor"),resistance:tCA,display_resistance:Y().optional()}),sCA=DB.extend({ftype:GA("simple_diode")}),pct=DB.extend({ftype:GA("simple_fiducial")}),oVA=sCA.extend({ftype:GA("simple_led"),color:Y().optional(),wavelength:Y().optional()}),fct=DB.extend({ftype:GA("simple_ground")}),nVA=DB.extend({ftype:GA("simple_chip")}),sVA=DB.extend({ftype:GA("simple_power_source"),voltage:a_}),yct=DB.extend({ftype:GA("simple_fuse"),current_rating_amps:WA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:WA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),rVA=DB.extend({ftype:GA("simple_battery"),capacity:hct}),aVA=DB.extend({ftype:GA("simple_inductor"),inductance:Qct,max_current_rating:WA().optional()}),gVA=DB.extend({ftype:GA("simple_push_button")}),IVA=DB.extend({ftype:GA("simple_potentiometer"),max_resistance:tCA}),wct=DB.extend({ftype:GA("simple_crystal"),frequency:WA().describe("Frequency in Hz"),load_capacitance:WA().optional().describe("Load capacitance in pF")}),cVA=DB.extend({ftype:GA("simple_pin_header"),pin_count:WA(),gender:Bt(["male","female"]).optional().default("male")}),BVA=DB.extend({ftype:GA("simple_pinout")}),lVA=DB.extend({ftype:GA("simple_resonator"),load_capacitance:AVA,equivalent_series_resistance:tCA.optional(),frequency:P5}),CVA=DB.extend({ftype:GA("simple_transistor"),transistor_type:Bt(["npn","pnp"])}),QVA=DB.extend({ftype:GA("simple_test_point"),footprint_variant:Bt(["pad","through_hole"]).optional(),pad_shape:Bt(["rect","circle"]).optional(),pad_diameter:ei([WA(),Y()]).optional(),hole_diameter:ei([WA(),Y()]).optional(),width:ei([WA(),Y()]).optional(),height:ei([WA(),Y()]).optional()}),EVA=DB.extend({ftype:GA("simple_mosfet"),channel_type:Bt(["n","p"]),mosfet_mode:Bt(["enhancement","depletion"])}),hVA=DB.extend({ftype:GA("simple_op_amp")}),uVA=DB.extend({ftype:GA("simple_switch")}),dVA=OA({type:GA("source_project_metadata"),name:Y().optional(),software_used_string:Y().optional(),project_url:Y().optional(),created_at:Ect.optional()}),mct=OA({type:GA("source_missing_property_error"),source_missing_property_error_id:Vt("source_missing_property_error"),source_component_id:Y(),property_name:Y(),subcircuit_id:Y().optional(),error_type:GA("source_missing_property_error").default("source_missing_property_error"),message:Y()}).describe("The source code is missing a property"),Dct=OA({type:GA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Vt("source_failed_to_create_component_error"),error_type:GA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:Y().optional(),subcircuit_id:Y().optional(),parent_source_component_id:Y().optional(),message:Y(),pcb_center:OA({x:WA().optional(),y:WA().optional()}).optional(),schematic_center:OA({x:WA().optional(),y:WA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),pVA=OA({type:GA("source_trace_not_connected_error"),source_trace_not_connected_error_id:Vt("source_trace_not_connected_error"),error_type:GA("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:Y(),subcircuit_id:Y().optional(),source_group_id:Y().optional(),source_trace_id:Y().optional(),connected_source_port_ids:be(Y()).optional(),selectors_not_found:be(Y()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Sct=OA({type:GA("source_property_ignored_warning"),source_property_ignored_warning_id:Vt("source_property_ignored_warning"),source_component_id:Y(),property_name:Y(),subcircuit_id:Y().optional(),error_type:GA("source_property_ignored_warning").default("source_property_ignored_warning"),message:Y()}).describe("The source property was ignored"),fVA=OA({type:GA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Vt("source_pin_missing_trace_warning"),warning_type:GA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:Y(),source_component_id:Y(),source_port_id:Y(),subcircuit_id:Y().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),bct=DB.extend({ftype:GA("simple_voltage_probe")}),xct=DB.extend({ftype:GA("interconnect")}),kct=ei([iVA,tVA,sCA,pct,oVA,fct,nVA,sVA,rVA,aVA,gVA,IVA,wct,cVA,BVA,lVA,uVA,CVA,QVA,EVA,hVA,yct,bct,xct,dVA,mct,Dct,pVA,Sct,fVA]),Gct=OA({type:GA("source_port"),pin_number:WA().optional(),port_hints:be(Y()).optional(),name:Y(),source_port_id:Y(),source_component_id:Y().optional(),source_group_id:Y().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),must_be_connected:ce().optional()}),Fct=OA({type:GA("source_component_internal_connection"),source_component_internal_connection_id:Y(),source_component_id:Y(),source_port_ids:be(Y()),subcircuit_id:Y().optional()}),Rct=OA({type:GA("source_trace"),source_trace_id:Y(),connected_source_port_ids:be(Y()),connected_source_net_ids:be(Y()),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),max_length:WA().optional(),min_trace_thickness:WA().optional(),display_name:Y().optional()}),Mct=OA({type:GA("source_group"),source_group_id:Y(),subcircuit_id:Y().optional(),parent_subcircuit_id:Y().optional(),parent_source_group_id:Y().optional(),is_subcircuit:ce().optional(),show_as_schematic_box:ce().optional(),name:Y().optional(),was_automatically_named:ce().optional()}),Nct=OA({type:GA("source_net"),source_net_id:Y(),name:Y(),member_source_group_ids:be(Y()),is_power:ce().optional(),is_ground:ce().optional(),is_digital_signal:ce().optional(),is_analog_signal:ce().optional(),is_positive_voltage_source:ce().optional(),trace_width:WA().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional()}),_ct=OA({type:GA("source_board"),source_board_id:Y(),source_group_id:Y(),title:Y().optional()}).describe("Defines a board in the source domain"),vct=OA({type:GA("source_pcb_ground_plane"),source_pcb_ground_plane_id:Y(),source_group_id:Y(),source_net_id:Y(),subcircuit_id:Y().optional()}).describe("Defines a ground plane in the source domain"),Uct=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],yVA=Bt(Uct),vr=yVA.or(OA({name:yVA})).transform(t=>typeof t=="string"?t:t.name),Km=Bt(["top","bottom"]),Lct=OA({type:GA("source_manually_placed_via"),source_manually_placed_via_id:Y(),source_group_id:Y(),source_net_id:Y(),subcircuit_id:Y().optional(),source_trace_id:Y().optional()}).describe("Defines a via that is manually placed in the source domain"),Hct=OA({type:GA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:Vt("source_pin_must_be_connected_error"),error_type:GA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),message:Y(),source_component_id:Y(),source_port_id:Y(),subcircuit_id:Y().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),Yct=OA({type:GA("unknown_error_finding_part"),unknown_error_finding_part_id:Vt("unknown_error_finding_part"),error_type:GA("unknown_error_finding_part").default("unknown_error_finding_part"),message:Y(),source_component_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),Jct=OA({type:GA("schematic_box"),schematic_component_id:Y().optional(),width:mt,height:mt,is_dashed:ce().default(!1),x:mt,y:mt,subcircuit_id:Y().optional()}).describe("Draws a box on the schematic"),Tct=OA({type:GA("schematic_path"),schematic_component_id:Y(),fill_color:Bt(["red","blue"]).optional(),is_filled:ce().optional(),points:be(Go),subcircuit_id:Y().optional()}),Kct=La(OA({left_margin:Ae.optional(),right_margin:Ae.optional(),top_margin:Ae.optional(),bottom_margin:Ae.optional()})),qct=OA({left_size:WA(),right_size:WA(),top_size:WA().optional(),bottom_size:WA().optional()}),Pct=OA({left_side:OA({pins:be(WA()),direction:Bt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:OA({pins:be(WA()),direction:Bt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:OA({pins:be(WA()),direction:Bt(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:OA({pins:be(WA()),direction:Bt(["left-to-right","right-to-left"]).optional()}).optional()}),Oct=ei([qct,Pct]),Wct=OA({type:GA("schematic_component"),size:eVA,center:Go,source_component_id:Y().optional(),schematic_component_id:Y(),pin_spacing:Ae.optional(),pin_styles:Kct.optional(),box_width:Ae.optional(),symbol_name:Y().optional(),port_arrangement:Oct.optional(),port_labels:La(Y()).optional(),symbol_display_value:Y().optional(),subcircuit_id:Y().optional(),schematic_group_id:Y().optional(),is_schematic_group:ce().optional(),source_group_id:Y().optional(),is_box_with_pins:ce().optional().default(!0)}),Zct=OA({type:GA("schematic_line"),schematic_line_id:Vt("schematic_line"),schematic_component_id:Y(),x1:mt,y1:mt,x2:mt,y2:mt,stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_dashed:ce().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled line on the schematic"),Vct=OA({type:GA("schematic_rect"),schematic_rect_id:Vt("schematic_rect"),schematic_component_id:Y(),center:Go,width:mt,height:mt,rotation:Gd.default(0),stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_filled:ce().default(!1),fill_color:Y().optional(),is_dashed:ce().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled rectangle on the schematic"),jct=OA({type:GA("schematic_circle"),schematic_circle_id:Vt("schematic_circle"),schematic_component_id:Y(),center:Go,radius:mt,stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_filled:ce().default(!1),fill_color:Y().optional(),is_dashed:ce().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled circle on the schematic"),zct=OA({type:GA("schematic_arc"),schematic_arc_id:Vt("schematic_arc"),schematic_component_id:Y(),center:Go,radius:mt,start_angle_degrees:Gd,end_angle_degrees:Gd,direction:Bt(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_dashed:ce().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled arc on the schematic"),Xct=OA({type:GA("schematic_trace"),schematic_trace_id:Y(),source_trace_id:Y().optional(),junctions:be(OA({x:WA(),y:WA()})),edges:be(OA({from:OA({x:WA(),y:WA()}),to:OA({x:WA(),y:WA()}),is_crossing:ce().optional(),from_schematic_port_id:Y().optional(),to_schematic_port_id:Y().optional()})),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional()}),$ct=Bt(["center","left","right","top","bottom"]),ABt=OA({type:GA("schematic_text"),schematic_component_id:Y().optional(),schematic_text_id:Y(),text:Y(),font_size:WA().default(.18),position:OA({x:mt,y:mt}),rotation:WA().default(0),anchor:ei([$ct.describe("legacy"),EF]).default("center"),color:Y().default("#000000"),subcircuit_id:Y().optional()}),eBt=OA({type:GA("schematic_port"),schematic_port_id:Y(),source_port_id:Y(),schematic_component_id:Y().optional(),center:Go,facing_direction:Bt(["up","down","left","right"]).optional(),distance_from_component_edge:WA().optional(),side_of_component:Bt(["top","bottom","left","right"]).optional(),true_ccw_index:WA().optional(),pin_number:WA().optional(),display_pin_label:Y().optional(),subcircuit_id:Y().optional(),is_connected:ce().optional(),has_input_arrow:ce().optional(),has_output_arrow:ce().optional()}).describe("Defines a port on a schematic component"),tBt=OA({type:GA("schematic_net_label"),schematic_net_label_id:Vt("schematic_net_label"),schematic_trace_id:Y().optional(),source_trace_id:Y().optional(),source_net_id:Y(),center:Go,anchor_position:Go.optional(),anchor_side:Bt(["top","bottom","left","right"]),text:Y(),symbol_name:Y().optional(),is_movable:ce().optional(),subcircuit_id:Y().optional()}),iBt=OA({type:GA("schematic_error"),schematic_error_id:Y(),error_type:GA("schematic_port_not_found").default("schematic_port_not_found"),message:Y(),subcircuit_id:Y().optional()}).describe("Defines a schematic error on the schematic"),oBt=OA({type:GA("schematic_layout_error"),schematic_layout_error_id:Vt("schematic_layout_error"),error_type:GA("schematic_layout_error").default("schematic_layout_error"),message:Y(),source_group_id:Y(),schematic_group_id:Y(),subcircuit_id:Y().optional()}).describe("Error emitted when schematic layout fails for a group"),rCA=OA({type:GA("schematic_debug_object"),label:Y().optional(),subcircuit_id:Y().optional()}),nBt=rCA.extend({shape:GA("rect"),center:Go,size:eVA}),sBt=rCA.extend({shape:GA("line"),start:Go,end:Go}),rBt=rCA.extend({shape:GA("point"),center:Go}),aBt=Jp("shape",[nBt,sBt,rBt]),gBt=OA({type:GA("schematic_voltage_probe"),schematic_voltage_probe_id:Y(),source_component_id:Y().optional(),name:Y().optional(),position:Go,schematic_trace_id:Y(),voltage:a_.optional(),subcircuit_id:Y().optional(),color:Y().optional(),label_alignment:EF.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),IBt=OA({type:GA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Vt("schematic_manual_edit_conflict_warning"),warning_type:GA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:Y(),schematic_component_id:Y(),schematic_group_id:Y().optional(),subcircuit_id:Y().optional(),source_component_id:Y()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),cBt=OA({type:GA("schematic_group"),schematic_group_id:Vt("schematic_group"),source_group_id:Y(),is_subcircuit:ce().optional(),subcircuit_id:Y().optional(),width:Ae,height:Ae,center:Go,schematic_component_ids:be(Y()),show_as_schematic_box:ce().optional(),name:Y().optional(),description:Y().optional()}).describe("Defines a group of components on the schematic"),BBt=OA({type:GA("schematic_table"),schematic_table_id:Vt("schematic_table"),anchor_position:Go,column_widths:be(mt),row_heights:be(mt),cell_padding:mt.optional(),border_width:mt.optional(),subcircuit_id:Y().optional(),schematic_component_id:Y().optional(),anchor:EF.optional()}).describe("Defines a table on the schematic"),lBt=OA({type:GA("schematic_table_cell"),schematic_table_cell_id:Vt("schematic_table_cell"),schematic_table_id:Y(),start_row_index:WA(),end_row_index:WA(),start_column_index:WA(),end_column_index:WA(),text:Y().optional(),center:Go,width:mt,height:mt,horizontal_align:Bt(["left","center","right"]).optional(),vertical_align:Bt(["top","middle","bottom"]).optional(),font_size:mt.optional(),subcircuit_id:Y().optional()}).describe("Defines a cell within a schematic_table"),CBt=OA({type:GA("schematic_sheet"),schematic_sheet_id:Vt("schematic_sheet"),name:Y().optional(),subcircuit_id:Y().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),QBt=OA({x:mt,y:mt,bulge:WA().optional()}),wVA=OA({vertices:be(QBt)}),EBt=OA({outer_ring:wVA,inner_rings:be(wVA).default([])}),hBt=OA({x:mt,y:mt,via:ce().optional(),via_to_layer:vr.optional()});be(hBt);var uBt=OA({x:mt,y:mt,via:ce().optional(),to_layer:vr.optional(),trace_width:mt.optional()}),dBt=OA({type:GA("pcb_component"),pcb_component_id:Vt("pcb_component"),source_component_id:Y(),center:Go,layer:vr,rotation:Gd,display_offset_x:Y().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:Y().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:Ae,height:Ae,do_not_place:ce().optional(),subcircuit_id:Y().optional(),pcb_group_id:Y().optional(),position_mode:Bt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:Y().optional(),positioned_relative_to_pcb_board_id:Y().optional(),obstructs_within_bounds:ce().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"),mVA=OA({type:GA("pcb_hole"),pcb_hole_id:Vt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:GA("circle"),hole_diameter:WA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()});mVA.describe("Defines a circular hole on the PCB");var DVA=OA({type:GA("pcb_hole"),pcb_hole_id:Vt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:GA("rect"),hole_width:WA(),hole_height:WA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()});DVA.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square.");var SVA=OA({type:GA("pcb_hole"),pcb_hole_id:Vt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:Bt(["circle","square"]),hole_diameter:WA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()});SVA.describe("Defines a circular or square hole on the PCB");var bVA=OA({type:GA("pcb_hole"),pcb_hole_id:Vt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:GA("oval"),hole_width:WA(),hole_height:WA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()});bVA.describe("Defines an oval hole on the PCB");var xVA=OA({type:GA("pcb_hole"),pcb_hole_id:Vt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:GA("pill"),hole_width:WA(),hole_height:WA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()});xVA.describe("Defines a pill-shaped hole on the PCB");var kVA=OA({type:GA("pcb_hole"),pcb_hole_id:Vt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:GA("rotated_pill"),hole_width:WA(),hole_height:WA(),x:mt,y:mt,ccw_rotation:Gd,is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()});kVA.describe("Defines a rotated pill-shaped hole on the PCB");var pBt=SVA.or(bVA).or(xVA).or(kVA).or(mVA).or(DVA),fBt=OA({type:GA("pcb_plated_hole"),shape:GA("circle"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),outer_diameter:WA(),hole_diameter:WA(),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(vr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Vt("pcb_plated_hole"),soldermask_margin:WA().optional()}),yBt=OA({type:GA("pcb_plated_hole"),shape:Bt(["oval","pill"]),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),outer_width:WA(),outer_height:WA(),hole_width:WA(),hole_height:WA(),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,ccw_rotation:Gd,layers:be(vr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Vt("pcb_plated_hole"),soldermask_margin:WA().optional()}),wBt=OA({type:GA("pcb_plated_hole"),shape:GA("circular_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:GA("circle"),pad_shape:GA("rect"),hole_diameter:WA(),rect_pad_width:WA(),rect_pad_height:WA(),rect_border_radius:WA().optional(),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(vr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Vt("pcb_plated_hole"),soldermask_margin:WA().optional()}),mBt=OA({type:GA("pcb_plated_hole"),shape:GA("pill_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:GA("pill"),pad_shape:GA("rect"),hole_width:WA(),hole_height:WA(),rect_pad_width:WA(),rect_pad_height:WA(),rect_border_radius:WA().optional(),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(vr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Vt("pcb_plated_hole"),soldermask_margin:WA().optional()}),DBt=OA({type:GA("pcb_plated_hole"),shape:GA("rotated_pill_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:GA("rotated_pill"),pad_shape:GA("rect"),hole_width:WA(),hole_height:WA(),hole_ccw_rotation:Gd,rect_pad_width:WA(),rect_pad_height:WA(),rect_border_radius:WA().optional(),rect_ccw_rotation:Gd,hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(vr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Vt("pcb_plated_hole"),soldermask_margin:WA().optional()}),SBt=OA({type:GA("pcb_plated_hole"),shape:GA("hole_with_polygon_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:Bt(["circle","oval","pill","rotated_pill"]),hole_diameter:WA().optional(),hole_width:WA().optional(),hole_height:WA().optional(),pad_outline:be(OA({x:mt,y:mt})).min(3),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(vr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Vt("pcb_plated_hole"),soldermask_margin:WA().optional()}),bBt=ei([fBt,yBt,wBt,mBt,DBt,SBt]),xBt=OA({type:GA("pcb_port"),pcb_port_id:Vt("pcb_port"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),source_port_id:Y(),pcb_component_id:Y().optional(),x:mt,y:mt,layers:be(vr),is_board_pinout:ce().optional()}).describe("Defines a port on the PCB"),kBt=OA({type:GA("pcb_smtpad"),shape:GA("circle"),pcb_smtpad_id:Vt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,radius:WA(),layer:vr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()}),GBt=OA({type:GA("pcb_smtpad"),shape:GA("rect"),pcb_smtpad_id:Vt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),rect_border_radius:WA().optional(),corner_radius:WA().optional(),layer:vr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()}),FBt=OA({type:GA("pcb_smtpad"),shape:GA("rotated_rect"),pcb_smtpad_id:Vt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),rect_border_radius:WA().optional(),corner_radius:WA().optional(),ccw_rotation:Gd,layer:vr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()}),RBt=OA({type:GA("pcb_smtpad"),shape:GA("pill"),pcb_smtpad_id:Vt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),radius:WA(),layer:vr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()}),MBt=OA({type:GA("pcb_smtpad"),shape:GA("rotated_pill"),pcb_smtpad_id:Vt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),radius:WA(),ccw_rotation:Gd,layer:vr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()}),NBt=OA({type:GA("pcb_smtpad"),shape:GA("polygon"),pcb_smtpad_id:Vt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),points:be(Go),layer:vr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()}),_Bt=Jp("shape",[kBt,GBt,FBt,MBt,RBt,NBt]).describe("Defines an SMT pad on the PCB"),vBt=OA({type:GA("pcb_solder_paste"),shape:GA("circle"),pcb_solder_paste_id:Vt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,radius:WA(),layer:vr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),UBt=OA({type:GA("pcb_solder_paste"),shape:GA("rect"),pcb_solder_paste_id:Vt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),layer:vr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),LBt=OA({type:GA("pcb_solder_paste"),shape:GA("pill"),pcb_solder_paste_id:Vt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),radius:WA(),layer:vr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),HBt=OA({type:GA("pcb_solder_paste"),shape:GA("rotated_rect"),pcb_solder_paste_id:Vt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),ccw_rotation:mt,layer:vr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),YBt=OA({type:GA("pcb_solder_paste"),shape:GA("oval"),pcb_solder_paste_id:Vt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),layer:vr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),JBt=ei([vBt,UBt,LBt,HBt,YBt]).describe("Defines solderpaste on the PCB"),TBt=OA({type:GA("pcb_text"),pcb_text_id:Vt("pcb_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),text:Y(),center:Go,layer:vr,width:Ae,height:Ae,lines:WA(),align:Bt(["bottom-left"])}).describe("Defines text on the PCB"),KBt=OA({route_type:GA("wire"),x:mt,y:mt,width:mt,start_pcb_port_id:Y().optional(),end_pcb_port_id:Y().optional(),layer:vr}),qBt=OA({route_type:GA("via"),x:mt,y:mt,hole_diameter:mt.optional(),outer_diameter:mt.optional(),from_layer:Y(),to_layer:Y()}),PBt=ei([KBt,qBt]),OBt=OA({type:GA("pcb_trace"),source_trace_id:Y().optional(),pcb_component_id:Y().optional(),pcb_trace_id:Vt("pcb_trace"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),route_thickness_mode:Bt(["constant","interpolated"]).default("constant").optional(),route_order_index:WA().optional(),should_round_corners:ce().optional(),trace_length:WA().optional(),highlight_color:Y().optional(),route:be(PBt)}).describe("Defines a trace on the PCB"),WBt=OA({type:GA("pcb_trace_error"),pcb_trace_error_id:Vt("pcb_trace_error"),error_type:GA("pcb_trace_error").default("pcb_trace_error"),message:Y(),center:Go.optional(),pcb_trace_id:Y(),source_trace_id:Y(),pcb_component_ids:be(Y()),pcb_port_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines a trace error on the PCB"),ZBt=OA({type:GA("pcb_trace_missing_error"),pcb_trace_missing_error_id:Vt("pcb_trace_missing_error"),error_type:GA("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:Y(),center:Go.optional(),source_trace_id:Y(),pcb_component_ids:be(Y()),pcb_port_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),VBt=OA({type:GA("pcb_port_not_matched_error"),pcb_error_id:Vt("pcb_error"),error_type:GA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:Y(),pcb_component_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),jBt=OA({type:GA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Vt("pcb_port_not_connected_error"),error_type:GA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:Y(),pcb_port_ids:be(Y()),pcb_component_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),zBt=OA({type:GA("pcb_net"),pcb_net_id:Vt("pcb_net"),source_net_id:Y().optional(),highlight_color:Y().optional()}).describe("Defines a net on the PCB"),XBt=OA({type:GA("pcb_via"),pcb_via_id:Vt("pcb_via"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),x:mt,y:mt,outer_diameter:mt.default("0.6mm"),hole_diameter:mt.default("0.25mm"),from_layer:vr.optional(),to_layer:vr.optional(),layers:be(vr),pcb_trace_id:Y().optional(),net_is_assignable:ce().optional(),net_assigned:ce().optional(),is_tented:ce().optional()}).describe("Defines a via on the PCB"),$Bt=OA({type:GA("pcb_board"),pcb_board_id:Vt("pcb_board"),pcb_panel_id:Y().optional(),is_subcircuit:ce().optional(),subcircuit_id:Y().optional(),width:Ae.optional(),height:Ae.optional(),center:Go,display_offset_x:Y().optional().describe("How to display the x offset for this board, usually corresponding with how the user specified it"),display_offset_y:Y().optional().describe("How to display the y offset for this board, usually corresponding with how the user specified it"),thickness:Ae.optional().default(1.4),num_layers:WA().optional().default(4),outline:be(Go).optional(),shape:Bt(["rect","polygon"]).optional(),material:Bt(["fr4","fr1"]).default("fr4"),anchor_position:Go.optional(),anchor_alignment:EF.optional(),position_mode:Bt(["relative_to_panel_anchor","none"]).optional()}).describe("Defines the board outline of the PCB"),Alt=OA({type:GA("pcb_panel"),pcb_panel_id:Vt("pcb_panel"),width:Ae,height:Ae,center:Go,covered_with_solder_mask:ce().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),elt=OA({type:GA("pcb_placement_error"),pcb_placement_error_id:Vt("pcb_placement_error"),error_type:GA("pcb_placement_error").default("pcb_placement_error"),message:Y(),subcircuit_id:Y().optional()}).describe("Defines a placement error on the PCB"),tlt=OA({type:GA("pcb_trace_hint"),pcb_trace_hint_id:Vt("pcb_trace_hint"),pcb_port_id:Y(),pcb_component_id:Y(),route:be(uBt),subcircuit_id:Y().optional()}).describe("A hint that can be used during generation of a PCB trace"),ilt=OA({type:GA("pcb_silkscreen_line"),pcb_silkscreen_line_id:Vt("pcb_silkscreen_line"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),stroke_width:mt.default("0.1mm"),x1:mt,y1:mt,x2:mt,y2:mt,layer:Km}).describe("Defines a silkscreen line on the PCB"),olt=OA({type:GA("pcb_silkscreen_path"),pcb_silkscreen_path_id:Vt("pcb_silkscreen_path"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Km,route:be(Go),stroke_width:Ae}).describe("Defines a silkscreen path on the PCB"),nlt=OA({type:GA("pcb_silkscreen_text"),pcb_silkscreen_text_id:Vt("pcb_silkscreen_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("0.2mm"),pcb_component_id:Y(),text:Y(),is_knockout:ce().default(!1).optional(),knockout_padding:OA({left:Ae,top:Ae,bottom:Ae,right:Ae}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:WA().optional(),layer:vr,is_mirrored:ce().default(!1).optional(),anchor_position:Go.default({x:0,y:0}),anchor_alignment:EF.default("center")}).describe("Defines silkscreen text on the PCB"),slt=OA({type:GA("pcb_copper_text"),pcb_copper_text_id:Vt("pcb_copper_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("0.2mm"),pcb_component_id:Y(),text:Y(),is_knockout:ce().default(!1).optional(),knockout_padding:OA({left:Ae,top:Ae,bottom:Ae,right:Ae}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:WA().optional(),layer:vr,is_mirrored:ce().default(!1).optional(),anchor_position:Go.default({x:0,y:0}),anchor_alignment:EF.default("center")}).describe("Defines copper text on the PCB"),rlt=OA({type:GA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Vt("pcb_silkscreen_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,width:Ae,height:Ae,layer:vr,stroke_width:Ae.default("1mm"),corner_radius:Ae.optional(),is_filled:ce().default(!0).optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),ccw_rotation:WA().optional()}).describe("Defines a silkscreen rect on the PCB"),alt=OA({type:GA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Vt("pcb_silkscreen_circle"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,radius:Ae,layer:Km,stroke_width:Ae.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),glt=OA({type:GA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Vt("pcb_silkscreen_oval"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,radius_x:mt,radius_y:mt,layer:Km,ccw_rotation:Gd.optional()}).describe("Defines a silkscreen oval on the PCB"),Ilt=OA({type:GA("pcb_silkscreen_pill"),pcb_silkscreen_pill_id:Vt("pcb_silkscreen_pill"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,width:Ae,height:Ae,layer:vr,ccw_rotation:WA().optional()}).describe("Defines a silkscreen pill on the PCB"),clt=OA({type:GA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Vt("pcb_fabrication_note_text"),subcircuit_id:Y().optional(),pcb_group_id:Y().optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("1mm"),pcb_component_id:Y(),text:Y(),layer:Km,anchor_position:Go.default({x:0,y:0}),anchor_alignment:Bt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Y().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),Blt=OA({type:GA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Vt("pcb_fabrication_note_path"),pcb_component_id:Y(),subcircuit_id:Y().optional(),layer:vr,route:be(Go),stroke_width:Ae,color:Y().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),llt=OA({type:GA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Vt("pcb_fabrication_note_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,width:Ae,height:Ae,layer:Km,stroke_width:Ae.default("0.1mm"),corner_radius:Ae.optional(),is_filled:ce().optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),color:Y().optional()}).describe("Defines a fabrication note rectangle on the PCB"),Clt=OA({type:GA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Vt("pcb_fabrication_note_dimension"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Km,from:Go,to:Go,text:Y().optional(),text_ccw_rotation:WA().optional(),offset:Ae.optional(),offset_distance:Ae.optional(),offset_direction:OA({x:WA(),y:WA()}).optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:Ae.default("1mm"),color:Y().optional(),arrow_size:Ae.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),Qlt=OA({type:GA("pcb_note_text"),pcb_note_text_id:Vt("pcb_note_text"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("1mm"),text:Y().optional(),anchor_position:Go.default({x:0,y:0}),anchor_alignment:Bt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Y().optional()}).describe("Defines a documentation note in text on the PCB"),Elt=OA({type:GA("pcb_note_rect"),pcb_note_rect_id:Vt("pcb_note_rect"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),center:Go,width:Ae,height:Ae,stroke_width:Ae.default("0.1mm"),corner_radius:Ae.optional(),is_filled:ce().optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),color:Y().optional()}).describe("Defines a rectangular documentation note on the PCB"),hlt=OA({type:GA("pcb_note_path"),pcb_note_path_id:Vt("pcb_note_path"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),route:be(Go),stroke_width:Ae.default("0.1mm"),color:Y().optional()}).describe("Defines a polyline documentation note on the PCB"),ult=OA({type:GA("pcb_note_line"),pcb_note_line_id:Vt("pcb_note_line"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),x1:mt,y1:mt,x2:mt,y2:mt,stroke_width:mt.default("0.1mm"),color:Y().optional(),is_dashed:ce().optional()}).describe("Defines a straight documentation note line on the PCB"),dlt=OA({type:GA("pcb_note_dimension"),pcb_note_dimension_id:Vt("pcb_note_dimension"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),from:Go,to:Go,text:Y().optional(),text_ccw_rotation:WA().optional(),offset_distance:Ae.optional(),offset_direction:OA({x:WA(),y:WA()}).optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:Ae.default("1mm"),color:Y().optional(),arrow_size:Ae.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),plt=OA({type:GA("pcb_footprint_overlap_error"),pcb_error_id:Vt("pcb_error"),error_type:GA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:Y(),pcb_smtpad_ids:be(Y()).optional(),pcb_plated_hole_ids:be(Y()).optional(),pcb_hole_ids:be(Y()).optional(),pcb_keepout_ids:be(Y()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),flt=OA({type:GA("pcb_keepout"),shape:GA("rect"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,width:mt,height:mt,pcb_keepout_id:Y(),layers:be(Y()),description:Y().optional()}).or(OA({type:GA("pcb_keepout"),shape:GA("circle"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,radius:mt,pcb_keepout_id:Y(),layers:be(Y()),description:Y().optional()})),O5=OA({type:GA("pcb_cutout"),pcb_cutout_id:Vt("pcb_cutout"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_board_id:Y().optional(),pcb_panel_id:Y().optional()}),ylt=O5.extend({shape:GA("rect"),center:Go,width:Ae,height:Ae,rotation:Gd.optional(),corner_radius:Ae.optional()}),wlt=O5.extend({shape:GA("circle"),center:Go,radius:Ae}),mlt=O5.extend({shape:GA("polygon"),points:be(Go)}),Dlt=O5.extend({shape:GA("path"),route:be(Go),slot_width:Ae,slot_length:Ae.optional(),space_between_slots:Ae.optional(),slot_corner_radius:Ae.optional()}),Slt=Jp("shape",[ylt,wlt,mlt,Dlt]).describe("Defines a cutout on the PCB, removing board material."),blt=OA({type:GA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Vt("pcb_missing_footprint_error"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),error_type:GA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:Y(),message:Y()}).describe("Defines a missing footprint error on the PCB"),xlt=OA({type:GA("external_footprint_load_error"),external_footprint_load_error_id:Vt("external_footprint_load_error"),pcb_component_id:Y(),source_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),footprinter_string:Y().optional(),error_type:GA("external_footprint_load_error").default("external_footprint_load_error"),message:Y()}).describe("Defines an error when an external footprint fails to load"),klt=OA({type:GA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Vt("circuit_json_footprint_load_error"),pcb_component_id:Y(),source_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),error_type:GA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:Y(),circuit_json:be(YI()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),Glt=OA({type:GA("pcb_group"),pcb_group_id:Vt("pcb_group"),source_group_id:Y(),is_subcircuit:ce().optional(),subcircuit_id:Y().optional(),width:Ae.optional(),height:Ae.optional(),center:Go,display_offset_x:Y().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:Y().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:be(Go).optional(),anchor_position:Go.optional(),anchor_alignment:EF.default("center"),position_mode:Bt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:Y().optional(),positioned_relative_to_pcb_board_id:Y().optional(),pcb_component_ids:be(Y()),child_layout_mode:Bt(["packed","none"]).optional(),name:Y().optional(),description:Y().optional(),layout_mode:Y().optional(),autorouter_configuration:OA({trace_clearance:Ae}).optional(),autorouter_used_string:Y().optional()}).describe("Defines a group of components on the PCB"),Flt=OA({type:GA("pcb_autorouting_error"),pcb_error_id:Vt("pcb_autorouting_error"),error_type:GA("pcb_autorouting_error").default("pcb_autorouting_error"),message:Y(),subcircuit_id:Y().optional()}).describe("The autorouting has failed to route a portion of the board"),Rlt=OA({type:GA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Vt("pcb_manual_edit_conflict_warning"),warning_type:GA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:Y(),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),source_component_id:Y()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),Mlt=OA({type:GA("pcb_breakout_point"),pcb_breakout_point_id:Vt("pcb_breakout_point"),pcb_group_id:Y(),subcircuit_id:Y().optional(),source_trace_id:Y().optional(),source_port_id:Y().optional(),source_net_id:Y().optional(),x:mt,y:mt}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),Nlt=OA({type:GA("pcb_ground_plane"),pcb_ground_plane_id:Vt("pcb_ground_plane"),source_pcb_ground_plane_id:Y(),source_net_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Defines a ground plane on the PCB"),_lt=OA({type:GA("pcb_ground_plane_region"),pcb_ground_plane_region_id:Vt("pcb_ground_plane_region"),pcb_ground_plane_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:vr,points:be(Go)}).describe("Defines a polygon region of a ground plane"),vlt=OA({type:GA("pcb_thermal_spoke"),pcb_thermal_spoke_id:Vt("pcb_thermal_spoke"),pcb_ground_plane_id:Y(),shape:Y(),spoke_count:WA(),spoke_thickness:mt,spoke_inner_diameter:mt,spoke_outer_diameter:mt,pcb_plated_hole_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),aCA=OA({type:GA("pcb_copper_pour"),pcb_copper_pour_id:Vt("pcb_copper_pour"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:vr,source_net_id:Y().optional(),covered_with_solder_mask:ce().optional().default(!0)}),Ult=aCA.extend({shape:GA("rect"),center:Go,width:Ae,height:Ae,rotation:Gd.optional()}),Llt=aCA.extend({shape:GA("brep"),brep_shape:EBt}),Hlt=aCA.extend({shape:GA("polygon"),points:be(Go)}),Ylt=Jp("shape",[Ult,Llt,Hlt]).describe("Defines a copper pour on the PCB."),Jlt=OA({type:GA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Vt("pcb_component_outside_board_error"),error_type:GA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:Y(),pcb_component_id:Y(),pcb_board_id:Y(),component_center:Go,component_bounds:OA({min_x:WA(),max_x:WA(),min_y:WA(),max_y:WA()}),subcircuit_id:Y().optional(),source_component_id:Y().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),Tlt=OA({type:GA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Vt("pcb_component_invalid_layer_error"),error_type:GA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:Y(),pcb_component_id:Y().optional(),source_component_id:Y(),layer:vr,subcircuit_id:Y().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),Klt=OA({type:GA("pcb_via_clearance_error"),pcb_error_id:Vt("pcb_error"),error_type:GA("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:Y(),pcb_via_ids:be(Y()).min(2),minimum_clearance:mt.optional(),actual_clearance:mt.optional(),pcb_center:OA({x:WA().optional(),y:WA().optional()}).optional(),subcircuit_id:Y().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),qlt=OA({type:GA("pcb_courtyard_rect"),pcb_courtyard_rect_id:Vt("pcb_courtyard_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,width:Ae,height:Ae,layer:Km,color:Y().optional()}).describe("Defines a courtyard rectangle on the PCB"),Plt=OA({type:GA("pcb_courtyard_outline"),pcb_courtyard_outline_id:Vt("pcb_courtyard_outline"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Km,outline:be(Go).min(2),stroke_width:Ae.default("0.1mm"),is_closed:ce().optional(),is_stroke_dashed:ce().optional(),color:Y().optional()}).describe("Defines a courtyard outline on the PCB"),Olt=OA({type:GA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Vt("pcb_courtyard_polygon"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Km,points:be(Go).min(3),color:Y().optional()}).describe("Defines a courtyard polygon on the PCB"),Wlt=OA({type:GA("cad_component"),cad_component_id:Y(),pcb_component_id:Y(),source_component_id:Y(),position:nCA,rotation:nCA.optional(),size:nCA.optional(),layer:vr.optional(),subcircuit_id:Y().optional(),footprinter_string:Y().optional(),model_obj_url:Y().optional(),model_stl_url:Y().optional(),model_3mf_url:Y().optional(),model_gltf_url:Y().optional(),model_glb_url:Y().optional(),model_step_url:Y().optional(),model_wrl_url:Y().optional(),model_unit_to_mm_scale_factor:WA().optional(),model_jscad:YI().optional(),show_as_translucent_model:ce().optional()}).describe("Defines a component on the PCB"),GVA=Bt(["sinewave","square","triangle","sawtooth"]),Zlt=ei([Y(),WA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(WA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),Vlt=OA({type:GA("simulation_voltage_source"),simulation_voltage_source_id:Vt("simulation_voltage_source"),is_dc_source:GA(!0).optional().default(!0),positive_source_port_id:Y().optional(),negative_source_port_id:Y().optional(),positive_source_net_id:Y().optional(),negative_source_net_id:Y().optional(),voltage:a_}).describe("Defines a DC voltage source for simulation"),jlt=OA({type:GA("simulation_voltage_source"),simulation_voltage_source_id:Vt("simulation_voltage_source"),is_dc_source:GA(!1),terminal1_source_port_id:Y().optional(),terminal2_source_port_id:Y().optional(),terminal1_source_net_id:Y().optional(),terminal2_source_net_id:Y().optional(),voltage:a_.optional(),frequency:P5.optional(),peak_to_peak_voltage:a_.optional(),wave_shape:GVA.optional(),phase:Gd.optional(),duty_cycle:Zlt.optional()}).describe("Defines an AC voltage source for simulation"),zlt=ei([Vlt,jlt]).describe("Defines a voltage source for simulation"),Xlt=ei([Y(),WA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(WA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),$lt=OA({type:GA("simulation_current_source"),simulation_current_source_id:Vt("simulation_current_source"),is_dc_source:GA(!0).optional().default(!0),positive_source_port_id:Y().optional(),negative_source_port_id:Y().optional(),positive_source_net_id:Y().optional(),negative_source_net_id:Y().optional(),current:iCA}).describe("Defines a DC current source for simulation"),ACt=OA({type:GA("simulation_current_source"),simulation_current_source_id:Vt("simulation_current_source"),is_dc_source:GA(!1),terminal1_source_port_id:Y().optional(),terminal2_source_port_id:Y().optional(),terminal1_source_net_id:Y().optional(),terminal2_source_net_id:Y().optional(),current:iCA.optional(),frequency:P5.optional(),peak_to_peak_current:iCA.optional(),wave_shape:GVA.optional(),phase:Gd.optional(),duty_cycle:Xlt.optional()}).describe("Defines an AC current source for simulation"),eCt=ei([$lt,ACt]).describe("Defines a current source for simulation"),tCt=ei([GA("spice_dc_sweep"),GA("spice_dc_operating_point"),GA("spice_transient_analysis"),GA("spice_ac_analysis")]),iCt=OA({type:GA("simulation_experiment"),simulation_experiment_id:Vt("simulation_experiment"),name:Y(),experiment_type:tCt,time_per_step:oCA.optional(),start_time_ms:g_.optional(),end_time_ms:g_.optional()}).describe("Defines a simulation experiment configuration"),oCt=OA({type:GA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Vt("simulation_transient_voltage_graph"),simulation_experiment_id:Y(),timestamps_ms:be(WA()).optional(),voltage_levels:be(WA()),source_component_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),time_per_step:oCA,start_time_ms:g_,end_time_ms:g_,name:Y().optional(),color:Y().optional()}).describe("Stores voltage measurements over time for a simulation"),nCt=OA({type:GA("simulation_switch"),simulation_switch_id:Vt("simulation_switch"),source_component_id:Y().optional(),closes_at:g_.optional(),opens_at:g_.optional(),starts_closed:ce().optional(),switching_frequency:P5.optional()}).describe("Defines a switch for simulation timing control"),sCt=OA({type:GA("simulation_voltage_probe"),simulation_voltage_probe_id:Vt("simulation_voltage_probe"),source_component_id:Y().optional(),name:Y().optional(),signal_input_source_port_id:Y().optional(),signal_input_source_net_id:Y().optional(),reference_input_source_port_id:Y().optional(),reference_input_source_net_id:Y().optional(),subcircuit_id:Y().optional(),color:Y().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,o=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&o?A.addIssue({code:Ot.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:Ot.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):o&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:Ot.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:Ot.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),rCt=OA({type:GA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Vt("simulation_unknown_experiment_error"),error_type:GA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:Y(),simulation_experiment_id:Y().optional(),subcircuit_id:Y().optional()}).describe("An unknown error occurred during the simulation experiment."),aCt=OA({type:GA("simulation_op_amp"),simulation_op_amp_id:Vt("simulation_op_amp"),source_component_id:Y().optional(),inverting_input_source_port_id:Y(),non_inverting_input_source_port_id:Y(),output_source_port_id:Y(),positive_supply_source_port_id:Y(),negative_supply_source_port_id:Y()}).describe("Defines a simple ideal operational amplifier for simulation");ei([Rct,Gct,Fct,kct,Nct,Mct,nVA,tVA,sCA,oVA,iVA,sVA,rVA,aVA,cVA,BVA,lVA,uVA,CVA,QVA,EVA,hVA,IVA,gVA,vct,Lct,_ct,dVA,pVA,fVA,Hct,Yct,dBt,pBt,blt,xlt,klt,Rlt,bBt,flt,xBt,zBt,TBt,OBt,XBt,_Bt,JBt,$Bt,Alt,Glt,tlt,ilt,olt,nlt,Ilt,slt,rlt,alt,glt,WBt,ZBt,elt,VBt,jBt,Klt,Blt,clt,llt,Clt,Qlt,Elt,hlt,ult,dlt,Flt,plt,Mlt,Slt,Nlt,_lt,vlt,Ylt,Jlt,Tlt,qlt,Plt,Olt,Jct,ABt,Zct,Vct,jct,zct,Wct,eBt,Xct,Tct,iBt,oBt,tBt,aBt,gBt,IBt,cBt,CBt,BBt,lBt,Wlt,zlt,eCt,iCt,oCt,nCt,sCt,rCt,aCt]);var gCt=Object.defineProperty,ICt=(t,A)=>{for(var e in A)gCt(t,e,{get:A[e],enumerable:!0})},DS={};ICt(DS,{axial:()=>MQt,bga:()=>TCt,breakoutheaders:()=>OQt,cap:()=>hCt,dfn:()=>CQt,diode:()=>ECt,dip:()=>lCt,electrolytic:()=>kut,hc49:()=>ZQt,jst:()=>zht,led:()=>uCt,lqfp:()=>qQt,m2host:()=>jut,melf:()=>sht,micromelf:()=>Iht,minimelf:()=>XEt,mlp:()=>zCt,ms012:()=>fQt,ms013:()=>wQt,msop:()=>rut,pad:()=>VQt,pinrow:()=>hQt,platedhole:()=>Jut,potentiometer:()=>Sut,pushbutton:()=>LQt,qfn:()=>ZCt,qfp:()=>jCt,quad:()=>c_,radial:()=>vQt,res:()=>HCt,sma:()=>Cht,smb:()=>yht,smbf:()=>Fut,smc:()=>Sht,smf:()=>uht,smtpad:()=>Hut,sod110:()=>$ht,sod123:()=>kQt,sod123f:()=>GEt,sod123fl:()=>NEt,sod123w:()=>IEt,sod128:()=>TEt,sod323:()=>CEt,sod323f:()=>SEt,sod323fl:()=>lut,sod323w:()=>gut,sod523:()=>AEt,sod723:()=>LEt,sod80:()=>sEt,sod882:()=>yEt,sod882d:()=>tht,sod923:()=>uEt,soic:()=>qCt,solderjumper:()=>uut,son:()=>hut,sop8:()=>oEt,sot:()=>Kut,sot223:()=>Ght,sot23:()=>rQt,sot23w:()=>Hht,sot25:()=>cQt,sot323:()=>_ut,sot343:()=>Out,sot363:()=>iQt,sot457:()=>fut,sot563:()=>dQt,sot723:()=>DQt,sot886:()=>nQt,sot89:()=>ZEt,sot963:()=>wut,ssop:()=>$Ct,stampboard:()=>YQt,stampreceiver:()=>KQt,to220:()=>jEt,to92:()=>XQt,to92l:()=>Xut,to92s:()=>Pht,tqfp:()=>VCt,tssop:()=>eQt,vssop:()=>out});var Yi=(t,A,e)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:e,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:A},anchor_alignment:"center"}),Ji=OA({norefdes:ce().optional().describe("disable reference designator label"),invert:ce().optional().describe("hint to invert the orientation of the 3D model"),faceup:ce().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:ce().optional().describe("omit all silkscreen elements from the footprint")}),Pn=(t,A,e,i,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:mr(i),outer_diameter:mr(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),SS=(t,A,e,i,o,n,s,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:A,y:e,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:[t.toString()],hole_offset_x:s,hole_offset_y:r}),FVA=Array.from({length:9},(t,A)=>Math.cos(A/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)}));function Ux(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var W5=ei([Y(),WA()]).transform(t=>Ux(t)),cCt=t=>Ji.extend({fn:Y(),num_pins:WA().optional().default(6),wide:ce().optional(),narrow:ce().optional(),w:W5.optional(),p:W5.default(t.p??"2.54mm"),id:W5.optional(),od:W5.optional(),nosquareplating:ce().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=Ux("0.55mm"),A.od=Ux("0.95mm")):(A.id=Ux("0.8mm"),A.od=Ux("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=Ux("600mil"):A.narrow?A.w=Ux("300mil"):A.w=Ux(t.w??"300mil")),A)),BCt=cCt({}),RVA=(t,A,e,i,o)=>{const n=t/2,s=A<=n,r=n-1,a=i,g=a*r;return s?{x:-e/2,y:g/2-(A-1)*a}:{x:e/2,y:-g/2+(A-n-1)*a}},lCt=t=>{const A=BCt.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:I,y:c}=RVA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating);if(g===0&&!A.nosquareplating){e.push(SS(g+1,I,c,A.id??"0.8mm",A.od??"1mm",A.od??"1mm"));continue}e.push(Pn(g+1,I,c,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},...FVA.map(({x:g,y:I})=>({x:g*o/6,y:I*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 I=g<A.num_pins/2,c=.6,{y:B}=RVA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating),l=I?-A.w/2-A.od/2-c:A.w/2+A.od/2+c,C=B;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:l,y:C},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Yi(0,n/2+.5,.4);return{circuitJson:[...e,s,a,...r],parameters:A}},Qi=(t,A,e,i,o)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:o,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),MVA=[{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}],CCt=Object.fromEntries(MVA.map(t=>[t.metric,t])),QCt=Object.fromEntries(MVA.map(t=>[t.imperial,t]));Ji.extend({tht:ce(),p:Ae.optional(),pw:Ae.optional(),ph:Ae.optional(),metric:mt.optional(),imperial:mt.optional(),w:Ae.optional(),h:Ae.optional(),textbottom:ce().optional()});var Z5=t=>{let{tht:A,p:e,pw:i,ph:o,metric:n,imperial:s,w:r,h:a,textbottom:g}=t;if(typeof r=="string"&&(r=mB(r)),typeof a=="string"&&(a=mB(a)),typeof e=="string"&&(e=mB(e)),typeof i=="string"&&(i=mB(i)),typeof o=="string"&&(o=mB(o)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let I;if(n&&(I=CCt[n]),s&&(I=QCt[s]),I&&(r=I.w_mm_min,a=I.h_mm_min,e=I.p_mm_min,i=I.pw_mm_min,o=I.ph_mm_min),e===void 0||i===void 0||o===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:e/2,y:o/2+.4},{x:-e/2-i/2-.2,y:o/2+.4},{x:-e/2-i/2-.2,y:-o/2-.4},{x:e/2,y:-o/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},B=g?-o/2-.9:o/2+.9,l=Yi(0,B,.2);return A?[Pn(1,-e/2,0,i,i*1/.8),Pn(2,e/2,0,i,i*1/.8),c,l]:[Qi(["1","left"],-e/2,0,i,o),Qi(["2","right"],e/2,0,i,o),c,l]},ECt=t=>({circuitJson:Z5(t),parameters:t}),hCt=t=>({circuitJson:Z5(t),parameters:t}),uCt=t=>({circuitJson:Z5(t),parameters:t}),I_=t=>{const{padSpacing:A,padWidth:e,padHeight:i,padPitch:o,numRows:n,textbottom:s}=t,r=[],a=(n-1)*(o/2);for(let x=0;x<n;x++)r.push(a-x*o);const g=[];r.forEach((x,F)=>{g.push(Qi(F+1,-A/2,x,e,i))}),r.slice().reverse().forEach((x,F)=>{g.push(Qi(F+n+1,A/2,x,e,i))});const I=Math.max(...r)+i/2+.4,c=Math.min(...r)-i/2-.4,B=-A/2-e/2-.4,l=A/2+e/2+.4,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l*.5,y:I},{x:B*.5,y:I}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l*.5,y:c},{x:B*.5,y:c}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},E=-A/2,h=Math.max(...r),u=.2,d=E-e/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},S=s?c-.9:I+.9,D=Yi(0,S,.2);return[...g,C,Q,m,D]},dCt=Ji.extend({pw:Y().default("0.5mm"),ph:Y().default("0.4mm"),p:Y().default("0.7mm"),textbottom:ce().optional()}),pCt=1,fCt=t=>{const A=dCt.parse(t),e=mB(A.pw),i=mB(A.ph),o=mB(A.p);return I_({padSpacing:pCt,padWidth:e,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},yCt=Ji.extend({pw:Y().default("0.5mm"),ph:Y().default("0.32mm"),p:Y().default("0.5mm"),textbottom:ce().optional()}),wCt=1,mCt=t=>{const A=yCt.parse(t),e=mB(A.pw),i=mB(A.ph),o=mB(A.p);return I_({padSpacing:wCt,padWidth:e,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},DCt=Ji.extend({pw:Y().default("0.9mm"),ph:Y().default("0.4mm"),p:Y().default("0.8mm"),textbottom:ce().optional()}),SCt=1.7,bCt=t=>{const A=DCt.parse(t),e=mB(A.pw),i=mB(A.ph),o=mB(A.p);return I_({padSpacing:SCt,padWidth:e,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},xCt=Ji.extend({pw:Y().default("0.9mm"),ph:Y().default("0.4mm"),p:Y().default("0.8mm"),textbottom:ce().optional()}),kCt=1.7,GCt=t=>{const A=xCt.parse(t),e=mB(A.pw),i=mB(A.ph),o=mB(A.p);return I_({padSpacing:kCt,padWidth:e,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},FCt=Ji.extend({pw:Y().default("0.7mm"),ph:Y().default("0.64mm"),p:Y().default("0.94mm"),textbottom:ce().optional()}),RCt=1.4,MCt=t=>{const A=FCt.parse(t),e=mB(A.pw),i=mB(A.ph),o=mB(A.p);return I_({padSpacing:RCt,padWidth:e,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},NCt=Ji.extend({pw:Y().default("0.9mm"),ph:Y().default("0.9mm"),p:Y().default("1.34mm"),textbottom:ce().optional()}),_Ct=3,vCt=t=>{const A=NCt.parse(t),e=mB(A.pw),i=mB(A.ph),o=mB(A.p);return I_({padSpacing:_Ct,padWidth:e,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},UCt=t=>{const A=t.array??t.x;if(typeof A=="number")return Number.isNaN(A)?void 0:A;if(typeof A=="string"){const e=Number.parseInt(A,10);return Number.isNaN(e)?void 0:e}if(typeof t.imperial=="string"){const i=t.imperial.match(/(?:array|x)(2|4)$/)?.[1];if(i)return Number.parseInt(i,10)}},LCt=t=>t?(typeof t=="number"?`${t}`:t).split("_")[0]:void 0,HCt=t=>{const A=UCt(t),e=LCt(t.imperial);return A===2&&e==="0402"?{circuitJson:fCt(t),parameters:t}:A===4&&e==="0402"?{circuitJson:mCt(t),parameters:t}:A===2&&e==="0603"?{circuitJson:bCt(t),parameters:t}:A===4&&e==="0603"?{circuitJson:GCt(t),parameters:t}:A===2&&e==="0606"?{circuitJson:MCt(t),parameters:t}:A===4&&e==="1206"?{circuitJson:vCt(t),parameters:t}:{circuitJson:Z5(t),parameters:t}},NVA=(t,{x:A,y:e,radius:i})=>({type:"pcb_smtpad",x:A,y:e,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),_VA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",vVA=Y().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A),y:parseFloat(e)}}).pipe(OA({x:WA(),y:WA()})),YCt=Y().or(be(YI())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(A=>{const e=Number(A);return isNaN(e)?A:e}))).pipe(be(Y().or(WA()))),JCt=Ji.extend({fn:Y(),num_pins:WA().optional().default(64),grid:vVA.optional(),p:mt.default("0.8mm"),w:Ae.optional(),h:Ae.optional(),ball:Ae.optional().describe("ball diameter"),pad:Ae.optional().describe("pad width/height"),circularpads:ce().optional().describe("use circular pads"),tlorigin:ce().optional(),blorigin:ce().optional(),trorigin:ce().optional(),brorigin:ce().optional(),missing:YCt.default([])}).transform(t=>{let A="tl";if(t.blorigin&&(A="bl"),t.trorigin&&(A="tr"),t.brorigin&&(A="br"),!t.grid){const i=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:i,y:i}}return t.missing&&(t.missing=t.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=_VA.indexOf(o[1]),s=Number.parseInt(o[2])-1;return n*t.grid.x+s+1})),{...t,origin:A}}),TCt=t=>{const A=JCt.parse(t);let{num_pins:e,grid:i,p:o,w:n,h:s,ball:r,pad:a,missing:g}=A;r??=.75/1.27*o,a??=r*.8;const I=[],c=(g??[]).filter(m=>typeof m=="number"),B=i.x*i.y-e;if(g.length===0&&B>0&&(Math.sqrt(B)%1===0?g.push("center"):B===1&&g.push("topleft")),g?.includes("center")){const m=Math.floor(Math.sqrt(B)),S=Math.floor((i.x-m)/2),D=Math.floor((i.y-m)/2);for(let x=D;x<D+m;x++)for(let F=S;F<S+m;F++)c.push(x*i.x+F+1)}g?.includes("topleft")&&c.push(1);const l=new Set(c);let C=0;for(let m=0;m<i.y;m++)for(let S=0;S<i.x;S++){const D=(S-(i.x-1)/2)*o,x=(m-(i.y-1)/2)*o;let F=S,k=m;switch(A.origin){case"bl":F=S,k=i.y-1-m;break;case"br":F=i.x-1-S,k=i.y-1-m;break;case"tr":F=i.x-1-S,k=m;break}let v=k*i.x+F+1;if(l.has(v)){C++;continue}v-=C;const _=[v,`${_VA[k]}${F+1}`];I.push(A.circularpads?NVA(_,{x:D,y:x,radius:a/2}):Qi(_,D,x,a,a))}const Q=Yi(0,i.y*o/2,.2),E=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-E},{x:-u-E,y:-d},{x:-u,y:-d}];break;case"br":h=[{x:u,y:-d},{x:u,y:-d-E},{x:u+E,y:-d},{x:u,y:-d}];break;case"tr":h=[{x:u,y:d},{x:u,y:d+E},{x:u+E,y:d},{x:u,y:d}];break;default:h=[{x:-u,y:d},{x:-u,y:d+E},{x:-u-E,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:[...I,Q,f],parameters:A}},V5=(t,A,e,i,o)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:o,radius:o/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),qm=t=>Ji.extend({fn:Y(),num_pins:WA().optional().default(8),w:Ae.default(Ae.parse(t.w??"5.3mm")),p:Ae.default(Ae.parse(t.p??"1.27mm")),pw:Ae.default(Ae.parse(t.pw??"0.6mm")),pl:Ae.default(Ae.parse(t.pl??"1.0mm")),legsoutside:ce().optional().default(t.legsoutside??!1),pillpads:ce().optional().default(t.pillpads??!1),silkscreen_stroke_width:WA().optional().default(.1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=Ae.parse("0.6mm"),A.pl=Ae.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),KCt=qm({}),gCA=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:A,pn:e,w:i,p:o,pl:n,legsoutside:s}=t,r=A/2,a=e<=r,g=r-1,I=o,c=I*g,B=s?n/2:-n/2;return a?{x:-i/2-B,y:c/2-(e-1)*I}:{x:i/2+B,y:-c/2+(e-r-1)*I}},qCt=t=>{const A=KCt.parse(t);return{circuitJson:Lx(A),parameters:A}},Lx=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=gCA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push(V5(r+1,a,g,t.pl,t.pw)):A.push(Qi(r+1,a,g,t.pl,t.pw))}const e=Math.min(1,t.p/2),i=t.w-(t.legsoutside?0:t.pl*2)-.2,o=(t.num_pins/2-1)*t.p+t.pw+e,n=Yi(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:t.silkscreen_stroke_width??.1,route:[{x:-i/2,y:-o/2},{x:-i/2,y:o/2},...FVA.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]},UVA=Bt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),PCt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const o=[],n=t/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<t;a++)o[s]=a+1,e||!A?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return o},ICA=Ji.extend({fn:Y(),cc:ce().default(!0).optional(),ccw:ce().default(!0).optional(),startingpin:Y().or(be(UVA)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(be(UVA)).optional(),num_pins:WA().optional().default(64),w:Ae.optional(),h:Ae.optional(),p:Ae.default(Ae.parse("0.5mm")),pw:Ae.optional(),pl:Ae.optional(),thermalpad:ei([GA(!0),vVA]).optional(),legsoutside:ce().default(!1)}),cCA=t=>{t.w&&!t.h?t.h=t.w:!t.w&&t.h&&(t.w=t.h);const A=t.num_pins/4;if(!t.p&&!t.pw&&!t.pl&&t.w){const e=A+4;t.p=t.w/e}return!t.p&&t.w&&t.h&&t.pw&&t.pl&&(t.p=(t.w-t.pl*2)/(A-1)),!t.w&&!t.h&&t.p&&(t.w=t.p*(A+4),t.h=t.w),t.p&&!t.pw&&!t.pl?(t.pw=t.p/2,t.pl=t.p/2):t.pw?t.pl||(t.pl=t.pw*(1/.6)):t.pw=t.pl*(.6/1),t},LVA=ICA.transform(cCA),OCt=["left","bottom","right","top"],WCt=t=>{const{pin_count:A,pn:e,w:i,h:o,p:n,pl:s,legsoutside:r}=t,a=A/4,g=OCt[Math.floor((e-1)/a)],I=(e-1)%a,c=n*(a-1),B=n*(a-1),l=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-l+.1,y:B/2-I*n,o:"vert"};case"bottom":return{x:-c/2+I*n,y:-o/2-l+.1,o:"horz"};case"right":return{x:i/2+l-.1,y:-B/2+I*n,o:"vert"};case"top":return{x:c/2-I*n,y:o/2+l-.1,o:"horz"};default:throw new Error("Invalid pin number")}},c_=t=>{const A=LVA.parse(t),e=[],i=PCt(A),o=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:I}=WCt({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 c=A.pw,B=A.pl;I==="vert"&&([c,B]=[B,c]);const l=i[r+1];e.push(Qi(l,a,g,c,B))}if(A.thermalpad)if(typeof A.thermalpad=="boolean"){const r=A.p*(o-1)+A.pw,a=A.p*(o-1)+A.pw;e.push(Qi(["thermalpad"],0,0,r,a))}else e.push(Qi(["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 I=A.w/2*a,c=A.h/2*g;let B="none",l=I,C=c;const Q=A.pw*2;i[1]===1&&r==="top-left"?B="in1":i[o*4]===1&&r==="top-left"||i[o*3+1]===1&&r==="top-right"?B="in2":i[o*3]===1&&r==="top-right"||i[o]===1&&r==="bottom-left"?B="in1":i[o+1]===1&&r==="bottom-left"?B="in2":i[o*2]===1&&r==="bottom-right"?B="in1":i[o*2+1]===1&&r==="bottom-right"&&(B="in2");const E=B==="in1"?1:-1;if(A.legsoutside){const h=B==="in1"?A.pl/2:A.pw/2,u=B==="in1"?A.pw/2:A.pl/2;l+=h*a*E,C-=u*g*E}(B==="none"||A.legsoutside)&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:I-Q*a,y:c},{x:I,y:c},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&!A.legsoutside&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:I-Q*a,y:c},{x:I-Q*a/2,y:c}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:I,y:c-Q*g/2},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:l-.2*-a,y:C+.2*E},{x:l,y:C},{x:l+.2*E*-a,y:C+.2},{x:l-.2*-a,y:C+.2*E}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Yi(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...n,s],parameters:A}};ICA.extend({}).transform(cCA);var ZCt=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),c_(t)),VCt=t=>{if(t.legsoutside=!0,!t.p)switch(t.num_pins){case 32:t.p=.8;break;case 44:case 48:t.p=.5;break;case 64:case 80:case 100:t.p=.5;break;case 144:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 32:case 44:case 48:case 64:case 80:case 100:t.pl=1.475;break;case 144:t.pl=1.6;break}if(!t.pw)switch(t.num_pins){case 32:t.pw=.55;break;case 44:case 48:case 64:case 80:case 100:t.pw=.3;break;case 144:t.pw=.25;break}return c_(t)},jCt=t=>{t.legsoutside=!0;const A=LVA.parse(t);if(!t.p)switch(t.num_pins){case 44:case 64:t.p=.8;break;case 52:t.w===14?t.p=1:t.p=.65;break;case 208:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 44:case 52:case 64:t.pl=2.25;break;case 208:t.pl=1.65;break;default:t.pl=A.pl*4;break}if(!t.pw)switch(t.num_pins){case 44:case 64:t.pw=.5;break;case 52:t.w===14?t.pw=.45:t.pw=.55;break;case 208:t.pw=.3;break;default:t.pw=A.pw;break}return c_(t)};ICA.extend({}).transform(cCA);var zCt=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),c_(t)),XCt=qm({w:"3.9mm",p:"1.27mm"}),$Ct=t=>{const A=XCt.parse(t);return{circuitJson:Lx(A),parameters:A}},AQt=qm({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),eQt=t=>{const A=AQt.parse(t);return{circuitJson:Lx(A),parameters:A}},tQt=qm({}),iQt=t=>{const A=tQt.parse({fn:"sot363",num_pins:6,w:2.56,p:.65,pw:.4,pl:.65,legoutside:!0});return{circuitJson:Lx(A),parameters:A}},oQt=Ji.extend({fn:Y(),num_pins:GA(6).default(6),w:Y().default("1.01mm"),h:Y().default("1.45mm"),p:Y().default("0.5mm"),pl:Y().default("0.33mm"),pw:Y().default("0.27mm"),string:Y().optional()}),nQt=t=>{const A=oQt.parse({fn:"sot886",...t}),e=Ae.parse(A.w),i=Ae.parse(A.h),o=Ae.parse(A.p),n=Ae.parse(A.pl),s=Ae.parse(A.pw),r=[];for(let l=0;l<6;l++){const{x:C,y:Q}=HVA(l+1,e,o,n);r.push(Qi(l+1,C,Q,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=HVA(1,e,o,n),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-n/2-.3,y:I.y},{x:I.x-n/2-.45,y:I.y+.15},{x:I.x-n/2-.45,y:I.y-.15},{x:I.x-n/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},B=Yi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,B,c],parameters:A}},HVA=(t,A,e,i)=>{const o=A/2-i/2;return t<=3?{x:-o,y:e-(t-1)*e}:{x:o,y:-e+(t-4)*e}},YVA=Ji.extend({fn:Y(),num_pins:WA().default(3),w:Y().default("1.92mm"),h:Y().default("2.74mm"),pl:Y().default("1.32mm"),pw:Y().default("0.6mm"),p:Y().default("0.95mm"),string:Y().optional()}),sQt=qm({p:"0.95mm",w:"1.6mm",legsoutside:!0}),rQt=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const o=sQt.parse({...t,num_pins:e});return{circuitJson:Lx(o),parameters:o}}const i=YVA.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:gQt(i),parameters:i};if(i.num_pins===5)return{circuitJson:TVA(i),parameters:i};throw new Error("Invalid number of pins")},aQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-1.155,y:e}:A===2?{x:-1.155,y:-e}:{x:1.15,y:0}},gQt=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:o,y:n}=aQt({num_pins:t.num_pins,pn:i+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(i+1,o,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Yi(0,Number.parseInt(t.h),.3);return[...A,e]},JVA=t=>{const{p:A,h:e,pn:i}=t;if(i===1)return{x:-e/2-.5,y:A};if(i===2)return{x:-e/2-.5,y:0};if(i===3)return{x:-e/2-.5,y:-A};if(i===4)return{x:e/2+.5,y:-A};if(i===5)return{x:e/2+.5,y:A};throw new Error("Invalid pin number")},TVA=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:l}=JVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(Qi(c,B,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.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:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Yi(0,i+.3,.3),r=JVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.3,g=.4,I={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,I]},IQt=YVA.extend({}),cQt=t=>{const A=IQt.parse({...t,num_pins:5});return{circuitJson:TVA(A),parameters:A}},BQt=[{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}],lQt=qm({}),CQt=t=>{const A=lQt.parse(t),e=[];for(let c=0;c<A.num_pins;c++){const{x:B,y:l}=gCA({num_pins:A.num_pins,pn:c+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(Qi(c+1,B,l,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 c of BQt){const{dx:B,dy:l}=c;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:B*o/2-B*A.p,y:l*n/2},{x:B*o/2,y:l*n/2},{x:B*o/2,y:l*n/2-l*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 I=Yi(0,n/2+.4,n/12);return{circuitJson:[...e,I,...s],parameters:A}},BCA=({fs:t,pn:A,anchor_x:e,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:t,pcb_component_id:"pcb_component_1",text:`{PIN${A}}`,layer:r,anchor_position:{x:e,y:i},anchor_alignment:g,ccw_rotation:a}};function QQt({pinlabeltextalignleft:t,pinlabeltextalignright:A,pinlabelorthogonal:e}){let i="top";return e?i="left":i="top",t&&(e?i="bottom":i="right"),A&&(e?i="top":i="left"),i}var EQt=Ji.extend({fn:Y(),num_pins:WA().optional().default(6),rows:ei([Y(),WA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:Ae.default("0.1in").describe("pitch"),id:Ae.default("1.0mm").describe("inner diameter"),od:Ae.default("1.5mm").describe("outer diameter"),male:ce().optional().describe("for male pin headers"),female:ce().optional().describe("for female pin headers"),smd:ce().optional().describe("surface mount device"),surfacemount:ce().optional().describe("surface mount device (verbose)"),rightangle:ce().optional().describe("right angle"),pw:Ae.optional().default("1.0mm").describe("pad width for SMD"),pl:Ae.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:ce().optional().default(!1),pinlabeltextaligncenter:ce().optional().default(!1),pinlabeltextalignright:ce().optional().default(!1),pinlabelverticallyinverted:ce().optional().default(!1),pinlabelorthogonal:ce().optional().default(!1),nosquareplating:ce().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:ce().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:ce().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:ce().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=QQt(t);return{...t,pinlabelAnchorSide:A,male:t.male??!t.female,female:t.female??!1,smd:t.smd??t.surfacemount??!1,rightangle:t.rightangle??!1}}).superRefine((t,A)=>{t.male&&t.female&&A.addIssue({code:Ot.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),hQt=t=>{const A=EQt.parse(t),{p:e,id:i,od:o,rows:n,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:I,pinlabeltextalignright:c,nopinlabels:B,doublesidedpinlabel:l,bottomsidepinlabel:C}=A;let Q="center";I?Q="left":c&&(Q="right");const E=[],h=Math.ceil(s/n),u=-e,d=({xoff:x,yoff:F,od:k,anchorSide:v,smd:_,pw:H,pl:P})=>{let J=0,W=0;if(_){const Z=k/5;switch(v){case"right":J=H/2+Z;break;case"top":W=P/2+Z;break;case"bottom":W=-(P/2+Z);break;case"left":J=-(H/2+Z);break}}else{const Z=k*.75;switch(v){case"right":J=Z;break;case"top":W=Z;break;case"bottom":W=-Z;break;case"left":J=-Z;break}}return{anchor_x:x+J,anchor_y:F+W}},f=(x,F,k)=>{A.smd?E.push(Qi(x,F,k,A.pw,A.pl)):x===1&&!A.nosquareplating?E.push(SS(x,F,k,i,o,o,0,0)):E.push(Pn(x,F,k,i,o));const{anchor_x:v,anchor_y:_}=d({xoff:F,yoff:k,od:o,anchorSide:r,smd:A.smd,pw:A.pw,pl:A.pl});B||(C?E.push(BCA({fs:o/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):E.push(BCA({fs:o/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),l&&E.push(BCA({fs:o/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},m=new Set,S=n>2&&h>2;if(n===1){const x=-((s-1)/2)*e;for(let F=0;F<s;F++){const k=F+1,v=x+F*e,_=`${v},0`;if(m.has(_))throw new Error(`Overlap at ${_}`);m.add(_),f(k,v,0)}}else if(S){const x=-((h-1)/2)*e;let F=1;for(let k=0;k<n&&F<=s;k++)for(let v=0;v<h&&F<=s;v++){const _=x+v*e,H=k*u,P=`${_},${H}`;if(m.has(P))throw new Error(`Overlap at ${P}`);m.add(P),f(F++,_,H)}}else{const x=-((h-1)/2)*e;let F=1,k=0,v=n-1,_=0,H=h-1;for(;F<=s&&k<=v&&_<=H;){for(let P=k;P<=v&&F<=s;P++){const J=x+_*e,W=P*u,Z=`${J},${W}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(F++,J,W)}_++;for(let P=_;P<=H&&F<=s;P++){const J=x+P*e,W=v*u,Z=`${J},${W}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(F++,J,W)}if(v--,_<=H){for(let P=v;P>=k&&F<=s;P--){const J=x+H*e,W=P*u,Z=`${J},${W}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(F++,J,W)}H--}if(k<=v){for(let P=H;P>=_&&F<=s;P--){const J=x+P*e,W=k*u,Z=`${J},${W}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(F++,J,W)}k++}}if(F-1<s)throw new Error(`Missing pins: assigned ${F-1}, expected ${s}`)}const D=Yi(0,e,.5);return{circuitJson:[...E,D],parameters:A}},uQt=Ji.extend({fn:Y(),num_pins:GA(6).default(6),w:Y().default("2.1mm"),h:Y().default("2.45mm"),p:Y().default("0.5mm"),pl:Y().default("0.675mm"),pw:Y().default("0.35mm"),string:Y().optional()}),dQt=t=>{const A=uQt.parse({...t,fn:"sot563"}),e=Ae.parse(A.w),i=Ae.parse(A.h),o=Ae.parse(A.p),n=Ae.parse(A.pl),s=Ae.parse(A.pw),r=[];for(let l=0;l<6;l++){const{x:C,y:Q}=KVA(l+1,e,o,n);r.push(Qi(l+1,C,Q,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=KVA(1,e,o,n),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-n/2-.3,y:I.y},{x:I.x-n/2-.45,y:I.y+.15},{x:I.x-n/2-.45,y:I.y-.15},{x:I.x-n/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},B=Yi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,B,c],parameters:A}},KVA=(t,A,e,i)=>{const o=A/2-i/2;return t<=3?{x:-o,y:e-(t-1)*e}:{x:o,y:-e+(t-4)*e}},pQt=qm({p:"1.27mm",w:"3.9mm",legsoutside:!0}),fQt=t=>{const A=pQt.parse({...t,num_pins:8});return{circuitJson:Lx(A),parameters:A}},yQt=qm({p:"1.27mm",w:"7.5mm",legsoutside:!0}),wQt=t=>{const A=yQt.parse({...t,num_pins:16});return{circuitJson:Lx(A),parameters:A}},mQt=Ji.extend({fn:Y(),num_pins:GA(3).default(3),w:Y().default("1.2mm"),h:Y().default("1.2mm"),pw:Y().default("0.40mm"),pl:Y().default("0.45mm"),p:Y().default("0.575mm")}),DQt=t=>{const A=mQt.parse(t),e=bQt(A),i=Yi(0,Ae.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},SQt=t=>{const{pn:A,p:e}=t;return A===1?{x:e,y:0}:A===2?{x:-e,y:-.4}:{x:-e,y:.4}},bQt=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:o}=SQt({num_pins:t.num_pins,pn:e+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(e+1,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},xQt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("2.36mm"),h:Y().default("1.22mm"),pl:Y().default("0.9mm"),pw:Y().default("1.2mm"),p:Y().default("3.30mm")}),kQt=t=>{const A=xQt.parse(t),e=Yi(0,Ae.parse(A.h)/4+.4,.3);return{circuitJson:FQt(A).concat(e),parameters:A}},GQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},FQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=GQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},RQt=Ji.extend({fn:Y(),p:Ae.optional().default("2.54mm"),id:Ae.optional().default("0.7mm"),od:Ae.optional().default("1.4mm")}),MQt=t=>{const A=RQt.parse(t),{p:e,id:i,od:o}=A,n=[Pn(1,-e/2,0,i,o),Pn(2,e/2,0,i,o)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2+o+i/2,y:0},{x:e/2-o-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},r=Yi(0,1.5,.5);return{circuitJson:[...n,s,r],parameters:A}},NQt=(t,A,e,i,o,n=.1)=>{const s=[],r=[],a=Math.max(1,Math.ceil(Math.PI*e/n)),g=Math.PI/a;for(let I=0;I<=a;I++){const c=I*g,B=t+Math.cos(c)*e,l=A+Math.sin(c)*e;B<t-i&&l>=A-o/2&&l<=A+o/2||s.push({x:B,y:l})}for(let I=0;I<=a;I++){const c=Math.PI+I*g,B=t+Math.cos(c)*e,l=A+Math.sin(c)*e;B<t-i&&l>=A-o/2&&l<=A+o/2||r.push({x:B,y:l})}return{topArc:s,bottomArc:r}},_Qt=Ji.extend({fn:Y(),p:Ae.optional().default("5mm"),id:Ae.optional().default("0.8mm"),od:Ae.optional().default("1.6mm"),ceramic:ce().optional(),electrolytic:ce().optional(),polarized:ce().optional()}),vQt=t=>{const A=_Qt.parse(t),{p:e,id:i,od:o}=A;i===.8&&o===1.6&&(A.id=e===5?.8:e*.25,A.od=e===5?1.6:e*.5);const n=[Pn(1,-e/2,0,A.id,A.od),Pn(2,e/2,0,A.id,A.od)],s=e+.1,{topArc:r,bottomArc:a}=NQt(0,0,s,A.od/2,A.od),g=.02*e,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:g,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:g,pcb_silkscreen_path_id:""},B={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:""},l=.1*e,C=-(e+l+.04*e),Q=s-l-.08*e,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C-l,y:Q},{x:C+l,y:Q}],stroke_width:g,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C,y:Q-l},{x:C,y:Q+l}],stroke_width:g,pcb_silkscreen_path_id:""},u=Yi(0,s+.12*e,.1*e),d=[...n,I,c,B,u];return(A.electrolytic===!0||A.polarized===!0)&&d.push(E,h),{circuitJson:d,parameters:A}},j5=(t,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:t,stroke_width:A.stroke_width||.1}),UQt=Ji.extend({fn:GA("pushbutton"),w:Ae.default(4.5),h:Ae.default(6.5),id:Ae.default(1),od:Ae.default(1.2)}),LQt=t=>{const A=UQt.parse(t),e=A.w,i=A.h,o=A.id,n=[Pn(1,-e/2,i/2,o,o*1.5),Pn(2,-e/2,-i/2,o,o*1.5),Pn(3,e/2,-i/2,o,o*1.5),Pn(4,e/2,i/2,o,o*1.5)],s=[j5([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),j5([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),j5([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),j5([{x:e/2,y:0},{x:e/5,y:0}])],r=Yi(0,i/2+.4,.5);return{circuitJson:[...n,...s,r],parameters:A}},qVA=Ji.extend({fn:Y(),w:Ae.default("22.58mm"),h:Ae.optional(),left:Ae.optional().default(20),right:Ae.optional().default(20),top:Ae.optional().default(2),bottom:Ae.optional().default(2),p:Ae.default(Ae.parse("2.54mm")),pw:Ae.default(Ae.parse("1.6mm")),pl:Ae.default(Ae.parse("2.4mm")),innerhole:ce().default(!1),innerholeedgedistance:Ae.default(Ae.parse("1.61mm")),silkscreenlabels:ce().default(!1),silkscreenlabelmargin:Ae.default(Ae.parse("0.1mm"))}),HQt=t=>{const A=qVA.parse(t);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},z5=(t,A,e)=>{let i=[];return e==="right"&&(i=[{x:t+1/2,y:A},{x:t-1/2,y:A+.6/2},{x:t-1/2,y:A-.6/2},{x:t+1/2,y:A}]),e==="left"&&(i=[{x:t-1/2,y:A},{x:t+1/2,y:A+.6/2},{x:t+1/2,y:A-.6/2},{x:t-1/2,y:A}]),e==="top"&&(i=[{x:t,y:A+1/2},{x:t-.6/2,y:A-1/2},{x:t+.6/2,y:A-1/2},{x:t,y:A+1/2}]),e==="bottom"&&(i=[{x:t,y:A-1/2},{x:t-.6/2,y:A+1/2},{x:t+.6/2,y:A+1/2},{x:t,y:A-1/2}]),i},YQt=t=>{const A=qVA.parse(t),e=A.h??HQt(A),i=[],o=[],n=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),c=`pin${g}`.length*.7/2;if(A.right){const Q=-((A.right-1)/2)*A.p;for(let E=0;E<A.right;E++){if(E===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=z5(A.w/2-A.pl*1.4,Q+E*A.p,"right")),i.push(Qi(E+1+A.left+(A.bottom??0),A.w/2-A.pl/2,Q+E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+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-(c+A.silkscreenlabelmargin),y:Q+E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push(Pn(E+1+A.left+(A.bottom??0)+g,A.w/2,Q+E*A.p,r,a)),o.push(Pn(E+1+A.left+(A.bottom??0)+g*2,A.w/2-A.innerholeedgedistance,Q+E*A.p,r,a)))}}if(A.left){const Q=(A.left-1)/2*A.p;for(let E=0;E<A.left;E++){if(E===0&&!A.silkscreenlabels&&(s=z5(-A.w/2+A.pl*1.4,Q-E*A.p,"left")),i.push(Qi(E+1,-A.w/2+A.pl/2,Q-E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+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+(c+A.silkscreenlabelmargin),y:Q-E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push(Pn(E+1+g,-A.w/2,Q-E*A.p,r,a)),o.push(Pn(E+1+g*2,-A.w/2+A.innerholeedgedistance,Q-E*A.p,r,a)))}}if(A.top){const Q=(A.top-1)/2*A.p;for(let E=0;E<A.top;E++){if(E===0&&!A.left&&!A.bottom&&!A.right&&!A.silkscreenlabels&&(s=z5(Q-E*A.p,e/2-A.pl*1.4,"top")),i.push(Qi(E+1+A.left+A.right+(A.bottom??0),Q-E*A.p,e/2-A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+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:Q-E*A.p,y:e/2-A.pl-(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(o.push(Pn(E+1+A.left+A.right+(A.bottom??0)+g,Q-E*A.p,e/2,r,a)),o.push(Pn(E+1+A.left+A.right+(A.bottom??0)+g*2,Q-E*A.p,e/2-A.innerholeedgedistance,r,a)))}}if(A.bottom){const Q=-((A.bottom-1)/2)*A.p;for(let E=0;E<A.bottom;E++){if(E===0&&!A.left&&!A.silkscreenlabels&&(s=z5(Q+E*A.p,-e/2+A.pl*1.4,"bottom")),i.push(Qi(E+1+A.left,Q+E*A.p,-e/2+A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+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:Q+E*A.p,y:-e/2+A.pl+(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(o.push(Pn(E+1+A.left+g,Q+E*A.p,-e/2,r,a)),o.push(Pn(E+1+A.left+g*2,Q+E*A.p,-e/2+A.innerholeedgedistance,r,a)))}}const B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2,y:e/2},{x:A.w/2,y:e/2},{x:A.w/2,y:-e/2},{x:-A.w/2,y:-e/2},{x:-A.w/2,y:e/2}],stroke_width:.1,layer:"top"},C=Yi(0,e/1.8,e/25);return{circuitJson:[...i,...o,...n,l,...A.silkscreenlabels?[]:[B],C],parameters:A}},PVA=Ji.extend({fn:Y(),w:Ae.default("22.58mm"),h:Ae.optional(),left:Ae.optional().default(20),right:Ae.optional().default(20),top:Ae.optional().default(2),bottom:Ae.optional().default(2),p:Ae.default(Ae.parse("2.54mm")),pw:Ae.default(Ae.parse("1.6mm")),pl:Ae.default(Ae.parse("3.2mm")),innerhole:ce().default(!1),innerholeedgedistance:Ae.default(Ae.parse("1.61mm"))}),JQt=t=>{const A=PVA.parse(t);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},TQt=(t,A,e,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:t+n,y:A},{x:t-n,y:A+s},{x:t-n,y:A-s},{x:t+n,y:A}],right:[{x:t-n,y:A},{x:t+n,y:A+s},{x:t+n,y:A-s},{x:t-n,y:A}],top:[{x:t,y:A-n},{x:t-s,y:A+n},{x:t+s,y:A+n},{x:t,y:A-n}],bottom:[{x:t,y:A+n},{x:t-s,y:A-n},{x:t+s,y:A-n},{x:t,y:A+n}]}[e]},KQt=t=>{const A=PVA.parse(t),e=A.h??JQt(A),i=[],o=[],n=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],I=1;if(A.left){const C=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++)Q===0&&(g=TQt(-A.w/2-A.pl/2,C-Q*A.p,"left")),i.push(Qi(I,-A.w/2+A.pl/2,C-Q*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:C-Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,-A.w/2+A.innerholeedgedistance,C-Q*A.p,s,r))}if(A.bottom){const C=(A.bottom-1)/2*A.p;for(let Q=A.bottom-1;Q>=0;Q--)i.push(Qi(I,C-Q*A.p,-e/2+A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C-Q*A.p,y:-e/2+A.pl/2-3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,C-Q*A.p,-e/2+A.innerholeedgedistance,s,r))}if(A.right){const C=-((A.right-1)/2)*A.p;for(let Q=0;Q<A.right;Q++)i.push(Qi(I,A.w/2-A.pl/2,C+Q*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:C+Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,A.w/2-A.innerholeedgedistance,C+Q*A.p,s,r))}if(A.top){const C=-((A.top-1)/2)*A.p;for(let Q=A.top-1;Q>=0;Q--)i.push(Qi(I,C+Q*A.p,e/2-A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C+Q*A.p,y:e/2-A.pl/2+3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,C+Q*A.p,e/2-A.innerholeedgedistance,s,r))}const c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:g,stroke_width:.1},B={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:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:e/2+A.pl/3}],stroke_width:.1,layer:"top"},l=Yi(0,e/1.8,e/25);return{circuitJson:[...n,...i,...o,B,c,l],parameters:A}},qQt=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),c_(t)),OVA=Ji.extend({fn:Y(),w:Ae.default("10mm"),h:Ae.optional(),left:Ae.optional().default(20),right:Ae.optional().default(20),top:Ae.optional().default(0),bottom:Ae.optional().default(0),p:Ae.default(Ae.parse("2.54mm")),id:Ae.optional().default(Ae.parse("1mm")),od:Ae.optional().default(Ae.parse("1.5mm"))}),PQt=t=>{const A=OVA.parse(t);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},X5=(t,A,e,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:t+n,y:A},{x:t-n,y:A+s},{x:t-n,y:A-s},{x:t+n,y:A}],right:[{x:t-n,y:A},{x:t+n,y:A+s},{x:t+n,y:A-s},{x:t-n,y:A}],top:[{x:t,y:A-n},{x:t-s,y:A+n},{x:t+s,y:A+n},{x:t,y:A-n}],bottom:[{x:t,y:A+n},{x:t-s,y:A-n},{x:t+s,y:A-n},{x:t,y:A+n}]}[e]},OQt=t=>{const A=OVA.parse(t),e=A.h??PQt(A),i=[],o=A.id,n=A.od;let s=[];if(A.right){const I=-((A.right-1)/2)*A.p;for(let c=0;c<A.right;c++)c===0&&!A.left&&!A.bottom&&(s=X5(A.w/2+n*1.4,I+c*A.p,"right")),i.push(Pn(c+1+A.left+(A.bottom??0),A.w/2,I+c*A.p,o,n))}if(A.left){const I=-((A.left-1)/2)*A.p;for(let c=0;c<A.left;c++)c===A.left-1&&(s=X5(-A.w/2-n*1.4,I+c*A.p,"left")),i.push(Pn(c+1,-A.w/2,I+c*A.p,o,n))}if(A.top){const I=-((A.top-1)/2)*A.p;for(let c=0;c<A.top;c++)c===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=X5(I+c*A.p,e/2+n*1.4,"top")),i.push(Pn(c+1+A.right+(A.bottom??0)+A.left,I+c*A.p,e/2,o,n))}if(A.bottom){const I=-((A.bottom-1)/2)*A.p;for(let c=0;c<A.bottom;c++)c===0&&!A.left&&(s=X5(I+c*A.p,-e/2-n*1.4,"bottom")),i.push(Pn(c+1+A.left,I+c*A.p,-e/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:e/2+n},{x:A.w/2+n,y:e/2+n},{x:A.w/2+n,y:-e/2-n},{x:-A.w/2-n,y:-e/2-n},{x:-A.w/2-n,y:e/2+n}],stroke_width:.1,layer:"top"},g=Yi(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},WVA=(t,A,e,i)=>Array.from({length:25},(o,n)=>{const s=n/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*e,y:A+Math.sin(s)*e}}),WQt=Ji.extend({fn:Y(),p:Ae.optional().default("4.88mm"),id:Ae.optional().default("0.8mm"),od:Ae.optional().default("1.5mm"),w:Ae.optional().default("5.6mm"),h:Ae.optional().default("3.5mm")}),ZQt=t=>{const A=WQt.parse(t),{p:e,id:i,od:o,w:n,h:s}=A,r=s/2,a=[Pn(1,-e/2,0,i,o),Pn(2,e/2,0,i,o)],g=WVA(-n/2,0,r,"left"),I=WVA(n/2,0,r,"right"),c={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},...I,{x:n/2,y:s/2},{x:-n/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},B=Yi(0,e/4,.5);return{circuitJson:[...a,c,B],parameters:A}};Ji.extend({w:Ae,h:Ae});var VQt=t=>{const{w:A,h:e}=t,i=mr(A),o=mr(e);return{circuitJson:[Qi(1,0,0,i,o),Yi(0,o/2+.5,.2)],parameters:t}},yL=(t,A,e,i,o,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:A,y:e,outer_width:mr(o),outer_height:mr(n),hole_width:mr(i),hole_height:mr(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),jQt=Ji.extend({fn:Y(),num_pins:ei([GA(3),GA(2)]).default(3),p:Y().default("1.27mm"),id:Y().default("0.72mm"),od:Y().default("0.95mm"),w:Y().default("4.5mm"),h:Y().default("4.5mm"),inline:ce().default(!1),string:Y().optional()}),zQt=(t,A,e)=>Array.from({length:25},(i,o)=>{const n=o/24*Math.PI;return{x:t+Math.cos(n)*e,y:A+Math.sin(n)*e}}),XQt=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=jQt.parse({...t,num_pins:e}),{p:o,id:n,od:s,w:r,h:a,inline:g}=i,I=Number.parseFloat(a)/2,c=Number.parseFloat(o),B=Number.parseFloat(n),l=Number.parseFloat(s),C=l,Q=l*(1.5/1.05);let E=[];if(i.num_pins===3)g?E=[SS(1,-c,I-c,B,l,Q,0,0),yL(2,0,I-c,B,C,Q),yL(3,c,I-c,B,C,Q)]:E=[SS(1,-c,I-c,B,l,l,0,0),Pn(2,0,I,B,l),Pn(3,c,I-c,B,l)];else if(i.num_pins===2)E=[SS(1,-c,I-c,B,C,Q,0,0),yL(2,c,I-c,B,C,Q)];else throw new Error("Invalid number of pins for TO-92");const h=Number.parseFloat(r)/2,u=zQt(0,I,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=Yi(0,I+1,.5);return{circuitJson:[...E,d,f],parameters:i}},$Qt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("2.15mm"),h:Y().default("1.20mm"),pl:Y().default("0.5mm"),pw:Y().default("0.6mm"),p:Y().default("1.4mm")}),AEt=t=>{const A=$Qt.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:tEt(A).concat(i,e),parameters:A}},eEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},tEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=eEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},iEt=qm({}),oEt=t=>{const A=iEt.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=gCA({num_pins:A.num_pins,pn:s+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(Qi(s+1,r,a,A.pl??"1.5mm",A.pw??"0.6mm"))}const i=(A.num_pins/2-1)*A.p+A.pw,o=Yi(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:[...e,o,n],parameters:A}},nEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("5.0mm"),h:Y().default("2.30mm"),pl:Y().default("1.25mm"),pw:Y().default("2mm"),p:Y().default("3.75mm")}),sEt=t=>{const A=nEt.parse(t),e=Yi(0,Ae.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2+.5,y:Ae.parse(A.h)/2+.5},{x:-Ae.parse(A.w)/2-.5,y:Ae.parse(A.h)/2+.5},{x:-Ae.parse(A.w)/2-.5,y:-Ae.parse(A.h)/2-.5},{x:Ae.parse(A.p)/2+.5,y:-Ae.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:aEt(A).concat(i,e),parameters:A}},rEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},aEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=rEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},gEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),p:Y().default("2.9mm")}),IEt=t=>{const A=gEt.parse(t),e=Yi(0,Ae.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:BEt(A).concat(i,e),parameters:A}},cEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},BEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=cEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},lEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("3.30mm"),h:Y().default("1.80mm"),pl:Y().default("0.60mm"),pw:Y().default("0.45mm"),p:Y().default("2.1mm")}),CEt=t=>{const A=lEt.parse(t),e=Yi(0,Ae.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:EEt(A).concat(i,e),parameters:A}},QEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},EEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=QEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},hEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("1.4mm"),h:Y().default("0.9mm"),pl:Y().default("0.36mm"),pw:Y().default("0.25mm"),p:Y().default("0.85mm")}),uEt=t=>{const A=hEt.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2+.15,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.15,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.15,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2+.15,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:pEt(A).concat(i,e),parameters:A}},dEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},pEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=dEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},fEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("1.3mm"),h:Y().default("0.9mm"),pl:Y().default("0.4mm"),pw:Y().default("0.7mm"),p:Y().default("0.7mm")}),yEt=t=>{const A=fEt.parse(t),e=Yi(0,Ae.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2+.2,y:Ae.parse(A.h)/2+.2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2+.2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2-.2},{x:Ae.parse(A.p)/2+.2,y:-Ae.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:mEt(A).concat(i,e),parameters:A}},wEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},mEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=wEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},DEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("3,05mm"),h:Y().default("1.65mm"),pl:Y().default("0.6mm"),pw:Y().default("0.6mm"),pad_spacing:Y().default("2.2mm")}),SEt=t=>{const A=DEt.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.pad_spacing)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.pad_spacing)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:xEt(A).concat(i,e),parameters:A}},bEt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},xEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=bEt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},kEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),p:Y().default("2.9mm")}),GEt=t=>{const A=kEt.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:REt(A).concat(i,e),parameters:A}},FEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},REt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=FEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},MEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("0.91mm"),pw:Y().default("1.22mm"),p:Y().default("3.146mm")}),NEt=t=>{const A=MEt.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:vEt(A).concat(i,e),parameters:A}},_Et=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},vEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=_Et({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},UEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("1.80mm"),h:Y().default("1.00mm"),pl:Y().default("0.66mm"),pw:Y().default("0.5mm"),p:Y().default("0.8mm")}),LEt=t=>{const A=UEt.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.1,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.1,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:YEt(A).concat(i,e),parameters:A}},HEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},YEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=HEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},JEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("6.2mm"),h:Y().default("3.4mm"),pl:Y().default("1.4mm"),pw:Y().default("2.1mm"),p:Y().default("4.4mm")}),TEt=t=>{const A=JEt.parse(t),e=Yi(0,Ae.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:qEt(A).concat(i,e),parameters:A}},KEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},qEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=KEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},PEt=Ji.extend({fn:Y(),num_pins:ei([GA(3),GA(5)]).default(3),w:Y().default("4.20mm"),h:Y().default("4.80mm"),pl:Y().default("1.3mm"),pw:Y().default("0.9mm"),p:Y().default("1.5mm"),string:Y().optional()}),OEt=t=>{const A=[],e=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),o=Number.parseFloat(t.w),n=Number.parseFloat(t.pl),s=.175,r=(n-(n+s))/2;A.push(Qi(1,-o/2+r,e,n,i),Qi(2,-o/2,0,n+s,i),Qi(3,-o/2+r,-e,n,i));const a=Yi(0,0,.3),g=Number.parseFloat(t.w)/2-1,I=Number.parseFloat(t.h)/2,c={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-g,y:I},{x:g,y:I},{x:g,y:I/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},B={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-g,y:-I},{x:g,y:-I},{x:g,y:-I/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,c,B,a]},WEt=t=>{const A=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),A.push(Qi(1,-1.85,-1.5,1.5,.7),Qi(2,-1.85,1.5,1.5,.7),Qi(3,0,0,.8,2),Qi(4,1.85,-1.5,1.5,.7),Qi(5,1.85,1.5,1.5,.7));const e=Yi(0,Number.parseFloat(t.h)/2+.5,.3),i=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.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,e]},ZEt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=PEt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:OEt(i),parameters:i};if(i.num_pins===5)return{circuitJson:WEt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},VEt=Ji.extend({fn:Y(),p:Ae.optional().default("5.0mm"),id:Ae.optional().default("1.0mm"),od:Ae.optional().default("1.9mm"),w:Ae.optional().default("13mm"),h:Ae.optional().default("7mm"),num_pins:WA().optional(),string:Y().optional()}),jEt=t=>{const A=VEt.parse(t),{fn:e,id:i,od:o,w:n,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,I=n/2,c=s/2,B=2.5,l=n*.4,C=Math.max(B,l/(a-1)),Q=Array.from({length:a},(m,S)=>{const D=a%2===0?(S-a/2+.5)*C:(S-Math.floor(a/2))*C;return Pn(S+1,D,g,i,o)}),E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:-c},{x:I,y:-c},{x:I,y:c},{x:-I,y:c},{x:-I,y:-c}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-c+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:h},{x:I,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:c}],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:c}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Yi(0,s/2+.6,.5);return{circuitJson:[...Q,E,u,...d,f],parameters:{...A,p:C}}},zEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("5.40mm"),h:Y().default("2.30mm"),pl:Y().default("1.30mm"),pw:Y().default("1.70mm"),p:Y().default("3.5mm")}),XEt=t=>{const A=zEt.parse(t),e=Yi(0,Ae.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Aht(A).concat(i,e),parameters:A}},$Et=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Aht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=$Et({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},eht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("1.90mm"),h:Y().default("1.33mm"),pl:Y().default("0.5mm"),pw:Y().default("0.7mm"),p:Y().default("0.8mm")}),tht=t=>{const A=eht.parse(t),e=Yi(0,Ae.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2+.1,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2+.1,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:oht(A).concat(i,e),parameters:A}},iht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},oht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=iht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},nht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("7.0mm"),h:Y().default("3.35mm"),pl:Y().default("1.50mm"),pw:Y().default("2.70mm"),p:Y().default("4.8mm")}),sht=t=>{const A=nht.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:aht(A).concat(i,e),parameters:A}},rht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},aht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=rht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ght=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("3.0mm"),h:Y().default("1.80mm"),pl:Y().default("0.80mm"),pw:Y().default("1.20mm"),p:Y().default("1.6mm")}),Iht=t=>{const A=ght.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.1,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.1,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Bht(A).concat(i,e),parameters:A}},cht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Bht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=cht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},lht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("7.10mm"),h:Y().default("3.40mm"),pl:Y().default("2.45mm"),pw:Y().default("1.80mm"),p:Y().default("4.05mm")}),Cht=t=>{const A=lht.parse(t),e=Yi(0,Ae.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.5,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.5,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Eht(A).concat(i,e),parameters:A}},Qht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Eht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Qht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},hht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("4.80mm"),h:Y().default("2.10mm"),pl:Y().default("1.30mm"),pw:Y().default("1.40mm"),p:Y().default("2.9mm")}),uht=t=>{const A=hht.parse(t),e=Yi(0,Ae.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:pht(A).concat(i,e),parameters:A}},dht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},pht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=dht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},fht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("7.30mm"),h:Y().default("4.40mm"),pl:Y().default("2.50mm"),pw:Y().default("2.30mm"),p:Y().default("4.30mm")}),yht=t=>{const A=fht.parse(t),e=Yi(0,Ae.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.1,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.1,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:mht(A).concat(i,e),parameters:A}},wht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},mht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=wht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Dht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("10.70mm"),h:Y().default("6.60mm"),pl:Y().default("3.30mm"),pw:Y().default("2.50mm"),p:Y().default("6.80mm")}),Sht=t=>{const A=Dht.parse(t),e=Yi(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2-.8},{x:-Ae.parse(A.w)/2-.8,y:Ae.parse(A.h)/2-.8},{x:-Ae.parse(A.w)/2-.8,y:-Ae.parse(A.h)/2+.8},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:xht(A).concat(i,e),parameters:A}},bht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},xht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=bht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},kht=Ji.extend({fn:Y(),num_pins:WA().default(4),w:Y().default("8.50mm"),h:Y().default("6.90mm"),pl:Y().default("2mm"),pw:Y().default("1.5mm"),p:Y().default("2.30mm"),string:Y().optional()}),Ght=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const o=Mht.parse({...t,num_pins:e});return{circuitJson:Lx(o),parameters:o}}const i=kht.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:Rht(i),parameters:i};if(i.num_pins===5)return{circuitJson:_ht(i),parameters:i};if(i.num_pins===6)return{circuitJson:Uht(i),parameters:i};throw new Error("Invalid number of pins")},Fht=t=>{const{pn:A,w:e,p:i}=t;return A===1?{x:-e/2+1.1,y:i}:A===2?{x:-e/2+1.1,y:0}:A===3?{x:-e/2+1.1,y:-i}:{x:e/2-1.1,y:0}},Rht=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=Fht({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),I=r===3?3.8:Number.parseFloat(t.pw);A.push(Qi(r+1,a,g,Number.parseFloat(t.pl),I))}const e=Yi(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,o=Number.parseFloat(t.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,e]},Mht=qm({p:"0.90mm",w:"2.8mm",legsoutside:!0}),Nht=t=>{const{p:A,pn:e,w:i}=t;if(e===1)return{x:-i/2+1.2,y:A/2+A};if(e===2)return{x:-i/2+1.2,y:A/2};if(e===3)return{x:-i/2+1.2,y:-A/2};if(e===4)return{x:-i/2+1.2,y:-A/2-A};if(e===5)return{x:i/2-1,y:0};throw new Error("Invalid pin number")},_ht=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=Nht({h:Number.parseFloat(t.h),p:1.5,pn:r,w:Number.parseFloat(t.w)});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===5?(I=3.4,c=1.8):(I=1,c=2.2),A.push(Qi(r,a,g,c,I))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,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:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Yi(0,0,.3);return[...A,o,n,s]},vht=t=>{const{p:A,pn:e,w:i}=t;if(e===1)return{x:-i/2+1.2,y:2*A};if(e===2)return{x:-i/2+1.2,y:A};if(e===3)return{x:-i/2+1.2,y:0};if(e===4)return{x:-i/2+1.2,y:-A};if(e===5)return{x:-i/2+1.2,y:-2*A};if(e===6)return{x:i/2-1.175,y:0};throw new Error("Invalid pin number")},Uht=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=vht({h:Number.parseFloat(t.h),p:1.3,pn:r,w:8.7});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===6?(I=3.4,c=2.15):(I=.6,c=2.2),A.push(Qi(r,a,g,c,I))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,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:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Yi(0,0,.3);return[...A,o,n,s]},Lht=Ji.extend({fn:Y(),num_pins:WA().default(3),w:Y().default("3.40mm"),h:Y().default("3.30mm"),pl:Y().default("1mm"),pw:Y().default("0.7mm"),p:Y().default("1.2mm"),string:Y().optional()}),Hht=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=Lht.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:Jht(i),parameters:i};throw new Error("Invalid number of pins")},Yht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},Jht=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=Yht({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Yi(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.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,e]},Tht=Ji.extend({fn:Y(),num_pins:ei([GA(3),GA(2)]).default(3),p:Y().default("1.27mm"),id:Y().default("0.72mm"),od:Y().default("0.95mm"),w:Y().default("2.5mm"),h:Y().default("4.2mm"),string:Y().optional()}),Kht=t=>{const{p:A,id:e,od:i,w:o,h:n}=t,s=Number.parseFloat(n)/2,r=Number.parseFloat(A);return[Pn(1,-r,s-r,e,i),Pn(2,0,s-r,e,i),Pn(3,r,s-r,e,i)]},qht=t=>{const{p:A,id:e,od:i,h:o}=t,n=Number.parseFloat(o)/2,s=Number.parseFloat(A);return[Pn(1,-s,n-s,e,i),Pn(2,s,n-s,e,i)]},Pht=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=Tht.parse({...t,num_pins:e});let o=[];if(i.num_pins===3)o=Kht(i);else if(i.num_pins===2)o=qht(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=Yi(0,n+1,.5);return{circuitJson:[...o,r,a],parameters:i}},Oht=Ji.extend({fn:Y(),p:Ae.optional(),id:Ae.optional(),pw:Ae.optional(),pl:Ae.optional(),w:Ae.optional(),h:Ae.optional(),sh:ei([ce(),Y(),WA()]).optional().transform(t=>{if(typeof t=="string"){const A=Number(t);return Number.isNaN(A)?!0:A}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:ce().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:Y().optional()}),Wht={ph:{p:Ae.parse("2.2mm"),id:Ae.parse("0.70mm"),pw:Ae.parse("1.20mm"),pl:Ae.parse("1.20mm"),w:Ae.parse("6mm"),h:Ae.parse("5mm")},sh:{p:Ae.parse("1mm"),pw:Ae.parse("0.6mm"),pl:Ae.parse("1.55mm"),w:Ae.parse("5.8mm"),h:Ae.parse("7.8mm")}};function Zht(t){return t.sh?"sh":(t.ph,"ph")}function Vht(t,A,e,i,o,n){const s=[];if(t==="ph"){const r=e/2;s.push(SS(1,-r,2,i,o,n)),s.push(SS(2,r,2,i,o,n))}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const I=r+g*e;console.log("x si",I),s.push(Qi(g+1,I,-1.325,o,n))}const a=(A-1)/2*e+1.3;console.log("offset",a),s.push(Qi(A+1,-a,1.22,1.2,1.8)),s.push(Qi(A+2,a,1.22,1.2,1.8))}return s}function jht(t,A,e){return t==="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 zht=t=>{const A=Oht.parse(t),e=Zht(A),i=Wht[e],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 I=e==="sh"?4:2;if(e==="sh"){const Q=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(Q&&Q[1]){const E=parseInt(Q[1],10);Number.isNaN(E)||(I=E)}else typeof A.sh=="number"&&(I=A.sh)}const c=Vht(e,I,o,n,s,r),B=jht(e),l=Yi(0,g/2+1,.5);return{circuitJson:[...c,B,l],parameters:{...A,p:o,id:n,pw:s,pl:r,w:a,h:g,num_pins:I,sh:e==="sh",ph:e==="ph"}}},Xht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("3.30mm"),h:Y().default("1.70mm"),pl:Y().default("0.80mm"),pw:Y().default("1mm"),p:Y().default("1.90mm")}),$ht=t=>{const A=Xht.parse(t),e=Yi(0,Ae.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eut(A).concat(i,e),parameters:A}},Aut=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eut=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Aut({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tut=t=>{switch(t){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"}}},iut=Ji.extend({fn:Y(),num_pins:ei([GA(8),GA(10)]).default(8),w:Y().optional(),h:Y().optional(),p:Y().optional(),pl:Y().optional(),pw:Y().optional(),string:Y().optional()}),out=t=>{const A=iut.parse(t),e=tut(A.num_pins),i=Ae.parse(A.w||e.w),o=Ae.parse(A.h||e.h),n=Ae.parse(A.p||e.p),s=Ae.parse(A.pl||e.pl),r=Ae.parse(A.pw||e.pw),a=[],g=A.num_pins/2;for(let u=0;u<A.num_pins;u++){const{x:d,y:f}=ZVA(A.num_pins,u+1,i,n),m=u<g?u+1:A.num_pins-(u-g);a.push(Qi(m,d,f,s,r))}const I=i,c=o,B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:c/2},{x:I/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:-c/2},{x:I/2,y:-c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=ZVA(A.num_pins,1,I,n),Q={x:C.x-.8,y:C.y},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:Q.x-.4,y:Q.y},{x:Q.x-.7,y:Q.y+.3},{x:Q.x-.7,y:Q.y-.3},{x:Q.x-.4,y:Q.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Yi(0,c/2+.5,.3);return{circuitJson:[...a,B,l,h,E],parameters:A}},ZVA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*Ae.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},nut=t=>{switch(t){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"}}},sut=Ji.extend({fn:Y(),num_pins:ei([GA(8),GA(10),GA(12),GA(16)]).default(8),w:Y().optional(),h:Y().optional(),p:Y().optional(),pl:Y().optional(),pw:Y().optional(),string:Y().optional()}),VVA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*Ae.parse("2mm"),y:r*i}},rut=t=>{const A=sut.parse(t),e=nut(A.num_pins),i=Ae.parse(A.w||e.w),o=Ae.parse(A.h||e.h),n=Ae.parse(A.p||e.p),s=Ae.parse(A.pl||e.pl),r=Ae.parse(A.pw||e.pw),a=[];for(let h=0;h<A.num_pins;h++){const{x:u,y:d}=VVA(A.num_pins,h+1,i,n);a.push(Qi(h+1,u,d,s,r))}const g=i,I=o,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:I/2},{x:g/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-I/2},{x:g/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=VVA(A.num_pins,1,g,n),C={x:l.x-.8,y:l.y},Q={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"},E=Yi(0,I/2+.5,.3);return{circuitJson:[...a,c,B,E,Q],parameters:A}},aut=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("3.8mm"),h:Y().default("1.65mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),pad_spacing:Y().default("2.6mm")}),gut=t=>{const A=aut.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.pad_spacing)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.pad_spacing)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:cut(A).concat(i,e),parameters:A}},Iut=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},cut=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Iut({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},But=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("3.20mm"),h:Y().default("1.65mm"),pl:Y().default("0.8mm"),pw:Y().default("0.9mm"),pad_spacing:Y().default("2.1mm")}),lut=t=>{const A=But.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.pad_spacing)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.pad_spacing)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Qut(A).concat(i,e),parameters:A}},Cut=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Qut=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Cut({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Eut=Ji.extend({fn:Y(),num_pins:ei([GA(6),GA(8)]).default(8),w:Y().default("3mm"),h:Y().default("3mm"),p:Y().default("0.5mm"),pl:Y().default("0.52mm"),pw:Y().default("0.35mm"),epw:Y().default("1.40mm"),eph:Y().default("1.60mm"),string:Y().optional(),ep:ce().default(!1)}),hut=t=>{t.string&&t.string.includes("_ep")&&(t.ep=!0);const A=t.string?.match(/^son_(\d+)/),e=A?Number.parseInt(A[1],10):t.num_pins||8,i=Eut.parse({...t,num_pins:e}),o=Ae.parse(i.w),n=Ae.parse(i.h),s=Ae.parse(i.p),r=Ae.parse(i.pl),a=Ae.parse(i.pw),g=Ae.parse(i.epw),I=Ae.parse(i.eph),c=[];for(let f=0;f<i.num_pins;f++){const{x:m,y:S}=jVA(i.num_pins,f+1,o,s);c.push(Qi(f+1,m,S,r,a))}i.ep&&c.push(Qi(i.num_pins+1,0,0,g,I));const B=o,l=n,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:l/2},{x:B/2,y:l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:-l/2},{x:B/2,y:-l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},E=jVA(i.num_pins,1,B,s),h={x:E.x-.4,y:E.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=Yi(0,l/2+.5,.3);return{circuitJson:[...c,C,Q,d,u],parameters:i}},jVA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*Ae.parse("1.4mm"),y:r*i}},uut=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:o=1.5,ph:n=1.5}=t,s=Ae.parse(i),r=Ae.parse(o),a=Ae.parse(n),g=Math.min(a/4,.5),I=[];for(let f=0;f<A;f++)I.push(Qi(f+1,f*s,0,r,a));let c=[];if(e){const f=e.split("").map(Number);if(f.length>1)for(let m=0;m<f.length-1;m++){const S=f[m],D=f[m+1];if(typeof S=="number"&&typeof D=="number"&&!isNaN(S)&&!isNaN(D)){const x=(S-1)*s,F=(D-1)*s,k=Math.sign(F-x),v=x+k*(r/2),_=F-k*(r/2);c.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${S}}`,x:v,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${D}}`,x:_,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const B=(A-1)*s+r+.7,l=a+1,C=(A-1)*s/2,Q=0,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:C-B/2,y:Q-l/2},{x:C+B/2,y:Q-l/2},{x:C+B/2,y:Q+l/2},{x:C-B/2,y:Q+l/2},{x:C-B/2,y:Q-l/2}],stroke_width:.15},u=Q+l/2+.6,d=Yi(C,u,.4);return{circuitJson:[...I,...c,E,d],parameters:t}},zVA={fn:GA("sot457"),num_pins:GA(6).default(6),pillh:Y().default("0.45mm"),pillw:Y().default("1.45mm"),pl:Y(),pw:Y(),p:Y(),wave:ce().optional(),reflow:ce().optional()},dut=Ji.extend({...zVA,h:Y().default("2.5mm"),w:Y().default("2.7mm"),pl:Y().default("0.8mm"),pw:Y().default("0.55mm"),p:Y().default("0.95mm")}),put=Ji.extend({...zVA,h:Y().default("3mm"),w:Y().default("4mm"),pillr:Y().default("0.225mm"),pl:Y().default("1.45mm"),pw:Y().default("1.5mm"),p:Y().default("1.475mm")}).transform(t=>({...t,wave:t.wave??(t.reflow===void 0?!0:!t.reflow),reflow:t.reflow??(t.wave===void 0?!1:!t.wave)})),bS=t=>Number.parseFloat(t.replace("mm","")),XVA=({pitch:t,width:A,pinNumber:e})=>{const n={1:{x:-A/2-.1,y:t},2:{x:-A/2-.1,y:0},3:{x:-A/2-.1,y:-t},4:{x:A/2+.1,y:-t},5:{x:A/2+.1,y:0},6:{x:A/2+.1,y:t}}[e];if(!n)throw new Error(`Invalid pin number: ${e}`);return n},$VA=t=>{const A=[],e=bS(t.p),i=bS(t.pl),o=bS(t.pw),n=bS(t.w),s=bS(t.h);if(t.wave){const C={1:({padWidth:Q,padHeight:E})=>Qi(1,-e,e,E,Q),2:({padWidth:Q,padHeight:E})=>Qi(2,-e,-e,E,Q),3:({padWidth:Q,padHeight:E})=>V5(3,-e,0,bS(t.pillw),bS(t.pillh)),4:({padWidth:Q,padHeight:E})=>V5(4,e,0,bS(t.pillw),bS(t.pillh)),5:({padWidth:Q,padHeight:E})=>Qi(5,e,e,E,Q),6:({padWidth:Q,padHeight:E})=>Qi(6,e,-e,E,Q)};for(let Q=1;Q<=t.num_pins;Q++){const E=C[Q];E&&A.push(E({padWidth:i,padHeight:o}))}}else for(let C=1;C<=t.num_pins;C++){const{x:Q,y:E}=XVA({pitch:e,width:n,pinNumber:C});A.push(Qi(C,Q,E,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+e/1.3},{x:n/3,y:s/2+e/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-e/1.3},{x:n/3,y:-s/2-e/1.3}],stroke_width:.05},g=Yi(0,s+.5,.3),I=XVA({pitch:e,width:n,pinNumber:1}),c=t.wave?1:.5,B=t.wave?.7:.3;I.x-=t.wave?o:o*1.7;const l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:I.x+c/2,y:I.y},{x:I.x-c/2,y:I.y+B/2},{x:I.x-c/2,y:I.y-B/2},{x:I.x+c/2,y:I.y}],stroke_width:.05};return[g,r,a,l,...A]},fut=t=>{if(t.wave){const e=put.parse({...t,fn:"sot457"});return{circuitJson:$VA(e),parameters:e}}const A=dut.parse(t);return{circuitJson:$VA(A),parameters:A}},yut=Ji.extend({fn:Y(),num_pins:GA(6).default(6),w:Y().default("1.1mm"),h:Y().default("1.45mm"),p:Y().default("0.35mm"),pl:Y().default("0.2mm"),pw:Y().default("0.2mm"),string:Y().optional()}),wut=t=>{const A=yut.parse({...t,fn:"sot963"}),e=Ae.parse(A.w),i=Ae.parse(A.h),o=Ae.parse(A.p),n=Ae.parse(A.pl),s=Ae.parse(A.pw),r=[];for(let l=0;l<6;l++){const{x:C,y:Q}=A9A(l+1,e,o,n);r.push(Qi(l+1,C,Q,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=A9A(1,e,o,n),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-n/2-.3,y:I.y},{x:I.x-n/2-.45,y:I.y+.15},{x:I.x-n/2-.45,y:I.y-.15},{x:I.x-n/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},B=Yi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,B,c],parameters:A}},A9A=(t,A,e,i)=>{const o=A/2-i/2;return t<=3?{x:-o,y:e-(t-1)*e}:{x:o,y:-e+(t-4)*e}},mut=Ji.extend({fn:Y(),num_pins:ei([GA(3),GA(2)]).default(3),p:Y().default("3.8mm"),id:Y().default("1.25mm"),od:Y().default("2.35mm"),ca:Y().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:Y().default("5.35mm"),h:Y().default("4mm"),string:Y().optional()}),Dut=t=>{const{p:A,id:e,od:i,h:o,ca:n}=t,s=Number.parseFloat(o),r=Number.parseFloat(n);return[Pn(1,0,r/4+.3,e,i),Pn(2,s,0,e,i),Pn(3,0,-r/4-.3,e,i)]},Sut=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=mut.parse({...t,num_pins:e});let o=[];i.num_pins===3&&(o=Dut(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:""},I=Number.parseFloat(i.w)/2,c=Yi(I,n+1,.5);return{circuitJson:[...o,a,g,c],parameters:i}},but=Ji.extend({fn:Y(),p:Ae.optional().default("7.5mm"),id:Ae.optional().default("1mm"),od:Ae.optional().default("2mm"),d:Ae.optional().default("10.5mm")}),xut=(t,A,e,i,o)=>{const n=[],s=[];for(let r=0;r<=50;r++){const a=r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-o/2&&I<=A+o/2||n.push({x:g,y:I})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-o/2&&I<=A+o/2||s.push({x:g,y:I})}return{topArc:n,bottomArc:s}},kut=t=>{const A=but.parse(t),{p:e,id:i,od:o,d:n}=A,s=[Pn(1,-e/2,0,i,o),Pn(2,e/2,0,i,o)],{topArc:r,bottomArc:a}=xut(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:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},c={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:""},B=-(n/2+.5),l=o/2+1.5,C=.5,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B-C,y:l},{x:B+C,y:l}],stroke_width:.1,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B,y:l-C},{x:B,y:l+C}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Yi(0,n/2+1,.5);return{circuitJson:[...s,g,I,c,Q,E,h],parameters:A}},Gut=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("6.5mm"),h:Y().default("3mm"),pl:Y().default("1.75mm"),pw:Y().default("2.40mm"),p:Y().default("4.75mm")}),Fut=t=>{const A=Gut.parse(t),e=Yi(0,Ae.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.3,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.3,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Mut(A).concat(i,e),parameters:A}},Rut=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Mut=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Rut({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Nut=Ji.extend({fn:Y(),num_pins:WA().default(3),w:Y().default("2.45mm"),h:Y().default("2.40mm"),pl:Y().default("1.225mm"),pw:Y().default("0.5mm"),p:Y().default("0.95mm"),string:Y().optional()}),_ut=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=Nut.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:Uut(i),parameters:i};throw new Error("Invalid number of pins")},vut=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},Uut=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=vut({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Yi(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),o=Number.parseFloat(t.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,e]},Lut=Ji.extend({fn:Y(),circle:ce().optional(),rect:ce().optional(),square:ce().optional(),pill:ce().optional(),d:Ae.optional(),pd:Ae.optional(),diameter:Ae.optional(),r:Ae.optional(),pr:Ae.optional(),radius:Ae.optional(),w:Ae.optional(),pw:Ae.optional(),width:Ae.optional(),h:Ae.optional(),ph:Ae.optional(),height:Ae.optional(),s:Ae.optional(),size:Ae.optional(),string:Y().optional()}).transform(t=>{let A="rect";t.circle&&(A="circle"),t.square&&(A="square"),t.rect&&(A="rect"),t.pill&&(A="pill");let e,i,o;return A==="circle"?t.r!==void 0?e=mr(t.r):t.pr!==void 0?e=mr(t.pr):t.radius!==void 0?e=mr(t.radius):t.d!==void 0?e=mr(t.d)/2:t.pd!==void 0?e=mr(t.pd)/2:t.diameter!==void 0?e=mr(t.diameter)/2:e=mr("1mm")/2:(t.w!==void 0?i=mr(t.w):t.pw!==void 0?i=mr(t.pw):t.width!==void 0?i=mr(t.width):t.s!==void 0?i=mr(t.s):t.size!==void 0?i=mr(t.size):i=mr("1mm"),t.h!==void 0?o=mr(t.h):t.ph!==void 0?o=mr(t.ph):t.height!==void 0?o=mr(t.height):A==="square"||A==="rect"?o=i:o=mr("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:o}}),Hut=t=>{const A=Lut.parse(t),{shape:e,radius:i,width:o,height:n}=A;let s,r;return e==="circle"?(s=NVA(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=V5(1,0,0,o,n),r=Math.max(o,n)/2+.5):(s=Qi(1,0,0,o,n),r=n/2+.5),{circuitJson:[s,Yi(0,r,.2)],parameters:A}},Yut=Ji.extend({fn:Y(),d:Ae.optional(),hd:Ae.optional(),r:Ae.optional(),hr:Ae.optional(),pd:Ae.optional(),pr:Ae.optional(),squarepad:ce().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=mr(t.d):t.hd!==void 0?A=mr(t.hd):t.r!==void 0?A=mr(t.r)*2:t.hr!==void 0?A=mr(t.hr)*2:A=mr("1mm");let e;return t.pd!==void 0?e=mr(t.pd):t.pr!==void 0?e=mr(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),Jut=t=>{const A=Yut.parse(t),{d:e,pd:i,squarepad:o}=A;return{circuitJson:[o?SS(1,0,0,e,i,i):Pn(1,0,0,e,i),Yi(0,i/2+.5,.2)],parameters:A}},Tut=Ji.extend({fn:Y(),num_pins:GA(6).default(6),h:Y().default("1.6mm"),pl:Y().default("1mm"),pw:Y().default("0.7mm"),p:Y().default("0.95mm")}),Kut=t=>{const A=Tut.parse(t);return{circuitJson:qut(A),parameters:A}},e9A=t=>{const{p:A,h:e,pn:i}=t;if(i===1)return{x:-e/2-.5,y:A};if(i===2)return{x:-e/2-.5,y:0};if(i===3)return{x:-e/2-.5,y:-A};if(i===4)return{x:e/2+.5,y:-A};if(i===5)return{x:e/2+.5,y:0};if(i===6)return{x:e/2+.5,y:A};throw new Error("Invalid pin number")},qut=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:l}=e9A({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(Qi(c,B,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.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:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Yi(0,i+.3,.3),r=e9A({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={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,I]},Put=Ji.extend({fn:Y(),num_pins:WA().default(4),w:Y().default("3.2mm"),h:Y().default("2.6mm"),pl:Y().default("1.35mm"),pw:Y().default("0.50mm"),p:Y().default("0.6mm"),string:Y().optional()}),Out=t=>{const A=t.string?.match(/^sot343_(\d+)/),e=A?Number.parseInt(A[1],4):4,i=Put.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:Zut(i),parameters:i};throw new Error("Invalid number of pins")},Wut=t=>{const{pn:A,p:e}=t;return A===1?{x:-e*1.92,y:-.65}:A===2?{x:-e*1.92,y:.65}:A===3?{x:e,y:.65}:A===4?{x:e,y:-.65}:{x:0,y:0}},Zut=t=>{const A=[],e=Number.parseFloat(t.w),i=Number.parseFloat(t.h),o=Number.parseFloat(t.pl),n=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let r=1/0,a=-1/0,g=1/0,I=-1/0;for(let d=0;d<t.num_pins;d++){const{x:f,y:m}=Wut({num_pins:t.num_pins,pn:d+1,p:s});A.push(Qi(d+1,f,m,o,n)),f<r&&(r=f),f>a&&(a=f),m<g&&(g=m),m>I&&(I=m)}const c=(r+a)/2,B=I-g,l=i*.3,C=B/2+l;let Q=e*.8;i<=2.6&&(Q/=2);const E=Yi(c,C+.5,.3),h={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:c-Q/2,y:C},{x:c+Q/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:c-Q/2,y:-C},{x:c+Q/2,y:-C}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,h,u,E]},Vut=Ji.extend({fn:Y()}),jut=t=>{const A=Vut.parse(t),e=[],i=.5-.15,o=1.5,s=.5/2,r=75,a=-37/2;for(let D=0;D<r;D++){const x=D+1;if(x>=24&&x<=31)continue;const F=a-D*s,k=x%2===0,v=o+(k?.25:0),H=.5-v/2,P=Qi(x,H,F,v,i);P.layer=k?"bottom":"top",e.push(P)}const g=46*.0254,I=137*.0254,c=261*.0254,B={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-I/2+o/2,y:a-c},width:I,height:g},l={x:-.5,y:a},C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-.4,y:l.y},{x:l.x-.7,y:l.y+.3},{x:l.x-.7,y:l.y-.3},{x:l.x-.4,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let Q=1/0,E=-1/0,h=1/0,u=-1/0;const d=(D,x,F=0,k=0)=>{Q=Math.min(Q,D-F/2),E=Math.max(E,D+F/2),h=Math.min(h,x-k/2),u=Math.max(u,x+k/2)};for(const D of e)d(D.x,D.y,D.width,D.height);d(B.center.x,B.center.y,B.width,B.height);for(const D of C.route)d(D.x,D.y);const f=(Q+E)/2,m=(h+u)/2,S=D=>{typeof D.x=="number"&&(D.x-=f),typeof D.y=="number"&&(D.y-=m),D.center&&(D.center.x-=f,D.center.y-=m),Array.isArray(D.route)&&(D.route=D.route.map(x=>({x:x.x-f,y:x.y-m})))};for(const D of e)S(D);return S(B),S(C),{circuitJson:[...e,B,C],parameters:A}},zut=Ji.extend({fn:Y(),num_pins:WA().default(3),inline:ce().default(!1),p:Y().default("1.27mm"),id:Y().default("0.75mm"),od:Y().default("1.3mm"),w:Y().default("4.8mm"),h:Y().default("4.0mm")}),Xut=t=>{const A=zut.parse(t),e=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=[SS(1,0,0,A.id,n,s,0,0),A.inline?yL(2,e,0,A.id,n,s):Pn(2,e,e,A.id,n),A.inline?yL(3,e*2,0,A.id,n,s):Pn(3,e*2,0,A.id,n)],a=i/2,g=A.inline?e-.09:e,I=.2,c=I+a-o,B=Array.from({length:32},(Q,E)=>{const h=Math.PI*E/31;return{x:g+a*Math.cos(h),y:I+a*Math.sin(h)}}),l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",stroke_width:.12,route:[...B,{x:g-a,y:c},{x:g+a,y:c},B[0]]},C=Yi(g,I+a+1,.5);return{circuitJson:[...r,l,C],parameters:A}};function $ut(t){return t!=null}var Adt=(t,A)=>{if(!A)return t;const e=t.filter(I=>I.type==="pcb_smtpad"||I.type==="pcb_plated_hole"||I.type==="pcb_thtpad");if(e.length===0)return t;let i=1/0,o=-1/0,n=1/0,s=-1/0;const r=(I,c,B=0,l=0)=>{const C=I-B/2,Q=I+B/2,E=c-l/2,h=c+l/2;i=Math.min(i,C),o=Math.max(o,Q),n=Math.min(n,E),s=Math.max(s,h)};for(const I of e)if(I.type==="pcb_smtpad"){const c=I.shape==="circle"?I.radius*2:I.width,B=I.shape==="circle"?I.radius*2:I.height;r(I.x,I.y,c,B)}else if(I.type==="pcb_plated_hole"){const c=I.outer_diameter??I.hole_diameter;r(I.x,I.y,c,c)}else if(I.type==="pcb_thtpad"){const c=I.diameter;r(I.x,I.y,c,c)}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 I=e.find(c=>c.port_hints?.[0]==="1")||e[0];a=I.x,g=I.y;break}if(a===0&&g===0)return t;for(const I of t){if(typeof I.x=="number"&&(I.x-=a),typeof I.y=="number"&&(I.y-=g),I.center&&typeof I.center.x=="number"&&(I.center.x-=a,I.center.y-=g),I.type==="pcb_silkscreen_path")for(const c of I.route)c.x-=a,c.y-=g;I.type==="pcb_silkscreen_text"&&I.anchor_position&&(I.anchor_position.x-=a,I.anchor_position.y-=g)}return t},edt=(t,A)=>{const e=t.filter(i=>i.type==="pcb_silkscreen_text");if(e.length===0)return t;for(const i of e)A.norefdes&&(i.text="");return t},tdt=(t,A)=>A.nosilkscreen?t.filter(e=>e.type!=="pcb_silkscreen_path"&&e.type!=="pcb_silkscreen_text"):t,idt=t=>{let A=$5();const i=t.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($ut);for(const{fn:o,v:n}of i)A=A[o](n);return A.setString(t),A},odt=()=>Object.keys(DS),$5=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&DS[A.fn])return()=>{const{circuitJson:i}=DS[A.fn](A),o=tdt(i,A),n=edt(o,A);return Adt(n,A.origin)};if(!DS[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 "${e}"`)}}if(e==="json"){if(!DS[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>DS[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(DS):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in DS?(A[`${e}${i}`]=!0,A.fn=`${e}${i}`):(A[e]=!0,A.fn=e,e==="res"||e==="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(e)||(A[e]=i??!0),t)}});return t};$5.string=idt,$5.getFootprintNames=odt;var ndt=$5,t9A=Symbol("Fragment");function lCA(t,A,...e){const i=e.length?e: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:t,props:(A&&A.children!==void 0?{...A,children:void 0}:A)||{},children:o}}var ut=Symbol("Cuboid"),i9A=Symbol("Cube"),tf=Symbol("Cylinder"),o9A=Symbol("Sphere"),wL=Symbol("RoundedCuboid"),Zi=Symbol("Translate"),fQ=Symbol("Rotate"),QE=Symbol("Union"),hF=Symbol("Subtract"),CI=Symbol("Hull"),ys=Symbol("Colorize"),mL=Symbol("Polygon"),DL=Symbol("ExtrudeLinear"),of=Symbol("RoundedCylinder"),Ko=t9A,ee=(t,A,e)=>lCA(t,A),Pt=(t,A,e)=>lCA(t,A),$B=({center:t,width:A,length:e,height:i,heightAboveSurface:o=.15,color:n="#555",taperRatio:s=.12,faceRatio:r=.75,straightHeightRatio:a=.5,includeNotch:g=!0,notchRadius:I,notchPosition:c,notchRotation:B=[0,0,0],notchLength:l=.5,notchWidth:C=.25,chamferSize:Q=0})=>{const E=i*a,h=i-E,u=Math.min(A,e)*s,d=Math.max(A-u,A*r),f=Math.max(e-u,e*r),m=Math.min(A,e)*.12,S=I??m,D={x:0,y:e/2-S*.25,z:i},x=c??D,F=Pt(QE,{children:[Pt(CI,{children:[ee(Zi,{z:.005,children:ee(ut,{size:[d,f,.01]})}),ee(Zi,{z:E,children:ee(ut,{size:[A,e,.01]})})]}),Pt(CI,{children:[ee(Zi,{z:E,children:ee(ut,{size:[A,e,.01]})}),ee(Zi,{z:E+h,children:ee(ut,{size:[d,f,.01]})})]})]}),k=(_,H)=>ee(Zi,{offset:{x:_,y:H,z:0},children:ee(fQ,{rotation:[0,0,Math.PI/4],children:ee(ut,{size:[Q*Math.SQRT2,Q*Math.SQRT2,i*3]})})});let v=F;if(Q>0){const _=A/2,H=e/2;v=Pt(hF,{children:[F,k(_,H),k(-_,H),k(_,-H),k(-_,-H)]})}return ee(ys,{color:n,children:ee(Zi,{offset:t,children:ee(Zi,{offset:{x:0,y:0,z:o},children:g?Pt(hF,{children:[v,ee(Zi,{offset:x,children:ee(fQ,{rotation:B,children:ee(tf,{radius:S,height:C})})})]}):v})})})},sdt=t=>Array.from({length:t},(A,e)=>e);function CCA(t,A){if(t.length<2)throw new Error("Stroke must have at least two points");const e=Array.isArray(t[0])?t.map(([I,c])=>({x:I,y:c})):t,i=A/2,o=[],n=[];function s(I,c){const B=c.x-I.x,l=c.y-I.y,C=Math.sqrt(B*B+l*l);return{x:-l/C,y:B/C}}function r(I,c,B){const l={x:I.x+c.x*i*B,y:I.y+c.y*i*B};B>0?o.push(l):n.unshift(l)}const a=s(e[0],e[1]);r(e[0],a,1),r(e[0],a,-1);for(let I=1;I<e.length-1;I++){const c=e[I-1],B=e[I],l=e[I+1],C=s(c,B),Q=s(B,l),E=C.x+Q.x,h=C.y+Q.y,u=Math.sqrt(E*E+h*h);if(u/2>2*i)r(B,C,1),r(B,Q,1),r(B,C,-1),r(B,Q,-1);else{const f=1/u;r(B,{x:E*f,y:h*f},1),r(B,{x:E*f,y:h*f},-1)}}const g=s(e[e.length-2],e[e.length-1]);return r(e[e.length-1],g,1),r(e[e.length-1],g,-1),[...o,...n]}var rdt=t=>{const A=Math.min(...t.map(r=>r.x)),e=Math.max(...t.map(r=>r.x)),i=Math.min(...t.map(r=>r.y)),s=5.47/(Math.max(...t.map(r=>r.y))-i);return t.map(r=>({x:(r.x-A-(e-A)/2)*s,y:(r.y-i)*s}))},adt=rdt([{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}]),n9A=5.47,A8=.5,gdt=({x:t,y:A,z:e})=>{const i=t>0;return Pt(Ko,{children:[ee(Zi,{offset:{x:t+.25/2,y:A,z:e},children:ee(fQ,{rotation:["-90deg",0,"90deg"],children:ee(DL,{height:.25,children:ee(mL,{points:adt.slice().reverse().map(o=>[o.x,o.y])})})})}),ee(Zi,{offset:{x:t,y:A+(i?1:-1),z:e},children:ee(fQ,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:ee(DL,{height:2,children:ee(mL,{points:CCA([[0,0],[-1,0],[-1,-1]],.25).map(o=>[o.x,o.y])})})})})]})},Idt=({numPins:t=8,pitch:A=2.54,bodyWidth:e=6.4,rowSpacing:i})=>{const o=Math.floor(t/2),n=i??(e>=7?e:e+1.22),s=e>=7?n-1.22:e;return Pt(Ko,{children:[sdt(t).map(r=>{const a=r%o,g=(Math.floor(r/o)-.5)*2;return ee(gdt,{x:g*n/2,y:a*A-(o-1)/2*A,z:n9A/2+A8})}),ee($B,{width:s,length:o*A+.5,height:n9A-A8,heightAboveSurface:A8,center:{x:0,y:0,z:A8}})]})};function cdt(t,{height:A,padContactLength:e,curveLength:i,bodyDistance:o,steepness:n=10}){i||(i=o*.3);let s=o-e-i;s<0&&(i+=s,s=0);const r=e*.75,a=e+i+(o-e-i)*.25;if(t<=r)return 0;if(t>=a)return A;const g=(t-r)/(a-r);return A/(1+Math.exp(-n*(g-.5)))}var Oo=t=>{const{thickness:A,width:e,padContactLength:i,bodyDistance:o,height:n,rotation:s}=t,r=15,a=Array.from({length:r}).map((I,c)=>c/(r-1)*o).map(I=>[I,cdt(I,t)]),g=CCA(a,A);return ee(ys,{color:"#fff",children:ee(Zi,{offset:{z:0,y:0,x:0,...t.position},children:ee(fQ,{rotation:["90deg",0,s??0],children:ee(Zi,{offset:{x:0,y:0,z:-e/2},children:ee(DL,{height:e,children:ee(mL,{points:g.map(I=>[I.x,I.y])})})})})})})},Bdt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:o})=>{const n=Math.ceil(t/2),s=i*t/2+e/2,r=(n-1)*i/2,a=.25;return Pt(Ko,{children:[Array.from({length:n}).map((g,I)=>ee(Oo,{position:{x:-o/2-A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:n}).map((g,I)=>ee(Oo,{rotation:Math.PI,position:{x:o/2+A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),ee($B,{center:{x:0,y:0,z:a/2},width:o-e-1,length:s,height:1.5})]})},ldt=({pinCount:t,padContactLength:A=.4,leadWidth:e=.2,pitch:i=.65,bodyWidth:o=3})=>{const n=Math.ceil(t/2),s=(n-1)*i/2,r=.2;return Pt(Ko,{children:[Array.from({length:n}).map((a,g)=>ee(Oo,{position:{x:-o/2-A-.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Array.from({length:n}).map((a,g)=>ee(Oo,{rotation:Math.PI,position:{x:o/2+A+.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),ee($B,{center:{x:0,y:0,z:r/2},width:o,length:o,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},QCA=1,ECA=.5,B_=.5,SL=.2,Cdt=QCA-SL*2,s9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Cdt,ECA,B_],offset:[0,0,B_/2],color:t}),ee(ut,{size:[SL,B_,ECA],offset:[QCA/2-SL/2,0,B_/2],color:"#ccc"}),ee(ut,{size:[SL,B_,ECA],offset:[-QCA/2+SL/2,0,B_/2],color:"#ccc"})]}),hCA=1.6,Qdt=hCA-.3*2,e8=.3,uCA=.85,l_=.6,r9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Qdt,uCA,l_],offset:[0,0,l_/2],color:t}),ee(ut,{size:[e8,uCA,l_],offset:[hCA/2-e8/2,0,l_/2],color:"#ccc"}),ee(ut,{size:[e8,uCA,l_],offset:[-hCA/2+e8/2,0,l_/2],color:"#ccc"})]}),dCA=2,pCA=1.25,C_=.55,bL=.5,Edt=dCA-bL*2,a9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Edt,pCA,C_],offset:[0,0,C_/2],color:t}),ee(ut,{size:[bL,pCA,C_],offset:[dCA/2-bL/2,0,C_/2],color:"#ccc"}),ee(ut,{size:[bL,pCA,C_],offset:[-dCA/2+bL/2,0,C_/2],color:"#ccc"})]}),hdt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:o})=>{const n=t/4;A||(A=udt(t,o)),i||(i=ddt(t)),e||(e=pdt(t,o)),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+2*i,g=a,I=.8,c=.15,B=(g-o)/2+.5;return Pt(Ko,{children:[Array.from({length:n}).map((l,C)=>ee(Oo,{position:{x:-g/2-.4,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:Math.PI,position:{x:g/2+.4,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),ee($B,{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})]})},udt=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},ddt=t=>{switch(t){case 32:return .6;case 40:return .6;case 52:case 64:return .65;case 208:return 1.65;default:return .6}},pdt=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},fdt=({numberOfPins:t,pitch:A=2.54,longSidePinLength:e=6,invert:i,faceup:o,rows:n=1})=>{const a=Math.ceil(t/n),g=2.54,I=a*A,c=n>1?(n-1)*g+.63*3:.63*3,B=3,l=-((a-1)/2)*A,C=n>1?-((n-1)*g)/2:0,Q=E=>i||o?-E+2:E;return Pt(Ko,{children:[ee(ut,{color:"#222",size:[I,c,2],center:[0,C,Q(2/2)]}),Array.from({length:t},(E,h)=>{const u=Math.floor(h/a),d=h%a,f=l+d*A,m=-u*g;return Pt(Ko,{children:[!o&&ee(ys,{color:"gold",children:Pt(CI,{children:[ee(ut,{color:"gold",size:[.63,.63,B*.9],center:[f,m,Q(2*.9+2/2)]}),ee(ut,{color:"gold",size:[.63/1.8,.63/1.8,B],center:[f,m,Q(2+2/2)]})]})}),ee(ys,{color:"gold",children:Pt(CI,{children:[ee(ut,{color:"gold",size:[.63,.63,e*.9],center:[f,m,Q(-e/2*.9)]}),ee(ut,{color:"gold",size:[.63/1.8,.63/1.8,e],center:[f,m,Q(-e/2)]})]})})]})})]})},ydt=t=>{const A=["left","bottom","right","top"],{pin_count:e,pn:i,w:o,h:n,p:s,pl:r}=t,a=e/4,g=A[Math.floor((i-1)/a)],I=(i-1)%a,c=s*(a-1),B=s*(a-1),l=-r/2;switch(g){case"left":return{x:-o/2-l,y:B/2-I*s,o:"vert"};case"bottom":return{x:-c/2+I*s,y:-n/2-l,o:"horz"};case"right":return{x:o/2+l,y:-B/2+I*s,o:"vert"};case"top":return{x:c/2-I*s,y:n/2+l,o:"horz"};default:throw new Error("Invalid pin number")}},wdt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const o=[],n=t/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<t;a++)o[s]=a+1,s++,s>t&&(s=1);return o},mdt=({num_pins:t=16,bodyWidth:A=9,bodyLength:e=9,bodyThickness:i=.8,thermalPadSize:o,padWidth:n=.25,padLength:s=.25,pitch:r=.5,thermalPadThickness:a=.05})=>{const g=wdt({num_pins:t,cw:!0,ccw:!0}),I=[];for(let c=0;c<t;c++){const{x:B,y:l,o:C}=ydt({pin_count:t,pn:c+1,w:A,h:e,p:r,pl:s});let Q=n,E=s;C==="vert"&&([Q,E]=[E,Q]);const h=g[c+1];I.push({pn:h,x:B,y:l,pw:Q,pl:E})}return Pt(Ko,{children:[ee(ys,{color:"grey",children:ee(ut,{center:{x:0,y:0,z:i/2},size:[A,e,i]})}),I.map((c,B)=>ee(ut,{center:{x:c.x,y:c.y,z:a/2},size:[c.pw,c.pl,a]})),o?.length!==void 0&&o?.width!==void 0&&ee(ut,{center:{x:0,y:0,z:a/2},size:[o.width,o.length,a]})]})},Ddt=mdt,Sdt=()=>{const a=1.1999999999999997;return Pt(Ko,{children:[ee(Oo,{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}),ee(Oo,{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}),ee(Oo,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),ee(Oo,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),ee(Oo,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),ee($B,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},bdt=Sdt,xdt=({fullWidth:t=2.9,fullLength:A=2.8})=>{const I=(t-1.92)/2+.3;return Pt(Ko,{children:[ee(Oo,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),ee(Oo,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),ee(Oo,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),ee($B,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},fCA=.6,yCA=.3,Q_=.33,xL=.1,kdt=fCA-xL*2,g9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[kdt,yCA,Q_],offset:[0,0,Q_/2],color:t}),ee(ut,{size:[xL,yCA,Q_],offset:[fCA/2-xL/2,0,Q_/2],color:"#ccc"}),ee(ut,{size:[xL,yCA,Q_],offset:[-fCA/2+xL/2,0,Q_/2],color:"#ccc"})]}),wCA=.4,mCA=.2,E_=.13,kL=.07,Gdt=wCA-kL*2,I9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Gdt,mCA,E_],offset:[0,0,E_/2],color:t}),ee(ut,{size:[kL,mCA,E_],offset:[wCA/2-kL/2,0,E_/2],color:"#ccc"}),ee(ut,{size:[kL,mCA,E_],offset:[-wCA/2+kL/2,0,E_/2],color:"#ccc"})]}),DCA=3.2,SCA=1.6,h_=.9,GL=.5,Fdt=DCA-GL*2,c9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Fdt,SCA,h_],offset:[0,0,h_/2],color:t}),ee(ut,{size:[GL,SCA,h_],offset:[DCA/2-GL/2,0,h_/2],color:"#ccc"}),ee(ut,{size:[GL,SCA,h_],offset:[-DCA/2+GL/2,0,h_/2],color:"#ccc"})]}),bCA=3.2,xCA=2.5,u_=1,FL=.6,Rdt=bCA-FL*2,B9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Rdt,xCA,u_],offset:[0,0,u_/2],color:t}),ee(ut,{size:[FL,xCA,u_],offset:[bCA/2-FL/2,0,u_/2],color:"#ccc"}),ee(ut,{size:[FL,xCA,u_],offset:[-bCA/2+FL/2,0,u_/2],color:"#ccc"})]}),kCA=5,GCA=2.5,d_=1.4,RL=.6,Mdt=kCA-RL*2,l9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Mdt,GCA,d_],offset:[0,0,d_/2],color:t}),ee(ut,{size:[RL,GCA,d_],offset:[kCA/2-RL/2,0,d_/2],color:"#ccc"}),ee(ut,{size:[RL,GCA,d_],offset:[-kCA/2+RL/2,0,d_/2],color:"#ccc"})]}),FCA=6.3,RCA=3.2,p_=1.8,ML=.8,Ndt=FCA-ML*2,C9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Ndt,RCA,p_],offset:[0,0,p_/2],color:t}),ee(ut,{size:[ML,RCA,p_],offset:[FCA/2-ML/2,0,p_/2],color:"#ccc"}),ee(ut,{size:[ML,RCA,p_],offset:[-FCA/2+ML/2,0,p_/2],color:"#ccc"})]}),_dt=({numberOfPins:t,pitch:A=2.54,legsLength:e=3,outerDiameter:i=.945,innerDiameter:o=.945,rows:n=1})=>{const s=o/1.5,r=s*2+i,a=5,g=Math.ceil(t/n),I=2.54,c=(g-1)*A+i+A/2,B=n>1?(n-1)*I+r:r,l=s*1.6,C=-((g-1)/2)*A,Q=n>1?-((n-1)*I)/2:0,E=ee(ys,{color:"#1a1a1a",children:Pt(hF,{children:[ee(ut,{color:"#000",size:[c,B,a],center:[0,Q,a/2]}),Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,m=C+f*A,S=-d*I;return o?ee(tf,{height:a+.1,radius:o/2,center:[m,S,a/2],color:"#222"},u):ee(ut,{size:[l,l,a],center:[m,S,a/2]},u)})]})});return Pt(Ko,{children:[E,Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,m=C+f*A,S=-d*I;return Pt(ys,{color:"silver",children:[Pt(CI,{children:[ee(ut,{color:"silver",size:[s,s,e*.9],center:[m,S,-e/2*.9]}),ee(ut,{color:"silver",size:[s/1.8,s/1.8,e],center:[m,S,-e/2]})]}),ee(ut,{color:"silver",size:[l,l,l*.5],center:[m,S,l/2*.5]})]},u)})]})},vdt=({width:t,length:A,innerDiameter:e=1})=>{const i=t,o=A,n=t*.7,s=e/2.5;return Pt(Ko,{children:[ee(wL,{color:"#1a1a1f",center:[0,0,n/2],size:[o,o,n],roundRadius:.3}),ee(wL,{color:"#f2f2f2",center:[0,0,n+n*.1/2.5],size:[o,o,n*.1],roundRadius:.14}),ee(tf,{color:"#1a1a1f",height:n*.8,radius:i/3,center:[0,0,n+n*.8/2]}),ee(tf,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[o/3,o/3,n+n*.1/2]}),ee(tf,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[-o/3,-o/3,n+n*.1/2]}),ee(tf,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[-o/3,o/3,n+n*.1/2]}),ee(tf,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[o/3,-o/3,n+n*.1/2]}),ee(t8,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:-o/2,z:-n*1.2}}),ee(t8,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),ee(t8,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),ee(t8,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2+e/3.6,y:-o/2,z:-n*1.2}})]})},t8=t=>{const{thickness:A,width:e,horizontalLength:i,verticalLength:o,rotation:n=0,position:s}=t,r=[[0,i],[-o/3,i/3],[-o/5,i/4],[0,0]],a=CCA(r,A);return ee(ys,{color:"#f2f2f2",children:ee(Zi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:ee(fQ,{rotation:[0,55,n],children:ee(DL,{height:e,children:ee(mL,{points:a.map(g=>[g.y,g.x])})})})})})},Udt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:o})=>{const n=Math.ceil(t/2),s=(n-1)*i/2,r=.25,a=1,g=.8,I=A*0,c=i*(n-1)+e+.2,B=o*.55;return Pt(Ko,{children:[Array.from({length:n}).map((l,C)=>ee(Oo,{position:{x:-o/2-I,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:Math.PI,position:{x:o/2+I,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),ee($B,{center:{x:0,y:0,z:r/2},width:B,length:c,height:a})]})},Ldt=({pinCount:t,pitch:A,leadWidth:e,leadLength:i,bodyWidth:o,bodyLength:n})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},r=isNaN(parseFloat(A))?s.pitch:parseFloat(A),a=isNaN(parseFloat(e))?s.leadWidth:parseFloat(e)*.8,g=isNaN(parseFloat(o))?2.6:parseFloat(o)*.8,I=isNaN(parseFloat(n))?2+Number(r)*1.4:parseFloat(n),c=t/2,B=(c-1)*r/2,l=.15,C=.8,Q=4.5,E=(Q-g)/2,h=E*.5;return Pt(Ko,{children:[Array.from({length:c}).map((u,d)=>ee(Oo,{position:{x:-Q/2,y:B-d*r,z:l/2},width:a,thickness:l,padContactLength:h+.05,bodyDistance:E+.1,height:C})),Array.from({length:c}).map((u,d)=>ee(Oo,{rotation:Math.PI,position:{x:Q/2,y:B-d*r,z:l/2},width:a,thickness:l,padContactLength:h+.05,bodyDistance:E+.1,height:C})),ee($B,{center:{x:0,y:0,z:l/2},width:g,length:I,height:1})]})},Hdt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),ee(ut,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[ee(Zi,{z:.3/2,children:ee(ut,{size:[1.65,.8,.3]})}),Pt(CI,{children:[ee(Zi,{z:.3,children:ee(ut,{size:[1.65,.8,.01]})}),ee(Zi,{z:.6,children:ee(ut,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),Ydt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),ee(ut,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),ee(ys,{color:"#222",children:ee(Zi,{z:.47/2+.02,children:ee(ut,{size:[.98,.58,.47]})})}),ee(ut,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),ee(ut,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),ee(ut,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),ee(ut,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),Jdt=()=>{const g=ee(ys,{color:"#1a1a1a",children:Pt(QE,{children:[Pt(CI,{children:[ee(Zi,{z:.13,children:ee(ut,{size:[4,3,.03]})}),ee(Zi,{z:1.15,children:ee(ut,{size:[4.4,3.4,.01]})})]}),Pt(CI,{children:[ee(Zi,{z:1.15,children:ee(ut,{size:[4.4,3.4,.01]})}),ee(Zi,{z:2.3,children:ee(ut,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const C=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return ee(ys,{color:"#c0c0c0",children:Pt(QE,{children:[ee(ut,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),ee(ut,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),ee(ut,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Pt(Ko,{children:[ee(I,{xDir:1}),ee(I,{xDir:-1}),g]})},Tdt=()=>{const g=ee(ys,{color:"#1a1a1a",children:Pt(QE,{children:[Pt(CI,{children:[ee(Zi,{z:.13,children:ee(ut,{size:[4,3,.03]})}),ee(Zi,{z:1.15,children:ee(ut,{size:[4.4,3.4,.01]})})]}),Pt(CI,{children:[ee(Zi,{z:1.15,children:ee(ut,{size:[4.4,3.4,.01]})}),ee(Zi,{z:2.3,children:ee(ut,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const C=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return ee(ys,{color:"#c0c0c0",children:Pt(QE,{children:[ee(ut,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),ee(ut,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),ee(ut,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Pt(Ko,{children:[ee(I,{xDir:1}),ee(I,{xDir:-1}),g]})},Kdt=()=>{const g=ee(ys,{color:"#1a1a1a",children:Pt(QE,{children:[Pt(CI,{children:[ee(Zi,{z:.21000000000000002,children:ee(ut,{size:[6.3999999999999995,5.6,.03]})}),ee(Zi,{z:1.15,children:ee(ut,{size:[6.8,6,.01]})})]}),Pt(CI,{children:[ee(Zi,{z:1.15,children:ee(ut,{size:[6.8,6,.01]})}),ee(Zi,{z:2.3,children:ee(ut,{size:[6.3999999999999995,5.6,.01]})})]})]})}),I=({xDir:c})=>{const C=c*3.08,Q=c*(6/2-.2/2+1),E=c*(6/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return ee(ys,{color:"#c0c0c0",children:Pt(QE,{children:[ee(ut,{size:[2.3*.8,2.95,.2],center:[C,0,.2/2]}),ee(ut,{size:[.2,2.95,1.14],center:[Q,0,1.14/2+.2]}),ee(ut,{size:[h,2.95,.2],center:[u,0,.2/2+1.14]})]})})};return Pt(Ko,{children:[ee(I,{xDir:1}),ee(I,{xDir:-1}),g]})},qdt=()=>{const c=ee(ys,{color:"#222",children:Pt(QE,{children:[ee(Zi,{z:.27,children:ee(ut,{size:[2.9,1.9,.54]})}),Pt(CI,{children:[ee(Zi,{z:.54,children:ee(ut,{size:[2.9,1.9,.01]})}),ee(Zi,{z:1.08,children:ee(ut,{size:[2.6999999999999997,1.7,.01]})})]})]})});return Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),ee(ut,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),c]})},Pdt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),ee(ut,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[ee(Zi,{z:.55/2,children:ee(ut,{size:[2.7,1.6,.55]})}),Pt(CI,{children:[ee(Zi,{z:.55,children:ee(ut,{size:[2.7,1.6,.01]})}),ee(Zi,{z:1.1,children:ee(ut,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),Odt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),ee(ut,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[ee(Zi,{z:.2/2,children:ee(ut,{size:[2.75,1.8,.2]})}),Pt(CI,{children:[ee(Zi,{z:.2,children:ee(ut,{size:[2.75,1.8,.01]})}),ee(Zi,{z:1,children:ee(ut,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),ee(ut,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),Wdt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),ee(ut,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[Pt(CI,{children:[ee(Zi,{z:.2,children:ee(ut,{size:[2.6-.1/2,1.7-.1/2,.01]})}),ee(Zi,{z:.01,children:ee(ut,{size:[2.6-.1,1.7-.1,.01]})})]}),Pt(CI,{children:[ee(Zi,{z:.2,children:ee(ut,{size:[2.6,1.7,.01]})}),ee(Zi,{z:1,children:ee(ut,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),ee(ut,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),Zdt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),ee(ut,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[Pt(CI,{children:[ee(Zi,{z:.2,children:ee(ut,{size:[3.8-.05/2,2.5-.05/2,.01]})}),ee(Zi,{z:.01,children:ee(ut,{size:[3.8-.05,2.5-.05,.01]})})]}),Pt(CI,{children:[ee(Zi,{z:.2,children:ee(ut,{size:[3.8,2.5,.01]})}),ee(Zi,{z:1,children:ee(ut,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),ee(ut,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),Vdt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),ee(ut,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[ee(Zi,{z:.14/2,children:ee(ut,{size:[.8,.6,.14]})}),Pt(CI,{children:[ee(Zi,{z:.14,children:ee(ut,{size:[.8,.6,.01]})}),ee(Zi,{z:.37,children:ee(ut,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),jdt=()=>{const I=3.0999999999999996;return Pt(Ko,{children:[ee(Oo,{rotation:Math.PI,position:{x:6.6/2+I/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),ee(Oo,{position:{x:-6.6/2-I/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),ee(Oo,{position:{x:-6.6/2-I/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),ee(Oo,{position:{x:-6.6/2-I/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),ee($B,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},zdt=()=>Pt(Ko,{children:[Array.from({length:16}).map((l,C)=>ee(Oo,{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((l,C)=>ee(Oo,{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((l,C)=>ee(Oo,{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((l,C)=>ee(Oo,{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})),ee($B,{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})]}),Xdt=zdt,$dt=()=>{const g=.7999999999999998;return Pt(Ko,{children:[ee(Oo,{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}),ee(Oo,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),ee(Oo,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),ee($B,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},Apt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:o})=>{const n=t/4;if(n!==Math.floor(n))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);A||(A=.5),i||(i=.6),e||(e=.22),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+3.3*i,g=a,I=.8,c=.2,B=(g-o)/2+.4;return Pt(Ko,{children:[Array.from({length:n}).map((l,C)=>ee(Oo,{position:{x:-g/2-.36,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:Math.PI,position:{x:g/2+.36,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),ee($B,{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})]})},ept=()=>{const i=.20900000000000002,o=.1,n=.3,s=.1,r=.2;return Pt(Ko,{children:[ee(ys,{color:"#222",children:Pt(QE,{children:[ee(ut,{size:[.85,1.2,i],center:[0,0,i/2]}),Pt(CI,{children:[ee(Zi,{z:i,children:ee(ut,{size:[.85,1.2,.01]})}),ee(Zi,{z:.38,children:ee(ut,{size:[.85-o,1.2-o,.01]})})]})]})}),ee(ut,{color:"#ccc",size:[n,.25,s],center:[.55,0,s/2]}),ee(ut,{color:"#ccc",size:[n,r,s],center:[-.55,.4,s/2]}),ee(ut,{color:"#ccc",size:[n,r,s],center:[-.55,-.4,s/2]})]})},tpt=({num_pins:t,bodyWidth:A=5.3,bodyLength:e=5.3,bodyThickness:i=1,thermalPadSize:o,padWidth:n=e/5.3*.6,padLength:s=e/5.3*1,pitch:r=.5,thermalPadThickness:a=.2})=>{const g=[],I=Math.floor(t/2),c=r*(I-1);for(let B=0;B<t;B++){const l=B<I?"left":"right",C=B%I,Q=c/2-C*r,E=s,h=n,u=l==="left"?-A/2+E/2:A/2-E/2,d=B+1;g.push({pinNumber:d,x:u,y:Q,padSizeX:E,padSizeY:h})}return Pt(Ko,{children:[ee($B,{center:{x:0,y:0,z:0},width:A,length:e,height:i,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(A/2-s),y:e/2-s,z:i}}),g.map((B,l)=>ee(ut,{center:[B.x,B.y,a/2],size:[B.padSizeX,B.padSizeY,a]})),o?.length!==void 0&&o?.width!==void 0&&ee(ut,{center:[0,0,a/2],size:[o.width,o.length,a]})]})},ipt=({bodyLength:t=10.2,bodyWidth:A=4.65,bodyHeight:e=13.46,leadSpacing:i=5,leadDiameter:o=.8,leadLength:n=12.7,color:s="#ddd",leadColor:r="#b87333"})=>{const a=t/2,g=A/2,I=a-g,c=i/2,B=.85;return Pt(Ko,{children:[Pt(ys,{color:s,children:[Pt(CI,{children:[ee(of,{height:e,roundRadius:.5,radius:g,center:[-I,0,e]}),ee(of,{height:e,roundRadius:.5,radius:g,center:[I,0,e]})]}),Pt(CI,{children:[ee(of,{height:B,roundRadius:.1,radius:g+.85,center:[-I,0,e/2+B/2]}),ee(of,{height:B,roundRadius:.1,radius:g+.85,center:[I,0,e/2+B/2]})]})]}),Pt(ys,{color:r,children:[ee(tf,{height:n+e/2,radius:o/2,center:[-c+.06,0,-(n/2)+e/2]}),ee(tf,{height:n+e/2,radius:o/2,center:[c-.06,0,-(n/2)+e/2]})]})]})},opt=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:o="#111"})=>Pt(Ko,{children:[ee(ys,{color:e,children:Pt(fQ,{rotation:[0,"90deg",0],children:[ee(wL,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),ee(tf,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),ee(ys,{color:o,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(wL,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),ee(ys,{color:i,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),ee(ys,{color:i,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),npt=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Pt(Ko,{children:[ee(ys,{color:e,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),ee(ys,{color:i,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),ee(ys,{color:i,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),spt=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Pt(Ko,{children:[ee(ys,{color:e,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),ee(ys,{color:i,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),ee(ys,{color:i,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),rpt=({pinCount:t,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t%2!==0)throw new Error("MS012 pinCount must be even");const o=t/2,n=4.9,s=3.9,r=(o-1)*i/2,a=.2;return Pt(Ko,{children:[Array.from({length:o}).map((g,I)=>ee(Oo,{position:{x:-s/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,I)=>ee(Oo,{rotation:Math.PI,position:{x:s/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),ee($B,{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})]})},apt=({pinCount:t=16,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t!==16)throw new Error("MS013 only supports 16 pins");const o=t/2,n=7.5,s=10.3,r=(o-1)*i/2,a=.2;return Pt(Ko,{children:[Array.from({length:o}).map((g,I)=>ee(Oo,{position:{x:-n/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,I)=>ee(Oo,{rotation:Math.PI,position:{x:n/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),ee($B,{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})]})},gpt=()=>{const Q=7.050000000000001,E=24.95+6.5/2;return ee(Zi,{center:[0,0,1],children:Pt(Ko,{children:[Pt(fQ,{rotation:[0,55,-55],children:[Pt(hF,{children:[ee(ut,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[E,0,1.3-2]}),ee(tf,{color:"black",center:[E,0,1.3-2],radius:3/2,height:1.3*1.2})]}),ee(ys,{color:"#222",children:ee($B,{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})})]}),ee(fQ,{rotation:[0,55,55],children:Array.from({length:3}).map((h,u)=>{const d=Q,f=(u-1)*2.7,m=-.5-.6;return Pt(ys,{color:"gold",children:[Pt(CI,{children:[ee(Zi,{center:[15.05-4.5/2+.1,f,m],children:ee(ut,{size:[4.5,.81+1,.5]})}),ee(Zi,{center:[15.05-4.5/2-1+.1,f,m],children:ee(ut,{size:[4.5,.81,.5]})})]}),ee(Zi,{center:[d,f,m],children:ee(ut,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},Ipt=()=>{const g=1.1999999999999997;return Pt(Ko,{children:[ee(Oo,{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}),ee(Oo,{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}),ee(Oo,{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}),ee(Oo,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),ee(Oo,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),ee(Oo,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),ee($B,{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})]})},cpt=()=>Pt(Ko,{children:[ee($B,{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 I=-.35+g*.35;return ee(ut,{center:[-.8/2+.19/2-.1,I,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(g=>{const I=-.35+g*.35;return ee(ut,{center:[.8/2-.19/2+.1,I,.12/2],size:[.19,.15,.12]})})]}),Bpt=()=>{const s="#222",a=[.43,.4,1.32],g=[.43,.4,.25],I=[0,0,-.66],c=[0,0,-1.32],B=[0,1.28,-2.72],l=[0,1.28,-8.9],C=-7.5;return Pt(Zi,{center:[0,1,10.5],children:[ee(ys,{color:s,children:Pt(hF,{children:[ee(Zi,{center:[0,0,2.25],children:ee(tf,{radius:2.4,height:4.5})}),ee(Zi,{center:[0,-1.8499999999999999,2.25],children:ee(ut,{size:[2.4*2,1.1,4.5+.2]})})]})}),ee(Zi,{center:I,children:ee(ut,{size:a})}),Pt(CI,{children:[ee(Zi,{center:c,children:ee(ut,{size:g})}),ee(Zi,{center:B,children:ee(ut,{size:g})})]}),ee(Zi,{center:l,children:ee(ut,{size:[.43,.4,12.2]})}),ee(Zi,{center:[1.3,0,C],children:ee(ut,{size:[.43,.4,15]})}),ee(Zi,{center:[-1.3,0,C],children:ee(ut,{size:[.43,.4,15]})})]})},lpt=()=>Pt(Ko,{children:[ee(Oo,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),ee(Oo,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),ee(Oo,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),ee(Oo,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),ee(Oo,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),ee(Oo,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),ee($B,{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})]}),Cpt=lpt,Qpt=()=>Pt(Ko,{children:[ee($B,{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 ee(ut,{center:[-1/2+.3/2,a,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(r=>{const a=-.5+r*.5;return ee(ut,{center:[1/2-.3/2,a,.05/2],size:[.3,.2,.05]})})]}),Ept=()=>Pt(Ko,{children:[ee(Oo,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),ee(Oo,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),ee(ys,{color:"#222",children:ee($B,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),ee(ut,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),hpt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),ee(ut,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[ee(Zi,{z:.175/2,children:ee(ut,{size:[1.7,1.25,.175]})}),Pt(CI,{children:[ee(Zi,{z:.175,children:ee(ut,{size:[1.7,1.25,.01]})}),ee(Zi,{z:.725,children:ee(ut,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),ee(ut,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),upt=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),ee(ut,{color:"#ccc",size:[.4,.325,.13],center:[r,0,.13/2]}),ee(ys,{color:"#222",children:ee($B,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),ee(ut,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},dpt=({footprint:t})=>{const A=ndt.string(t).json();switch(A.fn){case"dip":return ee(Idt,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"tssop":return ee(Bdt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return ee(ldt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return ee(Ldt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return ee(hdt,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return ee(Xdt,{});case"lqfp":return ee(Apt,{pinCount:A.num_pins});case"qfn":{const o=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return ee(Ddt,{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 ee(tpt,{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=t.match(/_rows(\d+)/),n=o&&o[1]?parseInt(o[1],10):1;if(A.male)return ee(fdt,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:n});if(A.female)return ee(_dt,{numberOfPins:A.num_pins,pitch:A.p,rows:n})}case"cap":switch(A.imperial){case"0402":return ee(s9A,{color:"#856c4d"});case"0603":return ee(r9A,{color:"#856c4d"});case"0805":return ee(a9A,{color:"#856c4d"});case"0201":return ee(g9A,{color:"#856c4d"});case"01005":return ee(I9A,{color:"#856c4d"});case"1206":return ee(c9A,{color:"#856c4d"});case"1210":return ee(B9A,{color:"#856c4d"});case"2010":return ee(l9A,{color:"#856c4d"});case"2512":return ee(C9A,{color:"#856c4d"})}case"sot235":return ee(bdt,{});case"sot457":return ee(Ipt,{});case"sot223":return ee(jdt,{});case"sot23w":return ee(xdt,{});case"sot323":return ee($dt,{});case"sod323f":return ee(hpt,{});case"sod323fl":return ee(upt,{});case"sot363":return ee(Cpt,{});case"sot886":return ee(Qpt,{});case"sot963":return ee(cpt,{});case"pushbutton":return ee(vdt,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return ee(Udt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return ee(Hdt,{});case"sod882":return ee(Ydt,{});case"sma":return ee(Jdt,{});case"smb":return ee(Tdt,{});case"smc":return ee(Kdt,{});case"smf":return ee(qdt,{});case"sod123f":return ee(Pdt,{});case"sod123fl":return ee(Odt,{});case"sod123w":return ee(Wdt,{});case"sod128":return ee(Zdt,{});case"sod323":return ee(Ept,{});case"sod923":return ee(Vdt,{});case"hc49":return ee(ipt,{});case"micromelf":return ee(opt,{});case"minimelf":return ee(npt,{});case"melf":return ee(spt,{});case"ms012":return ee(rpt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return ee(apt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return ee(ept,{});case"to220":return ee(gpt,{});case"to92":return ee(Bpt,{})}const e=t.match(/_color\(([^)]+)\)/),i=e?e[1]:void 0;switch(A.imperial){case"0402":return ee(s9A,{color:i});case"0603":return ee(r9A,{color:i});case"0805":return ee(a9A,{color:i});case"0201":return ee(g9A,{color:i});case"01005":return ee(I9A,{color:i});case"1206":return ee(c9A,{color:i});case"1210":return ee(B9A,{color:i});case"2010":return ee(l9A,{color:i});case"2512":return ee(C9A,{color:i})}return null},ppt=t=>t&&typeof t=="object"&&"type"in t,f_=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const A=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(t);if(A)return parseFloat(A[1])*Math.PI/180;const e=Number(t);if(!Number.isNaN(e))return e}return 0},fpt=t=>Array.isArray(t)?[Number(t[0])||0,Number(t[1])||0,Number(t[2])||0]:typeof t=="object"&&t?[Number(t.x)||0,Number(t.y)||0,Number(t.z)||0]:[0,0,0];function Pm(t,A,e){const{jscad:{primitives:i,booleans:o,hulls:n,geometries:s,extrusions:r,transforms:a}}=e;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(B=>Pm(B,A,e));if(!ppt(t))return[];const{type:g,props:I,children:c}=t;if(g===t9A)return(c??[]).flatMap(B=>Pm(B,A,e));if(g===ys){const B=I?.color;return(c??[]).flatMap(l=>Pm(l,B??A,e))}if(g===Zi){const B=fpt(I?.offset??I?.center??{x:I?.x,y:I?.y,z:I?.z});return(c??[]).flatMap(C=>Pm(C,A,e)).map(({geom:C,color:Q})=>({geom:a.translate(B,C),color:Q??A}))}if(g===fQ){const B=Array.isArray(I?.rotation)?[f_(I.rotation[0]),f_(I.rotation[1]),f_(I.rotation[2])]:[f_(I?.x??0),f_(I?.y??0),f_(I?.z??0)];return(c??[]).flatMap(C=>Pm(C,A,e)).map(({geom:C,color:Q})=>({geom:a.rotateZ(B[2],a.rotateY(B[1],a.rotateX(B[0],C))),color:Q}))}if(g===QE||g===hF||g===CI){const B=(c??[]).flatMap(C=>Pm(C,A,e)).map(C=>C.geom);if(B.length===0)return[];let l;return g===QE?l=o.union(B):g===hF?l=o.subtract(B[0],B.slice(1)):l=n.hull(B),[{geom:l,color:A}]}if(g===mL){const B=I?.points??[];return[{geom:s.geom2.fromPoints(B),color:A??I?.color}]}if(g===DL){const B=(c??[]).flatMap(E=>Pm(E,A,e)).map(E=>E.geom);if(B.length===0)return[];const l=B.length>1?o.union(B):B[0],C=I?.height??I?.h??1;let Q=r.extrudeLinear({height:C},l);if(Q.polygons)for(const E of Q.polygons)!E.plane||!E.vertices||E.vertices.length<3||E.vertices.reverse();return[{geom:Q,color:A??I?.color}]}if(g===ut||g===i9A||g===tf||g===o9A||g===wL||g===of){let B;if(g===ut){const l=I?.size??[1,1,1],C=I?.offset,Q=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);B=i.cuboid({size:l,center:Q})}else if(g===i9A){const l=I?.size??1,C=I?.offset,Q=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);B=i.cube({size:l,center:Q})}else if(g===tf){const l=I?.height??1,C=I?.radius??1,Q=I?.center??[0,0,0];B=i.cylinder({height:l,radius:C,center:Q})}else if(g===o9A){const l=I?.radius??1,C=I?.center??[0,0,0];B=i.sphere({radius:l,center:C})}else if(g===of){const l=I?.height??1,C=I?.radius??1,Q=I?.roundRadius??.1,E=I?.center??[0,0,0];B=i.roundedCylinder({height:l,radius:C,roundRadius:Q,center:E})}else{const l=I?.size??[1,1,1],C=I?.roundRadius??.1,Q=I?.center??[0,0,0];B=i.roundedCuboid({size:l,roundRadius:C,center:Q})}return[{geom:B,color:A??I?.color}]}if(typeof g=="function"){const B=g(I??{});return Pm(B,A,e)}return(c??[]).flatMap(B=>Pm(B,A,e))}function ypt(t,A){return{geometries:Pm(t,void 0,{jscad:A})}}function Q9A(t){if(t.polygons){const A=[],e=[],i=[];let o=0;for(const s of t.polygons){for(const a of s.vertices)a.index=o,A.push(a[0],a[1],a[2]),t.color&&t.color.length>=3?i.push(t.color[0],t.color[1],t.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,I=s.vertices[a].index;e.push(r,g,I)}}const n=new mg;if(n.setAttribute("position",new BI(new Float32Array(A),3)),n.setIndex(e),i.length>0&&n.setAttribute("color",new BI(new Float32Array(i),3)),t.transforms){const s=new es;s.fromArray(t.transforms),n.applyMatrix4(s)}return n.computeVertexNormals(),n}if(t.sides){const A=[],e=[];for(const o of t.sides)A.push(o[0][0],o[0][1],0),t.color&&t.color.length>=3?e.push(t.color[0],t.color[1],t.color[2]):e.push(1,1,1);const i=new mg;if(i.setAttribute("position",new BI(new Float32Array(A),3)),e.length>0&&i.setAttribute("color",new BI(new Float32Array(e),3)),t.transforms){const o=new es;o.fromArray(t.transforms),i.applyMatrix4(o)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new mg}function wpt(t,A){const e=lCA(dpt,{footprint:t});return ypt(e,A)}var mpt=_r(q5()),E9A=j.createContext(null),Dpt=()=>{const t=j.useContext(E9A);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},Spt=({children:t})=>{const{camera:A,renderer:e}=Ru(),[i,o]=j.useState([]),n=j.useMemo(()=>new c6e,[]),s=j.useMemo(()=>new so,[]),r=j.useRef(i);r.current=i;const a=j.useRef(null),g=j.useCallback(C=>{o(Q=>[...Q,C])},[]),I=j.useCallback(C=>{if(a.current){let Q=!1,E=a.current.object;for(;E;){if(E===C){Q=!0;break}E=E.parent}Q&&(a.current.onUnhover(),a.current=null)}o(Q=>Q.filter(E=>E.object!==C))},[]),c=j.useCallback(C=>{let Q=C;for(;Q;){const E=r.current.find(h=>h.object===Q);if(E)return E;Q=Q.parent}},[]),B=j.useCallback(C=>{if(!e.domElement)return;const Q=e.domElement.getBoundingClientRect();s.x=(C.clientX-Q.left)/Q.width*2-1,s.y=-((C.clientY-Q.top)/Q.height)*2+1,n.setFromCamera(s,A);const E=r.current.map(u=>u.object);if(E.length===0){a.current&&(a.current.onUnhover(),a.current=null);return}const h=n.intersectObjects(E,!0);if(h.length>0){const u=h[0],d=c(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,e,n,s,c]);j.useEffect(()=>{const C=e.domElement;return C.addEventListener("mousemove",B),()=>{C.removeEventListener("mousemove",B)}},[e,B]);const l=j.useMemo(()=>({addHoverable:g,removeHoverable:I}),[g,I]);return O.jsx(E9A.Provider,{value:l,children:t})},bpt=({children:t,object:A,onHover:e,onUnhover:i,isHovered:o})=>{const{addHoverable:n,removeHoverable:s}=Dpt();return j.useEffect(()=>A?(n({object:A,onHover:e,onUnhover:i}),()=>{s(A)}):void 0,[A,e,i,n,s]),O.jsx(O.Fragment,{children:t})},NL=bpt,xpt=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=Ru(),g=j.useMemo(()=>{if(!A)return null;const{geometries:I}=wpt(A,mpt),c=new ef;for(const B of I.flat(1/0)){const l=B.geom;if(!l||!l.polygons&&!l.sides)continue;const C=new Li(B.color);C.convertLinearToSRGB();const Q={...l,color:[C.r,C.g,C.b]},E=Q9A(Q),h=new hh({vertexColors:!0,side:Tl,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new Vo(E,h);c.add(u)}return c},[A,r]);return j.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),j.useEffect(()=>{g&&(t&&g.position.fromArray(t),e&&g.rotation.fromArray(e),s!==void 0&&g.scale.setScalar(s))},[g,t?.[0],t?.[1],t?.[2],e?.[0],e?.[1],e?.[2],s]),j.useEffect(()=>{g&&g.traverse(I=>{I instanceof Vo&&I.material instanceof hh&&(n?(I.material.emissive.setHex(255),I.material.emissiveIntensity=.2):I.material.emissiveIntensity=0)})},[n,g]),g?O.jsx(NL,{isHovered:n,onHover:i,onUnhover:o,object:g}):null},h9A=new WeakMap,kpt=()=>{const t=new Jc;return t.name="fallback-environment-map",t.mapping=AO,t},Gpt=t=>{if(!t)return null;const A=t,e=h9A.get(A);if(e)return e;let i;if(t instanceof RO){const o=new loA(t);i=o.fromScene(_6e(),.04).texture,o.dispose()}else i=kpt();return h9A.set(A,i),i},u9A=1.25;function d9A({gltfUrl:t,position:A,rotation:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=Ru(),[I,c]=j.useState(null),[B,l]=j.useState(null);if(j.useEffect(()=>{if(!t)return;const C=new U6e;let Q=!0;return C.load(t,E=>{if(!Q)return;const h=E.scene;h.traverse(u=>{if(u instanceof Vo&&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)}}),c(h)},void 0,E=>{if(!Q)return;console.error(`An error happened loading ${t}`,E);const h=E instanceof Error?E:new Error(`Failed to load glTF model from ${t}`);l(h)}),()=>{Q=!1}},[t,r]),j.useEffect(()=>{I&&(A&&I.position.fromArray(A),e&&I.rotation.fromArray(e),s!==void 0&&I.scale.setScalar(s))},[I,A?.[0],A?.[1],A?.[2],e?.[0],e?.[1],e?.[2],s]),j.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),j.useEffect(()=>{if(!I||!a)return;const C=Gpt(a);if(!C)return;const Q=[],E=h=>{h instanceof hh&&(Q.push({material:h,envMap:h.envMap??null,envMapIntensity:h.envMapIntensity??1}),h.envMap=C,(typeof h.envMapIntensity!="number"||h.envMapIntensity<u9A)&&(h.envMapIntensity=u9A),h.needsUpdate=!0)};return I.traverse(h=>{if(!(h instanceof Vo))return;const u=h.material;Array.isArray(u)?u.forEach(E):u&&E(u)}),()=>{Q.forEach(({material:h,envMap:u,envMapIntensity:d})=>{h.envMap=u,h.envMapIntensity=d,h.needsUpdate=!0})}},[I,a]),j.useEffect(()=>{I&&I.traverse(C=>{C instanceof Vo&&C.material instanceof hh&&(n?(C.material.emissive.setHex(255),C.material.emissiveIntensity=.2):C.material.emissiveIntensity=0)})},[n,I]),B)throw B;return I?O.jsx(NL,{isHovered:n,onHover:i,onUnhover:o,object:I}):null}var Fpt=_r(OZA()),Rpt=_r(q5()),Mpt=({jscadPlan:t,positionOffset:A,rotationOffset:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=Ru(),{threeGeom:g,material:I}=j.useMemo(()=>{const B=(0,Fpt.executeJscadOperations)(Rpt.default,t);if(!B||!B.polygons&&!B.sides)return{threeGeom:null,material:null};const l=Q9A(B),C=new hh({vertexColors:!0,side:Tl,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:l,material:C}},[t,r]),c=j.useMemo(()=>g?new Vo(g,I):null,[g,I]);return j.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),j.useEffect(()=>{c&&(A&&c.position.fromArray(A),e&&c.rotation.fromArray(e),s!==void 0&&c.scale.setScalar(s))},[c,A?.[0],A?.[1],A?.[2],e?.[0],e?.[1],e?.[2],s]),j.useMemo(()=>{if(I)if(n){const B=new Li(I.color.getHex());I.emissive.copy(B),I.emissive.setRGB(0,0,1),I.emissiveIntensity=.2}else I.emissiveIntensity=0},[n,I]),g?O.jsx(NL,{isHovered:n,onHover:i,onUnhover:o,object:c}):null};function Npt(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(A,e,i)=>`${e} ${i.replace(/-/g,"_")}`)}async function _pt(t){const A=await fetch(t);if(!A.ok)throw new Error(`Failed to fetch "${t}": ${A.status} ${A.statusText}`);const e=await A.text();return new y7e().parse(Npt(e),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function vpt(t){const[A,e]=j.useState(null);return j.useEffect(()=>{if(!t)return;const i=t.replace(/&cachebust_origin=$/,""),o=window.TSCIRCUIT_OBJ_LOADER_CACHE;let n=!1;async function s(){try{if(i.endsWith(".wrl"))return await _pt(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(),I=g.match(/newmtl[\s\S]*?endmtl/g),c=new F7e;if(I?.length){const B=I.join(`
|
|
5071
|
-
`).replace(/d 0\./g,"d 1."),l=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new d7e;C.setMaterialOptions({invertTrProperty:!0});const Q=C.parse(B.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return c.setMaterials(Q),c.parse(l)}return c.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(I=>I instanceof Error?I:I.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||e(a)}).catch(a=>{console.error(a)}),()=>{n=!0}},[t]),A}function Upt({url:t,position:A,rotation:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const a=vpt(t),{rootObject:g}=Ru(),I=j.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(c=>{if(c instanceof Vo&&c.material){const B=l=>{l.transparent=r,l.opacity=r?.5:1,l.depthWrite=!r,l.needsUpdate=!0};Array.isArray(c.material)?c.material.forEach(B):B(c.material)}}),a):new Vo(new Fw(.5,.5,.5),new hh({transparent:!0,color:"red",opacity:.25})),[a,r]);if(j.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),j.useEffect(()=>{I&&(A&&(Array.isArray(A)?I.position.fromArray(A):I.position.copy(A)),e&&(Array.isArray(e)?I.rotation.fromArray(e):I.rotation.copy(e)),s!==void 0&&I.scale.setScalar(s))},[I,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,s]),a instanceof Error)throw a;return O.jsx(NL,{isHovered:n,onHover:i,onUnhover:o,object:I})}var MCA,Lpt="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function Hpt(t){if(typeof t=="function")return t;if(t&&typeof t=="object"&&"default"in t&&typeof t.default=="function")return t.default;throw new Error("Unable to resolve occt-import-js factory export")}async function Ypt(){if(!MCA){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");MCA=Hpt(t)({locateFile:e=>`${Lpt}/${e}`})}return MCA}function Jpt(t){const A=new ef;for(const e of t){const i=e.attributes.position?.array??[],o=e.index?.array??[];if(!i.length||!o.length)continue;const n=new mg;n.setAttribute("position",new Un(i,3));const s=e.attributes.normal?.array??[];s.length?n.setAttribute("normal",new Un(s,3)):n.computeVertexNormals(),n.setIndex(o);const r=new hh({color:e.color?new Li(e.color[0],e.color[1],e.color[2]):new Li(.82,.82,.82)}),a=new Vo(n,r);a.name=e.name,A.add(a)}return A}async function Tpt(t){const A=await fetch(t);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const e=await A.arrayBuffer(),o=(await Ypt()).ReadStepFile(new Uint8Array(e),null);if(!o.success||!o.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const n=Jpt(o.meshes),s=new qoA,r=await new Promise((a,g)=>{s.parse(n,I=>{I instanceof ArrayBuffer?a(I):g(new Error("GLTFExporter did not return binary output"))},I=>{g(I)},{binary:!0})});return URL.createObjectURL(new Blob([r],{type:"model/gltf-binary"}))}var p9A="step-glb-cache:";function Kpt(t){const A=new Uint8Array(t),e=32768;let i="";for(let o=0;o<A.length;o+=e){const n=A.subarray(o,o+e);i+=String.fromCharCode(...n)}return btoa(i)}function qpt(t){const A=atob(t),e=new Uint8Array(A.length);for(let i=0;i<A.length;i+=1)e[i]=A.charCodeAt(i);return e.buffer}function Ppt(t){try{const A=localStorage.getItem(`${p9A}${t}`);return A?qpt(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function Opt(t,A){try{const e=Kpt(A);localStorage.setItem(`${p9A}${t}`,e)}catch(e){console.warn("Failed to write STEP GLB cache",e)}}var Wpt=({stepUrl:t,position:A,rotation:e,scale:i,onHover:o,onUnhover:n,isHovered:s,isTranslucent:r})=>{const[a,g]=j.useState(null);return j.useEffect(()=>{let I=!0,c=null;const B=Ppt(t);return B?(c=URL.createObjectURL(new Blob([B],{type:"model/gltf-binary"})),g(c),()=>{I=!1,c&&URL.revokeObjectURL(c)}):(Tpt(t).then(l=>{if(!I){URL.revokeObjectURL(l);return}c=l,g(l),fetch(l).then(C=>C.arrayBuffer()).then(C=>{Opt(t,C)}).catch(C=>{console.warn("Failed to cache STEP GLB",C)})}).catch(l=>{console.error("Failed to convert STEP file to GLB",l),I&&g(null)}),()=>{I=!1,c&&URL.revokeObjectURL(c)})},[t]),a?O.jsx(d9A,{gltfUrl:a,position:A,rotation:e,scale:i,onHover:o,onUnhover:n,isHovered:s,isTranslucent:r}):null},NCA=(...t)=>t,_CA=1.2;function f9A(t){return j.useMemo(()=>{if(!t)return _CA;try{return mi(t).pcb_board.list()[0]?.thickness??_CA}catch{return _CA}},[t])}var y9A=({cad_component:t,circuitJson:A})=>{const e=f9A(A),[i,o]=j.useState(!1),{visibility:n}=r_(),[s,r]=j.useState(null),a=j.useCallback(f=>{f?.mousePosition?(o(!0),r(f.mousePosition)):(o(!1),r(null))},[]),g=j.useCallback(()=>{o(!1),r(null)},[]),I=j.useMemo(()=>mi(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),c=j.useMemo(()=>A.filter(m=>m.type==="pcb_plated_hole"&&m.pcb_component_id===t.pcb_component_id).length>0,[A,t.pcb_component_id]),B=t.model_obj_url??t.model_wrl_url??t.model_stl_url,l=t.model_glb_url??t.model_gltf_url,C=t.model_step_url,E=A.find(f=>f.type==="pcb_component"&&f.source_component_id===t.source_component_id)?.layer??"top",h=j.useMemo(()=>{const f=t.rotation?NCA(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):NCA(0,0,0);return E==="bottom"?NCA(f[0]+Math.PI,f[1],f[2]):f},[t.rotation,E]),u=j.useMemo(()=>{if(!t.position)return;const f=.55;let m;return E==="top"?m=e/2:E==="bottom"?m=-(e/2)-f:m=t.position.z,[t.position.x,t.position.y,m]},[t.position,E,e]);let d=null;if(B?d=O.jsx(Upt,{url:B,position:u,rotation:h,scale:t.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:t.show_as_translucent_model},t.cad_component_id):l?d=O.jsx(d9A,{gltfUrl:l,position:u,rotation:h,scale:t.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:t.show_as_translucent_model},t.cad_component_id):C&&!t.model_jscad&&!t.footprinter_string?d=O.jsx(Wpt,{stepUrl:C,position:u,rotation:h,scale:t.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:t.show_as_translucent_model}):t.model_jscad?d=O.jsx(Mpt,{jscadPlan:t.model_jscad,positionOffset:u,rotationOffset:h,scale:t.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(d=O.jsx(xpt,{positionOffset:u,rotationOffset:h,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:t.show_as_translucent_model})),t.show_as_translucent_model){if(!n.translucentModels)return null}else if(c&&!n.throughHoleModels||!c&&!n.smtModels)return null;return O.jsxs(O.Fragment,{children:[d,i&&s?O.jsx(jZA,{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:I??"<unknown>"}):null]})},w9A={version:"0.0.499"};function Zpt(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var Vpt=t=>{t.outputColorSpace=yw,t.toneMapping=MLA,t.toneMappingExposure=1},m9A="cadViewerCameraStateSession",D9A=(t,A)=>{try{const e={position:t.position.toArray(),quaternion:t.quaternion.toArray(),up:t.up.toArray(),fov:t.fov??50,target:A.target.toArray()};sessionStorage.setItem(m9A,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},vCA=(t,A)=>{try{const e=sessionStorage.getItem(m9A);if(!e)return!1;const i=JSON.parse(e);if(t.position.fromArray(i.position),t.quaternion.fromArray(i.quaternion),t.up.fromArray(i.up),"fov"in t){const o=t;o.fov=i.fov,o.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),t.updateMatrixWorld(),!0}catch(e){return console.warn("Failed to restore camera:",e),!1}},S9A=j.createContext(void 0),jpt=({children:t,defaultTarget:A,initialCameraPosition:e})=>{const i=j.useRef(null),o=j.useRef(null),[n,s]=j.useState(null),[r,a]=j.useState("perspective"),[g,I]=j.useState(e??null),[c,B]=j.useState(new $p(0,0,0)),l=j.useMemo(()=>{const[h,u,d]=e??[5,-5,5],f=Math.hypot(h-A.x,u-A.y,d-A.z);return f>0?f:5},[e,A]),C=j.useCallback(h=>{const u=[A.x,A.y,A.z],d=o.current,f=i.current;let m=l;switch(d&&f&&(m=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const S=m/Math.sqrt(2);return{position:[A.x,A.y-S,A.z+S],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}},[l,A,o,i]),Q=j.useCallback(h=>{i.current=h},[]),E=j.useMemo(()=>({controlsRef:i,mainCameraRef:o,defaultTarget:A,baseDistance:l,controller:n,setController:s,getPresetConfig:C,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:I,cameraRotation:c,setCameraRotation:B,saveCameraToSession:D9A,loadCameraFromSession:vCA}),[A,l,n,C,Q,r,g,c]);return O.jsx(S9A.Provider,{value:E,children:t})},Hx=()=>{const t=j.useContext(S9A);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},zpt=j.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:o},n)=>{const{cameraType:s}=Hx(),r=j.useRef(null),[a,g]=j.useState(null),I=j.useRef([]),c=j.useRef(void 0);c.current=o;const B=j.useRef(null),l=j.useCallback(h=>{I.current.push(h)},[]),C=j.useCallback(h=>{I.current=I.current.filter(u=>u!==h)},[]),Q=j.useMemo(()=>new $G,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const E=j.useRef(new wg);return j.useImperativeHandle(n,()=>E.current),j.useEffect(()=>{if(!r.current)return;Zpt(r.current);const h=new RO({antialias:!0,alpha:!0});Vpt(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 CE(75,u,.1,1e3):new FU(-10*u,10*u,10,-10,-1e3,1e3);B.current?(d.position.copy(B.current.position),d.quaternion.copy(B.current.quaternion),d.up.copy(B.current.up)):(e?.up&&d.up.set(e.up[0],e.up[1],e.up[2]),e?.position&&d.position.set(e.position[0],e.position[1],e.position[2]),d.lookAt(0,0,0)),Q.add(E.current),window.__TSCIRCUIT_THREE_OBJECT=E.current,g({scene:Q,camera:d,renderer:h,rootObject:E.current,addFrameListener:l,removeFrameListener:C}),c.current?.({camera:d,renderer:h});let f;const m=new e6e,S=()=>{const x=m.getElapsedTime(),F=m.getDelta();I.current.forEach(k=>k(x,F)),h.render(Q,d),f=requestAnimationFrame(S)};S();const D=()=>{if(r.current){const x=r.current.clientWidth/r.current.clientHeight;d instanceof CE?d.aspect=x:d instanceof FU&&(d.left=-10*x,d.right=10*x,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),h.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",D),()=>{B.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",D),cancelAnimationFrame(f),r.current&&h.domElement&&r.current.removeChild(h.domElement),h.dispose(),Q.remove(E.current),window.__TSCIRCUIT_THREE_OBJECT===E.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,l,C,s]),O.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&O.jsx(VZA.Provider,{value:a,children:O.jsx(Spt,{children:t})})})}),Xpt=({autoRotate:t,autoRotateSpeed:A,onStart:e,panSpeed:i,rotateSpeed:o,zoomSpeed:n,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:I,renderer:c}=Ru(),B=j.useMemo(()=>!I||!c?null:new M7e(I,c.domElement),[I,c]);return j.useEffect(()=>(g?.(B??null),()=>g?.(null)),[B,g]),j.useEffect(()=>{if(!B)return;const l=()=>{g?.(B)};return B.addEventListener("change",l),()=>{B.removeEventListener("change",l)}},[B,g]),j.useEffect(()=>{B&&(B.autoRotate=t||!1,B.autoRotateSpeed=A||1,i!==void 0&&(B.panSpeed=i),o!==void 0&&(B.rotateSpeed=o),n!==void 0&&(B.zoomSpeed=n),s!==void 0&&(B.enableDamping=s),r!==void 0&&(B.dampingFactor=r),B.zoomToCursor=!0,B.mouseButtons={LEFT:Qx.ROTATE,MIDDLE:Qx.PAN,RIGHT:null},a&&(B.target.set(a[0],a[1],a[2]),B.update()))},[B,t,A,i,o,n,s,r,a]),j.useEffect(()=>{if(!(!B||!e))return B.addEventListener("start",e),()=>{B.removeEventListener("start",e)}},[B,e]),j.useEffect(()=>{if(B)return()=>{B.dispose()}},[B]),pL(()=>{B?.update()},[B]),null},$pt=`
|
|
5070
|
+
`,C.children.length>0&&I.push(C.children)}return a}};A.exports=s}}),SIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,A){var e=yIt(),i=DIt(),o=class{constructor(n){this.polygonTree=new i,this.rootnode=new e(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}}),jlA=oe({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,A){A.exports={Tree:SIt()}}}),bIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,A){var e=qn(),i=VlA(),{Tree:o}=jlA(),n=(s,r)=>{if(!i(s,r))return e.create();const a=new o(e.toPolygons(s)),g=new o(e.toPolygons(r));a.invert(),g.clipTo(a),g.invert(),a.clipTo(g),g.clipTo(a),a.addPolygons(g.allPolygons()),a.invert();const I=a.allPolygons();return e.create(I)};A.exports=n}}),UZA=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,A){var e=Fn(),i=uL(),o=bIt(),n=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=o(r,a)}),r=i(r),r};A.exports=n}}),xIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,A){var e=Fn(),i=qn(),o=_x(),n=WlA(),s=ZlA(),r=UZA(),a=(...g)=>{g=e(g);const I=g.map(l=>s({z0:-1,z1:1},l)),c=r(I),B=o(c);return n(B,i.toPolygons(c))};A.exports=a}}),kIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,A){var e=Fn(),i=hL(),o=Kn(),n=qn(),s=xIt(),r=UZA(),a=(...g)=>{if(g=e(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 I=g[0];return o.isA(I)?s(g):n.isA(I)?r(g):I};A.exports=a}}),GIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,A){var e=uo(),i=_x(),o=qn(),n=g=>g.sort((I,c)=>I-c).filter((I,c,B)=>!c||I!==B[c-1]),s=(g,I,c)=>{const B=`${I}`,l=g.get(B);l===void 0?g.set(B,[c]):l.push(c)},r=(g,I)=>{const c=`${I}`;return g.get(c)},a=g=>{const I=i(g),c=o.toPolygons(g),B=c.length,l=new Map,C=e.create();c.forEach((d,f)=>{d.vertices.forEach(m=>{s(l,e.snap(C,m,I),f)})});const Q=c.map(d=>{let f=[];return d.vertices.forEach(m=>{f=f.concat(r(l,e.snap(C,m,I)))}),{e:1,d:n(f)}});l.clear();let E=0;const h=Q.length;for(let d=0;d<h;d++){const f=Q[d];if(f.e>0){const m=new Array(B);m[d]=!0;do E=0,m.forEach((S,D)=>{const x=Q[D];if(x.e>0){x.e=-1;for(let F=0;F<x.d.length;F++)m[x.d[F]]=!0;E++}});while(E>0);f.indexes=m}}const u=[];for(let d=0;d<h;d++)if(Q[d].indexes){const f=[];Q[d].indexes.forEach((m,S)=>f.push(c[S])),u.push(o.create(f))}return u};A.exports=a}}),FIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,A){var e=Fn(),i=qn(),o=GIt(),n=(...s)=>{if(s=e(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}}),RIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,A){var e=qn(),i=VlA(),{Tree:o}=jlA(),n=(s,r)=>{if(!i(s,r))return e.clone(s);const a=new o(e.toPolygons(s)),g=new o(e.toPolygons(r));a.invert(),a.clipTo(g),g.clipTo(a,!0),a.addPolygons(g.allPolygons()),a.invert();const I=a.allPolygons();return e.create(I)};A.exports=n}}),LZA=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,A){var e=Fn(),i=uL(),o=RIt(),n=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=o(r,a)}),r=i(r),r};A.exports=n}}),MIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,A){var e=Fn(),i=qn(),o=_x(),n=WlA(),s=ZlA(),r=LZA(),a=(...g)=>{g=e(g);const I=g.map(l=>s({z0:-1,z1:1},l)),c=r(I),B=o(c);return n(B,i.toPolygons(c))};A.exports=a}}),NIt=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,A){var e=Fn(),i=hL(),o=Kn(),n=qn(),s=MIt(),r=LZA(),a=(...g)=>{if(g=e(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 I=g[0];return o.isA(I)?s(g):n.isA(I)?r(g):I};A.exports=a}}),HZA=oe({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,A){var e=qn(),i=VlA(),{Tree:o}=jlA(),n=(r,a)=>{if(!i(r,a))return s(r,a);const g=new o(e.toPolygons(r)),I=new o(e.toPolygons(a));g.clipTo(I,!1),I.clipTo(g),I.invert(),I.clipTo(g),I.invert();const c=g.allPolygons().concat(I.allPolygons());return e.create(c)},s=(r,a)=>{let g=e.toPolygons(r);return g=g.concat(e.toPolygons(a)),e.create(g)};A.exports=n}}),YZA=oe({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,A){var e=Fn(),i=uL(),o=HZA(),n=(...s)=>{s=e(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}}),JZA=oe({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,A){var e=Fn(),i=qn(),o=_x(),n=WlA(),s=ZlA(),r=YZA(),a=(...g)=>{g=e(g);const I=g.map(l=>s({z0:-1,z1:1},l)),c=r(I),B=o(c);return n(B,i.toPolygons(c))};A.exports=a}}),zlA=oe({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,A){var e=Fn(),i=hL(),o=Kn(),n=qn(),s=JZA(),r=YZA(),a=(...g)=>{if(g=e(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 I=g[0];return o.isA(I)?s(g):n.isA(I)?r(g):I};A.exports=a}}),s_=oe({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,A){A.exports={intersect:kIt(),scission:FIt(),subtract:NIt(),union:zlA()}}}),Y5=oe({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,A){var{EPS:e,TAU:i}=Cr(),o=EZA(),n=JlA(),s=ls(),r=U5(),a=(g,I)=>{const c={delta:1,corners:"edge",closed:!1,segments:16};let{delta:B,corners:l,closed:C,segments:Q}=Object.assign({},c,g);if(Math.abs(B)<e)return I;let E=g.closed?r(I):1;E===0&&(E=1);const h=E>0&&B>=0||E<0&&B<0;B=Math.abs(B);let u=null,d=[];const f=[],m=s.create(),S=I.length;for(let D=0;D<S;D++){const x=(D+1)%S,F=I[D],k=I[x];h?s.subtract(m,F,k):s.subtract(m,k,F),s.normal(m,m),s.normalize(m,m),s.scale(m,m,B);const v=s.add(s.create(),F,m),_=s.add(s.create(),k,m),H=[v,_];if(u!=null&&(C||!C&&x!==0)){const P=o(u[0],u[1],H[0],H[1]);P?(d.pop(),H[0]=P):f.push({c:F,s0:u,s1:H})}u=[v,_],!(x===0&&!C)&&(d.push(H[0]),d.push(H[1]))}if(C&&u!=null){const D=d[0],x=d[1],F=o(u[0],u[1],D,x);if(F)d[0]=F,d.pop();else{const k=I[0],v=[D,x];f.push({c:k,s0:u,s1:v})}}if(l==="edge"){const D=new Map;d.forEach((k,v)=>D.set(k,v));const x=n.create(),F=n.create();f.forEach(k=>{n.fromPoints(x,k.s0[0],k.s0[1]),n.fromPoints(F,k.s1[0],k.s1[1]);const v=n.intersectPointOfLines(x,F);if(Number.isFinite(v[0])&&Number.isFinite(v[1])){const _=k.s0[1],H=D.get(_);d[H]=v,d[(H+1)%d.length]=void 0}else{const _=k.s1[0],H=D.get(_);d[H]=void 0}}),d=d.filter(k=>k!==void 0)}if(l==="round"){let D=Math.floor(Q/4);const x=s.create();f.forEach(F=>{let k=s.angle(s.subtract(x,F.s1[0],F.c));if(k-=s.angle(s.subtract(x,F.s0[1],F.c)),h&&k<0&&(k=k+Math.PI,k<0&&(k=k+Math.PI)),!h&&k>0&&(k=k-Math.PI,k>0&&(k=k-Math.PI)),k!==0){D=Math.floor(Q*(Math.abs(k)/i));const v=k/D,_=s.angle(s.subtract(x,F.s0[1],F.c)),H=[];for(let P=1;P<D;P++){const J=_+v*P,W=s.fromAngleRadians(s.create(),J);s.scale(W,W,B),s.add(W,W,F.c),H.push(W)}if(H.length>0){const P=F.s0[1];let J=d.findIndex(W=>s.equals(P,W));J=(J+1)%d.length,d.splice(J,0,...H)}}else{const v=F.s1[0],_=d.findIndex(H=>s.equals(v,H));d.splice(_,1)}})}return d};A.exports=a}}),_It=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,A){var e=Kn(),i=Y5(),o=(n,s)=>{const r={delta:1,corners:"edge",segments:16},{delta:a,corners:g,segments:I}=Object.assign({},r,n);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const l=e.toOutlines(s).map(C=>(n={delta:a,corners:g,closed:!0,segments:I},i(n,C))).reduce((C,Q)=>C.concat(e.toSides(e.fromPoints(Q))),[]);return e.create(l)};A.exports=o}}),vIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,A){var e=Og(),i=uo(),o=qn(),n=Xs(),s=(r,a)=>{i.dot(n.plane(a),r)>0&&(a=n.invert(a));const I=[a],c=n.transform(e.fromTranslation(e.create(),r),a),B=a.vertices.length;for(let l=0;l<B;l++){const C=l<B-1?l+1:0,Q=n.create([a.vertices[l],c.vertices[l],c.vertices[C],a.vertices[C]]);I.push(Q)}return I.push(n.invert(c)),o.create(I)};A.exports=s}}),UIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,A){var{EPS:e,TAU:i}=Cr(),o=Og(),n=uo(),s=_ZA(),r=qn(),a=Xs(),g=xZA(),I=uL(),c=HZA(),B=vIt(),l=(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(),S=f<m?`${f},${m}`:`${m},${f}`;if(h.has(S))h.get(S)[1].push(d);else{const D=[u,[d]];h.set(S,D)}},Q=(h,u)=>{h.findIndex(f=>f===u)<0&&h.push(u)},E=(h,u)=>{const d={delta:1,segments:12},{delta:f,segments:m}=Object.assign({},d,h);let S=r.create();const D=new Map,x=new Map,F=n.create(),k=n.create();return r.toPolygons(u).forEach((_,H)=>{const P=n.scale(n.create(),a.plane(_),2*f),J=a.transform(o.fromTranslation(o.create(),n.scale(n.create(),P,-.5)),_),W=B(P,J);S=c(S,W);const Z=_.vertices;for(let AA=0;AA<Z.length;AA++){l(D,Z[AA],a.plane(_));const nA=(AA+1)%Z.length,gA=[Z[AA],Z[nA]];C(x,gA,a.plane(_))}}),x.forEach(_=>{const H=_[0],P=_[1],J=H[0],W=H[1],Z=n.subtract(n.create(),W,J);n.normalize(Z,Z);const AA=P[0],nA=n.cross(n.create(),AA,Z);let gA=[];for(let YA=0;YA<m;YA++)Q(gA,YA*i/m);for(let YA=0,lA=P.length;YA<lA;YA++){const RA=P[YA],uA=n.dot(nA,RA),KA=n.dot(AA,RA);let $A=Math.atan2(uA,KA);$A<0&&($A+=i),Q(gA,$A),$A=Math.atan2(-uA,-KA),$A<0&&($A+=i),Q(gA,$A)}gA=gA.sort(s);const tA=gA.length;let iA,rA;const CA=[],dA=[],bA=[];for(let YA=-1;YA<tA;YA++){const lA=gA[YA<0?YA+tA:YA],RA=Math.sin(lA),uA=Math.cos(lA);n.scale(F,AA,uA*f),n.scale(k,nA,RA*f),n.add(F,F,k);const KA=n.add(n.create(),J,F),$A=n.add(n.create(),W,F);let re=!1;if(YA>=0&&n.distance(KA,iA)<e&&(re=!0),!re){if(YA>=0){CA.push(KA),dA.push($A);const yA=[rA,$A,KA,iA],qA=a.create(yA);bA.push(qA)}iA=KA,rA=$A}}dA.reverse(),bA.push(a.create(CA)),bA.push(a.create(dA));const kA=r.create(bA);S=c(S,kA)}),D.forEach(_=>{const H=_[0],P=_[1],J=P[0];let W=null,Z=0;for(let tA=1;tA<P.length;tA++){const iA=P[tA],rA=n.cross(F,J,iA),CA=n.length(rA);CA>.05&&CA>Z&&(Z=CA,W=iA)}W||(W=n.orthogonal(F,J));const AA=n.cross(F,J,W);n.normalize(AA,AA);const nA=n.cross(k,AA,J),gA=g({center:[H[0],H[1],H[2]],radius:f,segments:m,axes:[J,AA,nA]});S=c(S,gA)}),I(S)};A.exports=E}}),LIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,A){var e=qn(),i=zlA(),o=UIt(),n=(s,r)=>{const a={delta:1,corners:"round",segments:12},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(I!=="round")throw new Error('corners must be "round" for 3D geometries');if(e.toPolygons(r).length===0)throw new Error("the given geometry cannot be empty");s={delta:g,corners:I,segments:c};const l=o(s,r);return i(r,l)};A.exports=n}}),HIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,A){var e=U5(),i=ls(),o=Kn(),n=Sg(),s=Y5(),r=I=>{let{external:c,internal:B}=I;e(c)<0?c=c.reverse():B=B.reverse();const l=n.fromPoints({closed:!0},c),C=n.fromPoints({closed:!0},B),Q=o.toSides(o.fromPoints(n.toPoints(l))),E=o.toSides(o.fromPoints(n.toPoints(C)));return Q.push(...E),o.create(Q)},a=(I,c,B,l)=>{const{points:C,external:Q,internal:E}=I,h=Math.floor(c/2),u=[],d=[];if(B==="round"&&h>0){const m=Math.PI/h,S=C[C.length-1],D=i.angle(i.subtract(i.create(),Q[Q.length-1],S)),x=C[0],F=i.angle(i.subtract(i.create(),E[0],x));for(let k=1;k<h;k++){let v=D+m*k,_=i.fromAngleRadians(i.create(),v);i.scale(_,_,l),i.add(_,_,S),u.push(_),v=F+m*k,_=i.fromAngleRadians(i.create(),v),i.scale(_,_,l),i.add(_,_,x),d.push(_)}}const f=[];return f.push(...Q,...u,...E.reverse(),...d),o.fromPoints(f)},g=(I,c)=>{I=Object.assign({},{delta:1,corners:"edge",segments:16},I);const{delta:l,corners:C,segments:Q}=I;if(l<=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 E=c.isClosed,h=n.toPoints(c);if(h.length===0)throw new Error("the given geometry cannot be empty");const u={points:h,external:s({delta:l,corners:C,segments:Q,closed:E},h),internal:s({delta:-l,corners:C,segments:Q,closed:E},h)};return c.isClosed?r(u):a(u,Q,C,l)};A.exports=g}}),XlA=oe({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,A){var e=Fn(),i=Kn(),o=qn(),n=Sg(),s=_It(),r=LIt(),a=HIt(),g=(I,...c)=>{if(c=e(c),c.length===0)throw new Error("wrong number of arguments");const B=c.map(l=>n.isA(l)?a(I,l):i.isA(l)?s(I,l):o.isA(l)?r(I,l):l);return B.length===1?B[0]:B};A.exports=g}}),YIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,A){var e=Kn(),i=vlA(),o=Y5(),n=(s,r)=>{const a={delta:1,corners:"edge",segments:0},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(!(I==="edge"||I==="chamfer"||I==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const B=e.toOutlines(r),C=B.map(Q=>(s={delta:B.reduce((u,d)=>u+i.arePointsInside(Q,i.create(d)),0)%2===0?g:-g,corners:I,closed:!0,segments:c},o(s,Q))).reduce((Q,E)=>Q.concat(e.toSides(e.fromPoints(E))),[]);return e.create(C)};A.exports=n}}),JIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,A){var e=Sg(),i=Y5(),o=(n,s)=>{const r={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:a,corners:g,closed:I,segments:c}=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:I,segments:c};const B=i(n,e.toPoints(s));return e.fromPoints({closed:I},B)};A.exports=o}}),TIt=oe({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,A){var e=Fn(),i=Kn(),o=Sg(),n=YIt(),s=JIt(),r=(a,...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");const I=g.map(c=>o.isA(c)?s(a,c):i.isA(c)?n(a,c):c);return I.length===1?I[0]:I};A.exports=r}}),TZA=oe({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,A){A.exports={expand:XlA(),offset:TIt()}}}),J5=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,A){var e=Og(),i=uo(),o=Kn(),n=n_(),s=H5(),r=(a,g)=>{const I={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:c,twistAngle:B,twistSteps:l,repair:C}=Object.assign({},I,a);if(l<1)throw new Error("twistSteps must be 1 or more");B===0&&(l=1);const Q=i.clone(c),E=o.toSides(g);if(E.length===0)throw new Error("the given geometry cannot be empty");const h=n.fromSides(E);Q[2]<0&&n.reverse(h,h);const u=e.create(),d=(f,m,S)=>{const D=m/l*B,x=i.scale(i.create(),Q,m/l);return e.multiply(u,e.fromZRotation(u,D),e.fromTranslation(e.create(),x)),n.transform(u,S)};return a={numberOfSlices:l+1,capStart:!0,capEnd:!0,repair:C,callback:d},s(a,h)};A.exports=r}}),KIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,A){var e=Kn(),i=Sg(),o=J5(),n=(s,r)=>{if(!r.isClosed)throw new Error("extruded path must be closed");const a=i.toPoints(r),g=e.fromPoints(a);return o(s,g)};A.exports=n}}),qIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,A){var e=Fn(),i=Kn(),o=Sg(),n=J5(),s=KIt(),r=(a,...g)=>{const I={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:c,twistAngle:B,twistSteps:l,repair:C}=Object.assign({},I,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");a={offset:[0,0,c],twistAngle:B,twistSteps:l,repair:C};const Q=g.map(E=>o.isA(E)?s(a,E):i.isA(E)?n(a,E):E);return Q.length===1?Q[0]:Q};A.exports=r}}),PIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,A){var e=Sg(),i=XlA(),o=J5(),n=(s,r)=>{const a={size:1,height:1},{size:g,height:I}=Object.assign({},a,s);if(s.delta=g,s.offset=[0,0,I],e.toPoints(r).length===0)throw new Error("the given geometry cannot be empty");const B=i(s,r);return o(s,B)};A.exports=n}}),OIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,A){var{area:e}=lL(),i=Kn(),o=Sg(),n=XlA(),s=J5(),r=(a,g)=>{const I={size:1,height:1},{size:c,height:B}=Object.assign({},I,a);a.delta=c,a.offset=[0,0,B];const l=i.toOutlines(g);if(l.length===0)throw new Error("the given geometry cannot be empty");const Q=l.map(h=>(e(h)<0&&h.reverse(),n(a,o.fromPoints({closed:!0},h)))).reduce((h,u)=>h.concat(i.toSides(u)),[]),E=i.create(Q);return s(a,E)};A.exports=r}}),WIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,A){var e=Fn(),i=Kn(),o=Sg(),n=PIt(),s=OIt(),r=(a,...g)=>{const I={size:1,height:1},{size:c,height:B}=Object.assign({},I,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(c<=0)throw new Error("size must be positive");if(B<=0)throw new Error("height must be positive");const l=g.map(C=>o.isA(C)?n(a,C):i.isA(C)?s(a,C):C);return l.length===1?l[0]:l};A.exports=r}}),ZIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,A){var{TAU:e}=Cr(),i=Og(),o=Kn(),n=H5(),s=n_(),r=(a,g)=>{const I={angle:e,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:c,startAngle:B,pitch:l,height:C,endOffset:Q,segmentsPerRotation:E}=Object.assign({},I,a);if(C!=0&&(l=C/(c/e)),E<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(k=>k[0][0]>=0);let f=s.fromSides(u);d.length===0&&(f=s.reverse(f));const m=Math.round(E/e*Math.abs(c)),S=m>=2?m:2,D=i.create(),x=i.create(),F=(k,v,_)=>{const H=B+c/S*v,P=Q/S*v,J=(H-B)/e*l;return i.multiply(D,i.fromTranslation(i.create(),[P,0,J*Math.sign(c)]),i.fromXRotation(i.create(),-e/4*Math.sign(c))),i.multiply(x,i.fromZRotation(i.create(),H),D),s.transform(x,_)};return n({numberOfSlices:S+1,callback:F},f)};A.exports=r}}),VIt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,A){var e=Fn(),i=YlA(),o=Tm(),n=Og(),s=Kn(),r=qn(),a=Xs(),g=_x(),I=JZA(),c=(l,C)=>{const Q=o.fromNormalAndPoint(o.create(),l.axis,l.origin);if(Number.isNaN(Q[0])||Number.isNaN(Q[1])||Number.isNaN(Q[2])||Number.isNaN(Q[3]))throw new Error("project: invalid axis or origin");const E=g(C),h=E*E*Math.sqrt(3)/4;if(E===0)return s.create();const u=r.toPolygons(C);let d=[];for(let m=0;m<u.length;m++){const S=u[m].vertices.map(F=>o.projectionOfPoint(Q,F)),D=a.create(S),x=a.plane(D);i(Q,x)&&(a.measureArea(D)<h||d.push(D))}if(!i(Q,[0,0,1])){const m=n.fromVectorRotation(n.create(),Q,[0,0,1]);d=d.map(S=>a.transform(m,S))}d=d.sort((m,S)=>a.measureArea(S)-a.measureArea(m));const f=d.map(m=>s.fromPoints(m.vertices));return I(f)},B=(l,...C)=>{const Q={axis:[0,0,1],origin:[0,0,0]},{axis:E,origin:h}=Object.assign({},Q,l);if(C=e(C),C.length===0)throw new Error("wrong number of arguments");l={axis:E,origin:h};const u=C.map(d=>r.isA(d)?c(l,d):d);return u.length===1?u[0]:u};A.exports=B}}),dL=oe({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,A){A.exports={extrudeFromSlices:H5(),extrudeLinear:qIt(),extrudeRectangular:WIt(),extrudeRotate:RZA(),extrudeHelical:ZIt(),project:VIt(),slice:n_()}}}),$lA=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,A){var e=ls(),i=s=>{let r=e.fromValues(1/0,1/0);s.forEach(I=>{(I[1]<r[1]||I[1]===r[1]&&I[0]<r[0])&&(r=I)});const a=[];s.forEach(I=>{const c=n(I[1]-r[1],I[0]-r[0]),B=e.squaredDistance(I,r);a.push({point:I,angle:c,distSq:B})}),a.sort((I,c)=>I.angle!==c.angle?I.angle-c.angle:I.distSq-c.distSq);const g=[];return a.forEach(I=>{let c=g.length;for(;c>1&&o(g[c-2],g[c-1],I.point)<=Number.EPSILON;)g.pop(),c=g.length;g.push(I.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}}),ACA=oe({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,A){var e=Kn(),i=qn(),o=Sg(),n=s=>{const r=new Set,a=[],g=I=>{const c=I.toString();r.has(c)||(a.push(I),r.add(c))};return s.forEach(I=>{e.isA(I)?e.toPoints(I).forEach(g):i.isA(I)?i.toPoints(I).forEach(c=>c.forEach(g)):o.isA(I)&&o.toPoints(I).forEach(g)}),a};A.exports=n}}),jIt=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,A){var e=Fn(),i=Sg(),o=$lA(),n=ACA(),s=(...r)=>{r=e(r);const a=n(r),g=o(a);return i.fromPoints({closed:!0},g)};A.exports=s}}),zIt=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,A){var e=Fn(),i=Kn(),o=$lA(),n=ACA(),s=(...r)=>{r=e(r);const a=n(r),g=o(a);return g.length<3?i.create():i.fromPoints(g)};A.exports=s}}),KZA=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,A){var e=Xs(),i=JWA(),o=n=>i(n,{skipTriangulation:!0}).map(a=>{const g=a.map(I=>n[I]);return e.create(g)});A.exports=o}}),XIt=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,A){var e=Fn(),i=qn(),o=ACA(),n=KZA(),s=(...r)=>{r=e(r);const a=o(r);return a.length===0?i.create():i.create(n(a))};A.exports=s}}),qZA=oe({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,A){var e=Fn(),i=hL(),o=Kn(),n=qn(),s=Sg(),r=jIt(),a=zIt(),g=XIt(),I=(...c)=>{if(c=e(c),c.length===0)throw new Error("wrong number of arguments");if(!i(c))throw new Error("only hulls of the same type are supported");const B=c[0];return s.isA(B)?r(c):o.isA(B)?a(c):n.isA(B)?g(c):B};A.exports=I}}),$It=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,A){var e=Fn(),i=zlA(),o=qZA(),n=(...s)=>{if(s=e(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}}),Act=oe({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,A){A.exports={hull:qZA(),hullChain:$It(),hullPoints2:$lA(),hullPoints3:KZA()}}}),PZA=oe({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,A){var e=uo(),i=Xs(),o=(s,r)=>{const a=Math.abs(i.measureArea(r));return Number.isFinite(a)&&a>s},n=(s,r)=>{let a=r.map(I=>{const c=I.vertices.map(C=>e.snap(e.create(),C,s)),B=[];for(let C=0;C<c.length;C++){const Q=(C+1)%c.length;e.equals(c[C],c[Q])||B.push(c[C])}const l=i.create(B);return I.color&&(l.color=I.color),l});const g=s*s*Math.sqrt(3)/4;return a=a.filter(I=>o(g,I)),a};A.exports=n}}),ect=oe({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,A){var e=YlA(),i=uo(),o=Xs(),n=h=>{const u=o.toPoints(h),d=[];for(let f=0;f<u.length;f++){const m=(f+1)%u.length,S={v1:u[f],v2:u[m]};d.push(S)}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,S=u.next.v2;const D=B(f,m,S,d);f=u.prev.v1,m=u.prev.v2,S=h.next.v2;const x=B(f,m,S,d);return[D,x]},I=i.create(),c=i.create(),B=(h,u,d,f)=>{const m=i.subtract(I,u,h),S=i.subtract(c,d,u);return i.cross(m,m,S),i.dot(m,f)},l=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 S=d.shift(),D=n(S);for(let x=0;x<D.length;x++){const F=D[x],k=a(f,F);if(k){const v=g(F,k,u);if(v[0]>=0&&v[1]>=0){const _=k.next,H=F.next;F.prev.next=k.next,F.next.prev=k.prev,k.prev.next=F.next,k.next.prev=F.prev,F.v1=null,F.v2=null,F.next=null,F.prev=null,r(f,k),k.v1=null,k.v2=null,k.next=null,k.prev=null;const P=(J,W,Z)=>{const AA={v1:Z.v1,v2:W.v2,next:W.next,prev:Z.prev};Z.prev.next=AA,W.next.prev=AA,r(J,W),W.v1=null,W.v2=null,W.next=null,W.prev=null,r(J,Z),Z.v1=null,Z.v2=null,Z.next=null,Z.prev=null};v[0]===0&&P(f,_,_.prev),v[1]===0&&P(f,H,H.prev)}}else F.next&&s(f,F)}}const m=[];return f.forEach(S=>{const D=l(S);D&&m.push(D)}),f.clear(),m},Q=(h,u)=>Math.abs(h[3]-u[3])<15e-8?e(h,u):!1,E=(h,u)=>{const d=[];u.forEach(m=>{const S=d.find(D=>Q(D[0],o.plane(m)));S?S[1].push(m):d.push([o.plane(m),[m]])});let f=[];return d.forEach(m=>{const S=m[1],D=C(S);f=f.concat(D)}),f};A.exports=E}}),tct=oe({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,A){var e=Cr(),i=uo(),o=Xs(),n=g=>`${g}`,s=(g,I,c,B,l,C)=>{const Q=n(B),E=n(l),h=`${Q}/${E}`,u=`${E}/${Q}`;if(g.has(u))return r(g,I,c,l,B,null),null;const d={vertex0:B,vertex1:l,polygonindex:C};return g.has(h)?g.get(h).push(d):g.set(h,[d]),I.has(Q)?I.get(Q).push(h):I.set(Q,[h]),c.has(E)?c.get(E).push(h):c.set(E,[h]),h},r=(g,I,c,B,l,C)=>{const Q=n(B),E=n(l),h=`${Q}/${E}`;let u=-1;const d=g.get(h);for(let f=0;f<d.length;f++){const m=d[f];let S=n(m.vertex0);if(S===Q&&(S=n(m.vertex1),S===E&&!(C!==null&&m.polygonindex!==C))){u=f;break}}d.splice(u,1),d.length===0&&g.delete(h),u=I.get(Q).indexOf(h),I.get(Q).splice(u,1),I.get(Q).length===0&&I.delete(Q),u=c.get(E).indexOf(h),c.get(E).splice(u,1),c.get(E).length===0&&c.delete(E)},a=g=>{const I=new Map;for(let c=0;c<g.length;c++){const B=g[c],l=B.vertices.length;if(l>=3){let C=B.vertices[0],Q=n(C);for(let E=0;E<l;E++){let h=E+1;h===l&&(h=0);const u=B.vertices[h],d=n(u),f=`${Q}/${d}`,m=`${d}/${Q}`;if(I.has(m)){const S=I.get(m);S.splice(-1,1),S.length===0&&I.delete(m)}else{const S={vertex0:C,vertex1:u,polygonindex:c};I.has(f)?I.get(f).push(S):I.set(f,[S])}C=u,Q=d}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(I.size>0){const c=new Map,B=new Map,l=new Map;for(const[Q,E]of I)l.set(Q,!0),E.forEach(h=>{const u=n(h.vertex0),d=n(h.vertex1);c.has(u)?c.get(u).push(Q):c.set(u,[Q]),B.has(d)?B.get(d).push(Q):B.set(d,[Q])});const C=g.slice(0);for(;I.size!==0;){for(const E of I.keys())l.set(E,!0);let Q=!1;for(;;){const E=Array.from(l.keys());if(E.length===0)break;const h=E[0];let u=!0;if(I.has(h)){const f=I.get(h)[0];for(let m=0;m<2;m++){const S=m===0?f.vertex0:f.vertex1,D=m===0?f.vertex1:f.vertex0,x=n(S),F=n(D);let k=[];m===0?B.has(x)&&(k=B.get(x)):c.has(x)&&(k=c.get(x));for(let v=0;v<k.length;v++){const _=k[v],H=I.get(_)[0],P=m===0?H.vertex0:H.vertex1;if(m===0?H.vertex1:H.vertex0,n(P)===F){r(I,c,B,S,D,null),r(I,c,B,D,S,null),u=!1,m=2,Q=!0;break}else{const W=S,Z=D,AA=P,nA=i.subtract(i.create(),AA,W),gA=i.dot(i.subtract(i.create(),Z,W),nA)/i.dot(nA,nA);if(gA>0&&gA<1){const tA=i.scale(i.create(),nA,gA);if(i.add(tA,tA,W),i.squaredDistance(tA,Z)<e.EPS*e.EPS){const rA=H.polygonindex,CA=C[rA],dA=n(H.vertex1);let bA=-1;for(let uA=0;uA<CA.vertices.length;uA++)if(n(CA.vertices[uA])===dA){bA=uA;break}const kA=CA.vertices.slice(0);kA.splice(bA,0,D);const YA=o.create(kA);C[rA]=YA,r(I,c,B,H.vertex0,H.vertex1,rA);const lA=s(I,c,B,H.vertex0,D,rA),RA=s(I,c,B,D,H.vertex1,rA);lA!==null&&l.set(lA,!0),RA!==null&&l.set(RA,!0),u=!1,m=2,Q=!0;break}}}}}}u&&l.delete(h)}if(!Q)break}g=C}return I.clear(),g};A.exports=a}}),ict=oe({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,A){var e=uo(),i=Xs(),o=(s,r,a)=>{const g=r.vertices.length;if(g>3){if(g>4){const B=[0,0,0];r.vertices.forEach(l=>e.add(B,B,l)),e.snap(B,e.divide(B,B,[g,g,g]),s);for(let l=0;l<g;l++){const C=i.create([B,r.vertices[l],r.vertices[(l+1)%g]]);r.color&&(C.color=r.color),a.push(C)}return}const I=i.create([r.vertices[0],r.vertices[1],r.vertices[2]]),c=i.create([r.vertices[0],r.vertices[2],r.vertices[3]]);r.color&&(I.color=r.color,c.color=r.color),a.push(I,c);return}a.push(r)},n=(s,r)=>{const a=[];return r.forEach(g=>{o(s,g,a)}),a};A.exports=n}}),oct=oe({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,A){var e=Fn(),i=_x(),o=Kn(),n=qn(),s=Sg(),r=PZA(),a=ect(),g=tct(),I=ict(),c=(Q,E)=>E,B=(Q,E)=>E,l=(Q,E)=>{const h={snap:!1,simplify:!1,triangulate:!1},{snap:u,simplify:d,triangulate:f}=Object.assign({},h,Q),m=i(E);let S=n.toPolygons(E);u&&(S=r(m,S)),d&&(S=a(m,S)),f&&(S=g(S),S=I(m,S));const D=Object.assign({},E);return D.polygons=S,D},C=(Q,...E)=>{if(E=e(E),E.length===0)throw new Error("wrong number of arguments");const h=E.map(u=>{if(s.isA(u))return c(Q,u);if(o.isA(u))return B(Q,u);if(n.isA(u))return l(Q,u);throw new Error("invalid geometry")});return h.length===1?h[0]:h};A.exports=C}}),nct=oe({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,A){var e=Fn(),i=ls(),o=Kn(),n=qn(),s=Sg(),r=_x(),a=PZA(),g=l=>{const C=r(l),E=s.toPoints(l).map(h=>i.snap(i.create(),h,C));return s.create(E)},I=l=>{const C=r(l);let E=o.toSides(l).map(h=>[i.snap(i.create(),h[0],C),i.snap(i.create(),h[1],C)]);return E=E.filter(h=>!i.equals(h[0],h[1])),o.create(E)},c=l=>{const C=r(l),Q=n.toPolygons(l),E=a(C,Q);return n.create(E)},B=(...l)=>{if(l=e(l),l.length===0)throw new Error("wrong number of arguments");const C=l.map(Q=>s.isA(Q)?g(Q):o.isA(Q)?I(Q):n.isA(Q)?c(Q):Q);return C.length===1?C[0]:C};A.exports=B}}),sct=oe({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,A){A.exports={generalize:oct(),snap:nct(),retessellate:uL()}}}),rct=oe({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,A){var e=(i,o,n)=>{for(i=i.slice();i.length<n;)i.push(o);return i};A.exports=e}}),act=oe({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,A){var e=Fn(),i=rct(),o=TlA(),{translate:n}=CF(),s=I=>{if(!Array.isArray(I.modes)||I.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(I.modes=i(I.modes,"none",3),I.modes.filter(c=>["center","max","min","none"].includes(c)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(I.relativeTo)||I.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(I.relativeTo=i(I.relativeTo,0,3),I.relativeTo.filter(c=>Number.isFinite(c)||c==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof I.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return I},r=(I,c,B)=>{for(let l=0;l<3;l++)I[l]==null&&(c[l]==="center"?I[l]=(B[0][l]+B[1][l])/2:c[l]==="max"?I[l]=B[1][l]:c[l]==="min"&&(I[l]=B[0][l]));return I},a=(I,c,B)=>{const l=o(I),C=[0,0,0];for(let Q=0;Q<3;Q++)c[Q]==="center"?C[Q]=B[Q]-(l[0][Q]+l[1][Q])/2:c[Q]==="max"?C[Q]=B[Q]-l[1][Q]:c[Q]==="min"&&(C[Q]=B[Q]-l[0][Q]);return n(C,I)},g=(I,...c)=>{I=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},I),I=s(I);let{modes:l,relativeTo:C,grouped:Q}=I;if(c=e(c),c.length===0)throw new Error("align(): No geometries were provided to act upon");if(C.filter(E=>E==null).length){const E=o(c);C=r(C,l,E)}return Q?c=a(c,l,C):c=c.map(E=>a(E,l,C)),c.length===1?c[0]:c};A.exports=g}}),T5=oe({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,A){var e=Fn(),i=Kn(),o=qn(),n=Sg(),s=BF(),{translate:r}=CF(),a=(l,C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,l),u=s(C),d=[0,0,0];return E[0]&&(d[0]=h[0]-(u[0][0]+(u[1][0]-u[0][0])/2)),E[1]&&(d[1]=h[1]-(u[0][1]+(u[1][1]-u[0][1])/2)),E[2]&&(d[2]=h[2]-(u[0][2]+(u[1][2]-u[0][2])/2)),r(d,C)},g=(l,...C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,l);if(C=e(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");l={axes:E,relativeTo:h};const u=C.map(d=>n.isA(d)||i.isA(d)||o.isA(d)?a(l,d):d);return u.length===1?u[0]:u},I=(...l)=>g({axes:[!0,!1,!1]},l),c=(...l)=>g({axes:[!1,!0,!1]},l),B=(...l)=>g({axes:[!1,!1,!0]},l);A.exports={center:g,centerX:I,centerY:c,centerZ:B}}}),K5=oe({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,A){var e=Fn(),i=Og(),o=Kn(),n=qn(),s=Sg(),r=(c,...B)=>{if(!Array.isArray(c))throw new Error("factors must be an array");if(B=e(B),B.length===0)throw new Error("wrong number of arguments");for(c=c.slice();c.length<3;)c.push(1);if(c[0]<=0||c[1]<=0||c[2]<=0)throw new Error("factors must be positive");const l=i.fromScaling(i.create(),c),C=B.map(Q=>s.isA(Q)?s.transform(l,Q):o.isA(Q)?o.transform(l,Q):n.isA(Q)?n.transform(l,Q):Q);return C.length===1?C[0]:C},a=(c,...B)=>r([c,1,1],B),g=(c,...B)=>r([1,c,1],B),I=(c,...B)=>r([1,1,c],B);A.exports={scale:r,scaleX:a,scaleY:g,scaleZ:I}}}),gct=oe({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,A){var e=Fn(),i=Kn(),o=qn(),n=Sg(),s=(r,...a)=>{if(a=e(a),a.length===0)throw new Error("wrong number of arguments");const g=a.map(I=>n.isA(I)?n.transform(r,I):i.isA(I)?i.transform(r,I):o.isA(I)?o.transform(r,I):I);return g.length===1?g[0]:g};A.exports=s}}),QF=oe({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,A){A.exports={align:act(),center:T5().center,centerX:T5().centerX,centerY:T5().centerY,centerZ:T5().centerZ,mirror:QL().mirror,mirrorX:QL().mirrorX,mirrorY:QL().mirrorY,mirrorZ:QL().mirrorZ,rotate:EL().rotate,rotateX:EL().rotateX,rotateY:EL().rotateY,rotateZ:EL().rotateZ,scale:K5().scale,scaleX:K5().scaleX,scaleY:K5().scaleY,scaleZ:K5().scaleZ,transform:gct(),translate:CF().translate,translateX:CF().translateX,translateY:CF().translateY,translateZ:CF().translateZ}}}),q5=oe({"node_modules/@jscad/modeling/src/index.js"(t,A){A.exports={colors:v5(),curves:ngt(),geometries:UlA(),maths:Ggt(),measurements:Lgt(),primitives:vx(),text:OlA(),utils:vZA(),booleans:s_(),expansions:TZA(),extrusions:dL(),hulls:Act(),modifiers:sct(),transforms:QF()}}}),OZA=oe({"node_modules/jscad-planner/dist/index.cjs"(t,A){var e=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,s=(B,l)=>{for(var C in l)e(B,C,{get:l[C],enumerable:!0})},r=(B,l,C,Q)=>{if(l&&typeof l=="object"||typeof l=="function")for(let E of o(l))!n.call(B,E)&&E!==C&&e(B,E,{get:()=>l[E],enumerable:!(Q=i(l,E))||Q.enumerable});return B},a=B=>r(e({},"__esModule",{value:!0}),B),g={};s(g,{executeJscadOperations:()=>c,jscadPlanner:()=>I}),A.exports=a(g);var I={booleans:{intersect:(...B)=>({type:"intersect",shapes:B}),subtract:(...B)=>({type:"subtract",shapes:B}),union:(...B)=>({type:"union",shapes:B})},hulls:{hull:(...B)=>({type:"hull",shapes:B.flat()}),hullChain:(...B)=>({type:"hullChain",shapes:B.flat()})},colors:{colorize:(B,l)=>({type:"colorize",color:B,shape:l})},primitives:{cube:B=>({type:"cube",...B}),sphere:B=>({type:"sphere",...B}),cylinder:B=>({type:"cylinder",...B}),polygon:B=>({type:"polygon",...B}),cuboid:B=>({type:"cuboid",...B}),roundedCuboid:B=>({type:"roundedCuboid",...B})},transforms:{rotate:(B,l)=>({type:"rotate",angles:B,shape:l}),scale:(B,l)=>({type:"scale",factors:B,shape:l}),translate:(B,l)=>({type:"translate",vector:B,shape:l})},extrusions:{extrudeLinear:(B,l)=>({type:"extrudeLinear",options:B,shape:l}),extrudeRotate:(B,l)=>({type:"extrudeRotate",options:B,shape:l})},maths:{vec2:{create:(B,l)=>[B,l],fromValues:(B,l)=>[B,l]},vec3:{create:(B,l,C)=>[B,l,C],fromValues:(B,l,C)=>[B,l,C]}},geometries:{geom2:{create:B=>({type:"createGeom2",points:B})},geom3:{create:B=>({type:"createGeom3",polygons:B})},path2:{create:B=>({type:"createPath2",points:B})}},measurements:{measureBoundingBox:B=>({type:"measureBoundingBox",shape:B}),measureArea:B=>({type:"measureArea",shape:B}),measureVolume:B=>({type:"measureVolume",shape:B})},utils:{degToRad:B=>B*Math.PI/180,radToDeg:B=>B*180/Math.PI}},c=(B,l)=>{if(Array.isArray(l)&&l.length===1)return c(B,l[0]);if(Array.isArray(l))throw new Error("executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually");const C=h=>c(B,h),{type:Q,...E}=l;switch(Q){case"intersect":return B.booleans.intersect(...l.shapes.map(C));case"subtract":return B.booleans.subtract(...l.shapes.map(C));case"union":return B.booleans.union(...l.shapes.map(C));case"hull":return B.hulls.hull(...l.shapes.map(C));case"hullChain":return B.hulls.hullChain(...l.shapes.map(C));case"colorize":return B.colors.colorize(l.color,C(l.shape));case"cube":return B.primitives.cube(E);case"sphere":return B.primitives.sphere(E);case"cylinder":return B.primitives.cylinder(E);case"polygon":return B.primitives.polygon(E);case"cuboid":return B.primitives.cuboid(E);case"roundedCuboid":return B.primitives.roundedCuboid(E);case"rotate":return B.transforms.rotate(l.angles,C(l.shape));case"scale":return B.transforms.scale(l.factors,C(l.shape));case"translate":return B.transforms.translate(l.vector,C(l.shape));case"extrudeLinear":return B.extrusions.extrudeLinear(l.options,C(l.shape));case"extrudeRotate":return B.extrusions.extrudeRotate(l.options,C(l.shape));case"createGeom2":return B.geometries.geom2.create(l.points);case"createGeom3":return B.geometries.geom3.create(l.polygons);case"createPath2":return B.geometries.path2.create(l.points);case"measureBoundingBox":return B.measurements.measureBoundingBox(C(l.shape));case"measureArea":return B.measurements.measureArea(C(l.shape));case"measureVolume":return B.measurements.measureVolume(C(l.shape));case"degToRad":return B.utils.degToRad(l.degrees);case"radToDeg":return B.utils.radToDeg(l.radians);default:throw l.type===void 0?new Error(`Operation type is undefined. This usually means the operation object is malformed or not properly initialized. Operation: ${JSON.stringify(l,null,2).slice(0,200)}...`):new Error(`Unsupported operation type: ${l.type}. Operation: ${JSON.stringify(l,null,2)}`)}}}}),Ict=oe({"node_modules/ms/index.js"(t,A){var e=1e3,i=e*60,o=i*60,n=o*24,s=n*7,r=n*365.25;A.exports=function(B,l){l=l||{};var C=typeof B;if(C==="string"&&B.length>0)return a(B);if(C==="number"&&isFinite(B))return l.long?I(B):g(B);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(B))};function a(B){if(B=String(B),!(B.length>100)){var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(B);if(l){var C=parseFloat(l[1]),Q=(l[2]||"ms").toLowerCase();switch(Q){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*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return C;default:return}}}}function g(B){var l=Math.abs(B);return l>=n?Math.round(B/n)+"d":l>=o?Math.round(B/o)+"h":l>=i?Math.round(B/i)+"m":l>=e?Math.round(B/e)+"s":B+"ms"}function I(B){var l=Math.abs(B);return l>=n?c(B,l,n,"day"):l>=o?c(B,l,o,"hour"):l>=i?c(B,l,i,"minute"):l>=e?c(B,l,e,"second"):B+" ms"}function c(B,l,C,Q){var E=l>=C*1.5;return Math.round(B/C)+" "+Q+(E?"s":"")}}}),cct=oe({"node_modules/debug/src/common.js"(t,A){function e(i){n.debug=n,n.default=n,n.coerce=c,n.disable=g,n.enable=r,n.enabled=I,n.humanize=Ict(),n.destroy=B,Object.keys(i).forEach(l=>{n[l]=i[l]}),n.names=[],n.skips=[],n.formatters={};function o(l){let C=0;for(let Q=0;Q<l.length;Q++)C=(C<<5)-C+l.charCodeAt(Q),C|=0;return n.colors[Math.abs(C)%n.colors.length]}n.selectColor=o;function n(l){let C,Q=null,E,h;function u(...d){if(!u.enabled)return;const f=u,m=Number(new Date),S=m-(C||m);f.diff=S,f.prev=C,f.curr=m,C=m,d[0]=n.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let D=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(F,k)=>{if(F==="%%")return"%";D++;const v=n.formatters[k];if(typeof v=="function"){const _=d[D];F=v.call(f,_),d.splice(D,1),D--}return F}),n.formatArgs.call(f,d),(f.log||n.log).apply(f,d)}return u.namespace=l,u.useColors=n.useColors(),u.color=n.selectColor(l),u.extend=s,u.destroy=n.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>Q!==null?Q:(E!==n.namespaces&&(E=n.namespaces,h=n.enabled(l)),h),set:d=>{Q=d}}),typeof n.init=="function"&&n.init(u),u}function s(l,C){const Q=n(this.namespace+(typeof C>"u"?":":C)+l);return Q.log=this.log,Q}function r(l){n.save(l),n.namespaces=l,n.names=[],n.skips=[];const C=(typeof l=="string"?l:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const Q of C)Q[0]==="-"?n.skips.push(Q.slice(1)):n.names.push(Q)}function a(l,C){let Q=0,E=0,h=-1,u=0;for(;Q<l.length;)if(E<C.length&&(C[E]===l[Q]||C[E]==="*"))C[E]==="*"?(h=E,u=Q,E++):(Q++,E++);else if(h!==-1)E=h+1,u++,Q=u;else return!1;for(;E<C.length&&C[E]==="*";)E++;return E===C.length}function g(){const l=[...n.names,...n.skips.map(C=>"-"+C)].join(",");return n.enable(""),l}function I(l){for(const C of n.skips)if(a(l,C))return!1;for(const C of n.names)if(a(l,C))return!0;return!1}function c(l){return l instanceof Error?l.stack||l.message:l}function B(){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=e}}),Bct=oe({"node_modules/debug/src/browser.js"(t,A){t.formatArgs=i,t.save=o,t.load=n,t.useColors=e,t.storage=s(),t.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`."))}})(),t.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 e(){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 I=0,c=0;a[0].replace(/%[a-zA-Z%]/g,B=>{B!=="%%"&&(I++,B==="%c"&&(c=I))}),a.splice(c,0,g)}t.log=console.debug||console.log||(()=>{});function o(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function n(){let a;try{a=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!a&&typeof xlA<"u"&&"env"in xlA&&(a=xlA.env.DEBUG),a}function s(){try{return localStorage}catch{}}A.exports=cct()(t);var{formatters:r}=A.exports;r.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}}}),WZA={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},ZZA=j.createContext(void 0),lct=({children:t})=>{const[A,e]=j.useState(WZA),i=j.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),o=j.useCallback(()=>{e(WZA)},[]),n=j.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:o}),[A,i,o]);return O.jsx(ZZA.Provider,{value:n,children:t})},r_=()=>{const t=j.useContext(ZZA);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},eCA=1.2;function VZA(t){return j.useMemo(()=>{if(!t)return eCA;try{return mi(t).pcb_board.list()[0]?.thickness??eCA}catch{return eCA}},[t])}var jZA=j.createContext(null),Ru=()=>{const t=j.useContext(jZA);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},pL=(t,A=[])=>{const{addFrameListener:e,removeFrameListener:i}=Ru();Xi.useEffect(()=>(e(t),()=>i(t)),[e,i,...A])},fL={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},zZA=({children:t,position:A,style:e})=>{const{camera:i,renderer:o}=Ru(),n=j.useRef(document.createElement("div")),[s,r]=j.useState(null);return j.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(E3.createPortal(t,n.current)),()=>{a.contains(n.current)&&a.removeChild(n.current)}},[o,t]),pL(()=>{if(!i||!n.current||!o)return;const a=new Me(...A);a.project(i);const g=o.domElement.getBoundingClientRect(),I=Math.round((a.x+1)/2*g.width),c=Math.round((-a.y+1)/2*g.height);n.current.style.position="absolute",n.current.style.left=`${I}px`,n.current.style.top=`${c}px`,n.current.style.pointerEvents="none",n.current.style.zIndex=fL.htmlElements.toString(),e&&Object.assign(n.current.style,e)},[i,o,A,e]),s},XZA={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},mr=t=>{let A=typeof t=="number"?"mm":t.replace(/^[^a-zA-Z]+/g,"").toLowerCase();A||(A="mm");const e=typeof t=="number"?t:Number.parseFloat(t.split(A)[0]);if(A in XZA)return e*XZA[A];throw new Error(`Unsupported unit: ${A}`)},mB=mr,$ZA={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}}},tCA=new Set;for(const[t,A]of Object.entries($ZA)){tCA.add(t);for(const e of Object.keys(A.variants))tCA.add(e)}function Cct(t){for(const[A,e]of Object.entries($ZA))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var AVA={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 _w(t){if(t==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:r,unitOfValue:a}=_w(t.x),g=_w(t.x),I=_w(t.y);return g.value===null||I.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:I.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),o=t.slice(0,-i.length);if(i in AVA&&!tCA.has(i)){const r=AVA[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(o)*r}}const{baseUnit:n,conversionFactor:s}=Cct(i);return{parsedUnit:i,unitOfValue:n,value:s*Number.parseFloat(o)}}var iCA=Y().or(WA()).transform(t=>_w(t).value),eVA=Y().or(WA()).transform(t=>_w(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),Qct=Y().or(WA()).transform(t=>_w(t).value),a_=Y().or(WA()).transform(t=>_w(t).value),Ae=Y().or(WA()).transform(t=>_w(t).value),P5=Y().or(WA()).transform(t=>_w(t).value),mt=Ae,oCA=Y().or(WA()).transform(t=>_w(t).value),nCA=Y().or(WA()).transform(t=>_w(t).value),g_=nCA,Ect=Y().datetime(),Gd=Y().or(WA()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),hct=WA().or(Y().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const A=t.replace("mAh",""),e=Number.parseFloat(A);if(Number.isNaN(e))throw new Error("Invalid capacity");return e}return t}).describe("Battery capacity in mAh"),Go=OA({x:mt,y:mt}),sCA=OA({x:mt,y:mt,z:mt}),tVA=OA({width:WA(),height:WA()}),uct=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},Vt=t=>Y().optional().default(()=>`${t}_${uct(10)}`),EF=Bt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]);Bt(["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 dct=Bt(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),DB=OA({type:GA("source_component"),ftype:Y().optional(),source_component_id:Y(),name:Y(),manufacturer_part_number:Y().optional(),supplier_part_numbers:La(dct,be(Y())).optional(),display_value:Y().optional(),are_pins_interchangeable:ce().optional(),internally_connected_source_port_ids:be(be(Y())).optional(),source_group_id:Y().optional(),subcircuit_id:Y().optional()}),iVA=DB.extend({ftype:GA("simple_capacitor"),capacitance:eVA,max_voltage_rating:a_.optional(),display_capacitance:Y().optional(),max_decoupling_trace_length:mt.optional()}),oVA=DB.extend({ftype:GA("simple_resistor"),resistance:iCA,display_resistance:Y().optional()}),rCA=DB.extend({ftype:GA("simple_diode")}),pct=DB.extend({ftype:GA("simple_fiducial")}),nVA=rCA.extend({ftype:GA("simple_led"),color:Y().optional(),wavelength:Y().optional()}),fct=DB.extend({ftype:GA("simple_ground")}),sVA=DB.extend({ftype:GA("simple_chip")}),rVA=DB.extend({ftype:GA("simple_power_source"),voltage:a_}),yct=DB.extend({ftype:GA("simple_fuse"),current_rating_amps:WA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:WA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),aVA=DB.extend({ftype:GA("simple_battery"),capacity:hct}),gVA=DB.extend({ftype:GA("simple_inductor"),inductance:Qct,max_current_rating:WA().optional()}),IVA=DB.extend({ftype:GA("simple_push_button")}),cVA=DB.extend({ftype:GA("simple_potentiometer"),max_resistance:iCA}),wct=DB.extend({ftype:GA("simple_crystal"),frequency:WA().describe("Frequency in Hz"),load_capacitance:WA().optional().describe("Load capacitance in pF")}),BVA=DB.extend({ftype:GA("simple_pin_header"),pin_count:WA(),gender:Bt(["male","female"]).optional().default("male")}),lVA=DB.extend({ftype:GA("simple_pinout")}),CVA=DB.extend({ftype:GA("simple_resonator"),load_capacitance:eVA,equivalent_series_resistance:iCA.optional(),frequency:P5}),QVA=DB.extend({ftype:GA("simple_transistor"),transistor_type:Bt(["npn","pnp"])}),EVA=DB.extend({ftype:GA("simple_test_point"),footprint_variant:Bt(["pad","through_hole"]).optional(),pad_shape:Bt(["rect","circle"]).optional(),pad_diameter:ei([WA(),Y()]).optional(),hole_diameter:ei([WA(),Y()]).optional(),width:ei([WA(),Y()]).optional(),height:ei([WA(),Y()]).optional()}),hVA=DB.extend({ftype:GA("simple_mosfet"),channel_type:Bt(["n","p"]),mosfet_mode:Bt(["enhancement","depletion"])}),uVA=DB.extend({ftype:GA("simple_op_amp")}),dVA=DB.extend({ftype:GA("simple_switch")}),pVA=OA({type:GA("source_project_metadata"),name:Y().optional(),software_used_string:Y().optional(),project_url:Y().optional(),created_at:Ect.optional()}),mct=OA({type:GA("source_missing_property_error"),source_missing_property_error_id:Vt("source_missing_property_error"),source_component_id:Y(),property_name:Y(),subcircuit_id:Y().optional(),error_type:GA("source_missing_property_error").default("source_missing_property_error"),message:Y()}).describe("The source code is missing a property"),Dct=OA({type:GA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Vt("source_failed_to_create_component_error"),error_type:GA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:Y().optional(),subcircuit_id:Y().optional(),parent_source_component_id:Y().optional(),message:Y(),pcb_center:OA({x:WA().optional(),y:WA().optional()}).optional(),schematic_center:OA({x:WA().optional(),y:WA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),fVA=OA({type:GA("source_trace_not_connected_error"),source_trace_not_connected_error_id:Vt("source_trace_not_connected_error"),error_type:GA("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:Y(),subcircuit_id:Y().optional(),source_group_id:Y().optional(),source_trace_id:Y().optional(),connected_source_port_ids:be(Y()).optional(),selectors_not_found:be(Y()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Sct=OA({type:GA("source_property_ignored_warning"),source_property_ignored_warning_id:Vt("source_property_ignored_warning"),source_component_id:Y(),property_name:Y(),subcircuit_id:Y().optional(),error_type:GA("source_property_ignored_warning").default("source_property_ignored_warning"),message:Y()}).describe("The source property was ignored"),yVA=OA({type:GA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Vt("source_pin_missing_trace_warning"),warning_type:GA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:Y(),source_component_id:Y(),source_port_id:Y(),subcircuit_id:Y().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),bct=DB.extend({ftype:GA("simple_voltage_probe")}),xct=DB.extend({ftype:GA("interconnect")}),kct=ei([oVA,iVA,rCA,pct,nVA,fct,sVA,rVA,aVA,gVA,IVA,cVA,wct,BVA,lVA,CVA,dVA,QVA,EVA,hVA,uVA,yct,bct,xct,pVA,mct,Dct,fVA,Sct,yVA]),Gct=OA({type:GA("source_port"),pin_number:WA().optional(),port_hints:be(Y()).optional(),name:Y(),source_port_id:Y(),source_component_id:Y().optional(),source_group_id:Y().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),must_be_connected:ce().optional()}),Fct=OA({type:GA("source_component_internal_connection"),source_component_internal_connection_id:Y(),source_component_id:Y(),source_port_ids:be(Y()),subcircuit_id:Y().optional()}),Rct=OA({type:GA("source_trace"),source_trace_id:Y(),connected_source_port_ids:be(Y()),connected_source_net_ids:be(Y()),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),max_length:WA().optional(),min_trace_thickness:WA().optional(),display_name:Y().optional()}),Mct=OA({type:GA("source_group"),source_group_id:Y(),subcircuit_id:Y().optional(),parent_subcircuit_id:Y().optional(),parent_source_group_id:Y().optional(),is_subcircuit:ce().optional(),show_as_schematic_box:ce().optional(),name:Y().optional(),was_automatically_named:ce().optional()}),Nct=OA({type:GA("source_net"),source_net_id:Y(),name:Y(),member_source_group_ids:be(Y()),is_power:ce().optional(),is_ground:ce().optional(),is_digital_signal:ce().optional(),is_analog_signal:ce().optional(),is_positive_voltage_source:ce().optional(),trace_width:WA().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional()}),_ct=OA({type:GA("source_board"),source_board_id:Y(),source_group_id:Y(),title:Y().optional()}).describe("Defines a board in the source domain"),vct=OA({type:GA("source_pcb_ground_plane"),source_pcb_ground_plane_id:Y(),source_group_id:Y(),source_net_id:Y(),subcircuit_id:Y().optional()}).describe("Defines a ground plane in the source domain"),Uct=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],wVA=Bt(Uct),vr=wVA.or(OA({name:wVA})).transform(t=>typeof t=="string"?t:t.name),Km=Bt(["top","bottom"]),Lct=OA({type:GA("source_manually_placed_via"),source_manually_placed_via_id:Y(),source_group_id:Y(),source_net_id:Y(),subcircuit_id:Y().optional(),source_trace_id:Y().optional()}).describe("Defines a via that is manually placed in the source domain"),Hct=OA({type:GA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:Vt("source_pin_must_be_connected_error"),error_type:GA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),message:Y(),source_component_id:Y(),source_port_id:Y(),subcircuit_id:Y().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),Yct=OA({type:GA("unknown_error_finding_part"),unknown_error_finding_part_id:Vt("unknown_error_finding_part"),error_type:GA("unknown_error_finding_part").default("unknown_error_finding_part"),message:Y(),source_component_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),Jct=OA({type:GA("schematic_box"),schematic_component_id:Y().optional(),width:mt,height:mt,is_dashed:ce().default(!1),x:mt,y:mt,subcircuit_id:Y().optional()}).describe("Draws a box on the schematic"),Tct=OA({type:GA("schematic_path"),schematic_component_id:Y(),fill_color:Bt(["red","blue"]).optional(),is_filled:ce().optional(),points:be(Go),subcircuit_id:Y().optional()}),Kct=La(OA({left_margin:Ae.optional(),right_margin:Ae.optional(),top_margin:Ae.optional(),bottom_margin:Ae.optional()})),qct=OA({left_size:WA(),right_size:WA(),top_size:WA().optional(),bottom_size:WA().optional()}),Pct=OA({left_side:OA({pins:be(WA()),direction:Bt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:OA({pins:be(WA()),direction:Bt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:OA({pins:be(WA()),direction:Bt(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:OA({pins:be(WA()),direction:Bt(["left-to-right","right-to-left"]).optional()}).optional()}),Oct=ei([qct,Pct]),Wct=OA({type:GA("schematic_component"),size:tVA,center:Go,source_component_id:Y().optional(),schematic_component_id:Y(),pin_spacing:Ae.optional(),pin_styles:Kct.optional(),box_width:Ae.optional(),symbol_name:Y().optional(),port_arrangement:Oct.optional(),port_labels:La(Y()).optional(),symbol_display_value:Y().optional(),subcircuit_id:Y().optional(),schematic_group_id:Y().optional(),is_schematic_group:ce().optional(),source_group_id:Y().optional(),is_box_with_pins:ce().optional().default(!0)}),Zct=OA({type:GA("schematic_line"),schematic_line_id:Vt("schematic_line"),schematic_component_id:Y(),x1:mt,y1:mt,x2:mt,y2:mt,stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_dashed:ce().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled line on the schematic"),Vct=OA({type:GA("schematic_rect"),schematic_rect_id:Vt("schematic_rect"),schematic_component_id:Y(),center:Go,width:mt,height:mt,rotation:Gd.default(0),stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_filled:ce().default(!1),fill_color:Y().optional(),is_dashed:ce().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled rectangle on the schematic"),jct=OA({type:GA("schematic_circle"),schematic_circle_id:Vt("schematic_circle"),schematic_component_id:Y(),center:Go,radius:mt,stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_filled:ce().default(!1),fill_color:Y().optional(),is_dashed:ce().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled circle on the schematic"),zct=OA({type:GA("schematic_arc"),schematic_arc_id:Vt("schematic_arc"),schematic_component_id:Y(),center:Go,radius:mt,start_angle_degrees:Gd,end_angle_degrees:Gd,direction:Bt(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:mt.nullable().optional(),color:Y().default("#000000"),is_dashed:ce().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled arc on the schematic"),Xct=OA({type:GA("schematic_trace"),schematic_trace_id:Y(),source_trace_id:Y().optional(),junctions:be(OA({x:WA(),y:WA()})),edges:be(OA({from:OA({x:WA(),y:WA()}),to:OA({x:WA(),y:WA()}),is_crossing:ce().optional(),from_schematic_port_id:Y().optional(),to_schematic_port_id:Y().optional()})),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional()}),$ct=Bt(["center","left","right","top","bottom"]),ABt=OA({type:GA("schematic_text"),schematic_component_id:Y().optional(),schematic_text_id:Y(),text:Y(),font_size:WA().default(.18),position:OA({x:mt,y:mt}),rotation:WA().default(0),anchor:ei([$ct.describe("legacy"),EF]).default("center"),color:Y().default("#000000"),subcircuit_id:Y().optional()}),eBt=OA({type:GA("schematic_port"),schematic_port_id:Y(),source_port_id:Y(),schematic_component_id:Y().optional(),center:Go,facing_direction:Bt(["up","down","left","right"]).optional(),distance_from_component_edge:WA().optional(),side_of_component:Bt(["top","bottom","left","right"]).optional(),true_ccw_index:WA().optional(),pin_number:WA().optional(),display_pin_label:Y().optional(),subcircuit_id:Y().optional(),is_connected:ce().optional(),has_input_arrow:ce().optional(),has_output_arrow:ce().optional()}).describe("Defines a port on a schematic component"),tBt=OA({type:GA("schematic_net_label"),schematic_net_label_id:Vt("schematic_net_label"),schematic_trace_id:Y().optional(),source_trace_id:Y().optional(),source_net_id:Y(),center:Go,anchor_position:Go.optional(),anchor_side:Bt(["top","bottom","left","right"]),text:Y(),symbol_name:Y().optional(),is_movable:ce().optional(),subcircuit_id:Y().optional()}),iBt=OA({type:GA("schematic_error"),schematic_error_id:Y(),error_type:GA("schematic_port_not_found").default("schematic_port_not_found"),message:Y(),subcircuit_id:Y().optional()}).describe("Defines a schematic error on the schematic"),oBt=OA({type:GA("schematic_layout_error"),schematic_layout_error_id:Vt("schematic_layout_error"),error_type:GA("schematic_layout_error").default("schematic_layout_error"),message:Y(),source_group_id:Y(),schematic_group_id:Y(),subcircuit_id:Y().optional()}).describe("Error emitted when schematic layout fails for a group"),aCA=OA({type:GA("schematic_debug_object"),label:Y().optional(),subcircuit_id:Y().optional()}),nBt=aCA.extend({shape:GA("rect"),center:Go,size:tVA}),sBt=aCA.extend({shape:GA("line"),start:Go,end:Go}),rBt=aCA.extend({shape:GA("point"),center:Go}),aBt=Jp("shape",[nBt,sBt,rBt]),gBt=OA({type:GA("schematic_voltage_probe"),schematic_voltage_probe_id:Y(),source_component_id:Y().optional(),name:Y().optional(),position:Go,schematic_trace_id:Y(),voltage:a_.optional(),subcircuit_id:Y().optional(),color:Y().optional(),label_alignment:EF.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),IBt=OA({type:GA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Vt("schematic_manual_edit_conflict_warning"),warning_type:GA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:Y(),schematic_component_id:Y(),schematic_group_id:Y().optional(),subcircuit_id:Y().optional(),source_component_id:Y()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),cBt=OA({type:GA("schematic_group"),schematic_group_id:Vt("schematic_group"),source_group_id:Y(),is_subcircuit:ce().optional(),subcircuit_id:Y().optional(),width:Ae,height:Ae,center:Go,schematic_component_ids:be(Y()),show_as_schematic_box:ce().optional(),name:Y().optional(),description:Y().optional()}).describe("Defines a group of components on the schematic"),BBt=OA({type:GA("schematic_table"),schematic_table_id:Vt("schematic_table"),anchor_position:Go,column_widths:be(mt),row_heights:be(mt),cell_padding:mt.optional(),border_width:mt.optional(),subcircuit_id:Y().optional(),schematic_component_id:Y().optional(),anchor:EF.optional()}).describe("Defines a table on the schematic"),lBt=OA({type:GA("schematic_table_cell"),schematic_table_cell_id:Vt("schematic_table_cell"),schematic_table_id:Y(),start_row_index:WA(),end_row_index:WA(),start_column_index:WA(),end_column_index:WA(),text:Y().optional(),center:Go,width:mt,height:mt,horizontal_align:Bt(["left","center","right"]).optional(),vertical_align:Bt(["top","middle","bottom"]).optional(),font_size:mt.optional(),subcircuit_id:Y().optional()}).describe("Defines a cell within a schematic_table"),CBt=OA({type:GA("schematic_sheet"),schematic_sheet_id:Vt("schematic_sheet"),name:Y().optional(),subcircuit_id:Y().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),QBt=OA({x:mt,y:mt,bulge:WA().optional()}),mVA=OA({vertices:be(QBt)}),EBt=OA({outer_ring:mVA,inner_rings:be(mVA).default([])}),hBt=OA({x:mt,y:mt,via:ce().optional(),via_to_layer:vr.optional()});be(hBt);var uBt=OA({x:mt,y:mt,via:ce().optional(),to_layer:vr.optional(),trace_width:mt.optional()}),dBt=OA({type:GA("pcb_component"),pcb_component_id:Vt("pcb_component"),source_component_id:Y(),center:Go,layer:vr,rotation:Gd,display_offset_x:Y().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:Y().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:Ae,height:Ae,do_not_place:ce().optional(),subcircuit_id:Y().optional(),pcb_group_id:Y().optional(),position_mode:Bt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:Y().optional(),positioned_relative_to_pcb_board_id:Y().optional(),obstructs_within_bounds:ce().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"),DVA=OA({type:GA("pcb_hole"),pcb_hole_id:Vt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:GA("circle"),hole_diameter:WA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()});DVA.describe("Defines a circular hole on the PCB");var SVA=OA({type:GA("pcb_hole"),pcb_hole_id:Vt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:GA("rect"),hole_width:WA(),hole_height:WA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()});SVA.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square.");var bVA=OA({type:GA("pcb_hole"),pcb_hole_id:Vt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:Bt(["circle","square"]),hole_diameter:WA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()});bVA.describe("Defines a circular or square hole on the PCB");var xVA=OA({type:GA("pcb_hole"),pcb_hole_id:Vt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:GA("oval"),hole_width:WA(),hole_height:WA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()});xVA.describe("Defines an oval hole on the PCB");var kVA=OA({type:GA("pcb_hole"),pcb_hole_id:Vt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:GA("pill"),hole_width:WA(),hole_height:WA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()});kVA.describe("Defines a pill-shaped hole on the PCB");var GVA=OA({type:GA("pcb_hole"),pcb_hole_id:Vt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:GA("rotated_pill"),hole_width:WA(),hole_height:WA(),x:mt,y:mt,ccw_rotation:Gd,is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()});GVA.describe("Defines a rotated pill-shaped hole on the PCB");var pBt=bVA.or(xVA).or(kVA).or(GVA).or(DVA).or(SVA),fBt=OA({type:GA("pcb_plated_hole"),shape:GA("circle"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),outer_diameter:WA(),hole_diameter:WA(),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(vr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Vt("pcb_plated_hole"),soldermask_margin:WA().optional()}),yBt=OA({type:GA("pcb_plated_hole"),shape:Bt(["oval","pill"]),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),outer_width:WA(),outer_height:WA(),hole_width:WA(),hole_height:WA(),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,ccw_rotation:Gd,layers:be(vr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Vt("pcb_plated_hole"),soldermask_margin:WA().optional()}),wBt=OA({type:GA("pcb_plated_hole"),shape:GA("circular_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:GA("circle"),pad_shape:GA("rect"),hole_diameter:WA(),rect_pad_width:WA(),rect_pad_height:WA(),rect_border_radius:WA().optional(),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(vr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Vt("pcb_plated_hole"),soldermask_margin:WA().optional()}),mBt=OA({type:GA("pcb_plated_hole"),shape:GA("pill_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:GA("pill"),pad_shape:GA("rect"),hole_width:WA(),hole_height:WA(),rect_pad_width:WA(),rect_pad_height:WA(),rect_border_radius:WA().optional(),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(vr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Vt("pcb_plated_hole"),soldermask_margin:WA().optional()}),DBt=OA({type:GA("pcb_plated_hole"),shape:GA("rotated_pill_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:GA("rotated_pill"),pad_shape:GA("rect"),hole_width:WA(),hole_height:WA(),hole_ccw_rotation:Gd,rect_pad_width:WA(),rect_pad_height:WA(),rect_border_radius:WA().optional(),rect_ccw_rotation:Gd,hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(vr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Vt("pcb_plated_hole"),soldermask_margin:WA().optional()}),SBt=OA({type:GA("pcb_plated_hole"),shape:GA("hole_with_polygon_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:Bt(["circle","oval","pill","rotated_pill"]),hole_diameter:WA().optional(),hole_width:WA().optional(),hole_height:WA().optional(),pad_outline:be(OA({x:mt,y:mt})).min(3),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(vr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:Vt("pcb_plated_hole"),soldermask_margin:WA().optional()}),bBt=ei([fBt,yBt,wBt,mBt,DBt,SBt]),xBt=OA({type:GA("pcb_port"),pcb_port_id:Vt("pcb_port"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),source_port_id:Y(),pcb_component_id:Y().optional(),x:mt,y:mt,layers:be(vr),is_board_pinout:ce().optional()}).describe("Defines a port on the PCB"),kBt=OA({type:GA("pcb_smtpad"),shape:GA("circle"),pcb_smtpad_id:Vt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,radius:WA(),layer:vr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()}),GBt=OA({type:GA("pcb_smtpad"),shape:GA("rect"),pcb_smtpad_id:Vt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),rect_border_radius:WA().optional(),corner_radius:WA().optional(),layer:vr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()}),FBt=OA({type:GA("pcb_smtpad"),shape:GA("rotated_rect"),pcb_smtpad_id:Vt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),rect_border_radius:WA().optional(),corner_radius:WA().optional(),ccw_rotation:Gd,layer:vr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()}),RBt=OA({type:GA("pcb_smtpad"),shape:GA("pill"),pcb_smtpad_id:Vt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),radius:WA(),layer:vr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()}),MBt=OA({type:GA("pcb_smtpad"),shape:GA("rotated_pill"),pcb_smtpad_id:Vt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),radius:WA(),ccw_rotation:Gd,layer:vr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()}),NBt=OA({type:GA("pcb_smtpad"),shape:GA("polygon"),pcb_smtpad_id:Vt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),points:be(Go),layer:vr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:WA().optional()}),_Bt=Jp("shape",[kBt,GBt,FBt,MBt,RBt,NBt]).describe("Defines an SMT pad on the PCB"),vBt=OA({type:GA("pcb_solder_paste"),shape:GA("circle"),pcb_solder_paste_id:Vt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,radius:WA(),layer:vr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),UBt=OA({type:GA("pcb_solder_paste"),shape:GA("rect"),pcb_solder_paste_id:Vt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),layer:vr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),LBt=OA({type:GA("pcb_solder_paste"),shape:GA("pill"),pcb_solder_paste_id:Vt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),radius:WA(),layer:vr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),HBt=OA({type:GA("pcb_solder_paste"),shape:GA("rotated_rect"),pcb_solder_paste_id:Vt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),ccw_rotation:mt,layer:vr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),YBt=OA({type:GA("pcb_solder_paste"),shape:GA("oval"),pcb_solder_paste_id:Vt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:mt,y:mt,width:WA(),height:WA(),layer:vr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),JBt=ei([vBt,UBt,LBt,HBt,YBt]).describe("Defines solderpaste on the PCB"),TBt=OA({type:GA("pcb_text"),pcb_text_id:Vt("pcb_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),text:Y(),center:Go,layer:vr,width:Ae,height:Ae,lines:WA(),align:Bt(["bottom-left"])}).describe("Defines text on the PCB"),KBt=OA({route_type:GA("wire"),x:mt,y:mt,width:mt,start_pcb_port_id:Y().optional(),end_pcb_port_id:Y().optional(),layer:vr}),qBt=OA({route_type:GA("via"),x:mt,y:mt,hole_diameter:mt.optional(),outer_diameter:mt.optional(),from_layer:Y(),to_layer:Y()}),PBt=ei([KBt,qBt]),OBt=OA({type:GA("pcb_trace"),source_trace_id:Y().optional(),pcb_component_id:Y().optional(),pcb_trace_id:Vt("pcb_trace"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),route_thickness_mode:Bt(["constant","interpolated"]).default("constant").optional(),route_order_index:WA().optional(),should_round_corners:ce().optional(),trace_length:WA().optional(),highlight_color:Y().optional(),route:be(PBt)}).describe("Defines a trace on the PCB"),WBt=OA({type:GA("pcb_trace_error"),pcb_trace_error_id:Vt("pcb_trace_error"),error_type:GA("pcb_trace_error").default("pcb_trace_error"),message:Y(),center:Go.optional(),pcb_trace_id:Y(),source_trace_id:Y(),pcb_component_ids:be(Y()),pcb_port_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines a trace error on the PCB"),ZBt=OA({type:GA("pcb_trace_missing_error"),pcb_trace_missing_error_id:Vt("pcb_trace_missing_error"),error_type:GA("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:Y(),center:Go.optional(),source_trace_id:Y(),pcb_component_ids:be(Y()),pcb_port_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),VBt=OA({type:GA("pcb_port_not_matched_error"),pcb_error_id:Vt("pcb_error"),error_type:GA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:Y(),pcb_component_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),jBt=OA({type:GA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Vt("pcb_port_not_connected_error"),error_type:GA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:Y(),pcb_port_ids:be(Y()),pcb_component_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),zBt=OA({type:GA("pcb_net"),pcb_net_id:Vt("pcb_net"),source_net_id:Y().optional(),highlight_color:Y().optional()}).describe("Defines a net on the PCB"),XBt=OA({type:GA("pcb_via"),pcb_via_id:Vt("pcb_via"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),x:mt,y:mt,outer_diameter:mt.default("0.6mm"),hole_diameter:mt.default("0.25mm"),from_layer:vr.optional(),to_layer:vr.optional(),layers:be(vr),pcb_trace_id:Y().optional(),net_is_assignable:ce().optional(),net_assigned:ce().optional(),is_tented:ce().optional()}).describe("Defines a via on the PCB"),$Bt=OA({type:GA("pcb_board"),pcb_board_id:Vt("pcb_board"),pcb_panel_id:Y().optional(),is_subcircuit:ce().optional(),subcircuit_id:Y().optional(),width:Ae.optional(),height:Ae.optional(),center:Go,display_offset_x:Y().optional().describe("How to display the x offset for this board, usually corresponding with how the user specified it"),display_offset_y:Y().optional().describe("How to display the y offset for this board, usually corresponding with how the user specified it"),thickness:Ae.optional().default(1.4),num_layers:WA().optional().default(4),outline:be(Go).optional(),shape:Bt(["rect","polygon"]).optional(),material:Bt(["fr4","fr1"]).default("fr4"),anchor_position:Go.optional(),anchor_alignment:EF.optional(),position_mode:Bt(["relative_to_panel_anchor","none"]).optional()}).describe("Defines the board outline of the PCB"),Alt=OA({type:GA("pcb_panel"),pcb_panel_id:Vt("pcb_panel"),width:Ae,height:Ae,center:Go,covered_with_solder_mask:ce().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),elt=OA({type:GA("pcb_placement_error"),pcb_placement_error_id:Vt("pcb_placement_error"),error_type:GA("pcb_placement_error").default("pcb_placement_error"),message:Y(),subcircuit_id:Y().optional()}).describe("Defines a placement error on the PCB"),tlt=OA({type:GA("pcb_trace_hint"),pcb_trace_hint_id:Vt("pcb_trace_hint"),pcb_port_id:Y(),pcb_component_id:Y(),route:be(uBt),subcircuit_id:Y().optional()}).describe("A hint that can be used during generation of a PCB trace"),ilt=OA({type:GA("pcb_silkscreen_line"),pcb_silkscreen_line_id:Vt("pcb_silkscreen_line"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),stroke_width:mt.default("0.1mm"),x1:mt,y1:mt,x2:mt,y2:mt,layer:Km}).describe("Defines a silkscreen line on the PCB"),olt=OA({type:GA("pcb_silkscreen_path"),pcb_silkscreen_path_id:Vt("pcb_silkscreen_path"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Km,route:be(Go),stroke_width:Ae}).describe("Defines a silkscreen path on the PCB"),nlt=OA({type:GA("pcb_silkscreen_text"),pcb_silkscreen_text_id:Vt("pcb_silkscreen_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("0.2mm"),pcb_component_id:Y(),text:Y(),is_knockout:ce().default(!1).optional(),knockout_padding:OA({left:Ae,top:Ae,bottom:Ae,right:Ae}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:WA().optional(),layer:vr,is_mirrored:ce().default(!1).optional(),anchor_position:Go.default({x:0,y:0}),anchor_alignment:EF.default("center")}).describe("Defines silkscreen text on the PCB"),slt=OA({type:GA("pcb_copper_text"),pcb_copper_text_id:Vt("pcb_copper_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("0.2mm"),pcb_component_id:Y(),text:Y(),is_knockout:ce().default(!1).optional(),knockout_padding:OA({left:Ae,top:Ae,bottom:Ae,right:Ae}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:WA().optional(),layer:vr,is_mirrored:ce().default(!1).optional(),anchor_position:Go.default({x:0,y:0}),anchor_alignment:EF.default("center")}).describe("Defines copper text on the PCB"),rlt=OA({type:GA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Vt("pcb_silkscreen_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,width:Ae,height:Ae,layer:vr,stroke_width:Ae.default("1mm"),corner_radius:Ae.optional(),is_filled:ce().default(!0).optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),ccw_rotation:WA().optional()}).describe("Defines a silkscreen rect on the PCB"),alt=OA({type:GA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Vt("pcb_silkscreen_circle"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,radius:Ae,layer:Km,stroke_width:Ae.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),glt=OA({type:GA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Vt("pcb_silkscreen_oval"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,radius_x:mt,radius_y:mt,layer:Km,ccw_rotation:Gd.optional()}).describe("Defines a silkscreen oval on the PCB"),Ilt=OA({type:GA("pcb_silkscreen_pill"),pcb_silkscreen_pill_id:Vt("pcb_silkscreen_pill"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,width:Ae,height:Ae,layer:vr,ccw_rotation:WA().optional()}).describe("Defines a silkscreen pill on the PCB"),clt=OA({type:GA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Vt("pcb_fabrication_note_text"),subcircuit_id:Y().optional(),pcb_group_id:Y().optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("1mm"),pcb_component_id:Y(),text:Y(),layer:Km,anchor_position:Go.default({x:0,y:0}),anchor_alignment:Bt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Y().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),Blt=OA({type:GA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Vt("pcb_fabrication_note_path"),pcb_component_id:Y(),subcircuit_id:Y().optional(),layer:vr,route:be(Go),stroke_width:Ae,color:Y().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),llt=OA({type:GA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Vt("pcb_fabrication_note_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,width:Ae,height:Ae,layer:Km,stroke_width:Ae.default("0.1mm"),corner_radius:Ae.optional(),is_filled:ce().optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),color:Y().optional()}).describe("Defines a fabrication note rectangle on the PCB"),Clt=OA({type:GA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Vt("pcb_fabrication_note_dimension"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Km,from:Go,to:Go,text:Y().optional(),text_ccw_rotation:WA().optional(),offset:Ae.optional(),offset_distance:Ae.optional(),offset_direction:OA({x:WA(),y:WA()}).optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:Ae.default("1mm"),color:Y().optional(),arrow_size:Ae.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),Qlt=OA({type:GA("pcb_note_text"),pcb_note_text_id:Vt("pcb_note_text"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("1mm"),text:Y().optional(),anchor_position:Go.default({x:0,y:0}),anchor_alignment:Bt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Y().optional()}).describe("Defines a documentation note in text on the PCB"),Elt=OA({type:GA("pcb_note_rect"),pcb_note_rect_id:Vt("pcb_note_rect"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),center:Go,width:Ae,height:Ae,stroke_width:Ae.default("0.1mm"),corner_radius:Ae.optional(),is_filled:ce().optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),color:Y().optional()}).describe("Defines a rectangular documentation note on the PCB"),hlt=OA({type:GA("pcb_note_path"),pcb_note_path_id:Vt("pcb_note_path"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),route:be(Go),stroke_width:Ae.default("0.1mm"),color:Y().optional()}).describe("Defines a polyline documentation note on the PCB"),ult=OA({type:GA("pcb_note_line"),pcb_note_line_id:Vt("pcb_note_line"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),x1:mt,y1:mt,x2:mt,y2:mt,stroke_width:mt.default("0.1mm"),color:Y().optional(),is_dashed:ce().optional()}).describe("Defines a straight documentation note line on the PCB"),dlt=OA({type:GA("pcb_note_dimension"),pcb_note_dimension_id:Vt("pcb_note_dimension"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),from:Go,to:Go,text:Y().optional(),text_ccw_rotation:WA().optional(),offset_distance:Ae.optional(),offset_direction:OA({x:WA(),y:WA()}).optional(),font:GA("tscircuit2024").default("tscircuit2024"),font_size:Ae.default("1mm"),color:Y().optional(),arrow_size:Ae.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),plt=OA({type:GA("pcb_footprint_overlap_error"),pcb_error_id:Vt("pcb_error"),error_type:GA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:Y(),pcb_smtpad_ids:be(Y()).optional(),pcb_plated_hole_ids:be(Y()).optional(),pcb_hole_ids:be(Y()).optional(),pcb_keepout_ids:be(Y()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),flt=OA({type:GA("pcb_keepout"),shape:GA("rect"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,width:mt,height:mt,pcb_keepout_id:Y(),layers:be(Y()),description:Y().optional()}).or(OA({type:GA("pcb_keepout"),shape:GA("circle"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,radius:mt,pcb_keepout_id:Y(),layers:be(Y()),description:Y().optional()})),O5=OA({type:GA("pcb_cutout"),pcb_cutout_id:Vt("pcb_cutout"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_board_id:Y().optional(),pcb_panel_id:Y().optional()}),ylt=O5.extend({shape:GA("rect"),center:Go,width:Ae,height:Ae,rotation:Gd.optional(),corner_radius:Ae.optional()}),wlt=O5.extend({shape:GA("circle"),center:Go,radius:Ae}),mlt=O5.extend({shape:GA("polygon"),points:be(Go)}),Dlt=O5.extend({shape:GA("path"),route:be(Go),slot_width:Ae,slot_length:Ae.optional(),space_between_slots:Ae.optional(),slot_corner_radius:Ae.optional()}),Slt=Jp("shape",[ylt,wlt,mlt,Dlt]).describe("Defines a cutout on the PCB, removing board material."),blt=OA({type:GA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Vt("pcb_missing_footprint_error"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),error_type:GA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:Y(),message:Y()}).describe("Defines a missing footprint error on the PCB"),xlt=OA({type:GA("external_footprint_load_error"),external_footprint_load_error_id:Vt("external_footprint_load_error"),pcb_component_id:Y(),source_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),footprinter_string:Y().optional(),error_type:GA("external_footprint_load_error").default("external_footprint_load_error"),message:Y()}).describe("Defines an error when an external footprint fails to load"),klt=OA({type:GA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Vt("circuit_json_footprint_load_error"),pcb_component_id:Y(),source_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),error_type:GA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:Y(),circuit_json:be(YI()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),Glt=OA({type:GA("pcb_group"),pcb_group_id:Vt("pcb_group"),source_group_id:Y(),is_subcircuit:ce().optional(),subcircuit_id:Y().optional(),width:Ae.optional(),height:Ae.optional(),center:Go,display_offset_x:Y().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:Y().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:be(Go).optional(),anchor_position:Go.optional(),anchor_alignment:EF.default("center"),position_mode:Bt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:Y().optional(),positioned_relative_to_pcb_board_id:Y().optional(),pcb_component_ids:be(Y()),child_layout_mode:Bt(["packed","none"]).optional(),name:Y().optional(),description:Y().optional(),layout_mode:Y().optional(),autorouter_configuration:OA({trace_clearance:Ae}).optional(),autorouter_used_string:Y().optional()}).describe("Defines a group of components on the PCB"),Flt=OA({type:GA("pcb_autorouting_error"),pcb_error_id:Vt("pcb_autorouting_error"),error_type:GA("pcb_autorouting_error").default("pcb_autorouting_error"),message:Y(),subcircuit_id:Y().optional()}).describe("The autorouting has failed to route a portion of the board"),Rlt=OA({type:GA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Vt("pcb_manual_edit_conflict_warning"),warning_type:GA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:Y(),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),source_component_id:Y()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),Mlt=OA({type:GA("pcb_breakout_point"),pcb_breakout_point_id:Vt("pcb_breakout_point"),pcb_group_id:Y(),subcircuit_id:Y().optional(),source_trace_id:Y().optional(),source_port_id:Y().optional(),source_net_id:Y().optional(),x:mt,y:mt}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),Nlt=OA({type:GA("pcb_ground_plane"),pcb_ground_plane_id:Vt("pcb_ground_plane"),source_pcb_ground_plane_id:Y(),source_net_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Defines a ground plane on the PCB"),_lt=OA({type:GA("pcb_ground_plane_region"),pcb_ground_plane_region_id:Vt("pcb_ground_plane_region"),pcb_ground_plane_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:vr,points:be(Go)}).describe("Defines a polygon region of a ground plane"),vlt=OA({type:GA("pcb_thermal_spoke"),pcb_thermal_spoke_id:Vt("pcb_thermal_spoke"),pcb_ground_plane_id:Y(),shape:Y(),spoke_count:WA(),spoke_thickness:mt,spoke_inner_diameter:mt,spoke_outer_diameter:mt,pcb_plated_hole_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),gCA=OA({type:GA("pcb_copper_pour"),pcb_copper_pour_id:Vt("pcb_copper_pour"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:vr,source_net_id:Y().optional(),covered_with_solder_mask:ce().optional().default(!0)}),Ult=gCA.extend({shape:GA("rect"),center:Go,width:Ae,height:Ae,rotation:Gd.optional()}),Llt=gCA.extend({shape:GA("brep"),brep_shape:EBt}),Hlt=gCA.extend({shape:GA("polygon"),points:be(Go)}),Ylt=Jp("shape",[Ult,Llt,Hlt]).describe("Defines a copper pour on the PCB."),Jlt=OA({type:GA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Vt("pcb_component_outside_board_error"),error_type:GA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:Y(),pcb_component_id:Y(),pcb_board_id:Y(),component_center:Go,component_bounds:OA({min_x:WA(),max_x:WA(),min_y:WA(),max_y:WA()}),subcircuit_id:Y().optional(),source_component_id:Y().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),Tlt=OA({type:GA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Vt("pcb_component_invalid_layer_error"),error_type:GA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:Y(),pcb_component_id:Y().optional(),source_component_id:Y(),layer:vr,subcircuit_id:Y().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),Klt=OA({type:GA("pcb_via_clearance_error"),pcb_error_id:Vt("pcb_error"),error_type:GA("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:Y(),pcb_via_ids:be(Y()).min(2),minimum_clearance:mt.optional(),actual_clearance:mt.optional(),pcb_center:OA({x:WA().optional(),y:WA().optional()}).optional(),subcircuit_id:Y().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),qlt=OA({type:GA("pcb_courtyard_rect"),pcb_courtyard_rect_id:Vt("pcb_courtyard_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:Go,width:Ae,height:Ae,layer:Km,color:Y().optional()}).describe("Defines a courtyard rectangle on the PCB"),Plt=OA({type:GA("pcb_courtyard_outline"),pcb_courtyard_outline_id:Vt("pcb_courtyard_outline"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Km,outline:be(Go).min(2),stroke_width:Ae.default("0.1mm"),is_closed:ce().optional(),is_stroke_dashed:ce().optional(),color:Y().optional()}).describe("Defines a courtyard outline on the PCB"),Olt=OA({type:GA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Vt("pcb_courtyard_polygon"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Km,points:be(Go).min(3),color:Y().optional()}).describe("Defines a courtyard polygon on the PCB"),Wlt=OA({type:GA("cad_component"),cad_component_id:Y(),pcb_component_id:Y(),source_component_id:Y(),position:sCA,rotation:sCA.optional(),size:sCA.optional(),layer:vr.optional(),subcircuit_id:Y().optional(),footprinter_string:Y().optional(),model_obj_url:Y().optional(),model_stl_url:Y().optional(),model_3mf_url:Y().optional(),model_gltf_url:Y().optional(),model_glb_url:Y().optional(),model_step_url:Y().optional(),model_wrl_url:Y().optional(),model_unit_to_mm_scale_factor:WA().optional(),model_jscad:YI().optional(),show_as_translucent_model:ce().optional()}).describe("Defines a component on the PCB"),FVA=Bt(["sinewave","square","triangle","sawtooth"]),Zlt=ei([Y(),WA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(WA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),Vlt=OA({type:GA("simulation_voltage_source"),simulation_voltage_source_id:Vt("simulation_voltage_source"),is_dc_source:GA(!0).optional().default(!0),positive_source_port_id:Y().optional(),negative_source_port_id:Y().optional(),positive_source_net_id:Y().optional(),negative_source_net_id:Y().optional(),voltage:a_}).describe("Defines a DC voltage source for simulation"),jlt=OA({type:GA("simulation_voltage_source"),simulation_voltage_source_id:Vt("simulation_voltage_source"),is_dc_source:GA(!1),terminal1_source_port_id:Y().optional(),terminal2_source_port_id:Y().optional(),terminal1_source_net_id:Y().optional(),terminal2_source_net_id:Y().optional(),voltage:a_.optional(),frequency:P5.optional(),peak_to_peak_voltage:a_.optional(),wave_shape:FVA.optional(),phase:Gd.optional(),duty_cycle:Zlt.optional()}).describe("Defines an AC voltage source for simulation"),zlt=ei([Vlt,jlt]).describe("Defines a voltage source for simulation"),Xlt=ei([Y(),WA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(WA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),$lt=OA({type:GA("simulation_current_source"),simulation_current_source_id:Vt("simulation_current_source"),is_dc_source:GA(!0).optional().default(!0),positive_source_port_id:Y().optional(),negative_source_port_id:Y().optional(),positive_source_net_id:Y().optional(),negative_source_net_id:Y().optional(),current:oCA}).describe("Defines a DC current source for simulation"),ACt=OA({type:GA("simulation_current_source"),simulation_current_source_id:Vt("simulation_current_source"),is_dc_source:GA(!1),terminal1_source_port_id:Y().optional(),terminal2_source_port_id:Y().optional(),terminal1_source_net_id:Y().optional(),terminal2_source_net_id:Y().optional(),current:oCA.optional(),frequency:P5.optional(),peak_to_peak_current:oCA.optional(),wave_shape:FVA.optional(),phase:Gd.optional(),duty_cycle:Xlt.optional()}).describe("Defines an AC current source for simulation"),eCt=ei([$lt,ACt]).describe("Defines a current source for simulation"),tCt=ei([GA("spice_dc_sweep"),GA("spice_dc_operating_point"),GA("spice_transient_analysis"),GA("spice_ac_analysis")]),iCt=OA({type:GA("simulation_experiment"),simulation_experiment_id:Vt("simulation_experiment"),name:Y(),experiment_type:tCt,time_per_step:nCA.optional(),start_time_ms:g_.optional(),end_time_ms:g_.optional()}).describe("Defines a simulation experiment configuration"),oCt=OA({type:GA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Vt("simulation_transient_voltage_graph"),simulation_experiment_id:Y(),timestamps_ms:be(WA()).optional(),voltage_levels:be(WA()),source_component_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),time_per_step:nCA,start_time_ms:g_,end_time_ms:g_,name:Y().optional(),color:Y().optional()}).describe("Stores voltage measurements over time for a simulation"),nCt=OA({type:GA("simulation_switch"),simulation_switch_id:Vt("simulation_switch"),source_component_id:Y().optional(),closes_at:g_.optional(),opens_at:g_.optional(),starts_closed:ce().optional(),switching_frequency:P5.optional()}).describe("Defines a switch for simulation timing control"),sCt=OA({type:GA("simulation_voltage_probe"),simulation_voltage_probe_id:Vt("simulation_voltage_probe"),source_component_id:Y().optional(),name:Y().optional(),signal_input_source_port_id:Y().optional(),signal_input_source_net_id:Y().optional(),reference_input_source_port_id:Y().optional(),reference_input_source_net_id:Y().optional(),subcircuit_id:Y().optional(),color:Y().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,o=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&o?A.addIssue({code:Ot.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:Ot.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):o&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:Ot.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:Ot.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),rCt=OA({type:GA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Vt("simulation_unknown_experiment_error"),error_type:GA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:Y(),simulation_experiment_id:Y().optional(),subcircuit_id:Y().optional()}).describe("An unknown error occurred during the simulation experiment."),aCt=OA({type:GA("simulation_op_amp"),simulation_op_amp_id:Vt("simulation_op_amp"),source_component_id:Y().optional(),inverting_input_source_port_id:Y(),non_inverting_input_source_port_id:Y(),output_source_port_id:Y(),positive_supply_source_port_id:Y(),negative_supply_source_port_id:Y()}).describe("Defines a simple ideal operational amplifier for simulation");ei([Rct,Gct,Fct,kct,Nct,Mct,sVA,iVA,rCA,nVA,oVA,rVA,aVA,gVA,BVA,lVA,CVA,dVA,QVA,EVA,hVA,uVA,cVA,IVA,vct,Lct,_ct,pVA,fVA,yVA,Hct,Yct,dBt,pBt,blt,xlt,klt,Rlt,bBt,flt,xBt,zBt,TBt,OBt,XBt,_Bt,JBt,$Bt,Alt,Glt,tlt,ilt,olt,nlt,Ilt,slt,rlt,alt,glt,WBt,ZBt,elt,VBt,jBt,Klt,Blt,clt,llt,Clt,Qlt,Elt,hlt,ult,dlt,Flt,plt,Mlt,Slt,Nlt,_lt,vlt,Ylt,Jlt,Tlt,qlt,Plt,Olt,Jct,ABt,Zct,Vct,jct,zct,Wct,eBt,Xct,Tct,iBt,oBt,tBt,aBt,gBt,IBt,cBt,CBt,BBt,lBt,Wlt,zlt,eCt,iCt,oCt,nCt,sCt,rCt,aCt]);var gCt=Object.defineProperty,ICt=(t,A)=>{for(var e in A)gCt(t,e,{get:A[e],enumerable:!0})},DS={};ICt(DS,{axial:()=>MQt,bga:()=>TCt,breakoutheaders:()=>OQt,cap:()=>hCt,dfn:()=>CQt,diode:()=>ECt,dip:()=>lCt,electrolytic:()=>kut,hc49:()=>ZQt,jst:()=>zht,led:()=>uCt,lqfp:()=>qQt,m2host:()=>jut,melf:()=>sht,micromelf:()=>Iht,minimelf:()=>XEt,mlp:()=>zCt,ms012:()=>fQt,ms013:()=>wQt,msop:()=>rut,pad:()=>VQt,pinrow:()=>hQt,platedhole:()=>Jut,potentiometer:()=>Sut,pushbutton:()=>LQt,qfn:()=>ZCt,qfp:()=>jCt,quad:()=>c_,radial:()=>vQt,res:()=>HCt,sma:()=>Cht,smb:()=>yht,smbf:()=>Fut,smc:()=>Sht,smf:()=>uht,smtpad:()=>Hut,sod110:()=>$ht,sod123:()=>kQt,sod123f:()=>GEt,sod123fl:()=>NEt,sod123w:()=>IEt,sod128:()=>TEt,sod323:()=>CEt,sod323f:()=>SEt,sod323fl:()=>lut,sod323w:()=>gut,sod523:()=>AEt,sod723:()=>LEt,sod80:()=>sEt,sod882:()=>yEt,sod882d:()=>tht,sod923:()=>uEt,soic:()=>qCt,solderjumper:()=>uut,son:()=>hut,sop8:()=>oEt,sot:()=>Kut,sot223:()=>Ght,sot23:()=>rQt,sot23w:()=>Hht,sot25:()=>cQt,sot323:()=>_ut,sot343:()=>Out,sot363:()=>iQt,sot457:()=>fut,sot563:()=>dQt,sot723:()=>DQt,sot886:()=>nQt,sot89:()=>ZEt,sot963:()=>wut,ssop:()=>$Ct,stampboard:()=>YQt,stampreceiver:()=>KQt,to220:()=>jEt,to92:()=>XQt,to92l:()=>Xut,to92s:()=>Pht,tqfp:()=>VCt,tssop:()=>eQt,vssop:()=>out});var Yi=(t,A,e)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:e,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:A},anchor_alignment:"center"}),Ji=OA({norefdes:ce().optional().describe("disable reference designator label"),invert:ce().optional().describe("hint to invert the orientation of the 3D model"),faceup:ce().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:ce().optional().describe("omit all silkscreen elements from the footprint")}),Pn=(t,A,e,i,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:mr(i),outer_diameter:mr(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),SS=(t,A,e,i,o,n,s,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:A,y:e,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:[t.toString()],hole_offset_x:s,hole_offset_y:r}),RVA=Array.from({length:9},(t,A)=>Math.cos(A/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)}));function Ux(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var W5=ei([Y(),WA()]).transform(t=>Ux(t)),cCt=t=>Ji.extend({fn:Y(),num_pins:WA().optional().default(6),wide:ce().optional(),narrow:ce().optional(),w:W5.optional(),p:W5.default(t.p??"2.54mm"),id:W5.optional(),od:W5.optional(),nosquareplating:ce().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=Ux("0.55mm"),A.od=Ux("0.95mm")):(A.id=Ux("0.8mm"),A.od=Ux("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=Ux("600mil"):A.narrow?A.w=Ux("300mil"):A.w=Ux(t.w??"300mil")),A)),BCt=cCt({}),MVA=(t,A,e,i,o)=>{const n=t/2,s=A<=n,r=n-1,a=i,g=a*r;return s?{x:-e/2,y:g/2-(A-1)*a}:{x:e/2,y:-g/2+(A-n-1)*a}},lCt=t=>{const A=BCt.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:I,y:c}=MVA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating);if(g===0&&!A.nosquareplating){e.push(SS(g+1,I,c,A.id??"0.8mm",A.od??"1mm",A.od??"1mm"));continue}e.push(Pn(g+1,I,c,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},...RVA.map(({x:g,y:I})=>({x:g*o/6,y:I*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 I=g<A.num_pins/2,c=.6,{y:B}=MVA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating),l=I?-A.w/2-A.od/2-c:A.w/2+A.od/2+c,C=B;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:l,y:C},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Yi(0,n/2+.5,.4);return{circuitJson:[...e,s,a,...r],parameters:A}},Qi=(t,A,e,i,o)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:o,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),NVA=[{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}],CCt=Object.fromEntries(NVA.map(t=>[t.metric,t])),QCt=Object.fromEntries(NVA.map(t=>[t.imperial,t]));Ji.extend({tht:ce(),p:Ae.optional(),pw:Ae.optional(),ph:Ae.optional(),metric:mt.optional(),imperial:mt.optional(),w:Ae.optional(),h:Ae.optional(),textbottom:ce().optional()});var Z5=t=>{let{tht:A,p:e,pw:i,ph:o,metric:n,imperial:s,w:r,h:a,textbottom:g}=t;if(typeof r=="string"&&(r=mB(r)),typeof a=="string"&&(a=mB(a)),typeof e=="string"&&(e=mB(e)),typeof i=="string"&&(i=mB(i)),typeof o=="string"&&(o=mB(o)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let I;if(n&&(I=CCt[n]),s&&(I=QCt[s]),I&&(r=I.w_mm_min,a=I.h_mm_min,e=I.p_mm_min,i=I.pw_mm_min,o=I.ph_mm_min),e===void 0||i===void 0||o===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:e/2,y:o/2+.4},{x:-e/2-i/2-.2,y:o/2+.4},{x:-e/2-i/2-.2,y:-o/2-.4},{x:e/2,y:-o/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},B=g?-o/2-.9:o/2+.9,l=Yi(0,B,.2);return A?[Pn(1,-e/2,0,i,i*1/.8),Pn(2,e/2,0,i,i*1/.8),c,l]:[Qi(["1","left"],-e/2,0,i,o),Qi(["2","right"],e/2,0,i,o),c,l]},ECt=t=>({circuitJson:Z5(t),parameters:t}),hCt=t=>({circuitJson:Z5(t),parameters:t}),uCt=t=>({circuitJson:Z5(t),parameters:t}),I_=t=>{const{padSpacing:A,padWidth:e,padHeight:i,padPitch:o,numRows:n,textbottom:s}=t,r=[],a=(n-1)*(o/2);for(let x=0;x<n;x++)r.push(a-x*o);const g=[];r.forEach((x,F)=>{g.push(Qi(F+1,-A/2,x,e,i))}),r.slice().reverse().forEach((x,F)=>{g.push(Qi(F+n+1,A/2,x,e,i))});const I=Math.max(...r)+i/2+.4,c=Math.min(...r)-i/2-.4,B=-A/2-e/2-.4,l=A/2+e/2+.4,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l*.5,y:I},{x:B*.5,y:I}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l*.5,y:c},{x:B*.5,y:c}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},E=-A/2,h=Math.max(...r),u=.2,d=E-e/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},S=s?c-.9:I+.9,D=Yi(0,S,.2);return[...g,C,Q,m,D]},dCt=Ji.extend({pw:Y().default("0.5mm"),ph:Y().default("0.4mm"),p:Y().default("0.7mm"),textbottom:ce().optional()}),pCt=1,fCt=t=>{const A=dCt.parse(t),e=mB(A.pw),i=mB(A.ph),o=mB(A.p);return I_({padSpacing:pCt,padWidth:e,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},yCt=Ji.extend({pw:Y().default("0.5mm"),ph:Y().default("0.32mm"),p:Y().default("0.5mm"),textbottom:ce().optional()}),wCt=1,mCt=t=>{const A=yCt.parse(t),e=mB(A.pw),i=mB(A.ph),o=mB(A.p);return I_({padSpacing:wCt,padWidth:e,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},DCt=Ji.extend({pw:Y().default("0.9mm"),ph:Y().default("0.4mm"),p:Y().default("0.8mm"),textbottom:ce().optional()}),SCt=1.7,bCt=t=>{const A=DCt.parse(t),e=mB(A.pw),i=mB(A.ph),o=mB(A.p);return I_({padSpacing:SCt,padWidth:e,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},xCt=Ji.extend({pw:Y().default("0.9mm"),ph:Y().default("0.4mm"),p:Y().default("0.8mm"),textbottom:ce().optional()}),kCt=1.7,GCt=t=>{const A=xCt.parse(t),e=mB(A.pw),i=mB(A.ph),o=mB(A.p);return I_({padSpacing:kCt,padWidth:e,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},FCt=Ji.extend({pw:Y().default("0.7mm"),ph:Y().default("0.64mm"),p:Y().default("0.94mm"),textbottom:ce().optional()}),RCt=1.4,MCt=t=>{const A=FCt.parse(t),e=mB(A.pw),i=mB(A.ph),o=mB(A.p);return I_({padSpacing:RCt,padWidth:e,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},NCt=Ji.extend({pw:Y().default("0.9mm"),ph:Y().default("0.9mm"),p:Y().default("1.34mm"),textbottom:ce().optional()}),_Ct=3,vCt=t=>{const A=NCt.parse(t),e=mB(A.pw),i=mB(A.ph),o=mB(A.p);return I_({padSpacing:_Ct,padWidth:e,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},UCt=t=>{const A=t.array??t.x;if(typeof A=="number")return Number.isNaN(A)?void 0:A;if(typeof A=="string"){const e=Number.parseInt(A,10);return Number.isNaN(e)?void 0:e}if(typeof t.imperial=="string"){const i=t.imperial.match(/(?:array|x)(2|4)$/)?.[1];if(i)return Number.parseInt(i,10)}},LCt=t=>t?(typeof t=="number"?`${t}`:t).split("_")[0]:void 0,HCt=t=>{const A=UCt(t),e=LCt(t.imperial);return A===2&&e==="0402"?{circuitJson:fCt(t),parameters:t}:A===4&&e==="0402"?{circuitJson:mCt(t),parameters:t}:A===2&&e==="0603"?{circuitJson:bCt(t),parameters:t}:A===4&&e==="0603"?{circuitJson:GCt(t),parameters:t}:A===2&&e==="0606"?{circuitJson:MCt(t),parameters:t}:A===4&&e==="1206"?{circuitJson:vCt(t),parameters:t}:{circuitJson:Z5(t),parameters:t}},_VA=(t,{x:A,y:e,radius:i})=>({type:"pcb_smtpad",x:A,y:e,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),vVA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",UVA=Y().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A),y:parseFloat(e)}}).pipe(OA({x:WA(),y:WA()})),YCt=Y().or(be(YI())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(A=>{const e=Number(A);return isNaN(e)?A:e}))).pipe(be(Y().or(WA()))),JCt=Ji.extend({fn:Y(),num_pins:WA().optional().default(64),grid:UVA.optional(),p:mt.default("0.8mm"),w:Ae.optional(),h:Ae.optional(),ball:Ae.optional().describe("ball diameter"),pad:Ae.optional().describe("pad width/height"),circularpads:ce().optional().describe("use circular pads"),tlorigin:ce().optional(),blorigin:ce().optional(),trorigin:ce().optional(),brorigin:ce().optional(),missing:YCt.default([])}).transform(t=>{let A="tl";if(t.blorigin&&(A="bl"),t.trorigin&&(A="tr"),t.brorigin&&(A="br"),!t.grid){const i=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:i,y:i}}return t.missing&&(t.missing=t.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=vVA.indexOf(o[1]),s=Number.parseInt(o[2])-1;return n*t.grid.x+s+1})),{...t,origin:A}}),TCt=t=>{const A=JCt.parse(t);let{num_pins:e,grid:i,p:o,w:n,h:s,ball:r,pad:a,missing:g}=A;r??=.75/1.27*o,a??=r*.8;const I=[],c=(g??[]).filter(m=>typeof m=="number"),B=i.x*i.y-e;if(g.length===0&&B>0&&(Math.sqrt(B)%1===0?g.push("center"):B===1&&g.push("topleft")),g?.includes("center")){const m=Math.floor(Math.sqrt(B)),S=Math.floor((i.x-m)/2),D=Math.floor((i.y-m)/2);for(let x=D;x<D+m;x++)for(let F=S;F<S+m;F++)c.push(x*i.x+F+1)}g?.includes("topleft")&&c.push(1);const l=new Set(c);let C=0;for(let m=0;m<i.y;m++)for(let S=0;S<i.x;S++){const D=(S-(i.x-1)/2)*o,x=(m-(i.y-1)/2)*o;let F=S,k=m;switch(A.origin){case"bl":F=S,k=i.y-1-m;break;case"br":F=i.x-1-S,k=i.y-1-m;break;case"tr":F=i.x-1-S,k=m;break}let v=k*i.x+F+1;if(l.has(v)){C++;continue}v-=C;const _=[v,`${vVA[k]}${F+1}`];I.push(A.circularpads?_VA(_,{x:D,y:x,radius:a/2}):Qi(_,D,x,a,a))}const Q=Yi(0,i.y*o/2,.2),E=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-E},{x:-u-E,y:-d},{x:-u,y:-d}];break;case"br":h=[{x:u,y:-d},{x:u,y:-d-E},{x:u+E,y:-d},{x:u,y:-d}];break;case"tr":h=[{x:u,y:d},{x:u,y:d+E},{x:u+E,y:d},{x:u,y:d}];break;default:h=[{x:-u,y:d},{x:-u,y:d+E},{x:-u-E,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:[...I,Q,f],parameters:A}},V5=(t,A,e,i,o)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:o,radius:o/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),qm=t=>Ji.extend({fn:Y(),num_pins:WA().optional().default(8),w:Ae.default(Ae.parse(t.w??"5.3mm")),p:Ae.default(Ae.parse(t.p??"1.27mm")),pw:Ae.default(Ae.parse(t.pw??"0.6mm")),pl:Ae.default(Ae.parse(t.pl??"1.0mm")),legsoutside:ce().optional().default(t.legsoutside??!1),pillpads:ce().optional().default(t.pillpads??!1),silkscreen_stroke_width:WA().optional().default(.1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=Ae.parse("0.6mm"),A.pl=Ae.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),KCt=qm({}),ICA=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:A,pn:e,w:i,p:o,pl:n,legsoutside:s}=t,r=A/2,a=e<=r,g=r-1,I=o,c=I*g,B=s?n/2:-n/2;return a?{x:-i/2-B,y:c/2-(e-1)*I}:{x:i/2+B,y:-c/2+(e-r-1)*I}},qCt=t=>{const A=KCt.parse(t);return{circuitJson:Lx(A),parameters:A}},Lx=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=ICA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push(V5(r+1,a,g,t.pl,t.pw)):A.push(Qi(r+1,a,g,t.pl,t.pw))}const e=Math.min(1,t.p/2),i=t.w-(t.legsoutside?0:t.pl*2)-.2,o=(t.num_pins/2-1)*t.p+t.pw+e,n=Yi(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:t.silkscreen_stroke_width??.1,route:[{x:-i/2,y:-o/2},{x:-i/2,y:o/2},...RVA.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]},LVA=Bt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),PCt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const o=[],n=t/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<t;a++)o[s]=a+1,e||!A?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return o},cCA=Ji.extend({fn:Y(),cc:ce().default(!0).optional(),ccw:ce().default(!0).optional(),startingpin:Y().or(be(LVA)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(be(LVA)).optional(),num_pins:WA().optional().default(64),w:Ae.optional(),h:Ae.optional(),p:Ae.default(Ae.parse("0.5mm")),pw:Ae.optional(),pl:Ae.optional(),thermalpad:ei([GA(!0),UVA]).optional(),legsoutside:ce().default(!1)}),BCA=t=>{t.w&&!t.h?t.h=t.w:!t.w&&t.h&&(t.w=t.h);const A=t.num_pins/4;if(!t.p&&!t.pw&&!t.pl&&t.w){const e=A+4;t.p=t.w/e}return!t.p&&t.w&&t.h&&t.pw&&t.pl&&(t.p=(t.w-t.pl*2)/(A-1)),!t.w&&!t.h&&t.p&&(t.w=t.p*(A+4),t.h=t.w),t.p&&!t.pw&&!t.pl?(t.pw=t.p/2,t.pl=t.p/2):t.pw?t.pl||(t.pl=t.pw*(1/.6)):t.pw=t.pl*(.6/1),t},HVA=cCA.transform(BCA),OCt=["left","bottom","right","top"],WCt=t=>{const{pin_count:A,pn:e,w:i,h:o,p:n,pl:s,legsoutside:r}=t,a=A/4,g=OCt[Math.floor((e-1)/a)],I=(e-1)%a,c=n*(a-1),B=n*(a-1),l=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-l+.1,y:B/2-I*n,o:"vert"};case"bottom":return{x:-c/2+I*n,y:-o/2-l+.1,o:"horz"};case"right":return{x:i/2+l-.1,y:-B/2+I*n,o:"vert"};case"top":return{x:c/2-I*n,y:o/2+l-.1,o:"horz"};default:throw new Error("Invalid pin number")}},c_=t=>{const A=HVA.parse(t),e=[],i=PCt(A),o=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:I}=WCt({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 c=A.pw,B=A.pl;I==="vert"&&([c,B]=[B,c]);const l=i[r+1];e.push(Qi(l,a,g,c,B))}if(A.thermalpad)if(typeof A.thermalpad=="boolean"){const r=A.p*(o-1)+A.pw,a=A.p*(o-1)+A.pw;e.push(Qi(["thermalpad"],0,0,r,a))}else e.push(Qi(["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 I=A.w/2*a,c=A.h/2*g;let B="none",l=I,C=c;const Q=A.pw*2;i[1]===1&&r==="top-left"?B="in1":i[o*4]===1&&r==="top-left"||i[o*3+1]===1&&r==="top-right"?B="in2":i[o*3]===1&&r==="top-right"||i[o]===1&&r==="bottom-left"?B="in1":i[o+1]===1&&r==="bottom-left"?B="in2":i[o*2]===1&&r==="bottom-right"?B="in1":i[o*2+1]===1&&r==="bottom-right"&&(B="in2");const E=B==="in1"?1:-1;if(A.legsoutside){const h=B==="in1"?A.pl/2:A.pw/2,u=B==="in1"?A.pw/2:A.pl/2;l+=h*a*E,C-=u*g*E}(B==="none"||A.legsoutside)&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:I-Q*a,y:c},{x:I,y:c},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&!A.legsoutside&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:I-Q*a,y:c},{x:I-Q*a/2,y:c}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:I,y:c-Q*g/2},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:l-.2*-a,y:C+.2*E},{x:l,y:C},{x:l+.2*E*-a,y:C+.2},{x:l-.2*-a,y:C+.2*E}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Yi(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...n,s],parameters:A}};cCA.extend({}).transform(BCA);var ZCt=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),c_(t)),VCt=t=>{if(t.legsoutside=!0,!t.p)switch(t.num_pins){case 32:t.p=.8;break;case 44:case 48:t.p=.5;break;case 64:case 80:case 100:t.p=.5;break;case 144:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 32:case 44:case 48:case 64:case 80:case 100:t.pl=1.475;break;case 144:t.pl=1.6;break}if(!t.pw)switch(t.num_pins){case 32:t.pw=.55;break;case 44:case 48:case 64:case 80:case 100:t.pw=.3;break;case 144:t.pw=.25;break}return c_(t)},jCt=t=>{t.legsoutside=!0;const A=HVA.parse(t);if(!t.p)switch(t.num_pins){case 44:case 64:t.p=.8;break;case 52:t.w===14?t.p=1:t.p=.65;break;case 208:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 44:case 52:case 64:t.pl=2.25;break;case 208:t.pl=1.65;break;default:t.pl=A.pl*4;break}if(!t.pw)switch(t.num_pins){case 44:case 64:t.pw=.5;break;case 52:t.w===14?t.pw=.45:t.pw=.55;break;case 208:t.pw=.3;break;default:t.pw=A.pw;break}return c_(t)};cCA.extend({}).transform(BCA);var zCt=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),c_(t)),XCt=qm({w:"3.9mm",p:"1.27mm"}),$Ct=t=>{const A=XCt.parse(t);return{circuitJson:Lx(A),parameters:A}},AQt=qm({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),eQt=t=>{const A=AQt.parse(t);return{circuitJson:Lx(A),parameters:A}},tQt=qm({}),iQt=t=>{const A=tQt.parse({fn:"sot363",num_pins:6,w:2.56,p:.65,pw:.4,pl:.65,legoutside:!0});return{circuitJson:Lx(A),parameters:A}},oQt=Ji.extend({fn:Y(),num_pins:GA(6).default(6),w:Y().default("1.01mm"),h:Y().default("1.45mm"),p:Y().default("0.5mm"),pl:Y().default("0.33mm"),pw:Y().default("0.27mm"),string:Y().optional()}),nQt=t=>{const A=oQt.parse({fn:"sot886",...t}),e=Ae.parse(A.w),i=Ae.parse(A.h),o=Ae.parse(A.p),n=Ae.parse(A.pl),s=Ae.parse(A.pw),r=[];for(let l=0;l<6;l++){const{x:C,y:Q}=YVA(l+1,e,o,n);r.push(Qi(l+1,C,Q,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=YVA(1,e,o,n),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-n/2-.3,y:I.y},{x:I.x-n/2-.45,y:I.y+.15},{x:I.x-n/2-.45,y:I.y-.15},{x:I.x-n/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},B=Yi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,B,c],parameters:A}},YVA=(t,A,e,i)=>{const o=A/2-i/2;return t<=3?{x:-o,y:e-(t-1)*e}:{x:o,y:-e+(t-4)*e}},JVA=Ji.extend({fn:Y(),num_pins:WA().default(3),w:Y().default("1.92mm"),h:Y().default("2.74mm"),pl:Y().default("1.32mm"),pw:Y().default("0.6mm"),p:Y().default("0.95mm"),string:Y().optional()}),sQt=qm({p:"0.95mm",w:"1.6mm",legsoutside:!0}),rQt=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const o=sQt.parse({...t,num_pins:e});return{circuitJson:Lx(o),parameters:o}}const i=JVA.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:gQt(i),parameters:i};if(i.num_pins===5)return{circuitJson:KVA(i),parameters:i};throw new Error("Invalid number of pins")},aQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-1.155,y:e}:A===2?{x:-1.155,y:-e}:{x:1.15,y:0}},gQt=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:o,y:n}=aQt({num_pins:t.num_pins,pn:i+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(i+1,o,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Yi(0,Number.parseInt(t.h),.3);return[...A,e]},TVA=t=>{const{p:A,h:e,pn:i}=t;if(i===1)return{x:-e/2-.5,y:A};if(i===2)return{x:-e/2-.5,y:0};if(i===3)return{x:-e/2-.5,y:-A};if(i===4)return{x:e/2+.5,y:-A};if(i===5)return{x:e/2+.5,y:A};throw new Error("Invalid pin number")},KVA=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:l}=TVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(Qi(c,B,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.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:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Yi(0,i+.3,.3),r=TVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.3,g=.4,I={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,I]},IQt=JVA.extend({}),cQt=t=>{const A=IQt.parse({...t,num_pins:5});return{circuitJson:KVA(A),parameters:A}},BQt=[{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}],lQt=qm({}),CQt=t=>{const A=lQt.parse(t),e=[];for(let c=0;c<A.num_pins;c++){const{x:B,y:l}=ICA({num_pins:A.num_pins,pn:c+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(Qi(c+1,B,l,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 c of BQt){const{dx:B,dy:l}=c;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:B*o/2-B*A.p,y:l*n/2},{x:B*o/2,y:l*n/2},{x:B*o/2,y:l*n/2-l*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 I=Yi(0,n/2+.4,n/12);return{circuitJson:[...e,I,...s],parameters:A}},lCA=({fs:t,pn:A,anchor_x:e,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:t,pcb_component_id:"pcb_component_1",text:`{PIN${A}}`,layer:r,anchor_position:{x:e,y:i},anchor_alignment:g,ccw_rotation:a}};function QQt({pinlabeltextalignleft:t,pinlabeltextalignright:A,pinlabelorthogonal:e}){let i="top";return e?i="left":i="top",t&&(e?i="bottom":i="right"),A&&(e?i="top":i="left"),i}var EQt=Ji.extend({fn:Y(),num_pins:WA().optional().default(6),rows:ei([Y(),WA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:Ae.default("0.1in").describe("pitch"),id:Ae.default("1.0mm").describe("inner diameter"),od:Ae.default("1.5mm").describe("outer diameter"),male:ce().optional().describe("for male pin headers"),female:ce().optional().describe("for female pin headers"),smd:ce().optional().describe("surface mount device"),surfacemount:ce().optional().describe("surface mount device (verbose)"),rightangle:ce().optional().describe("right angle"),pw:Ae.optional().default("1.0mm").describe("pad width for SMD"),pl:Ae.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:ce().optional().default(!1),pinlabeltextaligncenter:ce().optional().default(!1),pinlabeltextalignright:ce().optional().default(!1),pinlabelverticallyinverted:ce().optional().default(!1),pinlabelorthogonal:ce().optional().default(!1),nosquareplating:ce().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:ce().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:ce().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:ce().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=QQt(t);return{...t,pinlabelAnchorSide:A,male:t.male??!t.female,female:t.female??!1,smd:t.smd??t.surfacemount??!1,rightangle:t.rightangle??!1}}).superRefine((t,A)=>{t.male&&t.female&&A.addIssue({code:Ot.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),hQt=t=>{const A=EQt.parse(t),{p:e,id:i,od:o,rows:n,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:I,pinlabeltextalignright:c,nopinlabels:B,doublesidedpinlabel:l,bottomsidepinlabel:C}=A;let Q="center";I?Q="left":c&&(Q="right");const E=[],h=Math.ceil(s/n),u=-e,d=({xoff:x,yoff:F,od:k,anchorSide:v,smd:_,pw:H,pl:P})=>{let J=0,W=0;if(_){const Z=k/5;switch(v){case"right":J=H/2+Z;break;case"top":W=P/2+Z;break;case"bottom":W=-(P/2+Z);break;case"left":J=-(H/2+Z);break}}else{const Z=k*.75;switch(v){case"right":J=Z;break;case"top":W=Z;break;case"bottom":W=-Z;break;case"left":J=-Z;break}}return{anchor_x:x+J,anchor_y:F+W}},f=(x,F,k)=>{A.smd?E.push(Qi(x,F,k,A.pw,A.pl)):x===1&&!A.nosquareplating?E.push(SS(x,F,k,i,o,o,0,0)):E.push(Pn(x,F,k,i,o));const{anchor_x:v,anchor_y:_}=d({xoff:F,yoff:k,od:o,anchorSide:r,smd:A.smd,pw:A.pw,pl:A.pl});B||(C?E.push(lCA({fs:o/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):E.push(lCA({fs:o/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),l&&E.push(lCA({fs:o/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},m=new Set,S=n>2&&h>2;if(n===1){const x=-((s-1)/2)*e;for(let F=0;F<s;F++){const k=F+1,v=x+F*e,_=`${v},0`;if(m.has(_))throw new Error(`Overlap at ${_}`);m.add(_),f(k,v,0)}}else if(S){const x=-((h-1)/2)*e;let F=1;for(let k=0;k<n&&F<=s;k++)for(let v=0;v<h&&F<=s;v++){const _=x+v*e,H=k*u,P=`${_},${H}`;if(m.has(P))throw new Error(`Overlap at ${P}`);m.add(P),f(F++,_,H)}}else{const x=-((h-1)/2)*e;let F=1,k=0,v=n-1,_=0,H=h-1;for(;F<=s&&k<=v&&_<=H;){for(let P=k;P<=v&&F<=s;P++){const J=x+_*e,W=P*u,Z=`${J},${W}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(F++,J,W)}_++;for(let P=_;P<=H&&F<=s;P++){const J=x+P*e,W=v*u,Z=`${J},${W}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(F++,J,W)}if(v--,_<=H){for(let P=v;P>=k&&F<=s;P--){const J=x+H*e,W=P*u,Z=`${J},${W}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(F++,J,W)}H--}if(k<=v){for(let P=H;P>=_&&F<=s;P--){const J=x+P*e,W=k*u,Z=`${J},${W}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(F++,J,W)}k++}}if(F-1<s)throw new Error(`Missing pins: assigned ${F-1}, expected ${s}`)}const D=Yi(0,e,.5);return{circuitJson:[...E,D],parameters:A}},uQt=Ji.extend({fn:Y(),num_pins:GA(6).default(6),w:Y().default("2.1mm"),h:Y().default("2.45mm"),p:Y().default("0.5mm"),pl:Y().default("0.675mm"),pw:Y().default("0.35mm"),string:Y().optional()}),dQt=t=>{const A=uQt.parse({...t,fn:"sot563"}),e=Ae.parse(A.w),i=Ae.parse(A.h),o=Ae.parse(A.p),n=Ae.parse(A.pl),s=Ae.parse(A.pw),r=[];for(let l=0;l<6;l++){const{x:C,y:Q}=qVA(l+1,e,o,n);r.push(Qi(l+1,C,Q,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=qVA(1,e,o,n),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-n/2-.3,y:I.y},{x:I.x-n/2-.45,y:I.y+.15},{x:I.x-n/2-.45,y:I.y-.15},{x:I.x-n/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},B=Yi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,B,c],parameters:A}},qVA=(t,A,e,i)=>{const o=A/2-i/2;return t<=3?{x:-o,y:e-(t-1)*e}:{x:o,y:-e+(t-4)*e}},pQt=qm({p:"1.27mm",w:"3.9mm",legsoutside:!0}),fQt=t=>{const A=pQt.parse({...t,num_pins:8});return{circuitJson:Lx(A),parameters:A}},yQt=qm({p:"1.27mm",w:"7.5mm",legsoutside:!0}),wQt=t=>{const A=yQt.parse({...t,num_pins:16});return{circuitJson:Lx(A),parameters:A}},mQt=Ji.extend({fn:Y(),num_pins:GA(3).default(3),w:Y().default("1.2mm"),h:Y().default("1.2mm"),pw:Y().default("0.40mm"),pl:Y().default("0.45mm"),p:Y().default("0.575mm")}),DQt=t=>{const A=mQt.parse(t),e=bQt(A),i=Yi(0,Ae.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},SQt=t=>{const{pn:A,p:e}=t;return A===1?{x:e,y:0}:A===2?{x:-e,y:-.4}:{x:-e,y:.4}},bQt=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:o}=SQt({num_pins:t.num_pins,pn:e+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(e+1,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},xQt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("2.36mm"),h:Y().default("1.22mm"),pl:Y().default("0.9mm"),pw:Y().default("1.2mm"),p:Y().default("3.30mm")}),kQt=t=>{const A=xQt.parse(t),e=Yi(0,Ae.parse(A.h)/4+.4,.3);return{circuitJson:FQt(A).concat(e),parameters:A}},GQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},FQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=GQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},RQt=Ji.extend({fn:Y(),p:Ae.optional().default("2.54mm"),id:Ae.optional().default("0.7mm"),od:Ae.optional().default("1.4mm")}),MQt=t=>{const A=RQt.parse(t),{p:e,id:i,od:o}=A,n=[Pn(1,-e/2,0,i,o),Pn(2,e/2,0,i,o)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2+o+i/2,y:0},{x:e/2-o-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},r=Yi(0,1.5,.5);return{circuitJson:[...n,s,r],parameters:A}},NQt=(t,A,e,i,o,n=.1)=>{const s=[],r=[],a=Math.max(1,Math.ceil(Math.PI*e/n)),g=Math.PI/a;for(let I=0;I<=a;I++){const c=I*g,B=t+Math.cos(c)*e,l=A+Math.sin(c)*e;B<t-i&&l>=A-o/2&&l<=A+o/2||s.push({x:B,y:l})}for(let I=0;I<=a;I++){const c=Math.PI+I*g,B=t+Math.cos(c)*e,l=A+Math.sin(c)*e;B<t-i&&l>=A-o/2&&l<=A+o/2||r.push({x:B,y:l})}return{topArc:s,bottomArc:r}},_Qt=Ji.extend({fn:Y(),p:Ae.optional().default("5mm"),id:Ae.optional().default("0.8mm"),od:Ae.optional().default("1.6mm"),ceramic:ce().optional(),electrolytic:ce().optional(),polarized:ce().optional()}),vQt=t=>{const A=_Qt.parse(t),{p:e,id:i,od:o}=A;i===.8&&o===1.6&&(A.id=e===5?.8:e*.25,A.od=e===5?1.6:e*.5);const n=[Pn(1,-e/2,0,A.id,A.od),Pn(2,e/2,0,A.id,A.od)],s=e+.1,{topArc:r,bottomArc:a}=NQt(0,0,s,A.od/2,A.od),g=.02*e,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:g,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:g,pcb_silkscreen_path_id:""},B={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:""},l=.1*e,C=-(e+l+.04*e),Q=s-l-.08*e,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C-l,y:Q},{x:C+l,y:Q}],stroke_width:g,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C,y:Q-l},{x:C,y:Q+l}],stroke_width:g,pcb_silkscreen_path_id:""},u=Yi(0,s+.12*e,.1*e),d=[...n,I,c,B,u];return(A.electrolytic===!0||A.polarized===!0)&&d.push(E,h),{circuitJson:d,parameters:A}},j5=(t,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:t,stroke_width:A.stroke_width||.1}),UQt=Ji.extend({fn:GA("pushbutton"),w:Ae.default(4.5),h:Ae.default(6.5),id:Ae.default(1),od:Ae.default(1.2)}),LQt=t=>{const A=UQt.parse(t),e=A.w,i=A.h,o=A.id,n=[Pn(1,-e/2,i/2,o,o*1.5),Pn(2,-e/2,-i/2,o,o*1.5),Pn(3,e/2,-i/2,o,o*1.5),Pn(4,e/2,i/2,o,o*1.5)],s=[j5([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),j5([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),j5([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),j5([{x:e/2,y:0},{x:e/5,y:0}])],r=Yi(0,i/2+.4,.5);return{circuitJson:[...n,...s,r],parameters:A}},PVA=Ji.extend({fn:Y(),w:Ae.default("22.58mm"),h:Ae.optional(),left:Ae.optional().default(20),right:Ae.optional().default(20),top:Ae.optional().default(2),bottom:Ae.optional().default(2),p:Ae.default(Ae.parse("2.54mm")),pw:Ae.default(Ae.parse("1.6mm")),pl:Ae.default(Ae.parse("2.4mm")),innerhole:ce().default(!1),innerholeedgedistance:Ae.default(Ae.parse("1.61mm")),silkscreenlabels:ce().default(!1),silkscreenlabelmargin:Ae.default(Ae.parse("0.1mm"))}),HQt=t=>{const A=PVA.parse(t);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},z5=(t,A,e)=>{let i=[];return e==="right"&&(i=[{x:t+1/2,y:A},{x:t-1/2,y:A+.6/2},{x:t-1/2,y:A-.6/2},{x:t+1/2,y:A}]),e==="left"&&(i=[{x:t-1/2,y:A},{x:t+1/2,y:A+.6/2},{x:t+1/2,y:A-.6/2},{x:t-1/2,y:A}]),e==="top"&&(i=[{x:t,y:A+1/2},{x:t-.6/2,y:A-1/2},{x:t+.6/2,y:A-1/2},{x:t,y:A+1/2}]),e==="bottom"&&(i=[{x:t,y:A-1/2},{x:t-.6/2,y:A+1/2},{x:t+.6/2,y:A+1/2},{x:t,y:A-1/2}]),i},YQt=t=>{const A=PVA.parse(t),e=A.h??HQt(A),i=[],o=[],n=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),c=`pin${g}`.length*.7/2;if(A.right){const Q=-((A.right-1)/2)*A.p;for(let E=0;E<A.right;E++){if(E===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=z5(A.w/2-A.pl*1.4,Q+E*A.p,"right")),i.push(Qi(E+1+A.left+(A.bottom??0),A.w/2-A.pl/2,Q+E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+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-(c+A.silkscreenlabelmargin),y:Q+E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push(Pn(E+1+A.left+(A.bottom??0)+g,A.w/2,Q+E*A.p,r,a)),o.push(Pn(E+1+A.left+(A.bottom??0)+g*2,A.w/2-A.innerholeedgedistance,Q+E*A.p,r,a)))}}if(A.left){const Q=(A.left-1)/2*A.p;for(let E=0;E<A.left;E++){if(E===0&&!A.silkscreenlabels&&(s=z5(-A.w/2+A.pl*1.4,Q-E*A.p,"left")),i.push(Qi(E+1,-A.w/2+A.pl/2,Q-E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+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+(c+A.silkscreenlabelmargin),y:Q-E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push(Pn(E+1+g,-A.w/2,Q-E*A.p,r,a)),o.push(Pn(E+1+g*2,-A.w/2+A.innerholeedgedistance,Q-E*A.p,r,a)))}}if(A.top){const Q=(A.top-1)/2*A.p;for(let E=0;E<A.top;E++){if(E===0&&!A.left&&!A.bottom&&!A.right&&!A.silkscreenlabels&&(s=z5(Q-E*A.p,e/2-A.pl*1.4,"top")),i.push(Qi(E+1+A.left+A.right+(A.bottom??0),Q-E*A.p,e/2-A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+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:Q-E*A.p,y:e/2-A.pl-(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(o.push(Pn(E+1+A.left+A.right+(A.bottom??0)+g,Q-E*A.p,e/2,r,a)),o.push(Pn(E+1+A.left+A.right+(A.bottom??0)+g*2,Q-E*A.p,e/2-A.innerholeedgedistance,r,a)))}}if(A.bottom){const Q=-((A.bottom-1)/2)*A.p;for(let E=0;E<A.bottom;E++){if(E===0&&!A.left&&!A.silkscreenlabels&&(s=z5(Q+E*A.p,-e/2+A.pl*1.4,"bottom")),i.push(Qi(E+1+A.left,Q+E*A.p,-e/2+A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+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:Q+E*A.p,y:-e/2+A.pl+(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(o.push(Pn(E+1+A.left+g,Q+E*A.p,-e/2,r,a)),o.push(Pn(E+1+A.left+g*2,Q+E*A.p,-e/2+A.innerholeedgedistance,r,a)))}}const B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2,y:e/2},{x:A.w/2,y:e/2},{x:A.w/2,y:-e/2},{x:-A.w/2,y:-e/2},{x:-A.w/2,y:e/2}],stroke_width:.1,layer:"top"},C=Yi(0,e/1.8,e/25);return{circuitJson:[...i,...o,...n,l,...A.silkscreenlabels?[]:[B],C],parameters:A}},OVA=Ji.extend({fn:Y(),w:Ae.default("22.58mm"),h:Ae.optional(),left:Ae.optional().default(20),right:Ae.optional().default(20),top:Ae.optional().default(2),bottom:Ae.optional().default(2),p:Ae.default(Ae.parse("2.54mm")),pw:Ae.default(Ae.parse("1.6mm")),pl:Ae.default(Ae.parse("3.2mm")),innerhole:ce().default(!1),innerholeedgedistance:Ae.default(Ae.parse("1.61mm"))}),JQt=t=>{const A=OVA.parse(t);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},TQt=(t,A,e,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:t+n,y:A},{x:t-n,y:A+s},{x:t-n,y:A-s},{x:t+n,y:A}],right:[{x:t-n,y:A},{x:t+n,y:A+s},{x:t+n,y:A-s},{x:t-n,y:A}],top:[{x:t,y:A-n},{x:t-s,y:A+n},{x:t+s,y:A+n},{x:t,y:A-n}],bottom:[{x:t,y:A+n},{x:t-s,y:A-n},{x:t+s,y:A-n},{x:t,y:A+n}]}[e]},KQt=t=>{const A=OVA.parse(t),e=A.h??JQt(A),i=[],o=[],n=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],I=1;if(A.left){const C=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++)Q===0&&(g=TQt(-A.w/2-A.pl/2,C-Q*A.p,"left")),i.push(Qi(I,-A.w/2+A.pl/2,C-Q*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:C-Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,-A.w/2+A.innerholeedgedistance,C-Q*A.p,s,r))}if(A.bottom){const C=(A.bottom-1)/2*A.p;for(let Q=A.bottom-1;Q>=0;Q--)i.push(Qi(I,C-Q*A.p,-e/2+A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C-Q*A.p,y:-e/2+A.pl/2-3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,C-Q*A.p,-e/2+A.innerholeedgedistance,s,r))}if(A.right){const C=-((A.right-1)/2)*A.p;for(let Q=0;Q<A.right;Q++)i.push(Qi(I,A.w/2-A.pl/2,C+Q*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:C+Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,A.w/2-A.innerholeedgedistance,C+Q*A.p,s,r))}if(A.top){const C=-((A.top-1)/2)*A.p;for(let Q=A.top-1;Q>=0;Q--)i.push(Qi(I,C+Q*A.p,e/2-A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C+Q*A.p,y:e/2-A.pl/2+3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,C+Q*A.p,e/2-A.innerholeedgedistance,s,r))}const c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:g,stroke_width:.1},B={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:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:e/2+A.pl/3}],stroke_width:.1,layer:"top"},l=Yi(0,e/1.8,e/25);return{circuitJson:[...n,...i,...o,B,c,l],parameters:A}},qQt=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),c_(t)),WVA=Ji.extend({fn:Y(),w:Ae.default("10mm"),h:Ae.optional(),left:Ae.optional().default(20),right:Ae.optional().default(20),top:Ae.optional().default(0),bottom:Ae.optional().default(0),p:Ae.default(Ae.parse("2.54mm")),id:Ae.optional().default(Ae.parse("1mm")),od:Ae.optional().default(Ae.parse("1.5mm"))}),PQt=t=>{const A=WVA.parse(t);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},X5=(t,A,e,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:t+n,y:A},{x:t-n,y:A+s},{x:t-n,y:A-s},{x:t+n,y:A}],right:[{x:t-n,y:A},{x:t+n,y:A+s},{x:t+n,y:A-s},{x:t-n,y:A}],top:[{x:t,y:A-n},{x:t-s,y:A+n},{x:t+s,y:A+n},{x:t,y:A-n}],bottom:[{x:t,y:A+n},{x:t-s,y:A-n},{x:t+s,y:A-n},{x:t,y:A+n}]}[e]},OQt=t=>{const A=WVA.parse(t),e=A.h??PQt(A),i=[],o=A.id,n=A.od;let s=[];if(A.right){const I=-((A.right-1)/2)*A.p;for(let c=0;c<A.right;c++)c===0&&!A.left&&!A.bottom&&(s=X5(A.w/2+n*1.4,I+c*A.p,"right")),i.push(Pn(c+1+A.left+(A.bottom??0),A.w/2,I+c*A.p,o,n))}if(A.left){const I=-((A.left-1)/2)*A.p;for(let c=0;c<A.left;c++)c===A.left-1&&(s=X5(-A.w/2-n*1.4,I+c*A.p,"left")),i.push(Pn(c+1,-A.w/2,I+c*A.p,o,n))}if(A.top){const I=-((A.top-1)/2)*A.p;for(let c=0;c<A.top;c++)c===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=X5(I+c*A.p,e/2+n*1.4,"top")),i.push(Pn(c+1+A.right+(A.bottom??0)+A.left,I+c*A.p,e/2,o,n))}if(A.bottom){const I=-((A.bottom-1)/2)*A.p;for(let c=0;c<A.bottom;c++)c===0&&!A.left&&(s=X5(I+c*A.p,-e/2-n*1.4,"bottom")),i.push(Pn(c+1+A.left,I+c*A.p,-e/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:e/2+n},{x:A.w/2+n,y:e/2+n},{x:A.w/2+n,y:-e/2-n},{x:-A.w/2-n,y:-e/2-n},{x:-A.w/2-n,y:e/2+n}],stroke_width:.1,layer:"top"},g=Yi(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},ZVA=(t,A,e,i)=>Array.from({length:25},(o,n)=>{const s=n/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*e,y:A+Math.sin(s)*e}}),WQt=Ji.extend({fn:Y(),p:Ae.optional().default("4.88mm"),id:Ae.optional().default("0.8mm"),od:Ae.optional().default("1.5mm"),w:Ae.optional().default("5.6mm"),h:Ae.optional().default("3.5mm")}),ZQt=t=>{const A=WQt.parse(t),{p:e,id:i,od:o,w:n,h:s}=A,r=s/2,a=[Pn(1,-e/2,0,i,o),Pn(2,e/2,0,i,o)],g=ZVA(-n/2,0,r,"left"),I=ZVA(n/2,0,r,"right"),c={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},...I,{x:n/2,y:s/2},{x:-n/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},B=Yi(0,e/4,.5);return{circuitJson:[...a,c,B],parameters:A}};Ji.extend({w:Ae,h:Ae});var VQt=t=>{const{w:A,h:e}=t,i=mr(A),o=mr(e);return{circuitJson:[Qi(1,0,0,i,o),Yi(0,o/2+.5,.2)],parameters:t}},yL=(t,A,e,i,o,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:A,y:e,outer_width:mr(o),outer_height:mr(n),hole_width:mr(i),hole_height:mr(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),jQt=Ji.extend({fn:Y(),num_pins:ei([GA(3),GA(2)]).default(3),p:Y().default("1.27mm"),id:Y().default("0.72mm"),od:Y().default("0.95mm"),w:Y().default("4.5mm"),h:Y().default("4.5mm"),inline:ce().default(!1),string:Y().optional()}),zQt=(t,A,e)=>Array.from({length:25},(i,o)=>{const n=o/24*Math.PI;return{x:t+Math.cos(n)*e,y:A+Math.sin(n)*e}}),XQt=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=jQt.parse({...t,num_pins:e}),{p:o,id:n,od:s,w:r,h:a,inline:g}=i,I=Number.parseFloat(a)/2,c=Number.parseFloat(o),B=Number.parseFloat(n),l=Number.parseFloat(s),C=l,Q=l*(1.5/1.05);let E=[];if(i.num_pins===3)g?E=[SS(1,-c,I-c,B,l,Q,0,0),yL(2,0,I-c,B,C,Q),yL(3,c,I-c,B,C,Q)]:E=[SS(1,-c,I-c,B,l,l,0,0),Pn(2,0,I,B,l),Pn(3,c,I-c,B,l)];else if(i.num_pins===2)E=[SS(1,-c,I-c,B,C,Q,0,0),yL(2,c,I-c,B,C,Q)];else throw new Error("Invalid number of pins for TO-92");const h=Number.parseFloat(r)/2,u=zQt(0,I,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=Yi(0,I+1,.5);return{circuitJson:[...E,d,f],parameters:i}},$Qt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("2.15mm"),h:Y().default("1.20mm"),pl:Y().default("0.5mm"),pw:Y().default("0.6mm"),p:Y().default("1.4mm")}),AEt=t=>{const A=$Qt.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:tEt(A).concat(i,e),parameters:A}},eEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},tEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=eEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},iEt=qm({}),oEt=t=>{const A=iEt.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=ICA({num_pins:A.num_pins,pn:s+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(Qi(s+1,r,a,A.pl??"1.5mm",A.pw??"0.6mm"))}const i=(A.num_pins/2-1)*A.p+A.pw,o=Yi(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:[...e,o,n],parameters:A}},nEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("5.0mm"),h:Y().default("2.30mm"),pl:Y().default("1.25mm"),pw:Y().default("2mm"),p:Y().default("3.75mm")}),sEt=t=>{const A=nEt.parse(t),e=Yi(0,Ae.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2+.5,y:Ae.parse(A.h)/2+.5},{x:-Ae.parse(A.w)/2-.5,y:Ae.parse(A.h)/2+.5},{x:-Ae.parse(A.w)/2-.5,y:-Ae.parse(A.h)/2-.5},{x:Ae.parse(A.p)/2+.5,y:-Ae.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:aEt(A).concat(i,e),parameters:A}},rEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},aEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=rEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},gEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),p:Y().default("2.9mm")}),IEt=t=>{const A=gEt.parse(t),e=Yi(0,Ae.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:BEt(A).concat(i,e),parameters:A}},cEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},BEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=cEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},lEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("3.30mm"),h:Y().default("1.80mm"),pl:Y().default("0.60mm"),pw:Y().default("0.45mm"),p:Y().default("2.1mm")}),CEt=t=>{const A=lEt.parse(t),e=Yi(0,Ae.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:EEt(A).concat(i,e),parameters:A}},QEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},EEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=QEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},hEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("1.4mm"),h:Y().default("0.9mm"),pl:Y().default("0.36mm"),pw:Y().default("0.25mm"),p:Y().default("0.85mm")}),uEt=t=>{const A=hEt.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2+.15,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.15,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.15,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2+.15,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:pEt(A).concat(i,e),parameters:A}},dEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},pEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=dEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},fEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("1.3mm"),h:Y().default("0.9mm"),pl:Y().default("0.4mm"),pw:Y().default("0.7mm"),p:Y().default("0.7mm")}),yEt=t=>{const A=fEt.parse(t),e=Yi(0,Ae.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2+.2,y:Ae.parse(A.h)/2+.2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2+.2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2-.2},{x:Ae.parse(A.p)/2+.2,y:-Ae.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:mEt(A).concat(i,e),parameters:A}},wEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},mEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=wEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},DEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("3,05mm"),h:Y().default("1.65mm"),pl:Y().default("0.6mm"),pw:Y().default("0.6mm"),pad_spacing:Y().default("2.2mm")}),SEt=t=>{const A=DEt.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.pad_spacing)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.pad_spacing)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:xEt(A).concat(i,e),parameters:A}},bEt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},xEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=bEt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},kEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),p:Y().default("2.9mm")}),GEt=t=>{const A=kEt.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:REt(A).concat(i,e),parameters:A}},FEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},REt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=FEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},MEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("0.91mm"),pw:Y().default("1.22mm"),p:Y().default("3.146mm")}),NEt=t=>{const A=MEt.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:vEt(A).concat(i,e),parameters:A}},_Et=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},vEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=_Et({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},UEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("1.80mm"),h:Y().default("1.00mm"),pl:Y().default("0.66mm"),pw:Y().default("0.5mm"),p:Y().default("0.8mm")}),LEt=t=>{const A=UEt.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.1,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.1,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:YEt(A).concat(i,e),parameters:A}},HEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},YEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=HEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},JEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("6.2mm"),h:Y().default("3.4mm"),pl:Y().default("1.4mm"),pw:Y().default("2.1mm"),p:Y().default("4.4mm")}),TEt=t=>{const A=JEt.parse(t),e=Yi(0,Ae.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:qEt(A).concat(i,e),parameters:A}},KEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},qEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=KEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},PEt=Ji.extend({fn:Y(),num_pins:ei([GA(3),GA(5)]).default(3),w:Y().default("4.20mm"),h:Y().default("4.80mm"),pl:Y().default("1.3mm"),pw:Y().default("0.9mm"),p:Y().default("1.5mm"),string:Y().optional()}),OEt=t=>{const A=[],e=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),o=Number.parseFloat(t.w),n=Number.parseFloat(t.pl),s=.175,r=(n-(n+s))/2;A.push(Qi(1,-o/2+r,e,n,i),Qi(2,-o/2,0,n+s,i),Qi(3,-o/2+r,-e,n,i));const a=Yi(0,0,.3),g=Number.parseFloat(t.w)/2-1,I=Number.parseFloat(t.h)/2,c={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-g,y:I},{x:g,y:I},{x:g,y:I/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},B={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-g,y:-I},{x:g,y:-I},{x:g,y:-I/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,c,B,a]},WEt=t=>{const A=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),A.push(Qi(1,-1.85,-1.5,1.5,.7),Qi(2,-1.85,1.5,1.5,.7),Qi(3,0,0,.8,2),Qi(4,1.85,-1.5,1.5,.7),Qi(5,1.85,1.5,1.5,.7));const e=Yi(0,Number.parseFloat(t.h)/2+.5,.3),i=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.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,e]},ZEt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=PEt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:OEt(i),parameters:i};if(i.num_pins===5)return{circuitJson:WEt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},VEt=Ji.extend({fn:Y(),p:Ae.optional().default("5.0mm"),id:Ae.optional().default("1.0mm"),od:Ae.optional().default("1.9mm"),w:Ae.optional().default("13mm"),h:Ae.optional().default("7mm"),num_pins:WA().optional(),string:Y().optional()}),jEt=t=>{const A=VEt.parse(t),{fn:e,id:i,od:o,w:n,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,I=n/2,c=s/2,B=2.5,l=n*.4,C=Math.max(B,l/(a-1)),Q=Array.from({length:a},(m,S)=>{const D=a%2===0?(S-a/2+.5)*C:(S-Math.floor(a/2))*C;return Pn(S+1,D,g,i,o)}),E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:-c},{x:I,y:-c},{x:I,y:c},{x:-I,y:c},{x:-I,y:-c}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-c+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:h},{x:I,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:c}],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:c}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Yi(0,s/2+.6,.5);return{circuitJson:[...Q,E,u,...d,f],parameters:{...A,p:C}}},zEt=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("5.40mm"),h:Y().default("2.30mm"),pl:Y().default("1.30mm"),pw:Y().default("1.70mm"),p:Y().default("3.5mm")}),XEt=t=>{const A=zEt.parse(t),e=Yi(0,Ae.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Aht(A).concat(i,e),parameters:A}},$Et=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Aht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=$Et({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},eht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("1.90mm"),h:Y().default("1.33mm"),pl:Y().default("0.5mm"),pw:Y().default("0.7mm"),p:Y().default("0.8mm")}),tht=t=>{const A=eht.parse(t),e=Yi(0,Ae.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2+.1,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2+.1,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:oht(A).concat(i,e),parameters:A}},iht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},oht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=iht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},nht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("7.0mm"),h:Y().default("3.35mm"),pl:Y().default("1.50mm"),pw:Y().default("2.70mm"),p:Y().default("4.8mm")}),sht=t=>{const A=nht.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:aht(A).concat(i,e),parameters:A}},rht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},aht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=rht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ght=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("3.0mm"),h:Y().default("1.80mm"),pl:Y().default("0.80mm"),pw:Y().default("1.20mm"),p:Y().default("1.6mm")}),Iht=t=>{const A=ght.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.1,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.1,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Bht(A).concat(i,e),parameters:A}},cht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Bht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=cht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},lht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("7.10mm"),h:Y().default("3.40mm"),pl:Y().default("2.45mm"),pw:Y().default("1.80mm"),p:Y().default("4.05mm")}),Cht=t=>{const A=lht.parse(t),e=Yi(0,Ae.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.5,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.5,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Eht(A).concat(i,e),parameters:A}},Qht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Eht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Qht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},hht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("4.80mm"),h:Y().default("2.10mm"),pl:Y().default("1.30mm"),pw:Y().default("1.40mm"),p:Y().default("2.9mm")}),uht=t=>{const A=hht.parse(t),e=Yi(0,Ae.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:pht(A).concat(i,e),parameters:A}},dht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},pht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=dht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},fht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("7.30mm"),h:Y().default("4.40mm"),pl:Y().default("2.50mm"),pw:Y().default("2.30mm"),p:Y().default("4.30mm")}),yht=t=>{const A=fht.parse(t),e=Yi(0,Ae.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.1,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.1,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:mht(A).concat(i,e),parameters:A}},wht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},mht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=wht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Dht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("10.70mm"),h:Y().default("6.60mm"),pl:Y().default("3.30mm"),pw:Y().default("2.50mm"),p:Y().default("6.80mm")}),Sht=t=>{const A=Dht.parse(t),e=Yi(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2-.8},{x:-Ae.parse(A.w)/2-.8,y:Ae.parse(A.h)/2-.8},{x:-Ae.parse(A.w)/2-.8,y:-Ae.parse(A.h)/2+.8},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:xht(A).concat(i,e),parameters:A}},bht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},xht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=bht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},kht=Ji.extend({fn:Y(),num_pins:WA().default(4),w:Y().default("8.50mm"),h:Y().default("6.90mm"),pl:Y().default("2mm"),pw:Y().default("1.5mm"),p:Y().default("2.30mm"),string:Y().optional()}),Ght=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const o=Mht.parse({...t,num_pins:e});return{circuitJson:Lx(o),parameters:o}}const i=kht.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:Rht(i),parameters:i};if(i.num_pins===5)return{circuitJson:_ht(i),parameters:i};if(i.num_pins===6)return{circuitJson:Uht(i),parameters:i};throw new Error("Invalid number of pins")},Fht=t=>{const{pn:A,w:e,p:i}=t;return A===1?{x:-e/2+1.1,y:i}:A===2?{x:-e/2+1.1,y:0}:A===3?{x:-e/2+1.1,y:-i}:{x:e/2-1.1,y:0}},Rht=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=Fht({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),I=r===3?3.8:Number.parseFloat(t.pw);A.push(Qi(r+1,a,g,Number.parseFloat(t.pl),I))}const e=Yi(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,o=Number.parseFloat(t.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,e]},Mht=qm({p:"0.90mm",w:"2.8mm",legsoutside:!0}),Nht=t=>{const{p:A,pn:e,w:i}=t;if(e===1)return{x:-i/2+1.2,y:A/2+A};if(e===2)return{x:-i/2+1.2,y:A/2};if(e===3)return{x:-i/2+1.2,y:-A/2};if(e===4)return{x:-i/2+1.2,y:-A/2-A};if(e===5)return{x:i/2-1,y:0};throw new Error("Invalid pin number")},_ht=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=Nht({h:Number.parseFloat(t.h),p:1.5,pn:r,w:Number.parseFloat(t.w)});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===5?(I=3.4,c=1.8):(I=1,c=2.2),A.push(Qi(r,a,g,c,I))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,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:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Yi(0,0,.3);return[...A,o,n,s]},vht=t=>{const{p:A,pn:e,w:i}=t;if(e===1)return{x:-i/2+1.2,y:2*A};if(e===2)return{x:-i/2+1.2,y:A};if(e===3)return{x:-i/2+1.2,y:0};if(e===4)return{x:-i/2+1.2,y:-A};if(e===5)return{x:-i/2+1.2,y:-2*A};if(e===6)return{x:i/2-1.175,y:0};throw new Error("Invalid pin number")},Uht=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=vht({h:Number.parseFloat(t.h),p:1.3,pn:r,w:8.7});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===6?(I=3.4,c=2.15):(I=.6,c=2.2),A.push(Qi(r,a,g,c,I))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,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:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Yi(0,0,.3);return[...A,o,n,s]},Lht=Ji.extend({fn:Y(),num_pins:WA().default(3),w:Y().default("3.40mm"),h:Y().default("3.30mm"),pl:Y().default("1mm"),pw:Y().default("0.7mm"),p:Y().default("1.2mm"),string:Y().optional()}),Hht=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=Lht.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:Jht(i),parameters:i};throw new Error("Invalid number of pins")},Yht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},Jht=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=Yht({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Yi(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.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,e]},Tht=Ji.extend({fn:Y(),num_pins:ei([GA(3),GA(2)]).default(3),p:Y().default("1.27mm"),id:Y().default("0.72mm"),od:Y().default("0.95mm"),w:Y().default("2.5mm"),h:Y().default("4.2mm"),string:Y().optional()}),Kht=t=>{const{p:A,id:e,od:i,w:o,h:n}=t,s=Number.parseFloat(n)/2,r=Number.parseFloat(A);return[Pn(1,-r,s-r,e,i),Pn(2,0,s-r,e,i),Pn(3,r,s-r,e,i)]},qht=t=>{const{p:A,id:e,od:i,h:o}=t,n=Number.parseFloat(o)/2,s=Number.parseFloat(A);return[Pn(1,-s,n-s,e,i),Pn(2,s,n-s,e,i)]},Pht=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=Tht.parse({...t,num_pins:e});let o=[];if(i.num_pins===3)o=Kht(i);else if(i.num_pins===2)o=qht(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=Yi(0,n+1,.5);return{circuitJson:[...o,r,a],parameters:i}},Oht=Ji.extend({fn:Y(),p:Ae.optional(),id:Ae.optional(),pw:Ae.optional(),pl:Ae.optional(),w:Ae.optional(),h:Ae.optional(),sh:ei([ce(),Y(),WA()]).optional().transform(t=>{if(typeof t=="string"){const A=Number(t);return Number.isNaN(A)?!0:A}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:ce().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:Y().optional()}),Wht={ph:{p:Ae.parse("2.2mm"),id:Ae.parse("0.70mm"),pw:Ae.parse("1.20mm"),pl:Ae.parse("1.20mm"),w:Ae.parse("6mm"),h:Ae.parse("5mm")},sh:{p:Ae.parse("1mm"),pw:Ae.parse("0.6mm"),pl:Ae.parse("1.55mm"),w:Ae.parse("5.8mm"),h:Ae.parse("7.8mm")}};function Zht(t){return t.sh?"sh":(t.ph,"ph")}function Vht(t,A,e,i,o,n){const s=[];if(t==="ph"){const r=e/2;s.push(SS(1,-r,2,i,o,n)),s.push(SS(2,r,2,i,o,n))}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const I=r+g*e;console.log("x si",I),s.push(Qi(g+1,I,-1.325,o,n))}const a=(A-1)/2*e+1.3;console.log("offset",a),s.push(Qi(A+1,-a,1.22,1.2,1.8)),s.push(Qi(A+2,a,1.22,1.2,1.8))}return s}function jht(t,A,e){return t==="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 zht=t=>{const A=Oht.parse(t),e=Zht(A),i=Wht[e],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 I=e==="sh"?4:2;if(e==="sh"){const Q=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(Q&&Q[1]){const E=parseInt(Q[1],10);Number.isNaN(E)||(I=E)}else typeof A.sh=="number"&&(I=A.sh)}const c=Vht(e,I,o,n,s,r),B=jht(e),l=Yi(0,g/2+1,.5);return{circuitJson:[...c,B,l],parameters:{...A,p:o,id:n,pw:s,pl:r,w:a,h:g,num_pins:I,sh:e==="sh",ph:e==="ph"}}},Xht=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("3.30mm"),h:Y().default("1.70mm"),pl:Y().default("0.80mm"),pw:Y().default("1mm"),p:Y().default("1.90mm")}),$ht=t=>{const A=Xht.parse(t),e=Yi(0,Ae.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eut(A).concat(i,e),parameters:A}},Aut=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eut=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Aut({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tut=t=>{switch(t){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"}}},iut=Ji.extend({fn:Y(),num_pins:ei([GA(8),GA(10)]).default(8),w:Y().optional(),h:Y().optional(),p:Y().optional(),pl:Y().optional(),pw:Y().optional(),string:Y().optional()}),out=t=>{const A=iut.parse(t),e=tut(A.num_pins),i=Ae.parse(A.w||e.w),o=Ae.parse(A.h||e.h),n=Ae.parse(A.p||e.p),s=Ae.parse(A.pl||e.pl),r=Ae.parse(A.pw||e.pw),a=[],g=A.num_pins/2;for(let u=0;u<A.num_pins;u++){const{x:d,y:f}=VVA(A.num_pins,u+1,i,n),m=u<g?u+1:A.num_pins-(u-g);a.push(Qi(m,d,f,s,r))}const I=i,c=o,B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:c/2},{x:I/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:-c/2},{x:I/2,y:-c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=VVA(A.num_pins,1,I,n),Q={x:C.x-.8,y:C.y},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:Q.x-.4,y:Q.y},{x:Q.x-.7,y:Q.y+.3},{x:Q.x-.7,y:Q.y-.3},{x:Q.x-.4,y:Q.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Yi(0,c/2+.5,.3);return{circuitJson:[...a,B,l,h,E],parameters:A}},VVA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*Ae.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},nut=t=>{switch(t){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"}}},sut=Ji.extend({fn:Y(),num_pins:ei([GA(8),GA(10),GA(12),GA(16)]).default(8),w:Y().optional(),h:Y().optional(),p:Y().optional(),pl:Y().optional(),pw:Y().optional(),string:Y().optional()}),jVA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*Ae.parse("2mm"),y:r*i}},rut=t=>{const A=sut.parse(t),e=nut(A.num_pins),i=Ae.parse(A.w||e.w),o=Ae.parse(A.h||e.h),n=Ae.parse(A.p||e.p),s=Ae.parse(A.pl||e.pl),r=Ae.parse(A.pw||e.pw),a=[];for(let h=0;h<A.num_pins;h++){const{x:u,y:d}=jVA(A.num_pins,h+1,i,n);a.push(Qi(h+1,u,d,s,r))}const g=i,I=o,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:I/2},{x:g/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-I/2},{x:g/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=jVA(A.num_pins,1,g,n),C={x:l.x-.8,y:l.y},Q={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"},E=Yi(0,I/2+.5,.3);return{circuitJson:[...a,c,B,E,Q],parameters:A}},aut=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("3.8mm"),h:Y().default("1.65mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),pad_spacing:Y().default("2.6mm")}),gut=t=>{const A=aut.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.pad_spacing)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.pad_spacing)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:cut(A).concat(i,e),parameters:A}},Iut=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},cut=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Iut({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},But=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("3.20mm"),h:Y().default("1.65mm"),pl:Y().default("0.8mm"),pw:Y().default("0.9mm"),pad_spacing:Y().default("2.1mm")}),lut=t=>{const A=But.parse(t),e=Yi(0,Ae.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.pad_spacing)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.2,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.pad_spacing)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Qut(A).concat(i,e),parameters:A}},Cut=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Qut=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Cut({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Eut=Ji.extend({fn:Y(),num_pins:ei([GA(6),GA(8)]).default(8),w:Y().default("3mm"),h:Y().default("3mm"),p:Y().default("0.5mm"),pl:Y().default("0.52mm"),pw:Y().default("0.35mm"),epw:Y().default("1.40mm"),eph:Y().default("1.60mm"),string:Y().optional(),ep:ce().default(!1)}),hut=t=>{t.string&&t.string.includes("_ep")&&(t.ep=!0);const A=t.string?.match(/^son_(\d+)/),e=A?Number.parseInt(A[1],10):t.num_pins||8,i=Eut.parse({...t,num_pins:e}),o=Ae.parse(i.w),n=Ae.parse(i.h),s=Ae.parse(i.p),r=Ae.parse(i.pl),a=Ae.parse(i.pw),g=Ae.parse(i.epw),I=Ae.parse(i.eph),c=[];for(let f=0;f<i.num_pins;f++){const{x:m,y:S}=zVA(i.num_pins,f+1,o,s);c.push(Qi(f+1,m,S,r,a))}i.ep&&c.push(Qi(i.num_pins+1,0,0,g,I));const B=o,l=n,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:l/2},{x:B/2,y:l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:-l/2},{x:B/2,y:-l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},E=zVA(i.num_pins,1,B,s),h={x:E.x-.4,y:E.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=Yi(0,l/2+.5,.3);return{circuitJson:[...c,C,Q,d,u],parameters:i}},zVA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*Ae.parse("1.4mm"),y:r*i}},uut=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:o=1.5,ph:n=1.5}=t,s=Ae.parse(i),r=Ae.parse(o),a=Ae.parse(n),g=Math.min(a/4,.5),I=[];for(let f=0;f<A;f++)I.push(Qi(f+1,f*s,0,r,a));let c=[];if(e){const f=e.split("").map(Number);if(f.length>1)for(let m=0;m<f.length-1;m++){const S=f[m],D=f[m+1];if(typeof S=="number"&&typeof D=="number"&&!isNaN(S)&&!isNaN(D)){const x=(S-1)*s,F=(D-1)*s,k=Math.sign(F-x),v=x+k*(r/2),_=F-k*(r/2);c.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${S}}`,x:v,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${D}}`,x:_,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const B=(A-1)*s+r+.7,l=a+1,C=(A-1)*s/2,Q=0,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:C-B/2,y:Q-l/2},{x:C+B/2,y:Q-l/2},{x:C+B/2,y:Q+l/2},{x:C-B/2,y:Q+l/2},{x:C-B/2,y:Q-l/2}],stroke_width:.15},u=Q+l/2+.6,d=Yi(C,u,.4);return{circuitJson:[...I,...c,E,d],parameters:t}},XVA={fn:GA("sot457"),num_pins:GA(6).default(6),pillh:Y().default("0.45mm"),pillw:Y().default("1.45mm"),pl:Y(),pw:Y(),p:Y(),wave:ce().optional(),reflow:ce().optional()},dut=Ji.extend({...XVA,h:Y().default("2.5mm"),w:Y().default("2.7mm"),pl:Y().default("0.8mm"),pw:Y().default("0.55mm"),p:Y().default("0.95mm")}),put=Ji.extend({...XVA,h:Y().default("3mm"),w:Y().default("4mm"),pillr:Y().default("0.225mm"),pl:Y().default("1.45mm"),pw:Y().default("1.5mm"),p:Y().default("1.475mm")}).transform(t=>({...t,wave:t.wave??(t.reflow===void 0?!0:!t.reflow),reflow:t.reflow??(t.wave===void 0?!1:!t.wave)})),bS=t=>Number.parseFloat(t.replace("mm","")),$VA=({pitch:t,width:A,pinNumber:e})=>{const n={1:{x:-A/2-.1,y:t},2:{x:-A/2-.1,y:0},3:{x:-A/2-.1,y:-t},4:{x:A/2+.1,y:-t},5:{x:A/2+.1,y:0},6:{x:A/2+.1,y:t}}[e];if(!n)throw new Error(`Invalid pin number: ${e}`);return n},A9A=t=>{const A=[],e=bS(t.p),i=bS(t.pl),o=bS(t.pw),n=bS(t.w),s=bS(t.h);if(t.wave){const C={1:({padWidth:Q,padHeight:E})=>Qi(1,-e,e,E,Q),2:({padWidth:Q,padHeight:E})=>Qi(2,-e,-e,E,Q),3:({padWidth:Q,padHeight:E})=>V5(3,-e,0,bS(t.pillw),bS(t.pillh)),4:({padWidth:Q,padHeight:E})=>V5(4,e,0,bS(t.pillw),bS(t.pillh)),5:({padWidth:Q,padHeight:E})=>Qi(5,e,e,E,Q),6:({padWidth:Q,padHeight:E})=>Qi(6,e,-e,E,Q)};for(let Q=1;Q<=t.num_pins;Q++){const E=C[Q];E&&A.push(E({padWidth:i,padHeight:o}))}}else for(let C=1;C<=t.num_pins;C++){const{x:Q,y:E}=$VA({pitch:e,width:n,pinNumber:C});A.push(Qi(C,Q,E,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+e/1.3},{x:n/3,y:s/2+e/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-e/1.3},{x:n/3,y:-s/2-e/1.3}],stroke_width:.05},g=Yi(0,s+.5,.3),I=$VA({pitch:e,width:n,pinNumber:1}),c=t.wave?1:.5,B=t.wave?.7:.3;I.x-=t.wave?o:o*1.7;const l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:I.x+c/2,y:I.y},{x:I.x-c/2,y:I.y+B/2},{x:I.x-c/2,y:I.y-B/2},{x:I.x+c/2,y:I.y}],stroke_width:.05};return[g,r,a,l,...A]},fut=t=>{if(t.wave){const e=put.parse({...t,fn:"sot457"});return{circuitJson:A9A(e),parameters:e}}const A=dut.parse(t);return{circuitJson:A9A(A),parameters:A}},yut=Ji.extend({fn:Y(),num_pins:GA(6).default(6),w:Y().default("1.1mm"),h:Y().default("1.45mm"),p:Y().default("0.35mm"),pl:Y().default("0.2mm"),pw:Y().default("0.2mm"),string:Y().optional()}),wut=t=>{const A=yut.parse({...t,fn:"sot963"}),e=Ae.parse(A.w),i=Ae.parse(A.h),o=Ae.parse(A.p),n=Ae.parse(A.pl),s=Ae.parse(A.pw),r=[];for(let l=0;l<6;l++){const{x:C,y:Q}=e9A(l+1,e,o,n);r.push(Qi(l+1,C,Q,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=e9A(1,e,o,n),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-n/2-.3,y:I.y},{x:I.x-n/2-.45,y:I.y+.15},{x:I.x-n/2-.45,y:I.y-.15},{x:I.x-n/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},B=Yi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,B,c],parameters:A}},e9A=(t,A,e,i)=>{const o=A/2-i/2;return t<=3?{x:-o,y:e-(t-1)*e}:{x:o,y:-e+(t-4)*e}},mut=Ji.extend({fn:Y(),num_pins:ei([GA(3),GA(2)]).default(3),p:Y().default("3.8mm"),id:Y().default("1.25mm"),od:Y().default("2.35mm"),ca:Y().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:Y().default("5.35mm"),h:Y().default("4mm"),string:Y().optional()}),Dut=t=>{const{p:A,id:e,od:i,h:o,ca:n}=t,s=Number.parseFloat(o),r=Number.parseFloat(n);return[Pn(1,0,r/4+.3,e,i),Pn(2,s,0,e,i),Pn(3,0,-r/4-.3,e,i)]},Sut=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=mut.parse({...t,num_pins:e});let o=[];i.num_pins===3&&(o=Dut(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:""},I=Number.parseFloat(i.w)/2,c=Yi(I,n+1,.5);return{circuitJson:[...o,a,g,c],parameters:i}},but=Ji.extend({fn:Y(),p:Ae.optional().default("7.5mm"),id:Ae.optional().default("1mm"),od:Ae.optional().default("2mm"),d:Ae.optional().default("10.5mm")}),xut=(t,A,e,i,o)=>{const n=[],s=[];for(let r=0;r<=50;r++){const a=r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-o/2&&I<=A+o/2||n.push({x:g,y:I})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-o/2&&I<=A+o/2||s.push({x:g,y:I})}return{topArc:n,bottomArc:s}},kut=t=>{const A=but.parse(t),{p:e,id:i,od:o,d:n}=A,s=[Pn(1,-e/2,0,i,o),Pn(2,e/2,0,i,o)],{topArc:r,bottomArc:a}=xut(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:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},c={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:""},B=-(n/2+.5),l=o/2+1.5,C=.5,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B-C,y:l},{x:B+C,y:l}],stroke_width:.1,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B,y:l-C},{x:B,y:l+C}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Yi(0,n/2+1,.5);return{circuitJson:[...s,g,I,c,Q,E,h],parameters:A}},Gut=Ji.extend({fn:Y(),num_pins:GA(2).default(2),w:Y().default("6.5mm"),h:Y().default("3mm"),pl:Y().default("1.75mm"),pw:Y().default("2.40mm"),p:Y().default("4.75mm")}),Fut=t=>{const A=Gut.parse(t),e=Yi(0,Ae.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(A.p)/2,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.3,y:Ae.parse(A.h)/2},{x:-Ae.parse(A.w)/2-.3,y:-Ae.parse(A.h)/2},{x:Ae.parse(A.p)/2,y:-Ae.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Mut(A).concat(i,e),parameters:A}},Rut=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Mut=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Rut({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Nut=Ji.extend({fn:Y(),num_pins:WA().default(3),w:Y().default("2.45mm"),h:Y().default("2.40mm"),pl:Y().default("1.225mm"),pw:Y().default("0.5mm"),p:Y().default("0.95mm"),string:Y().optional()}),_ut=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=Nut.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:Uut(i),parameters:i};throw new Error("Invalid number of pins")},vut=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},Uut=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=vut({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Yi(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),o=Number.parseFloat(t.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,e]},Lut=Ji.extend({fn:Y(),circle:ce().optional(),rect:ce().optional(),square:ce().optional(),pill:ce().optional(),d:Ae.optional(),pd:Ae.optional(),diameter:Ae.optional(),r:Ae.optional(),pr:Ae.optional(),radius:Ae.optional(),w:Ae.optional(),pw:Ae.optional(),width:Ae.optional(),h:Ae.optional(),ph:Ae.optional(),height:Ae.optional(),s:Ae.optional(),size:Ae.optional(),string:Y().optional()}).transform(t=>{let A="rect";t.circle&&(A="circle"),t.square&&(A="square"),t.rect&&(A="rect"),t.pill&&(A="pill");let e,i,o;return A==="circle"?t.r!==void 0?e=mr(t.r):t.pr!==void 0?e=mr(t.pr):t.radius!==void 0?e=mr(t.radius):t.d!==void 0?e=mr(t.d)/2:t.pd!==void 0?e=mr(t.pd)/2:t.diameter!==void 0?e=mr(t.diameter)/2:e=mr("1mm")/2:(t.w!==void 0?i=mr(t.w):t.pw!==void 0?i=mr(t.pw):t.width!==void 0?i=mr(t.width):t.s!==void 0?i=mr(t.s):t.size!==void 0?i=mr(t.size):i=mr("1mm"),t.h!==void 0?o=mr(t.h):t.ph!==void 0?o=mr(t.ph):t.height!==void 0?o=mr(t.height):A==="square"||A==="rect"?o=i:o=mr("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:o}}),Hut=t=>{const A=Lut.parse(t),{shape:e,radius:i,width:o,height:n}=A;let s,r;return e==="circle"?(s=_VA(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=V5(1,0,0,o,n),r=Math.max(o,n)/2+.5):(s=Qi(1,0,0,o,n),r=n/2+.5),{circuitJson:[s,Yi(0,r,.2)],parameters:A}},Yut=Ji.extend({fn:Y(),d:Ae.optional(),hd:Ae.optional(),r:Ae.optional(),hr:Ae.optional(),pd:Ae.optional(),pr:Ae.optional(),squarepad:ce().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=mr(t.d):t.hd!==void 0?A=mr(t.hd):t.r!==void 0?A=mr(t.r)*2:t.hr!==void 0?A=mr(t.hr)*2:A=mr("1mm");let e;return t.pd!==void 0?e=mr(t.pd):t.pr!==void 0?e=mr(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),Jut=t=>{const A=Yut.parse(t),{d:e,pd:i,squarepad:o}=A;return{circuitJson:[o?SS(1,0,0,e,i,i):Pn(1,0,0,e,i),Yi(0,i/2+.5,.2)],parameters:A}},Tut=Ji.extend({fn:Y(),num_pins:GA(6).default(6),h:Y().default("1.6mm"),pl:Y().default("1mm"),pw:Y().default("0.7mm"),p:Y().default("0.95mm")}),Kut=t=>{const A=Tut.parse(t);return{circuitJson:qut(A),parameters:A}},t9A=t=>{const{p:A,h:e,pn:i}=t;if(i===1)return{x:-e/2-.5,y:A};if(i===2)return{x:-e/2-.5,y:0};if(i===3)return{x:-e/2-.5,y:-A};if(i===4)return{x:e/2+.5,y:-A};if(i===5)return{x:e/2+.5,y:0};if(i===6)return{x:e/2+.5,y:A};throw new Error("Invalid pin number")},qut=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:l}=t9A({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(Qi(c,B,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.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:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Yi(0,i+.3,.3),r=t9A({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={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,I]},Put=Ji.extend({fn:Y(),num_pins:WA().default(4),w:Y().default("3.2mm"),h:Y().default("2.6mm"),pl:Y().default("1.35mm"),pw:Y().default("0.50mm"),p:Y().default("0.6mm"),string:Y().optional()}),Out=t=>{const A=t.string?.match(/^sot343_(\d+)/),e=A?Number.parseInt(A[1],4):4,i=Put.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:Zut(i),parameters:i};throw new Error("Invalid number of pins")},Wut=t=>{const{pn:A,p:e}=t;return A===1?{x:-e*1.92,y:-.65}:A===2?{x:-e*1.92,y:.65}:A===3?{x:e,y:.65}:A===4?{x:e,y:-.65}:{x:0,y:0}},Zut=t=>{const A=[],e=Number.parseFloat(t.w),i=Number.parseFloat(t.h),o=Number.parseFloat(t.pl),n=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let r=1/0,a=-1/0,g=1/0,I=-1/0;for(let d=0;d<t.num_pins;d++){const{x:f,y:m}=Wut({num_pins:t.num_pins,pn:d+1,p:s});A.push(Qi(d+1,f,m,o,n)),f<r&&(r=f),f>a&&(a=f),m<g&&(g=m),m>I&&(I=m)}const c=(r+a)/2,B=I-g,l=i*.3,C=B/2+l;let Q=e*.8;i<=2.6&&(Q/=2);const E=Yi(c,C+.5,.3),h={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:c-Q/2,y:C},{x:c+Q/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:c-Q/2,y:-C},{x:c+Q/2,y:-C}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,h,u,E]},Vut=Ji.extend({fn:Y()}),jut=t=>{const A=Vut.parse(t),e=[],i=.5-.15,o=1.5,s=.5/2,r=75,a=-37/2;for(let D=0;D<r;D++){const x=D+1;if(x>=24&&x<=31)continue;const F=a-D*s,k=x%2===0,v=o+(k?.25:0),H=.5-v/2,P=Qi(x,H,F,v,i);P.layer=k?"bottom":"top",e.push(P)}const g=46*.0254,I=137*.0254,c=261*.0254,B={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-I/2+o/2,y:a-c},width:I,height:g},l={x:-.5,y:a},C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-.4,y:l.y},{x:l.x-.7,y:l.y+.3},{x:l.x-.7,y:l.y-.3},{x:l.x-.4,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let Q=1/0,E=-1/0,h=1/0,u=-1/0;const d=(D,x,F=0,k=0)=>{Q=Math.min(Q,D-F/2),E=Math.max(E,D+F/2),h=Math.min(h,x-k/2),u=Math.max(u,x+k/2)};for(const D of e)d(D.x,D.y,D.width,D.height);d(B.center.x,B.center.y,B.width,B.height);for(const D of C.route)d(D.x,D.y);const f=(Q+E)/2,m=(h+u)/2,S=D=>{typeof D.x=="number"&&(D.x-=f),typeof D.y=="number"&&(D.y-=m),D.center&&(D.center.x-=f,D.center.y-=m),Array.isArray(D.route)&&(D.route=D.route.map(x=>({x:x.x-f,y:x.y-m})))};for(const D of e)S(D);return S(B),S(C),{circuitJson:[...e,B,C],parameters:A}},zut=Ji.extend({fn:Y(),num_pins:WA().default(3),inline:ce().default(!1),p:Y().default("1.27mm"),id:Y().default("0.75mm"),od:Y().default("1.3mm"),w:Y().default("4.8mm"),h:Y().default("4.0mm")}),Xut=t=>{const A=zut.parse(t),e=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=[SS(1,0,0,A.id,n,s,0,0),A.inline?yL(2,e,0,A.id,n,s):Pn(2,e,e,A.id,n),A.inline?yL(3,e*2,0,A.id,n,s):Pn(3,e*2,0,A.id,n)],a=i/2,g=A.inline?e-.09:e,I=.2,c=I+a-o,B=Array.from({length:32},(Q,E)=>{const h=Math.PI*E/31;return{x:g+a*Math.cos(h),y:I+a*Math.sin(h)}}),l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",stroke_width:.12,route:[...B,{x:g-a,y:c},{x:g+a,y:c},B[0]]},C=Yi(g,I+a+1,.5);return{circuitJson:[...r,l,C],parameters:A}};function $ut(t){return t!=null}var Adt=(t,A)=>{if(!A)return t;const e=t.filter(I=>I.type==="pcb_smtpad"||I.type==="pcb_plated_hole"||I.type==="pcb_thtpad");if(e.length===0)return t;let i=1/0,o=-1/0,n=1/0,s=-1/0;const r=(I,c,B=0,l=0)=>{const C=I-B/2,Q=I+B/2,E=c-l/2,h=c+l/2;i=Math.min(i,C),o=Math.max(o,Q),n=Math.min(n,E),s=Math.max(s,h)};for(const I of e)if(I.type==="pcb_smtpad"){const c=I.shape==="circle"?I.radius*2:I.width,B=I.shape==="circle"?I.radius*2:I.height;r(I.x,I.y,c,B)}else if(I.type==="pcb_plated_hole"){const c=I.outer_diameter??I.hole_diameter;r(I.x,I.y,c,c)}else if(I.type==="pcb_thtpad"){const c=I.diameter;r(I.x,I.y,c,c)}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 I=e.find(c=>c.port_hints?.[0]==="1")||e[0];a=I.x,g=I.y;break}if(a===0&&g===0)return t;for(const I of t){if(typeof I.x=="number"&&(I.x-=a),typeof I.y=="number"&&(I.y-=g),I.center&&typeof I.center.x=="number"&&(I.center.x-=a,I.center.y-=g),I.type==="pcb_silkscreen_path")for(const c of I.route)c.x-=a,c.y-=g;I.type==="pcb_silkscreen_text"&&I.anchor_position&&(I.anchor_position.x-=a,I.anchor_position.y-=g)}return t},edt=(t,A)=>{const e=t.filter(i=>i.type==="pcb_silkscreen_text");if(e.length===0)return t;for(const i of e)A.norefdes&&(i.text="");return t},tdt=(t,A)=>A.nosilkscreen?t.filter(e=>e.type!=="pcb_silkscreen_path"&&e.type!=="pcb_silkscreen_text"):t,idt=t=>{let A=$5();const i=t.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($ut);for(const{fn:o,v:n}of i)A=A[o](n);return A.setString(t),A},odt=()=>Object.keys(DS),$5=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&DS[A.fn])return()=>{const{circuitJson:i}=DS[A.fn](A),o=tdt(i,A),n=edt(o,A);return Adt(n,A.origin)};if(!DS[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 "${e}"`)}}if(e==="json"){if(!DS[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>DS[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(DS):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in DS?(A[`${e}${i}`]=!0,A.fn=`${e}${i}`):(A[e]=!0,A.fn=e,e==="res"||e==="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(e)||(A[e]=i??!0),t)}});return t};$5.string=idt,$5.getFootprintNames=odt;var ndt=$5,i9A=Symbol("Fragment");function CCA(t,A,...e){const i=e.length?e: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:t,props:(A&&A.children!==void 0?{...A,children:void 0}:A)||{},children:o}}var ut=Symbol("Cuboid"),o9A=Symbol("Cube"),tf=Symbol("Cylinder"),n9A=Symbol("Sphere"),wL=Symbol("RoundedCuboid"),Zi=Symbol("Translate"),fQ=Symbol("Rotate"),QE=Symbol("Union"),hF=Symbol("Subtract"),CI=Symbol("Hull"),ys=Symbol("Colorize"),mL=Symbol("Polygon"),DL=Symbol("ExtrudeLinear"),of=Symbol("RoundedCylinder"),Ko=i9A,ee=(t,A,e)=>CCA(t,A),Pt=(t,A,e)=>CCA(t,A),$B=({center:t,width:A,length:e,height:i,heightAboveSurface:o=.15,color:n="#555",taperRatio:s=.12,faceRatio:r=.75,straightHeightRatio:a=.5,includeNotch:g=!0,notchRadius:I,notchPosition:c,notchRotation:B=[0,0,0],notchLength:l=.5,notchWidth:C=.25,chamferSize:Q=0})=>{const E=i*a,h=i-E,u=Math.min(A,e)*s,d=Math.max(A-u,A*r),f=Math.max(e-u,e*r),m=Math.min(A,e)*.12,S=I??m,D={x:0,y:e/2-S*.25,z:i},x=c??D,F=Pt(QE,{children:[Pt(CI,{children:[ee(Zi,{z:.005,children:ee(ut,{size:[d,f,.01]})}),ee(Zi,{z:E,children:ee(ut,{size:[A,e,.01]})})]}),Pt(CI,{children:[ee(Zi,{z:E,children:ee(ut,{size:[A,e,.01]})}),ee(Zi,{z:E+h,children:ee(ut,{size:[d,f,.01]})})]})]}),k=(_,H)=>ee(Zi,{offset:{x:_,y:H,z:0},children:ee(fQ,{rotation:[0,0,Math.PI/4],children:ee(ut,{size:[Q*Math.SQRT2,Q*Math.SQRT2,i*3]})})});let v=F;if(Q>0){const _=A/2,H=e/2;v=Pt(hF,{children:[F,k(_,H),k(-_,H),k(_,-H),k(-_,-H)]})}return ee(ys,{color:n,children:ee(Zi,{offset:t,children:ee(Zi,{offset:{x:0,y:0,z:o},children:g?Pt(hF,{children:[v,ee(Zi,{offset:x,children:ee(fQ,{rotation:B,children:ee(tf,{radius:S,height:C})})})]}):v})})})},sdt=t=>Array.from({length:t},(A,e)=>e);function QCA(t,A){if(t.length<2)throw new Error("Stroke must have at least two points");const e=Array.isArray(t[0])?t.map(([I,c])=>({x:I,y:c})):t,i=A/2,o=[],n=[];function s(I,c){const B=c.x-I.x,l=c.y-I.y,C=Math.sqrt(B*B+l*l);return{x:-l/C,y:B/C}}function r(I,c,B){const l={x:I.x+c.x*i*B,y:I.y+c.y*i*B};B>0?o.push(l):n.unshift(l)}const a=s(e[0],e[1]);r(e[0],a,1),r(e[0],a,-1);for(let I=1;I<e.length-1;I++){const c=e[I-1],B=e[I],l=e[I+1],C=s(c,B),Q=s(B,l),E=C.x+Q.x,h=C.y+Q.y,u=Math.sqrt(E*E+h*h);if(u/2>2*i)r(B,C,1),r(B,Q,1),r(B,C,-1),r(B,Q,-1);else{const f=1/u;r(B,{x:E*f,y:h*f},1),r(B,{x:E*f,y:h*f},-1)}}const g=s(e[e.length-2],e[e.length-1]);return r(e[e.length-1],g,1),r(e[e.length-1],g,-1),[...o,...n]}var rdt=t=>{const A=Math.min(...t.map(r=>r.x)),e=Math.max(...t.map(r=>r.x)),i=Math.min(...t.map(r=>r.y)),s=5.47/(Math.max(...t.map(r=>r.y))-i);return t.map(r=>({x:(r.x-A-(e-A)/2)*s,y:(r.y-i)*s}))},adt=rdt([{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}]),s9A=5.47,A8=.5,gdt=({x:t,y:A,z:e})=>{const i=t>0;return Pt(Ko,{children:[ee(Zi,{offset:{x:t+.25/2,y:A,z:e},children:ee(fQ,{rotation:["-90deg",0,"90deg"],children:ee(DL,{height:.25,children:ee(mL,{points:adt.slice().reverse().map(o=>[o.x,o.y])})})})}),ee(Zi,{offset:{x:t,y:A+(i?1:-1),z:e},children:ee(fQ,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:ee(DL,{height:2,children:ee(mL,{points:QCA([[0,0],[-1,0],[-1,-1]],.25).map(o=>[o.x,o.y])})})})})]})},Idt=({numPins:t=8,pitch:A=2.54,bodyWidth:e=6.4,rowSpacing:i})=>{const o=Math.floor(t/2),n=i??(e>=7?e:e+1.22),s=e>=7?n-1.22:e;return Pt(Ko,{children:[sdt(t).map(r=>{const a=r%o,g=(Math.floor(r/o)-.5)*2;return ee(gdt,{x:g*n/2,y:a*A-(o-1)/2*A,z:s9A/2+A8})}),ee($B,{width:s,length:o*A+.5,height:s9A-A8,heightAboveSurface:A8,center:{x:0,y:0,z:A8}})]})};function cdt(t,{height:A,padContactLength:e,curveLength:i,bodyDistance:o,steepness:n=10}){i||(i=o*.3);let s=o-e-i;s<0&&(i+=s,s=0);const r=e*.75,a=e+i+(o-e-i)*.25;if(t<=r)return 0;if(t>=a)return A;const g=(t-r)/(a-r);return A/(1+Math.exp(-n*(g-.5)))}var Oo=t=>{const{thickness:A,width:e,padContactLength:i,bodyDistance:o,height:n,rotation:s}=t,r=15,a=Array.from({length:r}).map((I,c)=>c/(r-1)*o).map(I=>[I,cdt(I,t)]),g=QCA(a,A);return ee(ys,{color:"#fff",children:ee(Zi,{offset:{z:0,y:0,x:0,...t.position},children:ee(fQ,{rotation:["90deg",0,s??0],children:ee(Zi,{offset:{x:0,y:0,z:-e/2},children:ee(DL,{height:e,children:ee(mL,{points:g.map(I=>[I.x,I.y])})})})})})})},Bdt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:o})=>{const n=Math.ceil(t/2),s=i*t/2+e/2,r=(n-1)*i/2,a=.25;return Pt(Ko,{children:[Array.from({length:n}).map((g,I)=>ee(Oo,{position:{x:-o/2-A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:n}).map((g,I)=>ee(Oo,{rotation:Math.PI,position:{x:o/2+A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),ee($B,{center:{x:0,y:0,z:a/2},width:o-e-1,length:s,height:1.5})]})},ldt=({pinCount:t,padContactLength:A=.4,leadWidth:e=.2,pitch:i=.65,bodyWidth:o=3})=>{const n=Math.ceil(t/2),s=(n-1)*i/2,r=.2;return Pt(Ko,{children:[Array.from({length:n}).map((a,g)=>ee(Oo,{position:{x:-o/2-A-.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Array.from({length:n}).map((a,g)=>ee(Oo,{rotation:Math.PI,position:{x:o/2+A+.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),ee($B,{center:{x:0,y:0,z:r/2},width:o,length:o,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},ECA=1,hCA=.5,B_=.5,SL=.2,Cdt=ECA-SL*2,r9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Cdt,hCA,B_],offset:[0,0,B_/2],color:t}),ee(ut,{size:[SL,B_,hCA],offset:[ECA/2-SL/2,0,B_/2],color:"#ccc"}),ee(ut,{size:[SL,B_,hCA],offset:[-ECA/2+SL/2,0,B_/2],color:"#ccc"})]}),uCA=1.6,Qdt=uCA-.3*2,e8=.3,dCA=.85,l_=.6,a9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Qdt,dCA,l_],offset:[0,0,l_/2],color:t}),ee(ut,{size:[e8,dCA,l_],offset:[uCA/2-e8/2,0,l_/2],color:"#ccc"}),ee(ut,{size:[e8,dCA,l_],offset:[-uCA/2+e8/2,0,l_/2],color:"#ccc"})]}),pCA=2,fCA=1.25,C_=.55,bL=.5,Edt=pCA-bL*2,g9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Edt,fCA,C_],offset:[0,0,C_/2],color:t}),ee(ut,{size:[bL,fCA,C_],offset:[pCA/2-bL/2,0,C_/2],color:"#ccc"}),ee(ut,{size:[bL,fCA,C_],offset:[-pCA/2+bL/2,0,C_/2],color:"#ccc"})]}),hdt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:o})=>{const n=t/4;A||(A=udt(t,o)),i||(i=ddt(t)),e||(e=pdt(t,o)),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+2*i,g=a,I=.8,c=.15,B=(g-o)/2+.5;return Pt(Ko,{children:[Array.from({length:n}).map((l,C)=>ee(Oo,{position:{x:-g/2-.4,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:Math.PI,position:{x:g/2+.4,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),ee($B,{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})]})},udt=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},ddt=t=>{switch(t){case 32:return .6;case 40:return .6;case 52:case 64:return .65;case 208:return 1.65;default:return .6}},pdt=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},fdt=({numberOfPins:t,pitch:A=2.54,longSidePinLength:e=6,invert:i,faceup:o,rows:n=1})=>{const a=Math.ceil(t/n),g=2.54,I=a*A,c=n>1?(n-1)*g+.63*3:.63*3,B=3,l=-((a-1)/2)*A,C=n>1?-((n-1)*g)/2:0,Q=E=>i||o?-E+2:E;return Pt(Ko,{children:[ee(ut,{color:"#222",size:[I,c,2],center:[0,C,Q(2/2)]}),Array.from({length:t},(E,h)=>{const u=Math.floor(h/a),d=h%a,f=l+d*A,m=-u*g;return Pt(Ko,{children:[!o&&ee(ys,{color:"gold",children:Pt(CI,{children:[ee(ut,{color:"gold",size:[.63,.63,B*.9],center:[f,m,Q(2*.9+2/2)]}),ee(ut,{color:"gold",size:[.63/1.8,.63/1.8,B],center:[f,m,Q(2+2/2)]})]})}),ee(ys,{color:"gold",children:Pt(CI,{children:[ee(ut,{color:"gold",size:[.63,.63,e*.9],center:[f,m,Q(-e/2*.9)]}),ee(ut,{color:"gold",size:[.63/1.8,.63/1.8,e],center:[f,m,Q(-e/2)]})]})})]})})]})},ydt=t=>{const A=["left","bottom","right","top"],{pin_count:e,pn:i,w:o,h:n,p:s,pl:r}=t,a=e/4,g=A[Math.floor((i-1)/a)],I=(i-1)%a,c=s*(a-1),B=s*(a-1),l=-r/2;switch(g){case"left":return{x:-o/2-l,y:B/2-I*s,o:"vert"};case"bottom":return{x:-c/2+I*s,y:-n/2-l,o:"horz"};case"right":return{x:o/2+l,y:-B/2+I*s,o:"vert"};case"top":return{x:c/2-I*s,y:n/2+l,o:"horz"};default:throw new Error("Invalid pin number")}},wdt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const o=[],n=t/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<t;a++)o[s]=a+1,s++,s>t&&(s=1);return o},mdt=({num_pins:t=16,bodyWidth:A=9,bodyLength:e=9,bodyThickness:i=.8,thermalPadSize:o,padWidth:n=.25,padLength:s=.25,pitch:r=.5,thermalPadThickness:a=.05})=>{const g=wdt({num_pins:t,cw:!0,ccw:!0}),I=[];for(let c=0;c<t;c++){const{x:B,y:l,o:C}=ydt({pin_count:t,pn:c+1,w:A,h:e,p:r,pl:s});let Q=n,E=s;C==="vert"&&([Q,E]=[E,Q]);const h=g[c+1];I.push({pn:h,x:B,y:l,pw:Q,pl:E})}return Pt(Ko,{children:[ee(ys,{color:"grey",children:ee(ut,{center:{x:0,y:0,z:i/2},size:[A,e,i]})}),I.map((c,B)=>ee(ut,{center:{x:c.x,y:c.y,z:a/2},size:[c.pw,c.pl,a]})),o?.length!==void 0&&o?.width!==void 0&&ee(ut,{center:{x:0,y:0,z:a/2},size:[o.width,o.length,a]})]})},Ddt=mdt,Sdt=()=>{const a=1.1999999999999997;return Pt(Ko,{children:[ee(Oo,{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}),ee(Oo,{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}),ee(Oo,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),ee(Oo,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),ee(Oo,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),ee($B,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},bdt=Sdt,xdt=({fullWidth:t=2.9,fullLength:A=2.8})=>{const I=(t-1.92)/2+.3;return Pt(Ko,{children:[ee(Oo,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),ee(Oo,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),ee(Oo,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),ee($B,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},yCA=.6,wCA=.3,Q_=.33,xL=.1,kdt=yCA-xL*2,I9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[kdt,wCA,Q_],offset:[0,0,Q_/2],color:t}),ee(ut,{size:[xL,wCA,Q_],offset:[yCA/2-xL/2,0,Q_/2],color:"#ccc"}),ee(ut,{size:[xL,wCA,Q_],offset:[-yCA/2+xL/2,0,Q_/2],color:"#ccc"})]}),mCA=.4,DCA=.2,E_=.13,kL=.07,Gdt=mCA-kL*2,c9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Gdt,DCA,E_],offset:[0,0,E_/2],color:t}),ee(ut,{size:[kL,DCA,E_],offset:[mCA/2-kL/2,0,E_/2],color:"#ccc"}),ee(ut,{size:[kL,DCA,E_],offset:[-mCA/2+kL/2,0,E_/2],color:"#ccc"})]}),SCA=3.2,bCA=1.6,h_=.9,GL=.5,Fdt=SCA-GL*2,B9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Fdt,bCA,h_],offset:[0,0,h_/2],color:t}),ee(ut,{size:[GL,bCA,h_],offset:[SCA/2-GL/2,0,h_/2],color:"#ccc"}),ee(ut,{size:[GL,bCA,h_],offset:[-SCA/2+GL/2,0,h_/2],color:"#ccc"})]}),xCA=3.2,kCA=2.5,u_=1,FL=.6,Rdt=xCA-FL*2,l9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Rdt,kCA,u_],offset:[0,0,u_/2],color:t}),ee(ut,{size:[FL,kCA,u_],offset:[xCA/2-FL/2,0,u_/2],color:"#ccc"}),ee(ut,{size:[FL,kCA,u_],offset:[-xCA/2+FL/2,0,u_/2],color:"#ccc"})]}),GCA=5,FCA=2.5,d_=1.4,RL=.6,Mdt=GCA-RL*2,C9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Mdt,FCA,d_],offset:[0,0,d_/2],color:t}),ee(ut,{size:[RL,FCA,d_],offset:[GCA/2-RL/2,0,d_/2],color:"#ccc"}),ee(ut,{size:[RL,FCA,d_],offset:[-GCA/2+RL/2,0,d_/2],color:"#ccc"})]}),RCA=6.3,MCA=3.2,p_=1.8,ML=.8,Ndt=RCA-ML*2,Q9A=({color:t="#333"})=>Pt(Ko,{children:[ee(ut,{size:[Ndt,MCA,p_],offset:[0,0,p_/2],color:t}),ee(ut,{size:[ML,MCA,p_],offset:[RCA/2-ML/2,0,p_/2],color:"#ccc"}),ee(ut,{size:[ML,MCA,p_],offset:[-RCA/2+ML/2,0,p_/2],color:"#ccc"})]}),_dt=({numberOfPins:t,pitch:A=2.54,legsLength:e=3,outerDiameter:i=.945,innerDiameter:o=.945,rows:n=1})=>{const s=o/1.5,r=s*2+i,a=5,g=Math.ceil(t/n),I=2.54,c=(g-1)*A+i+A/2,B=n>1?(n-1)*I+r:r,l=s*1.6,C=-((g-1)/2)*A,Q=n>1?-((n-1)*I)/2:0,E=ee(ys,{color:"#1a1a1a",children:Pt(hF,{children:[ee(ut,{color:"#000",size:[c,B,a],center:[0,Q,a/2]}),Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,m=C+f*A,S=-d*I;return o?ee(tf,{height:a+.1,radius:o/2,center:[m,S,a/2],color:"#222"},u):ee(ut,{size:[l,l,a],center:[m,S,a/2]},u)})]})});return Pt(Ko,{children:[E,Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,m=C+f*A,S=-d*I;return Pt(ys,{color:"silver",children:[Pt(CI,{children:[ee(ut,{color:"silver",size:[s,s,e*.9],center:[m,S,-e/2*.9]}),ee(ut,{color:"silver",size:[s/1.8,s/1.8,e],center:[m,S,-e/2]})]}),ee(ut,{color:"silver",size:[l,l,l*.5],center:[m,S,l/2*.5]})]},u)})]})},vdt=({width:t,length:A,innerDiameter:e=1})=>{const i=t,o=A,n=t*.7,s=e/2.5;return Pt(Ko,{children:[ee(wL,{color:"#1a1a1f",center:[0,0,n/2],size:[o,o,n],roundRadius:.3}),ee(wL,{color:"#f2f2f2",center:[0,0,n+n*.1/2.5],size:[o,o,n*.1],roundRadius:.14}),ee(tf,{color:"#1a1a1f",height:n*.8,radius:i/3,center:[0,0,n+n*.8/2]}),ee(tf,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[o/3,o/3,n+n*.1/2]}),ee(tf,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[-o/3,-o/3,n+n*.1/2]}),ee(tf,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[-o/3,o/3,n+n*.1/2]}),ee(tf,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[o/3,-o/3,n+n*.1/2]}),ee(t8,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:-o/2,z:-n*1.2}}),ee(t8,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),ee(t8,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),ee(t8,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2+e/3.6,y:-o/2,z:-n*1.2}})]})},t8=t=>{const{thickness:A,width:e,horizontalLength:i,verticalLength:o,rotation:n=0,position:s}=t,r=[[0,i],[-o/3,i/3],[-o/5,i/4],[0,0]],a=QCA(r,A);return ee(ys,{color:"#f2f2f2",children:ee(Zi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:ee(fQ,{rotation:[0,55,n],children:ee(DL,{height:e,children:ee(mL,{points:a.map(g=>[g.y,g.x])})})})})})},Udt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:o})=>{const n=Math.ceil(t/2),s=(n-1)*i/2,r=.25,a=1,g=.8,I=A*0,c=i*(n-1)+e+.2,B=o*.55;return Pt(Ko,{children:[Array.from({length:n}).map((l,C)=>ee(Oo,{position:{x:-o/2-I,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:Math.PI,position:{x:o/2+I,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),ee($B,{center:{x:0,y:0,z:r/2},width:B,length:c,height:a})]})},Ldt=({pinCount:t,pitch:A,leadWidth:e,leadLength:i,bodyWidth:o,bodyLength:n})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},r=isNaN(parseFloat(A))?s.pitch:parseFloat(A),a=isNaN(parseFloat(e))?s.leadWidth:parseFloat(e)*.8,g=isNaN(parseFloat(o))?2.6:parseFloat(o)*.8,I=isNaN(parseFloat(n))?2+Number(r)*1.4:parseFloat(n),c=t/2,B=(c-1)*r/2,l=.15,C=.8,Q=4.5,E=(Q-g)/2,h=E*.5;return Pt(Ko,{children:[Array.from({length:c}).map((u,d)=>ee(Oo,{position:{x:-Q/2,y:B-d*r,z:l/2},width:a,thickness:l,padContactLength:h+.05,bodyDistance:E+.1,height:C})),Array.from({length:c}).map((u,d)=>ee(Oo,{rotation:Math.PI,position:{x:Q/2,y:B-d*r,z:l/2},width:a,thickness:l,padContactLength:h+.05,bodyDistance:E+.1,height:C})),ee($B,{center:{x:0,y:0,z:l/2},width:g,length:I,height:1})]})},Hdt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),ee(ut,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[ee(Zi,{z:.3/2,children:ee(ut,{size:[1.65,.8,.3]})}),Pt(CI,{children:[ee(Zi,{z:.3,children:ee(ut,{size:[1.65,.8,.01]})}),ee(Zi,{z:.6,children:ee(ut,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),Ydt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),ee(ut,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),ee(ys,{color:"#222",children:ee(Zi,{z:.47/2+.02,children:ee(ut,{size:[.98,.58,.47]})})}),ee(ut,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),ee(ut,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),ee(ut,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),ee(ut,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),Jdt=()=>{const g=ee(ys,{color:"#1a1a1a",children:Pt(QE,{children:[Pt(CI,{children:[ee(Zi,{z:.13,children:ee(ut,{size:[4,3,.03]})}),ee(Zi,{z:1.15,children:ee(ut,{size:[4.4,3.4,.01]})})]}),Pt(CI,{children:[ee(Zi,{z:1.15,children:ee(ut,{size:[4.4,3.4,.01]})}),ee(Zi,{z:2.3,children:ee(ut,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const C=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return ee(ys,{color:"#c0c0c0",children:Pt(QE,{children:[ee(ut,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),ee(ut,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),ee(ut,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Pt(Ko,{children:[ee(I,{xDir:1}),ee(I,{xDir:-1}),g]})},Tdt=()=>{const g=ee(ys,{color:"#1a1a1a",children:Pt(QE,{children:[Pt(CI,{children:[ee(Zi,{z:.13,children:ee(ut,{size:[4,3,.03]})}),ee(Zi,{z:1.15,children:ee(ut,{size:[4.4,3.4,.01]})})]}),Pt(CI,{children:[ee(Zi,{z:1.15,children:ee(ut,{size:[4.4,3.4,.01]})}),ee(Zi,{z:2.3,children:ee(ut,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const C=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return ee(ys,{color:"#c0c0c0",children:Pt(QE,{children:[ee(ut,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),ee(ut,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),ee(ut,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Pt(Ko,{children:[ee(I,{xDir:1}),ee(I,{xDir:-1}),g]})},Kdt=()=>{const g=ee(ys,{color:"#1a1a1a",children:Pt(QE,{children:[Pt(CI,{children:[ee(Zi,{z:.21000000000000002,children:ee(ut,{size:[6.3999999999999995,5.6,.03]})}),ee(Zi,{z:1.15,children:ee(ut,{size:[6.8,6,.01]})})]}),Pt(CI,{children:[ee(Zi,{z:1.15,children:ee(ut,{size:[6.8,6,.01]})}),ee(Zi,{z:2.3,children:ee(ut,{size:[6.3999999999999995,5.6,.01]})})]})]})}),I=({xDir:c})=>{const C=c*3.08,Q=c*(6/2-.2/2+1),E=c*(6/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return ee(ys,{color:"#c0c0c0",children:Pt(QE,{children:[ee(ut,{size:[2.3*.8,2.95,.2],center:[C,0,.2/2]}),ee(ut,{size:[.2,2.95,1.14],center:[Q,0,1.14/2+.2]}),ee(ut,{size:[h,2.95,.2],center:[u,0,.2/2+1.14]})]})})};return Pt(Ko,{children:[ee(I,{xDir:1}),ee(I,{xDir:-1}),g]})},qdt=()=>{const c=ee(ys,{color:"#222",children:Pt(QE,{children:[ee(Zi,{z:.27,children:ee(ut,{size:[2.9,1.9,.54]})}),Pt(CI,{children:[ee(Zi,{z:.54,children:ee(ut,{size:[2.9,1.9,.01]})}),ee(Zi,{z:1.08,children:ee(ut,{size:[2.6999999999999997,1.7,.01]})})]})]})});return Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),ee(ut,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),c]})},Pdt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),ee(ut,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[ee(Zi,{z:.55/2,children:ee(ut,{size:[2.7,1.6,.55]})}),Pt(CI,{children:[ee(Zi,{z:.55,children:ee(ut,{size:[2.7,1.6,.01]})}),ee(Zi,{z:1.1,children:ee(ut,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),Odt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),ee(ut,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[ee(Zi,{z:.2/2,children:ee(ut,{size:[2.75,1.8,.2]})}),Pt(CI,{children:[ee(Zi,{z:.2,children:ee(ut,{size:[2.75,1.8,.01]})}),ee(Zi,{z:1,children:ee(ut,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),ee(ut,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),Wdt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),ee(ut,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[Pt(CI,{children:[ee(Zi,{z:.2,children:ee(ut,{size:[2.6-.1/2,1.7-.1/2,.01]})}),ee(Zi,{z:.01,children:ee(ut,{size:[2.6-.1,1.7-.1,.01]})})]}),Pt(CI,{children:[ee(Zi,{z:.2,children:ee(ut,{size:[2.6,1.7,.01]})}),ee(Zi,{z:1,children:ee(ut,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),ee(ut,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),Zdt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),ee(ut,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[Pt(CI,{children:[ee(Zi,{z:.2,children:ee(ut,{size:[3.8-.05/2,2.5-.05/2,.01]})}),ee(Zi,{z:.01,children:ee(ut,{size:[3.8-.05,2.5-.05,.01]})})]}),Pt(CI,{children:[ee(Zi,{z:.2,children:ee(ut,{size:[3.8,2.5,.01]})}),ee(Zi,{z:1,children:ee(ut,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),ee(ut,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),Vdt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),ee(ut,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[ee(Zi,{z:.14/2,children:ee(ut,{size:[.8,.6,.14]})}),Pt(CI,{children:[ee(Zi,{z:.14,children:ee(ut,{size:[.8,.6,.01]})}),ee(Zi,{z:.37,children:ee(ut,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),jdt=()=>{const I=3.0999999999999996;return Pt(Ko,{children:[ee(Oo,{rotation:Math.PI,position:{x:6.6/2+I/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),ee(Oo,{position:{x:-6.6/2-I/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),ee(Oo,{position:{x:-6.6/2-I/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),ee(Oo,{position:{x:-6.6/2-I/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),ee($B,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},zdt=()=>Pt(Ko,{children:[Array.from({length:16}).map((l,C)=>ee(Oo,{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((l,C)=>ee(Oo,{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((l,C)=>ee(Oo,{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((l,C)=>ee(Oo,{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})),ee($B,{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})]}),Xdt=zdt,$dt=()=>{const g=.7999999999999998;return Pt(Ko,{children:[ee(Oo,{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}),ee(Oo,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),ee(Oo,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),ee($B,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},Apt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:o})=>{const n=t/4;if(n!==Math.floor(n))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);A||(A=.5),i||(i=.6),e||(e=.22),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+3.3*i,g=a,I=.8,c=.2,B=(g-o)/2+.4;return Pt(Ko,{children:[Array.from({length:n}).map((l,C)=>ee(Oo,{position:{x:-g/2-.36,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:Math.PI,position:{x:g/2+.36,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((l,C)=>ee(Oo,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),ee($B,{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})]})},ept=()=>{const i=.20900000000000002,o=.1,n=.3,s=.1,r=.2;return Pt(Ko,{children:[ee(ys,{color:"#222",children:Pt(QE,{children:[ee(ut,{size:[.85,1.2,i],center:[0,0,i/2]}),Pt(CI,{children:[ee(Zi,{z:i,children:ee(ut,{size:[.85,1.2,.01]})}),ee(Zi,{z:.38,children:ee(ut,{size:[.85-o,1.2-o,.01]})})]})]})}),ee(ut,{color:"#ccc",size:[n,.25,s],center:[.55,0,s/2]}),ee(ut,{color:"#ccc",size:[n,r,s],center:[-.55,.4,s/2]}),ee(ut,{color:"#ccc",size:[n,r,s],center:[-.55,-.4,s/2]})]})},tpt=({num_pins:t,bodyWidth:A=5.3,bodyLength:e=5.3,bodyThickness:i=1,thermalPadSize:o,padWidth:n=e/5.3*.6,padLength:s=e/5.3*1,pitch:r=.5,thermalPadThickness:a=.2})=>{const g=[],I=Math.floor(t/2),c=r*(I-1);for(let B=0;B<t;B++){const l=B<I?"left":"right",C=B%I,Q=c/2-C*r,E=s,h=n,u=l==="left"?-A/2+E/2:A/2-E/2,d=B+1;g.push({pinNumber:d,x:u,y:Q,padSizeX:E,padSizeY:h})}return Pt(Ko,{children:[ee($B,{center:{x:0,y:0,z:0},width:A,length:e,height:i,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(A/2-s),y:e/2-s,z:i}}),g.map((B,l)=>ee(ut,{center:[B.x,B.y,a/2],size:[B.padSizeX,B.padSizeY,a]})),o?.length!==void 0&&o?.width!==void 0&&ee(ut,{center:[0,0,a/2],size:[o.width,o.length,a]})]})},ipt=({bodyLength:t=10.2,bodyWidth:A=4.65,bodyHeight:e=13.46,leadSpacing:i=5,leadDiameter:o=.8,leadLength:n=12.7,color:s="#ddd",leadColor:r="#b87333"})=>{const a=t/2,g=A/2,I=a-g,c=i/2,B=.85;return Pt(Ko,{children:[Pt(ys,{color:s,children:[Pt(CI,{children:[ee(of,{height:e,roundRadius:.5,radius:g,center:[-I,0,e]}),ee(of,{height:e,roundRadius:.5,radius:g,center:[I,0,e]})]}),Pt(CI,{children:[ee(of,{height:B,roundRadius:.1,radius:g+.85,center:[-I,0,e/2+B/2]}),ee(of,{height:B,roundRadius:.1,radius:g+.85,center:[I,0,e/2+B/2]})]})]}),Pt(ys,{color:r,children:[ee(tf,{height:n+e/2,radius:o/2,center:[-c+.06,0,-(n/2)+e/2]}),ee(tf,{height:n+e/2,radius:o/2,center:[c-.06,0,-(n/2)+e/2]})]})]})},opt=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:o="#111"})=>Pt(Ko,{children:[ee(ys,{color:e,children:Pt(fQ,{rotation:[0,"90deg",0],children:[ee(wL,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),ee(tf,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),ee(ys,{color:o,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(wL,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),ee(ys,{color:i,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),ee(ys,{color:i,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),npt=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Pt(Ko,{children:[ee(ys,{color:e,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),ee(ys,{color:i,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),ee(ys,{color:i,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),spt=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Pt(Ko,{children:[ee(ys,{color:e,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),ee(ys,{color:i,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),ee(ys,{color:i,children:ee(fQ,{rotation:[0,"90deg",0],children:ee(of,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),rpt=({pinCount:t,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t%2!==0)throw new Error("MS012 pinCount must be even");const o=t/2,n=4.9,s=3.9,r=(o-1)*i/2,a=.2;return Pt(Ko,{children:[Array.from({length:o}).map((g,I)=>ee(Oo,{position:{x:-s/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,I)=>ee(Oo,{rotation:Math.PI,position:{x:s/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),ee($B,{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})]})},apt=({pinCount:t=16,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t!==16)throw new Error("MS013 only supports 16 pins");const o=t/2,n=7.5,s=10.3,r=(o-1)*i/2,a=.2;return Pt(Ko,{children:[Array.from({length:o}).map((g,I)=>ee(Oo,{position:{x:-n/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,I)=>ee(Oo,{rotation:Math.PI,position:{x:n/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),ee($B,{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})]})},gpt=()=>{const Q=7.050000000000001,E=24.95+6.5/2;return ee(Zi,{center:[0,0,1],children:Pt(Ko,{children:[Pt(fQ,{rotation:[0,55,-55],children:[Pt(hF,{children:[ee(ut,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[E,0,1.3-2]}),ee(tf,{color:"black",center:[E,0,1.3-2],radius:3/2,height:1.3*1.2})]}),ee(ys,{color:"#222",children:ee($B,{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})})]}),ee(fQ,{rotation:[0,55,55],children:Array.from({length:3}).map((h,u)=>{const d=Q,f=(u-1)*2.7,m=-.5-.6;return Pt(ys,{color:"gold",children:[Pt(CI,{children:[ee(Zi,{center:[15.05-4.5/2+.1,f,m],children:ee(ut,{size:[4.5,.81+1,.5]})}),ee(Zi,{center:[15.05-4.5/2-1+.1,f,m],children:ee(ut,{size:[4.5,.81,.5]})})]}),ee(Zi,{center:[d,f,m],children:ee(ut,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},Ipt=()=>{const g=1.1999999999999997;return Pt(Ko,{children:[ee(Oo,{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}),ee(Oo,{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}),ee(Oo,{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}),ee(Oo,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),ee(Oo,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),ee(Oo,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),ee($B,{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})]})},cpt=()=>Pt(Ko,{children:[ee($B,{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 I=-.35+g*.35;return ee(ut,{center:[-.8/2+.19/2-.1,I,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(g=>{const I=-.35+g*.35;return ee(ut,{center:[.8/2-.19/2+.1,I,.12/2],size:[.19,.15,.12]})})]}),Bpt=()=>{const s="#222",a=[.43,.4,1.32],g=[.43,.4,.25],I=[0,0,-.66],c=[0,0,-1.32],B=[0,1.28,-2.72],l=[0,1.28,-8.9],C=-7.5;return Pt(Zi,{center:[0,1,10.5],children:[ee(ys,{color:s,children:Pt(hF,{children:[ee(Zi,{center:[0,0,2.25],children:ee(tf,{radius:2.4,height:4.5})}),ee(Zi,{center:[0,-1.8499999999999999,2.25],children:ee(ut,{size:[2.4*2,1.1,4.5+.2]})})]})}),ee(Zi,{center:I,children:ee(ut,{size:a})}),Pt(CI,{children:[ee(Zi,{center:c,children:ee(ut,{size:g})}),ee(Zi,{center:B,children:ee(ut,{size:g})})]}),ee(Zi,{center:l,children:ee(ut,{size:[.43,.4,12.2]})}),ee(Zi,{center:[1.3,0,C],children:ee(ut,{size:[.43,.4,15]})}),ee(Zi,{center:[-1.3,0,C],children:ee(ut,{size:[.43,.4,15]})})]})},lpt=()=>Pt(Ko,{children:[ee(Oo,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),ee(Oo,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),ee(Oo,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),ee(Oo,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),ee(Oo,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),ee(Oo,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),ee($B,{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})]}),Cpt=lpt,Qpt=()=>Pt(Ko,{children:[ee($B,{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 ee(ut,{center:[-1/2+.3/2,a,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(r=>{const a=-.5+r*.5;return ee(ut,{center:[1/2-.3/2,a,.05/2],size:[.3,.2,.05]})})]}),Ept=()=>Pt(Ko,{children:[ee(Oo,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),ee(Oo,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),ee(ys,{color:"#222",children:ee($B,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),ee(ut,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),hpt=()=>Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),ee(ut,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),ee(ys,{color:"#222",children:Pt(QE,{children:[ee(Zi,{z:.175/2,children:ee(ut,{size:[1.7,1.25,.175]})}),Pt(CI,{children:[ee(Zi,{z:.175,children:ee(ut,{size:[1.7,1.25,.01]})}),ee(Zi,{z:.725,children:ee(ut,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),ee(ut,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),upt=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return Pt(Ko,{children:[ee(ut,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),ee(ut,{color:"#ccc",size:[.4,.325,.13],center:[r,0,.13/2]}),ee(ys,{color:"#222",children:ee($B,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),ee(ut,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},dpt=({footprint:t})=>{const A=ndt.string(t).json();switch(A.fn){case"dip":return ee(Idt,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"tssop":return ee(Bdt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return ee(ldt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return ee(Ldt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return ee(hdt,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return ee(Xdt,{});case"lqfp":return ee(Apt,{pinCount:A.num_pins});case"qfn":{const o=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return ee(Ddt,{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 ee(tpt,{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=t.match(/_rows(\d+)/),n=o&&o[1]?parseInt(o[1],10):1;if(A.male)return ee(fdt,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:n});if(A.female)return ee(_dt,{numberOfPins:A.num_pins,pitch:A.p,rows:n})}case"cap":switch(A.imperial){case"0402":return ee(r9A,{color:"#856c4d"});case"0603":return ee(a9A,{color:"#856c4d"});case"0805":return ee(g9A,{color:"#856c4d"});case"0201":return ee(I9A,{color:"#856c4d"});case"01005":return ee(c9A,{color:"#856c4d"});case"1206":return ee(B9A,{color:"#856c4d"});case"1210":return ee(l9A,{color:"#856c4d"});case"2010":return ee(C9A,{color:"#856c4d"});case"2512":return ee(Q9A,{color:"#856c4d"})}case"sot235":return ee(bdt,{});case"sot457":return ee(Ipt,{});case"sot223":return ee(jdt,{});case"sot23w":return ee(xdt,{});case"sot323":return ee($dt,{});case"sod323f":return ee(hpt,{});case"sod323fl":return ee(upt,{});case"sot363":return ee(Cpt,{});case"sot886":return ee(Qpt,{});case"sot963":return ee(cpt,{});case"pushbutton":return ee(vdt,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return ee(Udt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return ee(Hdt,{});case"sod882":return ee(Ydt,{});case"sma":return ee(Jdt,{});case"smb":return ee(Tdt,{});case"smc":return ee(Kdt,{});case"smf":return ee(qdt,{});case"sod123f":return ee(Pdt,{});case"sod123fl":return ee(Odt,{});case"sod123w":return ee(Wdt,{});case"sod128":return ee(Zdt,{});case"sod323":return ee(Ept,{});case"sod923":return ee(Vdt,{});case"hc49":return ee(ipt,{});case"micromelf":return ee(opt,{});case"minimelf":return ee(npt,{});case"melf":return ee(spt,{});case"ms012":return ee(rpt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return ee(apt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return ee(ept,{});case"to220":return ee(gpt,{});case"to92":return ee(Bpt,{})}const e=t.match(/_color\(([^)]+)\)/),i=e?e[1]:void 0;switch(A.imperial){case"0402":return ee(r9A,{color:i});case"0603":return ee(a9A,{color:i});case"0805":return ee(g9A,{color:i});case"0201":return ee(I9A,{color:i});case"01005":return ee(c9A,{color:i});case"1206":return ee(B9A,{color:i});case"1210":return ee(l9A,{color:i});case"2010":return ee(C9A,{color:i});case"2512":return ee(Q9A,{color:i})}return null},ppt=t=>t&&typeof t=="object"&&"type"in t,f_=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const A=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(t);if(A)return parseFloat(A[1])*Math.PI/180;const e=Number(t);if(!Number.isNaN(e))return e}return 0},fpt=t=>Array.isArray(t)?[Number(t[0])||0,Number(t[1])||0,Number(t[2])||0]:typeof t=="object"&&t?[Number(t.x)||0,Number(t.y)||0,Number(t.z)||0]:[0,0,0];function Pm(t,A,e){const{jscad:{primitives:i,booleans:o,hulls:n,geometries:s,extrusions:r,transforms:a}}=e;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(B=>Pm(B,A,e));if(!ppt(t))return[];const{type:g,props:I,children:c}=t;if(g===i9A)return(c??[]).flatMap(B=>Pm(B,A,e));if(g===ys){const B=I?.color;return(c??[]).flatMap(l=>Pm(l,B??A,e))}if(g===Zi){const B=fpt(I?.offset??I?.center??{x:I?.x,y:I?.y,z:I?.z});return(c??[]).flatMap(C=>Pm(C,A,e)).map(({geom:C,color:Q})=>({geom:a.translate(B,C),color:Q??A}))}if(g===fQ){const B=Array.isArray(I?.rotation)?[f_(I.rotation[0]),f_(I.rotation[1]),f_(I.rotation[2])]:[f_(I?.x??0),f_(I?.y??0),f_(I?.z??0)];return(c??[]).flatMap(C=>Pm(C,A,e)).map(({geom:C,color:Q})=>({geom:a.rotateZ(B[2],a.rotateY(B[1],a.rotateX(B[0],C))),color:Q}))}if(g===QE||g===hF||g===CI){const B=(c??[]).flatMap(C=>Pm(C,A,e)).map(C=>C.geom);if(B.length===0)return[];let l;return g===QE?l=o.union(B):g===hF?l=o.subtract(B[0],B.slice(1)):l=n.hull(B),[{geom:l,color:A}]}if(g===mL){const B=I?.points??[];return[{geom:s.geom2.fromPoints(B),color:A??I?.color}]}if(g===DL){const B=(c??[]).flatMap(E=>Pm(E,A,e)).map(E=>E.geom);if(B.length===0)return[];const l=B.length>1?o.union(B):B[0],C=I?.height??I?.h??1;let Q=r.extrudeLinear({height:C},l);if(Q.polygons)for(const E of Q.polygons)!E.plane||!E.vertices||E.vertices.length<3||E.vertices.reverse();return[{geom:Q,color:A??I?.color}]}if(g===ut||g===o9A||g===tf||g===n9A||g===wL||g===of){let B;if(g===ut){const l=I?.size??[1,1,1],C=I?.offset,Q=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);B=i.cuboid({size:l,center:Q})}else if(g===o9A){const l=I?.size??1,C=I?.offset,Q=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);B=i.cube({size:l,center:Q})}else if(g===tf){const l=I?.height??1,C=I?.radius??1,Q=I?.center??[0,0,0];B=i.cylinder({height:l,radius:C,center:Q})}else if(g===n9A){const l=I?.radius??1,C=I?.center??[0,0,0];B=i.sphere({radius:l,center:C})}else if(g===of){const l=I?.height??1,C=I?.radius??1,Q=I?.roundRadius??.1,E=I?.center??[0,0,0];B=i.roundedCylinder({height:l,radius:C,roundRadius:Q,center:E})}else{const l=I?.size??[1,1,1],C=I?.roundRadius??.1,Q=I?.center??[0,0,0];B=i.roundedCuboid({size:l,roundRadius:C,center:Q})}return[{geom:B,color:A??I?.color}]}if(typeof g=="function"){const B=g(I??{});return Pm(B,A,e)}return(c??[]).flatMap(B=>Pm(B,A,e))}function ypt(t,A){return{geometries:Pm(t,void 0,{jscad:A})}}function E9A(t){if(t.polygons){const A=[],e=[],i=[];let o=0;for(const s of t.polygons){for(const a of s.vertices)a.index=o,A.push(a[0],a[1],a[2]),t.color&&t.color.length>=3?i.push(t.color[0],t.color[1],t.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,I=s.vertices[a].index;e.push(r,g,I)}}const n=new mg;if(n.setAttribute("position",new BI(new Float32Array(A),3)),n.setIndex(e),i.length>0&&n.setAttribute("color",new BI(new Float32Array(i),3)),t.transforms){const s=new es;s.fromArray(t.transforms),n.applyMatrix4(s)}return n.computeVertexNormals(),n}if(t.sides){const A=[],e=[];for(const o of t.sides)A.push(o[0][0],o[0][1],0),t.color&&t.color.length>=3?e.push(t.color[0],t.color[1],t.color[2]):e.push(1,1,1);const i=new mg;if(i.setAttribute("position",new BI(new Float32Array(A),3)),e.length>0&&i.setAttribute("color",new BI(new Float32Array(e),3)),t.transforms){const o=new es;o.fromArray(t.transforms),i.applyMatrix4(o)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new mg}function wpt(t,A){const e=CCA(dpt,{footprint:t});return ypt(e,A)}var mpt=_r(q5()),h9A=j.createContext(null),Dpt=()=>{const t=j.useContext(h9A);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},Spt=({children:t})=>{const{camera:A,renderer:e}=Ru(),[i,o]=j.useState([]),n=j.useMemo(()=>new c6e,[]),s=j.useMemo(()=>new so,[]),r=j.useRef(i);r.current=i;const a=j.useRef(null),g=j.useCallback(C=>{o(Q=>[...Q,C])},[]),I=j.useCallback(C=>{if(a.current){let Q=!1,E=a.current.object;for(;E;){if(E===C){Q=!0;break}E=E.parent}Q&&(a.current.onUnhover(),a.current=null)}o(Q=>Q.filter(E=>E.object!==C))},[]),c=j.useCallback(C=>{let Q=C;for(;Q;){const E=r.current.find(h=>h.object===Q);if(E)return E;Q=Q.parent}},[]),B=j.useCallback(C=>{if(!e.domElement)return;const Q=e.domElement.getBoundingClientRect();s.x=(C.clientX-Q.left)/Q.width*2-1,s.y=-((C.clientY-Q.top)/Q.height)*2+1,n.setFromCamera(s,A);const E=r.current.map(u=>u.object);if(E.length===0){a.current&&(a.current.onUnhover(),a.current=null);return}const h=n.intersectObjects(E,!0);if(h.length>0){const u=h[0],d=c(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,e,n,s,c]);j.useEffect(()=>{const C=e.domElement;return C.addEventListener("mousemove",B),()=>{C.removeEventListener("mousemove",B)}},[e,B]);const l=j.useMemo(()=>({addHoverable:g,removeHoverable:I}),[g,I]);return O.jsx(h9A.Provider,{value:l,children:t})},bpt=({children:t,object:A,onHover:e,onUnhover:i,isHovered:o})=>{const{addHoverable:n,removeHoverable:s}=Dpt();return j.useEffect(()=>A?(n({object:A,onHover:e,onUnhover:i}),()=>{s(A)}):void 0,[A,e,i,n,s]),O.jsx(O.Fragment,{children:t})},NL=bpt,xpt=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=Ru(),g=j.useMemo(()=>{if(!A)return null;const{geometries:I}=wpt(A,mpt),c=new ef;for(const B of I.flat(1/0)){const l=B.geom;if(!l||!l.polygons&&!l.sides)continue;const C=new Li(B.color);C.convertLinearToSRGB();const Q={...l,color:[C.r,C.g,C.b]},E=E9A(Q),h=new hh({vertexColors:!0,side:Tl,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new Vo(E,h);c.add(u)}return c},[A,r]);return j.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),j.useEffect(()=>{g&&(t&&g.position.fromArray(t),e&&g.rotation.fromArray(e),s!==void 0&&g.scale.setScalar(s))},[g,t?.[0],t?.[1],t?.[2],e?.[0],e?.[1],e?.[2],s]),j.useEffect(()=>{g&&g.traverse(I=>{I instanceof Vo&&I.material instanceof hh&&(n?(I.material.emissive.setHex(255),I.material.emissiveIntensity=.2):I.material.emissiveIntensity=0)})},[n,g]),g?O.jsx(NL,{isHovered:n,onHover:i,onUnhover:o,object:g}):null},u9A=new WeakMap,kpt=()=>{const t=new Jc;return t.name="fallback-environment-map",t.mapping=AO,t},Gpt=t=>{if(!t)return null;const A=t,e=u9A.get(A);if(e)return e;let i;if(t instanceof RO){const o=new loA(t);i=o.fromScene(_6e(),.04).texture,o.dispose()}else i=kpt();return u9A.set(A,i),i},d9A=1.25;function p9A({gltfUrl:t,position:A,rotation:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=Ru(),[I,c]=j.useState(null),[B,l]=j.useState(null);if(j.useEffect(()=>{if(!t)return;const C=new U6e;let Q=!0;return C.load(t,E=>{if(!Q)return;const h=E.scene;h.traverse(u=>{if(u instanceof Vo&&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)}}),c(h)},void 0,E=>{if(!Q)return;console.error(`An error happened loading ${t}`,E);const h=E instanceof Error?E:new Error(`Failed to load glTF model from ${t}`);l(h)}),()=>{Q=!1}},[t,r]),j.useEffect(()=>{I&&(A&&I.position.fromArray(A),e&&I.rotation.fromArray(e),s!==void 0&&I.scale.setScalar(s))},[I,A?.[0],A?.[1],A?.[2],e?.[0],e?.[1],e?.[2],s]),j.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),j.useEffect(()=>{if(!I||!a)return;const C=Gpt(a);if(!C)return;const Q=[],E=h=>{h instanceof hh&&(Q.push({material:h,envMap:h.envMap??null,envMapIntensity:h.envMapIntensity??1}),h.envMap=C,(typeof h.envMapIntensity!="number"||h.envMapIntensity<d9A)&&(h.envMapIntensity=d9A),h.needsUpdate=!0)};return I.traverse(h=>{if(!(h instanceof Vo))return;const u=h.material;Array.isArray(u)?u.forEach(E):u&&E(u)}),()=>{Q.forEach(({material:h,envMap:u,envMapIntensity:d})=>{h.envMap=u,h.envMapIntensity=d,h.needsUpdate=!0})}},[I,a]),j.useEffect(()=>{I&&I.traverse(C=>{C instanceof Vo&&C.material instanceof hh&&(n?(C.material.emissive.setHex(255),C.material.emissiveIntensity=.2):C.material.emissiveIntensity=0)})},[n,I]),B)throw B;return I?O.jsx(NL,{isHovered:n,onHover:i,onUnhover:o,object:I}):null}var Fpt=_r(OZA()),Rpt=_r(q5()),Mpt=({jscadPlan:t,positionOffset:A,rotationOffset:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=Ru(),{threeGeom:g,material:I}=j.useMemo(()=>{const B=(0,Fpt.executeJscadOperations)(Rpt.default,t);if(!B||!B.polygons&&!B.sides)return{threeGeom:null,material:null};const l=E9A(B),C=new hh({vertexColors:!0,side:Tl,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:l,material:C}},[t,r]),c=j.useMemo(()=>g?new Vo(g,I):null,[g,I]);return j.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),j.useEffect(()=>{c&&(A&&c.position.fromArray(A),e&&c.rotation.fromArray(e),s!==void 0&&c.scale.setScalar(s))},[c,A?.[0],A?.[1],A?.[2],e?.[0],e?.[1],e?.[2],s]),j.useMemo(()=>{if(I)if(n){const B=new Li(I.color.getHex());I.emissive.copy(B),I.emissive.setRGB(0,0,1),I.emissiveIntensity=.2}else I.emissiveIntensity=0},[n,I]),g?O.jsx(NL,{isHovered:n,onHover:i,onUnhover:o,object:c}):null};function Npt(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(A,e,i)=>`${e} ${i.replace(/-/g,"_")}`)}async function _pt(t){const A=await fetch(t);if(!A.ok)throw new Error(`Failed to fetch "${t}": ${A.status} ${A.statusText}`);const e=await A.text();return new y7e().parse(Npt(e),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function vpt(t){const[A,e]=j.useState(null);return j.useEffect(()=>{if(!t)return;const i=t.replace(/&cachebust_origin=$/,""),o=window.TSCIRCUIT_OBJ_LOADER_CACHE;let n=!1;async function s(){try{if(i.endsWith(".wrl"))return await _pt(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(),I=g.match(/newmtl[\s\S]*?endmtl/g),c=new F7e;if(I?.length){const B=I.join(`
|
|
5071
|
+
`).replace(/d 0\./g,"d 1."),l=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new d7e;C.setMaterialOptions({invertTrProperty:!0});const Q=C.parse(B.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return c.setMaterials(Q),c.parse(l)}return c.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(I=>I instanceof Error?I:I.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||e(a)}).catch(a=>{console.error(a)}),()=>{n=!0}},[t]),A}function Upt({url:t,position:A,rotation:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const a=vpt(t),{rootObject:g}=Ru(),I=j.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(c=>{if(c instanceof Vo&&c.material){const B=l=>{l.transparent=r,l.opacity=r?.5:1,l.depthWrite=!r,l.needsUpdate=!0};Array.isArray(c.material)?c.material.forEach(B):B(c.material)}}),a):new Vo(new Fw(.5,.5,.5),new hh({transparent:!0,color:"red",opacity:.25})),[a,r]);if(j.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),j.useEffect(()=>{I&&(A&&(Array.isArray(A)?I.position.fromArray(A):I.position.copy(A)),e&&(Array.isArray(e)?I.rotation.fromArray(e):I.rotation.copy(e)),s!==void 0&&I.scale.setScalar(s))},[I,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,s]),a instanceof Error)throw a;return O.jsx(NL,{isHovered:n,onHover:i,onUnhover:o,object:I})}var NCA,Lpt="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function Hpt(t){if(typeof t=="function")return t;if(t&&typeof t=="object"&&"default"in t&&typeof t.default=="function")return t.default;throw new Error("Unable to resolve occt-import-js factory export")}async function Ypt(){if(!NCA){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");NCA=Hpt(t)({locateFile:e=>`${Lpt}/${e}`})}return NCA}function Jpt(t){const A=new ef;for(const e of t){const i=e.attributes.position?.array??[],o=e.index?.array??[];if(!i.length||!o.length)continue;const n=new mg;n.setAttribute("position",new Un(i,3));const s=e.attributes.normal?.array??[];s.length?n.setAttribute("normal",new Un(s,3)):n.computeVertexNormals(),n.setIndex(o);const r=new hh({color:e.color?new Li(e.color[0],e.color[1],e.color[2]):new Li(.82,.82,.82)}),a=new Vo(n,r);a.name=e.name,A.add(a)}return A}async function Tpt(t){const A=await fetch(t);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const e=await A.arrayBuffer(),o=(await Ypt()).ReadStepFile(new Uint8Array(e),null);if(!o.success||!o.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const n=Jpt(o.meshes),s=new qoA,r=await new Promise((a,g)=>{s.parse(n,I=>{I instanceof ArrayBuffer?a(I):g(new Error("GLTFExporter did not return binary output"))},I=>{g(I)},{binary:!0})});return URL.createObjectURL(new Blob([r],{type:"model/gltf-binary"}))}var f9A="step-glb-cache:";function Kpt(t){const A=new Uint8Array(t),e=32768;let i="";for(let o=0;o<A.length;o+=e){const n=A.subarray(o,o+e);i+=String.fromCharCode(...n)}return btoa(i)}function qpt(t){const A=atob(t),e=new Uint8Array(A.length);for(let i=0;i<A.length;i+=1)e[i]=A.charCodeAt(i);return e.buffer}function Ppt(t){try{const A=localStorage.getItem(`${f9A}${t}`);return A?qpt(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function Opt(t,A){try{const e=Kpt(A);localStorage.setItem(`${f9A}${t}`,e)}catch(e){console.warn("Failed to write STEP GLB cache",e)}}var Wpt=({stepUrl:t,position:A,rotation:e,scale:i,onHover:o,onUnhover:n,isHovered:s,isTranslucent:r})=>{const[a,g]=j.useState(null);return j.useEffect(()=>{let I=!0,c=null;const B=Ppt(t);return B?(c=URL.createObjectURL(new Blob([B],{type:"model/gltf-binary"})),g(c),()=>{I=!1,c&&URL.revokeObjectURL(c)}):(Tpt(t).then(l=>{if(!I){URL.revokeObjectURL(l);return}c=l,g(l),fetch(l).then(C=>C.arrayBuffer()).then(C=>{Opt(t,C)}).catch(C=>{console.warn("Failed to cache STEP GLB",C)})}).catch(l=>{console.error("Failed to convert STEP file to GLB",l),I&&g(null)}),()=>{I=!1,c&&URL.revokeObjectURL(c)})},[t]),a?O.jsx(p9A,{gltfUrl:a,position:A,rotation:e,scale:i,onHover:o,onUnhover:n,isHovered:s,isTranslucent:r}):null},_CA=(...t)=>t,y9A=({cad_component:t,circuitJson:A})=>{const e=VZA(A),[i,o]=j.useState(!1),{visibility:n}=r_(),[s,r]=j.useState(null),a=j.useCallback(f=>{f?.mousePosition?(o(!0),r(f.mousePosition)):(o(!1),r(null))},[]),g=j.useCallback(()=>{o(!1),r(null)},[]),I=j.useMemo(()=>mi(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),c=j.useMemo(()=>A.filter(m=>m.type==="pcb_plated_hole"&&m.pcb_component_id===t.pcb_component_id).length>0,[A,t.pcb_component_id]),B=t.model_obj_url??t.model_wrl_url??t.model_stl_url,l=t.model_glb_url??t.model_gltf_url,C=t.model_step_url,E=A.find(f=>f.type==="pcb_component"&&f.source_component_id===t.source_component_id)?.layer??"top",h=j.useMemo(()=>{const f=t.rotation?_CA(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):_CA(0,0,0);return E==="bottom"?_CA(f[0]+Math.PI,f[1],-f[2]):f},[t.rotation,E]),u=j.useMemo(()=>{if(!t.position)return;const f=.55;let m;return E==="top"?m=e/2:E==="bottom"?m=-(e/2)-f:m=t.position.z,[t.position.x,t.position.y,m]},[t.position,E,e]);let d=null;if(B?d=O.jsx(Upt,{url:B,position:u,rotation:h,scale:t.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:t.show_as_translucent_model},t.cad_component_id):l?d=O.jsx(p9A,{gltfUrl:l,position:u,rotation:h,scale:t.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:t.show_as_translucent_model},t.cad_component_id):C&&!t.model_jscad&&!t.footprinter_string?d=O.jsx(Wpt,{stepUrl:C,position:u,rotation:h,scale:t.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:t.show_as_translucent_model}):t.model_jscad?d=O.jsx(Mpt,{jscadPlan:t.model_jscad,positionOffset:u,rotationOffset:h,scale:t.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(d=O.jsx(xpt,{positionOffset:u,rotationOffset:h,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:a,onUnhover:g,isHovered:i,isTranslucent:t.show_as_translucent_model})),t.show_as_translucent_model){if(!n.translucentModels)return null}else if(c&&!n.throughHoleModels||!c&&!n.smtModels)return null;return O.jsxs(O.Fragment,{children:[d,i&&s?O.jsx(zZA,{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:I??"<unknown>"}):null]})},w9A={version:"0.0.500"};function Zpt(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var Vpt=t=>{t.outputColorSpace=yw,t.toneMapping=MLA,t.toneMappingExposure=1},m9A="cadViewerCameraStateSession",D9A=(t,A)=>{try{const e={position:t.position.toArray(),quaternion:t.quaternion.toArray(),up:t.up.toArray(),fov:t.fov??50,target:A.target.toArray()};sessionStorage.setItem(m9A,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},vCA=(t,A)=>{try{const e=sessionStorage.getItem(m9A);if(!e)return!1;const i=JSON.parse(e);if(t.position.fromArray(i.position),t.quaternion.fromArray(i.quaternion),t.up.fromArray(i.up),"fov"in t){const o=t;o.fov=i.fov,o.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),t.updateMatrixWorld(),!0}catch(e){return console.warn("Failed to restore camera:",e),!1}},S9A=j.createContext(void 0),jpt=({children:t,defaultTarget:A,initialCameraPosition:e})=>{const i=j.useRef(null),o=j.useRef(null),[n,s]=j.useState(null),[r,a]=j.useState("perspective"),[g,I]=j.useState(e??null),[c,B]=j.useState(new $p(0,0,0)),l=j.useMemo(()=>{const[h,u,d]=e??[5,-5,5],f=Math.hypot(h-A.x,u-A.y,d-A.z);return f>0?f:5},[e,A]),C=j.useCallback(h=>{const u=[A.x,A.y,A.z],d=o.current,f=i.current;let m=l;switch(d&&f&&(m=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const S=m/Math.sqrt(2);return{position:[A.x,A.y-S,A.z+S],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}},[l,A,o,i]),Q=j.useCallback(h=>{i.current=h},[]),E=j.useMemo(()=>({controlsRef:i,mainCameraRef:o,defaultTarget:A,baseDistance:l,controller:n,setController:s,getPresetConfig:C,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:I,cameraRotation:c,setCameraRotation:B,saveCameraToSession:D9A,loadCameraFromSession:vCA}),[A,l,n,C,Q,r,g,c]);return O.jsx(S9A.Provider,{value:E,children:t})},Hx=()=>{const t=j.useContext(S9A);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},zpt=j.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:o},n)=>{const{cameraType:s}=Hx(),r=j.useRef(null),[a,g]=j.useState(null),I=j.useRef([]),c=j.useRef(void 0);c.current=o;const B=j.useRef(null),l=j.useCallback(h=>{I.current.push(h)},[]),C=j.useCallback(h=>{I.current=I.current.filter(u=>u!==h)},[]),Q=j.useMemo(()=>new $G,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const E=j.useRef(new wg);return j.useImperativeHandle(n,()=>E.current),j.useEffect(()=>{if(!r.current)return;Zpt(r.current);const h=new RO({antialias:!0,alpha:!0});Vpt(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 CE(75,u,.1,1e3):new FU(-10*u,10*u,10,-10,-1e3,1e3);B.current?(d.position.copy(B.current.position),d.quaternion.copy(B.current.quaternion),d.up.copy(B.current.up)):(e?.up&&d.up.set(e.up[0],e.up[1],e.up[2]),e?.position&&d.position.set(e.position[0],e.position[1],e.position[2]),d.lookAt(0,0,0)),Q.add(E.current),window.__TSCIRCUIT_THREE_OBJECT=E.current,g({scene:Q,camera:d,renderer:h,rootObject:E.current,addFrameListener:l,removeFrameListener:C}),c.current?.({camera:d,renderer:h});let f;const m=new e6e,S=()=>{const x=m.getElapsedTime(),F=m.getDelta();I.current.forEach(k=>k(x,F)),h.render(Q,d),f=requestAnimationFrame(S)};S();const D=()=>{if(r.current){const x=r.current.clientWidth/r.current.clientHeight;d instanceof CE?d.aspect=x:d instanceof FU&&(d.left=-10*x,d.right=10*x,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),h.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",D),()=>{B.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",D),cancelAnimationFrame(f),r.current&&h.domElement&&r.current.removeChild(h.domElement),h.dispose(),Q.remove(E.current),window.__TSCIRCUIT_THREE_OBJECT===E.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,l,C,s]),O.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&O.jsx(jZA.Provider,{value:a,children:O.jsx(Spt,{children:t})})})}),Xpt=({autoRotate:t,autoRotateSpeed:A,onStart:e,panSpeed:i,rotateSpeed:o,zoomSpeed:n,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:I,renderer:c}=Ru(),B=j.useMemo(()=>!I||!c?null:new M7e(I,c.domElement),[I,c]);return j.useEffect(()=>(g?.(B??null),()=>g?.(null)),[B,g]),j.useEffect(()=>{if(!B)return;const l=()=>{g?.(B)};return B.addEventListener("change",l),()=>{B.removeEventListener("change",l)}},[B,g]),j.useEffect(()=>{B&&(B.autoRotate=t||!1,B.autoRotateSpeed=A||1,i!==void 0&&(B.panSpeed=i),o!==void 0&&(B.rotateSpeed=o),n!==void 0&&(B.zoomSpeed=n),s!==void 0&&(B.enableDamping=s),r!==void 0&&(B.dampingFactor=r),B.zoomToCursor=!0,B.mouseButtons={LEFT:Qx.ROTATE,MIDDLE:Qx.PAN,RIGHT:null},a&&(B.target.set(a[0],a[1],a[2]),B.update()))},[B,t,A,i,o,n,s,r,a]),j.useEffect(()=>{if(!(!B||!e))return B.addEventListener("start",e),()=>{B.removeEventListener("start",e)}},[B,e]),j.useEffect(()=>{if(B)return()=>{B.dispose()}},[B]),pL(()=>{B?.update()},[B]),null},$pt=`
|
|
5072
5072
|
varying vec3 worldPosition;
|
|
5073
5073
|
void main() {
|
|
5074
5074
|
worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
@@ -5102,12 +5102,12 @@ ${a.join(`
|
|
|
5102
5102
|
gl_FragColor = vec4(color, max(g1, g2) * a);
|
|
5103
5103
|
if (gl_FragColor.a <= 0.0) discard;
|
|
5104
5104
|
}
|
|
5105
|
-
`,eft=({rotation:t,infiniteGrid:A,cellSize:e=1,sectionSize:i=10})=>{const{scene:o,camera:n}=Ru(),s=1e3,r=j.useMemo(()=>{const a=new Rw(s,s);a.rotateX(-Math.PI/2);const g=new _m({vertexShader:$pt,fragmentShader:Aft,uniforms:{cellSize:{value:e},sectionSize:{value:i},gridColor:{value:new Li(15658734)},sectionColor:{value:new Li(13421823)},fadeDistance:{value:100},fadeStrength:{value:1.5}},transparent:!0,side:Tl}),I=new Vo(a,g);return t&&I.rotation.fromArray(t),I},[s,e,i,t]);return pL(()=>{A&&r.position.set(n.position.x,n.position.y,0)}),j.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},tft=()=>{const{scene:t}=Ru(),A=j.useMemo(()=>new tJA(16777215,Math.PI/2),[]),e=j.useMemo(()=>{const i=new UoA(16777215,Math.PI/4);return i.position.set(-10,-10,10),i.decay=0,i},[]);return j.useEffect(()=>{if(t)return t.add(A),t.add(e),()=>{t.remove(A),t.remove(e)}},[t,A,e]),null},ift=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,oft=()=>{const{controlsRef:t,mainCameraRef:A,defaultTarget:e,setController:i,getPresetConfig:o}=Hx(),n=j.useRef(null),s=j.useRef(new Sd),r=j.useRef(new Me),a=j.useRef(new Me),g=j.useRef(new Sd),I=j.useRef(new Sd),c=j.useRef(new wg),B=j.useRef(new wg),l=j.useCallback(({position:Q,target:E,up:h,durationMs:u=600})=>{if(!A.current)return;const d=t.current?.target??e,f=new Me(Q[0],Q[1],Q[2]),m=E?new Me(E[0],E[1],E[2]):e.clone(),S=new Me(...h??[0,0,1]).normalize(),D=B.current;D.position.copy(f),D.up.copy(S),D.lookAt(m);const x=D.quaternion.clone(),F=A.current.quaternion.clone(),k=A.current.position.clone(),v=d.clone(),_=c.current;_.up.set(0,0,1),_.position.copy(k),_.lookAt(v);const H=_.quaternion.clone();_.up.set(0,0,1),_.position.copy(f),_.lookAt(m);const P=_.quaternion.clone(),J=H.clone().invert().multiply(F).normalize(),W=P.clone().invert().multiply(x).normalize();n.current={fromPosition:k,toPosition:f,fromTarget:v,toTarget:m,toQuaternion:x,rollFrom:J,rollTo:W,startTime:performance.now(),duration:u}},[A,t,e]),C=j.useCallback(Q=>{if(Q==="Custom")return;const E=o(Q);E&&l(E)},[l,o]);return j.useEffect(()=>A.current?(i({animateTo:l,animateToPreset:C}),()=>{i(null)}):void 0,[l,C,A,i]),pL(()=>{if(!A.current||!n.current)return;const{fromPosition:Q,toPosition:E,fromTarget:h,toTarget:u,toQuaternion:d,rollFrom:f,rollTo:m,startTime:S,duration:D}=n.current,x=performance.now()-S,F=D<=0?1:Math.min(x/D,1),k=ift(F);A.current.position.lerpVectors(Q,E,k);const v=r.current;v.copy(h).lerp(u,k);const _=c.current;_.up.set(0,0,1),_.position.copy(A.current.position),_.lookAt(v);const H=s.current;H.copy(_.quaternion);const P=g.current;P.copy(f);const J=I.current;J.copy(m),f.dot(m)<0&&(J.x*=-1,J.y*=-1,J.z*=-1,J.w*=-1),J.normalize(),P.slerp(J,k),A.current.quaternion.copy(H).multiply(P).normalize();const W=a.current;W.set(0,1,0).applyQuaternion(A.current.quaternion).normalize(),A.current.up.copy(W),t.current?.target.copy(v),A.current.updateMatrixWorld(),t.current?.update(),F>=1&&(A.current.position.copy(E),A.current.quaternion.copy(d),A.current.up.set(0,0,1),A.current.updateMatrixWorld(),t.current?.target.copy(u),t.current?.update(),n.current=null)}),null},nft=()=>{const{controlsRef:t}=Hx(),A=j.useRef(null),e=j.useRef(!1),i=j.useRef(null),o=j.useCallback(s=>{A.current=s,!e.current&&t.current&&vCA(s,t.current)&&(e.current=!0)},[t]),n=j.useCallback(()=>{if(!(!A.current||!t.current)){if(!e.current&&vCA(A.current,t.current)){e.current=!0;return}clearTimeout(i.current),i.current=setTimeout(()=>{A.current&&t.current&&D9A(A.current,t.current)},150)}},[t]);return{handleCameraCreated:o,handleControlsChange:n}};function sft(t,A){const e=new Sd().setFromEuler(new $p(t.x,t.y,t.z)),i=new Me(0,0,1);return i.applyQuaternion(e),i.multiplyScalar(A)}var rft=()=>{const{mainCameraRef:t}=Hx(),A=j.useRef(null),e=j.useRef(null),i=j.useRef(null),o=j.useRef(null),n=j.useRef(null),s=j.useRef(null);return j.useEffect(()=>{if(!A.current)return;const r=document.createElement("canvas");e.current=r,A.current.appendChild(r);const a=new RO({canvas:r,antialias:!0,alpha:!0});a.setSize(120,120),a.setPixelRatio(window.devicePixelRatio),i.current=a;const g=new $G;o.current=g;const I=new CE(75,1,.1,1e3);I.up.set(0,0,1),n.current=I;const c=new tJA(16777215,Math.PI/2);g.add(c);const B=new ef;B.rotation.fromArray([Math.PI/2,0,0]);const l=1,C=new Vo(new Fw(l,l,l),new hh({color:"white"}));B.add(C);const Q=new vU(new uXe(new Fw(l,l,l)),new AF({color:0,linewidth:2}));B.add(Q),g.add(B);const E=.51,h=(F,k,v)=>{const _=new gnA;return _.text=F,_.position.fromArray(k),v&&_.rotation.fromArray(v),_.color="black",_.fontSize=.25,_.anchorX="center",_.anchorY="middle",_.depthOffset=0,_.font=null,_.sync(),_},u=h("Front",[0,0,E]),d=h("Back",[0,0,-E],[0,Math.PI,0]),f=h("Right",[E,0,0],[0,Math.PI/2,0]),m=h("Left",[-E,0,0],[0,-Math.PI/2,0]),S=h("Top",[0,E,0],[-Math.PI/2,0,0]),D=h("Bottom",[0,-E,0],[Math.PI/2,0,0]);B.add(u),B.add(d),B.add(f),B.add(m),B.add(S),B.add(D);const x=()=>{if(t.current){const F=sft(t.current.rotation??new $p(0,0,0),2);F.equals(I.position)||(I.position.copy(F),I.lookAt(0,0,0))}a.render(g,I),s.current=requestAnimationFrame(x)};return x(),()=>{s.current&&cancelAnimationFrame(s.current),u.dispose(),d.dispose(),f.dispose(),m.dispose(),S.dispose(),D.dispose(),C.geometry.dispose(),C.material.dispose(),Q.geometry.dispose(),Q.material.dispose(),g.clear(),a.dispose(),e.current&&A.current&&A.current.removeChild(e.current)}},[t]),O.jsx("div",{ref:A,style:{position:"absolute",top:0,left:0,width:120,height:120,zIndex:fL.orientationCube}})},aft=()=>{const{camera:t}=Ru(),{setCameraRotation:A}=Hx();return pL(()=>{t&&A(t.rotation)}),null},b9A=j.forwardRef(({children:t,initialCameraPosition:A=[5,-5,5],autoRotateDisabled:e,clickToInteractEnabled:i=!1,boardDimensions:o,boardCenter:n,onUserInteraction:s,onCameraControllerReady:r},a)=>{const[g,I]=j.useState(!i),{mainCameraRef:c,handleControlsChange:B,controller:l}=Hx(),{handleCameraCreated:C,handleControlsChange:Q}=nft();j.useEffect(()=>{r&&r(l)},[l,r]);const E=j.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=j.useMemo(()=>{if(n)return[n.x,n.y,0]},[n]);return O.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[O.jsx(rft,{}),O.jsxs(zpt,{ref:a,scene:{up:new Me(0,0,1)},camera:{up:[0,0,1],position:A},onCreated:({camera:u})=>{c.current=u,C(u)},children:[O.jsx(oft,{}),O.jsx(aft,{}),g&&O.jsx(Xpt,{autoRotate:!e,autoRotateSpeed:1,onStart:s,rotateSpeed:.5,panSpeed:.75,zoomSpeed:.5,enableDamping:!0,dampingFactor:.1,target:h,onControlsChange:u=>{B(u),Q()}}),O.jsx(tft,{}),O.jsx(eft,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:3,sectionSize:E,args:[E,E]}),t]}),O.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:["@",w9A.version]}),i&&!g&&O.jsx("button",{type:"button",onClick:()=>I(!0),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&I(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:fL.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center"},children:O.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"})})]})}),x9A=t=>j.useMemo(()=>{if(!t)return[];const A=new l3e;return A.add(t),A.render(),A.getCircuitJson()},[t]),gft=t=>{const[A,e]=j.useState([]),[i,o]=j.useState(!0);return j.useEffect(()=>{if(!t)return;(async()=>{o(!0);const r=(Array.isArray(t)?t:[t]).map(async(a,g)=>{const I=Fot.serialize({binary:!0},[a]),B=await new Blob(I).arrayBuffer(),C=a.layerType||(g===0?"board":void 0);return{stlData:B,color:a.color,layerType:C}});try{const a=await Promise.all(r);e(a)}catch(a){console.error("Error generating STLs:",a),e([])}finally{o(!1)}})()},[t]),{stls:A,loading:i}},Ift=_r(vx()),cft=_r(v5()),mo=.01,ig={traces:.001,copper:.002},Fo={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]},nf=.001,ql=32,_L=.035,hc=150,i8=.6,UCA={fr1:Fo.fr1Tan,fr4:Fo.fr4Tan},Bft={fr1:Fo.fr1TracesWithMaskCopper,fr4:Fo.fr4TracesWithoutMaskTan},k9A={fr1:Fo.fr1SolderMaskGreen,fr4:Fo.fr4SolderMaskGreen},lft=_r(dL()),Cft=_r(vx()),Qft=_r(QF()),Eft=_r(TZA()),LCA=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1]}return A/2<=0},HCA=(t,A=1.2,e={})=>{const{xyOutset:i=0}=e,{outline:o}=t;let n=o.map(a=>[a.x,a.y]);LCA(n)&&(n=n.reverse());let s=(0,Cft.polygon)({points:n});i!==0&&(s=(0,Eft.expand)({delta:i,corners:"edge"},s));let r=(0,lft.extrudeLinear)({height:A},s);return r=(0,Qft.translate)([0,0,-A/2],r),r},hft=t=>{const A=t.filter(a=>a.type==="pcb_panel"),e=mi(t).pcb_board.list();let i,o=1.2;if(A.length>0)i=A[0],o=e.find(g=>g.pcb_panel_id===i.pcb_panel_id)?.thickness??1.2;else{if(i=e.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=HCA({outline:i.outline},o):n=(0,Ift.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?e.find(a=>a.pcb_panel_id===i.pcb_panel_id)?.material??"fr4":"fr4",r=UCA[s]??Fo.fr4Tan;return[(0,cft.colorize)(r,n)]},Al=_r(QF()),Ya=_r(vx()),fh=_r(v5()),og=_r(s_()),$s=_r(vx()),Om=_r(v5()),Xr=_r(s_()),G9A=_r(QF()),vL=_r(dL()),Fd=_r(QF()),uft=1e-5;function l0(t,A,e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return 0;const i=t/2,o=A/2,n=Math.min(i,o)-2*uft;return Math.max(0,Math.min(e,n))}function GC(t){if(!(!t||typeof t!="object"))return t.corner_radius??t.cornerRadius??t.rect_pad_border_radius??t.rectPadBorderRadius??t.rect_border_radius??t.rectBorderRadius??void 0}var Yx=_r(vx()),dft=_r(dL()),o8=_r(QF()),pft=_r(s_()),fft=64,yft=(t,A,e)=>{const i=(0,Yx.ellipse)({center:[0,0],radius:[Math.max(t/2,mo/2),Math.max(A/2,mo/2)],segments:fft}),o=(0,dft.extrudeLinear)({height:e},i);return(0,o8.translate)([0,0,-e/2],o)},wft=(t,A,e)=>{const i=Math.max(t,mo),o=Math.max(A,mo);if(Math.abs(i-o)<1e-6)return(0,Yx.cylinder)({center:[0,0,0],radius:i/2,height:e});const n=i>=o,s=n?i:o,r=n?o:i,a=Math.max(s-r,0),g=(0,Yx.cuboid)({center:[0,0,0],size:n?[a,r,e]:[r,a,e]});if(a<=1e-6)return(0,Yx.cylinder)({center:[0,0,0],radius:r/2,height:e});const I=a/2,c=(0,Yx.cylinder)({center:n?[-I,0,0]:[0,-I,0],radius:r/2,height:e}),B=(0,Yx.cylinder)({center:n?[I,0,0]:[0,I,0],radius:r/2,height:e});return(0,pft.union)(g,c,B)},n8=(t,A,e={})=>{const i=t.hole_shape||"circle",o=e.sizeDelta??0,n=t.hole_offset_x||0,s=t.hole_offset_y||0,r=[t.x+n,t.y+s,0];if(i==="circle"){const l=Math.max((t.hole_diameter??0)+o,mo),C=Math.max(l/2,mo/2);return(0,Yx.cylinder)({center:r,radius:C,height:A})}const a=t.hole_width??t.hole_diameter,g=t.hole_height??t.hole_diameter;if(!a||!g)return null;const I=Math.max(a+o,mo),c=Math.max(g+o,mo);if(i==="oval"){const l=yft(I,c,A);return(0,o8.translate)([r[0],r[1],0],l)}if(i==="pill"||i==="rotated_pill"){let l=wft(I,c,A);if(!l)return null;const C=t.ccw_rotation||0;return C&&(l=(0,o8.rotateZ)(C*Math.PI/180,l)),(0,o8.translate)(r,l)}const B=Math.max((t.hole_diameter??a??g??mo)+o,mo);return(0,Yx.cylinder)({center:r,radius:B/2,height:A})},C0=.02,s8=64,uF=(t,A)=>A?(0,Xr.intersect)(A,t):t,y_=({width:t,height:A,thickness:e,center:i,borderRadius:o})=>{const n=l0(t,A,o);if(n<=0)return(0,$s.cuboid)({center:i,size:[t,A,e]});const s=(0,$s.roundedRectangle)({size:[t,A],roundRadius:n,segments:s8}),r=(0,vL.extrudeLinear)({height:e},s),a=i[2]-e/2;return(0,Fd.translate)([i[0],i[1],a],r)},UL=(t,A,e={})=>{const{clipGeom:i}=e;t.shape||(t.shape="circle");const o=A.pcbThickness+2*C0+4*mo,n=A.pcbThickness/2+ig.copper,s=-A.pcbThickness/2-ig.copper,r=n-s;if(t.shape==="circle"){const a=t.outer_diameter??Math.max(t.hole_diameter,0),g=r+.01,I=(0,$s.cylinder)({center:[t.x,t.y,0],radius:a/2,height:g}),c=uF(I,i),B=(0,$s.cylinder)({center:[t.x,t.y,0],radius:Math.max(t.hole_diameter/2,.01),height:o});return(0,Om.colorize)(Fo.copper,(0,Xr.subtract)(c,B))}if(t.shape==="oval"){const a=t.outer_width||t.hole_width||0,g=t.outer_height||t.hole_height||0,I=t.hole_width||0,c=t.hole_height||0,B=(()=>{const Q=(0,$s.cylinder)({center:[0,0,0],radius:1,height:r+.01,segments:64}),E=(0,G9A.scale)([a/2,g/2,1],Q);return(0,Fd.translate)([t.x,t.y,0],E)})(),l=uF(B,i),C=(()=>{const Q=(0,$s.cylinder)({center:[0,0,0],radius:1,height:o,segments:64}),E=(0,G9A.scale)([Math.max(I/2,.01),Math.max(c/2,.01),1],Q);return(0,Fd.translate)([t.x,t.y,0],E)})();return(0,Om.colorize)(Fo.copper,(0,Xr.subtract)(l,C))}if(t.shape==="circular_hole_with_rect_pad"){const a=t.hole_offset_x||0,g=t.hole_offset_y||0,I=t.rect_pad_width||t.hole_diameter,c=t.rect_pad_height||t.hole_diameter,B=GC(t),l=uF((0,Xr.union)(y_({width:I,height:c,thickness:C0,center:[t.x,t.y,n],borderRadius:B}),y_({width:I,height:c,thickness:C0,center:[t.x,t.y,s],borderRadius:B}),(()=>{const h=Math.max(r-C0*2,mo),f=(n+s)/2,m=(0,$s.roundedRectangle)({size:[I,c],roundRadius:B||0,segments:s8}),S=(0,vL.extrudeLinear)({height:h},m);return(0,Fd.translate)([t.x,t.y,f-h/2],S)})(),(0,$s.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:t.hole_diameter/2,height:r})),i),C=(0,$s.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:Math.max(t.hole_diameter/2-mo,.01),height:o}),Q=(0,$s.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:t.hole_diameter/2,height:r});let E=(0,Xr.union)((0,Xr.subtract)(l,Q),Q);return e.clipGeom?(E=(0,Xr.subtract)(E,C),E=(0,Xr.intersect)(E,e.clipGeom),(0,Om.colorize)(Fo.copper,E)):(0,Om.colorize)(Fo.copper,(0,Xr.subtract)(E,C))}if(t.shape==="pill"){const a=(t.ccw_rotation||0)*Math.PI/180,g=k=>{if(!a)return k;const v=(0,Fd.translate)([-t.x,-t.y,0],k),_=(0,Fd.rotate)([0,0,a],v);return(0,Fd.translate)([t.x,t.y,0],_)},I=t.hole_height>t.hole_width,c=I?t.hole_height:t.hole_width,B=I?t.hole_width:t.hole_height,l=I?t.outer_height||B+.2:t.outer_width||c+.2,C=I?t.outer_width||c+.2:t.outer_height||B+.2,Q=B/2,E=Math.abs(c-B),h=r+.01,d=((k,v,_)=>{const H=v/2,P=Math.abs(k-v);if(P<=1e-6)return(0,$s.cylinder)({center:[t.x,t.y,0],radius:H,height:_});const J=(0,$s.cuboid)({center:[t.x,t.y,0],size:I?[v,P,_]:[P,v,_]}),W=(0,$s.cylinder)({center:I?[t.x,t.y-P/2,0]:[t.x-P/2,t.y,0],radius:H,height:_}),Z=(0,$s.cylinder)({center:I?[t.x,t.y+P/2,0]:[t.x+P/2,t.y,0],radius:H,height:_});return(0,Xr.union)(J,W,Z)})(l,C,h),f=(0,$s.cuboid)({center:[t.x,t.y,0],size:I?[B-2*mo,E,o]:[E,B-2*mo,o]}),m=(0,$s.cylinder)({center:I?[t.x,t.y-E/2,0]:[t.x-E/2,t.y,0],radius:Q-mo,height:o}),S=(0,$s.cylinder)({center:I?[t.x,t.y+E/2,0]:[t.x+E/2,t.y,0],radius:Q-mo,height:o}),D=(0,Xr.union)(f,m,S),x=uF(g(d),i),F=g(D);return(0,Om.colorize)(Fo.copper,(0,Xr.subtract)(x,F))}if(t.shape==="pill_hole_with_rect_pad"){if(t.hole_shape&&t.hole_shape!=="pill"||t.pad_shape&&t.pad_shape!=="rect")throw new Error("Invalid hole_shape or pad_shape for pill_hole_with_rect_pad");const a=t.hole_offset_x||0,g=t.hole_offset_y||0,I=t.hole_height>t.hole_width,c=I?t.hole_height:t.hole_width,B=I?t.hole_width:t.hole_height,l=B/2,C=Math.abs(c-B),Q=t.rect_pad_width||c+.2,E=t.rect_pad_height||B+.2,h=GC(t),u=.03,d=(0,Xr.union)((0,$s.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B+2*u,C+2*u,r]:[C+2*u,B+2*u,r]}),(0,$s.cylinder)({center:I?[t.x+a,t.y+g-C/2,0]:[t.x+a-C/2,t.y+g,0],radius:l+u,height:r}),(0,$s.cylinder)({center:I?[t.x+a,t.y+g+C/2,0]:[t.x+a+C/2,t.y+g,0],radius:l+u,height:r})),f=(0,Xr.union)((0,$s.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B,C,o*1.1]:[C,B,o*1.1]}),(0,$s.cylinder)({center:I?[t.x+a,t.y+g-C/2,0]:[t.x+a-C/2,t.y+g,0],radius:l,height:o*1.1}),(0,$s.cylinder)({center:I?[t.x+a,t.y+g+C/2,0]:[t.x+a+C/2,t.y+g,0],radius:l,height:o*1.1})),m=y_({width:Q,height:E,thickness:C0,center:[t.x,t.y,n],borderRadius:h}),S=y_({width:Q,height:E,thickness:C0,center:[t.x,t.y,s],borderRadius:h}),D=(()=>{const P=Math.max(r-C0*2,mo),Z=(n+s)/2,AA=(0,$s.roundedRectangle)({size:[Q,E],roundRadius:h||0,segments:s8}),nA=(0,vL.extrudeLinear)({height:P},AA);return(0,Fd.translate)([t.x,t.y,Z-P/2],nA)})(),x=(0,Xr.subtract)(m,f),F=(0,Xr.subtract)(S,f),k=(0,Xr.subtract)(D,f),v=(0,Xr.union)((0,$s.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B-2*mo,C-2*mo,o*1.1]:[C-2*mo,B-2*mo,o*1.1]}),(0,$s.cylinder)({center:I?[t.x+a,t.y+g-C/2,0]:[t.x+a-C/2,t.y+g,0],radius:l-mo,height:o*1.1}),(0,$s.cylinder)({center:I?[t.x+a,t.y+g+C/2,0]:[t.x+a+C/2,t.y+g,0],radius:l-mo,height:o*1.1})),_=(0,Xr.subtract)(d,v),H=uF((0,Xr.union)(x,F,k,_),i);return(0,Om.colorize)(Fo.copper,H)}else if(t.shape==="rotated_pill_hole_with_rect_pad"){if(t.hole_shape&&t.hole_shape!=="rotated_pill"||t.pad_shape&&t.pad_shape!=="rect")throw new Error("Invalid hole_shape or pad_shape for rotated_pill_hole_with_rect_pad");const a=t.hole_offset_x||0,g=t.hole_offset_y||0,I=t.hole_width,c=t.hole_height,B=I>=c,l=B?I:c,C=B?c:I,Q=C/2,E=Math.abs(l-C),h=t.rect_pad_width||I+.2,u=t.rect_pad_height||c+.2,d=GC(t),f=.03,m=(t.hole_ccw_rotation||0)*Math.PI/180,S=(t.rect_ccw_rotation||0)*Math.PI/180,D=gA=>{const tA=a*Math.cos(m)-g*Math.sin(m),iA=a*Math.sin(m)+g*Math.cos(m),rA=(0,Fd.rotate)([0,0,m],gA);return(0,Fd.translate)([t.x+tA,t.y+iA,0],rA)},x=gA=>{if(!S)return gA;const tA=(0,Fd.translate)([-t.x,-t.y,0],gA),iA=(0,Fd.rotate)([0,0,S],tA);return(0,Fd.translate)([t.x,t.y,0],iA)},F=D((0,Xr.union)((0,$s.cuboid)({center:[0,0,0],size:B?[E+2*f,C+2*f,r]:[C+2*f,E+2*f,r]}),(0,$s.cylinder)({center:B?[-E/2,0,0]:[0,-E/2,0],radius:Q+f,height:r}),(0,$s.cylinder)({center:B?[E/2,0,0]:[0,E/2,0],radius:Q+f,height:r}))),k=D((0,Xr.union)((0,$s.cuboid)({center:[0,0,0],size:B?[E,C,o*1.1]:[C,E,o*1.1]}),(0,$s.cylinder)({center:B?[-E/2,0,0]:[0,-E/2,0],radius:Q,height:o*1.1}),(0,$s.cylinder)({center:B?[E/2,0,0]:[0,E/2,0],radius:Q,height:o*1.1}))),v=x(y_({width:h,height:u,thickness:C0,center:[t.x,t.y,n],borderRadius:d})),_=x(y_({width:h,height:u,thickness:C0,center:[t.x,t.y,s],borderRadius:d})),H=x((()=>{const gA=Math.max(r-C0*2,mo),rA=(n+s)/2,CA=(0,$s.roundedRectangle)({size:[h,u],roundRadius:d||0,segments:s8}),dA=(0,vL.extrudeLinear)({height:gA},CA);return(0,Fd.translate)([t.x,t.y,rA-gA/2],dA)})()),P=(0,Xr.subtract)(v,k),J=(0,Xr.subtract)(_,k),W=(0,Xr.subtract)(H,k),Z=D((0,Xr.union)((0,$s.cuboid)({center:[0,0,0],size:B?[E-2*mo,C-2*mo,o*1.1]:[C-2*mo,E-2*mo,o*1.1]}),(0,$s.cylinder)({center:B?[-E/2,0,0]:[0,-E/2,0],radius:Q-mo,height:o*1.1}),(0,$s.cylinder)({center:B?[E/2,0,0]:[0,E/2,0],radius:Q-mo,height:o*1.1}))),AA=(0,Xr.subtract)(F,Z),nA=uF((0,Xr.union)(P,J,W,AA),i);return(0,Om.colorize)(Fo.copper,nA)}else if(t.shape==="hole_with_polygon_pad"){const a=t.pad_outline;if(!Array.isArray(a)||a.length<3)throw new Error(`Invalid pad_outline for plated hole at (${t.x}, ${t.y})`);const g=a.map(f=>[f.x,f.y]),I=(0,$s.polygon)({points:g}),c=(n+s)/2,B=(f,m)=>{const S=Math.max(f,mo),D=(0,vL.extrudeLinear)({height:S},I);return(0,Fd.translate)([t.x,t.y,m-S/2],D)},l=B(Math.max(r-C0*2,mo),c),C=B(C0,n),Q=B(C0,s),E=uF((0,Xr.union)(l,C,Q),i),h=n8(t,r);if(!h)return(0,Om.colorize)(Fo.copper,E);const u=n8(t,o,{sizeDelta:-2*mo})||h;let d=(0,Xr.union)((0,Xr.subtract)(E,h),h);return e.clipGeom?(d=(0,Xr.subtract)(d,u),d=(0,Xr.intersect)(d,e.clipGeom),(0,Om.colorize)(Fo.copper,d)):(0,Om.colorize)(Fo.copper,(0,Xr.subtract)(d,u))}else throw new Error(`Unsupported plated hole shape: ${t.shape}`)},w_=_r(dL()),F9A=_r(vx()),mft=_r(s_());function Dft(t,A,e,i){if(!e||Math.abs(e)<1e-9)return[];const o=4*Math.atan(e),n=A[0]-t[0],s=A[1]-t[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))),I=[(t[0]+A[0])/2,(t[1]+A[1])/2],c=n/r,l=-(s/r),C=c,Q=I[0]+l*g*Math.sign(e),E=I[1]+C*g*Math.sign(e),h=Math.atan2(t[1]-E,t[0]-Q),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 S=h+f*m;u.push([Q+a*Math.cos(S),E+a*Math.sin(S)])}return u}function r8(t,A){const e=[],i=t.vertices;for(let o=0;o<i.length;o++){const n=i[o],s=i[(o+1)%i.length];if(e.push([n.x,n.y]),n.bulge){const r=Dft([n.x,n.y],[s.x,s.y],n.bulge,A);e.push(...r)}}return e}function R9A(t){let A=0;for(let e=0;e<t.length;e++){const i=(e+1)%t.length;A+=t[e][0]*t[i][1],A-=t[i][0]*t[e][1]}return A/2<=0}function Sft(t,A=16){let e=r8(t.outer_ring,A);R9A(e)&&e.reverse();const i=(0,F9A.polygon)({points:e});if(!t.inner_rings||t.inner_rings.length===0)return i;const o=t.inner_rings.map(n=>{let s=r8(n,A);return R9A(s)&&s.reverse(),(0,F9A.polygon)({points:s})});return o.length===0?i:(0,mft.subtract)(i,o)}var M9A=_r(s_()),bft=_r(QF()),LL=_r(vx());function xft({x:t,y:A,outerDiameter:e,holeDiameter:i,thickness:o}){if(e<=i)throw new Error(`Invalid via geometry: outerDiameter (${e}) must be > holeDiameter (${i})`);const n=mo,s=mo,r=Math.min(e/2,i/2+s),a=(0,LL.cylinder)({center:[0,0,0],radius:r,height:o,segments:ql}),g=(0,LL.cylinder)({center:[0,0,o/2],radius:e/2,height:n,segments:ql}),I=(0,LL.cylinder)({center:[0,0,-o/2],radius:e/2,height:n,segments:ql}),c=(0,M9A.union)([a,g,I]),B=o+n*2,l=(0,LL.cylinder)({center:[0,0,0],radius:i/2,height:B,segments:ql}),C=(0,M9A.subtract)(c,l);return(0,bft.translate)([t,A,0],C)}function kft({x:t,y:A,holeDiameter:e,thickness:i}){const o=i*1.5,n=e/2+mo;return(0,LL.cylinder)({center:[t,A,0],radius:n,height:o,segments:ql})}var N9A=64,Gft=1,YCA=.05,_9A=(t,A,e,i)=>{const o=l0(t,A,i);if(o<=0)return(0,Ya.cuboid)({center:[0,0,0],size:[t,A,e]});const n=(0,Ya.roundedRectangle)({size:[t,A],roundRadius:o,segments:N9A}),s=(0,w_.extrudeLinear)({height:e},n);return(0,Al.translate)([0,0,-e/2],s)},v9A=["initializing","processing_pads","processing_copper_pours","processing_plated_holes","processing_holes","processing_cutouts","processing_vias","finalizing","done"],Fft=class{circuitJson;board;plated_holes;holes;pads;traces;pcb_vias;pcb_cutouts;pcb_copper_pours;boardGeom=null;platedHoleGeoms=[];padGeoms=[];viaGeoms=[];copperPourGeoms=[];boardClipGeom=null;state="initializing";currentIndex=0;ctx;onCompleteCallback;finalGeoms=[];getHoleToCut(t,A){const e=mo/10;for(const i of this.pcb_vias)if(Math.abs(i.x-t)<e&&Math.abs(i.y-A)<e&&i.hole_diameter)return{diameter:i.hole_diameter};for(const i of this.plated_holes)if(i.shape==="circle"&&Math.abs(i.x-t)<e&&Math.abs(i.y-A)<e&&i.hole_diameter)return{diameter:i.hole_diameter};return null}constructor(t,A){this.circuitJson=t,this.onCompleteCallback=A;const e=t.filter(o=>o.type==="pcb_panel"),i=mi(t).pcb_board.list();if(e.length>0){const o=e[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=mi(t).pcb_plated_hole.list(),this.holes=mi(t).pcb_hole.list(),this.pads=mi(t).pcb_smtpad.list(),this.traces=mi(t).pcb_trace.list(),this.pcb_vias=mi(t).pcb_via.list(),this.pcb_cutouts=mi(t).pcb_cutout.list(),this.pcb_copper_pours=t.filter(o=>o.type==="pcb_copper_pour"),this.ctx={pcbThickness:this.board.thickness??1.2},this.initializeBoard()}initializeBoard(){const t=this.ctx.pcbThickness+2*Gft;this.board.outline&&this.board.outline.length>0?(this.boardGeom=HCA({outline:this.board.outline},this.ctx.pcbThickness),this.boardClipGeom=HCA({outline:this.board.outline},t,{xyOutset:YCA})):(this.boardGeom=(0,Ya.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.boardClipGeom=(0,Ya.cuboid)({size:[this.board.width+2*YCA,this.board.height+2*YCA,t],center:[this.board.center.x,this.board.center.y,0]})),this.state="processing_pads",this.currentIndex=0}goToNextState(){const t=v9A.indexOf(this.state);t!==-1&&(this.state=v9A[t+1],this.currentIndex=0)}step(t=1){if(this.state==="done"||!this.boardGeom)return!0;for(let A=0;A<t&&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"processing_copper_pours":this.currentIndex<this.pcb_copper_pours.length?(this.processCopperPour(this.pcb_copper_pours[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"finalizing":this.finalize(),this.state="done";break}return this.state==="done"}processCutout(t){if(!this.boardGeom)return;let A=null;const e=this.ctx.pcbThickness*1.5;switch(t.shape){case"rect":{const i=l0(t.width,t.height,GC(t));if(i>0){const o=(0,Ya.roundedRectangle)({size:[t.width,t.height],roundRadius:i,segments:N9A});A=(0,w_.extrudeLinear)({height:e},o),A=(0,Al.translate)([0,0,-e/2],A)}else A=(0,Ya.cuboid)({center:[0,0,0],size:[t.width,t.height,e]});if(t.rotation){const o=t.rotation*Math.PI/180;A=(0,Al.rotateZ)(o,A)}A=(0,Al.translate)([t.center.x,t.center.y,0],A);break}case"circle":A=(0,Ya.cylinder)({center:[t.center.x,t.center.y,0],radius:t.radius,height:e});break;case"polygon":{let i=t.points.map(n=>[n.x,n.y]);if(i.length<3){console.warn(`PCB Cutout [${t.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}LCA(i)&&(i=i.reverse());const o=(0,Ya.polygon)({points:i});A=(0,w_.extrudeLinear)({height:e},o),A=(0,Al.translate)([0,0,-e/2],A);break}}A&&(this.boardGeom=(0,og.subtract)(this.boardGeom,A))}processCopperPour(t){const A=t.layer==="bottom"?-1:1,e=A*this.ctx.pcbThickness/2+A*ig.copper;let i=null;if(t.shape==="rect"){let o=(0,Ya.cuboid)({center:[0,0,0],size:[t.width,t.height,mo]});if("rotation"in t&&t.rotation){const n=t.rotation*Math.PI/180;o=(0,Al.rotateZ)(n,o)}i=(0,Al.translate)([t.center.x,t.center.y,e],o)}else if(t.shape==="brep"){const o=t.brep_shape;if(o?.outer_ring){const n=Sft(o);i=(0,w_.extrudeLinear)({height:mo},n),i=(0,Al.translate)([0,0,e],i)}}else if(t.shape==="polygon"){let o=t.points.map(s=>[s.x,s.y]);if(o.length<3){console.warn(`PCB Copper Pour [${t.pcb_copper_pour_id}] polygon has fewer than 3 points, skipping.`);return}LCA(o)&&(o=o.reverse());const n=(0,Ya.polygon)({points:o});i=(0,w_.extrudeLinear)({height:mo},n),i=(0,Al.translate)([0,0,e],i)}if(i){this.boardClipGeom&&(i=(0,og.intersect)(this.boardClipGeom,i));const n=t.covered_with_solder_mask!==!1?Bft[this.board.material]??Fo.fr4TracesWithoutMaskTan:Fo.copper,s=(0,fh.colorize)(n,i);this.copperPourGeoms.push(s)}}processPlatedHole(t,A={}){if(this.boardGeom){if(t.shape==="circle"||t.shape==="circular_hole_with_rect_pad"){let e=null;if(t.shape==="circular_hole_with_rect_pad"){if(t.hole_shape&&t.hole_shape!=="circle"||t.pad_shape&&t.pad_shape!=="rect")return;e=(0,Ya.cylinder)({center:[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0),0],radius:t.hole_diameter/2+mo,height:this.ctx.pcbThickness*1.5})}else e=(0,Ya.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+mo,height:this.ctx.pcbThickness*1.5});A.dontCutBoard||(this.boardGeom=(0,og.subtract)(this.boardGeom,e)),this.padGeoms=this.padGeoms.map(o=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(o,e)));const i=UL(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(i)}else if(t.shape==="pill"||t.shape==="oval"){const e=t.hole_height>t.hole_width,i=e?t.hole_height:t.hole_width,o=e?t.hole_width:t.hole_height,n=o/2,s=Math.abs(i-o);let r;if(r=(0,og.union)((0,Ya.cuboid)({center:[t.x,t.y,0],size:e?[o,s,this.ctx.pcbThickness*1.5]:[s,o,this.ctx.pcbThickness*1.5]}),(0,Ya.cylinder)({center:e?[t.x,t.y-s/2,0]:[t.x-s/2,t.y,0],radius:n,height:this.ctx.pcbThickness*1.5}),(0,Ya.cylinder)({center:e?[t.x,t.y+s/2,0]:[t.x+s/2,t.y,0],radius:n,height:this.ctx.pcbThickness*1.5})),t.ccw_rotation){const g=t.ccw_rotation*Math.PI/180;r=(0,Al.translate)([t.x,t.y,0],(0,Al.rotateZ)(g,(0,Al.translate)([-t.x,-t.y,0],r)))}A.dontCutBoard||(this.boardGeom=(0,og.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(g,r)));const a=UL(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(a)}else if(t.shape==="pill_hole_with_rect_pad"){if(t.hole_shape&&t.hole_shape!=="pill"||t.pad_shape&&t.pad_shape!=="rect")return;const e=t.hole_height>t.hole_width,i=e?t.hole_height:t.hole_width,o=e?t.hole_width:t.hole_height,n=o/2,s=Math.abs(i-o);let r;r=(0,og.union)((0,Ya.cuboid)({center:[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0),0],size:e?[o,s,this.ctx.pcbThickness*1.5]:[s,o,this.ctx.pcbThickness*1.5]}),(0,Ya.cylinder)({center:e?[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0)-s/2,0]:[t.x+(t.hole_offset_x||0)-s/2,t.y+(t.hole_offset_y||0),0],radius:n,height:this.ctx.pcbThickness*1.5}),(0,Ya.cylinder)({center:e?[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0)+s/2,0]:[t.x+(t.hole_offset_x||0)+s/2,t.y+(t.hole_offset_y||0),0],radius:n,height:this.ctx.pcbThickness*1.5})),A.dontCutBoard||(this.boardGeom=(0,og.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(g,r)));const a=UL(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(a)}else if(t.shape==="rotated_pill_hole_with_rect_pad"){if(t.hole_shape&&t.hole_shape!=="rotated_pill"||t.pad_shape&&t.pad_shape!=="rect")return;const e=t.hole_width,i=t.hole_height,o=e>=i,n=o?e:i,s=o?i:e,r=s/2,a=Math.abs(n-s),g=t.hole_offset_x||0,I=t.hole_offset_y||0;let c=(0,og.union)((0,Ya.cuboid)({center:[0,0,0],size:o?[a,s,this.ctx.pcbThickness*1.5]:[s,a,this.ctx.pcbThickness*1.5]}),(0,Ya.cylinder)({center:o?[-a/2,0,0]:[0,-a/2,0],radius:r,height:this.ctx.pcbThickness*1.5}),(0,Ya.cylinder)({center:o?[a/2,0,0]:[0,a/2,0],radius:r,height:this.ctx.pcbThickness*1.5}));const B=(t.hole_ccw_rotation||0)*Math.PI/180,l=g*Math.cos(B)-I*Math.sin(B),C=g*Math.sin(B)+I*Math.cos(B);c=(0,Al.rotateZ)(B,c);const Q=(0,Al.translate)([t.x+l,t.y+C,0],c);A.dontCutBoard||(this.boardGeom=(0,og.subtract)(this.boardGeom,Q)),this.padGeoms=this.padGeoms.map(h=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(h,Q)));const E=UL(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(E)}else if(t.shape==="hole_with_polygon_pad"){const e=t.pad_outline;if(!Array.isArray(e)||e.length<3)return;const i=this.ctx.pcbThickness*1.5,o=n8(t,i,{sizeDelta:2*mo}),n=n8(t,i,{sizeDelta:-2*mo});if(!o||!n)return;A.dontCutBoard||(this.boardGeom=(0,og.subtract)(this.boardGeom,o)),this.padGeoms=this.padGeoms.map(r=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(r,o))),this.platedHoleGeoms=this.platedHoleGeoms.map(r=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(r,n)));const s=UL(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(s)}}}processHole(t){if(!this.boardGeom)return;const A=this.ctx.pcbThickness*1.5;if(t.hole_shape==="circle"){const e=(0,Ya.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+mo,height:A});this.boardGeom=(0,og.subtract)(this.boardGeom,e),this.padGeoms=this.padGeoms.map(o=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(o,e)));const i=(0,Ya.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+mo/2,height:A});this.platedHoleGeoms=this.platedHoleGeoms.map(o=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(o,i)))}else if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"||t.hole_shape==="oval"){const e=t.hole_width??t.hole_diameter,i=t.hole_height??t.hole_diameter,o=t.ccw_rotation??t.rotation??0,n=.02,s=(g,I,c,B)=>{if(g<=0||I<=0)return null;if(B)return(0,Al.translate)([0,0,-c/2],(0,w_.extrudeLinear)({height:c},(0,Ya.ellipse)({radius:[g/2,I/2]})));const l=Math.min(g,I)/2,C=Math.abs(g-I);return g>I?(0,og.union)((0,Ya.cuboid)({center:[0,0,0],size:[C,I,c]}),(0,Ya.cylinder)({center:[-C/2,0,0],radius:l,height:c}),(0,Ya.cylinder)({center:[C/2,0,0],radius:l,height:c})):(0,og.union)((0,Ya.cuboid)({center:[0,0,0],size:[g,C,c]}),(0,Ya.cylinder)({center:[0,-C/2,0],radius:l,height:c}),(0,Ya.cylinder)({center:[0,C/2,0],radius:l,height:c}))};let r=s(e,i,A,t.hole_shape==="oval"),a=s(e-2*n,i-2*n,A,t.hole_shape==="oval");if(r&&o!==0&&(r=(0,Al.rotateZ)(o*Math.PI/180,r)),a&&o!==0&&(a=(0,Al.rotateZ)(o*Math.PI/180,a)),r){const g=(0,Al.translate)([t.x,t.y,0],r);this.boardGeom=(0,og.subtract)(this.boardGeom,g),this.padGeoms=this.padGeoms.map(I=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(I,g)))}if(a){const g=(0,Al.translate)([t.x,t.y,0],a);this.platedHoleGeoms=this.platedHoleGeoms.map(I=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(I,g)))}}}processPad(t){const A=t.layer==="bottom"?-1:1,e=A*this.ctx.pcbThickness/2+A*ig.copper,i=GC(t);if(t.shape==="rect"){const o=_9A(t.width,t.height,mo,i);let s=(0,Al.translate)([t.x,t.y,e],o);this.boardClipGeom&&(s=(0,og.intersect)(this.boardClipGeom,s)),s=(0,fh.colorize)(Fo.copper,s),this.padGeoms.push(s)}else if(t.shape==="rotated_rect"){let o=_9A(t.width,t.height,mo,i);const n=t.ccw_rotation*Math.PI/180;o=(0,Al.rotateZ)(n,o);let r=(0,Al.translate)([t.x,t.y,e],o);this.boardClipGeom&&(r=(0,og.intersect)(this.boardClipGeom,r)),r=(0,fh.colorize)(Fo.copper,r),this.padGeoms.push(r)}else if(t.shape==="circle"){let o=(0,Ya.cylinder)({center:[t.x,t.y,e],radius:t.radius,height:mo});this.boardClipGeom&&(o=(0,og.intersect)(this.boardClipGeom,o)),o=(0,fh.colorize)(Fo.copper,o),this.padGeoms.push(o)}}processVia(t){if(this.boardGeom){if(typeof t.outer_diameter=="number"&&typeof t.hole_diameter=="number"){const A=xft({x:t.x,y:t.y,outerDiameter:t.outer_diameter,holeDiameter:t.hole_diameter,thickness:this.ctx.pcbThickness});let e=A;this.boardClipGeom&&(e=(0,og.intersect)(this.boardClipGeom,A),e=(0,fh.colorize)(Fo.copper,e)),this.viaGeoms.push(e)}if(typeof t.hole_diameter=="number"){const A=kft({x:t.x,y:t.y,holeDiameter:t.hole_diameter,thickness:this.ctx.pcbThickness});this.boardGeom=(0,og.subtract)(this.boardGeom,A),this.padGeoms=this.padGeoms.map(e=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(e,A)))}}}finalize(){if(!this.boardGeom)return;const t=UCA[this.board.material]??Fo.fr4Tan;this.boardGeom=(0,fh.colorize)(t,this.boardGeom),this.finalGeoms=[this.boardGeom,...this.platedHoleGeoms,...this.padGeoms,...this.viaGeoms,...this.copperPourGeoms],this.onCompleteCallback&&this.onCompleteCallback(this.finalGeoms)}getGeoms(){return this.finalGeoms}},Rft=t=>{const[A,e]=j.useState(null),i=j.useRef(!1);return j.useEffect(()=>{let o=!1;if(!t){e(null);return}if(!t.some(g=>g.type==="pcb_board"||g.type==="pcb_panel")){e(null);return}const s=hft(t);e(s);const r=new Fft(t,g=>{});return(async()=>{if(!i.current){i.current=!0;try{let g=!1;for(;!g&&!o;)g=r.step(1),g||await new Promise(I=>setTimeout(I,0));o||e(r.getGeoms())}catch(g){console.error("Error during board geometry building:",g)}finally{i.current=!1}}})(),()=>{o=!0}},[t]),A},Mft=({children:t,parent:A,position:e,rotation:i,scale:o,color:n,fontSize:s,anchorX:r,anchorY:a,depthOffset:g})=>{const{rootObject:I}=Ru(),c=j.useMemo(()=>{const B=new gnA;return B.text=t,e&&B.position.fromArray(e),i&&B.rotation.fromArray(i),o&&B.scale.fromArray(o),B.color=n||"white",B.fontSize=s||1,B.anchorX=r||"center",B.anchorY=a||"middle",B.depthOffset=g||0,B.font=null,B.sync(),B},[t,e,i,o,n,s,r,a,g]);return j.useEffect(()=>{const B=A||I;if(!(!B||!c))return B.add(c),()=>{B.remove(c),c.dispose()}},[I,A,c]),null},U9A=({error:t,cad_component:A})=>{const{rootObject:e}=Ru(),[i,o]=j.useState(!1),[n,s]=j.useState(null),r=j.useCallback(c=>{c?.mousePosition?(o(!0),s(c.mousePosition)):(o(!1),s(null))},[]),a=j.useCallback(()=>{o(!1),s(null)},[]),g=j.useMemo(()=>A?.position?[A.position.x,A.position.y,A.position.z].map(B=>Number.isNaN(B)?0:B):[0,0,0],[A]),I=j.useMemo(()=>{const c=new ef;return c.position.fromArray(g),c},[g]);return j.useEffect(()=>{if(e)return e.add(I),()=>{e.remove(I)}},[e,I]),O.jsxs(O.Fragment,{children:[O.jsxs(NL,{isHovered:i,onHover:r,onUnhover:a,object:I,children:[O.jsx(Nft,{parent:I}),O.jsx(Mft,{parent:I,scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:`${t.toString().slice(0,50)}...`})]}),i&&n?O.jsx(jZA,{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:t.toString()}):null]})},Nft=({parent:t})=>{const A=j.useMemo(()=>{const e=new Vo(new Fw(.5,.5,.5),new hh({depthTest:!1,transparent:!0,color:"red",opacity:.5}));return e.renderOrder=999999,e.rotation.fromArray([Math.PI/4,Math.PI/4,0]),e},[]);return j.useEffect(()=>(t.add(A),()=>{t.remove(A)}),[t,A]),null};function _ft({stlUrl:t,stlData:A,mtlUrl:e,color:i,opacity:o=1}){const{rootObject:n}=Ru(),[s,r]=j.useState(null);j.useEffect(()=>{const g=new u7e;if(A){try{const I=g.parse(A);r(I)}catch(I){console.error("Failed to parse STL data",I),r(null)}return}t&&g.load(t,I=>{r(I)})},[t,A]);const a=j.useMemo(()=>{if(!s)return null;const g=new hh({color:Array.isArray(i)?new Li(i[0],i[1],i[2]):i,transparent:o!==1,opacity:o});return new Vo(s,g)},[s,i,o]);return j.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 vft({stlData:t,color:A,opacity:e=1,layerType:i}){const{visibility:o}=r_();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?O.jsx(_ft,{stlData:t,color:A,opacity:e}):null}var L9A=class extends Xi.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},Uft=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,o=t[0].y;for(let n=1;n<t.length;n++){const s=t[n];s.x<A&&(A=s.x),s.y<e&&(e=s.y),s.x>i&&(i=s.x),s.y>o&&(o=s.y)}return{minX:A,minY:e,maxX:i,maxY:o}};function dF(t){if(t.outline&&t.outline.length>=3){const s=Uft(t.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=t.width??0,e=t.height??0,i=t.center?.x??0,o=t.center?.y??0;return{...{minX:i-A/2,maxX:i+A/2,minY:o-e/2,maxY:o+e/2},width:A,height:e,centerX:i,centerY:o}}function a8({layer:t,circuitJson:A,boardData:e,soldermaskColor:i,traceTextureResolution:o}){const n=dF(e),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;t==="bottom"&&(g.translate(0,a),g.scale(1,-1));const I=f=>(f-n.minX)*o,c=f=>(n.maxY-f)*o;if(g.fillStyle=i,e.outline&&e.outline.length>=3){g.beginPath();const f=e.outline[0];g.moveTo(I(f.x),c(f.y));for(let m=1;m<e.outline.length;m++){const S=e.outline[m];g.lineTo(I(S.x),c(S.y))}g.closePath(),g.fill()}else g.fillRect(0,0,r,a);g.globalCompositeOperation="destination-out",g.fillStyle="black",mi(A).pcb_smtpad.list().filter(f=>f.layer===t).forEach(f=>{if(f.shape==="polygon"&&f.points){g.beginPath(),f.points.forEach((F,k)=>{const v=I(F.x),_=c(F.y);k===0?g.moveTo(v,_):g.lineTo(v,_)}),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,S=f.y,D=I(m),x=c(S);if(f.shape==="rect"){const F=f.width*o,k=f.height*o,v=GC(f),_=l0(f.width,f.height,v)*o;_>0?(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill()):g.fillRect(D-F/2,x-k/2,F,k)}else if(f.shape==="circle"){const F=(f.radius??f.width/2)*o;g.beginPath(),g.arc(D,x,F,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const F=f.width*o,k=f.height*o,v=GC(f),_=l0(f.width,f.height,v)*o;g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill()}else if(f.shape==="rotated_rect"){const F=f.width*o,k=f.height*o,v=GC(f),_=l0(f.width,f.height,v)*o,P=-(f.ccw_rotation||0)*(Math.PI/180);g.save(),g.translate(D,x),g.rotate(P),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()}}),mi(A).pcb_via.list().forEach(f=>{const m=I(f.x),S=c(f.y),D=f.outer_diameter/2*o;g.beginPath(),g.arc(m,S,D,0,2*Math.PI),g.fill()}),mi(A).pcb_plated_hole.list().forEach(f=>{if(!f.layers?.includes(t))return;const m=f.x,S=f.y,D=I(m),x=c(S);if(f.shape==="circle"){const k=f.outer_diameter/2*o;g.beginPath(),g.arc(D,x,k,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const F=(f.outer_width??f.outer_diameter??f.hole_width)*o,k=(f.outer_height??f.outer_diameter??f.hole_height)*o,v=Math.min(F,k)/2,H=-(f.ccw_rotation||0);H?(g.save(),g.translate(D,x),g.rotate(H*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,v),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,v),g.fill())}else if(f.shape==="oval"){const F=(f.outer_width??f.outer_diameter??f.hole_width)*o,k=(f.outer_height??f.outer_diameter??f.hole_height)*o,v=F/2,_=k/2,P=-(f.ccw_rotation||0);P?(g.save(),g.translate(D,x),g.rotate(P*Math.PI/180),g.beginPath(),g.ellipse(0,0,v,_,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(D,x,v,_,0,0,2*Math.PI),g.fill())}else if(f.shape==="hole_with_polygon_pad"){const F=f.hole_shape||"circle",k=f.hole_offset_x||0,v=f.hole_offset_y||0,_=I(f.x+k),H=c(f.y+v);if(F==="pill"||F==="rotated_pill"){const P=(f.outer_width??f.outer_diameter??f.hole_width)*o,J=(f.outer_height??f.outer_diameter??f.hole_height)*o,W=Math.min(P,J)/2,AA=-(f.ccw_rotation||0);AA?(g.save(),g.translate(_,H),g.rotate(AA*Math.PI/180),g.beginPath(),g.roundRect(-P/2,-J/2,P,J,W),g.fill(),g.restore()):(g.beginPath(),g.roundRect(_-P/2,H-J/2,P,J,W),g.fill())}else if(F==="oval"){const P=(f.outer_width??f.outer_diameter??f.hole_width)*o,J=(f.outer_height??f.outer_diameter??f.hole_height)*o,W=P/2,Z=J/2,nA=-(f.ccw_rotation||0);nA?(g.save(),g.translate(_,H),g.rotate(nA*Math.PI/180),g.beginPath(),g.ellipse(0,0,W,Z,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(_,H,W,Z,0,0,2*Math.PI),g.fill())}else if(F==="circle"){const J=(f.outer_diameter??f.hole_diameter??0)*o/2;g.beginPath(),g.arc(_,H,J,0,2*Math.PI),g.fill()}f.pad_outline&&f.pad_outline.length>=3&&(g.beginPath(),f.pad_outline.forEach((P,J)=>{const W=I(f.x+P.x),Z=c(f.y+P.y);J===0?g.moveTo(W,Z):g.lineTo(W,Z)}),g.closePath(),g.fill())}else if(f.shape==="circular_hole_with_rect_pad"){const F=(f.rect_pad_width??f.hole_diameter??0)*o,k=(f.rect_pad_height??f.hole_diameter??0)*o,v=GC(f),_=l0(f.rect_pad_width??f.hole_diameter??0,f.rect_pad_height??f.hole_diameter??0,v)*o;_>0?(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill()):g.fillRect(D-F/2,x-k/2,F,k)}else if(f.shape==="pill_hole_with_rect_pad"){const F=(f.rect_pad_width??f.hole_width??0)*o,k=(f.rect_pad_height??f.hole_height??0)*o,v=GC(f),_=l0(f.rect_pad_width??f.hole_width??0,f.rect_pad_height??f.hole_height??0,v)*o,P=-(f.ccw_rotation||0);P?(g.save(),g.translate(D,x),g.rotate(P*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill())}else if(f.shape==="rotated_pill_hole_with_rect_pad"){const F=(f.rect_pad_width??f.hole_width??0)*o,k=(f.rect_pad_height??f.hole_height??0)*o,v=GC(f),_=l0(f.rect_pad_width??f.hole_width??0,f.rect_pad_height??f.hole_height??0,v)*o,P=-(f.rect_ccw_rotation||0);P?(g.save(),g.translate(D,x),g.rotate(P*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill())}}),mi(A).pcb_hole.list().forEach(f=>{const m=f.x,S=f.y,D=I(m),x=c(S),F=f.hole_shape;if(F==="circle"&&typeof f.hole_diameter=="number"){const k=f.hole_diameter/2*o;g.beginPath(),g.arc(D,x,k,0,2*Math.PI),g.fill()}else if(F==="pill"&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const k=f.hole_width*o,v=f.hole_height*o,_=Math.min(k,v)/2;g.beginPath(),g.roundRect(D-k/2,x-v/2,k,v,_),g.fill()}else if(F==="rotated_pill"&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const k=f.hole_width*o,v=f.hole_height*o,_=Math.min(k,v)/2,P=-(f.ccw_rotation||0)*(Math.PI/180);P?(g.save(),g.translate(D,x),g.rotate(P),g.beginPath(),g.roundRect(-k/2,-v/2,k,v,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-k/2,x-v/2,k,v,_),g.fill())}else if(F==="oval"&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const k=f.hole_width*o,v=f.hole_height*o,_=k/2,H=v/2;g.beginPath(),g.ellipse(D,x,_,H,0,0,2*Math.PI),g.fill()}}),mi(A).pcb_copper_pour.list().forEach(f=>{if(f.layer===t&&f.covered_with_solder_mask===!1)if(f.shape==="rect"){const m=I(f.center.x),S=c(f.center.y),D=f.width*o,x=f.height*o;g.fillRect(m-D/2,S-x/2,D,x)}else f.shape==="polygon"&&f.points&&(g.beginPath(),f.points.forEach((m,S)=>{const D=I(m.x),x=c(m.y);S===0?g.moveTo(D,x):g.lineTo(D,x)}),g.closePath(),g.fill())}),mi(A).pcb_cutout.list().forEach(f=>{switch(f.shape){case"rect":{const m=I(f.center.x),S=c(f.center.y),D=f.width*o,x=f.height*o,F=GC(f),k=l0(f.width,f.height,F);if(f.rotation){g.save(),g.translate(m,S);const v=-f.rotation*(Math.PI/180);g.rotate(v),k>0?(g.beginPath(),g.roundRect(-D/2,-x/2,D,x,k*o),g.fill()):g.fillRect(-D/2,-x/2,D,x),g.restore()}else k>0?(g.beginPath(),g.roundRect(m-D/2,S-x/2,D,x,k*o),g.fill()):g.fillRect(m-D/2,S-x/2,D,x);break}case"circle":{const m=I(f.center.x),S=c(f.center.y),D=f.radius*o;g.beginPath(),g.arc(m,S,D,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,S)=>{const D=I(m.x),x=c(m.y);S===0?g.moveTo(D,x):g.lineTo(D,x)}),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 TN(s);return d.generateMipmaps=!0,d.minFilter=xu,d.magFilter=XB,d.anisotropy=16,d.needsUpdate=!0,d}var Lft=_r(OlA());function H9A(t,A){return Array.isArray(A)?[t.a*A[0]+t.c*A[1]+t.e,t.b*A[0]+t.d*A[1]+t.f]:{x:t.a*A.x+t.c*A.y+t.e,y:t.b*A.x+t.d*A.y+t.f}}function Jx(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function Y9A(...t){t=Array.isArray(t[0])?t[0]:t;const A=(e,i)=>({a:e.a*i.a+e.c*i.b,c:e.a*i.c+e.c*i.d,e:e.a*i.e+e.c*i.f+e.e,b:e.b*i.a+e.d*i.b,d:e.b*i.c+e.d*i.d,f:e.b*i.e+e.d*i.f+e.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return A(t[0],t[1]);default:{const[e,i,...o]=t,n=A(e,i);return Y9A(n,...o)}}}function J9A(...t){return Y9A(...t)}var{cos:Hft,sin:Yft}=Math;function T9A(t,A,e){const i=Hft(t),o=Yft(t);return{a:i,c:-o,e:0,b:o,d:i,f:0}}function Jft(t,A){function e(){this.constructor=t}e.prototype=A.prototype,t.prototype=new e}function g8(t,A,e,i){var o=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(o,g8.prototype),o.expected=A,o.found=e,o.location=i,o.name="SyntaxError",o}Jft(g8,Error);function JCA(t,A,e){return e=e||" ",t.length>A?t:(A-=t.length,e+=e.repeat(A),t+e.slice(0,A))}g8.prototype.format=function(t){var A="Error: "+this.message;if(this.location){var e=null,i;for(i=0;i<t.length;i++)if(t[i].source===this.location.source){e=t[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(e){var r=this.location.end,a=JCA("",n.line.toString().length," "),g=e[o.line-1],I=o.line===r.line?r.column:g.length+1,c=I-o.column||1;A+=`
|
|
5105
|
+
`,eft=({rotation:t,infiniteGrid:A,cellSize:e=1,sectionSize:i=10})=>{const{scene:o,camera:n}=Ru(),s=1e3,r=j.useMemo(()=>{const a=new Rw(s,s);a.rotateX(-Math.PI/2);const g=new _m({vertexShader:$pt,fragmentShader:Aft,uniforms:{cellSize:{value:e},sectionSize:{value:i},gridColor:{value:new Li(15658734)},sectionColor:{value:new Li(13421823)},fadeDistance:{value:100},fadeStrength:{value:1.5}},transparent:!0,side:Tl}),I=new Vo(a,g);return t&&I.rotation.fromArray(t),I},[s,e,i,t]);return pL(()=>{A&&r.position.set(n.position.x,n.position.y,0)}),j.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},tft=()=>{const{scene:t}=Ru(),A=j.useMemo(()=>new tJA(16777215,Math.PI/2),[]),e=j.useMemo(()=>{const i=new UoA(16777215,Math.PI/4);return i.position.set(-10,-10,10),i.decay=0,i},[]);return j.useEffect(()=>{if(t)return t.add(A),t.add(e),()=>{t.remove(A),t.remove(e)}},[t,A,e]),null},ift=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,oft=()=>{const{controlsRef:t,mainCameraRef:A,defaultTarget:e,setController:i,getPresetConfig:o}=Hx(),n=j.useRef(null),s=j.useRef(new Sd),r=j.useRef(new Me),a=j.useRef(new Me),g=j.useRef(new Sd),I=j.useRef(new Sd),c=j.useRef(new wg),B=j.useRef(new wg),l=j.useCallback(({position:Q,target:E,up:h,durationMs:u=600})=>{if(!A.current)return;const d=t.current?.target??e,f=new Me(Q[0],Q[1],Q[2]),m=E?new Me(E[0],E[1],E[2]):e.clone(),S=new Me(...h??[0,0,1]).normalize(),D=B.current;D.position.copy(f),D.up.copy(S),D.lookAt(m);const x=D.quaternion.clone(),F=A.current.quaternion.clone(),k=A.current.position.clone(),v=d.clone(),_=c.current;_.up.set(0,0,1),_.position.copy(k),_.lookAt(v);const H=_.quaternion.clone();_.up.set(0,0,1),_.position.copy(f),_.lookAt(m);const P=_.quaternion.clone(),J=H.clone().invert().multiply(F).normalize(),W=P.clone().invert().multiply(x).normalize();n.current={fromPosition:k,toPosition:f,fromTarget:v,toTarget:m,toQuaternion:x,rollFrom:J,rollTo:W,startTime:performance.now(),duration:u}},[A,t,e]),C=j.useCallback(Q=>{if(Q==="Custom")return;const E=o(Q);E&&l(E)},[l,o]);return j.useEffect(()=>A.current?(i({animateTo:l,animateToPreset:C}),()=>{i(null)}):void 0,[l,C,A,i]),pL(()=>{if(!A.current||!n.current)return;const{fromPosition:Q,toPosition:E,fromTarget:h,toTarget:u,toQuaternion:d,rollFrom:f,rollTo:m,startTime:S,duration:D}=n.current,x=performance.now()-S,F=D<=0?1:Math.min(x/D,1),k=ift(F);A.current.position.lerpVectors(Q,E,k);const v=r.current;v.copy(h).lerp(u,k);const _=c.current;_.up.set(0,0,1),_.position.copy(A.current.position),_.lookAt(v);const H=s.current;H.copy(_.quaternion);const P=g.current;P.copy(f);const J=I.current;J.copy(m),f.dot(m)<0&&(J.x*=-1,J.y*=-1,J.z*=-1,J.w*=-1),J.normalize(),P.slerp(J,k),A.current.quaternion.copy(H).multiply(P).normalize();const W=a.current;W.set(0,1,0).applyQuaternion(A.current.quaternion).normalize(),A.current.up.copy(W),t.current?.target.copy(v),A.current.updateMatrixWorld(),t.current?.update(),F>=1&&(A.current.position.copy(E),A.current.quaternion.copy(d),A.current.up.set(0,0,1),A.current.updateMatrixWorld(),t.current?.target.copy(u),t.current?.update(),n.current=null)}),null},nft=()=>{const{controlsRef:t}=Hx(),A=j.useRef(null),e=j.useRef(!1),i=j.useRef(null),o=j.useCallback(s=>{A.current=s,!e.current&&t.current&&vCA(s,t.current)&&(e.current=!0)},[t]),n=j.useCallback(()=>{if(!(!A.current||!t.current)){if(!e.current&&vCA(A.current,t.current)){e.current=!0;return}clearTimeout(i.current),i.current=setTimeout(()=>{A.current&&t.current&&D9A(A.current,t.current)},150)}},[t]);return{handleCameraCreated:o,handleControlsChange:n}};function sft(t,A){const e=new Sd().setFromEuler(new $p(t.x,t.y,t.z)),i=new Me(0,0,1);return i.applyQuaternion(e),i.multiplyScalar(A)}var rft=()=>{const{mainCameraRef:t}=Hx(),A=j.useRef(null),e=j.useRef(null),i=j.useRef(null),o=j.useRef(null),n=j.useRef(null),s=j.useRef(null);return j.useEffect(()=>{if(!A.current)return;const r=document.createElement("canvas");e.current=r,A.current.appendChild(r);const a=new RO({canvas:r,antialias:!0,alpha:!0});a.setSize(120,120),a.setPixelRatio(window.devicePixelRatio),i.current=a;const g=new $G;o.current=g;const I=new CE(75,1,.1,1e3);I.up.set(0,0,1),n.current=I;const c=new tJA(16777215,Math.PI/2);g.add(c);const B=new ef;B.rotation.fromArray([Math.PI/2,0,0]);const l=1,C=new Vo(new Fw(l,l,l),new hh({color:"white"}));B.add(C);const Q=new vU(new uXe(new Fw(l,l,l)),new AF({color:0,linewidth:2}));B.add(Q),g.add(B);const E=.51,h=(F,k,v)=>{const _=new gnA;return _.text=F,_.position.fromArray(k),v&&_.rotation.fromArray(v),_.color="black",_.fontSize=.25,_.anchorX="center",_.anchorY="middle",_.depthOffset=0,_.font=null,_.sync(),_},u=h("Front",[0,0,E]),d=h("Back",[0,0,-E],[0,Math.PI,0]),f=h("Right",[E,0,0],[0,Math.PI/2,0]),m=h("Left",[-E,0,0],[0,-Math.PI/2,0]),S=h("Top",[0,E,0],[-Math.PI/2,0,0]),D=h("Bottom",[0,-E,0],[Math.PI/2,0,0]);B.add(u),B.add(d),B.add(f),B.add(m),B.add(S),B.add(D);const x=()=>{if(t.current){const F=sft(t.current.rotation??new $p(0,0,0),2);F.equals(I.position)||(I.position.copy(F),I.lookAt(0,0,0))}a.render(g,I),s.current=requestAnimationFrame(x)};return x(),()=>{s.current&&cancelAnimationFrame(s.current),u.dispose(),d.dispose(),f.dispose(),m.dispose(),S.dispose(),D.dispose(),C.geometry.dispose(),C.material.dispose(),Q.geometry.dispose(),Q.material.dispose(),g.clear(),a.dispose(),e.current&&A.current&&A.current.removeChild(e.current)}},[t]),O.jsx("div",{ref:A,style:{position:"absolute",top:0,left:0,width:120,height:120,zIndex:fL.orientationCube}})},aft=()=>{const{camera:t}=Ru(),{setCameraRotation:A}=Hx();return pL(()=>{t&&A(t.rotation)}),null},b9A=j.forwardRef(({children:t,initialCameraPosition:A=[5,-5,5],autoRotateDisabled:e,clickToInteractEnabled:i=!1,boardDimensions:o,boardCenter:n,onUserInteraction:s,onCameraControllerReady:r},a)=>{const[g,I]=j.useState(!i),{mainCameraRef:c,handleControlsChange:B,controller:l}=Hx(),{handleCameraCreated:C,handleControlsChange:Q}=nft();j.useEffect(()=>{r&&r(l)},[l,r]);const E=j.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=j.useMemo(()=>{if(n)return[n.x,n.y,0]},[n]);return O.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[O.jsx(rft,{}),O.jsxs(zpt,{ref:a,scene:{up:new Me(0,0,1)},camera:{up:[0,0,1],position:A},onCreated:({camera:u})=>{c.current=u,C(u)},children:[O.jsx(oft,{}),O.jsx(aft,{}),g&&O.jsx(Xpt,{autoRotate:!e,autoRotateSpeed:1,onStart:s,rotateSpeed:.5,panSpeed:.75,zoomSpeed:.5,enableDamping:!0,dampingFactor:.1,target:h,onControlsChange:u=>{B(u),Q()}}),O.jsx(tft,{}),O.jsx(eft,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:3,sectionSize:E,args:[E,E]}),t]}),O.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:["@",w9A.version]}),i&&!g&&O.jsx("button",{type:"button",onClick:()=>I(!0),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&I(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:fL.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center"},children:O.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"})})]})}),x9A=t=>j.useMemo(()=>{if(!t)return[];const A=new l3e;return A.add(t),A.render(),A.getCircuitJson()},[t]),gft=t=>{const[A,e]=j.useState([]),[i,o]=j.useState(!0);return j.useEffect(()=>{if(!t)return;(async()=>{o(!0);const r=(Array.isArray(t)?t:[t]).map(async(a,g)=>{const I=Fot.serialize({binary:!0},[a]),B=await new Blob(I).arrayBuffer(),C=a.layerType||(g===0?"board":void 0);return{stlData:B,color:a.color,layerType:C}});try{const a=await Promise.all(r);e(a)}catch(a){console.error("Error generating STLs:",a),e([])}finally{o(!1)}})()},[t]),{stls:A,loading:i}},Ift=_r(vx()),cft=_r(v5()),mo=.01,ig={traces:.001,copper:.002},Fo={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]},nf=.001,ql=32,_L=.035,hc=150,i8=.6,UCA={fr1:Fo.fr1Tan,fr4:Fo.fr4Tan},Bft={fr1:Fo.fr1TracesWithMaskCopper,fr4:Fo.fr4TracesWithoutMaskTan},k9A={fr1:Fo.fr1SolderMaskGreen,fr4:Fo.fr4SolderMaskGreen},lft=_r(dL()),Cft=_r(vx()),Qft=_r(QF()),Eft=_r(TZA()),LCA=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1]}return A/2<=0},HCA=(t,A=1.2,e={})=>{const{xyOutset:i=0}=e,{outline:o}=t;let n=o.map(a=>[a.x,a.y]);LCA(n)&&(n=n.reverse());let s=(0,Cft.polygon)({points:n});i!==0&&(s=(0,Eft.expand)({delta:i,corners:"edge"},s));let r=(0,lft.extrudeLinear)({height:A},s);return r=(0,Qft.translate)([0,0,-A/2],r),r},hft=t=>{const A=t.filter(a=>a.type==="pcb_panel"),e=mi(t).pcb_board.list();let i,o=1.2;if(A.length>0)i=A[0],o=e.find(g=>g.pcb_panel_id===i.pcb_panel_id)?.thickness??1.2;else{if(i=e.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=HCA({outline:i.outline},o):n=(0,Ift.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?e.find(a=>a.pcb_panel_id===i.pcb_panel_id)?.material??"fr4":"fr4",r=UCA[s]??Fo.fr4Tan;return[(0,cft.colorize)(r,n)]},Al=_r(QF()),Ya=_r(vx()),fh=_r(v5()),og=_r(s_()),$s=_r(vx()),Om=_r(v5()),Xr=_r(s_()),G9A=_r(QF()),vL=_r(dL()),Fd=_r(QF()),uft=1e-5;function l0(t,A,e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return 0;const i=t/2,o=A/2,n=Math.min(i,o)-2*uft;return Math.max(0,Math.min(e,n))}function GC(t){if(!(!t||typeof t!="object"))return t.corner_radius??t.cornerRadius??t.rect_pad_border_radius??t.rectPadBorderRadius??t.rect_border_radius??t.rectBorderRadius??void 0}var Yx=_r(vx()),dft=_r(dL()),o8=_r(QF()),pft=_r(s_()),fft=64,yft=(t,A,e)=>{const i=(0,Yx.ellipse)({center:[0,0],radius:[Math.max(t/2,mo/2),Math.max(A/2,mo/2)],segments:fft}),o=(0,dft.extrudeLinear)({height:e},i);return(0,o8.translate)([0,0,-e/2],o)},wft=(t,A,e)=>{const i=Math.max(t,mo),o=Math.max(A,mo);if(Math.abs(i-o)<1e-6)return(0,Yx.cylinder)({center:[0,0,0],radius:i/2,height:e});const n=i>=o,s=n?i:o,r=n?o:i,a=Math.max(s-r,0),g=(0,Yx.cuboid)({center:[0,0,0],size:n?[a,r,e]:[r,a,e]});if(a<=1e-6)return(0,Yx.cylinder)({center:[0,0,0],radius:r/2,height:e});const I=a/2,c=(0,Yx.cylinder)({center:n?[-I,0,0]:[0,-I,0],radius:r/2,height:e}),B=(0,Yx.cylinder)({center:n?[I,0,0]:[0,I,0],radius:r/2,height:e});return(0,pft.union)(g,c,B)},n8=(t,A,e={})=>{const i=t.hole_shape||"circle",o=e.sizeDelta??0,n=t.hole_offset_x||0,s=t.hole_offset_y||0,r=[t.x+n,t.y+s,0];if(i==="circle"){const l=Math.max((t.hole_diameter??0)+o,mo),C=Math.max(l/2,mo/2);return(0,Yx.cylinder)({center:r,radius:C,height:A})}const a=t.hole_width??t.hole_diameter,g=t.hole_height??t.hole_diameter;if(!a||!g)return null;const I=Math.max(a+o,mo),c=Math.max(g+o,mo);if(i==="oval"){const l=yft(I,c,A);return(0,o8.translate)([r[0],r[1],0],l)}if(i==="pill"||i==="rotated_pill"){let l=wft(I,c,A);if(!l)return null;const C=t.ccw_rotation||0;return C&&(l=(0,o8.rotateZ)(C*Math.PI/180,l)),(0,o8.translate)(r,l)}const B=Math.max((t.hole_diameter??a??g??mo)+o,mo);return(0,Yx.cylinder)({center:r,radius:B/2,height:A})},C0=.02,s8=64,uF=(t,A)=>A?(0,Xr.intersect)(A,t):t,y_=({width:t,height:A,thickness:e,center:i,borderRadius:o})=>{const n=l0(t,A,o);if(n<=0)return(0,$s.cuboid)({center:i,size:[t,A,e]});const s=(0,$s.roundedRectangle)({size:[t,A],roundRadius:n,segments:s8}),r=(0,vL.extrudeLinear)({height:e},s),a=i[2]-e/2;return(0,Fd.translate)([i[0],i[1],a],r)},UL=(t,A,e={})=>{const{clipGeom:i}=e;t.shape||(t.shape="circle");const o=A.pcbThickness+2*C0+4*mo,n=A.pcbThickness/2+ig.copper,s=-A.pcbThickness/2-ig.copper,r=n-s;if(t.shape==="circle"){const a=t.outer_diameter??Math.max(t.hole_diameter,0),g=r+.01,I=(0,$s.cylinder)({center:[t.x,t.y,0],radius:a/2,height:g}),c=uF(I,i),B=(0,$s.cylinder)({center:[t.x,t.y,0],radius:Math.max(t.hole_diameter/2,.01),height:o});return(0,Om.colorize)(Fo.copper,(0,Xr.subtract)(c,B))}if(t.shape==="oval"){const a=t.outer_width||t.hole_width||0,g=t.outer_height||t.hole_height||0,I=t.hole_width||0,c=t.hole_height||0,B=(()=>{const Q=(0,$s.cylinder)({center:[0,0,0],radius:1,height:r+.01,segments:64}),E=(0,G9A.scale)([a/2,g/2,1],Q);return(0,Fd.translate)([t.x,t.y,0],E)})(),l=uF(B,i),C=(()=>{const Q=(0,$s.cylinder)({center:[0,0,0],radius:1,height:o,segments:64}),E=(0,G9A.scale)([Math.max(I/2,.01),Math.max(c/2,.01),1],Q);return(0,Fd.translate)([t.x,t.y,0],E)})();return(0,Om.colorize)(Fo.copper,(0,Xr.subtract)(l,C))}if(t.shape==="circular_hole_with_rect_pad"){const a=t.hole_offset_x||0,g=t.hole_offset_y||0,I=t.rect_pad_width||t.hole_diameter,c=t.rect_pad_height||t.hole_diameter,B=GC(t),l=uF((0,Xr.union)(y_({width:I,height:c,thickness:C0,center:[t.x,t.y,n],borderRadius:B}),y_({width:I,height:c,thickness:C0,center:[t.x,t.y,s],borderRadius:B}),(()=>{const h=Math.max(r-C0*2,mo),f=(n+s)/2,m=(0,$s.roundedRectangle)({size:[I,c],roundRadius:B||0,segments:s8}),S=(0,vL.extrudeLinear)({height:h},m);return(0,Fd.translate)([t.x,t.y,f-h/2],S)})(),(0,$s.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:t.hole_diameter/2,height:r})),i),C=(0,$s.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:Math.max(t.hole_diameter/2-mo,.01),height:o}),Q=(0,$s.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:t.hole_diameter/2,height:r});let E=(0,Xr.union)((0,Xr.subtract)(l,Q),Q);return e.clipGeom?(E=(0,Xr.subtract)(E,C),E=(0,Xr.intersect)(E,e.clipGeom),(0,Om.colorize)(Fo.copper,E)):(0,Om.colorize)(Fo.copper,(0,Xr.subtract)(E,C))}if(t.shape==="pill"){const a=(t.ccw_rotation||0)*Math.PI/180,g=k=>{if(!a)return k;const v=(0,Fd.translate)([-t.x,-t.y,0],k),_=(0,Fd.rotate)([0,0,a],v);return(0,Fd.translate)([t.x,t.y,0],_)},I=t.hole_height>t.hole_width,c=I?t.hole_height:t.hole_width,B=I?t.hole_width:t.hole_height,l=I?t.outer_height||B+.2:t.outer_width||c+.2,C=I?t.outer_width||c+.2:t.outer_height||B+.2,Q=B/2,E=Math.abs(c-B),h=r+.01,d=((k,v,_)=>{const H=v/2,P=Math.abs(k-v);if(P<=1e-6)return(0,$s.cylinder)({center:[t.x,t.y,0],radius:H,height:_});const J=(0,$s.cuboid)({center:[t.x,t.y,0],size:I?[v,P,_]:[P,v,_]}),W=(0,$s.cylinder)({center:I?[t.x,t.y-P/2,0]:[t.x-P/2,t.y,0],radius:H,height:_}),Z=(0,$s.cylinder)({center:I?[t.x,t.y+P/2,0]:[t.x+P/2,t.y,0],radius:H,height:_});return(0,Xr.union)(J,W,Z)})(l,C,h),f=(0,$s.cuboid)({center:[t.x,t.y,0],size:I?[B-2*mo,E,o]:[E,B-2*mo,o]}),m=(0,$s.cylinder)({center:I?[t.x,t.y-E/2,0]:[t.x-E/2,t.y,0],radius:Q-mo,height:o}),S=(0,$s.cylinder)({center:I?[t.x,t.y+E/2,0]:[t.x+E/2,t.y,0],radius:Q-mo,height:o}),D=(0,Xr.union)(f,m,S),x=uF(g(d),i),F=g(D);return(0,Om.colorize)(Fo.copper,(0,Xr.subtract)(x,F))}if(t.shape==="pill_hole_with_rect_pad"){if(t.hole_shape&&t.hole_shape!=="pill"||t.pad_shape&&t.pad_shape!=="rect")throw new Error("Invalid hole_shape or pad_shape for pill_hole_with_rect_pad");const a=t.hole_offset_x||0,g=t.hole_offset_y||0,I=t.hole_height>t.hole_width,c=I?t.hole_height:t.hole_width,B=I?t.hole_width:t.hole_height,l=B/2,C=Math.abs(c-B),Q=t.rect_pad_width||c+.2,E=t.rect_pad_height||B+.2,h=GC(t),u=.03,d=(0,Xr.union)((0,$s.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B+2*u,C+2*u,r]:[C+2*u,B+2*u,r]}),(0,$s.cylinder)({center:I?[t.x+a,t.y+g-C/2,0]:[t.x+a-C/2,t.y+g,0],radius:l+u,height:r}),(0,$s.cylinder)({center:I?[t.x+a,t.y+g+C/2,0]:[t.x+a+C/2,t.y+g,0],radius:l+u,height:r})),f=(0,Xr.union)((0,$s.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B,C,o*1.1]:[C,B,o*1.1]}),(0,$s.cylinder)({center:I?[t.x+a,t.y+g-C/2,0]:[t.x+a-C/2,t.y+g,0],radius:l,height:o*1.1}),(0,$s.cylinder)({center:I?[t.x+a,t.y+g+C/2,0]:[t.x+a+C/2,t.y+g,0],radius:l,height:o*1.1})),m=y_({width:Q,height:E,thickness:C0,center:[t.x,t.y,n],borderRadius:h}),S=y_({width:Q,height:E,thickness:C0,center:[t.x,t.y,s],borderRadius:h}),D=(()=>{const P=Math.max(r-C0*2,mo),Z=(n+s)/2,AA=(0,$s.roundedRectangle)({size:[Q,E],roundRadius:h||0,segments:s8}),nA=(0,vL.extrudeLinear)({height:P},AA);return(0,Fd.translate)([t.x,t.y,Z-P/2],nA)})(),x=(0,Xr.subtract)(m,f),F=(0,Xr.subtract)(S,f),k=(0,Xr.subtract)(D,f),v=(0,Xr.union)((0,$s.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B-2*mo,C-2*mo,o*1.1]:[C-2*mo,B-2*mo,o*1.1]}),(0,$s.cylinder)({center:I?[t.x+a,t.y+g-C/2,0]:[t.x+a-C/2,t.y+g,0],radius:l-mo,height:o*1.1}),(0,$s.cylinder)({center:I?[t.x+a,t.y+g+C/2,0]:[t.x+a+C/2,t.y+g,0],radius:l-mo,height:o*1.1})),_=(0,Xr.subtract)(d,v),H=uF((0,Xr.union)(x,F,k,_),i);return(0,Om.colorize)(Fo.copper,H)}else if(t.shape==="rotated_pill_hole_with_rect_pad"){if(t.hole_shape&&t.hole_shape!=="rotated_pill"||t.pad_shape&&t.pad_shape!=="rect")throw new Error("Invalid hole_shape or pad_shape for rotated_pill_hole_with_rect_pad");const a=t.hole_offset_x||0,g=t.hole_offset_y||0,I=t.hole_width,c=t.hole_height,B=I>=c,l=B?I:c,C=B?c:I,Q=C/2,E=Math.abs(l-C),h=t.rect_pad_width||I+.2,u=t.rect_pad_height||c+.2,d=GC(t),f=.03,m=(t.hole_ccw_rotation||0)*Math.PI/180,S=(t.rect_ccw_rotation||0)*Math.PI/180,D=gA=>{const tA=a*Math.cos(m)-g*Math.sin(m),iA=a*Math.sin(m)+g*Math.cos(m),rA=(0,Fd.rotate)([0,0,m],gA);return(0,Fd.translate)([t.x+tA,t.y+iA,0],rA)},x=gA=>{if(!S)return gA;const tA=(0,Fd.translate)([-t.x,-t.y,0],gA),iA=(0,Fd.rotate)([0,0,S],tA);return(0,Fd.translate)([t.x,t.y,0],iA)},F=D((0,Xr.union)((0,$s.cuboid)({center:[0,0,0],size:B?[E+2*f,C+2*f,r]:[C+2*f,E+2*f,r]}),(0,$s.cylinder)({center:B?[-E/2,0,0]:[0,-E/2,0],radius:Q+f,height:r}),(0,$s.cylinder)({center:B?[E/2,0,0]:[0,E/2,0],radius:Q+f,height:r}))),k=D((0,Xr.union)((0,$s.cuboid)({center:[0,0,0],size:B?[E,C,o*1.1]:[C,E,o*1.1]}),(0,$s.cylinder)({center:B?[-E/2,0,0]:[0,-E/2,0],radius:Q,height:o*1.1}),(0,$s.cylinder)({center:B?[E/2,0,0]:[0,E/2,0],radius:Q,height:o*1.1}))),v=x(y_({width:h,height:u,thickness:C0,center:[t.x,t.y,n],borderRadius:d})),_=x(y_({width:h,height:u,thickness:C0,center:[t.x,t.y,s],borderRadius:d})),H=x((()=>{const gA=Math.max(r-C0*2,mo),rA=(n+s)/2,CA=(0,$s.roundedRectangle)({size:[h,u],roundRadius:d||0,segments:s8}),dA=(0,vL.extrudeLinear)({height:gA},CA);return(0,Fd.translate)([t.x,t.y,rA-gA/2],dA)})()),P=(0,Xr.subtract)(v,k),J=(0,Xr.subtract)(_,k),W=(0,Xr.subtract)(H,k),Z=D((0,Xr.union)((0,$s.cuboid)({center:[0,0,0],size:B?[E-2*mo,C-2*mo,o*1.1]:[C-2*mo,E-2*mo,o*1.1]}),(0,$s.cylinder)({center:B?[-E/2,0,0]:[0,-E/2,0],radius:Q-mo,height:o*1.1}),(0,$s.cylinder)({center:B?[E/2,0,0]:[0,E/2,0],radius:Q-mo,height:o*1.1}))),AA=(0,Xr.subtract)(F,Z),nA=uF((0,Xr.union)(P,J,W,AA),i);return(0,Om.colorize)(Fo.copper,nA)}else if(t.shape==="hole_with_polygon_pad"){const a=t.pad_outline;if(!Array.isArray(a)||a.length<3)throw new Error(`Invalid pad_outline for plated hole at (${t.x}, ${t.y})`);const g=a.map(f=>[f.x,f.y]),I=(0,$s.polygon)({points:g}),c=(n+s)/2,B=(f,m)=>{const S=Math.max(f,mo),D=(0,vL.extrudeLinear)({height:S},I);return(0,Fd.translate)([t.x,t.y,m-S/2],D)},l=B(Math.max(r-C0*2,mo),c),C=B(C0,n),Q=B(C0,s),E=uF((0,Xr.union)(l,C,Q),i),h=n8(t,r);if(!h)return(0,Om.colorize)(Fo.copper,E);const u=n8(t,o,{sizeDelta:-2*mo})||h;let d=(0,Xr.union)((0,Xr.subtract)(E,h),h);return e.clipGeom?(d=(0,Xr.subtract)(d,u),d=(0,Xr.intersect)(d,e.clipGeom),(0,Om.colorize)(Fo.copper,d)):(0,Om.colorize)(Fo.copper,(0,Xr.subtract)(d,u))}else throw new Error(`Unsupported plated hole shape: ${t.shape}`)},w_=_r(dL()),F9A=_r(vx()),mft=_r(s_());function Dft(t,A,e,i){if(!e||Math.abs(e)<1e-9)return[];const o=4*Math.atan(e),n=A[0]-t[0],s=A[1]-t[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))),I=[(t[0]+A[0])/2,(t[1]+A[1])/2],c=n/r,l=-(s/r),C=c,Q=I[0]+l*g*Math.sign(e),E=I[1]+C*g*Math.sign(e),h=Math.atan2(t[1]-E,t[0]-Q),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 S=h+f*m;u.push([Q+a*Math.cos(S),E+a*Math.sin(S)])}return u}function r8(t,A){const e=[],i=t.vertices;for(let o=0;o<i.length;o++){const n=i[o],s=i[(o+1)%i.length];if(e.push([n.x,n.y]),n.bulge){const r=Dft([n.x,n.y],[s.x,s.y],n.bulge,A);e.push(...r)}}return e}function R9A(t){let A=0;for(let e=0;e<t.length;e++){const i=(e+1)%t.length;A+=t[e][0]*t[i][1],A-=t[i][0]*t[e][1]}return A/2<=0}function Sft(t,A=16){let e=r8(t.outer_ring,A);R9A(e)&&e.reverse();const i=(0,F9A.polygon)({points:e});if(!t.inner_rings||t.inner_rings.length===0)return i;const o=t.inner_rings.map(n=>{let s=r8(n,A);return R9A(s)&&s.reverse(),(0,F9A.polygon)({points:s})});return o.length===0?i:(0,mft.subtract)(i,o)}var M9A=_r(s_()),bft=_r(QF()),LL=_r(vx());function xft({x:t,y:A,outerDiameter:e,holeDiameter:i,thickness:o}){if(e<=i)throw new Error(`Invalid via geometry: outerDiameter (${e}) must be > holeDiameter (${i})`);const n=mo,s=mo,r=Math.min(e/2,i/2+s),a=(0,LL.cylinder)({center:[0,0,0],radius:r,height:o,segments:ql}),g=(0,LL.cylinder)({center:[0,0,o/2],radius:e/2,height:n,segments:ql}),I=(0,LL.cylinder)({center:[0,0,-o/2],radius:e/2,height:n,segments:ql}),c=(0,M9A.union)([a,g,I]),B=o+n*2,l=(0,LL.cylinder)({center:[0,0,0],radius:i/2,height:B,segments:ql}),C=(0,M9A.subtract)(c,l);return(0,bft.translate)([t,A,0],C)}function kft({x:t,y:A,holeDiameter:e,thickness:i}){const o=i*1.5,n=e/2+mo;return(0,LL.cylinder)({center:[t,A,0],radius:n,height:o,segments:ql})}var N9A=64,Gft=1,YCA=.05,_9A=(t,A,e,i)=>{const o=l0(t,A,i);if(o<=0)return(0,Ya.cuboid)({center:[0,0,0],size:[t,A,e]});const n=(0,Ya.roundedRectangle)({size:[t,A],roundRadius:o,segments:N9A}),s=(0,w_.extrudeLinear)({height:e},n);return(0,Al.translate)([0,0,-e/2],s)},v9A=["initializing","processing_pads","processing_copper_pours","processing_plated_holes","processing_holes","processing_cutouts","processing_vias","finalizing","done"],Fft=class{circuitJson;board;plated_holes;holes;pads;traces;pcb_vias;pcb_cutouts;pcb_copper_pours;boardGeom=null;platedHoleGeoms=[];padGeoms=[];viaGeoms=[];copperPourGeoms=[];boardClipGeom=null;state="initializing";currentIndex=0;ctx;onCompleteCallback;finalGeoms=[];getHoleToCut(t,A){const e=mo/10;for(const i of this.pcb_vias)if(Math.abs(i.x-t)<e&&Math.abs(i.y-A)<e&&i.hole_diameter)return{diameter:i.hole_diameter};for(const i of this.plated_holes)if(i.shape==="circle"&&Math.abs(i.x-t)<e&&Math.abs(i.y-A)<e&&i.hole_diameter)return{diameter:i.hole_diameter};return null}constructor(t,A){this.circuitJson=t,this.onCompleteCallback=A;const e=t.filter(o=>o.type==="pcb_panel"),i=mi(t).pcb_board.list();if(e.length>0){const o=e[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=mi(t).pcb_plated_hole.list(),this.holes=mi(t).pcb_hole.list(),this.pads=mi(t).pcb_smtpad.list(),this.traces=mi(t).pcb_trace.list(),this.pcb_vias=mi(t).pcb_via.list(),this.pcb_cutouts=mi(t).pcb_cutout.list(),this.pcb_copper_pours=t.filter(o=>o.type==="pcb_copper_pour"),this.ctx={pcbThickness:this.board.thickness??1.2},this.initializeBoard()}initializeBoard(){const t=this.ctx.pcbThickness+2*Gft;this.board.outline&&this.board.outline.length>0?(this.boardGeom=HCA({outline:this.board.outline},this.ctx.pcbThickness),this.boardClipGeom=HCA({outline:this.board.outline},t,{xyOutset:YCA})):(this.boardGeom=(0,Ya.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.boardClipGeom=(0,Ya.cuboid)({size:[this.board.width+2*YCA,this.board.height+2*YCA,t],center:[this.board.center.x,this.board.center.y,0]})),this.state="processing_pads",this.currentIndex=0}goToNextState(){const t=v9A.indexOf(this.state);t!==-1&&(this.state=v9A[t+1],this.currentIndex=0)}step(t=1){if(this.state==="done"||!this.boardGeom)return!0;for(let A=0;A<t&&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"processing_copper_pours":this.currentIndex<this.pcb_copper_pours.length?(this.processCopperPour(this.pcb_copper_pours[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"finalizing":this.finalize(),this.state="done";break}return this.state==="done"}processCutout(t){if(!this.boardGeom)return;let A=null;const e=this.ctx.pcbThickness*1.5;switch(t.shape){case"rect":{const i=l0(t.width,t.height,GC(t));if(i>0){const o=(0,Ya.roundedRectangle)({size:[t.width,t.height],roundRadius:i,segments:N9A});A=(0,w_.extrudeLinear)({height:e},o),A=(0,Al.translate)([0,0,-e/2],A)}else A=(0,Ya.cuboid)({center:[0,0,0],size:[t.width,t.height,e]});if(t.rotation){const o=t.rotation*Math.PI/180;A=(0,Al.rotateZ)(o,A)}A=(0,Al.translate)([t.center.x,t.center.y,0],A);break}case"circle":A=(0,Ya.cylinder)({center:[t.center.x,t.center.y,0],radius:t.radius,height:e});break;case"polygon":{let i=t.points.map(n=>[n.x,n.y]);if(i.length<3){console.warn(`PCB Cutout [${t.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}LCA(i)&&(i=i.reverse());const o=(0,Ya.polygon)({points:i});A=(0,w_.extrudeLinear)({height:e},o),A=(0,Al.translate)([0,0,-e/2],A);break}}A&&(this.boardGeom=(0,og.subtract)(this.boardGeom,A))}processCopperPour(t){const A=t.layer==="bottom"?-1:1,e=A*this.ctx.pcbThickness/2+A*ig.copper;let i=null;if(t.shape==="rect"){let o=(0,Ya.cuboid)({center:[0,0,0],size:[t.width,t.height,mo]});if("rotation"in t&&t.rotation){const n=t.rotation*Math.PI/180;o=(0,Al.rotateZ)(n,o)}i=(0,Al.translate)([t.center.x,t.center.y,e],o)}else if(t.shape==="brep"){const o=t.brep_shape;if(o?.outer_ring){const n=Sft(o);i=(0,w_.extrudeLinear)({height:mo},n),i=(0,Al.translate)([0,0,e],i)}}else if(t.shape==="polygon"){let o=t.points.map(s=>[s.x,s.y]);if(o.length<3){console.warn(`PCB Copper Pour [${t.pcb_copper_pour_id}] polygon has fewer than 3 points, skipping.`);return}LCA(o)&&(o=o.reverse());const n=(0,Ya.polygon)({points:o});i=(0,w_.extrudeLinear)({height:mo},n),i=(0,Al.translate)([0,0,e],i)}if(i){this.boardClipGeom&&(i=(0,og.intersect)(this.boardClipGeom,i));const n=t.covered_with_solder_mask!==!1?Bft[this.board.material]??Fo.fr4TracesWithoutMaskTan:Fo.copper,s=(0,fh.colorize)(n,i);this.copperPourGeoms.push(s)}}processPlatedHole(t,A={}){if(this.boardGeom){if(t.shape==="circle"||t.shape==="circular_hole_with_rect_pad"){let e=null;if(t.shape==="circular_hole_with_rect_pad"){if(t.hole_shape&&t.hole_shape!=="circle"||t.pad_shape&&t.pad_shape!=="rect")return;e=(0,Ya.cylinder)({center:[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0),0],radius:t.hole_diameter/2+mo,height:this.ctx.pcbThickness*1.5})}else e=(0,Ya.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+mo,height:this.ctx.pcbThickness*1.5});A.dontCutBoard||(this.boardGeom=(0,og.subtract)(this.boardGeom,e)),this.padGeoms=this.padGeoms.map(o=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(o,e)));const i=UL(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(i)}else if(t.shape==="pill"||t.shape==="oval"){const e=t.hole_height>t.hole_width,i=e?t.hole_height:t.hole_width,o=e?t.hole_width:t.hole_height,n=o/2,s=Math.abs(i-o);let r;if(r=(0,og.union)((0,Ya.cuboid)({center:[t.x,t.y,0],size:e?[o,s,this.ctx.pcbThickness*1.5]:[s,o,this.ctx.pcbThickness*1.5]}),(0,Ya.cylinder)({center:e?[t.x,t.y-s/2,0]:[t.x-s/2,t.y,0],radius:n,height:this.ctx.pcbThickness*1.5}),(0,Ya.cylinder)({center:e?[t.x,t.y+s/2,0]:[t.x+s/2,t.y,0],radius:n,height:this.ctx.pcbThickness*1.5})),t.ccw_rotation){const g=t.ccw_rotation*Math.PI/180;r=(0,Al.translate)([t.x,t.y,0],(0,Al.rotateZ)(g,(0,Al.translate)([-t.x,-t.y,0],r)))}A.dontCutBoard||(this.boardGeom=(0,og.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(g,r)));const a=UL(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(a)}else if(t.shape==="pill_hole_with_rect_pad"){if(t.hole_shape&&t.hole_shape!=="pill"||t.pad_shape&&t.pad_shape!=="rect")return;const e=t.hole_height>t.hole_width,i=e?t.hole_height:t.hole_width,o=e?t.hole_width:t.hole_height,n=o/2,s=Math.abs(i-o);let r;r=(0,og.union)((0,Ya.cuboid)({center:[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0),0],size:e?[o,s,this.ctx.pcbThickness*1.5]:[s,o,this.ctx.pcbThickness*1.5]}),(0,Ya.cylinder)({center:e?[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0)-s/2,0]:[t.x+(t.hole_offset_x||0)-s/2,t.y+(t.hole_offset_y||0),0],radius:n,height:this.ctx.pcbThickness*1.5}),(0,Ya.cylinder)({center:e?[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0)+s/2,0]:[t.x+(t.hole_offset_x||0)+s/2,t.y+(t.hole_offset_y||0),0],radius:n,height:this.ctx.pcbThickness*1.5})),A.dontCutBoard||(this.boardGeom=(0,og.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(g,r)));const a=UL(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(a)}else if(t.shape==="rotated_pill_hole_with_rect_pad"){if(t.hole_shape&&t.hole_shape!=="rotated_pill"||t.pad_shape&&t.pad_shape!=="rect")return;const e=t.hole_width,i=t.hole_height,o=e>=i,n=o?e:i,s=o?i:e,r=s/2,a=Math.abs(n-s),g=t.hole_offset_x||0,I=t.hole_offset_y||0;let c=(0,og.union)((0,Ya.cuboid)({center:[0,0,0],size:o?[a,s,this.ctx.pcbThickness*1.5]:[s,a,this.ctx.pcbThickness*1.5]}),(0,Ya.cylinder)({center:o?[-a/2,0,0]:[0,-a/2,0],radius:r,height:this.ctx.pcbThickness*1.5}),(0,Ya.cylinder)({center:o?[a/2,0,0]:[0,a/2,0],radius:r,height:this.ctx.pcbThickness*1.5}));const B=(t.hole_ccw_rotation||0)*Math.PI/180,l=g*Math.cos(B)-I*Math.sin(B),C=g*Math.sin(B)+I*Math.cos(B);c=(0,Al.rotateZ)(B,c);const Q=(0,Al.translate)([t.x+l,t.y+C,0],c);A.dontCutBoard||(this.boardGeom=(0,og.subtract)(this.boardGeom,Q)),this.padGeoms=this.padGeoms.map(h=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(h,Q)));const E=UL(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(E)}else if(t.shape==="hole_with_polygon_pad"){const e=t.pad_outline;if(!Array.isArray(e)||e.length<3)return;const i=this.ctx.pcbThickness*1.5,o=n8(t,i,{sizeDelta:2*mo}),n=n8(t,i,{sizeDelta:-2*mo});if(!o||!n)return;A.dontCutBoard||(this.boardGeom=(0,og.subtract)(this.boardGeom,o)),this.padGeoms=this.padGeoms.map(r=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(r,o))),this.platedHoleGeoms=this.platedHoleGeoms.map(r=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(r,n)));const s=UL(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(s)}}}processHole(t){if(!this.boardGeom)return;const A=this.ctx.pcbThickness*1.5;if(t.hole_shape==="circle"){const e=(0,Ya.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+mo,height:A});this.boardGeom=(0,og.subtract)(this.boardGeom,e),this.padGeoms=this.padGeoms.map(o=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(o,e)));const i=(0,Ya.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+mo/2,height:A});this.platedHoleGeoms=this.platedHoleGeoms.map(o=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(o,i)))}else if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"||t.hole_shape==="oval"){const e=t.hole_width??t.hole_diameter,i=t.hole_height??t.hole_diameter,o=t.ccw_rotation??t.rotation??0,n=.02,s=(g,I,c,B)=>{if(g<=0||I<=0)return null;if(B)return(0,Al.translate)([0,0,-c/2],(0,w_.extrudeLinear)({height:c},(0,Ya.ellipse)({radius:[g/2,I/2]})));const l=Math.min(g,I)/2,C=Math.abs(g-I);return g>I?(0,og.union)((0,Ya.cuboid)({center:[0,0,0],size:[C,I,c]}),(0,Ya.cylinder)({center:[-C/2,0,0],radius:l,height:c}),(0,Ya.cylinder)({center:[C/2,0,0],radius:l,height:c})):(0,og.union)((0,Ya.cuboid)({center:[0,0,0],size:[g,C,c]}),(0,Ya.cylinder)({center:[0,-C/2,0],radius:l,height:c}),(0,Ya.cylinder)({center:[0,C/2,0],radius:l,height:c}))};let r=s(e,i,A,t.hole_shape==="oval"),a=s(e-2*n,i-2*n,A,t.hole_shape==="oval");if(r&&o!==0&&(r=(0,Al.rotateZ)(o*Math.PI/180,r)),a&&o!==0&&(a=(0,Al.rotateZ)(o*Math.PI/180,a)),r){const g=(0,Al.translate)([t.x,t.y,0],r);this.boardGeom=(0,og.subtract)(this.boardGeom,g),this.padGeoms=this.padGeoms.map(I=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(I,g)))}if(a){const g=(0,Al.translate)([t.x,t.y,0],a);this.platedHoleGeoms=this.platedHoleGeoms.map(I=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(I,g)))}}}processPad(t){const A=t.layer==="bottom"?-1:1,e=A*this.ctx.pcbThickness/2+A*ig.copper,i=GC(t);if(t.shape==="rect"){const o=_9A(t.width,t.height,mo,i);let s=(0,Al.translate)([t.x,t.y,e],o);this.boardClipGeom&&(s=(0,og.intersect)(this.boardClipGeom,s)),s=(0,fh.colorize)(Fo.copper,s),this.padGeoms.push(s)}else if(t.shape==="rotated_rect"){let o=_9A(t.width,t.height,mo,i);const n=t.ccw_rotation*Math.PI/180;o=(0,Al.rotateZ)(n,o);let r=(0,Al.translate)([t.x,t.y,e],o);this.boardClipGeom&&(r=(0,og.intersect)(this.boardClipGeom,r)),r=(0,fh.colorize)(Fo.copper,r),this.padGeoms.push(r)}else if(t.shape==="circle"){let o=(0,Ya.cylinder)({center:[t.x,t.y,e],radius:t.radius,height:mo});this.boardClipGeom&&(o=(0,og.intersect)(this.boardClipGeom,o)),o=(0,fh.colorize)(Fo.copper,o),this.padGeoms.push(o)}}processVia(t){if(this.boardGeom){if(typeof t.outer_diameter=="number"&&typeof t.hole_diameter=="number"){const A=xft({x:t.x,y:t.y,outerDiameter:t.outer_diameter,holeDiameter:t.hole_diameter,thickness:this.ctx.pcbThickness});let e=A;this.boardClipGeom&&(e=(0,og.intersect)(this.boardClipGeom,A),e=(0,fh.colorize)(Fo.copper,e)),this.viaGeoms.push(e)}if(typeof t.hole_diameter=="number"){const A=kft({x:t.x,y:t.y,holeDiameter:t.hole_diameter,thickness:this.ctx.pcbThickness});this.boardGeom=(0,og.subtract)(this.boardGeom,A),this.padGeoms=this.padGeoms.map(e=>(0,fh.colorize)(Fo.copper,(0,og.subtract)(e,A)))}}}finalize(){if(!this.boardGeom)return;const t=UCA[this.board.material]??Fo.fr4Tan;this.boardGeom=(0,fh.colorize)(t,this.boardGeom),this.finalGeoms=[this.boardGeom,...this.platedHoleGeoms,...this.padGeoms,...this.viaGeoms,...this.copperPourGeoms],this.onCompleteCallback&&this.onCompleteCallback(this.finalGeoms)}getGeoms(){return this.finalGeoms}},Rft=t=>{const[A,e]=j.useState(null),i=j.useRef(!1);return j.useEffect(()=>{let o=!1;if(!t){e(null);return}if(!t.some(g=>g.type==="pcb_board"||g.type==="pcb_panel")){e(null);return}const s=hft(t);e(s);const r=new Fft(t,g=>{});return(async()=>{if(!i.current){i.current=!0;try{let g=!1;for(;!g&&!o;)g=r.step(1),g||await new Promise(I=>setTimeout(I,0));o||e(r.getGeoms())}catch(g){console.error("Error during board geometry building:",g)}finally{i.current=!1}}})(),()=>{o=!0}},[t]),A},Mft=({children:t,parent:A,position:e,rotation:i,scale:o,color:n,fontSize:s,anchorX:r,anchorY:a,depthOffset:g})=>{const{rootObject:I}=Ru(),c=j.useMemo(()=>{const B=new gnA;return B.text=t,e&&B.position.fromArray(e),i&&B.rotation.fromArray(i),o&&B.scale.fromArray(o),B.color=n||"white",B.fontSize=s||1,B.anchorX=r||"center",B.anchorY=a||"middle",B.depthOffset=g||0,B.font=null,B.sync(),B},[t,e,i,o,n,s,r,a,g]);return j.useEffect(()=>{const B=A||I;if(!(!B||!c))return B.add(c),()=>{B.remove(c),c.dispose()}},[I,A,c]),null},U9A=({error:t,cad_component:A})=>{const{rootObject:e}=Ru(),[i,o]=j.useState(!1),[n,s]=j.useState(null),r=j.useCallback(c=>{c?.mousePosition?(o(!0),s(c.mousePosition)):(o(!1),s(null))},[]),a=j.useCallback(()=>{o(!1),s(null)},[]),g=j.useMemo(()=>A?.position?[A.position.x,A.position.y,A.position.z].map(B=>Number.isNaN(B)?0:B):[0,0,0],[A]),I=j.useMemo(()=>{const c=new ef;return c.position.fromArray(g),c},[g]);return j.useEffect(()=>{if(e)return e.add(I),()=>{e.remove(I)}},[e,I]),O.jsxs(O.Fragment,{children:[O.jsxs(NL,{isHovered:i,onHover:r,onUnhover:a,object:I,children:[O.jsx(Nft,{parent:I}),O.jsx(Mft,{parent:I,scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:`${t.toString().slice(0,50)}...`})]}),i&&n?O.jsx(zZA,{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:t.toString()}):null]})},Nft=({parent:t})=>{const A=j.useMemo(()=>{const e=new Vo(new Fw(.5,.5,.5),new hh({depthTest:!1,transparent:!0,color:"red",opacity:.5}));return e.renderOrder=999999,e.rotation.fromArray([Math.PI/4,Math.PI/4,0]),e},[]);return j.useEffect(()=>(t.add(A),()=>{t.remove(A)}),[t,A]),null};function _ft({stlUrl:t,stlData:A,mtlUrl:e,color:i,opacity:o=1}){const{rootObject:n}=Ru(),[s,r]=j.useState(null);j.useEffect(()=>{const g=new u7e;if(A){try{const I=g.parse(A);r(I)}catch(I){console.error("Failed to parse STL data",I),r(null)}return}t&&g.load(t,I=>{r(I)})},[t,A]);const a=j.useMemo(()=>{if(!s)return null;const g=new hh({color:Array.isArray(i)?new Li(i[0],i[1],i[2]):i,transparent:o!==1,opacity:o});return new Vo(s,g)},[s,i,o]);return j.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 vft({stlData:t,color:A,opacity:e=1,layerType:i}){const{visibility:o}=r_();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?O.jsx(_ft,{stlData:t,color:A,opacity:e}):null}var L9A=class extends Xi.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},Uft=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,o=t[0].y;for(let n=1;n<t.length;n++){const s=t[n];s.x<A&&(A=s.x),s.y<e&&(e=s.y),s.x>i&&(i=s.x),s.y>o&&(o=s.y)}return{minX:A,minY:e,maxX:i,maxY:o}};function dF(t){if(t.outline&&t.outline.length>=3){const s=Uft(t.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=t.width??0,e=t.height??0,i=t.center?.x??0,o=t.center?.y??0;return{...{minX:i-A/2,maxX:i+A/2,minY:o-e/2,maxY:o+e/2},width:A,height:e,centerX:i,centerY:o}}function a8({layer:t,circuitJson:A,boardData:e,soldermaskColor:i,traceTextureResolution:o}){const n=dF(e),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;t==="bottom"&&(g.translate(0,a),g.scale(1,-1));const I=f=>(f-n.minX)*o,c=f=>(n.maxY-f)*o;if(g.fillStyle=i,e.outline&&e.outline.length>=3){g.beginPath();const f=e.outline[0];g.moveTo(I(f.x),c(f.y));for(let m=1;m<e.outline.length;m++){const S=e.outline[m];g.lineTo(I(S.x),c(S.y))}g.closePath(),g.fill()}else g.fillRect(0,0,r,a);g.globalCompositeOperation="destination-out",g.fillStyle="black",mi(A).pcb_smtpad.list().filter(f=>f.layer===t).forEach(f=>{if(f.shape==="polygon"&&f.points){g.beginPath(),f.points.forEach((F,k)=>{const v=I(F.x),_=c(F.y);k===0?g.moveTo(v,_):g.lineTo(v,_)}),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,S=f.y,D=I(m),x=c(S);if(f.shape==="rect"){const F=f.width*o,k=f.height*o,v=GC(f),_=l0(f.width,f.height,v)*o;_>0?(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill()):g.fillRect(D-F/2,x-k/2,F,k)}else if(f.shape==="circle"){const F=(f.radius??f.width/2)*o;g.beginPath(),g.arc(D,x,F,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const F=f.width*o,k=f.height*o,v=GC(f),_=l0(f.width,f.height,v)*o;g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill()}else if(f.shape==="rotated_rect"){const F=f.width*o,k=f.height*o,v=GC(f),_=l0(f.width,f.height,v)*o,P=-(f.ccw_rotation||0)*(Math.PI/180);g.save(),g.translate(D,x),g.rotate(P),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()}}),mi(A).pcb_via.list().forEach(f=>{const m=I(f.x),S=c(f.y),D=f.outer_diameter/2*o;g.beginPath(),g.arc(m,S,D,0,2*Math.PI),g.fill()}),mi(A).pcb_plated_hole.list().forEach(f=>{if(!f.layers?.includes(t))return;const m=f.x,S=f.y,D=I(m),x=c(S);if(f.shape==="circle"){const k=f.outer_diameter/2*o;g.beginPath(),g.arc(D,x,k,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const F=(f.outer_width??f.outer_diameter??f.hole_width)*o,k=(f.outer_height??f.outer_diameter??f.hole_height)*o,v=Math.min(F,k)/2,H=-(f.ccw_rotation||0);H?(g.save(),g.translate(D,x),g.rotate(H*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,v),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,v),g.fill())}else if(f.shape==="oval"){const F=(f.outer_width??f.outer_diameter??f.hole_width)*o,k=(f.outer_height??f.outer_diameter??f.hole_height)*o,v=F/2,_=k/2,P=-(f.ccw_rotation||0);P?(g.save(),g.translate(D,x),g.rotate(P*Math.PI/180),g.beginPath(),g.ellipse(0,0,v,_,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(D,x,v,_,0,0,2*Math.PI),g.fill())}else if(f.shape==="hole_with_polygon_pad"){const F=f.hole_shape||"circle",k=f.hole_offset_x||0,v=f.hole_offset_y||0,_=I(f.x+k),H=c(f.y+v);if(F==="pill"||F==="rotated_pill"){const P=(f.outer_width??f.outer_diameter??f.hole_width)*o,J=(f.outer_height??f.outer_diameter??f.hole_height)*o,W=Math.min(P,J)/2,AA=-(f.ccw_rotation||0);AA?(g.save(),g.translate(_,H),g.rotate(AA*Math.PI/180),g.beginPath(),g.roundRect(-P/2,-J/2,P,J,W),g.fill(),g.restore()):(g.beginPath(),g.roundRect(_-P/2,H-J/2,P,J,W),g.fill())}else if(F==="oval"){const P=(f.outer_width??f.outer_diameter??f.hole_width)*o,J=(f.outer_height??f.outer_diameter??f.hole_height)*o,W=P/2,Z=J/2,nA=-(f.ccw_rotation||0);nA?(g.save(),g.translate(_,H),g.rotate(nA*Math.PI/180),g.beginPath(),g.ellipse(0,0,W,Z,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(_,H,W,Z,0,0,2*Math.PI),g.fill())}else if(F==="circle"){const J=(f.outer_diameter??f.hole_diameter??0)*o/2;g.beginPath(),g.arc(_,H,J,0,2*Math.PI),g.fill()}f.pad_outline&&f.pad_outline.length>=3&&(g.beginPath(),f.pad_outline.forEach((P,J)=>{const W=I(f.x+P.x),Z=c(f.y+P.y);J===0?g.moveTo(W,Z):g.lineTo(W,Z)}),g.closePath(),g.fill())}else if(f.shape==="circular_hole_with_rect_pad"){const F=(f.rect_pad_width??f.hole_diameter??0)*o,k=(f.rect_pad_height??f.hole_diameter??0)*o,v=GC(f),_=l0(f.rect_pad_width??f.hole_diameter??0,f.rect_pad_height??f.hole_diameter??0,v)*o;_>0?(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill()):g.fillRect(D-F/2,x-k/2,F,k)}else if(f.shape==="pill_hole_with_rect_pad"){const F=(f.rect_pad_width??f.hole_width??0)*o,k=(f.rect_pad_height??f.hole_height??0)*o,v=GC(f),_=l0(f.rect_pad_width??f.hole_width??0,f.rect_pad_height??f.hole_height??0,v)*o,P=-(f.ccw_rotation||0);P?(g.save(),g.translate(D,x),g.rotate(P*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill())}else if(f.shape==="rotated_pill_hole_with_rect_pad"){const F=(f.rect_pad_width??f.hole_width??0)*o,k=(f.rect_pad_height??f.hole_height??0)*o,v=GC(f),_=l0(f.rect_pad_width??f.hole_width??0,f.rect_pad_height??f.hole_height??0,v)*o,P=-(f.rect_ccw_rotation||0);P?(g.save(),g.translate(D,x),g.rotate(P*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill())}}),mi(A).pcb_hole.list().forEach(f=>{const m=f.x,S=f.y,D=I(m),x=c(S),F=f.hole_shape;if(F==="circle"&&typeof f.hole_diameter=="number"){const k=f.hole_diameter/2*o;g.beginPath(),g.arc(D,x,k,0,2*Math.PI),g.fill()}else if(F==="pill"&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const k=f.hole_width*o,v=f.hole_height*o,_=Math.min(k,v)/2;g.beginPath(),g.roundRect(D-k/2,x-v/2,k,v,_),g.fill()}else if(F==="rotated_pill"&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const k=f.hole_width*o,v=f.hole_height*o,_=Math.min(k,v)/2,P=-(f.ccw_rotation||0)*(Math.PI/180);P?(g.save(),g.translate(D,x),g.rotate(P),g.beginPath(),g.roundRect(-k/2,-v/2,k,v,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-k/2,x-v/2,k,v,_),g.fill())}else if(F==="oval"&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const k=f.hole_width*o,v=f.hole_height*o,_=k/2,H=v/2;g.beginPath(),g.ellipse(D,x,_,H,0,0,2*Math.PI),g.fill()}}),mi(A).pcb_copper_pour.list().forEach(f=>{if(f.layer===t&&f.covered_with_solder_mask===!1)if(f.shape==="rect"){const m=I(f.center.x),S=c(f.center.y),D=f.width*o,x=f.height*o;g.fillRect(m-D/2,S-x/2,D,x)}else f.shape==="polygon"&&f.points&&(g.beginPath(),f.points.forEach((m,S)=>{const D=I(m.x),x=c(m.y);S===0?g.moveTo(D,x):g.lineTo(D,x)}),g.closePath(),g.fill())}),mi(A).pcb_cutout.list().forEach(f=>{switch(f.shape){case"rect":{const m=I(f.center.x),S=c(f.center.y),D=f.width*o,x=f.height*o,F=GC(f),k=l0(f.width,f.height,F);if(f.rotation){g.save(),g.translate(m,S);const v=-f.rotation*(Math.PI/180);g.rotate(v),k>0?(g.beginPath(),g.roundRect(-D/2,-x/2,D,x,k*o),g.fill()):g.fillRect(-D/2,-x/2,D,x),g.restore()}else k>0?(g.beginPath(),g.roundRect(m-D/2,S-x/2,D,x,k*o),g.fill()):g.fillRect(m-D/2,S-x/2,D,x);break}case"circle":{const m=I(f.center.x),S=c(f.center.y),D=f.radius*o;g.beginPath(),g.arc(m,S,D,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,S)=>{const D=I(m.x),x=c(m.y);S===0?g.moveTo(D,x):g.lineTo(D,x)}),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 TN(s);return d.generateMipmaps=!0,d.minFilter=xu,d.magFilter=XB,d.anisotropy=16,d.needsUpdate=!0,d}var Lft=_r(OlA());function H9A(t,A){return Array.isArray(A)?[t.a*A[0]+t.c*A[1]+t.e,t.b*A[0]+t.d*A[1]+t.f]:{x:t.a*A.x+t.c*A.y+t.e,y:t.b*A.x+t.d*A.y+t.f}}function Jx(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function Y9A(...t){t=Array.isArray(t[0])?t[0]:t;const A=(e,i)=>({a:e.a*i.a+e.c*i.b,c:e.a*i.c+e.c*i.d,e:e.a*i.e+e.c*i.f+e.e,b:e.b*i.a+e.d*i.b,d:e.b*i.c+e.d*i.d,f:e.b*i.e+e.d*i.f+e.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return A(t[0],t[1]);default:{const[e,i,...o]=t,n=A(e,i);return Y9A(n,...o)}}}function J9A(...t){return Y9A(...t)}var{cos:Hft,sin:Yft}=Math;function T9A(t,A,e){const i=Hft(t),o=Yft(t);return{a:i,c:-o,e:0,b:o,d:i,f:0}}function Jft(t,A){function e(){this.constructor=t}e.prototype=A.prototype,t.prototype=new e}function g8(t,A,e,i){var o=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(o,g8.prototype),o.expected=A,o.found=e,o.location=i,o.name="SyntaxError",o}Jft(g8,Error);function JCA(t,A,e){return e=e||" ",t.length>A?t:(A-=t.length,e+=e.repeat(A),t+e.slice(0,A))}g8.prototype.format=function(t){var A="Error: "+this.message;if(this.location){var e=null,i;for(i=0;i<t.length;i++)if(t[i].source===this.location.source){e=t[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(e){var r=this.location.end,a=JCA("",n.line.toString().length," "),g=e[o.line-1],I=o.line===r.line?r.column:g.length+1,c=I-o.column||1;A+=`
|
|
5106
5106
|
--> `+s+`
|
|
5107
5107
|
`+a+` |
|
|
5108
5108
|
`+n.line+" | "+g+`
|
|
5109
5109
|
`+a+" | "+JCA("",o.column-1," ")+JCA("",c,"^")}else A+=`
|
|
5110
|
-
at `+s}return A},g8.buildMessage=function(t,A){var e={literal:function(g){return'"'+o(g.text)+'"'},class:function(g){var I=g.parts.map(function(c){return Array.isArray(c)?n(c[0])+"-"+n(c[1]):n(c)});return"["+(g.inverted?"^":"")+I.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(I){return"\\x0"+i(I)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(I){return"\\x"+i(I)})}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(I){return"\\x0"+i(I)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(I){return"\\x"+i(I)})}function s(g){return e[g.type](g)}function r(g){var I=g.map(s),c,B;if(I.sort(),I.length>0){for(c=1,B=1;c<I.length;c++)I[c-1]!==I[c]&&(I[B]=I[c],B++);I.length=B}switch(I.length){case 1:return I[0];case 2:return I[0]+" or "+I[1];default:return I.slice(0,-1).join(", ")+", or "+I[I.length-1]}}function a(g){return g?'"'+o(g)+'"':"end of input"}return"Expected "+r(t)+" but "+a(A)+" found."};var K9A=25.4,Tft=K9A/1e3,Kft=/^\s*(-?\d*(?:\.\d+)?)(?:\s*(mm|mil|inch|in|"))?\s*$/i;function qft(t){if(!t)return;const A=t.trim().toLowerCase();return A==='"'||A==="inch"?"in":A}function yQ(t){if(t==null)return;if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(typeof t!="string")return;const A=t.trim();if(A.length===0)return;const e=A.match(Kft);if(!e){const r=Number.parseFloat(A);return Number.isFinite(r)?r:void 0}const[,i,o]=e,n=Number.parseFloat(i||"0");if(!Number.isFinite(n))return;switch(qft(o)){case"mil":return n*Tft;case"in":return n*K9A;case"mm":case void 0:return n;default:return n}}function vw(t,A){const e=yQ(t);return e===void 0?A:e}function q9A(t){let A=t;if(A.startsWith("#")&&(A=A.slice(1)),A.length===6){const e=parseInt(A.slice(0,2),16),i=parseInt(A.slice(2,4),16),o=parseInt(A.slice(4,6),16);return`rgb(${e}, ${i}, ${o})`}return t.startsWith("rgb")?t:"rgb(255, 243, 204)"}function I8({layer:t,circuitJson:A,boardData:e,silkscreenColor:i="rgb(255,255,255)",traceTextureResolution:o}){const n=mi(A).pcb_silkscreen_text.list(),s=mi(A).pcb_silkscreen_path.list(),r=mi(A).pcb_silkscreen_line.list(),a=mi(A).pcb_silkscreen_rect.list(),g=mi(A).pcb_silkscreen_circle.list(),I=mi(A).pcb_fabrication_note_rect.list(),c=mi(A).pcb_note_line.list(),B=n.filter(v=>v.layer===t),l=s.filter(v=>v.layer===t),C=r.filter(v=>v.layer===t),Q=a.filter(v=>v.layer===t),E=g.filter(v=>v.layer===t),h=I.filter(v=>v.layer===t),u=c.filter(v=>v.layer===t);if(B.length===0&&l.length===0&&C.length===0&&Q.length===0&&E.length===0&&h.length===0&&u.length===0)return null;const d=dF(e),f=document.createElement("canvas"),m=Math.floor(d.width*o),S=Math.floor(d.height*o);f.width=m,f.height=S;const D=f.getContext("2d");if(!D)return null;t==="bottom"&&(D.translate(0,S),D.scale(1,-1)),D.strokeStyle=i,D.fillStyle=i;const x=v=>(v-d.minX)*o,F=v=>(d.maxY-v)*o;C.forEach(v=>{const _=yQ(v.x1)??0,H=yQ(v.y1)??0,P=yQ(v.x2)??0,J=yQ(v.y2)??0;_===P&&H===J||(D.beginPath(),D.lineWidth=vw(v.stroke_width,.1)*o,D.lineCap="round",D.moveTo(x(_),F(H)),D.lineTo(x(P),F(J)),D.stroke())}),u.forEach(v=>{const _=yQ(v.x1)??0,H=yQ(v.y1)??0,P=yQ(v.x2)??0,J=yQ(v.y2)??0;if(_===P&&H===J)return;D.save();let W=i;v.color?W=q9A(v.color):W="rgb(255, 243, 204)",D.strokeStyle=W,D.beginPath(),D.lineWidth=vw(v.stroke_width,.1)*o,D.lineCap="round";const Z=v.is_dashed??!1;if(Z){const AA=Math.max(D.lineWidth*2,1);D.setLineDash([AA,AA])}D.moveTo(x(_),F(H)),D.lineTo(x(P),F(J)),D.stroke(),Z&&D.setLineDash([]),D.restore()}),l.forEach(v=>{v.route.length<2||(D.beginPath(),D.lineWidth=vw(v.stroke_width,.1)*o,D.lineCap="round",D.lineJoin="round",v.route.forEach((_,H)=>{const P=x(yQ(_.x)??0),J=F(yQ(_.y)??0);H===0?D.moveTo(P,J):D.lineTo(P,J)}),D.stroke())}),E.forEach(v=>{const _=vw(v.radius,0);if(_<=0)return;const H=vw(v.stroke_width,.12),P=H>0,J=yQ(v.center?.x)??0,W=yQ(v.center?.y)??0,Z=x(J),AA=F(W),nA=_*o;if(D.save(),D.translate(Z,AA),P){const gA=nA+H/2*o,tA=Math.max(0,nA-H/2*o);tA>0?(D.beginPath(),D.arc(0,0,gA,0,2*Math.PI),D.arc(0,0,tA,0,2*Math.PI,!0),D.fill("evenodd")):(D.beginPath(),D.arc(0,0,gA,0,2*Math.PI),D.fill())}else D.beginPath(),D.arc(0,0,nA,0,2*Math.PI),D.fill();D.restore()}),Q.forEach(v=>{const _=vw(v.width,0),H=vw(v.height,0);if(_<=0||H<=0)return;const P=yQ(v.center?.x)??0,J=yQ(v.center?.y)??0,W=x(P),Z=F(J),AA=GC(v),nA=typeof AA=="string"?yQ(AA):AA,gA=l0(_,H,nA);D.save(),D.translate(W,Z);const tA=_/2*o,iA=H/2*o,rA=Math.min(gA*o,tA,iA),CA=v.stroke_width??!1,dA=v.is_filled??!0,bA=v.is_stroke_dashed??!1,kA=CA?vw(v.stroke_width,.1)*o:0;if(((lA,RA,uA,KA,$A)=>{if(D.beginPath(),$A<=0)D.rect(lA,RA,uA,KA);else{const re=$A,yA=lA+uA,qA=RA+KA;D.moveTo(lA+re,RA),D.lineTo(yA-re,RA),D.quadraticCurveTo(yA,RA,yA,RA+re),D.lineTo(yA,qA-re),D.quadraticCurveTo(yA,qA,yA-re,qA),D.lineTo(lA+re,qA),D.quadraticCurveTo(lA,qA,lA,qA-re),D.lineTo(lA,RA+re),D.quadraticCurveTo(lA,RA,lA+re,RA),D.closePath()}})(-tA,-iA,tA*2,iA*2,rA),dA&&D.fill(),CA&&kA>0){if(D.lineWidth=kA,bA){const lA=Math.max(kA*2,1);D.setLineDash([lA,lA])}D.stroke(),bA&&D.setLineDash([])}D.restore()}),h.forEach(v=>{const _=vw(v.width,0),H=vw(v.height,0);if(_<=0||H<=0)return;const P=yQ(v.center?.x)??0,J=yQ(v.center?.y)??0,W=x(P),Z=F(J),AA=GC(v),nA=typeof AA=="string"?yQ(AA):AA,gA=l0(_,H,nA);D.save(),D.translate(W,Z);const tA=_/2*o,iA=H/2*o,rA=Math.min(gA*o,tA,iA),CA=v.has_stroke??!1,dA=v.is_filled??!0,bA=v.is_stroke_dashed??!1,kA=CA?vw(v.stroke_width,.1)*o:0;let YA=i,lA=i;if(v.color){const uA=q9A(v.color);YA=uA,lA=uA}else YA="rgb(255, 243, 204)",lA="rgb(255, 243, 204)";if(((uA,KA,$A,re,yA)=>{if(D.beginPath(),yA<=0)D.rect(uA,KA,$A,re);else{const qA=yA,HA=uA+$A,vA=KA+re;D.moveTo(uA+qA,KA),D.lineTo(HA-qA,KA),D.quadraticCurveTo(HA,KA,HA,KA+qA),D.lineTo(HA,vA-qA),D.quadraticCurveTo(HA,vA,HA-qA,vA),D.lineTo(uA+qA,vA),D.quadraticCurveTo(uA,vA,uA,vA-qA),D.lineTo(uA,KA+qA),D.quadraticCurveTo(uA,KA,uA+qA,KA),D.closePath()}})(-tA,-iA,tA*2,iA*2,rA),dA&&(D.fillStyle=YA,D.fill()),CA&&kA>0){if(D.strokeStyle=lA,D.lineWidth=kA,bA){const uA=Math.max(kA*2,1);D.setLineDash([uA,uA])}D.stroke(),bA&&D.setLineDash([])}D.restore()}),B.forEach(v=>{const _=v.font_size||.25,H=Math.min(Math.max(.01,_*.1),_*.05)*o;D.lineWidth=H,D.lineCap="butt",D.lineJoin="miter";const P=(0,Lft.vectorText)({height:_*.45,input:v.text}),J=[];P.forEach(bA=>{bA.length===29?(J.push(bA.slice(0,15)),J.push(bA.slice(14,29))):bA.length===17?(J.push(bA.slice(0,10)),J.push(bA.slice(9,17))):J.push(bA)});const W=J.flat(),Z={minX:W.length>0?Math.min(...W.map(bA=>bA[0])):0,maxX:W.length>0?Math.max(...W.map(bA=>bA[0])):0,minY:W.length>0?Math.min(...W.map(bA=>bA[1])):0,maxY:W.length>0?Math.max(...W.map(bA=>bA[1])):0},AA=(Z.minX+Z.maxX)/2,nA=(Z.minY+Z.maxY)/2;let gA=-AA,tA=-nA;const iA=v.anchor_alignment||"center";iA.includes("left")?gA=-Z.minX:iA.includes("right")&&(gA=-Z.maxX),iA.includes("top")?tA=-Z.maxY:iA.includes("bottom")&&(tA=-Z.minY);const rA=[];let CA=v.ccw_rotation??0;if(v.layer==="bottom"&&(rA.push(Jx(AA,nA),{a:-1,b:0,c:0,d:1,e:0,f:0},Jx(-AA,-nA)),CA=-CA),CA){const bA=CA*Math.PI/180;rA.push(Jx(AA,nA),T9A(bA),Jx(-AA,-nA))}const dA=rA.length>0?J9A(...rA):void 0;J.forEach(bA=>{D.beginPath(),bA.forEach((kA,YA)=>{let lA={x:kA[0],y:kA[1]};dA&&(lA=H9A(dA,lA));const RA=lA.x+gA+v.anchor_position.x,uA=lA.y+tA+v.anchor_position.y,KA=x(RA),$A=F(uA);YA===0?D.moveTo(KA,$A):D.lineTo(KA,$A)}),D.stroke()})});const k=new TN(f);return k.generateMipmaps=!0,k.minFilter=xu,k.magFilter=XB,k.anisotropy=16,k.needsUpdate=!0,k}function P9A(t){return t&&t.route_type==="wire"&&typeof t.layer=="string"&&typeof t.width=="number"}function m_({layer:t,circuitJson:A,boardData:e,traceColor:i,traceTextureResolution:o}){const n=mi(A).pcb_trace.list(),s=mi(A).pcb_via.list(),r=mi(A).pcb_plated_hole.list(),a=n.filter(Q=>Q.route.some(E=>P9A(E)&&E.layer===t));if(a.length===0)return null;const g=dF(e),I=document.createElement("canvas"),c=Math.floor(g.width*o),B=Math.floor(g.height*o);I.width=c,I.height=B;const l=I.getContext("2d");if(!l)return null;t==="bottom"&&(l.translate(0,B),l.scale(1,-1)),a.forEach(Q=>{let E=!0;l.beginPath(),l.strokeStyle=i,l.lineCap="round",l.lineJoin="round";let h=0;for(const u of Q.route){if(!P9A(u)||u.layer!==t){E||l.stroke(),E=!0;continue}const d=u.x,f=u.y;h=u.width*o,l.lineWidth=h;const m=(d-g.minX)*o,S=(g.maxY-f)*o;E?(l.moveTo(m,S),E=!1):l.lineTo(m,S)}E||l.stroke()}),l.globalCompositeOperation="destination-out",l.fillStyle="black",s.forEach(Q=>{const E=(Q.x-g.minX)*o,h=(g.maxY-Q.y)*o,u=Q.outer_diameter/2*o;l.beginPath(),l.arc(E,h,u,0,2*Math.PI,!1),l.fill()}),r.forEach(Q=>{if(Q.layers.includes(t)&&Q.shape==="circle"){const E=(Q.x-g.minX)*o,h=(g.maxY-Q.y)*o,u=Q.outer_diameter/2*o;l.beginPath(),l.arc(E,h,u,0,2*Math.PI,!1),l.fill()}else if(Q.layers.includes(t)&&Q.shape==="rotated_pill_hole_with_rect_pad"){const E=(Q.x-g.minX)*o,h=(g.maxY-Q.y)*o,u=(Q.rect_pad_width??Q.hole_width??0)*o,d=(Q.rect_pad_height??Q.hole_height??0)*o,m=-(Q.rect_ccw_rotation||0);m?(l.save(),l.translate(E,h),l.rotate(m*Math.PI/180),l.beginPath(),l.rect(-u/2,-d/2,u,d),l.fill(),l.restore()):(l.beginPath(),l.rect(E-u/2,h-d/2,u,d),l.fill())}}),l.globalCompositeOperation="source-over";const C=new TN(I);return C.generateMipmaps=!0,C.minFilter=xu,C.magFilter=XB,C.anisotropy=16,C.needsUpdate=!0,C}var Pft=_r(OlA());function c8(t,A){if(t===void 0)return A;if(typeof t=="number")return t;const e=parseFloat(t.replace(/mm$/,""));return isNaN(e)?A:e}function Oft(t){return t.layer==="bottom"?t.is_mirrored!==!1:t.is_mirrored===!0}function Wft(t){const A=t.flat();if(A.length===0)return{minX:0,maxX:0,minY:0,maxY:0,width:0,height:0,centerX:0,centerY:0};const e=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:e,maxX:i,minY:o,maxY:n,width:i-e,height:n-o,centerX:(e+i)/2,centerY:(o+n)/2}}function Zft(t){const A=[];return t.forEach(e=>{e.length===29?(A.push(e.slice(0,15)),A.push(e.slice(14,29))):e.length===17?(A.push(e.slice(0,10)),A.push(e.slice(9,17))):A.push(e)}),A}function Vft(t,A){let e=-t.centerX,i=-t.centerY;return A.includes("left")?e=-t.minX:A.includes("right")&&(e=-t.maxX),A.includes("top")?i=-t.maxY:A.includes("bottom")&&(i=-t.minY),{x:e,y:i}}function jft(t,A){const e=[];let i=t.ccw_rotation??0;if(Oft(t)&&(e.push(Jx(A.centerX,A.centerY),{a:-1,b:0,c:0,d:1,e:0,f:0},Jx(-A.centerX,-A.centerY)),i=-i),i){const s=i*Math.PI/180;e.push(Jx(A.centerX,A.centerY),T9A(s),Jx(-A.centerX,-A.centerY))}return{matrix:e.length>0?J9A(...e):void 0,rotationDeg:i}}function O9A(t,A,e,i,o,n,s){A.forEach(r=>{t.beginPath(),r.forEach((a,g)=>{let I={x:a[0],y:a[1]};e&&(I=H9A(e,I));const c=I.x+i.x+o.x,B=I.y+i.y+o.y,l=n(c),C=s(B);g===0?t.moveTo(l,C):t.lineTo(l,C)}),t.stroke()})}function zft(t,A,e,i,o,n){t.save(),t.translate(A,e),t.rotate(-n),t.fillRect(-i/2,-o/2,i,o),t.restore()}function Xft(t,A,e,i,o,n,s,r,a,g){const I=typeof A.font_size=="number"?A.font_size:.2,c={left:c8(A.knockout_padding?.left,I*.5),right:c8(A.knockout_padding?.right,I*.5),top:c8(A.knockout_padding?.top,I*.3),bottom:c8(A.knockout_padding?.bottom,I*.3)},B=i.width+c.left+c.right,l=i.height+c.top+c.bottom,C=s(A.anchor_position.x),Q=r(A.anchor_position.y),E=B*a,h=l*a;t.fillStyle=g;const u=n*Math.PI/180;zft(t,C,Q,E,h,u);const d={x:-i.centerX,y:-i.centerY};t.globalCompositeOperation="destination-out",O9A(t,e,o,d,A.anchor_position,s,r),t.globalCompositeOperation="source-over"}function B8({layer:t,circuitJson:A,boardData:e,copperColor:i="rgb(230, 153, 51)",traceTextureResolution:o}){const s=A.filter(Q=>Q.type==="pcb_copper_text").filter(Q=>Q.layer===t);if(s.length===0)return null;const r=dF(e),a=document.createElement("canvas"),g=Math.floor(r.width*o),I=Math.floor(r.height*o);a.width=g,a.height=I;const c=a.getContext("2d");if(!c)return null;t==="bottom"&&(c.translate(0,I),c.scale(1,-1)),c.strokeStyle=i,c.fillStyle=i;const B=Q=>(Q-r.minX)*o,l=Q=>(r.maxY-Q)*o;s.forEach(Q=>{const E=typeof Q.font_size=="number"?Q.font_size:.2,h=Math.max(.02,E*.08)*o;c.lineWidth=h,c.lineCap="round",c.lineJoin="round";const u=(0,Pft.vectorText)({height:E*.45,input:Q.text}),d=Zft(u),f=Wft(d),{matrix:m,rotationDeg:S}=jft(Q,f);if(Q.is_knockout)Xft(c,Q,d,f,m,S,B,l,o,i);else{const D=Q.anchor_alignment||"center",x=Vft(f,D);O9A(c,d,m,x,Q.anchor_position,B,l)}});const C=new TN(a);return C.generateMipmaps=!0,C.minFilter=xu,C.magFilter=XB,C.anisotropy=16,C.needsUpdate=!0,C}function l8({layer:t,circuitJson:A,panelData:e,outlineColor:i="black",traceTextureResolution:o}){const n=mi(A).pcb_board.list().filter(l=>l.pcb_panel_id===e.pcb_board_id);if(n.length===0)return null;const s=document.createElement("canvas"),r=Math.floor(e.width*o),a=Math.floor(e.height*o);s.width=r,s.height=a;const g=s.getContext("2d");if(!g)return null;t==="bottom"&&(g.translate(0,a),g.scale(1,-1)),g.strokeStyle=i,g.lineWidth=.05*o;const I=l=>(l-e.center.x+e.width/2)*o,c=l=>(-(l-e.center.y)+e.height/2)*o;n.forEach(l=>{if(l.outline&&l.outline.length>=2)g.beginPath(),l.outline.forEach((C,Q)=>{const E=I(C.x),h=c(C.y);Q===0?g.moveTo(E,h):g.lineTo(E,h)}),g.closePath(),g.stroke();else{const C=l.width,Q=l.height,{x:E,y:h}=l.center,u=I(E-C/2),d=c(h+Q/2);g.strokeRect(u,d,C*o,Q*o)}});const B=new TN(s);return B.generateMipmaps=!0,B.minFilter=xu,B.magFilter=XB,B.anisotropy=16,B.needsUpdate=!0,B}function $ft({circuitJson:t,pcbThickness:A,isFaux:e=!1}){const{rootObject:i}=Ru(),{visibility:o}=r_(),n=j.useMemo(()=>{const r=t.filter(I=>I.type==="pcb_panel"),a=mi(t).pcb_board.list();if(r.length>0){const I=r[0],c=a.find(B=>B.pcb_panel_id===I.pcb_panel_id);return{type:"pcb_board",pcb_board_id:I.pcb_panel_id,center:I.center,width:I.width,height:I.height,thickness:c?.thickness??1.4,material:c?.material??"fr4",num_layers:c?.num_layers??2}}const g=a.filter(I=>!I.pcb_panel_id);return g.length>0?g[0]:null},[t]),s=j.useMemo(()=>{if(!n||!n.width||!n.height)return null;const r=k9A[n.material]??Fo.fr4SolderMaskGreen,a=`rgb(${Math.round(r[0]*255)}, ${Math.round(r[1]*255)}, ${Math.round(r[2]*255)})`,g="rgb(255,255,255)",I=Fo.fr4TracesWithMaskGreen,c=`rgb(${Math.round(I[0]*255)}, ${Math.round(I[1]*255)}, ${Math.round(I[2]*255)})`;return{topSoldermask:a8({layer:"top",circuitJson:t,boardData:n,soldermaskColor:a,traceTextureResolution:hc}),bottomSoldermask:a8({layer:"bottom",circuitJson:t,boardData:n,soldermaskColor:a,traceTextureResolution:hc}),topSilkscreen:I8({layer:"top",circuitJson:t,boardData:n,silkscreenColor:g,traceTextureResolution:hc}),bottomSilkscreen:I8({layer:"bottom",circuitJson:t,boardData:n,silkscreenColor:g,traceTextureResolution:hc}),topTraceWithMask:m_({layer:"top",circuitJson:t,boardData:n,traceColor:c,traceTextureResolution:hc}),bottomTraceWithMask:m_({layer:"bottom",circuitJson:t,boardData:n,traceColor:c,traceTextureResolution:hc}),topCopperText:B8({layer:"top",circuitJson:t,boardData:n,copperColor:`rgb(${Math.round(Fo.copper[0]*255)}, ${Math.round(Fo.copper[1]*255)}, ${Math.round(Fo.copper[2]*255)})`,traceTextureResolution:hc}),bottomCopperText:B8({layer:"bottom",circuitJson:t,boardData:n,copperColor:`rgb(${Math.round(Fo.copper[0]*255)}, ${Math.round(Fo.copper[1]*255)}, ${Math.round(Fo.copper[2]*255)})`,traceTextureResolution:hc}),topPanelOutlines:l8({layer:"top",circuitJson:t,panelData:n,traceTextureResolution:hc}),bottomPanelOutlines:l8({layer:"bottom",circuitJson:t,panelData:n,traceTextureResolution:hc})}},[t,n]);return j.useEffect(()=>{if(!i||!n||!s)return;const r=[],a=(I,c,B,l,C=!1,Q=!1)=>{if(!I)return null;const E=dF(n),h=new Rw(E.width,E.height),u=new bd({map:I,transparent:!0,side:Tl,depthWrite:Q,polygonOffset:C,polygonOffsetFactor:C?-1:0,polygonOffsetUnits:C?-1:0,opacity:e?i8:1}),d=new Vo(h,u);return d.position.set(E.centerX,E.centerY,c),B&&d.rotation.set(Math.PI,0,0),d.name=l,d},g=.001;if(o.topMask){const I=a(s.topSoldermask,A/2+g,!1,"jscad-top-soldermask",!0);I&&(r.push(I),i.add(I))}if(o.bottomMask){const I=a(s.bottomSoldermask,-A/2-g,!0,"jscad-bottom-soldermask",!0);I&&(r.push(I),i.add(I))}if(o.topCopper&&o.topMask){const I=a(s.topTraceWithMask,A/2+ig.traces+.004,!1,"jscad-top-trace-with-mask");I&&(r.push(I),i.add(I))}if(o.bottomCopper&&o.bottomMask){const I=a(s.bottomTraceWithMask,-A/2-ig.traces-.005,!0,"jscad-bottom-trace-with-mask");I&&(r.push(I),i.add(I))}if(o.topSilkscreen){const I=a(s.topSilkscreen,A/2+g+.002,!1,"jscad-top-silkscreen");I&&(r.push(I),i.add(I))}if(o.bottomSilkscreen){const I=a(s.bottomSilkscreen,-A/2-g-.002,!0,"jscad-bottom-silkscreen");I&&(r.push(I),i.add(I))}if(o.topCopper){const I=a(s.topCopperText,A/2+ig.copper,!1,"jscad-top-copper-text");I&&(r.push(I),i.add(I))}if(o.bottomCopper){const I=a(s.bottomCopperText,-A/2-ig.copper,!0,"jscad-bottom-copper-text");I&&(r.push(I),i.add(I))}if(o.boardBody){const I=a(s.topPanelOutlines,A/2+g+.003,!1,"jscad-top-panel-outlines",!1,!0);I&&(r.push(I),i.add(I));const c=a(s.bottomPanelOutlines,-A/2-g-.003,!0,"jscad-bottom-panel-outlines",!1,!0);c&&(r.push(c),i.add(c))}return()=>{r.forEach(I=>{I.parent===i&&i.remove(I),I.geometry.dispose(),I.material instanceof Af&&I.material.dispose()})}},[i,n,s,A,o]),null}function A0t(t){const A=mi(t).cad_component.list(),e=mi(t).pcb_smtpad.list(),i=mi(t).pcb_hole.list(),o=mi(t).pcb_plated_hole.list(),n=mi(t).pcb_via.list();if(A.length===0&&e.length===0&&i.length===0&&o.length===0&&n.length===0)return null;const s=[...i,...o,...n,...e],r=A2(s);let a=r.minX,g=r.maxX,I=r.minY,c=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),I=Math.min(I,f),c=Math.max(c,f)}a===1/0&&(a=-10,g=10,I=-10,c=10);const B=2,l=Math.max(Math.abs(a),Math.abs(g))+B,C=Math.max(Math.abs(I),Math.abs(c))+B,Q=Math.max(2*l,10),E=Math.max(2*C,10);return{type:"pcb_board",pcb_board_id:"faux-board",center:{x:0,y:0},width:Q,height:E,thickness:1.4,material:"fr4",num_layers:2}}function W9A(t){if(mi(t).pcb_board.list().length>0)return t;const e=A0t(t);if(!e)return t;const o=e.thickness/2;return[...t.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}),e]}var e0t=j.forwardRef(({circuitJson:t,children:A,autoRotateDisabled:e,clickToInteractEnabled:i,onUserInteraction:o,onCameraControllerReady:n},s)=>{const r=x9A(A),a=j.useMemo(()=>W9A(t??r),[t,r]),g=Rft(a),I=j.useMemo(()=>{if(!a)return[5,-5,5];try{const h=mi(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),S=Math.max(d,f),D=Math.max(m,S);return[D*.4,-D*.7,D*.9]}catch(h){return console.error(h),[5,-5,5]}},[a]),c=j.useMemo(()=>{if(!a)return!1;try{const h=mi(a).pcb_board.list()[0];return!!h&&h.pcb_board_id==="faux-board"}catch{return!1}},[a]),B=j.useMemo(()=>{if(a)try{const h=mi(a).pcb_board.list()[0];return h?{width:h.width??0,height:h.height??0}:void 0}catch(h){console.error(h);return}},[a]),l=j.useMemo(()=>{if(a)try{const h=mi(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=f9A(a),{stls:Q}=gft(g),E=mi(a).cad_component.list();return O.jsxs(b9A,{ref:s,autoRotateDisabled:e,initialCameraPosition:I,clickToInteractEnabled:i,boardDimensions:B,boardCenter:l,onUserInteraction:o,onCameraControllerReady:n,children:[Q.map(({stlData:h,color:u,layerType:d},f)=>O.jsx(vft,{stlData:h,color:u,opacity:f===0?c?.8:.95:1,layerType:d},`board-${f}`)),O.jsx($ft,{circuitJson:a,pcbThickness:C,isFaux:c}),E.map(h=>O.jsx(L9A,{fallback:({error:u})=>O.jsx(U9A,{cad_component:h,error:u}),children:O.jsx(y9A,{cad_component:h,circuitJson:a},h.cad_component_id)},h.cad_component_id))]})}),t0t=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;t[i]&&t[o]&&(A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1])}return A/2<=0};function i0t(t,A,e,i,o){let n,s=null;if(e.outline&&e.outline.length>=3){let r=e.outline.map(g=>[g.x,g.y]);t0t(r)&&(r=r.reverse());const a=A.ofPolygons([r]);o.push(a),s=a,n=t.extrude(a,i,void 0,void 0,void 0,!0),o.push(n)}else e.outline&&e.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),n=t.cube([e.width,e.height,i],!0),o.push(n),n=n.translate([e.center.x,e.center.y,0]),o.push(n);return{boardOp:n,outlineCrossSection:s}}var o0t=64;function Rd({Manifold:t,width:A,height:e,thickness:i,borderRadius:o}){const n=l0(A,e,o);if(n<=0)return t.cube([A,e,i],!0);const s=[],r=A-2*n,a=e-2*n;return r>0&&s.push(t.cube([r,e,i],!0)),a>0&&s.push(t.cube([A,a,i],!0)),[[A/2-n,e/2-n],[-A/2+n,e/2-n],[-A/2+n,-e/2+n],[A/2-n,-e/2+n]].forEach(([I,c])=>{s.push(t.cylinder(i,n,n,o0t,!0).translate([I,c,0]))}),t.union(s)}function n0t({Manifold:t,pad:A,padBaseThickness:e}){if(A.shape==="rect"){const i=GC(A);return Rd({Manifold:t,width:A.width,height:A.height,thickness:e,borderRadius:i})}else if(A.shape==="rotated_rect"){const i=GC(A);let o=Rd({Manifold:t,width:A.width,height:A.height,thickness:e,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 t.cylinder(e,A.radius,-1,32,!0);return null}var s0t=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;t[i]&&t[o]&&(A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1])}return A/2<=0};function r0t(t,A,e,i,o){const n=[],s=mi(e).pcb_cutout.list();for(const r of s){let a;const g=i*1.5;switch(r.shape){case"rect":{const B=GC(r);if(typeof B=="number"&&B>0?a=Rd({Manifold:t,width:r.width,height:r.height,thickness:g,borderRadius:B}):a=t.cube([r.width,r.height,g],!0),o.push(a),r.rotation){const l=a.rotate([0,0,r.rotation]);o.push(l),a=l}a=a.translate([r.center.x,r.center.y,0]),o.push(a);break}case"circle":a=t.cylinder(g,r.radius,-1,ql,!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 I=r.points.map(B=>[B.x,B.y]);s0t(I)&&(I=I.reverse());const c=A.ofPolygons([I]);o.push(c),a=t.extrude(c,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 Z9A({Manifold:t,x:A,y:e,diameter:i,thickness:o,segments:n=32}){return t.cylinder(o*1.2,i/2,i/2,n,!0).translate([A,e,0])}function V9A({Manifold:t,x:A,y:e,holeDiameter:i,thickness:o,zOffset:n=.001,segments:s=32}){const r=i/2+n;return t.cylinder(o*1.2,r,r,s,!0).translate([A,e,0])}function a0t(t,A,e,i,o){const n=[],s=mi(e).pcb_hole.list(),r=(g,I,c)=>{const B=Rd({Manifold:t,width:g,height:I,thickness:c,borderRadius:Math.min(g,I)/2});return o.push(B),B},a=(g,I,c)=>{const B=[];for(let l=0;l<c;l++){const C=2*Math.PI*l/c;B.push([g/2*Math.cos(C),I/2*Math.sin(C)])}return B};return s.forEach(g=>{const I=g.hole_shape,c=g.x,B=g.y,l=i*1.2,C=g.ccw_rotation??g.rotation??0,Q=g.hole_width??g.hole_diameter,E=g.hole_height??g.hole_diameter;let h=null;if(I==="circle"){h=Z9A({Manifold:t,x:c,y:B,diameter:g.hole_diameter,thickness:i,segments:ql}),n.push(h),o.push(h);return}if(I==="pill"||I==="rotated_pill")h=r(Q,E,l);else if(I==="oval"){let u=a(Q,E,ql),d=0;for(let m=0;m<u.length;m++){const S=(m+1)%u.length;d+=u[m][0]*u[S][1],d-=u[S][0]*u[m][1]}d<=0&&(u=u.reverse());const f=A.ofPolygons([u]);o.push(f),h=t.extrude(f,l,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([c,B,0]);o.push(u),n.push(u)}}),{nonPlatedHoleBoardDrills:n}}function Uw(t){const A=new mg;if(A.setAttribute("position",new Un(t.vertProperties,3)),A.setIndex(new ioA(t.triVerts,1)),t.runIndex&&t.runIndex.length>1&&t.runOriginalID)for(let e=0;e<t.runIndex.length-1;e++){const i=t.runIndex[e],o=t.runIndex[e+1]-i;A.addGroup(i,o,0)}else A.addGroup(0,t.triVerts.length,0);return A}var HL=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;t[i]&&t[o]&&(A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1])}return A/2<=0},C8=(t,A,e)=>{const i=[];for(let o=0;o<e;o++){const n=2*Math.PI*o/e;i.push([t/2*Math.cos(n),A/2*Math.sin(n)])}return i},pF=new Li(...Fo.copper),Q8=.05;function g0t(t,A,e,i,o,n){const s=[],r=mi(e).pcb_plated_hole.list(),a=[],g=[],I=(C,Q,E)=>{const h=Rd({Manifold:t,width:C,height:Q,thickness:E,borderRadius:Math.min(C,Q)/2});return o.push(h),h},c=({padOutline:C,thickness:Q})=>{if(!Array.isArray(C)||C.length<3)return null;let E=C.map(d=>[d.x,d.y]);HL(E)&&(E=E.reverse());const h=A.ofPolygons([E]);o.push(h);const u=t.extrude(h,Q,0,0,[1,1],!0);return o.push(u),u},B=({ph:C,depth:Q,sizeDelta:E=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 S=null;if(d==="circle"){const D=Math.max((C.hole_diameter??0)+E,mo),x=Math.max(D/2,mo/2);S=t.cylinder(Q,x,x,ql,!0),o.push(S)}else{const D=C.hole_width??C.hole_diameter,x=C.hole_height??C.hole_diameter;if(!D||!x)return null;const F=Math.max(D+E,mo),k=Math.max(x+E,mo);if(d==="oval"){let v=C8(F,k,ql);HL(v)&&(v=v.reverse());const _=A.ofPolygons([v]);o.push(_),S=t.extrude(_,Q,0,0,[1,1],!0),o.push(S)}else(d==="pill"||d==="rotated_pill")&&(S=Rd({Manifold:t,width:F,height:k,thickness:Q,borderRadius:Math.min(F,k)/2}),o.push(S))}if(!S)return null;if(f||m){const D=S.translate([f,m,0]);o.push(D),S=D}return S};r.forEach((C,Q)=>{if(C.shape==="circle"){const E=V9A({Manifold:t,x:C.x,y:C.y,holeDiameter:C.hole_diameter*1.02,thickness:i,zOffset:nf,segments:ql});o.push(E),s.push(E);const h=i+2*nf,u=t.cylinder(h,C.outer_diameter/2,C.outer_diameter/2,ql,!0);o.push(u);const d=t.cylinder(h*1.05,C.hole_diameter/2,C.hole_diameter/2,ql,!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 S=m;if(n){const x=t.intersection([m,n]);o.push(x),S=x}g.push(S);const D=Uw(S.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:D,color:pF})}else if(C.shape==="pill"){const E=C.hole_width,h=C.hole_height,u=.4,d=C.outer_width??E+u,f=C.outer_height??h+u,m=E+2*nf,S=h+2*nf,D=i*1.2;let x=I(m,S,D);if(C.ccw_rotation){const Z=x.rotate([0,0,C.ccw_rotation]);o.push(Z),x=Z}const F=x.translate([C.x,C.y,0]);o.push(F),s.push(F);const k=i+2*nf,v=I(d,f,k),_=I(E,h,k*1.05);let H=v.subtract(_);if(o.push(H),C.ccw_rotation){const Z=H.rotate([0,0,C.ccw_rotation]);o.push(Z),H=Z}const P=H.translate([C.x,C.y,0]);o.push(P);let J=P;if(n){const Z=t.intersection([P,n]);o.push(Z),J=Z}g.push(J);const W=Uw(J.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:W,color:pF})}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 E=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,S=GC(C),D=_L,x=E+2*nf,F=h+2*nf,k=i*1.2,_=I(x,F,k).translate([u,d,0]).translate([C.x,C.y,0]);o.push(_),s.push(_);const H=Rd({Manifold:t,width:f,height:m,thickness:i-2*D-2*ig.copper+.1,borderRadius:S});o.push(H);const P=Rd({Manifold:t,width:f,height:m,thickness:D,borderRadius:S}).translate([0,0,i/2/2+ig.copper]),J=Rd({Manifold:t,width:f,height:m,thickness:D,borderRadius:S}).translate([0,0,-i/2/2-ig.copper]);o.push(P,J);const W=I(E,h,i*1.02).translate([u,d,0]);o.push(W);const Z=t.union([H,P,J,W]);o.push(Z);const AA=I(Math.max(E-2*Q8,.01),Math.max(h-2*Q8,.01),i*1.2).translate([u,d,0]);o.push(AA);const nA=Z.subtract(AA);o.push(nA);const gA=nA.translate([C.x,C.y,0]);o.push(gA);let tA=gA;if(n){const rA=t.intersection([gA,n]);o.push(rA),tA=rA}g.push(tA);const iA=Uw(tA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:iA,color:pF})}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 E=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,S=GC(C),D=_L,x=E+2*nf,F=h+2*nf,k=i*1.2;let v=I(x,F,k).translate([u,d,0]);if(C.hole_ccw_rotation){const rA=v.rotate([0,0,C.hole_ccw_rotation]);o.push(rA),v=rA}const _=v.translate([C.x,C.y,0]);o.push(_),s.push(_);let H=Rd({Manifold:t,width:f,height:m,thickness:i-2*D-2*ig.copper+.1,borderRadius:S});if(o.push(H),C.rect_ccw_rotation){const rA=H.rotate([0,0,C.rect_ccw_rotation]);o.push(rA),H=rA}let P=Rd({Manifold:t,width:f,height:m,thickness:D,borderRadius:S}).translate([0,0,i/2/2+ig.copper]);if(C.rect_ccw_rotation){const rA=P.rotate([0,0,C.rect_ccw_rotation]);o.push(rA),P=rA}let J=Rd({Manifold:t,width:f,height:m,thickness:D,borderRadius:S}).translate([0,0,-i/2/2-ig.copper]);if(C.rect_ccw_rotation){const rA=J.rotate([0,0,C.rect_ccw_rotation]);o.push(rA),J=rA}o.push(P,J);let W=I(E,h,i*1.02).translate([u,d,0]);if(C.hole_ccw_rotation){const rA=W.rotate([0,0,C.hole_ccw_rotation]);o.push(rA),W=rA}o.push(W);const Z=t.union([H,P,J,W]);o.push(Z);let AA=I(Math.max(E-2*Q8,.01),Math.max(h-2*Q8,.01),i*1.2).translate([u,d,0]);if(C.hole_ccw_rotation){const rA=AA.rotate([0,0,C.hole_ccw_rotation]);o.push(rA),AA=rA}o.push(AA);const nA=Z.subtract(AA);o.push(nA);const gA=nA.translate([C.x,C.y,0]);o.push(gA);let tA=gA;if(n){const rA=t.intersection([gA,n]);o.push(rA),tA=rA}g.push(tA);const iA=Uw(tA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:iA,color:pF})}else if(C.shape==="hole_with_polygon_pad"){const E=C.pad_outline;if(!Array.isArray(E)||E.length<3)return;const h=B({ph:C,depth:i*1.2,sizeDelta:2*mo});if(!h)return;const u=h.translate([C.x,C.y,0]);o.push(u),s.push(u);const d=_L,f=Math.max(i-2*d-2*ig.copper+.1,mo),m=c({padOutline:E,thickness:f}),S=c({padOutline:E,thickness:d}),D=c({padOutline:E,thickness:d});if(!m||!S||!D)return;const x=S.translate([0,0,i/2/2+ig.copper]),F=D.translate([0,0,-i/2/2-ig.copper]);o.push(x,F);const k=B({ph:C,depth:i*1.02});if(!k)return;const v=B({ph:C,depth:i*1.2,sizeDelta:-2*mo})||k,_=t.union([m,x,F,k]);o.push(_);const H=_.subtract(v);o.push(H);const P=H.translate([C.x,C.y,0]);o.push(P);let J=P;if(n){const Z=t.intersection([P,n]);o.push(Z),J=Z}g.push(J);const W=Uw(J.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:W,color:pF})}else if(C.shape==="oval"){const E=C.hole_width,h=C.hole_height,u=C.outer_width??E+.4,d=C.outer_height??h+.4,f=E+2*nf,m=h+2*nf,S=i*1.2;let D=C8(f,m,ql);HL(D)&&(D=D.reverse());const x=A.ofPolygons([D]);o.push(x);let F=t.extrude(x,S,0,0,[1,1],!0);if(o.push(F),C.ccw_rotation){const iA=F.rotate([0,0,C.ccw_rotation]);o.push(iA),F=iA}const k=F.translate([C.x,C.y,0]);o.push(k),s.push(k);const v=i+2*nf;let _=C8(u,d,ql);HL(_)&&(_=_.reverse());const H=A.ofPolygons([_]);o.push(H);const P=t.extrude(H,v,0,0,[1,1],!0);o.push(P);let J=C8(E,h,ql);HL(J)&&(J=J.reverse());const W=A.ofPolygons([J]);o.push(W);const Z=t.extrude(W,v*1.05,0,0,[1,1],!0);o.push(Z);let AA=P.subtract(Z);if(o.push(AA),C.ccw_rotation){const iA=AA.rotate([0,0,C.ccw_rotation]);o.push(iA),AA=iA}const nA=AA.translate([C.x,C.y,0]);o.push(nA);let gA=nA;if(n){const iA=t.intersection([nA,n]);o.push(iA),gA=iA}g.push(gA);const tA=Uw(gA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:tA,color:pF})}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 E=C.hole_offset_x||0,h=C.hole_offset_y||0,u=Z9A({Manifold:t,x:C.x+E,y:C.y+h,diameter:C.hole_diameter,thickness:i,segments:ql});o.push(u),s.push(u);const d=C.rect_pad_width??C.hole_diameter,f=C.rect_pad_height??C.hole_diameter,m=GC(C),S=_L,D=C.hole_diameter/2,x=Rd({Manifold:t,width:d,height:f,thickness:i-2*S-2*ig.copper+.1,borderRadius:m});o.push(x);const F=Rd({Manifold:t,width:d,height:f,thickness:S,borderRadius:m}).translate([0,0,i/2/2+ig.copper]),k=Rd({Manifold:t,width:d,height:f,thickness:S,borderRadius:m}).translate([0,0,-i/2/2-ig.copper]);o.push(F,k);const v=t.cylinder(i*1.02,D,D,ql,!0).translate([E,h,0]);o.push(v);const _=t.union([x,F,k,v]);o.push(_);const H=t.cylinder(i*1.2,Math.max(D-mo,.01),Math.max(D-mo,.01),ql,!0).translate([E,h,0]);o.push(H);const P=_.subtract(H);o.push(P);const J=P.translate([C.x,C.y,0]);o.push(J);let W=J;if(n){const AA=t.intersection([J,n]);o.push(AA),W=AA}g.push(W);const Z=Uw(W.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:Z,color:pF})}});let l;return g.length>0&&(l=t.union(g),o.push(l)),{platedHoleBoardDrills:s,platedHoleCopperGeoms:a,platedHoleSubtractOp:l}}var I0t=new Li(...Fo.copper);function c0t(t,A,e,i,o,n){const s=[];return mi(A).pcb_smtpad.list().forEach((a,g)=>{const I=_L,c=a.layer==="bottom"?-e/2-ig.copper:e/2+ig.copper;let B=n0t({Manifold:t,pad:a,padBaseThickness:I});if(B){i.push(B);const l=B.translate([a.x,a.y,c]);i.push(l);let C=l;if(o&&(C=l.subtract(o),i.push(C)),n){const E=t.intersection([C,n]);i.push(E),C=E}const Q=Uw(C.getMesh());s.push({key:`smt_pad-${a.layer||"top"}-${a.pcb_smtpad_id||g}`,geometry:Q,color:I0t})}}),{smtPadGeoms:s}}function B0t({Manifold:t,x:A,y:e,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 I=Math.min(i/2,o/2+g),c=t.cylinder(n,I,-1,r,!0),B=t.cylinder(a,i/2,-1,r,!0).translate([0,0,n/2]),l=t.cylinder(a,i/2,-1,r,!0).translate([0,0,-n/2]),C=t.union([c,B,l]),Q=n+a*2,E=t.cylinder(Q,o/2,-1,r,!0);return C.subtract(E).translate([A,e,0])}var l0t=new Li(...Fo.copper);function C0t(t,A,e,i,o){const n=[],s=mi(A).pcb_via.list(),r=[];return s.forEach((a,g)=>{if(typeof a.hole_diameter=="number"){const I=V9A({Manifold:t,x:a.x,y:a.y,holeDiameter:a.hole_diameter,thickness:e,zOffset:nf,segments:ql});i.push(I),n.push(I)}if(typeof a.outer_diameter=="number"&&typeof a.hole_diameter=="number"){const I=B0t({Manifold:t,x:a.x,y:a.y,outerDiameter:a.outer_diameter,holeDiameter:a.hole_diameter,thickness:e,zOffset:nf,segments:ql});i.push(I);let c=I;if(o){const l=t.intersection([I,o]);i.push(l),c=l}const B=Uw(c.getMesh());r.push({key:`via-${a.pcb_via_id||g}`,geometry:B,color:l0t})}}),{viaBoardDrills:n,viaCopperGeoms:r}}function j9A({ctx:t,points:A,canvasXFromPcb:e,canvasYFromPcb:i}){A.length<3||(t.beginPath(),A.forEach((o,n)=>{const s=e(o[0]),r=i(o[1]);n===0?t.moveTo(s,r):t.lineTo(s,r)}),t.closePath(),t.fill())}function Q0t({ctx:t,pour:A,canvasXFromPcb:e,canvasYFromPcb:i}){const o=A.brep_shape;if(!o||!o.outer_ring)return;const n=r8(o.outer_ring,32);if(n.length>=3&&j9A({ctx:t,points:n,canvasXFromPcb:e,canvasYFromPcb:i}),o.inner_rings&&o.inner_rings.length>0){t.globalCompositeOperation="destination-out";for(const s of o.inner_rings){const r=r8(s,32);r.length>=3&&j9A({ctx:t,points:r,canvasXFromPcb:e,canvasYFromPcb:i})}t.globalCompositeOperation="source-over"}}function z9A({layer:t,circuitJson:A,boardData:e,traceTextureResolution:i=hc}){const o=A.filter(h=>h.type==="pcb_copper_pour"),n=t==="top"?"top_copper":"bottom_copper",s=o.filter(h=>h.layer===t);if(s.length===0)return null;const r=dF(e),a=document.createElement("canvas"),g=Math.floor(r.width*i),I=Math.floor(r.height*i);a.width=g,a.height=I;const c=a.getContext("2d");if(!c)return null;t==="bottom"&&(c.translate(0,I),c.scale(1,-1));const B=h=>(h-r.minX)*i,l=h=>(r.maxY-h)*i,C=s.filter(h=>h.shape==="rect"||h.shape==="polygon"),Q=s.filter(h=>h.shape==="brep");if(C.length>0){const h=new _nt(c);h.setCameraBounds({minX:r.minX,maxX:r.maxX,minY:r.minY,maxY:r.maxY});const u=C.filter(S=>S.covered_with_solder_mask!==!1),d=C.filter(S=>S.covered_with_solder_mask===!1),f=`rgb(${Fo.fr4TracesWithMaskGreen.map(S=>S*255).join(",")})`,m=`rgb(${Fo.copper.map(S=>S*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 Q){const d=h.covered_with_solder_mask!==!1?Fo.fr4TracesWithMaskGreen:Fo.copper,f=`rgb(${d[0]*255}, ${d[1]*255}, ${d[2]*255})`;c.fillStyle=f,Q0t({ctx:c,pour:h,canvasXFromPcb:B,canvasYFromPcb:l})}const E=new TN(a);return E.generateMipmaps=!0,E.minFilter=xu,E.magFilter=XB,E.anisotropy=16,E.needsUpdate=!0,E}function sf(t,A){const{texture:e,yOffset:i,isBottomLayer:o,textureType:n,usePolygonOffset:s=!1,renderOrder:r=0,isFaux:a=!1}=t;if(!e)return null;const g=dF(A),I=new Rw(g.width,g.height),c=new bd({map:e,transparent:!0,side:Tl,depthWrite:n==="panel-outlines",polygonOffset:s,polygonOffsetFactor:s?-4:0,polygonOffsetUnits:s?-4:0,opacity:a?i8:1}),B=new Vo(I,c);return B.position.set(g.centerX,g.centerY,i),o&&B.rotation.set(Math.PI,0,0),B.name=`${o?"bottom":"top"}-${n}-texture-plane`,B.renderOrder=r,B}function E0t(t,A,e,i=!1){const o=[];if(!t||!A||e===null)return o;const n=sf({texture:t.topTrace,yOffset:e/2+ig.traces,isBottomLayer:!1,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);n&&o.push(n);const s=sf({texture:t.topTraceWithMask,yOffset:e/2+ig.traces,isBottomLayer:!1,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);s&&o.push(s);const r=sf({texture:t.topSilkscreen,yOffset:e/2+.003,isBottomLayer:!1,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);r&&o.push(r);const a=sf({texture:t.bottomTrace,yOffset:-e/2-ig.traces,isBottomLayer:!0,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);a&&o.push(a);const g=sf({texture:t.bottomTraceWithMask,yOffset:-e/2-ig.traces,isBottomLayer:!0,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);g&&o.push(g);const I=sf({texture:t.bottomSilkscreen,yOffset:-e/2-.003,isBottomLayer:!0,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);I&&o.push(I);const c=sf({texture:t.topSoldermask,yOffset:e/2+.001,isBottomLayer:!1,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);c&&o.push(c);const B=sf({texture:t.bottomSoldermask,yOffset:-e/2-.001,isBottomLayer:!0,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);B&&o.push(B);const l=sf({texture:t.topCopperText,yOffset:e/2+ig.copper,isBottomLayer:!1,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);l&&o.push(l);const C=sf({texture:t.bottomCopperText,yOffset:-e/2-ig.copper,isBottomLayer:!0,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);C&&o.push(C);const Q=sf({texture:t.topCopper,yOffset:e/2+ig.copper,isBottomLayer:!1,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);Q&&o.push(Q);const E=sf({texture:t.bottomCopper,yOffset:-e/2-ig.copper,isBottomLayer:!0,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);E&&o.push(E);const h=sf({texture:t.topPanelOutlines,yOffset:e/2+.004,isBottomLayer:!1,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);h&&o.push(h);const u=sf({texture:t.bottomPanelOutlines,yOffset:-e/2-.004,isBottomLayer:!0,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);return u&&o.push(u),o}var h0t=(t,A)=>{const[e,i]=j.useState(null),[o,n]=j.useState(null),[s,r]=j.useState(null),[a,g]=j.useState(null),[I,c]=j.useState(!0),B=j.useRef([]),l=j.useMemo(()=>{const Q=A.filter(u=>u.type==="pcb_panel"),E=mi(A).pcb_board.list();if(Q.length>0){const u=Q[0],d=E.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=E.filter(u=>!u.pcb_panel_id);return h.length>0?h[0]:null},[A]),C=j.useMemo(()=>{const Q=mi(A).pcb_board.list();return Q.length>0&&Q[0].pcb_board_id==="faux-board"},[A]);return j.useEffect(()=>{if(!t||!l){i(null),n(null),r(null),c(!1);return}if((l.width===0||!l.width)&&(l.height===0||!l.height)&&(!l.outline||l.outline.length<3)){i({platedHoles:[],smtPads:[],vias:[]}),n({}),r(l.thickness??0),c(!1);return}c(!0),g(null);const Q=t.Manifold,E=t.CrossSection,h=m=>{if(!(!m||typeof m.delete!="function"))try{m.delete()}catch(S){(!(S instanceof Error)||!S.message?.includes("Manifold instance already deleted"))&&console.warn("Failed to delete Manifold instance",S)}};B.current.forEach(h),B.current=[];let u=null;const d={},f={};try{const m=l.thickness||1.4;r(m);const{boardOp:S,outlineCrossSection:D}=i0t(Q,E,l,m,B.current);let x=S;const k=m+2*1;let v=null;const _=.01;if(D){let KA=D;if(_>0){const re=D.offset(_);B.current.push(re),KA=re}const $A=Q.extrude(KA,k,void 0,void 0,void 0,!0);B.current.push($A),v=$A}else{const KA=(l.width||0)+2*_,$A=(l.height||0)+2*_,re=Q.cube([KA,$A,k],!0);B.current.push(re);const yA=re.translate([l.center.x,l.center.y,0]);B.current.push(yA),v=yA}const H=[];let P=null;const{nonPlatedHoleBoardDrills:J}=a0t(Q,E,A,m,B.current);H.push(...J);const{platedHoleBoardDrills:W,platedHoleCopperGeoms:Z,platedHoleSubtractOp:AA}=g0t(Q,E,A,m,B.current,v);H.push(...W),d.platedHoles=Z;const{viaBoardDrills:nA,viaCopperGeoms:gA}=C0t(Q,A,m,B.current,v);if(H.push(...nA),d.vias=gA,H.length>0){P=Q.union(H),B.current.push(P);const KA=AA?Q.union([P,AA]):P;B.current.push(KA);const $A=x.subtract(KA);if(B.current.push($A),x=$A,AA){const re=AA.subtract(P);B.current.push(re);const yA=re.getMesh(),qA=Uw(yA);d.platedHoles=[{key:"plated-holes-union",geometry:qA,color:new Li(Fo.copper[0],Fo.copper[1],Fo.copper[2])}]}}const{cutoutOps:tA}=r0t(Q,E,A,m,B.current);if(tA.length>0){const KA=Q.union(tA);B.current.push(KA);const $A=x.subtract(KA);B.current.push($A),x=$A}if(u=x,u){const KA=u.getMesh(),$A=Uw(KA),re=UCA[l.material]??Fo.fr4Tan;d.board={geometry:$A,color:new Li(re[0],re[1],re[2]),material:l.material,isFaux:C}}const{smtPadGeoms:iA}=c0t(Q,A,m,B.current,P,v);d.smtPads=iA,i(d);const rA=Fo.fr4TracesWithoutMaskTan,CA=`rgb(${Math.round(rA[0]*255)}, ${Math.round(rA[1]*255)}, ${Math.round(rA[2]*255)})`;f.topTrace=m_({layer:"top",circuitJson:A,boardData:l,traceColor:CA,traceTextureResolution:hc}),f.bottomTrace=m_({layer:"bottom",circuitJson:A,boardData:l,traceColor:CA,traceTextureResolution:hc});const dA=Fo.fr4TracesWithMaskGreen,bA=`rgb(${Math.round(dA[0]*255)}, ${Math.round(dA[1]*255)}, ${Math.round(dA[2]*255)})`;f.topTraceWithMask=m_({layer:"top",circuitJson:A,boardData:l,traceColor:bA,traceTextureResolution:hc}),f.bottomTraceWithMask=m_({layer:"bottom",circuitJson:A,boardData:l,traceColor:bA,traceTextureResolution:hc});const kA="rgb(255,255,255)";f.topSilkscreen=I8({layer:"top",circuitJson:A,boardData:l,silkscreenColor:kA,traceTextureResolution:hc}),f.bottomSilkscreen=I8({layer:"bottom",circuitJson:A,boardData:l,silkscreenColor:kA,traceTextureResolution:hc});const YA=k9A[l.material]??Fo.fr4SolderMaskGreen,lA=`rgb(${Math.round(YA[0]*255)}, ${Math.round(YA[1]*255)}, ${Math.round(YA[2]*255)})`;f.topSoldermask=a8({layer:"top",circuitJson:A,boardData:l,soldermaskColor:lA,traceTextureResolution:hc}),f.bottomSoldermask=a8({layer:"bottom",circuitJson:A,boardData:l,soldermaskColor:lA,traceTextureResolution:hc});const RA=Fo.copper,uA=`rgb(${Math.round(RA[0]*255)}, ${Math.round(RA[1]*255)}, ${Math.round(RA[2]*255)})`;f.topCopperText=B8({layer:"top",circuitJson:A,boardData:l,copperColor:uA,traceTextureResolution:hc}),f.bottomCopperText=B8({layer:"bottom",circuitJson:A,boardData:l,copperColor:uA,traceTextureResolution:hc}),f.topPanelOutlines=l8({layer:"top",circuitJson:A,panelData:l,traceTextureResolution:hc}),f.bottomPanelOutlines=l8({layer:"bottom",circuitJson:A,panelData:l,traceTextureResolution:hc}),f.topCopper=z9A({layer:"top",circuitJson:A,boardData:l,traceTextureResolution:hc}),f.bottomCopper=z9A({layer:"bottom",circuitJson:A,boardData:l,traceTextureResolution:hc}),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{c(!1)}return()=>{B.current.forEach(h),B.current=[]}},[t,A,l]),{geoms:e,textures:o,pcbThickness:s,error:a,isLoading:I,boardData:l,isFauxBoard:C}},u0t=Tl,d0t=({material:t,color:A,side:e=u0t,isFaux:i=!1})=>t==="fr4"?new Mw({color:A,side:e,metalness:0,roughness:.8,specularIntensity:.2,ior:1.45,sheen:0,clearcoat:0,transparent:i,opacity:i?i8:1,flatShading:!0}):new hh({color:A,side:e,flatShading:!0,metalness:.1,roughness:.8,transparent:!0,opacity:i?i8:.9});function p0t(t){const A=[];if(!t)return A;if(t.board&&t.board.geometry){const i=new Vo(t.board.geometry,d0t({material:t.board.material,color:t.board.color,side:Tl,isFaux:t.board.isFaux}));i.name="board-geom",A.push(i)}const e=i=>{i&&i.forEach(o=>{const n=new Vo(o.geometry,new hh({color:o.color,side:Tl,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}));n.name=o.key,A.push(n)})};return e(t.platedHoles),e(t.smtPads),e(t.vias),A}var f0t=({geometryMeshes:t,textureMeshes:A})=>{const{rootObject:e}=Ru(),{visibility:i}=r_();return j.useEffect(()=>{if(e)return t.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&&e.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&&e.add(o)}),()=>{t.forEach(o=>{o.parent===e&&e.remove(o)}),A.forEach(o=>{o.parent===e&&e.remove(o)})}},[e,t,A,i]),null},y0t="https://cdn.jsdelivr.net/npm/manifold-3d@3.2.1",w0t=({circuitJson:t,autoRotateDisabled:A,clickToInteractEnabled:e,onUserInteraction:i,children:o,onCameraControllerReady:n})=>{const s=x9A(o),r=j.useMemo(()=>W9A(t??s),[t,s]),[a,g]=j.useState(null),[I,c]=j.useState(null);j.useEffect(()=>{if(window.ManifoldModule&&typeof window.ManifoldModule=="object"&&window.ManifoldModule.setup){g(window.ManifoldModule);return}const F=async J=>{try{const W=await J();W.setup(),window.ManifoldModule=W,g(W)}catch(W){console.error("Failed to initialize Manifold:",W),c(`Failed to initialize Manifold: ${W instanceof Error?W.message:"Unknown error"}`)}},k=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(k){window.ManifoldModule=k,F(window.ManifoldModule);return}const v="manifoldLoaded",_=()=>{const J=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(J)window.ManifoldModule=J,F(window.ManifoldModule);else{const W="ManifoldModule not found on window after script load.";console.error(W),c(W)}};window.addEventListener(v,_,{once:!0});const H=document.createElement("script");H.type="module",H.innerHTML=`
|
|
5110
|
+
at `+s}return A},g8.buildMessage=function(t,A){var e={literal:function(g){return'"'+o(g.text)+'"'},class:function(g){var I=g.parts.map(function(c){return Array.isArray(c)?n(c[0])+"-"+n(c[1]):n(c)});return"["+(g.inverted?"^":"")+I.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(I){return"\\x0"+i(I)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(I){return"\\x"+i(I)})}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(I){return"\\x0"+i(I)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(I){return"\\x"+i(I)})}function s(g){return e[g.type](g)}function r(g){var I=g.map(s),c,B;if(I.sort(),I.length>0){for(c=1,B=1;c<I.length;c++)I[c-1]!==I[c]&&(I[B]=I[c],B++);I.length=B}switch(I.length){case 1:return I[0];case 2:return I[0]+" or "+I[1];default:return I.slice(0,-1).join(", ")+", or "+I[I.length-1]}}function a(g){return g?'"'+o(g)+'"':"end of input"}return"Expected "+r(t)+" but "+a(A)+" found."};var K9A=25.4,Tft=K9A/1e3,Kft=/^\s*(-?\d*(?:\.\d+)?)(?:\s*(mm|mil|inch|in|"))?\s*$/i;function qft(t){if(!t)return;const A=t.trim().toLowerCase();return A==='"'||A==="inch"?"in":A}function yQ(t){if(t==null)return;if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(typeof t!="string")return;const A=t.trim();if(A.length===0)return;const e=A.match(Kft);if(!e){const r=Number.parseFloat(A);return Number.isFinite(r)?r:void 0}const[,i,o]=e,n=Number.parseFloat(i||"0");if(!Number.isFinite(n))return;switch(qft(o)){case"mil":return n*Tft;case"in":return n*K9A;case"mm":case void 0:return n;default:return n}}function vw(t,A){const e=yQ(t);return e===void 0?A:e}function q9A(t){let A=t;if(A.startsWith("#")&&(A=A.slice(1)),A.length===6){const e=parseInt(A.slice(0,2),16),i=parseInt(A.slice(2,4),16),o=parseInt(A.slice(4,6),16);return`rgb(${e}, ${i}, ${o})`}return t.startsWith("rgb")?t:"rgb(255, 243, 204)"}function I8({layer:t,circuitJson:A,boardData:e,silkscreenColor:i="rgb(255,255,255)",traceTextureResolution:o}){const n=mi(A).pcb_silkscreen_text.list(),s=mi(A).pcb_silkscreen_path.list(),r=mi(A).pcb_silkscreen_line.list(),a=mi(A).pcb_silkscreen_rect.list(),g=mi(A).pcb_silkscreen_circle.list(),I=mi(A).pcb_fabrication_note_rect.list(),c=mi(A).pcb_note_line.list(),B=n.filter(v=>v.layer===t),l=s.filter(v=>v.layer===t),C=r.filter(v=>v.layer===t),Q=a.filter(v=>v.layer===t),E=g.filter(v=>v.layer===t),h=I.filter(v=>v.layer===t),u=c.filter(v=>v.layer===t);if(B.length===0&&l.length===0&&C.length===0&&Q.length===0&&E.length===0&&h.length===0&&u.length===0)return null;const d=dF(e),f=document.createElement("canvas"),m=Math.floor(d.width*o),S=Math.floor(d.height*o);f.width=m,f.height=S;const D=f.getContext("2d");if(!D)return null;t==="bottom"&&(D.translate(0,S),D.scale(1,-1)),D.strokeStyle=i,D.fillStyle=i;const x=v=>(v-d.minX)*o,F=v=>(d.maxY-v)*o;C.forEach(v=>{const _=yQ(v.x1)??0,H=yQ(v.y1)??0,P=yQ(v.x2)??0,J=yQ(v.y2)??0;_===P&&H===J||(D.beginPath(),D.lineWidth=vw(v.stroke_width,.1)*o,D.lineCap="round",D.moveTo(x(_),F(H)),D.lineTo(x(P),F(J)),D.stroke())}),u.forEach(v=>{const _=yQ(v.x1)??0,H=yQ(v.y1)??0,P=yQ(v.x2)??0,J=yQ(v.y2)??0;if(_===P&&H===J)return;D.save();let W=i;v.color?W=q9A(v.color):W="rgb(255, 243, 204)",D.strokeStyle=W,D.beginPath(),D.lineWidth=vw(v.stroke_width,.1)*o,D.lineCap="round";const Z=v.is_dashed??!1;if(Z){const AA=Math.max(D.lineWidth*2,1);D.setLineDash([AA,AA])}D.moveTo(x(_),F(H)),D.lineTo(x(P),F(J)),D.stroke(),Z&&D.setLineDash([]),D.restore()}),l.forEach(v=>{v.route.length<2||(D.beginPath(),D.lineWidth=vw(v.stroke_width,.1)*o,D.lineCap="round",D.lineJoin="round",v.route.forEach((_,H)=>{const P=x(yQ(_.x)??0),J=F(yQ(_.y)??0);H===0?D.moveTo(P,J):D.lineTo(P,J)}),D.stroke())}),E.forEach(v=>{const _=vw(v.radius,0);if(_<=0)return;const H=vw(v.stroke_width,.12),P=H>0,J=yQ(v.center?.x)??0,W=yQ(v.center?.y)??0,Z=x(J),AA=F(W),nA=_*o;if(D.save(),D.translate(Z,AA),P){const gA=nA+H/2*o,tA=Math.max(0,nA-H/2*o);tA>0?(D.beginPath(),D.arc(0,0,gA,0,2*Math.PI),D.arc(0,0,tA,0,2*Math.PI,!0),D.fill("evenodd")):(D.beginPath(),D.arc(0,0,gA,0,2*Math.PI),D.fill())}else D.beginPath(),D.arc(0,0,nA,0,2*Math.PI),D.fill();D.restore()}),Q.forEach(v=>{const _=vw(v.width,0),H=vw(v.height,0);if(_<=0||H<=0)return;const P=yQ(v.center?.x)??0,J=yQ(v.center?.y)??0,W=x(P),Z=F(J),AA=GC(v),nA=typeof AA=="string"?yQ(AA):AA,gA=l0(_,H,nA);D.save(),D.translate(W,Z);const tA=_/2*o,iA=H/2*o,rA=Math.min(gA*o,tA,iA),CA=v.stroke_width??!1,dA=v.is_filled??!0,bA=v.is_stroke_dashed??!1,kA=CA?vw(v.stroke_width,.1)*o:0;if(((lA,RA,uA,KA,$A)=>{if(D.beginPath(),$A<=0)D.rect(lA,RA,uA,KA);else{const re=$A,yA=lA+uA,qA=RA+KA;D.moveTo(lA+re,RA),D.lineTo(yA-re,RA),D.quadraticCurveTo(yA,RA,yA,RA+re),D.lineTo(yA,qA-re),D.quadraticCurveTo(yA,qA,yA-re,qA),D.lineTo(lA+re,qA),D.quadraticCurveTo(lA,qA,lA,qA-re),D.lineTo(lA,RA+re),D.quadraticCurveTo(lA,RA,lA+re,RA),D.closePath()}})(-tA,-iA,tA*2,iA*2,rA),dA&&D.fill(),CA&&kA>0){if(D.lineWidth=kA,bA){const lA=Math.max(kA*2,1);D.setLineDash([lA,lA])}D.stroke(),bA&&D.setLineDash([])}D.restore()}),h.forEach(v=>{const _=vw(v.width,0),H=vw(v.height,0);if(_<=0||H<=0)return;const P=yQ(v.center?.x)??0,J=yQ(v.center?.y)??0,W=x(P),Z=F(J),AA=GC(v),nA=typeof AA=="string"?yQ(AA):AA,gA=l0(_,H,nA);D.save(),D.translate(W,Z);const tA=_/2*o,iA=H/2*o,rA=Math.min(gA*o,tA,iA),CA=v.has_stroke??!1,dA=v.is_filled??!0,bA=v.is_stroke_dashed??!1,kA=CA?vw(v.stroke_width,.1)*o:0;let YA=i,lA=i;if(v.color){const uA=q9A(v.color);YA=uA,lA=uA}else YA="rgb(255, 243, 204)",lA="rgb(255, 243, 204)";if(((uA,KA,$A,re,yA)=>{if(D.beginPath(),yA<=0)D.rect(uA,KA,$A,re);else{const qA=yA,HA=uA+$A,vA=KA+re;D.moveTo(uA+qA,KA),D.lineTo(HA-qA,KA),D.quadraticCurveTo(HA,KA,HA,KA+qA),D.lineTo(HA,vA-qA),D.quadraticCurveTo(HA,vA,HA-qA,vA),D.lineTo(uA+qA,vA),D.quadraticCurveTo(uA,vA,uA,vA-qA),D.lineTo(uA,KA+qA),D.quadraticCurveTo(uA,KA,uA+qA,KA),D.closePath()}})(-tA,-iA,tA*2,iA*2,rA),dA&&(D.fillStyle=YA,D.fill()),CA&&kA>0){if(D.strokeStyle=lA,D.lineWidth=kA,bA){const uA=Math.max(kA*2,1);D.setLineDash([uA,uA])}D.stroke(),bA&&D.setLineDash([])}D.restore()}),B.forEach(v=>{const _=v.font_size||.25,H=Math.min(Math.max(.01,_*.1),_*.05)*o;D.lineWidth=H,D.lineCap="butt",D.lineJoin="miter";const P=(0,Lft.vectorText)({height:_*.45,input:v.text}),J=[];P.forEach(bA=>{bA.length===29?(J.push(bA.slice(0,15)),J.push(bA.slice(14,29))):bA.length===17?(J.push(bA.slice(0,10)),J.push(bA.slice(9,17))):J.push(bA)});const W=J.flat(),Z={minX:W.length>0?Math.min(...W.map(bA=>bA[0])):0,maxX:W.length>0?Math.max(...W.map(bA=>bA[0])):0,minY:W.length>0?Math.min(...W.map(bA=>bA[1])):0,maxY:W.length>0?Math.max(...W.map(bA=>bA[1])):0},AA=(Z.minX+Z.maxX)/2,nA=(Z.minY+Z.maxY)/2;let gA=-AA,tA=-nA;const iA=v.anchor_alignment||"center";iA.includes("left")?gA=-Z.minX:iA.includes("right")&&(gA=-Z.maxX),iA.includes("top")?tA=-Z.maxY:iA.includes("bottom")&&(tA=-Z.minY);const rA=[];let CA=v.ccw_rotation??0;if(v.layer==="bottom"&&(rA.push(Jx(AA,nA),{a:-1,b:0,c:0,d:1,e:0,f:0},Jx(-AA,-nA)),CA=-CA),CA){const bA=CA*Math.PI/180;rA.push(Jx(AA,nA),T9A(bA),Jx(-AA,-nA))}const dA=rA.length>0?J9A(...rA):void 0;J.forEach(bA=>{D.beginPath(),bA.forEach((kA,YA)=>{let lA={x:kA[0],y:kA[1]};dA&&(lA=H9A(dA,lA));const RA=lA.x+gA+v.anchor_position.x,uA=lA.y+tA+v.anchor_position.y,KA=x(RA),$A=F(uA);YA===0?D.moveTo(KA,$A):D.lineTo(KA,$A)}),D.stroke()})});const k=new TN(f);return k.generateMipmaps=!0,k.minFilter=xu,k.magFilter=XB,k.anisotropy=16,k.needsUpdate=!0,k}function P9A(t){return t&&t.route_type==="wire"&&typeof t.layer=="string"&&typeof t.width=="number"}function m_({layer:t,circuitJson:A,boardData:e,traceColor:i,traceTextureResolution:o}){const n=mi(A).pcb_trace.list(),s=mi(A).pcb_via.list(),r=mi(A).pcb_plated_hole.list(),a=n.filter(Q=>Q.route.some(E=>P9A(E)&&E.layer===t));if(a.length===0)return null;const g=dF(e),I=document.createElement("canvas"),c=Math.floor(g.width*o),B=Math.floor(g.height*o);I.width=c,I.height=B;const l=I.getContext("2d");if(!l)return null;t==="bottom"&&(l.translate(0,B),l.scale(1,-1)),a.forEach(Q=>{let E=!0;l.beginPath(),l.strokeStyle=i,l.lineCap="round",l.lineJoin="round";let h=0;for(const u of Q.route){if(!P9A(u)||u.layer!==t){E||l.stroke(),E=!0;continue}const d=u.x,f=u.y;h=u.width*o,l.lineWidth=h;const m=(d-g.minX)*o,S=(g.maxY-f)*o;E?(l.moveTo(m,S),E=!1):l.lineTo(m,S)}E||l.stroke()}),l.globalCompositeOperation="destination-out",l.fillStyle="black",s.forEach(Q=>{const E=(Q.x-g.minX)*o,h=(g.maxY-Q.y)*o,u=Q.outer_diameter/2*o;l.beginPath(),l.arc(E,h,u,0,2*Math.PI,!1),l.fill()}),r.forEach(Q=>{if(Q.layers.includes(t)&&Q.shape==="circle"){const E=(Q.x-g.minX)*o,h=(g.maxY-Q.y)*o,u=Q.outer_diameter/2*o;l.beginPath(),l.arc(E,h,u,0,2*Math.PI,!1),l.fill()}else if(Q.layers.includes(t)&&Q.shape==="rotated_pill_hole_with_rect_pad"){const E=(Q.x-g.minX)*o,h=(g.maxY-Q.y)*o,u=(Q.rect_pad_width??Q.hole_width??0)*o,d=(Q.rect_pad_height??Q.hole_height??0)*o,m=-(Q.rect_ccw_rotation||0);m?(l.save(),l.translate(E,h),l.rotate(m*Math.PI/180),l.beginPath(),l.rect(-u/2,-d/2,u,d),l.fill(),l.restore()):(l.beginPath(),l.rect(E-u/2,h-d/2,u,d),l.fill())}}),l.globalCompositeOperation="source-over";const C=new TN(I);return C.generateMipmaps=!0,C.minFilter=xu,C.magFilter=XB,C.anisotropy=16,C.needsUpdate=!0,C}var Pft=_r(OlA());function c8(t,A){if(t===void 0)return A;if(typeof t=="number")return t;const e=parseFloat(t.replace(/mm$/,""));return isNaN(e)?A:e}function Oft(t){return t.layer==="bottom"?t.is_mirrored!==!1:t.is_mirrored===!0}function Wft(t){const A=t.flat();if(A.length===0)return{minX:0,maxX:0,minY:0,maxY:0,width:0,height:0,centerX:0,centerY:0};const e=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:e,maxX:i,minY:o,maxY:n,width:i-e,height:n-o,centerX:(e+i)/2,centerY:(o+n)/2}}function Zft(t){const A=[];return t.forEach(e=>{e.length===29?(A.push(e.slice(0,15)),A.push(e.slice(14,29))):e.length===17?(A.push(e.slice(0,10)),A.push(e.slice(9,17))):A.push(e)}),A}function Vft(t,A){let e=-t.centerX,i=-t.centerY;return A.includes("left")?e=-t.minX:A.includes("right")&&(e=-t.maxX),A.includes("top")?i=-t.maxY:A.includes("bottom")&&(i=-t.minY),{x:e,y:i}}function jft(t,A){const e=[];let i=t.ccw_rotation??0;if(Oft(t)&&(e.push(Jx(A.centerX,A.centerY),{a:-1,b:0,c:0,d:1,e:0,f:0},Jx(-A.centerX,-A.centerY)),i=-i),i){const s=i*Math.PI/180;e.push(Jx(A.centerX,A.centerY),T9A(s),Jx(-A.centerX,-A.centerY))}return{matrix:e.length>0?J9A(...e):void 0,rotationDeg:i}}function O9A(t,A,e,i,o,n,s){A.forEach(r=>{t.beginPath(),r.forEach((a,g)=>{let I={x:a[0],y:a[1]};e&&(I=H9A(e,I));const c=I.x+i.x+o.x,B=I.y+i.y+o.y,l=n(c),C=s(B);g===0?t.moveTo(l,C):t.lineTo(l,C)}),t.stroke()})}function zft(t,A,e,i,o,n){t.save(),t.translate(A,e),t.rotate(-n),t.fillRect(-i/2,-o/2,i,o),t.restore()}function Xft(t,A,e,i,o,n,s,r,a,g){const I=typeof A.font_size=="number"?A.font_size:.2,c={left:c8(A.knockout_padding?.left,I*.5),right:c8(A.knockout_padding?.right,I*.5),top:c8(A.knockout_padding?.top,I*.3),bottom:c8(A.knockout_padding?.bottom,I*.3)},B=i.width+c.left+c.right,l=i.height+c.top+c.bottom,C=s(A.anchor_position.x),Q=r(A.anchor_position.y),E=B*a,h=l*a;t.fillStyle=g;const u=n*Math.PI/180;zft(t,C,Q,E,h,u);const d={x:-i.centerX,y:-i.centerY};t.globalCompositeOperation="destination-out",O9A(t,e,o,d,A.anchor_position,s,r),t.globalCompositeOperation="source-over"}function B8({layer:t,circuitJson:A,boardData:e,copperColor:i="rgb(230, 153, 51)",traceTextureResolution:o}){const s=A.filter(Q=>Q.type==="pcb_copper_text").filter(Q=>Q.layer===t);if(s.length===0)return null;const r=dF(e),a=document.createElement("canvas"),g=Math.floor(r.width*o),I=Math.floor(r.height*o);a.width=g,a.height=I;const c=a.getContext("2d");if(!c)return null;t==="bottom"&&(c.translate(0,I),c.scale(1,-1)),c.strokeStyle=i,c.fillStyle=i;const B=Q=>(Q-r.minX)*o,l=Q=>(r.maxY-Q)*o;s.forEach(Q=>{const E=typeof Q.font_size=="number"?Q.font_size:.2,h=Math.max(.02,E*.08)*o;c.lineWidth=h,c.lineCap="round",c.lineJoin="round";const u=(0,Pft.vectorText)({height:E*.45,input:Q.text}),d=Zft(u),f=Wft(d),{matrix:m,rotationDeg:S}=jft(Q,f);if(Q.is_knockout)Xft(c,Q,d,f,m,S,B,l,o,i);else{const D=Q.anchor_alignment||"center",x=Vft(f,D);O9A(c,d,m,x,Q.anchor_position,B,l)}});const C=new TN(a);return C.generateMipmaps=!0,C.minFilter=xu,C.magFilter=XB,C.anisotropy=16,C.needsUpdate=!0,C}function l8({layer:t,circuitJson:A,panelData:e,outlineColor:i="black",traceTextureResolution:o}){const n=mi(A).pcb_board.list().filter(l=>l.pcb_panel_id===e.pcb_board_id);if(n.length===0)return null;const s=document.createElement("canvas"),r=Math.floor(e.width*o),a=Math.floor(e.height*o);s.width=r,s.height=a;const g=s.getContext("2d");if(!g)return null;t==="bottom"&&(g.translate(0,a),g.scale(1,-1)),g.strokeStyle=i,g.lineWidth=.05*o;const I=l=>(l-e.center.x+e.width/2)*o,c=l=>(-(l-e.center.y)+e.height/2)*o;n.forEach(l=>{if(l.outline&&l.outline.length>=2)g.beginPath(),l.outline.forEach((C,Q)=>{const E=I(C.x),h=c(C.y);Q===0?g.moveTo(E,h):g.lineTo(E,h)}),g.closePath(),g.stroke();else{const C=l.width,Q=l.height,{x:E,y:h}=l.center,u=I(E-C/2),d=c(h+Q/2);g.strokeRect(u,d,C*o,Q*o)}});const B=new TN(s);return B.generateMipmaps=!0,B.minFilter=xu,B.magFilter=XB,B.anisotropy=16,B.needsUpdate=!0,B}function $ft({circuitJson:t,pcbThickness:A,isFaux:e=!1}){const{rootObject:i}=Ru(),{visibility:o}=r_(),n=j.useMemo(()=>{const r=t.filter(I=>I.type==="pcb_panel"),a=mi(t).pcb_board.list();if(r.length>0){const I=r[0],c=a.find(B=>B.pcb_panel_id===I.pcb_panel_id);return{type:"pcb_board",pcb_board_id:I.pcb_panel_id,center:I.center,width:I.width,height:I.height,thickness:c?.thickness??1.4,material:c?.material??"fr4",num_layers:c?.num_layers??2}}const g=a.filter(I=>!I.pcb_panel_id);return g.length>0?g[0]:null},[t]),s=j.useMemo(()=>{if(!n||!n.width||!n.height)return null;const r=k9A[n.material]??Fo.fr4SolderMaskGreen,a=`rgb(${Math.round(r[0]*255)}, ${Math.round(r[1]*255)}, ${Math.round(r[2]*255)})`,g="rgb(255,255,255)",I=Fo.fr4TracesWithMaskGreen,c=`rgb(${Math.round(I[0]*255)}, ${Math.round(I[1]*255)}, ${Math.round(I[2]*255)})`;return{topSoldermask:a8({layer:"top",circuitJson:t,boardData:n,soldermaskColor:a,traceTextureResolution:hc}),bottomSoldermask:a8({layer:"bottom",circuitJson:t,boardData:n,soldermaskColor:a,traceTextureResolution:hc}),topSilkscreen:I8({layer:"top",circuitJson:t,boardData:n,silkscreenColor:g,traceTextureResolution:hc}),bottomSilkscreen:I8({layer:"bottom",circuitJson:t,boardData:n,silkscreenColor:g,traceTextureResolution:hc}),topTraceWithMask:m_({layer:"top",circuitJson:t,boardData:n,traceColor:c,traceTextureResolution:hc}),bottomTraceWithMask:m_({layer:"bottom",circuitJson:t,boardData:n,traceColor:c,traceTextureResolution:hc}),topCopperText:B8({layer:"top",circuitJson:t,boardData:n,copperColor:`rgb(${Math.round(Fo.copper[0]*255)}, ${Math.round(Fo.copper[1]*255)}, ${Math.round(Fo.copper[2]*255)})`,traceTextureResolution:hc}),bottomCopperText:B8({layer:"bottom",circuitJson:t,boardData:n,copperColor:`rgb(${Math.round(Fo.copper[0]*255)}, ${Math.round(Fo.copper[1]*255)}, ${Math.round(Fo.copper[2]*255)})`,traceTextureResolution:hc}),topPanelOutlines:l8({layer:"top",circuitJson:t,panelData:n,traceTextureResolution:hc}),bottomPanelOutlines:l8({layer:"bottom",circuitJson:t,panelData:n,traceTextureResolution:hc})}},[t,n]);return j.useEffect(()=>{if(!i||!n||!s)return;const r=[],a=(I,c,B,l,C=!1,Q=!1)=>{if(!I)return null;const E=dF(n),h=new Rw(E.width,E.height),u=new bd({map:I,transparent:!0,side:Tl,depthWrite:Q,polygonOffset:C,polygonOffsetFactor:C?-1:0,polygonOffsetUnits:C?-1:0,opacity:e?i8:1}),d=new Vo(h,u);return d.position.set(E.centerX,E.centerY,c),B&&d.rotation.set(Math.PI,0,0),d.name=l,d},g=.001;if(o.topMask){const I=a(s.topSoldermask,A/2+g,!1,"jscad-top-soldermask",!0);I&&(r.push(I),i.add(I))}if(o.bottomMask){const I=a(s.bottomSoldermask,-A/2-g,!0,"jscad-bottom-soldermask",!0);I&&(r.push(I),i.add(I))}if(o.topCopper&&o.topMask){const I=a(s.topTraceWithMask,A/2+ig.traces+.004,!1,"jscad-top-trace-with-mask");I&&(r.push(I),i.add(I))}if(o.bottomCopper&&o.bottomMask){const I=a(s.bottomTraceWithMask,-A/2-ig.traces-.005,!0,"jscad-bottom-trace-with-mask");I&&(r.push(I),i.add(I))}if(o.topSilkscreen){const I=a(s.topSilkscreen,A/2+g+.002,!1,"jscad-top-silkscreen");I&&(r.push(I),i.add(I))}if(o.bottomSilkscreen){const I=a(s.bottomSilkscreen,-A/2-g-.002,!0,"jscad-bottom-silkscreen");I&&(r.push(I),i.add(I))}if(o.topCopper){const I=a(s.topCopperText,A/2+ig.copper,!1,"jscad-top-copper-text");I&&(r.push(I),i.add(I))}if(o.bottomCopper){const I=a(s.bottomCopperText,-A/2-ig.copper,!0,"jscad-bottom-copper-text");I&&(r.push(I),i.add(I))}if(o.boardBody){const I=a(s.topPanelOutlines,A/2+g+.003,!1,"jscad-top-panel-outlines",!1,!0);I&&(r.push(I),i.add(I));const c=a(s.bottomPanelOutlines,-A/2-g-.003,!0,"jscad-bottom-panel-outlines",!1,!0);c&&(r.push(c),i.add(c))}return()=>{r.forEach(I=>{I.parent===i&&i.remove(I),I.geometry.dispose(),I.material instanceof Af&&I.material.dispose()})}},[i,n,s,A,o]),null}function A0t(t){const A=mi(t).cad_component.list(),e=mi(t).pcb_smtpad.list(),i=mi(t).pcb_hole.list(),o=mi(t).pcb_plated_hole.list(),n=mi(t).pcb_via.list();if(A.length===0&&e.length===0&&i.length===0&&o.length===0&&n.length===0)return null;const s=[...i,...o,...n,...e],r=A2(s);let a=r.minX,g=r.maxX,I=r.minY,c=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),I=Math.min(I,f),c=Math.max(c,f)}a===1/0&&(a=-10,g=10,I=-10,c=10);const B=2,l=Math.max(Math.abs(a),Math.abs(g))+B,C=Math.max(Math.abs(I),Math.abs(c))+B,Q=Math.max(2*l,10),E=Math.max(2*C,10);return{type:"pcb_board",pcb_board_id:"faux-board",center:{x:0,y:0},width:Q,height:E,thickness:1.4,material:"fr4",num_layers:2}}function W9A(t){if(mi(t).pcb_board.list().length>0)return t;const e=A0t(t);if(!e)return t;const o=e.thickness/2;return[...t.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}),e]}var e0t=j.forwardRef(({circuitJson:t,children:A,autoRotateDisabled:e,clickToInteractEnabled:i,onUserInteraction:o,onCameraControllerReady:n},s)=>{const r=x9A(A),a=j.useMemo(()=>W9A(t??r),[t,r]),g=Rft(a),I=j.useMemo(()=>{if(!a)return[5,-5,5];try{const h=mi(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),S=Math.max(d,f),D=Math.max(m,S);return[D*.4,-D*.7,D*.9]}catch(h){return console.error(h),[5,-5,5]}},[a]),c=j.useMemo(()=>{if(!a)return!1;try{const h=mi(a).pcb_board.list()[0];return!!h&&h.pcb_board_id==="faux-board"}catch{return!1}},[a]),B=j.useMemo(()=>{if(a)try{const h=mi(a).pcb_board.list()[0];return h?{width:h.width??0,height:h.height??0}:void 0}catch(h){console.error(h);return}},[a]),l=j.useMemo(()=>{if(a)try{const h=mi(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=VZA(a),{stls:Q}=gft(g),E=mi(a).cad_component.list();return O.jsxs(b9A,{ref:s,autoRotateDisabled:e,initialCameraPosition:I,clickToInteractEnabled:i,boardDimensions:B,boardCenter:l,onUserInteraction:o,onCameraControllerReady:n,children:[Q.map(({stlData:h,color:u,layerType:d},f)=>O.jsx(vft,{stlData:h,color:u,opacity:f===0?c?.8:.95:1,layerType:d},`board-${f}`)),O.jsx($ft,{circuitJson:a,pcbThickness:C,isFaux:c}),E.map(h=>O.jsx(L9A,{fallback:({error:u})=>O.jsx(U9A,{cad_component:h,error:u}),children:O.jsx(y9A,{cad_component:h,circuitJson:a},h.cad_component_id)},h.cad_component_id))]})}),t0t=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;t[i]&&t[o]&&(A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1])}return A/2<=0};function i0t(t,A,e,i,o){let n,s=null;if(e.outline&&e.outline.length>=3){let r=e.outline.map(g=>[g.x,g.y]);t0t(r)&&(r=r.reverse());const a=A.ofPolygons([r]);o.push(a),s=a,n=t.extrude(a,i,void 0,void 0,void 0,!0),o.push(n)}else e.outline&&e.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),n=t.cube([e.width,e.height,i],!0),o.push(n),n=n.translate([e.center.x,e.center.y,0]),o.push(n);return{boardOp:n,outlineCrossSection:s}}var o0t=64;function Rd({Manifold:t,width:A,height:e,thickness:i,borderRadius:o}){const n=l0(A,e,o);if(n<=0)return t.cube([A,e,i],!0);const s=[],r=A-2*n,a=e-2*n;return r>0&&s.push(t.cube([r,e,i],!0)),a>0&&s.push(t.cube([A,a,i],!0)),[[A/2-n,e/2-n],[-A/2+n,e/2-n],[-A/2+n,-e/2+n],[A/2-n,-e/2+n]].forEach(([I,c])=>{s.push(t.cylinder(i,n,n,o0t,!0).translate([I,c,0]))}),t.union(s)}function n0t({Manifold:t,pad:A,padBaseThickness:e}){if(A.shape==="rect"){const i=GC(A);return Rd({Manifold:t,width:A.width,height:A.height,thickness:e,borderRadius:i})}else if(A.shape==="rotated_rect"){const i=GC(A);let o=Rd({Manifold:t,width:A.width,height:A.height,thickness:e,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 t.cylinder(e,A.radius,-1,32,!0);return null}var s0t=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;t[i]&&t[o]&&(A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1])}return A/2<=0};function r0t(t,A,e,i,o){const n=[],s=mi(e).pcb_cutout.list();for(const r of s){let a;const g=i*1.5;switch(r.shape){case"rect":{const B=GC(r);if(typeof B=="number"&&B>0?a=Rd({Manifold:t,width:r.width,height:r.height,thickness:g,borderRadius:B}):a=t.cube([r.width,r.height,g],!0),o.push(a),r.rotation){const l=a.rotate([0,0,r.rotation]);o.push(l),a=l}a=a.translate([r.center.x,r.center.y,0]),o.push(a);break}case"circle":a=t.cylinder(g,r.radius,-1,ql,!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 I=r.points.map(B=>[B.x,B.y]);s0t(I)&&(I=I.reverse());const c=A.ofPolygons([I]);o.push(c),a=t.extrude(c,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 Z9A({Manifold:t,x:A,y:e,diameter:i,thickness:o,segments:n=32}){return t.cylinder(o*1.2,i/2,i/2,n,!0).translate([A,e,0])}function V9A({Manifold:t,x:A,y:e,holeDiameter:i,thickness:o,zOffset:n=.001,segments:s=32}){const r=i/2+n;return t.cylinder(o*1.2,r,r,s,!0).translate([A,e,0])}function a0t(t,A,e,i,o){const n=[],s=mi(e).pcb_hole.list(),r=(g,I,c)=>{const B=Rd({Manifold:t,width:g,height:I,thickness:c,borderRadius:Math.min(g,I)/2});return o.push(B),B},a=(g,I,c)=>{const B=[];for(let l=0;l<c;l++){const C=2*Math.PI*l/c;B.push([g/2*Math.cos(C),I/2*Math.sin(C)])}return B};return s.forEach(g=>{const I=g.hole_shape,c=g.x,B=g.y,l=i*1.2,C=g.ccw_rotation??g.rotation??0,Q=g.hole_width??g.hole_diameter,E=g.hole_height??g.hole_diameter;let h=null;if(I==="circle"){h=Z9A({Manifold:t,x:c,y:B,diameter:g.hole_diameter,thickness:i,segments:ql}),n.push(h),o.push(h);return}if(I==="pill"||I==="rotated_pill")h=r(Q,E,l);else if(I==="oval"){let u=a(Q,E,ql),d=0;for(let m=0;m<u.length;m++){const S=(m+1)%u.length;d+=u[m][0]*u[S][1],d-=u[S][0]*u[m][1]}d<=0&&(u=u.reverse());const f=A.ofPolygons([u]);o.push(f),h=t.extrude(f,l,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([c,B,0]);o.push(u),n.push(u)}}),{nonPlatedHoleBoardDrills:n}}function Uw(t){const A=new mg;if(A.setAttribute("position",new Un(t.vertProperties,3)),A.setIndex(new ioA(t.triVerts,1)),t.runIndex&&t.runIndex.length>1&&t.runOriginalID)for(let e=0;e<t.runIndex.length-1;e++){const i=t.runIndex[e],o=t.runIndex[e+1]-i;A.addGroup(i,o,0)}else A.addGroup(0,t.triVerts.length,0);return A}var HL=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;t[i]&&t[o]&&(A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1])}return A/2<=0},C8=(t,A,e)=>{const i=[];for(let o=0;o<e;o++){const n=2*Math.PI*o/e;i.push([t/2*Math.cos(n),A/2*Math.sin(n)])}return i},pF=new Li(...Fo.copper),Q8=.05;function g0t(t,A,e,i,o,n){const s=[],r=mi(e).pcb_plated_hole.list(),a=[],g=[],I=(C,Q,E)=>{const h=Rd({Manifold:t,width:C,height:Q,thickness:E,borderRadius:Math.min(C,Q)/2});return o.push(h),h},c=({padOutline:C,thickness:Q})=>{if(!Array.isArray(C)||C.length<3)return null;let E=C.map(d=>[d.x,d.y]);HL(E)&&(E=E.reverse());const h=A.ofPolygons([E]);o.push(h);const u=t.extrude(h,Q,0,0,[1,1],!0);return o.push(u),u},B=({ph:C,depth:Q,sizeDelta:E=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 S=null;if(d==="circle"){const D=Math.max((C.hole_diameter??0)+E,mo),x=Math.max(D/2,mo/2);S=t.cylinder(Q,x,x,ql,!0),o.push(S)}else{const D=C.hole_width??C.hole_diameter,x=C.hole_height??C.hole_diameter;if(!D||!x)return null;const F=Math.max(D+E,mo),k=Math.max(x+E,mo);if(d==="oval"){let v=C8(F,k,ql);HL(v)&&(v=v.reverse());const _=A.ofPolygons([v]);o.push(_),S=t.extrude(_,Q,0,0,[1,1],!0),o.push(S)}else(d==="pill"||d==="rotated_pill")&&(S=Rd({Manifold:t,width:F,height:k,thickness:Q,borderRadius:Math.min(F,k)/2}),o.push(S))}if(!S)return null;if(f||m){const D=S.translate([f,m,0]);o.push(D),S=D}return S};r.forEach((C,Q)=>{if(C.shape==="circle"){const E=V9A({Manifold:t,x:C.x,y:C.y,holeDiameter:C.hole_diameter*1.02,thickness:i,zOffset:nf,segments:ql});o.push(E),s.push(E);const h=i+2*nf,u=t.cylinder(h,C.outer_diameter/2,C.outer_diameter/2,ql,!0);o.push(u);const d=t.cylinder(h*1.05,C.hole_diameter/2,C.hole_diameter/2,ql,!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 S=m;if(n){const x=t.intersection([m,n]);o.push(x),S=x}g.push(S);const D=Uw(S.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:D,color:pF})}else if(C.shape==="pill"){const E=C.hole_width,h=C.hole_height,u=.4,d=C.outer_width??E+u,f=C.outer_height??h+u,m=E+2*nf,S=h+2*nf,D=i*1.2;let x=I(m,S,D);if(C.ccw_rotation){const Z=x.rotate([0,0,C.ccw_rotation]);o.push(Z),x=Z}const F=x.translate([C.x,C.y,0]);o.push(F),s.push(F);const k=i+2*nf,v=I(d,f,k),_=I(E,h,k*1.05);let H=v.subtract(_);if(o.push(H),C.ccw_rotation){const Z=H.rotate([0,0,C.ccw_rotation]);o.push(Z),H=Z}const P=H.translate([C.x,C.y,0]);o.push(P);let J=P;if(n){const Z=t.intersection([P,n]);o.push(Z),J=Z}g.push(J);const W=Uw(J.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:W,color:pF})}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 E=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,S=GC(C),D=_L,x=E+2*nf,F=h+2*nf,k=i*1.2,_=I(x,F,k).translate([u,d,0]).translate([C.x,C.y,0]);o.push(_),s.push(_);const H=Rd({Manifold:t,width:f,height:m,thickness:i-2*D-2*ig.copper+.1,borderRadius:S});o.push(H);const P=Rd({Manifold:t,width:f,height:m,thickness:D,borderRadius:S}).translate([0,0,i/2/2+ig.copper]),J=Rd({Manifold:t,width:f,height:m,thickness:D,borderRadius:S}).translate([0,0,-i/2/2-ig.copper]);o.push(P,J);const W=I(E,h,i*1.02).translate([u,d,0]);o.push(W);const Z=t.union([H,P,J,W]);o.push(Z);const AA=I(Math.max(E-2*Q8,.01),Math.max(h-2*Q8,.01),i*1.2).translate([u,d,0]);o.push(AA);const nA=Z.subtract(AA);o.push(nA);const gA=nA.translate([C.x,C.y,0]);o.push(gA);let tA=gA;if(n){const rA=t.intersection([gA,n]);o.push(rA),tA=rA}g.push(tA);const iA=Uw(tA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:iA,color:pF})}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 E=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,S=GC(C),D=_L,x=E+2*nf,F=h+2*nf,k=i*1.2;let v=I(x,F,k).translate([u,d,0]);if(C.hole_ccw_rotation){const rA=v.rotate([0,0,C.hole_ccw_rotation]);o.push(rA),v=rA}const _=v.translate([C.x,C.y,0]);o.push(_),s.push(_);let H=Rd({Manifold:t,width:f,height:m,thickness:i-2*D-2*ig.copper+.1,borderRadius:S});if(o.push(H),C.rect_ccw_rotation){const rA=H.rotate([0,0,C.rect_ccw_rotation]);o.push(rA),H=rA}let P=Rd({Manifold:t,width:f,height:m,thickness:D,borderRadius:S}).translate([0,0,i/2/2+ig.copper]);if(C.rect_ccw_rotation){const rA=P.rotate([0,0,C.rect_ccw_rotation]);o.push(rA),P=rA}let J=Rd({Manifold:t,width:f,height:m,thickness:D,borderRadius:S}).translate([0,0,-i/2/2-ig.copper]);if(C.rect_ccw_rotation){const rA=J.rotate([0,0,C.rect_ccw_rotation]);o.push(rA),J=rA}o.push(P,J);let W=I(E,h,i*1.02).translate([u,d,0]);if(C.hole_ccw_rotation){const rA=W.rotate([0,0,C.hole_ccw_rotation]);o.push(rA),W=rA}o.push(W);const Z=t.union([H,P,J,W]);o.push(Z);let AA=I(Math.max(E-2*Q8,.01),Math.max(h-2*Q8,.01),i*1.2).translate([u,d,0]);if(C.hole_ccw_rotation){const rA=AA.rotate([0,0,C.hole_ccw_rotation]);o.push(rA),AA=rA}o.push(AA);const nA=Z.subtract(AA);o.push(nA);const gA=nA.translate([C.x,C.y,0]);o.push(gA);let tA=gA;if(n){const rA=t.intersection([gA,n]);o.push(rA),tA=rA}g.push(tA);const iA=Uw(tA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:iA,color:pF})}else if(C.shape==="hole_with_polygon_pad"){const E=C.pad_outline;if(!Array.isArray(E)||E.length<3)return;const h=B({ph:C,depth:i*1.2,sizeDelta:2*mo});if(!h)return;const u=h.translate([C.x,C.y,0]);o.push(u),s.push(u);const d=_L,f=Math.max(i-2*d-2*ig.copper+.1,mo),m=c({padOutline:E,thickness:f}),S=c({padOutline:E,thickness:d}),D=c({padOutline:E,thickness:d});if(!m||!S||!D)return;const x=S.translate([0,0,i/2/2+ig.copper]),F=D.translate([0,0,-i/2/2-ig.copper]);o.push(x,F);const k=B({ph:C,depth:i*1.02});if(!k)return;const v=B({ph:C,depth:i*1.2,sizeDelta:-2*mo})||k,_=t.union([m,x,F,k]);o.push(_);const H=_.subtract(v);o.push(H);const P=H.translate([C.x,C.y,0]);o.push(P);let J=P;if(n){const Z=t.intersection([P,n]);o.push(Z),J=Z}g.push(J);const W=Uw(J.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:W,color:pF})}else if(C.shape==="oval"){const E=C.hole_width,h=C.hole_height,u=C.outer_width??E+.4,d=C.outer_height??h+.4,f=E+2*nf,m=h+2*nf,S=i*1.2;let D=C8(f,m,ql);HL(D)&&(D=D.reverse());const x=A.ofPolygons([D]);o.push(x);let F=t.extrude(x,S,0,0,[1,1],!0);if(o.push(F),C.ccw_rotation){const iA=F.rotate([0,0,C.ccw_rotation]);o.push(iA),F=iA}const k=F.translate([C.x,C.y,0]);o.push(k),s.push(k);const v=i+2*nf;let _=C8(u,d,ql);HL(_)&&(_=_.reverse());const H=A.ofPolygons([_]);o.push(H);const P=t.extrude(H,v,0,0,[1,1],!0);o.push(P);let J=C8(E,h,ql);HL(J)&&(J=J.reverse());const W=A.ofPolygons([J]);o.push(W);const Z=t.extrude(W,v*1.05,0,0,[1,1],!0);o.push(Z);let AA=P.subtract(Z);if(o.push(AA),C.ccw_rotation){const iA=AA.rotate([0,0,C.ccw_rotation]);o.push(iA),AA=iA}const nA=AA.translate([C.x,C.y,0]);o.push(nA);let gA=nA;if(n){const iA=t.intersection([nA,n]);o.push(iA),gA=iA}g.push(gA);const tA=Uw(gA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:tA,color:pF})}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 E=C.hole_offset_x||0,h=C.hole_offset_y||0,u=Z9A({Manifold:t,x:C.x+E,y:C.y+h,diameter:C.hole_diameter,thickness:i,segments:ql});o.push(u),s.push(u);const d=C.rect_pad_width??C.hole_diameter,f=C.rect_pad_height??C.hole_diameter,m=GC(C),S=_L,D=C.hole_diameter/2,x=Rd({Manifold:t,width:d,height:f,thickness:i-2*S-2*ig.copper+.1,borderRadius:m});o.push(x);const F=Rd({Manifold:t,width:d,height:f,thickness:S,borderRadius:m}).translate([0,0,i/2/2+ig.copper]),k=Rd({Manifold:t,width:d,height:f,thickness:S,borderRadius:m}).translate([0,0,-i/2/2-ig.copper]);o.push(F,k);const v=t.cylinder(i*1.02,D,D,ql,!0).translate([E,h,0]);o.push(v);const _=t.union([x,F,k,v]);o.push(_);const H=t.cylinder(i*1.2,Math.max(D-mo,.01),Math.max(D-mo,.01),ql,!0).translate([E,h,0]);o.push(H);const P=_.subtract(H);o.push(P);const J=P.translate([C.x,C.y,0]);o.push(J);let W=J;if(n){const AA=t.intersection([J,n]);o.push(AA),W=AA}g.push(W);const Z=Uw(W.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:Z,color:pF})}});let l;return g.length>0&&(l=t.union(g),o.push(l)),{platedHoleBoardDrills:s,platedHoleCopperGeoms:a,platedHoleSubtractOp:l}}var I0t=new Li(...Fo.copper);function c0t(t,A,e,i,o,n){const s=[];return mi(A).pcb_smtpad.list().forEach((a,g)=>{const I=_L,c=a.layer==="bottom"?-e/2-ig.copper:e/2+ig.copper;let B=n0t({Manifold:t,pad:a,padBaseThickness:I});if(B){i.push(B);const l=B.translate([a.x,a.y,c]);i.push(l);let C=l;if(o&&(C=l.subtract(o),i.push(C)),n){const E=t.intersection([C,n]);i.push(E),C=E}const Q=Uw(C.getMesh());s.push({key:`smt_pad-${a.layer||"top"}-${a.pcb_smtpad_id||g}`,geometry:Q,color:I0t})}}),{smtPadGeoms:s}}function B0t({Manifold:t,x:A,y:e,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 I=Math.min(i/2,o/2+g),c=t.cylinder(n,I,-1,r,!0),B=t.cylinder(a,i/2,-1,r,!0).translate([0,0,n/2]),l=t.cylinder(a,i/2,-1,r,!0).translate([0,0,-n/2]),C=t.union([c,B,l]),Q=n+a*2,E=t.cylinder(Q,o/2,-1,r,!0);return C.subtract(E).translate([A,e,0])}var l0t=new Li(...Fo.copper);function C0t(t,A,e,i,o){const n=[],s=mi(A).pcb_via.list(),r=[];return s.forEach((a,g)=>{if(typeof a.hole_diameter=="number"){const I=V9A({Manifold:t,x:a.x,y:a.y,holeDiameter:a.hole_diameter,thickness:e,zOffset:nf,segments:ql});i.push(I),n.push(I)}if(typeof a.outer_diameter=="number"&&typeof a.hole_diameter=="number"){const I=B0t({Manifold:t,x:a.x,y:a.y,outerDiameter:a.outer_diameter,holeDiameter:a.hole_diameter,thickness:e,zOffset:nf,segments:ql});i.push(I);let c=I;if(o){const l=t.intersection([I,o]);i.push(l),c=l}const B=Uw(c.getMesh());r.push({key:`via-${a.pcb_via_id||g}`,geometry:B,color:l0t})}}),{viaBoardDrills:n,viaCopperGeoms:r}}function j9A({ctx:t,points:A,canvasXFromPcb:e,canvasYFromPcb:i}){A.length<3||(t.beginPath(),A.forEach((o,n)=>{const s=e(o[0]),r=i(o[1]);n===0?t.moveTo(s,r):t.lineTo(s,r)}),t.closePath(),t.fill())}function Q0t({ctx:t,pour:A,canvasXFromPcb:e,canvasYFromPcb:i}){const o=A.brep_shape;if(!o||!o.outer_ring)return;const n=r8(o.outer_ring,32);if(n.length>=3&&j9A({ctx:t,points:n,canvasXFromPcb:e,canvasYFromPcb:i}),o.inner_rings&&o.inner_rings.length>0){t.globalCompositeOperation="destination-out";for(const s of o.inner_rings){const r=r8(s,32);r.length>=3&&j9A({ctx:t,points:r,canvasXFromPcb:e,canvasYFromPcb:i})}t.globalCompositeOperation="source-over"}}function z9A({layer:t,circuitJson:A,boardData:e,traceTextureResolution:i=hc}){const o=A.filter(h=>h.type==="pcb_copper_pour"),n=t==="top"?"top_copper":"bottom_copper",s=o.filter(h=>h.layer===t);if(s.length===0)return null;const r=dF(e),a=document.createElement("canvas"),g=Math.floor(r.width*i),I=Math.floor(r.height*i);a.width=g,a.height=I;const c=a.getContext("2d");if(!c)return null;t==="bottom"&&(c.translate(0,I),c.scale(1,-1));const B=h=>(h-r.minX)*i,l=h=>(r.maxY-h)*i,C=s.filter(h=>h.shape==="rect"||h.shape==="polygon"),Q=s.filter(h=>h.shape==="brep");if(C.length>0){const h=new _nt(c);h.setCameraBounds({minX:r.minX,maxX:r.maxX,minY:r.minY,maxY:r.maxY});const u=C.filter(S=>S.covered_with_solder_mask!==!1),d=C.filter(S=>S.covered_with_solder_mask===!1),f=`rgb(${Fo.fr4TracesWithMaskGreen.map(S=>S*255).join(",")})`,m=`rgb(${Fo.copper.map(S=>S*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 Q){const d=h.covered_with_solder_mask!==!1?Fo.fr4TracesWithMaskGreen:Fo.copper,f=`rgb(${d[0]*255}, ${d[1]*255}, ${d[2]*255})`;c.fillStyle=f,Q0t({ctx:c,pour:h,canvasXFromPcb:B,canvasYFromPcb:l})}const E=new TN(a);return E.generateMipmaps=!0,E.minFilter=xu,E.magFilter=XB,E.anisotropy=16,E.needsUpdate=!0,E}function sf(t,A){const{texture:e,yOffset:i,isBottomLayer:o,textureType:n,usePolygonOffset:s=!1,renderOrder:r=0,isFaux:a=!1}=t;if(!e)return null;const g=dF(A),I=new Rw(g.width,g.height),c=new bd({map:e,transparent:!0,side:Tl,depthWrite:n==="panel-outlines",polygonOffset:s,polygonOffsetFactor:s?-4:0,polygonOffsetUnits:s?-4:0,opacity:a?i8:1}),B=new Vo(I,c);return B.position.set(g.centerX,g.centerY,i),o&&B.rotation.set(Math.PI,0,0),B.name=`${o?"bottom":"top"}-${n}-texture-plane`,B.renderOrder=r,B}function E0t(t,A,e,i=!1){const o=[];if(!t||!A||e===null)return o;const n=sf({texture:t.topTrace,yOffset:e/2+ig.traces,isBottomLayer:!1,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);n&&o.push(n);const s=sf({texture:t.topTraceWithMask,yOffset:e/2+ig.traces,isBottomLayer:!1,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);s&&o.push(s);const r=sf({texture:t.topSilkscreen,yOffset:e/2+.003,isBottomLayer:!1,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);r&&o.push(r);const a=sf({texture:t.bottomTrace,yOffset:-e/2-ig.traces,isBottomLayer:!0,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);a&&o.push(a);const g=sf({texture:t.bottomTraceWithMask,yOffset:-e/2-ig.traces,isBottomLayer:!0,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);g&&o.push(g);const I=sf({texture:t.bottomSilkscreen,yOffset:-e/2-.003,isBottomLayer:!0,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);I&&o.push(I);const c=sf({texture:t.topSoldermask,yOffset:e/2+.001,isBottomLayer:!1,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);c&&o.push(c);const B=sf({texture:t.bottomSoldermask,yOffset:-e/2-.001,isBottomLayer:!0,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);B&&o.push(B);const l=sf({texture:t.topCopperText,yOffset:e/2+ig.copper,isBottomLayer:!1,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);l&&o.push(l);const C=sf({texture:t.bottomCopperText,yOffset:-e/2-ig.copper,isBottomLayer:!0,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);C&&o.push(C);const Q=sf({texture:t.topCopper,yOffset:e/2+ig.copper,isBottomLayer:!1,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);Q&&o.push(Q);const E=sf({texture:t.bottomCopper,yOffset:-e/2-ig.copper,isBottomLayer:!0,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);E&&o.push(E);const h=sf({texture:t.topPanelOutlines,yOffset:e/2+.004,isBottomLayer:!1,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);h&&o.push(h);const u=sf({texture:t.bottomPanelOutlines,yOffset:-e/2-.004,isBottomLayer:!0,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);return u&&o.push(u),o}var h0t=(t,A)=>{const[e,i]=j.useState(null),[o,n]=j.useState(null),[s,r]=j.useState(null),[a,g]=j.useState(null),[I,c]=j.useState(!0),B=j.useRef([]),l=j.useMemo(()=>{const Q=A.filter(u=>u.type==="pcb_panel"),E=mi(A).pcb_board.list();if(Q.length>0){const u=Q[0],d=E.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=E.filter(u=>!u.pcb_panel_id);return h.length>0?h[0]:null},[A]),C=j.useMemo(()=>{const Q=mi(A).pcb_board.list();return Q.length>0&&Q[0].pcb_board_id==="faux-board"},[A]);return j.useEffect(()=>{if(!t||!l){i(null),n(null),r(null),c(!1);return}if((l.width===0||!l.width)&&(l.height===0||!l.height)&&(!l.outline||l.outline.length<3)){i({platedHoles:[],smtPads:[],vias:[]}),n({}),r(l.thickness??0),c(!1);return}c(!0),g(null);const Q=t.Manifold,E=t.CrossSection,h=m=>{if(!(!m||typeof m.delete!="function"))try{m.delete()}catch(S){(!(S instanceof Error)||!S.message?.includes("Manifold instance already deleted"))&&console.warn("Failed to delete Manifold instance",S)}};B.current.forEach(h),B.current=[];let u=null;const d={},f={};try{const m=l.thickness||1.4;r(m);const{boardOp:S,outlineCrossSection:D}=i0t(Q,E,l,m,B.current);let x=S;const k=m+2*1;let v=null;const _=.01;if(D){let KA=D;if(_>0){const re=D.offset(_);B.current.push(re),KA=re}const $A=Q.extrude(KA,k,void 0,void 0,void 0,!0);B.current.push($A),v=$A}else{const KA=(l.width||0)+2*_,$A=(l.height||0)+2*_,re=Q.cube([KA,$A,k],!0);B.current.push(re);const yA=re.translate([l.center.x,l.center.y,0]);B.current.push(yA),v=yA}const H=[];let P=null;const{nonPlatedHoleBoardDrills:J}=a0t(Q,E,A,m,B.current);H.push(...J);const{platedHoleBoardDrills:W,platedHoleCopperGeoms:Z,platedHoleSubtractOp:AA}=g0t(Q,E,A,m,B.current,v);H.push(...W),d.platedHoles=Z;const{viaBoardDrills:nA,viaCopperGeoms:gA}=C0t(Q,A,m,B.current,v);if(H.push(...nA),d.vias=gA,H.length>0){P=Q.union(H),B.current.push(P);const KA=AA?Q.union([P,AA]):P;B.current.push(KA);const $A=x.subtract(KA);if(B.current.push($A),x=$A,AA){const re=AA.subtract(P);B.current.push(re);const yA=re.getMesh(),qA=Uw(yA);d.platedHoles=[{key:"plated-holes-union",geometry:qA,color:new Li(Fo.copper[0],Fo.copper[1],Fo.copper[2])}]}}const{cutoutOps:tA}=r0t(Q,E,A,m,B.current);if(tA.length>0){const KA=Q.union(tA);B.current.push(KA);const $A=x.subtract(KA);B.current.push($A),x=$A}if(u=x,u){const KA=u.getMesh(),$A=Uw(KA),re=UCA[l.material]??Fo.fr4Tan;d.board={geometry:$A,color:new Li(re[0],re[1],re[2]),material:l.material,isFaux:C}}const{smtPadGeoms:iA}=c0t(Q,A,m,B.current,P,v);d.smtPads=iA,i(d);const rA=Fo.fr4TracesWithoutMaskTan,CA=`rgb(${Math.round(rA[0]*255)}, ${Math.round(rA[1]*255)}, ${Math.round(rA[2]*255)})`;f.topTrace=m_({layer:"top",circuitJson:A,boardData:l,traceColor:CA,traceTextureResolution:hc}),f.bottomTrace=m_({layer:"bottom",circuitJson:A,boardData:l,traceColor:CA,traceTextureResolution:hc});const dA=Fo.fr4TracesWithMaskGreen,bA=`rgb(${Math.round(dA[0]*255)}, ${Math.round(dA[1]*255)}, ${Math.round(dA[2]*255)})`;f.topTraceWithMask=m_({layer:"top",circuitJson:A,boardData:l,traceColor:bA,traceTextureResolution:hc}),f.bottomTraceWithMask=m_({layer:"bottom",circuitJson:A,boardData:l,traceColor:bA,traceTextureResolution:hc});const kA="rgb(255,255,255)";f.topSilkscreen=I8({layer:"top",circuitJson:A,boardData:l,silkscreenColor:kA,traceTextureResolution:hc}),f.bottomSilkscreen=I8({layer:"bottom",circuitJson:A,boardData:l,silkscreenColor:kA,traceTextureResolution:hc});const YA=k9A[l.material]??Fo.fr4SolderMaskGreen,lA=`rgb(${Math.round(YA[0]*255)}, ${Math.round(YA[1]*255)}, ${Math.round(YA[2]*255)})`;f.topSoldermask=a8({layer:"top",circuitJson:A,boardData:l,soldermaskColor:lA,traceTextureResolution:hc}),f.bottomSoldermask=a8({layer:"bottom",circuitJson:A,boardData:l,soldermaskColor:lA,traceTextureResolution:hc});const RA=Fo.copper,uA=`rgb(${Math.round(RA[0]*255)}, ${Math.round(RA[1]*255)}, ${Math.round(RA[2]*255)})`;f.topCopperText=B8({layer:"top",circuitJson:A,boardData:l,copperColor:uA,traceTextureResolution:hc}),f.bottomCopperText=B8({layer:"bottom",circuitJson:A,boardData:l,copperColor:uA,traceTextureResolution:hc}),f.topPanelOutlines=l8({layer:"top",circuitJson:A,panelData:l,traceTextureResolution:hc}),f.bottomPanelOutlines=l8({layer:"bottom",circuitJson:A,panelData:l,traceTextureResolution:hc}),f.topCopper=z9A({layer:"top",circuitJson:A,boardData:l,traceTextureResolution:hc}),f.bottomCopper=z9A({layer:"bottom",circuitJson:A,boardData:l,traceTextureResolution:hc}),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{c(!1)}return()=>{B.current.forEach(h),B.current=[]}},[t,A,l]),{geoms:e,textures:o,pcbThickness:s,error:a,isLoading:I,boardData:l,isFauxBoard:C}},u0t=Tl,d0t=({material:t,color:A,side:e=u0t,isFaux:i=!1})=>t==="fr4"?new Mw({color:A,side:e,metalness:0,roughness:.8,specularIntensity:.2,ior:1.45,sheen:0,clearcoat:0,transparent:i,opacity:i?i8:1,flatShading:!0}):new hh({color:A,side:e,flatShading:!0,metalness:.1,roughness:.8,transparent:!0,opacity:i?i8:.9});function p0t(t){const A=[];if(!t)return A;if(t.board&&t.board.geometry){const i=new Vo(t.board.geometry,d0t({material:t.board.material,color:t.board.color,side:Tl,isFaux:t.board.isFaux}));i.name="board-geom",A.push(i)}const e=i=>{i&&i.forEach(o=>{const n=new Vo(o.geometry,new hh({color:o.color,side:Tl,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}));n.name=o.key,A.push(n)})};return e(t.platedHoles),e(t.smtPads),e(t.vias),A}var f0t=({geometryMeshes:t,textureMeshes:A})=>{const{rootObject:e}=Ru(),{visibility:i}=r_();return j.useEffect(()=>{if(e)return t.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&&e.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&&e.add(o)}),()=>{t.forEach(o=>{o.parent===e&&e.remove(o)}),A.forEach(o=>{o.parent===e&&e.remove(o)})}},[e,t,A,i]),null},y0t="https://cdn.jsdelivr.net/npm/manifold-3d@3.2.1",w0t=({circuitJson:t,autoRotateDisabled:A,clickToInteractEnabled:e,onUserInteraction:i,children:o,onCameraControllerReady:n})=>{const s=x9A(o),r=j.useMemo(()=>W9A(t??s),[t,s]),[a,g]=j.useState(null),[I,c]=j.useState(null);j.useEffect(()=>{if(window.ManifoldModule&&typeof window.ManifoldModule=="object"&&window.ManifoldModule.setup){g(window.ManifoldModule);return}const F=async J=>{try{const W=await J();W.setup(),window.ManifoldModule=W,g(W)}catch(W){console.error("Failed to initialize Manifold:",W),c(`Failed to initialize Manifold: ${W instanceof Error?W.message:"Unknown error"}`)}},k=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(k){window.ManifoldModule=k,F(window.ManifoldModule);return}const v="manifoldLoaded",_=()=>{const J=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(J)window.ManifoldModule=J,F(window.ManifoldModule);else{const W="ManifoldModule not found on window after script load.";console.error(W),c(W)}};window.addEventListener(v,_,{once:!0});const H=document.createElement("script");H.type="module",H.innerHTML=`
|
|
5111
5111
|
try {
|
|
5112
5112
|
const { default: ManifoldModule } = await import('${y0t}/manifold.js');
|
|
5113
5113
|
window.ManifoldModule = ManifoldModule;
|
|
@@ -5617,7 +5617,7 @@ test("${g} should solve problem correctly", () => {
|
|
|
5617
5617
|
// Add more specific assertions based on expected output
|
|
5618
5618
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5619
5619
|
})
|
|
5620
|
-
`,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),l=document.createElement("a");l.href=B,l.download=`${g}.test.ts`,l.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return O.jsxs("div",{className:`relative ${A}`,ref:o,children:[O.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&O.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:[O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},zte=t=>t.activeSubSolver?[t,...zte(t.activeSubSolver)]:[t],yKt=({solver:t})=>{const A=zte(t);return O.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>O.jsxs("div",{className:"flex items-center",children:[i>0&&O.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),O.jsx(fKt,{solver:e})]},e.constructor.name))})},wKt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=j.useReducer(Q=>!Q,!1),r=j.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};j.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),j.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const l=t.getCurrentPhase!==void 0,C=l?t.getCurrentPhase():null;return O.jsxs("div",{className:"space-y-2 p-2 border-b",children:[O.jsx("div",{className:"flex items-center",children:O.jsx(yKt,{solver:t})}),O.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[O.jsx("button",{onClick:a,disabled:t.solved||t.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"}),O.jsx("button",{onClick:g,disabled:t.solved||t.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"}),O.jsx("button",{onClick:I,disabled:t.solved||t.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"}),O.jsx("button",{onClick:B,disabled:t.solved||t.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"}),l&&O.jsx("button",{onClick:c,disabled:t.solved||t.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"}),O.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",O.jsx("span",{className:"font-medium",children:C})]}),t.solved&&O.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&O.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&O.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},mKt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},DKt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=mKt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],l=B?t.firstIterationOfPhase?.[B.solverName]:void 0;l!==void 0&&s!==null?a=l-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},SKt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return O.jsx("span",{className:`font-medium ${A[t]}`,children:t})},bKt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:O.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),O.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},xKt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),kKt=({stats:t})=>{if(!t||Object.keys(t).length===0)return O.jsx("span",{children:"-"});const A=Object.entries(t),e=xKt(t);return O.jsxs("details",{className:"cursor-pointer",children:[O.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),O.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>O.jsxs("div",{children:[i,": ",String(o)]},i))})]})},suA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(suA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=suA(i));return A},GKt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=suA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,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(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},FKt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>DKt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):GKt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return O.jsxs("div",{className:"border-t border-gray-200",children:[O.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:O.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),O.jsx("div",{className:"overflow-x-auto",children:O.jsxs("table",{className:"w-full text-sm",children:[O.jsx("thead",{children:O.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),O.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",O.jsx("sub",{children:"0"})]}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),O.jsx("tbody",{children:i.map(r=>O.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[O.jsx("td",{className:"px-4 py-2",children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),O.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.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"})})}),O.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(SKt,{status:r.status})}),O.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(bKt,{progress:r.progress})}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),O.jsx("td",{className:"px-4 py-2 text-gray-500",children:O.jsx(kKt,{stats:r.stats})}),O.jsx("td",{className:"px-4 py-2",children:r.solverInstance?O.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:[O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.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"})}),O.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},RKt=class extends Xi.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function MKt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,l=r-c,C=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return O.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${l} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>O.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>O.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>O.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var NKt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=j.useReducer(I=>I+1,0),s=j.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=j.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);j.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return O.jsxs("div",{children:[O.jsx(wKt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?O.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):O.jsx(RKt,{fallback:O.jsx(MKt,{graphics:s}),children:O.jsx(pKt,{graphics:s})}),a&&O.jsx(FKt,{solver:t,onStepUntilPhase:g})]})};const _Kt=()=>{j.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},vKt=t=>t.toLowerCase().includes("pack")?jSt:t.toLowerCase().includes("rout")?ebt:_St,UKt=({solverEvents:t=[]})=>{const[A,e]=j.useState(null);_Kt();const i=j.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=j.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=j.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=OeA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(OeA).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 t.length===0?O.jsx("div",{className:"rf-p-4",children:O.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:O.jsxs("div",{className:"rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),O.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."})]})})}):O.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[O.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[O.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 O.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=vKt(a.solverName);return O.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[O.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),O.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[O.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),O.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),O.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?O.jsx(by,{fallback:O.jsx("div",{className:"rf-p-4",children:O.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),O.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:O.jsx(NKt,{solver:s.instance})}):O.jsxs("div",{className:"rf-p-4",children:[O.jsxs("div",{className:"rf-mb-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),O.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&O.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:O.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),O.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[O.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:O.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),O.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:O.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)})})]})]}):O.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:O.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Xte=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{j.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{V3.captureException(i)}catch{}}},[t,A]),j.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{V3.captureException(o,{error_type:i.type})}catch{}}},[e])},$te="0.0.1490",LKt={version:$te},LZ=y1A()(w1A(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),HKt=t=>{const[A,e]=j.useState([]),[i,o]=j.useState(null),[n,s]=j.useState(""),[r,a]=rv("eval-version-selection",null),g=LZ(l=>l.setLastRunEvalVersion),I=LZ(l=>l.lastRunEvalVersion);return j.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(l=>l.json()).then(l=>{if(Array.isArray(l?.versions)){let C=[...l.versions];l.tags?.latest&&(o(l.tags.latest),C=C.filter(Q=>Q!==l.tags.latest)),e(C)}}).catch(()=>{})},[t]),j.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:j.useMemo(()=>A.filter(l=>l.includes(n)).slice(0,50),[A,n]),latestVersion:i,lastRunEvalVersion:I,search:n,setSearch:s,selectVersion:l=>{a(l),s("")}}},YKt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[o,n]=j.useState(""),[s,r]=j.useState("");if(!i)return null;const a=t.filter(c=>c.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),I=c=>{c.key==="Enter"&&(a.length===1?n(a[0]):g&&n(s))};return O.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:O.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[O.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),O.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:c=>r(c.target.value),onKeyDown:I}),O.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(c=>O.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${o===c?"bg-blue-50":""}`,onClick:()=>n(c),children:c},c)),g&&O.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${o===s?"bg-blue-50":""}`,onClick:()=>n(s),children:['Create new "',s,'"']})]}),O.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>o&&A(o),disabled:!o,children:o===s?`Create "${o}"`:`Save to ${o}`})]})]})})},JKt=t=>{const A=j.useRef(null),e=Yc(i=>i.recentEvents);j.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function TKt(t){const A=KKt(t),e=j.forwardRef((i,o)=>{const{children:n,...s}=i,r=j.Children.toArray(n),a=r.find(PKt);if(a){const g=a.props.children,I=r.map(c=>c===a?j.Children.count(g)>1?j.Children.only(null):j.isValidElement(g)?g.props.children:null:c);return O.jsx(A,{...s,ref:o,children:j.isValidElement(g)?j.cloneElement(g,void 0,I):null})}return O.jsx(A,{...s,ref:o,children:n})});return e.displayName=`${t}.Slot`,e}function KKt(t){const A=j.forwardRef((e,i)=>{const{children:o,...n}=e;if(j.isValidElement(o)){const s=WKt(o),r=OKt(n,o.props);return o.type!==j.Fragment&&(r.ref=i?Vp(i,s):s),j.cloneElement(o,r)}return j.Children.count(o)>1?j.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var qKt=Symbol("radix.slottable");function PKt(t){return j.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===qKt}function OKt(t,A){const e={...A};for(const i in A){const o=t[i],n=A[i];/^on[A-Z]/.test(i)?o&&n?e[i]=(...r)=>{const a=n(...r);return o(...r),a}:o&&(e[i]=o):i==="style"?e[i]={...o,...n}:i==="className"&&(e[i]=[o,n].filter(Boolean).join(" "))}return{...t,...e}}function WKt(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var HZ="Dialog",[Aie,eie]=hw(HZ),[ZKt,qw]=Aie(HZ),tie=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:o,onOpenChange:n,modal:s=!0}=t,r=j.useRef(null),a=j.useRef(null),[g,I]=ox({prop:i,defaultProp:o??!1,onChange:n,caller:HZ});return O.jsx(ZKt,{scope:A,triggerRef:r,contentRef:a,contentId:Bh(),titleId:Bh(),descriptionId:Bh(),open:g,onOpenChange:I,onOpenToggle:j.useCallback(()=>I(c=>!c),[I]),modal:s,children:e})};tie.displayName=HZ;var iie="DialogTrigger",oie=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=qw(iie,e),n=Bc(A,o.triggerRef);return O.jsx(Ha.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":guA(o.open),...i,ref:n,onClick:vo(t.onClick,o.onOpenToggle)})});oie.displayName=iie;var ruA="DialogPortal",[VKt,nie]=Aie(ruA,{forceMount:void 0}),sie=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:o}=t,n=qw(ruA,A);return O.jsx(VKt,{scope:A,forceMount:e,children:j.Children.map(i,s=>O.jsx(n0,{present:e||n.open,children:O.jsx(iW,{asChild:!0,container:o,children:s})}))})};sie.displayName=ruA;var YZ="DialogOverlay",rie=j.forwardRef((t,A)=>{const e=nie(YZ,t.__scopeDialog),{forceMount:i=e.forceMount,...o}=t,n=qw(YZ,t.__scopeDialog);return n.modal?O.jsx(n0,{present:i||n.open,children:O.jsx(zKt,{...o,ref:A})}):null});rie.displayName=YZ;var jKt=TKt("DialogOverlay.RemoveScroll"),zKt=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=qw(YZ,e);return O.jsx(cW,{as:jKt,allowPinchZoom:!0,shards:[o.contentRef],children:O.jsx(Ha.div,{"data-state":guA(o.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),WF="DialogContent",aie=j.forwardRef((t,A)=>{const e=nie(WF,t.__scopeDialog),{forceMount:i=e.forceMount,...o}=t,n=qw(WF,t.__scopeDialog);return O.jsx(n0,{present:i||n.open,children:n.modal?O.jsx(XKt,{...o,ref:A}):O.jsx($Kt,{...o,ref:A})})});aie.displayName=WF;var XKt=j.forwardRef((t,A)=>{const e=qw(WF,t.__scopeDialog),i=j.useRef(null),o=Bc(A,e.contentRef,i);return j.useEffect(()=>{const n=i.current;if(n)return XQA(n)},[]),O.jsx(gie,{...t,ref:o,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:vo(t.onCloseAutoFocus,n=>{n.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:vo(t.onPointerDownOutside,n=>{const s=n.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&n.preventDefault()}),onFocusOutside:vo(t.onFocusOutside,n=>n.preventDefault())})}),$Kt=j.forwardRef((t,A)=>{const e=qw(WF,t.__scopeDialog),i=j.useRef(!1),o=j.useRef(!1);return O.jsx(gie,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:n=>{t.onCloseAutoFocus?.(n),n.defaultPrevented||(i.current||e.triggerRef.current?.focus(),n.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:n=>{t.onInteractOutside?.(n),n.defaultPrevented||(i.current=!0,n.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=n.target;e.triggerRef.current?.contains(s)&&n.preventDefault(),n.detail.originalEvent.type==="focusin"&&o.current&&n.preventDefault()}})}),gie=j.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:n,...s}=t,r=qw(WF,e),a=j.useRef(null),g=Bc(A,a);return MQA(),O.jsxs(O.Fragment,{children:[O.jsx(q8,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:n,children:O.jsx(eH,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":guA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),O.jsxs(O.Fragment,{children:[O.jsx(eqt,{titleId:r.titleId}),O.jsx(iqt,{contentRef:a,descriptionId:r.descriptionId})]})]})}),auA="DialogTitle",Iie=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=qw(auA,e);return O.jsx(Ha.h2,{id:o.titleId,...i,ref:A})});Iie.displayName=auA;var cie="DialogDescription",Bie=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=qw(cie,e);return O.jsx(Ha.p,{id:o.descriptionId,...i,ref:A})});Bie.displayName=cie;var lie="DialogClose",Cie=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=qw(lie,e);return O.jsx(Ha.button,{type:"button",...i,ref:A,onClick:vo(t.onClick,()=>o.onOpenChange(!1))})});Cie.displayName=lie;function guA(t){return t?"open":"closed"}var Qie="DialogTitleWarning",[Aqt,Eie]=M3e(Qie,{contentName:WF,titleName:auA,docsSlug:"dialog"}),eqt=({titleId:t})=>{const A=Eie(Qie),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
|
|
5620
|
+
`,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),l=document.createElement("a");l.href=B,l.download=`${g}.test.ts`,l.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return O.jsxs("div",{className:`relative ${A}`,ref:o,children:[O.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&O.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:[O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},zte=t=>t.activeSubSolver?[t,...zte(t.activeSubSolver)]:[t],yKt=({solver:t})=>{const A=zte(t);return O.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>O.jsxs("div",{className:"flex items-center",children:[i>0&&O.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),O.jsx(fKt,{solver:e})]},e.constructor.name))})},wKt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=j.useReducer(Q=>!Q,!1),r=j.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};j.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),j.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const l=t.getCurrentPhase!==void 0,C=l?t.getCurrentPhase():null;return O.jsxs("div",{className:"space-y-2 p-2 border-b",children:[O.jsx("div",{className:"flex items-center",children:O.jsx(yKt,{solver:t})}),O.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[O.jsx("button",{onClick:a,disabled:t.solved||t.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"}),O.jsx("button",{onClick:g,disabled:t.solved||t.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"}),O.jsx("button",{onClick:I,disabled:t.solved||t.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"}),O.jsx("button",{onClick:B,disabled:t.solved||t.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"}),l&&O.jsx("button",{onClick:c,disabled:t.solved||t.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"}),O.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",O.jsx("span",{className:"font-medium",children:C})]}),t.solved&&O.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&O.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&O.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},mKt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},DKt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=mKt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],l=B?t.firstIterationOfPhase?.[B.solverName]:void 0;l!==void 0&&s!==null?a=l-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},SKt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return O.jsx("span",{className:`font-medium ${A[t]}`,children:t})},bKt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:O.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),O.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},xKt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),kKt=({stats:t})=>{if(!t||Object.keys(t).length===0)return O.jsx("span",{children:"-"});const A=Object.entries(t),e=xKt(t);return O.jsxs("details",{className:"cursor-pointer",children:[O.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),O.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>O.jsxs("div",{children:[i,": ",String(o)]},i))})]})},suA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(suA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=suA(i));return A},GKt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=suA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,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(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},FKt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>DKt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):GKt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return O.jsxs("div",{className:"border-t border-gray-200",children:[O.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:O.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),O.jsx("div",{className:"overflow-x-auto",children:O.jsxs("table",{className:"w-full text-sm",children:[O.jsx("thead",{children:O.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),O.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",O.jsx("sub",{children:"0"})]}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),O.jsx("tbody",{children:i.map(r=>O.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[O.jsx("td",{className:"px-4 py-2",children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),O.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.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"})})}),O.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(SKt,{status:r.status})}),O.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(bKt,{progress:r.progress})}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),O.jsx("td",{className:"px-4 py-2 text-gray-500",children:O.jsx(kKt,{stats:r.stats})}),O.jsx("td",{className:"px-4 py-2",children:r.solverInstance?O.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:[O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.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"})}),O.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},RKt=class extends Xi.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function MKt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,l=r-c,C=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return O.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${l} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>O.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>O.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>O.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var NKt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=j.useReducer(I=>I+1,0),s=j.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=j.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);j.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return O.jsxs("div",{children:[O.jsx(wKt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?O.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):O.jsx(RKt,{fallback:O.jsx(MKt,{graphics:s}),children:O.jsx(pKt,{graphics:s})}),a&&O.jsx(FKt,{solver:t,onStepUntilPhase:g})]})};const _Kt=()=>{j.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},vKt=t=>t.toLowerCase().includes("pack")?jSt:t.toLowerCase().includes("rout")?ebt:_St,UKt=({solverEvents:t=[]})=>{const[A,e]=j.useState(null);_Kt();const i=j.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=j.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=j.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=OeA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(OeA).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 t.length===0?O.jsx("div",{className:"rf-p-4",children:O.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:O.jsxs("div",{className:"rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),O.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."})]})})}):O.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[O.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[O.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 O.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=vKt(a.solverName);return O.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[O.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),O.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[O.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),O.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),O.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?O.jsx(by,{fallback:O.jsx("div",{className:"rf-p-4",children:O.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),O.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:O.jsx(NKt,{solver:s.instance})}):O.jsxs("div",{className:"rf-p-4",children:[O.jsxs("div",{className:"rf-mb-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),O.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&O.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:O.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),O.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[O.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:O.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),O.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:O.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)})})]})]}):O.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:O.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Xte=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{j.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{V3.captureException(i)}catch{}}},[t,A]),j.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{V3.captureException(o,{error_type:i.type})}catch{}}},[e])},$te="0.0.1491",LKt={version:$te},LZ=y1A()(w1A(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),HKt=t=>{const[A,e]=j.useState([]),[i,o]=j.useState(null),[n,s]=j.useState(""),[r,a]=rv("eval-version-selection",null),g=LZ(l=>l.setLastRunEvalVersion),I=LZ(l=>l.lastRunEvalVersion);return j.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(l=>l.json()).then(l=>{if(Array.isArray(l?.versions)){let C=[...l.versions];l.tags?.latest&&(o(l.tags.latest),C=C.filter(Q=>Q!==l.tags.latest)),e(C)}}).catch(()=>{})},[t]),j.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:j.useMemo(()=>A.filter(l=>l.includes(n)).slice(0,50),[A,n]),latestVersion:i,lastRunEvalVersion:I,search:n,setSearch:s,selectVersion:l=>{a(l),s("")}}},YKt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[o,n]=j.useState(""),[s,r]=j.useState("");if(!i)return null;const a=t.filter(c=>c.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),I=c=>{c.key==="Enter"&&(a.length===1?n(a[0]):g&&n(s))};return O.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:O.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[O.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),O.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:c=>r(c.target.value),onKeyDown:I}),O.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(c=>O.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${o===c?"bg-blue-50":""}`,onClick:()=>n(c),children:c},c)),g&&O.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${o===s?"bg-blue-50":""}`,onClick:()=>n(s),children:['Create new "',s,'"']})]}),O.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>o&&A(o),disabled:!o,children:o===s?`Create "${o}"`:`Save to ${o}`})]})]})})},JKt=t=>{const A=j.useRef(null),e=Yc(i=>i.recentEvents);j.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function TKt(t){const A=KKt(t),e=j.forwardRef((i,o)=>{const{children:n,...s}=i,r=j.Children.toArray(n),a=r.find(PKt);if(a){const g=a.props.children,I=r.map(c=>c===a?j.Children.count(g)>1?j.Children.only(null):j.isValidElement(g)?g.props.children:null:c);return O.jsx(A,{...s,ref:o,children:j.isValidElement(g)?j.cloneElement(g,void 0,I):null})}return O.jsx(A,{...s,ref:o,children:n})});return e.displayName=`${t}.Slot`,e}function KKt(t){const A=j.forwardRef((e,i)=>{const{children:o,...n}=e;if(j.isValidElement(o)){const s=WKt(o),r=OKt(n,o.props);return o.type!==j.Fragment&&(r.ref=i?Vp(i,s):s),j.cloneElement(o,r)}return j.Children.count(o)>1?j.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var qKt=Symbol("radix.slottable");function PKt(t){return j.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===qKt}function OKt(t,A){const e={...A};for(const i in A){const o=t[i],n=A[i];/^on[A-Z]/.test(i)?o&&n?e[i]=(...r)=>{const a=n(...r);return o(...r),a}:o&&(e[i]=o):i==="style"?e[i]={...o,...n}:i==="className"&&(e[i]=[o,n].filter(Boolean).join(" "))}return{...t,...e}}function WKt(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var HZ="Dialog",[Aie,eie]=hw(HZ),[ZKt,qw]=Aie(HZ),tie=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:o,onOpenChange:n,modal:s=!0}=t,r=j.useRef(null),a=j.useRef(null),[g,I]=ox({prop:i,defaultProp:o??!1,onChange:n,caller:HZ});return O.jsx(ZKt,{scope:A,triggerRef:r,contentRef:a,contentId:Bh(),titleId:Bh(),descriptionId:Bh(),open:g,onOpenChange:I,onOpenToggle:j.useCallback(()=>I(c=>!c),[I]),modal:s,children:e})};tie.displayName=HZ;var iie="DialogTrigger",oie=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=qw(iie,e),n=Bc(A,o.triggerRef);return O.jsx(Ha.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":guA(o.open),...i,ref:n,onClick:vo(t.onClick,o.onOpenToggle)})});oie.displayName=iie;var ruA="DialogPortal",[VKt,nie]=Aie(ruA,{forceMount:void 0}),sie=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:o}=t,n=qw(ruA,A);return O.jsx(VKt,{scope:A,forceMount:e,children:j.Children.map(i,s=>O.jsx(n0,{present:e||n.open,children:O.jsx(iW,{asChild:!0,container:o,children:s})}))})};sie.displayName=ruA;var YZ="DialogOverlay",rie=j.forwardRef((t,A)=>{const e=nie(YZ,t.__scopeDialog),{forceMount:i=e.forceMount,...o}=t,n=qw(YZ,t.__scopeDialog);return n.modal?O.jsx(n0,{present:i||n.open,children:O.jsx(zKt,{...o,ref:A})}):null});rie.displayName=YZ;var jKt=TKt("DialogOverlay.RemoveScroll"),zKt=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=qw(YZ,e);return O.jsx(cW,{as:jKt,allowPinchZoom:!0,shards:[o.contentRef],children:O.jsx(Ha.div,{"data-state":guA(o.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),WF="DialogContent",aie=j.forwardRef((t,A)=>{const e=nie(WF,t.__scopeDialog),{forceMount:i=e.forceMount,...o}=t,n=qw(WF,t.__scopeDialog);return O.jsx(n0,{present:i||n.open,children:n.modal?O.jsx(XKt,{...o,ref:A}):O.jsx($Kt,{...o,ref:A})})});aie.displayName=WF;var XKt=j.forwardRef((t,A)=>{const e=qw(WF,t.__scopeDialog),i=j.useRef(null),o=Bc(A,e.contentRef,i);return j.useEffect(()=>{const n=i.current;if(n)return XQA(n)},[]),O.jsx(gie,{...t,ref:o,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:vo(t.onCloseAutoFocus,n=>{n.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:vo(t.onPointerDownOutside,n=>{const s=n.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&n.preventDefault()}),onFocusOutside:vo(t.onFocusOutside,n=>n.preventDefault())})}),$Kt=j.forwardRef((t,A)=>{const e=qw(WF,t.__scopeDialog),i=j.useRef(!1),o=j.useRef(!1);return O.jsx(gie,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:n=>{t.onCloseAutoFocus?.(n),n.defaultPrevented||(i.current||e.triggerRef.current?.focus(),n.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:n=>{t.onInteractOutside?.(n),n.defaultPrevented||(i.current=!0,n.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=n.target;e.triggerRef.current?.contains(s)&&n.preventDefault(),n.detail.originalEvent.type==="focusin"&&o.current&&n.preventDefault()}})}),gie=j.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:n,...s}=t,r=qw(WF,e),a=j.useRef(null),g=Bc(A,a);return MQA(),O.jsxs(O.Fragment,{children:[O.jsx(q8,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:n,children:O.jsx(eH,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":guA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),O.jsxs(O.Fragment,{children:[O.jsx(eqt,{titleId:r.titleId}),O.jsx(iqt,{contentRef:a,descriptionId:r.descriptionId})]})]})}),auA="DialogTitle",Iie=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=qw(auA,e);return O.jsx(Ha.h2,{id:o.titleId,...i,ref:A})});Iie.displayName=auA;var cie="DialogDescription",Bie=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=qw(cie,e);return O.jsx(Ha.p,{id:o.descriptionId,...i,ref:A})});Bie.displayName=cie;var lie="DialogClose",Cie=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=qw(lie,e);return O.jsx(Ha.button,{type:"button",...i,ref:A,onClick:vo(t.onClick,()=>o.onOpenChange(!1))})});Cie.displayName=lie;function guA(t){return t?"open":"closed"}var Qie="DialogTitleWarning",[Aqt,Eie]=M3e(Qie,{contentName:WF,titleName:auA,docsSlug:"dialog"}),eqt=({titleId:t})=>{const A=Eie(Qie),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
|
|
5621
5621
|
|
|
5622
5622
|
If you want to hide the \`${A.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
5623
5623
|
|