@tscircuit/runframe 0.0.1732 → 0.0.1733
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
|
@@ -5152,8 +5152,8 @@ ${a.join(`
|
|
|
5152
5152
|
`){E=L,u-=w.height*Q,Y();continue}D=w.width*h,_.width+=D,E+=D,m!==" "&&(_.segments=_.segments.concat(w.segments))}for(_.segments.length&&Y(),d=0,f=x.length;d<f;d++)_=x[d],F>_.width&&(S=F-_.width,B==="right"?_=n({x:S},_):B==="center"&&(_=n({x:S/2},_))),G=G.concat(_.segments);return G};A.exports=o}}),Gkt=ae({"node_modules/@jscad/modeling/src/text/index.js"(t,A){A.exports={vectorChar:fte(),vectorText:Rkt()}}}),TY=ae({"node_modules/@jscad/modeling/src/utils/areAllShapesTheSameType.js"(t,A){var e=os(),i=As(),n=Lg(),o=s=>{let r;for(const a of s){let g=0;if(e.isA(a)&&(g=1),i.isA(a)&&(g=2),n.isA(a)&&(g=3),r&&g!==r)return!1;r=g}return!0};A.exports=o}}),Mkt=ae({"node_modules/@jscad/modeling/src/utils/degToRad.js"(t,A){var e=i=>i*.017453292519943295;A.exports=e}}),yte=ae({"node_modules/@jscad/modeling/src/utils/fnNumberSort.js"(t,A){var e=(i,n)=>i-n;A.exports=e}}),Lkt=ae({"node_modules/@jscad/modeling/src/utils/insertSorted.js"(t,A){var e=(i,n,o)=>{let s=0,r=i.length;for(;r>s;){const a=Math.floor((s+r)/2),g=i[a];o(n,g)>0?s=a+1:r=a}i.splice(s,0,n)};A.exports=e}}),Ukt=ae({"node_modules/@jscad/modeling/src/utils/radiusToSegments.js"(t,A){var{TAU:e}=Br(),i=(n,o,s)=>{const r=o>0?n*e/o:0,a=s>0?e/s:0;return Math.ceil(Math.max(r,a,4))};A.exports=i}}),Hkt=ae({"node_modules/@jscad/modeling/src/utils/radToDeg.js"(t,A){var e=i=>i*57.29577951308232;A.exports=e}}),mte=ae({"node_modules/@jscad/modeling/src/utils/index.js"(t,A){A.exports={areAllShapesTheSameType:TY(),degToRad:Mkt(),flatten:ko(),fnNumberSort:yte(),insertSorted:Lkt(),radiusToSegments:Ukt(),radToDeg:Hkt()}}}),pdA=ae({"node_modules/@jscad/modeling/src/operations/booleans/fromFakePolygons.js"(t,A){var e=_s(),i=os(),n=(s,r)=>{if(r.vertices.length<4)return null;const a=[],g=r.vertices.filter((l,B)=>l[2]>0?(a.push(B),!0):!1);if(g.length!==2)throw new Error("Assertion failed: fromFakePolygon: not enough points found");const c=g.map(l=>{const B=Math.round(l[0]/s)*s+0,C=Math.round(l[1]/s)*s+0;return e.fromValues(B,C)});if(e.equals(c[0],c[1]))return null;const I=a[1]-a[0];if(I===1||I===3)I===1&&c.reverse();else throw new Error("Assertion failed: fromFakePolygon: unknown index ordering");return c},o=(s,r)=>{const a=r.map(g=>n(s,g)).filter(g=>g!==null);return i.create(a)};A.exports=o}}),fdA=ae({"node_modules/@jscad/modeling/src/operations/booleans/to3DWalls.js"(t,A){var e=bn(),i=os(),n=As(),o=Ar(),s=(a,g,c)=>{const I=[e.fromVec2(e.create(),c[0],a),e.fromVec2(e.create(),c[1],a),e.fromVec2(e.create(),c[1],g),e.fromVec2(e.create(),c[0],g)];return o.create(I)},r=(a,g)=>{const I=i.toSides(g).map(B=>s(a.z0,a.z1,B));return n.create(I)};A.exports=r}}),Ykt=ae({"node_modules/@jscad/modeling/src/maths/OrthoNormalBasis.js"(t,A){var e=tc(),i=_s(),n=bn(),o=function(s,r){arguments.length<2&&(r=n.orthogonal(n.create(),s)),this.v=n.normalize(n.create(),n.cross(n.create(),s,r)),this.u=n.cross(n.create(),this.v,s),this.plane=s,this.planeorigin=n.scale(n.create(),s,s[3])};o.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=n.scale(n.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(n.dot(s,this.u),n.dot(s,this.v))},to3D:function(s){const r=n.scale(n.create(),this.u,s[0]),a=n.scale(n.create(),this.v,s[1]),g=n.add(r,r,this.planeorigin);return n.add(a,a,g)}},A.exports=o}}),Jkt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/reTesselateCoplanarPolygons.js"(t,A){var{EPS:e}=Br(),i=QdA(),n=_s(),o=Ykt(),s=tte(),{insertSorted:r,fnNumberSort:a}=mte(),g=Ar(),c=I=>{if(I.length<2)return I;const l=[],B=I.length,C=g.plane(I[0]),Q=new o(C),h=[],E=[],u=new Map,d=new Map,f=new Map,m=10/e;for(let _=0;_<B;_++){const x=I[_];let G=[],F=x.vertices.length,L=-1;if(F>0){let Y,J;for(let O=0;O<F;O++){let Z=Q.to2D(x.vertices[O]);const X=Math.floor(Z[1]*m);let eA;f.has(X)?eA=f.get(X):f.has(X+1)?eA=f.get(X+1):f.has(X-1)?eA=f.get(X-1):(eA=Z[1],f.set(X,Z[1])),Z=n.fromValues(Z[0],eA),G.push(Z);const gA=Z[1];(O===0||gA<Y)&&(Y=gA,L=O),(O===0||gA>J)&&(J=gA);let tA=d.get(gA);tA||(tA={},d.set(gA,tA)),tA[_]=!0}if(Y>=J)G=[],F=0,L=-1;else{let O=u.get(Y);O||(O=[],u.set(Y,O)),O.push(_)}}G.reverse(),L=F-L-1,h.push(G),E.push(L)}const w=[];d.forEach((_,x)=>w.push(x)),w.sort(a);let D=[],S=[];for(let _=0;_<w.length;_++){const x=[],G=w[_],F=d.get(G);let L=0;for(let J=0;J<D.length;++J){const O=D[J],Z=O.polygonindex;if(F[Z]){const X=h[Z],eA=X.length;let gA=O.leftvertexindex,tA=O.rightvertexindex;for(;;){let sA=gA+1;if(sA>=eA&&(sA=0),X[sA][1]!==G)break;gA=sA}let iA=tA-1;if(iA<0&&(iA=eA-1),X[iA][1]===G&&(tA=iA),gA!==O.leftvertexindex&&gA===tA)O._remove=!0,L++;else{O.leftvertexindex=gA,O.rightvertexindex=tA,O.topleft=X[gA],O.topright=X[tA];let sA=gA+1;sA>=eA&&(sA=0),O.bottomleft=X[sA];let aA=tA-1;aA<0&&(aA=eA-1),O.bottomright=X[aA]}}}L>0&&(D=D.filter(J=>!J._remove));let Y;if(_>=w.length-1)D=[],Y=null;else{Y=Number(w[_+1]);const J=.5*(G+Y),O=u.get(G);for(const Z in O){const X=O[Z],eA=h[X],gA=eA.length,tA=E[X];let iA=tA;for(;;){let xA=iA+1;if(xA>=gA&&(xA=0),eA[xA][1]!==G||xA===tA)break;iA=xA}let sA=tA;for(;;){let xA=sA-1;if(xA<0&&(xA=gA-1),eA[xA][1]!==G||xA===iA)break;sA=xA}let aA=iA+1;aA>=gA&&(aA=0);let EA=sA-1;EA<0&&(EA=gA-1);const bA={polygonindex:X,leftvertexindex:iA,rightvertexindex:sA,topleft:eA[iA],topright:eA[sA],bottomleft:eA[aA],bottomright:eA[EA]};r(D,bA,(xA,YA)=>{const QA=s(xA.topleft,xA.bottomleft,J),_A=s(YA.topleft,YA.bottomleft,J);return QA>_A?1:QA<_A?-1:0})}}for(const J in D){const O=D[J];let Z=s(O.topleft,O.bottomleft,G);const X=n.fromValues(Z,G);Z=s(O.topright,O.bottomright,G);const eA=n.fromValues(Z,G);Z=s(O.topleft,O.bottomleft,Y);const gA=n.fromValues(Z,Y);Z=s(O.topright,O.bottomright,Y);const tA=n.fromValues(Z,Y),iA={topleft:X,topright:eA,bottomleft:gA,bottomright:tA,leftline:i.fromPoints(i.create(),X,gA),rightline:i.fromPoints(i.create(),tA,eA)};if(x.length>0){const sA=x[x.length-1],aA=n.distance(iA.topleft,sA.topright),EA=n.distance(iA.bottomleft,sA.bottomright);aA<e&&EA<e&&(iA.topleft=sA.topleft,iA.leftline=sA.leftline,iA.bottomleft=sA.bottomleft,x.splice(x.length-1,1))}x.push(iA)}if(_>0){const J=new Set,O=new Set;for(let Z=0;Z<x.length;Z++){const X=x[Z];for(let eA=0;eA<S.length;eA++)if(!O.has(eA)){const gA=S[eA];if(n.distance(gA.bottomleft,X.topleft)<e&&n.distance(gA.bottomright,X.topright)<e){O.add(eA);const tA=i.direction(X.leftline),iA=i.direction(gA.leftline),sA=tA[0]-iA[0],aA=i.direction(X.rightline),EA=i.direction(gA.rightline),bA=aA[0]-EA[0],xA=Math.abs(sA)<e,YA=Math.abs(bA)<e,QA=xA||sA>=0,_A=YA||bA>=0;QA&&_A&&(X.outpolygon=gA.outpolygon,X.leftlinecontinues=xA,X.rightlinecontinues=YA,J.add(eA));break}}}for(let Z=0;Z<S.length;Z++)if(!J.has(Z)){const X=S[Z];X.outpolygon.rightpoints.push(X.bottomright),n.distance(X.bottomright,X.bottomleft)>e&&X.outpolygon.leftpoints.push(X.bottomleft),X.outpolygon.leftpoints.reverse();const gA=X.outpolygon.rightpoints.concat(X.outpolygon.leftpoints).map(iA=>Q.to3D(iA)),tA=g.fromPointsAndPlane(gA,C);tA.vertices.length&&l.push(tA)}}for(let J=0;J<x.length;J++){const O=x[J];O.outpolygon?(O.leftlinecontinues||O.outpolygon.leftpoints.push(O.topleft),O.rightlinecontinues||O.outpolygon.rightpoints.push(O.topright)):(O.outpolygon={leftpoints:[],rightpoints:[]},O.outpolygon.leftpoints.push(O.topleft),n.distance(O.topleft,O.topright)>e&&O.outpolygon.rightpoints.push(O.topright))}S=x}return l};A.exports=c}}),PY=ae({"node_modules/@jscad/modeling/src/operations/modifiers/retessellate.js"(t,A){var e=As(),i=Ar(),{NEPS:n}=Br(),o=Jkt(),s=g=>{if(g.isRetesselated)return g;const c=e.toPolygons(g).map((C,Q)=>({vertices:C.vertices,plane:i.plane(C),index:Q})),I=r(c),l=[];I.forEach(C=>{if(Array.isArray(C)){const Q=o(C);for(let h=0;h<Q.length;h++)l.push(Q[h])}else l.push(C)});const B=e.create(l);return B.isRetesselated=!0,B},r=g=>{let c=[g];const I=[];for(let B=3;B>=0;B--){const C=[],Q=B===3?15e-9:n;c.forEach(h=>{h.sort(a(B,Q));let E=0;for(let u=1;u<h.length;u++)h[u].plane[B]-h[E].plane[B]>Q&&(u-E===1?I.push(h[E]):C.push(h.slice(E,u)),E=u);h.length-E===1?I.push(h[E]):C.push(h.slice(E))}),c=C}const l=[];return c.forEach(B=>{B[0]&&(l[B[0].index]=B)}),I.forEach(B=>{l[B.index]=B}),l},a=(g,c)=>(I,l)=>I.plane[g]-l.plane[g]>c?1:l.plane[g]-I.plane[g]>c?-1:0;A.exports=s}}),ydA=ae({"node_modules/@jscad/modeling/src/operations/booleans/mayOverlap.js"(t,A){var{EPS:e}=Br(),i=HF(),n=(o,s)=>{if(o.polygons.length===0||s.polygons.length===0)return!1;const r=i(o),a=r[0],g=r[1],c=i(s),I=c[0],l=c[1];return!(I[0]-g[0]>e||a[0]-l[0]>e||I[1]-g[1]>e||a[1]-l[1]>e||I[2]-g[2]>e||a[2]-l[2]>e)};A.exports=n}}),Tkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/trees/Node.js"(t,A){var e=HD(),i=Ar(),n=class f_A{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 c=[];do{if(g=a.node,s=a.polygontreenodes,g.plane){const I=g.plane,l=[],B=[],C=r?l:B,Q=s.length;for(let E=0;E<Q;E++){const u=s[E];u.isRemoved()||u.splitByPlane(I,C,l,B,l)}g.front&&B.length>0&&c.push({node:g.front,polygontreenodes:B});const h=l.length;if(g.back&&h>0)c.push({node:g.back,polygontreenodes:l});else for(let E=0;E<h;E++)l[E].remove()}a=c.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,c=r.polygontreenodes;if(c.length===0){r=a.pop();continue}if(!g.plane){let C=0;C=Math.floor(c.length/2);const Q=c[C].getPolygon();g.plane=i.plane(Q)}const I=[],l=[],B=c.length;for(let C=0;C<B;++C)c[C].splitByPlane(g.plane,g.polygontreenodes,l,I,l);I.length>0&&(g.front||(g.front=new f_A(g)),B===I.length&&l.length===0?g.front.polygontreenodes=I:a.push({node:g.front,polygontreenodes:I})),l.length>0&&(g.back||(g.back=new f_A(g)),B===l.length&&I.length===0?g.back.polygontreenodes=l:a.push({node:g.back,polygontreenodes:l})),r=a.pop()}while(r!==void 0)}};A.exports=n}}),Pkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/trees/splitLineSegmentByPlane.js"(t,A){var e=bn(),i=(n,o,s)=>{const r=e.subtract(e.create(),s,o);let a=(n[3]-e.dot(n,o))/e.dot(n,r);return Number.isNaN(a)&&(a=0),a>1&&(a=1),a<0&&(a=0),e.scale(r,r,a),e.add(r,o,r),r};A.exports=i}}),Kkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/trees/splitPolygonByPlane.js"(t,A){var{EPS:e}=Br(),i=HD(),n=bn(),o=Ar(),s=Pkt(),r=e*e,a=c=>{const I=[];let l=c[c.length-1];for(let B=0;B<c.length;B++){const C=c[B];n.squaredDistance(C,l)>=r&&I.push(C),l=C}return I},g=(c,I)=>{const l={type:null,front:null,back:null},B=I.vertices,C=B.length,Q=o.plane(I);if(i.equals(Q,c))l.type=0;else{let h=!1,E=!1;const u=[],d=-e;for(let f=0;f<C;f++){const m=n.dot(c,B[f])-c[3],w=m<d;u.push(w),m>e&&(h=!0),m<d&&(E=!0)}if(!h&&!E){const f=n.dot(c,Q);l.type=f>=0?0:1}else if(!E)l.type=2;else if(!h)l.type=3;else{l.type=4;const f=[],m=[];let w=u[0];for(let D=0;D<C;D++){const S=B[D];let _=D+1;_>=C&&(_=0);const x=u[_];if(w===x)w?m.push(S):f.push(S);else{const G=B[_],F=s(c,S,G);w?(m.push(S),m.push(F),f.push(F)):(f.push(S),f.push(F),m.push(F))}w=x}if(f.length>=3){const D=a(f);D.length>=3&&(l.front=o.fromPointsAndPlane(D,Q))}if(m.length>=3){const D=a(m);D.length>=3&&(l.back=o.fromPointsAndPlane(D,Q))}}}return l};A.exports=g}}),qkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/trees/PolygonTreeNode.js"(t,A){var{EPS:e}=Br(),i=bn(),n=Ar(),o=Kkt(),s=class ESe{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(c=>{g.addChild(c)})}remove(){this.removed||(this.removed=!0,this.polygon=null,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){if(this.isRootNode()&&this.children.length>0){const Q=[];for(let h=0;h<this.children.length;h++)this.children[h].removed||Q.push(this.children[h]);this.children=Q}let g=[this];const c=[g];let I,l,B,C;for(I=0;I<c.length;++I)for(g=c[I],l=0,B=g.length;l<B;l++)C=g[l],C.polygon?a.push(C.polygon):C.children.length>0&&c.push(C.children)}splitByPlane(a,g,c,I,l){if(this.children.length){const B=[this.children];let C,Q,h,E,u;for(C=0;C<B.length;C++)for(u=B[C],Q=0,h=u.length;Q<h;Q++)E=u[Q],E.children.length>0?B.push(E.children):E._splitByPlane(a,g,c,I,l)}else this._splitByPlane(a,g,c,I,l)}_splitByPlane(a,g,c,I,l){const B=this.polygon;if(B){const C=n.measureBoundingSphere(B),Q=C[3]+e,h=C,E=i.dot(a,h)-a[3];if(E>Q)I.push(this);else if(E<-Q)l.push(this);else{const u=o(a,B);switch(u.type){case 0:g.push(this);break;case 1:c.push(this);break;case 2:I.push(this);break;case 3:l.push(this);break;case 4:if(u.front){const d=this.addChild(u.front);I.push(d)}if(u.back){const d=this.addChild(u.back);l.push(d)}break}}}}addChild(a){const g=new ESe(this,a);return this.children.push(g),g}invertSub(){let a=[this];const g=[a];let c,I,l,B;for(c=0;c<g.length;c++)for(a=g[c],I=0,l=a.length;I<l;I++)B=a[I],B.polygon&&(B.polygon=n.invert(B.polygon)),B.children.length>0&&g.push(B.children)}recursivelyInvalidatePolygon(){this.polygon=null,this.parent&&this.parent.recursivelyInvalidatePolygon()}clear(){let a=[this];const g=[a];for(let c=0;c<g.length;++c){a=g[c];const I=a.length;for(let l=0;l<I;l++){const B=a[l];B.polygon&&(B.polygon=null),B.parent&&(B.parent=null),B.children.length>0&&g.push(B.children),B.children=[]}}}toString(){let a="",g=[this];const c=[g];let I,l,B,C;for(I=0;I<c.length;++I){g=c[I];const Q=" ".repeat(I);for(l=0,B=g.length;l<B;l++)C=g[l],a+=`${Q}PolygonTreeNode (${C.isRootNode()}): ${C.children.length}`,C.polygon?a+=`
|
|
5153
5153
|
${Q}polygon: ${C.polygon.vertices}
|
|
5154
5154
|
`:a+=`
|
|
5155
|
-
`,C.children.length>0&&c.push(C.children)}return a}};A.exports=s}}),Okt=ae({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,A){var e=Tkt(),i=qkt(),n=class{constructor(o){this.polygonTree=new i,this.rootnode=new e(null),o&&this.addPolygons(o)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(o,s=!1){this.rootnode.clipTo(o,s)}allPolygons(){const o=[];return this.polygonTree.getPolygons(o),o}addPolygons(o){const s=new Array(o.length);for(let r=0;r<o.length;r++)s[r]=this.polygonTree.addChild(o[r]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};A.exports=n}}),mdA=ae({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,A){A.exports={Tree:Okt()}}}),Wkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,A){var e=As(),i=ydA(),{Tree:n}=mdA(),o=(s,r)=>{if(!i(s,r))return e.create();const a=new n(e.toPolygons(s)),g=new n(e.toPolygons(r));a.invert(),g.clipTo(a),g.invert(),a.clipTo(g),g.clipTo(a),a.addPolygons(g.allPolygons()),a.invert();const c=a.allPolygons();return e.create(c)};A.exports=o}}),wte=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,A){var e=ko(),i=PY(),n=Wkt(),o=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),Zkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,A){var e=ko(),i=As(),n=Ak(),o=pdA(),s=fdA(),r=wte(),a=(...g)=>{g=e(g);const c=g.map(B=>s({z0:-1,z1:1},B)),I=r(c),l=n(I);return o(l,i.toPolygons(I))};A.exports=a}}),Vkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,A){var e=ko(),i=TY(),n=os(),o=As(),s=Zkt(),r=wte(),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 c=g[0];return n.isA(c)?s(g):o.isA(c)?r(g):c};A.exports=a}}),wdA=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,A){var e=Ar(),i=_ee(),n=o=>i(o,{skipTriangulation:!0}).map(a=>{const g=a.map(c=>o[c]);return e.create(g)});A.exports=n}}),Dte=ae({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,A){var e=As(),i=ydA(),{Tree:n}=mdA(),o=(r,a)=>{if(!i(r,a))return s(r,a);const g=new n(e.toPolygons(r)),c=new n(e.toPolygons(a));g.clipTo(c,!1),c.clipTo(g),c.invert(),c.clipTo(g),c.invert();const I=g.allPolygons().concat(c.allPolygons());return e.create(I)},s=(r,a)=>{let g=e.toPolygons(r);return g=g.concat(e.toPolygons(a)),e.create(g)};A.exports=o}}),DdA=ae({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,A){var e=ko(),i=PY(),n=Dte(),o=(...s)=>{s=e(s);let r;for(r=1;r<s.length;r+=2)s.push(n(s[r-1],s[r]));let a=s[r-1];return a=i(a),a};A.exports=o}}),Ste=ae({"node_modules/@jscad/modeling/src/operations/minkowski/minkowskiSum.js"(t,A){var e=ko(),i=As(),n=Ar(),o=wdA(),s=DdA(),r=(...B)=>{if(B=e(B),B.length!==2)throw new Error("minkowskiSum requires exactly two geometries");const[C,Q]=B;if(!i.isA(C)||!i.isA(Q))throw new Error("minkowskiSum requires geom3 geometries");const h=i.isConvex(C),E=i.isConvex(Q);if(h&&E)return I(C,Q);if(!h&&E)return a(C,Q);if(h&&!E)return a(Q,C);throw new Error("minkowskiSum of two non-convex geometries is not yet supported")},a=(B,C)=>{const Q=g(B);if(Q.length===0)return i.create();const h=Q.map(E=>I(E,C));return h.length===1?h[0]:s(h)},g=B=>{const C=i.toPolygons(B);if(C.length===0)return[];const Q=[];for(let h=0;h<C.length;h++){const E=C[h],u=E.vertices;let d=0,f=0,m=0;for(let F=0;F<u.length;F++)d+=u[F][0],f+=u[F][1],m+=u[F][2];d/=u.length,f/=u.length,m/=u.length;const w=n.plane(E),D=w[0],S=w[1],_=w[2],x=.1,G=[d-D*x,f-S*x,m-_*x];for(let F=1;F<u.length-1;F++){const L=u[0],Y=u[F],J=u[F+1],O=c(G,L,Y,J);Q.push(i.create(O))}}return Q},c=(B,C,Q,h)=>[n.create([B,Q,C]),n.create([B,C,h]),n.create([C,Q,h]),n.create([Q,B,h])],I=(B,C)=>{const Q=l(B),h=l(C);if(Q.length===0||h.length===0)return i.create();const E=[];for(let d=0;d<Q.length;d++){const f=Q[d];for(let m=0;m<h.length;m++){const w=h[m];E.push([f[0]+w[0],f[1]+w[1],f[2]+w[2]])}}const u=o(E);return i.create(u)},l=B=>{const C=new Set,Q=[],h=i.toPolygons(B);for(let E=0;E<h.length;E++){const u=h[E].vertices;for(let d=0;d<u.length;d++){const f=u[d],m=`${f[0]},${f[1]},${f[2]}`;C.has(m)||(C.add(m),Q.push(f))}}return Q};A.exports=r}}),jkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,A){var e=bn(),i=Ak(),n=As(),o=g=>g.sort((c,I)=>c-I).filter((c,I,l)=>!I||c!==l[I-1]),s=(g,c,I)=>{const l=`${c}`,B=g.get(l);B===void 0?g.set(l,[I]):B.push(I)},r=(g,c)=>{const I=`${c}`;return g.get(I)},a=g=>{const c=i(g),I=n.toPolygons(g),l=I.length,B=new Map,C=e.create();I.forEach((d,f)=>{d.vertices.forEach(m=>{s(B,e.snap(C,m,c),f)})});const Q=I.map(d=>{let f=[];return d.vertices.forEach(m=>{f=f.concat(r(B,e.snap(C,m,c)))}),{e:1,d:o(f)}});B.clear();let h=0;const E=Q.length;for(let d=0;d<E;d++){const f=Q[d];if(f.e>0){const m=new Array(l);m[d]=!0;do h=0,m.forEach((w,D)=>{const S=Q[D];if(S.e>0){S.e=-1;for(let _=0;_<S.d.length;_++)m[S.d[_]]=!0;h++}});while(h>0);f.indexes=m}}const u=[];for(let d=0;d<E;d++)if(Q[d].indexes){const f=[];Q[d].indexes.forEach((m,w)=>f.push(I[w])),u.push(n.create(f))}return u};A.exports=a}}),zkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,A){var e=ko(),i=As(),n=jkt(),o=(...s)=>{if(s=e(s),s.length===0)throw new Error("wrong number of arguments");const r=s.map(a=>i.isA(a)?n(a):a);return r.length===1?r[0]:r};A.exports=o}}),Xkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,A){var e=As(),i=ydA(),{Tree:n}=mdA(),o=(s,r)=>{if(!i(s,r))return e.clone(s);const a=new n(e.toPolygons(s)),g=new n(e.toPolygons(r));a.invert(),a.clipTo(g),g.clipTo(a,!0),a.addPolygons(g.allPolygons()),a.invert();const c=a.allPolygons();return e.create(c)};A.exports=o}}),bte=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,A){var e=ko(),i=PY(),n=Xkt(),o=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),$kt=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,A){var e=ko(),i=As(),n=Ak(),o=pdA(),s=fdA(),r=bte(),a=(...g)=>{g=e(g);const c=g.map(B=>s({z0:-1,z1:1},B)),I=r(c),l=n(I);return o(l,i.toPolygons(I))};A.exports=a}}),Avt=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,A){var e=ko(),i=TY(),n=os(),o=As(),s=$kt(),r=bte(),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 c=g[0];return n.isA(c)?s(g):o.isA(c)?r(g):c};A.exports=a}}),xte=ae({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,A){var e=ko(),i=As(),n=Ak(),o=pdA(),s=fdA(),r=DdA(),a=(...g)=>{g=e(g);const c=g.map(B=>s({z0:-1,z1:1},B)),I=r(c),l=n(I);return o(l,i.toPolygons(I))};A.exports=a}}),SdA=ae({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,A){var e=ko(),i=TY(),n=os(),o=As(),s=xte(),r=DdA(),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 c=g[0];return n.isA(c)?s(g):o.isA(c)?r(g):c};A.exports=a}}),g1=ae({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,A){A.exports={intersect:Vkt(),minkowski:Ste(),scission:zkt(),subtract:Avt(),union:SdA()}}}),pV=ae({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,A){var{EPS:e,TAU:i}=Br(),n=ite(),o=QdA(),s=_s(),r=EV(),a=(g,c)=>{const I={delta:1,corners:"edge",closed:!1,segments:16};let{delta:l,corners:B,closed:C,segments:Q}=Object.assign({},I,g);if(Math.abs(l)<e)return c;let h=g.closed?r(c):1;h===0&&(h=1);const E=h>0&&l>=0||h<0&&l<0;l=Math.abs(l);let u=null,d=[];const f=[],m=s.create(),w=c.length;for(let D=0;D<w;D++){const S=(D+1)%w,_=c[D],x=c[S];E?s.subtract(m,_,x):s.subtract(m,x,_),s.normal(m,m),s.normalize(m,m),s.scale(m,m,l);const G=s.add(s.create(),_,m),F=s.add(s.create(),x,m),L=[G,F];if(u!=null&&(C||!C&&S!==0)){const Y=n(u[0],u[1],L[0],L[1]);Y?(d.pop(),L[0]=Y):f.push({c:_,s0:u,s1:L})}u=[G,F],!(S===0&&!C)&&(d.push(L[0]),d.push(L[1]))}if(C&&u!=null){const D=d[0],S=d[1],_=n(u[0],u[1],D,S);if(_)d[0]=_,d.pop();else{const x=c[0],G=[D,S];f.push({c:x,s0:u,s1:G})}}if(B==="edge"){const D=new Map;d.forEach((x,G)=>D.set(x,G));const S=o.create(),_=o.create();f.forEach(x=>{o.fromPoints(S,x.s0[0],x.s0[1]),o.fromPoints(_,x.s1[0],x.s1[1]);const G=o.intersectPointOfLines(S,_);if(Number.isFinite(G[0])&&Number.isFinite(G[1])){const F=x.s0[1],L=D.get(F);d[L]=G,d[(L+1)%d.length]=void 0}else{const F=x.s1[0],L=D.get(F);d[L]=void 0}}),d=d.filter(x=>x!==void 0)}if(B==="round"){let D=Math.floor(Q/4);const S=s.create();f.forEach(_=>{let x=s.angle(s.subtract(S,_.s1[0],_.c));if(x-=s.angle(s.subtract(S,_.s0[1],_.c)),E&&x<0&&(x=x+Math.PI,x<0&&(x=x+Math.PI)),!E&&x>0&&(x=x-Math.PI,x>0&&(x=x-Math.PI)),x!==0){D=Math.floor(Q*(Math.abs(x)/i));const G=x/D,F=s.angle(s.subtract(S,_.s0[1],_.c)),L=[];for(let Y=1;Y<D;Y++){const J=F+G*Y,O=s.fromAngleRadians(s.create(),J);s.scale(O,O,l),s.add(O,O,_.c),L.push(O)}if(L.length>0){const Y=_.s0[1];let J=d.findIndex(O=>s.equals(Y,O));J=(J+1)%d.length,d.splice(J,0,...L)}}else{const G=_.s1[0],F=d.findIndex(L=>s.equals(G,L));d.splice(F,1)}})}return d};A.exports=a}}),evt=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,A){var e=os(),i=pV(),n=(o,s)=>{const r={delta:1,corners:"edge",segments:16},{delta:a,corners:g,segments:c}=Object.assign({},r,o);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const B=e.toOutlines(s).map(C=>(o={delta:a,corners:g,closed:!0,segments:c},i(o,C))).reduce((C,Q)=>C.concat(e.toSides(e.fromPoints(Q))),[]);return e.create(B)};A.exports=n}}),tvt=ae({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,A){var e=tc(),i=bn(),n=As(),o=Ar(),s=(r,a)=>{i.dot(o.plane(a),r)>0&&(a=o.invert(a));const c=[a],I=o.transform(e.fromTranslation(e.create(),r),a),l=a.vertices.length;for(let B=0;B<l;B++){const C=B<l-1?B+1:0,Q=o.create([a.vertices[B],I.vertices[B],I.vertices[C],a.vertices[C]]);c.push(Q)}return c.push(o.invert(I)),n.create(c)};A.exports=s}}),ivt=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,A){var{EPS:e,TAU:i}=Br(),n=tc(),o=bn(),s=yte(),r=As(),a=Ar(),g=Qte(),c=PY(),I=Dte(),l=tvt(),B=(E,u,d)=>{const f=u.toString();if(E.has(f))E.get(f)[1].push(d);else{const m=[u,[d]];E.set(f,m)}},C=(E,u,d)=>{const f=u[0].toString(),m=u[1].toString(),w=f<m?`${f},${m}`:`${m},${f}`;if(E.has(w))E.get(w)[1].push(d);else{const D=[u,[d]];E.set(w,D)}},Q=(E,u)=>{E.findIndex(f=>f===u)<0&&E.push(u)},h=(E,u)=>{const d={delta:1,segments:12},{delta:f,segments:m}=Object.assign({},d,E);let w=r.create();const D=new Map,S=new Map,_=o.create(),x=o.create();return r.toPolygons(u).forEach((F,L)=>{const Y=o.scale(o.create(),a.plane(F),2*f),J=a.transform(n.fromTranslation(n.create(),o.scale(o.create(),Y,-.5)),F),O=l(Y,J);w=I(w,O);const Z=F.vertices;for(let X=0;X<Z.length;X++){B(D,Z[X],a.plane(F));const eA=(X+1)%Z.length,gA=[Z[X],Z[eA]];C(S,gA,a.plane(F))}}),S.forEach(F=>{const L=F[0],Y=F[1],J=L[0],O=L[1],Z=o.subtract(o.create(),O,J);o.normalize(Z,Z);const X=Y[0],eA=o.cross(o.create(),X,Z);let gA=[];for(let YA=0;YA<m;YA++)Q(gA,YA*i/m);for(let YA=0,QA=Y.length;YA<QA;YA++){const _A=Y[YA],dA=o.dot(eA,_A),KA=o.dot(X,_A);let ZA=Math.atan2(dA,KA);ZA<0&&(ZA+=i),Q(gA,ZA),ZA=Math.atan2(-dA,-KA),ZA<0&&(ZA+=i),Q(gA,ZA)}gA=gA.sort(s);const tA=gA.length;let iA,sA;const aA=[],EA=[],bA=[];for(let YA=-1;YA<tA;YA++){const QA=gA[YA<0?YA+tA:YA],_A=Math.sin(QA),dA=Math.cos(QA);o.scale(_,X,dA*f),o.scale(x,eA,_A*f),o.add(_,_,x);const KA=o.add(o.create(),J,_),ZA=o.add(o.create(),O,_);let ce=!1;if(YA>=0&&o.distance(KA,iA)<e&&(ce=!0),!ce){if(YA>=0){aA.push(KA),EA.push(ZA);const fA=[sA,ZA,KA,iA],ge=a.create(fA);bA.push(ge)}iA=KA,sA=ZA}}EA.reverse(),bA.push(a.create(aA)),bA.push(a.create(EA));const xA=r.create(bA);w=I(w,xA)}),D.forEach(F=>{const L=F[0],Y=F[1],J=Y[0];let O=null,Z=0;for(let tA=1;tA<Y.length;tA++){const iA=Y[tA],sA=o.cross(_,J,iA),aA=o.length(sA);aA>.05&&aA>Z&&(Z=aA,O=iA)}O||(O=o.orthogonal(_,J));const X=o.cross(_,J,O);o.normalize(X,X);const eA=o.cross(x,X,J),gA=g({center:[L[0],L[1],L[2]],radius:f,segments:m,axes:[J,X,eA]});w=I(w,gA)}),c(w)};A.exports=h}}),nvt=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,A){var e=As(),i=SdA(),n=ivt(),o=(s,r)=>{const a={delta:1,corners:"round",segments:12},{delta:g,corners:c,segments:I}=Object.assign({},a,s);if(c!=="round")throw new Error('corners must be "round" for 3D geometries');if(e.toPolygons(r).length===0)throw new Error("the given geometry cannot be empty");s={delta:g,corners:c,segments:I};const B=n(s,r);return i(r,B)};A.exports=o}}),ovt=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,A){var e=EV(),i=_s(),n=os(),o=Lg(),s=pV(),r=c=>{let{external:I,internal:l}=c;e(I)<0?I=I.reverse():l=l.reverse();const B=o.fromPoints({closed:!0},I),C=o.fromPoints({closed:!0},l),Q=n.toSides(n.fromPoints(o.toPoints(B))),h=n.toSides(n.fromPoints(o.toPoints(C)));return Q.push(...h),n.create(Q)},a=(c,I,l,B)=>{const{points:C,external:Q,internal:h}=c,E=Math.floor(I/2),u=[],d=[];if(l==="round"&&E>0){const m=Math.PI/E,w=C[C.length-1],D=i.angle(i.subtract(i.create(),Q[Q.length-1],w)),S=C[0],_=i.angle(i.subtract(i.create(),h[0],S));for(let x=1;x<E;x++){let G=D+m*x,F=i.fromAngleRadians(i.create(),G);i.scale(F,F,B),i.add(F,F,w),u.push(F),G=_+m*x,F=i.fromAngleRadians(i.create(),G),i.scale(F,F,B),i.add(F,F,S),d.push(F)}}const f=[];return f.push(...Q,...u,...h.reverse(),...d),n.fromPoints(f)},g=(c,I)=>{c=Object.assign({},{delta:1,corners:"edge",segments:16},c);const{delta:B,corners:C,segments:Q}=c;if(B<=0)throw new Error("the given delta must be positive for paths");if(!(C==="edge"||C==="chamfer"||C==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const h=I.isClosed,E=o.toPoints(I);if(E.length===0)throw new Error("the given geometry cannot be empty");const u={points:E,external:s({delta:B,corners:C,segments:Q,closed:h},E),internal:s({delta:-B,corners:C,segments:Q,closed:h},E)};return I.isClosed?r(u):a(u,Q,C,B)};A.exports=g}}),bdA=ae({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,A){var e=ko(),i=os(),n=As(),o=Lg(),s=evt(),r=nvt(),a=ovt(),g=(c,...I)=>{if(I=e(I),I.length===0)throw new Error("wrong number of arguments");const l=I.map(B=>o.isA(B)?a(c,B):i.isA(B)?s(c,B):n.isA(B)?r(c,B):B);return l.length===1?l[0]:l};A.exports=g}}),svt=ae({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,A){var e=os(),i=cdA(),n=pV(),o=(s,r)=>{const a={delta:1,corners:"edge",segments:0},{delta:g,corners:c,segments:I}=Object.assign({},a,s);if(!(c==="edge"||c==="chamfer"||c==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const l=e.toOutlines(r),C=l.map(Q=>(s={delta:l.reduce((u,d)=>u+i.arePointsInside(Q,i.create(d)),0)%2===0?g:-g,corners:c,closed:!0,segments:I},n(s,Q))).reduce((Q,h)=>Q.concat(e.toSides(e.fromPoints(h))),[]);return e.create(C)};A.exports=o}}),rvt=ae({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,A){var e=Lg(),i=pV(),n=(o,s)=>{const r={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:a,corners:g,closed:c,segments:I}=Object.assign({},r,o);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');o={delta:a,corners:g,closed:c,segments:I};const l=i(o,e.toPoints(s));return e.fromPoints({closed:c},l)};A.exports=n}}),avt=ae({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,A){var e=ko(),i=os(),n=Lg(),o=svt(),s=rvt(),r=(a,...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");const c=g.map(I=>n.isA(I)?s(a,I):i.isA(I)?o(a,I):I);return c.length===1?c[0]:c};A.exports=r}}),_te=ae({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,A){A.exports={expand:bdA(),offset:avt()}}}),fV=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,A){var e=tc(),i=bn(),n=os(),o=a1(),s=dV(),r=(a,g)=>{const c={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:I,twistAngle:l,twistSteps:B,repair:C}=Object.assign({},c,a);if(B<1)throw new Error("twistSteps must be 1 or more");l===0&&(B=1);const Q=i.clone(I),h=n.toSides(g);if(h.length===0)throw new Error("the given geometry cannot be empty");const E=o.fromSides(h);Q[2]<0&&o.reverse(E,E);const u=e.create(),d=(f,m,w)=>{const D=m/B*l,S=i.scale(i.create(),Q,m/B);return e.multiply(u,e.fromZRotation(u,D),e.fromTranslation(e.create(),S)),o.transform(u,w)};return a={numberOfSlices:B+1,capStart:!0,capEnd:!0,repair:C,callback:d},s(a,E)};A.exports=r}}),gvt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,A){var e=os(),i=Lg(),n=fV(),o=(s,r)=>{if(!r.isClosed)throw new Error("extruded path must be closed");const a=i.toPoints(r),g=e.fromPoints(a);return n(s,g)};A.exports=o}}),cvt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,A){var e=ko(),i=os(),n=Lg(),o=fV(),s=gvt(),r=(a,...g)=>{const c={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:I,twistAngle:l,twistSteps:B,repair:C}=Object.assign({},c,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");a={offset:[0,0,I],twistAngle:l,twistSteps:B,repair:C};const Q=g.map(h=>n.isA(h)?s(a,h):i.isA(h)?o(a,h):h);return Q.length===1?Q[0]:Q};A.exports=r}}),Ivt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,A){var e=Lg(),i=bdA(),n=fV(),o=(s,r)=>{const a={size:1,height:1},{size:g,height:c}=Object.assign({},a,s);if(s.delta=g,s.offset=[0,0,c],e.toPoints(r).length===0)throw new Error("the given geometry cannot be empty");const l=i(s,r);return n(s,l)};A.exports=o}}),lvt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,A){var{area:e}=UY(),i=os(),n=Lg(),o=bdA(),s=fV(),r=(a,g)=>{const c={size:1,height:1},{size:I,height:l}=Object.assign({},c,a);a.delta=I,a.offset=[0,0,l];const B=i.toOutlines(g);if(B.length===0)throw new Error("the given geometry cannot be empty");const Q=B.map(E=>(e(E)<0&&E.reverse(),o(a,n.fromPoints({closed:!0},E)))).reduce((E,u)=>E.concat(i.toSides(u)),[]),h=i.create(Q);return s(a,h)};A.exports=r}}),Bvt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,A){var e=ko(),i=os(),n=Lg(),o=Ivt(),s=lvt(),r=(a,...g)=>{const c={size:1,height:1},{size:I,height:l}=Object.assign({},c,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(I<=0)throw new Error("size must be positive");if(l<=0)throw new Error("height must be positive");const B=g.map(C=>n.isA(C)?o(a,C):i.isA(C)?s(a,C):C);return B.length===1?B[0]:B};A.exports=r}}),Cvt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,A){var{TAU:e}=Br(),i=tc(),n=os(),o=dV(),s=a1(),r=(a,g)=>{const c={angle:e,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:I,startAngle:l,pitch:B,height:C,endOffset:Q,segmentsPerRotation:h}=Object.assign({},c,a);if(C!=0&&(B=C/(I/e)),h<3)throw new Error("The number of segments per rotation needs to be at least 3.");const u=n.toSides(g);if(u.length===0)throw new Error("The given geometry cannot be empty");const d=u.filter(x=>x[0][0]>=0);let f=s.fromSides(u);d.length===0&&(f=s.reverse(f));const m=Math.round(h/e*Math.abs(I)),w=m>=2?m:2,D=i.create(),S=i.create(),_=(x,G,F)=>{const L=l+I/w*G,Y=Q/w*G,J=(L-l)/e*B;return i.multiply(D,i.fromTranslation(i.create(),[Y,0,J*Math.sign(I)]),i.fromXRotation(i.create(),-e/4*Math.sign(I))),i.multiply(S,i.fromZRotation(i.create(),L),D),s.transform(S,F)};return o({numberOfSlices:w+1,callback:_},f)};A.exports=r}}),Qvt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,A){var e=ko(),i=CdA(),n=HD(),o=tc(),s=os(),r=As(),a=Ar(),g=Ak(),c=xte(),I=(B,C)=>{const Q=n.fromNormalAndPoint(n.create(),B.axis,B.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 h=g(C),E=h*h*Math.sqrt(3)/4;if(h===0)return s.create();const u=r.toPolygons(C);let d=[];for(let m=0;m<u.length;m++){const w=u[m].vertices.map(_=>n.projectionOfPoint(Q,_)),D=a.create(w),S=a.plane(D);i(Q,S)&&(a.measureArea(D)<E||d.push(D))}if(!i(Q,[0,0,1])){const m=o.fromVectorRotation(o.create(),Q,[0,0,1]);d=d.map(w=>a.transform(m,w))}d=d.sort((m,w)=>a.measureArea(w)-a.measureArea(m));const f=d.map(m=>s.fromPoints(m.vertices));return c(f)},l=(B,...C)=>{const Q={axis:[0,0,1],origin:[0,0,0]},{axis:h,origin:E}=Object.assign({},Q,B);if(C=e(C),C.length===0)throw new Error("wrong number of arguments");B={axis:h,origin:E};const u=C.map(d=>r.isA(d)?I(B,d):d);return u.length===1?u[0]:u};A.exports=l}}),KY=ae({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,A){A.exports={extrudeFromSlices:dV(),extrudeLinear:cvt(),extrudeRectangular:Bvt(),extrudeRotate:dte(),extrudeHelical:Cvt(),project:Qvt(),slice:a1()}}}),xdA=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,A){var e=_s(),i=s=>{let r=e.fromValues(1/0,1/0);s.forEach(c=>{(c[1]<r[1]||c[1]===r[1]&&c[0]<r[0])&&(r=c)});const a=[];s.forEach(c=>{const I=o(c[1]-r[1],c[0]-r[0]),l=e.squaredDistance(c,r);a.push({point:c,angle:I,distSq:l})}),a.sort((c,I)=>c.angle!==I.angle?c.angle-I.angle:c.distSq-I.distSq);const g=[];return a.forEach(c=>{let I=g.length;for(;I>1&&n(g[I-2],g[I-1],c.point)<=Number.EPSILON;)g.pop(),I=g.length;g.push(c.point)}),g},n=(s,r,a)=>(r[0]-s[0])*(a[1]-s[1])-(r[1]-s[1])*(a[0]-s[0]),o=(s,r)=>s===0&&r===0?-1/0:-r/s;A.exports=i}}),_dA=ae({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,A){var e=os(),i=As(),n=Lg(),o=s=>{const r=new Set,a=[],g=c=>{const I=c.toString();r.has(I)||(a.push(c),r.add(I))};return s.forEach(c=>{e.isA(c)?e.toPoints(c).forEach(g):i.isA(c)?i.toPoints(c).forEach(I=>I.forEach(g)):n.isA(c)&&n.toPoints(c).forEach(g)}),a};A.exports=o}}),hvt=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,A){var e=ko(),i=Lg(),n=xdA(),o=_dA(),s=(...r)=>{r=e(r);const a=o(r),g=n(a);return i.fromPoints({closed:!0},g)};A.exports=s}}),Evt=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,A){var e=ko(),i=os(),n=xdA(),o=_dA(),s=(...r)=>{r=e(r);const a=o(r),g=n(a);return g.length<3?i.create():i.fromPoints(g)};A.exports=s}}),uvt=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,A){var e=ko(),i=As(),n=_dA(),o=wdA(),s=(...r)=>{r=e(r);const a=n(r);return a.length===0?i.create():i.create(o(a))};A.exports=s}}),kte=ae({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,A){var e=ko(),i=TY(),n=os(),o=As(),s=Lg(),r=hvt(),a=Evt(),g=uvt(),c=(...I)=>{if(I=e(I),I.length===0)throw new Error("wrong number of arguments");if(!i(I))throw new Error("only hulls of the same type are supported");const l=I[0];return s.isA(l)?r(I):n.isA(l)?a(I):o.isA(l)?g(I):l};A.exports=c}}),dvt=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,A){var e=ko(),i=SdA(),n=kte(),o=(...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(n(s[a-1],s[a]));return i(r)};A.exports=o}}),pvt=ae({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,A){A.exports={hull:kte(),hullChain:dvt(),hullPoints2:xdA(),hullPoints3:wdA()}}}),fvt=ae({"node_modules/@jscad/modeling/src/operations/minkowski/index.js"(t,A){A.exports={minkowskiSum:Ste()}}}),vte=ae({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,A){var e=bn(),i=Ar(),n=(s,r)=>{const a=Math.abs(i.measureArea(r));return Number.isFinite(a)&&a>s},o=(s,r)=>{let a=r.map(c=>{const I=c.vertices.map(C=>e.snap(e.create(),C,s)),l=[];for(let C=0;C<I.length;C++){const Q=(C+1)%I.length;e.equals(I[C],I[Q])||l.push(I[C])}const B=i.create(l);return c.color&&(B.color=c.color),B});const g=s*s*Math.sqrt(3)/4;return a=a.filter(c=>n(g,c)),a};A.exports=o}}),yvt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,A){var e=CdA(),i=bn(),n=Ar(),o=E=>{const u=n.toPoints(E),d=[];for(let f=0;f<u.length;f++){const m=(f+1)%u.length,w={v1:u[f],v2:u[m]};d.push(w)}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=(E,u)=>{const d=`${u.v1}:${u.v2}`;E.set(d,u)},r=(E,u)=>{const d=`${u.v1}:${u.v2}`;E.delete(d)},a=(E,u)=>{const d=`${u.v2}:${u.v1}`;return E.get(d)},g=(E,u,d)=>{let f=E.prev.v1,m=E.prev.v2,w=u.next.v2;const D=l(f,m,w,d);f=u.prev.v1,m=u.prev.v2,w=E.next.v2;const S=l(f,m,w,d);return[D,S]},c=i.create(),I=i.create(),l=(E,u,d,f)=>{const m=i.subtract(c,u,E),w=i.subtract(I,d,u);return i.cross(m,m,w),i.dot(m,f)},B=E=>{let u;const d=[];for(;E.next;){const f=E.next;d.push(E.v1),E.v1=null,E.v2=null,E.next=null,E.prev=null,E=f}return d.length>0&&(u=n.create(d)),u},C=E=>{if(E.length<2)return E;const u=E[0].plane,d=E.slice(),f=new Map;for(;d.length>0;){const w=d.shift(),D=o(w);for(let S=0;S<D.length;S++){const _=D[S],x=a(f,_);if(x){const G=g(_,x,u);if(G[0]>=0&&G[1]>=0){const F=x.next,L=_.next;_.prev.next=x.next,_.next.prev=x.prev,x.prev.next=_.next,x.next.prev=_.prev,_.v1=null,_.v2=null,_.next=null,_.prev=null,r(f,x),x.v1=null,x.v2=null,x.next=null,x.prev=null;const Y=(J,O,Z)=>{const X={v1:Z.v1,v2:O.v2,next:O.next,prev:Z.prev};Z.prev.next=X,O.next.prev=X,r(J,O),O.v1=null,O.v2=null,O.next=null,O.prev=null,r(J,Z),Z.v1=null,Z.v2=null,Z.next=null,Z.prev=null};G[0]===0&&Y(f,F,F.prev),G[1]===0&&Y(f,L,L.prev)}}else _.next&&s(f,_)}}const m=[];return f.forEach(w=>{const D=B(w);D&&m.push(D)}),f.clear(),m},Q=(E,u)=>Math.abs(E[3]-u[3])<15e-8?e(E,u):!1,h=(E,u)=>{const d=[];u.forEach(m=>{const w=d.find(D=>Q(D[0],n.plane(m)));w?w[1].push(m):d.push([n.plane(m),[m]])});let f=[];return d.forEach(m=>{const w=m[1],D=C(w);f=f.concat(D)}),f};A.exports=h}}),mvt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,A){var e=Br(),i=bn(),n=Ar(),o=g=>`${g}`,s=(g,c,I,l,B,C)=>{const Q=o(l),h=o(B),E=`${Q}/${h}`,u=`${h}/${Q}`;if(g.has(u))return r(g,c,I,B,l,null),null;const d={vertex0:l,vertex1:B,polygonindex:C};return g.has(E)?g.get(E).push(d):g.set(E,[d]),c.has(Q)?c.get(Q).push(E):c.set(Q,[E]),I.has(h)?I.get(h).push(E):I.set(h,[E]),E},r=(g,c,I,l,B,C)=>{const Q=o(l),h=o(B),E=`${Q}/${h}`;let u=-1;const d=g.get(E);for(let f=0;f<d.length;f++){const m=d[f];let w=o(m.vertex0);if(w===Q&&(w=o(m.vertex1),w===h&&!(C!==null&&m.polygonindex!==C))){u=f;break}}d.splice(u,1),d.length===0&&g.delete(E),u=c.get(Q).indexOf(E),c.get(Q).splice(u,1),c.get(Q).length===0&&c.delete(Q),u=I.get(h).indexOf(E),I.get(h).splice(u,1),I.get(h).length===0&&I.delete(h)},a=g=>{const c=new Map;for(let I=0;I<g.length;I++){const l=g[I],B=l.vertices.length;if(B>=3){let C=l.vertices[0],Q=o(C);for(let h=0;h<B;h++){let E=h+1;E===B&&(E=0);const u=l.vertices[E],d=o(u),f=`${Q}/${d}`,m=`${d}/${Q}`;if(c.has(m)){const w=c.get(m);w.splice(-1,1),w.length===0&&c.delete(m)}else{const w={vertex0:C,vertex1:u,polygonindex:I};c.has(f)?c.get(f).push(w):c.set(f,[w])}C=u,Q=d}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(c.size>0){const I=new Map,l=new Map,B=new Map;for(const[Q,h]of c)B.set(Q,!0),h.forEach(E=>{const u=o(E.vertex0),d=o(E.vertex1);I.has(u)?I.get(u).push(Q):I.set(u,[Q]),l.has(d)?l.get(d).push(Q):l.set(d,[Q])});const C=g.slice(0);for(;c.size!==0;){for(const h of c.keys())B.set(h,!0);let Q=!1;for(;;){const h=Array.from(B.keys());if(h.length===0)break;const E=h[0];let u=!0;if(c.has(E)){const f=c.get(E)[0];for(let m=0;m<2;m++){const w=m===0?f.vertex0:f.vertex1,D=m===0?f.vertex1:f.vertex0,S=o(w),_=o(D);let x=[];m===0?l.has(S)&&(x=l.get(S)):I.has(S)&&(x=I.get(S));for(let G=0;G<x.length;G++){const F=x[G],L=c.get(F)[0],Y=m===0?L.vertex0:L.vertex1;if(m===0?L.vertex1:L.vertex0,o(Y)===_){r(c,I,l,w,D,null),r(c,I,l,D,w,null),u=!1,m=2,Q=!0;break}else{const O=w,Z=D,X=Y,eA=i.subtract(i.create(),X,O),gA=i.dot(i.subtract(i.create(),Z,O),eA)/i.dot(eA,eA);if(gA>0&&gA<1){const tA=i.scale(i.create(),eA,gA);if(i.add(tA,tA,O),i.squaredDistance(tA,Z)<e.EPS*e.EPS){const sA=L.polygonindex,aA=C[sA],EA=o(L.vertex1);let bA=-1;for(let dA=0;dA<aA.vertices.length;dA++)if(o(aA.vertices[dA])===EA){bA=dA;break}const xA=aA.vertices.slice(0);xA.splice(bA,0,D);const YA=n.create(xA);C[sA]=YA,r(c,I,l,L.vertex0,L.vertex1,sA);const QA=s(c,I,l,L.vertex0,D,sA),_A=s(c,I,l,D,L.vertex1,sA);QA!==null&&B.set(QA,!0),_A!==null&&B.set(_A,!0),u=!1,m=2,Q=!0;break}}}}}}u&&B.delete(E)}if(!Q)break}g=C}return c.clear(),g};A.exports=a}}),wvt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,A){var e=bn(),i=Ar(),n=(s,r,a)=>{const g=r.vertices.length;if(g>3){if(g>4){const l=[0,0,0];r.vertices.forEach(B=>e.add(l,l,B)),e.snap(l,e.divide(l,l,[g,g,g]),s);for(let B=0;B<g;B++){const C=i.create([l,r.vertices[B],r.vertices[(B+1)%g]]);r.color&&(C.color=r.color),a.push(C)}return}const c=i.create([r.vertices[0],r.vertices[1],r.vertices[2]]),I=i.create([r.vertices[0],r.vertices[2],r.vertices[3]]);r.color&&(c.color=r.color,I.color=r.color),a.push(c,I);return}a.push(r)},o=(s,r)=>{const a=[];return r.forEach(g=>{n(s,g,a)}),a};A.exports=o}}),Dvt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,A){var e=ko(),i=Ak(),n=os(),o=As(),s=Lg(),r=vte(),a=yvt(),g=mvt(),c=wvt(),I=(Q,h)=>h,l=(Q,h)=>h,B=(Q,h)=>{const E={snap:!1,simplify:!1,triangulate:!1},{snap:u,simplify:d,triangulate:f}=Object.assign({},E,Q),m=i(h);let w=o.toPolygons(h);u&&(w=r(m,w)),d&&(w=a(m,w)),f&&(w=g(w),w=c(m,w));const D=Object.assign({},h);return D.polygons=w,D},C=(Q,...h)=>{if(h=e(h),h.length===0)throw new Error("wrong number of arguments");const E=h.map(u=>{if(s.isA(u))return I(Q,u);if(n.isA(u))return l(Q,u);if(o.isA(u))return B(Q,u);throw new Error("invalid geometry")});return E.length===1?E[0]:E};A.exports=C}}),Svt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,A){var e=ko(),i=_s(),n=os(),o=As(),s=Lg(),r=Ak(),a=vte(),g=B=>{const C=r(B),h=s.toPoints(B).map(E=>i.snap(i.create(),E,C));return s.create(h)},c=B=>{const C=r(B);let h=n.toSides(B).map(E=>[i.snap(i.create(),E[0],C),i.snap(i.create(),E[1],C)]);return h=h.filter(E=>!i.equals(E[0],E[1])),n.create(h)},I=B=>{const C=r(B),Q=o.toPolygons(B),h=a(C,Q);return o.create(h)},l=(...B)=>{if(B=e(B),B.length===0)throw new Error("wrong number of arguments");const C=B.map(Q=>s.isA(Q)?g(Q):n.isA(Q)?c(Q):o.isA(Q)?I(Q):Q);return C.length===1?C[0]:C};A.exports=l}}),bvt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,A){A.exports={generalize:Dvt(),snap:Svt(),retessellate:PY()}}}),xvt=ae({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,A){var e=(i,n,o)=>{for(i=i.slice();i.length<o;)i.push(n);return i};A.exports=e}}),_vt=ae({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,A){var e=ko(),i=xvt(),n=hdA(),{translate:o}=JF(),s=c=>{if(!Array.isArray(c.modes)||c.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(c.modes=i(c.modes,"none",3),c.modes.filter(I=>["center","max","min","none"].includes(I)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(c.relativeTo)||c.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(c.relativeTo=i(c.relativeTo,0,3),c.relativeTo.filter(I=>Number.isFinite(I)||I==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof c.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return c},r=(c,I,l)=>{for(let B=0;B<3;B++)c[B]==null&&(I[B]==="center"?c[B]=(l[0][B]+l[1][B])/2:I[B]==="max"?c[B]=l[1][B]:I[B]==="min"&&(c[B]=l[0][B]));return c},a=(c,I,l)=>{const B=n(c),C=[0,0,0];for(let Q=0;Q<3;Q++)I[Q]==="center"?C[Q]=l[Q]-(B[0][Q]+B[1][Q])/2:I[Q]==="max"?C[Q]=l[Q]-B[1][Q]:I[Q]==="min"&&(C[Q]=l[Q]-B[0][Q]);return o(C,c)},g=(c,...I)=>{c=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},c),c=s(c);let{modes:B,relativeTo:C,grouped:Q}=c;if(I=e(I),I.length===0)throw new Error("align(): No geometries were provided to act upon");if(C.filter(h=>h==null).length){const h=n(I);C=r(C,B,h)}return Q?I=a(I,B,C):I=I.map(h=>a(h,B,C)),I.length===1?I[0]:I};A.exports=g}}),yV=ae({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,A){var e=ko(),i=os(),n=As(),o=Lg(),s=HF(),{translate:r}=JF(),a=(B,C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:h,relativeTo:E}=Object.assign({},Q,B),u=s(C),d=[0,0,0];return h[0]&&(d[0]=E[0]-(u[0][0]+(u[1][0]-u[0][0])/2)),h[1]&&(d[1]=E[1]-(u[0][1]+(u[1][1]-u[0][1])/2)),h[2]&&(d[2]=E[2]-(u[0][2]+(u[1][2]-u[0][2])/2)),r(d,C)},g=(B,...C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:h,relativeTo:E}=Object.assign({},Q,B);if(C=e(C),C.length===0)throw new Error("wrong number of arguments");if(E.length!==3)throw new Error("relativeTo must be an array of length 3");B={axes:h,relativeTo:E};const u=C.map(d=>o.isA(d)||i.isA(d)||n.isA(d)?a(B,d):d);return u.length===1?u[0]:u},c=(...B)=>g({axes:[!0,!1,!1]},B),I=(...B)=>g({axes:[!1,!0,!1]},B),l=(...B)=>g({axes:[!1,!1,!0]},B);A.exports={center:g,centerX:c,centerY:I,centerZ:l}}}),mV=ae({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,A){var e=ko(),i=tc(),n=os(),o=As(),s=Lg(),r=(I,...l)=>{if(!Array.isArray(I))throw new Error("factors must be an array");if(l=e(l),l.length===0)throw new Error("wrong number of arguments");for(I=I.slice();I.length<3;)I.push(1);if(I[0]<=0||I[1]<=0||I[2]<=0)throw new Error("factors must be positive");const B=i.fromScaling(i.create(),I),C=l.map(Q=>s.isA(Q)?s.transform(B,Q):n.isA(Q)?n.transform(B,Q):o.isA(Q)?o.transform(B,Q):Q);return C.length===1?C[0]:C},a=(I,...l)=>r([I,1,1],l),g=(I,...l)=>r([1,I,1],l),c=(I,...l)=>r([1,1,I],l);A.exports={scale:r,scaleX:a,scaleY:g,scaleZ:c}}}),kvt=ae({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,A){var e=ko(),i=os(),n=As(),o=Lg(),s=(r,...a)=>{if(a=e(a),a.length===0)throw new Error("wrong number of arguments");const g=a.map(c=>o.isA(c)?o.transform(r,c):i.isA(c)?i.transform(r,c):n.isA(c)?n.transform(r,c):c);return g.length===1?g[0]:g};A.exports=s}}),TF=ae({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,A){A.exports={align:_vt(),center:yV().center,centerX:yV().centerX,centerY:yV().centerY,centerZ:yV().centerZ,mirror:YY().mirror,mirrorX:YY().mirrorX,mirrorY:YY().mirrorY,mirrorZ:YY().mirrorZ,rotate:JY().rotate,rotateX:JY().rotateX,rotateY:JY().rotateY,rotateZ:JY().rotateZ,scale:mV().scale,scaleX:mV().scaleX,scaleY:mV().scaleY,scaleZ:mV().scaleZ,transform:kvt(),translate:JF().translate,translateX:JF().translateX,translateY:JF().translateY,translateZ:JF().translateZ}}}),wV=ae({"node_modules/@jscad/modeling/src/index.js"(t,A){A.exports={colors:hV(),curves:w_t(),geometries:IdA(),maths:V_t(),measurements:ikt(),primitives:ek(),text:Gkt(),utils:mte(),booleans:g1(),expansions:_te(),extrusions:KY(),hulls:pvt(),minkowski:fvt(),modifiers:bvt(),transforms:TF()}}}),Fte=ae({"node_modules/jscad-planner/dist/index.cjs"(t,A){var e=Object.defineProperty,i=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(l,B)=>{for(var C in B)e(l,C,{get:B[C],enumerable:!0})},r=(l,B,C,Q)=>{if(B&&typeof B=="object"||typeof B=="function")for(let h of n(B))!o.call(l,h)&&h!==C&&e(l,h,{get:()=>B[h],enumerable:!(Q=i(B,h))||Q.enumerable});return l},a=l=>r(e({},"__esModule",{value:!0}),l),g={};s(g,{executeJscadOperations:()=>I,jscadPlanner:()=>c}),A.exports=a(g);var c={booleans:{intersect:(...l)=>({type:"intersect",shapes:l}),subtract:(...l)=>({type:"subtract",shapes:l}),union:(...l)=>({type:"union",shapes:l})},hulls:{hull:(...l)=>({type:"hull",shapes:l.flat()}),hullChain:(...l)=>({type:"hullChain",shapes:l.flat()})},colors:{colorize:(l,B)=>({type:"colorize",color:l,shape:B})},primitives:{cube:l=>({type:"cube",...l}),sphere:l=>({type:"sphere",...l}),cylinder:l=>({type:"cylinder",...l}),polygon:l=>({type:"polygon",...l}),cuboid:l=>({type:"cuboid",...l}),roundedCuboid:l=>({type:"roundedCuboid",...l})},transforms:{rotate:(l,B)=>({type:"rotate",angles:l,shape:B}),scale:(l,B)=>({type:"scale",factors:l,shape:B}),translate:(l,B)=>({type:"translate",vector:l,shape:B})},extrusions:{extrudeLinear:(l,B)=>({type:"extrudeLinear",options:l,shape:B}),extrudeRotate:(l,B)=>({type:"extrudeRotate",options:l,shape:B})},maths:{vec2:{create:(l,B)=>[l,B],fromValues:(l,B)=>[l,B]},vec3:{create:(l,B,C)=>[l,B,C],fromValues:(l,B,C)=>[l,B,C]}},geometries:{geom2:{create:l=>({type:"createGeom2",points:l})},geom3:{create:l=>({type:"createGeom3",polygons:l})},path2:{create:l=>({type:"createPath2",points:l})}},measurements:{measureBoundingBox:l=>({type:"measureBoundingBox",shape:l}),measureArea:l=>({type:"measureArea",shape:l}),measureVolume:l=>({type:"measureVolume",shape:l})},utils:{degToRad:l=>l*Math.PI/180,radToDeg:l=>l*180/Math.PI}},I=(l,B)=>{if(Array.isArray(B)&&B.length===1)return I(l,B[0]);if(Array.isArray(B))throw new Error("executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually");const C=E=>I(l,E),{type:Q,...h}=B;switch(Q){case"intersect":return l.booleans.intersect(...B.shapes.map(C));case"subtract":return l.booleans.subtract(...B.shapes.map(C));case"union":return l.booleans.union(...B.shapes.map(C));case"hull":return l.hulls.hull(...B.shapes.map(C));case"hullChain":return l.hulls.hullChain(...B.shapes.map(C));case"colorize":return l.colors.colorize(B.color,C(B.shape));case"cube":return l.primitives.cube(h);case"sphere":return l.primitives.sphere(h);case"cylinder":return l.primitives.cylinder(h);case"polygon":return l.primitives.polygon(h);case"cuboid":return l.primitives.cuboid(h);case"roundedCuboid":return l.primitives.roundedCuboid(h);case"rotate":return l.transforms.rotate(B.angles,C(B.shape));case"scale":return l.transforms.scale(B.factors,C(B.shape));case"translate":return l.transforms.translate(B.vector,C(B.shape));case"extrudeLinear":return l.extrusions.extrudeLinear(B.options,C(B.shape));case"extrudeRotate":return l.extrusions.extrudeRotate(B.options,C(B.shape));case"createGeom2":return l.geometries.geom2.create(B.points);case"createGeom3":return l.geometries.geom3.create(B.polygons);case"createPath2":return l.geometries.path2.create(B.points);case"measureBoundingBox":return l.measurements.measureBoundingBox(C(B.shape));case"measureArea":return l.measurements.measureArea(C(B.shape));case"measureVolume":return l.measurements.measureVolume(C(B.shape));case"degToRad":return l.utils.degToRad(B.degrees);case"radToDeg":return l.utils.radToDeg(B.radians);default:throw B.type===void 0?new Error(`Operation type is undefined. This usually means the operation object is malformed or not properly initialized. Operation: ${JSON.stringify(B,null,2).slice(0,200)}...`):new Error(`Unsupported operation type: ${B.type}. Operation: ${JSON.stringify(B,null,2)}`)}}}}),vvt=ae({"node_modules/ms/index.js"(t,A){var e=1e3,i=e*60,n=i*60,o=n*24,s=o*7,r=o*365.25;A.exports=function(l,B){B=B||{};var C=typeof l;if(C==="string"&&l.length>0)return a(l);if(C==="number"&&isFinite(l))return B.long?c(l):g(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function a(l){if(l=String(l),!(l.length>100)){var B=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(B){var C=parseFloat(B[1]),Q=(B[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*o;case"hours":case"hour":case"hrs":case"hr":case"h":return C*n;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(l){var B=Math.abs(l);return B>=o?Math.round(l/o)+"d":B>=n?Math.round(l/n)+"h":B>=i?Math.round(l/i)+"m":B>=e?Math.round(l/e)+"s":l+"ms"}function c(l){var B=Math.abs(l);return B>=o?I(l,B,o,"day"):B>=n?I(l,B,n,"hour"):B>=i?I(l,B,i,"minute"):B>=e?I(l,B,e,"second"):l+" ms"}function I(l,B,C,Q){var h=B>=C*1.5;return Math.round(l/C)+" "+Q+(h?"s":"")}}}),Fvt=ae({"node_modules/debug/src/common.js"(t,A){function e(i){o.debug=o,o.default=o,o.coerce=I,o.disable=g,o.enable=r,o.enabled=c,o.humanize=vvt(),o.destroy=l,Object.keys(i).forEach(B=>{o[B]=i[B]}),o.names=[],o.skips=[],o.formatters={};function n(B){let C=0;for(let Q=0;Q<B.length;Q++)C=(C<<5)-C+B.charCodeAt(Q),C|=0;return o.colors[Math.abs(C)%o.colors.length]}o.selectColor=n;function o(B){let C,Q=null,h,E;function u(...d){if(!u.enabled)return;const f=u,m=Number(new Date),w=m-(C||m);f.diff=w,f.prev=C,f.curr=m,C=m,d[0]=o.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let D=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(_,x)=>{if(_==="%%")return"%";D++;const G=o.formatters[x];if(typeof G=="function"){const F=d[D];_=G.call(f,F),d.splice(D,1),D--}return _}),o.formatArgs.call(f,d),(f.log||o.log).apply(f,d)}return u.namespace=B,u.useColors=o.useColors(),u.color=o.selectColor(B),u.extend=s,u.destroy=o.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>Q!==null?Q:(h!==o.namespaces&&(h=o.namespaces,E=o.enabled(B)),E),set:d=>{Q=d}}),typeof o.init=="function"&&o.init(u),u}function s(B,C){const Q=o(this.namespace+(typeof C>"u"?":":C)+B);return Q.log=this.log,Q}function r(B){o.save(B),o.namespaces=B,o.names=[],o.skips=[];const C=(typeof B=="string"?B:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const Q of C)Q[0]==="-"?o.skips.push(Q.slice(1)):o.names.push(Q)}function a(B,C){let Q=0,h=0,E=-1,u=0;for(;Q<B.length;)if(h<C.length&&(C[h]===B[Q]||C[h]==="*"))C[h]==="*"?(E=h,u=Q,h++):(Q++,h++);else if(E!==-1)h=E+1,u++,Q=u;else return!1;for(;h<C.length&&C[h]==="*";)h++;return h===C.length}function g(){const B=[...o.names,...o.skips.map(C=>"-"+C)].join(",");return o.enable(""),B}function c(B){for(const C of o.skips)if(a(B,C))return!1;for(const C of o.names)if(a(B,C))return!0;return!1}function I(B){return B instanceof Error?B.stack||B.message:B}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}A.exports=e}}),Nvt=ae({"node_modules/debug/src/browser.js"(t,A){t.formatArgs=i,t.save=n,t.load=o,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 c=0,I=0;a[0].replace(/%[a-zA-Z%]/g,l=>{l!=="%%"&&(c++,l==="%c"&&(I=c))}),a.splice(I,0,g)}t.log=console.debug||console.log||(()=>{});function n(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function o(){let a;try{a=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!a&&typeof edA<"u"&&"env"in edA&&(a=edA.env.DEBUG),a}function s(){try{return localStorage}catch{}}A.exports=Fvt()(t);var{formatters:r}=A.exports;r.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}}}),Nte={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,pcbNotes:!1,backgroundStart:!0,backgroundEnd:!0},Rte=V.createContext(void 0),Rvt=({children:t})=>{const[A,e]=V.useState(Nte),i=V.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),n=V.useCallback(()=>{e(Nte)},[]),o=V.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:n}),[A,i,n]);return W.jsx(Rte.Provider,{value:o,children:t})},PF=()=>{const t=V.useContext(Rte);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},kdA=1.2;function Gte(t){return V.useMemo(()=>{if(!t)return kdA;try{return mn(t).pcb_board.list()[0]?.thickness??kdA}catch{return kdA}},[t])}var Mte=V.createContext(null),ed=()=>{const t=V.useContext(Mte);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},qY=(t,A=[])=>{const{addFrameListener:e,removeFrameListener:i}=ed();Bn.useEffect(()=>(e(t),()=>i(t)),[e,i,...A])},OY={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},Lte=({children:t,position:A,style:e})=>{const{camera:i,renderer:n}=ed(),o=V.useRef(document.createElement("div")),[s,r]=V.useState(null);return V.useEffect(()=>{const a=n?.domElement.parentNode;if(a)return a.style.position!=="relative"&&a.style.position!=="absolute"&&(a.style.position="relative"),a.appendChild(o.current),r(V8.createPortal(t,o.current)),()=>{a.contains(o.current)&&a.removeChild(o.current)}},[n,t]),qY(()=>{if(!i||!o.current||!n)return;const a=new Re(...A);a.project(i);const g=n.domElement.getBoundingClientRect(),c=Math.round((a.x+1)/2*g.width),I=Math.round((-a.y+1)/2*g.height);o.current.style.position="absolute",o.current.style.left=`${c}px`,o.current.style.top=`${I}px`,o.current.style.pointerEvents="none",o.current.style.zIndex=OY.htmlElements.toString(),e&&Object.assign(o.current.style,e)},[i,n,A,e]),s},Ute={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},Lr=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 Ute)return e*Ute[A];throw new Error(`Unsupported unit: ${A}`)},ql=Lr,Gvt=Object.defineProperty,Mvt=(t,A)=>{for(var e in A)Gvt(t,e,{get:A[e],enumerable:!0})},_b={};Mvt(_b,{axial:()=>sNt,bga:()=>CFt,breakoutheaders:()=>dNt,cap:()=>Pvt,dfn:()=>TFt,diode:()=>Tvt,dip:()=>Hvt,electrolytic:()=>sMt,hc49:()=>fNt,jst:()=>wGt,led:()=>Kvt,lqfp:()=>ENt,m2host:()=>bMt,melf:()=>NRt,micromelf:()=>LRt,minimelf:()=>DRt,mlp:()=>mFt,mountedpcbmodule:()=>_Mt,ms012:()=>ZFt,ms013:()=>jFt,msop:()=>RGt,pad:()=>yNt,pinrow:()=>KFt,platedhole:()=>uMt,potentiometer:()=>iMt,pushbutton:()=>INt,qfn:()=>pFt,qfp:()=>yFt,quad:()=>I1,radial:()=>gNt,res:()=>IFt,sma:()=>JRt,smb:()=>VRt,smbf:()=>aMt,smc:()=>$Rt,smf:()=>qRt,smtpad:()=>hMt,sod110:()=>SGt,sod123:()=>tNt,sod123f:()=>iRt,sod123fl:()=>rRt,sod123w:()=>LNt,sod128:()=>QRt,sod323:()=>JNt,sod323f:()=>$Nt,sod323fl:()=>YGt,sod323w:()=>MGt,sod523:()=>bNt,sod723:()=>IRt,sod80:()=>NNt,sod882:()=>VNt,sod882d:()=>_Rt,sod923:()=>qNt,soic:()=>hFt,solderjumper:()=>VGt,son:()=>KGt,sop8:()=>vNt,sot:()=>pMt,sot223:()=>iGt,sot23:()=>GFt,sot23w:()=>lGt,sot25:()=>HFt,sot323:()=>lMt,sot343:()=>mMt,sot363:()=>vFt,sot457:()=>XGt,sot563:()=>OFt,sot723:()=>XFt,sot886:()=>NFt,sot89:()=>fRt,sot963:()=>AMt,ssop:()=>SFt,stampboard:()=>BNt,stampreceiver:()=>hNt,to220:()=>mRt,to92:()=>DNt,to92l:()=>vMt,to92s:()=>uGt,tqfp:()=>fFt,tssop:()=>_Ft,vson:()=>OGt,vssop:()=>vGt});var Mi=(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"}),Li=te({norefdes:qA().optional().describe("disable reference designator label"),invert:qA().optional().describe("hint to invert the orientation of the 3D model"),faceup:qA().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:qA().optional().describe("omit all silkscreen elements from the footprint")}),vo=(t,A,e,i,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:Lr(i),outer_diameter:Lr(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),YD=t=>{const{pn:A,x:e,y:i,holeDiameter:n,rectPadWidth:o,rectPadHeight:s,holeOffsetX:r=0,holeOffsetY:a=0}=t;return{pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:e,y:i,hole_diameter:Lr(n),hole_shape:"circle",pad_shape:"rect",rect_pad_width:Lr(o),rect_pad_height:Lr(s),pcb_port_id:"",layers:["top","bottom"],port_hints:[A.toString()],hole_offset_x:r,hole_offset_y:a}},DV=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 tk(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var SV=Gt([H(),OA()]).transform(t=>tk(t)),Lvt=t=>Li.extend({fn:H(),num_pins:OA().optional().default(6),wide:qA().optional(),narrow:qA().optional(),w:SV.optional(),p:SV.default(t.p??"2.54mm"),id:SV.optional(),od:SV.optional(),nosquareplating:qA().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=tk("0.55mm"),A.od=tk("0.95mm")):(A.id=tk("0.8mm"),A.od=tk("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=tk("600mil"):A.narrow?A.w=tk("300mil"):A.w=tk(t.w??"300mil")),A)),Uvt=Lvt({}),Hte=(t,A,e,i,n)=>{const o=t/2,s=A<=o,r=o-1,a=i,g=a*r;return s?{x:-e/2,y:g/2-(A-1)*a}:{x:e/2,y:-g/2+(A-o-1)*a}},Hvt=t=>{const A=Uvt.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:c,y:I}=Hte(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating);if(g===0&&!A.nosquareplating){e.push(YD({pn:g+1,x:c,y:I,holeDiameter:A.id??"0.8mm",rectPadWidth:A.od??"1mm",rectPadHeight:A.od??"1mm"}));continue}e.push(vo(g+1,c,I,A.id??"0.8mm",A.od??"1mm"))}(A.num_pins/2-1)*A.p+A.od;const n=A.w-A.od-1,o=(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:-n/2,y:-o/2},{x:-n/2,y:o/2},...DV.map(({x:g,y:c})=>({x:g*n/6,y:c*n/6+o/2})),{x:n/2,y:o/2},{x:n/2,y:-o/2},{x:-n/2,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1},r=[];for(let g=0;g<A.num_pins;g++){const c=g<A.num_pins/2,I=.6,{y:l}=Hte(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating),B=c?-A.w/2-A.od/2-I:A.w/2+A.od/2+I,C=l;r.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${g+1}`,layer:"top",pcb_component_id:`pin_${g+1}`,text:`{pin${g+1}}`,anchor_position:{x:B,y:C},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Mi(0,o/2+.5,.4);return{circuitJson:[...e,s,a,...r],parameters:A}},Ii=(t,A,e,i,n)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:n,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),Yte=[{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}],Yvt=Object.fromEntries(Yte.map(t=>[t.metric,t])),Jvt=Object.fromEntries(Yte.map(t=>[t.imperial,t]));Li.extend({tht:qA(),p:lA.optional(),pw:lA.optional(),ph:lA.optional(),metric:se.optional(),imperial:se.optional(),w:lA.optional(),h:lA.optional(),textbottom:qA().optional()});var bV=t=>{let{tht:A,p:e,pw:i,ph:n,metric:o,imperial:s,w:r,h:a,textbottom:g}=t;if(typeof r=="string"&&(r=ql(r)),typeof a=="string"&&(a=ql(a)),typeof e=="string"&&(e=ql(e)),typeof i=="string"&&(i=ql(i)),typeof n=="string"&&(n=ql(n)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let c;if(o&&(c=Yvt[o]),s&&(c=Jvt[s]),c&&(r=c.w_mm_min,a=c.h_mm_min,e=c.p_mm_min,i=c.pw_mm_min,n=c.ph_mm_min),e===void 0||i===void 0||n===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:e/2,y:n/2+.4},{x:-e/2-i/2-.2,y:n/2+.4},{x:-e/2-i/2-.2,y:-n/2-.4},{x:e/2,y:-n/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},l=g?-n/2-.9:n/2+.9,B=Mi(0,l,.2);return A?[vo(1,-e/2,0,i,i*1/.8),vo(2,e/2,0,i,i*1/.8),I,B]:[Ii(["1","left"],-e/2,0,i,n),Ii(["2","right"],e/2,0,i,n),I,B]},Tvt=t=>({circuitJson:bV(t),parameters:t}),Pvt=t=>({circuitJson:bV(t),parameters:t}),Kvt=t=>({circuitJson:bV(t),parameters:t}),c1=t=>{const{padSpacing:A,padWidth:e,padHeight:i,padPitch:n,numRows:o,textbottom:s}=t,r=[],a=(o-1)*(n/2);for(let S=0;S<o;S++)r.push(a-S*n);const g=[];r.forEach((S,_)=>{g.push(Ii(_+1,-A/2,S,e,i))}),r.slice().reverse().forEach((S,_)=>{g.push(Ii(_+o+1,A/2,S,e,i))});const c=Math.max(...r)+i/2+.4,I=Math.min(...r)-i/2-.4,l=-A/2-e/2-.4,B=A/2+e/2+.4,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B*.5,y:c},{x:l*.5,y:c}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B*.5,y:I},{x:l*.5,y:I}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},h=-A/2,E=Math.max(...r),u=.2,d=h-e/2-.1,f=E+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},w=s?I-.9:c+.9,D=Mi(0,w,.2);return[...g,C,Q,m,D]},qvt=Li.extend({pw:lA.default("0.5mm"),ph:lA.default("0.4mm"),p:lA.default("0.7mm"),textbottom:qA().optional(),convex:qA().optional(),concave:qA().optional()}),Ovt=1,Wvt=t=>{const A=qvt.parse(t);if(A.concave===!0)return[];const e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return c1({padSpacing:Ovt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},Zvt=Li.extend({pw:lA.default("0.5mm"),ph:lA.default("0.32mm"),p:lA.default("0.5mm"),textbottom:qA().optional(),convex:qA().optional(),concave:qA().optional()}),Vvt=1,jvt=t=>{const A=Zvt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return c1({padSpacing:Vvt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},zvt=Li.extend({pw:lA.default("0.9mm"),ph:lA.default("0.4mm"),p:lA.default("0.8mm"),textbottom:qA().optional(),convex:qA().optional(),concave:qA().optional()}),Xvt=1.7,$vt=t=>{const A=zvt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return c1({padSpacing:Xvt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},AFt=Li.extend({pw:lA.default("0.9mm"),ph:lA.default("0.4mm"),p:lA.default("0.8mm"),textbottom:qA().optional(),convex:qA().optional(),concave:qA().optional()}),eFt=1.7,tFt=t=>{const A=AFt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return c1({padSpacing:eFt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},iFt=Li.extend({pw:lA.default("0.7mm"),ph:lA.default("0.64mm"),p:lA.default("0.94mm"),textbottom:qA().optional(),convex:qA().optional(),concave:qA().optional()}),nFt=1.4,oFt=t=>{const A=iFt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return c1({padSpacing:nFt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},sFt=Li.extend({pw:lA.default("0.9mm"),ph:lA.default("0.9mm"),p:lA.default("1.34mm"),textbottom:qA().optional(),convex:qA().optional(),concave:qA().optional()}),rFt=3,aFt=t=>{const A=sFt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return c1({padSpacing:rFt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},gFt=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(/x(2|4)$/)?.[1];if(i)return Number.parseInt(i,10)}},cFt=t=>t?(typeof t=="number"?`${t}`:t).split(/[_x]/)[0]:void 0,IFt=t=>{const A=gFt(t),e=cFt(t.imperial);return A===2&&e==="0402"?{circuitJson:Wvt(t),parameters:t}:A===4&&e==="0402"?{circuitJson:jvt(t),parameters:t}:A===2&&e==="0603"?{circuitJson:$vt(t),parameters:t}:A===4&&e==="0603"?{circuitJson:tFt(t),parameters:t}:A===2&&e==="0606"?{circuitJson:oFt(t),parameters:t}:A===4&&e==="1206"?{circuitJson:aFt(t),parameters:t}:{circuitJson:bV(t),parameters:t}},Jte=(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(n=>n.toString()):[t.toString()]}),Tte="ABCDEFGHIJKLMNOPQRSTUVWXYZ",xV=H().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A??""),y:parseFloat(e??"")}}).pipe(te({x:OA(),y:OA()})),lFt=H().or(be(Xc())).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(H().or(OA()))),BFt=Li.extend({fn:H(),num_pins:OA().optional().default(64),grid:xV.optional(),p:se.default("0.8mm"),w:lA.optional(),h:lA.optional(),ball:lA.optional().describe("ball diameter"),pad:lA.optional().describe("pad width/height"),circularpads:qA().optional().describe("use circular pads"),tlorigin:qA().optional(),blorigin:qA().optional(),trorigin:qA().optional(),brorigin:qA().optional(),missing:lFt.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 n=i.match(/([A-Z]+)(\d+)/);if(!n)return i;const o=Tte.indexOf(n[1]),s=Number.parseInt(n[2])-1;return o*t.grid.x+s+1})),{...t,origin:A}}),CFt=t=>{const A=BFt.parse(t);let{num_pins:e,grid:i,p:n,w:o,h:s,ball:r,pad:a,missing:g}=A;r??=.75/1.27*n,a??=r*.8;const c=[],I=(g??[]).filter(m=>typeof m=="number"),l=i.x*i.y-e;if(g.length===0&&l>0&&(Math.sqrt(l)%1===0?g.push("center"):l===1&&g.push("topleft")),g?.includes("center")){const m=Math.floor(Math.sqrt(l)),w=Math.floor((i.x-m)/2),D=Math.floor((i.y-m)/2);for(let S=D;S<D+m;S++)for(let _=w;_<w+m;_++)I.push(S*i.x+_+1)}g?.includes("topleft")&&I.push(1);const B=new Set(I);let C=0;for(let m=0;m<i.y;m++)for(let w=0;w<i.x;w++){const D=(w-(i.x-1)/2)*n,S=(m-(i.y-1)/2)*n;let _=w,x=m;switch(A.origin){case"bl":_=w,x=i.y-1-m;break;case"br":_=i.x-1-w,x=i.y-1-m;break;case"tr":_=i.x-1-w,x=m;break}let G=x*i.x+_+1;if(B.has(G)){C++;continue}G-=C;const F=[G,`${Tte[x]}${_+1}`];c.push(A.circularpads?Jte(F,{x:D,y:S,radius:a/2}):Ii(F,D,S,a,a))}const Q=Mi(0,i.y*n/2,.2),h=n/6;let E;const u=i.x*n/2,d=i.y*n/2;switch(A.origin){case"bl":E=[{x:-u,y:-d},{x:-u,y:-d-h},{x:-u-h,y:-d},{x:-u,y:-d}];break;case"br":E=[{x:u,y:-d},{x:u,y:-d-h},{x:u+h,y:-d},{x:u,y:-d}];break;case"tr":E=[{x:u,y:d},{x:u,y:d+h},{x:u+h,y:d},{x:u,y:d}];break;default:E=[{x:-u,y:d},{x:-u,y:d+h},{x:-u-h,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:E,stroke_width:.05};return{circuitJson:[...c,Q,f],parameters:A}},_V=(t,A,e,i,n)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:n,radius:n/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),KF=t=>Li.extend({fn:H(),num_pins:OA().optional().default(8),w:lA.default(lA.parse(t.w??"5.3mm")),p:lA.default(lA.parse(t.p??"1.27mm")),pw:lA.default(lA.parse(t.pw??"0.6mm")),pl:lA.default(lA.parse(t.pl??"1.0mm")),legsoutside:qA().optional().default(t.legsoutside??!1),pillpads:qA().optional().default(t.pillpads??!1),silkscreen_stroke_width:OA().optional().default(.1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=lA.parse("0.6mm"),A.pl=lA.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),QFt=KF({}),vdA=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:A,pn:e,w:i,p:n,pl:o,legsoutside:s}=t,r=A/2,a=e<=r,g=r-1,c=n,I=c*g,l=s?o/2:-o/2;return a?{x:-i/2-l,y:I/2-(e-1)*c}:{x:i/2+l,y:-I/2+(e-r-1)*c}},hFt=t=>{const A=QFt.parse(t);return{circuitJson:WY(A),parameters:A}},WY=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=vdA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push(_V(r+1,a,g,t.pl,t.pw)):A.push(Ii(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,n=(t.num_pins/2-1)*t.p+t.pw+e,o=Mi(0,n/2+.4,n/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:-n/2},{x:-i/2,y:n/2},...DV.map(({x:r,y:a})=>({x:r*i/6,y:a*i/6+n/2})),{x:i/2,y:n/2},{x:i/2,y:-n/2},{x:-i/2,y:-n/2}]};return[...A,s,o]},Pte=et(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),EFt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const n=[],o=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=o:r.bottomside&&r.leftpin?s=o+1:r.bottomside&&r.rightpin?s=o*2:r.rightside&&r.bottompin?s=o*2+1:r.rightside&&r.toppin?s=o*3:r.topside&&r.rightpin?s=o*3+1:r.topside&&r.leftpin&&(s=o*4),n.push(-1);for(let a=0;a<t;a++)n[s]=a+1,e||!A?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return n},FdA=Li.extend({fn:H(),cc:qA().default(!0).optional(),ccw:qA().default(!0).optional(),startingpin:H().or(be(Pte)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(be(Pte)).optional(),num_pins:OA().optional().default(64),w:lA.optional(),h:lA.optional(),p:lA.default(lA.parse("0.5mm")),pw:lA.optional(),pl:lA.optional(),thermalpad:Gt([kA(!0),xV]).optional(),legsoutside:qA().default(!1)}),NdA=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},Kte=FdA.transform(NdA),uFt=["left","bottom","right","top"],dFt=t=>{const{pin_count:A,pn:e,w:i,h:n,p:o,pl:s,legsoutside:r}=t,a=A/4,g=uFt[Math.floor((e-1)/a)],c=(e-1)%a,I=o*(a-1),l=o*(a-1),B=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-B+.1,y:l/2-c*o,o:"vert"};case"bottom":return{x:-I/2+c*o,y:-n/2-B+.1,o:"horz"};case"right":return{x:i/2+B-.1,y:-l/2+c*o,o:"vert"};case"top":return{x:I/2-c*o,y:n/2+B-.1,o:"horz"};default:throw new Error("Invalid pin number")}},I1=t=>{const A=Kte.parse(t),e=[],i=EFt(A),n=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:c}=dFt({pin_count:A.num_pins,pn:r+1,w:A.w,h:A.h,p:A.p??.5,pl:A.pl,legsoutside:A.legsoutside});let I=A.pw,l=A.pl;c==="vert"&&([I,l]=[l,I]);const B=i[r+1];e.push(Ii(B,a,g,I,l))}if(A.thermalpad)if(typeof A.thermalpad=="boolean"){const r=A.p*(n-1)+A.pw,a=A.p*(n-1)+A.pw;e.push(Ii(["thermalpad"],0,0,r,a))}else e.push(Ii(["thermalpad"],0,0,A.thermalpad.x,A.thermalpad.y));const o=[];for(const[r,a,g]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const c=A.w/2*a,I=A.h/2*g;let l="none",B=c,C=I;const Q=A.pw*2;i[1]===1&&r==="top-left"?l="in1":i[n*4]===1&&r==="top-left"||i[n*3+1]===1&&r==="top-right"?l="in2":i[n*3]===1&&r==="top-right"||i[n]===1&&r==="bottom-left"?l="in1":i[n+1]===1&&r==="bottom-left"?l="in2":i[n*2]===1&&r==="bottom-right"?l="in1":i[n*2+1]===1&&r==="bottom-right"&&(l="in2");const h=l==="in1"?1:-1;if(A.legsoutside){const E=l==="in1"?A.pl/2:A.pw/2,u=l==="in1"?A.pw/2:A.pl/2;B+=E*a*h,C-=u*g*h}(l==="none"||A.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:c-Q*a,y:I},{x:c,y:I},{x:c,y:I-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(l==="in1"||l==="in2")&&!A.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:c-Q*a,y:I},{x:c-Q*a/2,y:I}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:c,y:I-Q*g/2},{x:c,y:I-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(l==="in1"||l==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:B-.2*-a,y:C+.2*h},{x:B,y:C},{x:B+.2*h*-a,y:C+.2},{x:B-.2*-a,y:C+.2*h}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Mi(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...o,s],parameters:A}};FdA.extend({}).transform(NdA);var pFt=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),I1(t)),fFt=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 I1(t)},yFt=t=>{t.legsoutside=!0;const A=Kte.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 I1(t)};FdA.extend({}).transform(NdA);var mFt=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),I1(t)),wFt=Li.extend({fn:H(),num_pins:OA().optional().default(8),w:lA.default(lA.parse("3.9mm")),p:lA.default(lA.parse("1.27mm")),pw:lA.optional(),pl:lA.optional(),legsoutside:qA().optional().default(!1),silkscreen_stroke_width:OA().optional().default(.1)}).transform(t=>(t.pw==null&&t.pl==null?(t.pw=lA.parse("0.51mm"),t.pl=lA.parse("1.1mm")):t.pw==null?t.pw=t.pl*(.51/1.1):t.pl==null&&(t.pl=t.pw*(1.1/.51)),t)),DFt=t=>{const{num_pins:A,pn:e,w:i,p:n}=t,o=A/2,s=e<=o,r=o-1,a=n,g=a*r,c=i+lA.parse("0.2mm"),I=(s?-1:1)*(c/2);return s?{x:I,y:g/2-(e-1)*a}:{x:I,y:-g/2+(e-o-1)*a}},SFt=t=>{const A=wFt.parse(t),e=[];for(let a=0;a<A.num_pins;a++){const{x:g,y:c}=DFt({num_pins:A.num_pins,pn:a+1,w:A.w,p:A.p,pl:A.pl,legsoutside:A.legsoutside});e.push(Ii(a+1,g,c,A.pl,A.pw))}const i=Math.min(1,A.p/2),n=A.w-(A.legsoutside?0:A.pl)-.2,o=(A.num_pins/2-1)*A.p+A.pw+i,s=Mi(0,o/2+.4,o/12),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:A.silkscreen_stroke_width??.1,route:[{x:-n/2,y:-o/2},{x:-n/2,y:o/2},...DV.map(({x:a,y:g})=>({x:a*n/6,y:g*n/6+o/2})),{x:n/2,y:o/2},{x:n/2,y:-o/2},{x:-n/2,y:-o/2}]};return{circuitJson:[...e,r,s],parameters:A}},bFt=Li.extend({fn:H(),num_pins:OA().optional().default(8),w:lA.default(lA.parse("3.0mm")),p:lA.default(lA.parse("0.5mm")),pw:lA.default(lA.parse("0.30mm")),pl:lA.default(lA.parse("1.45mm")),legsoutside:qA().optional().default(!0),silkscreen_stroke_width:OA().optional().default(.1)}),xFt=t=>{const{num_pins:A,pn:e,w:i,p:n,pl:o,legsoutside:s}=t,r=A/2,a=e<=r,g=r-1,c=n*g,I=s?o/2:-o/2;return a?{x:-i/2-I,y:c/2-(e-1)*n}:{x:i/2+I,y:-c/2+(e-r-1)*n}},_Ft=t=>{const A={...t},e=A.p,i=typeof e=="string"||typeof e=="number"?lA.parse(e):void 0,n=i!=null&&i<=lA.parse("0.5mm"),o=bFt.parse(A),s=[],r=n?o.w-lA.parse("0.15mm"):o.w;for(let B=0;B<o.num_pins;B++){const{x:C,y:Q}=xFt({num_pins:o.num_pins,pn:B+1,w:r,p:o.p,pl:o.pl,legsoutside:o.legsoutside});s.push(Ii(B+1,C,Q,o.pl,o.pw))}const a=Math.min(1,o.p/2),g=o.w-(o.legsoutside?0:o.pl*2)-.2,c=(o.num_pins/2-1)*o.p+o.pw+a,I=Mi(0,c/2+.4,c/12),l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:o.silkscreen_stroke_width??.1,route:[{x:-g/2,y:-c/2},{x:-g/2,y:c/2},...DV.map(({x:B,y:C})=>({x:B*g/6,y:C*g/6+c/2})),{x:g/2,y:c/2},{x:g/2,y:-c/2},{x:-g/2,y:-c/2}]};return{circuitJson:[...s,l,I],parameters:o}},kFt=Li.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("3.1mm"),h:H().default("2.0mm"),p:H().default("0.65mm"),pl:H().default("1.03mm"),pw:H().default("0.35mm"),string:H().optional()}),vFt=t=>{const A=kFt.parse({...t,fn:"sot363"}),e=lA.parse(A.w),i=lA.parse(A.h),n=lA.parse(A.p),o=lA.parse(A.pl),s=lA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=qte(B+1,e,n);r.push(Ii(B+1,C,Q,o,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/4,y:i/2+.1},{x:e/4,y:i/2+.1}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/4,y:-i/2-.1},{x:e/4,y:-i/2-.1}],stroke_width:.05,pcb_silkscreen_path_id:""},c=qte(1,e,n),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-o/2-.3,y:c.y},{x:c.x-o/2-.45,y:c.y+.15},{x:c.x-o/2-.45,y:c.y-.15},{x:c.x-o/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Mi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},qte=(t,A,e,i)=>t<=3?{x:-.84,y:e-(t-1)*e}:{x:.84,y:-e+(t-4)*e},FFt=Li.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("1.01mm"),h:H().default("1.45mm"),p:H().default("0.5mm"),pl:H().default("0.33mm"),pw:H().default("0.27mm"),string:H().optional()}),NFt=t=>{const A=FFt.parse({...t,fn:"sot886"}),e=lA.parse(A.w),i=lA.parse(A.h),n=lA.parse(A.p),o=lA.parse(A.pl),s=lA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=Ote(B+1,e,n,o);r.push(Ii(B+1,C,Q,o,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:""},c=Ote(1,e,n,o),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-o/2-.3,y:c.y},{x:c.x-o/2-.45,y:c.y+.15},{x:c.x-o/2-.45,y:c.y-.15},{x:c.x-o/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Mi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},Ote=(t,A,e,i)=>{const n=A/2-i/2;return t<=3?{x:-n,y:e-(t-1)*e}:{x:n,y:-e+(t-4)*e}},Wte=Li.extend({fn:H(),num_pins:OA().default(3),w:H().default("1.92mm"),h:H().default("2.74mm"),pl:H().default("1.32mm"),pw:H().default("0.6mm"),p:H().default("0.95mm"),string:H().optional()}),RFt=KF({p:"0.95mm",w:"1.6mm",legsoutside:!0}),GFt=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const n=RFt.parse({...t,num_pins:e});return{circuitJson:WY(n),parameters:n}}const i=Wte.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:LFt(i),parameters:i};if(i.num_pins===5)return{circuitJson:Vte(i),parameters:i};throw new Error("Invalid number of pins")},MFt=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}},LFt=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:n,y:o}=MFt({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(Ii(i+1,n,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Mi(0,Number.parseInt(t.h),.3);return[...A,e]},Zte=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")},Vte=t=>{const A=[];for(let I=1;I<=t.num_pins;I++){const{x:l,y:B}=Zte({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:I});A.push(Ii(I,l,B,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),n={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},o={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=Mi(0,i+.3,.3),r=Zte({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,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,n,o,c]},UFt=Wte.extend({}),HFt=t=>{const A=UFt.parse({...t,num_pins:5});return{circuitJson:Vte(A),parameters:A}},YFt=[{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}],JFt=KF({}),TFt=t=>{const A=JFt.parse(t),e=[];for(let I=0;I<A.num_pins;I++){const{x:l,y:B}=vdA({num_pins:A.num_pins,pn:I+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(Ii(I+1,l,B,A.pl??"1mm",A.pw??"0.6mm"))}const i=Math.min(1,A.p/2),n=A.w+i,o=(A.num_pins/2-1)*A.p+A.pw+i,s=[];for(const I of YFt){const{dx:l,dy:B}=I;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:l*n/2-l*A.p,y:B*o/2},{x:l*n/2,y:B*o/2},{x:l*n/2,y:B*o/2-B*A.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const r=A.p/4,a=-n/2-r/2,g=o/2-A.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:a,y:g},{x:a-r,y:g+r},{x:a-r,y:g-r},{x:a,y:g}],stroke_width:.1});const c=Mi(0,o/2+.4,o/12);return{circuitJson:[...e,c,...s],parameters:A}},qF=({fs:t,pn:A,anchor_x:e,anchor_y:i,textalign:n="center",orthogonal:o=!1,verticallyinverted:s=!1,layer:r="top"})=>{let a=0;o&&s?a=270:s?a=180:o?a=90:a=0;let g="center";return n==="left"&&(s?g="center_right":g="center_left"),n==="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 jte({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 PFt=Li.extend({fn:H(),num_pins:OA().optional().default(6),rows:Gt([H(),OA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:lA.default("0.1in").describe("pitch"),id:lA.default("1.0mm").describe("inner diameter"),od:lA.default("1.5mm").describe("outer diameter"),male:qA().optional().describe("for male pin headers"),female:qA().optional().describe("for female pin headers"),smd:qA().optional().describe("surface mount device"),surfacemount:qA().optional().describe("surface mount device (verbose)"),rightangle:qA().optional().describe("right angle"),pw:lA.optional().default("1.0mm").describe("pad width for SMD"),pl:lA.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:qA().optional().default(!1),pinlabeltextaligncenter:qA().optional().default(!1),pinlabeltextalignright:qA().optional().default(!1),pinlabelverticallyinverted:qA().optional().default(!1),pinlabelorthogonal:qA().optional().default(!1),nosquareplating:qA().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:qA().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:qA().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:qA().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=jte(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:jt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),KFt=t=>{const A=PFt.parse(t),{p:e,id:i,od:n,rows:o,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:c,pinlabeltextalignright:I,nopinlabels:l,doublesidedpinlabel:B,bottomsidepinlabel:C}=A;let Q="center";c?Q="left":I&&(Q="right");const h=[],E=Math.ceil(s/o),u=-e,d=({xoff:S,yoff:_,od:x,anchorSide:G,smd:F,pw:L,pl:Y})=>{let J=0,O=0;if(F){const Z=x/5;switch(G){case"right":J=L/2+Z;break;case"top":O=Y/2+Z;break;case"bottom":O=-(Y/2+Z);break;case"left":J=-(L/2+Z);break}}else{const Z=x*.75;switch(G){case"right":J=Z;break;case"top":O=Z;break;case"bottom":O=-Z;break;case"left":J=-Z;break}}return{anchor_x:S+J,anchor_y:_+O}},f=(S,_,x)=>{A.smd?h.push(Ii(S,_,x,A.pw,A.pl)):S===1&&!A.nosquareplating?h.push(YD({pn:S,x:_,y:x,holeDiameter:i,rectPadWidth:n,rectPadHeight:n})):h.push(vo(S,_,x,i,n));const{anchor_x:G,anchor_y:F}=d({xoff:_,yoff:x,od:n,anchorSide:r,smd:A.smd,pw:A.pw,pl:A.pl});l||(C?h.push(qF({fs:n/5,pn:S,anchor_x:G,anchor_y:F,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):h.push(qF({fs:n/5,pn:S,anchor_x:G,anchor_y:F,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),B&&h.push(qF({fs:n/5,pn:S,anchor_x:G,anchor_y:F,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},m=new Set,w=o>2&&E>2;if(o===1){const S=-((s-1)/2)*e;for(let _=0;_<s;_++){const x=_+1,G=S+_*e,F=`${G},0`;if(m.has(F))throw new Error(`Overlap at ${F}`);m.add(F),f(x,G,0)}}else if(w){const S=-((E-1)/2)*e;let _=1;for(let x=0;x<o&&_<=s;x++)for(let G=0;G<E&&_<=s;G++){const F=S+G*e,L=x*u,Y=`${F},${L}`;if(m.has(Y))throw new Error(`Overlap at ${Y}`);m.add(Y),f(_++,F,L)}}else{const S=-((E-1)/2)*e;let _=1,x=0,G=o-1,F=0,L=E-1;for(;_<=s&&x<=G&&F<=L;){for(let Y=x;Y<=G&&_<=s;Y++){const J=S+F*e,O=Y*u,Z=`${J},${O}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(_++,J,O)}F++;for(let Y=F;Y<=L&&_<=s;Y++){const J=S+Y*e,O=G*u,Z=`${J},${O}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(_++,J,O)}if(G--,F<=L){for(let Y=G;Y>=x&&_<=s;Y--){const J=S+L*e,O=Y*u,Z=`${J},${O}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(_++,J,O)}L--}if(x<=G){for(let Y=L;Y>=F&&_<=s;Y--){const J=S+Y*e,O=x*u,Z=`${J},${O}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(_++,J,O)}x++}}if(_-1<s)throw new Error(`Missing pins: assigned ${_-1}, expected ${s}`)}const D=Mi(0,e,.5);return{circuitJson:[...h,D],parameters:A}},qFt=Li.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("2.1mm"),h:H().default("2.45mm"),p:H().default("0.5mm"),pl:H().default("0.675mm"),pw:H().default("0.35mm"),string:H().optional()}),OFt=t=>{const A=qFt.parse({...t,fn:"sot563"}),e=lA.parse(A.w),i=lA.parse(A.h),n=lA.parse(A.p),o=lA.parse(A.pl),s=lA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=zte(B+1,e,n,o);r.push(Ii(B+1,C,Q,o,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:""},c=zte(1,e,n,o),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-o/2-.3,y:c.y},{x:c.x-o/2-.45,y:c.y+.15},{x:c.x-o/2-.45,y:c.y-.15},{x:c.x-o/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Mi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},zte=(t,A,e,i)=>{const n=A/2-i/2;return t<=3?{x:-n,y:e-(t-1)*e}:{x:n,y:-e+(t-4)*e}},WFt=KF({p:"1.27mm",w:"3.9mm",legsoutside:!0}),ZFt=t=>{const A=WFt.parse({...t,num_pins:8});return{circuitJson:WY(A),parameters:A}},VFt=KF({p:"1.27mm",w:"7.5mm",legsoutside:!0}),jFt=t=>{const A=VFt.parse({...t,num_pins:16});return{circuitJson:WY(A),parameters:A}},zFt=Li.extend({fn:H(),num_pins:kA(3).default(3),w:H().default("1.2mm"),h:H().default("1.2mm"),pw:H().default("0.40mm"),pl:H().default("0.45mm"),p:H().default("0.575mm")}),XFt=t=>{const A=zFt.parse(t),e=ANt(A),i=Mi(0,lA.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},$Ft=t=>{const{pn:A,p:e}=t;return A===1?{x:e,y:0}:A===2?{x:-e,y:-.4}:{x:-e,y:.4}},ANt=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:n}=$Ft({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(Ii(e+1,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},eNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("2.36mm"),h:H().default("1.22mm"),pl:H().default("0.9mm"),pw:H().default("1.2mm"),p:H().default("3.30mm")}),tNt=t=>{const A=eNt.parse(t),e=Mi(0,lA.parse(A.h)/4+.4,.3);return{circuitJson:nNt(A).concat(e),parameters:A}},iNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},nNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=iNt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},oNt=Li.extend({fn:H(),p:lA.optional().default("2.54mm"),id:lA.optional().default("0.7mm"),od:lA.optional().default("1.4mm")}),sNt=t=>{const A=oNt.parse(t),{p:e,id:i,od:n}=A,o=[vo(1,-e/2,0,i,n),vo(2,e/2,0,i,n)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2+n+i/2,y:0},{x:e/2-n-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},r=Mi(0,1.5,.5);return{circuitJson:[...o,s,r],parameters:A}},rNt=(t,A,e,i,n,o=.1)=>{const s=[],r=[],a=Math.max(1,Math.ceil(Math.PI*e/o)),g=Math.PI/a;for(let c=0;c<=a;c++){const I=c*g,l=t+Math.cos(I)*e,B=A+Math.sin(I)*e;l<t-i&&B>=A-n/2&&B<=A+n/2||s.push({x:l,y:B})}for(let c=0;c<=a;c++){const I=Math.PI+c*g,l=t+Math.cos(I)*e,B=A+Math.sin(I)*e;l<t-i&&B>=A-n/2&&B<=A+n/2||r.push({x:l,y:B})}return{topArc:s,bottomArc:r}},aNt=Li.extend({fn:H(),p:lA.optional().default("5mm"),id:lA.optional().default("0.8mm"),od:lA.optional().default("1.6mm"),ceramic:qA().optional(),electrolytic:qA().optional(),polarized:qA().optional()}),gNt=t=>{const A=aNt.parse(t),{p:e,id:i,od:n}=A;i===.8&&n===1.6&&(A.id=e===5?.8:e*.25,A.od=e===5?1.6:e*.5);const o=[vo(1,-e/2,0,A.id,A.od),vo(2,e/2,0,A.id,A.od)],s=e+.1,{topArc:r,bottomArc:a}=rNt(0,0,s,A.od/2,A.od),g=.02*e,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:g,pcb_silkscreen_path_id:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:g,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:s},{x:0,y:-s}],stroke_width:g,pcb_silkscreen_path_id:""},B=.1*e,C=-(e+B+.04*e),Q=s-B-.08*e,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C-B,y:Q},{x:C+B,y:Q}],stroke_width:g,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C,y:Q-B},{x:C,y:Q+B}],stroke_width:g,pcb_silkscreen_path_id:""},u=Mi(0,s+.12*e,.1*e),d=[...o,c,I,l,u];return(A.electrolytic===!0||A.polarized===!0)&&d.push(h,E),{circuitJson:d,parameters:A}},OF=(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}),cNt=Li.extend({fn:kA("pushbutton"),w:lA.default(4.5),h:lA.default(6.5),id:lA.default(1),od:lA.default(1.2)}),INt=t=>{const A=cNt.parse(t),e=A.w,i=A.h,n=A.id,o=[vo(1,-e/2,i/2,n,n*1.5),vo(2,-e/2,-i/2,n,n*1.5),vo(3,e/2,-i/2,n,n*1.5),vo(4,e/2,i/2,n,n*1.5)],s=[OF([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),OF([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),OF([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),OF([{x:e/2,y:0},{x:e/5,y:0}])],r=Mi(0,i/2+.4,.5);return{circuitJson:[...o,...s,r],parameters:A}},Xte=Li.extend({fn:H(),w:lA.default("22.58mm"),h:lA.optional(),left:lA.optional().default(20),right:lA.optional().default(20),top:lA.optional().default(2),bottom:lA.optional().default(2),p:lA.default(lA.parse("2.54mm")),pw:lA.default(lA.parse("1.6mm")),pl:lA.default(lA.parse("2.4mm")),innerhole:qA().default(!1),innerholeedgedistance:lA.default(lA.parse("1.61mm")),silkscreenlabels:qA().default(!1),silkscreenlabelmargin:lA.default(lA.parse("0.1mm"))}),lNt=t=>{const A=Xte.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},kV=(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},BNt=t=>{const A=Xte.parse(t),e=A.h??lNt(A),i=[],n=[],o=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),I=`pin${g}`.length*.7/2;if(A.right){const Q=-((A.right-1)/2)*A.p;for(let h=0;h<A.right;h++){if(h===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=kV(A.w/2-A.pl*1.4,Q+h*A.p,"right")),i.push(Ii(h+1+A.left+(A.bottom??0),A.w/2-A.pl/2,Q+h*A.p,A.pl,A.pw)),A.silkscreenlabels){const E=h+1+A.left+(A.bottom??0),u=`pin${E}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${E}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl-(I+A.silkscreenlabelmargin),y:Q+h*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(vo(h+1+A.left+(A.bottom??0)+g,A.w/2,Q+h*A.p,r,a)),n.push(vo(h+1+A.left+(A.bottom??0)+g*2,A.w/2-A.innerholeedgedistance,Q+h*A.p,r,a)))}}if(A.left){const Q=(A.left-1)/2*A.p;for(let h=0;h<A.left;h++){if(h===0&&!A.silkscreenlabels&&(s=kV(-A.w/2+A.pl*1.4,Q-h*A.p,"left")),i.push(Ii(h+1,-A.w/2+A.pl/2,Q-h*A.p,A.pl,A.pw)),A.silkscreenlabels){const E=h+1,u=`pin${E}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${E}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl+(I+A.silkscreenlabelmargin),y:Q-h*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(vo(h+1+g,-A.w/2,Q-h*A.p,r,a)),n.push(vo(h+1+g*2,-A.w/2+A.innerholeedgedistance,Q-h*A.p,r,a)))}}if(A.top){const Q=(A.top-1)/2*A.p;for(let h=0;h<A.top;h++){if(h===0&&!A.left&&!A.bottom&&!A.right&&!A.silkscreenlabels&&(s=kV(Q-h*A.p,e/2-A.pl*1.4,"top")),i.push(Ii(h+1+A.left+A.right+(A.bottom??0),Q-h*A.p,e/2-A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const E=h+1+A.left+A.right+(A.bottom??0),u=`pin${E}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${E}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q-h*A.p,y:e/2-A.pl-(I+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(n.push(vo(h+1+A.left+A.right+(A.bottom??0)+g,Q-h*A.p,e/2,r,a)),n.push(vo(h+1+A.left+A.right+(A.bottom??0)+g*2,Q-h*A.p,e/2-A.innerholeedgedistance,r,a)))}}if(A.bottom){const Q=-((A.bottom-1)/2)*A.p;for(let h=0;h<A.bottom;h++){if(h===0&&!A.left&&!A.silkscreenlabels&&(s=kV(Q+h*A.p,-e/2+A.pl*1.4,"bottom")),i.push(Ii(h+1+A.left,Q+h*A.p,-e/2+A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const E=h+1+A.left,u=`pin${E}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${E}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q+h*A.p,y:-e/2+A.pl+(I+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(n.push(vo(h+1+A.left+g,Q+h*A.p,-e/2,r,a)),n.push(vo(h+1+A.left+g*2,Q+h*A.p,-e/2+A.innerholeedgedistance,r,a)))}}const l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2,y: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=Mi(0,e/1.8,e/25);return{circuitJson:[...i,...n,...o,B,...A.silkscreenlabels?[]:[l],C],parameters:A}},$te=Li.extend({fn:H(),w:lA.default("22.58mm"),h:lA.optional(),left:lA.optional().default(20),right:lA.optional().default(20),top:lA.optional().default(2),bottom:lA.optional().default(2),p:lA.default(lA.parse("2.54mm")),pw:lA.default(lA.parse("1.6mm")),pl:lA.default(lA.parse("3.2mm")),innerhole:qA().default(!1),innerholeedgedistance:lA.default(lA.parse("1.61mm"))}),CNt=t=>{const A=$te.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},QNt=(t,A,e,i=1,n=.6)=>{const o=i/2,s=n/2;return{left:[{x:t+o,y:A},{x:t-o,y:A+s},{x:t-o,y:A-s},{x:t+o,y:A}],right:[{x:t-o,y:A},{x:t+o,y:A+s},{x:t+o,y:A-s},{x:t-o,y:A}],top:[{x:t,y:A-o},{x:t-s,y:A+o},{x:t+s,y:A+o},{x:t,y:A-o}],bottom:[{x:t,y:A+o},{x:t-s,y:A-o},{x:t+s,y:A-o},{x:t,y:A+o}]}[e]},hNt=t=>{const A=$te.parse(t),e=A.h??CNt(A),i=[],n=[],o=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],c=1;if(A.left){const C=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++)Q===0&&(g=QNt(-A.w/2-A.pl/2,C-Q*A.p,"left")),i.push(Ii(c,-A.w/2+A.pl/2,C-Q*A.p,A.pl,A.pw)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:C-Q*A.p},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&o.push(vo(c+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(Ii(c,C-Q*A.p,-e/2+A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C-Q*A.p,y:-e/2+A.pl/2-3.2},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&o.push(vo(c+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(Ii(c,A.w/2-A.pl/2,C+Q*A.p,A.pl,A.pw)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:C+Q*A.p},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&o.push(vo(c+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(Ii(c,C+Q*A.p,e/2-A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C+Q*A.p,y:e/2-A.pl/2+3.2},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&o.push(vo(c+a,C+Q*A.p,e/2-A.innerholeedgedistance,s,r))}const I={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:g,stroke_width:.1},l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-A.pl/3,y: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"},B=Mi(0,e/1.8,e/25);return{circuitJson:[...o,...i,...n,l,I,B],parameters:A}},ENt=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),I1(t)),Aie=Li.extend({fn:H(),w:lA.default("10mm"),h:lA.optional(),left:lA.optional().default(20),right:lA.optional().default(20),top:lA.optional().default(0),bottom:lA.optional().default(0),p:lA.default(lA.parse("2.54mm")),id:lA.optional().default(lA.parse("1mm")),od:lA.optional().default(lA.parse("1.5mm"))}),uNt=t=>{const A=Aie.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},vV=(t,A,e,i=1,n=.6)=>{const o=i/2,s=n/2;return{left:[{x:t+o,y:A},{x:t-o,y:A+s},{x:t-o,y:A-s},{x:t+o,y:A}],right:[{x:t-o,y:A},{x:t+o,y:A+s},{x:t+o,y:A-s},{x:t-o,y:A}],top:[{x:t,y:A-o},{x:t-s,y:A+o},{x:t+s,y:A+o},{x:t,y:A-o}],bottom:[{x:t,y:A+o},{x:t-s,y:A-o},{x:t+s,y:A-o},{x:t,y:A+o}]}[e]},dNt=t=>{const A=Aie.parse(t),e=A.h??uNt(A),i=[],n=A.id,o=A.od;let s=[];if(A.right){const c=-((A.right-1)/2)*A.p;for(let I=0;I<A.right;I++)I===0&&!A.left&&!A.bottom&&(s=vV(A.w/2+o*1.4,c+I*A.p,"right")),i.push(vo(I+1+A.left+(A.bottom??0),A.w/2,c+I*A.p,n,o))}if(A.left){const c=-((A.left-1)/2)*A.p;for(let I=0;I<A.left;I++)I===A.left-1&&(s=vV(-A.w/2-o*1.4,c+I*A.p,"left")),i.push(vo(I+1,-A.w/2,c+I*A.p,n,o))}if(A.top){const c=-((A.top-1)/2)*A.p;for(let I=0;I<A.top;I++)I===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=vV(c+I*A.p,e/2+o*1.4,"top")),i.push(vo(I+1+A.right+(A.bottom??0)+A.left,c+I*A.p,e/2,n,o))}if(A.bottom){const c=-((A.bottom-1)/2)*A.p;for(let I=0;I<A.bottom;I++)I===0&&!A.left&&(s=vV(c+I*A.p,-e/2-o*1.4,"bottom")),i.push(vo(I+1+A.left,c+I*A.p,-e/2,n,o))}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-o,y:e/2+o},{x:A.w/2+o,y:e/2+o},{x:A.w/2+o,y:-e/2-o},{x:-A.w/2-o,y:-e/2-o},{x:-A.w/2-o,y:e/2+o}],stroke_width:.1,layer:"top"},g=Mi(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},eie=(t,A,e,i)=>Array.from({length:25},(n,o)=>{const s=o/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*e,y:A+Math.sin(s)*e}}),pNt=Li.extend({fn:H(),p:lA.optional().default("4.88mm"),id:lA.optional().default("0.8mm"),od:lA.optional().default("1.5mm"),w:lA.optional().default("5.6mm"),h:lA.optional().default("3.5mm")}),fNt=t=>{const A=pNt.parse(t),{p:e,id:i,od:n,w:o,h:s}=A,r=s/2,a=[vo(1,-e/2,0,i,n),vo(2,e/2,0,i,n)],g=eie(-o/2,0,r,"left"),c=eie(o/2,0,r,"right"),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...g,...g.slice(1).reverse(),{x:-o/2,y:-s/2},{x:o/2,y:-s/2},...c,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},l=Mi(0,e/4,.5);return{circuitJson:[...a,I,l],parameters:A}};Li.extend({w:lA,h:lA});var yNt=t=>{const{w:A,h:e}=t,i=Lr(A),n=Lr(e);return{circuitJson:[Ii(1,0,0,i,n),Mi(0,n/2+.5,.2)],parameters:t}},ZY=(t,A,e,i,n,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:A,y:e,outer_width:Lr(n),outer_height:Lr(o),hole_width:Lr(i),hole_height:Lr(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),mNt=Li.extend({fn:H(),num_pins:Gt([kA(3),kA(2)]).default(3),p:H().default("1.27mm"),id:H().default("0.72mm"),od:H().default("0.95mm"),w:H().default("4.5mm"),h:H().default("4.5mm"),inline:qA().default(!1),string:H().optional()}),wNt=(t,A,e)=>Array.from({length:25},(i,n)=>{const o=n/24*Math.PI;return{x:t+Math.cos(o)*e,y:A+Math.sin(o)*e}}),DNt=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=mNt.parse({...t,num_pins:e}),{p:n,id:o,od:s,w:r,h:a,inline:g}=i,c=Number.parseFloat(a)/2,I=Number.parseFloat(n),l=Number.parseFloat(o),B=Number.parseFloat(s),C=B,Q=B*(1.5/1.05);let h=[];if(i.num_pins===3)g?h=[YD({pn:1,x:-I,y:c-I,holeDiameter:l,rectPadWidth:B,rectPadHeight:Q}),ZY(2,0,c-I,l,C,Q),ZY(3,I,c-I,l,C,Q)]:h=[YD({pn:1,x:-I,y:c-I,holeDiameter:l,rectPadWidth:B,rectPadHeight:B}),vo(2,0,c,l,B),vo(3,I,c-I,l,B)];else if(i.num_pins===2)h=[YD({pn:1,x:-I,y:c-I,holeDiameter:l,rectPadWidth:C,rectPadHeight:Q}),ZY(2,I,c-I,l,C,Q)];else throw new Error("Invalid number of pins for TO-92");const E=Number.parseFloat(r)/2,u=wNt(0,c,E),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...u,{x:-E,y:0},{x:E,y:0},u[0]],stroke_width:.1,pcb_silkscreen_path_id:""},f=Mi(0,c+1,.5);return{circuitJson:[...h,d,f],parameters:i}},SNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("2.15mm"),h:H().default("1.20mm"),pl:H().default("0.5mm"),pw:H().default("0.6mm"),p:H().default("1.4mm")}),bNt=t=>{const A=SNt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:_Nt(A).concat(i,e),parameters:A}},xNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},_Nt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=xNt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},kNt=KF({w:"7.05mm",p:"1.27mm",pw:"0.65mm",pl:"1.975mm"}),vNt=t=>{const A=kNt.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=vdA({num_pins:A.num_pins,pn:s+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(Ii(s+1,r,a,A.pl??"1.5mm",A.pw??"0.6mm"))}const i=(A.num_pins/2-1)*A.p+A.pw,n=Mi(0,i/2+1,i/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-A.w/3,y:i/2+.4},{x:A.w/3,y:i/2+.4}],stroke_width:.1};return{circuitJson:[...e,n,o],parameters:A}},FNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("5.0mm"),h:H().default("2.30mm"),pl:H().default("1.25mm"),pw:H().default("2mm"),p:H().default("3.75mm")}),NNt=t=>{const A=FNt.parse(t),e=Mi(0,lA.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2+.5,y:lA.parse(A.h)/2+.5},{x:-lA.parse(A.w)/2-.5,y:lA.parse(A.h)/2+.5},{x:-lA.parse(A.w)/2-.5,y:-lA.parse(A.h)/2-.5},{x:lA.parse(A.p)/2+.5,y:-lA.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:GNt(A).concat(i,e),parameters:A}},RNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},GNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=RNt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},MNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("1.2mm"),pw:H().default("1.2mm"),p:H().default("2.9mm")}),LNt=t=>{const A=MNt.parse(t),e=Mi(0,lA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:HNt(A).concat(i,e),parameters:A}},UNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},HNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=UNt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},YNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.30mm"),h:H().default("1.80mm"),pl:H().default("0.60mm"),pw:H().default("0.45mm"),p:H().default("2.1mm")}),JNt=t=>{const A=YNt.parse(t),e=Mi(0,lA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:PNt(A).concat(i,e),parameters:A}},TNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},PNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=TNt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},KNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.4mm"),h:H().default("0.9mm"),pl:H().default("0.36mm"),pw:H().default("0.25mm"),p:H().default("0.85mm")}),qNt=t=>{const A=KNt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2+.15,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.15,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.15,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2+.15,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:WNt(A).concat(i,e),parameters:A}},ONt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},WNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=ONt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ZNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.3mm"),h:H().default("0.9mm"),pl:H().default("0.4mm"),pw:H().default("0.7mm"),p:H().default("0.7mm")}),VNt=t=>{const A=ZNt.parse(t),e=Mi(0,lA.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2+.2,y:lA.parse(A.h)/2+.2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2+.2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2-.2},{x:lA.parse(A.p)/2+.2,y:-lA.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:zNt(A).concat(i,e),parameters:A}},jNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},zNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=jNt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},XNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3,05mm"),h:H().default("1.65mm"),pl:H().default("0.6mm"),pw:H().default("0.6mm"),pad_spacing:H().default("2.2mm")}),$Nt=t=>{const A=XNt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.pad_spacing)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.pad_spacing)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eRt(A).concat(i,e),parameters:A}},ARt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=ARt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("1.10mm"),pw:H().default("1.10mm"),p:H().default("2.8mm")}),iRt=t=>{const A=tRt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:oRt(A).concat(i,e),parameters:A}},nRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},oRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=nRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},sRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("0.91mm"),pw:H().default("1.22mm"),p:H().default("3.146mm")}),rRt=t=>{const A=sRt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gRt(A).concat(i,e),parameters:A}},aRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},gRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=aRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},cRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.80mm"),h:H().default("1.00mm"),pl:H().default("0.66mm"),pw:H().default("0.5mm"),p:H().default("0.8mm")}),IRt=t=>{const A=cRt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:BRt(A).concat(i,e),parameters:A}},lRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},BRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=lRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},CRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("6.2mm"),h:H().default("3.4mm"),pl:H().default("1.4mm"),pw:H().default("2.1mm"),p:H().default("4.4mm")}),QRt=t=>{const A=CRt.parse(t),e=Mi(0,lA.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ERt(A).concat(i,e),parameters:A}},hRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},ERt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=hRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},uRt=Li.extend({fn:H(),num_pins:Gt([kA(3),kA(5)]).default(3),w:H().default("4.20mm"),h:H().default("4.80mm"),pl:H().default("1.3mm"),pw:H().default("0.9mm"),p:H().default("1.5mm"),string:H().optional()}),dRt=t=>{const A=[],e=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),n=Number.parseFloat(t.w),o=Number.parseFloat(t.pl),s=.175,r=(o-(o+s))/2;A.push(Ii(1,-n/2+r,e,o,i),Ii(2,-n/2,0,o+s,i),Ii(3,-n/2+r,-e,o,i));const a=Mi(0,0,.3),g=Number.parseFloat(t.w)/2-1,c=Number.parseFloat(t.h)/2,I={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-g,y:c},{x:g,y:c},{x:g,y:c/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},l={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-g,y:-c},{x:g,y:-c},{x:g,y:-c/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,I,l,a]},pRt=t=>{const A=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),A.push(Ii(1,-1.85,-1.5,1.5,.7),Ii(2,-1.85,1.5,1.5,.7),Ii(3,0,0,.8,2),Ii(4,1.85,-1.5,1.5,.7),Ii(5,1.85,1.5,1.5,.7));const e=Mi(0,Number.parseFloat(t.h)/2+.5,.3),i=Number.parseFloat(t.w)/2-1,n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i,y:n}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n},{x:i,y:-n}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},fRt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=uRt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:dRt(i),parameters:i};if(i.num_pins===5)return{circuitJson:pRt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},yRt=Li.extend({fn:H(),p:lA.optional().default("5.0mm"),id:lA.optional().default("1.0mm"),od:lA.optional().default("1.9mm"),w:lA.optional().default("13mm"),h:lA.optional().default("7mm"),num_pins:OA().optional(),string:H().optional()}),mRt=t=>{const A=yRt.parse(t),{fn:e,id:i,od:n,w:o,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,c=o/2,I=s/2,l=2.5,B=o*.4,C=Math.max(l,B/(a-1)),Q=Array.from({length:a},(m,w)=>{const D=a%2===0?(w-a/2+.5)*C:(w-Math.floor(a/2))*C;return vo(w+1,D,g,i,n)}),h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:-I},{x:c,y:-I},{x:c,y:I},{x:-c,y:I},{x:-c,y:-I}],stroke_width:.1,pcb_silkscreen_path_id:""},E=-I+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:E},{x:c,y:E}],stroke_width:.1,pcb_silkscreen_path_id:""},d=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:E},{x:-o/6,y:I}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:E},{x:o/6,y:I}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Mi(0,s/2+.6,.5);return{circuitJson:[...Q,h,u,...d,f],parameters:{...A,p:C}}},wRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("5.40mm"),h:H().default("2.30mm"),pl:H().default("1.30mm"),pw:H().default("1.70mm"),p:H().default("3.5mm")}),DRt=t=>{const A=wRt.parse(t),e=Mi(0,lA.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bRt(A).concat(i,e),parameters:A}},SRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},bRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=SRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},xRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.90mm"),h:H().default("1.33mm"),pl:H().default("0.5mm"),pw:H().default("0.7mm"),p:H().default("0.8mm")}),_Rt=t=>{const A=xRt.parse(t),e=Mi(0,lA.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2+.1,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2+.1,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:vRt(A).concat(i,e),parameters:A}},kRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},vRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=kRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},FRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("7.0mm"),h:H().default("3.35mm"),pl:H().default("1.50mm"),pw:H().default("2.70mm"),p:H().default("4.8mm")}),NRt=t=>{const A=FRt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:GRt(A).concat(i,e),parameters:A}},RRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},GRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=RRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},MRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.0mm"),h:H().default("1.80mm"),pl:H().default("0.80mm"),pw:H().default("1.20mm"),p:H().default("1.6mm")}),LRt=t=>{const A=MRt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:HRt(A).concat(i,e),parameters:A}},URt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},HRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=URt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},YRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("7.10mm"),h:H().default("3.40mm"),pl:H().default("2.45mm"),pw:H().default("1.80mm"),p:H().default("4.05mm")}),JRt=t=>{const A=YRt.parse(t),e=Mi(0,lA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.5,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.5,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:PRt(A).concat(i,e),parameters:A}},TRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},PRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=TRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},KRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.80mm"),h:H().default("2.10mm"),pl:H().default("1.30mm"),pw:H().default("1.40mm"),p:H().default("2.9mm")}),qRt=t=>{const A=KRt.parse(t),e=Mi(0,lA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:WRt(A).concat(i,e),parameters:A}},ORt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},WRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=ORt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ZRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("7.30mm"),h:H().default("4.40mm"),pl:H().default("2.50mm"),pw:H().default("2.30mm"),p:H().default("4.30mm")}),VRt=t=>{const A=ZRt.parse(t),e=Mi(0,lA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:zRt(A).concat(i,e),parameters:A}},jRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},zRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=jRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},XRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("10.70mm"),h:H().default("6.60mm"),pl:H().default("3.30mm"),pw:H().default("2.50mm"),p:H().default("6.80mm")}),$Rt=t=>{const A=XRt.parse(t),e=Mi(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2-.8},{x:-lA.parse(A.w)/2-.8,y:lA.parse(A.h)/2-.8},{x:-lA.parse(A.w)/2-.8,y:-lA.parse(A.h)/2+.8},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eGt(A).concat(i,e),parameters:A}},AGt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=AGt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tGt=Li.extend({fn:H(),num_pins:OA().default(4),w:H().default("8.50mm"),h:H().default("6.90mm"),pl:H().default("2mm"),pw:H().default("1.5mm"),p:H().default("2.30mm"),string:H().optional()}),iGt=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const n=sGt.parse({...t,num_pins:e});return{circuitJson:WY(n),parameters:n}}const i=tGt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:oGt(i),parameters:i};if(i.num_pins===5)return{circuitJson:aGt(i),parameters:i};if(i.num_pins===6)return{circuitJson:cGt(i),parameters:i};throw new Error("Invalid number of pins")},nGt=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}},oGt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=nGt({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)}),c=r===3?3.8:Number.parseFloat(t.pw);A.push(Ii(r+1,a,g,Number.parseFloat(t.pl),c))}const e=Mi(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i,y:n},{x:i,y:n/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:-n},{x:i,y:-n},{x:i,y:-n/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},sGt=KF({p:"0.90mm",w:"2.8mm",legsoutside:!0}),rGt=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")},aGt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=rGt({h:Number.parseFloat(t.h),p:1.5,pn:r,w:Number.parseFloat(t.w)});let c=Number.parseFloat(t.pw),I=Number.parseFloat(t.pl);r===5?(c=3.4,I=1.8):(c=1,I=2.2),A.push(Ii(r,a,g,I,c))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,n={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},o={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=Mi(0,0,.3);return[...A,n,o,s]},gGt=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")},cGt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=gGt({h:Number.parseFloat(t.h),p:1.3,pn:r,w:8.7});let c=Number.parseFloat(t.pw),I=Number.parseFloat(t.pl);r===6?(c=3.4,I=2.15):(c=.6,I=2.2),A.push(Ii(r,a,g,I,c))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,n={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},o={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=Mi(0,0,.3);return[...A,n,o,s]},IGt=Li.extend({fn:H(),num_pins:OA().default(3),w:H().default("3.40mm"),h:H().default("3.30mm"),pl:H().default("1mm"),pw:H().default("0.7mm"),p:H().default("1.2mm"),string:H().optional()}),lGt=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=IGt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:CGt(i),parameters:i};throw new Error("Invalid number of pins")},BGt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},CGt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=BGt({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(Ii(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Mi(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-1,n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i+.3,y:n},{x:i+.3,y:n/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:-n},{x:i+.3,y:-n},{x:i+.3,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},QGt=Li.extend({fn:H(),num_pins:Gt([kA(3),kA(2)]).default(3),p:H().default("1.27mm"),id:H().default("0.72mm"),od:H().default("0.95mm"),w:H().default("2.5mm"),h:H().default("4.2mm"),string:H().optional()}),hGt=t=>{const{p:A,id:e,od:i,w:n,h:o}=t,s=Number.parseFloat(o)/2,r=Number.parseFloat(A);return[vo(1,-r,s-r,e,i),vo(2,0,s-r,e,i),vo(3,r,s-r,e,i)]},EGt=t=>{const{p:A,id:e,od:i,h:n}=t,o=Number.parseFloat(n)/2,s=Number.parseFloat(A);return[vo(1,-s,o-s,e,i),vo(2,s,o-s,e,i)]},uGt=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=QGt.parse({...t,num_pins:e});let n=[];if(i.num_pins===3)n=hGt(i);else if(i.num_pins===2)n=EGt(i);else throw new Error("Invalid number of pins for TO-92");const o=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o,y:o-s},{x:-1.9,y:0},{x:1.9,y:0},{x:o,y:o-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-o,y:o-s}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Mi(0,o+1,.5);return{circuitJson:[...n,r,a],parameters:i}},dGt=Li.extend({fn:H(),p:lA.optional(),id:lA.optional(),pw:lA.optional(),pl:lA.optional(),w:lA.optional(),h:lA.optional(),sh:qA().optional().describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:qA().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:H().optional()}),pGt={ph:{p:lA.parse("2.2mm"),id:lA.parse("0.70mm"),pw:lA.parse("1.20mm"),pl:lA.parse("1.20mm"),w:lA.parse("6mm"),h:lA.parse("5mm")},sh:{p:lA.parse("1mm"),pw:lA.parse("0.6mm"),pl:lA.parse("1.55mm"),w:lA.parse("5.8mm"),h:lA.parse("7.8mm")}};function fGt(t){return t.sh?"sh":(t.ph,"ph")}function yGt(t,A,e,i,n,o){const s=[];if(t==="ph"){const r=-((A-1)/2)*e;for(let a=0;a<A;a++){const g=r+a*e;s.push(YD({pn:a+1,x:g,y:2,holeDiameter:i,rectPadWidth:n,rectPadHeight:o}))}}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const c=r+g*e;s.push(Ii(g+1,c,-1.325,n,o))}const a=(A-1)/2*e+1.3;s.push(Ii(A+1,-a,1.22,1.2,1.8)),s.push(Ii(A+2,a,1.22,1.2,1.8))}return s}function mGt(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 wGt=t=>{const A=dGt.parse(t),e=fGt(A),i=pGt[e],n=A.p??i.p,o=A.id??i.id,s=A.pw??i.pw,r=A.pl??i.pl,a=A.w??i.w,g=A.h??i.h;let c;const I=t.num_pins;typeof I=="number"&&(c=I);const B=(typeof t.string=="string"?t.string:"").match(/(?:^|_)jst(\d+)(?:_|$)/);if(B&&B[1]){const E=parseInt(B[1],10);Number.isNaN(E)||(c=E)}if(typeof c!="number")throw new Error(`JST requires an explicit pin count (e.g. jst6_sh or .jst(6))${A.string?`, from string "${A.string}"`:""}`);const C=yGt(e,c,n,o,s,r),Q=mGt(e),h=Mi(0,g/2+1,.5);return{circuitJson:[...C,Q,h],parameters:{...A,p:n,id:o,pw:s,pl:r,w:a,h:g,num_pins:c,sh:e==="sh",ph:e==="ph"}}},DGt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.30mm"),h:H().default("1.70mm"),pl:H().default("0.80mm"),pw:H().default("1mm"),p:H().default("1.90mm")}),SGt=t=>{const A=DGt.parse(t),e=Mi(0,lA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:xGt(A).concat(i,e),parameters:A}},bGt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},xGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=bGt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},_Gt=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"}}},kGt=Li.extend({fn:H(),num_pins:Gt([kA(8),kA(10)]).default(8),w:H().optional(),h:H().optional(),p:H().optional(),pl:H().optional(),pw:H().optional(),string:H().optional()}),vGt=t=>{const A=kGt.parse(t),e=_Gt(A.num_pins),i=lA.parse(A.w||e.w),n=lA.parse(A.h||e.h),o=lA.parse(A.p||e.p),s=lA.parse(A.pl||e.pl),r=lA.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}=tie(A.num_pins,u+1,i,o),m=u<g?u+1:A.num_pins-(u-g);a.push(Ii(m,d,f,s,r))}const c=i,I=n,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:I/2},{x:c/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:-I/2},{x:c/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=tie(A.num_pins,1,c,o),Q={x:C.x-.8,y:C.y},h={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"},E=Mi(0,I/2+.5,.3);return{circuitJson:[...a,l,B,E,h],parameters:A}},tie=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*lA.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},FGt=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"}}},NGt=Li.extend({fn:H(),num_pins:Gt([kA(8),kA(10),kA(12),kA(16)]).default(8),w:H().optional(),h:H().optional(),p:H().optional(),pl:H().optional(),pw:H().optional(),string:H().optional()}),iie=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*lA.parse("2mm"),y:r*i}},RGt=t=>{const A=NGt.parse(t),e=FGt(A.num_pins),i=lA.parse(A.w||e.w),n=lA.parse(A.h||e.h),o=lA.parse(A.p||e.p),s=lA.parse(A.pl||e.pl),r=lA.parse(A.pw||e.pw),a=[];for(let E=0;E<A.num_pins;E++){const{x:u,y:d}=iie(A.num_pins,E+1,i,o);a.push(Ii(E+1,u,d,s,r))}const g=i,c=n,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:c/2},{x:g/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-c/2},{x:g/2,y:-c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B=iie(A.num_pins,1,g,o),C={x:B.x-.8,y:B.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"},h=Mi(0,c/2+.5,.3);return{circuitJson:[...a,I,l,h,Q],parameters:A}},GGt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.8mm"),h:H().default("1.65mm"),pl:H().default("1.2mm"),pw:H().default("1.2mm"),pad_spacing:H().default("2.6mm")}),MGt=t=>{const A=GGt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.pad_spacing)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.pad_spacing)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:UGt(A).concat(i,e),parameters:A}},LGt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},UGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=LGt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},HGt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.20mm"),h:H().default("1.65mm"),pl:H().default("0.8mm"),pw:H().default("0.9mm"),pad_spacing:H().default("2.1mm")}),YGt=t=>{const A=HGt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.pad_spacing)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.pad_spacing)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:TGt(A).concat(i,e),parameters:A}},JGt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},TGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=JGt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},PGt=Li.extend({fn:H(),num_pins:Gt([kA(6),kA(8)]).default(8),w:H().default("3mm"),h:H().default("3mm"),p:H().default("0.5mm"),pl:H().default("0.52mm"),pw:H().default("0.35mm"),epw:H().default("1.40mm"),eph:H().default("1.60mm"),string:H().optional(),ep:qA().default(!1)}),KGt=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=PGt.parse({...t,num_pins:e}),n=lA.parse(i.w),o=lA.parse(i.h),s=lA.parse(i.p),r=lA.parse(i.pl),a=lA.parse(i.pw),g=lA.parse(i.epw),c=lA.parse(i.eph),I=[];for(let f=0;f<i.num_pins;f++){const{x:m,y:w}=nie(i.num_pins,f+1,n,s);I.push(Ii(f+1,m,w,r,a))}i.ep&&I.push(Ii(i.num_pins+1,0,0,g,c));const l=n,B=o,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:B/2},{x:l/2,y:B/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-B/2},{x:l/2,y:-B/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h=nie(i.num_pins,1,l,s),E={x:h.x-.4,y:h.y},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:E.x-.4,y:E.y},{x:E.x-.7,y:E.y+.3},{x:E.x-.7,y:E.y-.3},{x:E.x-.4,y:E.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Mi(0,B/2+.5,.3);return{circuitJson:[...I,C,Q,d,u],parameters:i}},nie=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*lA.parse("1.4mm"),y:r*i}},qGt=Li.extend({fn:H(),num_pins:OA().optional().default(8),p:se.describe("pitch (distance between center of each pin)"),w:lA.describe("width between vertical rows of pins"),grid:xV.describe("width and height of the border of the footprint"),ep:xV.default("0x0mm").describe("width and height of the central exposed thermal pad"),epx:lA.default("0mm").describe("x offset of the center of the central exposed thermal pad"),pinw:lA.describe("width of the pin pads"),pinh:lA.describe("height of the pin pads")}),OGt=t=>{const A=qGt.parse(t),{num_pins:e,p:i,w:n,grid:o,ep:s,epx:r,pinw:a,pinh:g}=A;if(e%2!==0)throw new Error("invalid number of pins");const c=[];for(let B=0;B<e;B++){const{pinX:C,pinY:Q}=WGt({pinCount:e,pinIndex:B,width:n,pitch:i});c.push(Ii(B+1,C,Q,a,g))}s.x>0&&s.y>0&&c.push(Ii(A.num_pins+1,r,0,s.x,s.y));const I=ZGt(o),l=Mi(0,o.y/2+i,o.y/6);return{circuitJson:[...c,...I,l],parameters:A}},WGt=t=>{let A=0,e=0;const i=(t.pinCount/2-1)*t.pitch/2,n=t.pinCount/2;return t.pinIndex+1<=n?(A=t.pitch*t.pinIndex-i,e=0-t.width/2):(A=t.pitch*(t.pinCount-t.pinIndex-1)-i,e=t.width/2),{pinX:e,pinY:A}},ZGt=t=>{const e=t.y/30;return[{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-t.x/2-.1,y:t.y/2+.1-e},{x:-t.x/2-.1,y:t.y/2+.1},{x:t.x/2+.1,y:t.y/2+.1},{x:t.x/2+.1,y:t.y/2+.1-e}],stroke_width:t.y/30},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-t.x/2-.1,y:-t.y/2-.1+e},{x:-t.x/2-.1,y:-t.y/2-.1},{x:t.x/2+.1,y:-t.y/2-.1},{x:t.x/2+.1,y:-t.y/2-.1+e}],stroke_width:t.y/30}]},VGt=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:n=1.5,ph:o=1.5}=t,s=lA.parse(i),r=lA.parse(n),a=lA.parse(o),g=Math.min(a/4,.5),c=[];for(let f=0;f<A;f++)c.push(Ii(f+1,f*s,0,r,a));let I=[];if(e){const f=e.split("").map(Number);if(f.length>1)for(let m=0;m<f.length-1;m++){const w=f[m],D=f[m+1];if(typeof w=="number"&&typeof D=="number"&&!isNaN(w)&&!isNaN(D)){const S=(w-1)*s,_=(D-1)*s,x=Math.sign(_-S),G=S+x*(r/2),F=_-x*(r/2);I.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${w}}`,x:G,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${D}}`,x:F,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const l=(A-1)*s+r+.7,B=a+1,C=(A-1)*s/2,Q=0,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:C-l/2,y:Q-B/2},{x:C+l/2,y:Q-B/2},{x:C+l/2,y:Q+B/2},{x:C-l/2,y:Q+B/2},{x:C-l/2,y:Q-B/2}],stroke_width:.15},u=Q+B/2+.6,d=Mi(C,u,.4);return{circuitJson:[...c,...I,h,d],parameters:t}},oie={fn:kA("sot457"),num_pins:kA(6).default(6),pillh:H().default("0.45mm"),pillw:H().default("1.45mm"),pl:H(),pw:H(),p:H(),wave:qA().optional(),reflow:qA().optional()},jGt=Li.extend({...oie,h:H().default("2.5mm"),w:H().default("2.7mm"),pl:H().default("0.8mm"),pw:H().default("0.55mm"),p:H().default("0.95mm")}),zGt=Li.extend({...oie,h:H().default("3mm"),w:H().default("4mm"),pillr:H().default("0.225mm"),pl:H().default("1.45mm"),pw:H().default("1.5mm"),p:H().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)})),kb=t=>Number.parseFloat(t.replace("mm","")),sie=({pitch:t,width:A,pinNumber:e})=>{const o={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(!o)throw new Error(`Invalid pin number: ${e}`);return o},rie=t=>{const A=[],e=kb(t.p),i=kb(t.pl),n=kb(t.pw),o=kb(t.w),s=kb(t.h);if(t.wave){const C={1:({padWidth:Q,padHeight:h})=>Ii(1,-e,e,h,Q),2:({padWidth:Q,padHeight:h})=>Ii(2,-e,-e,h,Q),3:({padWidth:Q,padHeight:h})=>_V(3,-e,0,kb(t.pillw),kb(t.pillh)),4:({padWidth:Q,padHeight:h})=>_V(4,e,0,kb(t.pillw),kb(t.pillh)),5:({padWidth:Q,padHeight:h})=>Ii(5,e,e,h,Q),6:({padWidth:Q,padHeight:h})=>Ii(6,e,-e,h,Q)};for(let Q=1;Q<=t.num_pins;Q++){const h=C[Q];h&&A.push(h({padWidth:i,padHeight:n}))}}else for(let C=1;C<=t.num_pins;C++){const{x:Q,y:h}=sie({pitch:e,width:o,pinNumber:C});A.push(Ii(C,Q,h,i,n))}const r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/3,y:s/2+e/1.3},{x:o/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:-o/3,y:-s/2-e/1.3},{x:o/3,y:-s/2-e/1.3}],stroke_width:.05},g=Mi(0,s+.5,.3),c=sie({pitch:e,width:o,pinNumber:1}),I=t.wave?1:.5,l=t.wave?.7:.3;c.x-=t.wave?n:n*1.7;const B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:c.x+I/2,y:c.y},{x:c.x-I/2,y:c.y+l/2},{x:c.x-I/2,y:c.y-l/2},{x:c.x+I/2,y:c.y}],stroke_width:.05};return[g,r,a,B,...A]},XGt=t=>{if(t.wave){const e=zGt.parse({...t,fn:"sot457"});return{circuitJson:rie(e),parameters:e}}const A=jGt.parse(t);return{circuitJson:rie(A),parameters:A}},$Gt=Li.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("1.1mm"),h:H().default("1.45mm"),p:H().default("0.35mm"),pl:H().default("0.2mm"),pw:H().default("0.2mm"),string:H().optional()}),AMt=t=>{const A=$Gt.parse({...t,fn:"sot963"}),e=lA.parse(A.w),i=lA.parse(A.h),n=lA.parse(A.p),o=lA.parse(A.pl),s=lA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=aie(B+1,e,n,o);r.push(Ii(B+1,C,Q,o,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:""},c=aie(1,e,n,o),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-o/2-.3,y:c.y},{x:c.x-o/2-.45,y:c.y+.15},{x:c.x-o/2-.45,y:c.y-.15},{x:c.x-o/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Mi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},aie=(t,A,e,i)=>{const n=A/2-i/2;return t<=3?{x:-n,y:e-(t-1)*e}:{x:n,y:-e+(t-4)*e}},eMt=Li.extend({fn:H(),num_pins:Gt([kA(3),kA(2)]).default(3),p:H().default("3.8mm"),id:H().default("1.25mm"),od:H().default("2.35mm"),ca:H().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:H().default("5.35mm"),h:H().default("4mm"),string:H().optional()}),tMt=t=>{const{p:A,id:e,od:i,h:n,ca:o}=t,s=Number.parseFloat(n),r=Number.parseFloat(o);return[vo(1,0,r/4+.3,e,i),vo(2,s,0,e,i),vo(3,0,-r/4-.3,e,i)]},iMt=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=eMt.parse({...t,num_pins:e});let n=[];i.num_pins===3&&(n=tMt(i));const o=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:o-1.75},{x:0,y:o},{x:s,y:o},{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:-o},{x:0,y:-o},{x:0,y:-o+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},c=Number.parseFloat(i.w)/2,I=Mi(c,o+1,.5);return{circuitJson:[...n,a,g,I],parameters:i}},nMt=Li.extend({fn:H(),p:lA.optional().default("7.5mm"),id:lA.optional().default("1mm"),od:lA.optional().default("2mm"),d:lA.optional().default("10.5mm")}),oMt=(t,A,e,i,n)=>{const o=[],s=[];for(let r=0;r<=50;r++){const a=r/50*Math.PI,g=t+Math.cos(a)*e,c=A+Math.sin(a)*e;g<t-i&&c>=A-n/2&&c<=A+n/2||o.push({x:g,y:c})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=t+Math.cos(a)*e,c=A+Math.sin(a)*e;g<t-i&&c>=A-n/2&&c<=A+n/2||s.push({x:g,y:c})}return{topArc:o,bottomArc:s}},sMt=t=>{const A=nMt.parse(t),{p:e,id:i,od:n,d:o}=A,s=[vo(1,-e/2,0,i,n),vo(2,e/2,0,i,n)],{topArc:r,bottomArc:a}=oMt(0,0,o/2+.1,n/2,n),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},l=-(o/2+.5),B=n/2+1.5,C=.5,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l-C,y:B},{x:l+C,y:B}],stroke_width:.1,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l,y:B-C},{x:l,y:B+C}],stroke_width:.1,pcb_silkscreen_path_id:""},E=Mi(0,o/2+1,.5);return{circuitJson:[...s,g,c,I,Q,h,E],parameters:A}},rMt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("6.5mm"),h:H().default("3mm"),pl:H().default("1.75mm"),pw:H().default("2.40mm"),p:H().default("4.75mm")}),aMt=t=>{const A=rMt.parse(t),e=Mi(0,lA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.3,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.3,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:cMt(A).concat(i,e),parameters:A}},gMt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},cMt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=gMt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},IMt=Li.extend({fn:H(),num_pins:OA().default(3),w:H().default("2.45mm"),h:H().default("2.40mm"),pl:H().default("0.92mm"),pw:H().default("0.45mm"),p:H().default("0.891mm"),string:H().optional()}),lMt=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=IMt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:CMt(i),parameters:i};throw new Error("Invalid number of pins")},BMt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},CMt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=BMt({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(Ii(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Mi(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n+.3},{x:i,y:n+.3},{x:i,y:n/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:-n-.3},{x:i,y:-n-.3},{x:i,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},QMt=Li.extend({fn:H(),circle:qA().optional(),rect:qA().optional(),square:qA().optional(),pill:qA().optional(),d:lA.optional(),pd:lA.optional(),diameter:lA.optional(),r:lA.optional(),pr:lA.optional(),radius:lA.optional(),w:lA.optional(),pw:lA.optional(),width:lA.optional(),h:lA.optional(),ph:lA.optional(),height:lA.optional(),s:lA.optional(),size:lA.optional(),string:H().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,n;return A==="circle"?t.r!==void 0?e=Lr(t.r):t.pr!==void 0?e=Lr(t.pr):t.radius!==void 0?e=Lr(t.radius):t.d!==void 0?e=Lr(t.d)/2:t.pd!==void 0?e=Lr(t.pd)/2:t.diameter!==void 0?e=Lr(t.diameter)/2:e=Lr("1mm")/2:(t.w!==void 0?i=Lr(t.w):t.pw!==void 0?i=Lr(t.pw):t.width!==void 0?i=Lr(t.width):t.s!==void 0?i=Lr(t.s):t.size!==void 0?i=Lr(t.size):i=Lr("1mm"),t.h!==void 0?n=Lr(t.h):t.ph!==void 0?n=Lr(t.ph):t.height!==void 0?n=Lr(t.height):A==="square"||A==="rect"?n=i:n=Lr("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:n}}),hMt=t=>{const A=QMt.parse(t),{shape:e,radius:i,width:n,height:o}=A;let s,r;return e==="circle"?(s=Jte(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=_V(1,0,0,n,o),r=Math.max(n,o)/2+.5):(s=Ii(1,0,0,n,o),r=o/2+.5),{circuitJson:[s,Mi(0,r,.2)],parameters:A}},EMt=Li.extend({fn:H(),d:lA.optional(),hd:lA.optional(),r:lA.optional(),hr:lA.optional(),pd:lA.optional(),pr:lA.optional(),squarepad:qA().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=Lr(t.d):t.hd!==void 0?A=Lr(t.hd):t.r!==void 0?A=Lr(t.r)*2:t.hr!==void 0?A=Lr(t.hr)*2:A=Lr("1mm");let e;return t.pd!==void 0?e=Lr(t.pd):t.pr!==void 0?e=Lr(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),uMt=t=>{const A=EMt.parse(t),{d:e,pd:i,squarepad:n}=A;return{circuitJson:[n?YD({pn:1,x:0,y:0,holeDiameter:e,rectPadWidth:i,rectPadHeight:i}):vo(1,0,0,e,i),Mi(0,i/2+.5,.2)],parameters:A}},dMt=Li.extend({fn:H(),num_pins:kA(6).default(6),h:H().default("1.6mm"),pl:H().default("1mm"),pw:H().default("0.7mm"),p:H().default("0.95mm")}),pMt=t=>{const A=dMt.parse(t);return{circuitJson:fMt(A),parameters:A}},gie=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")},fMt=t=>{const A=[];for(let I=1;I<=t.num_pins;I++){const{x:l,y:B}=gie({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:I});A.push(Ii(I,l,B,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),n={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},o={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=Mi(0,i+.3,.3),r=gie({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,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,n,o,c]},yMt=Li.extend({fn:H(),num_pins:OA().default(4),w:H().default("3.2mm"),h:H().default("2.6mm"),pl:H().default("1.05mm"),pw:H().default("0.45mm"),p:H().default("0.55mm"),string:H().optional()}),mMt=t=>{const A=t.string?.match(/^sot343_(\d+)/),e=A?Number.parseInt(A[1],4):4,i=yMt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:DMt(i),parameters:i};throw new Error("Invalid number of pins")},wMt=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}},DMt=t=>{const A=[],e=Number.parseFloat(t.w),i=Number.parseFloat(t.h),n=Number.parseFloat(t.pl),o=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let r=1/0,a=-1/0,g=1/0,c=-1/0;for(let d=0;d<t.num_pins;d++){const{x:f,y:m}=wMt({num_pins:t.num_pins,pn:d+1,p:s});A.push(Ii(d+1,f,m,n,o)),f<r&&(r=f),f>a&&(a=f),m<g&&(g=m),m>c&&(c=m)}const I=(r+a)/2,l=c-g,B=i*.3,C=l/2+B;let Q=e*.8;i<=2.6&&(Q/=2);const h=Mi(I,C+.5,.3),E={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:I-Q/2,y:C},{x:I+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:I-Q/2,y:-C},{x:I+Q/2,y:-C}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,E,u,h]},SMt=Li.extend({fn:H()}),bMt=t=>{const A=SMt.parse(t),e=[],i=.5-.15,n=1.5,s=.5/2,r=75,a=-37/2;for(let D=0;D<r;D++){const S=D+1;if(S>=24&&S<=31)continue;const _=a-D*s,x=S%2===0,G=n+(x?.25:0),L=.5-G/2,Y=Ii(S,L,_,G,i);Y.layer=x?"bottom":"top",e.push(Y)}const g=46*.0254,c=137*.0254,I=261*.0254,l={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-c/2+n/2,y:a-I},width:c,height:g},B={x:-.5,y:a},C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:B.x-.4,y:B.y},{x:B.x-.7,y:B.y+.3},{x:B.x-.7,y:B.y-.3},{x:B.x-.4,y:B.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let Q=1/0,h=-1/0,E=1/0,u=-1/0;const d=(D,S,_=0,x=0)=>{Q=Math.min(Q,D-_/2),h=Math.max(h,D+_/2),E=Math.min(E,S-x/2),u=Math.max(u,S+x/2)};for(const D of e){const S=D;d(S.x,S.y,S.width,S.height)}d(l.center.x,l.center.y,l.width,l.height);for(const D of C.route)d(D.x,D.y);const f=(Q+h)/2,m=(E+u)/2,w=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(S=>({x:S.x-f,y:S.y-m})))};for(const D of e)w(D);return w(l),w(C),{circuitJson:[...e,l,C],parameters:A}},xMt=Li.extend({fn:H(),numPins:OA().optional().default(0),rows:Gt([H(),OA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:lA.default("2.54mm").describe("pitch"),id:lA.default("1.0mm").describe("inner diameter"),od:lA.default("1.5mm").describe("outer diameter"),male:qA().optional().describe("the module uses male headers"),nopin:qA().optional().default(!1).describe("omit pins rendering"),female:qA().optional().describe("the module uses female headers"),smd:qA().optional().describe("surface mount device"),pinlabeltextalignleft:qA().optional().default(!1),pinlabeltextaligncenter:qA().optional().default(!1),pinlabeltextalignright:qA().optional().default(!1),pinlabelverticallyinverted:qA().optional().default(!1),pinlabelorthogonal:qA().optional().default(!1),nopinlabels:qA().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:qA().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:qA().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top"),pinRowSide:et(["left","right","top","bottom"]).optional().default("left"),pinrowleft:qA().optional().default(!1),pinrowright:qA().optional().default(!1),pinrowtop:qA().optional().default(!1),pinrowbottom:qA().optional().default(!1),pinrowleftpins:Gt([H(),OA()]).transform(t=>Number(t)).optional(),pinrowrightpins:Gt([H(),OA()]).transform(t=>Number(t)).optional(),pinrowtoppins:Gt([H(),OA()]).transform(t=>Number(t)).optional(),pinrowbottompins:Gt([H(),OA()]).transform(t=>Number(t)).optional(),width:lA.optional(),height:lA.optional(),pinRowHoleEdgeToEdgeDist:lA.default("2mm"),holes:Gt([H(),be(H())]).optional().transform(t=>!t||Array.isArray(t)?t:t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1).split(",").map(A=>A.trim()):[t]),holeXDist:lA.optional(),holeYDist:lA.optional(),holeInset:lA.default("1mm"),pinrow:Gt([H(),OA()]).optional(),usbposition:et(["left","right","top","bottom"]).optional().default("left"),usbleft:qA().optional().default(!1),usbtop:qA().optional().default(!1),usbright:qA().optional().default(!1),usbbottom:qA().optional().default(!1),usbtype:et(["micro","c"]).optional(),usbmicro:qA().optional().default(!1),usbc:qA().optional().default(!1),screen:qA().optional().default(!1).describe("add silkscreen outline for screen/display area"),screenwidth:lA.optional(),screenheight:lA.optional(),screencenteroffsetx:lA.optional(),screencenteroffsety:lA.optional()}).transform(t=>{const A=jte(t);let e=t.pinRowSide;t.pinrowleft&&(e="left"),t.pinrowright&&(e="right"),t.pinrowtop&&(e="top"),t.pinrowbottom&&(e="bottom");let i=t.usbposition;t.usbleft&&(i="left"),t.usbtop&&(i="top"),t.usbright&&(i="right"),t.usbbottom&&(i="bottom");let n=t.usbtype;t.usbmicro&&(n="micro"),t.usbc&&(n="c"),t.pinrow!==void 0&&(t.numPins=Number(t.pinrow));const o={left:t.pinrowleftpins,right:t.pinrowrightpins,top:t.pinrowtoppins,bottom:t.pinrowbottompins},s=Object.values(o).some(f=>f!==void 0&&f>0),r=(o.left??0)>0&&(o.right??0)>0,a=(o.top??0)>0&&(o.bottom??0)>0;s&&((o.left??0)>0?e="left":(o.right??0)>0?e="right":(o.top??0)>0?e="top":(o.bottom??0)>0&&(e="bottom"),t.numPins=(o.left??0)+(o.right??0)+(o.top??0)+(o.bottom??0));const g=Math.ceil(t.numPins/t.rows),c=Math.max(o.left??0,o.right??0),I=Math.max(o.top??0,o.bottom??0);let l,B;if(s){const f=r?t.p:0,m=a?t.p:0;l=(I>0?(I-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+f,B=(c>0?(c-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+m}else e==="left"||e==="right"?(l=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,B=(g-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist):(B=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,l=(g-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist);t.numPins===0&&(l=10,B=10);const C=t.width??l,Q=t.height??B,h=t.screenwidth??C*.95,E=t.screenheight??Q*.95,u=t.screencenteroffsetx??0,d=t.screencenteroffsety??0;return{...t,pinlabelAnchorSide:A,pinRowSide:e,usbposition:i,usbtype:n,male:t.male??!t.female,female:t.female??!1,width:C,height:Q,screenwidth:h,screenheight:E,screencenteroffsetx:u,screencenteroffsety:d,pinrowleftpins:o.left,pinrowrightpins:o.right,pinrowtoppins:o.top,pinrowbottompins:o.bottom}}).superRefine((t,A)=>{t.male&&t.female&&A.addIssue({code:jt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),_Mt=t=>{const A=xMt.parse(t),{p:e,id:i,od:n,rows:o,numPins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:c,pinlabeltextalignright:I,nopinlabels:l,doublesidedpinlabel:B,bottomsidepinlabel:C,pinRowSide:Q,width:h,height:E,pinRowHoleEdgeToEdgeDist:u,holes:d,holeXDist:f,holeYDist:m,holeInset:w,pinrowleftpins:D,pinrowrightpins:S,pinrowtoppins:_,pinrowbottompins:x,usbposition:G,usbtype:F,screen:L,screenwidth:Y,screenheight:J,screencenteroffsetx:O,screencenteroffsety:Z}=A;let X="center";c?X="left":I&&(X="right");const eA=[],gA={left:D,right:S,top:_,bottom:x},tA=Object.values(gA).some(aA=>aA!==void 0&&aA>0),iA=(aA,EA,bA,xA)=>{if(A.smd?eA.push(Ii(aA,EA,bA,A.od,A.od)):aA===1?eA.push(YD({pn:aA,x:EA,y:bA,holeDiameter:i,rectPadWidth:n,rectPadHeight:n})):eA.push(vo(aA,EA,bA,i,n)),!l){const YA=EA+(xA==="left"?-n:xA==="right"?n:0),QA=bA+(xA==="top"?n:xA==="bottom"?-n:0);C||eA.push(qF({fs:n/5,pn:aA,anchor_x:YA,anchor_y:QA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"top"})),(B||C)&&eA.push(qF({fs:n/5,pn:aA,anchor_x:YA,anchor_y:QA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"bottom"}))}};if(tA){const aA=e;let EA=1;const bA=gA.left??0,xA=gA.right??0,YA=gA.top??0,QA=gA.bottom??0,_A=(dA,KA)=>{if(!(KA<=0))if(dA==="left"||dA==="right"){const ZA=dA==="left"?-h/2+u:h/2-u,ce=(KA-1)/2*aA;for(let fA=0;fA<KA;fA++)iA(EA,ZA,ce-fA*aA,dA),EA++}else{const ZA=dA==="top"?E/2-u:-E/2+u,ce=-((KA-1)/2)*aA;for(let fA=0;fA<KA;fA++)iA(EA,ce+fA*aA,ZA,dA),EA++}};_A("left",bA),_A("right",xA),_A("top",YA),_A("bottom",QA)}else{const aA=e;let EA=0,bA=0,xA=0,YA=0,QA=0,_A=0;const dA=Math.ceil(s/o);Q==="left"||Q==="right"?(EA=Q==="left"?-h/2+u:h/2-u,bA=(dA-1)/2*aA,xA=0,YA=-aA,QA=Q==="left"?aA:-aA,_A=0):(EA=-(dA-1)/2*aA,bA=Q==="top"?E/2-u:-E/2+u,xA=aA,YA=0,QA=0,_A=Q==="top"?-aA:aA);let KA=1;for(let ZA=0;ZA<o&&KA<=s;ZA++)for(let ce=0;ce<dA&&KA<=s;ce++){const fA=EA+ce*xA+ZA*QA,ge=bA+ce*YA+ZA*_A;if(A.smd?eA.push(Ii(KA,fA,ge,A.od,A.od)):KA===1?eA.push(YD({pn:KA,x:fA,y:ge,holeDiameter:i,rectPadWidth:n,rectPadHeight:n})):eA.push(vo(KA,fA,ge,i,n)),!l){const VA=fA+(Q==="left"?-n:Q==="right"?n:0),RA=ge+(Q==="top"?n:Q==="bottom"?-n:0);C||eA.push(qF({fs:n/5,pn:KA,anchor_x:VA,anchor_y:RA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"top"})),(B||C)&&eA.push(qF({fs:n/5,pn:KA,anchor_x:VA,anchor_y:RA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"bottom"}))}KA++}}if(d)for(const aA of d){let EA=0,bA=0;aA==="topleft"?(EA=-h/2+w,bA=E/2-w):aA==="topright"?(EA=h/2-w,bA=E/2-w):aA==="bottomleft"?(EA=-h/2+w,bA=-E/2+w):aA==="bottomright"?(EA=h/2-w,bA=-E/2+w):aA==="center"&&(EA=0,bA=0),f!==void 0&&(EA+=f),m!==void 0&&(bA+=m),eA.push(vo(s+d.indexOf(aA)+1,EA,bA,i,n))}if(!A.nosilkscreen){const aA=[{x:-h/2,y:-E/2},{x:h/2,y:-E/2},{x:h/2,y:E/2},{x:-h/2,y:E/2},{x:-h/2,y:-E/2}];eA.push(OF(aA,{stroke_width:.1,layer:"top"}))}const sA=Mi(0,E/2+1,.5);if(eA.push(sA),G&&F){let aA,EA;if(F==="c")aA=8,EA=3;else if(F==="micro")aA=6,EA=2;else return{circuitJson:eA,parameters:A};let bA;if(G==="left")bA=[{x:-h/2,y:-aA/2},{x:-h/2+EA,y:-aA/2},{x:-h/2+EA,y:aA/2},{x:-h/2,y:aA/2},{x:-h/2,y:-aA/2}];else if(G==="right")bA=[{x:h/2-EA,y:-aA/2},{x:h/2,y:-aA/2},{x:h/2,y:aA/2},{x:h/2-EA,y:aA/2},{x:h/2-EA,y:-aA/2}];else if(G==="top")bA=[{x:-aA/2,y:E/2-EA},{x:aA/2,y:E/2-EA},{x:aA/2,y:E/2},{x:-aA/2,y:E/2},{x:-aA/2,y:E/2-EA}];else if(G==="bottom")bA=[{x:-aA/2,y:-E/2},{x:aA/2,y:-E/2},{x:aA/2,y:-E/2+EA},{x:-aA/2,y:-E/2+EA},{x:-aA/2,y:-E/2}];else return{circuitJson:eA,parameters:A};eA.push(OF(bA,{stroke_width:.1,layer:"top"}))}if(L){const aA=Y/2,EA=J/2,bA=O,xA=Z,YA=[{x:-aA+bA,y:-EA+xA},{x:aA+bA,y:-EA+xA},{x:aA+bA,y:EA+xA},{x:-aA+bA,y:EA+xA},{x:-aA+bA,y:-EA+xA}];eA.push(OF(YA,{stroke_width:.05,layer:"top"}))}return{circuitJson:eA,parameters:A}},kMt=Li.extend({fn:H(),num_pins:OA().default(3),inline:qA().default(!1),p:H().default("1.27mm"),id:H().default("0.75mm"),od:H().default("1.3mm"),w:H().default("4.8mm"),h:H().default("4.0mm")}),vMt=t=>{const A=kMt.parse(t),e=Number.parseFloat(A.p),i=Number.parseFloat(A.w),n=Number.parseFloat(A.h),o=A.inline?1.05:Number.parseFloat(A.od),s=A.inline?1.5:o,r=[YD({pn:1,x:0,y:0,holeDiameter:A.id,rectPadWidth:o,rectPadHeight:s}),A.inline?ZY(2,e,0,Number.parseFloat(A.id),o,s):vo(2,e,e,A.id,o),A.inline?ZY(3,e*2,0,Number.parseFloat(A.id),o,s):vo(3,e*2,0,A.id,o)],a=i/2,g=A.inline?e-.09:e,c=.2,I=c+a-n,l=Array.from({length:32},(Q,h)=>{const E=Math.PI*h/31;return{x:g+a*Math.cos(E),y:c+a*Math.sin(E)}}),B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",stroke_width:.12,route:[...l,{x:g-a,y:I},{x:g+a,y:I},l[0]]},C=Mi(g,c+a+1,.5);return{circuitJson:[...r,B,C],parameters:A}};function FMt(t){return t!=null}var NMt=(t,A)=>{if(!A)return t;const e=t.filter(c=>c.type==="pcb_smtpad"||c.type==="pcb_plated_hole"||c.type==="pcb_thtpad");if(e.length===0)return t;let i=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;const r=(c,I,l=0,B=0)=>{const C=c-l/2,Q=c+l/2,h=I-B/2,E=I+B/2;i=Math.min(i,C),n=Math.max(n,Q),o=Math.min(o,h),s=Math.max(s,E)};for(const c of e)if(c.type==="pcb_smtpad"){const I=c.shape==="circle"?c.radius*2:c.width,l=c.shape==="circle"?c.radius*2:c.height;r(c.x,c.y,I,l)}else if(c.type==="pcb_plated_hole"){const I=c.outer_diameter??c.hole_diameter;r(c.x,c.y,I,I)}else if(c.type==="pcb_thtpad"){const I=c.diameter;r(c.x,c.y,I,I)}let a=0,g=0;switch(A){case"center":a=(i+n)/2,g=(o+s)/2;break;case"bottomleft":a=i,g=o;break;case"bottomcenter":case"centerbottom":a=(i+n)/2,g=o;break;case"topcenter":case"centertop":a=(i+n)/2,g=s;break;case"leftcenter":case"centerleft":a=i,g=(o+s)/2;break;case"rightcenter":case"centerright":a=n,g=(o+s)/2;break;case"pin1":{const c=e.find(I=>I.port_hints?.[0]==="1")||e[0];a=c.x,g=c.y;break}}if(a===0&&g===0)return t;for(const c of t){if(typeof c.x=="number"&&(c.x-=a),typeof c.y=="number"&&(c.y-=g),c.center&&typeof c.center.x=="number"&&(c.center.x-=a,c.center.y-=g),c.type==="pcb_silkscreen_path")for(const I of c.route)I.x-=a,I.y-=g;c.type==="pcb_silkscreen_text"&&c.anchor_position&&(c.anchor_position.x-=a,c.anchor_position.y-=g)}return t},RMt=(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},GMt=(t,A)=>A.nosilkscreen?t.filter(e=>e.type!=="pcb_silkscreen_path"&&e.type!=="pcb_silkscreen_text"):t,MMt=t=>{let A=FV();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_|x)/,"res$1").split(/_(?!metric)/).map(n=>{const o=n.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,r]=o;if(!s)return null;const a=s.toLowerCase();return r?.includes("?")?null:{fn:a,v:r}}).filter(FMt);for(const{fn:n,v:o}of i)A=A[n](o);return A.setString(t),A},LMt=()=>Object.keys(_b),FV=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&_b[A.fn])return()=>{const{circuitJson:i}=_b[A.fn](A),n=GMt(i,A),o=RMt(n,A);return NMt(o,A.origin)};if(!_b[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(!_b[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>_b[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(_b):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in _b?(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};FV.string=MMt,FV.getFootprintNames=LMt;var UMt=FV,cie=Symbol("Fragment");function RdA(t,A,...e){const i=e.length?e:A?.children!==void 0?[A.children]:[],n=[],o=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of o)s==null||s===!1||(Array.isArray(s)?n.push(...s):n.push(s));return{type:t,props:(A&&A.children!==void 0?{...A,children:void 0}:A)||{},children:n}}var Qt=Symbol("Cuboid"),Iie=Symbol("Cube"),Ol=Symbol("Cylinder"),NV=Symbol("Sphere"),VY=Symbol("RoundedCuboid"),Wi=Symbol("Translate"),gC=Symbol("Rotate"),VQ=Symbol("Union"),lm=Symbol("Subtract"),bc=Symbol("Hull"),wo=Symbol("Colorize"),jY=Symbol("Polygon"),zY=Symbol("ExtrudeLinear"),_f=Symbol("RoundedCylinder"),Jn=cie,zA=(t,A,e)=>RdA(t,A),qt=(t,A,e)=>RdA(t,A),yB=({center:t,width:A,length:e,height:i,heightAboveSurface:n=.15,color:o="#555",taperRatio:s=.12,faceRatio:r=.75,straightHeightRatio:a=.5,includeNotch:g=!0,notchRadius:c,notchPosition:I,notchRotation:l=[0,0,0],notchLength:B=.5,notchWidth:C=.25,chamferSize:Q=0})=>{const h=i*a,E=i-h,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,w=c??m,D={x:0,y:e/2-w*.25,z:i},S=I??D,_=qt(VQ,{children:[qt(bc,{children:[zA(Wi,{z:.005,children:zA(Qt,{size:[d,f,.01]})}),zA(Wi,{z:h,children:zA(Qt,{size:[A,e,.01]})})]}),qt(bc,{children:[zA(Wi,{z:h,children:zA(Qt,{size:[A,e,.01]})}),zA(Wi,{z:h+E,children:zA(Qt,{size:[d,f,.01]})})]})]}),x=(F,L)=>zA(Wi,{offset:{x:F,y:L,z:0},children:zA(gC,{rotation:[0,0,Math.PI/4],children:zA(Qt,{size:[Q*Math.SQRT2,Q*Math.SQRT2,i*3]})})});let G=_;if(Q>0){const F=A/2,L=e/2;G=qt(lm,{children:[_,x(F,L),x(-F,L),x(F,-L),x(-F,-L)]})}return zA(wo,{color:o,children:zA(Wi,{offset:t,children:zA(Wi,{offset:{x:0,y:0,z:n},children:g?qt(lm,{children:[G,zA(Wi,{offset:S,children:zA(gC,{rotation:l,children:zA(Ol,{radius:w,height:C})})})]}):G})})})},HMt=t=>Array.from({length:t},(A,e)=>e);function GdA(t,A){if(t.length<2)throw new Error("Stroke must have at least two points");const e=Array.isArray(t[0])?t.map(([c,I])=>({x:c,y:I})):t,i=A/2,n=[],o=[];function s(c,I){const l=I.x-c.x,B=I.y-c.y,C=Math.sqrt(l*l+B*B);return{x:-B/C,y:l/C}}function r(c,I,l){const B={x:c.x+I.x*i*l,y:c.y+I.y*i*l};l>0?n.push(B):o.unshift(B)}const a=s(e[0],e[1]);r(e[0],a,1),r(e[0],a,-1);for(let c=1;c<e.length-1;c++){const I=e[c-1],l=e[c],B=e[c+1],C=s(I,l),Q=s(l,B),h=C.x+Q.x,E=C.y+Q.y,u=Math.sqrt(h*h+E*E);if(u/2>2*i)r(l,C,1),r(l,Q,1),r(l,C,-1),r(l,Q,-1);else{const f=1/u;r(l,{x:h*f,y:E*f},1),r(l,{x:h*f,y:E*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),[...n,...o]}var YMt=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}))},JMt=YMt([{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}]),lie=5.47,RV=.5,TMt=({x:t,y:A,z:e})=>{const i=t>0;return qt(Jn,{children:[zA(Wi,{offset:{x:t+.25/2,y:A,z:e},children:zA(gC,{rotation:["-90deg",0,"90deg"],children:zA(zY,{height:.25,children:zA(jY,{points:JMt.slice().reverse().map(n=>[n.x,n.y])})})})}),zA(Wi,{offset:{x:t,y:A+(i?1:-1),z:e},children:zA(gC,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:zA(zY,{height:2,children:zA(jY,{points:GdA([[0,0],[-1,0],[-1,-1]],.25).map(n=>[n.x,n.y])})})})})]})},PMt=({numPins:t=8,pitch:A=2.54,bodyWidth:e=6.4,rowSpacing:i})=>{const n=Math.floor(t/2),o=i??(e>=7?e:e+1.22),s=e>=7?o-1.22:e;return qt(Jn,{children:[HMt(t).map(r=>{const a=r%n,g=(Math.floor(r/n)-.5)*2;return zA(TMt,{x:g*o/2,y:a*A-(n-1)/2*A,z:lie/2+RV})}),zA(yB,{width:s,length:n*A+.5,height:lie-RV,heightAboveSurface:RV,center:{x:0,y:0,z:RV}})]})};function KMt(t,{height:A,padContactLength:e,curveLength:i,bodyDistance:n,steepness:o=10}){i||(i=n*.3);let s=n-e-i;s<0&&(i+=s,s=0);const r=e*.75,a=e+i+(n-e-i)*.25;if(t<=r)return 0;if(t>=a)return A;const g=(t-r)/(a-r);return A/(1+Math.exp(-o*(g-.5)))}var oo=t=>{const{thickness:A,width:e,padContactLength:i,bodyDistance:n,height:o,rotation:s}=t,r=15,a=Array.from({length:r}).map((c,I)=>I/(r-1)*n).map(c=>[c,KMt(c,t)]),g=GdA(a,A);return zA(wo,{color:"#fff",children:zA(Wi,{offset:{z:0,y:0,x:0,...t.position},children:zA(gC,{rotation:["90deg",0,s??0],children:zA(Wi,{offset:{x:0,y:0,z:-e/2},children:zA(zY,{height:e,children:zA(jY,{points:g.map(c=>[c.x,c.y])})})})})})})},qMt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:n})=>{const o=Math.ceil(t/2),s=i*t/2+e/2,r=(o-1)*i/2,a=.25;return qt(Jn,{children:[Array.from({length:o}).map((g,c)=>zA(oo,{position:{x:-n/2-A,y:c*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:o}).map((g,c)=>zA(oo,{rotation:Math.PI,position:{x:n/2+A,y:c*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),zA(yB,{center:{x:0,y:0,z:a/2},width:n-e-1,length:s,height:1.5})]})},OMt=({pinCount:t,padContactLength:A=.4,leadWidth:e=.2,pitch:i=.65,bodyWidth:n=3})=>{const o=Math.ceil(t/2),s=(o-1)*i/2,r=.2;return qt(Jn,{children:[Array.from({length:o}).map((a,g)=>zA(oo,{position:{x:-n/2-A-.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Array.from({length:o}).map((a,g)=>zA(oo,{rotation:Math.PI,position:{x:n/2+A+.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),zA(yB,{center:{x:0,y:0,z:r/2},width:n,length:n,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},MdA=1,LdA=.5,l1=.5,XY=.2,WMt=MdA-XY*2,Bie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[WMt,LdA,l1],offset:[0,0,l1/2],color:t}),zA(Qt,{size:[XY,l1,LdA],offset:[MdA/2-XY/2,0,l1/2],color:"#ccc"}),zA(Qt,{size:[XY,l1,LdA],offset:[-MdA/2+XY/2,0,l1/2],color:"#ccc"})]}),UdA=1.6,ZMt=UdA-.3*2,GV=.3,HdA=.85,B1=.6,Cie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[ZMt,HdA,B1],offset:[0,0,B1/2],color:t}),zA(Qt,{size:[GV,HdA,B1],offset:[UdA/2-GV/2,0,B1/2],color:"#ccc"}),zA(Qt,{size:[GV,HdA,B1],offset:[-UdA/2+GV/2,0,B1/2],color:"#ccc"})]}),YdA=2,JdA=1.25,C1=.55,$Y=.5,VMt=YdA-$Y*2,Qie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[VMt,JdA,C1],offset:[0,0,C1/2],color:t}),zA(Qt,{size:[$Y,JdA,C1],offset:[YdA/2-$Y/2,0,C1/2],color:"#ccc"}),zA(Qt,{size:[$Y,JdA,C1],offset:[-YdA/2+$Y/2,0,C1/2],color:"#ccc"})]}),jMt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:n})=>{const o=t/4;A||(A=zMt(t,n)),i||(i=XMt(t)),e||(e=$Mt(t,n)),n||(n=A*(o+4));const s=n,r=(o-1)*A/2,a=s+2*i,g=a,c=.8,I=.15,l=(g-n)/2+.5;return qt(Jn,{children:[Array.from({length:o}).map((B,C)=>zA(oo,{position:{x:-g/2-.4,y:C*A-r,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:Math.PI,position:{x:g/2+.4,y:C*A-r,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.4,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.4,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),zA(yB,{center:{x:0,y:0,z:0},width:n,length:s,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:n/2-1.5,z:1.5},notchRadius:1.5/2})]})},zMt=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},XMt=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}},$Mt=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},hie=({x:t,y:A,pinThickness:e,shortSidePinLength:i,longSidePinLength:n,bodyHeight:o,bodyLength:s=2.54,bodyWidth:r=2.54,flipZ:a,faceup:g,smd:c,rightangle:I})=>qt(Jn,{children:[zA(Wi,{y:I?-3:0,children:zA(Qt,{color:"#222",size:[s,r,o],center:[t,A,a(o/2)]})}),!g&&zA(wo,{color:"gold",children:c?zA(oo,{rotation:-Math.PI/2,position:{x:t,y:A+1,z:e/2},thickness:e,width:e,height:e,padContactLength:2,bodyDistance:3}):qt(bc,{children:[zA(Qt,{color:"gold",size:[e,e,i*.9],center:[t,A,a(o*.9+o/2)]}),zA(Qt,{color:"gold",size:[e/1.8,e/1.8,i],center:[t,A,a(o+o/2)]})]})}),zA(wo,{color:"gold",children:zA(Wi,{y:I?-3.9:0,z:I?1:0,children:zA(gC,{rotation:I?[-Math.PI/2,0,0]:[0,0,0],children:qt(bc,{children:[zA(Qt,{color:"gold",size:[e,e,n*.9],center:[t,A,a(-n/2*.9)]}),zA(Qt,{color:"gold",size:[e/1.8,e/1.8,n],center:[t,A,a(-n/2)]})]})})})})]}),A1t=({numberOfPins:t,pitch:A=2.54,longSidePinLength:e=6,invert:i,faceup:n,rows:o=1,smd:s,rightangle:r})=>{const c=Math.ceil(t/o),I=2.54,l=3,B=-((c-1)/2)*A,C=!s&&!r?-2-1.6:0,Q=h=>(i||n?-h+2:h)+C;return zA(Jn,{children:Array.from({length:t},(h,E)=>{const u=Math.floor(E/c),d=E%c,f=B+d*A,m=-u*I;return zA(hie,{x:f,y:m,pinThickness:.63,shortSidePinLength:l,longSidePinLength:e,bodyHeight:2,flipZ:Q,faceup:n,smd:s,rightangle:r},E)})})},e1t=t=>{const A=["left","bottom","right","top"],{pin_count:e,pn:i,w:n,h:o,p:s,pl:r}=t,a=e/4,g=A[Math.floor((i-1)/a)],c=(i-1)%a,I=s*(a-1),l=s*(a-1),B=-r/2;switch(g){case"left":return{x:-n/2-B,y:l/2-c*s,o:"vert"};case"bottom":return{x:-I/2+c*s,y:-o/2-B,o:"horz"};case"right":return{x:n/2+B,y:-l/2+c*s,o:"vert"};case"top":return{x:I/2-c*s,y:o/2+B,o:"horz"};default:throw new Error("Invalid pin number")}},t1t=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const n=[],o=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=o:r.bottomside&&r.leftpin?s=o+1:r.bottomside&&r.rightpin?s=o*2:r.rightside&&r.bottompin?s=o*2+1:r.rightside&&r.toppin?s=o*3:r.topside&&r.rightpin?s=o*3+1:r.topside&&r.leftpin&&(s=o*4),n.push(-1);for(let a=0;a<t;a++)n[s]=a+1,s++,s>t&&(s=1);return n},i1t=({num_pins:t=16,bodyWidth:A=9,bodyLength:e=9,bodyThickness:i=.8,thermalPadSize:n,padWidth:o=.25,padLength:s=.25,pitch:r=.5,thermalPadThickness:a=.05})=>{const g=t1t({num_pins:t,cw:!0,ccw:!0}),c=[];for(let I=0;I<t;I++){const{x:l,y:B,o:C}=e1t({pin_count:t,pn:I+1,w:A,h:e,p:r,pl:s});let Q=o,h=s;C==="vert"&&([Q,h]=[h,Q]);const E=g[I+1];c.push({pn:E,x:l,y:B,pw:Q,pl:h})}return qt(Jn,{children:[zA(wo,{color:"grey",children:zA(Qt,{center:{x:0,y:0,z:i/2},size:[A,e,i]})}),c.map((I,l)=>zA(Qt,{center:{x:I.x,y:I.y,z:a/2},size:[I.pw,I.pl,a]})),n?.length!==void 0&&n?.width!==void 0&&zA(Qt,{center:{x:0,y:0,z:a/2},size:[n.width,n.length,a]})]})},n1t=i1t,o1t=()=>{const a=1.1999999999999997;return qt(Jn,{children:[zA(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}),zA(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}),zA(oo,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),zA(oo,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),zA(oo,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),zA(yB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},s1t=o1t,r1t=({fullWidth:t=2.9,fullLength:A=2.8})=>{const c=(t-1.92)/2+.3;return qt(Jn,{children:[zA(oo,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),zA(oo,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),zA(oo,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),zA(yB,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},TdA=.6,PdA=.3,Q1=.33,AJ=.1,a1t=TdA-AJ*2,Eie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[a1t,PdA,Q1],offset:[0,0,Q1/2],color:t}),zA(Qt,{size:[AJ,PdA,Q1],offset:[TdA/2-AJ/2,0,Q1/2],color:"#ccc"}),zA(Qt,{size:[AJ,PdA,Q1],offset:[-TdA/2+AJ/2,0,Q1/2],color:"#ccc"})]}),KdA=.4,qdA=.2,h1=.13,eJ=.07,g1t=KdA-eJ*2,uie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[g1t,qdA,h1],offset:[0,0,h1/2],color:t}),zA(Qt,{size:[eJ,qdA,h1],offset:[KdA/2-eJ/2,0,h1/2],color:"#ccc"}),zA(Qt,{size:[eJ,qdA,h1],offset:[-KdA/2+eJ/2,0,h1/2],color:"#ccc"})]}),OdA=3.2,WdA=1.6,E1=.9,tJ=.5,c1t=OdA-tJ*2,die=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[c1t,WdA,E1],offset:[0,0,E1/2],color:t}),zA(Qt,{size:[tJ,WdA,E1],offset:[OdA/2-tJ/2,0,E1/2],color:"#ccc"}),zA(Qt,{size:[tJ,WdA,E1],offset:[-OdA/2+tJ/2,0,E1/2],color:"#ccc"})]}),ZdA=3.2,VdA=2.5,u1=1,iJ=.6,I1t=ZdA-iJ*2,pie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[I1t,VdA,u1],offset:[0,0,u1/2],color:t}),zA(Qt,{size:[iJ,VdA,u1],offset:[ZdA/2-iJ/2,0,u1/2],color:"#ccc"}),zA(Qt,{size:[iJ,VdA,u1],offset:[-ZdA/2+iJ/2,0,u1/2],color:"#ccc"})]}),jdA=5,zdA=2.5,d1=1.4,nJ=.6,l1t=jdA-nJ*2,fie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[l1t,zdA,d1],offset:[0,0,d1/2],color:t}),zA(Qt,{size:[nJ,zdA,d1],offset:[jdA/2-nJ/2,0,d1/2],color:"#ccc"}),zA(Qt,{size:[nJ,zdA,d1],offset:[-jdA/2+nJ/2,0,d1/2],color:"#ccc"})]}),XdA=6.3,$dA=3.2,p1=1.8,oJ=.8,B1t=XdA-oJ*2,yie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[B1t,$dA,p1],offset:[0,0,p1/2],color:t}),zA(Qt,{size:[oJ,$dA,p1],offset:[XdA/2-oJ/2,0,p1/2],color:"#ccc"}),zA(Qt,{size:[oJ,$dA,p1],offset:[-XdA/2+oJ/2,0,p1/2],color:"#ccc"})]}),mie=({x:t,y:A,z:e=0,pitch:i=2.54,legsLength:n=3,innerDiameter:o=.945,bodyHeight:s=5,bodyLength:r=i,bodyWidth:a=i,flipZ:g})=>{const c=o/1.5,I=c*1.6;return qt(Jn,{children:[zA(wo,{color:"#1a1a1a",children:qt(lm,{children:[zA(Qt,{color:"#000",size:[r,a,s],center:[t,A,g(e+s/2)]}),o?zA(Ol,{height:s+.1,radius:o/2,center:[t,A,g(e+s/2)],color:"#222"}):zA(Qt,{size:[I,I,s],center:[t,A,g(e+s/2)]})]})}),qt(wo,{color:"silver",children:[qt(bc,{children:[zA(Qt,{color:"silver",size:[c,c,n*.9],center:[t,A,g(e+-n/2*.9)]}),zA(Qt,{color:"silver",size:[c/1.8,c/1.8,n],center:[t,A,g(e+-n/2)]})]}),zA(Qt,{color:"silver",size:[I,I,I*.5],center:[t,A,g(e+I/2*.5)]})]})]})},C1t=({numberOfPins:t,pitch:A=2.54,legsLength:e=3,innerDiameter:i=.945,rows:n=1,invert:o})=>{const r=Math.ceil(t/n),a=2.54,g=-((r-1)/2)*A,c=I=>o?-I+5:I;return zA(Jn,{children:Array.from({length:t},(I,l)=>{const B=Math.floor(l/r),C=l%r,Q=g+C*A,h=-B*a;return zA(mie,{x:Q,y:h,pitch:A,legsLength:e,innerDiameter:i,flipZ:c},l)})})},Q1t=({width:t,length:A,innerDiameter:e=1})=>{const i=t,n=A,o=t*.7,s=e/2.5;return qt(Jn,{children:[zA(VY,{color:"#1a1a1f",center:[0,0,o/2],size:[n,n,o],roundRadius:.3}),zA(VY,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[n,n,o*.1],roundRadius:.14}),zA(Ol,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),zA(Ol,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,n/3,o+o*.1/2]}),zA(Ol,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,-n/3,o+o*.1/2]}),zA(Ol,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,n/3,o+o*.1/2]}),zA(Ol,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,-n/3,o+o*.1/2]}),zA(MV,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:-n/2,z:-o*1.2}}),zA(MV,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:n/2,z:-o*1.2},rotation:Math.PI}),zA(MV,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:i/2,y:n/2,z:-o*1.2},rotation:Math.PI}),zA(MV,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:i/2+e/3.6,y:-n/2,z:-o*1.2}})]})},MV=t=>{const{thickness:A,width:e,horizontalLength:i,verticalLength:n,rotation:o=0,position:s}=t,r=[[0,i],[-n/3,i/3],[-n/5,i/4],[0,0]],a=GdA(r,A);return zA(wo,{color:"#f2f2f2",children:zA(Wi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:zA(gC,{rotation:[0,55,o],children:zA(zY,{height:e,children:zA(jY,{points:a.map(g=>[g.y,g.x])})})})})})},h1t=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:n})=>{const o=Math.ceil(t/2),s=(o-1)*i/2,r=.25,a=1,g=.8,c=A*0,I=i*(o-1)+e+.2,l=n*.55;return qt(Jn,{children:[Array.from({length:o}).map((B,C)=>zA(oo,{position:{x:-n/2-c,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:Math.PI,position:{x:n/2+c,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),zA(yB,{center:{x:0,y:0,z:r/2},width:l,length:I,height:a})]})},E1t=({pinCount:t,pitch:A,leadWidth:e,leadLength:i,bodyWidth:n,bodyLength:o})=>{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(n))?2.6:parseFloat(n)*.8,c=isNaN(parseFloat(o))?2+Number(r)*1.4:parseFloat(o),I=t/2,l=(I-1)*r/2,B=.15,C=.8,Q=4.5,h=(Q-g)/2,E=h*.5;return qt(Jn,{children:[Array.from({length:I}).map((u,d)=>zA(oo,{position:{x:-Q/2,y:l-d*r,z:B/2},width:a,thickness:B,padContactLength:E+.05,bodyDistance:h+.1,height:C})),Array.from({length:I}).map((u,d)=>zA(oo,{rotation:Math.PI,position:{x:Q/2,y:l-d*r,z:B/2},width:a,thickness:B,padContactLength:E+.05,bodyDistance:h+.1,height:C})),zA(yB,{center:{x:0,y:0,z:B/2},width:g,length:c,height:1})]})},u1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),zA(Qt,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Wi,{z:.3/2,children:zA(Qt,{size:[1.65,.8,.3]})}),qt(bc,{children:[zA(Wi,{z:.3,children:zA(Qt,{size:[1.65,.8,.01]})}),zA(Wi,{z:.6,children:zA(Qt,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),d1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),zA(Qt,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),zA(wo,{color:"#222",children:zA(Wi,{z:.47/2+.02,children:zA(Qt,{size:[.98,.58,.47]})})}),zA(Qt,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),zA(Qt,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),zA(Qt,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),zA(Qt,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),p1t=()=>{const g=zA(wo,{color:"#1a1a1a",children:qt(VQ,{children:[qt(bc,{children:[zA(Wi,{z:.13,children:zA(Qt,{size:[4,3,.03]})}),zA(Wi,{z:1.15,children:zA(Qt,{size:[4.4,3.4,.01]})})]}),qt(bc,{children:[zA(Wi,{z:1.15,children:zA(Qt,{size:[4.4,3.4,.01]})}),zA(Wi,{z:2.3,children:zA(Qt,{size:[4,3,.01]})})]})]})}),c=({xDir:I})=>{const C=I*1.78,Q=I*(3.4/2-.2/2+1),h=I*(3.4/2-.2/2),E=Math.abs(h-Q),u=(Q+h)/2;return zA(wo,{color:"#c0c0c0",children:qt(VQ,{children:[zA(Qt,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),zA(Qt,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),zA(Qt,{size:[E,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return qt(Jn,{children:[zA(c,{xDir:1}),zA(c,{xDir:-1}),g]})},f1t=()=>{const g=zA(wo,{color:"#1a1a1a",children:qt(VQ,{children:[qt(bc,{children:[zA(Wi,{z:.13,children:zA(Qt,{size:[4,3,.03]})}),zA(Wi,{z:1.15,children:zA(Qt,{size:[4.4,3.4,.01]})})]}),qt(bc,{children:[zA(Wi,{z:1.15,children:zA(Qt,{size:[4.4,3.4,.01]})}),zA(Wi,{z:2.3,children:zA(Qt,{size:[4,3,.01]})})]})]})}),c=({xDir:I})=>{const C=I*1.78,Q=I*(3.4/2-.2/2+1),h=I*(3.4/2-.2/2),E=Math.abs(h-Q),u=(Q+h)/2;return zA(wo,{color:"#c0c0c0",children:qt(VQ,{children:[zA(Qt,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),zA(Qt,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),zA(Qt,{size:[E,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return qt(Jn,{children:[zA(c,{xDir:1}),zA(c,{xDir:-1}),g]})},y1t=()=>{const g=zA(wo,{color:"#1a1a1a",children:qt(VQ,{children:[qt(bc,{children:[zA(Wi,{z:.21000000000000002,children:zA(Qt,{size:[6.3999999999999995,5.6,.03]})}),zA(Wi,{z:1.15,children:zA(Qt,{size:[6.8,6,.01]})})]}),qt(bc,{children:[zA(Wi,{z:1.15,children:zA(Qt,{size:[6.8,6,.01]})}),zA(Wi,{z:2.3,children:zA(Qt,{size:[6.3999999999999995,5.6,.01]})})]})]})}),c=({xDir:I})=>{const C=I*3.08,Q=I*(6/2-.2/2+1),h=I*(6/2-.2/2),E=Math.abs(h-Q),u=(Q+h)/2;return zA(wo,{color:"#c0c0c0",children:qt(VQ,{children:[zA(Qt,{size:[2.3*.8,2.95,.2],center:[C,0,.2/2]}),zA(Qt,{size:[.2,2.95,1.14],center:[Q,0,1.14/2+.2]}),zA(Qt,{size:[E,2.95,.2],center:[u,0,.2/2+1.14]})]})})};return qt(Jn,{children:[zA(c,{xDir:1}),zA(c,{xDir:-1}),g]})},m1t=()=>{const I=zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Wi,{z:.27,children:zA(Qt,{size:[2.9,1.9,.54]})}),qt(bc,{children:[zA(Wi,{z:.54,children:zA(Qt,{size:[2.9,1.9,.01]})}),zA(Wi,{z:1.08,children:zA(Qt,{size:[2.6999999999999997,1.7,.01]})})]})]})});return qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),zA(Qt,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),I]})},w1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),zA(Qt,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Wi,{z:.55/2,children:zA(Qt,{size:[2.7,1.6,.55]})}),qt(bc,{children:[zA(Wi,{z:.55,children:zA(Qt,{size:[2.7,1.6,.01]})}),zA(Wi,{z:1.1,children:zA(Qt,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),D1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),zA(Qt,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Wi,{z:.2/2,children:zA(Qt,{size:[2.75,1.8,.2]})}),qt(bc,{children:[zA(Wi,{z:.2,children:zA(Qt,{size:[2.75,1.8,.01]})}),zA(Wi,{z:1,children:zA(Qt,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),zA(Qt,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),S1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),zA(Qt,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[qt(bc,{children:[zA(Wi,{z:.2,children:zA(Qt,{size:[2.6-.1/2,1.7-.1/2,.01]})}),zA(Wi,{z:.01,children:zA(Qt,{size:[2.6-.1,1.7-.1,.01]})})]}),qt(bc,{children:[zA(Wi,{z:.2,children:zA(Qt,{size:[2.6,1.7,.01]})}),zA(Wi,{z:1,children:zA(Qt,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),zA(Qt,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),b1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),zA(Qt,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[qt(bc,{children:[zA(Wi,{z:.2,children:zA(Qt,{size:[3.8-.05/2,2.5-.05/2,.01]})}),zA(Wi,{z:.01,children:zA(Qt,{size:[3.8-.05,2.5-.05,.01]})})]}),qt(bc,{children:[zA(Wi,{z:.2,children:zA(Qt,{size:[3.8,2.5,.01]})}),zA(Wi,{z:1,children:zA(Qt,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),zA(Qt,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),x1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),zA(Qt,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Wi,{z:.14/2,children:zA(Qt,{size:[.8,.6,.14]})}),qt(bc,{children:[zA(Wi,{z:.14,children:zA(Qt,{size:[.8,.6,.01]})}),zA(Wi,{z:.37,children:zA(Qt,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),_1t=()=>{const c=3.0999999999999996;return qt(Jn,{children:[zA(oo,{rotation:Math.PI,position:{x:6.6/2+c/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(oo,{position:{x:-6.6/2-c/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(oo,{position:{x:-6.6/2-c/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(oo,{position:{x:-6.6/2-c/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(yB,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},k1t=()=>qt(Jn,{children:[Array.from({length:16}).map((B,C)=>zA(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((B,C)=>zA(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((B,C)=>zA(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((B,C)=>zA(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})),zA(yB,{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})]}),v1t=k1t,F1t=()=>{const g=.7999999999999998;return qt(Jn,{children:[zA(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}),zA(oo,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),zA(oo,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),zA(yB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},N1t=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:n})=>{const o=t/4;if(o!==Math.floor(o))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);A||(A=.5),i||(i=.6),e||(e=.22),n||(n=A*(o+4));const s=n,r=(o-1)*A/2,a=s+3.3*i,g=a,c=.8,I=.2,l=(g-n)/2+.4;return qt(Jn,{children:[Array.from({length:o}).map((B,C)=>zA(oo,{position:{x:-g/2-.36,y:C*A-r,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:Math.PI,position:{x:g/2+.36,y:C*A-r,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.36,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.36,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),zA(yB,{center:{x:0,y:0,z:0},width:n,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})]})},R1t=()=>{const i=.20900000000000002,n=.1,o=.3,s=.1,r=.2;return qt(Jn,{children:[zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Qt,{size:[.85,1.2,i],center:[0,0,i/2]}),qt(bc,{children:[zA(Wi,{z:i,children:zA(Qt,{size:[.85,1.2,.01]})}),zA(Wi,{z:.38,children:zA(Qt,{size:[.85-n,1.2-n,.01]})})]})]})}),zA(Qt,{color:"#ccc",size:[o,.25,s],center:[.55,0,s/2]}),zA(Qt,{color:"#ccc",size:[o,r,s],center:[-.55,.4,s/2]}),zA(Qt,{color:"#ccc",size:[o,r,s],center:[-.55,-.4,s/2]})]})},G1t=({num_pins:t,bodyWidth:A=5.3,bodyLength:e=5.3,bodyThickness:i=1,thermalPadSize:n,padWidth:o=e/5.3*.6,padLength:s=e/5.3*1,pitch:r=.5,thermalPadThickness:a=.2})=>{const g=[],c=Math.floor(t/2),I=r*(c-1);for(let l=0;l<t;l++){const B=l<c?"left":"right",C=l%c,Q=I/2-C*r,h=s,E=o,u=B==="left"?-A/2+h/2:A/2-h/2,d=l+1;g.push({pinNumber:d,x:u,y:Q,padSizeX:h,padSizeY:E})}return qt(Jn,{children:[zA(yB,{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((l,B)=>zA(Qt,{center:[l.x,l.y,a/2],size:[l.padSizeX,l.padSizeY,a]})),n?.length!==void 0&&n?.width!==void 0&&zA(Qt,{center:[0,0,a/2],size:[n.width,n.length,a]})]})},M1t=({bodyLength:t=10.2,bodyWidth:A=4.65,bodyHeight:e=13.46,leadSpacing:i=5,leadDiameter:n=.8,leadLength:o=12.7,color:s="#ddd",leadColor:r="#b87333"})=>{const a=t/2,g=A/2,c=a-g,I=i/2,l=.85;return qt(Jn,{children:[qt(wo,{color:s,children:[qt(bc,{children:[zA(_f,{height:e,roundRadius:.5,radius:g,center:[-c,0,e]}),zA(_f,{height:e,roundRadius:.5,radius:g,center:[c,0,e]})]}),qt(bc,{children:[zA(_f,{height:l,roundRadius:.1,radius:g+.85,center:[-c,0,e/2+l/2]}),zA(_f,{height:l,roundRadius:.1,radius:g+.85,center:[c,0,e/2+l/2]})]})]}),qt(wo,{color:r,children:[zA(Ol,{height:o+e/2,radius:n/2,center:[-I+.06,0,-(o/2)+e/2]}),zA(Ol,{height:o+e/2,radius:n/2,center:[I-.06,0,-(o/2)+e/2]})]})]})},L1t=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:n="#111"})=>qt(Jn,{children:[zA(wo,{color:e,children:qt(gC,{rotation:[0,"90deg",0],children:[zA(VY,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),zA(Ol,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),zA(wo,{color:n,children:zA(gC,{rotation:[0,"90deg",0],children:zA(VY,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),zA(wo,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),zA(wo,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),U1t=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>qt(Jn,{children:[zA(wo,{color:e,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),zA(wo,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),zA(wo,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),H1t=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>qt(Jn,{children:[zA(wo,{color:e,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),zA(wo,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),zA(wo,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),Y1t=({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 n=t/2,o=4.9,s=3.9,r=(n-1)*i/2,a=.2;return qt(Jn,{children:[Array.from({length:n}).map((g,c)=>zA(oo,{position:{x:-s/2-A-.3,y:c*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,c)=>zA(oo,{rotation:Math.PI,position:{x:s/2+A+.3,y:c*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),zA(yB,{center:{x:0,y:0,z:a/2},width:s,length:o,height:1.55,notchPosition:{x:-.95,y:o/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},J1t=({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 n=t/2,o=7.5,s=10.3,r=(n-1)*i/2,a=.2;return qt(Jn,{children:[Array.from({length:n}).map((g,c)=>zA(oo,{position:{x:-o/2-A-.3,y:c*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,c)=>zA(oo,{rotation:Math.PI,position:{x:o/2+A+.3,y:c*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),zA(yB,{center:{x:0,y:0,z:a/2},width:o,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},T1t=()=>{const Q=7.050000000000001,h=24.95+6.5/2;return zA(Wi,{center:[0,0,1],children:qt(Jn,{children:[qt(gC,{rotation:[0,55,-55],children:[qt(lm,{children:[zA(Qt,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[h,0,1.3-2]}),zA(Ol,{color:"black",center:[h,0,1.3-2],radius:3/2,height:1.3*1.2})]}),zA(wo,{color:"#222",children:zA(yB,{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})})]}),zA(gC,{rotation:[0,55,55],children:Array.from({length:3}).map((E,u)=>{const d=Q,f=(u-1)*2.7,m=-.5-.6;return qt(wo,{color:"gold",children:[qt(bc,{children:[zA(Wi,{center:[15.05-4.5/2+.1,f,m],children:zA(Qt,{size:[4.5,.81+1,.5]})}),zA(Wi,{center:[15.05-4.5/2-1+.1,f,m],children:zA(Qt,{size:[4.5,.81,.5]})})]}),zA(Wi,{center:[d,f,m],children:zA(Qt,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},P1t=()=>{const g=1.1999999999999997;return qt(Jn,{children:[zA(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}),zA(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}),zA(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}),zA(oo,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(oo,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(oo,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(yB,{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})]})},K1t=()=>qt(Jn,{children:[zA(yB,{center:{x:0,y:0,z:0},width:.8,length:1,height:.37,heightAboveSurface:0,color:"#1a1a1a",taperRatio:.15,straightHeightRatio:0,notchPosition:{x:-.8/4,y:.7/2.2,z:.37+.1}}),[0,1,2].map(g=>{const c=-.35+g*.35;return zA(Qt,{center:[-.8/2+.19/2-.1,c,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(g=>{const c=-.35+g*.35;return zA(Qt,{center:[.8/2-.19/2+.1,c,.12/2],size:[.19,.15,.12]})})]}),q1t=()=>{const s="#222",a=[.43,.4,1.32],g=[.43,.4,.25],c=[0,0,-.66],I=[0,0,-1.32],l=[0,1.28,-2.72],B=[0,1.28,-8.9],C=-7.5;return qt(Wi,{center:[0,1,10.5],children:[zA(wo,{color:s,children:qt(lm,{children:[zA(Wi,{center:[0,0,2.25],children:zA(Ol,{radius:2.4,height:4.5})}),zA(Wi,{center:[0,-1.8499999999999999,2.25],children:zA(Qt,{size:[2.4*2,1.1,4.5+.2]})})]})}),zA(Wi,{center:c,children:zA(Qt,{size:a})}),qt(bc,{children:[zA(Wi,{center:I,children:zA(Qt,{size:g})}),zA(Wi,{center:l,children:zA(Qt,{size:g})})]}),zA(Wi,{center:B,children:zA(Qt,{size:[.43,.4,12.2]})}),zA(Wi,{center:[1.3,0,C],children:zA(Qt,{size:[.43,.4,15]})}),zA(Wi,{center:[-1.3,0,C],children:zA(Qt,{size:[.43,.4,15]})})]})},O1t=()=>qt(Jn,{children:[zA(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}),zA(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}),zA(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}),zA(oo,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(oo,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(oo,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(yB,{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})]}),W1t=O1t,Z1t=()=>qt(Jn,{children:[zA(yB,{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 zA(Qt,{center:[-1/2+.3/2,a,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(r=>{const a=-.5+r*.5;return zA(Qt,{center:[1/2-.3/2,a,.05/2],size:[.3,.2,.05]})})]}),V1t=()=>qt(Jn,{children:[zA(oo,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),zA(oo,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),zA(wo,{color:"#222",children:zA(yB,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),zA(Qt,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),j1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),zA(Qt,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Wi,{z:.175/2,children:zA(Qt,{size:[1.7,1.25,.175]})}),qt(bc,{children:[zA(Wi,{z:.175,children:zA(Qt,{size:[1.7,1.25,.01]})}),zA(Wi,{z:.725,children:zA(Qt,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),zA(Qt,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),z1t=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),zA(Qt,{color:"#ccc",size:[.4,.325,.13],center:[r,0,.13/2]}),zA(wo,{color:"#222",children:zA(yB,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),zA(Qt,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},X1t=({pitch:t=10})=>qt(Jn,{children:[zA(Ol,{height:4,radius:.5,center:[-t/2,0,.5]}),zA(NV,{radius:.5,center:[-t/2,0,2.5]}),zA(Wi,{x:-2.5,y:0,z:2.5,children:qt(gC,{rotation:[0,Math.PI/2,0],children:[zA(Ol,{height:t,radius:.5,center:[0,0,2.5]}),zA(wo,{color:"#d2b48c",children:zA(Ol,{height:5,radius:1.3,center:[0,0,2.5]})})]})}),zA(Ol,{height:4,radius:.5,center:[t/2,0,.5]}),zA(NV,{radius:.5,center:[t/2,0,2.5]})]}),$1t=({bodyWidth:t=21,boardThickness:A=.5,leadWidth:e=1.6,leadLength:i=2.4,leadsPitch:n=2.54,leadsLeft:o,leadsRight:s,leadsTop:r,leadsBottom:a,innerHoles:g=!0,innerHoleEdgeDistance:c=1.61,innerHoleDiameter:I=1})=>{const l=t/2,B=A/2,C=A*1.05,Q=I/2,h=Math.max(o||0,s||0,r||0,a||0)*n||51,E=[],u=[];if(s){const w=-((s-1)/2)*n;for(let D=0;D<s;D++){const S=w+D*n;E.push({x:l-i/2,y:-S,pl:i,pw:e}),g&&u.push({x:l,y:-S},{x:l-c,y:-S})}}if(o){const w=-((o-1)/2)*n;for(let D=0;D<o;D++){const S=w+D*n;E.push({x:-l+i/2,y:-S,pl:i,pw:e}),g&&u.push({x:-l,y:-S},{x:-l+c,y:-S})}}if(r){const w=-((r-1)/2)*n;for(let D=0;D<r;D++){const S=w+D*n;E.push({x:-S,y:h/2-i/2,pl:e,pw:i}),g&&u.push({x:-S,y:h/2},{x:-S,y:h/2-c})}}if(a){const w=-((a-1)/2)*n;for(let D=0;D<a;D++){const S=w+D*n;E.push({x:-S,y:-h/2+i/2,pl:e,pw:i}),g&&u.push({x:-S,y:-h/2},{x:-S,y:-h/2+c})}}const d=zA(wo,{color:"#008080",children:qt(lm,{children:[zA(Qt,{center:[0,0,B],size:[t,h,A]}),E.map((w,D)=>zA(Qt,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]},D))]})}),f=g&&u.map((w,D)=>zA(Ol,{color:"black",center:[w.x,w.y,B],radius:Q,height:A*1.07})),m=E.map((w,D)=>zA(Qt,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]}));return qt(Jn,{children:[d,zA(wo,{color:"#FFD700",children:g?qt(lm,{children:[zA(VQ,{children:E.map((w,D)=>zA(Qt,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]},D))}),f]}):m})]})},A2t=({width:t=30,height:A=22,thickness:e=1,bezelInset:i=2,bezelDepth:n=1,screenColor:o="#001414",bezelColor:s="#0f1116",screenWidth:r,screenHeight:a,offset:g})=>{const c=t,I=A,l=Math.max(e,.4),B=Math.max(Math.min(n,l),.2),C=Math.max(l-B,0),Q=Math.max(i,0),h=Math.max(r??c-Q*2,2),E=Math.max(a??I-Q*2,2),u=Math.min(Math.max(B*.6,.2),B),d=g?.x??0,f=g?.y??0,m=g?.z??0;return qt(Wi,{offset:{x:d,y:f,z:m},children:[C>0&&zA(wo,{color:s,children:zA(Qt,{size:[c,I,C],offset:[0,0,C/2]})}),zA(wo,{color:s,children:qt(lm,{children:[zA(Qt,{size:[c,I,B],offset:[0,0,C+B/2]}),zA(Qt,{size:[h,E,B+.02],offset:[0,0,C+B/2]})]})}),zA(wo,{color:o,children:zA(Qt,{size:[h,E,u],offset:[0,0,C+u/2]})})]})},e2t=({numPins:t=5,rows:A=1,p:e=2.54,id:i=1,od:n=1.5,boardThickness:o=1.6,width:s,height:r,pinRowSide:a="left",holes:g=[],holeInset:c=1,pinRowHoleEdgeToEdgeDist:I=2,female:l,nopin:B,screen:C,screenWidth:Q,screenHeight:h,screenCenterOffsetX:E,screenCenterOffsetY:u})=>{const d=C??!1,f=o/2,m=Math.ceil(t/A);let w,D;a==="left"||a==="right"?(w=(A-1)*e+2*I,D=(m-1)*e+2*I):(D=(A-1)*e+2*I,w=(m-1)*e+2*I),t===0&&(w=10,D=10);const S=Number(s??w),_=Number(r??D),x=[];let G=0,F=0,L=0,Y=0,J=0,O=0;a==="left"||a==="right"?(G=a==="left"?-S/2+I:S/2-I,F=-((m-1)/2)*e,L=0,Y=e,J=a==="left"?e:-e,O=0):(G=-((m-1)/2)*e,F=a==="top"?_/2-I:-_/2+I,L=e,Y=0,J=0,O=a==="top"?-e:e);let Z=0;for(let QA=0;QA<A&&Z<t;QA++)for(let _A=0;_A<m&&Z<t;_A++){const dA=G+_A*L+QA*J,KA=F+_A*Y+QA*O;x.push({x:dA,y:KA}),Z++}const X=[];if(g)for(const QA of g){let _A=0,dA=0;QA==="topleft"?(_A=-S/2+c,dA=_/2-c):QA==="topright"?(_A=S/2-c,dA=_/2-c):QA==="bottomleft"?(_A=-S/2+c,dA=-_/2+c):QA==="bottomright"?(_A=S/2-c,dA=-_/2+c):QA==="center"&&(_A=0,dA=0),X.push({x:_A,y:dA})}const eA=.63,gA=2,tA=6,iA=3,sA=B||l?0:gA,aA=sA+o,EA=zA(wo,{color:"#008080",children:qt(lm,{children:[zA(Qt,{center:[0,0,f+sA],size:[S,_,o]}),X.map((QA,_A)=>zA(Ol,{center:[QA.x,QA.y,f+sA],radius:n/2,height:o},`hole-${_A}`)),x.map((QA,_A)=>zA(Ol,{center:[QA.x,QA.y,f+sA],radius:n/2,height:o},`pin-hole-${_A}`))]})}),bA=x.map((QA,_A)=>zA(wo,{color:"#FFD700",children:qt(lm,{children:[zA(Ol,{center:[QA.x,QA.y,o/2+sA],radius:n/2,height:o}),zA(Ol,{center:[QA.x,QA.y,o/2+sA],radius:i/2,height:o})]})})),xA=x.map((QA,_A)=>zA(hie,{x:QA.x,y:QA.y,pinThickness:eA,shortSidePinLength:iA,longSidePinLength:tA,bodyHeight:gA,flipZ:dA=>dA})),YA=x.map((QA,_A)=>zA(mie,{x:QA.x,y:QA.y,flipZ:dA=>-dA}));return qt(Jn,{children:[EA,bA,!l&&!B&&xA,l&&YA,d&&zA(A2t,{width:Q??S*.8,height:h??_*.6,offset:{x:E??0,y:u??0,z:aA}})]})},t2t=({footprint:t})=>{const A=UMt.string(t).json();switch(A.fn){case"dip":return zA(PMt,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"axial":return zA(X1t,{pitch:A.p});case"tssop":return zA(qMt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return zA(OMt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return zA(E1t,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return zA(jMt,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return zA(v1t,{});case"lqfp":return zA(N1t,{pinCount:A.num_pins});case"qfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return zA(n1t,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:n?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"dfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return zA(G1t,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:n?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"pinrow":{const n=t.match(/_rows(\d+)/),o=n&&n[1]?parseInt(n[1],10):1;if(A.male)return zA(A1t,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:o,smd:A.smd||A.surface_mount,rightangle:A.rightangle});if(A.female)return zA(C1t,{numberOfPins:A.num_pins,pitch:A.p,rows:o})}case"cap":switch(A.imperial){case"0402":return zA(Bie,{color:"#856c4d"});case"0603":return zA(Cie,{color:"#856c4d"});case"0805":return zA(Qie,{color:"#856c4d"});case"0201":return zA(Eie,{color:"#856c4d"});case"01005":return zA(uie,{color:"#856c4d"});case"1206":return zA(die,{color:"#856c4d"});case"1210":return zA(pie,{color:"#856c4d"});case"2010":return zA(fie,{color:"#856c4d"});case"2512":return zA(yie,{color:"#856c4d"})}case"sot235":return zA(s1t,{});case"sot457":return zA(P1t,{});case"sot223":return zA(_1t,{});case"sot23w":return zA(r1t,{});case"sot323":return zA(F1t,{});case"sod323f":return zA(j1t,{});case"sod323fl":return zA(z1t,{});case"sot363":return zA(W1t,{});case"sot886":return zA(Z1t,{});case"sot963":return zA(K1t,{});case"pushbutton":return zA(Q1t,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return zA(h1t,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return zA(u1t,{});case"sod882":return zA(d1t,{});case"sma":return zA(p1t,{});case"smb":return zA(f1t,{});case"smc":return zA(y1t,{});case"smf":return zA(m1t,{});case"sod123f":return zA(w1t,{});case"sod123fl":return zA(D1t,{});case"sod123w":return zA(S1t,{});case"sod128":return zA(b1t,{});case"sod323":return zA(V1t,{});case"sod923":return zA(x1t,{});case"hc49":return zA(M1t,{});case"micromelf":return zA(L1t,{});case"minimelf":return zA(U1t,{});case"melf":return zA(H1t,{});case"ms012":return zA(Y1t,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return zA(J1t,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return zA(R1t,{});case"to220":return zA(T1t,{});case"to92":return zA(q1t,{});case"stampboard":case"stampreceiver":return zA($1t,{bodyWidth:A.w,leadsLeft:A.left,leadsRight:A.right,leadsTop:A.top,leadsBottom:A.bottom,leadsPitch:A.p,leadWidth:A.pw,leadLength:A.pl,innerHoles:A.innerhole,innerHoleEdgeDistance:A.innerholeedgedistance});case"mountedpcbmodule":{const n=A.rows??1,o=A.pinRowSide??"left",s=A.holeInset,r=A.width,a=A.height,g=A.pinrow,c=A.pinRowHoleEdgeToEdgeDist,I=Array.isArray(A.holes)?A.holes:[];return zA(e2t,{numPins:g,rows:n,p:A.p,id:A.id,od:A.od,width:r,height:a,pinRowSide:o,holes:I,holeInset:s,pinRowHoleEdgeToEdgeDist:c,nopin:A.nopin,female:A.female,screen:A.screen,screenWidth:A.screenwidth,screenHeight:A.screenheight,screenCenterOffsetX:A.screencenteroffsetx,screenCenterOffsetY:A.screencenteroffsety})}}const e=t.match(/_color\(([^)]+)\)/),i=e?e[1]:void 0;switch(A.imperial){case"0402":return zA(Bie,{color:i});case"0603":return zA(Cie,{color:i});case"0805":return zA(Qie,{color:i});case"0201":return zA(Eie,{color:i});case"01005":return zA(uie,{color:i});case"1206":return zA(die,{color:i});case"1210":return zA(pie,{color:i});case"2010":return zA(fie,{color:i});case"2512":return zA(yie,{color:i})}return null},i2t=t=>t&&typeof t=="object"&&"type"in t,f1=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},n2t=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 JD(t,A,e){const{jscad:{primitives:i,booleans:n,hulls:o,geometries:s,extrusions:r,transforms:a}}=e;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(l=>JD(l,A,e));if(!i2t(t))return[];const{type:g,props:c,children:I}=t;if(g===cie)return(I??[]).flatMap(l=>JD(l,A,e));if(g===wo){const l=c?.color;return(I??[]).flatMap(B=>JD(B,l??A,e))}if(g===Wi){const l=n2t(c?.offset??c?.center??{x:c?.x,y:c?.y,z:c?.z});return(I??[]).flatMap(C=>JD(C,A,e)).map(({geom:C,color:Q})=>({geom:a.translate(l,C),color:Q??A}))}if(g===gC){const l=Array.isArray(c?.rotation)?[f1(c.rotation[0]),f1(c.rotation[1]),f1(c.rotation[2])]:[f1(c?.x??0),f1(c?.y??0),f1(c?.z??0)];return(I??[]).flatMap(C=>JD(C,A,e)).map(({geom:C,color:Q})=>({geom:a.rotateZ(l[2],a.rotateY(l[1],a.rotateX(l[0],C))),color:Q}))}if(g===VQ||g===lm||g===bc){const l=(I??[]).flatMap(C=>JD(C,A,e)).map(C=>C.geom);if(l.length===0)return[];let B;return g===VQ?B=n.union(l):g===lm?B=n.subtract(l[0],l.slice(1)):B=o.hull(l),[{geom:B,color:A}]}if(g===jY){const l=c?.points??[];return[{geom:s.geom2.fromPoints(l),color:A??c?.color}]}if(g===zY){const l=(I??[]).flatMap(h=>JD(h,A,e)).map(h=>h.geom);if(l.length===0)return[];const B=l.length>1?n.union(l):l[0],C=c?.height??c?.h??1;let Q=r.extrudeLinear({height:C},B);if(Q.polygons)for(const h of Q.polygons)!h.plane||!h.vertices||h.vertices.length<3||h.vertices.reverse();return[{geom:Q,color:A??c?.color}]}if(g===Qt||g===Iie||g===Ol||g===NV||g===VY||g===_f){let l;if(g===Qt){const B=c?.size??[1,1,1],C=c?.offset,Q=c?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);l=i.cuboid({size:B,center:Q})}else if(g===Iie){const B=c?.size??1,C=c?.offset,Q=c?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);l=i.cube({size:B,center:Q})}else if(g===Ol){const B=c?.height??1,C=c?.radius??1,Q=c?.center??[0,0,0];l=i.cylinder({height:B,radius:C,center:Q})}else if(g===NV){const B=c?.radius??1,C=c?.center??[0,0,0];l=i.sphere({radius:B,center:C})}else if(g===_f){const B=c?.height??1,C=c?.radius??1,Q=c?.roundRadius??.1,h=c?.center??[0,0,0];l=i.roundedCylinder({height:B,radius:C,roundRadius:Q,center:h})}else{const B=c?.size??[1,1,1],C=c?.roundRadius??.1,Q=c?.center??[0,0,0];l=i.roundedCuboid({size:B,roundRadius:C,center:Q})}return[{geom:l,color:A??c?.color}]}if(typeof g=="function"){const l=g(c??{});return JD(l,A,e)}return(I??[]).flatMap(l=>JD(l,A,e))}function o2t(t,A){return{geometries:JD(t,void 0,{jscad:A})}}function wie(t){if(t.polygons){const A=[],e=[],i=[];let n=0;for(const s of t.polygons){for(const a of s.vertices)a.index=n,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),n++;const r=s.vertices[0].index;for(let a=2;a<s.vertices.length;a++){const g=s.vertices[a-1].index,c=s.vertices[a].index;e.push(r,g,c)}}const o=new Gg;if(o.setAttribute("position",new Sc(new Float32Array(A),3)),o.setIndex(e),i.length>0&&o.setAttribute("color",new Sc(new Float32Array(i),3)),t.transforms){const s=new Qs;s.fromArray(t.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(t.sides){const A=[],e=[];for(const n of t.sides)A.push(n[0][0],n[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 Gg;if(i.setAttribute("position",new Sc(new Float32Array(A),3)),e.length>0&&i.setAttribute("color",new Sc(new Float32Array(e),3)),t.transforms){const n=new Qs;n.fromArray(t.transforms),i.applyMatrix4(n)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Gg}function s2t(t,A){const e=RdA(t2t,{footprint:t});return o2t(e,A)}var r2t=ka(wV()),Die=V.createContext(null),a2t=()=>{const t=V.useContext(Die);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},g2t=({children:t})=>{const{camera:A,renderer:e}=ed(),[i,n]=V.useState([]),o=V.useMemo(()=>new $Et,[]),s=V.useMemo(()=>new dn,[]),r=V.useRef(i);r.current=i;const a=V.useRef(null),g=V.useCallback(C=>{n(Q=>[...Q,C])},[]),c=V.useCallback(C=>{if(a.current){let Q=!1,h=a.current.object;for(;h;){if(h===C){Q=!0;break}h=h.parent}Q&&(a.current.onUnhover(),a.current=null)}n(Q=>Q.filter(h=>h.object!==C))},[]),I=V.useCallback(C=>{let Q=C;for(;Q;){const h=r.current.find(E=>E.object===Q);if(h)return h;Q=Q.parent}},[]),l=V.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,o.setFromCamera(s,A);const h=r.current.map(u=>u.object);if(h.length===0){a.current&&(a.current.onUnhover(),a.current=null);return}const E=o.intersectObjects(h,!0);if(E.length>0){const u=E[0],d=I(u.object);if(d){const f={mousePosition:[u.point.x,u.point.y,u.point.z]};a.current!==d?(a.current?.onUnhover(),d.onHover(f),a.current=d):d.onHover(f)}else a.current&&(a.current.onUnhover(),a.current=null)}else a.current&&(a.current.onUnhover(),a.current=null)},[A,e,o,s,I]);V.useEffect(()=>{const C=e.domElement;return C.addEventListener("mousemove",l),()=>{C.removeEventListener("mousemove",l)}},[e,l]);const B=V.useMemo(()=>({addHoverable:g,removeHoverable:c}),[g,c]);return W.jsx(Die.Provider,{value:B,children:t})},c2t=({children:t,object:A,onHover:e,onUnhover:i,isHovered:n})=>{const{addHoverable:o,removeHoverable:s}=a2t();return V.useEffect(()=>A?(o({object:A,onHover:e,onUnhover:i}),()=>{s(A)}):void 0,[A,e,i,o,s]),W.jsx(W.Fragment,{children:t})},sJ=c2t,I2t=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=ed(),g=V.useMemo(()=>{if(!A)return null;const{geometries:c}=s2t(A,r2t),I=new xf;for(const l of c.flat(1/0)){const B=l.geom;if(!B||!B.polygons&&!B.sides)continue;const C=new An(l.color);C.convertLinearToSRGB();const Q={...B,color:[C.r,C.g,C.b]},h=wie(Q),E=new qE({vertexColors:!0,side:aC,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new lo(h,E);I.add(u)}return I},[A,r]);return V.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),V.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]),V.useEffect(()=>{g&&g.traverse(c=>{c instanceof lo&&c.material instanceof qE&&(o?(c.material.emissive.setHex(255),c.material.emissiveIntensity=.2):c.material.emissiveIntensity=0)})},[o,g]),g?W.jsx(sJ,{isHovered:o,onHover:i,onUnhover:n,object:g}):null},Sie=new WeakMap,l2t=()=>{const t=new tI;return t.name="fallback-environment-map",t.mapping=kW,t},B2t=t=>{if(!t)return null;const A=t,e=Sie.get(A);if(e)return e;let i;if(t instanceof aZ){const n=new YgA(t);i=n.fromScene(mut(),.04).texture,n.dispose()}else i=l2t();return Sie.set(A,i),i},bie=1.25;function xie({gltfUrl:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=ed(),[c,I]=V.useState(null),[l,B]=V.useState(null);if(V.useEffect(()=>{if(!t)return;const C=new Dut;let Q=!0;return C.load(t,h=>{if(!Q)return;const E=h.scene;E.traverse(u=>{if(u instanceof lo&&u.material){const d=f=>{f.transparent=r,f.opacity=r?.5:1,f.depthWrite=!r,f.needsUpdate=!0};Array.isArray(u.material)?u.material.forEach(d):d(u.material)}}),I(E)},void 0,h=>{if(!Q)return;console.error(`An error happened loading ${t}`,h);const E=h instanceof Error?h:new Error(`Failed to load glTF model from ${t}`);B(E)}),()=>{Q=!1}},[t,r]),V.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]),V.useEffect(()=>{if(!(!g||!c))return g.add(c),()=>{g.remove(c)}},[g,c]),V.useEffect(()=>{if(!c||!a)return;const C=B2t(a);if(!C)return;const Q=[],h=E=>{E instanceof qE&&(Q.push({material:E,envMap:E.envMap??null,envMapIntensity:E.envMapIntensity??1}),E.envMap=C,(typeof E.envMapIntensity!="number"||E.envMapIntensity<bie)&&(E.envMapIntensity=bie),E.needsUpdate=!0)};return c.traverse(E=>{if(!(E instanceof lo))return;const u=E.material;Array.isArray(u)?u.forEach(h):u&&h(u)}),()=>{Q.forEach(({material:E,envMap:u,envMapIntensity:d})=>{E.envMap=u,E.envMapIntensity=d,E.needsUpdate=!0})}},[c,a]),V.useEffect(()=>{c&&c.traverse(C=>{C instanceof lo&&C.material instanceof qE&&(o?(C.material.emissive.setHex(255),C.material.emissiveIntensity=.2):C.material.emissiveIntensity=0)})},[o,c]),l)throw l;return c?W.jsx(sJ,{isHovered:o,onHover:i,onUnhover:n,object:c}):null}var C2t=ka(Fte()),Q2t=ka(wV()),h2t=({jscadPlan:t,positionOffset:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=ed(),{threeGeom:g,material:c}=V.useMemo(()=>{const l=(0,C2t.executeJscadOperations)(Q2t.default,t);if(!l||!l.polygons&&!l.sides)return{threeGeom:null,material:null};const B=wie(l),C=new qE({vertexColors:!0,side:aC,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:B,material:C}},[t,r]),I=V.useMemo(()=>g?new lo(g,c):null,[g,c]);return V.useEffect(()=>{if(!(!I||!a))return a.add(I),()=>{a.remove(I)}},[a,I]),V.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]),V.useMemo(()=>{if(c)if(o){const l=new An(c.color.getHex());c.emissive.copy(l),c.emissive.setRGB(0,0,1),c.emissiveIntensity=.2}else c.emissiveIntensity=0},[o,c]),g?W.jsx(sJ,{isHovered:o,onHover:i,onUnhover:n,object:I}):null};function E2t(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(A,e,i)=>`${e} ${i.replace(/-/g,"_")}`)}async function u2t(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 cdt().parse(E2t(e),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function d2t(t){const[A,e]=V.useState(null);return V.useEffect(()=>{if(!t)return;const i=t.replace(/&cachebust_origin=$/,""),n=window.TSCIRCUIT_OBJ_LOADER_CACHE;let o=!1;async function s(){try{if(i.endsWith(".wrl"))return await u2t(i);const a=await fetch(i);if(!a.ok)throw new Error(`Failed to fetch "${i}": ${a.status} ${a.statusText}`);const g=await a.text(),c=g.match(/newmtl[\s\S]*?endmtl/g),I=new ddt;if(c?.length){const l=c.join(`
|
|
5156
|
-
`).replace(/d 0\./g,"d 1."),B=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new rdt;C.setMaterialOptions({invertTrProperty:!0});const Q=C.parse(l.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return I.setMaterials(Q),I.parse(B)}return I.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(n.has(i)){const g=n.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(c=>c instanceof Error?c:c.clone())}const a=s().then(g=>(g instanceof Error||n.set(i,{...n.get(i),result:g}),g));return n.set(i,{promise:a,result:null}),a}return r().then(a=>{o||e(a)}).catch(a=>{console.error(a)}),()=>{o=!0}},[t]),A}function p2t({url:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const a=d2t(t),{rootObject:g}=ed(),c=V.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(I=>{if(I instanceof lo&&I.material){const l=B=>{B.transparent=r,B.opacity=r?.5:1,B.depthWrite=!r,B.needsUpdate=!0};Array.isArray(I.material)?I.material.forEach(l):l(I.material)}}),a):new lo(new fw(.5,.5,.5),new qE({transparent:!0,color:"red",opacity:.25})),[a,r]);if(V.useEffect(()=>{if(!(!g||!c))return g.add(c),()=>{g.remove(c)}},[g,c]),V.useEffect(()=>{c&&(A&&(Array.isArray(A)?c.position.fromArray(A):c.position.copy(A)),e&&(Array.isArray(e)?c.rotation.fromArray(e):c.rotation.copy(e)),s!==void 0&&c.scale.setScalar(s))},[c,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(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 W.jsx(sJ,{isHovered:o,onHover:i,onUnhover:n,object:c})}var ApA,f2t="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function y2t(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 m2t(){if(!ApA){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");ApA=y2t(t)({locateFile:e=>`${f2t}/${e}`})}return ApA}function w2t(t){const A=new xf;for(const e of t){const i=e.attributes.position?.array??[],n=e.index?.array??[];if(!i.length||!n.length)continue;const o=new Gg;o.setAttribute("position",new $o(i,3));const s=e.attributes.normal?.array??[];s.length?o.setAttribute("normal",new $o(s,3)):o.computeVertexNormals(),o.setIndex(n);const r=new qE({color:e.color?new An(e.color[0],e.color[1],e.color[2]):new An(.82,.82,.82)}),a=new lo(o,r);a.name=e.name,A.add(a)}return A}async function D2t(t){const A=await fetch(t);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const e=await A.arrayBuffer(),n=(await m2t()).ReadStepFile(new Uint8Array(e),null);if(!n.success||!n.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=w2t(n.meshes),s=new EcA;return await new Promise((a,g)=>{s.parse(o,c=>{c instanceof ArrayBuffer?a(c):g(new Error("GLTFExporter did not return binary output"))},c=>{g(c)},{binary:!0})})}var _ie="step-glb-cache:";function S2t(t){const A=new Uint8Array(t),e=32768;let i="";for(let n=0;n<A.length;n+=e){const o=A.subarray(n,n+e);i+=String.fromCharCode(...o)}return btoa(i)}function b2t(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 x2t(t){try{const A=localStorage.getItem(`${_ie}${t}`);return A?b2t(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function kie(t,A){try{const e=S2t(A);localStorage.setItem(`${_ie}${t}`,e)}catch(e){console.warn("Failed to write STEP GLB cache",e)}}function _2t(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var k2t=({stepUrl:t,position:A,rotation:e,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r})=>{const[a,g]=V.useState(null);return V.useEffect(()=>{let c=!0,I=null,l=!0;const B=_2t(),C=x2t(t);if(C){const E={arrayBuffer:C,blobUrl:URL.createObjectURL(new Blob([C],{type:"model/gltf-binary"}))};return B.completed.set(t,E),I=E.blobUrl,l=!1,g(E.blobUrl),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)}}const Q=B.completed.get(t);if(Q)return I=Q.blobUrl,l=!1,g(Q.blobUrl),kie(t,Q.arrayBuffer),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)};let h=B.inProgress.get(t);return h||(h=D2t(t).then(E=>{const u={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return B.completed.set(t,u),B.inProgress.delete(t),u}).catch(E=>{throw B.inProgress.delete(t),E}),B.inProgress.set(t,h)),h.then(E=>{c&&(I=E.blobUrl,l=!1,g(E.blobUrl),kie(t,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),c&&g(null)}),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)}},[t]),a?W.jsx(xie,{gltfUrl:a,position:A,rotation:e,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r}):null},v2t=(t,A)=>{if(t)return A?A(t):t},vie=(...t)=>t,epA=class extends Bn.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}},F2t=({error:t,onError:A})=>(V.useEffect(()=>{A(t)},[t,A]),null),Fie=({cad_component:t,circuitJson:A,resolveStaticAsset:e})=>{const i=Gte(A),[n,o]=V.useState(!1),{visibility:s}=PF(),[r,a]=V.useState(null),g=V.useCallback(G=>{G?.mousePosition?(o(!0),a(G.mousePosition)):(o(!1),a(null))},[]),c=V.useCallback(()=>{o(!1),a(null)},[]),I=V.useMemo(()=>mn(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),l=V.useMemo(()=>A.filter(F=>F.type==="pcb_plated_hole"&&F.pcb_component_id===t.pcb_component_id).length>0,[A,t.pcb_component_id]),B=V.useCallback(G=>v2t(G,e),[e]),C=B(t.model_obj_url??t.model_wrl_url??t.model_stl_url),Q=B(t.model_glb_url??t.model_gltf_url),h=B(t.model_step_url),[E,u]=V.useState(0),[d,f]=V.useState(null);V.useEffect(()=>{u(0),f(null)},[t.cad_component_id,C,Q,h]);const w=A.find(G=>G.type==="pcb_component"&&G.source_component_id===t.source_component_id)?.layer??"top",D=V.useMemo(()=>t.rotation?vie(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):vie(0,0,0),[t.rotation,w]),S=V.useMemo(()=>{if(!t.position)return;let G;return w==="top"?G=t.position.z:w==="bottom"?G=-(t.position.z+i):G=t.position.z,[t.position.x,t.position.y,G]},[t.position,w,i]),_=V.useMemo(()=>{const G=[];return C&&G.push(W.jsx(p2t,{url:C,position:S,rotation:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${C}`)),Q&&G.push(W.jsx(xie,{gltfUrl:Q,position:S,rotation:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${Q}`)),h&&!t.model_jscad&&!t.footprinter_string&&G.push(W.jsx(k2t,{stepUrl:h,position:S,rotation:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${h}`)),G},[S,t.cad_component_id,t.footprinter_string,t.model_jscad,t.model_unit_to_mm_scale_factor,t.show_as_translucent_model,Q,g,c,n,D,h,C]);let x=null;if(_.length>0){if(E>=_.length){if(d)throw d;return null}x=W.jsx(epA,{fallback:({error:G})=>W.jsx(F2t,{error:G,onError:F=>{f(F),u(L=>Math.max(L,E+1))}}),children:_[E]},`${t.cad_component_id}-fallback-${E}`)}else t.model_jscad?x=W.jsx(h2t,{jscadPlan:t.model_jscad,positionOffset:S,rotationOffset:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(x=W.jsx(I2t,{positionOffset:S,rotationOffset:D,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model}));if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(l&&!s.throughHoleModels||!l&&!s.smtModels)return null;return W.jsxs(W.Fragment,{children:[x,n&&r?W.jsx(Lte,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:I??"<unknown>"}):null]})},Nie={version:"0.0.536"};function N2t(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var R2t=t=>{t.outputColorSpace=lw,t.toneMapping=n5A,t.toneMappingExposure=1},Rie="cadViewerCameraStateSession",Gie=(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(Rie,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},tpA=(t,A)=>{try{const e=sessionStorage.getItem(Rie);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 n=t;n.fov=i.fov,n.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),t.updateMatrixWorld(),!0}catch(e){return console.warn("Failed to restore camera:",e),!1}},Mie=V.createContext(void 0),G2t=({children:t,defaultTarget:A,initialCameraPosition:e})=>{const i=V.useRef(null),n=V.useRef(null),[o,s]=V.useState(null),[r,a]=V.useState("perspective"),[g,c]=V.useState(e??null),[I,l]=V.useState(new Sf(0,0,0)),B=V.useMemo(()=>{const[E,u,d]=e??[5,-5,5],f=Math.hypot(E-A.x,u-A.y,d-A.z);return f>0?f:5},[e,A]),C=V.useCallback(E=>{const u=[A.x,A.y,A.z],d=n.current,f=i.current;let m=B;switch(d&&f&&(m=d.position.distanceTo(f.target)),E){case"Top Center Angled":{const w=m/Math.sqrt(2);return{position:[A.x,A.y-w,A.z+w],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+m],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-m,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+m,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-m,A.z],target:u,up:[0,0,1]};default:return null}},[B,A,n,i]),Q=V.useCallback(E=>{i.current=E},[]),h=V.useMemo(()=>({controlsRef:i,mainCameraRef:n,defaultTarget:A,baseDistance:B,controller:o,setController:s,getPresetConfig:C,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:c,cameraRotation:I,setCameraRotation:l,saveCameraToSession:Gie,loadCameraFromSession:tpA}),[A,B,o,C,Q,r,g,I]);return W.jsx(Mie.Provider,{value:h,children:t})},ik=()=>{const t=V.useContext(Mie);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},M2t=V.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:n},o)=>{const{cameraType:s}=ik(),r=V.useRef(null),[a,g]=V.useState(null),c=V.useRef([]),I=V.useRef(void 0);I.current=n;const l=V.useRef(null),B=V.useCallback(E=>{c.current.push(E)},[]),C=V.useCallback(E=>{c.current=c.current.filter(u=>u!==E)},[]),Q=V.useMemo(()=>new SF,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const h=V.useRef(new Rg);return V.useImperativeHandle(o,()=>h.current),V.useEffect(()=>{if(!r.current)return;N2t(r.current);const E=new aZ({antialias:!0,alpha:!0});R2t(E),E.setSize(r.current.clientWidth,r.current.clientHeight),E.setPixelRatio(window.devicePixelRatio),r.current.appendChild(E.domElement);const u=r.current.clientWidth/r.current.clientHeight,d=s==="perspective"?new Ph(75,u,.1,1e3):new tY(-10*u,10*u,10,-10,-1e3,1e3);l.current?(d.position.copy(l.current.position),d.quaternion.copy(l.current.quaternion),d.up.copy(l.current.up)):(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(h.current),window.__TSCIRCUIT_THREE_OBJECT=h.current,g({scene:Q,camera:d,renderer:E,rootObject:h.current,addFrameListener:B,removeFrameListener:C}),I.current?.({camera:d,renderer:E});let f;const m=new PEt,w=()=>{const S=m.getElapsedTime(),_=m.getDelta();c.current.forEach(x=>x(S,_)),E.render(Q,d),f=requestAnimationFrame(w)};w();const D=()=>{if(r.current){const S=r.current.clientWidth/r.current.clientHeight;d instanceof Ph?d.aspect=S:d instanceof tY&&(d.left=-10*S,d.right=10*S,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),E.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",D),()=>{l.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",D),cancelAnimationFrame(f),r.current&&E.domElement&&r.current.removeChild(E.domElement),E.dispose(),Q.remove(h.current),window.__TSCIRCUIT_THREE_OBJECT===h.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,B,C,s]),W.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&W.jsx(Mte.Provider,{value:a,children:W.jsx(g2t,{children:t})})})}),L2t=({autoRotate:t,autoRotateSpeed:A,onStart:e,panSpeed:i,rotateSpeed:n,zoomSpeed:o,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:c,renderer:I}=ed(),l=V.useMemo(()=>!c||!I?null:new fdt(c,I.domElement),[c,I]);return V.useEffect(()=>(g?.(l??null),()=>g?.(null)),[l,g]),V.useEffect(()=>{if(!l)return;const B=()=>{g?.(l)};return l.addEventListener("change",B),()=>{l.removeEventListener("change",B)}},[l,g]),V.useEffect(()=>{l&&(l.autoRotate=t||!1,l.autoRotateSpeed=A||1,i!==void 0&&(l.panSpeed=i),n!==void 0&&(l.rotateSpeed=n),o!==void 0&&(l.zoomSpeed=o),s!==void 0&&(l.enableDamping=s),r!==void 0&&(l.dampingFactor=r),l.zoomToCursor=!0,l.mouseButtons={LEFT:F_.ROTATE,MIDDLE:F_.PAN,RIGHT:null},a&&(l.target.set(a[0],a[1],a[2]),l.update()))},[l,t,A,i,n,o,s,r,a]),V.useEffect(()=>{if(!(!l||!e))return l.addEventListener("start",e),()=>{l.removeEventListener("start",e)}},[l,e]),V.useEffect(()=>{if(l)return()=>{l.dispose()}},[l]),qY(()=>{l?.update()},[l]),null},U2t=`
|
|
5155
|
+
`,C.children.length>0&&c.push(C.children)}return a}};A.exports=s}}),Okt=ae({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,A){var e=Tkt(),i=qkt(),n=class{constructor(o){this.polygonTree=new i,this.rootnode=new e(null),o&&this.addPolygons(o)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(o,s=!1){this.rootnode.clipTo(o,s)}allPolygons(){const o=[];return this.polygonTree.getPolygons(o),o}addPolygons(o){const s=new Array(o.length);for(let r=0;r<o.length;r++)s[r]=this.polygonTree.addChild(o[r]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};A.exports=n}}),mdA=ae({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,A){A.exports={Tree:Okt()}}}),Wkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,A){var e=As(),i=ydA(),{Tree:n}=mdA(),o=(s,r)=>{if(!i(s,r))return e.create();const a=new n(e.toPolygons(s)),g=new n(e.toPolygons(r));a.invert(),g.clipTo(a),g.invert(),a.clipTo(g),g.clipTo(a),a.addPolygons(g.allPolygons()),a.invert();const c=a.allPolygons();return e.create(c)};A.exports=o}}),wte=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,A){var e=ko(),i=PY(),n=Wkt(),o=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),Zkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,A){var e=ko(),i=As(),n=Ak(),o=pdA(),s=fdA(),r=wte(),a=(...g)=>{g=e(g);const c=g.map(B=>s({z0:-1,z1:1},B)),I=r(c),l=n(I);return o(l,i.toPolygons(I))};A.exports=a}}),Vkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,A){var e=ko(),i=TY(),n=os(),o=As(),s=Zkt(),r=wte(),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 c=g[0];return n.isA(c)?s(g):o.isA(c)?r(g):c};A.exports=a}}),wdA=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,A){var e=Ar(),i=_ee(),n=o=>i(o,{skipTriangulation:!0}).map(a=>{const g=a.map(c=>o[c]);return e.create(g)});A.exports=n}}),Dte=ae({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,A){var e=As(),i=ydA(),{Tree:n}=mdA(),o=(r,a)=>{if(!i(r,a))return s(r,a);const g=new n(e.toPolygons(r)),c=new n(e.toPolygons(a));g.clipTo(c,!1),c.clipTo(g),c.invert(),c.clipTo(g),c.invert();const I=g.allPolygons().concat(c.allPolygons());return e.create(I)},s=(r,a)=>{let g=e.toPolygons(r);return g=g.concat(e.toPolygons(a)),e.create(g)};A.exports=o}}),DdA=ae({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,A){var e=ko(),i=PY(),n=Dte(),o=(...s)=>{s=e(s);let r;for(r=1;r<s.length;r+=2)s.push(n(s[r-1],s[r]));let a=s[r-1];return a=i(a),a};A.exports=o}}),Ste=ae({"node_modules/@jscad/modeling/src/operations/minkowski/minkowskiSum.js"(t,A){var e=ko(),i=As(),n=Ar(),o=wdA(),s=DdA(),r=(...B)=>{if(B=e(B),B.length!==2)throw new Error("minkowskiSum requires exactly two geometries");const[C,Q]=B;if(!i.isA(C)||!i.isA(Q))throw new Error("minkowskiSum requires geom3 geometries");const h=i.isConvex(C),E=i.isConvex(Q);if(h&&E)return I(C,Q);if(!h&&E)return a(C,Q);if(h&&!E)return a(Q,C);throw new Error("minkowskiSum of two non-convex geometries is not yet supported")},a=(B,C)=>{const Q=g(B);if(Q.length===0)return i.create();const h=Q.map(E=>I(E,C));return h.length===1?h[0]:s(h)},g=B=>{const C=i.toPolygons(B);if(C.length===0)return[];const Q=[];for(let h=0;h<C.length;h++){const E=C[h],u=E.vertices;let d=0,f=0,m=0;for(let F=0;F<u.length;F++)d+=u[F][0],f+=u[F][1],m+=u[F][2];d/=u.length,f/=u.length,m/=u.length;const w=n.plane(E),D=w[0],S=w[1],_=w[2],x=.1,G=[d-D*x,f-S*x,m-_*x];for(let F=1;F<u.length-1;F++){const L=u[0],Y=u[F],J=u[F+1],O=c(G,L,Y,J);Q.push(i.create(O))}}return Q},c=(B,C,Q,h)=>[n.create([B,Q,C]),n.create([B,C,h]),n.create([C,Q,h]),n.create([Q,B,h])],I=(B,C)=>{const Q=l(B),h=l(C);if(Q.length===0||h.length===0)return i.create();const E=[];for(let d=0;d<Q.length;d++){const f=Q[d];for(let m=0;m<h.length;m++){const w=h[m];E.push([f[0]+w[0],f[1]+w[1],f[2]+w[2]])}}const u=o(E);return i.create(u)},l=B=>{const C=new Set,Q=[],h=i.toPolygons(B);for(let E=0;E<h.length;E++){const u=h[E].vertices;for(let d=0;d<u.length;d++){const f=u[d],m=`${f[0]},${f[1]},${f[2]}`;C.has(m)||(C.add(m),Q.push(f))}}return Q};A.exports=r}}),jkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,A){var e=bn(),i=Ak(),n=As(),o=g=>g.sort((c,I)=>c-I).filter((c,I,l)=>!I||c!==l[I-1]),s=(g,c,I)=>{const l=`${c}`,B=g.get(l);B===void 0?g.set(l,[I]):B.push(I)},r=(g,c)=>{const I=`${c}`;return g.get(I)},a=g=>{const c=i(g),I=n.toPolygons(g),l=I.length,B=new Map,C=e.create();I.forEach((d,f)=>{d.vertices.forEach(m=>{s(B,e.snap(C,m,c),f)})});const Q=I.map(d=>{let f=[];return d.vertices.forEach(m=>{f=f.concat(r(B,e.snap(C,m,c)))}),{e:1,d:o(f)}});B.clear();let h=0;const E=Q.length;for(let d=0;d<E;d++){const f=Q[d];if(f.e>0){const m=new Array(l);m[d]=!0;do h=0,m.forEach((w,D)=>{const S=Q[D];if(S.e>0){S.e=-1;for(let _=0;_<S.d.length;_++)m[S.d[_]]=!0;h++}});while(h>0);f.indexes=m}}const u=[];for(let d=0;d<E;d++)if(Q[d].indexes){const f=[];Q[d].indexes.forEach((m,w)=>f.push(I[w])),u.push(n.create(f))}return u};A.exports=a}}),zkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,A){var e=ko(),i=As(),n=jkt(),o=(...s)=>{if(s=e(s),s.length===0)throw new Error("wrong number of arguments");const r=s.map(a=>i.isA(a)?n(a):a);return r.length===1?r[0]:r};A.exports=o}}),Xkt=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,A){var e=As(),i=ydA(),{Tree:n}=mdA(),o=(s,r)=>{if(!i(s,r))return e.clone(s);const a=new n(e.toPolygons(s)),g=new n(e.toPolygons(r));a.invert(),a.clipTo(g),g.clipTo(a,!0),a.addPolygons(g.allPolygons()),a.invert();const c=a.allPolygons();return e.create(c)};A.exports=o}}),bte=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,A){var e=ko(),i=PY(),n=Xkt(),o=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),$kt=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,A){var e=ko(),i=As(),n=Ak(),o=pdA(),s=fdA(),r=bte(),a=(...g)=>{g=e(g);const c=g.map(B=>s({z0:-1,z1:1},B)),I=r(c),l=n(I);return o(l,i.toPolygons(I))};A.exports=a}}),Avt=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,A){var e=ko(),i=TY(),n=os(),o=As(),s=$kt(),r=bte(),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 c=g[0];return n.isA(c)?s(g):o.isA(c)?r(g):c};A.exports=a}}),xte=ae({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,A){var e=ko(),i=As(),n=Ak(),o=pdA(),s=fdA(),r=DdA(),a=(...g)=>{g=e(g);const c=g.map(B=>s({z0:-1,z1:1},B)),I=r(c),l=n(I);return o(l,i.toPolygons(I))};A.exports=a}}),SdA=ae({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,A){var e=ko(),i=TY(),n=os(),o=As(),s=xte(),r=DdA(),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 c=g[0];return n.isA(c)?s(g):o.isA(c)?r(g):c};A.exports=a}}),g1=ae({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,A){A.exports={intersect:Vkt(),minkowski:Ste(),scission:zkt(),subtract:Avt(),union:SdA()}}}),pV=ae({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,A){var{EPS:e,TAU:i}=Br(),n=ite(),o=QdA(),s=_s(),r=EV(),a=(g,c)=>{const I={delta:1,corners:"edge",closed:!1,segments:16};let{delta:l,corners:B,closed:C,segments:Q}=Object.assign({},I,g);if(Math.abs(l)<e)return c;let h=g.closed?r(c):1;h===0&&(h=1);const E=h>0&&l>=0||h<0&&l<0;l=Math.abs(l);let u=null,d=[];const f=[],m=s.create(),w=c.length;for(let D=0;D<w;D++){const S=(D+1)%w,_=c[D],x=c[S];E?s.subtract(m,_,x):s.subtract(m,x,_),s.normal(m,m),s.normalize(m,m),s.scale(m,m,l);const G=s.add(s.create(),_,m),F=s.add(s.create(),x,m),L=[G,F];if(u!=null&&(C||!C&&S!==0)){const Y=n(u[0],u[1],L[0],L[1]);Y?(d.pop(),L[0]=Y):f.push({c:_,s0:u,s1:L})}u=[G,F],!(S===0&&!C)&&(d.push(L[0]),d.push(L[1]))}if(C&&u!=null){const D=d[0],S=d[1],_=n(u[0],u[1],D,S);if(_)d[0]=_,d.pop();else{const x=c[0],G=[D,S];f.push({c:x,s0:u,s1:G})}}if(B==="edge"){const D=new Map;d.forEach((x,G)=>D.set(x,G));const S=o.create(),_=o.create();f.forEach(x=>{o.fromPoints(S,x.s0[0],x.s0[1]),o.fromPoints(_,x.s1[0],x.s1[1]);const G=o.intersectPointOfLines(S,_);if(Number.isFinite(G[0])&&Number.isFinite(G[1])){const F=x.s0[1],L=D.get(F);d[L]=G,d[(L+1)%d.length]=void 0}else{const F=x.s1[0],L=D.get(F);d[L]=void 0}}),d=d.filter(x=>x!==void 0)}if(B==="round"){let D=Math.floor(Q/4);const S=s.create();f.forEach(_=>{let x=s.angle(s.subtract(S,_.s1[0],_.c));if(x-=s.angle(s.subtract(S,_.s0[1],_.c)),E&&x<0&&(x=x+Math.PI,x<0&&(x=x+Math.PI)),!E&&x>0&&(x=x-Math.PI,x>0&&(x=x-Math.PI)),x!==0){D=Math.floor(Q*(Math.abs(x)/i));const G=x/D,F=s.angle(s.subtract(S,_.s0[1],_.c)),L=[];for(let Y=1;Y<D;Y++){const J=F+G*Y,O=s.fromAngleRadians(s.create(),J);s.scale(O,O,l),s.add(O,O,_.c),L.push(O)}if(L.length>0){const Y=_.s0[1];let J=d.findIndex(O=>s.equals(Y,O));J=(J+1)%d.length,d.splice(J,0,...L)}}else{const G=_.s1[0],F=d.findIndex(L=>s.equals(G,L));d.splice(F,1)}})}return d};A.exports=a}}),evt=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,A){var e=os(),i=pV(),n=(o,s)=>{const r={delta:1,corners:"edge",segments:16},{delta:a,corners:g,segments:c}=Object.assign({},r,o);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const B=e.toOutlines(s).map(C=>(o={delta:a,corners:g,closed:!0,segments:c},i(o,C))).reduce((C,Q)=>C.concat(e.toSides(e.fromPoints(Q))),[]);return e.create(B)};A.exports=n}}),tvt=ae({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,A){var e=tc(),i=bn(),n=As(),o=Ar(),s=(r,a)=>{i.dot(o.plane(a),r)>0&&(a=o.invert(a));const c=[a],I=o.transform(e.fromTranslation(e.create(),r),a),l=a.vertices.length;for(let B=0;B<l;B++){const C=B<l-1?B+1:0,Q=o.create([a.vertices[B],I.vertices[B],I.vertices[C],a.vertices[C]]);c.push(Q)}return c.push(o.invert(I)),n.create(c)};A.exports=s}}),ivt=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,A){var{EPS:e,TAU:i}=Br(),n=tc(),o=bn(),s=yte(),r=As(),a=Ar(),g=Qte(),c=PY(),I=Dte(),l=tvt(),B=(E,u,d)=>{const f=u.toString();if(E.has(f))E.get(f)[1].push(d);else{const m=[u,[d]];E.set(f,m)}},C=(E,u,d)=>{const f=u[0].toString(),m=u[1].toString(),w=f<m?`${f},${m}`:`${m},${f}`;if(E.has(w))E.get(w)[1].push(d);else{const D=[u,[d]];E.set(w,D)}},Q=(E,u)=>{E.findIndex(f=>f===u)<0&&E.push(u)},h=(E,u)=>{const d={delta:1,segments:12},{delta:f,segments:m}=Object.assign({},d,E);let w=r.create();const D=new Map,S=new Map,_=o.create(),x=o.create();return r.toPolygons(u).forEach((F,L)=>{const Y=o.scale(o.create(),a.plane(F),2*f),J=a.transform(n.fromTranslation(n.create(),o.scale(o.create(),Y,-.5)),F),O=l(Y,J);w=I(w,O);const Z=F.vertices;for(let X=0;X<Z.length;X++){B(D,Z[X],a.plane(F));const eA=(X+1)%Z.length,gA=[Z[X],Z[eA]];C(S,gA,a.plane(F))}}),S.forEach(F=>{const L=F[0],Y=F[1],J=L[0],O=L[1],Z=o.subtract(o.create(),O,J);o.normalize(Z,Z);const X=Y[0],eA=o.cross(o.create(),X,Z);let gA=[];for(let YA=0;YA<m;YA++)Q(gA,YA*i/m);for(let YA=0,QA=Y.length;YA<QA;YA++){const _A=Y[YA],dA=o.dot(eA,_A),KA=o.dot(X,_A);let ZA=Math.atan2(dA,KA);ZA<0&&(ZA+=i),Q(gA,ZA),ZA=Math.atan2(-dA,-KA),ZA<0&&(ZA+=i),Q(gA,ZA)}gA=gA.sort(s);const tA=gA.length;let iA,sA;const aA=[],EA=[],bA=[];for(let YA=-1;YA<tA;YA++){const QA=gA[YA<0?YA+tA:YA],_A=Math.sin(QA),dA=Math.cos(QA);o.scale(_,X,dA*f),o.scale(x,eA,_A*f),o.add(_,_,x);const KA=o.add(o.create(),J,_),ZA=o.add(o.create(),O,_);let ce=!1;if(YA>=0&&o.distance(KA,iA)<e&&(ce=!0),!ce){if(YA>=0){aA.push(KA),EA.push(ZA);const fA=[sA,ZA,KA,iA],ge=a.create(fA);bA.push(ge)}iA=KA,sA=ZA}}EA.reverse(),bA.push(a.create(aA)),bA.push(a.create(EA));const xA=r.create(bA);w=I(w,xA)}),D.forEach(F=>{const L=F[0],Y=F[1],J=Y[0];let O=null,Z=0;for(let tA=1;tA<Y.length;tA++){const iA=Y[tA],sA=o.cross(_,J,iA),aA=o.length(sA);aA>.05&&aA>Z&&(Z=aA,O=iA)}O||(O=o.orthogonal(_,J));const X=o.cross(_,J,O);o.normalize(X,X);const eA=o.cross(x,X,J),gA=g({center:[L[0],L[1],L[2]],radius:f,segments:m,axes:[J,X,eA]});w=I(w,gA)}),c(w)};A.exports=h}}),nvt=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,A){var e=As(),i=SdA(),n=ivt(),o=(s,r)=>{const a={delta:1,corners:"round",segments:12},{delta:g,corners:c,segments:I}=Object.assign({},a,s);if(c!=="round")throw new Error('corners must be "round" for 3D geometries');if(e.toPolygons(r).length===0)throw new Error("the given geometry cannot be empty");s={delta:g,corners:c,segments:I};const B=n(s,r);return i(r,B)};A.exports=o}}),ovt=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,A){var e=EV(),i=_s(),n=os(),o=Lg(),s=pV(),r=c=>{let{external:I,internal:l}=c;e(I)<0?I=I.reverse():l=l.reverse();const B=o.fromPoints({closed:!0},I),C=o.fromPoints({closed:!0},l),Q=n.toSides(n.fromPoints(o.toPoints(B))),h=n.toSides(n.fromPoints(o.toPoints(C)));return Q.push(...h),n.create(Q)},a=(c,I,l,B)=>{const{points:C,external:Q,internal:h}=c,E=Math.floor(I/2),u=[],d=[];if(l==="round"&&E>0){const m=Math.PI/E,w=C[C.length-1],D=i.angle(i.subtract(i.create(),Q[Q.length-1],w)),S=C[0],_=i.angle(i.subtract(i.create(),h[0],S));for(let x=1;x<E;x++){let G=D+m*x,F=i.fromAngleRadians(i.create(),G);i.scale(F,F,B),i.add(F,F,w),u.push(F),G=_+m*x,F=i.fromAngleRadians(i.create(),G),i.scale(F,F,B),i.add(F,F,S),d.push(F)}}const f=[];return f.push(...Q,...u,...h.reverse(),...d),n.fromPoints(f)},g=(c,I)=>{c=Object.assign({},{delta:1,corners:"edge",segments:16},c);const{delta:B,corners:C,segments:Q}=c;if(B<=0)throw new Error("the given delta must be positive for paths");if(!(C==="edge"||C==="chamfer"||C==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const h=I.isClosed,E=o.toPoints(I);if(E.length===0)throw new Error("the given geometry cannot be empty");const u={points:E,external:s({delta:B,corners:C,segments:Q,closed:h},E),internal:s({delta:-B,corners:C,segments:Q,closed:h},E)};return I.isClosed?r(u):a(u,Q,C,B)};A.exports=g}}),bdA=ae({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,A){var e=ko(),i=os(),n=As(),o=Lg(),s=evt(),r=nvt(),a=ovt(),g=(c,...I)=>{if(I=e(I),I.length===0)throw new Error("wrong number of arguments");const l=I.map(B=>o.isA(B)?a(c,B):i.isA(B)?s(c,B):n.isA(B)?r(c,B):B);return l.length===1?l[0]:l};A.exports=g}}),svt=ae({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,A){var e=os(),i=cdA(),n=pV(),o=(s,r)=>{const a={delta:1,corners:"edge",segments:0},{delta:g,corners:c,segments:I}=Object.assign({},a,s);if(!(c==="edge"||c==="chamfer"||c==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const l=e.toOutlines(r),C=l.map(Q=>(s={delta:l.reduce((u,d)=>u+i.arePointsInside(Q,i.create(d)),0)%2===0?g:-g,corners:c,closed:!0,segments:I},n(s,Q))).reduce((Q,h)=>Q.concat(e.toSides(e.fromPoints(h))),[]);return e.create(C)};A.exports=o}}),rvt=ae({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,A){var e=Lg(),i=pV(),n=(o,s)=>{const r={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:a,corners:g,closed:c,segments:I}=Object.assign({},r,o);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');o={delta:a,corners:g,closed:c,segments:I};const l=i(o,e.toPoints(s));return e.fromPoints({closed:c},l)};A.exports=n}}),avt=ae({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,A){var e=ko(),i=os(),n=Lg(),o=svt(),s=rvt(),r=(a,...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");const c=g.map(I=>n.isA(I)?s(a,I):i.isA(I)?o(a,I):I);return c.length===1?c[0]:c};A.exports=r}}),_te=ae({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,A){A.exports={expand:bdA(),offset:avt()}}}),fV=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,A){var e=tc(),i=bn(),n=os(),o=a1(),s=dV(),r=(a,g)=>{const c={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:I,twistAngle:l,twistSteps:B,repair:C}=Object.assign({},c,a);if(B<1)throw new Error("twistSteps must be 1 or more");l===0&&(B=1);const Q=i.clone(I),h=n.toSides(g);if(h.length===0)throw new Error("the given geometry cannot be empty");const E=o.fromSides(h);Q[2]<0&&o.reverse(E,E);const u=e.create(),d=(f,m,w)=>{const D=m/B*l,S=i.scale(i.create(),Q,m/B);return e.multiply(u,e.fromZRotation(u,D),e.fromTranslation(e.create(),S)),o.transform(u,w)};return a={numberOfSlices:B+1,capStart:!0,capEnd:!0,repair:C,callback:d},s(a,E)};A.exports=r}}),gvt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,A){var e=os(),i=Lg(),n=fV(),o=(s,r)=>{if(!r.isClosed)throw new Error("extruded path must be closed");const a=i.toPoints(r),g=e.fromPoints(a);return n(s,g)};A.exports=o}}),cvt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,A){var e=ko(),i=os(),n=Lg(),o=fV(),s=gvt(),r=(a,...g)=>{const c={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:I,twistAngle:l,twistSteps:B,repair:C}=Object.assign({},c,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");a={offset:[0,0,I],twistAngle:l,twistSteps:B,repair:C};const Q=g.map(h=>n.isA(h)?s(a,h):i.isA(h)?o(a,h):h);return Q.length===1?Q[0]:Q};A.exports=r}}),Ivt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,A){var e=Lg(),i=bdA(),n=fV(),o=(s,r)=>{const a={size:1,height:1},{size:g,height:c}=Object.assign({},a,s);if(s.delta=g,s.offset=[0,0,c],e.toPoints(r).length===0)throw new Error("the given geometry cannot be empty");const l=i(s,r);return n(s,l)};A.exports=o}}),lvt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,A){var{area:e}=UY(),i=os(),n=Lg(),o=bdA(),s=fV(),r=(a,g)=>{const c={size:1,height:1},{size:I,height:l}=Object.assign({},c,a);a.delta=I,a.offset=[0,0,l];const B=i.toOutlines(g);if(B.length===0)throw new Error("the given geometry cannot be empty");const Q=B.map(E=>(e(E)<0&&E.reverse(),o(a,n.fromPoints({closed:!0},E)))).reduce((E,u)=>E.concat(i.toSides(u)),[]),h=i.create(Q);return s(a,h)};A.exports=r}}),Bvt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,A){var e=ko(),i=os(),n=Lg(),o=Ivt(),s=lvt(),r=(a,...g)=>{const c={size:1,height:1},{size:I,height:l}=Object.assign({},c,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(I<=0)throw new Error("size must be positive");if(l<=0)throw new Error("height must be positive");const B=g.map(C=>n.isA(C)?o(a,C):i.isA(C)?s(a,C):C);return B.length===1?B[0]:B};A.exports=r}}),Cvt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,A){var{TAU:e}=Br(),i=tc(),n=os(),o=dV(),s=a1(),r=(a,g)=>{const c={angle:e,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:I,startAngle:l,pitch:B,height:C,endOffset:Q,segmentsPerRotation:h}=Object.assign({},c,a);if(C!=0&&(B=C/(I/e)),h<3)throw new Error("The number of segments per rotation needs to be at least 3.");const u=n.toSides(g);if(u.length===0)throw new Error("The given geometry cannot be empty");const d=u.filter(x=>x[0][0]>=0);let f=s.fromSides(u);d.length===0&&(f=s.reverse(f));const m=Math.round(h/e*Math.abs(I)),w=m>=2?m:2,D=i.create(),S=i.create(),_=(x,G,F)=>{const L=l+I/w*G,Y=Q/w*G,J=(L-l)/e*B;return i.multiply(D,i.fromTranslation(i.create(),[Y,0,J*Math.sign(I)]),i.fromXRotation(i.create(),-e/4*Math.sign(I))),i.multiply(S,i.fromZRotation(i.create(),L),D),s.transform(S,F)};return o({numberOfSlices:w+1,callback:_},f)};A.exports=r}}),Qvt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,A){var e=ko(),i=CdA(),n=HD(),o=tc(),s=os(),r=As(),a=Ar(),g=Ak(),c=xte(),I=(B,C)=>{const Q=n.fromNormalAndPoint(n.create(),B.axis,B.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 h=g(C),E=h*h*Math.sqrt(3)/4;if(h===0)return s.create();const u=r.toPolygons(C);let d=[];for(let m=0;m<u.length;m++){const w=u[m].vertices.map(_=>n.projectionOfPoint(Q,_)),D=a.create(w),S=a.plane(D);i(Q,S)&&(a.measureArea(D)<E||d.push(D))}if(!i(Q,[0,0,1])){const m=o.fromVectorRotation(o.create(),Q,[0,0,1]);d=d.map(w=>a.transform(m,w))}d=d.sort((m,w)=>a.measureArea(w)-a.measureArea(m));const f=d.map(m=>s.fromPoints(m.vertices));return c(f)},l=(B,...C)=>{const Q={axis:[0,0,1],origin:[0,0,0]},{axis:h,origin:E}=Object.assign({},Q,B);if(C=e(C),C.length===0)throw new Error("wrong number of arguments");B={axis:h,origin:E};const u=C.map(d=>r.isA(d)?I(B,d):d);return u.length===1?u[0]:u};A.exports=l}}),KY=ae({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,A){A.exports={extrudeFromSlices:dV(),extrudeLinear:cvt(),extrudeRectangular:Bvt(),extrudeRotate:dte(),extrudeHelical:Cvt(),project:Qvt(),slice:a1()}}}),xdA=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,A){var e=_s(),i=s=>{let r=e.fromValues(1/0,1/0);s.forEach(c=>{(c[1]<r[1]||c[1]===r[1]&&c[0]<r[0])&&(r=c)});const a=[];s.forEach(c=>{const I=o(c[1]-r[1],c[0]-r[0]),l=e.squaredDistance(c,r);a.push({point:c,angle:I,distSq:l})}),a.sort((c,I)=>c.angle!==I.angle?c.angle-I.angle:c.distSq-I.distSq);const g=[];return a.forEach(c=>{let I=g.length;for(;I>1&&n(g[I-2],g[I-1],c.point)<=Number.EPSILON;)g.pop(),I=g.length;g.push(c.point)}),g},n=(s,r,a)=>(r[0]-s[0])*(a[1]-s[1])-(r[1]-s[1])*(a[0]-s[0]),o=(s,r)=>s===0&&r===0?-1/0:-r/s;A.exports=i}}),_dA=ae({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,A){var e=os(),i=As(),n=Lg(),o=s=>{const r=new Set,a=[],g=c=>{const I=c.toString();r.has(I)||(a.push(c),r.add(I))};return s.forEach(c=>{e.isA(c)?e.toPoints(c).forEach(g):i.isA(c)?i.toPoints(c).forEach(I=>I.forEach(g)):n.isA(c)&&n.toPoints(c).forEach(g)}),a};A.exports=o}}),hvt=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,A){var e=ko(),i=Lg(),n=xdA(),o=_dA(),s=(...r)=>{r=e(r);const a=o(r),g=n(a);return i.fromPoints({closed:!0},g)};A.exports=s}}),Evt=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,A){var e=ko(),i=os(),n=xdA(),o=_dA(),s=(...r)=>{r=e(r);const a=o(r),g=n(a);return g.length<3?i.create():i.fromPoints(g)};A.exports=s}}),uvt=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,A){var e=ko(),i=As(),n=_dA(),o=wdA(),s=(...r)=>{r=e(r);const a=n(r);return a.length===0?i.create():i.create(o(a))};A.exports=s}}),kte=ae({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,A){var e=ko(),i=TY(),n=os(),o=As(),s=Lg(),r=hvt(),a=Evt(),g=uvt(),c=(...I)=>{if(I=e(I),I.length===0)throw new Error("wrong number of arguments");if(!i(I))throw new Error("only hulls of the same type are supported");const l=I[0];return s.isA(l)?r(I):n.isA(l)?a(I):o.isA(l)?g(I):l};A.exports=c}}),dvt=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,A){var e=ko(),i=SdA(),n=kte(),o=(...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(n(s[a-1],s[a]));return i(r)};A.exports=o}}),pvt=ae({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,A){A.exports={hull:kte(),hullChain:dvt(),hullPoints2:xdA(),hullPoints3:wdA()}}}),fvt=ae({"node_modules/@jscad/modeling/src/operations/minkowski/index.js"(t,A){A.exports={minkowskiSum:Ste()}}}),vte=ae({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,A){var e=bn(),i=Ar(),n=(s,r)=>{const a=Math.abs(i.measureArea(r));return Number.isFinite(a)&&a>s},o=(s,r)=>{let a=r.map(c=>{const I=c.vertices.map(C=>e.snap(e.create(),C,s)),l=[];for(let C=0;C<I.length;C++){const Q=(C+1)%I.length;e.equals(I[C],I[Q])||l.push(I[C])}const B=i.create(l);return c.color&&(B.color=c.color),B});const g=s*s*Math.sqrt(3)/4;return a=a.filter(c=>n(g,c)),a};A.exports=o}}),yvt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,A){var e=CdA(),i=bn(),n=Ar(),o=E=>{const u=n.toPoints(E),d=[];for(let f=0;f<u.length;f++){const m=(f+1)%u.length,w={v1:u[f],v2:u[m]};d.push(w)}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=(E,u)=>{const d=`${u.v1}:${u.v2}`;E.set(d,u)},r=(E,u)=>{const d=`${u.v1}:${u.v2}`;E.delete(d)},a=(E,u)=>{const d=`${u.v2}:${u.v1}`;return E.get(d)},g=(E,u,d)=>{let f=E.prev.v1,m=E.prev.v2,w=u.next.v2;const D=l(f,m,w,d);f=u.prev.v1,m=u.prev.v2,w=E.next.v2;const S=l(f,m,w,d);return[D,S]},c=i.create(),I=i.create(),l=(E,u,d,f)=>{const m=i.subtract(c,u,E),w=i.subtract(I,d,u);return i.cross(m,m,w),i.dot(m,f)},B=E=>{let u;const d=[];for(;E.next;){const f=E.next;d.push(E.v1),E.v1=null,E.v2=null,E.next=null,E.prev=null,E=f}return d.length>0&&(u=n.create(d)),u},C=E=>{if(E.length<2)return E;const u=E[0].plane,d=E.slice(),f=new Map;for(;d.length>0;){const w=d.shift(),D=o(w);for(let S=0;S<D.length;S++){const _=D[S],x=a(f,_);if(x){const G=g(_,x,u);if(G[0]>=0&&G[1]>=0){const F=x.next,L=_.next;_.prev.next=x.next,_.next.prev=x.prev,x.prev.next=_.next,x.next.prev=_.prev,_.v1=null,_.v2=null,_.next=null,_.prev=null,r(f,x),x.v1=null,x.v2=null,x.next=null,x.prev=null;const Y=(J,O,Z)=>{const X={v1:Z.v1,v2:O.v2,next:O.next,prev:Z.prev};Z.prev.next=X,O.next.prev=X,r(J,O),O.v1=null,O.v2=null,O.next=null,O.prev=null,r(J,Z),Z.v1=null,Z.v2=null,Z.next=null,Z.prev=null};G[0]===0&&Y(f,F,F.prev),G[1]===0&&Y(f,L,L.prev)}}else _.next&&s(f,_)}}const m=[];return f.forEach(w=>{const D=B(w);D&&m.push(D)}),f.clear(),m},Q=(E,u)=>Math.abs(E[3]-u[3])<15e-8?e(E,u):!1,h=(E,u)=>{const d=[];u.forEach(m=>{const w=d.find(D=>Q(D[0],n.plane(m)));w?w[1].push(m):d.push([n.plane(m),[m]])});let f=[];return d.forEach(m=>{const w=m[1],D=C(w);f=f.concat(D)}),f};A.exports=h}}),mvt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,A){var e=Br(),i=bn(),n=Ar(),o=g=>`${g}`,s=(g,c,I,l,B,C)=>{const Q=o(l),h=o(B),E=`${Q}/${h}`,u=`${h}/${Q}`;if(g.has(u))return r(g,c,I,B,l,null),null;const d={vertex0:l,vertex1:B,polygonindex:C};return g.has(E)?g.get(E).push(d):g.set(E,[d]),c.has(Q)?c.get(Q).push(E):c.set(Q,[E]),I.has(h)?I.get(h).push(E):I.set(h,[E]),E},r=(g,c,I,l,B,C)=>{const Q=o(l),h=o(B),E=`${Q}/${h}`;let u=-1;const d=g.get(E);for(let f=0;f<d.length;f++){const m=d[f];let w=o(m.vertex0);if(w===Q&&(w=o(m.vertex1),w===h&&!(C!==null&&m.polygonindex!==C))){u=f;break}}d.splice(u,1),d.length===0&&g.delete(E),u=c.get(Q).indexOf(E),c.get(Q).splice(u,1),c.get(Q).length===0&&c.delete(Q),u=I.get(h).indexOf(E),I.get(h).splice(u,1),I.get(h).length===0&&I.delete(h)},a=g=>{const c=new Map;for(let I=0;I<g.length;I++){const l=g[I],B=l.vertices.length;if(B>=3){let C=l.vertices[0],Q=o(C);for(let h=0;h<B;h++){let E=h+1;E===B&&(E=0);const u=l.vertices[E],d=o(u),f=`${Q}/${d}`,m=`${d}/${Q}`;if(c.has(m)){const w=c.get(m);w.splice(-1,1),w.length===0&&c.delete(m)}else{const w={vertex0:C,vertex1:u,polygonindex:I};c.has(f)?c.get(f).push(w):c.set(f,[w])}C=u,Q=d}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(c.size>0){const I=new Map,l=new Map,B=new Map;for(const[Q,h]of c)B.set(Q,!0),h.forEach(E=>{const u=o(E.vertex0),d=o(E.vertex1);I.has(u)?I.get(u).push(Q):I.set(u,[Q]),l.has(d)?l.get(d).push(Q):l.set(d,[Q])});const C=g.slice(0);for(;c.size!==0;){for(const h of c.keys())B.set(h,!0);let Q=!1;for(;;){const h=Array.from(B.keys());if(h.length===0)break;const E=h[0];let u=!0;if(c.has(E)){const f=c.get(E)[0];for(let m=0;m<2;m++){const w=m===0?f.vertex0:f.vertex1,D=m===0?f.vertex1:f.vertex0,S=o(w),_=o(D);let x=[];m===0?l.has(S)&&(x=l.get(S)):I.has(S)&&(x=I.get(S));for(let G=0;G<x.length;G++){const F=x[G],L=c.get(F)[0],Y=m===0?L.vertex0:L.vertex1;if(m===0?L.vertex1:L.vertex0,o(Y)===_){r(c,I,l,w,D,null),r(c,I,l,D,w,null),u=!1,m=2,Q=!0;break}else{const O=w,Z=D,X=Y,eA=i.subtract(i.create(),X,O),gA=i.dot(i.subtract(i.create(),Z,O),eA)/i.dot(eA,eA);if(gA>0&&gA<1){const tA=i.scale(i.create(),eA,gA);if(i.add(tA,tA,O),i.squaredDistance(tA,Z)<e.EPS*e.EPS){const sA=L.polygonindex,aA=C[sA],EA=o(L.vertex1);let bA=-1;for(let dA=0;dA<aA.vertices.length;dA++)if(o(aA.vertices[dA])===EA){bA=dA;break}const xA=aA.vertices.slice(0);xA.splice(bA,0,D);const YA=n.create(xA);C[sA]=YA,r(c,I,l,L.vertex0,L.vertex1,sA);const QA=s(c,I,l,L.vertex0,D,sA),_A=s(c,I,l,D,L.vertex1,sA);QA!==null&&B.set(QA,!0),_A!==null&&B.set(_A,!0),u=!1,m=2,Q=!0;break}}}}}}u&&B.delete(E)}if(!Q)break}g=C}return c.clear(),g};A.exports=a}}),wvt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,A){var e=bn(),i=Ar(),n=(s,r,a)=>{const g=r.vertices.length;if(g>3){if(g>4){const l=[0,0,0];r.vertices.forEach(B=>e.add(l,l,B)),e.snap(l,e.divide(l,l,[g,g,g]),s);for(let B=0;B<g;B++){const C=i.create([l,r.vertices[B],r.vertices[(B+1)%g]]);r.color&&(C.color=r.color),a.push(C)}return}const c=i.create([r.vertices[0],r.vertices[1],r.vertices[2]]),I=i.create([r.vertices[0],r.vertices[2],r.vertices[3]]);r.color&&(c.color=r.color,I.color=r.color),a.push(c,I);return}a.push(r)},o=(s,r)=>{const a=[];return r.forEach(g=>{n(s,g,a)}),a};A.exports=o}}),Dvt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,A){var e=ko(),i=Ak(),n=os(),o=As(),s=Lg(),r=vte(),a=yvt(),g=mvt(),c=wvt(),I=(Q,h)=>h,l=(Q,h)=>h,B=(Q,h)=>{const E={snap:!1,simplify:!1,triangulate:!1},{snap:u,simplify:d,triangulate:f}=Object.assign({},E,Q),m=i(h);let w=o.toPolygons(h);u&&(w=r(m,w)),d&&(w=a(m,w)),f&&(w=g(w),w=c(m,w));const D=Object.assign({},h);return D.polygons=w,D},C=(Q,...h)=>{if(h=e(h),h.length===0)throw new Error("wrong number of arguments");const E=h.map(u=>{if(s.isA(u))return I(Q,u);if(n.isA(u))return l(Q,u);if(o.isA(u))return B(Q,u);throw new Error("invalid geometry")});return E.length===1?E[0]:E};A.exports=C}}),Svt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,A){var e=ko(),i=_s(),n=os(),o=As(),s=Lg(),r=Ak(),a=vte(),g=B=>{const C=r(B),h=s.toPoints(B).map(E=>i.snap(i.create(),E,C));return s.create(h)},c=B=>{const C=r(B);let h=n.toSides(B).map(E=>[i.snap(i.create(),E[0],C),i.snap(i.create(),E[1],C)]);return h=h.filter(E=>!i.equals(E[0],E[1])),n.create(h)},I=B=>{const C=r(B),Q=o.toPolygons(B),h=a(C,Q);return o.create(h)},l=(...B)=>{if(B=e(B),B.length===0)throw new Error("wrong number of arguments");const C=B.map(Q=>s.isA(Q)?g(Q):n.isA(Q)?c(Q):o.isA(Q)?I(Q):Q);return C.length===1?C[0]:C};A.exports=l}}),bvt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,A){A.exports={generalize:Dvt(),snap:Svt(),retessellate:PY()}}}),xvt=ae({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,A){var e=(i,n,o)=>{for(i=i.slice();i.length<o;)i.push(n);return i};A.exports=e}}),_vt=ae({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,A){var e=ko(),i=xvt(),n=hdA(),{translate:o}=JF(),s=c=>{if(!Array.isArray(c.modes)||c.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(c.modes=i(c.modes,"none",3),c.modes.filter(I=>["center","max","min","none"].includes(I)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(c.relativeTo)||c.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(c.relativeTo=i(c.relativeTo,0,3),c.relativeTo.filter(I=>Number.isFinite(I)||I==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof c.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return c},r=(c,I,l)=>{for(let B=0;B<3;B++)c[B]==null&&(I[B]==="center"?c[B]=(l[0][B]+l[1][B])/2:I[B]==="max"?c[B]=l[1][B]:I[B]==="min"&&(c[B]=l[0][B]));return c},a=(c,I,l)=>{const B=n(c),C=[0,0,0];for(let Q=0;Q<3;Q++)I[Q]==="center"?C[Q]=l[Q]-(B[0][Q]+B[1][Q])/2:I[Q]==="max"?C[Q]=l[Q]-B[1][Q]:I[Q]==="min"&&(C[Q]=l[Q]-B[0][Q]);return o(C,c)},g=(c,...I)=>{c=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},c),c=s(c);let{modes:B,relativeTo:C,grouped:Q}=c;if(I=e(I),I.length===0)throw new Error("align(): No geometries were provided to act upon");if(C.filter(h=>h==null).length){const h=n(I);C=r(C,B,h)}return Q?I=a(I,B,C):I=I.map(h=>a(h,B,C)),I.length===1?I[0]:I};A.exports=g}}),yV=ae({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,A){var e=ko(),i=os(),n=As(),o=Lg(),s=HF(),{translate:r}=JF(),a=(B,C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:h,relativeTo:E}=Object.assign({},Q,B),u=s(C),d=[0,0,0];return h[0]&&(d[0]=E[0]-(u[0][0]+(u[1][0]-u[0][0])/2)),h[1]&&(d[1]=E[1]-(u[0][1]+(u[1][1]-u[0][1])/2)),h[2]&&(d[2]=E[2]-(u[0][2]+(u[1][2]-u[0][2])/2)),r(d,C)},g=(B,...C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:h,relativeTo:E}=Object.assign({},Q,B);if(C=e(C),C.length===0)throw new Error("wrong number of arguments");if(E.length!==3)throw new Error("relativeTo must be an array of length 3");B={axes:h,relativeTo:E};const u=C.map(d=>o.isA(d)||i.isA(d)||n.isA(d)?a(B,d):d);return u.length===1?u[0]:u},c=(...B)=>g({axes:[!0,!1,!1]},B),I=(...B)=>g({axes:[!1,!0,!1]},B),l=(...B)=>g({axes:[!1,!1,!0]},B);A.exports={center:g,centerX:c,centerY:I,centerZ:l}}}),mV=ae({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,A){var e=ko(),i=tc(),n=os(),o=As(),s=Lg(),r=(I,...l)=>{if(!Array.isArray(I))throw new Error("factors must be an array");if(l=e(l),l.length===0)throw new Error("wrong number of arguments");for(I=I.slice();I.length<3;)I.push(1);if(I[0]<=0||I[1]<=0||I[2]<=0)throw new Error("factors must be positive");const B=i.fromScaling(i.create(),I),C=l.map(Q=>s.isA(Q)?s.transform(B,Q):n.isA(Q)?n.transform(B,Q):o.isA(Q)?o.transform(B,Q):Q);return C.length===1?C[0]:C},a=(I,...l)=>r([I,1,1],l),g=(I,...l)=>r([1,I,1],l),c=(I,...l)=>r([1,1,I],l);A.exports={scale:r,scaleX:a,scaleY:g,scaleZ:c}}}),kvt=ae({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,A){var e=ko(),i=os(),n=As(),o=Lg(),s=(r,...a)=>{if(a=e(a),a.length===0)throw new Error("wrong number of arguments");const g=a.map(c=>o.isA(c)?o.transform(r,c):i.isA(c)?i.transform(r,c):n.isA(c)?n.transform(r,c):c);return g.length===1?g[0]:g};A.exports=s}}),TF=ae({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,A){A.exports={align:_vt(),center:yV().center,centerX:yV().centerX,centerY:yV().centerY,centerZ:yV().centerZ,mirror:YY().mirror,mirrorX:YY().mirrorX,mirrorY:YY().mirrorY,mirrorZ:YY().mirrorZ,rotate:JY().rotate,rotateX:JY().rotateX,rotateY:JY().rotateY,rotateZ:JY().rotateZ,scale:mV().scale,scaleX:mV().scaleX,scaleY:mV().scaleY,scaleZ:mV().scaleZ,transform:kvt(),translate:JF().translate,translateX:JF().translateX,translateY:JF().translateY,translateZ:JF().translateZ}}}),wV=ae({"node_modules/@jscad/modeling/src/index.js"(t,A){A.exports={colors:hV(),curves:w_t(),geometries:IdA(),maths:V_t(),measurements:ikt(),primitives:ek(),text:Gkt(),utils:mte(),booleans:g1(),expansions:_te(),extrusions:KY(),hulls:pvt(),minkowski:fvt(),modifiers:bvt(),transforms:TF()}}}),Fte=ae({"node_modules/jscad-planner/dist/index.cjs"(t,A){var e=Object.defineProperty,i=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(l,B)=>{for(var C in B)e(l,C,{get:B[C],enumerable:!0})},r=(l,B,C,Q)=>{if(B&&typeof B=="object"||typeof B=="function")for(let h of n(B))!o.call(l,h)&&h!==C&&e(l,h,{get:()=>B[h],enumerable:!(Q=i(B,h))||Q.enumerable});return l},a=l=>r(e({},"__esModule",{value:!0}),l),g={};s(g,{executeJscadOperations:()=>I,jscadPlanner:()=>c}),A.exports=a(g);var c={booleans:{intersect:(...l)=>({type:"intersect",shapes:l}),subtract:(...l)=>({type:"subtract",shapes:l}),union:(...l)=>({type:"union",shapes:l})},hulls:{hull:(...l)=>({type:"hull",shapes:l.flat()}),hullChain:(...l)=>({type:"hullChain",shapes:l.flat()})},colors:{colorize:(l,B)=>({type:"colorize",color:l,shape:B})},primitives:{cube:l=>({type:"cube",...l}),sphere:l=>({type:"sphere",...l}),cylinder:l=>({type:"cylinder",...l}),polygon:l=>({type:"polygon",...l}),cuboid:l=>({type:"cuboid",...l}),roundedCuboid:l=>({type:"roundedCuboid",...l})},transforms:{rotate:(l,B)=>({type:"rotate",angles:l,shape:B}),scale:(l,B)=>({type:"scale",factors:l,shape:B}),translate:(l,B)=>({type:"translate",vector:l,shape:B})},extrusions:{extrudeLinear:(l,B)=>({type:"extrudeLinear",options:l,shape:B}),extrudeRotate:(l,B)=>({type:"extrudeRotate",options:l,shape:B})},maths:{vec2:{create:(l,B)=>[l,B],fromValues:(l,B)=>[l,B]},vec3:{create:(l,B,C)=>[l,B,C],fromValues:(l,B,C)=>[l,B,C]}},geometries:{geom2:{create:l=>({type:"createGeom2",points:l})},geom3:{create:l=>({type:"createGeom3",polygons:l})},path2:{create:l=>({type:"createPath2",points:l})}},measurements:{measureBoundingBox:l=>({type:"measureBoundingBox",shape:l}),measureArea:l=>({type:"measureArea",shape:l}),measureVolume:l=>({type:"measureVolume",shape:l})},utils:{degToRad:l=>l*Math.PI/180,radToDeg:l=>l*180/Math.PI}},I=(l,B)=>{if(Array.isArray(B)&&B.length===1)return I(l,B[0]);if(Array.isArray(B))throw new Error("executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually");const C=E=>I(l,E),{type:Q,...h}=B;switch(Q){case"intersect":return l.booleans.intersect(...B.shapes.map(C));case"subtract":return l.booleans.subtract(...B.shapes.map(C));case"union":return l.booleans.union(...B.shapes.map(C));case"hull":return l.hulls.hull(...B.shapes.map(C));case"hullChain":return l.hulls.hullChain(...B.shapes.map(C));case"colorize":return l.colors.colorize(B.color,C(B.shape));case"cube":return l.primitives.cube(h);case"sphere":return l.primitives.sphere(h);case"cylinder":return l.primitives.cylinder(h);case"polygon":return l.primitives.polygon(h);case"cuboid":return l.primitives.cuboid(h);case"roundedCuboid":return l.primitives.roundedCuboid(h);case"rotate":return l.transforms.rotate(B.angles,C(B.shape));case"scale":return l.transforms.scale(B.factors,C(B.shape));case"translate":return l.transforms.translate(B.vector,C(B.shape));case"extrudeLinear":return l.extrusions.extrudeLinear(B.options,C(B.shape));case"extrudeRotate":return l.extrusions.extrudeRotate(B.options,C(B.shape));case"createGeom2":return l.geometries.geom2.create(B.points);case"createGeom3":return l.geometries.geom3.create(B.polygons);case"createPath2":return l.geometries.path2.create(B.points);case"measureBoundingBox":return l.measurements.measureBoundingBox(C(B.shape));case"measureArea":return l.measurements.measureArea(C(B.shape));case"measureVolume":return l.measurements.measureVolume(C(B.shape));case"degToRad":return l.utils.degToRad(B.degrees);case"radToDeg":return l.utils.radToDeg(B.radians);default:throw B.type===void 0?new Error(`Operation type is undefined. This usually means the operation object is malformed or not properly initialized. Operation: ${JSON.stringify(B,null,2).slice(0,200)}...`):new Error(`Unsupported operation type: ${B.type}. Operation: ${JSON.stringify(B,null,2)}`)}}}}),vvt=ae({"node_modules/ms/index.js"(t,A){var e=1e3,i=e*60,n=i*60,o=n*24,s=o*7,r=o*365.25;A.exports=function(l,B){B=B||{};var C=typeof l;if(C==="string"&&l.length>0)return a(l);if(C==="number"&&isFinite(l))return B.long?c(l):g(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function a(l){if(l=String(l),!(l.length>100)){var B=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(B){var C=parseFloat(B[1]),Q=(B[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*o;case"hours":case"hour":case"hrs":case"hr":case"h":return C*n;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(l){var B=Math.abs(l);return B>=o?Math.round(l/o)+"d":B>=n?Math.round(l/n)+"h":B>=i?Math.round(l/i)+"m":B>=e?Math.round(l/e)+"s":l+"ms"}function c(l){var B=Math.abs(l);return B>=o?I(l,B,o,"day"):B>=n?I(l,B,n,"hour"):B>=i?I(l,B,i,"minute"):B>=e?I(l,B,e,"second"):l+" ms"}function I(l,B,C,Q){var h=B>=C*1.5;return Math.round(l/C)+" "+Q+(h?"s":"")}}}),Fvt=ae({"node_modules/debug/src/common.js"(t,A){function e(i){o.debug=o,o.default=o,o.coerce=I,o.disable=g,o.enable=r,o.enabled=c,o.humanize=vvt(),o.destroy=l,Object.keys(i).forEach(B=>{o[B]=i[B]}),o.names=[],o.skips=[],o.formatters={};function n(B){let C=0;for(let Q=0;Q<B.length;Q++)C=(C<<5)-C+B.charCodeAt(Q),C|=0;return o.colors[Math.abs(C)%o.colors.length]}o.selectColor=n;function o(B){let C,Q=null,h,E;function u(...d){if(!u.enabled)return;const f=u,m=Number(new Date),w=m-(C||m);f.diff=w,f.prev=C,f.curr=m,C=m,d[0]=o.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let D=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(_,x)=>{if(_==="%%")return"%";D++;const G=o.formatters[x];if(typeof G=="function"){const F=d[D];_=G.call(f,F),d.splice(D,1),D--}return _}),o.formatArgs.call(f,d),(f.log||o.log).apply(f,d)}return u.namespace=B,u.useColors=o.useColors(),u.color=o.selectColor(B),u.extend=s,u.destroy=o.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>Q!==null?Q:(h!==o.namespaces&&(h=o.namespaces,E=o.enabled(B)),E),set:d=>{Q=d}}),typeof o.init=="function"&&o.init(u),u}function s(B,C){const Q=o(this.namespace+(typeof C>"u"?":":C)+B);return Q.log=this.log,Q}function r(B){o.save(B),o.namespaces=B,o.names=[],o.skips=[];const C=(typeof B=="string"?B:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const Q of C)Q[0]==="-"?o.skips.push(Q.slice(1)):o.names.push(Q)}function a(B,C){let Q=0,h=0,E=-1,u=0;for(;Q<B.length;)if(h<C.length&&(C[h]===B[Q]||C[h]==="*"))C[h]==="*"?(E=h,u=Q,h++):(Q++,h++);else if(E!==-1)h=E+1,u++,Q=u;else return!1;for(;h<C.length&&C[h]==="*";)h++;return h===C.length}function g(){const B=[...o.names,...o.skips.map(C=>"-"+C)].join(",");return o.enable(""),B}function c(B){for(const C of o.skips)if(a(B,C))return!1;for(const C of o.names)if(a(B,C))return!0;return!1}function I(B){return B instanceof Error?B.stack||B.message:B}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}A.exports=e}}),Nvt=ae({"node_modules/debug/src/browser.js"(t,A){t.formatArgs=i,t.save=n,t.load=o,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 c=0,I=0;a[0].replace(/%[a-zA-Z%]/g,l=>{l!=="%%"&&(c++,l==="%c"&&(I=c))}),a.splice(I,0,g)}t.log=console.debug||console.log||(()=>{});function n(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function o(){let a;try{a=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!a&&typeof edA<"u"&&"env"in edA&&(a=edA.env.DEBUG),a}function s(){try{return localStorage}catch{}}A.exports=Fvt()(t);var{formatters:r}=A.exports;r.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}}}),Nte={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,pcbNotes:!1,backgroundStart:!0,backgroundEnd:!0},Rte=V.createContext(void 0),Rvt=({children:t})=>{const[A,e]=V.useState(Nte),i=V.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),n=V.useCallback(()=>{e(Nte)},[]),o=V.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:n}),[A,i,n]);return W.jsx(Rte.Provider,{value:o,children:t})},PF=()=>{const t=V.useContext(Rte);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},kdA=1.2;function Gte(t){return V.useMemo(()=>{if(!t)return kdA;try{return mn(t).pcb_board.list()[0]?.thickness??kdA}catch{return kdA}},[t])}var Mte=V.createContext(null),ed=()=>{const t=V.useContext(Mte);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},qY=(t,A=[])=>{const{addFrameListener:e,removeFrameListener:i}=ed();Bn.useEffect(()=>(e(t),()=>i(t)),[e,i,...A])},OY={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},Lte=({children:t,position:A,style:e})=>{const{camera:i,renderer:n}=ed(),o=V.useRef(document.createElement("div")),[s,r]=V.useState(null);return V.useEffect(()=>{const a=n?.domElement.parentNode;if(a)return a.style.position!=="relative"&&a.style.position!=="absolute"&&(a.style.position="relative"),a.appendChild(o.current),r(V8.createPortal(t,o.current)),()=>{a.contains(o.current)&&a.removeChild(o.current)}},[n,t]),qY(()=>{if(!i||!o.current||!n)return;const a=new Re(...A);a.project(i);const g=n.domElement.getBoundingClientRect(),c=Math.round((a.x+1)/2*g.width),I=Math.round((-a.y+1)/2*g.height);o.current.style.position="absolute",o.current.style.left=`${c}px`,o.current.style.top=`${I}px`,o.current.style.pointerEvents="none",o.current.style.zIndex=OY.htmlElements.toString(),e&&Object.assign(o.current.style,e)},[i,n,A,e]),s},Ute={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},Lr=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 Ute)return e*Ute[A];throw new Error(`Unsupported unit: ${A}`)},ql=Lr,Gvt=Object.defineProperty,Mvt=(t,A)=>{for(var e in A)Gvt(t,e,{get:A[e],enumerable:!0})},_b={};Mvt(_b,{axial:()=>sNt,bga:()=>CFt,breakoutheaders:()=>dNt,cap:()=>Pvt,dfn:()=>TFt,diode:()=>Tvt,dip:()=>Hvt,electrolytic:()=>sMt,hc49:()=>fNt,jst:()=>wGt,led:()=>Kvt,lqfp:()=>ENt,m2host:()=>bMt,melf:()=>NRt,micromelf:()=>LRt,minimelf:()=>DRt,mlp:()=>mFt,mountedpcbmodule:()=>_Mt,ms012:()=>ZFt,ms013:()=>jFt,msop:()=>RGt,pad:()=>yNt,pinrow:()=>KFt,platedhole:()=>uMt,potentiometer:()=>iMt,pushbutton:()=>INt,qfn:()=>pFt,qfp:()=>yFt,quad:()=>I1,radial:()=>gNt,res:()=>IFt,sma:()=>JRt,smb:()=>VRt,smbf:()=>aMt,smc:()=>$Rt,smf:()=>qRt,smtpad:()=>hMt,sod110:()=>SGt,sod123:()=>tNt,sod123f:()=>iRt,sod123fl:()=>rRt,sod123w:()=>LNt,sod128:()=>QRt,sod323:()=>JNt,sod323f:()=>$Nt,sod323fl:()=>YGt,sod323w:()=>MGt,sod523:()=>bNt,sod723:()=>IRt,sod80:()=>NNt,sod882:()=>VNt,sod882d:()=>_Rt,sod923:()=>qNt,soic:()=>hFt,solderjumper:()=>VGt,son:()=>KGt,sop8:()=>vNt,sot:()=>pMt,sot223:()=>iGt,sot23:()=>GFt,sot23w:()=>lGt,sot25:()=>HFt,sot323:()=>lMt,sot343:()=>mMt,sot363:()=>vFt,sot457:()=>XGt,sot563:()=>OFt,sot723:()=>XFt,sot886:()=>NFt,sot89:()=>fRt,sot963:()=>AMt,ssop:()=>SFt,stampboard:()=>BNt,stampreceiver:()=>hNt,to220:()=>mRt,to92:()=>DNt,to92l:()=>vMt,to92s:()=>uGt,tqfp:()=>fFt,tssop:()=>_Ft,vson:()=>OGt,vssop:()=>vGt});var Mi=(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"}),Li=te({norefdes:qA().optional().describe("disable reference designator label"),invert:qA().optional().describe("hint to invert the orientation of the 3D model"),faceup:qA().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:qA().optional().describe("omit all silkscreen elements from the footprint")}),vo=(t,A,e,i,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:Lr(i),outer_diameter:Lr(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),YD=t=>{const{pn:A,x:e,y:i,holeDiameter:n,rectPadWidth:o,rectPadHeight:s,holeOffsetX:r=0,holeOffsetY:a=0}=t;return{pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:e,y:i,hole_diameter:Lr(n),hole_shape:"circle",pad_shape:"rect",rect_pad_width:Lr(o),rect_pad_height:Lr(s),pcb_port_id:"",layers:["top","bottom"],port_hints:[A.toString()],hole_offset_x:r,hole_offset_y:a}},DV=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 tk(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var SV=Gt([H(),OA()]).transform(t=>tk(t)),Lvt=t=>Li.extend({fn:H(),num_pins:OA().optional().default(6),wide:qA().optional(),narrow:qA().optional(),w:SV.optional(),p:SV.default(t.p??"2.54mm"),id:SV.optional(),od:SV.optional(),nosquareplating:qA().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=tk("0.55mm"),A.od=tk("0.95mm")):(A.id=tk("0.8mm"),A.od=tk("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=tk("600mil"):A.narrow?A.w=tk("300mil"):A.w=tk(t.w??"300mil")),A)),Uvt=Lvt({}),Hte=(t,A,e,i,n)=>{const o=t/2,s=A<=o,r=o-1,a=i,g=a*r;return s?{x:-e/2,y:g/2-(A-1)*a}:{x:e/2,y:-g/2+(A-o-1)*a}},Hvt=t=>{const A=Uvt.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:c,y:I}=Hte(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating);if(g===0&&!A.nosquareplating){e.push(YD({pn:g+1,x:c,y:I,holeDiameter:A.id??"0.8mm",rectPadWidth:A.od??"1mm",rectPadHeight:A.od??"1mm"}));continue}e.push(vo(g+1,c,I,A.id??"0.8mm",A.od??"1mm"))}(A.num_pins/2-1)*A.p+A.od;const n=A.w-A.od-1,o=(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:-n/2,y:-o/2},{x:-n/2,y:o/2},...DV.map(({x:g,y:c})=>({x:g*n/6,y:c*n/6+o/2})),{x:n/2,y:o/2},{x:n/2,y:-o/2},{x:-n/2,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1},r=[];for(let g=0;g<A.num_pins;g++){const c=g<A.num_pins/2,I=.6,{y:l}=Hte(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating),B=c?-A.w/2-A.od/2-I:A.w/2+A.od/2+I,C=l;r.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${g+1}`,layer:"top",pcb_component_id:`pin_${g+1}`,text:`{pin${g+1}}`,anchor_position:{x:B,y:C},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Mi(0,o/2+.5,.4);return{circuitJson:[...e,s,a,...r],parameters:A}},Ii=(t,A,e,i,n)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:n,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),Yte=[{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}],Yvt=Object.fromEntries(Yte.map(t=>[t.metric,t])),Jvt=Object.fromEntries(Yte.map(t=>[t.imperial,t]));Li.extend({tht:qA(),p:lA.optional(),pw:lA.optional(),ph:lA.optional(),metric:se.optional(),imperial:se.optional(),w:lA.optional(),h:lA.optional(),textbottom:qA().optional()});var bV=t=>{let{tht:A,p:e,pw:i,ph:n,metric:o,imperial:s,w:r,h:a,textbottom:g}=t;if(typeof r=="string"&&(r=ql(r)),typeof a=="string"&&(a=ql(a)),typeof e=="string"&&(e=ql(e)),typeof i=="string"&&(i=ql(i)),typeof n=="string"&&(n=ql(n)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let c;if(o&&(c=Yvt[o]),s&&(c=Jvt[s]),c&&(r=c.w_mm_min,a=c.h_mm_min,e=c.p_mm_min,i=c.pw_mm_min,n=c.ph_mm_min),e===void 0||i===void 0||n===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:e/2,y:n/2+.4},{x:-e/2-i/2-.2,y:n/2+.4},{x:-e/2-i/2-.2,y:-n/2-.4},{x:e/2,y:-n/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},l=g?-n/2-.9:n/2+.9,B=Mi(0,l,.2);return A?[vo(1,-e/2,0,i,i*1/.8),vo(2,e/2,0,i,i*1/.8),I,B]:[Ii(["1","left"],-e/2,0,i,n),Ii(["2","right"],e/2,0,i,n),I,B]},Tvt=t=>({circuitJson:bV(t),parameters:t}),Pvt=t=>({circuitJson:bV(t),parameters:t}),Kvt=t=>({circuitJson:bV(t),parameters:t}),c1=t=>{const{padSpacing:A,padWidth:e,padHeight:i,padPitch:n,numRows:o,textbottom:s}=t,r=[],a=(o-1)*(n/2);for(let S=0;S<o;S++)r.push(a-S*n);const g=[];r.forEach((S,_)=>{g.push(Ii(_+1,-A/2,S,e,i))}),r.slice().reverse().forEach((S,_)=>{g.push(Ii(_+o+1,A/2,S,e,i))});const c=Math.max(...r)+i/2+.4,I=Math.min(...r)-i/2-.4,l=-A/2-e/2-.4,B=A/2+e/2+.4,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B*.5,y:c},{x:l*.5,y:c}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B*.5,y:I},{x:l*.5,y:I}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},h=-A/2,E=Math.max(...r),u=.2,d=h-e/2-.1,f=E+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},w=s?I-.9:c+.9,D=Mi(0,w,.2);return[...g,C,Q,m,D]},qvt=Li.extend({pw:lA.default("0.5mm"),ph:lA.default("0.4mm"),p:lA.default("0.7mm"),textbottom:qA().optional(),convex:qA().optional(),concave:qA().optional()}),Ovt=1,Wvt=t=>{const A=qvt.parse(t);if(A.concave===!0)return[];const e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return c1({padSpacing:Ovt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},Zvt=Li.extend({pw:lA.default("0.5mm"),ph:lA.default("0.32mm"),p:lA.default("0.5mm"),textbottom:qA().optional(),convex:qA().optional(),concave:qA().optional()}),Vvt=1,jvt=t=>{const A=Zvt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return c1({padSpacing:Vvt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},zvt=Li.extend({pw:lA.default("0.9mm"),ph:lA.default("0.4mm"),p:lA.default("0.8mm"),textbottom:qA().optional(),convex:qA().optional(),concave:qA().optional()}),Xvt=1.7,$vt=t=>{const A=zvt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return c1({padSpacing:Xvt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},AFt=Li.extend({pw:lA.default("0.9mm"),ph:lA.default("0.4mm"),p:lA.default("0.8mm"),textbottom:qA().optional(),convex:qA().optional(),concave:qA().optional()}),eFt=1.7,tFt=t=>{const A=AFt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return c1({padSpacing:eFt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},iFt=Li.extend({pw:lA.default("0.7mm"),ph:lA.default("0.64mm"),p:lA.default("0.94mm"),textbottom:qA().optional(),convex:qA().optional(),concave:qA().optional()}),nFt=1.4,oFt=t=>{const A=iFt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return c1({padSpacing:nFt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},sFt=Li.extend({pw:lA.default("0.9mm"),ph:lA.default("0.9mm"),p:lA.default("1.34mm"),textbottom:qA().optional(),convex:qA().optional(),concave:qA().optional()}),rFt=3,aFt=t=>{const A=sFt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return c1({padSpacing:rFt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},gFt=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(/x(2|4)$/)?.[1];if(i)return Number.parseInt(i,10)}},cFt=t=>t?(typeof t=="number"?`${t}`:t).split(/[_x]/)[0]:void 0,IFt=t=>{const A=gFt(t),e=cFt(t.imperial);return A===2&&e==="0402"?{circuitJson:Wvt(t),parameters:t}:A===4&&e==="0402"?{circuitJson:jvt(t),parameters:t}:A===2&&e==="0603"?{circuitJson:$vt(t),parameters:t}:A===4&&e==="0603"?{circuitJson:tFt(t),parameters:t}:A===2&&e==="0606"?{circuitJson:oFt(t),parameters:t}:A===4&&e==="1206"?{circuitJson:aFt(t),parameters:t}:{circuitJson:bV(t),parameters:t}},Jte=(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(n=>n.toString()):[t.toString()]}),Tte="ABCDEFGHIJKLMNOPQRSTUVWXYZ",xV=H().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A??""),y:parseFloat(e??"")}}).pipe(te({x:OA(),y:OA()})),lFt=H().or(be(Xc())).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(H().or(OA()))),BFt=Li.extend({fn:H(),num_pins:OA().optional().default(64),grid:xV.optional(),p:se.default("0.8mm"),w:lA.optional(),h:lA.optional(),ball:lA.optional().describe("ball diameter"),pad:lA.optional().describe("pad width/height"),circularpads:qA().optional().describe("use circular pads"),tlorigin:qA().optional(),blorigin:qA().optional(),trorigin:qA().optional(),brorigin:qA().optional(),missing:lFt.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 n=i.match(/([A-Z]+)(\d+)/);if(!n)return i;const o=Tte.indexOf(n[1]),s=Number.parseInt(n[2])-1;return o*t.grid.x+s+1})),{...t,origin:A}}),CFt=t=>{const A=BFt.parse(t);let{num_pins:e,grid:i,p:n,w:o,h:s,ball:r,pad:a,missing:g}=A;r??=.75/1.27*n,a??=r*.8;const c=[],I=(g??[]).filter(m=>typeof m=="number"),l=i.x*i.y-e;if(g.length===0&&l>0&&(Math.sqrt(l)%1===0?g.push("center"):l===1&&g.push("topleft")),g?.includes("center")){const m=Math.floor(Math.sqrt(l)),w=Math.floor((i.x-m)/2),D=Math.floor((i.y-m)/2);for(let S=D;S<D+m;S++)for(let _=w;_<w+m;_++)I.push(S*i.x+_+1)}g?.includes("topleft")&&I.push(1);const B=new Set(I);let C=0;for(let m=0;m<i.y;m++)for(let w=0;w<i.x;w++){const D=(w-(i.x-1)/2)*n,S=(m-(i.y-1)/2)*n;let _=w,x=m;switch(A.origin){case"bl":_=w,x=i.y-1-m;break;case"br":_=i.x-1-w,x=i.y-1-m;break;case"tr":_=i.x-1-w,x=m;break}let G=x*i.x+_+1;if(B.has(G)){C++;continue}G-=C;const F=[G,`${Tte[x]}${_+1}`];c.push(A.circularpads?Jte(F,{x:D,y:S,radius:a/2}):Ii(F,D,S,a,a))}const Q=Mi(0,i.y*n/2,.2),h=n/6;let E;const u=i.x*n/2,d=i.y*n/2;switch(A.origin){case"bl":E=[{x:-u,y:-d},{x:-u,y:-d-h},{x:-u-h,y:-d},{x:-u,y:-d}];break;case"br":E=[{x:u,y:-d},{x:u,y:-d-h},{x:u+h,y:-d},{x:u,y:-d}];break;case"tr":E=[{x:u,y:d},{x:u,y:d+h},{x:u+h,y:d},{x:u,y:d}];break;default:E=[{x:-u,y:d},{x:-u,y:d+h},{x:-u-h,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:E,stroke_width:.05};return{circuitJson:[...c,Q,f],parameters:A}},_V=(t,A,e,i,n)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:n,radius:n/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),KF=t=>Li.extend({fn:H(),num_pins:OA().optional().default(8),w:lA.default(lA.parse(t.w??"5.3mm")),p:lA.default(lA.parse(t.p??"1.27mm")),pw:lA.default(lA.parse(t.pw??"0.6mm")),pl:lA.default(lA.parse(t.pl??"1.0mm")),legsoutside:qA().optional().default(t.legsoutside??!1),pillpads:qA().optional().default(t.pillpads??!1),silkscreen_stroke_width:OA().optional().default(.1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=lA.parse("0.6mm"),A.pl=lA.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),QFt=KF({}),vdA=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:A,pn:e,w:i,p:n,pl:o,legsoutside:s}=t,r=A/2,a=e<=r,g=r-1,c=n,I=c*g,l=s?o/2:-o/2;return a?{x:-i/2-l,y:I/2-(e-1)*c}:{x:i/2+l,y:-I/2+(e-r-1)*c}},hFt=t=>{const A=QFt.parse(t);return{circuitJson:WY(A),parameters:A}},WY=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=vdA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push(_V(r+1,a,g,t.pl,t.pw)):A.push(Ii(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,n=(t.num_pins/2-1)*t.p+t.pw+e,o=Mi(0,n/2+.4,n/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:-n/2},{x:-i/2,y:n/2},...DV.map(({x:r,y:a})=>({x:r*i/6,y:a*i/6+n/2})),{x:i/2,y:n/2},{x:i/2,y:-n/2},{x:-i/2,y:-n/2}]};return[...A,s,o]},Pte=et(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),EFt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const n=[],o=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=o:r.bottomside&&r.leftpin?s=o+1:r.bottomside&&r.rightpin?s=o*2:r.rightside&&r.bottompin?s=o*2+1:r.rightside&&r.toppin?s=o*3:r.topside&&r.rightpin?s=o*3+1:r.topside&&r.leftpin&&(s=o*4),n.push(-1);for(let a=0;a<t;a++)n[s]=a+1,e||!A?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return n},FdA=Li.extend({fn:H(),cc:qA().default(!0).optional(),ccw:qA().default(!0).optional(),startingpin:H().or(be(Pte)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(be(Pte)).optional(),num_pins:OA().optional().default(64),w:lA.optional(),h:lA.optional(),p:lA.default(lA.parse("0.5mm")),pw:lA.optional(),pl:lA.optional(),thermalpad:Gt([kA(!0),xV]).optional(),legsoutside:qA().default(!1)}),NdA=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},Kte=FdA.transform(NdA),uFt=["left","bottom","right","top"],dFt=t=>{const{pin_count:A,pn:e,w:i,h:n,p:o,pl:s,legsoutside:r}=t,a=A/4,g=uFt[Math.floor((e-1)/a)],c=(e-1)%a,I=o*(a-1),l=o*(a-1),B=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-B+.1,y:l/2-c*o,o:"vert"};case"bottom":return{x:-I/2+c*o,y:-n/2-B+.1,o:"horz"};case"right":return{x:i/2+B-.1,y:-l/2+c*o,o:"vert"};case"top":return{x:I/2-c*o,y:n/2+B-.1,o:"horz"};default:throw new Error("Invalid pin number")}},I1=t=>{const A=Kte.parse(t),e=[],i=EFt(A),n=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:c}=dFt({pin_count:A.num_pins,pn:r+1,w:A.w,h:A.h,p:A.p??.5,pl:A.pl,legsoutside:A.legsoutside});let I=A.pw,l=A.pl;c==="vert"&&([I,l]=[l,I]);const B=i[r+1];e.push(Ii(B,a,g,I,l))}if(A.thermalpad)if(typeof A.thermalpad=="boolean"){const r=A.p*(n-1)+A.pw,a=A.p*(n-1)+A.pw;e.push(Ii(["thermalpad"],0,0,r,a))}else e.push(Ii(["thermalpad"],0,0,A.thermalpad.x,A.thermalpad.y));const o=[];for(const[r,a,g]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const c=A.w/2*a,I=A.h/2*g;let l="none",B=c,C=I;const Q=A.pw*2;i[1]===1&&r==="top-left"?l="in1":i[n*4]===1&&r==="top-left"||i[n*3+1]===1&&r==="top-right"?l="in2":i[n*3]===1&&r==="top-right"||i[n]===1&&r==="bottom-left"?l="in1":i[n+1]===1&&r==="bottom-left"?l="in2":i[n*2]===1&&r==="bottom-right"?l="in1":i[n*2+1]===1&&r==="bottom-right"&&(l="in2");const h=l==="in1"?1:-1;if(A.legsoutside){const E=l==="in1"?A.pl/2:A.pw/2,u=l==="in1"?A.pw/2:A.pl/2;B+=E*a*h,C-=u*g*h}(l==="none"||A.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:c-Q*a,y:I},{x:c,y:I},{x:c,y:I-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(l==="in1"||l==="in2")&&!A.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:c-Q*a,y:I},{x:c-Q*a/2,y:I}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:c,y:I-Q*g/2},{x:c,y:I-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(l==="in1"||l==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:B-.2*-a,y:C+.2*h},{x:B,y:C},{x:B+.2*h*-a,y:C+.2},{x:B-.2*-a,y:C+.2*h}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Mi(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...o,s],parameters:A}};FdA.extend({}).transform(NdA);var pFt=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),I1(t)),fFt=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 I1(t)},yFt=t=>{t.legsoutside=!0;const A=Kte.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 I1(t)};FdA.extend({}).transform(NdA);var mFt=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),I1(t)),wFt=Li.extend({fn:H(),num_pins:OA().optional().default(8),w:lA.default(lA.parse("3.9mm")),p:lA.default(lA.parse("1.27mm")),pw:lA.optional(),pl:lA.optional(),legsoutside:qA().optional().default(!1),silkscreen_stroke_width:OA().optional().default(.1)}).transform(t=>(t.pw==null&&t.pl==null?(t.pw=lA.parse("0.51mm"),t.pl=lA.parse("1.1mm")):t.pw==null?t.pw=t.pl*(.51/1.1):t.pl==null&&(t.pl=t.pw*(1.1/.51)),t)),DFt=t=>{const{num_pins:A,pn:e,w:i,p:n}=t,o=A/2,s=e<=o,r=o-1,a=n,g=a*r,c=i+lA.parse("0.2mm"),I=(s?-1:1)*(c/2);return s?{x:I,y:g/2-(e-1)*a}:{x:I,y:-g/2+(e-o-1)*a}},SFt=t=>{const A=wFt.parse(t),e=[];for(let a=0;a<A.num_pins;a++){const{x:g,y:c}=DFt({num_pins:A.num_pins,pn:a+1,w:A.w,p:A.p,pl:A.pl,legsoutside:A.legsoutside});e.push(Ii(a+1,g,c,A.pl,A.pw))}const i=Math.min(1,A.p/2),n=A.w-(A.legsoutside?0:A.pl)-.2,o=(A.num_pins/2-1)*A.p+A.pw+i,s=Mi(0,o/2+.4,o/12),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:A.silkscreen_stroke_width??.1,route:[{x:-n/2,y:-o/2},{x:-n/2,y:o/2},...DV.map(({x:a,y:g})=>({x:a*n/6,y:g*n/6+o/2})),{x:n/2,y:o/2},{x:n/2,y:-o/2},{x:-n/2,y:-o/2}]};return{circuitJson:[...e,r,s],parameters:A}},bFt=Li.extend({fn:H(),num_pins:OA().optional().default(8),w:lA.default(lA.parse("3.0mm")),p:lA.default(lA.parse("0.5mm")),pw:lA.default(lA.parse("0.30mm")),pl:lA.default(lA.parse("1.45mm")),legsoutside:qA().optional().default(!0),silkscreen_stroke_width:OA().optional().default(.1)}),xFt=t=>{const{num_pins:A,pn:e,w:i,p:n,pl:o,legsoutside:s}=t,r=A/2,a=e<=r,g=r-1,c=n*g,I=s?o/2:-o/2;return a?{x:-i/2-I,y:c/2-(e-1)*n}:{x:i/2+I,y:-c/2+(e-r-1)*n}},_Ft=t=>{const A={...t},e=A.p,i=typeof e=="string"||typeof e=="number"?lA.parse(e):void 0,n=i!=null&&i<=lA.parse("0.5mm"),o=bFt.parse(A),s=[],r=n?o.w-lA.parse("0.15mm"):o.w;for(let B=0;B<o.num_pins;B++){const{x:C,y:Q}=xFt({num_pins:o.num_pins,pn:B+1,w:r,p:o.p,pl:o.pl,legsoutside:o.legsoutside});s.push(Ii(B+1,C,Q,o.pl,o.pw))}const a=Math.min(1,o.p/2),g=o.w-(o.legsoutside?0:o.pl*2)-.2,c=(o.num_pins/2-1)*o.p+o.pw+a,I=Mi(0,c/2+.4,c/12),l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:o.silkscreen_stroke_width??.1,route:[{x:-g/2,y:-c/2},{x:-g/2,y:c/2},...DV.map(({x:B,y:C})=>({x:B*g/6,y:C*g/6+c/2})),{x:g/2,y:c/2},{x:g/2,y:-c/2},{x:-g/2,y:-c/2}]};return{circuitJson:[...s,l,I],parameters:o}},kFt=Li.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("3.1mm"),h:H().default("2.0mm"),p:H().default("0.65mm"),pl:H().default("1.03mm"),pw:H().default("0.35mm"),string:H().optional()}),vFt=t=>{const A=kFt.parse({...t,fn:"sot363"}),e=lA.parse(A.w),i=lA.parse(A.h),n=lA.parse(A.p),o=lA.parse(A.pl),s=lA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=qte(B+1,e,n);r.push(Ii(B+1,C,Q,o,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/4,y:i/2+.1},{x:e/4,y:i/2+.1}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/4,y:-i/2-.1},{x:e/4,y:-i/2-.1}],stroke_width:.05,pcb_silkscreen_path_id:""},c=qte(1,e,n),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-o/2-.3,y:c.y},{x:c.x-o/2-.45,y:c.y+.15},{x:c.x-o/2-.45,y:c.y-.15},{x:c.x-o/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Mi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},qte=(t,A,e,i)=>t<=3?{x:-.84,y:e-(t-1)*e}:{x:.84,y:-e+(t-4)*e},FFt=Li.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("1.01mm"),h:H().default("1.45mm"),p:H().default("0.5mm"),pl:H().default("0.33mm"),pw:H().default("0.27mm"),string:H().optional()}),NFt=t=>{const A=FFt.parse({...t,fn:"sot886"}),e=lA.parse(A.w),i=lA.parse(A.h),n=lA.parse(A.p),o=lA.parse(A.pl),s=lA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=Ote(B+1,e,n,o);r.push(Ii(B+1,C,Q,o,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:""},c=Ote(1,e,n,o),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-o/2-.3,y:c.y},{x:c.x-o/2-.45,y:c.y+.15},{x:c.x-o/2-.45,y:c.y-.15},{x:c.x-o/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Mi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},Ote=(t,A,e,i)=>{const n=A/2-i/2;return t<=3?{x:-n,y:e-(t-1)*e}:{x:n,y:-e+(t-4)*e}},Wte=Li.extend({fn:H(),num_pins:OA().default(3),w:H().default("1.92mm"),h:H().default("2.74mm"),pl:H().default("1.32mm"),pw:H().default("0.6mm"),p:H().default("0.95mm"),string:H().optional()}),RFt=KF({p:"0.95mm",w:"1.6mm",legsoutside:!0}),GFt=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const n=RFt.parse({...t,num_pins:e});return{circuitJson:WY(n),parameters:n}}const i=Wte.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:LFt(i),parameters:i};if(i.num_pins===5)return{circuitJson:Vte(i),parameters:i};throw new Error("Invalid number of pins")},MFt=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}},LFt=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:n,y:o}=MFt({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(Ii(i+1,n,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Mi(0,Number.parseInt(t.h),.3);return[...A,e]},Zte=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")},Vte=t=>{const A=[];for(let I=1;I<=t.num_pins;I++){const{x:l,y:B}=Zte({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:I});A.push(Ii(I,l,B,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),n={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},o={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=Mi(0,i+.3,.3),r=Zte({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,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,n,o,c]},UFt=Wte.extend({}),HFt=t=>{const A=UFt.parse({...t,num_pins:5});return{circuitJson:Vte(A),parameters:A}},YFt=[{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}],JFt=KF({}),TFt=t=>{const A=JFt.parse(t),e=[];for(let I=0;I<A.num_pins;I++){const{x:l,y:B}=vdA({num_pins:A.num_pins,pn:I+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(Ii(I+1,l,B,A.pl??"1mm",A.pw??"0.6mm"))}const i=Math.min(1,A.p/2),n=A.w+i,o=(A.num_pins/2-1)*A.p+A.pw+i,s=[];for(const I of YFt){const{dx:l,dy:B}=I;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:l*n/2-l*A.p,y:B*o/2},{x:l*n/2,y:B*o/2},{x:l*n/2,y:B*o/2-B*A.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const r=A.p/4,a=-n/2-r/2,g=o/2-A.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:a,y:g},{x:a-r,y:g+r},{x:a-r,y:g-r},{x:a,y:g}],stroke_width:.1});const c=Mi(0,o/2+.4,o/12);return{circuitJson:[...e,c,...s],parameters:A}},qF=({fs:t,pn:A,anchor_x:e,anchor_y:i,textalign:n="center",orthogonal:o=!1,verticallyinverted:s=!1,layer:r="top"})=>{let a=0;o&&s?a=270:s?a=180:o?a=90:a=0;let g="center";return n==="left"&&(s?g="center_right":g="center_left"),n==="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 jte({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 PFt=Li.extend({fn:H(),num_pins:OA().optional().default(6),rows:Gt([H(),OA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:lA.default("0.1in").describe("pitch"),id:lA.default("1.0mm").describe("inner diameter"),od:lA.default("1.5mm").describe("outer diameter"),male:qA().optional().describe("for male pin headers"),female:qA().optional().describe("for female pin headers"),smd:qA().optional().describe("surface mount device"),surfacemount:qA().optional().describe("surface mount device (verbose)"),rightangle:qA().optional().describe("right angle"),pw:lA.optional().default("1.0mm").describe("pad width for SMD"),pl:lA.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:qA().optional().default(!1),pinlabeltextaligncenter:qA().optional().default(!1),pinlabeltextalignright:qA().optional().default(!1),pinlabelverticallyinverted:qA().optional().default(!1),pinlabelorthogonal:qA().optional().default(!1),nosquareplating:qA().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:qA().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:qA().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:qA().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=jte(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:jt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),KFt=t=>{const A=PFt.parse(t),{p:e,id:i,od:n,rows:o,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:c,pinlabeltextalignright:I,nopinlabels:l,doublesidedpinlabel:B,bottomsidepinlabel:C}=A;let Q="center";c?Q="left":I&&(Q="right");const h=[],E=Math.ceil(s/o),u=-e,d=({xoff:S,yoff:_,od:x,anchorSide:G,smd:F,pw:L,pl:Y})=>{let J=0,O=0;if(F){const Z=x/5;switch(G){case"right":J=L/2+Z;break;case"top":O=Y/2+Z;break;case"bottom":O=-(Y/2+Z);break;case"left":J=-(L/2+Z);break}}else{const Z=x*.75;switch(G){case"right":J=Z;break;case"top":O=Z;break;case"bottom":O=-Z;break;case"left":J=-Z;break}}return{anchor_x:S+J,anchor_y:_+O}},f=(S,_,x)=>{A.smd?h.push(Ii(S,_,x,A.pw,A.pl)):S===1&&!A.nosquareplating?h.push(YD({pn:S,x:_,y:x,holeDiameter:i,rectPadWidth:n,rectPadHeight:n})):h.push(vo(S,_,x,i,n));const{anchor_x:G,anchor_y:F}=d({xoff:_,yoff:x,od:n,anchorSide:r,smd:A.smd,pw:A.pw,pl:A.pl});l||(C?h.push(qF({fs:n/5,pn:S,anchor_x:G,anchor_y:F,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):h.push(qF({fs:n/5,pn:S,anchor_x:G,anchor_y:F,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),B&&h.push(qF({fs:n/5,pn:S,anchor_x:G,anchor_y:F,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},m=new Set,w=o>2&&E>2;if(o===1){const S=-((s-1)/2)*e;for(let _=0;_<s;_++){const x=_+1,G=S+_*e,F=`${G},0`;if(m.has(F))throw new Error(`Overlap at ${F}`);m.add(F),f(x,G,0)}}else if(w){const S=-((E-1)/2)*e;let _=1;for(let x=0;x<o&&_<=s;x++)for(let G=0;G<E&&_<=s;G++){const F=S+G*e,L=x*u,Y=`${F},${L}`;if(m.has(Y))throw new Error(`Overlap at ${Y}`);m.add(Y),f(_++,F,L)}}else{const S=-((E-1)/2)*e;let _=1,x=0,G=o-1,F=0,L=E-1;for(;_<=s&&x<=G&&F<=L;){for(let Y=x;Y<=G&&_<=s;Y++){const J=S+F*e,O=Y*u,Z=`${J},${O}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(_++,J,O)}F++;for(let Y=F;Y<=L&&_<=s;Y++){const J=S+Y*e,O=G*u,Z=`${J},${O}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(_++,J,O)}if(G--,F<=L){for(let Y=G;Y>=x&&_<=s;Y--){const J=S+L*e,O=Y*u,Z=`${J},${O}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(_++,J,O)}L--}if(x<=G){for(let Y=L;Y>=F&&_<=s;Y--){const J=S+Y*e,O=x*u,Z=`${J},${O}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(_++,J,O)}x++}}if(_-1<s)throw new Error(`Missing pins: assigned ${_-1}, expected ${s}`)}const D=Mi(0,e,.5);return{circuitJson:[...h,D],parameters:A}},qFt=Li.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("2.1mm"),h:H().default("2.45mm"),p:H().default("0.5mm"),pl:H().default("0.675mm"),pw:H().default("0.35mm"),string:H().optional()}),OFt=t=>{const A=qFt.parse({...t,fn:"sot563"}),e=lA.parse(A.w),i=lA.parse(A.h),n=lA.parse(A.p),o=lA.parse(A.pl),s=lA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=zte(B+1,e,n,o);r.push(Ii(B+1,C,Q,o,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:""},c=zte(1,e,n,o),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-o/2-.3,y:c.y},{x:c.x-o/2-.45,y:c.y+.15},{x:c.x-o/2-.45,y:c.y-.15},{x:c.x-o/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Mi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},zte=(t,A,e,i)=>{const n=A/2-i/2;return t<=3?{x:-n,y:e-(t-1)*e}:{x:n,y:-e+(t-4)*e}},WFt=KF({p:"1.27mm",w:"3.9mm",legsoutside:!0}),ZFt=t=>{const A=WFt.parse({...t,num_pins:8});return{circuitJson:WY(A),parameters:A}},VFt=KF({p:"1.27mm",w:"7.5mm",legsoutside:!0}),jFt=t=>{const A=VFt.parse({...t,num_pins:16});return{circuitJson:WY(A),parameters:A}},zFt=Li.extend({fn:H(),num_pins:kA(3).default(3),w:H().default("1.2mm"),h:H().default("1.2mm"),pw:H().default("0.40mm"),pl:H().default("0.45mm"),p:H().default("0.575mm")}),XFt=t=>{const A=zFt.parse(t),e=ANt(A),i=Mi(0,lA.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},$Ft=t=>{const{pn:A,p:e}=t;return A===1?{x:e,y:0}:A===2?{x:-e,y:-.4}:{x:-e,y:.4}},ANt=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:n}=$Ft({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(Ii(e+1,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},eNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("2.36mm"),h:H().default("1.22mm"),pl:H().default("0.9mm"),pw:H().default("1.2mm"),p:H().default("3.30mm")}),tNt=t=>{const A=eNt.parse(t),e=Mi(0,lA.parse(A.h)/4+.4,.3);return{circuitJson:nNt(A).concat(e),parameters:A}},iNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},nNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=iNt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},oNt=Li.extend({fn:H(),p:lA.optional().default("2.54mm"),id:lA.optional().default("0.7mm"),od:lA.optional().default("1.4mm")}),sNt=t=>{const A=oNt.parse(t),{p:e,id:i,od:n}=A,o=[vo(1,-e/2,0,i,n),vo(2,e/2,0,i,n)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2+n+i/2,y:0},{x:e/2-n-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},r=Mi(0,1.5,.5);return{circuitJson:[...o,s,r],parameters:A}},rNt=(t,A,e,i,n,o=.1)=>{const s=[],r=[],a=Math.max(1,Math.ceil(Math.PI*e/o)),g=Math.PI/a;for(let c=0;c<=a;c++){const I=c*g,l=t+Math.cos(I)*e,B=A+Math.sin(I)*e;l<t-i&&B>=A-n/2&&B<=A+n/2||s.push({x:l,y:B})}for(let c=0;c<=a;c++){const I=Math.PI+c*g,l=t+Math.cos(I)*e,B=A+Math.sin(I)*e;l<t-i&&B>=A-n/2&&B<=A+n/2||r.push({x:l,y:B})}return{topArc:s,bottomArc:r}},aNt=Li.extend({fn:H(),p:lA.optional().default("5mm"),id:lA.optional().default("0.8mm"),od:lA.optional().default("1.6mm"),ceramic:qA().optional(),electrolytic:qA().optional(),polarized:qA().optional()}),gNt=t=>{const A=aNt.parse(t),{p:e,id:i,od:n}=A;i===.8&&n===1.6&&(A.id=e===5?.8:e*.25,A.od=e===5?1.6:e*.5);const o=[vo(1,-e/2,0,A.id,A.od),vo(2,e/2,0,A.id,A.od)],s=e+.1,{topArc:r,bottomArc:a}=rNt(0,0,s,A.od/2,A.od),g=.02*e,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:g,pcb_silkscreen_path_id:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:g,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:s},{x:0,y:-s}],stroke_width:g,pcb_silkscreen_path_id:""},B=.1*e,C=-(e+B+.04*e),Q=s-B-.08*e,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C-B,y:Q},{x:C+B,y:Q}],stroke_width:g,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C,y:Q-B},{x:C,y:Q+B}],stroke_width:g,pcb_silkscreen_path_id:""},u=Mi(0,s+.12*e,.1*e),d=[...o,c,I,l,u];return(A.electrolytic===!0||A.polarized===!0)&&d.push(h,E),{circuitJson:d,parameters:A}},OF=(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}),cNt=Li.extend({fn:kA("pushbutton"),w:lA.default(4.5),h:lA.default(6.5),id:lA.default(1),od:lA.default(1.2)}),INt=t=>{const A=cNt.parse(t),e=A.w,i=A.h,n=A.id,o=[vo(1,-e/2,i/2,n,n*1.5),vo(2,-e/2,-i/2,n,n*1.5),vo(3,e/2,-i/2,n,n*1.5),vo(4,e/2,i/2,n,n*1.5)],s=[OF([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),OF([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),OF([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),OF([{x:e/2,y:0},{x:e/5,y:0}])],r=Mi(0,i/2+.4,.5);return{circuitJson:[...o,...s,r],parameters:A}},Xte=Li.extend({fn:H(),w:lA.default("22.58mm"),h:lA.optional(),left:lA.optional().default(20),right:lA.optional().default(20),top:lA.optional().default(2),bottom:lA.optional().default(2),p:lA.default(lA.parse("2.54mm")),pw:lA.default(lA.parse("1.6mm")),pl:lA.default(lA.parse("2.4mm")),innerhole:qA().default(!1),innerholeedgedistance:lA.default(lA.parse("1.61mm")),silkscreenlabels:qA().default(!1),silkscreenlabelmargin:lA.default(lA.parse("0.1mm"))}),lNt=t=>{const A=Xte.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},kV=(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},BNt=t=>{const A=Xte.parse(t),e=A.h??lNt(A),i=[],n=[],o=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),I=`pin${g}`.length*.7/2;if(A.right){const Q=-((A.right-1)/2)*A.p;for(let h=0;h<A.right;h++){if(h===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=kV(A.w/2-A.pl*1.4,Q+h*A.p,"right")),i.push(Ii(h+1+A.left+(A.bottom??0),A.w/2-A.pl/2,Q+h*A.p,A.pl,A.pw)),A.silkscreenlabels){const E=h+1+A.left+(A.bottom??0),u=`pin${E}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${E}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl-(I+A.silkscreenlabelmargin),y:Q+h*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(vo(h+1+A.left+(A.bottom??0)+g,A.w/2,Q+h*A.p,r,a)),n.push(vo(h+1+A.left+(A.bottom??0)+g*2,A.w/2-A.innerholeedgedistance,Q+h*A.p,r,a)))}}if(A.left){const Q=(A.left-1)/2*A.p;for(let h=0;h<A.left;h++){if(h===0&&!A.silkscreenlabels&&(s=kV(-A.w/2+A.pl*1.4,Q-h*A.p,"left")),i.push(Ii(h+1,-A.w/2+A.pl/2,Q-h*A.p,A.pl,A.pw)),A.silkscreenlabels){const E=h+1,u=`pin${E}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${E}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl+(I+A.silkscreenlabelmargin),y:Q-h*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(vo(h+1+g,-A.w/2,Q-h*A.p,r,a)),n.push(vo(h+1+g*2,-A.w/2+A.innerholeedgedistance,Q-h*A.p,r,a)))}}if(A.top){const Q=(A.top-1)/2*A.p;for(let h=0;h<A.top;h++){if(h===0&&!A.left&&!A.bottom&&!A.right&&!A.silkscreenlabels&&(s=kV(Q-h*A.p,e/2-A.pl*1.4,"top")),i.push(Ii(h+1+A.left+A.right+(A.bottom??0),Q-h*A.p,e/2-A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const E=h+1+A.left+A.right+(A.bottom??0),u=`pin${E}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${E}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q-h*A.p,y:e/2-A.pl-(I+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(n.push(vo(h+1+A.left+A.right+(A.bottom??0)+g,Q-h*A.p,e/2,r,a)),n.push(vo(h+1+A.left+A.right+(A.bottom??0)+g*2,Q-h*A.p,e/2-A.innerholeedgedistance,r,a)))}}if(A.bottom){const Q=-((A.bottom-1)/2)*A.p;for(let h=0;h<A.bottom;h++){if(h===0&&!A.left&&!A.silkscreenlabels&&(s=kV(Q+h*A.p,-e/2+A.pl*1.4,"bottom")),i.push(Ii(h+1+A.left,Q+h*A.p,-e/2+A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const E=h+1+A.left,u=`pin${E}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${E}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q+h*A.p,y:-e/2+A.pl+(I+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(n.push(vo(h+1+A.left+g,Q+h*A.p,-e/2,r,a)),n.push(vo(h+1+A.left+g*2,Q+h*A.p,-e/2+A.innerholeedgedistance,r,a)))}}const l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2,y: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=Mi(0,e/1.8,e/25);return{circuitJson:[...i,...n,...o,B,...A.silkscreenlabels?[]:[l],C],parameters:A}},$te=Li.extend({fn:H(),w:lA.default("22.58mm"),h:lA.optional(),left:lA.optional().default(20),right:lA.optional().default(20),top:lA.optional().default(2),bottom:lA.optional().default(2),p:lA.default(lA.parse("2.54mm")),pw:lA.default(lA.parse("1.6mm")),pl:lA.default(lA.parse("3.2mm")),innerhole:qA().default(!1),innerholeedgedistance:lA.default(lA.parse("1.61mm"))}),CNt=t=>{const A=$te.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},QNt=(t,A,e,i=1,n=.6)=>{const o=i/2,s=n/2;return{left:[{x:t+o,y:A},{x:t-o,y:A+s},{x:t-o,y:A-s},{x:t+o,y:A}],right:[{x:t-o,y:A},{x:t+o,y:A+s},{x:t+o,y:A-s},{x:t-o,y:A}],top:[{x:t,y:A-o},{x:t-s,y:A+o},{x:t+s,y:A+o},{x:t,y:A-o}],bottom:[{x:t,y:A+o},{x:t-s,y:A-o},{x:t+s,y:A-o},{x:t,y:A+o}]}[e]},hNt=t=>{const A=$te.parse(t),e=A.h??CNt(A),i=[],n=[],o=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],c=1;if(A.left){const C=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++)Q===0&&(g=QNt(-A.w/2-A.pl/2,C-Q*A.p,"left")),i.push(Ii(c,-A.w/2+A.pl/2,C-Q*A.p,A.pl,A.pw)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:C-Q*A.p},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&o.push(vo(c+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(Ii(c,C-Q*A.p,-e/2+A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C-Q*A.p,y:-e/2+A.pl/2-3.2},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&o.push(vo(c+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(Ii(c,A.w/2-A.pl/2,C+Q*A.p,A.pl,A.pw)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:C+Q*A.p},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&o.push(vo(c+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(Ii(c,C+Q*A.p,e/2-A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C+Q*A.p,y:e/2-A.pl/2+3.2},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&o.push(vo(c+a,C+Q*A.p,e/2-A.innerholeedgedistance,s,r))}const I={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:g,stroke_width:.1},l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-A.pl/3,y: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"},B=Mi(0,e/1.8,e/25);return{circuitJson:[...o,...i,...n,l,I,B],parameters:A}},ENt=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),I1(t)),Aie=Li.extend({fn:H(),w:lA.default("10mm"),h:lA.optional(),left:lA.optional().default(20),right:lA.optional().default(20),top:lA.optional().default(0),bottom:lA.optional().default(0),p:lA.default(lA.parse("2.54mm")),id:lA.optional().default(lA.parse("1mm")),od:lA.optional().default(lA.parse("1.5mm"))}),uNt=t=>{const A=Aie.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},vV=(t,A,e,i=1,n=.6)=>{const o=i/2,s=n/2;return{left:[{x:t+o,y:A},{x:t-o,y:A+s},{x:t-o,y:A-s},{x:t+o,y:A}],right:[{x:t-o,y:A},{x:t+o,y:A+s},{x:t+o,y:A-s},{x:t-o,y:A}],top:[{x:t,y:A-o},{x:t-s,y:A+o},{x:t+s,y:A+o},{x:t,y:A-o}],bottom:[{x:t,y:A+o},{x:t-s,y:A-o},{x:t+s,y:A-o},{x:t,y:A+o}]}[e]},dNt=t=>{const A=Aie.parse(t),e=A.h??uNt(A),i=[],n=A.id,o=A.od;let s=[];if(A.right){const c=-((A.right-1)/2)*A.p;for(let I=0;I<A.right;I++)I===0&&!A.left&&!A.bottom&&(s=vV(A.w/2+o*1.4,c+I*A.p,"right")),i.push(vo(I+1+A.left+(A.bottom??0),A.w/2,c+I*A.p,n,o))}if(A.left){const c=-((A.left-1)/2)*A.p;for(let I=0;I<A.left;I++)I===A.left-1&&(s=vV(-A.w/2-o*1.4,c+I*A.p,"left")),i.push(vo(I+1,-A.w/2,c+I*A.p,n,o))}if(A.top){const c=-((A.top-1)/2)*A.p;for(let I=0;I<A.top;I++)I===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=vV(c+I*A.p,e/2+o*1.4,"top")),i.push(vo(I+1+A.right+(A.bottom??0)+A.left,c+I*A.p,e/2,n,o))}if(A.bottom){const c=-((A.bottom-1)/2)*A.p;for(let I=0;I<A.bottom;I++)I===0&&!A.left&&(s=vV(c+I*A.p,-e/2-o*1.4,"bottom")),i.push(vo(I+1+A.left,c+I*A.p,-e/2,n,o))}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-o,y:e/2+o},{x:A.w/2+o,y:e/2+o},{x:A.w/2+o,y:-e/2-o},{x:-A.w/2-o,y:-e/2-o},{x:-A.w/2-o,y:e/2+o}],stroke_width:.1,layer:"top"},g=Mi(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},eie=(t,A,e,i)=>Array.from({length:25},(n,o)=>{const s=o/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*e,y:A+Math.sin(s)*e}}),pNt=Li.extend({fn:H(),p:lA.optional().default("4.88mm"),id:lA.optional().default("0.8mm"),od:lA.optional().default("1.5mm"),w:lA.optional().default("5.6mm"),h:lA.optional().default("3.5mm")}),fNt=t=>{const A=pNt.parse(t),{p:e,id:i,od:n,w:o,h:s}=A,r=s/2,a=[vo(1,-e/2,0,i,n),vo(2,e/2,0,i,n)],g=eie(-o/2,0,r,"left"),c=eie(o/2,0,r,"right"),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...g,...g.slice(1).reverse(),{x:-o/2,y:-s/2},{x:o/2,y:-s/2},...c,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},l=Mi(0,e/4,.5);return{circuitJson:[...a,I,l],parameters:A}};Li.extend({w:lA,h:lA});var yNt=t=>{const{w:A,h:e}=t,i=Lr(A),n=Lr(e);return{circuitJson:[Ii(1,0,0,i,n),Mi(0,n/2+.5,.2)],parameters:t}},ZY=(t,A,e,i,n,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:A,y:e,outer_width:Lr(n),outer_height:Lr(o),hole_width:Lr(i),hole_height:Lr(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),mNt=Li.extend({fn:H(),num_pins:Gt([kA(3),kA(2)]).default(3),p:H().default("1.27mm"),id:H().default("0.72mm"),od:H().default("0.95mm"),w:H().default("4.5mm"),h:H().default("4.5mm"),inline:qA().default(!1),string:H().optional()}),wNt=(t,A,e)=>Array.from({length:25},(i,n)=>{const o=n/24*Math.PI;return{x:t+Math.cos(o)*e,y:A+Math.sin(o)*e}}),DNt=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=mNt.parse({...t,num_pins:e}),{p:n,id:o,od:s,w:r,h:a,inline:g}=i,c=Number.parseFloat(a)/2,I=Number.parseFloat(n),l=Number.parseFloat(o),B=Number.parseFloat(s),C=B,Q=B*(1.5/1.05);let h=[];if(i.num_pins===3)g?h=[YD({pn:1,x:-I,y:c-I,holeDiameter:l,rectPadWidth:B,rectPadHeight:Q}),ZY(2,0,c-I,l,C,Q),ZY(3,I,c-I,l,C,Q)]:h=[YD({pn:1,x:-I,y:c-I,holeDiameter:l,rectPadWidth:B,rectPadHeight:B}),vo(2,0,c,l,B),vo(3,I,c-I,l,B)];else if(i.num_pins===2)h=[YD({pn:1,x:-I,y:c-I,holeDiameter:l,rectPadWidth:C,rectPadHeight:Q}),ZY(2,I,c-I,l,C,Q)];else throw new Error("Invalid number of pins for TO-92");const E=Number.parseFloat(r)/2,u=wNt(0,c,E),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...u,{x:-E,y:0},{x:E,y:0},u[0]],stroke_width:.1,pcb_silkscreen_path_id:""},f=Mi(0,c+1,.5);return{circuitJson:[...h,d,f],parameters:i}},SNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("2.15mm"),h:H().default("1.20mm"),pl:H().default("0.5mm"),pw:H().default("0.6mm"),p:H().default("1.4mm")}),bNt=t=>{const A=SNt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:_Nt(A).concat(i,e),parameters:A}},xNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},_Nt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=xNt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},kNt=KF({w:"7.05mm",p:"1.27mm",pw:"0.65mm",pl:"1.975mm"}),vNt=t=>{const A=kNt.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=vdA({num_pins:A.num_pins,pn:s+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(Ii(s+1,r,a,A.pl??"1.5mm",A.pw??"0.6mm"))}const i=(A.num_pins/2-1)*A.p+A.pw,n=Mi(0,i/2+1,i/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-A.w/3,y:i/2+.4},{x:A.w/3,y:i/2+.4}],stroke_width:.1};return{circuitJson:[...e,n,o],parameters:A}},FNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("5.0mm"),h:H().default("2.30mm"),pl:H().default("1.25mm"),pw:H().default("2mm"),p:H().default("3.75mm")}),NNt=t=>{const A=FNt.parse(t),e=Mi(0,lA.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2+.5,y:lA.parse(A.h)/2+.5},{x:-lA.parse(A.w)/2-.5,y:lA.parse(A.h)/2+.5},{x:-lA.parse(A.w)/2-.5,y:-lA.parse(A.h)/2-.5},{x:lA.parse(A.p)/2+.5,y:-lA.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:GNt(A).concat(i,e),parameters:A}},RNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},GNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=RNt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},MNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("1.2mm"),pw:H().default("1.2mm"),p:H().default("2.9mm")}),LNt=t=>{const A=MNt.parse(t),e=Mi(0,lA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:HNt(A).concat(i,e),parameters:A}},UNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},HNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=UNt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},YNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.30mm"),h:H().default("1.80mm"),pl:H().default("0.60mm"),pw:H().default("0.45mm"),p:H().default("2.1mm")}),JNt=t=>{const A=YNt.parse(t),e=Mi(0,lA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:PNt(A).concat(i,e),parameters:A}},TNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},PNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=TNt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},KNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.4mm"),h:H().default("0.9mm"),pl:H().default("0.36mm"),pw:H().default("0.25mm"),p:H().default("0.85mm")}),qNt=t=>{const A=KNt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2+.15,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.15,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.15,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2+.15,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:WNt(A).concat(i,e),parameters:A}},ONt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},WNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=ONt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ZNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.3mm"),h:H().default("0.9mm"),pl:H().default("0.4mm"),pw:H().default("0.7mm"),p:H().default("0.7mm")}),VNt=t=>{const A=ZNt.parse(t),e=Mi(0,lA.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2+.2,y:lA.parse(A.h)/2+.2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2+.2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2-.2},{x:lA.parse(A.p)/2+.2,y:-lA.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:zNt(A).concat(i,e),parameters:A}},jNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},zNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=jNt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},XNt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3,05mm"),h:H().default("1.65mm"),pl:H().default("0.6mm"),pw:H().default("0.6mm"),pad_spacing:H().default("2.2mm")}),$Nt=t=>{const A=XNt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.pad_spacing)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.pad_spacing)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eRt(A).concat(i,e),parameters:A}},ARt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=ARt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("1.10mm"),pw:H().default("1.10mm"),p:H().default("2.8mm")}),iRt=t=>{const A=tRt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:oRt(A).concat(i,e),parameters:A}},nRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},oRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=nRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},sRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("0.91mm"),pw:H().default("1.22mm"),p:H().default("3.146mm")}),rRt=t=>{const A=sRt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gRt(A).concat(i,e),parameters:A}},aRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},gRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=aRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},cRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.80mm"),h:H().default("1.00mm"),pl:H().default("0.66mm"),pw:H().default("0.5mm"),p:H().default("0.8mm")}),IRt=t=>{const A=cRt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:BRt(A).concat(i,e),parameters:A}},lRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},BRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=lRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},CRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("6.2mm"),h:H().default("3.4mm"),pl:H().default("1.4mm"),pw:H().default("2.1mm"),p:H().default("4.4mm")}),QRt=t=>{const A=CRt.parse(t),e=Mi(0,lA.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ERt(A).concat(i,e),parameters:A}},hRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},ERt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=hRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},uRt=Li.extend({fn:H(),num_pins:Gt([kA(3),kA(5)]).default(3),w:H().default("4.20mm"),h:H().default("4.80mm"),pl:H().default("1.3mm"),pw:H().default("0.9mm"),p:H().default("1.5mm"),string:H().optional()}),dRt=t=>{const A=[],e=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),n=Number.parseFloat(t.w),o=Number.parseFloat(t.pl),s=.175,r=(o-(o+s))/2;A.push(Ii(1,-n/2+r,e,o,i),Ii(2,-n/2,0,o+s,i),Ii(3,-n/2+r,-e,o,i));const a=Mi(0,0,.3),g=Number.parseFloat(t.w)/2-1,c=Number.parseFloat(t.h)/2,I={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-g,y:c},{x:g,y:c},{x:g,y:c/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},l={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-g,y:-c},{x:g,y:-c},{x:g,y:-c/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,I,l,a]},pRt=t=>{const A=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),A.push(Ii(1,-1.85,-1.5,1.5,.7),Ii(2,-1.85,1.5,1.5,.7),Ii(3,0,0,.8,2),Ii(4,1.85,-1.5,1.5,.7),Ii(5,1.85,1.5,1.5,.7));const e=Mi(0,Number.parseFloat(t.h)/2+.5,.3),i=Number.parseFloat(t.w)/2-1,n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i,y:n}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n},{x:i,y:-n}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},fRt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=uRt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:dRt(i),parameters:i};if(i.num_pins===5)return{circuitJson:pRt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},yRt=Li.extend({fn:H(),p:lA.optional().default("5.0mm"),id:lA.optional().default("1.0mm"),od:lA.optional().default("1.9mm"),w:lA.optional().default("13mm"),h:lA.optional().default("7mm"),num_pins:OA().optional(),string:H().optional()}),mRt=t=>{const A=yRt.parse(t),{fn:e,id:i,od:n,w:o,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,c=o/2,I=s/2,l=2.5,B=o*.4,C=Math.max(l,B/(a-1)),Q=Array.from({length:a},(m,w)=>{const D=a%2===0?(w-a/2+.5)*C:(w-Math.floor(a/2))*C;return vo(w+1,D,g,i,n)}),h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:-I},{x:c,y:-I},{x:c,y:I},{x:-c,y:I},{x:-c,y:-I}],stroke_width:.1,pcb_silkscreen_path_id:""},E=-I+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:E},{x:c,y:E}],stroke_width:.1,pcb_silkscreen_path_id:""},d=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:E},{x:-o/6,y:I}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:E},{x:o/6,y:I}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Mi(0,s/2+.6,.5);return{circuitJson:[...Q,h,u,...d,f],parameters:{...A,p:C}}},wRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("5.40mm"),h:H().default("2.30mm"),pl:H().default("1.30mm"),pw:H().default("1.70mm"),p:H().default("3.5mm")}),DRt=t=>{const A=wRt.parse(t),e=Mi(0,lA.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bRt(A).concat(i,e),parameters:A}},SRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},bRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=SRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},xRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.90mm"),h:H().default("1.33mm"),pl:H().default("0.5mm"),pw:H().default("0.7mm"),p:H().default("0.8mm")}),_Rt=t=>{const A=xRt.parse(t),e=Mi(0,lA.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2+.1,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2+.1,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:vRt(A).concat(i,e),parameters:A}},kRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},vRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=kRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},FRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("7.0mm"),h:H().default("3.35mm"),pl:H().default("1.50mm"),pw:H().default("2.70mm"),p:H().default("4.8mm")}),NRt=t=>{const A=FRt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:GRt(A).concat(i,e),parameters:A}},RRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},GRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=RRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},MRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.0mm"),h:H().default("1.80mm"),pl:H().default("0.80mm"),pw:H().default("1.20mm"),p:H().default("1.6mm")}),LRt=t=>{const A=MRt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:HRt(A).concat(i,e),parameters:A}},URt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},HRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=URt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},YRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("7.10mm"),h:H().default("3.40mm"),pl:H().default("2.45mm"),pw:H().default("1.80mm"),p:H().default("4.05mm")}),JRt=t=>{const A=YRt.parse(t),e=Mi(0,lA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.5,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.5,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:PRt(A).concat(i,e),parameters:A}},TRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},PRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=TRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},KRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.80mm"),h:H().default("2.10mm"),pl:H().default("1.30mm"),pw:H().default("1.40mm"),p:H().default("2.9mm")}),qRt=t=>{const A=KRt.parse(t),e=Mi(0,lA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:WRt(A).concat(i,e),parameters:A}},ORt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},WRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=ORt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ZRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("7.30mm"),h:H().default("4.40mm"),pl:H().default("2.50mm"),pw:H().default("2.30mm"),p:H().default("4.30mm")}),VRt=t=>{const A=ZRt.parse(t),e=Mi(0,lA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:zRt(A).concat(i,e),parameters:A}},jRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},zRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=jRt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},XRt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("10.70mm"),h:H().default("6.60mm"),pl:H().default("3.30mm"),pw:H().default("2.50mm"),p:H().default("6.80mm")}),$Rt=t=>{const A=XRt.parse(t),e=Mi(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2-.8},{x:-lA.parse(A.w)/2-.8,y:lA.parse(A.h)/2-.8},{x:-lA.parse(A.w)/2-.8,y:-lA.parse(A.h)/2+.8},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eGt(A).concat(i,e),parameters:A}},AGt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=AGt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tGt=Li.extend({fn:H(),num_pins:OA().default(4),w:H().default("8.50mm"),h:H().default("6.90mm"),pl:H().default("2mm"),pw:H().default("1.5mm"),p:H().default("2.30mm"),string:H().optional()}),iGt=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const n=sGt.parse({...t,num_pins:e});return{circuitJson:WY(n),parameters:n}}const i=tGt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:oGt(i),parameters:i};if(i.num_pins===5)return{circuitJson:aGt(i),parameters:i};if(i.num_pins===6)return{circuitJson:cGt(i),parameters:i};throw new Error("Invalid number of pins")},nGt=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}},oGt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=nGt({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)}),c=r===3?3.8:Number.parseFloat(t.pw);A.push(Ii(r+1,a,g,Number.parseFloat(t.pl),c))}const e=Mi(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i,y:n},{x:i,y:n/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:-n},{x:i,y:-n},{x:i,y:-n/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},sGt=KF({p:"0.90mm",w:"2.8mm",legsoutside:!0}),rGt=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")},aGt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=rGt({h:Number.parseFloat(t.h),p:1.5,pn:r,w:Number.parseFloat(t.w)});let c=Number.parseFloat(t.pw),I=Number.parseFloat(t.pl);r===5?(c=3.4,I=1.8):(c=1,I=2.2),A.push(Ii(r,a,g,I,c))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,n={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},o={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=Mi(0,0,.3);return[...A,n,o,s]},gGt=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")},cGt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=gGt({h:Number.parseFloat(t.h),p:1.3,pn:r,w:8.7});let c=Number.parseFloat(t.pw),I=Number.parseFloat(t.pl);r===6?(c=3.4,I=2.15):(c=.6,I=2.2),A.push(Ii(r,a,g,I,c))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,n={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},o={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=Mi(0,0,.3);return[...A,n,o,s]},IGt=Li.extend({fn:H(),num_pins:OA().default(3),w:H().default("3.40mm"),h:H().default("3.30mm"),pl:H().default("1mm"),pw:H().default("0.7mm"),p:H().default("1.2mm"),string:H().optional()}),lGt=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=IGt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:CGt(i),parameters:i};throw new Error("Invalid number of pins")},BGt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},CGt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=BGt({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(Ii(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Mi(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-1,n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i+.3,y:n},{x:i+.3,y:n/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:-n},{x:i+.3,y:-n},{x:i+.3,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},QGt=Li.extend({fn:H(),num_pins:Gt([kA(3),kA(2)]).default(3),p:H().default("1.27mm"),id:H().default("0.72mm"),od:H().default("0.95mm"),w:H().default("2.5mm"),h:H().default("4.2mm"),string:H().optional()}),hGt=t=>{const{p:A,id:e,od:i,w:n,h:o}=t,s=Number.parseFloat(o)/2,r=Number.parseFloat(A);return[vo(1,-r,s-r,e,i),vo(2,0,s-r,e,i),vo(3,r,s-r,e,i)]},EGt=t=>{const{p:A,id:e,od:i,h:n}=t,o=Number.parseFloat(n)/2,s=Number.parseFloat(A);return[vo(1,-s,o-s,e,i),vo(2,s,o-s,e,i)]},uGt=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=QGt.parse({...t,num_pins:e});let n=[];if(i.num_pins===3)n=hGt(i);else if(i.num_pins===2)n=EGt(i);else throw new Error("Invalid number of pins for TO-92");const o=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o,y:o-s},{x:-1.9,y:0},{x:1.9,y:0},{x:o,y:o-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-o,y:o-s}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Mi(0,o+1,.5);return{circuitJson:[...n,r,a],parameters:i}},dGt=Li.extend({fn:H(),p:lA.optional(),id:lA.optional(),pw:lA.optional(),pl:lA.optional(),w:lA.optional(),h:lA.optional(),sh:qA().optional().describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:qA().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:H().optional()}),pGt={ph:{p:lA.parse("2.2mm"),id:lA.parse("0.70mm"),pw:lA.parse("1.20mm"),pl:lA.parse("1.20mm"),w:lA.parse("6mm"),h:lA.parse("5mm")},sh:{p:lA.parse("1mm"),pw:lA.parse("0.6mm"),pl:lA.parse("1.55mm"),w:lA.parse("5.8mm"),h:lA.parse("7.8mm")}};function fGt(t){return t.sh?"sh":(t.ph,"ph")}function yGt(t,A,e,i,n,o){const s=[];if(t==="ph"){const r=-((A-1)/2)*e;for(let a=0;a<A;a++){const g=r+a*e;s.push(YD({pn:a+1,x:g,y:2,holeDiameter:i,rectPadWidth:n,rectPadHeight:o}))}}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const c=r+g*e;s.push(Ii(g+1,c,-1.325,n,o))}const a=(A-1)/2*e+1.3;s.push(Ii(A+1,-a,1.22,1.2,1.8)),s.push(Ii(A+2,a,1.22,1.2,1.8))}return s}function mGt(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 wGt=t=>{const A=dGt.parse(t),e=fGt(A),i=pGt[e],n=A.p??i.p,o=A.id??i.id,s=A.pw??i.pw,r=A.pl??i.pl,a=A.w??i.w,g=A.h??i.h;let c;const I=t.num_pins;typeof I=="number"&&(c=I);const B=(typeof t.string=="string"?t.string:"").match(/(?:^|_)jst(\d+)(?:_|$)/);if(B&&B[1]){const E=parseInt(B[1],10);Number.isNaN(E)||(c=E)}if(typeof c!="number")throw new Error(`JST requires an explicit pin count (e.g. jst6_sh or .jst(6))${A.string?`, from string "${A.string}"`:""}`);const C=yGt(e,c,n,o,s,r),Q=mGt(e),h=Mi(0,g/2+1,.5);return{circuitJson:[...C,Q,h],parameters:{...A,p:n,id:o,pw:s,pl:r,w:a,h:g,num_pins:c,sh:e==="sh",ph:e==="ph"}}},DGt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.30mm"),h:H().default("1.70mm"),pl:H().default("0.80mm"),pw:H().default("1mm"),p:H().default("1.90mm")}),SGt=t=>{const A=DGt.parse(t),e=Mi(0,lA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:xGt(A).concat(i,e),parameters:A}},bGt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},xGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=bGt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},_Gt=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"}}},kGt=Li.extend({fn:H(),num_pins:Gt([kA(8),kA(10)]).default(8),w:H().optional(),h:H().optional(),p:H().optional(),pl:H().optional(),pw:H().optional(),string:H().optional()}),vGt=t=>{const A=kGt.parse(t),e=_Gt(A.num_pins),i=lA.parse(A.w||e.w),n=lA.parse(A.h||e.h),o=lA.parse(A.p||e.p),s=lA.parse(A.pl||e.pl),r=lA.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}=tie(A.num_pins,u+1,i,o),m=u<g?u+1:A.num_pins-(u-g);a.push(Ii(m,d,f,s,r))}const c=i,I=n,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:I/2},{x:c/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:-I/2},{x:c/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=tie(A.num_pins,1,c,o),Q={x:C.x-.8,y:C.y},h={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"},E=Mi(0,I/2+.5,.3);return{circuitJson:[...a,l,B,E,h],parameters:A}},tie=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*lA.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},FGt=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"}}},NGt=Li.extend({fn:H(),num_pins:Gt([kA(8),kA(10),kA(12),kA(16)]).default(8),w:H().optional(),h:H().optional(),p:H().optional(),pl:H().optional(),pw:H().optional(),string:H().optional()}),iie=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*lA.parse("2mm"),y:r*i}},RGt=t=>{const A=NGt.parse(t),e=FGt(A.num_pins),i=lA.parse(A.w||e.w),n=lA.parse(A.h||e.h),o=lA.parse(A.p||e.p),s=lA.parse(A.pl||e.pl),r=lA.parse(A.pw||e.pw),a=[];for(let E=0;E<A.num_pins;E++){const{x:u,y:d}=iie(A.num_pins,E+1,i,o);a.push(Ii(E+1,u,d,s,r))}const g=i,c=n,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:c/2},{x:g/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-c/2},{x:g/2,y:-c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B=iie(A.num_pins,1,g,o),C={x:B.x-.8,y:B.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"},h=Mi(0,c/2+.5,.3);return{circuitJson:[...a,I,l,h,Q],parameters:A}},GGt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.8mm"),h:H().default("1.65mm"),pl:H().default("1.2mm"),pw:H().default("1.2mm"),pad_spacing:H().default("2.6mm")}),MGt=t=>{const A=GGt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.pad_spacing)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.pad_spacing)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:UGt(A).concat(i,e),parameters:A}},LGt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},UGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=LGt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},HGt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.20mm"),h:H().default("1.65mm"),pl:H().default("0.8mm"),pw:H().default("0.9mm"),pad_spacing:H().default("2.1mm")}),YGt=t=>{const A=HGt.parse(t),e=Mi(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.pad_spacing)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.pad_spacing)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:TGt(A).concat(i,e),parameters:A}},JGt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},TGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=JGt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},PGt=Li.extend({fn:H(),num_pins:Gt([kA(6),kA(8)]).default(8),w:H().default("3mm"),h:H().default("3mm"),p:H().default("0.5mm"),pl:H().default("0.52mm"),pw:H().default("0.35mm"),epw:H().default("1.40mm"),eph:H().default("1.60mm"),string:H().optional(),ep:qA().default(!1)}),KGt=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=PGt.parse({...t,num_pins:e}),n=lA.parse(i.w),o=lA.parse(i.h),s=lA.parse(i.p),r=lA.parse(i.pl),a=lA.parse(i.pw),g=lA.parse(i.epw),c=lA.parse(i.eph),I=[];for(let f=0;f<i.num_pins;f++){const{x:m,y:w}=nie(i.num_pins,f+1,n,s);I.push(Ii(f+1,m,w,r,a))}i.ep&&I.push(Ii(i.num_pins+1,0,0,g,c));const l=n,B=o,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:B/2},{x:l/2,y:B/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-B/2},{x:l/2,y:-B/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h=nie(i.num_pins,1,l,s),E={x:h.x-.4,y:h.y},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:E.x-.4,y:E.y},{x:E.x-.7,y:E.y+.3},{x:E.x-.7,y:E.y-.3},{x:E.x-.4,y:E.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Mi(0,B/2+.5,.3);return{circuitJson:[...I,C,Q,d,u],parameters:i}},nie=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*lA.parse("1.4mm"),y:r*i}},qGt=Li.extend({fn:H(),num_pins:OA().optional().default(8),p:se.describe("pitch (distance between center of each pin)"),w:lA.describe("width between vertical rows of pins"),grid:xV.describe("width and height of the border of the footprint"),ep:xV.default("0x0mm").describe("width and height of the central exposed thermal pad"),epx:lA.default("0mm").describe("x offset of the center of the central exposed thermal pad"),pinw:lA.describe("width of the pin pads"),pinh:lA.describe("height of the pin pads")}),OGt=t=>{const A=qGt.parse(t),{num_pins:e,p:i,w:n,grid:o,ep:s,epx:r,pinw:a,pinh:g}=A;if(e%2!==0)throw new Error("invalid number of pins");const c=[];for(let B=0;B<e;B++){const{pinX:C,pinY:Q}=WGt({pinCount:e,pinIndex:B,width:n,pitch:i});c.push(Ii(B+1,C,Q,a,g))}s.x>0&&s.y>0&&c.push(Ii(A.num_pins+1,r,0,s.x,s.y));const I=ZGt(o),l=Mi(0,o.y/2+i,o.y/6);return{circuitJson:[...c,...I,l],parameters:A}},WGt=t=>{let A=0,e=0;const i=(t.pinCount/2-1)*t.pitch/2,n=t.pinCount/2;return t.pinIndex+1<=n?(A=t.pitch*t.pinIndex-i,e=0-t.width/2):(A=t.pitch*(t.pinCount-t.pinIndex-1)-i,e=t.width/2),{pinX:e,pinY:A}},ZGt=t=>{const e=t.y/30;return[{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-t.x/2-.1,y:t.y/2+.1-e},{x:-t.x/2-.1,y:t.y/2+.1},{x:t.x/2+.1,y:t.y/2+.1},{x:t.x/2+.1,y:t.y/2+.1-e}],stroke_width:t.y/30},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-t.x/2-.1,y:-t.y/2-.1+e},{x:-t.x/2-.1,y:-t.y/2-.1},{x:t.x/2+.1,y:-t.y/2-.1},{x:t.x/2+.1,y:-t.y/2-.1+e}],stroke_width:t.y/30}]},VGt=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:n=1.5,ph:o=1.5}=t,s=lA.parse(i),r=lA.parse(n),a=lA.parse(o),g=Math.min(a/4,.5),c=[];for(let f=0;f<A;f++)c.push(Ii(f+1,f*s,0,r,a));let I=[];if(e){const f=e.split("").map(Number);if(f.length>1)for(let m=0;m<f.length-1;m++){const w=f[m],D=f[m+1];if(typeof w=="number"&&typeof D=="number"&&!isNaN(w)&&!isNaN(D)){const S=(w-1)*s,_=(D-1)*s,x=Math.sign(_-S),G=S+x*(r/2),F=_-x*(r/2);I.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${w}}`,x:G,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${D}}`,x:F,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const l=(A-1)*s+r+.7,B=a+1,C=(A-1)*s/2,Q=0,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:C-l/2,y:Q-B/2},{x:C+l/2,y:Q-B/2},{x:C+l/2,y:Q+B/2},{x:C-l/2,y:Q+B/2},{x:C-l/2,y:Q-B/2}],stroke_width:.15},u=Q+B/2+.6,d=Mi(C,u,.4);return{circuitJson:[...c,...I,h,d],parameters:t}},oie={fn:kA("sot457"),num_pins:kA(6).default(6),pillh:H().default("0.45mm"),pillw:H().default("1.45mm"),pl:H(),pw:H(),p:H(),wave:qA().optional(),reflow:qA().optional()},jGt=Li.extend({...oie,h:H().default("2.5mm"),w:H().default("2.7mm"),pl:H().default("0.8mm"),pw:H().default("0.55mm"),p:H().default("0.95mm")}),zGt=Li.extend({...oie,h:H().default("3mm"),w:H().default("4mm"),pillr:H().default("0.225mm"),pl:H().default("1.45mm"),pw:H().default("1.5mm"),p:H().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)})),kb=t=>Number.parseFloat(t.replace("mm","")),sie=({pitch:t,width:A,pinNumber:e})=>{const o={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(!o)throw new Error(`Invalid pin number: ${e}`);return o},rie=t=>{const A=[],e=kb(t.p),i=kb(t.pl),n=kb(t.pw),o=kb(t.w),s=kb(t.h);if(t.wave){const C={1:({padWidth:Q,padHeight:h})=>Ii(1,-e,e,h,Q),2:({padWidth:Q,padHeight:h})=>Ii(2,-e,-e,h,Q),3:({padWidth:Q,padHeight:h})=>_V(3,-e,0,kb(t.pillw),kb(t.pillh)),4:({padWidth:Q,padHeight:h})=>_V(4,e,0,kb(t.pillw),kb(t.pillh)),5:({padWidth:Q,padHeight:h})=>Ii(5,e,e,h,Q),6:({padWidth:Q,padHeight:h})=>Ii(6,e,-e,h,Q)};for(let Q=1;Q<=t.num_pins;Q++){const h=C[Q];h&&A.push(h({padWidth:i,padHeight:n}))}}else for(let C=1;C<=t.num_pins;C++){const{x:Q,y:h}=sie({pitch:e,width:o,pinNumber:C});A.push(Ii(C,Q,h,i,n))}const r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/3,y:s/2+e/1.3},{x:o/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:-o/3,y:-s/2-e/1.3},{x:o/3,y:-s/2-e/1.3}],stroke_width:.05},g=Mi(0,s+.5,.3),c=sie({pitch:e,width:o,pinNumber:1}),I=t.wave?1:.5,l=t.wave?.7:.3;c.x-=t.wave?n:n*1.7;const B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:c.x+I/2,y:c.y},{x:c.x-I/2,y:c.y+l/2},{x:c.x-I/2,y:c.y-l/2},{x:c.x+I/2,y:c.y}],stroke_width:.05};return[g,r,a,B,...A]},XGt=t=>{if(t.wave){const e=zGt.parse({...t,fn:"sot457"});return{circuitJson:rie(e),parameters:e}}const A=jGt.parse(t);return{circuitJson:rie(A),parameters:A}},$Gt=Li.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("1.1mm"),h:H().default("1.45mm"),p:H().default("0.35mm"),pl:H().default("0.2mm"),pw:H().default("0.2mm"),string:H().optional()}),AMt=t=>{const A=$Gt.parse({...t,fn:"sot963"}),e=lA.parse(A.w),i=lA.parse(A.h),n=lA.parse(A.p),o=lA.parse(A.pl),s=lA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=aie(B+1,e,n,o);r.push(Ii(B+1,C,Q,o,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:""},c=aie(1,e,n,o),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-o/2-.3,y:c.y},{x:c.x-o/2-.45,y:c.y+.15},{x:c.x-o/2-.45,y:c.y-.15},{x:c.x-o/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Mi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},aie=(t,A,e,i)=>{const n=A/2-i/2;return t<=3?{x:-n,y:e-(t-1)*e}:{x:n,y:-e+(t-4)*e}},eMt=Li.extend({fn:H(),num_pins:Gt([kA(3),kA(2)]).default(3),p:H().default("3.8mm"),id:H().default("1.25mm"),od:H().default("2.35mm"),ca:H().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:H().default("5.35mm"),h:H().default("4mm"),string:H().optional()}),tMt=t=>{const{p:A,id:e,od:i,h:n,ca:o}=t,s=Number.parseFloat(n),r=Number.parseFloat(o);return[vo(1,0,r/4+.3,e,i),vo(2,s,0,e,i),vo(3,0,-r/4-.3,e,i)]},iMt=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=eMt.parse({...t,num_pins:e});let n=[];i.num_pins===3&&(n=tMt(i));const o=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:o-1.75},{x:0,y:o},{x:s,y:o},{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:-o},{x:0,y:-o},{x:0,y:-o+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},c=Number.parseFloat(i.w)/2,I=Mi(c,o+1,.5);return{circuitJson:[...n,a,g,I],parameters:i}},nMt=Li.extend({fn:H(),p:lA.optional().default("7.5mm"),id:lA.optional().default("1mm"),od:lA.optional().default("2mm"),d:lA.optional().default("10.5mm")}),oMt=(t,A,e,i,n)=>{const o=[],s=[];for(let r=0;r<=50;r++){const a=r/50*Math.PI,g=t+Math.cos(a)*e,c=A+Math.sin(a)*e;g<t-i&&c>=A-n/2&&c<=A+n/2||o.push({x:g,y:c})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=t+Math.cos(a)*e,c=A+Math.sin(a)*e;g<t-i&&c>=A-n/2&&c<=A+n/2||s.push({x:g,y:c})}return{topArc:o,bottomArc:s}},sMt=t=>{const A=nMt.parse(t),{p:e,id:i,od:n,d:o}=A,s=[vo(1,-e/2,0,i,n),vo(2,e/2,0,i,n)],{topArc:r,bottomArc:a}=oMt(0,0,o/2+.1,n/2,n),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},l=-(o/2+.5),B=n/2+1.5,C=.5,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l-C,y:B},{x:l+C,y:B}],stroke_width:.1,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l,y:B-C},{x:l,y:B+C}],stroke_width:.1,pcb_silkscreen_path_id:""},E=Mi(0,o/2+1,.5);return{circuitJson:[...s,g,c,I,Q,h,E],parameters:A}},rMt=Li.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("6.5mm"),h:H().default("3mm"),pl:H().default("1.75mm"),pw:H().default("2.40mm"),p:H().default("4.75mm")}),aMt=t=>{const A=rMt.parse(t),e=Mi(0,lA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.3,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.3,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:cMt(A).concat(i,e),parameters:A}},gMt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},cMt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=gMt({pn:e,p:Number.parseFloat(t.p)});A.push(Ii(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},IMt=Li.extend({fn:H(),num_pins:OA().default(3),w:H().default("2.45mm"),h:H().default("2.40mm"),pl:H().default("0.92mm"),pw:H().default("0.45mm"),p:H().default("0.891mm"),string:H().optional()}),lMt=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=IMt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:CMt(i),parameters:i};throw new Error("Invalid number of pins")},BMt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},CMt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=BMt({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(Ii(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Mi(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n+.3},{x:i,y:n+.3},{x:i,y:n/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:-n-.3},{x:i,y:-n-.3},{x:i,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},QMt=Li.extend({fn:H(),circle:qA().optional(),rect:qA().optional(),square:qA().optional(),pill:qA().optional(),d:lA.optional(),pd:lA.optional(),diameter:lA.optional(),r:lA.optional(),pr:lA.optional(),radius:lA.optional(),w:lA.optional(),pw:lA.optional(),width:lA.optional(),h:lA.optional(),ph:lA.optional(),height:lA.optional(),s:lA.optional(),size:lA.optional(),string:H().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,n;return A==="circle"?t.r!==void 0?e=Lr(t.r):t.pr!==void 0?e=Lr(t.pr):t.radius!==void 0?e=Lr(t.radius):t.d!==void 0?e=Lr(t.d)/2:t.pd!==void 0?e=Lr(t.pd)/2:t.diameter!==void 0?e=Lr(t.diameter)/2:e=Lr("1mm")/2:(t.w!==void 0?i=Lr(t.w):t.pw!==void 0?i=Lr(t.pw):t.width!==void 0?i=Lr(t.width):t.s!==void 0?i=Lr(t.s):t.size!==void 0?i=Lr(t.size):i=Lr("1mm"),t.h!==void 0?n=Lr(t.h):t.ph!==void 0?n=Lr(t.ph):t.height!==void 0?n=Lr(t.height):A==="square"||A==="rect"?n=i:n=Lr("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:n}}),hMt=t=>{const A=QMt.parse(t),{shape:e,radius:i,width:n,height:o}=A;let s,r;return e==="circle"?(s=Jte(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=_V(1,0,0,n,o),r=Math.max(n,o)/2+.5):(s=Ii(1,0,0,n,o),r=o/2+.5),{circuitJson:[s,Mi(0,r,.2)],parameters:A}},EMt=Li.extend({fn:H(),d:lA.optional(),hd:lA.optional(),r:lA.optional(),hr:lA.optional(),pd:lA.optional(),pr:lA.optional(),squarepad:qA().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=Lr(t.d):t.hd!==void 0?A=Lr(t.hd):t.r!==void 0?A=Lr(t.r)*2:t.hr!==void 0?A=Lr(t.hr)*2:A=Lr("1mm");let e;return t.pd!==void 0?e=Lr(t.pd):t.pr!==void 0?e=Lr(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),uMt=t=>{const A=EMt.parse(t),{d:e,pd:i,squarepad:n}=A;return{circuitJson:[n?YD({pn:1,x:0,y:0,holeDiameter:e,rectPadWidth:i,rectPadHeight:i}):vo(1,0,0,e,i),Mi(0,i/2+.5,.2)],parameters:A}},dMt=Li.extend({fn:H(),num_pins:kA(6).default(6),h:H().default("1.6mm"),pl:H().default("1mm"),pw:H().default("0.7mm"),p:H().default("0.95mm")}),pMt=t=>{const A=dMt.parse(t);return{circuitJson:fMt(A),parameters:A}},gie=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")},fMt=t=>{const A=[];for(let I=1;I<=t.num_pins;I++){const{x:l,y:B}=gie({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:I});A.push(Ii(I,l,B,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),n={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},o={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=Mi(0,i+.3,.3),r=gie({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,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,n,o,c]},yMt=Li.extend({fn:H(),num_pins:OA().default(4),w:H().default("3.2mm"),h:H().default("2.6mm"),pl:H().default("1.05mm"),pw:H().default("0.45mm"),p:H().default("0.55mm"),string:H().optional()}),mMt=t=>{const A=t.string?.match(/^sot343_(\d+)/),e=A?Number.parseInt(A[1],4):4,i=yMt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:DMt(i),parameters:i};throw new Error("Invalid number of pins")},wMt=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}},DMt=t=>{const A=[],e=Number.parseFloat(t.w),i=Number.parseFloat(t.h),n=Number.parseFloat(t.pl),o=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let r=1/0,a=-1/0,g=1/0,c=-1/0;for(let d=0;d<t.num_pins;d++){const{x:f,y:m}=wMt({num_pins:t.num_pins,pn:d+1,p:s});A.push(Ii(d+1,f,m,n,o)),f<r&&(r=f),f>a&&(a=f),m<g&&(g=m),m>c&&(c=m)}const I=(r+a)/2,l=c-g,B=i*.3,C=l/2+B;let Q=e*.8;i<=2.6&&(Q/=2);const h=Mi(I,C+.5,.3),E={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:I-Q/2,y:C},{x:I+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:I-Q/2,y:-C},{x:I+Q/2,y:-C}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,E,u,h]},SMt=Li.extend({fn:H()}),bMt=t=>{const A=SMt.parse(t),e=[],i=.5-.15,n=1.5,s=.5/2,r=75,a=-37/2;for(let D=0;D<r;D++){const S=D+1;if(S>=24&&S<=31)continue;const _=a-D*s,x=S%2===0,G=n+(x?.25:0),L=.5-G/2,Y=Ii(S,L,_,G,i);Y.layer=x?"bottom":"top",e.push(Y)}const g=46*.0254,c=137*.0254,I=261*.0254,l={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-c/2+n/2,y:a-I},width:c,height:g},B={x:-.5,y:a},C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:B.x-.4,y:B.y},{x:B.x-.7,y:B.y+.3},{x:B.x-.7,y:B.y-.3},{x:B.x-.4,y:B.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let Q=1/0,h=-1/0,E=1/0,u=-1/0;const d=(D,S,_=0,x=0)=>{Q=Math.min(Q,D-_/2),h=Math.max(h,D+_/2),E=Math.min(E,S-x/2),u=Math.max(u,S+x/2)};for(const D of e){const S=D;d(S.x,S.y,S.width,S.height)}d(l.center.x,l.center.y,l.width,l.height);for(const D of C.route)d(D.x,D.y);const f=(Q+h)/2,m=(E+u)/2,w=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(S=>({x:S.x-f,y:S.y-m})))};for(const D of e)w(D);return w(l),w(C),{circuitJson:[...e,l,C],parameters:A}},xMt=Li.extend({fn:H(),numPins:OA().optional().default(0),rows:Gt([H(),OA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:lA.default("2.54mm").describe("pitch"),id:lA.default("1.0mm").describe("inner diameter"),od:lA.default("1.5mm").describe("outer diameter"),male:qA().optional().describe("the module uses male headers"),nopin:qA().optional().default(!1).describe("omit pins rendering"),female:qA().optional().describe("the module uses female headers"),smd:qA().optional().describe("surface mount device"),pinlabeltextalignleft:qA().optional().default(!1),pinlabeltextaligncenter:qA().optional().default(!1),pinlabeltextalignright:qA().optional().default(!1),pinlabelverticallyinverted:qA().optional().default(!1),pinlabelorthogonal:qA().optional().default(!1),nopinlabels:qA().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:qA().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:qA().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top"),pinRowSide:et(["left","right","top","bottom"]).optional().default("left"),pinrowleft:qA().optional().default(!1),pinrowright:qA().optional().default(!1),pinrowtop:qA().optional().default(!1),pinrowbottom:qA().optional().default(!1),pinrowleftpins:Gt([H(),OA()]).transform(t=>Number(t)).optional(),pinrowrightpins:Gt([H(),OA()]).transform(t=>Number(t)).optional(),pinrowtoppins:Gt([H(),OA()]).transform(t=>Number(t)).optional(),pinrowbottompins:Gt([H(),OA()]).transform(t=>Number(t)).optional(),width:lA.optional(),height:lA.optional(),pinRowHoleEdgeToEdgeDist:lA.default("2mm"),holes:Gt([H(),be(H())]).optional().transform(t=>!t||Array.isArray(t)?t:t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1).split(",").map(A=>A.trim()):[t]),holeXDist:lA.optional(),holeYDist:lA.optional(),holeInset:lA.default("1mm"),pinrow:Gt([H(),OA()]).optional(),usbposition:et(["left","right","top","bottom"]).optional().default("left"),usbleft:qA().optional().default(!1),usbtop:qA().optional().default(!1),usbright:qA().optional().default(!1),usbbottom:qA().optional().default(!1),usbtype:et(["micro","c"]).optional(),usbmicro:qA().optional().default(!1),usbc:qA().optional().default(!1),screen:qA().optional().default(!1).describe("add silkscreen outline for screen/display area"),screenwidth:lA.optional(),screenheight:lA.optional(),screencenteroffsetx:lA.optional(),screencenteroffsety:lA.optional()}).transform(t=>{const A=jte(t);let e=t.pinRowSide;t.pinrowleft&&(e="left"),t.pinrowright&&(e="right"),t.pinrowtop&&(e="top"),t.pinrowbottom&&(e="bottom");let i=t.usbposition;t.usbleft&&(i="left"),t.usbtop&&(i="top"),t.usbright&&(i="right"),t.usbbottom&&(i="bottom");let n=t.usbtype;t.usbmicro&&(n="micro"),t.usbc&&(n="c"),t.pinrow!==void 0&&(t.numPins=Number(t.pinrow));const o={left:t.pinrowleftpins,right:t.pinrowrightpins,top:t.pinrowtoppins,bottom:t.pinrowbottompins},s=Object.values(o).some(f=>f!==void 0&&f>0),r=(o.left??0)>0&&(o.right??0)>0,a=(o.top??0)>0&&(o.bottom??0)>0;s&&((o.left??0)>0?e="left":(o.right??0)>0?e="right":(o.top??0)>0?e="top":(o.bottom??0)>0&&(e="bottom"),t.numPins=(o.left??0)+(o.right??0)+(o.top??0)+(o.bottom??0));const g=Math.ceil(t.numPins/t.rows),c=Math.max(o.left??0,o.right??0),I=Math.max(o.top??0,o.bottom??0);let l,B;if(s){const f=r?t.p:0,m=a?t.p:0;l=(I>0?(I-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+f,B=(c>0?(c-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+m}else e==="left"||e==="right"?(l=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,B=(g-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist):(B=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,l=(g-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist);t.numPins===0&&(l=10,B=10);const C=t.width??l,Q=t.height??B,h=t.screenwidth??C*.95,E=t.screenheight??Q*.95,u=t.screencenteroffsetx??0,d=t.screencenteroffsety??0;return{...t,pinlabelAnchorSide:A,pinRowSide:e,usbposition:i,usbtype:n,male:t.male??!t.female,female:t.female??!1,width:C,height:Q,screenwidth:h,screenheight:E,screencenteroffsetx:u,screencenteroffsety:d,pinrowleftpins:o.left,pinrowrightpins:o.right,pinrowtoppins:o.top,pinrowbottompins:o.bottom}}).superRefine((t,A)=>{t.male&&t.female&&A.addIssue({code:jt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),_Mt=t=>{const A=xMt.parse(t),{p:e,id:i,od:n,rows:o,numPins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:c,pinlabeltextalignright:I,nopinlabels:l,doublesidedpinlabel:B,bottomsidepinlabel:C,pinRowSide:Q,width:h,height:E,pinRowHoleEdgeToEdgeDist:u,holes:d,holeXDist:f,holeYDist:m,holeInset:w,pinrowleftpins:D,pinrowrightpins:S,pinrowtoppins:_,pinrowbottompins:x,usbposition:G,usbtype:F,screen:L,screenwidth:Y,screenheight:J,screencenteroffsetx:O,screencenteroffsety:Z}=A;let X="center";c?X="left":I&&(X="right");const eA=[],gA={left:D,right:S,top:_,bottom:x},tA=Object.values(gA).some(aA=>aA!==void 0&&aA>0),iA=(aA,EA,bA,xA)=>{if(A.smd?eA.push(Ii(aA,EA,bA,A.od,A.od)):aA===1?eA.push(YD({pn:aA,x:EA,y:bA,holeDiameter:i,rectPadWidth:n,rectPadHeight:n})):eA.push(vo(aA,EA,bA,i,n)),!l){const YA=EA+(xA==="left"?-n:xA==="right"?n:0),QA=bA+(xA==="top"?n:xA==="bottom"?-n:0);C||eA.push(qF({fs:n/5,pn:aA,anchor_x:YA,anchor_y:QA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"top"})),(B||C)&&eA.push(qF({fs:n/5,pn:aA,anchor_x:YA,anchor_y:QA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"bottom"}))}};if(tA){const aA=e;let EA=1;const bA=gA.left??0,xA=gA.right??0,YA=gA.top??0,QA=gA.bottom??0,_A=(dA,KA)=>{if(!(KA<=0))if(dA==="left"||dA==="right"){const ZA=dA==="left"?-h/2+u:h/2-u,ce=(KA-1)/2*aA;for(let fA=0;fA<KA;fA++)iA(EA,ZA,ce-fA*aA,dA),EA++}else{const ZA=dA==="top"?E/2-u:-E/2+u,ce=-((KA-1)/2)*aA;for(let fA=0;fA<KA;fA++)iA(EA,ce+fA*aA,ZA,dA),EA++}};_A("left",bA),_A("right",xA),_A("top",YA),_A("bottom",QA)}else{const aA=e;let EA=0,bA=0,xA=0,YA=0,QA=0,_A=0;const dA=Math.ceil(s/o);Q==="left"||Q==="right"?(EA=Q==="left"?-h/2+u:h/2-u,bA=(dA-1)/2*aA,xA=0,YA=-aA,QA=Q==="left"?aA:-aA,_A=0):(EA=-(dA-1)/2*aA,bA=Q==="top"?E/2-u:-E/2+u,xA=aA,YA=0,QA=0,_A=Q==="top"?-aA:aA);let KA=1;for(let ZA=0;ZA<o&&KA<=s;ZA++)for(let ce=0;ce<dA&&KA<=s;ce++){const fA=EA+ce*xA+ZA*QA,ge=bA+ce*YA+ZA*_A;if(A.smd?eA.push(Ii(KA,fA,ge,A.od,A.od)):KA===1?eA.push(YD({pn:KA,x:fA,y:ge,holeDiameter:i,rectPadWidth:n,rectPadHeight:n})):eA.push(vo(KA,fA,ge,i,n)),!l){const VA=fA+(Q==="left"?-n:Q==="right"?n:0),RA=ge+(Q==="top"?n:Q==="bottom"?-n:0);C||eA.push(qF({fs:n/5,pn:KA,anchor_x:VA,anchor_y:RA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"top"})),(B||C)&&eA.push(qF({fs:n/5,pn:KA,anchor_x:VA,anchor_y:RA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"bottom"}))}KA++}}if(d)for(const aA of d){let EA=0,bA=0;aA==="topleft"?(EA=-h/2+w,bA=E/2-w):aA==="topright"?(EA=h/2-w,bA=E/2-w):aA==="bottomleft"?(EA=-h/2+w,bA=-E/2+w):aA==="bottomright"?(EA=h/2-w,bA=-E/2+w):aA==="center"&&(EA=0,bA=0),f!==void 0&&(EA+=f),m!==void 0&&(bA+=m),eA.push(vo(s+d.indexOf(aA)+1,EA,bA,i,n))}if(!A.nosilkscreen){const aA=[{x:-h/2,y:-E/2},{x:h/2,y:-E/2},{x:h/2,y:E/2},{x:-h/2,y:E/2},{x:-h/2,y:-E/2}];eA.push(OF(aA,{stroke_width:.1,layer:"top"}))}const sA=Mi(0,E/2+1,.5);if(eA.push(sA),G&&F){let aA,EA;if(F==="c")aA=8,EA=3;else if(F==="micro")aA=6,EA=2;else return{circuitJson:eA,parameters:A};let bA;if(G==="left")bA=[{x:-h/2,y:-aA/2},{x:-h/2+EA,y:-aA/2},{x:-h/2+EA,y:aA/2},{x:-h/2,y:aA/2},{x:-h/2,y:-aA/2}];else if(G==="right")bA=[{x:h/2-EA,y:-aA/2},{x:h/2,y:-aA/2},{x:h/2,y:aA/2},{x:h/2-EA,y:aA/2},{x:h/2-EA,y:-aA/2}];else if(G==="top")bA=[{x:-aA/2,y:E/2-EA},{x:aA/2,y:E/2-EA},{x:aA/2,y:E/2},{x:-aA/2,y:E/2},{x:-aA/2,y:E/2-EA}];else if(G==="bottom")bA=[{x:-aA/2,y:-E/2},{x:aA/2,y:-E/2},{x:aA/2,y:-E/2+EA},{x:-aA/2,y:-E/2+EA},{x:-aA/2,y:-E/2}];else return{circuitJson:eA,parameters:A};eA.push(OF(bA,{stroke_width:.1,layer:"top"}))}if(L){const aA=Y/2,EA=J/2,bA=O,xA=Z,YA=[{x:-aA+bA,y:-EA+xA},{x:aA+bA,y:-EA+xA},{x:aA+bA,y:EA+xA},{x:-aA+bA,y:EA+xA},{x:-aA+bA,y:-EA+xA}];eA.push(OF(YA,{stroke_width:.05,layer:"top"}))}return{circuitJson:eA,parameters:A}},kMt=Li.extend({fn:H(),num_pins:OA().default(3),inline:qA().default(!1),p:H().default("1.27mm"),id:H().default("0.75mm"),od:H().default("1.3mm"),w:H().default("4.8mm"),h:H().default("4.0mm")}),vMt=t=>{const A=kMt.parse(t),e=Number.parseFloat(A.p),i=Number.parseFloat(A.w),n=Number.parseFloat(A.h),o=A.inline?1.05:Number.parseFloat(A.od),s=A.inline?1.5:o,r=[YD({pn:1,x:0,y:0,holeDiameter:A.id,rectPadWidth:o,rectPadHeight:s}),A.inline?ZY(2,e,0,Number.parseFloat(A.id),o,s):vo(2,e,e,A.id,o),A.inline?ZY(3,e*2,0,Number.parseFloat(A.id),o,s):vo(3,e*2,0,A.id,o)],a=i/2,g=A.inline?e-.09:e,c=.2,I=c+a-n,l=Array.from({length:32},(Q,h)=>{const E=Math.PI*h/31;return{x:g+a*Math.cos(E),y:c+a*Math.sin(E)}}),B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",stroke_width:.12,route:[...l,{x:g-a,y:I},{x:g+a,y:I},l[0]]},C=Mi(g,c+a+1,.5);return{circuitJson:[...r,B,C],parameters:A}};function FMt(t){return t!=null}var NMt=(t,A)=>{if(!A)return t;const e=t.filter(c=>c.type==="pcb_smtpad"||c.type==="pcb_plated_hole"||c.type==="pcb_thtpad");if(e.length===0)return t;let i=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;const r=(c,I,l=0,B=0)=>{const C=c-l/2,Q=c+l/2,h=I-B/2,E=I+B/2;i=Math.min(i,C),n=Math.max(n,Q),o=Math.min(o,h),s=Math.max(s,E)};for(const c of e)if(c.type==="pcb_smtpad"){const I=c.shape==="circle"?c.radius*2:c.width,l=c.shape==="circle"?c.radius*2:c.height;r(c.x,c.y,I,l)}else if(c.type==="pcb_plated_hole"){const I=c.outer_diameter??c.hole_diameter;r(c.x,c.y,I,I)}else if(c.type==="pcb_thtpad"){const I=c.diameter;r(c.x,c.y,I,I)}let a=0,g=0;switch(A){case"center":a=(i+n)/2,g=(o+s)/2;break;case"bottomleft":a=i,g=o;break;case"bottomcenter":case"centerbottom":a=(i+n)/2,g=o;break;case"topcenter":case"centertop":a=(i+n)/2,g=s;break;case"leftcenter":case"centerleft":a=i,g=(o+s)/2;break;case"rightcenter":case"centerright":a=n,g=(o+s)/2;break;case"pin1":{const c=e.find(I=>I.port_hints?.[0]==="1")||e[0];a=c.x,g=c.y;break}}if(a===0&&g===0)return t;for(const c of t){if(typeof c.x=="number"&&(c.x-=a),typeof c.y=="number"&&(c.y-=g),c.center&&typeof c.center.x=="number"&&(c.center.x-=a,c.center.y-=g),c.type==="pcb_silkscreen_path")for(const I of c.route)I.x-=a,I.y-=g;c.type==="pcb_silkscreen_text"&&c.anchor_position&&(c.anchor_position.x-=a,c.anchor_position.y-=g)}return t},RMt=(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},GMt=(t,A)=>A.nosilkscreen?t.filter(e=>e.type!=="pcb_silkscreen_path"&&e.type!=="pcb_silkscreen_text"):t,MMt=t=>{let A=FV();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_|x)/,"res$1").split(/_(?!metric)/).map(n=>{const o=n.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,r]=o;if(!s)return null;const a=s.toLowerCase();return r?.includes("?")?null:{fn:a,v:r}}).filter(FMt);for(const{fn:n,v:o}of i)A=A[n](o);return A.setString(t),A},LMt=()=>Object.keys(_b),FV=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&_b[A.fn])return()=>{const{circuitJson:i}=_b[A.fn](A),n=GMt(i,A),o=RMt(n,A);return NMt(o,A.origin)};if(!_b[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(!_b[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>_b[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(_b):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in _b?(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};FV.string=MMt,FV.getFootprintNames=LMt;var UMt=FV,cie=Symbol("Fragment");function RdA(t,A,...e){const i=e.length?e:A?.children!==void 0?[A.children]:[],n=[],o=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of o)s==null||s===!1||(Array.isArray(s)?n.push(...s):n.push(s));return{type:t,props:(A&&A.children!==void 0?{...A,children:void 0}:A)||{},children:n}}var Qt=Symbol("Cuboid"),Iie=Symbol("Cube"),Ol=Symbol("Cylinder"),NV=Symbol("Sphere"),VY=Symbol("RoundedCuboid"),Wi=Symbol("Translate"),gC=Symbol("Rotate"),VQ=Symbol("Union"),lm=Symbol("Subtract"),bc=Symbol("Hull"),wo=Symbol("Colorize"),jY=Symbol("Polygon"),zY=Symbol("ExtrudeLinear"),_f=Symbol("RoundedCylinder"),Jn=cie,zA=(t,A,e)=>RdA(t,A),qt=(t,A,e)=>RdA(t,A),yB=({center:t,width:A,length:e,height:i,heightAboveSurface:n=.15,color:o="#555",taperRatio:s=.12,faceRatio:r=.75,straightHeightRatio:a=.5,includeNotch:g=!0,notchRadius:c,notchPosition:I,notchRotation:l=[0,0,0],notchLength:B=.5,notchWidth:C=.25,chamferSize:Q=0})=>{const h=i*a,E=i-h,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,w=c??m,D={x:0,y:e/2-w*.25,z:i},S=I??D,_=qt(VQ,{children:[qt(bc,{children:[zA(Wi,{z:.005,children:zA(Qt,{size:[d,f,.01]})}),zA(Wi,{z:h,children:zA(Qt,{size:[A,e,.01]})})]}),qt(bc,{children:[zA(Wi,{z:h,children:zA(Qt,{size:[A,e,.01]})}),zA(Wi,{z:h+E,children:zA(Qt,{size:[d,f,.01]})})]})]}),x=(F,L)=>zA(Wi,{offset:{x:F,y:L,z:0},children:zA(gC,{rotation:[0,0,Math.PI/4],children:zA(Qt,{size:[Q*Math.SQRT2,Q*Math.SQRT2,i*3]})})});let G=_;if(Q>0){const F=A/2,L=e/2;G=qt(lm,{children:[_,x(F,L),x(-F,L),x(F,-L),x(-F,-L)]})}return zA(wo,{color:o,children:zA(Wi,{offset:t,children:zA(Wi,{offset:{x:0,y:0,z:n},children:g?qt(lm,{children:[G,zA(Wi,{offset:S,children:zA(gC,{rotation:l,children:zA(Ol,{radius:w,height:C})})})]}):G})})})},HMt=t=>Array.from({length:t},(A,e)=>e);function GdA(t,A){if(t.length<2)throw new Error("Stroke must have at least two points");const e=Array.isArray(t[0])?t.map(([c,I])=>({x:c,y:I})):t,i=A/2,n=[],o=[];function s(c,I){const l=I.x-c.x,B=I.y-c.y,C=Math.sqrt(l*l+B*B);return{x:-B/C,y:l/C}}function r(c,I,l){const B={x:c.x+I.x*i*l,y:c.y+I.y*i*l};l>0?n.push(B):o.unshift(B)}const a=s(e[0],e[1]);r(e[0],a,1),r(e[0],a,-1);for(let c=1;c<e.length-1;c++){const I=e[c-1],l=e[c],B=e[c+1],C=s(I,l),Q=s(l,B),h=C.x+Q.x,E=C.y+Q.y,u=Math.sqrt(h*h+E*E);if(u/2>2*i)r(l,C,1),r(l,Q,1),r(l,C,-1),r(l,Q,-1);else{const f=1/u;r(l,{x:h*f,y:E*f},1),r(l,{x:h*f,y:E*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),[...n,...o]}var YMt=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}))},JMt=YMt([{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}]),lie=5.47,RV=.5,TMt=({x:t,y:A,z:e})=>{const i=t>0;return qt(Jn,{children:[zA(Wi,{offset:{x:t+.25/2,y:A,z:e},children:zA(gC,{rotation:["-90deg",0,"90deg"],children:zA(zY,{height:.25,children:zA(jY,{points:JMt.slice().reverse().map(n=>[n.x,n.y])})})})}),zA(Wi,{offset:{x:t,y:A+(i?1:-1),z:e},children:zA(gC,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:zA(zY,{height:2,children:zA(jY,{points:GdA([[0,0],[-1,0],[-1,-1]],.25).map(n=>[n.x,n.y])})})})})]})},PMt=({numPins:t=8,pitch:A=2.54,bodyWidth:e=6.4,rowSpacing:i})=>{const n=Math.floor(t/2),o=i??(e>=7?e:e+1.22),s=e>=7?o-1.22:e;return qt(Jn,{children:[HMt(t).map(r=>{const a=r%n,g=(Math.floor(r/n)-.5)*2;return zA(TMt,{x:g*o/2,y:a*A-(n-1)/2*A,z:lie/2+RV})}),zA(yB,{width:s,length:n*A+.5,height:lie-RV,heightAboveSurface:RV,center:{x:0,y:0,z:RV}})]})};function KMt(t,{height:A,padContactLength:e,curveLength:i,bodyDistance:n,steepness:o=10}){i||(i=n*.3);let s=n-e-i;s<0&&(i+=s,s=0);const r=e*.75,a=e+i+(n-e-i)*.25;if(t<=r)return 0;if(t>=a)return A;const g=(t-r)/(a-r);return A/(1+Math.exp(-o*(g-.5)))}var oo=t=>{const{thickness:A,width:e,padContactLength:i,bodyDistance:n,height:o,rotation:s}=t,r=15,a=Array.from({length:r}).map((c,I)=>I/(r-1)*n).map(c=>[c,KMt(c,t)]),g=GdA(a,A);return zA(wo,{color:"#fff",children:zA(Wi,{offset:{z:0,y:0,x:0,...t.position},children:zA(gC,{rotation:["90deg",0,s??0],children:zA(Wi,{offset:{x:0,y:0,z:-e/2},children:zA(zY,{height:e,children:zA(jY,{points:g.map(c=>[c.x,c.y])})})})})})})},qMt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:n})=>{const o=Math.ceil(t/2),s=i*t/2+e/2,r=(o-1)*i/2,a=.25;return qt(Jn,{children:[Array.from({length:o}).map((g,c)=>zA(oo,{position:{x:-n/2-A,y:c*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:o}).map((g,c)=>zA(oo,{rotation:Math.PI,position:{x:n/2+A,y:c*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),zA(yB,{center:{x:0,y:0,z:a/2},width:n-e-1,length:s,height:1.5})]})},OMt=({pinCount:t,padContactLength:A=.4,leadWidth:e=.2,pitch:i=.65,bodyWidth:n=3})=>{const o=Math.ceil(t/2),s=(o-1)*i/2,r=.2;return qt(Jn,{children:[Array.from({length:o}).map((a,g)=>zA(oo,{position:{x:-n/2-A-.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Array.from({length:o}).map((a,g)=>zA(oo,{rotation:Math.PI,position:{x:n/2+A+.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),zA(yB,{center:{x:0,y:0,z:r/2},width:n,length:n,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},MdA=1,LdA=.5,l1=.5,XY=.2,WMt=MdA-XY*2,Bie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[WMt,LdA,l1],offset:[0,0,l1/2],color:t}),zA(Qt,{size:[XY,l1,LdA],offset:[MdA/2-XY/2,0,l1/2],color:"#ccc"}),zA(Qt,{size:[XY,l1,LdA],offset:[-MdA/2+XY/2,0,l1/2],color:"#ccc"})]}),UdA=1.6,ZMt=UdA-.3*2,GV=.3,HdA=.85,B1=.6,Cie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[ZMt,HdA,B1],offset:[0,0,B1/2],color:t}),zA(Qt,{size:[GV,HdA,B1],offset:[UdA/2-GV/2,0,B1/2],color:"#ccc"}),zA(Qt,{size:[GV,HdA,B1],offset:[-UdA/2+GV/2,0,B1/2],color:"#ccc"})]}),YdA=2,JdA=1.25,C1=.55,$Y=.5,VMt=YdA-$Y*2,Qie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[VMt,JdA,C1],offset:[0,0,C1/2],color:t}),zA(Qt,{size:[$Y,JdA,C1],offset:[YdA/2-$Y/2,0,C1/2],color:"#ccc"}),zA(Qt,{size:[$Y,JdA,C1],offset:[-YdA/2+$Y/2,0,C1/2],color:"#ccc"})]}),jMt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:n})=>{const o=t/4;A||(A=zMt(t,n)),i||(i=XMt(t)),e||(e=$Mt(t,n)),n||(n=A*(o+4));const s=n,r=(o-1)*A/2,a=s+2*i,g=a,c=.8,I=.15,l=(g-n)/2+.5;return qt(Jn,{children:[Array.from({length:o}).map((B,C)=>zA(oo,{position:{x:-g/2-.4,y:C*A-r,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:Math.PI,position:{x:g/2+.4,y:C*A-r,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.4,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.4,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),zA(yB,{center:{x:0,y:0,z:0},width:n,length:s,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:n/2-1.5,z:1.5},notchRadius:1.5/2})]})},zMt=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},XMt=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}},$Mt=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},hie=({x:t,y:A,pinThickness:e,shortSidePinLength:i,longSidePinLength:n,bodyHeight:o,bodyLength:s=2.54,bodyWidth:r=2.54,flipZ:a,faceup:g,smd:c,rightangle:I})=>qt(Jn,{children:[zA(Wi,{y:I?-3:0,children:zA(Qt,{color:"#222",size:[s,r,o],center:[t,A,a(o/2)]})}),!g&&zA(wo,{color:"gold",children:c?zA(oo,{rotation:-Math.PI/2,position:{x:t,y:A+1,z:e/2},thickness:e,width:e,height:e,padContactLength:2,bodyDistance:3}):qt(bc,{children:[zA(Qt,{color:"gold",size:[e,e,i*.9],center:[t,A,a(o*.9+o/2)]}),zA(Qt,{color:"gold",size:[e/1.8,e/1.8,i],center:[t,A,a(o+o/2)]})]})}),zA(wo,{color:"gold",children:zA(Wi,{y:I?-3.9:0,z:I?1:0,children:zA(gC,{rotation:I?[-Math.PI/2,0,0]:[0,0,0],children:qt(bc,{children:[zA(Qt,{color:"gold",size:[e,e,n*.9],center:[t,A,a(-n/2*.9)]}),zA(Qt,{color:"gold",size:[e/1.8,e/1.8,n],center:[t,A,a(-n/2)]})]})})})})]}),A1t=({numberOfPins:t,pitch:A=2.54,longSidePinLength:e=6,invert:i,faceup:n,rows:o=1,smd:s,rightangle:r})=>{const c=Math.ceil(t/o),I=2.54,l=3,B=-((c-1)/2)*A,C=!s&&!r?-2-1.6:0,Q=h=>(i||n?-h+2:h)+C;return zA(Jn,{children:Array.from({length:t},(h,E)=>{const u=Math.floor(E/c),d=E%c,f=B+d*A,m=-u*I;return zA(hie,{x:f,y:m,pinThickness:.63,shortSidePinLength:l,longSidePinLength:e,bodyHeight:2,flipZ:Q,faceup:n,smd:s,rightangle:r},E)})})},e1t=t=>{const A=["left","bottom","right","top"],{pin_count:e,pn:i,w:n,h:o,p:s,pl:r}=t,a=e/4,g=A[Math.floor((i-1)/a)],c=(i-1)%a,I=s*(a-1),l=s*(a-1),B=-r/2;switch(g){case"left":return{x:-n/2-B,y:l/2-c*s,o:"vert"};case"bottom":return{x:-I/2+c*s,y:-o/2-B,o:"horz"};case"right":return{x:n/2+B,y:-l/2+c*s,o:"vert"};case"top":return{x:I/2-c*s,y:o/2+B,o:"horz"};default:throw new Error("Invalid pin number")}},t1t=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const n=[],o=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=o:r.bottomside&&r.leftpin?s=o+1:r.bottomside&&r.rightpin?s=o*2:r.rightside&&r.bottompin?s=o*2+1:r.rightside&&r.toppin?s=o*3:r.topside&&r.rightpin?s=o*3+1:r.topside&&r.leftpin&&(s=o*4),n.push(-1);for(let a=0;a<t;a++)n[s]=a+1,s++,s>t&&(s=1);return n},i1t=({num_pins:t=16,bodyWidth:A=9,bodyLength:e=9,bodyThickness:i=.8,thermalPadSize:n,padWidth:o=.25,padLength:s=.25,pitch:r=.5,thermalPadThickness:a=.05})=>{const g=t1t({num_pins:t,cw:!0,ccw:!0}),c=[];for(let I=0;I<t;I++){const{x:l,y:B,o:C}=e1t({pin_count:t,pn:I+1,w:A,h:e,p:r,pl:s});let Q=o,h=s;C==="vert"&&([Q,h]=[h,Q]);const E=g[I+1];c.push({pn:E,x:l,y:B,pw:Q,pl:h})}return qt(Jn,{children:[zA(wo,{color:"grey",children:zA(Qt,{center:{x:0,y:0,z:i/2},size:[A,e,i]})}),c.map((I,l)=>zA(Qt,{center:{x:I.x,y:I.y,z:a/2},size:[I.pw,I.pl,a]})),n?.length!==void 0&&n?.width!==void 0&&zA(Qt,{center:{x:0,y:0,z:a/2},size:[n.width,n.length,a]})]})},n1t=i1t,o1t=()=>{const a=1.1999999999999997;return qt(Jn,{children:[zA(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}),zA(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}),zA(oo,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),zA(oo,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),zA(oo,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),zA(yB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},s1t=o1t,r1t=({fullWidth:t=2.9,fullLength:A=2.8})=>{const c=(t-1.92)/2+.3;return qt(Jn,{children:[zA(oo,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),zA(oo,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),zA(oo,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),zA(yB,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},TdA=.6,PdA=.3,Q1=.33,AJ=.1,a1t=TdA-AJ*2,Eie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[a1t,PdA,Q1],offset:[0,0,Q1/2],color:t}),zA(Qt,{size:[AJ,PdA,Q1],offset:[TdA/2-AJ/2,0,Q1/2],color:"#ccc"}),zA(Qt,{size:[AJ,PdA,Q1],offset:[-TdA/2+AJ/2,0,Q1/2],color:"#ccc"})]}),KdA=.4,qdA=.2,h1=.13,eJ=.07,g1t=KdA-eJ*2,uie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[g1t,qdA,h1],offset:[0,0,h1/2],color:t}),zA(Qt,{size:[eJ,qdA,h1],offset:[KdA/2-eJ/2,0,h1/2],color:"#ccc"}),zA(Qt,{size:[eJ,qdA,h1],offset:[-KdA/2+eJ/2,0,h1/2],color:"#ccc"})]}),OdA=3.2,WdA=1.6,E1=.9,tJ=.5,c1t=OdA-tJ*2,die=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[c1t,WdA,E1],offset:[0,0,E1/2],color:t}),zA(Qt,{size:[tJ,WdA,E1],offset:[OdA/2-tJ/2,0,E1/2],color:"#ccc"}),zA(Qt,{size:[tJ,WdA,E1],offset:[-OdA/2+tJ/2,0,E1/2],color:"#ccc"})]}),ZdA=3.2,VdA=2.5,u1=1,iJ=.6,I1t=ZdA-iJ*2,pie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[I1t,VdA,u1],offset:[0,0,u1/2],color:t}),zA(Qt,{size:[iJ,VdA,u1],offset:[ZdA/2-iJ/2,0,u1/2],color:"#ccc"}),zA(Qt,{size:[iJ,VdA,u1],offset:[-ZdA/2+iJ/2,0,u1/2],color:"#ccc"})]}),jdA=5,zdA=2.5,d1=1.4,nJ=.6,l1t=jdA-nJ*2,fie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[l1t,zdA,d1],offset:[0,0,d1/2],color:t}),zA(Qt,{size:[nJ,zdA,d1],offset:[jdA/2-nJ/2,0,d1/2],color:"#ccc"}),zA(Qt,{size:[nJ,zdA,d1],offset:[-jdA/2+nJ/2,0,d1/2],color:"#ccc"})]}),XdA=6.3,$dA=3.2,p1=1.8,oJ=.8,B1t=XdA-oJ*2,yie=({color:t="#333"})=>qt(Jn,{children:[zA(Qt,{size:[B1t,$dA,p1],offset:[0,0,p1/2],color:t}),zA(Qt,{size:[oJ,$dA,p1],offset:[XdA/2-oJ/2,0,p1/2],color:"#ccc"}),zA(Qt,{size:[oJ,$dA,p1],offset:[-XdA/2+oJ/2,0,p1/2],color:"#ccc"})]}),mie=({x:t,y:A,z:e=0,pitch:i=2.54,legsLength:n=3,innerDiameter:o=.945,bodyHeight:s=5,bodyLength:r=i,bodyWidth:a=i,flipZ:g})=>{const c=o/1.5,I=c*1.6;return qt(Jn,{children:[zA(wo,{color:"#1a1a1a",children:qt(lm,{children:[zA(Qt,{color:"#000",size:[r,a,s],center:[t,A,g(e+s/2)]}),o?zA(Ol,{height:s+.1,radius:o/2,center:[t,A,g(e+s/2)],color:"#222"}):zA(Qt,{size:[I,I,s],center:[t,A,g(e+s/2)]})]})}),qt(wo,{color:"silver",children:[qt(bc,{children:[zA(Qt,{color:"silver",size:[c,c,n*.9],center:[t,A,g(e+-n/2*.9)]}),zA(Qt,{color:"silver",size:[c/1.8,c/1.8,n],center:[t,A,g(e+-n/2)]})]}),zA(Qt,{color:"silver",size:[I,I,I*.5],center:[t,A,g(e+I/2*.5)]})]})]})},C1t=({numberOfPins:t,pitch:A=2.54,legsLength:e=3,innerDiameter:i=.945,rows:n=1,invert:o})=>{const r=Math.ceil(t/n),a=2.54,g=-((r-1)/2)*A,c=I=>o?-I+5:I;return zA(Jn,{children:Array.from({length:t},(I,l)=>{const B=Math.floor(l/r),C=l%r,Q=g+C*A,h=-B*a;return zA(mie,{x:Q,y:h,pitch:A,legsLength:e,innerDiameter:i,flipZ:c},l)})})},Q1t=({width:t,length:A,innerDiameter:e=1})=>{const i=t,n=A,o=t*.7,s=e/2.5;return qt(Jn,{children:[zA(VY,{color:"#1a1a1f",center:[0,0,o/2],size:[n,n,o],roundRadius:.3}),zA(VY,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[n,n,o*.1],roundRadius:.14}),zA(Ol,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),zA(Ol,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,n/3,o+o*.1/2]}),zA(Ol,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,-n/3,o+o*.1/2]}),zA(Ol,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,n/3,o+o*.1/2]}),zA(Ol,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,-n/3,o+o*.1/2]}),zA(MV,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:-n/2,z:-o*1.2}}),zA(MV,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:n/2,z:-o*1.2},rotation:Math.PI}),zA(MV,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:i/2,y:n/2,z:-o*1.2},rotation:Math.PI}),zA(MV,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:i/2+e/3.6,y:-n/2,z:-o*1.2}})]})},MV=t=>{const{thickness:A,width:e,horizontalLength:i,verticalLength:n,rotation:o=0,position:s}=t,r=[[0,i],[-n/3,i/3],[-n/5,i/4],[0,0]],a=GdA(r,A);return zA(wo,{color:"#f2f2f2",children:zA(Wi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:zA(gC,{rotation:[0,55,o],children:zA(zY,{height:e,children:zA(jY,{points:a.map(g=>[g.y,g.x])})})})})})},h1t=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:n})=>{const o=Math.ceil(t/2),s=(o-1)*i/2,r=.25,a=1,g=.8,c=A*0,I=i*(o-1)+e+.2,l=n*.55;return qt(Jn,{children:[Array.from({length:o}).map((B,C)=>zA(oo,{position:{x:-n/2-c,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:Math.PI,position:{x:n/2+c,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),zA(yB,{center:{x:0,y:0,z:r/2},width:l,length:I,height:a})]})},E1t=({pinCount:t,pitch:A,leadWidth:e,leadLength:i,bodyWidth:n,bodyLength:o})=>{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(n))?2.6:parseFloat(n)*.8,c=isNaN(parseFloat(o))?2+Number(r)*1.4:parseFloat(o),I=t/2,l=(I-1)*r/2,B=.15,C=.8,Q=4.5,h=(Q-g)/2,E=h*.5;return qt(Jn,{children:[Array.from({length:I}).map((u,d)=>zA(oo,{position:{x:-Q/2,y:l-d*r,z:B/2},width:a,thickness:B,padContactLength:E+.05,bodyDistance:h+.1,height:C})),Array.from({length:I}).map((u,d)=>zA(oo,{rotation:Math.PI,position:{x:Q/2,y:l-d*r,z:B/2},width:a,thickness:B,padContactLength:E+.05,bodyDistance:h+.1,height:C})),zA(yB,{center:{x:0,y:0,z:B/2},width:g,length:c,height:1})]})},u1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),zA(Qt,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Wi,{z:.3/2,children:zA(Qt,{size:[1.65,.8,.3]})}),qt(bc,{children:[zA(Wi,{z:.3,children:zA(Qt,{size:[1.65,.8,.01]})}),zA(Wi,{z:.6,children:zA(Qt,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),d1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),zA(Qt,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),zA(wo,{color:"#222",children:zA(Wi,{z:.47/2+.02,children:zA(Qt,{size:[.98,.58,.47]})})}),zA(Qt,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),zA(Qt,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),zA(Qt,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),zA(Qt,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),p1t=()=>{const g=zA(wo,{color:"#1a1a1a",children:qt(VQ,{children:[qt(bc,{children:[zA(Wi,{z:.13,children:zA(Qt,{size:[4,3,.03]})}),zA(Wi,{z:1.15,children:zA(Qt,{size:[4.4,3.4,.01]})})]}),qt(bc,{children:[zA(Wi,{z:1.15,children:zA(Qt,{size:[4.4,3.4,.01]})}),zA(Wi,{z:2.3,children:zA(Qt,{size:[4,3,.01]})})]})]})}),c=({xDir:I})=>{const C=I*1.78,Q=I*(3.4/2-.2/2+1),h=I*(3.4/2-.2/2),E=Math.abs(h-Q),u=(Q+h)/2;return zA(wo,{color:"#c0c0c0",children:qt(VQ,{children:[zA(Qt,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),zA(Qt,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),zA(Qt,{size:[E,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return qt(Jn,{children:[zA(c,{xDir:1}),zA(c,{xDir:-1}),g]})},f1t=()=>{const g=zA(wo,{color:"#1a1a1a",children:qt(VQ,{children:[qt(bc,{children:[zA(Wi,{z:.13,children:zA(Qt,{size:[4,3,.03]})}),zA(Wi,{z:1.15,children:zA(Qt,{size:[4.4,3.4,.01]})})]}),qt(bc,{children:[zA(Wi,{z:1.15,children:zA(Qt,{size:[4.4,3.4,.01]})}),zA(Wi,{z:2.3,children:zA(Qt,{size:[4,3,.01]})})]})]})}),c=({xDir:I})=>{const C=I*1.78,Q=I*(3.4/2-.2/2+1),h=I*(3.4/2-.2/2),E=Math.abs(h-Q),u=(Q+h)/2;return zA(wo,{color:"#c0c0c0",children:qt(VQ,{children:[zA(Qt,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),zA(Qt,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),zA(Qt,{size:[E,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return qt(Jn,{children:[zA(c,{xDir:1}),zA(c,{xDir:-1}),g]})},y1t=()=>{const g=zA(wo,{color:"#1a1a1a",children:qt(VQ,{children:[qt(bc,{children:[zA(Wi,{z:.21000000000000002,children:zA(Qt,{size:[6.3999999999999995,5.6,.03]})}),zA(Wi,{z:1.15,children:zA(Qt,{size:[6.8,6,.01]})})]}),qt(bc,{children:[zA(Wi,{z:1.15,children:zA(Qt,{size:[6.8,6,.01]})}),zA(Wi,{z:2.3,children:zA(Qt,{size:[6.3999999999999995,5.6,.01]})})]})]})}),c=({xDir:I})=>{const C=I*3.08,Q=I*(6/2-.2/2+1),h=I*(6/2-.2/2),E=Math.abs(h-Q),u=(Q+h)/2;return zA(wo,{color:"#c0c0c0",children:qt(VQ,{children:[zA(Qt,{size:[2.3*.8,2.95,.2],center:[C,0,.2/2]}),zA(Qt,{size:[.2,2.95,1.14],center:[Q,0,1.14/2+.2]}),zA(Qt,{size:[E,2.95,.2],center:[u,0,.2/2+1.14]})]})})};return qt(Jn,{children:[zA(c,{xDir:1}),zA(c,{xDir:-1}),g]})},m1t=()=>{const I=zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Wi,{z:.27,children:zA(Qt,{size:[2.9,1.9,.54]})}),qt(bc,{children:[zA(Wi,{z:.54,children:zA(Qt,{size:[2.9,1.9,.01]})}),zA(Wi,{z:1.08,children:zA(Qt,{size:[2.6999999999999997,1.7,.01]})})]})]})});return qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),zA(Qt,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),I]})},w1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),zA(Qt,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Wi,{z:.55/2,children:zA(Qt,{size:[2.7,1.6,.55]})}),qt(bc,{children:[zA(Wi,{z:.55,children:zA(Qt,{size:[2.7,1.6,.01]})}),zA(Wi,{z:1.1,children:zA(Qt,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),D1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),zA(Qt,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Wi,{z:.2/2,children:zA(Qt,{size:[2.75,1.8,.2]})}),qt(bc,{children:[zA(Wi,{z:.2,children:zA(Qt,{size:[2.75,1.8,.01]})}),zA(Wi,{z:1,children:zA(Qt,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),zA(Qt,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),S1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),zA(Qt,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[qt(bc,{children:[zA(Wi,{z:.2,children:zA(Qt,{size:[2.6-.1/2,1.7-.1/2,.01]})}),zA(Wi,{z:.01,children:zA(Qt,{size:[2.6-.1,1.7-.1,.01]})})]}),qt(bc,{children:[zA(Wi,{z:.2,children:zA(Qt,{size:[2.6,1.7,.01]})}),zA(Wi,{z:1,children:zA(Qt,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),zA(Qt,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),b1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),zA(Qt,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[qt(bc,{children:[zA(Wi,{z:.2,children:zA(Qt,{size:[3.8-.05/2,2.5-.05/2,.01]})}),zA(Wi,{z:.01,children:zA(Qt,{size:[3.8-.05,2.5-.05,.01]})})]}),qt(bc,{children:[zA(Wi,{z:.2,children:zA(Qt,{size:[3.8,2.5,.01]})}),zA(Wi,{z:1,children:zA(Qt,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),zA(Qt,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),x1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),zA(Qt,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Wi,{z:.14/2,children:zA(Qt,{size:[.8,.6,.14]})}),qt(bc,{children:[zA(Wi,{z:.14,children:zA(Qt,{size:[.8,.6,.01]})}),zA(Wi,{z:.37,children:zA(Qt,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),_1t=()=>{const c=3.0999999999999996;return qt(Jn,{children:[zA(oo,{rotation:Math.PI,position:{x:6.6/2+c/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(oo,{position:{x:-6.6/2-c/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(oo,{position:{x:-6.6/2-c/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(oo,{position:{x:-6.6/2-c/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(yB,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},k1t=()=>qt(Jn,{children:[Array.from({length:16}).map((B,C)=>zA(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((B,C)=>zA(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((B,C)=>zA(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((B,C)=>zA(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})),zA(yB,{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})]}),v1t=k1t,F1t=()=>{const g=.7999999999999998;return qt(Jn,{children:[zA(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}),zA(oo,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),zA(oo,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),zA(yB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},N1t=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:n})=>{const o=t/4;if(o!==Math.floor(o))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);A||(A=.5),i||(i=.6),e||(e=.22),n||(n=A*(o+4));const s=n,r=(o-1)*A/2,a=s+3.3*i,g=a,c=.8,I=.2,l=(g-n)/2+.4;return qt(Jn,{children:[Array.from({length:o}).map((B,C)=>zA(oo,{position:{x:-g/2-.36,y:C*A-r,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:Math.PI,position:{x:g/2+.36,y:C*A-r,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.36,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(oo,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.36,z:I/2},width:e,thickness:I,padContactLength:i,bodyDistance:l,height:c})),zA(yB,{center:{x:0,y:0,z:0},width:n,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})]})},R1t=()=>{const i=.20900000000000002,n=.1,o=.3,s=.1,r=.2;return qt(Jn,{children:[zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Qt,{size:[.85,1.2,i],center:[0,0,i/2]}),qt(bc,{children:[zA(Wi,{z:i,children:zA(Qt,{size:[.85,1.2,.01]})}),zA(Wi,{z:.38,children:zA(Qt,{size:[.85-n,1.2-n,.01]})})]})]})}),zA(Qt,{color:"#ccc",size:[o,.25,s],center:[.55,0,s/2]}),zA(Qt,{color:"#ccc",size:[o,r,s],center:[-.55,.4,s/2]}),zA(Qt,{color:"#ccc",size:[o,r,s],center:[-.55,-.4,s/2]})]})},G1t=({num_pins:t,bodyWidth:A=5.3,bodyLength:e=5.3,bodyThickness:i=1,thermalPadSize:n,padWidth:o=e/5.3*.6,padLength:s=e/5.3*1,pitch:r=.5,thermalPadThickness:a=.2})=>{const g=[],c=Math.floor(t/2),I=r*(c-1);for(let l=0;l<t;l++){const B=l<c?"left":"right",C=l%c,Q=I/2-C*r,h=s,E=o,u=B==="left"?-A/2+h/2:A/2-h/2,d=l+1;g.push({pinNumber:d,x:u,y:Q,padSizeX:h,padSizeY:E})}return qt(Jn,{children:[zA(yB,{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((l,B)=>zA(Qt,{center:[l.x,l.y,a/2],size:[l.padSizeX,l.padSizeY,a]})),n?.length!==void 0&&n?.width!==void 0&&zA(Qt,{center:[0,0,a/2],size:[n.width,n.length,a]})]})},M1t=({bodyLength:t=10.2,bodyWidth:A=4.65,bodyHeight:e=13.46,leadSpacing:i=5,leadDiameter:n=.8,leadLength:o=12.7,color:s="#ddd",leadColor:r="#b87333"})=>{const a=t/2,g=A/2,c=a-g,I=i/2,l=.85;return qt(Jn,{children:[qt(wo,{color:s,children:[qt(bc,{children:[zA(_f,{height:e,roundRadius:.5,radius:g,center:[-c,0,e]}),zA(_f,{height:e,roundRadius:.5,radius:g,center:[c,0,e]})]}),qt(bc,{children:[zA(_f,{height:l,roundRadius:.1,radius:g+.85,center:[-c,0,e/2+l/2]}),zA(_f,{height:l,roundRadius:.1,radius:g+.85,center:[c,0,e/2+l/2]})]})]}),qt(wo,{color:r,children:[zA(Ol,{height:o+e/2,radius:n/2,center:[-I+.06,0,-(o/2)+e/2]}),zA(Ol,{height:o+e/2,radius:n/2,center:[I-.06,0,-(o/2)+e/2]})]})]})},L1t=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:n="#111"})=>qt(Jn,{children:[zA(wo,{color:e,children:qt(gC,{rotation:[0,"90deg",0],children:[zA(VY,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),zA(Ol,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),zA(wo,{color:n,children:zA(gC,{rotation:[0,"90deg",0],children:zA(VY,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),zA(wo,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),zA(wo,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),U1t=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>qt(Jn,{children:[zA(wo,{color:e,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),zA(wo,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),zA(wo,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),H1t=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>qt(Jn,{children:[zA(wo,{color:e,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),zA(wo,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),zA(wo,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(_f,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),Y1t=({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 n=t/2,o=4.9,s=3.9,r=(n-1)*i/2,a=.2;return qt(Jn,{children:[Array.from({length:n}).map((g,c)=>zA(oo,{position:{x:-s/2-A-.3,y:c*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,c)=>zA(oo,{rotation:Math.PI,position:{x:s/2+A+.3,y:c*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),zA(yB,{center:{x:0,y:0,z:a/2},width:s,length:o,height:1.55,notchPosition:{x:-.95,y:o/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},J1t=({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 n=t/2,o=7.5,s=10.3,r=(n-1)*i/2,a=.2;return qt(Jn,{children:[Array.from({length:n}).map((g,c)=>zA(oo,{position:{x:-o/2-A-.3,y:c*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,c)=>zA(oo,{rotation:Math.PI,position:{x:o/2+A+.3,y:c*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),zA(yB,{center:{x:0,y:0,z:a/2},width:o,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},T1t=()=>{const Q=7.050000000000001,h=24.95+6.5/2;return zA(Wi,{center:[0,0,1],children:qt(Jn,{children:[qt(gC,{rotation:[0,55,-55],children:[qt(lm,{children:[zA(Qt,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[h,0,1.3-2]}),zA(Ol,{color:"black",center:[h,0,1.3-2],radius:3/2,height:1.3*1.2})]}),zA(wo,{color:"#222",children:zA(yB,{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})})]}),zA(gC,{rotation:[0,55,55],children:Array.from({length:3}).map((E,u)=>{const d=Q,f=(u-1)*2.7,m=-.5-.6;return qt(wo,{color:"gold",children:[qt(bc,{children:[zA(Wi,{center:[15.05-4.5/2+.1,f,m],children:zA(Qt,{size:[4.5,.81+1,.5]})}),zA(Wi,{center:[15.05-4.5/2-1+.1,f,m],children:zA(Qt,{size:[4.5,.81,.5]})})]}),zA(Wi,{center:[d,f,m],children:zA(Qt,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},P1t=()=>{const g=1.1999999999999997;return qt(Jn,{children:[zA(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}),zA(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}),zA(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}),zA(oo,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(oo,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(oo,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(yB,{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})]})},K1t=()=>qt(Jn,{children:[zA(yB,{center:{x:0,y:0,z:0},width:.8,length:1,height:.37,heightAboveSurface:0,color:"#1a1a1a",taperRatio:.15,straightHeightRatio:0,notchPosition:{x:-.8/4,y:.7/2.2,z:.37+.1}}),[0,1,2].map(g=>{const c=-.35+g*.35;return zA(Qt,{center:[-.8/2+.19/2-.1,c,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(g=>{const c=-.35+g*.35;return zA(Qt,{center:[.8/2-.19/2+.1,c,.12/2],size:[.19,.15,.12]})})]}),q1t=()=>{const s="#222",a=[.43,.4,1.32],g=[.43,.4,.25],c=[0,0,-.66],I=[0,0,-1.32],l=[0,1.28,-2.72],B=[0,1.28,-8.9],C=-7.5;return qt(Wi,{center:[0,1,10.5],children:[zA(wo,{color:s,children:qt(lm,{children:[zA(Wi,{center:[0,0,2.25],children:zA(Ol,{radius:2.4,height:4.5})}),zA(Wi,{center:[0,-1.8499999999999999,2.25],children:zA(Qt,{size:[2.4*2,1.1,4.5+.2]})})]})}),zA(Wi,{center:c,children:zA(Qt,{size:a})}),qt(bc,{children:[zA(Wi,{center:I,children:zA(Qt,{size:g})}),zA(Wi,{center:l,children:zA(Qt,{size:g})})]}),zA(Wi,{center:B,children:zA(Qt,{size:[.43,.4,12.2]})}),zA(Wi,{center:[1.3,0,C],children:zA(Qt,{size:[.43,.4,15]})}),zA(Wi,{center:[-1.3,0,C],children:zA(Qt,{size:[.43,.4,15]})})]})},O1t=()=>qt(Jn,{children:[zA(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}),zA(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}),zA(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}),zA(oo,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(oo,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(oo,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(yB,{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})]}),W1t=O1t,Z1t=()=>qt(Jn,{children:[zA(yB,{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 zA(Qt,{center:[-1/2+.3/2,a,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(r=>{const a=-.5+r*.5;return zA(Qt,{center:[1/2-.3/2,a,.05/2],size:[.3,.2,.05]})})]}),V1t=()=>qt(Jn,{children:[zA(oo,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),zA(oo,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),zA(wo,{color:"#222",children:zA(yB,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),zA(Qt,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),j1t=()=>qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),zA(Qt,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),zA(wo,{color:"#222",children:qt(VQ,{children:[zA(Wi,{z:.175/2,children:zA(Qt,{size:[1.7,1.25,.175]})}),qt(bc,{children:[zA(Wi,{z:.175,children:zA(Qt,{size:[1.7,1.25,.01]})}),zA(Wi,{z:.725,children:zA(Qt,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),zA(Qt,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),z1t=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return qt(Jn,{children:[zA(Qt,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),zA(Qt,{color:"#ccc",size:[.4,.325,.13],center:[r,0,.13/2]}),zA(wo,{color:"#222",children:zA(yB,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),zA(Qt,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},X1t=({pitch:t=10})=>qt(Jn,{children:[zA(Ol,{height:4,radius:.5,center:[-t/2,0,.5]}),zA(NV,{radius:.5,center:[-t/2,0,2.5]}),zA(Wi,{x:-2.5,y:0,z:2.5,children:qt(gC,{rotation:[0,Math.PI/2,0],children:[zA(Ol,{height:t,radius:.5,center:[0,0,2.5]}),zA(wo,{color:"#d2b48c",children:zA(Ol,{height:5,radius:1.3,center:[0,0,2.5]})})]})}),zA(Ol,{height:4,radius:.5,center:[t/2,0,.5]}),zA(NV,{radius:.5,center:[t/2,0,2.5]})]}),$1t=({bodyWidth:t=21,boardThickness:A=.5,leadWidth:e=1.6,leadLength:i=2.4,leadsPitch:n=2.54,leadsLeft:o,leadsRight:s,leadsTop:r,leadsBottom:a,innerHoles:g=!0,innerHoleEdgeDistance:c=1.61,innerHoleDiameter:I=1})=>{const l=t/2,B=A/2,C=A*1.05,Q=I/2,h=Math.max(o||0,s||0,r||0,a||0)*n||51,E=[],u=[];if(s){const w=-((s-1)/2)*n;for(let D=0;D<s;D++){const S=w+D*n;E.push({x:l-i/2,y:-S,pl:i,pw:e}),g&&u.push({x:l,y:-S},{x:l-c,y:-S})}}if(o){const w=-((o-1)/2)*n;for(let D=0;D<o;D++){const S=w+D*n;E.push({x:-l+i/2,y:-S,pl:i,pw:e}),g&&u.push({x:-l,y:-S},{x:-l+c,y:-S})}}if(r){const w=-((r-1)/2)*n;for(let D=0;D<r;D++){const S=w+D*n;E.push({x:-S,y:h/2-i/2,pl:e,pw:i}),g&&u.push({x:-S,y:h/2},{x:-S,y:h/2-c})}}if(a){const w=-((a-1)/2)*n;for(let D=0;D<a;D++){const S=w+D*n;E.push({x:-S,y:-h/2+i/2,pl:e,pw:i}),g&&u.push({x:-S,y:-h/2},{x:-S,y:-h/2+c})}}const d=zA(wo,{color:"#008080",children:qt(lm,{children:[zA(Qt,{center:[0,0,B],size:[t,h,A]}),E.map((w,D)=>zA(Qt,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]},D))]})}),f=g&&u.map((w,D)=>zA(Ol,{color:"black",center:[w.x,w.y,B],radius:Q,height:A*1.07})),m=E.map((w,D)=>zA(Qt,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]}));return qt(Jn,{children:[d,zA(wo,{color:"#FFD700",children:g?qt(lm,{children:[zA(VQ,{children:E.map((w,D)=>zA(Qt,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]},D))}),f]}):m})]})},A2t=({width:t=30,height:A=22,thickness:e=1,bezelInset:i=2,bezelDepth:n=1,screenColor:o="#001414",bezelColor:s="#0f1116",screenWidth:r,screenHeight:a,offset:g})=>{const c=t,I=A,l=Math.max(e,.4),B=Math.max(Math.min(n,l),.2),C=Math.max(l-B,0),Q=Math.max(i,0),h=Math.max(r??c-Q*2,2),E=Math.max(a??I-Q*2,2),u=Math.min(Math.max(B*.6,.2),B),d=g?.x??0,f=g?.y??0,m=g?.z??0;return qt(Wi,{offset:{x:d,y:f,z:m},children:[C>0&&zA(wo,{color:s,children:zA(Qt,{size:[c,I,C],offset:[0,0,C/2]})}),zA(wo,{color:s,children:qt(lm,{children:[zA(Qt,{size:[c,I,B],offset:[0,0,C+B/2]}),zA(Qt,{size:[h,E,B+.02],offset:[0,0,C+B/2]})]})}),zA(wo,{color:o,children:zA(Qt,{size:[h,E,u],offset:[0,0,C+u/2]})})]})},e2t=({numPins:t=5,rows:A=1,p:e=2.54,id:i=1,od:n=1.5,boardThickness:o=1.6,width:s,height:r,pinRowSide:a="left",holes:g=[],holeInset:c=1,pinRowHoleEdgeToEdgeDist:I=2,female:l,nopin:B,screen:C,screenWidth:Q,screenHeight:h,screenCenterOffsetX:E,screenCenterOffsetY:u})=>{const d=C??!1,f=o/2,m=Math.ceil(t/A);let w,D;a==="left"||a==="right"?(w=(A-1)*e+2*I,D=(m-1)*e+2*I):(D=(A-1)*e+2*I,w=(m-1)*e+2*I),t===0&&(w=10,D=10);const S=Number(s??w),_=Number(r??D),x=[];let G=0,F=0,L=0,Y=0,J=0,O=0;a==="left"||a==="right"?(G=a==="left"?-S/2+I:S/2-I,F=-((m-1)/2)*e,L=0,Y=e,J=a==="left"?e:-e,O=0):(G=-((m-1)/2)*e,F=a==="top"?_/2-I:-_/2+I,L=e,Y=0,J=0,O=a==="top"?-e:e);let Z=0;for(let QA=0;QA<A&&Z<t;QA++)for(let _A=0;_A<m&&Z<t;_A++){const dA=G+_A*L+QA*J,KA=F+_A*Y+QA*O;x.push({x:dA,y:KA}),Z++}const X=[];if(g)for(const QA of g){let _A=0,dA=0;QA==="topleft"?(_A=-S/2+c,dA=_/2-c):QA==="topright"?(_A=S/2-c,dA=_/2-c):QA==="bottomleft"?(_A=-S/2+c,dA=-_/2+c):QA==="bottomright"?(_A=S/2-c,dA=-_/2+c):QA==="center"&&(_A=0,dA=0),X.push({x:_A,y:dA})}const eA=.63,gA=2,tA=6,iA=3,sA=B||l?0:gA,aA=sA+o,EA=zA(wo,{color:"#008080",children:qt(lm,{children:[zA(Qt,{center:[0,0,f+sA],size:[S,_,o]}),X.map((QA,_A)=>zA(Ol,{center:[QA.x,QA.y,f+sA],radius:n/2,height:o},`hole-${_A}`)),x.map((QA,_A)=>zA(Ol,{center:[QA.x,QA.y,f+sA],radius:n/2,height:o},`pin-hole-${_A}`))]})}),bA=x.map((QA,_A)=>zA(wo,{color:"#FFD700",children:qt(lm,{children:[zA(Ol,{center:[QA.x,QA.y,o/2+sA],radius:n/2,height:o}),zA(Ol,{center:[QA.x,QA.y,o/2+sA],radius:i/2,height:o})]})})),xA=x.map((QA,_A)=>zA(hie,{x:QA.x,y:QA.y,pinThickness:eA,shortSidePinLength:iA,longSidePinLength:tA,bodyHeight:gA,flipZ:dA=>dA})),YA=x.map((QA,_A)=>zA(mie,{x:QA.x,y:QA.y,flipZ:dA=>-dA}));return qt(Jn,{children:[EA,bA,!l&&!B&&xA,l&&YA,d&&zA(A2t,{width:Q??S*.8,height:h??_*.6,offset:{x:E??0,y:u??0,z:aA}})]})},t2t=({footprint:t})=>{const A=UMt.string(t).json();switch(A.fn){case"dip":return zA(PMt,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"axial":return zA(X1t,{pitch:A.p});case"tssop":return zA(qMt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return zA(OMt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return zA(E1t,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return zA(jMt,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return zA(v1t,{});case"lqfp":return zA(N1t,{pinCount:A.num_pins});case"qfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return zA(n1t,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:n?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"dfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return zA(G1t,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:n?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"pinrow":{const n=t.match(/_rows(\d+)/),o=n&&n[1]?parseInt(n[1],10):1;if(A.male)return zA(A1t,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:o,smd:A.smd||A.surface_mount,rightangle:A.rightangle});if(A.female)return zA(C1t,{numberOfPins:A.num_pins,pitch:A.p,rows:o})}case"cap":switch(A.imperial){case"0402":return zA(Bie,{color:"#856c4d"});case"0603":return zA(Cie,{color:"#856c4d"});case"0805":return zA(Qie,{color:"#856c4d"});case"0201":return zA(Eie,{color:"#856c4d"});case"01005":return zA(uie,{color:"#856c4d"});case"1206":return zA(die,{color:"#856c4d"});case"1210":return zA(pie,{color:"#856c4d"});case"2010":return zA(fie,{color:"#856c4d"});case"2512":return zA(yie,{color:"#856c4d"})}case"sot235":return zA(s1t,{});case"sot457":return zA(P1t,{});case"sot223":return zA(_1t,{});case"sot23w":return zA(r1t,{});case"sot323":return zA(F1t,{});case"sod323f":return zA(j1t,{});case"sod323fl":return zA(z1t,{});case"sot363":return zA(W1t,{});case"sot886":return zA(Z1t,{});case"sot963":return zA(K1t,{});case"pushbutton":return zA(Q1t,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return zA(h1t,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return zA(u1t,{});case"sod882":return zA(d1t,{});case"sma":return zA(p1t,{});case"smb":return zA(f1t,{});case"smc":return zA(y1t,{});case"smf":return zA(m1t,{});case"sod123f":return zA(w1t,{});case"sod123fl":return zA(D1t,{});case"sod123w":return zA(S1t,{});case"sod128":return zA(b1t,{});case"sod323":return zA(V1t,{});case"sod923":return zA(x1t,{});case"hc49":return zA(M1t,{});case"micromelf":return zA(L1t,{});case"minimelf":return zA(U1t,{});case"melf":return zA(H1t,{});case"ms012":return zA(Y1t,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return zA(J1t,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return zA(R1t,{});case"to220":return zA(T1t,{});case"to92":return zA(q1t,{});case"stampboard":case"stampreceiver":return zA($1t,{bodyWidth:A.w,leadsLeft:A.left,leadsRight:A.right,leadsTop:A.top,leadsBottom:A.bottom,leadsPitch:A.p,leadWidth:A.pw,leadLength:A.pl,innerHoles:A.innerhole,innerHoleEdgeDistance:A.innerholeedgedistance});case"mountedpcbmodule":{const n=A.rows??1,o=A.pinRowSide??"left",s=A.holeInset,r=A.width,a=A.height,g=A.pinrow,c=A.pinRowHoleEdgeToEdgeDist,I=Array.isArray(A.holes)?A.holes:[];return zA(e2t,{numPins:g,rows:n,p:A.p,id:A.id,od:A.od,width:r,height:a,pinRowSide:o,holes:I,holeInset:s,pinRowHoleEdgeToEdgeDist:c,nopin:A.nopin,female:A.female,screen:A.screen,screenWidth:A.screenwidth,screenHeight:A.screenheight,screenCenterOffsetX:A.screencenteroffsetx,screenCenterOffsetY:A.screencenteroffsety})}}const e=t.match(/_color\(([^)]+)\)/),i=e?e[1]:void 0;switch(A.imperial){case"0402":return zA(Bie,{color:i});case"0603":return zA(Cie,{color:i});case"0805":return zA(Qie,{color:i});case"0201":return zA(Eie,{color:i});case"01005":return zA(uie,{color:i});case"1206":return zA(die,{color:i});case"1210":return zA(pie,{color:i});case"2010":return zA(fie,{color:i});case"2512":return zA(yie,{color:i})}return null},i2t=t=>t&&typeof t=="object"&&"type"in t,f1=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},n2t=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 JD(t,A,e){const{jscad:{primitives:i,booleans:n,hulls:o,geometries:s,extrusions:r,transforms:a}}=e;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(l=>JD(l,A,e));if(!i2t(t))return[];const{type:g,props:c,children:I}=t;if(g===cie)return(I??[]).flatMap(l=>JD(l,A,e));if(g===wo){const l=c?.color;return(I??[]).flatMap(B=>JD(B,l??A,e))}if(g===Wi){const l=n2t(c?.offset??c?.center??{x:c?.x,y:c?.y,z:c?.z});return(I??[]).flatMap(C=>JD(C,A,e)).map(({geom:C,color:Q})=>({geom:a.translate(l,C),color:Q??A}))}if(g===gC){const l=Array.isArray(c?.rotation)?[f1(c.rotation[0]),f1(c.rotation[1]),f1(c.rotation[2])]:[f1(c?.x??0),f1(c?.y??0),f1(c?.z??0)];return(I??[]).flatMap(C=>JD(C,A,e)).map(({geom:C,color:Q})=>({geom:a.rotateZ(l[2],a.rotateY(l[1],a.rotateX(l[0],C))),color:Q}))}if(g===VQ||g===lm||g===bc){const l=(I??[]).flatMap(C=>JD(C,A,e)).map(C=>C.geom);if(l.length===0)return[];let B;return g===VQ?B=n.union(l):g===lm?B=n.subtract(l[0],l.slice(1)):B=o.hull(l),[{geom:B,color:A}]}if(g===jY){const l=c?.points??[];return[{geom:s.geom2.fromPoints(l),color:A??c?.color}]}if(g===zY){const l=(I??[]).flatMap(h=>JD(h,A,e)).map(h=>h.geom);if(l.length===0)return[];const B=l.length>1?n.union(l):l[0],C=c?.height??c?.h??1;let Q=r.extrudeLinear({height:C},B);if(Q.polygons)for(const h of Q.polygons)!h.plane||!h.vertices||h.vertices.length<3||h.vertices.reverse();return[{geom:Q,color:A??c?.color}]}if(g===Qt||g===Iie||g===Ol||g===NV||g===VY||g===_f){let l;if(g===Qt){const B=c?.size??[1,1,1],C=c?.offset,Q=c?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);l=i.cuboid({size:B,center:Q})}else if(g===Iie){const B=c?.size??1,C=c?.offset,Q=c?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);l=i.cube({size:B,center:Q})}else if(g===Ol){const B=c?.height??1,C=c?.radius??1,Q=c?.center??[0,0,0];l=i.cylinder({height:B,radius:C,center:Q})}else if(g===NV){const B=c?.radius??1,C=c?.center??[0,0,0];l=i.sphere({radius:B,center:C})}else if(g===_f){const B=c?.height??1,C=c?.radius??1,Q=c?.roundRadius??.1,h=c?.center??[0,0,0];l=i.roundedCylinder({height:B,radius:C,roundRadius:Q,center:h})}else{const B=c?.size??[1,1,1],C=c?.roundRadius??.1,Q=c?.center??[0,0,0];l=i.roundedCuboid({size:B,roundRadius:C,center:Q})}return[{geom:l,color:A??c?.color}]}if(typeof g=="function"){const l=g(c??{});return JD(l,A,e)}return(I??[]).flatMap(l=>JD(l,A,e))}function o2t(t,A){return{geometries:JD(t,void 0,{jscad:A})}}function wie(t){if(t.polygons){const A=[],e=[],i=[];let n=0;for(const s of t.polygons){for(const a of s.vertices)a.index=n,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),n++;const r=s.vertices[0].index;for(let a=2;a<s.vertices.length;a++){const g=s.vertices[a-1].index,c=s.vertices[a].index;e.push(r,g,c)}}const o=new Gg;if(o.setAttribute("position",new Sc(new Float32Array(A),3)),o.setIndex(e),i.length>0&&o.setAttribute("color",new Sc(new Float32Array(i),3)),t.transforms){const s=new Qs;s.fromArray(t.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(t.sides){const A=[],e=[];for(const n of t.sides)A.push(n[0][0],n[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 Gg;if(i.setAttribute("position",new Sc(new Float32Array(A),3)),e.length>0&&i.setAttribute("color",new Sc(new Float32Array(e),3)),t.transforms){const n=new Qs;n.fromArray(t.transforms),i.applyMatrix4(n)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Gg}function s2t(t,A){const e=RdA(t2t,{footprint:t});return o2t(e,A)}var r2t=ka(wV()),Die=V.createContext(null),a2t=()=>{const t=V.useContext(Die);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},g2t=({children:t})=>{const{camera:A,renderer:e}=ed(),[i,n]=V.useState([]),o=V.useMemo(()=>new $Et,[]),s=V.useMemo(()=>new dn,[]),r=V.useRef(i);r.current=i;const a=V.useRef(null),g=V.useCallback(C=>{n(Q=>[...Q,C])},[]),c=V.useCallback(C=>{if(a.current){let Q=!1,h=a.current.object;for(;h;){if(h===C){Q=!0;break}h=h.parent}Q&&(a.current.onUnhover(),a.current=null)}n(Q=>Q.filter(h=>h.object!==C))},[]),I=V.useCallback(C=>{let Q=C;for(;Q;){const h=r.current.find(E=>E.object===Q);if(h)return h;Q=Q.parent}},[]),l=V.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,o.setFromCamera(s,A);const h=r.current.map(u=>u.object);if(h.length===0){a.current&&(a.current.onUnhover(),a.current=null);return}const E=o.intersectObjects(h,!0);if(E.length>0){const u=E[0],d=I(u.object);if(d){const f={mousePosition:[u.point.x,u.point.y,u.point.z]};a.current!==d?(a.current?.onUnhover(),d.onHover(f),a.current=d):d.onHover(f)}else a.current&&(a.current.onUnhover(),a.current=null)}else a.current&&(a.current.onUnhover(),a.current=null)},[A,e,o,s,I]);V.useEffect(()=>{const C=e.domElement;return C.addEventListener("mousemove",l),()=>{C.removeEventListener("mousemove",l)}},[e,l]);const B=V.useMemo(()=>({addHoverable:g,removeHoverable:c}),[g,c]);return W.jsx(Die.Provider,{value:B,children:t})},c2t=({children:t,object:A,onHover:e,onUnhover:i,isHovered:n})=>{const{addHoverable:o,removeHoverable:s}=a2t();return V.useEffect(()=>A?(o({object:A,onHover:e,onUnhover:i}),()=>{s(A)}):void 0,[A,e,i,o,s]),W.jsx(W.Fragment,{children:t})},sJ=c2t,I2t=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=ed(),g=V.useMemo(()=>{if(!A)return null;const{geometries:c}=s2t(A,r2t),I=new xf;for(const l of c.flat(1/0)){const B=l.geom;if(!B||!B.polygons&&!B.sides)continue;const C=new An(l.color);C.convertLinearToSRGB();const Q={...B,color:[C.r,C.g,C.b]},h=wie(Q),E=new qE({vertexColors:!0,side:aC,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new lo(h,E);u.renderOrder=r?2:1,I.add(u)}return I},[A,r]);return V.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),V.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]),V.useEffect(()=>{g&&g.traverse(c=>{c instanceof lo&&c.material instanceof qE&&(o?(c.material.emissive.setHex(255),c.material.emissiveIntensity=.2):c.material.emissiveIntensity=0)})},[o,g]),g?W.jsx(sJ,{isHovered:o,onHover:i,onUnhover:n,object:g}):null},Sie=new WeakMap,l2t=()=>{const t=new tI;return t.name="fallback-environment-map",t.mapping=kW,t},B2t=t=>{if(!t)return null;const A=t,e=Sie.get(A);if(e)return e;let i;if(t instanceof aZ){const n=new YgA(t);i=n.fromScene(mut(),.04).texture,n.dispose()}else i=l2t();return Sie.set(A,i),i},bie=1.25;function xie({gltfUrl:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=ed(),[c,I]=V.useState(null),[l,B]=V.useState(null);if(V.useEffect(()=>{if(!t)return;const C=new Dut;let Q=!0;return C.load(t,h=>{if(!Q)return;const E=h.scene;E.traverse(u=>{if(u instanceof lo&&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),u.renderOrder=r?2:1}}),I(E)},void 0,h=>{if(!Q)return;console.error(`An error happened loading ${t}`,h);const E=h instanceof Error?h:new Error(`Failed to load glTF model from ${t}`);B(E)}),()=>{Q=!1}},[t,r]),V.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]),V.useEffect(()=>{if(!(!g||!c))return g.add(c),()=>{g.remove(c)}},[g,c]),V.useEffect(()=>{if(!c||!a)return;const C=B2t(a);if(!C)return;const Q=[],h=E=>{E instanceof qE&&(Q.push({material:E,envMap:E.envMap??null,envMapIntensity:E.envMapIntensity??1}),E.envMap=C,(typeof E.envMapIntensity!="number"||E.envMapIntensity<bie)&&(E.envMapIntensity=bie),E.needsUpdate=!0)};return c.traverse(E=>{if(!(E instanceof lo))return;const u=E.material;Array.isArray(u)?u.forEach(h):u&&h(u)}),()=>{Q.forEach(({material:E,envMap:u,envMapIntensity:d})=>{E.envMap=u,E.envMapIntensity=d,E.needsUpdate=!0})}},[c,a]),V.useEffect(()=>{c&&c.traverse(C=>{C instanceof lo&&C.material instanceof qE&&(o?(C.material.emissive.setHex(255),C.material.emissiveIntensity=.2):C.material.emissiveIntensity=0)})},[o,c]),l)throw l;return c?W.jsx(sJ,{isHovered:o,onHover:i,onUnhover:n,object:c}):null}var C2t=ka(Fte()),Q2t=ka(wV()),h2t=({jscadPlan:t,positionOffset:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=ed(),{threeGeom:g,material:c}=V.useMemo(()=>{const l=(0,C2t.executeJscadOperations)(Q2t.default,t);if(!l||!l.polygons&&!l.sides)return{threeGeom:null,material:null};const B=wie(l),C=new qE({vertexColors:!0,side:aC,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:B,material:C}},[t,r]),I=V.useMemo(()=>{if(!g)return null;const l=new lo(g,c);return l.renderOrder=r?2:1,l},[g,c,r]);return V.useEffect(()=>{if(!(!I||!a))return a.add(I),()=>{a.remove(I)}},[a,I]),V.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]),V.useMemo(()=>{if(c)if(o){const l=new An(c.color.getHex());c.emissive.copy(l),c.emissive.setRGB(0,0,1),c.emissiveIntensity=.2}else c.emissiveIntensity=0},[o,c]),g?W.jsx(sJ,{isHovered:o,onHover:i,onUnhover:n,object:I}):null};function E2t(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(A,e,i)=>`${e} ${i.replace(/-/g,"_")}`)}async function u2t(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 cdt().parse(E2t(e),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function d2t(t){const[A,e]=V.useState(null);return V.useEffect(()=>{if(!t)return;const i=t.replace(/&cachebust_origin=$/,""),n=window.TSCIRCUIT_OBJ_LOADER_CACHE;let o=!1;async function s(){try{if(i.endsWith(".wrl"))return await u2t(i);const a=await fetch(i);if(!a.ok)throw new Error(`Failed to fetch "${i}": ${a.status} ${a.statusText}`);const g=await a.text(),c=g.match(/newmtl[\s\S]*?endmtl/g),I=new ddt;if(c?.length){const l=c.join(`
|
|
5156
|
+
`).replace(/d 0\./g,"d 1."),B=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new rdt;C.setMaterialOptions({invertTrProperty:!0});const Q=C.parse(l.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return I.setMaterials(Q),I.parse(B)}return I.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(n.has(i)){const g=n.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(c=>c instanceof Error?c:c.clone())}const a=s().then(g=>(g instanceof Error||n.set(i,{...n.get(i),result:g}),g));return n.set(i,{promise:a,result:null}),a}return r().then(a=>{o||e(a)}).catch(a=>{console.error(a)}),()=>{o=!0}},[t]),A}function p2t({url:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const a=d2t(t),{rootObject:g}=ed(),c=V.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(I=>{if(I instanceof lo&&I.material){const l=B=>{B.transparent=r,B.opacity=r?.5:1,B.depthWrite=!r,B.needsUpdate=!0};Array.isArray(I.material)?I.material.forEach(l):l(I.material),I.renderOrder=r?2:1}}),a):new lo(new fw(.5,.5,.5),new qE({transparent:!0,color:"red",opacity:.25})),[a,r]);if(V.useEffect(()=>{if(!(!g||!c))return g.add(c),()=>{g.remove(c)}},[g,c]),V.useEffect(()=>{c&&(A&&(Array.isArray(A)?c.position.fromArray(A):c.position.copy(A)),e&&(Array.isArray(e)?c.rotation.fromArray(e):c.rotation.copy(e)),s!==void 0&&c.scale.setScalar(s))},[c,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(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 W.jsx(sJ,{isHovered:o,onHover:i,onUnhover:n,object:c})}var ApA,f2t="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function y2t(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 m2t(){if(!ApA){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");ApA=y2t(t)({locateFile:e=>`${f2t}/${e}`})}return ApA}function w2t(t){const A=new xf;for(const e of t){const i=e.attributes.position?.array??[],n=e.index?.array??[];if(!i.length||!n.length)continue;const o=new Gg;o.setAttribute("position",new $o(i,3));const s=e.attributes.normal?.array??[];s.length?o.setAttribute("normal",new $o(s,3)):o.computeVertexNormals(),o.setIndex(n);const r=new qE({color:e.color?new An(e.color[0],e.color[1],e.color[2]):new An(.82,.82,.82)}),a=new lo(o,r);a.name=e.name,A.add(a)}return A}async function D2t(t){const A=await fetch(t);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const e=await A.arrayBuffer(),n=(await m2t()).ReadStepFile(new Uint8Array(e),null);if(!n.success||!n.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=w2t(n.meshes),s=new EcA;return await new Promise((a,g)=>{s.parse(o,c=>{c instanceof ArrayBuffer?a(c):g(new Error("GLTFExporter did not return binary output"))},c=>{g(c)},{binary:!0})})}var _ie="step-glb-cache:";function S2t(t){const A=new Uint8Array(t),e=32768;let i="";for(let n=0;n<A.length;n+=e){const o=A.subarray(n,n+e);i+=String.fromCharCode(...o)}return btoa(i)}function b2t(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 x2t(t){try{const A=localStorage.getItem(`${_ie}${t}`);return A?b2t(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function kie(t,A){try{const e=S2t(A);localStorage.setItem(`${_ie}${t}`,e)}catch(e){console.warn("Failed to write STEP GLB cache",e)}}function _2t(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var k2t=({stepUrl:t,position:A,rotation:e,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r})=>{const[a,g]=V.useState(null);return V.useEffect(()=>{let c=!0,I=null,l=!0;const B=_2t(),C=x2t(t);if(C){const E={arrayBuffer:C,blobUrl:URL.createObjectURL(new Blob([C],{type:"model/gltf-binary"}))};return B.completed.set(t,E),I=E.blobUrl,l=!1,g(E.blobUrl),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)}}const Q=B.completed.get(t);if(Q)return I=Q.blobUrl,l=!1,g(Q.blobUrl),kie(t,Q.arrayBuffer),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)};let h=B.inProgress.get(t);return h||(h=D2t(t).then(E=>{const u={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return B.completed.set(t,u),B.inProgress.delete(t),u}).catch(E=>{throw B.inProgress.delete(t),E}),B.inProgress.set(t,h)),h.then(E=>{c&&(I=E.blobUrl,l=!1,g(E.blobUrl),kie(t,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),c&&g(null)}),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)}},[t]),a?W.jsx(xie,{gltfUrl:a,position:A,rotation:e,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r}):null},v2t=(t,A)=>{if(t)return A?A(t):t},vie=(...t)=>t,epA=class extends Bn.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}},F2t=({error:t,onError:A})=>(V.useEffect(()=>{A(t)},[t,A]),null),Fie=({cad_component:t,circuitJson:A,resolveStaticAsset:e})=>{const i=Gte(A),[n,o]=V.useState(!1),{visibility:s}=PF(),[r,a]=V.useState(null),g=V.useCallback(G=>{G?.mousePosition?(o(!0),a(G.mousePosition)):(o(!1),a(null))},[]),c=V.useCallback(()=>{o(!1),a(null)},[]),I=V.useMemo(()=>mn(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),l=V.useMemo(()=>A.filter(F=>F.type==="pcb_plated_hole"&&F.pcb_component_id===t.pcb_component_id).length>0,[A,t.pcb_component_id]),B=V.useCallback(G=>v2t(G,e),[e]),C=B(t.model_obj_url??t.model_wrl_url??t.model_stl_url),Q=B(t.model_glb_url??t.model_gltf_url),h=B(t.model_step_url),[E,u]=V.useState(0),[d,f]=V.useState(null);V.useEffect(()=>{u(0),f(null)},[t.cad_component_id,C,Q,h]);const w=A.find(G=>G.type==="pcb_component"&&G.source_component_id===t.source_component_id)?.layer??"top",D=V.useMemo(()=>t.rotation?vie(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):vie(0,0,0),[t.rotation,w]),S=V.useMemo(()=>{if(!t.position)return;let G;return w==="top"?G=t.position.z:w==="bottom"?G=-(t.position.z+i):G=t.position.z,[t.position.x,t.position.y,G]},[t.position,w,i]),_=V.useMemo(()=>{const G=[];return C&&G.push(W.jsx(p2t,{url:C,position:S,rotation:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${C}`)),Q&&G.push(W.jsx(xie,{gltfUrl:Q,position:S,rotation:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${Q}`)),h&&!t.model_jscad&&!t.footprinter_string&&G.push(W.jsx(k2t,{stepUrl:h,position:S,rotation:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${h}`)),G},[S,t.cad_component_id,t.footprinter_string,t.model_jscad,t.model_unit_to_mm_scale_factor,t.show_as_translucent_model,Q,g,c,n,D,h,C]);let x=null;if(_.length>0){if(E>=_.length){if(d)throw d;return null}x=W.jsx(epA,{fallback:({error:G})=>W.jsx(F2t,{error:G,onError:F=>{f(F),u(L=>Math.max(L,E+1))}}),children:_[E]},`${t.cad_component_id}-fallback-${E}`)}else t.model_jscad?x=W.jsx(h2t,{jscadPlan:t.model_jscad,positionOffset:S,rotationOffset:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(x=W.jsx(I2t,{positionOffset:S,rotationOffset:D,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model}));if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(l&&!s.throughHoleModels||!l&&!s.smtModels)return null;return W.jsxs(W.Fragment,{children:[x,n&&r?W.jsx(Lte,{position:r,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:I??"<unknown>"}):null]})},Nie={version:"0.0.537"};function N2t(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var R2t=t=>{t.outputColorSpace=lw,t.toneMapping=n5A,t.toneMappingExposure=1},Rie="cadViewerCameraStateSession",Gie=(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(Rie,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},tpA=(t,A)=>{try{const e=sessionStorage.getItem(Rie);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 n=t;n.fov=i.fov,n.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),t.updateMatrixWorld(),!0}catch(e){return console.warn("Failed to restore camera:",e),!1}},Mie=V.createContext(void 0),G2t=({children:t,defaultTarget:A,initialCameraPosition:e})=>{const i=V.useRef(null),n=V.useRef(null),[o,s]=V.useState(null),[r,a]=V.useState("perspective"),[g,c]=V.useState(e??null),[I,l]=V.useState(new Sf(0,0,0)),B=V.useMemo(()=>{const[E,u,d]=e??[5,-5,5],f=Math.hypot(E-A.x,u-A.y,d-A.z);return f>0?f:5},[e,A]),C=V.useCallback(E=>{const u=[A.x,A.y,A.z],d=n.current,f=i.current;let m=B;switch(d&&f&&(m=d.position.distanceTo(f.target)),E){case"Top Center Angled":{const w=m/Math.sqrt(2);return{position:[A.x,A.y-w,A.z+w],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+m],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-m,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+m,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-m,A.z],target:u,up:[0,0,1]};default:return null}},[B,A,n,i]),Q=V.useCallback(E=>{i.current=E},[]),h=V.useMemo(()=>({controlsRef:i,mainCameraRef:n,defaultTarget:A,baseDistance:B,controller:o,setController:s,getPresetConfig:C,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:c,cameraRotation:I,setCameraRotation:l,saveCameraToSession:Gie,loadCameraFromSession:tpA}),[A,B,o,C,Q,r,g,I]);return W.jsx(Mie.Provider,{value:h,children:t})},ik=()=>{const t=V.useContext(Mie);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},M2t=V.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:n},o)=>{const{cameraType:s}=ik(),r=V.useRef(null),[a,g]=V.useState(null),c=V.useRef([]),I=V.useRef(void 0);I.current=n;const l=V.useRef(null),B=V.useCallback(E=>{c.current.push(E)},[]),C=V.useCallback(E=>{c.current=c.current.filter(u=>u!==E)},[]),Q=V.useMemo(()=>new SF,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const h=V.useRef(new Rg);return V.useImperativeHandle(o,()=>h.current),V.useEffect(()=>{if(!r.current)return;N2t(r.current);const E=new aZ({antialias:!0,alpha:!0});R2t(E),E.setSize(r.current.clientWidth,r.current.clientHeight),E.setPixelRatio(window.devicePixelRatio),r.current.appendChild(E.domElement);const u=r.current.clientWidth/r.current.clientHeight,d=s==="perspective"?new Ph(75,u,.1,1e3):new tY(-10*u,10*u,10,-10,-1e3,1e3);l.current?(d.position.copy(l.current.position),d.quaternion.copy(l.current.quaternion),d.up.copy(l.current.up)):(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(h.current),window.__TSCIRCUIT_THREE_OBJECT=h.current,g({scene:Q,camera:d,renderer:E,rootObject:h.current,addFrameListener:B,removeFrameListener:C}),I.current?.({camera:d,renderer:E});let f;const m=new PEt,w=()=>{const S=m.getElapsedTime(),_=m.getDelta();c.current.forEach(x=>x(S,_)),E.render(Q,d),f=requestAnimationFrame(w)};w();const D=()=>{if(r.current){const S=r.current.clientWidth/r.current.clientHeight;d instanceof Ph?d.aspect=S:d instanceof tY&&(d.left=-10*S,d.right=10*S,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),E.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",D),()=>{l.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",D),cancelAnimationFrame(f),r.current&&E.domElement&&r.current.removeChild(E.domElement),E.dispose(),Q.remove(h.current),window.__TSCIRCUIT_THREE_OBJECT===h.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,B,C,s]),W.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&W.jsx(Mte.Provider,{value:a,children:W.jsx(g2t,{children:t})})})}),L2t=({autoRotate:t,autoRotateSpeed:A,onStart:e,panSpeed:i,rotateSpeed:n,zoomSpeed:o,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:c,renderer:I}=ed(),l=V.useMemo(()=>!c||!I?null:new fdt(c,I.domElement),[c,I]);return V.useEffect(()=>(g?.(l??null),()=>g?.(null)),[l,g]),V.useEffect(()=>{if(!l)return;const B=()=>{g?.(l)};return l.addEventListener("change",B),()=>{l.removeEventListener("change",B)}},[l,g]),V.useEffect(()=>{l&&(l.autoRotate=t||!1,l.autoRotateSpeed=A||1,i!==void 0&&(l.panSpeed=i),n!==void 0&&(l.rotateSpeed=n),o!==void 0&&(l.zoomSpeed=o),s!==void 0&&(l.enableDamping=s),r!==void 0&&(l.dampingFactor=r),l.zoomToCursor=!0,l.mouseButtons={LEFT:F_.ROTATE,MIDDLE:F_.PAN,RIGHT:null},a&&(l.target.set(a[0],a[1],a[2]),l.update()))},[l,t,A,i,n,o,s,r,a]),V.useEffect(()=>{if(!(!l||!e))return l.addEventListener("start",e),()=>{l.removeEventListener("start",e)}},[l,e]),V.useEffect(()=>{if(l)return()=>{l.dispose()}},[l]),qY(()=>{l?.update()},[l]),null},U2t=`
|
|
5157
5157
|
varying vec3 worldPosition;
|
|
5158
5158
|
void main() {
|
|
5159
5159
|
worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
@@ -5687,7 +5687,7 @@ test("${g} should solve problem correctly", () => {
|
|
|
5687
5687
|
// Add more specific assertions based on expected output
|
|
5688
5688
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5689
5689
|
})
|
|
5690
|
-
`,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&W.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Ahe=t=>t.activeSubSolver?[t,...Ahe(t.activeSubSolver)]:[t],hei=({solver:t})=>{const A=Ahe(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(Qei,{solver:e})]},e.constructor.name))})},Eei=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(hei,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),W.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),W.jsx("button",{onClick:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&W.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:C})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},uei=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},dei=(t,A)=>{const i=t.pipelineDef[A].solverName,n=uei(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},pei=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${A[t]}`,children:t})},fei=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},yei=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),mei=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=yei(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},VyA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(VyA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=VyA(i));return A},wei=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=VyA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},Dei=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>dei(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):wei(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:i.map(r=>W.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),W.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(pei,{status:r.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(fei,{progress:r.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(mei,{stats:r.stats})}),W.jsx("td",{className:"px-4 py-2",children:r.solverInstance?W.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),W.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},Sei=class extends Bn.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 bei({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>W.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),e.map((h,E)=>W.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var xei=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=V.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);V.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return W.jsxs("div",{children:[W.jsx(Eei,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(Sei,{fallback:W.jsx(bei,{graphics:s}),children:W.jsx(Cei,{graphics:s})}),a&&W.jsx(Dei,{solver:t,onStepUntilPhase:g})]})};const _ei=()=>{V.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},kei=t=>t.toLowerCase().includes("pack")?VPt:t.toLowerCase().includes("rout")?AKt:RPt,vei=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);_ei();const i=V.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=V.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=V.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=urA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(urA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.length===0?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return W.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const c=kei(a.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?W.jsx(Qm,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:W.jsx(xei,{solver:s.instance})}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&W.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:W.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},ehe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{DW.captureException(i)}catch{}}},[t,A]),V.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{DW.captureException(n,{error_type:i.type})}catch{}}},[e])},the="0.0.1731",Fei={version:the},lz=ZqA()(VqA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),Nei=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=qG("eval-version-selection",null),g=lz(B=>B.setLastRunEvalVersion),c=lz(B=>B.lastRunEvalVersion);return V.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(B=>B.json()).then(B=>{if(Array.isArray(B?.versions)){let C=[...B.versions];B.tags?.latest&&(n(B.tags.latest),C=C.filter(Q=>Q!==B.tags.latest)),e(C)}}).catch(()=>{})},[t]),V.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:V.useMemo(()=>A.filter(B=>B.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:c,search:o,setSearch:s,selectVersion:B=>{a(B),s("")}}},Rei=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=t.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),c=I=>{I.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:W.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[W.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),W.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:I=>r(I.target.value),onKeyDown:c}),W.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(I=>W.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===I?"bg-blue-50":""}`,onClick:()=>o(I),children:I},I)),g&&W.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),W.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},Gei=t=>{const A=V.useRef(null),e=FI(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function Mei(t){const A=Lei(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(Hei);if(a){const g=a.props.children,c=r.map(I=>I===a?V.Children.count(g)>1?V.Children.only(null):V.isValidElement(g)?g.props.children:null:I);return W.jsx(A,{...s,ref:n,children:V.isValidElement(g)?V.cloneElement(g,void 0,c):null})}return W.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function Lei(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=Jei(n),r=Yei(o,n.props);return n.type!==V.Fragment&&(r.ref=i?yf(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var Uei=Symbol("radix.slottable");function Hei(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Uei}function Yei(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function Jei(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 Bz="Dialog",[ihe,nhe]=aw(Bz),[Tei,Nw]=ihe(Bz),ohe=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=V.useRef(null),a=V.useRef(null),[g,c]=f_({prop:i,defaultProp:n??!1,onChange:o,caller:Bz});return W.jsx(Tei,{scope:A,triggerRef:r,contentRef:a,contentId:YE(),titleId:YE(),descriptionId:YE(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};ohe.displayName=Bz;var she="DialogTrigger",rhe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nw(she,e),o=NI(A,n.triggerRef);return W.jsx(Ag.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":XyA(n.open),...i,ref:o,onClick:Zn(t.onClick,n.onOpenToggle)})});rhe.displayName=she;var jyA="DialogPortal",[Pei,ahe]=ihe(jyA,{forceMount:void 0}),ghe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Nw(jyA,A);return W.jsx(Pei,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(H0,{present:e||o.open,children:W.jsx(N9,{asChild:!0,container:n,children:s})}))})};ghe.displayName=jyA;var Cz="DialogOverlay",che=V.forwardRef((t,A)=>{const e=ahe(Cz,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Nw(Cz,t.__scopeDialog);return o.modal?W.jsx(H0,{present:i||o.open,children:W.jsx(qei,{...n,ref:A})}):null});che.displayName=Cz;var Kei=Mei("DialogOverlay.RemoveScroll"),qei=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nw(Cz,e);return W.jsx(J9,{as:Kei,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(Ag.div,{"data-state":XyA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),DN="DialogContent",Ihe=V.forwardRef((t,A)=>{const e=ahe(DN,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Nw(DN,t.__scopeDialog);return W.jsx(H0,{present:i||o.open,children:o.modal?W.jsx(Oei,{...n,ref:A}):W.jsx(Wei,{...n,ref:A})})});Ihe.displayName=DN;var Oei=V.forwardRef((t,A)=>{const e=Nw(DN,t.__scopeDialog),i=V.useRef(null),n=NI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return pfA(o)},[]),W.jsx(lhe,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Zn(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Zn(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Zn(t.onFocusOutside,o=>o.preventDefault())})}),Wei=V.forwardRef((t,A)=>{const e=Nw(DN,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(lhe,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),lhe=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Nw(DN,e),a=V.useRef(null),g=NI(A,a);return efA(),W.jsxs(W.Fragment,{children:[W.jsx(p9,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(bJ,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":XyA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(Vei,{titleId:r.titleId}),W.jsx(zei,{contentRef:a,descriptionId:r.descriptionId})]})]})}),zyA="DialogTitle",Bhe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nw(zyA,e);return W.jsx(Ag.h2,{id:n.titleId,...i,ref:A})});Bhe.displayName=zyA;var Che="DialogDescription",Qhe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nw(Che,e);return W.jsx(Ag.p,{id:n.descriptionId,...i,ref:A})});Qhe.displayName=Che;var hhe="DialogClose",Ehe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nw(hhe,e);return W.jsx(Ag.button,{type:"button",...i,ref:A,onClick:Zn(t.onClick,()=>n.onOpenChange(!1))})});Ehe.displayName=hhe;function XyA(t){return t?"open":"closed"}var uhe="DialogTitleWarning",[Zei,dhe]=prt(uhe,{contentName:DN,titleName:zyA,docsSlug:"dialog"}),Vei=({titleId:t})=>{const A=dhe(uhe),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
|
|
5690
|
+
`,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&W.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Ahe=t=>t.activeSubSolver?[t,...Ahe(t.activeSubSolver)]:[t],hei=({solver:t})=>{const A=Ahe(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>W.jsxs("div",{className:"flex items-center",children:[i>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(Qei,{solver:e})]},e.constructor.name))})},Eei=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=V.useReducer(Q=>!Q,!1),r=V.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},I=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const h=Q.getCurrentPhase();for(;Q.getCurrentPhase()===h&&!t.solved&&!t.failed;)t.step();A()}},l=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const h=Number(Q);if(!Number.isFinite(h)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<h&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};V.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),V.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const B=t.getCurrentPhase!==void 0,C=B?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(hei,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),W.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),W.jsx("button",{onClick:c,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),W.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&W.jsx("button",{onClick:I,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:C})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},uei=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},dei=(t,A)=>{const i=t.pipelineDef[A].solverName,n=uei(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const l=t.pipelineDef[A+1],B=l?t.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},pei=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${A[t]}`,children:t})},fei=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},yei=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),mei=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=yei(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),W.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>W.jsxs("div",{children:[i,": ",String(n)]},i))})]})},VyA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(VyA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=VyA(i));return A},wei=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=VyA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},Dei=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>dei(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):wei(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:i.map(r=>W.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),W.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(pei,{status:r.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(fei,{progress:r.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(mei,{stats:r.stats})}),W.jsx("td",{className:"px-4 py-2",children:r.solverInstance?W.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),W.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},Sei=class extends Bn.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 bei({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>W.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),e.map((h,E)=>W.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var xei=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=V.useReducer(c=>c+1,0),s=V.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=V.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);V.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=t.pipelineDef!==void 0,g=c=>{const I=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)t.step();o()}};return W.jsxs("div",{children:[W.jsx(Eei,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(Sei,{fallback:W.jsx(bei,{graphics:s}),children:W.jsx(Cei,{graphics:s})}),a&&W.jsx(Dei,{solver:t,onStepUntilPhase:g})]})};const _ei=()=>{V.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},kei=t=>t.toLowerCase().includes("pack")?VPt:t.toLowerCase().includes("rout")?AKt:RPt,vei=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);_ei();const i=V.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=V.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=V.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=urA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(urA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.length===0?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return W.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const c=kei(a.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?W.jsx(Qm,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:W.jsx(xei,{solver:s.instance})}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&W.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:W.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},ehe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{DW.captureException(i)}catch{}}},[t,A]),V.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{DW.captureException(n,{error_type:i.type})}catch{}}},[e])},the="0.0.1732",Fei={version:the},lz=ZqA()(VqA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),Nei=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=qG("eval-version-selection",null),g=lz(B=>B.setLastRunEvalVersion),c=lz(B=>B.lastRunEvalVersion);return V.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(B=>B.json()).then(B=>{if(Array.isArray(B?.versions)){let C=[...B.versions];B.tags?.latest&&(n(B.tags.latest),C=C.filter(Q=>Q!==B.tags.latest)),e(C)}}).catch(()=>{})},[t]),V.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:V.useMemo(()=>A.filter(B=>B.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:c,search:o,setSearch:s,selectVersion:B=>{a(B),s("")}}},Rei=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=V.useState(""),[s,r]=V.useState("");if(!i)return null;const a=t.filter(I=>I.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),c=I=>{I.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return W.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:W.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[W.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),W.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:I=>r(I.target.value),onKeyDown:c}),W.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(I=>W.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===I?"bg-blue-50":""}`,onClick:()=>o(I),children:I},I)),g&&W.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),W.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),W.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},Gei=t=>{const A=V.useRef(null),e=FI(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function Mei(t){const A=Lei(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(Hei);if(a){const g=a.props.children,c=r.map(I=>I===a?V.Children.count(g)>1?V.Children.only(null):V.isValidElement(g)?g.props.children:null:I);return W.jsx(A,{...s,ref:n,children:V.isValidElement(g)?V.cloneElement(g,void 0,c):null})}return W.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function Lei(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=Jei(n),r=Yei(o,n.props);return n.type!==V.Fragment&&(r.ref=i?yf(i,s):s),V.cloneElement(n,r)}return V.Children.count(n)>1?V.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var Uei=Symbol("radix.slottable");function Hei(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Uei}function Yei(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function Jei(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 Bz="Dialog",[ihe,nhe]=aw(Bz),[Tei,Nw]=ihe(Bz),ohe=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=V.useRef(null),a=V.useRef(null),[g,c]=f_({prop:i,defaultProp:n??!1,onChange:o,caller:Bz});return W.jsx(Tei,{scope:A,triggerRef:r,contentRef:a,contentId:YE(),titleId:YE(),descriptionId:YE(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};ohe.displayName=Bz;var she="DialogTrigger",rhe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nw(she,e),o=NI(A,n.triggerRef);return W.jsx(Ag.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":XyA(n.open),...i,ref:o,onClick:Zn(t.onClick,n.onOpenToggle)})});rhe.displayName=she;var jyA="DialogPortal",[Pei,ahe]=ihe(jyA,{forceMount:void 0}),ghe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Nw(jyA,A);return W.jsx(Pei,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(H0,{present:e||o.open,children:W.jsx(N9,{asChild:!0,container:n,children:s})}))})};ghe.displayName=jyA;var Cz="DialogOverlay",che=V.forwardRef((t,A)=>{const e=ahe(Cz,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Nw(Cz,t.__scopeDialog);return o.modal?W.jsx(H0,{present:i||o.open,children:W.jsx(qei,{...n,ref:A})}):null});che.displayName=Cz;var Kei=Mei("DialogOverlay.RemoveScroll"),qei=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nw(Cz,e);return W.jsx(J9,{as:Kei,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(Ag.div,{"data-state":XyA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),DN="DialogContent",Ihe=V.forwardRef((t,A)=>{const e=ahe(DN,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Nw(DN,t.__scopeDialog);return W.jsx(H0,{present:i||o.open,children:o.modal?W.jsx(Oei,{...n,ref:A}):W.jsx(Wei,{...n,ref:A})})});Ihe.displayName=DN;var Oei=V.forwardRef((t,A)=>{const e=Nw(DN,t.__scopeDialog),i=V.useRef(null),n=NI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return pfA(o)},[]),W.jsx(lhe,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Zn(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Zn(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Zn(t.onFocusOutside,o=>o.preventDefault())})}),Wei=V.forwardRef((t,A)=>{const e=Nw(DN,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(lhe,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),lhe=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Nw(DN,e),a=V.useRef(null),g=NI(A,a);return efA(),W.jsxs(W.Fragment,{children:[W.jsx(p9,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(bJ,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":XyA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(Vei,{titleId:r.titleId}),W.jsx(zei,{contentRef:a,descriptionId:r.descriptionId})]})]})}),zyA="DialogTitle",Bhe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nw(zyA,e);return W.jsx(Ag.h2,{id:n.titleId,...i,ref:A})});Bhe.displayName=zyA;var Che="DialogDescription",Qhe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nw(Che,e);return W.jsx(Ag.p,{id:n.descriptionId,...i,ref:A})});Qhe.displayName=Che;var hhe="DialogClose",Ehe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nw(hhe,e);return W.jsx(Ag.button,{type:"button",...i,ref:A,onClick:Zn(t.onClick,()=>n.onOpenChange(!1))})});Ehe.displayName=hhe;function XyA(t){return t?"open":"closed"}var uhe="DialogTitleWarning",[Zei,dhe]=prt(uhe,{contentName:DN,titleName:zyA,docsSlug:"dialog"}),Vei=({titleId:t})=>{const A=dhe(uhe),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
|
|
5691
5691
|
|
|
5692
5692
|
If you want to hide the \`${A.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
5693
5693
|
|