tscircuit 0.0.1592-libonly → 0.0.1593-libonly

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.
@@ -5153,7 +5153,7 @@ ${a.join(`
5153
5153
  ${Q}polygon: ${C.polygon.vertices}
5154
5154
  `:a+=`
5155
5155
  `,C.children.length>0&&c.push(C.children)}return a}};A.exports=s}}),_4t=ae({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,A){var e=D4t(),i=b4t(),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}}),ndA=ae({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,A){A.exports={Tree:_4t()}}}),k4t=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,A){var e=ts(),i=idA(),{Tree:n}=ndA(),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}}),bie=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,A){var e=Fo(),i=g9(),n=k4t(),o=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),v4t=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,A){var e=Fo(),i=ts(),n=Cb(),o=edA(),s=tdA(),r=bie(),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}}),F4t=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,A){var e=Fo(),i=a9(),n=rs(),o=ts(),s=v4t(),r=bie(),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}}),odA=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,A){var e=er(),i=Mte(),n=o=>i(o,{skipTriangulation:!0}).map(a=>{const g=a.map(c=>o[c]);return e.create(g)});A.exports=n}}),_ie=ae({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,A){var e=ts(),i=idA(),{Tree:n}=ndA(),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}}),sdA=ae({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,A){var e=Fo(),i=g9(),n=_ie(),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}}),kie=ae({"node_modules/@jscad/modeling/src/operations/minkowski/minkowskiSum.js"(t,A){var e=Fo(),i=ts(),n=er(),o=odA(),s=sdA(),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,p=0,y=0;for(let F=0;F<u.length;F++)d+=u[F][0],p+=u[F][1],y+=u[F][2];d/=u.length,p/=u.length,y/=u.length;const w=n.plane(E),D=w[0],x=w[1],_=w[2],S=.1,N=[d-D*S,p-x*S,y-_*S];for(let F=1;F<u.length-1;F++){const L=u[0],Y=u[F],J=u[F+1],q=c(N,L,Y,J);Q.push(i.create(q))}}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 p=Q[d];for(let y=0;y<h.length;y++){const w=h[y];E.push([p[0]+w[0],p[1]+w[1],p[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 p=u[d],y=`${p[0]},${p[1]},${p[2]}`;C.has(y)||(C.add(y),Q.push(p))}}return Q};A.exports=r}}),M4t=ae({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,A){var e=bn(),i=Cb(),n=ts(),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,p)=>{d.vertices.forEach(y=>{s(B,e.snap(C,y,c),p)})});const Q=I.map(d=>{let p=[];return d.vertices.forEach(y=>{p=p.concat(r(B,e.snap(C,y,c)))}),{e:1,d:o(p)}});B.clear();let h=0;const E=Q.length;for(let d=0;d<E;d++){const p=Q[d];if(p.e>0){const y=new Array(l);y[d]=!0;do h=0,y.forEach((w,D)=>{const x=Q[D];if(x.e>0){x.e=-1;for(let _=0;_<x.d.length;_++)y[x.d[_]]=!0;h++}});while(h>0);p.indexes=y}}const u=[];for(let d=0;d<E;d++)if(Q[d].indexes){const p=[];Q[d].indexes.forEach((y,w)=>p.push(I[w])),u.push(n.create(p))}return u};A.exports=a}}),R4t=ae({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,A){var e=Fo(),i=ts(),n=M4t(),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}}),N4t=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,A){var e=ts(),i=idA(),{Tree:n}=ndA(),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}}),vie=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,A){var e=Fo(),i=g9(),n=N4t(),o=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),G4t=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,A){var e=Fo(),i=ts(),n=Cb(),o=edA(),s=tdA(),r=vie(),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}}),L4t=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,A){var e=Fo(),i=a9(),n=rs(),o=ts(),s=G4t(),r=vie(),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}}),Fie=ae({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,A){var e=Fo(),i=ts(),n=Cb(),o=edA(),s=tdA(),r=sdA(),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}}),rdA=ae({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,A){var e=Fo(),i=a9(),n=rs(),o=ts(),s=Fie(),r=sdA(),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}}),c9=ae({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,A){A.exports={intersect:F4t(),minkowski:kie(),scission:R4t(),subtract:L4t(),union:rdA()}}}),KO=ae({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,A){var{EPS:e,TAU:i}=Qr(),n=rie(),o=juA(),s=ks(),r=JO(),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 p=[],y=s.create(),w=c.length;for(let D=0;D<w;D++){const x=(D+1)%w,_=c[D],S=c[x];E?s.subtract(y,_,S):s.subtract(y,S,_),s.normal(y,y),s.normalize(y,y),s.scale(y,y,l);const N=s.add(s.create(),_,y),F=s.add(s.create(),S,y),L=[N,F];if(u!=null&&(C||!C&&x!==0)){const Y=n(u[0],u[1],L[0],L[1]);Y?(d.pop(),L[0]=Y):p.push({c:_,s0:u,s1:L})}u=[N,F],!(x===0&&!C)&&(d.push(L[0]),d.push(L[1]))}if(C&&u!=null){const D=d[0],x=d[1],_=n(u[0],u[1],D,x);if(_)d[0]=_,d.pop();else{const S=c[0],N=[D,x];p.push({c:S,s0:u,s1:N})}}if(B==="edge"){const D=new Map;d.forEach((S,N)=>D.set(S,N));const x=o.create(),_=o.create();p.forEach(S=>{o.fromPoints(x,S.s0[0],S.s0[1]),o.fromPoints(_,S.s1[0],S.s1[1]);const N=o.intersectPointOfLines(x,_);if(Number.isFinite(N[0])&&Number.isFinite(N[1])){const F=S.s0[1],L=D.get(F);d[L]=N,d[(L+1)%d.length]=void 0}else{const F=S.s1[0],L=D.get(F);d[L]=void 0}}),d=d.filter(S=>S!==void 0)}if(B==="round"){let D=Math.floor(Q/4);const x=s.create();p.forEach(_=>{let S=s.angle(s.subtract(x,_.s1[0],_.c));if(S-=s.angle(s.subtract(x,_.s0[1],_.c)),E&&S<0&&(S=S+Math.PI,S<0&&(S=S+Math.PI)),!E&&S>0&&(S=S-Math.PI,S>0&&(S=S-Math.PI)),S!==0){D=Math.floor(Q*(Math.abs(S)/i));const N=S/D,F=s.angle(s.subtract(x,_.s0[1],_.c)),L=[];for(let Y=1;Y<D;Y++){const J=F+N*Y,q=s.fromAngleRadians(s.create(),J);s.scale(q,q,l),s.add(q,q,_.c),L.push(q)}if(L.length>0){const Y=_.s0[1];let J=d.findIndex(q=>s.equals(Y,q));J=(J+1)%d.length,d.splice(J,0,...L)}}else{const N=_.s1[0],F=d.findIndex(L=>s.equals(N,L));d.splice(F,1)}})}return d};A.exports=a}}),U4t=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,A){var e=rs(),i=KO(),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}}),H4t=ae({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,A){var e=nc(),i=bn(),n=ts(),o=er(),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}}),Y4t=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,A){var{EPS:e,TAU:i}=Qr(),n=nc(),o=bn(),s=xie(),r=ts(),a=er(),g=die(),c=g9(),I=_ie(),l=H4t(),B=(E,u,d)=>{const p=u.toString();if(E.has(p))E.get(p)[1].push(d);else{const y=[u,[d]];E.set(p,y)}},C=(E,u,d)=>{const p=u[0].toString(),y=u[1].toString(),w=p<y?`${p},${y}`:`${y},${p}`;if(E.has(w))E.get(w)[1].push(d);else{const D=[u,[d]];E.set(w,D)}},Q=(E,u)=>{E.findIndex(p=>p===u)<0&&E.push(u)},h=(E,u)=>{const d={delta:1,segments:12},{delta:p,segments:y}=Object.assign({},d,E);let w=r.create();const D=new Map,x=new Map,_=o.create(),S=o.create();return r.toPolygons(u).forEach((F,L)=>{const Y=o.scale(o.create(),a.plane(F),2*p),J=a.transform(n.fromTranslation(n.create(),o.scale(o.create(),Y,-.5)),F),q=l(Y,J);w=I(w,q);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(x,gA,a.plane(F))}}),x.forEach(F=>{const L=F[0],Y=F[1],J=L[0],q=L[1],Z=o.subtract(o.create(),q,J);o.normalize(Z,Z);const X=Y[0],eA=o.cross(o.create(),X,Z);let gA=[];for(let LA=0;LA<y;LA++)Q(gA,LA*i/y);for(let LA=0,QA=Y.length;LA<QA;LA++){const kA=Y[LA],dA=o.dot(eA,kA),qA=o.dot(X,kA);let VA=Math.atan2(dA,qA);VA<0&&(VA+=i),Q(gA,VA),VA=Math.atan2(-dA,-qA),VA<0&&(VA+=i),Q(gA,VA)}gA=gA.sort(s);const tA=gA.length;let iA,sA;const aA=[],EA=[],SA=[];for(let LA=-1;LA<tA;LA++){const QA=gA[LA<0?LA+tA:LA],kA=Math.sin(QA),dA=Math.cos(QA);o.scale(_,X,dA*p),o.scale(S,eA,kA*p),o.add(_,_,S);const qA=o.add(o.create(),J,_),VA=o.add(o.create(),q,_);let ce=!1;if(LA>=0&&o.distance(qA,iA)<e&&(ce=!0),!ce){if(LA>=0){aA.push(qA),EA.push(VA);const fA=[sA,VA,qA,iA],ge=a.create(fA);SA.push(ge)}iA=qA,sA=VA}}EA.reverse(),SA.push(a.create(aA)),SA.push(a.create(EA));const _A=r.create(SA);w=I(w,_A)}),D.forEach(F=>{const L=F[0],Y=F[1],J=Y[0];let q=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,q=iA)}q||(q=o.orthogonal(_,J));const X=o.cross(_,J,q);o.normalize(X,X);const eA=o.cross(S,X,J),gA=g({center:[L[0],L[1],L[2]],radius:p,segments:y,axes:[J,X,eA]});w=I(w,gA)}),c(w)};A.exports=h}}),J4t=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,A){var e=ts(),i=rdA(),n=Y4t(),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}}),T4t=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,A){var e=JO(),i=ks(),n=rs(),o=Lg(),s=KO(),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 y=Math.PI/E,w=C[C.length-1],D=i.angle(i.subtract(i.create(),Q[Q.length-1],w)),x=C[0],_=i.angle(i.subtract(i.create(),h[0],x));for(let S=1;S<E;S++){let N=D+y*S,F=i.fromAngleRadians(i.create(),N);i.scale(F,F,B),i.add(F,F,w),u.push(F),N=_+y*S,F=i.fromAngleRadians(i.create(),N),i.scale(F,F,B),i.add(F,F,x),d.push(F)}}const p=[];return p.push(...Q,...u,...h.reverse(),...d),n.fromPoints(p)},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}}),adA=ae({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,A){var e=Fo(),i=rs(),n=ts(),o=Lg(),s=U4t(),r=J4t(),a=T4t(),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}}),P4t=ae({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,A){var e=rs(),i=quA(),n=KO(),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}}),K4t=ae({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,A){var e=Lg(),i=KO(),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}}),q4t=ae({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,A){var e=Fo(),i=rs(),n=Lg(),o=P4t(),s=K4t(),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}}),Mie=ae({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,A){A.exports={expand:adA(),offset:q4t()}}}),qO=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,A){var e=nc(),i=bn(),n=rs(),o=bF(),s=PO(),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=(p,y,w)=>{const D=y/B*l,x=i.scale(i.create(),Q,y/B);return e.multiply(u,e.fromZRotation(u,D),e.fromTranslation(e.create(),x)),o.transform(u,w)};return a={numberOfSlices:B+1,capStart:!0,capEnd:!0,repair:C,callback:d},s(a,E)};A.exports=r}}),O4t=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,A){var e=rs(),i=Lg(),n=qO(),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}}),W4t=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,A){var e=Fo(),i=rs(),n=Lg(),o=qO(),s=O4t(),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}}),Z4t=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,A){var e=Lg(),i=adA(),n=qO(),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}}),V4t=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,A){var{area:e}=n9(),i=rs(),n=Lg(),o=adA(),s=qO(),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}}),j4t=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,A){var e=Fo(),i=rs(),n=Lg(),o=Z4t(),s=V4t(),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}}),z4t=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,A){var{TAU:e}=Qr(),i=nc(),n=rs(),o=PO(),s=bF(),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(S=>S[0][0]>=0);let p=s.fromSides(u);d.length===0&&(p=s.reverse(p));const y=Math.round(h/e*Math.abs(I)),w=y>=2?y:2,D=i.create(),x=i.create(),_=(S,N,F)=>{const L=l+I/w*N,Y=Q/w*N,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(x,i.fromZRotation(i.create(),L),D),s.transform(x,F)};return o({numberOfSlices:w+1,callback:_},p)};A.exports=r}}),X4t=ae({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,A){var e=Fo(),i=VuA(),n=XD(),o=nc(),s=rs(),r=ts(),a=er(),g=Cb(),c=Fie(),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 y=0;y<u.length;y++){const w=u[y].vertices.map(_=>n.projectionOfPoint(Q,_)),D=a.create(w),x=a.plane(D);i(Q,x)&&(a.measureArea(D)<E||d.push(D))}if(!i(Q,[0,0,1])){const y=o.fromVectorRotation(o.create(),Q,[0,0,1]);d=d.map(w=>a.transform(y,w))}d=d.sort((y,w)=>a.measureArea(w)-a.measureArea(y));const p=d.map(y=>s.fromPoints(y.vertices));return c(p)},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}}),I9=ae({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,A){A.exports={extrudeFromSlices:PO(),extrudeLinear:W4t(),extrudeRectangular:j4t(),extrudeRotate:mie(),extrudeHelical:z4t(),project:X4t(),slice:bF()}}}),gdA=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,A){var e=ks(),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}}),cdA=ae({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,A){var e=rs(),i=ts(),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}}),$4t=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,A){var e=Fo(),i=Lg(),n=gdA(),o=cdA(),s=(...r)=>{r=e(r);const a=o(r),g=n(a);return i.fromPoints({closed:!0},g)};A.exports=s}}),A3t=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,A){var e=Fo(),i=rs(),n=gdA(),o=cdA(),s=(...r)=>{r=e(r);const a=o(r),g=n(a);return g.length<3?i.create():i.fromPoints(g)};A.exports=s}}),e3t=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,A){var e=Fo(),i=ts(),n=cdA(),o=odA(),s=(...r)=>{r=e(r);const a=n(r);return a.length===0?i.create():i.create(o(a))};A.exports=s}}),Rie=ae({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,A){var e=Fo(),i=a9(),n=rs(),o=ts(),s=Lg(),r=$4t(),a=A3t(),g=e3t(),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}}),t3t=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,A){var e=Fo(),i=rdA(),n=Rie(),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}}),i3t=ae({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,A){A.exports={hull:Rie(),hullChain:t3t(),hullPoints2:gdA(),hullPoints3:odA()}}}),n3t=ae({"node_modules/@jscad/modeling/src/operations/minkowski/index.js"(t,A){A.exports={minkowskiSum:kie()}}}),Nie=ae({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,A){var e=bn(),i=er(),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}}),o3t=ae({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,A){var e=VuA(),i=bn(),n=er(),o=E=>{const u=n.toPoints(E),d=[];for(let p=0;p<u.length;p++){const y=(p+1)%u.length,w={v1:u[p],v2:u[y]};d.push(w)}for(let p=0;p<d.length;p++){const y=(p+1)%u.length;d[p].next=d[y],d[y].prev=d[p]}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 p=E.prev.v1,y=E.prev.v2,w=u.next.v2;const D=l(p,y,w,d);p=u.prev.v1,y=u.prev.v2,w=E.next.v2;const x=l(p,y,w,d);return[D,x]},c=i.create(),I=i.create(),l=(E,u,d,p)=>{const y=i.subtract(c,u,E),w=i.subtract(I,d,u);return i.cross(y,y,w),i.dot(y,p)},B=E=>{let u;const d=[];for(;E.next;){const p=E.next;d.push(E.v1),E.v1=null,E.v2=null,E.next=null,E.prev=null,E=p}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(),p=new Map;for(;d.length>0;){const w=d.shift(),D=o(w);for(let x=0;x<D.length;x++){const _=D[x],S=a(p,_);if(S){const N=g(_,S,u);if(N[0]>=0&&N[1]>=0){const F=S.next,L=_.next;_.prev.next=S.next,_.next.prev=S.prev,S.prev.next=_.next,S.next.prev=_.prev,_.v1=null,_.v2=null,_.next=null,_.prev=null,r(p,S),S.v1=null,S.v2=null,S.next=null,S.prev=null;const Y=(J,q,Z)=>{const X={v1:Z.v1,v2:q.v2,next:q.next,prev:Z.prev};Z.prev.next=X,q.next.prev=X,r(J,q),q.v1=null,q.v2=null,q.next=null,q.prev=null,r(J,Z),Z.v1=null,Z.v2=null,Z.next=null,Z.prev=null};N[0]===0&&Y(p,F,F.prev),N[1]===0&&Y(p,L,L.prev)}}else _.next&&s(p,_)}}const y=[];return p.forEach(w=>{const D=B(w);D&&y.push(D)}),p.clear(),y},Q=(E,u)=>Math.abs(E[3]-u[3])<15e-8?e(E,u):!1,h=(E,u)=>{const d=[];u.forEach(y=>{const w=d.find(D=>Q(D[0],n.plane(y)));w?w[1].push(y):d.push([n.plane(y),[y]])});let p=[];return d.forEach(y=>{const w=y[1],D=C(w);p=p.concat(D)}),p};A.exports=h}}),s3t=ae({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,A){var e=Qr(),i=bn(),n=er(),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 p=0;p<d.length;p++){const y=d[p];let w=o(y.vertex0);if(w===Q&&(w=o(y.vertex1),w===h&&!(C!==null&&y.polygonindex!==C))){u=p;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),p=`${Q}/${d}`,y=`${d}/${Q}`;if(c.has(y)){const w=c.get(y);w.splice(-1,1),w.length===0&&c.delete(y)}else{const w={vertex0:C,vertex1:u,polygonindex:I};c.has(p)?c.get(p).push(w):c.set(p,[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 p=c.get(E)[0];for(let y=0;y<2;y++){const w=y===0?p.vertex0:p.vertex1,D=y===0?p.vertex1:p.vertex0,x=o(w),_=o(D);let S=[];y===0?l.has(x)&&(S=l.get(x)):I.has(x)&&(S=I.get(x));for(let N=0;N<S.length;N++){const F=S[N],L=c.get(F)[0],Y=y===0?L.vertex0:L.vertex1;if(y===0?L.vertex1:L.vertex0,o(Y)===_){r(c,I,l,w,D,null),r(c,I,l,D,w,null),u=!1,y=2,Q=!0;break}else{const q=w,Z=D,X=Y,eA=i.subtract(i.create(),X,q),gA=i.dot(i.subtract(i.create(),Z,q),eA)/i.dot(eA,eA);if(gA>0&&gA<1){const tA=i.scale(i.create(),eA,gA);if(i.add(tA,tA,q),i.squaredDistance(tA,Z)<e.EPS*e.EPS){const sA=L.polygonindex,aA=C[sA],EA=o(L.vertex1);let SA=-1;for(let dA=0;dA<aA.vertices.length;dA++)if(o(aA.vertices[dA])===EA){SA=dA;break}const _A=aA.vertices.slice(0);_A.splice(SA,0,D);const LA=n.create(_A);C[sA]=LA,r(c,I,l,L.vertex0,L.vertex1,sA);const QA=s(c,I,l,L.vertex0,D,sA),kA=s(c,I,l,D,L.vertex1,sA);QA!==null&&B.set(QA,!0),kA!==null&&B.set(kA,!0),u=!1,y=2,Q=!0;break}}}}}}u&&B.delete(E)}if(!Q)break}g=C}return c.clear(),g};A.exports=a}}),r3t=ae({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,A){var e=bn(),i=er(),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}}),a3t=ae({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,A){var e=Fo(),i=Cb(),n=rs(),o=ts(),s=Lg(),r=Nie(),a=o3t(),g=s3t(),c=r3t(),I=(Q,h)=>h,l=(Q,h)=>h,B=(Q,h)=>{const E={snap:!1,simplify:!1,triangulate:!1},{snap:u,simplify:d,triangulate:p}=Object.assign({},E,Q),y=i(h);let w=o.toPolygons(h);u&&(w=r(y,w)),d&&(w=a(y,w)),p&&(w=g(w),w=c(y,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}}),g3t=ae({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,A){var e=Fo(),i=ks(),n=rs(),o=ts(),s=Lg(),r=Cb(),a=Nie(),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}}),c3t=ae({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,A){A.exports={generalize:a3t(),snap:g3t(),retessellate:g9()}}}),I3t=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}}),l3t=ae({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,A){var e=Fo(),i=I3t(),n=zuA(),{translate:o}=t3(),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}}),OO=ae({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,A){var e=Fo(),i=rs(),n=ts(),o=Lg(),s=A3(),{translate:r}=t3(),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}}}),WO=ae({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,A){var e=Fo(),i=nc(),n=rs(),o=ts(),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}}}),B3t=ae({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,A){var e=Fo(),i=rs(),n=ts(),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}}),n3=ae({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,A){A.exports={align:l3t(),center:OO().center,centerX:OO().centerX,centerY:OO().centerY,centerZ:OO().centerZ,mirror:s9().mirror,mirrorX:s9().mirrorX,mirrorY:s9().mirrorY,mirrorZ:s9().mirrorZ,rotate:r9().rotate,rotateX:r9().rotateX,rotateY:r9().rotateY,rotateZ:r9().rotateZ,scale:WO().scale,scaleX:WO().scaleX,scaleY:WO().scaleY,scaleZ:WO().scaleZ,transform:B3t(),translate:t3().translate,translateX:t3().translateX,translateY:t3().translateY,translateZ:t3().translateZ}}}),ZO=ae({"node_modules/@jscad/modeling/src/index.js"(t,A){A.exports={colors:YO(),curves:r_t(),geometries:OuA(),maths:F_t(),measurements:Y_t(),primitives:i3(),text:u4t(),utils:Sie(),booleans:c9(),expansions:Mie(),extrusions:I9(),hulls:i3t(),minkowski:n3t(),modifiers:c3t(),transforms:n3()}}}),Gie=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)}`)}}}}),C3t=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":"")}}}),Q3t=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=C3t(),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 p=u,y=Number(new Date),w=y-(C||y);p.diff=w,p.prev=C,p.curr=y,C=y,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,(_,S)=>{if(_==="%%")return"%";D++;const N=o.formatters[S];if(typeof N=="function"){const F=d[D];_=N.call(p,F),d.splice(D,1),D--}return _}),o.formatArgs.call(p,d),(p.log||o.log).apply(p,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}}),h3t=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 GuA<"u"&&"env"in GuA&&(a=GuA.env.DEBUG),a}function s(){try{return localStorage}catch{}}A.exports=Q3t()(t);var{formatters:r}=A.exports;r.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}}}),Lie={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},Uie=V.createContext(void 0),E3t=({children:t})=>{const[A,e]=V.useState(Lie),i=V.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),n=V.useCallback(()=>{e(Lie)},[]),o=V.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:n}),[A,i,n]);return W.jsx(Uie.Provider,{value:o,children:t})},o3=()=>{const t=V.useContext(Uie);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},IdA=1.2;function Hie(t){return V.useMemo(()=>{if(!t)return IdA;try{return wn(t).pcb_board.list()[0]?.thickness??IdA}catch{return IdA}},[t])}var Yie=V.createContext(null),gd=()=>{const t=V.useContext(Yie);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},l9=(t,A=[])=>{const{addFrameListener:e,removeFrameListener:i}=gd();Qn.useEffect(()=>(e(t),()=>i(t)),[e,i,...A])},B9={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},Jie=({children:t,position:A,style:e})=>{const{camera:i,renderer:n}=gd(),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(dK.createPortal(t,o.current)),()=>{a.contains(o.current)&&a.removeChild(o.current)}},[n,t]),l9(()=>{if(!i||!o.current||!n)return;const a=new Me(...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=B9.htmlElements.toString(),e&&Object.assign(o.current.style,e)},[i,n,A,e]),s},Tie={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},cr=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 Tie)return e*Tie[A];throw new Error(`Unsupported unit: ${A}`)},Ol=cr,u3t=Object.defineProperty,d3t=(t,A)=>{for(var e in A)u3t(t,e,{get:A[e],enumerable:!0})},P2={};d3t(P2,{axial:()=>P5t,bga:()=>z3t,breakoutheaders:()=>tkt,cap:()=>x3t,dfn:()=>D5t,diode:()=>D3t,dip:()=>y3t,electrolytic:()=>KFt,hc49:()=>nkt,jst:()=>aFt,led:()=>S3t,lqfp:()=>Akt,m2host:()=>IMt,melf:()=>Evt,micromelf:()=>fvt,minimelf:()=>gvt,mlp:()=>s5t,mountedpcbmodule:()=>BMt,ms012:()=>v5t,ms013:()=>M5t,msop:()=>uFt,pad:()=>okt,pinrow:()=>S5t,platedhole:()=>tMt,potentiometer:()=>JFt,pushbutton:()=>Z5t,qfn:()=>i5t,qfp:()=>o5t,quad:()=>kF,radial:()=>O5t,res:()=>Z3t,sma:()=>Dvt,smb:()=>Mvt,smbf:()=>OFt,smc:()=>Lvt,smf:()=>_vt,smtpad:()=>AMt,sod110:()=>cFt,sod123:()=>H5t,sod123f:()=>Ykt,sod123fl:()=>Kkt,sod123w:()=>pkt,sod128:()=>Xkt,sod323:()=>wkt,sod323f:()=>Gkt,sod323fl:()=>wFt,sod323w:()=>pFt,sod523:()=>ckt,sod723:()=>Zkt,sod80:()=>hkt,sod882:()=>Fkt,sod882d:()=>Bvt,sod923:()=>bkt,soic:()=>$3t,solderjumper:()=>MFt,son:()=>bFt,sop8:()=>Ckt,sot:()=>nMt,sot223:()=>Jvt,sot23:()=>u5t,sot23w:()=>jvt,sot25:()=>y5t,sot323:()=>jFt,sot343:()=>rMt,sot363:()=>C5t,sot457:()=>GFt,sot563:()=>_5t,sot723:()=>N5t,sot886:()=>h5t,sot89:()=>nvt,sot963:()=>UFt,ssop:()=>g5t,stampboard:()=>j5t,stampreceiver:()=>$5t,to220:()=>sne,to220f:()=>rvt,to92:()=>akt,to92l:()=>QMt,to92s:()=>tFt,tqfp:()=>n5t,tssop:()=>l5t,vson:()=>kFt,vssop:()=>QFt});var Ui=(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"}),Ri=Ae({norefdes:YA().optional().describe("disable reference designator label"),invert:YA().optional().describe("hint to invert the orientation of the 3D model"),faceup:YA().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:YA().optional().describe("omit all silkscreen elements from the footprint")}),Mo=(t,A,e,i,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:cr(i),outer_diameter:cr(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),ym=t=>{const{pn:A,x:e,y:i,holeDiameter:n,rectPadWidth:o,rectPadHeight:s,holeOffsetX:r=0,holeOffsetY:a=0,rectBorderRadius:g}=t;return{pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:e,y:i,hole_diameter:cr(n),hole_shape:"circle",pad_shape:"rect",rect_pad_width:cr(o),rect_pad_height:cr(s),...g!==void 0&&{rect_border_radius:g},pcb_port_id:"",layers:["top","bottom"],port_hints:[A.toString()],hole_offset_x:r,hole_offset_y:a}},VO=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 Qb(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var jO=_t([U(),OA()]).transform(t=>Qb(t)),p3t=t=>Ri.extend({fn:U(),num_pins:OA().optional().default(6),wide:YA().optional(),narrow:YA().optional(),w:jO.optional(),p:jO.default(t.p??"2.54mm"),id:jO.optional(),od:jO.optional(),nosquareplating:YA().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=Qb("0.55mm"),A.od=Qb("0.95mm")):(A.id=Qb("0.8mm"),A.od=Qb("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=Qb("600mil"):A.narrow?A.w=Qb("300mil"):A.w=Qb(t.w??"300mil")),A)),f3t=p3t({}),Pie=(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}},y3t=t=>{const A=f3t.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:c,y:I}=Pie(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating);if(g===0&&!A.nosquareplating){e.push(ym({pn:g+1,x:c,y:I,holeDiameter:A.id??"0.8mm",rectPadWidth:A.od??"1mm",rectPadHeight:A.od??"1mm"}));continue}e.push(Mo(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},...VO.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}=Pie(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=Ui(0,o/2+.5,.4);return{circuitJson:[...e,s,a,...r],parameters:A}},li=(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()]}),Kie=[{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}],m3t=Object.fromEntries(Kie.map(t=>[t.metric,t])),w3t=Object.fromEntries(Kie.map(t=>[t.imperial,t]));Ri.extend({tht:YA(),p:IA.optional(),pw:IA.optional(),ph:IA.optional(),metric:se.optional(),imperial:se.optional(),w:IA.optional(),h:IA.optional(),textbottom:YA().optional()});var zO=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=Ol(r)),typeof a=="string"&&(a=Ol(a)),typeof e=="string"&&(e=Ol(e)),typeof i=="string"&&(i=Ol(i)),typeof n=="string"&&(n=Ol(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=m3t[o]),s&&(c=w3t[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=Ui(0,l,.2),C=.25,Q=I.route.map(w=>w.x),h=I.route.map(w=>w.y),E=Math.min(-(r??0)/2,-(e/2+i/2),...Q)-C,u=Math.max((r??0)/2,e/2+i/2,...Q)+C,d=Math.min(-(a??0)/2,-n/2,...h)-C,p=Math.max((a??0)/2,n/2,...h)+C,y={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(E+u)/2,y:(d+p)/2},width:u-E,height:p-d,layer:"top"};return A?[Mo(1,-e/2,0,i,i*1/.8),Mo(2,e/2,0,i,i*1/.8),I,B,y]:[li(["1","left"],-e/2,0,i,n),li(["2","right"],e/2,0,i,n),I,B,y]},D3t=t=>({circuitJson:zO(t),parameters:t}),x3t=t=>({circuitJson:zO(t),parameters:t}),S3t=t=>({circuitJson:zO(t),parameters:t}),_F=t=>{const{padSpacing:A,padWidth:e,padHeight:i,padPitch:n,numRows:o,textbottom:s}=t,r=[],a=(o-1)*(n/2);for(let x=0;x<o;x++)r.push(a-x*n);const g=[];r.forEach((x,_)=>{g.push(li(_+1,-A/2,x,e,i))}),r.slice().reverse().forEach((x,_)=>{g.push(li(_+o+1,A/2,x,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,p=E+i/2+.1,y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:[{x:d,y:p},{x:d-u,y:p},{x:d,y:p+u},{x:d,y:p}],stroke_width:.1},w=s?I-.9:c+.9,D=Ui(0,w,.2);return[...g,C,Q,y,D]},b3t=Ri.extend({pw:IA.default("0.5mm"),ph:IA.default("0.4mm"),p:IA.default("0.7mm"),textbottom:YA().optional(),convex:YA().optional(),concave:YA().optional()}),_3t=1,k3t=t=>{const A=b3t.parse(t);if(A.concave===!0)return[];const e=Ol(A.pw),i=Ol(A.ph),n=Ol(A.p);return _F({padSpacing:_3t,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},v3t=Ri.extend({pw:IA.default("0.5mm"),ph:IA.default("0.32mm"),p:IA.default("0.5mm"),textbottom:YA().optional(),convex:YA().optional(),concave:YA().optional()}),F3t=1,M3t=t=>{const A=v3t.parse(t),e=Ol(A.pw),i=Ol(A.ph),n=Ol(A.p);return _F({padSpacing:F3t,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},R3t=Ri.extend({pw:IA.default("0.9mm"),ph:IA.default("0.4mm"),p:IA.default("0.8mm"),textbottom:YA().optional(),convex:YA().optional(),concave:YA().optional()}),N3t=1.7,G3t=t=>{const A=R3t.parse(t),e=Ol(A.pw),i=Ol(A.ph),n=Ol(A.p);return _F({padSpacing:N3t,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},L3t=Ri.extend({pw:IA.default("0.9mm"),ph:IA.default("0.4mm"),p:IA.default("0.8mm"),textbottom:YA().optional(),convex:YA().optional(),concave:YA().optional()}),U3t=1.7,H3t=t=>{const A=L3t.parse(t),e=Ol(A.pw),i=Ol(A.ph),n=Ol(A.p);return _F({padSpacing:U3t,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},Y3t=Ri.extend({pw:IA.default("0.7mm"),ph:IA.default("0.64mm"),p:IA.default("0.94mm"),textbottom:YA().optional(),convex:YA().optional(),concave:YA().optional()}),J3t=1.4,T3t=t=>{const A=Y3t.parse(t),e=Ol(A.pw),i=Ol(A.ph),n=Ol(A.p);return _F({padSpacing:J3t,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},P3t=Ri.extend({pw:IA.default("0.9mm"),ph:IA.default("0.9mm"),p:IA.default("1.34mm"),textbottom:YA().optional(),convex:YA().optional(),concave:YA().optional()}),K3t=3,q3t=t=>{const A=P3t.parse(t),e=Ol(A.pw),i=Ol(A.ph),n=Ol(A.p);return _F({padSpacing:K3t,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},O3t=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)}},W3t=t=>t?(typeof t=="number"?`${t}`:t).split(/[_x]/)[0]:void 0,Z3t=t=>{const A=O3t(t),e=W3t(t.imperial);return A===2&&e==="0402"?{circuitJson:k3t(t),parameters:t}:A===4&&e==="0402"?{circuitJson:M3t(t),parameters:t}:A===2&&e==="0603"?{circuitJson:G3t(t),parameters:t}:A===4&&e==="0603"?{circuitJson:H3t(t),parameters:t}:A===2&&e==="0606"?{circuitJson:T3t(t),parameters:t}:A===4&&e==="1206"?{circuitJson:q3t(t),parameters:t}:{circuitJson:zO(t),parameters:t}},qie=(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()]}),Oie="ABCDEFGHIJKLMNOPQRSTUVWXYZ",XO=U().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A??""),y:parseFloat(e??"")}}).pipe(Ae({x:OA(),y:OA()})),V3t=U().or(xe(eI())).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(xe(U().or(OA()))),j3t=Ri.extend({fn:U(),num_pins:OA().optional().default(64),grid:XO.optional(),p:se.default("0.8mm"),w:IA.optional(),h:IA.optional(),ball:IA.optional().describe("ball diameter"),pad:IA.optional().describe("pad width/height"),circularpads:YA().optional().describe("use circular pads"),tlorigin:YA().optional(),blorigin:YA().optional(),trorigin:YA().optional(),brorigin:YA().optional(),missing:V3t.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=Oie.indexOf(n[1]),s=Number.parseInt(n[2])-1;return o*t.grid.x+s+1})),{...t,origin:A}}),z3t=t=>{const A=j3t.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(y=>typeof y=="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 y=Math.floor(Math.sqrt(l)),w=Math.floor((i.x-y)/2),D=Math.floor((i.y-y)/2);for(let x=D;x<D+y;x++)for(let _=w;_<w+y;_++)I.push(x*i.x+_+1)}g?.includes("topleft")&&I.push(1);const B=new Set(I);let C=0;for(let y=0;y<i.y;y++)for(let w=0;w<i.x;w++){const D=(w-(i.x-1)/2)*n,x=(y-(i.y-1)/2)*n;let _=w,S=y;switch(A.origin){case"bl":_=w,S=i.y-1-y;break;case"br":_=i.x-1-w,S=i.y-1-y;break;case"tr":_=i.x-1-w,S=y;break}let N=S*i.x+_+1;if(B.has(N)){C++;continue}N-=C;const F=[N,`${Oie[S]}${_+1}`];c.push(A.circularpads?qie(F,{x:D,y:x,radius:a/2}):li(F,D,x,a,a))}const Q=Ui(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 p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:E,stroke_width:.05};return{circuitJson:[...c,Q,p],parameters:A}},$O=(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()]}),s3=t=>Ri.extend({fn:U(),num_pins:OA().optional().default(8),w:IA.default(IA.parse(t.w??"5.3mm")),p:IA.default(IA.parse(t.p??"1.27mm")),pw:IA.default(IA.parse(t.pw??"0.6mm")),pl:IA.default(IA.parse(t.pl??"1.0mm")),legsoutside:YA().optional().default(t.legsoutside??!1),pillpads:YA().optional().default(t.pillpads??!1),silkscreen_stroke_width:OA().optional().default(.1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=IA.parse("0.6mm"),A.pl=IA.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),X3t=s3({}),ldA=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}},$3t=t=>{const A=X3t.parse(t);return{circuitJson:C9(A),parameters:A}},C9=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=ldA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push($O(r+1,a,g,t.pl,t.pw)):A.push(li(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=Ui(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},...VO.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]},Wie=Ve(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),A5t=({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},BdA=Ri.extend({fn:U(),cc:YA().default(!0).optional(),ccw:YA().default(!0).optional(),startingpin:U().or(xe(Wie)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(xe(Wie)).optional(),num_pins:OA().optional().default(64),w:IA.optional(),h:IA.optional(),p:IA.default(IA.parse("0.5mm")),pw:IA.optional(),pl:IA.optional(),thermalpad:_t([bA(!0),XO]).optional(),legsoutside:YA().default(!1)}),CdA=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},Zie=BdA.transform(CdA),e5t=["left","bottom","right","top"],t5t=t=>{const{pin_count:A,pn:e,w:i,h:n,p:o,pl:s,legsoutside:r}=t,a=A/4,g=e5t[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")}},kF=t=>{const A=Zie.parse(t),e=[],i=A5t(A),n=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:c}=t5t({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(li(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(li(["thermalpad"],0,0,r,a))}else e.push(li(["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=Ui(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...o,s],parameters:A}};BdA.extend({}).transform(CdA);var i5t=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),kF(t)),n5t=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 kF(t)},o5t=t=>{t.legsoutside=!0;const A=Zie.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 kF(t)};BdA.extend({}).transform(CdA);var s5t=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),kF(t)),r5t=Ri.extend({fn:U(),num_pins:OA().optional().default(8),w:IA.default(IA.parse("3.9mm")),p:IA.default(IA.parse("1.27mm")),pw:IA.optional(),pl:IA.optional(),legsoutside:YA().optional().default(!1),silkscreen_stroke_width:OA().optional().default(.1)}).transform(t=>(t.pw==null&&t.pl==null?(t.pw=IA.parse("0.51mm"),t.pl=IA.parse("1.1mm")):t.pw==null?t.pw=t.pl*(.51/1.1):t.pl==null&&(t.pl=t.pw*(1.1/.51)),t)),a5t=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+IA.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}},g5t=t=>{const A=r5t.parse(t),e=[];for(let a=0;a<A.num_pins;a++){const{x:g,y:c}=a5t({num_pins:A.num_pins,pn:a+1,w:A.w,p:A.p,pl:A.pl,legsoutside:A.legsoutside});e.push(li(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=Ui(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},...VO.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}},c5t=Ri.extend({fn:U(),num_pins:OA().optional().default(8),w:IA.default(IA.parse("3.0mm")),p:IA.default(IA.parse("0.5mm")),pw:IA.default(IA.parse("0.30mm")),pl:IA.default(IA.parse("1.45mm")),legsoutside:YA().optional().default(!0),silkscreen_stroke_width:OA().optional().default(.1)}),I5t=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}},l5t=t=>{const A={...t},e=A.p,i=typeof e=="string"||typeof e=="number"?IA.parse(e):void 0,n=i!=null&&i<=IA.parse("0.5mm"),o=c5t.parse(A),s=[],r=n?o.w-IA.parse("0.15mm"):o.w;for(let B=0;B<o.num_pins;B++){const{x:C,y:Q}=I5t({num_pins:o.num_pins,pn:B+1,w:r,p:o.p,pl:o.pl,legsoutside:o.legsoutside});s.push(li(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=Ui(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},...VO.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}},B5t=Ri.extend({fn:U(),num_pins:bA(6).default(6),w:U().default("3.1mm"),h:U().default("2.0mm"),p:U().default("0.65mm"),pl:U().default("1.03mm"),pw:U().default("0.35mm"),string:U().optional()}),C5t=t=>{const A=B5t.parse({...t,fn:"sot363"}),e=IA.parse(A.w),i=IA.parse(A.h),n=IA.parse(A.p),o=IA.parse(A.pl),s=IA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=Vie(B+1,e,n);r.push(li(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=Vie(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=Ui(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},Vie=(t,A,e,i)=>t<=3?{x:-.84,y:e-(t-1)*e}:{x:.84,y:-e+(t-4)*e},Q5t=Ri.extend({fn:U(),num_pins:bA(6).default(6),w:U().default("1.01mm"),h:U().default("1.45mm"),p:U().default("0.5mm"),pl:U().default("0.33mm"),pw:U().default("0.27mm"),string:U().optional()}),h5t=t=>{const A=Q5t.parse({...t,fn:"sot886"}),e=IA.parse(A.w),i=IA.parse(A.h),n=IA.parse(A.p),o=IA.parse(A.pl),s=IA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=jie(B+1,e,n,o);r.push(li(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=jie(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=Ui(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},jie=(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}},zie=Ri.extend({fn:U(),num_pins:OA().default(3),w:U().default("1.92mm"),h:U().default("2.74mm"),pl:U().default("1.32mm"),pw:U().default("0.6mm"),p:U().default("0.95mm"),string:U().optional()}),E5t=s3({p:"0.95mm",w:"1.6mm",legsoutside:!0}),u5t=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const n=E5t.parse({...t,num_pins:e});return{circuitJson:C9(n),parameters:n}}const i=zie.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:p5t(i),parameters:i};if(i.num_pins===5)return{circuitJson:$ie(i),parameters:i};throw new Error("Invalid number of pins")},d5t=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}},p5t=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:n,y:o}=d5t({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(li(i+1,n,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Ui(0,Number.parseInt(t.h),.3);return[...A,e]},Xie=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")},$ie=t=>{const A=[];for(let I=1;I<=t.num_pins;I++){const{x:l,y:B}=Xie({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:I});A.push(li(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=Ui(0,i+.3,.3),r=Xie({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]},f5t=zie.extend({}),y5t=t=>{const A=f5t.parse({...t,num_pins:5});return{circuitJson:$ie(A),parameters:A}},m5t=[{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}],w5t=s3({}),D5t=t=>{const A=w5t.parse(t),e=[];for(let I=0;I<A.num_pins;I++){const{x:l,y:B}=ldA({num_pins:A.num_pins,pn:I+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(li(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 m5t){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=Ui(0,o/2+.4,o/12);return{circuitJson:[...e,c,...s],parameters:A}},r3=({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 Ane({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 x5t=Ri.extend({fn:U(),num_pins:OA().optional().default(6),rows:_t([U(),OA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:IA.default("0.1in").describe("pitch"),id:IA.default("1.0mm").describe("inner diameter"),od:IA.default("1.5mm").describe("outer diameter"),male:YA().optional().describe("for male pin headers"),female:YA().optional().describe("for female pin headers"),smd:YA().optional().describe("surface mount device"),surfacemount:YA().optional().describe("surface mount device (verbose)"),rightangle:YA().optional().describe("right angle"),pw:IA.optional().default("1.0mm").describe("pad width for SMD"),pl:IA.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:YA().optional().default(!1),pinlabeltextaligncenter:YA().optional().default(!1),pinlabeltextalignright:YA().optional().default(!1),pinlabelverticallyinverted:YA().optional().default(!1),pinlabelorthogonal:YA().optional().default(!1),nosquareplating:YA().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:YA().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:YA().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:YA().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=Ane(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:Xt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),S5t=t=>{const A=x5t.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:x,yoff:_,od:S,anchorSide:N,smd:F,pw:L,pl:Y})=>{let J=0,q=0;if(F){const Z=S/5;switch(N){case"right":J=L/2+Z;break;case"top":q=Y/2+Z;break;case"bottom":q=-(Y/2+Z);break;case"left":J=-(L/2+Z);break}}else{const Z=S*.75;switch(N){case"right":J=Z;break;case"top":q=Z;break;case"bottom":q=-Z;break;case"left":J=-Z;break}}return{anchor_x:x+J,anchor_y:_+q}},p=(x,_,S)=>{A.smd?h.push(li(x,_,S,A.pw,A.pl)):x===1&&!A.nosquareplating?h.push(ym({pn:x,x:_,y:S,holeDiameter:i,rectPadWidth:n,rectPadHeight:n})):h.push(Mo(x,_,S,i,n));const{anchor_x:N,anchor_y:F}=d({xoff:_,yoff:S,od:n,anchorSide:r,smd:A.smd,pw:A.pw,pl:A.pl});l||(C?h.push(r3({fs:n/5,pn:x,anchor_x:N,anchor_y:F,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):h.push(r3({fs:n/5,pn:x,anchor_x:N,anchor_y:F,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),B&&h.push(r3({fs:n/5,pn:x,anchor_x:N,anchor_y:F,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},y=new Set,w=o>2&&E>2;if(o===1){const x=-((s-1)/2)*e;for(let _=0;_<s;_++){const S=_+1,N=x+_*e,F=`${N},0`;if(y.has(F))throw new Error(`Overlap at ${F}`);y.add(F),p(S,N,0)}}else if(w){const x=-((E-1)/2)*e;let _=1;for(let S=0;S<o&&_<=s;S++)for(let N=0;N<E&&_<=s;N++){const F=x+N*e,L=S*u,Y=`${F},${L}`;if(y.has(Y))throw new Error(`Overlap at ${Y}`);y.add(Y),p(_++,F,L)}}else{const x=-((E-1)/2)*e;let _=1,S=0,N=o-1,F=0,L=E-1;for(;_<=s&&S<=N&&F<=L;){for(let Y=S;Y<=N&&_<=s;Y++){const J=x+F*e,q=Y*u,Z=`${J},${q}`;if(y.has(Z))throw new Error(`Overlap at ${Z}`);y.add(Z),p(_++,J,q)}F++;for(let Y=F;Y<=L&&_<=s;Y++){const J=x+Y*e,q=N*u,Z=`${J},${q}`;if(y.has(Z))throw new Error(`Overlap at ${Z}`);y.add(Z),p(_++,J,q)}if(N--,F<=L){for(let Y=N;Y>=S&&_<=s;Y--){const J=x+L*e,q=Y*u,Z=`${J},${q}`;if(y.has(Z))throw new Error(`Overlap at ${Z}`);y.add(Z),p(_++,J,q)}L--}if(S<=N){for(let Y=L;Y>=F&&_<=s;Y--){const J=x+Y*e,q=S*u,Z=`${J},${q}`;if(y.has(Z))throw new Error(`Overlap at ${Z}`);y.add(Z),p(_++,J,q)}S++}}if(_-1<s)throw new Error(`Missing pins: assigned ${_-1}, expected ${s}`)}const D=Ui(0,e,.5);return{circuitJson:[...h,D],parameters:A}},b5t=Ri.extend({fn:U(),num_pins:bA(6).default(6),w:U().default("2.1mm"),h:U().default("2.45mm"),p:U().default("0.5mm"),pl:U().default("0.675mm"),pw:U().default("0.35mm"),string:U().optional()}),_5t=t=>{const A=b5t.parse({...t,fn:"sot563"}),e=IA.parse(A.w),i=IA.parse(A.h),n=IA.parse(A.p),o=IA.parse(A.pl),s=IA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=ene(B+1,e,n,o);r.push(li(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=ene(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=Ui(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},ene=(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}},k5t=s3({p:"1.27mm",w:"3.9mm",legsoutside:!0}),v5t=t=>{const A=k5t.parse({...t,num_pins:8});return{circuitJson:C9(A),parameters:A}},F5t=s3({p:"1.27mm",w:"7.5mm",legsoutside:!0}),M5t=t=>{const A=F5t.parse({...t,num_pins:16});return{circuitJson:C9(A),parameters:A}},R5t=Ri.extend({fn:U(),num_pins:bA(3).default(3),w:U().default("1.2mm"),h:U().default("1.2mm"),pw:U().default("0.40mm"),pl:U().default("0.45mm"),p:U().default("0.575mm")}),N5t=t=>{const A=R5t.parse(t),e=L5t(A),i=Ui(0,IA.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},G5t=t=>{const{pn:A,p:e}=t;return A===1?{x:e,y:0}:A===2?{x:-e,y:-.4}:{x:-e,y:.4}},L5t=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:n}=G5t({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(li(e+1,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},U5t=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("2.36mm"),h:U().default("1.22mm"),pl:U().default("0.9mm"),pw:U().default("1.2mm"),p:U().default("3.30mm")}),H5t=t=>{const A=U5t.parse(t),e=Ui(0,IA.parse(A.h)/4+.4,.3);return{circuitJson:J5t(A).concat(e),parameters:A}},Y5t=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},J5t=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Y5t({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},T5t=Ri.extend({fn:U(),p:IA.optional().default("2.54mm"),id:IA.optional().default("0.7mm"),od:IA.optional().default("1.4mm")}),P5t=t=>{const A=T5t.parse(t),{p:e,id:i,od:n}=A,o=[Mo(1,-e/2,0,i,n),Mo(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=Ui(0,1.5,.5);return{circuitJson:[...o,s,r],parameters:A}},K5t=(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}},q5t=Ri.extend({fn:U(),p:IA.optional().default("5mm"),id:IA.optional().default("0.8mm"),od:IA.optional().default("1.6mm"),ceramic:YA().optional(),electrolytic:YA().optional(),polarized:YA().optional()}),O5t=t=>{const A=q5t.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=[Mo(1,-e/2,0,A.id,A.od),Mo(2,e/2,0,A.id,A.od)],s=e+.1,{topArc:r,bottomArc:a}=K5t(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=Ui(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}},a3=(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}),W5t=Ri.extend({fn:bA("pushbutton"),w:IA.default(4.5),h:IA.default(6.5),id:IA.default(1),od:IA.default(1.2)}),Z5t=t=>{const A=W5t.parse(t),e=A.w,i=A.h,n=A.id,o=[Mo(1,-e/2,i/2,n,n*1.5),Mo(2,-e/2,-i/2,n,n*1.5),Mo(3,e/2,-i/2,n,n*1.5),Mo(4,e/2,i/2,n,n*1.5)],s=[a3([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),a3([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),a3([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),a3([{x:e/2,y:0},{x:e/5,y:0}])],r=Ui(0,i/2+.4,.5);return{circuitJson:[...o,...s,r],parameters:A}},tne=Ri.extend({fn:U(),w:IA.default("22.58mm"),h:IA.optional(),left:IA.optional().default(20),right:IA.optional().default(20),top:IA.optional().default(2),bottom:IA.optional().default(2),p:IA.default(IA.parse("2.54mm")),pw:IA.default(IA.parse("1.6mm")),pl:IA.default(IA.parse("2.4mm")),innerhole:YA().default(!1),innerholeedgedistance:IA.default(IA.parse("1.61mm")),silkscreenlabels:YA().default(!1),silkscreenlabelmargin:IA.default(IA.parse("0.1mm"))}),V5t=t=>{const A=tne.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},AW=(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},j5t=t=>{const A=tne.parse(t),e=A.h??V5t(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=AW(A.w/2-A.pl*1.4,Q+h*A.p,"right")),i.push(li(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(Mo(h+1+A.left+(A.bottom??0)+g,A.w/2,Q+h*A.p,r,a)),n.push(Mo(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=AW(-A.w/2+A.pl*1.4,Q-h*A.p,"left")),i.push(li(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(Mo(h+1+g,-A.w/2,Q-h*A.p,r,a)),n.push(Mo(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=AW(Q-h*A.p,e/2-A.pl*1.4,"top")),i.push(li(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(Mo(h+1+A.left+A.right+(A.bottom??0)+g,Q-h*A.p,e/2,r,a)),n.push(Mo(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=AW(Q+h*A.p,-e/2+A.pl*1.4,"bottom")),i.push(li(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(Mo(h+1+A.left+g,Q+h*A.p,-e/2,r,a)),n.push(Mo(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=Ui(0,e/1.8,e/25);return{circuitJson:[...i,...n,...o,B,...A.silkscreenlabels?[]:[l],C],parameters:A}},ine=Ri.extend({fn:U(),w:IA.default("22.58mm"),h:IA.optional(),left:IA.optional().default(20),right:IA.optional().default(20),top:IA.optional().default(2),bottom:IA.optional().default(2),p:IA.default(IA.parse("2.54mm")),pw:IA.default(IA.parse("1.6mm")),pl:IA.default(IA.parse("3.2mm")),innerhole:YA().default(!1),innerholeedgedistance:IA.default(IA.parse("1.61mm"))}),z5t=t=>{const A=ine.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},X5t=(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]},$5t=t=>{const A=ine.parse(t),e=A.h??z5t(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=X5t(-A.w/2-A.pl/2,C-Q*A.p,"left")),i.push(li(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(Mo(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(li(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(Mo(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(li(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(Mo(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(li(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(Mo(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=Ui(0,e/1.8,e/25);return{circuitJson:[...o,...i,...n,l,I,B],parameters:A}},Akt=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),kF(t)),nne=Ri.extend({fn:U(),w:IA.default("10mm"),h:IA.optional(),left:IA.optional().default(20),right:IA.optional().default(20),top:IA.optional().default(0),bottom:IA.optional().default(0),p:IA.default(IA.parse("2.54mm")),id:IA.optional().default(IA.parse("1mm")),od:IA.optional().default(IA.parse("1.5mm"))}),ekt=t=>{const A=nne.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},eW=(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]},tkt=t=>{const A=nne.parse(t),e=A.h??ekt(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=eW(A.w/2+o*1.4,c+I*A.p,"right")),i.push(Mo(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=eW(-A.w/2-o*1.4,c+I*A.p,"left")),i.push(Mo(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=eW(c+I*A.p,e/2+o*1.4,"top")),i.push(Mo(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=eW(c+I*A.p,-e/2-o*1.4,"bottom")),i.push(Mo(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=Ui(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},one=(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}}),ikt=Ri.extend({fn:U(),p:IA.optional().default("4.88mm"),id:IA.optional().default("0.8mm"),od:IA.optional().default("1.5mm"),w:IA.optional().default("5.6mm"),h:IA.optional().default("3.5mm")}),nkt=t=>{const A=ikt.parse(t),{p:e,id:i,od:n,w:o,h:s}=A,r=s/2,a=[Mo(1,-e/2,0,i,n),Mo(2,e/2,0,i,n)],g=one(-o/2,0,r,"left"),c=one(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=Ui(0,e/4,.5);return{circuitJson:[...a,I,l],parameters:A}};Ri.extend({w:IA,h:IA});var okt=t=>{const{w:A,h:e}=t,i=cr(A),n=cr(e);return{circuitJson:[li(1,0,0,i,n),Ui(0,n/2+.5,.2)],parameters:t}},g3=(t,A,e,i,n,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:A,y:e,outer_width:cr(n),outer_height:cr(o),hole_width:cr(i),hole_height:cr(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),skt=Ri.extend({fn:U(),num_pins:_t([bA(3),bA(2)]).default(3),p:U().default("1.27mm"),id:U().default("0.72mm"),od:U().default("0.95mm"),w:U().default("4.5mm"),h:U().default("4.5mm"),inline:YA().default(!1),string:U().optional()}),rkt=(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}}),akt=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=skt.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=[ym({pn:1,x:-I,y:c-I,holeDiameter:l,rectPadWidth:B,rectPadHeight:Q}),g3(2,0,c-I,l,C,Q),g3(3,I,c-I,l,C,Q)]:h=[ym({pn:1,x:-I,y:c-I,holeDiameter:l,rectPadWidth:B,rectPadHeight:B}),Mo(2,0,c,l,B),Mo(3,I,c-I,l,B)];else if(i.num_pins===2)h=[ym({pn:1,x:-I,y:c-I,holeDiameter:l,rectPadWidth:C,rectPadHeight:Q}),g3(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=rkt(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:""},p=Ui(0,c+1,.5);return{circuitJson:[...h,d,p],parameters:i}},gkt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("2.15mm"),h:U().default("1.20mm"),pl:U().default("0.5mm"),pw:U().default("0.6mm"),p:U().default("1.4mm")}),ckt=t=>{const A=gkt.parse(t),e=Ui(0,IA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:lkt(A).concat(i,e),parameters:A}},Ikt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},lkt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Ikt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Bkt=s3({w:"7.05mm",p:"1.27mm",pw:"0.65mm",pl:"1.975mm"}),Ckt=t=>{const A=Bkt.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=ldA({num_pins:A.num_pins,pn:s+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(li(s+1,r,a,A.pl??"1.5mm",A.pw??"0.6mm"))}const i=(A.num_pins/2-1)*A.p+A.pw,n=Ui(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}},Qkt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("5.0mm"),h:U().default("2.30mm"),pl:U().default("1.25mm"),pw:U().default("2mm"),p:U().default("3.75mm")}),hkt=t=>{const A=Qkt.parse(t),e=Ui(0,IA.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2+.5,y:IA.parse(A.h)/2+.5},{x:-IA.parse(A.w)/2-.5,y:IA.parse(A.h)/2+.5},{x:-IA.parse(A.w)/2-.5,y:-IA.parse(A.h)/2-.5},{x:IA.parse(A.p)/2+.5,y:-IA.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ukt(A).concat(i,e),parameters:A}},Ekt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},ukt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Ekt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},dkt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("4.4mm"),h:U().default("2.1mm"),pl:U().default("1.2mm"),pw:U().default("1.2mm"),p:U().default("2.9mm")}),pkt=t=>{const A=dkt.parse(t),e=Ui(0,IA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ykt(A).concat(i,e),parameters:A}},fkt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},ykt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=fkt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},mkt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("3.30mm"),h:U().default("1.80mm"),pl:U().default("0.60mm"),pw:U().default("0.45mm"),p:U().default("2.1mm")}),wkt=t=>{const A=mkt.parse(t),e=Ui(0,IA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:xkt(A).concat(i,e),parameters:A}},Dkt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},xkt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Dkt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Skt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("1.4mm"),h:U().default("0.9mm"),pl:U().default("0.36mm"),pw:U().default("0.25mm"),p:U().default("0.85mm")}),bkt=t=>{const A=Skt.parse(t),e=Ui(0,IA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2+.15,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.15,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.15,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2+.15,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:kkt(A).concat(i,e),parameters:A}},_kt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},kkt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=_kt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},vkt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("1.3mm"),h:U().default("0.9mm"),pl:U().default("0.4mm"),pw:U().default("0.7mm"),p:U().default("0.7mm")}),Fkt=t=>{const A=vkt.parse(t),e=Ui(0,IA.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2+.2,y:IA.parse(A.h)/2+.2},{x:-IA.parse(A.w)/2-.2,y:IA.parse(A.h)/2+.2},{x:-IA.parse(A.w)/2-.2,y:-IA.parse(A.h)/2-.2},{x:IA.parse(A.p)/2+.2,y:-IA.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Rkt(A).concat(i,e),parameters:A}},Mkt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Rkt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Mkt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Nkt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("3,05mm"),h:U().default("1.65mm"),pl:U().default("0.6mm"),pw:U().default("0.6mm"),pad_spacing:U().default("2.2mm")}),Gkt=t=>{const A=Nkt.parse(t),e=Ui(0,IA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.pad_spacing)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:-IA.parse(A.h)/2},{x:IA.parse(A.pad_spacing)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Ukt(A).concat(i,e),parameters:A}},Lkt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Ukt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Lkt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Hkt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("4.4mm"),h:U().default("2.1mm"),pl:U().default("1.10mm"),pw:U().default("1.10mm"),p:U().default("2.8mm")}),Ykt=t=>{const A=Hkt.parse(t),e=Ui(0,IA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Tkt(A).concat(i,e),parameters:A}},Jkt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Tkt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Jkt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Pkt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("4.4mm"),h:U().default("2.1mm"),pl:U().default("0.91mm"),pw:U().default("1.22mm"),p:U().default("3.146mm")}),Kkt=t=>{const A=Pkt.parse(t),e=Ui(0,IA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Okt(A).concat(i,e),parameters:A}},qkt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Okt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=qkt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Wkt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("1.80mm"),h:U().default("1.00mm"),pl:U().default("0.66mm"),pw:U().default("0.5mm"),p:U().default("0.8mm")}),Zkt=t=>{const A=Wkt.parse(t),e=Ui(0,IA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.1,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.1,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:jkt(A).concat(i,e),parameters:A}},Vkt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},jkt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Vkt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},zkt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("6.2mm"),h:U().default("3.4mm"),pl:U().default("1.4mm"),pw:U().default("2.1mm"),p:U().default("4.4mm")}),Xkt=t=>{const A=zkt.parse(t),e=Ui(0,IA.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Avt(A).concat(i,e),parameters:A}},$kt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Avt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=$kt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},evt=Ri.extend({fn:U(),num_pins:_t([bA(3),bA(5)]).default(3),w:U().default("4.20mm"),h:U().default("4.80mm"),pl:U().default("1.3mm"),pw:U().default("0.9mm"),p:U().default("1.5mm"),string:U().optional()}),tvt=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(li(1,-n/2+r,e,o,i),li(2,-n/2,0,o+s,i),li(3,-n/2+r,-e,o,i));const a=Ui(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]},ivt=t=>{const A=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),A.push(li(1,-1.85,-1.5,1.5,.7),li(2,-1.85,1.5,1.5,.7),li(3,0,0,.8,2),li(4,1.85,-1.5,1.5,.7),li(5,1.85,1.5,1.5,.7));const e=Ui(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]},nvt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=evt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:tvt(i),parameters:i};if(i.num_pins===5)return{circuitJson:ivt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},ovt=Ri.extend({fn:U(),p:IA.optional().default("5.0mm"),id:IA.optional().default("1.0mm"),od:IA.optional().default("1.9mm"),w:IA.optional().default("13mm"),h:IA.optional().default("7mm"),num_pins:OA().optional(),string:U().optional()}),sne=t=>{const A=ovt.parse(t),{id:e,od:i,w:n,h:o,string:s}=A,r=A.num_pins??Number.parseInt(s?.match(/^to220(?:_|-)(\d+)/i)?.[1]??"3"),a=-1,g=n/2,c=o/2,I=2.5,l=n*.4,B=Math.max(I,l/(r-1)),C=Array.from({length:r},(p,y)=>{const w=r%2===0?(y-r/2+.5)*B:(y-Math.floor(r/2))*B;return Mo(y+1,w,a,e,i)}),Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g,y:-c},{x:g,y:-c},{x:g,y:c},{x:-g,y:c},{x:-g,y:-c}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-c+2*o/3,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g,y:h},{x:g,y:h}],stroke_width:.1,pcb_silkscreen_path_id:""},u=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/6,y:h},{x:-n/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:n/6,y:h},{x:n/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""}],d=Ui(0,o/2+.6,.5);return{circuitJson:[...C,Q,E,...u,d],parameters:{...A,p:B}}},QdA=2.54,svt=Ri.extend({fn:U(),id:IA.optional().default("1.2mm"),od:IA.optional().default("1.905mm"),ph:IA.optional().default("2mm"),w:IA.optional().default("13mm"),h:IA.optional().default("7mm"),num_pins:OA().optional(),string:U().optional()}),rvt=t=>{const A=svt.parse(t),e=A.num_pins??Number.parseInt(A.string?.match(/^to220f(?:_|-)(\d+)/i)?.[1]??"3"),i=sne({...A,fn:"to220",string:A.string?.replace(/^to220f/i,"to220"),num_pins:e}),n=-1,o=Array.from({length:e},(r,a)=>{const g=e%2===0?(a-e/2+.5)*QdA:(a-Math.floor(e/2))*QdA;return a===0?ym({pn:1,x:g,y:n,holeDiameter:A.id,rectPadWidth:A.od,rectPadHeight:A.ph}):g3(a+1,g,n,cr(A.id),cr(A.od),cr(A.ph))}),s=i.circuitJson.filter(r=>r.type!=="pcb_plated_hole");return{circuitJson:[...o,...s],parameters:{...A,p:QdA,num_pins:e}}},avt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("5.40mm"),h:U().default("2.30mm"),pl:U().default("1.30mm"),pw:U().default("1.70mm"),p:U().default("3.5mm")}),gvt=t=>{const A=avt.parse(t),e=Ui(0,IA.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Ivt(A).concat(i,e),parameters:A}},cvt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Ivt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=cvt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},lvt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("1.90mm"),h:U().default("1.33mm"),pl:U().default("0.5mm"),pw:U().default("0.7mm"),p:U().default("0.8mm")}),Bvt=t=>{const A=lvt.parse(t),e=Ui(0,IA.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2+.1,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2+.1,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Qvt(A).concat(i,e),parameters:A}},Cvt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Qvt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Cvt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},hvt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("7.0mm"),h:U().default("3.35mm"),pl:U().default("1.50mm"),pw:U().default("2.70mm"),p:U().default("4.8mm")}),Evt=t=>{const A=hvt.parse(t),e=Ui(0,IA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:dvt(A).concat(i,e),parameters:A}},uvt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},dvt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=uvt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},pvt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("3.0mm"),h:U().default("1.80mm"),pl:U().default("0.80mm"),pw:U().default("1.20mm"),p:U().default("1.6mm")}),fvt=t=>{const A=pvt.parse(t),e=Ui(0,IA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.1,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.1,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:mvt(A).concat(i,e),parameters:A}},yvt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},mvt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=yvt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},wvt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("7.10mm"),h:U().default("3.40mm"),pl:U().default("2.45mm"),pw:U().default("1.80mm"),p:U().default("4.05mm")}),Dvt=t=>{const A=wvt.parse(t),e=Ui(0,IA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.5,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.5,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Svt(A).concat(i,e),parameters:A}},xvt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Svt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=xvt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},bvt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("4.80mm"),h:U().default("2.10mm"),pl:U().default("1.30mm"),pw:U().default("1.40mm"),p:U().default("2.9mm")}),_vt=t=>{const A=bvt.parse(t),e=Ui(0,IA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:vvt(A).concat(i,e),parameters:A}},kvt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},vvt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=kvt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Fvt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("7.30mm"),h:U().default("4.40mm"),pl:U().default("2.50mm"),pw:U().default("2.30mm"),p:U().default("4.30mm")}),Mvt=t=>{const A=Fvt.parse(t),e=Ui(0,IA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.1,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.1,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Nvt(A).concat(i,e),parameters:A}},Rvt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Nvt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Rvt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Gvt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("10.70mm"),h:U().default("6.60mm"),pl:U().default("3.30mm"),pw:U().default("2.50mm"),p:U().default("6.80mm")}),Lvt=t=>{const A=Gvt.parse(t),e=Ui(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2-.8},{x:-IA.parse(A.w)/2-.8,y:IA.parse(A.h)/2-.8},{x:-IA.parse(A.w)/2-.8,y:-IA.parse(A.h)/2+.8},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Hvt(A).concat(i,e),parameters:A}},Uvt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Hvt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Uvt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Yvt=Ri.extend({fn:U(),num_pins:OA().default(4),w:U().default("8.50mm"),h:U().default("6.90mm"),pl:U().default("2mm"),pw:U().default("1.5mm"),p:U().default("2.30mm"),string:U().optional()}),Jvt=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const n=Kvt.parse({...t,num_pins:e});return{circuitJson:C9(n),parameters:n}}const i=Yvt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:Pvt(i),parameters:i};if(i.num_pins===5)return{circuitJson:Ovt(i),parameters:i};if(i.num_pins===6)return{circuitJson:Zvt(i),parameters:i};throw new Error("Invalid number of pins")},Tvt=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}},Pvt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=Tvt({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(li(r+1,a,g,Number.parseFloat(t.pl),c))}const e=Ui(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]},Kvt=s3({p:"0.90mm",w:"2.8mm",legsoutside:!0}),qvt=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")},Ovt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=qvt({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(li(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=Ui(0,0,.3);return[...A,n,o,s]},Wvt=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")},Zvt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=Wvt({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(li(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=Ui(0,0,.3);return[...A,n,o,s]},Vvt=Ri.extend({fn:U(),num_pins:OA().default(3),w:U().default("3.40mm"),h:U().default("3.30mm"),pl:U().default("1mm"),pw:U().default("0.7mm"),p:U().default("1.2mm"),string:U().optional()}),jvt=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=Vvt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:Xvt(i),parameters:i};throw new Error("Invalid number of pins")},zvt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},Xvt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=zvt({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(li(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Ui(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]},$vt=Ri.extend({fn:U(),num_pins:_t([bA(3),bA(2)]).default(3),p:U().default("1.27mm"),id:U().default("0.72mm"),od:U().default("0.95mm"),w:U().default("2.5mm"),h:U().default("4.2mm"),string:U().optional()}),AFt=t=>{const{p:A,id:e,od:i,w:n,h:o}=t,s=Number.parseFloat(o)/2,r=Number.parseFloat(A);return[Mo(1,-r,s-r,e,i),Mo(2,0,s-r,e,i),Mo(3,r,s-r,e,i)]},eFt=t=>{const{p:A,id:e,od:i,h:n}=t,o=Number.parseFloat(n)/2,s=Number.parseFloat(A);return[Mo(1,-s,o-s,e,i),Mo(2,s,o-s,e,i)]},tFt=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=$vt.parse({...t,num_pins:e});let n=[];if(i.num_pins===3)n=AFt(i);else if(i.num_pins===2)n=eFt(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=Ui(0,o+1,.5);return{circuitJson:[...n,r,a],parameters:i}},iFt=Ri.extend({fn:U(),p:IA.optional(),id:IA.optional(),pw:IA.optional(),pl:IA.optional(),w:IA.optional(),h:IA.optional(),sh:YA().optional().describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:YA().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),zh:YA().optional().describe("JST ZH (Through-hole) connector family. 1.5mm pitch wire-to-board."),string:U().optional()}),nFt={ph:{p:IA.parse("2.2mm"),id:IA.parse("0.70mm"),pw:IA.parse("1.20mm"),pl:IA.parse("1.20mm"),w:IA.parse("6mm"),h:IA.parse("5mm")},sh:{p:IA.parse("1mm"),pw:IA.parse("0.6mm"),pl:IA.parse("1.55mm"),w:IA.parse("5.8mm"),h:IA.parse("7.8mm")},zh:{p:IA.parse("1.5mm"),id:IA.parse("0.73mm"),pw:IA.parse("1.03mm"),pl:IA.parse("1.73mm"),w:IA.parse("3mm"),h:IA.parse("3.5mm")}};function oFt(t){return t.sh?"sh":t.ph?"ph":t.zh?"zh":"ph"}function sFt(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(ym({pn:a+1,x:g,y:2,holeDiameter:i,rectPadWidth:n,rectPadHeight:o}))}}else if(t==="zh"){const r=-((A-1)/2)*e;for(let a=0;a<A;a++){const g=r+a*e;a===0?s.push(ym({pn:a+1,x:g,y:0,holeDiameter:i,rectPadWidth:n,rectPadHeight:o,rectBorderRadius:.12499977})):s.push(g3(a+1,g,0,i,n,o))}}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const c=r+g*e;s.push(li(g+1,c,-1.325,n,o))}const a=(A-1)/2*e+1.3;s.push(li(A+1,-a,1.22,1.2,1.8)),s.push(li(A+2,a,1.22,1.2,1.8))}return s}function rFt(t,A,e,i,n){if(t==="ph")return{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:""};if(t==="zh"&&i&&n){const o=(i-1)*n,s=-o/2-1.5,r=o/2+1.5,a=-e/2,g=e/2;return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:a},{x:r,y:a},{x:r,y:g},{x:s,y:g},{x:s,y:a}],stroke_width:.1,pcb_silkscreen_path_id:""}}else return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[],stroke_width:.1,pcb_silkscreen_path_id:""}}var aFt=t=>{const A=iFt.parse(t),e=oFt(A),i=nFt[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 l=typeof t.string=="string"?t.string:"",B=l.match(/(?:^|_)jst(\d+)(?:_|$)/),C=l.match(/(?:^|_)zh(\d+)(?:_|$)/);if(B&&B[1]){const u=Number.parseInt(B[1],10);Number.isNaN(u)||(c=u)}if(C&&C[1]){const u=Number.parseInt(C[1],10);Number.isNaN(u)||(c=u)}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 Q=sFt(e,c,n,o,s,r),h=rFt(e,a,g,c,n),E=Ui(0,g/2+1,.5);return{circuitJson:[...Q,h,E],parameters:{...A,p:n,id:o,pw:s,pl:r,w:a,h:g,num_pins:c,sh:e==="sh",ph:e==="ph",zh:e==="zh"}}},gFt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("3.30mm"),h:U().default("1.70mm"),pl:U().default("0.80mm"),pw:U().default("1mm"),p:U().default("1.90mm")}),cFt=t=>{const A=gFt.parse(t),e=Ui(0,IA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:lFt(A).concat(i,e),parameters:A}},IFt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},lFt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=IFt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},BFt=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"}}},CFt=Ri.extend({fn:U(),num_pins:_t([bA(8),bA(10)]).default(8),w:U().optional(),h:U().optional(),p:U().optional(),pl:U().optional(),pw:U().optional(),string:U().optional()}),QFt=t=>{const A=CFt.parse(t),e=BFt(A.num_pins),i=IA.parse(A.w||e.w),n=IA.parse(A.h||e.h),o=IA.parse(A.p||e.p),s=IA.parse(A.pl||e.pl),r=IA.parse(A.pw||e.pw),a=[],g=A.num_pins/2;for(let u=0;u<A.num_pins;u++){const{x:d,y:p}=rne(A.num_pins,u+1,i,o),y=u<g?u+1:A.num_pins-(u-g);a.push(li(y,d,p,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=rne(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=Ui(0,I/2+.5,.3);return{circuitJson:[...a,l,B,E,h],parameters:A}},rne=(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*IA.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},hFt=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"}}},EFt=Ri.extend({fn:U(),num_pins:_t([bA(8),bA(10),bA(12),bA(16)]).default(8),w:U().optional(),h:U().optional(),p:U().optional(),pl:U().optional(),pw:U().optional(),string:U().optional()}),ane=(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*IA.parse("2mm"),y:r*i}},uFt=t=>{const A=EFt.parse(t),e=hFt(A.num_pins),i=IA.parse(A.w||e.w),n=IA.parse(A.h||e.h),o=IA.parse(A.p||e.p),s=IA.parse(A.pl||e.pl),r=IA.parse(A.pw||e.pw),a=[];for(let E=0;E<A.num_pins;E++){const{x:u,y:d}=ane(A.num_pins,E+1,i,o);a.push(li(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=ane(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=Ui(0,c/2+.5,.3);return{circuitJson:[...a,I,l,h,Q],parameters:A}},dFt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("3.8mm"),h:U().default("1.65mm"),pl:U().default("1.2mm"),pw:U().default("1.2mm"),pad_spacing:U().default("2.6mm")}),pFt=t=>{const A=dFt.parse(t),e=Ui(0,IA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.pad_spacing)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:-IA.parse(A.h)/2},{x:IA.parse(A.pad_spacing)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:yFt(A).concat(i,e),parameters:A}},fFt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},yFt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=fFt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},mFt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("3.20mm"),h:U().default("1.65mm"),pl:U().default("0.8mm"),pw:U().default("0.9mm"),pad_spacing:U().default("2.1mm")}),wFt=t=>{const A=mFt.parse(t),e=Ui(0,IA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.pad_spacing)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.2,y:-IA.parse(A.h)/2},{x:IA.parse(A.pad_spacing)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:xFt(A).concat(i,e),parameters:A}},DFt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},xFt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=DFt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},SFt=Ri.extend({fn:U(),num_pins:_t([bA(6),bA(8)]).default(8),w:U().default("3mm"),h:U().default("3mm"),p:U().default("0.5mm"),pl:U().default("0.52mm"),pw:U().default("0.35mm"),epw:U().default("1.40mm"),eph:U().default("1.60mm"),string:U().optional(),ep:YA().default(!1)}),bFt=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=SFt.parse({...t,num_pins:e}),n=IA.parse(i.w),o=IA.parse(i.h),s=IA.parse(i.p),r=IA.parse(i.pl),a=IA.parse(i.pw),g=IA.parse(i.epw),c=IA.parse(i.eph),I=[];for(let p=0;p<i.num_pins;p++){const{x:y,y:w}=gne(i.num_pins,p+1,n,s);I.push(li(p+1,y,w,r,a))}i.ep&&I.push(li(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=gne(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=Ui(0,B/2+.5,.3);return{circuitJson:[...I,C,Q,d,u],parameters:i}},gne=(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*IA.parse("1.4mm"),y:r*i}},_Ft=Ri.extend({fn:U(),num_pins:OA().optional().default(8),p:se.describe("pitch (distance between center of each pin)"),w:IA.describe("width between vertical rows of pins"),grid:XO.describe("width and height of the border of the footprint"),ep:XO.default("0x0mm").describe("width and height of the central exposed thermal pad"),epx:IA.default("0mm").describe("x offset of the center of the central exposed thermal pad"),pinw:IA.describe("width of the pin pads"),pinh:IA.describe("height of the pin pads")}),kFt=t=>{const A=_Ft.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}=vFt({pinCount:e,pinIndex:B,width:n,pitch:i});c.push(li(B+1,C,Q,a,g))}s.x>0&&s.y>0&&c.push(li(A.num_pins+1,r,0,s.x,s.y));const I=FFt(o),l=Ui(0,o.y/2+i,o.y/6);return{circuitJson:[...c,...I,l],parameters:A}},vFt=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}},FFt=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}]},MFt=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:n=1.5,ph:o=1.5}=t,s=IA.parse(i),r=IA.parse(n),a=IA.parse(o),g=Math.min(a/4,.5),c=[];for(let p=0;p<A;p++)c.push(li(p+1,p*s,0,r,a));let I=[];if(e){const p=e.split("").map(Number);if(p.length>1)for(let y=0;y<p.length-1;y++){const w=p[y],D=p[y+1];if(typeof w=="number"&&typeof D=="number"&&!isNaN(w)&&!isNaN(D)){const x=(w-1)*s,_=(D-1)*s,S=Math.sign(_-x),N=x+S*(r/2),F=_-S*(r/2);I.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${w}}`,x:N,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=Ui(C,u,.4);return{circuitJson:[...c,...I,h,d],parameters:t}},cne={fn:bA("sot457"),num_pins:bA(6).default(6),pillh:U().default("0.45mm"),pillw:U().default("1.45mm"),pl:U(),pw:U(),p:U(),wave:YA().optional(),reflow:YA().optional()},RFt=Ri.extend({...cne,h:U().default("2.5mm"),w:U().default("2.7mm"),pl:U().default("0.8mm"),pw:U().default("0.55mm"),p:U().default("0.95mm")}),NFt=Ri.extend({...cne,h:U().default("3mm"),w:U().default("4mm"),pillr:U().default("0.225mm"),pl:U().default("1.45mm"),pw:U().default("1.5mm"),p:U().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)})),K2=t=>Number.parseFloat(t.replace("mm","")),Ine=({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},lne=t=>{const A=[],e=K2(t.p),i=K2(t.pl),n=K2(t.pw),o=K2(t.w),s=K2(t.h);if(t.wave){const C={1:({padWidth:Q,padHeight:h})=>li(1,-e,e,h,Q),2:({padWidth:Q,padHeight:h})=>li(2,-e,-e,h,Q),3:({padWidth:Q,padHeight:h})=>$O(3,-e,0,K2(t.pillw),K2(t.pillh)),4:({padWidth:Q,padHeight:h})=>$O(4,e,0,K2(t.pillw),K2(t.pillh)),5:({padWidth:Q,padHeight:h})=>li(5,e,e,h,Q),6:({padWidth:Q,padHeight:h})=>li(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}=Ine({pitch:e,width:o,pinNumber:C});A.push(li(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=Ui(0,s+.5,.3),c=Ine({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]},GFt=t=>{if(t.wave){const e=NFt.parse({...t,fn:"sot457"});return{circuitJson:lne(e),parameters:e}}const A=RFt.parse(t);return{circuitJson:lne(A),parameters:A}},LFt=Ri.extend({fn:U(),num_pins:bA(6).default(6),w:U().default("1.1mm"),h:U().default("1.45mm"),p:U().default("0.35mm"),pl:U().default("0.2mm"),pw:U().default("0.2mm"),string:U().optional()}),UFt=t=>{const A=LFt.parse({...t,fn:"sot963"}),e=IA.parse(A.w),i=IA.parse(A.h),n=IA.parse(A.p),o=IA.parse(A.pl),s=IA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=Bne(B+1,e,n,o);r.push(li(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=Bne(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=Ui(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},Bne=(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}},HFt=Ri.extend({fn:U(),num_pins:_t([bA(3),bA(2)]).default(3),p:U().default("3.8mm"),id:U().default("1.25mm"),od:U().default("2.35mm"),ca:U().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:U().default("5.35mm"),h:U().default("4mm"),string:U().optional()}),YFt=t=>{const{p:A,id:e,od:i,h:n,ca:o}=t,s=Number.parseFloat(n),r=Number.parseFloat(o);return[Mo(1,0,r/4+.3,e,i),Mo(2,s,0,e,i),Mo(3,0,-r/4-.3,e,i)]},JFt=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=HFt.parse({...t,num_pins:e});let n=[];i.num_pins===3&&(n=YFt(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=Ui(c,o+1,.5);return{circuitJson:[...n,a,g,I],parameters:i}},TFt=Ri.extend({fn:U(),p:IA.optional().default("7.5mm"),id:IA.optional().default("1mm"),od:IA.optional().default("2mm"),d:IA.optional().default("10.5mm")}),PFt=(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}},KFt=t=>{const A=TFt.parse(t),{p:e,id:i,od:n,d:o}=A,s=[Mo(1,-e/2,0,i,n),Mo(2,e/2,0,i,n)],{topArc:r,bottomArc:a}=PFt(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=Ui(0,o/2+1,.5);return{circuitJson:[...s,g,c,I,Q,h,E],parameters:A}},qFt=Ri.extend({fn:U(),num_pins:bA(2).default(2),w:U().default("6.5mm"),h:U().default("3mm"),pl:U().default("1.75mm"),pw:U().default("2.40mm"),p:U().default("4.75mm")}),OFt=t=>{const A=qFt.parse(t),e=Ui(0,IA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:IA.parse(A.p)/2,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.3,y:IA.parse(A.h)/2},{x:-IA.parse(A.w)/2-.3,y:-IA.parse(A.h)/2},{x:IA.parse(A.p)/2,y:-IA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ZFt(A).concat(i,e),parameters:A}},WFt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},ZFt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=WFt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},VFt=Ri.extend({fn:U(),num_pins:OA().default(3),w:U().default("2.45mm"),h:U().default("2.40mm"),pl:U().default("0.92mm"),pw:U().default("0.45mm"),p:U().default("0.891mm"),string:U().optional()}),jFt=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=VFt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:XFt(i),parameters:i};throw new Error("Invalid number of pins")},zFt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},XFt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=zFt({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(li(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Ui(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]},$Ft=Ri.extend({fn:U(),circle:YA().optional(),rect:YA().optional(),square:YA().optional(),pill:YA().optional(),d:IA.optional(),pd:IA.optional(),diameter:IA.optional(),r:IA.optional(),pr:IA.optional(),radius:IA.optional(),w:IA.optional(),pw:IA.optional(),width:IA.optional(),h:IA.optional(),ph:IA.optional(),height:IA.optional(),s:IA.optional(),size:IA.optional(),string:U().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=cr(t.r):t.pr!==void 0?e=cr(t.pr):t.radius!==void 0?e=cr(t.radius):t.d!==void 0?e=cr(t.d)/2:t.pd!==void 0?e=cr(t.pd)/2:t.diameter!==void 0?e=cr(t.diameter)/2:e=cr("1mm")/2:(t.w!==void 0?i=cr(t.w):t.pw!==void 0?i=cr(t.pw):t.width!==void 0?i=cr(t.width):t.s!==void 0?i=cr(t.s):t.size!==void 0?i=cr(t.size):i=cr("1mm"),t.h!==void 0?n=cr(t.h):t.ph!==void 0?n=cr(t.ph):t.height!==void 0?n=cr(t.height):A==="square"||A==="rect"?n=i:n=cr("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:n}}),AMt=t=>{const A=$Ft.parse(t),{shape:e,radius:i,width:n,height:o}=A;let s,r;return e==="circle"?(s=qie(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=$O(1,0,0,n,o),r=Math.max(n,o)/2+.5):(s=li(1,0,0,n,o),r=o/2+.5),{circuitJson:[s,Ui(0,r,.2)],parameters:A}},eMt=Ri.extend({fn:U(),d:IA.optional(),hd:IA.optional(),r:IA.optional(),hr:IA.optional(),pd:IA.optional(),pr:IA.optional(),squarepad:YA().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=cr(t.d):t.hd!==void 0?A=cr(t.hd):t.r!==void 0?A=cr(t.r)*2:t.hr!==void 0?A=cr(t.hr)*2:A=cr("1mm");let e;return t.pd!==void 0?e=cr(t.pd):t.pr!==void 0?e=cr(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),tMt=t=>{const A=eMt.parse(t),{d:e,pd:i,squarepad:n}=A;return{circuitJson:[n?ym({pn:1,x:0,y:0,holeDiameter:e,rectPadWidth:i,rectPadHeight:i}):Mo(1,0,0,e,i),Ui(0,i/2+.5,.2)],parameters:A}},iMt=Ri.extend({fn:U(),num_pins:bA(6).default(6),h:U().default("1.6mm"),pl:U().default("1mm"),pw:U().default("0.7mm"),p:U().default("0.95mm")}),nMt=t=>{const A=iMt.parse(t);return{circuitJson:oMt(A),parameters:A}},Cne=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")},oMt=t=>{const A=[];for(let I=1;I<=t.num_pins;I++){const{x:l,y:B}=Cne({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:I});A.push(li(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=Ui(0,i+.3,.3),r=Cne({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]},sMt=Ri.extend({fn:U(),num_pins:OA().default(4),w:U().default("3.2mm"),h:U().default("2.6mm"),pl:U().default("1.05mm"),pw:U().default("0.45mm"),p:U().default("0.55mm"),string:U().optional()}),rMt=t=>{const A=t.string?.match(/^sot343_(\d+)/),e=A?Number.parseInt(A[1],4):4,i=sMt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:gMt(i),parameters:i};throw new Error("Invalid number of pins")},aMt=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}},gMt=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:p,y}=aMt({num_pins:t.num_pins,pn:d+1,p:s});A.push(li(d+1,p,y,n,o)),p<r&&(r=p),p>a&&(a=p),y<g&&(g=y),y>c&&(c=y)}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=Ui(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]},cMt=Ri.extend({fn:U()}),IMt=t=>{const A=cMt.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 x=D+1;if(x>=24&&x<=31)continue;const _=a-D*s,S=x%2===0,N=n+(S?.25:0),L=.5-N/2,Y=li(x,L,_,N,i);Y.layer=S?"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,x,_=0,S=0)=>{Q=Math.min(Q,D-_/2),h=Math.max(h,D+_/2),E=Math.min(E,x-S/2),u=Math.max(u,x+S/2)};for(const D of e){const x=D;d(x.x,x.y,x.width,x.height)}d(l.center.x,l.center.y,l.width,l.height);for(const D of C.route)d(D.x,D.y);const p=(Q+h)/2,y=(E+u)/2,w=D=>{typeof D.x=="number"&&(D.x-=p),typeof D.y=="number"&&(D.y-=y),D.center&&(D.center.x-=p,D.center.y-=y),Array.isArray(D.route)&&(D.route=D.route.map(x=>({x:x.x-p,y:x.y-y})))};for(const D of e)w(D);return w(l),w(C),{circuitJson:[...e,l,C],parameters:A}},lMt=Ri.extend({fn:U(),numPins:OA().optional().default(0),rows:_t([U(),OA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:IA.default("2.54mm").describe("pitch"),id:IA.default("1.0mm").describe("inner diameter"),od:IA.default("1.5mm").describe("outer diameter"),male:YA().optional().describe("the module uses male headers"),nopin:YA().optional().default(!1).describe("omit pins rendering"),female:YA().optional().describe("the module uses female headers"),smd:YA().optional().describe("surface mount device"),pinlabeltextalignleft:YA().optional().default(!1),pinlabeltextaligncenter:YA().optional().default(!1),pinlabeltextalignright:YA().optional().default(!1),pinlabelverticallyinverted:YA().optional().default(!1),pinlabelorthogonal:YA().optional().default(!1),nopinlabels:YA().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:YA().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:YA().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top"),pinRowSide:Ve(["left","right","top","bottom"]).optional().default("left"),pinrowleft:YA().optional().default(!1),pinrowright:YA().optional().default(!1),pinrowtop:YA().optional().default(!1),pinrowbottom:YA().optional().default(!1),pinrowleftpins:_t([U(),OA()]).transform(t=>Number(t)).optional(),pinrowrightpins:_t([U(),OA()]).transform(t=>Number(t)).optional(),pinrowtoppins:_t([U(),OA()]).transform(t=>Number(t)).optional(),pinrowbottompins:_t([U(),OA()]).transform(t=>Number(t)).optional(),width:IA.optional(),height:IA.optional(),pinRowHoleEdgeToEdgeDist:IA.default("2mm"),holes:_t([U(),xe(U())]).optional().transform(t=>!t||Array.isArray(t)?t:t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1).split(",").map(A=>A.trim()):[t]),holeXDist:IA.optional(),holeYDist:IA.optional(),holeInset:IA.default("1mm"),pinrow:_t([U(),OA()]).optional(),usbposition:Ve(["left","right","top","bottom"]).optional().default("left"),usbleft:YA().optional().default(!1),usbtop:YA().optional().default(!1),usbright:YA().optional().default(!1),usbbottom:YA().optional().default(!1),usbtype:Ve(["micro","c"]).optional(),usbmicro:YA().optional().default(!1),usbc:YA().optional().default(!1),screen:YA().optional().default(!1).describe("add silkscreen outline for screen/display area"),screenwidth:IA.optional(),screenheight:IA.optional(),screencenteroffsetx:IA.optional(),screencenteroffsety:IA.optional()}).transform(t=>{const A=Ane(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(p=>p!==void 0&&p>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 p=r?t.p:0,y=a?t.p:0;l=(I>0?(I-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+p,B=(c>0?(c-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+y}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:Xt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),BMt=t=>{const A=lMt.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:p,holeYDist:y,holeInset:w,pinrowleftpins:D,pinrowrightpins:x,pinrowtoppins:_,pinrowbottompins:S,usbposition:N,usbtype:F,screen:L,screenwidth:Y,screenheight:J,screencenteroffsetx:q,screencenteroffsety:Z}=A;let X="center";c?X="left":I&&(X="right");const eA=[],gA={left:D,right:x,top:_,bottom:S},tA=Object.values(gA).some(aA=>aA!==void 0&&aA>0),iA=(aA,EA,SA,_A)=>{if(A.smd?eA.push(li(aA,EA,SA,A.od,A.od)):aA===1?eA.push(ym({pn:aA,x:EA,y:SA,holeDiameter:i,rectPadWidth:n,rectPadHeight:n})):eA.push(Mo(aA,EA,SA,i,n)),!l){const LA=EA+(_A==="left"?-n:_A==="right"?n:0),QA=SA+(_A==="top"?n:_A==="bottom"?-n:0);C||eA.push(r3({fs:n/5,pn:aA,anchor_x:LA,anchor_y:QA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"top"})),(B||C)&&eA.push(r3({fs:n/5,pn:aA,anchor_x:LA,anchor_y:QA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"bottom"}))}};if(tA){const aA=e;let EA=1;const SA=gA.left??0,_A=gA.right??0,LA=gA.top??0,QA=gA.bottom??0,kA=(dA,qA)=>{if(!(qA<=0))if(dA==="left"||dA==="right"){const VA=dA==="left"?-h/2+u:h/2-u,ce=(qA-1)/2*aA;for(let fA=0;fA<qA;fA++)iA(EA,VA,ce-fA*aA,dA),EA++}else{const VA=dA==="top"?E/2-u:-E/2+u,ce=-((qA-1)/2)*aA;for(let fA=0;fA<qA;fA++)iA(EA,ce+fA*aA,VA,dA),EA++}};kA("left",SA),kA("right",_A),kA("top",LA),kA("bottom",QA)}else{const aA=e;let EA=0,SA=0,_A=0,LA=0,QA=0,kA=0;const dA=Math.ceil(s/o);Q==="left"||Q==="right"?(EA=Q==="left"?-h/2+u:h/2-u,SA=(dA-1)/2*aA,_A=0,LA=-aA,QA=Q==="left"?aA:-aA,kA=0):(EA=-(dA-1)/2*aA,SA=Q==="top"?E/2-u:-E/2+u,_A=aA,LA=0,QA=0,kA=Q==="top"?-aA:aA);let qA=1;for(let VA=0;VA<o&&qA<=s;VA++)for(let ce=0;ce<dA&&qA<=s;ce++){const fA=EA+ce*_A+VA*QA,ge=SA+ce*LA+VA*kA;if(A.smd?eA.push(li(qA,fA,ge,A.od,A.od)):qA===1?eA.push(ym({pn:qA,x:fA,y:ge,holeDiameter:i,rectPadWidth:n,rectPadHeight:n})):eA.push(Mo(qA,fA,ge,i,n)),!l){const jA=fA+(Q==="left"?-n:Q==="right"?n:0),TA=ge+(Q==="top"?n:Q==="bottom"?-n:0);C||eA.push(r3({fs:n/5,pn:qA,anchor_x:jA,anchor_y:TA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"top"})),(B||C)&&eA.push(r3({fs:n/5,pn:qA,anchor_x:jA,anchor_y:TA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"bottom"}))}qA++}}if(d)for(const aA of d){let EA=0,SA=0;aA==="topleft"?(EA=-h/2+w,SA=E/2-w):aA==="topright"?(EA=h/2-w,SA=E/2-w):aA==="bottomleft"?(EA=-h/2+w,SA=-E/2+w):aA==="bottomright"?(EA=h/2-w,SA=-E/2+w):aA==="center"&&(EA=0,SA=0),p!==void 0&&(EA+=p),y!==void 0&&(SA+=y),eA.push(Mo(s+d.indexOf(aA)+1,EA,SA,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(a3(aA,{stroke_width:.1,layer:"top"}))}const sA=Ui(0,E/2+1,.5);if(eA.push(sA),N&&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 SA;if(N==="left")SA=[{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(N==="right")SA=[{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(N==="top")SA=[{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(N==="bottom")SA=[{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(a3(SA,{stroke_width:.1,layer:"top"}))}if(L){const aA=Y/2,EA=J/2,SA=q,_A=Z,LA=[{x:-aA+SA,y:-EA+_A},{x:aA+SA,y:-EA+_A},{x:aA+SA,y:EA+_A},{x:-aA+SA,y:EA+_A},{x:-aA+SA,y:-EA+_A}];eA.push(a3(LA,{stroke_width:.05,layer:"top"}))}return{circuitJson:eA,parameters:A}},CMt=Ri.extend({fn:U(),num_pins:OA().default(3),inline:YA().default(!1),p:U().default("1.27mm"),id:U().default("0.75mm"),od:U().default("1.3mm"),w:U().default("4.8mm"),h:U().default("4.0mm")}),QMt=t=>{const A=CMt.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=[ym({pn:1,x:0,y:0,holeDiameter:A.id,rectPadWidth:o,rectPadHeight:s}),A.inline?g3(2,e,0,Number.parseFloat(A.id),o,s):Mo(2,e,e,A.id,o),A.inline?g3(3,e*2,0,Number.parseFloat(A.id),o,s):Mo(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=Ui(g,c+a+1,.5);return{circuitJson:[...r,B,C],parameters:A}},hMt=(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},EMt=(t,A)=>A.nosilkscreen?t.filter(e=>e.type!=="pcb_silkscreen_path"&&e.type!=="pcb_silkscreen_text"):t,uMt=(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};function dMt(t){return t!=null}var pMt=t=>t.trim().replace(/^sot-223-(\d+)(?=_|$)/i,"sot223_$1").replace(/^to-220f-(\d+)(?=_|$)/i,"to220f_$1"),fMt=t=>{let A=tW();const e=pMt(t),n=e.replace(/^((?:\d{4}|\d{5}))(?=$|_|x)/,"res$1").replace(/^zh(\d+)(?:$|_)/,"jst$1_zh").split(/_(?!metric)/).map(o=>{const s=o.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!s)return null;const[,r,a]=s;if(!r)return null;const g=r.toLowerCase();return a?.includes("?")?null:{fn:g,v:a}}).filter(dMt);for(const{fn:o,v:s}of n)A=A[o](s);return A.setString(e),A},yMt=()=>Object.keys(P2),tW=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&P2[A.fn])return()=>{const{circuitJson:i}=P2[A.fn](A),n=EMt(i,A),o=hMt(n,A);return uMt(o,A.origin)};if(!P2[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(!P2[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>P2[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(P2):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in P2?(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};tW.string=fMt,tW.getFootprintNames=yMt;var mMt=tW,Qne=Symbol("Fragment");function hdA(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"),hne=Symbol("Cube"),Wl=Symbol("Cylinder"),iW=Symbol("Sphere"),Q9=Symbol("RoundedCuboid"),Zi=Symbol("Translate"),aC=Symbol("Rotate"),XQ=Symbol("Union"),mm=Symbol("Subtract"),_c=Symbol("Hull"),xo=Symbol("Colorize"),h9=Symbol("Polygon"),E9=Symbol("ExtrudeLinear"),Gp=Symbol("RoundedCylinder"),Tn=Qne,zA=(t,A,e)=>hdA(t,A),qt=(t,A,e)=>hdA(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),p=Math.max(e-u,e*r),y=Math.min(A,e)*.12,w=c??y,D={x:0,y:e/2-w*.25,z:i},x=I??D,_=qt(XQ,{children:[qt(_c,{children:[zA(Zi,{z:.005,children:zA(Qt,{size:[d,p,.01]})}),zA(Zi,{z:h,children:zA(Qt,{size:[A,e,.01]})})]}),qt(_c,{children:[zA(Zi,{z:h,children:zA(Qt,{size:[A,e,.01]})}),zA(Zi,{z:h+E,children:zA(Qt,{size:[d,p,.01]})})]})]}),S=(F,L)=>zA(Zi,{offset:{x:F,y:L,z:0},children:zA(aC,{rotation:[0,0,Math.PI/4],children:zA(Qt,{size:[Q*Math.SQRT2,Q*Math.SQRT2,i*3]})})});let N=_;if(Q>0){const F=A/2,L=e/2;N=qt(mm,{children:[_,S(F,L),S(-F,L),S(F,-L),S(-F,-L)]})}return zA(xo,{color:o,children:zA(Zi,{offset:t,children:zA(Zi,{offset:{x:0,y:0,z:n},children:g?qt(mm,{children:[N,zA(Zi,{offset:x,children:zA(aC,{rotation:l,children:zA(Wl,{radius:w,height:C})})})]}):N})})})},wMt=t=>Array.from({length:t},(A,e)=>e);function EdA(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 p=1/u;r(l,{x:h*p,y:E*p},1),r(l,{x:h*p,y:E*p},-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 DMt=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}))},xMt=DMt([{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}]),Ene=5.47,nW=.5,SMt=({x:t,y:A,z:e})=>{const i=t>0;return qt(Tn,{children:[zA(Zi,{offset:{x:t+.25/2,y:A,z:e},children:zA(aC,{rotation:["-90deg",0,"90deg"],children:zA(E9,{height:.25,children:zA(h9,{points:xMt.slice().reverse().map(n=>[n.x,n.y])})})})}),zA(Zi,{offset:{x:t,y:A+(i?1:-1),z:e},children:zA(aC,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:zA(E9,{height:2,children:zA(h9,{points:EdA([[0,0],[-1,0],[-1,-1]],.25).map(n=>[n.x,n.y])})})})})]})},bMt=({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(Tn,{children:[wMt(t).map(r=>{const a=r%n,g=(Math.floor(r/n)-.5)*2;return zA(SMt,{x:g*o/2,y:a*A-(n-1)/2*A,z:Ene/2+nW})}),zA(yB,{width:s,length:n*A+.5,height:Ene-nW,heightAboveSurface:nW,center:{x:0,y:0,z:nW}})]})};function _Mt(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 so=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,_Mt(c,t)]),g=EdA(a,A);return zA(xo,{color:"#fff",children:zA(Zi,{offset:{z:0,y:0,x:0,...t.position},children:zA(aC,{rotation:["90deg",0,s??0],children:zA(Zi,{offset:{x:0,y:0,z:-e/2},children:zA(E9,{height:e,children:zA(h9,{points:g.map(c=>[c.x,c.y])})})})})})})},kMt=({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(Tn,{children:[Array.from({length:o}).map((g,c)=>zA(so,{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(so,{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})]})},vMt=({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(Tn,{children:[Array.from({length:o}).map((a,g)=>zA(so,{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(so,{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})]})},udA=1,ddA=.5,vF=.5,u9=.2,FMt=udA-u9*2,une=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[FMt,ddA,vF],offset:[0,0,vF/2],color:t}),zA(Qt,{size:[u9,vF,ddA],offset:[udA/2-u9/2,0,vF/2],color:"#ccc"}),zA(Qt,{size:[u9,vF,ddA],offset:[-udA/2+u9/2,0,vF/2],color:"#ccc"})]}),pdA=1.6,MMt=pdA-.3*2,oW=.3,fdA=.85,FF=.6,dne=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[MMt,fdA,FF],offset:[0,0,FF/2],color:t}),zA(Qt,{size:[oW,fdA,FF],offset:[pdA/2-oW/2,0,FF/2],color:"#ccc"}),zA(Qt,{size:[oW,fdA,FF],offset:[-pdA/2+oW/2,0,FF/2],color:"#ccc"})]}),ydA=2,mdA=1.25,MF=.55,d9=.5,RMt=ydA-d9*2,pne=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[RMt,mdA,MF],offset:[0,0,MF/2],color:t}),zA(Qt,{size:[d9,mdA,MF],offset:[ydA/2-d9/2,0,MF/2],color:"#ccc"}),zA(Qt,{size:[d9,mdA,MF],offset:[-ydA/2+d9/2,0,MF/2],color:"#ccc"})]}),NMt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:n})=>{const o=t/4;A||(A=GMt(t,n)),i||(i=LMt(t)),e||(e=UMt(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(Tn,{children:[Array.from({length:o}).map((B,C)=>zA(so,{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(so,{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(so,{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(so,{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})]})},GMt=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},LMt=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}},UMt=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},fne=({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(Tn,{children:[zA(Zi,{y:I?-3:0,children:zA(Qt,{color:"#222",size:[s,r,o],center:[t,A,a(o/2)]})}),!g&&zA(xo,{color:"gold",children:c?zA(so,{rotation:-Math.PI/2,position:{x:t,y:A+1,z:e/2},thickness:e,width:e,height:e,padContactLength:2,bodyDistance:3}):qt(_c,{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(xo,{color:"gold",children:zA(Zi,{y:I?-3.9:0,z:I?1:0,children:zA(aC,{rotation:I?[-Math.PI/2,0,0]:[0,0,0],children:qt(_c,{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)]})]})})})})]}),HMt=({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(Tn,{children:Array.from({length:t},(h,E)=>{const u=Math.floor(E/c),d=E%c,p=B+d*A,y=-u*I;return zA(fne,{x:p,y,pinThickness:.63,shortSidePinLength:l,longSidePinLength:e,bodyHeight:2,flipZ:Q,faceup:n,smd:s,rightangle:r},E)})})},YMt=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")}},JMt=({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},TMt=({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=JMt({num_pins:t,cw:!0,ccw:!0}),c=[];for(let I=0;I<t;I++){const{x:l,y:B,o:C}=YMt({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(Tn,{children:[zA(xo,{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]})]})},PMt=TMt,KMt=()=>{const a=1.1999999999999997;return qt(Tn,{children:[zA(so,{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(so,{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(so,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),zA(so,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),zA(so,{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})]})},qMt=KMt,OMt=({fullWidth:t=2.9,fullLength:A=2.8})=>{const c=(t-1.92)/2+.3;return qt(Tn,{children:[zA(so,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),zA(so,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),zA(so,{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})]})},wdA=.6,DdA=.3,RF=.33,p9=.1,WMt=wdA-p9*2,yne=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[WMt,DdA,RF],offset:[0,0,RF/2],color:t}),zA(Qt,{size:[p9,DdA,RF],offset:[wdA/2-p9/2,0,RF/2],color:"#ccc"}),zA(Qt,{size:[p9,DdA,RF],offset:[-wdA/2+p9/2,0,RF/2],color:"#ccc"})]}),xdA=.4,SdA=.2,NF=.13,f9=.07,ZMt=xdA-f9*2,mne=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[ZMt,SdA,NF],offset:[0,0,NF/2],color:t}),zA(Qt,{size:[f9,SdA,NF],offset:[xdA/2-f9/2,0,NF/2],color:"#ccc"}),zA(Qt,{size:[f9,SdA,NF],offset:[-xdA/2+f9/2,0,NF/2],color:"#ccc"})]}),bdA=3.2,_dA=1.6,GF=.9,y9=.5,VMt=bdA-y9*2,wne=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[VMt,_dA,GF],offset:[0,0,GF/2],color:t}),zA(Qt,{size:[y9,_dA,GF],offset:[bdA/2-y9/2,0,GF/2],color:"#ccc"}),zA(Qt,{size:[y9,_dA,GF],offset:[-bdA/2+y9/2,0,GF/2],color:"#ccc"})]}),kdA=3.2,vdA=2.5,LF=1,m9=.6,jMt=kdA-m9*2,Dne=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[jMt,vdA,LF],offset:[0,0,LF/2],color:t}),zA(Qt,{size:[m9,vdA,LF],offset:[kdA/2-m9/2,0,LF/2],color:"#ccc"}),zA(Qt,{size:[m9,vdA,LF],offset:[-kdA/2+m9/2,0,LF/2],color:"#ccc"})]}),FdA=5,MdA=2.5,UF=1.4,w9=.6,zMt=FdA-w9*2,xne=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[zMt,MdA,UF],offset:[0,0,UF/2],color:t}),zA(Qt,{size:[w9,MdA,UF],offset:[FdA/2-w9/2,0,UF/2],color:"#ccc"}),zA(Qt,{size:[w9,MdA,UF],offset:[-FdA/2+w9/2,0,UF/2],color:"#ccc"})]}),RdA=6.3,NdA=3.2,HF=1.8,D9=.8,XMt=RdA-D9*2,Sne=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[XMt,NdA,HF],offset:[0,0,HF/2],color:t}),zA(Qt,{size:[D9,NdA,HF],offset:[RdA/2-D9/2,0,HF/2],color:"#ccc"}),zA(Qt,{size:[D9,NdA,HF],offset:[-RdA/2+D9/2,0,HF/2],color:"#ccc"})]}),bne=({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(Tn,{children:[zA(xo,{color:"#1a1a1a",children:qt(mm,{children:[zA(Qt,{color:"#000",size:[r,a,s],center:[t,A,g(e+s/2)]}),o?zA(Wl,{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(xo,{color:"silver",children:[qt(_c,{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)]})]})]})},$Mt=({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(Tn,{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(bne,{x:Q,y:h,pitch:A,legsLength:e,innerDiameter:i,flipZ:c},l)})})},ARt=({width:t,length:A,innerDiameter:e=1})=>{const i=t,n=A,o=t*.7,s=e/2.5;return qt(Tn,{children:[zA(Q9,{color:"#1a1a1f",center:[0,0,o/2],size:[n,n,o],roundRadius:.3}),zA(Q9,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[n,n,o*.1],roundRadius:.14}),zA(Wl,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),zA(Wl,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,n/3,o+o*.1/2]}),zA(Wl,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,-n/3,o+o*.1/2]}),zA(Wl,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,n/3,o+o*.1/2]}),zA(Wl,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,-n/3,o+o*.1/2]}),zA(sW,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:-n/2,z:-o*1.2}}),zA(sW,{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(sW,{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(sW,{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}})]})},sW=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=EdA(r,A);return zA(xo,{color:"#f2f2f2",children:zA(Zi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:zA(aC,{rotation:[0,55,o],children:zA(E9,{height:e,children:zA(h9,{points:a.map(g=>[g.y,g.x])})})})})})},eRt=({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(Tn,{children:[Array.from({length:o}).map((B,C)=>zA(so,{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(so,{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})]})},tRt=({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(Tn,{children:[Array.from({length:I}).map((u,d)=>zA(so,{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(so,{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})]})},iRt=()=>qt(Tn,{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(xo,{color:"#222",children:qt(XQ,{children:[zA(Zi,{z:.3/2,children:zA(Qt,{size:[1.65,.8,.3]})}),qt(_c,{children:[zA(Zi,{z:.3,children:zA(Qt,{size:[1.65,.8,.01]})}),zA(Zi,{z:.6,children:zA(Qt,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),nRt=()=>qt(Tn,{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(xo,{color:"#222",children:zA(Zi,{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]})]}),oRt=()=>{const g=zA(xo,{color:"#1a1a1a",children:qt(XQ,{children:[qt(_c,{children:[zA(Zi,{z:.13,children:zA(Qt,{size:[4,3,.03]})}),zA(Zi,{z:1.15,children:zA(Qt,{size:[4.4,3.4,.01]})})]}),qt(_c,{children:[zA(Zi,{z:1.15,children:zA(Qt,{size:[4.4,3.4,.01]})}),zA(Zi,{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(xo,{color:"#c0c0c0",children:qt(XQ,{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(Tn,{children:[zA(c,{xDir:1}),zA(c,{xDir:-1}),g]})},sRt=()=>{const g=zA(xo,{color:"#1a1a1a",children:qt(XQ,{children:[qt(_c,{children:[zA(Zi,{z:.13,children:zA(Qt,{size:[4,3,.03]})}),zA(Zi,{z:1.15,children:zA(Qt,{size:[4.4,3.4,.01]})})]}),qt(_c,{children:[zA(Zi,{z:1.15,children:zA(Qt,{size:[4.4,3.4,.01]})}),zA(Zi,{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(xo,{color:"#c0c0c0",children:qt(XQ,{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(Tn,{children:[zA(c,{xDir:1}),zA(c,{xDir:-1}),g]})},rRt=()=>{const g=zA(xo,{color:"#1a1a1a",children:qt(XQ,{children:[qt(_c,{children:[zA(Zi,{z:.21000000000000002,children:zA(Qt,{size:[6.3999999999999995,5.6,.03]})}),zA(Zi,{z:1.15,children:zA(Qt,{size:[6.8,6,.01]})})]}),qt(_c,{children:[zA(Zi,{z:1.15,children:zA(Qt,{size:[6.8,6,.01]})}),zA(Zi,{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(xo,{color:"#c0c0c0",children:qt(XQ,{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(Tn,{children:[zA(c,{xDir:1}),zA(c,{xDir:-1}),g]})},aRt=()=>{const I=zA(xo,{color:"#222",children:qt(XQ,{children:[zA(Zi,{z:.27,children:zA(Qt,{size:[2.9,1.9,.54]})}),qt(_c,{children:[zA(Zi,{z:.54,children:zA(Qt,{size:[2.9,1.9,.01]})}),zA(Zi,{z:1.08,children:zA(Qt,{size:[2.6999999999999997,1.7,.01]})})]})]})});return qt(Tn,{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]})},gRt=()=>qt(Tn,{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(xo,{color:"#222",children:qt(XQ,{children:[zA(Zi,{z:.55/2,children:zA(Qt,{size:[2.7,1.6,.55]})}),qt(_c,{children:[zA(Zi,{z:.55,children:zA(Qt,{size:[2.7,1.6,.01]})}),zA(Zi,{z:1.1,children:zA(Qt,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),cRt=()=>qt(Tn,{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(xo,{color:"#222",children:qt(XQ,{children:[zA(Zi,{z:.2/2,children:zA(Qt,{size:[2.75,1.8,.2]})}),qt(_c,{children:[zA(Zi,{z:.2,children:zA(Qt,{size:[2.75,1.8,.01]})}),zA(Zi,{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]})]}),IRt=()=>qt(Tn,{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(xo,{color:"#222",children:qt(XQ,{children:[qt(_c,{children:[zA(Zi,{z:.2,children:zA(Qt,{size:[2.6-.1/2,1.7-.1/2,.01]})}),zA(Zi,{z:.01,children:zA(Qt,{size:[2.6-.1,1.7-.1,.01]})})]}),qt(_c,{children:[zA(Zi,{z:.2,children:zA(Qt,{size:[2.6,1.7,.01]})}),zA(Zi,{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]})]}),lRt=()=>qt(Tn,{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(xo,{color:"#222",children:qt(XQ,{children:[qt(_c,{children:[zA(Zi,{z:.2,children:zA(Qt,{size:[3.8-.05/2,2.5-.05/2,.01]})}),zA(Zi,{z:.01,children:zA(Qt,{size:[3.8-.05,2.5-.05,.01]})})]}),qt(_c,{children:[zA(Zi,{z:.2,children:zA(Qt,{size:[3.8,2.5,.01]})}),zA(Zi,{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]})]}),BRt=()=>qt(Tn,{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(xo,{color:"#222",children:qt(XQ,{children:[zA(Zi,{z:.14/2,children:zA(Qt,{size:[.8,.6,.14]})}),qt(_c,{children:[zA(Zi,{z:.14,children:zA(Qt,{size:[.8,.6,.01]})}),zA(Zi,{z:.37,children:zA(Qt,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),CRt=()=>{const c=3.0999999999999996;return qt(Tn,{children:[zA(so,{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(so,{position:{x:-6.6/2-c/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(so,{position:{x:-6.6/2-c/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(so,{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})]})},QRt=()=>qt(Tn,{children:[Array.from({length:16}).map((B,C)=>zA(so,{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(so,{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(so,{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(so,{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})]}),hRt=QRt,ERt=()=>{const g=.7999999999999998;return qt(Tn,{children:[zA(so,{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(so,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),zA(so,{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})]})},uRt=({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(Tn,{children:[Array.from({length:o}).map((B,C)=>zA(so,{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(so,{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(so,{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(so,{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})]})},dRt=()=>{const i=.20900000000000002,n=.1,o=.3,s=.1,r=.2;return qt(Tn,{children:[zA(xo,{color:"#222",children:qt(XQ,{children:[zA(Qt,{size:[.85,1.2,i],center:[0,0,i/2]}),qt(_c,{children:[zA(Zi,{z:i,children:zA(Qt,{size:[.85,1.2,.01]})}),zA(Zi,{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]})]})},pRt=({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(Tn,{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]})]})},fRt=({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(Tn,{children:[qt(xo,{color:s,children:[qt(_c,{children:[zA(Gp,{height:e,roundRadius:.5,radius:g,center:[-c,0,e]}),zA(Gp,{height:e,roundRadius:.5,radius:g,center:[c,0,e]})]}),qt(_c,{children:[zA(Gp,{height:l,roundRadius:.1,radius:g+.85,center:[-c,0,e/2+l/2]}),zA(Gp,{height:l,roundRadius:.1,radius:g+.85,center:[c,0,e/2+l/2]})]})]}),qt(xo,{color:r,children:[zA(Wl,{height:o+e/2,radius:n/2,center:[-I+.06,0,-(o/2)+e/2]}),zA(Wl,{height:o+e/2,radius:n/2,center:[I-.06,0,-(o/2)+e/2]})]})]})},yRt=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:n="#111"})=>qt(Tn,{children:[zA(xo,{color:e,children:qt(aC,{rotation:[0,"90deg",0],children:[zA(Q9,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),zA(Wl,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),zA(xo,{color:n,children:zA(aC,{rotation:[0,"90deg",0],children:zA(Q9,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),zA(xo,{color:i,children:zA(aC,{rotation:[0,"90deg",0],children:zA(Gp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),zA(xo,{color:i,children:zA(aC,{rotation:[0,"90deg",0],children:zA(Gp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),mRt=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>qt(Tn,{children:[zA(xo,{color:e,children:zA(aC,{rotation:[0,"90deg",0],children:zA(Gp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),zA(xo,{color:i,children:zA(aC,{rotation:[0,"90deg",0],children:zA(Gp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),zA(xo,{color:i,children:zA(aC,{rotation:[0,"90deg",0],children:zA(Gp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),wRt=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>qt(Tn,{children:[zA(xo,{color:e,children:zA(aC,{rotation:[0,"90deg",0],children:zA(Gp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),zA(xo,{color:i,children:zA(aC,{rotation:[0,"90deg",0],children:zA(Gp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),zA(xo,{color:i,children:zA(aC,{rotation:[0,"90deg",0],children:zA(Gp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),DRt=({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(Tn,{children:[Array.from({length:n}).map((g,c)=>zA(so,{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(so,{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})]})},xRt=({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(Tn,{children:[Array.from({length:n}).map((g,c)=>zA(so,{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(so,{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})]})},SRt=()=>{const Q=7.050000000000001,h=24.95+6.5/2;return zA(Zi,{center:[0,0,1],children:qt(Tn,{children:[qt(aC,{rotation:[0,55,-55],children:[qt(mm,{children:[zA(Qt,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[h,0,1.3-2]}),zA(Wl,{color:"black",center:[h,0,1.3-2],radius:3/2,height:1.3*1.2})]}),zA(xo,{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(aC,{rotation:[0,55,55],children:Array.from({length:3}).map((E,u)=>{const d=Q,p=(u-1)*2.7,y=-.5-.6;return qt(xo,{color:"gold",children:[qt(_c,{children:[zA(Zi,{center:[15.05-4.5/2+.1,p,y],children:zA(Qt,{size:[4.5,.81+1,.5]})}),zA(Zi,{center:[15.05-4.5/2-1+.1,p,y],children:zA(Qt,{size:[4.5,.81,.5]})})]}),zA(Zi,{center:[d,p,y],children:zA(Qt,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},bRt=()=>{const g=1.1999999999999997;return qt(Tn,{children:[zA(so,{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(so,{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(so,{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(so,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(so,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(so,{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})]})},_Rt=()=>qt(Tn,{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]})})]}),kRt=()=>{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(Zi,{center:[0,1,10.5],children:[zA(xo,{color:s,children:qt(mm,{children:[zA(Zi,{center:[0,0,2.25],children:zA(Wl,{radius:2.4,height:4.5})}),zA(Zi,{center:[0,-1.8499999999999999,2.25],children:zA(Qt,{size:[2.4*2,1.1,4.5+.2]})})]})}),zA(Zi,{center:c,children:zA(Qt,{size:a})}),qt(_c,{children:[zA(Zi,{center:I,children:zA(Qt,{size:g})}),zA(Zi,{center:l,children:zA(Qt,{size:g})})]}),zA(Zi,{center:B,children:zA(Qt,{size:[.43,.4,12.2]})}),zA(Zi,{center:[1.3,0,C],children:zA(Qt,{size:[.43,.4,15]})}),zA(Zi,{center:[-1.3,0,C],children:zA(Qt,{size:[.43,.4,15]})})]})},vRt=()=>qt(Tn,{children:[zA(so,{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(so,{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(so,{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(so,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(so,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(so,{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})]}),FRt=vRt,MRt=()=>qt(Tn,{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]})})]}),RRt=()=>qt(Tn,{children:[zA(so,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),zA(so,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),zA(xo,{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]})]}),NRt=()=>qt(Tn,{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(xo,{color:"#222",children:qt(XQ,{children:[zA(Zi,{z:.175/2,children:zA(Qt,{size:[1.7,1.25,.175]})}),qt(_c,{children:[zA(Zi,{z:.175,children:zA(Qt,{size:[1.7,1.25,.01]})}),zA(Zi,{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]})]}),GRt=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return qt(Tn,{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(xo,{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]})]})},LRt=({pitch:t=10})=>qt(Tn,{children:[zA(Wl,{height:4,radius:.5,center:[-t/2,0,.5]}),zA(iW,{radius:.5,center:[-t/2,0,2.5]}),zA(Zi,{x:-2.5,y:0,z:2.5,children:qt(aC,{rotation:[0,Math.PI/2,0],children:[zA(Wl,{height:t,radius:.5,center:[0,0,2.5]}),zA(xo,{color:"#d2b48c",children:zA(Wl,{height:5,radius:1.3,center:[0,0,2.5]})})]})}),zA(Wl,{height:4,radius:.5,center:[t/2,0,.5]}),zA(iW,{radius:.5,center:[t/2,0,2.5]})]}),URt=({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 x=w+D*n;E.push({x:l-i/2,y:-x,pl:i,pw:e}),g&&u.push({x:l,y:-x},{x:l-c,y:-x})}}if(o){const w=-((o-1)/2)*n;for(let D=0;D<o;D++){const x=w+D*n;E.push({x:-l+i/2,y:-x,pl:i,pw:e}),g&&u.push({x:-l,y:-x},{x:-l+c,y:-x})}}if(r){const w=-((r-1)/2)*n;for(let D=0;D<r;D++){const x=w+D*n;E.push({x:-x,y:h/2-i/2,pl:e,pw:i}),g&&u.push({x:-x,y:h/2},{x:-x,y:h/2-c})}}if(a){const w=-((a-1)/2)*n;for(let D=0;D<a;D++){const x=w+D*n;E.push({x:-x,y:-h/2+i/2,pl:e,pw:i}),g&&u.push({x:-x,y:-h/2},{x:-x,y:-h/2+c})}}const d=zA(xo,{color:"#008080",children:qt(mm,{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))]})}),p=g&&u.map((w,D)=>zA(Wl,{color:"black",center:[w.x,w.y,B],radius:Q,height:A*1.07})),y=E.map((w,D)=>zA(Qt,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]}));return qt(Tn,{children:[d,zA(xo,{color:"#FFD700",children:g?qt(mm,{children:[zA(XQ,{children:E.map((w,D)=>zA(Qt,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]},D))}),p]}):y})]})},HRt=({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,p=g?.y??0,y=g?.z??0;return qt(Zi,{offset:{x:d,y:p,z:y},children:[C>0&&zA(xo,{color:s,children:zA(Qt,{size:[c,I,C],offset:[0,0,C/2]})}),zA(xo,{color:s,children:qt(mm,{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(xo,{color:o,children:zA(Qt,{size:[h,E,u],offset:[0,0,C+u/2]})})]})},YRt=({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,p=o/2,y=Math.ceil(t/A);let w,D;a==="left"||a==="right"?(w=(A-1)*e+2*I,D=(y-1)*e+2*I):(D=(A-1)*e+2*I,w=(y-1)*e+2*I),t===0&&(w=10,D=10);const x=Number(s??w),_=Number(r??D),S=[];let N=0,F=0,L=0,Y=0,J=0,q=0;a==="left"||a==="right"?(N=a==="left"?-x/2+I:x/2-I,F=-((y-1)/2)*e,L=0,Y=e,J=a==="left"?e:-e,q=0):(N=-((y-1)/2)*e,F=a==="top"?_/2-I:-_/2+I,L=e,Y=0,J=0,q=a==="top"?-e:e);let Z=0;for(let QA=0;QA<A&&Z<t;QA++)for(let kA=0;kA<y&&Z<t;kA++){const dA=N+kA*L+QA*J,qA=F+kA*Y+QA*q;S.push({x:dA,y:qA}),Z++}const X=[];if(g)for(const QA of g){let kA=0,dA=0;QA==="topleft"?(kA=-x/2+c,dA=_/2-c):QA==="topright"?(kA=x/2-c,dA=_/2-c):QA==="bottomleft"?(kA=-x/2+c,dA=-_/2+c):QA==="bottomright"?(kA=x/2-c,dA=-_/2+c):QA==="center"&&(kA=0,dA=0),X.push({x:kA,y:dA})}const eA=.63,gA=2,tA=6,iA=3,sA=B||l?0:gA,aA=sA+o,EA=zA(xo,{color:"#008080",children:qt(mm,{children:[zA(Qt,{center:[0,0,p+sA],size:[x,_,o]}),X.map((QA,kA)=>zA(Wl,{center:[QA.x,QA.y,p+sA],radius:n/2,height:o},`hole-${kA}`)),S.map((QA,kA)=>zA(Wl,{center:[QA.x,QA.y,p+sA],radius:n/2,height:o},`pin-hole-${kA}`))]})}),SA=S.map((QA,kA)=>zA(xo,{color:"#FFD700",children:qt(mm,{children:[zA(Wl,{center:[QA.x,QA.y,o/2+sA],radius:n/2,height:o}),zA(Wl,{center:[QA.x,QA.y,o/2+sA],radius:i/2,height:o})]})})),_A=S.map((QA,kA)=>zA(fne,{x:QA.x,y:QA.y,pinThickness:eA,shortSidePinLength:iA,longSidePinLength:tA,bodyHeight:gA,flipZ:dA=>dA})),LA=S.map((QA,kA)=>zA(bne,{x:QA.x,y:QA.y,flipZ:dA=>-dA}));return qt(Tn,{children:[EA,SA,!l&&!B&&_A,l&&LA,d&&zA(HRt,{width:Q??x*.8,height:h??_*.6,offset:{x:E??0,y:u??0,z:aA}})]})},JRt=({footprint:t})=>{const A=mMt.string(t).json();switch(A.fn){case"dip":return zA(bMt,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"axial":return zA(LRt,{pitch:A.p});case"tssop":return zA(kMt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return zA(vMt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return zA(tRt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return zA(NMt,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return zA(hRt,{});case"lqfp":return zA(uRt,{pinCount:A.num_pins});case"qfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return zA(PMt,{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(pRt,{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(HMt,{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($Mt,{numberOfPins:A.num_pins,pitch:A.p,rows:o})}case"cap":switch(A.imperial){case"0402":return zA(une,{color:"#856c4d"});case"0603":return zA(dne,{color:"#856c4d"});case"0805":return zA(pne,{color:"#856c4d"});case"0201":return zA(yne,{color:"#856c4d"});case"01005":return zA(mne,{color:"#856c4d"});case"1206":return zA(wne,{color:"#856c4d"});case"1210":return zA(Dne,{color:"#856c4d"});case"2010":return zA(xne,{color:"#856c4d"});case"2512":return zA(Sne,{color:"#856c4d"})}case"sot235":return zA(qMt,{});case"sot457":return zA(bRt,{});case"sot223":return zA(CRt,{});case"sot23w":return zA(OMt,{});case"sot323":return zA(ERt,{});case"sod323f":return zA(NRt,{});case"sod323fl":return zA(GRt,{});case"sot363":return zA(FRt,{});case"sot886":return zA(MRt,{});case"sot963":return zA(_Rt,{});case"pushbutton":return zA(ARt,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return zA(eRt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return zA(iRt,{});case"sod882":return zA(nRt,{});case"sma":return zA(oRt,{});case"smb":return zA(sRt,{});case"smc":return zA(rRt,{});case"smf":return zA(aRt,{});case"sod123f":return zA(gRt,{});case"sod123fl":return zA(cRt,{});case"sod123w":return zA(IRt,{});case"sod128":return zA(lRt,{});case"sod323":return zA(RRt,{});case"sod923":return zA(BRt,{});case"hc49":return zA(fRt,{});case"micromelf":return zA(yRt,{});case"minimelf":return zA(mRt,{});case"melf":return zA(wRt,{});case"ms012":return zA(DRt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return zA(xRt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return zA(dRt,{});case"to220":return zA(SRt,{});case"to92":return zA(kRt,{});case"stampboard":case"stampreceiver":return zA(URt,{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(YRt,{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(une,{color:i});case"0603":return zA(dne,{color:i});case"0805":return zA(pne,{color:i});case"0201":return zA(yne,{color:i});case"01005":return zA(mne,{color:i});case"1206":return zA(wne,{color:i});case"1210":return zA(Dne,{color:i});case"2010":return zA(xne,{color:i});case"2512":return zA(Sne,{color:i})}return null},TRt=t=>t&&typeof t=="object"&&"type"in t,YF=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},PRt=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 $D(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=>$D(l,A,e));if(!TRt(t))return[];const{type:g,props:c,children:I}=t;if(g===Qne)return(I??[]).flatMap(l=>$D(l,A,e));if(g===xo){const l=c?.color;return(I??[]).flatMap(B=>$D(B,l??A,e))}if(g===Zi){const l=PRt(c?.offset??c?.center??{x:c?.x,y:c?.y,z:c?.z});return(I??[]).flatMap(C=>$D(C,A,e)).map(({geom:C,color:Q})=>({geom:a.translate(l,C),color:Q??A}))}if(g===aC){const l=Array.isArray(c?.rotation)?[YF(c.rotation[0]),YF(c.rotation[1]),YF(c.rotation[2])]:[YF(c?.x??0),YF(c?.y??0),YF(c?.z??0)];return(I??[]).flatMap(C=>$D(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===XQ||g===mm||g===_c){const l=(I??[]).flatMap(C=>$D(C,A,e)).map(C=>C.geom);if(l.length===0)return[];let B;return g===XQ?B=n.union(l):g===mm?B=n.subtract(l[0],l.slice(1)):B=o.hull(l),[{geom:B,color:A}]}if(g===h9){const l=c?.points??[];return[{geom:s.geom2.fromPoints(l),color:A??c?.color}]}if(g===E9){const l=(I??[]).flatMap(h=>$D(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===hne||g===Wl||g===iW||g===Q9||g===Gp){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===hne){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===Wl){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===iW){const B=c?.radius??1,C=c?.center??[0,0,0];l=i.sphere({radius:B,center:C})}else if(g===Gp){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 $D(l,A,e)}return(I??[]).flatMap(l=>$D(l,A,e))}function KRt(t,A){return{geometries:$D(t,void 0,{jscad:A})}}function _ne(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 Ng;if(o.setAttribute("position",new bc(new Float32Array(A),3)),o.setIndex(e),i.length>0&&o.setAttribute("color",new bc(new Float32Array(i),3)),t.transforms){const s=new As;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 Ng;if(i.setAttribute("position",new bc(new Float32Array(A),3)),e.length>0&&i.setAttribute("color",new bc(new Float32Array(e),3)),t.transforms){const n=new As;n.fromArray(t.transforms),i.applyMatrix4(n)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Ng}function qRt(t,A){const e=hdA(JRt,{footprint:t});return KRt(e,A)}var ORt=tg(ZO()),kne=V.createContext(null),WRt=()=>{const t=V.useContext(kne);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},ZRt=({children:t})=>{const{camera:A,renderer:e}=gd(),[i,n]=V.useState([]),o=V.useMemo(()=>new Uut,[]),s=V.useMemo(()=>new fn,[]),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 p={mousePosition:[u.point.x,u.point.y,u.point.z]};a.current!==d?(a.current?.onUnhover(),d.onHover(p),a.current=d):d.onHover(p)}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(kne.Provider,{value:B,children:t})},VRt=({children:t,object:A,onHover:e,onUnhover:i,isHovered:n})=>{const{addHoverable:o,removeHoverable:s}=WRt();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})},x9=VRt,jRt=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=gd(),g=V.useMemo(()=>{if(!A)return null;const{geometries:c}=qRt(A,ORt),I=new Zh;for(const l of c.flat(1/0)){const B=l.geom;if(!B||!B.polygons&&!B.sides)continue;const C=new en(l.color);C.convertLinearToSRGB();const Q={...B,color:[C.r,C.g,C.b]},h=_ne(Q),E=new X0({vertexColors:!0,side:OQ,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new co(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 co&&c.material instanceof X0&&(o?(c.material.emissive.setHex(255),c.material.emissiveIntensity=.2):c.material.emissiveIntensity=0)})},[o,g]),g?W.jsx(x9,{isHovered:o,onHover:i,onUnhover:n,object:g}):null},vne=new WeakMap,zRt=()=>{const t=new oI;return t.name="fallback-environment-map",t.mapping=Aq,t},XRt=t=>{if(!t)return null;const A=t,e=vne.get(A);if(e)return e;let i;if(t instanceof Fq){const n=new fcA(t);i=n.fromScene(adt(),.04).texture,n.dispose()}else i=zRt();return vne.set(A,i),i};function $Rt(t){const A=new Em;let e=!1;t.updateWorldMatrix(!0,!1);const i=t.parent?t.parent.matrixWorld.clone().invert():new As;return t.traverse(n=>{if(n.updateWorldMatrix(!0,!1),n instanceof co&&n.geometry&&(n.geometry.boundingBox||n.geometry.computeBoundingBox(),n.geometry.boundingBox)){const o=n.geometry.boundingBox.clone();o.applyMatrix4(n.matrixWorld),o.applyMatrix4(i),e?A.union(o):(A.copy(o),e=!0)}}),e?A:null}function ANt(t){const A=$Rt(t);return A?A.getSize(new Me):new Me}function eNt(t,A,e="contain_within_bounds"){if(!A)return[1,1,1];const i=ANt(t),n=[i.x>0?A[0]/i.x:1,i.y>0?A[1]/i.y:1,i.z>0?A[2]/i.z:1];if(e==="fill_bounds")return n;const o=Math.min(...n);return[o,o,o]}var GdA=({model:t,position:A,rotation:e,modelOffset:i=[0,0,0],modelRotation:n=[0,0,0],sourceCoordinateTransform:o,modelSize:s,modelFitMode:r="contain_within_bounds",scale:a})=>{const{rootObject:g}=gd(),c=V.useMemo(()=>new Zh,[]),I=V.useMemo(()=>new Zh,[]),l=V.useMemo(()=>new Zh,[]),B=V.useMemo(()=>new Zh,[]);return V.useEffect(()=>(c.add(I),()=>{c.remove(I)}),[c,I]),V.useEffect(()=>(I.add(l),()=>{I.remove(l)}),[I,l]),V.useEffect(()=>(l.add(B),()=>{l.remove(B)}),[l,B]),V.useEffect(()=>{for(;B.children.length>0;){const C=B.children[0];if(!C)break;B.remove(C)}t&&B.add(t)},[B,t]),V.useEffect(()=>{if(!o){B.matrixAutoUpdate=!0,B.position.set(0,0,0),B.rotation.set(0,0,0),B.scale.set(1,1,1),B.updateMatrix();return}B.matrixAutoUpdate=!1,B.matrix.copy(o),B.matrixWorldNeedsUpdate=!0},[B,o]),V.useEffect(()=>{if(g)return g.add(c),()=>{g.remove(c)}},[g,c]),V.useEffect(()=>{if(A?c.position.fromArray(A):c.position.set(0,0,0),e?c.rotation.fromArray(e):c.rotation.set(0,0,0),l.position.fromArray(i),l.rotation.fromArray(n),l.scale.setScalar(a??1),!t){I.scale.set(1,1,1);return}I.scale.set(1,1,1),I.updateWorldMatrix(!0,!0);const C=eNt(l,s,r);I.scale.set(C[0],C[1],C[2])},[c,I,t,r,i,B,l,n,s,A,e,a]),{boardTransformGroup:c}},Fne=1.25;function Mne({gltfUrl:t,position:A,rotation:e,modelOffset:i=[0,0,0],modelRotation:n=[0,0,0],sourceCoordinateTransform:o,modelSize:s,modelFitMode:r="contain_within_bounds",onHover:a,onUnhover:g,isHovered:c,scale:I,isTranslucent:l=!1}){const{renderer:B}=gd(),[C,Q]=V.useState(null),[h,E]=V.useState(null),{boardTransformGroup:u}=GdA({model:C,position:A,rotation:e,modelOffset:i,modelRotation:n,sourceCoordinateTransform:o,modelSize:s,modelFitMode:r,scale:I});if(V.useEffect(()=>{if(!t)return;const d=new cdt;let p=!0;return d.load(t,y=>{if(!p)return;const w=y.scene;w.traverse(D=>{if(D instanceof co&&D.material){const x=_=>{_.transparent=l,_.opacity=l?.5:1,_.depthWrite=!l,_.needsUpdate=!0};Array.isArray(D.material)?D.material.forEach(x):x(D.material),D.renderOrder=l?2:1}}),Q(w)},void 0,y=>{if(!p)return;console.error(`An error happened loading ${t}`,y);const w=y instanceof Error?y:new Error(`Failed to load glTF model from ${t}`);E(w)}),()=>{p=!1}},[t,l]),V.useEffect(()=>{if(!C||!B)return;const d=XRt(B);if(!d)return;const p=[],y=w=>{w instanceof X0&&(p.push({material:w,envMap:w.envMap??null,envMapIntensity:w.envMapIntensity??1}),w.envMap=d,(typeof w.envMapIntensity!="number"||w.envMapIntensity<Fne)&&(w.envMapIntensity=Fne),w.needsUpdate=!0)};return C.traverse(w=>{if(!(w instanceof co))return;const D=w.material;Array.isArray(D)?D.forEach(y):D&&y(D)}),()=>{p.forEach(({material:w,envMap:D,envMapIntensity:x})=>{w.envMap=D,w.envMapIntensity=x,w.needsUpdate=!0})}},[C,B]),V.useEffect(()=>{C&&C.traverse(d=>{d instanceof co&&d.material instanceof X0&&(c?(d.material.emissive.setHex(255),d.material.emissiveIntensity=.2):d.material.emissiveIntensity=0)})},[c,C]),h)throw h;return C?W.jsx(x9,{isHovered:c,onHover:a,onUnhover:g,object:u}):null}var tNt=tg(Gie()),iNt=tg(ZO()),nNt=({jscadPlan:t,positionOffset:A,rotationOffset:e,modelOffset:i=[0,0,0],modelRotation:n=[0,0,0],sourceCoordinateTransform:o,modelSize:s,modelFitMode:r="contain_within_bounds",onHover:a,onUnhover:g,isHovered:c,scale:I,isTranslucent:l=!1})=>{const{threeGeom:B,material:C}=V.useMemo(()=>{const E=(0,tNt.executeJscadOperations)(iNt.default,t);if(!E||!E.polygons&&!E.sides)return{threeGeom:null,material:null};const u=_ne(E),d=new X0({vertexColors:!0,side:OQ,transparent:l,opacity:l?.5:1,depthWrite:!l});return{threeGeom:u,material:d}},[t,l]),Q=V.useMemo(()=>{if(!B)return null;const E=new co(B,C);return E.renderOrder=l?2:1,E},[B,C,l]),{boardTransformGroup:h}=GdA({model:Q,position:A,rotation:e,modelOffset:i,modelRotation:n,sourceCoordinateTransform:o,modelSize:s,modelFitMode:r,scale:I});return V.useEffect(()=>{if(C)if(c){const E=new en(C.color.getHex());C.emissive.copy(E),C.emissive.setRGB(0,0,1),C.emissiveIntensity=.2}else C.emissiveIntensity=0},[c,C]),B?W.jsx(x9,{isHovered:c,onHover:a,onUnhover:g,object:h}):null};function oNt(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(A,e,i)=>`${e} ${i.replace(/-/g,"_")}`)}async function sNt(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 Vdt().parse(oNt(e),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function rNt(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 sNt(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 npt;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 Odt;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 aNt({url:t,position:A,rotation:e,modelOffset:i=[0,0,0],modelRotation:n=[0,0,0],sourceCoordinateTransform:o,modelSize:s,modelFitMode:r="contain_within_bounds",onHover:a,onUnhover:g,isHovered:c,scale:I,isTranslucent:l=!1}){const B=rNt(t),C=V.useMemo(()=>B&&!(B instanceof Error)?(B.traverse(h=>{if(h instanceof co&&h.material){const E=u=>{u.transparent=l,u.opacity=l?.5:1,u.depthWrite=!l,u.needsUpdate=!0};Array.isArray(h.material)?h.material.forEach(E):E(h.material),h.renderOrder=l?2:1}}),B):new co(new kw(.5,.5,.5),new X0({transparent:!0,color:"red",opacity:.25})),[B,l]),{boardTransformGroup:Q}=GdA({model:C,position:Array.isArray(A)?A:A?[A.x,A.y,A.z]:void 0,rotation:Array.isArray(e)?e:e?[e.x,e.y,e.z]:void 0,modelOffset:i,modelRotation:n,sourceCoordinateTransform:o,modelSize:s,modelFitMode:r,scale:I});if(B instanceof Error)throw B;return W.jsx(x9,{isHovered:c,onHover:a,onUnhover:g,object:Q})}var LdA,gNt="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function cNt(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 INt(){if(!LdA){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");LdA=cNt(t)({locateFile:e=>`${gNt}/${e}`})}return LdA}function lNt(t){const A=new Zh;for(const e of t){const i=e.attributes.position?.array??[],n=e.index?.array??[];if(!i.length||!n.length)continue;const o=new Ng;o.setAttribute("position",new es(i,3));const s=e.attributes.normal?.array??[];s.length?o.setAttribute("normal",new es(s,3)):o.computeVertexNormals(),o.setIndex(n);const r=new X0({color:e.color?new en(e.color[0],e.color[1],e.color[2]):new en(.82,.82,.82)}),a=new co(o,r);a.name=e.name,A.add(a)}return A}async function BNt(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 INt()).ReadStepFile(new Uint8Array(e),null);if(!n.success||!n.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=lNt(n.meshes),s=new XcA;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 Rne="step-glb-cache:";function CNt(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 QNt(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 hNt(t){try{const A=localStorage.getItem(`${Rne}${t}`);return A?QNt(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function Nne(t,A){try{const e=CNt(A);localStorage.setItem(`${Rne}${t}`,e)}catch(e){console.warn("Failed to write STEP GLB cache",e)}}function ENt(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var uNt=({stepUrl:t,position:A,rotation:e,modelOffset:i,modelRotation:n,sourceCoordinateTransform:o,modelSize:s,modelFitMode:r,scale:a,onHover:g,onUnhover:c,isHovered:I,isTranslucent:l})=>{const[B,C]=V.useState(null);return V.useEffect(()=>{let Q=!0,h=null,E=!0;const u=ENt(),d=hNt(t);if(d){const w={arrayBuffer:d,blobUrl:URL.createObjectURL(new Blob([d],{type:"model/gltf-binary"}))};return u.completed.set(t,w),h=w.blobUrl,E=!1,C(w.blobUrl),()=>{Q=!1,h&&E&&URL.revokeObjectURL(h)}}const p=u.completed.get(t);if(p)return h=p.blobUrl,E=!1,C(p.blobUrl),Nne(t,p.arrayBuffer),()=>{Q=!1,h&&E&&URL.revokeObjectURL(h)};let y=u.inProgress.get(t);return y||(y=BNt(t).then(w=>{const D={arrayBuffer:w,blobUrl:URL.createObjectURL(new Blob([w],{type:"model/gltf-binary"}))};return u.completed.set(t,D),u.inProgress.delete(t),D}).catch(w=>{throw u.inProgress.delete(t),w}),u.inProgress.set(t,y)),y.then(w=>{Q&&(h=w.blobUrl,E=!1,C(w.blobUrl),Nne(t,w.arrayBuffer))}).catch(w=>{console.error("Failed to convert STEP file to GLB",w),Q&&C(null)}),()=>{Q=!1,h&&E&&URL.revokeObjectURL(h)}},[t]),B?W.jsx(Mne,{gltfUrl:B,position:A,rotation:e,modelOffset:i,modelRotation:n,sourceCoordinateTransform:o,modelSize:s,modelFitMode:r,scale:a,onHover:g,onUnhover:c,isHovered:I,isTranslucent:l}):null};function rW(t,A){let{x:e,y:i,z:n}=t;if(A.axisMapping){const o={x:e,y:i,z:n};A.axisMapping.x&&(e=UdA(o,A.axisMapping.x)),A.axisMapping.y&&(i=UdA(o,A.axisMapping.y)),A.axisMapping.z&&(n=UdA(o,A.axisMapping.z))}if(e*=A.flipX??1,i*=A.flipY??1,n*=A.flipZ??1,A.rotation){if(A.rotation.x){const o=A.rotation.x*Math.PI/180,s=Math.cos(o),r=Math.sin(o),a=i*s-n*r,g=i*r+n*s;i=a,n=g}if(A.rotation.y){const o=A.rotation.y*Math.PI/180,s=Math.cos(o),r=Math.sin(o),a=e*s+n*r,g=-e*r+n*s;e=a,n=g}if(A.rotation.z){const o=A.rotation.z*Math.PI/180,s=Math.cos(o),r=Math.sin(o),a=e*s-i*r,g=e*r+i*s;e=a,i=g}}return{x:e,y:i,z:n}}function UdA(t,A){switch(A){case"x":return t.x;case"y":return t.y;case"z":return t.z;case"-x":return-t.x;case"-y":return-t.y;case"-z":return-t.z;default:return 0}}var HdA={STEP_INVERTED:{axisMapping:{x:"-x",y:"z",z:"-y"}},Z_UP_TO_Y_UP_USB_FIX:{axisMapping:{x:"x",y:"-z",z:"y"},flipZ:-1},FOOTPRINTER_MODEL_TRANSFORM:{axisMapping:{x:"x",y:"-z",z:"y"},flipX:-1,rotation:{x:180,y:180}}};function dNt(t,A){if(A.coordinateTransform)return A.coordinateTransform;if(!A.usingGlbCoordinates){if(A.hasFootprinterModel)return HdA.FOOTPRINTER_MODEL_TRANSFORM;if(!A.usingObjFormat)return A.usingStepFormat?HdA.STEP_INVERTED:HdA.Z_UP_TO_Y_UP_USB_FIX}}function S9(t,A){return dNt(t,{usingGlbCoordinates:A==="gltf"||A==="glb"||A==="jscad",usingObjFormat:A==="obj"||A==="wrl",usingStepFormat:A==="step",hasFootprinterModel:A==="footprinter"})}function aW(t){if(!t)return;const A=rW({x:1,y:0,z:0},t),e=rW({x:0,y:1,z:0},t),i=rW({x:0,y:0,z:1},t);return new As().makeBasis(new Me(A.x,A.y,A.z),new Me(e.x,e.y,e.z),new Me(i.x,i.y,i.z))}function hb(t){return t*Math.PI/180}function pNt(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,hb(-90),0];case"x-":return[0,hb(90),0];case"y+":return[hb(90),0,0];case"y-":return[hb(-90),0,0];case"z-":return[hb(180),0,0];default:return[0,0,0]}}function fNt(t,A,e){if(!t.position)return;let i=t.position.z;return A==="bottom"&&t.position.z>=0&&(i=-(t.position.z+e)),[t.position.x,t.position.y,i]}function yNt(t,A){return t.rotation?[hb(t.rotation.x),hb(t.rotation.y),hb(t.rotation.z)]:A==="bottom"?[Math.PI,0,0]:[0,0,0]}function mNt(t,A){const e=new Me(t.x,t.y,t.z),i=new od(A[0],A[1],A[2],"XYZ");return e.applyEuler(i),[e.x,e.y,e.z]}function wNt(t,A,e){if(!t.model_origin_position)return[0,0,0];const i=A?rW(t.model_origin_position,A):t.model_origin_position;return mNt(i,e)}function DNt(t,A){const e=fNt(t,A.layer,A.pcbThickness),i=yNt(t,A.layer),n=S9(t,A.modelType),o=pNt(t.model_board_normal_direction??"z+"),s=wNt(t,n,o);return{position:e,rotation:i,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:o,scale:t.model_unit_to_mm_scale_factor??void 0,fitMode:t.model_object_fit??"contain_within_bounds",size:t.size?[t.size.x,t.size.y,t.size.z]:void 0}}var xNt=t=>t.model_glb_url||t.model_gltf_url?t.model_glb_url?"glb":"gltf":t.model_obj_url||t.model_wrl_url||t.model_stl_url?t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj":t.model_jscad?"jscad":t.footprinter_string?"footprinter":t.model_step_url?"step":"unknown",SNt=t=>t==="step"?"glb":t,bNt=(t,A)=>{if(t)return A?A(t):t},_Nt=(...t)=>t,YdA=class extends Qn.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}},kNt=({error:t,onError:A})=>(V.useEffect(()=>{A(t)},[t,A]),null),Gne=({cad_component:t,circuitJson:A,resolveStaticAsset:e})=>{const i=Hie(A),[n,o]=V.useState(!1),{visibility:s}=o3(),[r,a]=V.useState(null),g=V.useCallback(q=>{q?.mousePosition?(o(!0),a(q.mousePosition)):(o(!1),a(null))},[]),c=V.useCallback(()=>{o(!1),a(null)},[]),I=V.useMemo(()=>wn(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),l=V.useMemo(()=>A.filter(Z=>Z.type==="pcb_plated_hole"&&Z.pcb_component_id===t.pcb_component_id).length>0,[A,t.pcb_component_id]),B=V.useCallback(q=>bNt(q,e),[e]),C=B(t.model_wrl_url??t.model_stl_url??t.model_obj_url),Q=B(t.model_glb_url??t.model_gltf_url),h=B(t.model_step_url),[E,u]=V.useState(0),[d,p]=V.useState(null);V.useEffect(()=>{u(0),p(null)},[t.cad_component_id,C,Q,h]);const w=A.find(q=>q.type==="pcb_component"&&q.source_component_id===t.source_component_id)?.layer??"top",D=xNt(t),x=SNt(D),_=t.model_glb_url?"glb":"gltf",S=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",N=V.useMemo(()=>DNt(t,{layer:w,pcbThickness:i,modelType:x}),[t,w,i,x]),F=_Nt(...N.rotation),L=N.position,Y=V.useMemo(()=>{const q=[];return Q&&q.push(W.jsx(Mne,{gltfUrl:Q,position:L,rotation:F,modelOffset:N.modelPosition,modelRotation:N.modelRotation,sourceCoordinateTransform:aW(S9(t,_)),scale:N.scale,modelSize:N.size,modelFitMode:N.fitMode,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${Q}`)),C&&q.push(W.jsx(aNt,{url:C,position:L,rotation:F,modelOffset:N.modelPosition,modelRotation:N.modelRotation,sourceCoordinateTransform:aW(S9(t,S)),scale:N.scale,modelSize:N.size,modelFitMode:N.fitMode,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${C}`)),h&&!t.model_jscad&&!t.footprinter_string&&q.push(W.jsx(uNt,{stepUrl:h,position:L,rotation:F,modelOffset:N.modelPosition,modelRotation:N.modelRotation,sourceCoordinateTransform:aW(S9(t,x)),scale:N.scale,modelSize:N.size,modelFitMode:N.fitMode,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${h}`)),q},[L,t.cad_component_id,t.footprinter_string,t.model_jscad,t.show_as_translucent_model,Q,_,g,c,n,S,N.modelPosition,N.modelRotation,N.scale,N.fitMode,N.size,x,F,h,C]);let J=null;if(Y.length>0){if(E>=Y.length){if(d)throw d;return null}J=W.jsx(YdA,{fallback:({error:q})=>W.jsx(kNt,{error:q,onError:Z=>{p(Z),u(X=>Math.max(X,E+1))}}),children:Y[E]},`${t.cad_component_id}-fallback-${E}`)}else t.model_jscad?J=W.jsx(nNt,{jscadPlan:t.model_jscad,positionOffset:L,rotationOffset:F,modelOffset:N.modelPosition,modelRotation:N.modelRotation,sourceCoordinateTransform:aW(S9(t,"jscad")),scale:N.scale,modelSize:N.size,modelFitMode:N.fitMode,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(J=W.jsx(jRt,{positionOffset:L,rotationOffset:F,footprint:t.footprinter_string,scale:N.scale,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:[J,n&&r?W.jsx(Jie,{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]})},Lne={version:"0.0.545"};function vNt(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var FNt=t=>{t.outputColorSpace=yw,t.toneMapping=oPA,t.toneMappingExposure=1},Une="cadViewerCameraStateSession",Hne=(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(Une,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},JdA=(t,A)=>{try{const e=sessionStorage.getItem(Une);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}},Yne=V.createContext(void 0),MNt=({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 od(0,0,0)),B=V.useMemo(()=>{const[E,u,d]=e??[5,-5,5],p=Math.hypot(E-A.x,u-A.y,d-A.z);return p>0?p:5},[e,A]),C=V.useCallback(E=>{const u=[A.x,A.y,A.z],d=n.current,p=i.current;let y=B;switch(d&&p&&(y=d.position.distanceTo(p.target)),E){case"Top Center Angled":{const w=y/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+y],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-y*.6,A.y-y*.6,A.z+y*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+y*.6,A.y-y*.6,A.z+y*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-y,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+y,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-y,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:Hne,loadCameraFromSession:JdA}),[A,B,o,C,Q,r,g,I]);return W.jsx(Yne.Provider,{value:h,children:t})},Eb=()=>{const t=V.useContext(Yne);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},RNt=V.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:n},o)=>{const{cameraType:s}=Eb(),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 J4,[]);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;vNt(r.current);const E=new Fq({antialias:!0,alpha:!0});FNt(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 Wh(75,u,.1,1e3):new y8(-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 p;const y=new but,w=()=>{const x=y.getElapsedTime(),_=y.getDelta();c.current.forEach(S=>S(x,_)),E.render(Q,d),p=requestAnimationFrame(w)};w();const D=()=>{if(r.current){const x=r.current.clientWidth/r.current.clientHeight;d instanceof Wh?d.aspect=x:d instanceof y8&&(d.left=-10*x,d.right=10*x,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(p),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(Yie.Provider,{value:a,children:W.jsx(ZRt,{children:t})})})}),NNt=({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}=gd(),l=V.useMemo(()=>!c||!I?null:new spt(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:WS.ROTATE,MIDDLE:WS.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]),l9(()=>{l?.update()},[l]),null},GNt=`
5156
+ `).replace(/d 0\./g,"d 1."),B=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new Odt;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 aNt({url:t,position:A,rotation:e,modelOffset:i=[0,0,0],modelRotation:n=[0,0,0],sourceCoordinateTransform:o,modelSize:s,modelFitMode:r="contain_within_bounds",onHover:a,onUnhover:g,isHovered:c,scale:I,isTranslucent:l=!1}){const B=rNt(t),C=V.useMemo(()=>B&&!(B instanceof Error)?(B.traverse(h=>{if(h instanceof co&&h.material){const E=u=>{u.transparent=l,u.opacity=l?.5:1,u.depthWrite=!l,u.needsUpdate=!0};Array.isArray(h.material)?h.material.forEach(E):E(h.material),h.renderOrder=l?2:1}}),B):new co(new kw(.5,.5,.5),new X0({transparent:!0,color:"red",opacity:.25})),[B,l]),{boardTransformGroup:Q}=GdA({model:C,position:Array.isArray(A)?A:A?[A.x,A.y,A.z]:void 0,rotation:Array.isArray(e)?e:e?[e.x,e.y,e.z]:void 0,modelOffset:i,modelRotation:n,sourceCoordinateTransform:o,modelSize:s,modelFitMode:r,scale:I});if(B instanceof Error)throw B;return W.jsx(x9,{isHovered:c,onHover:a,onUnhover:g,object:Q})}var LdA,gNt="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function cNt(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 INt(){if(!LdA){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");LdA=cNt(t)({locateFile:e=>`${gNt}/${e}`})}return LdA}function lNt(t){const A=new Zh;for(const e of t){const i=e.attributes.position?.array??[],n=e.index?.array??[];if(!i.length||!n.length)continue;const o=new Ng;o.setAttribute("position",new es(i,3));const s=e.attributes.normal?.array??[];s.length?o.setAttribute("normal",new es(s,3)):o.computeVertexNormals(),o.setIndex(n);const r=new X0({color:e.color?new en(e.color[0],e.color[1],e.color[2]):new en(.82,.82,.82)}),a=new co(o,r);a.name=e.name,A.add(a)}return A}async function BNt(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 INt()).ReadStepFile(new Uint8Array(e),null);if(!n.success||!n.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=lNt(n.meshes),s=new XcA;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 Rne="step-glb-cache:";function CNt(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 QNt(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 hNt(t){try{const A=localStorage.getItem(`${Rne}${t}`);return A?QNt(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function Nne(t,A){try{const e=CNt(A);localStorage.setItem(`${Rne}${t}`,e)}catch(e){console.warn("Failed to write STEP GLB cache",e)}}function ENt(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var uNt=({stepUrl:t,position:A,rotation:e,modelOffset:i,modelRotation:n,sourceCoordinateTransform:o,modelSize:s,modelFitMode:r,scale:a,onHover:g,onUnhover:c,isHovered:I,isTranslucent:l})=>{const[B,C]=V.useState(null);return V.useEffect(()=>{let Q=!0,h=null,E=!0;const u=ENt(),d=hNt(t);if(d){const w={arrayBuffer:d,blobUrl:URL.createObjectURL(new Blob([d],{type:"model/gltf-binary"}))};return u.completed.set(t,w),h=w.blobUrl,E=!1,C(w.blobUrl),()=>{Q=!1,h&&E&&URL.revokeObjectURL(h)}}const p=u.completed.get(t);if(p)return h=p.blobUrl,E=!1,C(p.blobUrl),Nne(t,p.arrayBuffer),()=>{Q=!1,h&&E&&URL.revokeObjectURL(h)};let y=u.inProgress.get(t);return y||(y=BNt(t).then(w=>{const D={arrayBuffer:w,blobUrl:URL.createObjectURL(new Blob([w],{type:"model/gltf-binary"}))};return u.completed.set(t,D),u.inProgress.delete(t),D}).catch(w=>{throw u.inProgress.delete(t),w}),u.inProgress.set(t,y)),y.then(w=>{Q&&(h=w.blobUrl,E=!1,C(w.blobUrl),Nne(t,w.arrayBuffer))}).catch(w=>{console.error("Failed to convert STEP file to GLB",w),Q&&C(null)}),()=>{Q=!1,h&&E&&URL.revokeObjectURL(h)}},[t]),B?W.jsx(Mne,{gltfUrl:B,position:A,rotation:e,modelOffset:i,modelRotation:n,sourceCoordinateTransform:o,modelSize:s,modelFitMode:r,scale:a,onHover:g,onUnhover:c,isHovered:I,isTranslucent:l}):null};function rW(t,A){let{x:e,y:i,z:n}=t;if(A.axisMapping){const o={x:e,y:i,z:n};A.axisMapping.x&&(e=UdA(o,A.axisMapping.x)),A.axisMapping.y&&(i=UdA(o,A.axisMapping.y)),A.axisMapping.z&&(n=UdA(o,A.axisMapping.z))}if(e*=A.flipX??1,i*=A.flipY??1,n*=A.flipZ??1,A.rotation){if(A.rotation.x){const o=A.rotation.x*Math.PI/180,s=Math.cos(o),r=Math.sin(o),a=i*s-n*r,g=i*r+n*s;i=a,n=g}if(A.rotation.y){const o=A.rotation.y*Math.PI/180,s=Math.cos(o),r=Math.sin(o),a=e*s+n*r,g=-e*r+n*s;e=a,n=g}if(A.rotation.z){const o=A.rotation.z*Math.PI/180,s=Math.cos(o),r=Math.sin(o),a=e*s-i*r,g=e*r+i*s;e=a,i=g}}return{x:e,y:i,z:n}}function UdA(t,A){switch(A){case"x":return t.x;case"y":return t.y;case"z":return t.z;case"-x":return-t.x;case"-y":return-t.y;case"-z":return-t.z;default:return 0}}var HdA={STEP_INVERTED:{axisMapping:{x:"-x",y:"z",z:"-y"}},Z_UP_TO_Y_UP_USB_FIX:{axisMapping:{x:"x",y:"-z",z:"y"},flipZ:-1},FOOTPRINTER_MODEL_TRANSFORM:{axisMapping:{x:"x",y:"-z",z:"y"},flipX:-1,rotation:{x:180,y:180}}};function dNt(t,A){if(A.coordinateTransform)return A.coordinateTransform;if(!A.usingGlbCoordinates){if(A.hasFootprinterModel)return HdA.FOOTPRINTER_MODEL_TRANSFORM;if(!A.usingObjFormat)return A.usingStepFormat?HdA.STEP_INVERTED:HdA.Z_UP_TO_Y_UP_USB_FIX}}function S9(t,A){return dNt(t,{usingGlbCoordinates:A==="gltf"||A==="glb"||A==="jscad",usingObjFormat:A==="obj"||A==="wrl",usingStepFormat:A==="step",hasFootprinterModel:A==="footprinter"})}function aW(t){if(!t)return;const A=rW({x:1,y:0,z:0},t),e=rW({x:0,y:1,z:0},t),i=rW({x:0,y:0,z:1},t);return new As().makeBasis(new Me(A.x,A.y,A.z),new Me(e.x,e.y,e.z),new Me(i.x,i.y,i.z))}function hb(t){return t*Math.PI/180}function pNt(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,hb(-90),0];case"x-":return[0,hb(90),0];case"y+":return[hb(90),0,0];case"y-":return[hb(-90),0,0];case"z-":return[hb(180),0,0];default:return[0,0,0]}}function fNt(t,A,e){if(!t.position)return;let i=t.position.z;return A==="bottom"&&t.position.z>=0&&(i=-(t.position.z+e)),[t.position.x,t.position.y,i]}function yNt(t,A){return t.rotation?[hb(t.rotation.x),hb(t.rotation.y),hb(t.rotation.z)]:A==="bottom"?[Math.PI,0,0]:[0,0,0]}function mNt(t,A){const e=new Me(t.x,t.y,t.z),i=new od(A[0],A[1],A[2],"XYZ");return e.applyEuler(i),[e.x,e.y,e.z]}function wNt(t,A,e){if(!t.model_origin_position)return[0,0,0];const i=A?rW(t.model_origin_position,A):t.model_origin_position;return mNt(i,e)}function DNt(t,A){const e=fNt(t,A.layer,A.pcbThickness),i=yNt(t,A.layer),n=S9(t,A.modelType),o=pNt(t.model_board_normal_direction??"z+"),s=wNt(t,n,o);return{position:e,rotation:i,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:o,scale:t.model_unit_to_mm_scale_factor??void 0,fitMode:t.model_object_fit??"contain_within_bounds",size:t.size?[t.size.x,t.size.y,t.size.z]:void 0}}var xNt=t=>t.model_glb_url||t.model_gltf_url?t.model_glb_url?"glb":"gltf":t.model_obj_url||t.model_wrl_url||t.model_stl_url?t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj":t.model_jscad?"jscad":t.footprinter_string?"footprinter":t.model_step_url?"step":"unknown",SNt=t=>t==="step"?"glb":t,bNt=(t,A)=>{if(t)return A?A(t):t},_Nt=(...t)=>t,YdA=class extends Qn.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}},kNt=({error:t,onError:A})=>(V.useEffect(()=>{A(t)},[t,A]),null),Gne=({cad_component:t,circuitJson:A,resolveStaticAsset:e})=>{const i=Hie(A),[n,o]=V.useState(!1),{visibility:s}=o3(),[r,a]=V.useState(null),g=V.useCallback(q=>{q?.mousePosition?(o(!0),a(q.mousePosition)):(o(!1),a(null))},[]),c=V.useCallback(()=>{o(!1),a(null)},[]),I=V.useMemo(()=>wn(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),l=V.useMemo(()=>A.filter(Z=>Z.type==="pcb_plated_hole"&&Z.pcb_component_id===t.pcb_component_id).length>0,[A,t.pcb_component_id]),B=V.useCallback(q=>bNt(q,e),[e]),C=B(t.model_wrl_url??t.model_stl_url??t.model_obj_url),Q=B(t.model_glb_url??t.model_gltf_url),h=B(t.model_step_url),[E,u]=V.useState(0),[d,p]=V.useState(null);V.useEffect(()=>{u(0),p(null)},[t.cad_component_id,C,Q,h]);const w=A.find(q=>q.type==="pcb_component"&&q.source_component_id===t.source_component_id)?.layer??"top",D=xNt(t),x=SNt(D),_=t.model_glb_url?"glb":"gltf",S=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",N=V.useMemo(()=>DNt(t,{layer:w,pcbThickness:i,modelType:x}),[t,w,i,x]),F=_Nt(...N.rotation),L=N.position,Y=V.useMemo(()=>{const q=[];return Q&&q.push(W.jsx(Mne,{gltfUrl:Q,position:L,rotation:F,modelOffset:N.modelPosition,modelRotation:N.modelRotation,sourceCoordinateTransform:aW(S9(t,_)),scale:N.scale,modelSize:N.size,modelFitMode:N.fitMode,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${Q}`)),C&&q.push(W.jsx(aNt,{url:C,position:L,rotation:F,modelOffset:N.modelPosition,modelRotation:N.modelRotation,sourceCoordinateTransform:aW(S9(t,S)),scale:N.scale,modelSize:N.size,modelFitMode:N.fitMode,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${C}`)),h&&!t.model_jscad&&!t.footprinter_string&&q.push(W.jsx(uNt,{stepUrl:h,position:L,rotation:F,modelOffset:N.modelPosition,modelRotation:N.modelRotation,sourceCoordinateTransform:aW(S9(t,x)),scale:N.scale,modelSize:N.size,modelFitMode:N.fitMode,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${h}`)),q},[L,t.cad_component_id,t.footprinter_string,t.model_jscad,t.show_as_translucent_model,Q,_,g,c,n,S,N.modelPosition,N.modelRotation,N.scale,N.fitMode,N.size,x,F,h,C]);let J=null;if(Y.length>0){if(E>=Y.length){if(d)throw d;return null}J=W.jsx(YdA,{fallback:({error:q})=>W.jsx(kNt,{error:q,onError:Z=>{p(Z),u(X=>Math.max(X,E+1))}}),children:Y[E]},`${t.cad_component_id}-fallback-${E}`)}else t.model_jscad?J=W.jsx(nNt,{jscadPlan:t.model_jscad,positionOffset:L,rotationOffset:F,modelOffset:N.modelPosition,modelRotation:N.modelRotation,sourceCoordinateTransform:aW(S9(t,"jscad")),scale:N.scale,modelSize:N.size,modelFitMode:N.fitMode,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(J=W.jsx(jRt,{positionOffset:L,rotationOffset:F,footprint:t.footprinter_string,scale:N.scale,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:[J,n&&r?W.jsx(Jie,{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]})},Lne={version:"0.0.546"};function vNt(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var FNt=t=>{t.outputColorSpace=yw,t.toneMapping=oPA,t.toneMappingExposure=1},Une="cadViewerCameraStateSession",Hne=(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(Une,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},JdA=(t,A)=>{try{const e=sessionStorage.getItem(Une);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}},Yne=V.createContext(void 0),MNt=({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 od(0,0,0)),B=V.useMemo(()=>{const[E,u,d]=e??[5,-5,5],p=Math.hypot(E-A.x,u-A.y,d-A.z);return p>0?p:5},[e,A]),C=V.useCallback(E=>{const u=[A.x,A.y,A.z],d=n.current,p=i.current;let y=B;switch(d&&p&&(y=d.position.distanceTo(p.target)),E){case"Top Center Angled":{const w=y/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+y],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-y*.6,A.y-y*.6,A.z+y*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+y*.6,A.y-y*.6,A.z+y*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-y,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+y,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-y,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:Hne,loadCameraFromSession:JdA}),[A,B,o,C,Q,r,g,I]);return W.jsx(Yne.Provider,{value:h,children:t})},Eb=()=>{const t=V.useContext(Yne);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},RNt=V.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:n},o)=>{const{cameraType:s}=Eb(),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 J4,[]);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;vNt(r.current);const E=new Fq({antialias:!0,alpha:!0});FNt(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 Wh(75,u,.1,1e3):new y8(-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 p;const y=new but,w=()=>{const x=y.getElapsedTime(),_=y.getDelta();c.current.forEach(S=>S(x,_)),E.render(Q,d),p=requestAnimationFrame(w)};w();const D=()=>{if(r.current){const x=r.current.clientWidth/r.current.clientHeight;d instanceof Wh?d.aspect=x:d instanceof y8&&(d.left=-10*x,d.right=10*x,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(p),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(Yie.Provider,{value:a,children:W.jsx(ZRt,{children:t})})})}),NNt=({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}=gd(),l=V.useMemo(()=>!c||!I?null:new spt(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:WS.ROTATE,MIDDLE:WS.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]),l9(()=>{l?.update()},[l]),null},GNt=`
5157
5157
  varying vec3 worldPosition;
5158
5158
  void main() {
5159
5159
  worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
@@ -5689,7 +5689,7 @@ test("${g} should solve problem correctly", () => {
5689
5689
  // Add more specific assertions based on expected output
5690
5690
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5691
5691
  })
5692
- `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&W.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},M0e=t=>t.activeSubSolver?[t,...M0e(t.activeSubSolver)]:[t],eoi=({solver:t})=>{const A=M0e(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(Aoi,{solver:e})]},e.constructor.name))})},toi=({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(eoi,{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]})]})},ioi=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},noi=(t,A)=>{const i=t.pipelineDef[A].solverName,n=ioi(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}},ooi=({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})},soi=({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,"%"]})]})},roi=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),aoi=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=roi(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))})]})},TmA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(TmA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=TmA(i));return A},goi=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=TmA(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)}`)}},coi=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>noi(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):goi(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(ooi,{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(soi,{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(aoi,{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))})]})})]})},Ioi=class extends Qn.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function loi({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,p=h.height??0;c(E,u),c(E+d,u+p)}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 Boi=({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(toi,{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(Ioi,{fallback:W.jsx(loi,{graphics:s}),children:W.jsx($ni,{graphics:s})}),a&&W.jsx(coi,{solver:t,onStepUntilPhase:g})]})};const Coi=()=>{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)},[])},Qoi=t=>t.toLowerCase().includes("pack")?jHt:t.toLowerCase().includes("rout")?eYt:NHt,hoi=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);Coi();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=$rA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys($rA).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=Qoi(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(xm,{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(Boi,{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"})})})]})},R0e=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{VK.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{VK.captureException(n,{error_type:i.type})}catch{}}},[e])},N0e="0.0.1774",Eoi={version:N0e},OV=VYA()(jYA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),uoi=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=Iv("eval-version-selection",null),g=OV(B=>B.setLastRunEvalVersion),c=OV(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("")}}},doi=({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}`})]})]})})},poi=t=>{const A=V.useRef(null),e=MI(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function foi(t){const A=yoi(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(woi);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 yoi(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=xoi(n),r=Doi(o,n.props);return n.type!==V.Fragment&&(r.ref=i?vp(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 moi=Symbol("radix.slottable");function woi(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===moi}function Doi(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 xoi(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 WV="Dialog",[G0e,L0e]=dw(WV),[Soi,Ow]=G0e(WV),U0e=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]=GS({prop:i,defaultProp:n??!1,onChange:o,caller:WV});return W.jsx(Soi,{scope:A,triggerRef:r,contentRef:a,contentId:W0(),titleId:W0(),descriptionId:W0(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};U0e.displayName=WV;var H0e="DialogTrigger",Y0e=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Ow(H0e,e),o=RI(A,n.triggerRef);return W.jsx(Ag.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":qmA(n.open),...i,ref:o,onClick:Vn(t.onClick,n.onOpenToggle)})});Y0e.displayName=H0e;var PmA="DialogPortal",[boi,J0e]=G0e(PmA,{forceMount:void 0}),T0e=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Ow(PmA,A);return W.jsx(boi,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(qf,{present:e||o.open,children:W.jsx(oZ,{asChild:!0,container:n,children:s})}))})};T0e.displayName=PmA;var ZV="DialogOverlay",P0e=V.forwardRef((t,A)=>{const e=J0e(ZV,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Ow(ZV,t.__scopeDialog);return o.modal?W.jsx(qf,{present:i||o.open,children:W.jsx(koi,{...n,ref:A})}):null});P0e.displayName=ZV;var _oi=foi("DialogOverlay.RemoveScroll"),koi=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Ow(ZV,e);return W.jsx(BZ,{as:_oi,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(Ag.div,{"data-state":qmA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),K3="DialogContent",K0e=V.forwardRef((t,A)=>{const e=J0e(K3,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Ow(K3,t.__scopeDialog);return W.jsx(qf,{present:i||o.open,children:o.modal?W.jsx(voi,{...n,ref:A}):W.jsx(Foi,{...n,ref:A})})});K0e.displayName=K3;var voi=V.forwardRef((t,A)=>{const e=Ow(K3,t.__scopeDialog),i=V.useRef(null),n=RI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return ofA(o)},[]),W.jsx(q0e,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vn(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Vn(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Vn(t.onFocusOutside,o=>o.preventDefault())})}),Foi=V.forwardRef((t,A)=>{const e=Ow(K3,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(q0e,{...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()}})}),q0e=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Ow(K3,e),a=V.useRef(null),g=RI(A,a);return YpA(),W.jsxs(W.Fragment,{children:[W.jsx(OW,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(Z9,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":qmA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(Roi,{titleId:r.titleId}),W.jsx(Goi,{contentRef:a,descriptionId:r.descriptionId})]})]})}),KmA="DialogTitle",O0e=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Ow(KmA,e);return W.jsx(Ag.h2,{id:n.titleId,...i,ref:A})});O0e.displayName=KmA;var W0e="DialogDescription",Z0e=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Ow(W0e,e);return W.jsx(Ag.p,{id:n.descriptionId,...i,ref:A})});Z0e.displayName=W0e;var V0e="DialogClose",j0e=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Ow(V0e,e);return W.jsx(Ag.button,{type:"button",...i,ref:A,onClick:Vn(t.onClick,()=>n.onOpenChange(!1))})});j0e.displayName=V0e;function qmA(t){return t?"open":"closed"}var z0e="DialogTitleWarning",[Moi,X0e]=ogt(z0e,{contentName:K3,titleName:KmA,docsSlug:"dialog"}),Roi=({titleId:t})=>{const A=X0e(z0e),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5692
+ `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return W.jsxs("div",{className:`relative ${A}`,ref:n,children:[W.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&W.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},M0e=t=>t.activeSubSolver?[t,...M0e(t.activeSubSolver)]:[t],eoi=({solver:t})=>{const A=M0e(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(Aoi,{solver:e})]},e.constructor.name))})},toi=({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(eoi,{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]})]})},ioi=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},noi=(t,A)=>{const i=t.pipelineDef[A].solverName,n=ioi(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}},ooi=({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})},soi=({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,"%"]})]})},roi=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),aoi=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=roi(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))})]})},TmA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(TmA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=TmA(i));return A},goi=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=TmA(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)}`)}},coi=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>noi(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):goi(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(ooi,{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(soi,{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(aoi,{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))})]})})]})},Ioi=class extends Qn.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function loi({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,p=h.height??0;c(E,u),c(E+d,u+p)}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 Boi=({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(toi,{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(Ioi,{fallback:W.jsx(loi,{graphics:s}),children:W.jsx($ni,{graphics:s})}),a&&W.jsx(coi,{solver:t,onStepUntilPhase:g})]})};const Coi=()=>{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)},[])},Qoi=t=>t.toLowerCase().includes("pack")?jHt:t.toLowerCase().includes("rout")?eYt:NHt,hoi=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);Coi();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=$rA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys($rA).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=Qoi(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(xm,{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(Boi,{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"})})})]})},R0e=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{VK.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{VK.captureException(n,{error_type:i.type})}catch{}}},[e])},N0e="0.0.1775",Eoi={version:N0e},OV=VYA()(jYA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),uoi=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=Iv("eval-version-selection",null),g=OV(B=>B.setLastRunEvalVersion),c=OV(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("")}}},doi=({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}`})]})]})})},poi=t=>{const A=V.useRef(null),e=MI(i=>i.recentEvents);V.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function foi(t){const A=yoi(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(woi);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 yoi(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=xoi(n),r=Doi(o,n.props);return n.type!==V.Fragment&&(r.ref=i?vp(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 moi=Symbol("radix.slottable");function woi(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===moi}function Doi(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 xoi(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 WV="Dialog",[G0e,L0e]=dw(WV),[Soi,Ow]=G0e(WV),U0e=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]=GS({prop:i,defaultProp:n??!1,onChange:o,caller:WV});return W.jsx(Soi,{scope:A,triggerRef:r,contentRef:a,contentId:W0(),titleId:W0(),descriptionId:W0(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};U0e.displayName=WV;var H0e="DialogTrigger",Y0e=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Ow(H0e,e),o=RI(A,n.triggerRef);return W.jsx(Ag.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":qmA(n.open),...i,ref:o,onClick:Vn(t.onClick,n.onOpenToggle)})});Y0e.displayName=H0e;var PmA="DialogPortal",[boi,J0e]=G0e(PmA,{forceMount:void 0}),T0e=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Ow(PmA,A);return W.jsx(boi,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(qf,{present:e||o.open,children:W.jsx(oZ,{asChild:!0,container:n,children:s})}))})};T0e.displayName=PmA;var ZV="DialogOverlay",P0e=V.forwardRef((t,A)=>{const e=J0e(ZV,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Ow(ZV,t.__scopeDialog);return o.modal?W.jsx(qf,{present:i||o.open,children:W.jsx(koi,{...n,ref:A})}):null});P0e.displayName=ZV;var _oi=foi("DialogOverlay.RemoveScroll"),koi=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Ow(ZV,e);return W.jsx(BZ,{as:_oi,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(Ag.div,{"data-state":qmA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),K3="DialogContent",K0e=V.forwardRef((t,A)=>{const e=J0e(K3,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Ow(K3,t.__scopeDialog);return W.jsx(qf,{present:i||o.open,children:o.modal?W.jsx(voi,{...n,ref:A}):W.jsx(Foi,{...n,ref:A})})});K0e.displayName=K3;var voi=V.forwardRef((t,A)=>{const e=Ow(K3,t.__scopeDialog),i=V.useRef(null),n=RI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return ofA(o)},[]),W.jsx(q0e,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Vn(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Vn(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:Vn(t.onFocusOutside,o=>o.preventDefault())})}),Foi=V.forwardRef((t,A)=>{const e=Ow(K3,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(q0e,{...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()}})}),q0e=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Ow(K3,e),a=V.useRef(null),g=RI(A,a);return YpA(),W.jsxs(W.Fragment,{children:[W.jsx(OW,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(Z9,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":qmA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(Roi,{titleId:r.titleId}),W.jsx(Goi,{contentRef:a,descriptionId:r.descriptionId})]})]})}),KmA="DialogTitle",O0e=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Ow(KmA,e);return W.jsx(Ag.h2,{id:n.titleId,...i,ref:A})});O0e.displayName=KmA;var W0e="DialogDescription",Z0e=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Ow(W0e,e);return W.jsx(Ag.p,{id:n.descriptionId,...i,ref:A})});Z0e.displayName=W0e;var V0e="DialogClose",j0e=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Ow(V0e,e);return W.jsx(Ag.button,{type:"button",...i,ref:A,onClick:Vn(t.onClick,()=>n.onOpenChange(!1))})});j0e.displayName=V0e;function qmA(t){return t?"open":"closed"}var z0e="DialogTitleWarning",[Moi,X0e]=ogt(z0e,{contentName:K3,titleName:KmA,docsSlug:"dialog"}),Roi=({titleId:t})=>{const A=X0e(z0e),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5693
5693
 
5694
5694
  If you want to hide the \`${A.titleName}\`, you can wrap it with our VisuallyHidden component.
5695
5695
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "dist/index.js",
4
4
  "types": "dist/index.d.ts",
5
5
  "type": "module",
6
- "version": "0.0.1592-libonly",
6
+ "version": "0.0.1593-libonly",
7
7
  "license": "MIT",
8
8
  "repository": {
9
9
  "type": "git",
@@ -51,7 +51,7 @@
51
51
  "@tscircuit/checks": "0.0.115",
52
52
  "@tscircuit/circuit-json-util": "^0.0.90",
53
53
  "@tscircuit/copper-pour-solver": "^0.0.20",
54
- "@tscircuit/core": "^0.0.1128",
54
+ "@tscircuit/core": "^0.0.1130",
55
55
  "@tscircuit/eval": "^0.0.726",
56
56
  "@tscircuit/footprinter": "^0.0.333",
57
57
  "@tscircuit/infer-cable-insertion-point": "^0.0.2",
@@ -60,8 +60,8 @@
60
60
  "@tscircuit/math-utils": "^0.0.36",
61
61
  "@tscircuit/miniflex": "^0.0.4",
62
62
  "@tscircuit/ngspice-spice-engine": "^0.0.8",
63
- "@tscircuit/props": "^0.0.499",
64
- "@tscircuit/runframe": "^0.0.1775",
63
+ "@tscircuit/props": "^0.0.501",
64
+ "@tscircuit/runframe": "^0.0.1776",
65
65
  "@tscircuit/schematic-match-adapt": "^0.0.16",
66
66
  "@tscircuit/schematic-trace-solver": "^v0.0.45",
67
67
  "@tscircuit/simple-3d-svg": "^0.0.41",