@tscircuit/runframe 0.0.1735 → 0.0.1736

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}}),aFt=ae({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,A){var e=nFt(),i=rFt(),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}}),XdA=ae({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,A){A.exports={Tree:aFt()}}}),gFt=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,A){var e=es(),i=zdA(),{Tree:n}=XdA(),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}}),gie=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,A){var e=vo(),i=sJ(),n=gFt(),o=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),cFt=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,A){var e=vo(),i=es(),n=Ck(),o=VdA(),s=jdA(),r=gie(),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}}),IFt=ae({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,A){var e=vo(),i=oJ(),n=ss(),o=es(),s=cFt(),r=gie(),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}}),$dA=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,A){var e=er(),i=Cte(),n=o=>i(o,{skipTriangulation:!0}).map(a=>{const g=a.map(c=>o[c]);return e.create(g)});A.exports=n}}),cie=ae({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,A){var e=es(),i=zdA(),{Tree:n}=XdA(),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}}),ApA=ae({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,A){var e=vo(),i=sJ(),n=cie(),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}}),Iie=ae({"node_modules/@jscad/modeling/src/operations/minkowski/minkowskiSum.js"(t,A){var e=vo(),i=es(),n=er(),o=$dA(),s=ApA(),r=(...B)=>{if(B=e(B),B.length!==2)throw new Error("minkowskiSum requires exactly two geometries");const[C,Q]=B;if(!i.isA(C)||!i.isA(Q))throw new Error("minkowskiSum requires geom3 geometries");const h=i.isConvex(C),E=i.isConvex(Q);if(h&&E)return I(C,Q);if(!h&&E)return a(C,Q);if(h&&!E)return a(Q,C);throw new Error("minkowskiSum of two non-convex geometries is not yet supported")},a=(B,C)=>{const Q=g(B);if(Q.length===0)return i.create();const h=Q.map(E=>I(E,C));return h.length===1?h[0]:s(h)},g=B=>{const C=i.toPolygons(B);if(C.length===0)return[];const Q=[];for(let h=0;h<C.length;h++){const E=C[h],u=E.vertices;let d=0,f=0,m=0;for(let F=0;F<u.length;F++)d+=u[F][0],f+=u[F][1],m+=u[F][2];d/=u.length,f/=u.length,m/=u.length;const w=n.plane(E),D=w[0],S=w[1],_=w[2],b=.1,N=[d-D*b,f-S*b,m-_*b];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 f=Q[d];for(let m=0;m<h.length;m++){const w=h[m];E.push([f[0]+w[0],f[1]+w[1],f[2]+w[2]])}}const u=o(E);return i.create(u)},l=B=>{const C=new Set,Q=[],h=i.toPolygons(B);for(let E=0;E<h.length;E++){const u=h[E].vertices;for(let d=0;d<u.length;d++){const f=u[d],m=`${f[0]},${f[1]},${f[2]}`;C.has(m)||(C.add(m),Q.push(f))}}return Q};A.exports=r}}),lFt=ae({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,A){var e=xn(),i=Ck(),n=es(),o=g=>g.sort((c,I)=>c-I).filter((c,I,l)=>!I||c!==l[I-1]),s=(g,c,I)=>{const l=`${c}`,B=g.get(l);B===void 0?g.set(l,[I]):B.push(I)},r=(g,c)=>{const I=`${c}`;return g.get(I)},a=g=>{const c=i(g),I=n.toPolygons(g),l=I.length,B=new Map,C=e.create();I.forEach((d,f)=>{d.vertices.forEach(m=>{s(B,e.snap(C,m,c),f)})});const Q=I.map(d=>{let f=[];return d.vertices.forEach(m=>{f=f.concat(r(B,e.snap(C,m,c)))}),{e:1,d:o(f)}});B.clear();let h=0;const E=Q.length;for(let d=0;d<E;d++){const f=Q[d];if(f.e>0){const m=new Array(l);m[d]=!0;do h=0,m.forEach((w,D)=>{const S=Q[D];if(S.e>0){S.e=-1;for(let _=0;_<S.d.length;_++)m[S.d[_]]=!0;h++}});while(h>0);f.indexes=m}}const u=[];for(let d=0;d<E;d++)if(Q[d].indexes){const f=[];Q[d].indexes.forEach((m,w)=>f.push(I[w])),u.push(n.create(f))}return u};A.exports=a}}),BFt=ae({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,A){var e=vo(),i=es(),n=lFt(),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}}),CFt=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,A){var e=es(),i=zdA(),{Tree:n}=XdA(),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}}),lie=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,A){var e=vo(),i=sJ(),n=CFt(),o=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),QFt=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,A){var e=vo(),i=es(),n=Ck(),o=VdA(),s=jdA(),r=lie(),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}}),hFt=ae({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,A){var e=vo(),i=oJ(),n=ss(),o=es(),s=QFt(),r=lie(),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}}),Bie=ae({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,A){var e=vo(),i=es(),n=Ck(),o=VdA(),s=jdA(),r=ApA(),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}}),epA=ae({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,A){var e=vo(),i=oJ(),n=ss(),o=es(),s=Bie(),r=ApA(),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}}),w1=ae({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,A){A.exports={intersect:IFt(),minkowski:Iie(),scission:BFt(),subtract:hFt(),union:epA()}}}),YV=ae({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,A){var{EPS:e,TAU:i}=Cr(),n=Tte(),o=KdA(),s=ks(),r=LV(),a=(g,c)=>{const I={delta:1,corners:"edge",closed:!1,segments:16};let{delta:l,corners:B,closed:C,segments:Q}=Object.assign({},I,g);if(Math.abs(l)<e)return c;let h=g.closed?r(c):1;h===0&&(h=1);const E=h>0&&l>=0||h<0&&l<0;l=Math.abs(l);let u=null,d=[];const f=[],m=s.create(),w=c.length;for(let D=0;D<w;D++){const S=(D+1)%w,_=c[D],b=c[S];E?s.subtract(m,_,b):s.subtract(m,b,_),s.normal(m,m),s.normalize(m,m),s.scale(m,m,l);const N=s.add(s.create(),_,m),F=s.add(s.create(),b,m),L=[N,F];if(u!=null&&(C||!C&&S!==0)){const Y=n(u[0],u[1],L[0],L[1]);Y?(d.pop(),L[0]=Y):f.push({c:_,s0:u,s1:L})}u=[N,F],!(S===0&&!C)&&(d.push(L[0]),d.push(L[1]))}if(C&&u!=null){const D=d[0],S=d[1],_=n(u[0],u[1],D,S);if(_)d[0]=_,d.pop();else{const b=c[0],N=[D,S];f.push({c:b,s0:u,s1:N})}}if(B==="edge"){const D=new Map;d.forEach((b,N)=>D.set(b,N));const S=o.create(),_=o.create();f.forEach(b=>{o.fromPoints(S,b.s0[0],b.s0[1]),o.fromPoints(_,b.s1[0],b.s1[1]);const N=o.intersectPointOfLines(S,_);if(Number.isFinite(N[0])&&Number.isFinite(N[1])){const F=b.s0[1],L=D.get(F);d[L]=N,d[(L+1)%d.length]=void 0}else{const F=b.s1[0],L=D.get(F);d[L]=void 0}}),d=d.filter(b=>b!==void 0)}if(B==="round"){let D=Math.floor(Q/4);const S=s.create();f.forEach(_=>{let b=s.angle(s.subtract(S,_.s1[0],_.c));if(b-=s.angle(s.subtract(S,_.s0[1],_.c)),E&&b<0&&(b=b+Math.PI,b<0&&(b=b+Math.PI)),!E&&b>0&&(b=b-Math.PI,b>0&&(b=b-Math.PI)),b!==0){D=Math.floor(Q*(Math.abs(b)/i));const N=b/D,F=s.angle(s.subtract(S,_.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}}),EFt=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,A){var e=ss(),i=YV(),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}}),uFt=ae({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,A){var e=tc(),i=xn(),n=es(),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}}),dFt=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,A){var{EPS:e,TAU:i}=Cr(),n=tc(),o=xn(),s=rie(),r=es(),a=er(),g=Aie(),c=sJ(),I=cie(),l=uFt(),B=(E,u,d)=>{const f=u.toString();if(E.has(f))E.get(f)[1].push(d);else{const m=[u,[d]];E.set(f,m)}},C=(E,u,d)=>{const f=u[0].toString(),m=u[1].toString(),w=f<m?`${f},${m}`:`${m},${f}`;if(E.has(w))E.get(w)[1].push(d);else{const D=[u,[d]];E.set(w,D)}},Q=(E,u)=>{E.findIndex(f=>f===u)<0&&E.push(u)},h=(E,u)=>{const d={delta:1,segments:12},{delta:f,segments:m}=Object.assign({},d,E);let w=r.create();const D=new Map,S=new Map,_=o.create(),b=o.create();return r.toPolygons(u).forEach((F,L)=>{const Y=o.scale(o.create(),a.plane(F),2*f),J=a.transform(n.fromTranslation(n.create(),o.scale(o.create(),Y,-.5)),F),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(S,gA,a.plane(F))}}),S.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 YA=0;YA<m;YA++)Q(gA,YA*i/m);for(let YA=0,QA=Y.length;YA<QA;YA++){const kA=Y[YA],dA=o.dot(eA,kA),qA=o.dot(X,kA);let ZA=Math.atan2(dA,qA);ZA<0&&(ZA+=i),Q(gA,ZA),ZA=Math.atan2(-dA,-qA),ZA<0&&(ZA+=i),Q(gA,ZA)}gA=gA.sort(s);const iA=gA.length;let tA,sA;const aA=[],EA=[],bA=[];for(let YA=-1;YA<iA;YA++){const QA=gA[YA<0?YA+iA:YA],kA=Math.sin(QA),dA=Math.cos(QA);o.scale(_,X,dA*f),o.scale(b,eA,kA*f),o.add(_,_,b);const qA=o.add(o.create(),J,_),ZA=o.add(o.create(),q,_);let ce=!1;if(YA>=0&&o.distance(qA,tA)<e&&(ce=!0),!ce){if(YA>=0){aA.push(qA),EA.push(ZA);const fA=[sA,ZA,qA,tA],ge=a.create(fA);bA.push(ge)}tA=qA,sA=ZA}}EA.reverse(),bA.push(a.create(aA)),bA.push(a.create(EA));const _A=r.create(bA);w=I(w,_A)}),D.forEach(F=>{const L=F[0],Y=F[1],J=Y[0];let q=null,Z=0;for(let iA=1;iA<Y.length;iA++){const tA=Y[iA],sA=o.cross(_,J,tA),aA=o.length(sA);aA>.05&&aA>Z&&(Z=aA,q=tA)}q||(q=o.orthogonal(_,J));const X=o.cross(_,J,q);o.normalize(X,X);const eA=o.cross(b,X,J),gA=g({center:[L[0],L[1],L[2]],radius:f,segments:m,axes:[J,X,eA]});w=I(w,gA)}),c(w)};A.exports=h}}),pFt=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,A){var e=es(),i=epA(),n=dFt(),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}}),fFt=ae({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,A){var e=LV(),i=ks(),n=ss(),o=Lg(),s=YV(),r=c=>{let{external:I,internal:l}=c;e(I)<0?I=I.reverse():l=l.reverse();const B=o.fromPoints({closed:!0},I),C=o.fromPoints({closed:!0},l),Q=n.toSides(n.fromPoints(o.toPoints(B))),h=n.toSides(n.fromPoints(o.toPoints(C)));return Q.push(...h),n.create(Q)},a=(c,I,l,B)=>{const{points:C,external:Q,internal:h}=c,E=Math.floor(I/2),u=[],d=[];if(l==="round"&&E>0){const m=Math.PI/E,w=C[C.length-1],D=i.angle(i.subtract(i.create(),Q[Q.length-1],w)),S=C[0],_=i.angle(i.subtract(i.create(),h[0],S));for(let b=1;b<E;b++){let N=D+m*b,F=i.fromAngleRadians(i.create(),N);i.scale(F,F,B),i.add(F,F,w),u.push(F),N=_+m*b,F=i.fromAngleRadians(i.create(),N),i.scale(F,F,B),i.add(F,F,S),d.push(F)}}const f=[];return f.push(...Q,...u,...h.reverse(),...d),n.fromPoints(f)},g=(c,I)=>{c=Object.assign({},{delta:1,corners:"edge",segments:16},c);const{delta:B,corners:C,segments:Q}=c;if(B<=0)throw new Error("the given delta must be positive for paths");if(!(C==="edge"||C==="chamfer"||C==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const h=I.isClosed,E=o.toPoints(I);if(E.length===0)throw new Error("the given geometry cannot be empty");const u={points:E,external:s({delta:B,corners:C,segments:Q,closed:h},E),internal:s({delta:-B,corners:C,segments:Q,closed:h},E)};return I.isClosed?r(u):a(u,Q,C,B)};A.exports=g}}),tpA=ae({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,A){var e=vo(),i=ss(),n=es(),o=Lg(),s=EFt(),r=pFt(),a=fFt(),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}}),yFt=ae({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,A){var e=ss(),i=HdA(),n=YV(),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}}),mFt=ae({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,A){var e=Lg(),i=YV(),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}}),wFt=ae({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,A){var e=vo(),i=ss(),n=Lg(),o=yFt(),s=mFt(),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}}),Cie=ae({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,A){A.exports={expand:tpA(),offset:wFt()}}}),JV=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,A){var e=tc(),i=xn(),n=ss(),o=m1(),s=HV(),r=(a,g)=>{const c={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:I,twistAngle:l,twistSteps:B,repair:C}=Object.assign({},c,a);if(B<1)throw new Error("twistSteps must be 1 or more");l===0&&(B=1);const Q=i.clone(I),h=n.toSides(g);if(h.length===0)throw new Error("the given geometry cannot be empty");const E=o.fromSides(h);Q[2]<0&&o.reverse(E,E);const u=e.create(),d=(f,m,w)=>{const D=m/B*l,S=i.scale(i.create(),Q,m/B);return e.multiply(u,e.fromZRotation(u,D),e.fromTranslation(e.create(),S)),o.transform(u,w)};return a={numberOfSlices:B+1,capStart:!0,capEnd:!0,repair:C,callback:d},s(a,E)};A.exports=r}}),DFt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,A){var e=ss(),i=Lg(),n=JV(),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}}),SFt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,A){var e=vo(),i=ss(),n=Lg(),o=JV(),s=DFt(),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}}),bFt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,A){var e=Lg(),i=tpA(),n=JV(),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}}),xFt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,A){var{area:e}=eJ(),i=ss(),n=Lg(),o=tpA(),s=JV(),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}}),_Ft=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,A){var e=vo(),i=ss(),n=Lg(),o=bFt(),s=xFt(),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}}),kFt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,A){var{TAU:e}=Cr(),i=tc(),n=ss(),o=HV(),s=m1(),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(b=>b[0][0]>=0);let f=s.fromSides(u);d.length===0&&(f=s.reverse(f));const m=Math.round(h/e*Math.abs(I)),w=m>=2?m:2,D=i.create(),S=i.create(),_=(b,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(S,i.fromZRotation(i.create(),L),D),s.transform(S,F)};return o({numberOfSlices:w+1,callback:_},f)};A.exports=r}}),vFt=ae({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,A){var e=vo(),i=PdA(),n=VD(),o=tc(),s=ss(),r=es(),a=er(),g=Ck(),c=Bie(),I=(B,C)=>{const Q=n.fromNormalAndPoint(n.create(),B.axis,B.origin);if(Number.isNaN(Q[0])||Number.isNaN(Q[1])||Number.isNaN(Q[2])||Number.isNaN(Q[3]))throw new Error("project: invalid axis or origin");const h=g(C),E=h*h*Math.sqrt(3)/4;if(h===0)return s.create();const u=r.toPolygons(C);let d=[];for(let m=0;m<u.length;m++){const w=u[m].vertices.map(_=>n.projectionOfPoint(Q,_)),D=a.create(w),S=a.plane(D);i(Q,S)&&(a.measureArea(D)<E||d.push(D))}if(!i(Q,[0,0,1])){const m=o.fromVectorRotation(o.create(),Q,[0,0,1]);d=d.map(w=>a.transform(m,w))}d=d.sort((m,w)=>a.measureArea(w)-a.measureArea(m));const f=d.map(m=>s.fromPoints(m.vertices));return c(f)},l=(B,...C)=>{const Q={axis:[0,0,1],origin:[0,0,0]},{axis:h,origin:E}=Object.assign({},Q,B);if(C=e(C),C.length===0)throw new Error("wrong number of arguments");B={axis:h,origin:E};const u=C.map(d=>r.isA(d)?I(B,d):d);return u.length===1?u[0]:u};A.exports=l}}),rJ=ae({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,A){A.exports={extrudeFromSlices:HV(),extrudeLinear:SFt(),extrudeRectangular:_Ft(),extrudeRotate:nie(),extrudeHelical:kFt(),project:vFt(),slice:m1()}}}),ipA=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}}),npA=ae({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,A){var e=ss(),i=es(),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}}),FFt=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,A){var e=vo(),i=Lg(),n=ipA(),o=npA(),s=(...r)=>{r=e(r);const a=o(r),g=n(a);return i.fromPoints({closed:!0},g)};A.exports=s}}),MFt=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,A){var e=vo(),i=ss(),n=ipA(),o=npA(),s=(...r)=>{r=e(r);const a=o(r),g=n(a);return g.length<3?i.create():i.fromPoints(g)};A.exports=s}}),RFt=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,A){var e=vo(),i=es(),n=npA(),o=$dA(),s=(...r)=>{r=e(r);const a=n(r);return a.length===0?i.create():i.create(o(a))};A.exports=s}}),Qie=ae({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,A){var e=vo(),i=oJ(),n=ss(),o=es(),s=Lg(),r=FFt(),a=MFt(),g=RFt(),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}}),NFt=ae({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,A){var e=vo(),i=epA(),n=Qie(),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}}),GFt=ae({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,A){A.exports={hull:Qie(),hullChain:NFt(),hullPoints2:ipA(),hullPoints3:$dA()}}}),LFt=ae({"node_modules/@jscad/modeling/src/operations/minkowski/index.js"(t,A){A.exports={minkowskiSum:Iie()}}}),hie=ae({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,A){var e=xn(),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}}),UFt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,A){var e=PdA(),i=xn(),n=er(),o=E=>{const u=n.toPoints(E),d=[];for(let f=0;f<u.length;f++){const m=(f+1)%u.length,w={v1:u[f],v2:u[m]};d.push(w)}for(let f=0;f<d.length;f++){const m=(f+1)%u.length;d[f].next=d[m],d[m].prev=d[f]}return d},s=(E,u)=>{const d=`${u.v1}:${u.v2}`;E.set(d,u)},r=(E,u)=>{const d=`${u.v1}:${u.v2}`;E.delete(d)},a=(E,u)=>{const d=`${u.v2}:${u.v1}`;return E.get(d)},g=(E,u,d)=>{let f=E.prev.v1,m=E.prev.v2,w=u.next.v2;const D=l(f,m,w,d);f=u.prev.v1,m=u.prev.v2,w=E.next.v2;const S=l(f,m,w,d);return[D,S]},c=i.create(),I=i.create(),l=(E,u,d,f)=>{const m=i.subtract(c,u,E),w=i.subtract(I,d,u);return i.cross(m,m,w),i.dot(m,f)},B=E=>{let u;const d=[];for(;E.next;){const f=E.next;d.push(E.v1),E.v1=null,E.v2=null,E.next=null,E.prev=null,E=f}return d.length>0&&(u=n.create(d)),u},C=E=>{if(E.length<2)return E;const u=E[0].plane,d=E.slice(),f=new Map;for(;d.length>0;){const w=d.shift(),D=o(w);for(let S=0;S<D.length;S++){const _=D[S],b=a(f,_);if(b){const N=g(_,b,u);if(N[0]>=0&&N[1]>=0){const F=b.next,L=_.next;_.prev.next=b.next,_.next.prev=b.prev,b.prev.next=_.next,b.next.prev=_.prev,_.v1=null,_.v2=null,_.next=null,_.prev=null,r(f,b),b.v1=null,b.v2=null,b.next=null,b.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(f,F,F.prev),N[1]===0&&Y(f,L,L.prev)}}else _.next&&s(f,_)}}const m=[];return f.forEach(w=>{const D=B(w);D&&m.push(D)}),f.clear(),m},Q=(E,u)=>Math.abs(E[3]-u[3])<15e-8?e(E,u):!1,h=(E,u)=>{const d=[];u.forEach(m=>{const w=d.find(D=>Q(D[0],n.plane(m)));w?w[1].push(m):d.push([n.plane(m),[m]])});let f=[];return d.forEach(m=>{const w=m[1],D=C(w);f=f.concat(D)}),f};A.exports=h}}),HFt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,A){var e=Cr(),i=xn(),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 f=0;f<d.length;f++){const m=d[f];let w=o(m.vertex0);if(w===Q&&(w=o(m.vertex1),w===h&&!(C!==null&&m.polygonindex!==C))){u=f;break}}d.splice(u,1),d.length===0&&g.delete(E),u=c.get(Q).indexOf(E),c.get(Q).splice(u,1),c.get(Q).length===0&&c.delete(Q),u=I.get(h).indexOf(E),I.get(h).splice(u,1),I.get(h).length===0&&I.delete(h)},a=g=>{const c=new Map;for(let I=0;I<g.length;I++){const l=g[I],B=l.vertices.length;if(B>=3){let C=l.vertices[0],Q=o(C);for(let h=0;h<B;h++){let E=h+1;E===B&&(E=0);const u=l.vertices[E],d=o(u),f=`${Q}/${d}`,m=`${d}/${Q}`;if(c.has(m)){const w=c.get(m);w.splice(-1,1),w.length===0&&c.delete(m)}else{const w={vertex0:C,vertex1:u,polygonindex:I};c.has(f)?c.get(f).push(w):c.set(f,[w])}C=u,Q=d}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(c.size>0){const I=new Map,l=new Map,B=new Map;for(const[Q,h]of c)B.set(Q,!0),h.forEach(E=>{const u=o(E.vertex0),d=o(E.vertex1);I.has(u)?I.get(u).push(Q):I.set(u,[Q]),l.has(d)?l.get(d).push(Q):l.set(d,[Q])});const C=g.slice(0);for(;c.size!==0;){for(const h of c.keys())B.set(h,!0);let Q=!1;for(;;){const h=Array.from(B.keys());if(h.length===0)break;const E=h[0];let u=!0;if(c.has(E)){const f=c.get(E)[0];for(let m=0;m<2;m++){const w=m===0?f.vertex0:f.vertex1,D=m===0?f.vertex1:f.vertex0,S=o(w),_=o(D);let b=[];m===0?l.has(S)&&(b=l.get(S)):I.has(S)&&(b=I.get(S));for(let N=0;N<b.length;N++){const F=b[N],L=c.get(F)[0],Y=m===0?L.vertex0:L.vertex1;if(m===0?L.vertex1:L.vertex0,o(Y)===_){r(c,I,l,w,D,null),r(c,I,l,D,w,null),u=!1,m=2,Q=!0;break}else{const 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 iA=i.scale(i.create(),eA,gA);if(i.add(iA,iA,q),i.squaredDistance(iA,Z)<e.EPS*e.EPS){const sA=L.polygonindex,aA=C[sA],EA=o(L.vertex1);let bA=-1;for(let dA=0;dA<aA.vertices.length;dA++)if(o(aA.vertices[dA])===EA){bA=dA;break}const _A=aA.vertices.slice(0);_A.splice(bA,0,D);const YA=n.create(_A);C[sA]=YA,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,m=2,Q=!0;break}}}}}}u&&B.delete(E)}if(!Q)break}g=C}return c.clear(),g};A.exports=a}}),YFt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,A){var e=xn(),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}}),JFt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,A){var e=vo(),i=Ck(),n=ss(),o=es(),s=Lg(),r=hie(),a=UFt(),g=HFt(),c=YFt(),I=(Q,h)=>h,l=(Q,h)=>h,B=(Q,h)=>{const E={snap:!1,simplify:!1,triangulate:!1},{snap:u,simplify:d,triangulate:f}=Object.assign({},E,Q),m=i(h);let w=o.toPolygons(h);u&&(w=r(m,w)),d&&(w=a(m,w)),f&&(w=g(w),w=c(m,w));const D=Object.assign({},h);return D.polygons=w,D},C=(Q,...h)=>{if(h=e(h),h.length===0)throw new Error("wrong number of arguments");const E=h.map(u=>{if(s.isA(u))return I(Q,u);if(n.isA(u))return l(Q,u);if(o.isA(u))return B(Q,u);throw new Error("invalid geometry")});return E.length===1?E[0]:E};A.exports=C}}),TFt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,A){var e=vo(),i=ks(),n=ss(),o=es(),s=Lg(),r=Ck(),a=hie(),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}}),PFt=ae({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,A){A.exports={generalize:JFt(),snap:TFt(),retessellate:sJ()}}}),KFt=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}}),qFt=ae({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,A){var e=vo(),i=KFt(),n=qdA(),{translate:o}=tM(),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}}),TV=ae({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,A){var e=vo(),i=ss(),n=es(),o=Lg(),s=AM(),{translate:r}=tM(),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}}}),PV=ae({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,A){var e=vo(),i=tc(),n=ss(),o=es(),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}}}),OFt=ae({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,A){var e=vo(),i=ss(),n=es(),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}}),iM=ae({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,A){A.exports={align:qFt(),center:TV().center,centerX:TV().centerX,centerY:TV().centerY,centerZ:TV().centerZ,mirror:iJ().mirror,mirrorX:iJ().mirrorX,mirrorY:iJ().mirrorY,mirrorZ:iJ().mirrorZ,rotate:nJ().rotate,rotateX:nJ().rotateX,rotateY:nJ().rotateY,rotateZ:nJ().rotateZ,scale:PV().scale,scaleX:PV().scaleX,scaleY:PV().scaleY,scaleZ:PV().scaleZ,transform:OFt(),translate:tM().translate,translateX:tM().translateX,translateY:tM().translateY,translateZ:tM().translateZ}}}),KV=ae({"node_modules/@jscad/modeling/src/index.js"(t,A){A.exports={colors:GV(),curves:Ykt(),geometries:YdA(),maths:Ivt(),measurements:dvt(),primitives:Qk(),text:zvt(),utils:aie(),booleans:w1(),expansions:Cie(),extrusions:rJ(),hulls:GFt(),minkowski:LFt(),modifiers:PFt(),transforms:iM()}}}),Eie=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)}`)}}}}),WFt=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":"")}}}),ZFt=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=WFt(),o.destroy=l,Object.keys(i).forEach(B=>{o[B]=i[B]}),o.names=[],o.skips=[],o.formatters={};function n(B){let C=0;for(let Q=0;Q<B.length;Q++)C=(C<<5)-C+B.charCodeAt(Q),C|=0;return o.colors[Math.abs(C)%o.colors.length]}o.selectColor=n;function o(B){let C,Q=null,h,E;function u(...d){if(!u.enabled)return;const f=u,m=Number(new Date),w=m-(C||m);f.diff=w,f.prev=C,f.curr=m,C=m,d[0]=o.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let D=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(_,b)=>{if(_==="%%")return"%";D++;const N=o.formatters[b];if(typeof N=="function"){const F=d[D];_=N.call(f,F),d.splice(D,1),D--}return _}),o.formatArgs.call(f,d),(f.log||o.log).apply(f,d)}return u.namespace=B,u.useColors=o.useColors(),u.color=o.selectColor(B),u.extend=s,u.destroy=o.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>Q!==null?Q:(h!==o.namespaces&&(h=o.namespaces,E=o.enabled(B)),E),set:d=>{Q=d}}),typeof o.init=="function"&&o.init(u),u}function s(B,C){const Q=o(this.namespace+(typeof C>"u"?":":C)+B);return Q.log=this.log,Q}function r(B){o.save(B),o.namespaces=B,o.names=[],o.skips=[];const C=(typeof B=="string"?B:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const Q of C)Q[0]==="-"?o.skips.push(Q.slice(1)):o.names.push(Q)}function a(B,C){let Q=0,h=0,E=-1,u=0;for(;Q<B.length;)if(h<C.length&&(C[h]===B[Q]||C[h]==="*"))C[h]==="*"?(E=h,u=Q,h++):(Q++,h++);else if(E!==-1)h=E+1,u++,Q=u;else return!1;for(;h<C.length&&C[h]==="*";)h++;return h===C.length}function g(){const B=[...o.names,...o.skips.map(C=>"-"+C)].join(",");return o.enable(""),B}function c(B){for(const C of o.skips)if(a(B,C))return!1;for(const C of o.names)if(a(B,C))return!0;return!1}function I(B){return B instanceof Error?B.stack||B.message:B}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}A.exports=e}}),VFt=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 kdA<"u"&&"env"in kdA&&(a=kdA.env.DEBUG),a}function s(){try{return localStorage}catch{}}A.exports=ZFt()(t);var{formatters:r}=A.exports;r.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}}}),uie={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},die=V.createContext(void 0),jFt=({children:t})=>{const[A,e]=V.useState(uie),i=V.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),n=V.useCallback(()=>{e(uie)},[]),o=V.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:n}),[A,i,n]);return W.jsx(die.Provider,{value:o,children:t})},nM=()=>{const t=V.useContext(die);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},opA=1.2;function pie(t){return V.useMemo(()=>{if(!t)return opA;try{return wn(t).pcb_board.list()[0]?.thickness??opA}catch{return opA}},[t])}var fie=V.createContext(null),rd=()=>{const t=V.useContext(fie);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},aJ=(t,A=[])=>{const{addFrameListener:e,removeFrameListener:i}=rd();Qn.useEffect(()=>(e(t),()=>i(t)),[e,i,...A])},gJ={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},yie=({children:t,position:A,style:e})=>{const{camera:i,renderer:n}=rd(),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(QW.createPortal(t,o.current)),()=>{a.contains(o.current)&&a.removeChild(o.current)}},[n,t]),aJ(()=>{if(!i||!o.current||!n)return;const a=new Re(...A);a.project(i);const g=n.domElement.getBoundingClientRect(),c=Math.round((a.x+1)/2*g.width),I=Math.round((-a.y+1)/2*g.height);o.current.style.position="absolute",o.current.style.left=`${c}px`,o.current.style.top=`${I}px`,o.current.style.pointerEvents="none",o.current.style.zIndex=gJ.htmlElements.toString(),e&&Object.assign(o.current.style,e)},[i,n,A,e]),s},mie={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},Ur=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 mie)return e*mie[A];throw new Error(`Unsupported unit: ${A}`)},ql=Ur,zFt=Object.defineProperty,XFt=(t,A)=>{for(var e in A)zFt(t,e,{get:A[e],enumerable:!0})},Jb={};XFt(Jb,{axial:()=>yRt,bga:()=>kMt,breakoutheaders:()=>NRt,cap:()=>oMt,dfn:()=>nRt,diode:()=>nMt,dip:()=>eMt,electrolytic:()=>y1t,hc49:()=>LRt,jst:()=>YGt,led:()=>sMt,lqfp:()=>MRt,m2host:()=>P1t,melf:()=>VNt,micromelf:()=>$Nt,minimelf:()=>JNt,mlp:()=>HMt,mountedpcbmodule:()=>q1t,ms012:()=>cRt,ms013:()=>lRt,msop:()=>jGt,pad:()=>URt,pinrow:()=>sRt,platedhole:()=>R1t,potentiometer:()=>d1t,pushbutton:()=>bRt,qfn:()=>GMt,qfp:()=>UMt,quad:()=>S1,radial:()=>DRt,res:()=>bMt,sma:()=>iGt,smb:()=>IGt,smbf:()=>w1t,smc:()=>QGt,smf:()=>rGt,smtpad:()=>F1t,sod110:()=>TGt,sod123:()=>uRt,sod123f:()=>dNt,sod123fl:()=>mNt,sod123w:()=>$Rt,sod128:()=>vNt,sod323:()=>iNt,sod323f:()=>QNt,sod323fl:()=>t1t,sod323w:()=>XGt,sod523:()=>PRt,sod723:()=>bNt,sod80:()=>VRt,sod882:()=>INt,sod882d:()=>qNt,sod923:()=>rNt,soic:()=>FMt,solderjumper:()=>I1t,son:()=>s1t,sop8:()=>WRt,sot:()=>G1t,sot223:()=>dGt,sot23:()=>zMt,sot23w:()=>xGt,sot25:()=>eRt,sot323:()=>x1t,sot343:()=>H1t,sot363:()=>WMt,sot457:()=>C1t,sot563:()=>aRt,sot723:()=>CRt,sot886:()=>VMt,sot89:()=>LNt,sot963:()=>h1t,ssop:()=>TMt,stampboard:()=>_Rt,stampreceiver:()=>FRt,to220:()=>HNt,to92:()=>JRt,to92l:()=>W1t,to92s:()=>RGt,tqfp:()=>LMt,tssop:()=>qMt,vson:()=>a1t,vssop:()=>WGt});var Li=(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"}),Ui=te({norefdes:PA().optional().describe("disable reference designator label"),invert:PA().optional().describe("hint to invert the orientation of the 3D model"),faceup:PA().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:PA().optional().describe("omit all silkscreen elements from the footprint")}),Fo=(t,A,e,i,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:Ur(i),outer_diameter:Ur(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),jD=t=>{const{pn:A,x:e,y:i,holeDiameter:n,rectPadWidth:o,rectPadHeight:s,holeOffsetX:r=0,holeOffsetY:a=0}=t;return{pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:e,y:i,hole_diameter:Ur(n),hole_shape:"circle",pad_shape:"rect",rect_pad_width:Ur(o),rect_pad_height:Ur(s),pcb_port_id:"",layers:["top","bottom"],port_hints:[A.toString()],hole_offset_x:r,hole_offset_y:a}},qV=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 hk(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var OV=Rt([U(),OA()]).transform(t=>hk(t)),$Ft=t=>Ui.extend({fn:U(),num_pins:OA().optional().default(6),wide:PA().optional(),narrow:PA().optional(),w:OV.optional(),p:OV.default(t.p??"2.54mm"),id:OV.optional(),od:OV.optional(),nosquareplating:PA().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=hk("0.55mm"),A.od=hk("0.95mm")):(A.id=hk("0.8mm"),A.od=hk("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=hk("600mil"):A.narrow?A.w=hk("300mil"):A.w=hk(t.w??"300mil")),A)),AMt=$Ft({}),wie=(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}},eMt=t=>{const A=AMt.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:c,y:I}=wie(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating);if(g===0&&!A.nosquareplating){e.push(jD({pn:g+1,x:c,y:I,holeDiameter:A.id??"0.8mm",rectPadWidth:A.od??"1mm",rectPadHeight:A.od??"1mm"}));continue}e.push(Fo(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},...qV.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}=wie(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=Li(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()]}),Die=[{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}],tMt=Object.fromEntries(Die.map(t=>[t.metric,t])),iMt=Object.fromEntries(Die.map(t=>[t.imperial,t]));Ui.extend({tht:PA(),p:lA.optional(),pw:lA.optional(),ph:lA.optional(),metric:se.optional(),imperial:se.optional(),w:lA.optional(),h:lA.optional(),textbottom:PA().optional()});var WV=t=>{let{tht:A,p:e,pw:i,ph:n,metric:o,imperial:s,w:r,h:a,textbottom:g}=t;if(typeof r=="string"&&(r=ql(r)),typeof a=="string"&&(a=ql(a)),typeof e=="string"&&(e=ql(e)),typeof i=="string"&&(i=ql(i)),typeof n=="string"&&(n=ql(n)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let c;if(o&&(c=tMt[o]),s&&(c=iMt[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=Li(0,l,.2);return A?[Fo(1,-e/2,0,i,i*1/.8),Fo(2,e/2,0,i,i*1/.8),I,B]:[li(["1","left"],-e/2,0,i,n),li(["2","right"],e/2,0,i,n),I,B]},nMt=t=>({circuitJson:WV(t),parameters:t}),oMt=t=>({circuitJson:WV(t),parameters:t}),sMt=t=>({circuitJson:WV(t),parameters:t}),D1=t=>{const{padSpacing:A,padWidth:e,padHeight:i,padPitch:n,numRows:o,textbottom:s}=t,r=[],a=(o-1)*(n/2);for(let S=0;S<o;S++)r.push(a-S*n);const g=[];r.forEach((S,_)=>{g.push(li(_+1,-A/2,S,e,i))}),r.slice().reverse().forEach((S,_)=>{g.push(li(_+o+1,A/2,S,e,i))});const c=Math.max(...r)+i/2+.4,I=Math.min(...r)-i/2-.4,l=-A/2-e/2-.4,B=A/2+e/2+.4,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B*.5,y:c},{x:l*.5,y:c}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B*.5,y:I},{x:l*.5,y:I}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},h=-A/2,E=Math.max(...r),u=.2,d=h-e/2-.1,f=E+i/2+.1,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:[{x:d,y:f},{x:d-u,y:f},{x:d,y:f+u},{x:d,y:f}],stroke_width:.1},w=s?I-.9:c+.9,D=Li(0,w,.2);return[...g,C,Q,m,D]},rMt=Ui.extend({pw:lA.default("0.5mm"),ph:lA.default("0.4mm"),p:lA.default("0.7mm"),textbottom:PA().optional(),convex:PA().optional(),concave:PA().optional()}),aMt=1,gMt=t=>{const A=rMt.parse(t);if(A.concave===!0)return[];const e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return D1({padSpacing:aMt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},cMt=Ui.extend({pw:lA.default("0.5mm"),ph:lA.default("0.32mm"),p:lA.default("0.5mm"),textbottom:PA().optional(),convex:PA().optional(),concave:PA().optional()}),IMt=1,lMt=t=>{const A=cMt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return D1({padSpacing:IMt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},BMt=Ui.extend({pw:lA.default("0.9mm"),ph:lA.default("0.4mm"),p:lA.default("0.8mm"),textbottom:PA().optional(),convex:PA().optional(),concave:PA().optional()}),CMt=1.7,QMt=t=>{const A=BMt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return D1({padSpacing:CMt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},hMt=Ui.extend({pw:lA.default("0.9mm"),ph:lA.default("0.4mm"),p:lA.default("0.8mm"),textbottom:PA().optional(),convex:PA().optional(),concave:PA().optional()}),EMt=1.7,uMt=t=>{const A=hMt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return D1({padSpacing:EMt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},dMt=Ui.extend({pw:lA.default("0.7mm"),ph:lA.default("0.64mm"),p:lA.default("0.94mm"),textbottom:PA().optional(),convex:PA().optional(),concave:PA().optional()}),pMt=1.4,fMt=t=>{const A=dMt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return D1({padSpacing:pMt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},yMt=Ui.extend({pw:lA.default("0.9mm"),ph:lA.default("0.9mm"),p:lA.default("1.34mm"),textbottom:PA().optional(),convex:PA().optional(),concave:PA().optional()}),mMt=3,wMt=t=>{const A=yMt.parse(t),e=ql(A.pw),i=ql(A.ph),n=ql(A.p);return D1({padSpacing:mMt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom,convex:A.convex,concave:A.concave})},DMt=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)}},SMt=t=>t?(typeof t=="number"?`${t}`:t).split(/[_x]/)[0]:void 0,bMt=t=>{const A=DMt(t),e=SMt(t.imperial);return A===2&&e==="0402"?{circuitJson:gMt(t),parameters:t}:A===4&&e==="0402"?{circuitJson:lMt(t),parameters:t}:A===2&&e==="0603"?{circuitJson:QMt(t),parameters:t}:A===4&&e==="0603"?{circuitJson:uMt(t),parameters:t}:A===2&&e==="0606"?{circuitJson:fMt(t),parameters:t}:A===4&&e==="1206"?{circuitJson:wMt(t),parameters:t}:{circuitJson:WV(t),parameters:t}},Sie=(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()]}),bie="ABCDEFGHIJKLMNOPQRSTUVWXYZ",ZV=U().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A??""),y:parseFloat(e??"")}}).pipe(te({x:OA(),y:OA()})),xMt=U().or(Se(AI())).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(Se(U().or(OA()))),_Mt=Ui.extend({fn:U(),num_pins:OA().optional().default(64),grid:ZV.optional(),p:se.default("0.8mm"),w:lA.optional(),h:lA.optional(),ball:lA.optional().describe("ball diameter"),pad:lA.optional().describe("pad width/height"),circularpads:PA().optional().describe("use circular pads"),tlorigin:PA().optional(),blorigin:PA().optional(),trorigin:PA().optional(),brorigin:PA().optional(),missing:xMt.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=bie.indexOf(n[1]),s=Number.parseInt(n[2])-1;return o*t.grid.x+s+1})),{...t,origin:A}}),kMt=t=>{const A=_Mt.parse(t);let{num_pins:e,grid:i,p:n,w:o,h:s,ball:r,pad:a,missing:g}=A;r??=.75/1.27*n,a??=r*.8;const c=[],I=(g??[]).filter(m=>typeof m=="number"),l=i.x*i.y-e;if(g.length===0&&l>0&&(Math.sqrt(l)%1===0?g.push("center"):l===1&&g.push("topleft")),g?.includes("center")){const m=Math.floor(Math.sqrt(l)),w=Math.floor((i.x-m)/2),D=Math.floor((i.y-m)/2);for(let S=D;S<D+m;S++)for(let _=w;_<w+m;_++)I.push(S*i.x+_+1)}g?.includes("topleft")&&I.push(1);const B=new Set(I);let C=0;for(let m=0;m<i.y;m++)for(let w=0;w<i.x;w++){const D=(w-(i.x-1)/2)*n,S=(m-(i.y-1)/2)*n;let _=w,b=m;switch(A.origin){case"bl":_=w,b=i.y-1-m;break;case"br":_=i.x-1-w,b=i.y-1-m;break;case"tr":_=i.x-1-w,b=m;break}let N=b*i.x+_+1;if(B.has(N)){C++;continue}N-=C;const F=[N,`${bie[b]}${_+1}`];c.push(A.circularpads?Sie(F,{x:D,y:S,radius:a/2}):li(F,D,S,a,a))}const Q=Li(0,i.y*n/2,.2),h=n/6;let E;const u=i.x*n/2,d=i.y*n/2;switch(A.origin){case"bl":E=[{x:-u,y:-d},{x:-u,y:-d-h},{x:-u-h,y:-d},{x:-u,y:-d}];break;case"br":E=[{x:u,y:-d},{x:u,y:-d-h},{x:u+h,y:-d},{x:u,y:-d}];break;case"tr":E=[{x:u,y:d},{x:u,y:d+h},{x:u+h,y:d},{x:u,y:d}];break;default:E=[{x:-u,y:d},{x:-u,y:d+h},{x:-u-h,y:d},{x:-u,y:d}];break}const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:E,stroke_width:.05};return{circuitJson:[...c,Q,f],parameters:A}},VV=(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()]}),oM=t=>Ui.extend({fn:U(),num_pins:OA().optional().default(8),w:lA.default(lA.parse(t.w??"5.3mm")),p:lA.default(lA.parse(t.p??"1.27mm")),pw:lA.default(lA.parse(t.pw??"0.6mm")),pl:lA.default(lA.parse(t.pl??"1.0mm")),legsoutside:PA().optional().default(t.legsoutside??!1),pillpads:PA().optional().default(t.pillpads??!1),silkscreen_stroke_width:OA().optional().default(.1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=lA.parse("0.6mm"),A.pl=lA.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),vMt=oM({}),spA=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}},FMt=t=>{const A=vMt.parse(t);return{circuitJson:cJ(A),parameters:A}},cJ=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=spA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push(VV(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=Li(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},...qV.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]},xie=Xe(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),MMt=({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},rpA=Ui.extend({fn:U(),cc:PA().default(!0).optional(),ccw:PA().default(!0).optional(),startingpin:U().or(Se(xie)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(Se(xie)).optional(),num_pins:OA().optional().default(64),w:lA.optional(),h:lA.optional(),p:lA.default(lA.parse("0.5mm")),pw:lA.optional(),pl:lA.optional(),thermalpad:Rt([xA(!0),ZV]).optional(),legsoutside:PA().default(!1)}),apA=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},_ie=rpA.transform(apA),RMt=["left","bottom","right","top"],NMt=t=>{const{pin_count:A,pn:e,w:i,h:n,p:o,pl:s,legsoutside:r}=t,a=A/4,g=RMt[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")}},S1=t=>{const A=_ie.parse(t),e=[],i=MMt(A),n=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:c}=NMt({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=Li(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...o,s],parameters:A}};rpA.extend({}).transform(apA);var GMt=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),S1(t)),LMt=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 S1(t)},UMt=t=>{t.legsoutside=!0;const A=_ie.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 S1(t)};rpA.extend({}).transform(apA);var HMt=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),S1(t)),YMt=Ui.extend({fn:U(),num_pins:OA().optional().default(8),w:lA.default(lA.parse("3.9mm")),p:lA.default(lA.parse("1.27mm")),pw:lA.optional(),pl:lA.optional(),legsoutside:PA().optional().default(!1),silkscreen_stroke_width:OA().optional().default(.1)}).transform(t=>(t.pw==null&&t.pl==null?(t.pw=lA.parse("0.51mm"),t.pl=lA.parse("1.1mm")):t.pw==null?t.pw=t.pl*(.51/1.1):t.pl==null&&(t.pl=t.pw*(1.1/.51)),t)),JMt=t=>{const{num_pins:A,pn:e,w:i,p:n}=t,o=A/2,s=e<=o,r=o-1,a=n,g=a*r,c=i+lA.parse("0.2mm"),I=(s?-1:1)*(c/2);return s?{x:I,y:g/2-(e-1)*a}:{x:I,y:-g/2+(e-o-1)*a}},TMt=t=>{const A=YMt.parse(t),e=[];for(let a=0;a<A.num_pins;a++){const{x:g,y:c}=JMt({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=Li(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},...qV.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}},PMt=Ui.extend({fn:U(),num_pins:OA().optional().default(8),w:lA.default(lA.parse("3.0mm")),p:lA.default(lA.parse("0.5mm")),pw:lA.default(lA.parse("0.30mm")),pl:lA.default(lA.parse("1.45mm")),legsoutside:PA().optional().default(!0),silkscreen_stroke_width:OA().optional().default(.1)}),KMt=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}},qMt=t=>{const A={...t},e=A.p,i=typeof e=="string"||typeof e=="number"?lA.parse(e):void 0,n=i!=null&&i<=lA.parse("0.5mm"),o=PMt.parse(A),s=[],r=n?o.w-lA.parse("0.15mm"):o.w;for(let B=0;B<o.num_pins;B++){const{x:C,y:Q}=KMt({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=Li(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},...qV.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}},OMt=Ui.extend({fn:U(),num_pins:xA(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()}),WMt=t=>{const A=OMt.parse({...t,fn:"sot363"}),e=lA.parse(A.w),i=lA.parse(A.h),n=lA.parse(A.p),o=lA.parse(A.pl),s=lA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=kie(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=kie(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=Li(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},kie=(t,A,e,i)=>t<=3?{x:-.84,y:e-(t-1)*e}:{x:.84,y:-e+(t-4)*e},ZMt=Ui.extend({fn:U(),num_pins:xA(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()}),VMt=t=>{const A=ZMt.parse({...t,fn:"sot886"}),e=lA.parse(A.w),i=lA.parse(A.h),n=lA.parse(A.p),o=lA.parse(A.pl),s=lA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=vie(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=vie(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=Li(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},vie=(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}},Fie=Ui.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()}),jMt=oM({p:"0.95mm",w:"1.6mm",legsoutside:!0}),zMt=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const n=jMt.parse({...t,num_pins:e});return{circuitJson:cJ(n),parameters:n}}const i=Fie.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:$Mt(i),parameters:i};if(i.num_pins===5)return{circuitJson:Rie(i),parameters:i};throw new Error("Invalid number of pins")},XMt=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}},$Mt=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:n,y:o}=XMt({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=Li(0,Number.parseInt(t.h),.3);return[...A,e]},Mie=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")},Rie=t=>{const A=[];for(let I=1;I<=t.num_pins;I++){const{x:l,y:B}=Mie({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=Li(0,i+.3,.3),r=Mie({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]},ARt=Fie.extend({}),eRt=t=>{const A=ARt.parse({...t,num_pins:5});return{circuitJson:Rie(A),parameters:A}},tRt=[{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}],iRt=oM({}),nRt=t=>{const A=iRt.parse(t),e=[];for(let I=0;I<A.num_pins;I++){const{x:l,y:B}=spA({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 tRt){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=Li(0,o/2+.4,o/12);return{circuitJson:[...e,c,...s],parameters:A}},sM=({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 Nie({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 oRt=Ui.extend({fn:U(),num_pins:OA().optional().default(6),rows:Rt([U(),OA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:lA.default("0.1in").describe("pitch"),id:lA.default("1.0mm").describe("inner diameter"),od:lA.default("1.5mm").describe("outer diameter"),male:PA().optional().describe("for male pin headers"),female:PA().optional().describe("for female pin headers"),smd:PA().optional().describe("surface mount device"),surfacemount:PA().optional().describe("surface mount device (verbose)"),rightangle:PA().optional().describe("right angle"),pw:lA.optional().default("1.0mm").describe("pad width for SMD"),pl:lA.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:PA().optional().default(!1),pinlabeltextaligncenter:PA().optional().default(!1),pinlabeltextalignright:PA().optional().default(!1),pinlabelverticallyinverted:PA().optional().default(!1),pinlabelorthogonal:PA().optional().default(!1),nosquareplating:PA().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:PA().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:PA().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:PA().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=Nie(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:zt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),sRt=t=>{const A=oRt.parse(t),{p:e,id:i,od:n,rows:o,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:c,pinlabeltextalignright:I,nopinlabels:l,doublesidedpinlabel:B,bottomsidepinlabel:C}=A;let Q="center";c?Q="left":I&&(Q="right");const h=[],E=Math.ceil(s/o),u=-e,d=({xoff:S,yoff:_,od:b,anchorSide:N,smd:F,pw:L,pl:Y})=>{let J=0,q=0;if(F){const Z=b/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=b*.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:S+J,anchor_y:_+q}},f=(S,_,b)=>{A.smd?h.push(li(S,_,b,A.pw,A.pl)):S===1&&!A.nosquareplating?h.push(jD({pn:S,x:_,y:b,holeDiameter:i,rectPadWidth:n,rectPadHeight:n})):h.push(Fo(S,_,b,i,n));const{anchor_x:N,anchor_y:F}=d({xoff:_,yoff:b,od:n,anchorSide:r,smd:A.smd,pw:A.pw,pl:A.pl});l||(C?h.push(sM({fs:n/5,pn:S,anchor_x:N,anchor_y:F,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):h.push(sM({fs:n/5,pn:S,anchor_x:N,anchor_y:F,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),B&&h.push(sM({fs:n/5,pn:S,anchor_x:N,anchor_y:F,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},m=new Set,w=o>2&&E>2;if(o===1){const S=-((s-1)/2)*e;for(let _=0;_<s;_++){const b=_+1,N=S+_*e,F=`${N},0`;if(m.has(F))throw new Error(`Overlap at ${F}`);m.add(F),f(b,N,0)}}else if(w){const S=-((E-1)/2)*e;let _=1;for(let b=0;b<o&&_<=s;b++)for(let N=0;N<E&&_<=s;N++){const F=S+N*e,L=b*u,Y=`${F},${L}`;if(m.has(Y))throw new Error(`Overlap at ${Y}`);m.add(Y),f(_++,F,L)}}else{const S=-((E-1)/2)*e;let _=1,b=0,N=o-1,F=0,L=E-1;for(;_<=s&&b<=N&&F<=L;){for(let Y=b;Y<=N&&_<=s;Y++){const J=S+F*e,q=Y*u,Z=`${J},${q}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(_++,J,q)}F++;for(let Y=F;Y<=L&&_<=s;Y++){const J=S+Y*e,q=N*u,Z=`${J},${q}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(_++,J,q)}if(N--,F<=L){for(let Y=N;Y>=b&&_<=s;Y--){const J=S+L*e,q=Y*u,Z=`${J},${q}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(_++,J,q)}L--}if(b<=N){for(let Y=L;Y>=F&&_<=s;Y--){const J=S+Y*e,q=b*u,Z=`${J},${q}`;if(m.has(Z))throw new Error(`Overlap at ${Z}`);m.add(Z),f(_++,J,q)}b++}}if(_-1<s)throw new Error(`Missing pins: assigned ${_-1}, expected ${s}`)}const D=Li(0,e,.5);return{circuitJson:[...h,D],parameters:A}},rRt=Ui.extend({fn:U(),num_pins:xA(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()}),aRt=t=>{const A=rRt.parse({...t,fn:"sot563"}),e=lA.parse(A.w),i=lA.parse(A.h),n=lA.parse(A.p),o=lA.parse(A.pl),s=lA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=Gie(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=Gie(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=Li(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},Gie=(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}},gRt=oM({p:"1.27mm",w:"3.9mm",legsoutside:!0}),cRt=t=>{const A=gRt.parse({...t,num_pins:8});return{circuitJson:cJ(A),parameters:A}},IRt=oM({p:"1.27mm",w:"7.5mm",legsoutside:!0}),lRt=t=>{const A=IRt.parse({...t,num_pins:16});return{circuitJson:cJ(A),parameters:A}},BRt=Ui.extend({fn:U(),num_pins:xA(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")}),CRt=t=>{const A=BRt.parse(t),e=hRt(A),i=Li(0,lA.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},QRt=t=>{const{pn:A,p:e}=t;return A===1?{x:e,y:0}:A===2?{x:-e,y:-.4}:{x:-e,y:.4}},hRt=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:n}=QRt({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},ERt=Ui.extend({fn:U(),num_pins:xA(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")}),uRt=t=>{const A=ERt.parse(t),e=Li(0,lA.parse(A.h)/4+.4,.3);return{circuitJson:pRt(A).concat(e),parameters:A}},dRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},pRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=dRt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},fRt=Ui.extend({fn:U(),p:lA.optional().default("2.54mm"),id:lA.optional().default("0.7mm"),od:lA.optional().default("1.4mm")}),yRt=t=>{const A=fRt.parse(t),{p:e,id:i,od:n}=A,o=[Fo(1,-e/2,0,i,n),Fo(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=Li(0,1.5,.5);return{circuitJson:[...o,s,r],parameters:A}},mRt=(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}},wRt=Ui.extend({fn:U(),p:lA.optional().default("5mm"),id:lA.optional().default("0.8mm"),od:lA.optional().default("1.6mm"),ceramic:PA().optional(),electrolytic:PA().optional(),polarized:PA().optional()}),DRt=t=>{const A=wRt.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=[Fo(1,-e/2,0,A.id,A.od),Fo(2,e/2,0,A.id,A.od)],s=e+.1,{topArc:r,bottomArc:a}=mRt(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=Li(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}},rM=(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}),SRt=Ui.extend({fn:xA("pushbutton"),w:lA.default(4.5),h:lA.default(6.5),id:lA.default(1),od:lA.default(1.2)}),bRt=t=>{const A=SRt.parse(t),e=A.w,i=A.h,n=A.id,o=[Fo(1,-e/2,i/2,n,n*1.5),Fo(2,-e/2,-i/2,n,n*1.5),Fo(3,e/2,-i/2,n,n*1.5),Fo(4,e/2,i/2,n,n*1.5)],s=[rM([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),rM([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),rM([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),rM([{x:e/2,y:0},{x:e/5,y:0}])],r=Li(0,i/2+.4,.5);return{circuitJson:[...o,...s,r],parameters:A}},Lie=Ui.extend({fn:U(),w:lA.default("22.58mm"),h:lA.optional(),left:lA.optional().default(20),right:lA.optional().default(20),top:lA.optional().default(2),bottom:lA.optional().default(2),p:lA.default(lA.parse("2.54mm")),pw:lA.default(lA.parse("1.6mm")),pl:lA.default(lA.parse("2.4mm")),innerhole:PA().default(!1),innerholeedgedistance:lA.default(lA.parse("1.61mm")),silkscreenlabels:PA().default(!1),silkscreenlabelmargin:lA.default(lA.parse("0.1mm"))}),xRt=t=>{const A=Lie.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},jV=(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},_Rt=t=>{const A=Lie.parse(t),e=A.h??xRt(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=jV(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(Fo(h+1+A.left+(A.bottom??0)+g,A.w/2,Q+h*A.p,r,a)),n.push(Fo(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=jV(-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(Fo(h+1+g,-A.w/2,Q-h*A.p,r,a)),n.push(Fo(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=jV(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(Fo(h+1+A.left+A.right+(A.bottom??0)+g,Q-h*A.p,e/2,r,a)),n.push(Fo(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=jV(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(Fo(h+1+A.left+g,Q+h*A.p,-e/2,r,a)),n.push(Fo(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=Li(0,e/1.8,e/25);return{circuitJson:[...i,...n,...o,B,...A.silkscreenlabels?[]:[l],C],parameters:A}},Uie=Ui.extend({fn:U(),w:lA.default("22.58mm"),h:lA.optional(),left:lA.optional().default(20),right:lA.optional().default(20),top:lA.optional().default(2),bottom:lA.optional().default(2),p:lA.default(lA.parse("2.54mm")),pw:lA.default(lA.parse("1.6mm")),pl:lA.default(lA.parse("3.2mm")),innerhole:PA().default(!1),innerholeedgedistance:lA.default(lA.parse("1.61mm"))}),kRt=t=>{const A=Uie.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},vRt=(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]},FRt=t=>{const A=Uie.parse(t),e=A.h??kRt(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=vRt(-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(Fo(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(Fo(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(Fo(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(Fo(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=Li(0,e/1.8,e/25);return{circuitJson:[...o,...i,...n,l,I,B],parameters:A}},MRt=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),S1(t)),Hie=Ui.extend({fn:U(),w:lA.default("10mm"),h:lA.optional(),left:lA.optional().default(20),right:lA.optional().default(20),top:lA.optional().default(0),bottom:lA.optional().default(0),p:lA.default(lA.parse("2.54mm")),id:lA.optional().default(lA.parse("1mm")),od:lA.optional().default(lA.parse("1.5mm"))}),RRt=t=>{const A=Hie.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},zV=(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]},NRt=t=>{const A=Hie.parse(t),e=A.h??RRt(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=zV(A.w/2+o*1.4,c+I*A.p,"right")),i.push(Fo(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=zV(-A.w/2-o*1.4,c+I*A.p,"left")),i.push(Fo(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=zV(c+I*A.p,e/2+o*1.4,"top")),i.push(Fo(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=zV(c+I*A.p,-e/2-o*1.4,"bottom")),i.push(Fo(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=Li(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},Yie=(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}}),GRt=Ui.extend({fn:U(),p:lA.optional().default("4.88mm"),id:lA.optional().default("0.8mm"),od:lA.optional().default("1.5mm"),w:lA.optional().default("5.6mm"),h:lA.optional().default("3.5mm")}),LRt=t=>{const A=GRt.parse(t),{p:e,id:i,od:n,w:o,h:s}=A,r=s/2,a=[Fo(1,-e/2,0,i,n),Fo(2,e/2,0,i,n)],g=Yie(-o/2,0,r,"left"),c=Yie(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=Li(0,e/4,.5);return{circuitJson:[...a,I,l],parameters:A}};Ui.extend({w:lA,h:lA});var URt=t=>{const{w:A,h:e}=t,i=Ur(A),n=Ur(e);return{circuitJson:[li(1,0,0,i,n),Li(0,n/2+.5,.2)],parameters:t}},IJ=(t,A,e,i,n,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:A,y:e,outer_width:Ur(n),outer_height:Ur(o),hole_width:Ur(i),hole_height:Ur(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),HRt=Ui.extend({fn:U(),num_pins:Rt([xA(3),xA(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:PA().default(!1),string:U().optional()}),YRt=(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}}),JRt=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=HRt.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=[jD({pn:1,x:-I,y:c-I,holeDiameter:l,rectPadWidth:B,rectPadHeight:Q}),IJ(2,0,c-I,l,C,Q),IJ(3,I,c-I,l,C,Q)]:h=[jD({pn:1,x:-I,y:c-I,holeDiameter:l,rectPadWidth:B,rectPadHeight:B}),Fo(2,0,c,l,B),Fo(3,I,c-I,l,B)];else if(i.num_pins===2)h=[jD({pn:1,x:-I,y:c-I,holeDiameter:l,rectPadWidth:C,rectPadHeight:Q}),IJ(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=YRt(0,c,E),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...u,{x:-E,y:0},{x:E,y:0},u[0]],stroke_width:.1,pcb_silkscreen_path_id:""},f=Li(0,c+1,.5);return{circuitJson:[...h,d,f],parameters:i}},TRt=Ui.extend({fn:U(),num_pins:xA(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")}),PRt=t=>{const A=TRt.parse(t),e=Li(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:qRt(A).concat(i,e),parameters:A}},KRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},qRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=KRt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ORt=oM({w:"7.05mm",p:"1.27mm",pw:"0.65mm",pl:"1.975mm"}),WRt=t=>{const A=ORt.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=spA({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=Li(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}},ZRt=Ui.extend({fn:U(),num_pins:xA(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")}),VRt=t=>{const A=ZRt.parse(t),e=Li(0,lA.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2+.5,y:lA.parse(A.h)/2+.5},{x:-lA.parse(A.w)/2-.5,y:lA.parse(A.h)/2+.5},{x:-lA.parse(A.w)/2-.5,y:-lA.parse(A.h)/2-.5},{x:lA.parse(A.p)/2+.5,y:-lA.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:zRt(A).concat(i,e),parameters:A}},jRt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},zRt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=jRt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},XRt=Ui.extend({fn:U(),num_pins:xA(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")}),$Rt=t=>{const A=XRt.parse(t),e=Li(0,lA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eNt(A).concat(i,e),parameters:A}},ANt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=ANt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tNt=Ui.extend({fn:U(),num_pins:xA(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")}),iNt=t=>{const A=tNt.parse(t),e=Li(0,lA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:oNt(A).concat(i,e),parameters:A}},nNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},oNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=nNt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},sNt=Ui.extend({fn:U(),num_pins:xA(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")}),rNt=t=>{const A=sNt.parse(t),e=Li(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2+.15,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.15,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.15,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2+.15,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gNt(A).concat(i,e),parameters:A}},aNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},gNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=aNt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},cNt=Ui.extend({fn:U(),num_pins:xA(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")}),INt=t=>{const A=cNt.parse(t),e=Li(0,lA.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2+.2,y:lA.parse(A.h)/2+.2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2+.2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2-.2},{x:lA.parse(A.p)/2+.2,y:-lA.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:BNt(A).concat(i,e),parameters:A}},lNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},BNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=lNt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},CNt=Ui.extend({fn:U(),num_pins:xA(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")}),QNt=t=>{const A=CNt.parse(t),e=Li(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.pad_spacing)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.pad_spacing)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ENt(A).concat(i,e),parameters:A}},hNt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},ENt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=hNt({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},uNt=Ui.extend({fn:U(),num_pins:xA(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")}),dNt=t=>{const A=uNt.parse(t),e=Li(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:fNt(A).concat(i,e),parameters:A}},pNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},fNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=pNt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},yNt=Ui.extend({fn:U(),num_pins:xA(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")}),mNt=t=>{const A=yNt.parse(t),e=Li(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:DNt(A).concat(i,e),parameters:A}},wNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},DNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=wNt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},SNt=Ui.extend({fn:U(),num_pins:xA(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")}),bNt=t=>{const A=SNt.parse(t),e=Li(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:_Nt(A).concat(i,e),parameters:A}},xNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},_Nt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=xNt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},kNt=Ui.extend({fn:U(),num_pins:xA(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")}),vNt=t=>{const A=kNt.parse(t),e=Li(0,lA.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:MNt(A).concat(i,e),parameters:A}},FNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},MNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=FNt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},RNt=Ui.extend({fn:U(),num_pins:Rt([xA(3),xA(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()}),NNt=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=Li(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]},GNt=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=Li(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]},LNt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=RNt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:NNt(i),parameters:i};if(i.num_pins===5)return{circuitJson:GNt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},UNt=Ui.extend({fn:U(),p:lA.optional().default("5.0mm"),id:lA.optional().default("1.0mm"),od:lA.optional().default("1.9mm"),w:lA.optional().default("13mm"),h:lA.optional().default("7mm"),num_pins:OA().optional(),string:U().optional()}),HNt=t=>{const A=UNt.parse(t),{fn:e,id:i,od:n,w:o,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,c=o/2,I=s/2,l=2.5,B=o*.4,C=Math.max(l,B/(a-1)),Q=Array.from({length:a},(m,w)=>{const D=a%2===0?(w-a/2+.5)*C:(w-Math.floor(a/2))*C;return Fo(w+1,D,g,i,n)}),h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:-I},{x:c,y:-I},{x:c,y:I},{x:-c,y:I},{x:-c,y:-I}],stroke_width:.1,pcb_silkscreen_path_id:""},E=-I+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:E},{x:c,y:E}],stroke_width:.1,pcb_silkscreen_path_id:""},d=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:E},{x:-o/6,y:I}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:E},{x:o/6,y:I}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Li(0,s/2+.6,.5);return{circuitJson:[...Q,h,u,...d,f],parameters:{...A,p:C}}},YNt=Ui.extend({fn:U(),num_pins:xA(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")}),JNt=t=>{const A=YNt.parse(t),e=Li(0,lA.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:PNt(A).concat(i,e),parameters:A}},TNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},PNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=TNt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},KNt=Ui.extend({fn:U(),num_pins:xA(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")}),qNt=t=>{const A=KNt.parse(t),e=Li(0,lA.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2+.1,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2+.1,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:WNt(A).concat(i,e),parameters:A}},ONt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},WNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=ONt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ZNt=Ui.extend({fn:U(),num_pins:xA(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")}),VNt=t=>{const A=ZNt.parse(t),e=Li(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:zNt(A).concat(i,e),parameters:A}},jNt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},zNt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=jNt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},XNt=Ui.extend({fn:U(),num_pins:xA(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")}),$Nt=t=>{const A=XNt.parse(t),e=Li(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eGt(A).concat(i,e),parameters:A}},AGt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=AGt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tGt=Ui.extend({fn:U(),num_pins:xA(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")}),iGt=t=>{const A=tGt.parse(t),e=Li(0,lA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.5,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.5,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:oGt(A).concat(i,e),parameters:A}},nGt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},oGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=nGt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},sGt=Ui.extend({fn:U(),num_pins:xA(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")}),rGt=t=>{const A=sGt.parse(t),e=Li(0,lA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gGt(A).concat(i,e),parameters:A}},aGt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},gGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=aGt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},cGt=Ui.extend({fn:U(),num_pins:xA(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")}),IGt=t=>{const A=cGt.parse(t),e=Li(0,lA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.1,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:BGt(A).concat(i,e),parameters:A}},lGt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},BGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=lGt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},CGt=Ui.extend({fn:U(),num_pins:xA(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")}),QGt=t=>{const A=CGt.parse(t),e=Li(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2-.8},{x:-lA.parse(A.w)/2-.8,y:lA.parse(A.h)/2-.8},{x:-lA.parse(A.w)/2-.8,y:-lA.parse(A.h)/2+.8},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:EGt(A).concat(i,e),parameters:A}},hGt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},EGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=hGt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},uGt=Ui.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()}),dGt=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const n=yGt.parse({...t,num_pins:e});return{circuitJson:cJ(n),parameters:n}}const i=uGt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:fGt(i),parameters:i};if(i.num_pins===5)return{circuitJson:wGt(i),parameters:i};if(i.num_pins===6)return{circuitJson:SGt(i),parameters:i};throw new Error("Invalid number of pins")},pGt=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}},fGt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=pGt({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=Li(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]},yGt=oM({p:"0.90mm",w:"2.8mm",legsoutside:!0}),mGt=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")},wGt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=mGt({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=Li(0,0,.3);return[...A,n,o,s]},DGt=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")},SGt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=DGt({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=Li(0,0,.3);return[...A,n,o,s]},bGt=Ui.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()}),xGt=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=bGt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:kGt(i),parameters:i};throw new Error("Invalid number of pins")},_Gt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},kGt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=_Gt({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=Li(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]},vGt=Ui.extend({fn:U(),num_pins:Rt([xA(3),xA(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()}),FGt=t=>{const{p:A,id:e,od:i,w:n,h:o}=t,s=Number.parseFloat(o)/2,r=Number.parseFloat(A);return[Fo(1,-r,s-r,e,i),Fo(2,0,s-r,e,i),Fo(3,r,s-r,e,i)]},MGt=t=>{const{p:A,id:e,od:i,h:n}=t,o=Number.parseFloat(n)/2,s=Number.parseFloat(A);return[Fo(1,-s,o-s,e,i),Fo(2,s,o-s,e,i)]},RGt=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=vGt.parse({...t,num_pins:e});let n=[];if(i.num_pins===3)n=FGt(i);else if(i.num_pins===2)n=MGt(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=Li(0,o+1,.5);return{circuitJson:[...n,r,a],parameters:i}},NGt=Ui.extend({fn:U(),p:lA.optional(),id:lA.optional(),pw:lA.optional(),pl:lA.optional(),w:lA.optional(),h:lA.optional(),sh:PA().optional().describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:PA().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:U().optional()}),GGt={ph:{p:lA.parse("2.2mm"),id:lA.parse("0.70mm"),pw:lA.parse("1.20mm"),pl:lA.parse("1.20mm"),w:lA.parse("6mm"),h:lA.parse("5mm")},sh:{p:lA.parse("1mm"),pw:lA.parse("0.6mm"),pl:lA.parse("1.55mm"),w:lA.parse("5.8mm"),h:lA.parse("7.8mm")}};function LGt(t){return t.sh?"sh":(t.ph,"ph")}function UGt(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(jD({pn:a+1,x:g,y:2,holeDiameter:i,rectPadWidth:n,rectPadHeight:o}))}}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const c=r+g*e;s.push(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 HGt(t,A,e){return t==="ph"?{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-3,y:3},{x:3,y:3},{x:3,y:-2},{x:-3,y:-2},{x:-3,y:3}],stroke_width:.1,pcb_silkscreen_path_id:""}:{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[],stroke_width:.1,pcb_silkscreen_path_id:""}}var YGt=t=>{const A=NGt.parse(t),e=LGt(A),i=GGt[e],n=A.p??i.p,o=A.id??i.id,s=A.pw??i.pw,r=A.pl??i.pl,a=A.w??i.w,g=A.h??i.h;let c;const I=t.num_pins;typeof I=="number"&&(c=I);const B=(typeof t.string=="string"?t.string:"").match(/(?:^|_)jst(\d+)(?:_|$)/);if(B&&B[1]){const E=parseInt(B[1],10);Number.isNaN(E)||(c=E)}if(typeof c!="number")throw new Error(`JST requires an explicit pin count (e.g. jst6_sh or .jst(6))${A.string?`, from string "${A.string}"`:""}`);const C=UGt(e,c,n,o,s,r),Q=HGt(e),h=Li(0,g/2+1,.5);return{circuitJson:[...C,Q,h],parameters:{...A,p:n,id:o,pw:s,pl:r,w:a,h:g,num_pins:c,sh:e==="sh",ph:e==="ph"}}},JGt=Ui.extend({fn:U(),num_pins:xA(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")}),TGt=t=>{const A=JGt.parse(t),e=Li(0,lA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:KGt(A).concat(i,e),parameters:A}},PGt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},KGt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=PGt({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},qGt=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"}}},OGt=Ui.extend({fn:U(),num_pins:Rt([xA(8),xA(10)]).default(8),w:U().optional(),h:U().optional(),p:U().optional(),pl:U().optional(),pw:U().optional(),string:U().optional()}),WGt=t=>{const A=OGt.parse(t),e=qGt(A.num_pins),i=lA.parse(A.w||e.w),n=lA.parse(A.h||e.h),o=lA.parse(A.p||e.p),s=lA.parse(A.pl||e.pl),r=lA.parse(A.pw||e.pw),a=[],g=A.num_pins/2;for(let u=0;u<A.num_pins;u++){const{x:d,y:f}=Jie(A.num_pins,u+1,i,o),m=u<g?u+1:A.num_pins-(u-g);a.push(li(m,d,f,s,r))}const c=i,I=n,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:I/2},{x:c/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:-I/2},{x:c/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=Jie(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=Li(0,I/2+.5,.3);return{circuitJson:[...a,l,B,E,h],parameters:A}},Jie=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*lA.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},ZGt=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"}}},VGt=Ui.extend({fn:U(),num_pins:Rt([xA(8),xA(10),xA(12),xA(16)]).default(8),w:U().optional(),h:U().optional(),p:U().optional(),pl:U().optional(),pw:U().optional(),string:U().optional()}),Tie=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*lA.parse("2mm"),y:r*i}},jGt=t=>{const A=VGt.parse(t),e=ZGt(A.num_pins),i=lA.parse(A.w||e.w),n=lA.parse(A.h||e.h),o=lA.parse(A.p||e.p),s=lA.parse(A.pl||e.pl),r=lA.parse(A.pw||e.pw),a=[];for(let E=0;E<A.num_pins;E++){const{x:u,y:d}=Tie(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=Tie(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=Li(0,c/2+.5,.3);return{circuitJson:[...a,I,l,h,Q],parameters:A}},zGt=Ui.extend({fn:U(),num_pins:xA(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")}),XGt=t=>{const A=zGt.parse(t),e=Li(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.pad_spacing)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.pad_spacing)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:A1t(A).concat(i,e),parameters:A}},$Gt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},A1t=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=$Gt({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},e1t=Ui.extend({fn:U(),num_pins:xA(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")}),t1t=t=>{const A=e1t.parse(t),e=Li(0,lA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.pad_spacing)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.2,y:-lA.parse(A.h)/2},{x:lA.parse(A.pad_spacing)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:n1t(A).concat(i,e),parameters:A}},i1t=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},n1t=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=i1t({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},o1t=Ui.extend({fn:U(),num_pins:Rt([xA(6),xA(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:PA().default(!1)}),s1t=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=o1t.parse({...t,num_pins:e}),n=lA.parse(i.w),o=lA.parse(i.h),s=lA.parse(i.p),r=lA.parse(i.pl),a=lA.parse(i.pw),g=lA.parse(i.epw),c=lA.parse(i.eph),I=[];for(let f=0;f<i.num_pins;f++){const{x:m,y:w}=Pie(i.num_pins,f+1,n,s);I.push(li(f+1,m,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=Pie(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=Li(0,B/2+.5,.3);return{circuitJson:[...I,C,Q,d,u],parameters:i}},Pie=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*lA.parse("1.4mm"),y:r*i}},r1t=Ui.extend({fn:U(),num_pins:OA().optional().default(8),p:se.describe("pitch (distance between center of each pin)"),w:lA.describe("width between vertical rows of pins"),grid:ZV.describe("width and height of the border of the footprint"),ep:ZV.default("0x0mm").describe("width and height of the central exposed thermal pad"),epx:lA.default("0mm").describe("x offset of the center of the central exposed thermal pad"),pinw:lA.describe("width of the pin pads"),pinh:lA.describe("height of the pin pads")}),a1t=t=>{const A=r1t.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}=g1t({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=c1t(o),l=Li(0,o.y/2+i,o.y/6);return{circuitJson:[...c,...I,l],parameters:A}},g1t=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}},c1t=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}]},I1t=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:n=1.5,ph:o=1.5}=t,s=lA.parse(i),r=lA.parse(n),a=lA.parse(o),g=Math.min(a/4,.5),c=[];for(let f=0;f<A;f++)c.push(li(f+1,f*s,0,r,a));let I=[];if(e){const f=e.split("").map(Number);if(f.length>1)for(let m=0;m<f.length-1;m++){const w=f[m],D=f[m+1];if(typeof w=="number"&&typeof D=="number"&&!isNaN(w)&&!isNaN(D)){const S=(w-1)*s,_=(D-1)*s,b=Math.sign(_-S),N=S+b*(r/2),F=_-b*(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=Li(C,u,.4);return{circuitJson:[...c,...I,h,d],parameters:t}},Kie={fn:xA("sot457"),num_pins:xA(6).default(6),pillh:U().default("0.45mm"),pillw:U().default("1.45mm"),pl:U(),pw:U(),p:U(),wave:PA().optional(),reflow:PA().optional()},l1t=Ui.extend({...Kie,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")}),B1t=Ui.extend({...Kie,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)})),Tb=t=>Number.parseFloat(t.replace("mm","")),qie=({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},Oie=t=>{const A=[],e=Tb(t.p),i=Tb(t.pl),n=Tb(t.pw),o=Tb(t.w),s=Tb(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})=>VV(3,-e,0,Tb(t.pillw),Tb(t.pillh)),4:({padWidth:Q,padHeight:h})=>VV(4,e,0,Tb(t.pillw),Tb(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}=qie({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=Li(0,s+.5,.3),c=qie({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]},C1t=t=>{if(t.wave){const e=B1t.parse({...t,fn:"sot457"});return{circuitJson:Oie(e),parameters:e}}const A=l1t.parse(t);return{circuitJson:Oie(A),parameters:A}},Q1t=Ui.extend({fn:U(),num_pins:xA(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()}),h1t=t=>{const A=Q1t.parse({...t,fn:"sot963"}),e=lA.parse(A.w),i=lA.parse(A.h),n=lA.parse(A.p),o=lA.parse(A.pl),s=lA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=Wie(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=Wie(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=Li(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},Wie=(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}},E1t=Ui.extend({fn:U(),num_pins:Rt([xA(3),xA(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()}),u1t=t=>{const{p:A,id:e,od:i,h:n,ca:o}=t,s=Number.parseFloat(n),r=Number.parseFloat(o);return[Fo(1,0,r/4+.3,e,i),Fo(2,s,0,e,i),Fo(3,0,-r/4-.3,e,i)]},d1t=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=E1t.parse({...t,num_pins:e});let n=[];i.num_pins===3&&(n=u1t(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=Li(c,o+1,.5);return{circuitJson:[...n,a,g,I],parameters:i}},p1t=Ui.extend({fn:U(),p:lA.optional().default("7.5mm"),id:lA.optional().default("1mm"),od:lA.optional().default("2mm"),d:lA.optional().default("10.5mm")}),f1t=(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}},y1t=t=>{const A=p1t.parse(t),{p:e,id:i,od:n,d:o}=A,s=[Fo(1,-e/2,0,i,n),Fo(2,e/2,0,i,n)],{topArc:r,bottomArc:a}=f1t(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=Li(0,o/2+1,.5);return{circuitJson:[...s,g,c,I,Q,h,E],parameters:A}},m1t=Ui.extend({fn:U(),num_pins:xA(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")}),w1t=t=>{const A=m1t.parse(t),e=Li(0,lA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:lA.parse(A.p)/2,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.3,y:lA.parse(A.h)/2},{x:-lA.parse(A.w)/2-.3,y:-lA.parse(A.h)/2},{x:lA.parse(A.p)/2,y:-lA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:S1t(A).concat(i,e),parameters:A}},D1t=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},S1t=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=D1t({pn:e,p:Number.parseFloat(t.p)});A.push(li(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},b1t=Ui.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()}),x1t=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=b1t.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:k1t(i),parameters:i};throw new Error("Invalid number of pins")},_1t=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},k1t=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=_1t({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=Li(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]},v1t=Ui.extend({fn:U(),circle:PA().optional(),rect:PA().optional(),square:PA().optional(),pill:PA().optional(),d:lA.optional(),pd:lA.optional(),diameter:lA.optional(),r:lA.optional(),pr:lA.optional(),radius:lA.optional(),w:lA.optional(),pw:lA.optional(),width:lA.optional(),h:lA.optional(),ph:lA.optional(),height:lA.optional(),s:lA.optional(),size:lA.optional(),string: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=Ur(t.r):t.pr!==void 0?e=Ur(t.pr):t.radius!==void 0?e=Ur(t.radius):t.d!==void 0?e=Ur(t.d)/2:t.pd!==void 0?e=Ur(t.pd)/2:t.diameter!==void 0?e=Ur(t.diameter)/2:e=Ur("1mm")/2:(t.w!==void 0?i=Ur(t.w):t.pw!==void 0?i=Ur(t.pw):t.width!==void 0?i=Ur(t.width):t.s!==void 0?i=Ur(t.s):t.size!==void 0?i=Ur(t.size):i=Ur("1mm"),t.h!==void 0?n=Ur(t.h):t.ph!==void 0?n=Ur(t.ph):t.height!==void 0?n=Ur(t.height):A==="square"||A==="rect"?n=i:n=Ur("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:n}}),F1t=t=>{const A=v1t.parse(t),{shape:e,radius:i,width:n,height:o}=A;let s,r;return e==="circle"?(s=Sie(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=VV(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,Li(0,r,.2)],parameters:A}},M1t=Ui.extend({fn:U(),d:lA.optional(),hd:lA.optional(),r:lA.optional(),hr:lA.optional(),pd:lA.optional(),pr:lA.optional(),squarepad:PA().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=Ur(t.d):t.hd!==void 0?A=Ur(t.hd):t.r!==void 0?A=Ur(t.r)*2:t.hr!==void 0?A=Ur(t.hr)*2:A=Ur("1mm");let e;return t.pd!==void 0?e=Ur(t.pd):t.pr!==void 0?e=Ur(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),R1t=t=>{const A=M1t.parse(t),{d:e,pd:i,squarepad:n}=A;return{circuitJson:[n?jD({pn:1,x:0,y:0,holeDiameter:e,rectPadWidth:i,rectPadHeight:i}):Fo(1,0,0,e,i),Li(0,i/2+.5,.2)],parameters:A}},N1t=Ui.extend({fn:U(),num_pins:xA(6).default(6),h:U().default("1.6mm"),pl:U().default("1mm"),pw:U().default("0.7mm"),p:U().default("0.95mm")}),G1t=t=>{const A=N1t.parse(t);return{circuitJson:L1t(A),parameters:A}},Zie=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")},L1t=t=>{const A=[];for(let I=1;I<=t.num_pins;I++){const{x:l,y:B}=Zie({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=Li(0,i+.3,.3),r=Zie({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]},U1t=Ui.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()}),H1t=t=>{const A=t.string?.match(/^sot343_(\d+)/),e=A?Number.parseInt(A[1],4):4,i=U1t.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:J1t(i),parameters:i};throw new Error("Invalid number of pins")},Y1t=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}},J1t=t=>{const A=[],e=Number.parseFloat(t.w),i=Number.parseFloat(t.h),n=Number.parseFloat(t.pl),o=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let r=1/0,a=-1/0,g=1/0,c=-1/0;for(let d=0;d<t.num_pins;d++){const{x:f,y:m}=Y1t({num_pins:t.num_pins,pn:d+1,p:s});A.push(li(d+1,f,m,n,o)),f<r&&(r=f),f>a&&(a=f),m<g&&(g=m),m>c&&(c=m)}const I=(r+a)/2,l=c-g,B=i*.3,C=l/2+B;let Q=e*.8;i<=2.6&&(Q/=2);const h=Li(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]},T1t=Ui.extend({fn:U()}),P1t=t=>{const A=T1t.parse(t),e=[],i=.5-.15,n=1.5,s=.5/2,r=75,a=-37/2;for(let D=0;D<r;D++){const S=D+1;if(S>=24&&S<=31)continue;const _=a-D*s,b=S%2===0,N=n+(b?.25:0),L=.5-N/2,Y=li(S,L,_,N,i);Y.layer=b?"bottom":"top",e.push(Y)}const g=46*.0254,c=137*.0254,I=261*.0254,l={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-c/2+n/2,y:a-I},width:c,height:g},B={x:-.5,y:a},C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:B.x-.4,y:B.y},{x:B.x-.7,y:B.y+.3},{x:B.x-.7,y:B.y-.3},{x:B.x-.4,y:B.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let Q=1/0,h=-1/0,E=1/0,u=-1/0;const d=(D,S,_=0,b=0)=>{Q=Math.min(Q,D-_/2),h=Math.max(h,D+_/2),E=Math.min(E,S-b/2),u=Math.max(u,S+b/2)};for(const D of e){const S=D;d(S.x,S.y,S.width,S.height)}d(l.center.x,l.center.y,l.width,l.height);for(const D of C.route)d(D.x,D.y);const f=(Q+h)/2,m=(E+u)/2,w=D=>{typeof D.x=="number"&&(D.x-=f),typeof D.y=="number"&&(D.y-=m),D.center&&(D.center.x-=f,D.center.y-=m),Array.isArray(D.route)&&(D.route=D.route.map(S=>({x:S.x-f,y:S.y-m})))};for(const D of e)w(D);return w(l),w(C),{circuitJson:[...e,l,C],parameters:A}},K1t=Ui.extend({fn:U(),numPins:OA().optional().default(0),rows:Rt([U(),OA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:lA.default("2.54mm").describe("pitch"),id:lA.default("1.0mm").describe("inner diameter"),od:lA.default("1.5mm").describe("outer diameter"),male:PA().optional().describe("the module uses male headers"),nopin:PA().optional().default(!1).describe("omit pins rendering"),female:PA().optional().describe("the module uses female headers"),smd:PA().optional().describe("surface mount device"),pinlabeltextalignleft:PA().optional().default(!1),pinlabeltextaligncenter:PA().optional().default(!1),pinlabeltextalignright:PA().optional().default(!1),pinlabelverticallyinverted:PA().optional().default(!1),pinlabelorthogonal:PA().optional().default(!1),nopinlabels:PA().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:PA().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:PA().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top"),pinRowSide:Xe(["left","right","top","bottom"]).optional().default("left"),pinrowleft:PA().optional().default(!1),pinrowright:PA().optional().default(!1),pinrowtop:PA().optional().default(!1),pinrowbottom:PA().optional().default(!1),pinrowleftpins:Rt([U(),OA()]).transform(t=>Number(t)).optional(),pinrowrightpins:Rt([U(),OA()]).transform(t=>Number(t)).optional(),pinrowtoppins:Rt([U(),OA()]).transform(t=>Number(t)).optional(),pinrowbottompins:Rt([U(),OA()]).transform(t=>Number(t)).optional(),width:lA.optional(),height:lA.optional(),pinRowHoleEdgeToEdgeDist:lA.default("2mm"),holes:Rt([U(),Se(U())]).optional().transform(t=>!t||Array.isArray(t)?t:t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1).split(",").map(A=>A.trim()):[t]),holeXDist:lA.optional(),holeYDist:lA.optional(),holeInset:lA.default("1mm"),pinrow:Rt([U(),OA()]).optional(),usbposition:Xe(["left","right","top","bottom"]).optional().default("left"),usbleft:PA().optional().default(!1),usbtop:PA().optional().default(!1),usbright:PA().optional().default(!1),usbbottom:PA().optional().default(!1),usbtype:Xe(["micro","c"]).optional(),usbmicro:PA().optional().default(!1),usbc:PA().optional().default(!1),screen:PA().optional().default(!1).describe("add silkscreen outline for screen/display area"),screenwidth:lA.optional(),screenheight:lA.optional(),screencenteroffsetx:lA.optional(),screencenteroffsety:lA.optional()}).transform(t=>{const A=Nie(t);let e=t.pinRowSide;t.pinrowleft&&(e="left"),t.pinrowright&&(e="right"),t.pinrowtop&&(e="top"),t.pinrowbottom&&(e="bottom");let i=t.usbposition;t.usbleft&&(i="left"),t.usbtop&&(i="top"),t.usbright&&(i="right"),t.usbbottom&&(i="bottom");let n=t.usbtype;t.usbmicro&&(n="micro"),t.usbc&&(n="c"),t.pinrow!==void 0&&(t.numPins=Number(t.pinrow));const o={left:t.pinrowleftpins,right:t.pinrowrightpins,top:t.pinrowtoppins,bottom:t.pinrowbottompins},s=Object.values(o).some(f=>f!==void 0&&f>0),r=(o.left??0)>0&&(o.right??0)>0,a=(o.top??0)>0&&(o.bottom??0)>0;s&&((o.left??0)>0?e="left":(o.right??0)>0?e="right":(o.top??0)>0?e="top":(o.bottom??0)>0&&(e="bottom"),t.numPins=(o.left??0)+(o.right??0)+(o.top??0)+(o.bottom??0));const g=Math.ceil(t.numPins/t.rows),c=Math.max(o.left??0,o.right??0),I=Math.max(o.top??0,o.bottom??0);let l,B;if(s){const f=r?t.p:0,m=a?t.p:0;l=(I>0?(I-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+f,B=(c>0?(c-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+m}else e==="left"||e==="right"?(l=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,B=(g-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist):(B=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,l=(g-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist);t.numPins===0&&(l=10,B=10);const C=t.width??l,Q=t.height??B,h=t.screenwidth??C*.95,E=t.screenheight??Q*.95,u=t.screencenteroffsetx??0,d=t.screencenteroffsety??0;return{...t,pinlabelAnchorSide:A,pinRowSide:e,usbposition:i,usbtype:n,male:t.male??!t.female,female:t.female??!1,width:C,height:Q,screenwidth:h,screenheight:E,screencenteroffsetx:u,screencenteroffsety:d,pinrowleftpins:o.left,pinrowrightpins:o.right,pinrowtoppins:o.top,pinrowbottompins:o.bottom}}).superRefine((t,A)=>{t.male&&t.female&&A.addIssue({code:zt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),q1t=t=>{const A=K1t.parse(t),{p:e,id:i,od:n,rows:o,numPins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:c,pinlabeltextalignright:I,nopinlabels:l,doublesidedpinlabel:B,bottomsidepinlabel:C,pinRowSide:Q,width:h,height:E,pinRowHoleEdgeToEdgeDist:u,holes:d,holeXDist:f,holeYDist:m,holeInset:w,pinrowleftpins:D,pinrowrightpins:S,pinrowtoppins:_,pinrowbottompins:b,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:S,top:_,bottom:b},iA=Object.values(gA).some(aA=>aA!==void 0&&aA>0),tA=(aA,EA,bA,_A)=>{if(A.smd?eA.push(li(aA,EA,bA,A.od,A.od)):aA===1?eA.push(jD({pn:aA,x:EA,y:bA,holeDiameter:i,rectPadWidth:n,rectPadHeight:n})):eA.push(Fo(aA,EA,bA,i,n)),!l){const YA=EA+(_A==="left"?-n:_A==="right"?n:0),QA=bA+(_A==="top"?n:_A==="bottom"?-n:0);C||eA.push(sM({fs:n/5,pn:aA,anchor_x:YA,anchor_y:QA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"top"})),(B||C)&&eA.push(sM({fs:n/5,pn:aA,anchor_x:YA,anchor_y:QA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"bottom"}))}};if(iA){const aA=e;let EA=1;const bA=gA.left??0,_A=gA.right??0,YA=gA.top??0,QA=gA.bottom??0,kA=(dA,qA)=>{if(!(qA<=0))if(dA==="left"||dA==="right"){const ZA=dA==="left"?-h/2+u:h/2-u,ce=(qA-1)/2*aA;for(let fA=0;fA<qA;fA++)tA(EA,ZA,ce-fA*aA,dA),EA++}else{const ZA=dA==="top"?E/2-u:-E/2+u,ce=-((qA-1)/2)*aA;for(let fA=0;fA<qA;fA++)tA(EA,ce+fA*aA,ZA,dA),EA++}};kA("left",bA),kA("right",_A),kA("top",YA),kA("bottom",QA)}else{const aA=e;let EA=0,bA=0,_A=0,YA=0,QA=0,kA=0;const dA=Math.ceil(s/o);Q==="left"||Q==="right"?(EA=Q==="left"?-h/2+u:h/2-u,bA=(dA-1)/2*aA,_A=0,YA=-aA,QA=Q==="left"?aA:-aA,kA=0):(EA=-(dA-1)/2*aA,bA=Q==="top"?E/2-u:-E/2+u,_A=aA,YA=0,QA=0,kA=Q==="top"?-aA:aA);let qA=1;for(let ZA=0;ZA<o&&qA<=s;ZA++)for(let ce=0;ce<dA&&qA<=s;ce++){const fA=EA+ce*_A+ZA*QA,ge=bA+ce*YA+ZA*kA;if(A.smd?eA.push(li(qA,fA,ge,A.od,A.od)):qA===1?eA.push(jD({pn:qA,x:fA,y:ge,holeDiameter:i,rectPadWidth:n,rectPadHeight:n})):eA.push(Fo(qA,fA,ge,i,n)),!l){const VA=fA+(Q==="left"?-n:Q==="right"?n:0),RA=ge+(Q==="top"?n:Q==="bottom"?-n:0);C||eA.push(sM({fs:n/5,pn:qA,anchor_x:VA,anchor_y:RA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"top"})),(B||C)&&eA.push(sM({fs:n/5,pn:qA,anchor_x:VA,anchor_y:RA,textalign:X,orthogonal:g,verticallyinverted:a,layer:"bottom"}))}qA++}}if(d)for(const aA of d){let EA=0,bA=0;aA==="topleft"?(EA=-h/2+w,bA=E/2-w):aA==="topright"?(EA=h/2-w,bA=E/2-w):aA==="bottomleft"?(EA=-h/2+w,bA=-E/2+w):aA==="bottomright"?(EA=h/2-w,bA=-E/2+w):aA==="center"&&(EA=0,bA=0),f!==void 0&&(EA+=f),m!==void 0&&(bA+=m),eA.push(Fo(s+d.indexOf(aA)+1,EA,bA,i,n))}if(!A.nosilkscreen){const aA=[{x:-h/2,y:-E/2},{x:h/2,y:-E/2},{x:h/2,y:E/2},{x:-h/2,y:E/2},{x:-h/2,y:-E/2}];eA.push(rM(aA,{stroke_width:.1,layer:"top"}))}const sA=Li(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 bA;if(N==="left")bA=[{x:-h/2,y:-aA/2},{x:-h/2+EA,y:-aA/2},{x:-h/2+EA,y:aA/2},{x:-h/2,y:aA/2},{x:-h/2,y:-aA/2}];else if(N==="right")bA=[{x:h/2-EA,y:-aA/2},{x:h/2,y:-aA/2},{x:h/2,y:aA/2},{x:h/2-EA,y:aA/2},{x:h/2-EA,y:-aA/2}];else if(N==="top")bA=[{x:-aA/2,y:E/2-EA},{x:aA/2,y:E/2-EA},{x:aA/2,y:E/2},{x:-aA/2,y:E/2},{x:-aA/2,y:E/2-EA}];else if(N==="bottom")bA=[{x:-aA/2,y:-E/2},{x:aA/2,y:-E/2},{x:aA/2,y:-E/2+EA},{x:-aA/2,y:-E/2+EA},{x:-aA/2,y:-E/2}];else return{circuitJson:eA,parameters:A};eA.push(rM(bA,{stroke_width:.1,layer:"top"}))}if(L){const aA=Y/2,EA=J/2,bA=q,_A=Z,YA=[{x:-aA+bA,y:-EA+_A},{x:aA+bA,y:-EA+_A},{x:aA+bA,y:EA+_A},{x:-aA+bA,y:EA+_A},{x:-aA+bA,y:-EA+_A}];eA.push(rM(YA,{stroke_width:.05,layer:"top"}))}return{circuitJson:eA,parameters:A}},O1t=Ui.extend({fn:U(),num_pins:OA().default(3),inline:PA().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")}),W1t=t=>{const A=O1t.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=[jD({pn:1,x:0,y:0,holeDiameter:A.id,rectPadWidth:o,rectPadHeight:s}),A.inline?IJ(2,e,0,Number.parseFloat(A.id),o,s):Fo(2,e,e,A.id,o),A.inline?IJ(3,e*2,0,Number.parseFloat(A.id),o,s):Fo(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=Li(g,c+a+1,.5);return{circuitJson:[...r,B,C],parameters:A}};function Z1t(t){return t!=null}var V1t=(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},j1t=(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},z1t=(t,A)=>A.nosilkscreen?t.filter(e=>e.type!=="pcb_silkscreen_path"&&e.type!=="pcb_silkscreen_text"):t,X1t=t=>{let A=XV();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_|x)/,"res$1").split(/_(?!metric)/).map(n=>{const o=n.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,r]=o;if(!s)return null;const a=s.toLowerCase();return r?.includes("?")?null:{fn:a,v:r}}).filter(Z1t);for(const{fn:n,v:o}of i)A=A[n](o);return A.setString(t),A},$1t=()=>Object.keys(Jb),XV=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&Jb[A.fn])return()=>{const{circuitJson:i}=Jb[A.fn](A),n=z1t(i,A),o=j1t(n,A);return V1t(o,A.origin)};if(!Jb[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(!Jb[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>Jb[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(Jb):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in Jb?(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};XV.string=X1t,XV.getFootprintNames=$1t;var A2t=XV,Vie=Symbol("Fragment");function gpA(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"),jie=Symbol("Cube"),Ol=Symbol("Cylinder"),$V=Symbol("Sphere"),lJ=Symbol("RoundedCuboid"),Zi=Symbol("Translate"),gC=Symbol("Rotate"),XQ=Symbol("Union"),pm=Symbol("Subtract"),xc=Symbol("Hull"),Do=Symbol("Colorize"),BJ=Symbol("Polygon"),CJ=Symbol("ExtrudeLinear"),Nf=Symbol("RoundedCylinder"),Tn=Vie,zA=(t,A,e)=>gpA(t,A),qt=(t,A,e)=>gpA(t,A),yB=({center:t,width:A,length:e,height:i,heightAboveSurface:n=.15,color:o="#555",taperRatio:s=.12,faceRatio:r=.75,straightHeightRatio:a=.5,includeNotch:g=!0,notchRadius:c,notchPosition:I,notchRotation:l=[0,0,0],notchLength:B=.5,notchWidth:C=.25,chamferSize:Q=0})=>{const h=i*a,E=i-h,u=Math.min(A,e)*s,d=Math.max(A-u,A*r),f=Math.max(e-u,e*r),m=Math.min(A,e)*.12,w=c??m,D={x:0,y:e/2-w*.25,z:i},S=I??D,_=qt(XQ,{children:[qt(xc,{children:[zA(Zi,{z:.005,children:zA(Qt,{size:[d,f,.01]})}),zA(Zi,{z:h,children:zA(Qt,{size:[A,e,.01]})})]}),qt(xc,{children:[zA(Zi,{z:h,children:zA(Qt,{size:[A,e,.01]})}),zA(Zi,{z:h+E,children:zA(Qt,{size:[d,f,.01]})})]})]}),b=(F,L)=>zA(Zi,{offset:{x:F,y:L,z:0},children:zA(gC,{rotation:[0,0,Math.PI/4],children:zA(Qt,{size:[Q*Math.SQRT2,Q*Math.SQRT2,i*3]})})});let N=_;if(Q>0){const F=A/2,L=e/2;N=qt(pm,{children:[_,b(F,L),b(-F,L),b(F,-L),b(-F,-L)]})}return zA(Do,{color:o,children:zA(Zi,{offset:t,children:zA(Zi,{offset:{x:0,y:0,z:n},children:g?qt(pm,{children:[N,zA(Zi,{offset:S,children:zA(gC,{rotation:l,children:zA(Ol,{radius:w,height:C})})})]}):N})})})},e2t=t=>Array.from({length:t},(A,e)=>e);function cpA(t,A){if(t.length<2)throw new Error("Stroke must have at least two points");const e=Array.isArray(t[0])?t.map(([c,I])=>({x:c,y:I})):t,i=A/2,n=[],o=[];function s(c,I){const l=I.x-c.x,B=I.y-c.y,C=Math.sqrt(l*l+B*B);return{x:-B/C,y:l/C}}function r(c,I,l){const B={x:c.x+I.x*i*l,y:c.y+I.y*i*l};l>0?n.push(B):o.unshift(B)}const a=s(e[0],e[1]);r(e[0],a,1),r(e[0],a,-1);for(let c=1;c<e.length-1;c++){const I=e[c-1],l=e[c],B=e[c+1],C=s(I,l),Q=s(l,B),h=C.x+Q.x,E=C.y+Q.y,u=Math.sqrt(h*h+E*E);if(u/2>2*i)r(l,C,1),r(l,Q,1),r(l,C,-1),r(l,Q,-1);else{const f=1/u;r(l,{x:h*f,y:E*f},1),r(l,{x:h*f,y:E*f},-1)}}const g=s(e[e.length-2],e[e.length-1]);return r(e[e.length-1],g,1),r(e[e.length-1],g,-1),[...n,...o]}var t2t=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}))},i2t=t2t([{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}]),zie=5.47,A9=.5,n2t=({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(gC,{rotation:["-90deg",0,"90deg"],children:zA(CJ,{height:.25,children:zA(BJ,{points:i2t.slice().reverse().map(n=>[n.x,n.y])})})})}),zA(Zi,{offset:{x:t,y:A+(i?1:-1),z:e},children:zA(gC,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:zA(CJ,{height:2,children:zA(BJ,{points:cpA([[0,0],[-1,0],[-1,-1]],.25).map(n=>[n.x,n.y])})})})})]})},o2t=({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:[e2t(t).map(r=>{const a=r%n,g=(Math.floor(r/n)-.5)*2;return zA(n2t,{x:g*o/2,y:a*A-(n-1)/2*A,z:zie/2+A9})}),zA(yB,{width:s,length:n*A+.5,height:zie-A9,heightAboveSurface:A9,center:{x:0,y:0,z:A9}})]})};function s2t(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,s2t(c,t)]),g=cpA(a,A);return zA(Do,{color:"#fff",children:zA(Zi,{offset:{z:0,y:0,x:0,...t.position},children:zA(gC,{rotation:["90deg",0,s??0],children:zA(Zi,{offset:{x:0,y:0,z:-e/2},children:zA(CJ,{height:e,children:zA(BJ,{points:g.map(c=>[c.x,c.y])})})})})})})},r2t=({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})]})},a2t=({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})]})},IpA=1,lpA=.5,b1=.5,QJ=.2,g2t=IpA-QJ*2,Xie=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[g2t,lpA,b1],offset:[0,0,b1/2],color:t}),zA(Qt,{size:[QJ,b1,lpA],offset:[IpA/2-QJ/2,0,b1/2],color:"#ccc"}),zA(Qt,{size:[QJ,b1,lpA],offset:[-IpA/2+QJ/2,0,b1/2],color:"#ccc"})]}),BpA=1.6,c2t=BpA-.3*2,e9=.3,CpA=.85,x1=.6,$ie=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[c2t,CpA,x1],offset:[0,0,x1/2],color:t}),zA(Qt,{size:[e9,CpA,x1],offset:[BpA/2-e9/2,0,x1/2],color:"#ccc"}),zA(Qt,{size:[e9,CpA,x1],offset:[-BpA/2+e9/2,0,x1/2],color:"#ccc"})]}),QpA=2,hpA=1.25,_1=.55,hJ=.5,I2t=QpA-hJ*2,Ane=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[I2t,hpA,_1],offset:[0,0,_1/2],color:t}),zA(Qt,{size:[hJ,hpA,_1],offset:[QpA/2-hJ/2,0,_1/2],color:"#ccc"}),zA(Qt,{size:[hJ,hpA,_1],offset:[-QpA/2+hJ/2,0,_1/2],color:"#ccc"})]}),l2t=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:n})=>{const o=t/4;A||(A=B2t(t,n)),i||(i=C2t(t)),e||(e=Q2t(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})]})},B2t=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},C2t=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}},Q2t=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},ene=({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(Do,{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(xc,{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(Do,{color:"gold",children:zA(Zi,{y:I?-3.9:0,z:I?1:0,children:zA(gC,{rotation:I?[-Math.PI/2,0,0]:[0,0,0],children:qt(xc,{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)]})]})})})})]}),h2t=({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,f=B+d*A,m=-u*I;return zA(ene,{x:f,y:m,pinThickness:.63,shortSidePinLength:l,longSidePinLength:e,bodyHeight:2,flipZ:Q,faceup:n,smd:s,rightangle:r},E)})})},E2t=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")}},u2t=({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},d2t=({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=u2t({num_pins:t,cw:!0,ccw:!0}),c=[];for(let I=0;I<t;I++){const{x:l,y:B,o:C}=E2t({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(Do,{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]})]})},p2t=d2t,f2t=()=>{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})]})},y2t=f2t,m2t=({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})]})},EpA=.6,upA=.3,k1=.33,EJ=.1,w2t=EpA-EJ*2,tne=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[w2t,upA,k1],offset:[0,0,k1/2],color:t}),zA(Qt,{size:[EJ,upA,k1],offset:[EpA/2-EJ/2,0,k1/2],color:"#ccc"}),zA(Qt,{size:[EJ,upA,k1],offset:[-EpA/2+EJ/2,0,k1/2],color:"#ccc"})]}),dpA=.4,ppA=.2,v1=.13,uJ=.07,D2t=dpA-uJ*2,ine=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[D2t,ppA,v1],offset:[0,0,v1/2],color:t}),zA(Qt,{size:[uJ,ppA,v1],offset:[dpA/2-uJ/2,0,v1/2],color:"#ccc"}),zA(Qt,{size:[uJ,ppA,v1],offset:[-dpA/2+uJ/2,0,v1/2],color:"#ccc"})]}),fpA=3.2,ypA=1.6,F1=.9,dJ=.5,S2t=fpA-dJ*2,nne=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[S2t,ypA,F1],offset:[0,0,F1/2],color:t}),zA(Qt,{size:[dJ,ypA,F1],offset:[fpA/2-dJ/2,0,F1/2],color:"#ccc"}),zA(Qt,{size:[dJ,ypA,F1],offset:[-fpA/2+dJ/2,0,F1/2],color:"#ccc"})]}),mpA=3.2,wpA=2.5,M1=1,pJ=.6,b2t=mpA-pJ*2,one=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[b2t,wpA,M1],offset:[0,0,M1/2],color:t}),zA(Qt,{size:[pJ,wpA,M1],offset:[mpA/2-pJ/2,0,M1/2],color:"#ccc"}),zA(Qt,{size:[pJ,wpA,M1],offset:[-mpA/2+pJ/2,0,M1/2],color:"#ccc"})]}),DpA=5,SpA=2.5,R1=1.4,fJ=.6,x2t=DpA-fJ*2,sne=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[x2t,SpA,R1],offset:[0,0,R1/2],color:t}),zA(Qt,{size:[fJ,SpA,R1],offset:[DpA/2-fJ/2,0,R1/2],color:"#ccc"}),zA(Qt,{size:[fJ,SpA,R1],offset:[-DpA/2+fJ/2,0,R1/2],color:"#ccc"})]}),bpA=6.3,xpA=3.2,N1=1.8,yJ=.8,_2t=bpA-yJ*2,rne=({color:t="#333"})=>qt(Tn,{children:[zA(Qt,{size:[_2t,xpA,N1],offset:[0,0,N1/2],color:t}),zA(Qt,{size:[yJ,xpA,N1],offset:[bpA/2-yJ/2,0,N1/2],color:"#ccc"}),zA(Qt,{size:[yJ,xpA,N1],offset:[-bpA/2+yJ/2,0,N1/2],color:"#ccc"})]}),ane=({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(Do,{color:"#1a1a1a",children:qt(pm,{children:[zA(Qt,{color:"#000",size:[r,a,s],center:[t,A,g(e+s/2)]}),o?zA(Ol,{height:s+.1,radius:o/2,center:[t,A,g(e+s/2)],color:"#222"}):zA(Qt,{size:[I,I,s],center:[t,A,g(e+s/2)]})]})}),qt(Do,{color:"silver",children:[qt(xc,{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)]})]})]})},k2t=({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(ane,{x:Q,y:h,pitch:A,legsLength:e,innerDiameter:i,flipZ:c},l)})})},v2t=({width:t,length:A,innerDiameter:e=1})=>{const i=t,n=A,o=t*.7,s=e/2.5;return qt(Tn,{children:[zA(lJ,{color:"#1a1a1f",center:[0,0,o/2],size:[n,n,o],roundRadius:.3}),zA(lJ,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[n,n,o*.1],roundRadius:.14}),zA(Ol,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),zA(Ol,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,n/3,o+o*.1/2]}),zA(Ol,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,-n/3,o+o*.1/2]}),zA(Ol,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,n/3,o+o*.1/2]}),zA(Ol,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,-n/3,o+o*.1/2]}),zA(t9,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:-n/2,z:-o*1.2}}),zA(t9,{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(t9,{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(t9,{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}})]})},t9=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=cpA(r,A);return zA(Do,{color:"#f2f2f2",children:zA(Zi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:zA(gC,{rotation:[0,55,o],children:zA(CJ,{height:e,children:zA(BJ,{points:a.map(g=>[g.y,g.x])})})})})})},F2t=({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})]})},M2t=({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})]})},R2t=()=>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(Do,{color:"#222",children:qt(XQ,{children:[zA(Zi,{z:.3/2,children:zA(Qt,{size:[1.65,.8,.3]})}),qt(xc,{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]})})]})]})})]}),N2t=()=>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(Do,{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]})]}),G2t=()=>{const g=zA(Do,{color:"#1a1a1a",children:qt(XQ,{children:[qt(xc,{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(xc,{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(Do,{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]})},L2t=()=>{const g=zA(Do,{color:"#1a1a1a",children:qt(XQ,{children:[qt(xc,{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(xc,{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(Do,{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]})},U2t=()=>{const g=zA(Do,{color:"#1a1a1a",children:qt(XQ,{children:[qt(xc,{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(xc,{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(Do,{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]})},H2t=()=>{const I=zA(Do,{color:"#222",children:qt(XQ,{children:[zA(Zi,{z:.27,children:zA(Qt,{size:[2.9,1.9,.54]})}),qt(xc,{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]})},Y2t=()=>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(Do,{color:"#222",children:qt(XQ,{children:[zA(Zi,{z:.55/2,children:zA(Qt,{size:[2.7,1.6,.55]})}),qt(xc,{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]})})]})]})})]}),J2t=()=>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(Do,{color:"#222",children:qt(XQ,{children:[zA(Zi,{z:.2/2,children:zA(Qt,{size:[2.75,1.8,.2]})}),qt(xc,{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]})]}),T2t=()=>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(Do,{color:"#222",children:qt(XQ,{children:[qt(xc,{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(xc,{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]})]}),P2t=()=>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(Do,{color:"#222",children:qt(XQ,{children:[qt(xc,{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(xc,{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]})]}),K2t=()=>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(Do,{color:"#222",children:qt(XQ,{children:[zA(Zi,{z:.14/2,children:zA(Qt,{size:[.8,.6,.14]})}),qt(xc,{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]})})]})]})})]}),q2t=()=>{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})]})},O2t=()=>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})]}),W2t=O2t,Z2t=()=>{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})]})},V2t=({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})]})},j2t=()=>{const i=.20900000000000002,n=.1,o=.3,s=.1,r=.2;return qt(Tn,{children:[zA(Do,{color:"#222",children:qt(XQ,{children:[zA(Qt,{size:[.85,1.2,i],center:[0,0,i/2]}),qt(xc,{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]})]})},z2t=({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]})]})},X2t=({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(Do,{color:s,children:[qt(xc,{children:[zA(Nf,{height:e,roundRadius:.5,radius:g,center:[-c,0,e]}),zA(Nf,{height:e,roundRadius:.5,radius:g,center:[c,0,e]})]}),qt(xc,{children:[zA(Nf,{height:l,roundRadius:.1,radius:g+.85,center:[-c,0,e/2+l/2]}),zA(Nf,{height:l,roundRadius:.1,radius:g+.85,center:[c,0,e/2+l/2]})]})]}),qt(Do,{color:r,children:[zA(Ol,{height:o+e/2,radius:n/2,center:[-I+.06,0,-(o/2)+e/2]}),zA(Ol,{height:o+e/2,radius:n/2,center:[I-.06,0,-(o/2)+e/2]})]})]})},$2t=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:n="#111"})=>qt(Tn,{children:[zA(Do,{color:e,children:qt(gC,{rotation:[0,"90deg",0],children:[zA(lJ,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),zA(Ol,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),zA(Do,{color:n,children:zA(gC,{rotation:[0,"90deg",0],children:zA(lJ,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),zA(Do,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(Nf,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),zA(Do,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(Nf,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),ALt=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>qt(Tn,{children:[zA(Do,{color:e,children:zA(gC,{rotation:[0,"90deg",0],children:zA(Nf,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),zA(Do,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(Nf,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),zA(Do,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(Nf,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),eLt=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>qt(Tn,{children:[zA(Do,{color:e,children:zA(gC,{rotation:[0,"90deg",0],children:zA(Nf,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),zA(Do,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(Nf,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),zA(Do,{color:i,children:zA(gC,{rotation:[0,"90deg",0],children:zA(Nf,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),tLt=({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})]})},iLt=({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})]})},nLt=()=>{const Q=7.050000000000001,h=24.95+6.5/2;return zA(Zi,{center:[0,0,1],children:qt(Tn,{children:[qt(gC,{rotation:[0,55,-55],children:[qt(pm,{children:[zA(Qt,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[h,0,1.3-2]}),zA(Ol,{color:"black",center:[h,0,1.3-2],radius:3/2,height:1.3*1.2})]}),zA(Do,{color:"#222",children:zA(yB,{width:9.9,length:9.9,height:4.5,center:{x:20,y:0,z:-2.4},includeNotch:!1,straightHeightRatio:.3,taperRatio:.04,heightAboveSurface:1})})]}),zA(gC,{rotation:[0,55,55],children:Array.from({length:3}).map((E,u)=>{const d=Q,f=(u-1)*2.7,m=-.5-.6;return qt(Do,{color:"gold",children:[qt(xc,{children:[zA(Zi,{center:[15.05-4.5/2+.1,f,m],children:zA(Qt,{size:[4.5,.81+1,.5]})}),zA(Zi,{center:[15.05-4.5/2-1+.1,f,m],children:zA(Qt,{size:[4.5,.81,.5]})})]}),zA(Zi,{center:[d,f,m],children:zA(Qt,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},oLt=()=>{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})]})},sLt=()=>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]})})]}),rLt=()=>{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(Do,{color:s,children:qt(pm,{children:[zA(Zi,{center:[0,0,2.25],children:zA(Ol,{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(xc,{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]})})]})},aLt=()=>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})]}),gLt=aLt,cLt=()=>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]})})]}),ILt=()=>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(Do,{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]})]}),lLt=()=>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(Do,{color:"#222",children:qt(XQ,{children:[zA(Zi,{z:.175/2,children:zA(Qt,{size:[1.7,1.25,.175]})}),qt(xc,{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]})]}),BLt=()=>{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(Do,{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]})]})},CLt=({pitch:t=10})=>qt(Tn,{children:[zA(Ol,{height:4,radius:.5,center:[-t/2,0,.5]}),zA($V,{radius:.5,center:[-t/2,0,2.5]}),zA(Zi,{x:-2.5,y:0,z:2.5,children:qt(gC,{rotation:[0,Math.PI/2,0],children:[zA(Ol,{height:t,radius:.5,center:[0,0,2.5]}),zA(Do,{color:"#d2b48c",children:zA(Ol,{height:5,radius:1.3,center:[0,0,2.5]})})]})}),zA(Ol,{height:4,radius:.5,center:[t/2,0,.5]}),zA($V,{radius:.5,center:[t/2,0,2.5]})]}),QLt=({bodyWidth:t=21,boardThickness:A=.5,leadWidth:e=1.6,leadLength:i=2.4,leadsPitch:n=2.54,leadsLeft:o,leadsRight:s,leadsTop:r,leadsBottom:a,innerHoles:g=!0,innerHoleEdgeDistance:c=1.61,innerHoleDiameter:I=1})=>{const l=t/2,B=A/2,C=A*1.05,Q=I/2,h=Math.max(o||0,s||0,r||0,a||0)*n||51,E=[],u=[];if(s){const w=-((s-1)/2)*n;for(let D=0;D<s;D++){const S=w+D*n;E.push({x:l-i/2,y:-S,pl:i,pw:e}),g&&u.push({x:l,y:-S},{x:l-c,y:-S})}}if(o){const w=-((o-1)/2)*n;for(let D=0;D<o;D++){const S=w+D*n;E.push({x:-l+i/2,y:-S,pl:i,pw:e}),g&&u.push({x:-l,y:-S},{x:-l+c,y:-S})}}if(r){const w=-((r-1)/2)*n;for(let D=0;D<r;D++){const S=w+D*n;E.push({x:-S,y:h/2-i/2,pl:e,pw:i}),g&&u.push({x:-S,y:h/2},{x:-S,y:h/2-c})}}if(a){const w=-((a-1)/2)*n;for(let D=0;D<a;D++){const S=w+D*n;E.push({x:-S,y:-h/2+i/2,pl:e,pw:i}),g&&u.push({x:-S,y:-h/2},{x:-S,y:-h/2+c})}}const d=zA(Do,{color:"#008080",children:qt(pm,{children:[zA(Qt,{center:[0,0,B],size:[t,h,A]}),E.map((w,D)=>zA(Qt,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]},D))]})}),f=g&&u.map((w,D)=>zA(Ol,{color:"black",center:[w.x,w.y,B],radius:Q,height:A*1.07})),m=E.map((w,D)=>zA(Qt,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]}));return qt(Tn,{children:[d,zA(Do,{color:"#FFD700",children:g?qt(pm,{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))}),f]}):m})]})},hLt=({width:t=30,height:A=22,thickness:e=1,bezelInset:i=2,bezelDepth:n=1,screenColor:o="#001414",bezelColor:s="#0f1116",screenWidth:r,screenHeight:a,offset:g})=>{const c=t,I=A,l=Math.max(e,.4),B=Math.max(Math.min(n,l),.2),C=Math.max(l-B,0),Q=Math.max(i,0),h=Math.max(r??c-Q*2,2),E=Math.max(a??I-Q*2,2),u=Math.min(Math.max(B*.6,.2),B),d=g?.x??0,f=g?.y??0,m=g?.z??0;return qt(Zi,{offset:{x:d,y:f,z:m},children:[C>0&&zA(Do,{color:s,children:zA(Qt,{size:[c,I,C],offset:[0,0,C/2]})}),zA(Do,{color:s,children:qt(pm,{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(Do,{color:o,children:zA(Qt,{size:[h,E,u],offset:[0,0,C+u/2]})})]})},ELt=({numPins:t=5,rows:A=1,p:e=2.54,id:i=1,od:n=1.5,boardThickness:o=1.6,width:s,height:r,pinRowSide:a="left",holes:g=[],holeInset:c=1,pinRowHoleEdgeToEdgeDist:I=2,female:l,nopin:B,screen:C,screenWidth:Q,screenHeight:h,screenCenterOffsetX:E,screenCenterOffsetY:u})=>{const d=C??!1,f=o/2,m=Math.ceil(t/A);let w,D;a==="left"||a==="right"?(w=(A-1)*e+2*I,D=(m-1)*e+2*I):(D=(A-1)*e+2*I,w=(m-1)*e+2*I),t===0&&(w=10,D=10);const S=Number(s??w),_=Number(r??D),b=[];let N=0,F=0,L=0,Y=0,J=0,q=0;a==="left"||a==="right"?(N=a==="left"?-S/2+I:S/2-I,F=-((m-1)/2)*e,L=0,Y=e,J=a==="left"?e:-e,q=0):(N=-((m-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<m&&Z<t;kA++){const dA=N+kA*L+QA*J,qA=F+kA*Y+QA*q;b.push({x:dA,y:qA}),Z++}const X=[];if(g)for(const QA of g){let kA=0,dA=0;QA==="topleft"?(kA=-S/2+c,dA=_/2-c):QA==="topright"?(kA=S/2-c,dA=_/2-c):QA==="bottomleft"?(kA=-S/2+c,dA=-_/2+c):QA==="bottomright"?(kA=S/2-c,dA=-_/2+c):QA==="center"&&(kA=0,dA=0),X.push({x:kA,y:dA})}const eA=.63,gA=2,iA=6,tA=3,sA=B||l?0:gA,aA=sA+o,EA=zA(Do,{color:"#008080",children:qt(pm,{children:[zA(Qt,{center:[0,0,f+sA],size:[S,_,o]}),X.map((QA,kA)=>zA(Ol,{center:[QA.x,QA.y,f+sA],radius:n/2,height:o},`hole-${kA}`)),b.map((QA,kA)=>zA(Ol,{center:[QA.x,QA.y,f+sA],radius:n/2,height:o},`pin-hole-${kA}`))]})}),bA=b.map((QA,kA)=>zA(Do,{color:"#FFD700",children:qt(pm,{children:[zA(Ol,{center:[QA.x,QA.y,o/2+sA],radius:n/2,height:o}),zA(Ol,{center:[QA.x,QA.y,o/2+sA],radius:i/2,height:o})]})})),_A=b.map((QA,kA)=>zA(ene,{x:QA.x,y:QA.y,pinThickness:eA,shortSidePinLength:tA,longSidePinLength:iA,bodyHeight:gA,flipZ:dA=>dA})),YA=b.map((QA,kA)=>zA(ane,{x:QA.x,y:QA.y,flipZ:dA=>-dA}));return qt(Tn,{children:[EA,bA,!l&&!B&&_A,l&&YA,d&&zA(hLt,{width:Q??S*.8,height:h??_*.6,offset:{x:E??0,y:u??0,z:aA}})]})},uLt=({footprint:t})=>{const A=A2t.string(t).json();switch(A.fn){case"dip":return zA(o2t,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"axial":return zA(CLt,{pitch:A.p});case"tssop":return zA(r2t,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return zA(a2t,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return zA(M2t,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return zA(l2t,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return zA(W2t,{});case"lqfp":return zA(V2t,{pinCount:A.num_pins});case"qfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return zA(p2t,{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(z2t,{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(h2t,{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(k2t,{numberOfPins:A.num_pins,pitch:A.p,rows:o})}case"cap":switch(A.imperial){case"0402":return zA(Xie,{color:"#856c4d"});case"0603":return zA($ie,{color:"#856c4d"});case"0805":return zA(Ane,{color:"#856c4d"});case"0201":return zA(tne,{color:"#856c4d"});case"01005":return zA(ine,{color:"#856c4d"});case"1206":return zA(nne,{color:"#856c4d"});case"1210":return zA(one,{color:"#856c4d"});case"2010":return zA(sne,{color:"#856c4d"});case"2512":return zA(rne,{color:"#856c4d"})}case"sot235":return zA(y2t,{});case"sot457":return zA(oLt,{});case"sot223":return zA(q2t,{});case"sot23w":return zA(m2t,{});case"sot323":return zA(Z2t,{});case"sod323f":return zA(lLt,{});case"sod323fl":return zA(BLt,{});case"sot363":return zA(gLt,{});case"sot886":return zA(cLt,{});case"sot963":return zA(sLt,{});case"pushbutton":return zA(v2t,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return zA(F2t,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return zA(R2t,{});case"sod882":return zA(N2t,{});case"sma":return zA(G2t,{});case"smb":return zA(L2t,{});case"smc":return zA(U2t,{});case"smf":return zA(H2t,{});case"sod123f":return zA(Y2t,{});case"sod123fl":return zA(J2t,{});case"sod123w":return zA(T2t,{});case"sod128":return zA(P2t,{});case"sod323":return zA(ILt,{});case"sod923":return zA(K2t,{});case"hc49":return zA(X2t,{});case"micromelf":return zA($2t,{});case"minimelf":return zA(ALt,{});case"melf":return zA(eLt,{});case"ms012":return zA(tLt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return zA(iLt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return zA(j2t,{});case"to220":return zA(nLt,{});case"to92":return zA(rLt,{});case"stampboard":case"stampreceiver":return zA(QLt,{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(ELt,{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(Xie,{color:i});case"0603":return zA($ie,{color:i});case"0805":return zA(Ane,{color:i});case"0201":return zA(tne,{color:i});case"01005":return zA(ine,{color:i});case"1206":return zA(nne,{color:i});case"1210":return zA(one,{color:i});case"2010":return zA(sne,{color:i});case"2512":return zA(rne,{color:i})}return null},dLt=t=>t&&typeof t=="object"&&"type"in t,G1=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},pLt=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 zD(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=>zD(l,A,e));if(!dLt(t))return[];const{type:g,props:c,children:I}=t;if(g===Vie)return(I??[]).flatMap(l=>zD(l,A,e));if(g===Do){const l=c?.color;return(I??[]).flatMap(B=>zD(B,l??A,e))}if(g===Zi){const l=pLt(c?.offset??c?.center??{x:c?.x,y:c?.y,z:c?.z});return(I??[]).flatMap(C=>zD(C,A,e)).map(({geom:C,color:Q})=>({geom:a.translate(l,C),color:Q??A}))}if(g===gC){const l=Array.isArray(c?.rotation)?[G1(c.rotation[0]),G1(c.rotation[1]),G1(c.rotation[2])]:[G1(c?.x??0),G1(c?.y??0),G1(c?.z??0)];return(I??[]).flatMap(C=>zD(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===pm||g===xc){const l=(I??[]).flatMap(C=>zD(C,A,e)).map(C=>C.geom);if(l.length===0)return[];let B;return g===XQ?B=n.union(l):g===pm?B=n.subtract(l[0],l.slice(1)):B=o.hull(l),[{geom:B,color:A}]}if(g===BJ){const l=c?.points??[];return[{geom:s.geom2.fromPoints(l),color:A??c?.color}]}if(g===CJ){const l=(I??[]).flatMap(h=>zD(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===jie||g===Ol||g===$V||g===lJ||g===Nf){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===jie){const B=c?.size??1,C=c?.offset,Q=c?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);l=i.cube({size:B,center:Q})}else if(g===Ol){const B=c?.height??1,C=c?.radius??1,Q=c?.center??[0,0,0];l=i.cylinder({height:B,radius:C,center:Q})}else if(g===$V){const B=c?.radius??1,C=c?.center??[0,0,0];l=i.sphere({radius:B,center:C})}else if(g===Nf){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 zD(l,A,e)}return(I??[]).flatMap(l=>zD(l,A,e))}function fLt(t,A){return{geometries:zD(t,void 0,{jscad:A})}}function gne(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 hs;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 hs;n.fromArray(t.transforms),i.applyMatrix4(n)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Ng}function yLt(t,A){const e=gpA(uLt,{footprint:t});return fLt(e,A)}var mLt=va(KV()),cne=V.createContext(null),wLt=()=>{const t=V.useContext(cne);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},DLt=({children:t})=>{const{camera:A,renderer:e}=rd(),[i,n]=V.useState([]),o=V.useMemo(()=>new Edt,[]),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 f={mousePosition:[u.point.x,u.point.y,u.point.z]};a.current!==d?(a.current?.onUnhover(),d.onHover(f),a.current=d):d.onHover(f)}else a.current&&(a.current.onUnhover(),a.current=null)}else a.current&&(a.current.onUnhover(),a.current=null)},[A,e,o,s,I]);V.useEffect(()=>{const C=e.domElement;return C.addEventListener("mousemove",l),()=>{C.removeEventListener("mousemove",l)}},[e,l]);const B=V.useMemo(()=>({addHoverable:g,removeHoverable:c}),[g,c]);return W.jsx(cne.Provider,{value:B,children:t})},SLt=({children:t,object:A,onHover:e,onUnhover:i,isHovered:n})=>{const{addHoverable:o,removeHoverable:s}=wLt();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})},mJ=SLt,bLt=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=rd(),g=V.useMemo(()=>{if(!A)return null;const{geometries:c}=yLt(A,mLt),I=new Rf;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=gne(Q),E=new jE({vertexColors:!0,side:aC,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new Bo(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 Bo&&c.material instanceof jE&&(o?(c.material.emissive.setHex(255),c.material.emissiveIntensity=.2):c.material.emissiveIntensity=0)})},[o,g]),g?W.jsx(mJ,{isHovered:o,onHover:i,onUnhover:n,object:g}):null},Ine=new WeakMap,xLt=()=>{const t=new nI;return t.name="fallback-environment-map",t.mapping=jW,t},_Lt=t=>{if(!t)return null;const A=t,e=Ine.get(A);if(e)return e;let i;if(t instanceof xZ){const n=new QcA(t);i=n.fromScene(Jdt(),.04).texture,n.dispose()}else i=xLt();return Ine.set(A,i),i},lne=1.25;function Bne({gltfUrl:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=rd(),[c,I]=V.useState(null),[l,B]=V.useState(null);if(V.useEffect(()=>{if(!t)return;const C=new Pdt;let Q=!0;return C.load(t,h=>{if(!Q)return;const E=h.scene;E.traverse(u=>{if(u instanceof Bo&&u.material){const d=f=>{f.transparent=r,f.opacity=r?.5:1,f.depthWrite=!r,f.needsUpdate=!0};Array.isArray(u.material)?u.material.forEach(d):d(u.material),u.renderOrder=r?2:1}}),I(E)},void 0,h=>{if(!Q)return;console.error(`An error happened loading ${t}`,h);const E=h instanceof Error?h:new Error(`Failed to load glTF model from ${t}`);B(E)}),()=>{Q=!1}},[t,r]),V.useEffect(()=>{c&&(A&&c.position.fromArray(A),e&&c.rotation.fromArray(e),s!==void 0&&c.scale.setScalar(s))},[c,A?.[0],A?.[1],A?.[2],e?.[0],e?.[1],e?.[2],s]),V.useEffect(()=>{if(!(!g||!c))return g.add(c),()=>{g.remove(c)}},[g,c]),V.useEffect(()=>{if(!c||!a)return;const C=_Lt(a);if(!C)return;const Q=[],h=E=>{E instanceof jE&&(Q.push({material:E,envMap:E.envMap??null,envMapIntensity:E.envMapIntensity??1}),E.envMap=C,(typeof E.envMapIntensity!="number"||E.envMapIntensity<lne)&&(E.envMapIntensity=lne),E.needsUpdate=!0)};return c.traverse(E=>{if(!(E instanceof Bo))return;const u=E.material;Array.isArray(u)?u.forEach(h):u&&h(u)}),()=>{Q.forEach(({material:E,envMap:u,envMapIntensity:d})=>{E.envMap=u,E.envMapIntensity=d,E.needsUpdate=!0})}},[c,a]),V.useEffect(()=>{c&&c.traverse(C=>{C instanceof Bo&&C.material instanceof jE&&(o?(C.material.emissive.setHex(255),C.material.emissiveIntensity=.2):C.material.emissiveIntensity=0)})},[o,c]),l)throw l;return c?W.jsx(mJ,{isHovered:o,onHover:i,onUnhover:n,object:c}):null}var kLt=va(Eie()),vLt=va(KV()),FLt=({jscadPlan:t,positionOffset:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=rd(),{threeGeom:g,material:c}=V.useMemo(()=>{const l=(0,kLt.executeJscadOperations)(vLt.default,t);if(!l||!l.polygons&&!l.sides)return{threeGeom:null,material:null};const B=gne(l),C=new jE({vertexColors:!0,side:aC,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:B,material:C}},[t,r]),I=V.useMemo(()=>{if(!g)return null;const l=new Bo(g,c);return l.renderOrder=r?2:1,l},[g,c,r]);return V.useEffect(()=>{if(!(!I||!a))return a.add(I),()=>{a.remove(I)}},[a,I]),V.useEffect(()=>{I&&(A&&I.position.fromArray(A),e&&I.rotation.fromArray(e),s!==void 0&&I.scale.setScalar(s))},[I,A?.[0],A?.[1],A?.[2],e?.[0],e?.[1],e?.[2],s]),V.useMemo(()=>{if(c)if(o){const l=new en(c.color.getHex());c.emissive.copy(l),c.emissive.setRGB(0,0,1),c.emissiveIntensity=.2}else c.emissiveIntensity=0},[o,c]),g?W.jsx(mJ,{isHovered:o,onHover:i,onUnhover:n,object:I}):null};function MLt(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(A,e,i)=>`${e} ${i.replace(/-/g,"_")}`)}async function RLt(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 xpt().parse(MLt(e),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function NLt(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 RLt(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 Lpt;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 Dpt;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 GLt({url:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const a=NLt(t),{rootObject:g}=rd(),c=V.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(I=>{if(I instanceof Bo&&I.material){const l=B=>{B.transparent=r,B.opacity=r?.5:1,B.depthWrite=!r,B.needsUpdate=!0};Array.isArray(I.material)?I.material.forEach(l):l(I.material),I.renderOrder=r?2:1}}),a):new Bo(new kw(.5,.5,.5),new jE({transparent:!0,color:"red",opacity:.25})),[a,r]);if(V.useEffect(()=>{if(!(!g||!c))return g.add(c),()=>{g.remove(c)}},[g,c]),V.useEffect(()=>{c&&(A&&(Array.isArray(A)?c.position.fromArray(A):c.position.copy(A)),e&&(Array.isArray(e)?c.rotation.fromArray(e):c.rotation.copy(e)),s!==void 0&&c.scale.setScalar(s))},[c,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,s]),a instanceof Error)throw a;return W.jsx(mJ,{isHovered:o,onHover:i,onUnhover:n,object:c})}var _pA,LLt="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function ULt(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 HLt(){if(!_pA){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");_pA=ULt(t)({locateFile:e=>`${LLt}/${e}`})}return _pA}function YLt(t){const A=new Rf;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 As(i,3));const s=e.attributes.normal?.array??[];s.length?o.setAttribute("normal",new As(s,3)):o.computeVertexNormals(),o.setIndex(n);const r=new jE({color:e.color?new en(e.color[0],e.color[1],e.color[2]):new en(.82,.82,.82)}),a=new Bo(o,r);a.name=e.name,A.add(a)}return A}async function JLt(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 HLt()).ReadStepFile(new Uint8Array(e),null);if(!n.success||!n.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=YLt(n.meshes),s=new OcA;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 Cne="step-glb-cache:";function TLt(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 PLt(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 KLt(t){try{const A=localStorage.getItem(`${Cne}${t}`);return A?PLt(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function Qne(t,A){try{const e=TLt(A);localStorage.setItem(`${Cne}${t}`,e)}catch(e){console.warn("Failed to write STEP GLB cache",e)}}function qLt(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var OLt=({stepUrl:t,position:A,rotation:e,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r})=>{const[a,g]=V.useState(null);return V.useEffect(()=>{let c=!0,I=null,l=!0;const B=qLt(),C=KLt(t);if(C){const E={arrayBuffer:C,blobUrl:URL.createObjectURL(new Blob([C],{type:"model/gltf-binary"}))};return B.completed.set(t,E),I=E.blobUrl,l=!1,g(E.blobUrl),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)}}const Q=B.completed.get(t);if(Q)return I=Q.blobUrl,l=!1,g(Q.blobUrl),Qne(t,Q.arrayBuffer),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)};let h=B.inProgress.get(t);return h||(h=JLt(t).then(E=>{const u={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return B.completed.set(t,u),B.inProgress.delete(t),u}).catch(E=>{throw B.inProgress.delete(t),E}),B.inProgress.set(t,h)),h.then(E=>{c&&(I=E.blobUrl,l=!1,g(E.blobUrl),Qne(t,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),c&&g(null)}),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)}},[t]),a?W.jsx(Bne,{gltfUrl:a,position:A,rotation:e,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r}):null},WLt=(t,A)=>{if(t)return A?A(t):t},hne=(...t)=>t,kpA=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}},ZLt=({error:t,onError:A})=>(V.useEffect(()=>{A(t)},[t,A]),null),Ene=({cad_component:t,circuitJson:A,resolveStaticAsset:e})=>{const i=pie(A),[n,o]=V.useState(!1),{visibility:s}=nM(),[r,a]=V.useState(null),g=V.useCallback(N=>{N?.mousePosition?(o(!0),a(N.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(F=>F.type==="pcb_plated_hole"&&F.pcb_component_id===t.pcb_component_id).length>0,[A,t.pcb_component_id]),B=V.useCallback(N=>WLt(N,e),[e]),C=B(t.model_obj_url??t.model_wrl_url??t.model_stl_url),Q=B(t.model_glb_url??t.model_gltf_url),h=B(t.model_step_url),[E,u]=V.useState(0),[d,f]=V.useState(null);V.useEffect(()=>{u(0),f(null)},[t.cad_component_id,C,Q,h]);const w=A.find(N=>N.type==="pcb_component"&&N.source_component_id===t.source_component_id)?.layer??"top",D=V.useMemo(()=>t.rotation?hne(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):hne(0,0,0),[t.rotation,w]),S=V.useMemo(()=>{if(!t.position)return;let N;return w==="top"?N=t.position.z:w==="bottom"?N=-(t.position.z+i):N=t.position.z,[t.position.x,t.position.y,N]},[t.position,w,i]),_=V.useMemo(()=>{const N=[];return C&&N.push(W.jsx(GLt,{url:C,position:S,rotation:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${C}`)),Q&&N.push(W.jsx(Bne,{gltfUrl:Q,position:S,rotation:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${Q}`)),h&&!t.model_jscad&&!t.footprinter_string&&N.push(W.jsx(OLt,{stepUrl:h,position:S,rotation:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${h}`)),N},[S,t.cad_component_id,t.footprinter_string,t.model_jscad,t.model_unit_to_mm_scale_factor,t.show_as_translucent_model,Q,g,c,n,D,h,C]);let b=null;if(_.length>0){if(E>=_.length){if(d)throw d;return null}b=W.jsx(kpA,{fallback:({error:N})=>W.jsx(ZLt,{error:N,onError:F=>{f(F),u(L=>Math.max(L,E+1))}}),children:_[E]},`${t.cad_component_id}-fallback-${E}`)}else t.model_jscad?b=W.jsx(FLt,{jscadPlan:t.model_jscad,positionOffset:S,rotationOffset:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(b=W.jsx(bLt,{positionOffset:S,rotationOffset:D,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model}));if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(l&&!s.throughHoleModels||!l&&!s.smtModels)return null;return W.jsxs(W.Fragment,{children:[b,n&&r?W.jsx(yie,{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]})},une={version:"0.0.537"};function VLt(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var jLt=t=>{t.outputColorSpace=fw,t.toneMapping=Y5A,t.toneMappingExposure=1},dne="cadViewerCameraStateSession",pne=(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(dne,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},vpA=(t,A)=>{try{const e=sessionStorage.getItem(dne);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}},fne=V.createContext(void 0),zLt=({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 Ff(0,0,0)),B=V.useMemo(()=>{const[E,u,d]=e??[5,-5,5],f=Math.hypot(E-A.x,u-A.y,d-A.z);return f>0?f:5},[e,A]),C=V.useCallback(E=>{const u=[A.x,A.y,A.z],d=n.current,f=i.current;let m=B;switch(d&&f&&(m=d.position.distanceTo(f.target)),E){case"Top Center Angled":{const w=m/Math.sqrt(2);return{position:[A.x,A.y-w,A.z+w],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+m],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-m,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+m,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-m,A.z],target:u,up:[0,0,1]};default:return null}},[B,A,n,i]),Q=V.useCallback(E=>{i.current=E},[]),h=V.useMemo(()=>({controlsRef:i,mainCameraRef:n,defaultTarget:A,baseDistance:B,controller:o,setController:s,getPresetConfig:C,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:c,cameraRotation:I,setCameraRotation:l,saveCameraToSession:pne,loadCameraFromSession:vpA}),[A,B,o,C,Q,r,g,I]);return W.jsx(fne.Provider,{value:h,children:t})},Ek=()=>{const t=V.useContext(fne);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},XLt=V.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:n},o)=>{const{cameraType:s}=Ek(),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 JF,[]);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;VLt(r.current);const E=new xZ({antialias:!0,alpha:!0});jLt(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 dY(-10*u,10*u,10,-10,-1e3,1e3);l.current?(d.position.copy(l.current.position),d.quaternion.copy(l.current.quaternion),d.up.copy(l.current.up)):(e?.up&&d.up.set(e.up[0],e.up[1],e.up[2]),e?.position&&d.position.set(e.position[0],e.position[1],e.position[2]),d.lookAt(0,0,0)),Q.add(h.current),window.__TSCIRCUIT_THREE_OBJECT=h.current,g({scene:Q,camera:d,renderer:E,rootObject:h.current,addFrameListener:B,removeFrameListener:C}),I.current?.({camera:d,renderer:E});let f;const m=new rdt,w=()=>{const S=m.getElapsedTime(),_=m.getDelta();c.current.forEach(b=>b(S,_)),E.render(Q,d),f=requestAnimationFrame(w)};w();const D=()=>{if(r.current){const S=r.current.clientWidth/r.current.clientHeight;d instanceof Wh?d.aspect=S:d instanceof dY&&(d.left=-10*S,d.right=10*S,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),E.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",D),()=>{l.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",D),cancelAnimationFrame(f),r.current&&E.domElement&&r.current.removeChild(E.domElement),E.dispose(),Q.remove(h.current),window.__TSCIRCUIT_THREE_OBJECT===h.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,B,C,s]),W.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&W.jsx(fie.Provider,{value:a,children:W.jsx(DLt,{children:t})})})}),$Lt=({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}=rd(),l=V.useMemo(()=>!c||!I?null:new Hpt(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:W_.ROTATE,MIDDLE:W_.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]),aJ(()=>{l?.update()},[l]),null},AUt=`
5156
+ `).replace(/d 0\./g,"d 1."),B=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new Dpt;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 GLt({url:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const a=NLt(t),{rootObject:g}=rd(),c=V.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(I=>{if(I instanceof Bo&&I.material){const l=B=>{B.transparent=r,B.opacity=r?.5:1,B.depthWrite=!r,B.needsUpdate=!0};Array.isArray(I.material)?I.material.forEach(l):l(I.material),I.renderOrder=r?2:1}}),a):new Bo(new kw(.5,.5,.5),new jE({transparent:!0,color:"red",opacity:.25})),[a,r]);if(V.useEffect(()=>{if(!(!g||!c))return g.add(c),()=>{g.remove(c)}},[g,c]),V.useEffect(()=>{c&&(A&&(Array.isArray(A)?c.position.fromArray(A):c.position.copy(A)),e&&(Array.isArray(e)?c.rotation.fromArray(e):c.rotation.copy(e)),s!==void 0&&c.scale.setScalar(s))},[c,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,s]),a instanceof Error)throw a;return W.jsx(mJ,{isHovered:o,onHover:i,onUnhover:n,object:c})}var _pA,LLt="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function ULt(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 HLt(){if(!_pA){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");_pA=ULt(t)({locateFile:e=>`${LLt}/${e}`})}return _pA}function YLt(t){const A=new Rf;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 As(i,3));const s=e.attributes.normal?.array??[];s.length?o.setAttribute("normal",new As(s,3)):o.computeVertexNormals(),o.setIndex(n);const r=new jE({color:e.color?new en(e.color[0],e.color[1],e.color[2]):new en(.82,.82,.82)}),a=new Bo(o,r);a.name=e.name,A.add(a)}return A}async function JLt(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 HLt()).ReadStepFile(new Uint8Array(e),null);if(!n.success||!n.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=YLt(n.meshes),s=new OcA;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 Cne="step-glb-cache:";function TLt(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 PLt(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 KLt(t){try{const A=localStorage.getItem(`${Cne}${t}`);return A?PLt(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function Qne(t,A){try{const e=TLt(A);localStorage.setItem(`${Cne}${t}`,e)}catch(e){console.warn("Failed to write STEP GLB cache",e)}}function qLt(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var OLt=({stepUrl:t,position:A,rotation:e,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r})=>{const[a,g]=V.useState(null);return V.useEffect(()=>{let c=!0,I=null,l=!0;const B=qLt(),C=KLt(t);if(C){const E={arrayBuffer:C,blobUrl:URL.createObjectURL(new Blob([C],{type:"model/gltf-binary"}))};return B.completed.set(t,E),I=E.blobUrl,l=!1,g(E.blobUrl),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)}}const Q=B.completed.get(t);if(Q)return I=Q.blobUrl,l=!1,g(Q.blobUrl),Qne(t,Q.arrayBuffer),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)};let h=B.inProgress.get(t);return h||(h=JLt(t).then(E=>{const u={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return B.completed.set(t,u),B.inProgress.delete(t),u}).catch(E=>{throw B.inProgress.delete(t),E}),B.inProgress.set(t,h)),h.then(E=>{c&&(I=E.blobUrl,l=!1,g(E.blobUrl),Qne(t,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),c&&g(null)}),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)}},[t]),a?W.jsx(Bne,{gltfUrl:a,position:A,rotation:e,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r}):null},WLt=(t,A)=>{if(t)return A?A(t):t},hne=(...t)=>t,kpA=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}},ZLt=({error:t,onError:A})=>(V.useEffect(()=>{A(t)},[t,A]),null),Ene=({cad_component:t,circuitJson:A,resolveStaticAsset:e})=>{const i=pie(A),[n,o]=V.useState(!1),{visibility:s}=nM(),[r,a]=V.useState(null),g=V.useCallback(N=>{N?.mousePosition?(o(!0),a(N.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(F=>F.type==="pcb_plated_hole"&&F.pcb_component_id===t.pcb_component_id).length>0,[A,t.pcb_component_id]),B=V.useCallback(N=>WLt(N,e),[e]),C=B(t.model_obj_url??t.model_wrl_url??t.model_stl_url),Q=B(t.model_glb_url??t.model_gltf_url),h=B(t.model_step_url),[E,u]=V.useState(0),[d,f]=V.useState(null);V.useEffect(()=>{u(0),f(null)},[t.cad_component_id,C,Q,h]);const w=A.find(N=>N.type==="pcb_component"&&N.source_component_id===t.source_component_id)?.layer??"top",D=V.useMemo(()=>t.rotation?hne(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):hne(0,0,0),[t.rotation,w]),S=V.useMemo(()=>{if(!t.position)return;let N;return w==="top"?N=t.position.z:w==="bottom"?N=-(t.position.z+i):N=t.position.z,[t.position.x,t.position.y,N]},[t.position,w,i]),_=V.useMemo(()=>{const N=[];return C&&N.push(W.jsx(GLt,{url:C,position:S,rotation:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${C}`)),Q&&N.push(W.jsx(Bne,{gltfUrl:Q,position:S,rotation:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${Q}`)),h&&!t.model_jscad&&!t.footprinter_string&&N.push(W.jsx(OLt,{stepUrl:h,position:S,rotation:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${h}`)),N},[S,t.cad_component_id,t.footprinter_string,t.model_jscad,t.model_unit_to_mm_scale_factor,t.show_as_translucent_model,Q,g,c,n,D,h,C]);let b=null;if(_.length>0){if(E>=_.length){if(d)throw d;return null}b=W.jsx(kpA,{fallback:({error:N})=>W.jsx(ZLt,{error:N,onError:F=>{f(F),u(L=>Math.max(L,E+1))}}),children:_[E]},`${t.cad_component_id}-fallback-${E}`)}else t.model_jscad?b=W.jsx(FLt,{jscadPlan:t.model_jscad,positionOffset:S,rotationOffset:D,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(b=W.jsx(bLt,{positionOffset:S,rotationOffset:D,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:t.show_as_translucent_model}));if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(l&&!s.throughHoleModels||!l&&!s.smtModels)return null;return W.jsxs(W.Fragment,{children:[b,n&&r?W.jsx(yie,{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]})},une={version:"0.0.538"};function VLt(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var jLt=t=>{t.outputColorSpace=fw,t.toneMapping=Y5A,t.toneMappingExposure=1},dne="cadViewerCameraStateSession",pne=(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(dne,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},vpA=(t,A)=>{try{const e=sessionStorage.getItem(dne);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}},fne=V.createContext(void 0),zLt=({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 Ff(0,0,0)),B=V.useMemo(()=>{const[E,u,d]=e??[5,-5,5],f=Math.hypot(E-A.x,u-A.y,d-A.z);return f>0?f:5},[e,A]),C=V.useCallback(E=>{const u=[A.x,A.y,A.z],d=n.current,f=i.current;let m=B;switch(d&&f&&(m=d.position.distanceTo(f.target)),E){case"Top Center Angled":{const w=m/Math.sqrt(2);return{position:[A.x,A.y-w,A.z+w],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+m],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-m,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+m,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-m,A.z],target:u,up:[0,0,1]};default:return null}},[B,A,n,i]),Q=V.useCallback(E=>{i.current=E},[]),h=V.useMemo(()=>({controlsRef:i,mainCameraRef:n,defaultTarget:A,baseDistance:B,controller:o,setController:s,getPresetConfig:C,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:c,cameraRotation:I,setCameraRotation:l,saveCameraToSession:pne,loadCameraFromSession:vpA}),[A,B,o,C,Q,r,g,I]);return W.jsx(fne.Provider,{value:h,children:t})},Ek=()=>{const t=V.useContext(fne);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},XLt=V.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:n},o)=>{const{cameraType:s}=Ek(),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 JF,[]);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;VLt(r.current);const E=new xZ({antialias:!0,alpha:!0});jLt(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 dY(-10*u,10*u,10,-10,-1e3,1e3);l.current?(d.position.copy(l.current.position),d.quaternion.copy(l.current.quaternion),d.up.copy(l.current.up)):(e?.up&&d.up.set(e.up[0],e.up[1],e.up[2]),e?.position&&d.position.set(e.position[0],e.position[1],e.position[2]),d.lookAt(0,0,0)),Q.add(h.current),window.__TSCIRCUIT_THREE_OBJECT=h.current,g({scene:Q,camera:d,renderer:E,rootObject:h.current,addFrameListener:B,removeFrameListener:C}),I.current?.({camera:d,renderer:E});let f;const m=new rdt,w=()=>{const S=m.getElapsedTime(),_=m.getDelta();c.current.forEach(b=>b(S,_)),E.render(Q,d),f=requestAnimationFrame(w)};w();const D=()=>{if(r.current){const S=r.current.clientWidth/r.current.clientHeight;d instanceof Wh?d.aspect=S:d instanceof dY&&(d.left=-10*S,d.right=10*S,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),E.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",D),()=>{l.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",D),cancelAnimationFrame(f),r.current&&E.domElement&&r.current.removeChild(E.domElement),E.dispose(),Q.remove(h.current),window.__TSCIRCUIT_THREE_OBJECT===h.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,B,C,s]),W.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&W.jsx(fie.Provider,{value:a,children:W.jsx(DLt,{children:t})})})}),$Lt=({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}=rd(),l=V.useMemo(()=>!c||!I?null:new Hpt(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:W_.ROTATE,MIDDLE:W_.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]),aJ(()=>{l?.update()},[l]),null},AUt=`
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"})]})]})},EEe=t=>t.activeSubSolver?[t,...EEe(t.activeSubSolver)]:[t],gni=({solver:t})=>{const A=EEe(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(ani,{solver:e})]},e.constructor.name))})},cni=({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(gni,{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]})]})},Ini=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},lni=(t,A)=>{const i=t.pipelineDef[A].solverName,n=Ini(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}},Bni=({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})},Cni=({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,"%"]})]})},Qni=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),hni=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=Qni(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))})]})},FmA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(FmA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=FmA(i));return A},Eni=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=FmA(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)}`)}},uni=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>lni(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):Eni(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(Bni,{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(Cni,{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(hni,{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))})]})})]})},dni=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 pni({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>W.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),e.map((h,E)=>W.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var fni=({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(cni,{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(dni,{fallback:W.jsx(pni,{graphics:s}),children:W.jsx(rni,{graphics:s})}),a&&W.jsx(uni,{solver:t,onStepUntilPhase:g})]})};const yni=()=>{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)},[])},mni=t=>t.toLowerCase().includes("pack")?Iqt:t.toLowerCase().includes("rout")?hqt:jKt,wni=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);yni();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=WrA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(WrA).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=mni(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(mm,{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(fni,{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"})})})]})},uEe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{qW.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{qW.captureException(n,{error_type:i.type})}catch{}}},[e])},dEe="0.0.1734",Dni={version:dEe},Jz=k4A()(v4A(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),Sni=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=sG("eval-version-selection",null),g=Jz(B=>B.setLastRunEvalVersion),c=Jz(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("")}}},bni=({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}`})]})]})})},xni=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 _ni(t){const A=kni(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(Fni);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 kni(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=Rni(n),r=Mni(o,n.props);return n.type!==V.Fragment&&(r.ref=i?xf(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 vni=Symbol("radix.slottable");function Fni(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===vni}function Mni(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 Rni(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 Tz="Dialog",[pEe,fEe]=Ew(Tz),[Nni,Tw]=pEe(Tz),yEe=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]=G_({prop:i,defaultProp:n??!1,onChange:o,caller:Tz});return W.jsx(Nni,{scope:A,triggerRef:r,contentRef:a,contentId:qE(),titleId:qE(),descriptionId:qE(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};yEe.displayName=Tz;var mEe="DialogTrigger",wEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(mEe,e),o=RI(A,n.triggerRef);return W.jsx(eg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":NmA(n.open),...i,ref:o,onClick:Vn(t.onClick,n.onOpenToggle)})});wEe.displayName=mEe;var MmA="DialogPortal",[Gni,DEe]=pEe(MmA,{forceMount:void 0}),SEe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Tw(MmA,A);return W.jsx(Gni,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(q0,{present:e||o.open,children:W.jsx($9,{asChild:!0,container:n,children:s})}))})};SEe.displayName=MmA;var Pz="DialogOverlay",bEe=V.forwardRef((t,A)=>{const e=DEe(Pz,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Tw(Pz,t.__scopeDialog);return o.modal?W.jsx(q0,{present:i||o.open,children:W.jsx(Uni,{...n,ref:A})}):null});bEe.displayName=Pz;var Lni=_ni("DialogOverlay.RemoveScroll"),Uni=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(Pz,e);return W.jsx(rj,{as:Lni,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(eg.div,{"data-state":NmA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),YM="DialogContent",xEe=V.forwardRef((t,A)=>{const e=DEe(YM,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Tw(YM,t.__scopeDialog);return W.jsx(q0,{present:i||o.open,children:o.modal?W.jsx(Hni,{...n,ref:A}):W.jsx(Yni,{...n,ref:A})})});xEe.displayName=YM;var Hni=V.forwardRef((t,A)=>{const e=Tw(YM,t.__scopeDialog),i=V.useRef(null),n=RI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return VfA(o)},[]),W.jsx(_Ee,{...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())})}),Yni=V.forwardRef((t,A)=>{const e=Tw(YM,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(_Ee,{...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()}})}),_Ee=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Tw(YM,e),a=V.useRef(null),g=RI(A,a);return kfA(),W.jsxs(W.Fragment,{children:[W.jsx(Y9,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(KJ,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":NmA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(Tni,{titleId:r.titleId}),W.jsx(Kni,{contentRef:a,descriptionId:r.descriptionId})]})]})}),RmA="DialogTitle",kEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(RmA,e);return W.jsx(eg.h2,{id:n.titleId,...i,ref:A})});kEe.displayName=RmA;var vEe="DialogDescription",FEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(vEe,e);return W.jsx(eg.p,{id:n.descriptionId,...i,ref:A})});FEe.displayName=vEe;var MEe="DialogClose",REe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(MEe,e);return W.jsx(eg.button,{type:"button",...i,ref:A,onClick:Vn(t.onClick,()=>n.onOpenChange(!1))})});REe.displayName=MEe;function NmA(t){return t?"open":"closed"}var NEe="DialogTitleWarning",[Jni,GEe]=Uat(NEe,{contentName:YM,titleName:RmA,docsSlug:"dialog"}),Tni=({titleId:t})=>{const A=GEe(NEe),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"})]})]})},EEe=t=>t.activeSubSolver?[t,...EEe(t.activeSubSolver)]:[t],gni=({solver:t})=>{const A=EEe(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(ani,{solver:e})]},e.constructor.name))})},cni=({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(gni,{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]})]})},Ini=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},lni=(t,A)=>{const i=t.pipelineDef[A].solverName,n=Ini(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}},Bni=({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})},Cni=({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,"%"]})]})},Qni=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),hni=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const A=Object.entries(t),e=Qni(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))})]})},FmA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(FmA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=FmA(i));return A},Eni=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=FmA(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)}`)}},uni=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>lni(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):Eni(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(Bni,{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(Cni,{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(hni,{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))})]})})]})},dni=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 pni({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(h,E)=>{typeof h=="number"&&(h<s&&(s=h),h>a&&(a=h)),typeof E=="number"&&(E<r&&(r=E),E>g&&(g=E))};for(const h of A)c(h.x,h.y);for(const h of e){const E=h.points??[];for(const u of E)c(u.x,u.y)}for(const h of i){const E=h.x??0,u=h.y??0,d=h.width??0,f=h.height??0;c(E,u),c(E+d,u+f)}for(const h of n){const E=h.x??0,u=h.y??0,d=h.radius??1;c(E-d,u-d),c(E+d,u+d)}for(const h of o)c(h.x,h.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((h,E)=>W.jsx("rect",{x:h.x??0,y:h.y??0,width:h.width??0,height:h.height??0,fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`rect-${E}`)),e.map((h,E)=>W.jsx("polyline",{fill:"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1,points:(h.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${E}`)),n.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.fillColor??"none",stroke:h.strokeColor??"black",strokeWidth:h.strokeWidth??1},`circle-${E}`)),A.map((h,E)=>W.jsx("circle",{cx:h.x??0,cy:h.y??0,r:h.radius??1.5,fill:h.color??"black"},`point-${E}`)),o.map((h,E)=>W.jsx("text",{x:h.x??0,y:h.y??0,fontSize:h.fontSize??10,fill:h.color??"black",children:h.text??""},`text-${E}`))]})}var fni=({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(cni,{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(dni,{fallback:W.jsx(pni,{graphics:s}),children:W.jsx(rni,{graphics:s})}),a&&W.jsx(uni,{solver:t,onStepUntilPhase:g})]})};const yni=()=>{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)},[])},mni=t=>t.toLowerCase().includes("pack")?Iqt:t.toLowerCase().includes("rout")?hqt:jKt,wni=({solverEvents:t=[]})=>{const[A,e]=V.useState(null);yni();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=WrA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(WrA).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=mni(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(mm,{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(fni,{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"})})})]})},uEe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{V.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{qW.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{qW.captureException(n,{error_type:i.type})}catch{}}},[e])},dEe="0.0.1735",Dni={version:dEe},Jz=k4A()(v4A(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),Sni=t=>{const[A,e]=V.useState([]),[i,n]=V.useState(null),[o,s]=V.useState(""),[r,a]=sG("eval-version-selection",null),g=Jz(B=>B.setLastRunEvalVersion),c=Jz(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("")}}},bni=({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}`})]})]})})},xni=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 _ni(t){const A=kni(t),e=V.forwardRef((i,n)=>{const{children:o,...s}=i,r=V.Children.toArray(o),a=r.find(Fni);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 kni(t){const A=V.forwardRef((e,i)=>{const{children:n,...o}=e;if(V.isValidElement(n)){const s=Rni(n),r=Mni(o,n.props);return n.type!==V.Fragment&&(r.ref=i?xf(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 vni=Symbol("radix.slottable");function Fni(t){return V.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===vni}function Mni(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 Rni(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 Tz="Dialog",[pEe,fEe]=Ew(Tz),[Nni,Tw]=pEe(Tz),yEe=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]=G_({prop:i,defaultProp:n??!1,onChange:o,caller:Tz});return W.jsx(Nni,{scope:A,triggerRef:r,contentRef:a,contentId:qE(),titleId:qE(),descriptionId:qE(),open:g,onOpenChange:c,onOpenToggle:V.useCallback(()=>c(I=>!I),[c]),modal:s,children:e})};yEe.displayName=Tz;var mEe="DialogTrigger",wEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(mEe,e),o=RI(A,n.triggerRef);return W.jsx(eg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":NmA(n.open),...i,ref:o,onClick:Vn(t.onClick,n.onOpenToggle)})});wEe.displayName=mEe;var MmA="DialogPortal",[Gni,DEe]=pEe(MmA,{forceMount:void 0}),SEe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Tw(MmA,A);return W.jsx(Gni,{scope:A,forceMount:e,children:V.Children.map(i,s=>W.jsx(q0,{present:e||o.open,children:W.jsx($9,{asChild:!0,container:n,children:s})}))})};SEe.displayName=MmA;var Pz="DialogOverlay",bEe=V.forwardRef((t,A)=>{const e=DEe(Pz,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Tw(Pz,t.__scopeDialog);return o.modal?W.jsx(q0,{present:i||o.open,children:W.jsx(Uni,{...n,ref:A})}):null});bEe.displayName=Pz;var Lni=_ni("DialogOverlay.RemoveScroll"),Uni=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(Pz,e);return W.jsx(rj,{as:Lni,allowPinchZoom:!0,shards:[n.contentRef],children:W.jsx(eg.div,{"data-state":NmA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),YM="DialogContent",xEe=V.forwardRef((t,A)=>{const e=DEe(YM,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Tw(YM,t.__scopeDialog);return W.jsx(q0,{present:i||o.open,children:o.modal?W.jsx(Hni,{...n,ref:A}):W.jsx(Yni,{...n,ref:A})})});xEe.displayName=YM;var Hni=V.forwardRef((t,A)=>{const e=Tw(YM,t.__scopeDialog),i=V.useRef(null),n=RI(A,e.contentRef,i);return V.useEffect(()=>{const o=i.current;if(o)return VfA(o)},[]),W.jsx(_Ee,{...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())})}),Yni=V.forwardRef((t,A)=>{const e=Tw(YM,t.__scopeDialog),i=V.useRef(!1),n=V.useRef(!1);return W.jsx(_Ee,{...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()}})}),_Ee=V.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Tw(YM,e),a=V.useRef(null),g=RI(A,a);return kfA(),W.jsxs(W.Fragment,{children:[W.jsx(Y9,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:W.jsx(KJ,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":NmA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),W.jsxs(W.Fragment,{children:[W.jsx(Tni,{titleId:r.titleId}),W.jsx(Kni,{contentRef:a,descriptionId:r.descriptionId})]})]})}),RmA="DialogTitle",kEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(RmA,e);return W.jsx(eg.h2,{id:n.titleId,...i,ref:A})});kEe.displayName=RmA;var vEe="DialogDescription",FEe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(vEe,e);return W.jsx(eg.p,{id:n.descriptionId,...i,ref:A})});FEe.displayName=vEe;var MEe="DialogClose",REe=V.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Tw(MEe,e);return W.jsx(eg.button,{type:"button",...i,ref:A,onClick:Vn(t.onClick,()=>n.onOpenChange(!1))})});REe.displayName=MEe;function NmA(t){return t?"open":"closed"}var NEe="DialogTitleWarning",[Jni,GEe]=Uat(NEe,{contentName:YM,titleName:RmA,docsSlug:"dialog"}),Tni=({titleId:t})=>{const A=GEe(NEe),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