@tscircuit/runframe 0.0.1459 → 0.0.1460

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.
@@ -5063,7 +5063,7 @@ ${a.join(`
5063
5063
  ${Q}polygon: ${C.polygon.vertices}
5064
5064
  `:a+=`
5065
5065
  `,C.children.length>0&&I.push(C.children)}return a}};A.exports=s}}),rgt=ne({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,A){var e=igt(),i=sgt(),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}}),AlA=ne({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,A){A.exports={Tree:rgt()}}}),agt=ne({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,A){var e=qo(),i=$BA(),{Tree:n}=AlA(),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 I=a.allPolygons();return e.create(I)};A.exports=o}}),PWA=ne({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,A){var e=Fo(),i=KU(),n=agt(),o=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),ggt=ne({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,A){var e=Fo(),i=qo(),n=px(),o=zBA(),s=XBA(),r=PWA(),a=(...g)=>{g=e(g);const I=g.map(l=>s({z0:-1,z1:1},l)),c=r(I),B=n(c);return o(B,i.toPolygons(c))};A.exports=a}}),Igt=ne({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,A){var e=Fo(),i=TU(),n=Ko(),o=qo(),s=ggt(),r=PWA(),a=(...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only intersect of the types are supported");const I=g[0];return n.isA(I)?s(g):o.isA(I)?r(g):I};A.exports=a}}),cgt=ne({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,A){var e=dn(),i=px(),n=qo(),o=g=>g.sort((I,c)=>I-c).filter((I,c,B)=>!c||I!==B[c-1]),s=(g,I,c)=>{const B=`${I}`,l=g.get(B);l===void 0?g.set(B,[c]):l.push(c)},r=(g,I)=>{const c=`${I}`;return g.get(c)},a=g=>{const I=i(g),c=n.toPolygons(g),B=c.length,l=new Map,C=e.create();c.forEach((d,f)=>{d.vertices.forEach(w=>{s(l,e.snap(C,w,I),f)})});const Q=c.map(d=>{let f=[];return d.vertices.forEach(w=>{f=f.concat(r(l,e.snap(C,w,I)))}),{e:1,d:o(f)}});l.clear();let E=0;const h=Q.length;for(let d=0;d<h;d++){const f=Q[d];if(f.e>0){const w=new Array(B);w[d]=!0;do E=0,w.forEach((S,D)=>{const x=Q[D];if(x.e>0){x.e=-1;for(let F=0;F<x.d.length;F++)w[x.d[F]]=!0;E++}});while(E>0);f.indexes=w}}const u=[];for(let d=0;d<h;d++)if(Q[d].indexes){const f=[];Q[d].indexes.forEach((w,S)=>f.push(c[S])),u.push(n.create(f))}return u};A.exports=a}}),Bgt=ne({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,A){var e=Fo(),i=qo(),n=cgt(),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}}),lgt=ne({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,A){var e=qo(),i=$BA(),{Tree:n}=AlA(),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 I=a.allPolygons();return e.create(I)};A.exports=o}}),OWA=ne({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,A){var e=Fo(),i=KU(),n=lgt(),o=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),Cgt=ne({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,A){var e=Fo(),i=qo(),n=px(),o=zBA(),s=XBA(),r=OWA(),a=(...g)=>{g=e(g);const I=g.map(l=>s({z0:-1,z1:1},l)),c=r(I),B=n(c);return o(B,i.toPolygons(c))};A.exports=a}}),Qgt=ne({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,A){var e=Fo(),i=TU(),n=Ko(),o=qo(),s=Cgt(),r=OWA(),a=(...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only subtract of the types are supported");const I=g[0];return n.isA(I)?s(g):o.isA(I)?r(g):I};A.exports=a}}),WWA=ne({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,A){var e=qo(),i=$BA(),{Tree:n}=AlA(),o=(r,a)=>{if(!i(r,a))return s(r,a);const g=new n(e.toPolygons(r)),I=new n(e.toPolygons(a));g.clipTo(I,!1),I.clipTo(g),I.invert(),I.clipTo(g),I.invert();const c=g.allPolygons().concat(I.allPolygons());return e.create(c)},s=(r,a)=>{let g=e.toPolygons(r);return g=g.concat(e.toPolygons(a)),e.create(g)};A.exports=o}}),ZWA=ne({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,A){var e=Fo(),i=KU(),n=WWA(),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}}),VWA=ne({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,A){var e=Fo(),i=qo(),n=px(),o=zBA(),s=XBA(),r=ZWA(),a=(...g)=>{g=e(g);const I=g.map(l=>s({z0:-1,z1:1},l)),c=r(I),B=n(c);return o(B,i.toPolygons(c))};A.exports=a}}),elA=ne({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,A){var e=Fo(),i=TU(),n=Ko(),o=qo(),s=VWA(),r=ZWA(),a=(...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only unions of the same type are supported");const I=g[0];return n.isA(I)?s(g):o.isA(I)?r(g):I};A.exports=a}}),LM=ne({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,A){A.exports={intersect:Igt(),scission:Bgt(),subtract:Qgt(),union:elA()}}}),XO=ne({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,A){var{EPS:e,TAU:i}=Br(),n=wWA(),o=PBA(),s=ls(),r=VO(),a=(g,I)=>{const c={delta:1,corners:"edge",closed:!1,segments:16};let{delta:B,corners:l,closed:C,segments:Q}=Object.assign({},c,g);if(Math.abs(B)<e)return I;let E=g.closed?r(I):1;E===0&&(E=1);const h=E>0&&B>=0||E<0&&B<0;B=Math.abs(B);let u=null,d=[];const f=[],w=s.create(),S=I.length;for(let D=0;D<S;D++){const x=(D+1)%S,F=I[D],k=I[x];h?s.subtract(w,F,k):s.subtract(w,k,F),s.normal(w,w),s.normalize(w,w),s.scale(w,w,B);const v=s.add(s.create(),F,w),M=s.add(s.create(),k,w),L=[v,M];if(u!=null&&(C||!C&&x!==0)){const K=n(u[0],u[1],L[0],L[1]);K?(d.pop(),L[0]=K):f.push({c:F,s0:u,s1:L})}u=[v,M],!(x===0&&!C)&&(d.push(L[0]),d.push(L[1]))}if(C&&u!=null){const D=d[0],x=d[1],F=n(u[0],u[1],D,x);if(F)d[0]=F,d.pop();else{const k=I[0],v=[D,x];f.push({c:k,s0:u,s1:v})}}if(l==="edge"){const D=new Map;d.forEach((k,v)=>D.set(k,v));const x=o.create(),F=o.create();f.forEach(k=>{o.fromPoints(x,k.s0[0],k.s0[1]),o.fromPoints(F,k.s1[0],k.s1[1]);const v=o.intersectPointOfLines(x,F);if(Number.isFinite(v[0])&&Number.isFinite(v[1])){const M=k.s0[1],L=D.get(M);d[L]=v,d[(L+1)%d.length]=void 0}else{const M=k.s1[0],L=D.get(M);d[L]=void 0}}),d=d.filter(k=>k!==void 0)}if(l==="round"){let D=Math.floor(Q/4);const x=s.create();f.forEach(F=>{let k=s.angle(s.subtract(x,F.s1[0],F.c));if(k-=s.angle(s.subtract(x,F.s0[1],F.c)),h&&k<0&&(k=k+Math.PI,k<0&&(k=k+Math.PI)),!h&&k>0&&(k=k-Math.PI,k>0&&(k=k-Math.PI)),k!==0){D=Math.floor(Q*(Math.abs(k)/i));const v=k/D,M=s.angle(s.subtract(x,F.s0[1],F.c)),L=[];for(let K=1;K<D;K++){const Y=M+v*K,W=s.fromAngleRadians(s.create(),Y);s.scale(W,W,B),s.add(W,W,F.c),L.push(W)}if(L.length>0){const K=F.s0[1];let Y=d.findIndex(W=>s.equals(K,W));Y=(Y+1)%d.length,d.splice(Y,0,...L)}}else{const v=F.s1[0],M=d.findIndex(L=>s.equals(v,L));d.splice(M,1)}})}return d};A.exports=a}}),Egt=ne({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,A){var e=Ko(),i=XO(),n=(o,s)=>{const r={delta:1,corners:"edge",segments:16},{delta:a,corners:g,segments:I}=Object.assign({},r,o);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const l=e.toOutlines(s).map(C=>(o={delta:a,corners:g,closed:!0,segments:I},i(o,C))).reduce((C,Q)=>C.concat(e.toSides(e.fromPoints(Q))),[]);return e.create(l)};A.exports=n}}),hgt=ne({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,A){var e=Hg(),i=dn(),n=qo(),o=Xs(),s=(r,a)=>{i.dot(o.plane(a),r)>0&&(a=o.invert(a));const I=[a],c=o.transform(e.fromTranslation(e.create(),r),a),B=a.vertices.length;for(let l=0;l<B;l++){const C=l<B-1?l+1:0,Q=o.create([a.vertices[l],c.vertices[l],c.vertices[C],a.vertices[C]]);I.push(Q)}return I.push(o.invert(c)),n.create(I)};A.exports=s}}),ugt=ne({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,A){var{EPS:e,TAU:i}=Br(),n=Hg(),o=dn(),s=KWA(),r=qo(),a=Xs(),g=vWA(),I=KU(),c=WWA(),B=hgt(),l=(h,u,d)=>{const f=u.toString();if(h.has(f))h.get(f)[1].push(d);else{const w=[u,[d]];h.set(f,w)}},C=(h,u,d)=>{const f=u[0].toString(),w=u[1].toString(),S=f<w?`${f},${w}`:`${w},${f}`;if(h.has(S))h.get(S)[1].push(d);else{const D=[u,[d]];h.set(S,D)}},Q=(h,u)=>{h.findIndex(f=>f===u)<0&&h.push(u)},E=(h,u)=>{const d={delta:1,segments:12},{delta:f,segments:w}=Object.assign({},d,h);let S=r.create();const D=new Map,x=new Map,F=o.create(),k=o.create();return r.toPolygons(u).forEach((M,L)=>{const K=o.scale(o.create(),a.plane(M),2*f),Y=a.transform(n.fromTranslation(n.create(),o.scale(o.create(),K,-.5)),M),W=B(K,Y);S=c(S,W);const Z=M.vertices;for(let AA=0;AA<Z.length;AA++){l(D,Z[AA],a.plane(M));const nA=(AA+1)%Z.length,cA=[Z[AA],Z[nA]];C(x,cA,a.plane(M))}}),x.forEach(M=>{const L=M[0],K=M[1],Y=L[0],W=L[1],Z=o.subtract(o.create(),W,Y);o.normalize(Z,Z);const AA=K[0],nA=o.cross(o.create(),AA,Z);let cA=[];for(let JA=0;JA<w;JA++)Q(cA,JA*i/w);for(let JA=0,gA=K.length;JA<gA;JA++){const yA=K[JA],EA=o.dot(nA,yA),KA=o.dot(AA,yA);let ee=Math.atan2(EA,KA);ee<0&&(ee+=i),Q(cA,ee),ee=Math.atan2(-EA,-KA),ee<0&&(ee+=i),Q(cA,ee)}cA=cA.sort(s);const tA=cA.length;let oA,rA;const CA=[],dA=[],bA=[];for(let JA=-1;JA<tA;JA++){const gA=cA[JA<0?JA+tA:JA],yA=Math.sin(gA),EA=Math.cos(gA);o.scale(F,AA,EA*f),o.scale(k,nA,yA*f),o.add(F,F,k);const KA=o.add(o.create(),Y,F),ee=o.add(o.create(),W,F);let ce=!1;if(JA>=0&&o.distance(KA,oA)<e&&(ce=!0),!ce){if(JA>=0){CA.push(KA),dA.push(ee);const mA=[rA,ee,KA,oA],PA=a.create(mA);bA.push(PA)}oA=KA,rA=ee}}dA.reverse(),bA.push(a.create(CA)),bA.push(a.create(dA));const kA=r.create(bA);S=c(S,kA)}),D.forEach(M=>{const L=M[0],K=M[1],Y=K[0];let W=null,Z=0;for(let tA=1;tA<K.length;tA++){const oA=K[tA],rA=o.cross(F,Y,oA),CA=o.length(rA);CA>.05&&CA>Z&&(Z=CA,W=oA)}W||(W=o.orthogonal(F,Y));const AA=o.cross(F,Y,W);o.normalize(AA,AA);const nA=o.cross(k,AA,Y),cA=g({center:[L[0],L[1],L[2]],radius:f,segments:w,axes:[Y,AA,nA]});S=c(S,cA)}),I(S)};A.exports=E}}),dgt=ne({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,A){var e=qo(),i=elA(),n=ugt(),o=(s,r)=>{const a={delta:1,corners:"round",segments:12},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(I!=="round")throw new Error('corners must be "round" for 3D geometries');if(e.toPolygons(r).length===0)throw new Error("the given geometry cannot be empty");s={delta:g,corners:I,segments:c};const l=n(s,r);return i(r,l)};A.exports=o}}),pgt=ne({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,A){var e=VO(),i=ls(),n=Ko(),o=dg(),s=XO(),r=I=>{let{external:c,internal:B}=I;e(c)<0?c=c.reverse():B=B.reverse();const l=o.fromPoints({closed:!0},c),C=o.fromPoints({closed:!0},B),Q=n.toSides(n.fromPoints(o.toPoints(l))),E=n.toSides(n.fromPoints(o.toPoints(C)));return Q.push(...E),n.create(Q)},a=(I,c,B,l)=>{const{points:C,external:Q,internal:E}=I,h=Math.floor(c/2),u=[],d=[];if(B==="round"&&h>0){const w=Math.PI/h,S=C[C.length-1],D=i.angle(i.subtract(i.create(),Q[Q.length-1],S)),x=C[0],F=i.angle(i.subtract(i.create(),E[0],x));for(let k=1;k<h;k++){let v=D+w*k,M=i.fromAngleRadians(i.create(),v);i.scale(M,M,l),i.add(M,M,S),u.push(M),v=F+w*k,M=i.fromAngleRadians(i.create(),v),i.scale(M,M,l),i.add(M,M,x),d.push(M)}}const f=[];return f.push(...Q,...u,...E.reverse(),...d),n.fromPoints(f)},g=(I,c)=>{I=Object.assign({},{delta:1,corners:"edge",segments:16},I);const{delta:l,corners:C,segments:Q}=I;if(l<=0)throw new Error("the given delta must be positive for paths");if(!(C==="edge"||C==="chamfer"||C==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const E=c.isClosed,h=o.toPoints(c);if(h.length===0)throw new Error("the given geometry cannot be empty");const u={points:h,external:s({delta:l,corners:C,segments:Q,closed:E},h),internal:s({delta:-l,corners:C,segments:Q,closed:E},h)};return c.isClosed?r(u):a(u,Q,C,l)};A.exports=g}}),tlA=ne({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,A){var e=Fo(),i=Ko(),n=qo(),o=dg(),s=Egt(),r=dgt(),a=pgt(),g=(I,...c)=>{if(c=e(c),c.length===0)throw new Error("wrong number of arguments");const B=c.map(l=>o.isA(l)?a(I,l):i.isA(l)?s(I,l):n.isA(l)?r(I,l):l);return B.length===1?B[0]:B};A.exports=g}}),fgt=ne({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,A){var e=Ko(),i=YBA(),n=XO(),o=(s,r)=>{const a={delta:1,corners:"edge",segments:0},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(!(I==="edge"||I==="chamfer"||I==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const B=e.toOutlines(r),C=B.map(Q=>(s={delta:B.reduce((u,d)=>u+i.arePointsInside(Q,i.create(d)),0)%2===0?g:-g,corners:I,closed:!0,segments:c},n(s,Q))).reduce((Q,E)=>Q.concat(e.toSides(e.fromPoints(E))),[]);return e.create(C)};A.exports=o}}),ygt=ne({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,A){var e=dg(),i=XO(),n=(o,s)=>{const r={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:a,corners:g,closed:I,segments:c}=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:I,segments:c};const B=i(o,e.toPoints(s));return e.fromPoints({closed:I},B)};A.exports=n}}),mgt=ne({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,A){var e=Fo(),i=Ko(),n=dg(),o=fgt(),s=ygt(),r=(a,...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");const I=g.map(c=>n.isA(c)?s(a,c):i.isA(c)?o(a,c):c);return I.length===1?I[0]:I};A.exports=r}}),ilA=ne({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,A){A.exports={expand:tlA(),offset:mgt()}}}),$O=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,A){var e=Hg(),i=dn(),n=Ko(),o=UM(),s=zO(),r=(a,g)=>{const I={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:c,twistAngle:B,twistSteps:l,repair:C}=Object.assign({},I,a);if(l<1)throw new Error("twistSteps must be 1 or more");B===0&&(l=1);const Q=i.clone(c),E=n.toSides(g);if(E.length===0)throw new Error("the given geometry cannot be empty");const h=o.fromSides(E);Q[2]<0&&o.reverse(h,h);const u=e.create(),d=(f,w,S)=>{const D=w/l*B,x=i.scale(i.create(),Q,w/l);return e.multiply(u,e.fromZRotation(u,D),e.fromTranslation(e.create(),x)),o.transform(u,S)};return a={numberOfSlices:l+1,capStart:!0,capEnd:!0,repair:C,callback:d},s(a,h)};A.exports=r}}),wgt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,A){var e=Ko(),i=dg(),n=$O(),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}}),Dgt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,A){var e=Fo(),i=Ko(),n=dg(),o=$O(),s=wgt(),r=(a,...g)=>{const I={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:c,twistAngle:B,twistSteps:l,repair:C}=Object.assign({},I,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");a={offset:[0,0,c],twistAngle:B,twistSteps:l,repair:C};const Q=g.map(E=>n.isA(E)?s(a,E):i.isA(E)?o(a,E):E);return Q.length===1?Q[0]:Q};A.exports=r}}),Sgt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,A){var e=dg(),i=tlA(),n=$O(),o=(s,r)=>{const a={size:1,height:1},{size:g,height:I}=Object.assign({},a,s);if(s.delta=g,s.offset=[0,0,I],e.toPoints(r).length===0)throw new Error("the given geometry cannot be empty");const B=i(s,r);return n(s,B)};A.exports=o}}),bgt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,A){var{area:e}=LU(),i=Ko(),n=dg(),o=tlA(),s=$O(),r=(a,g)=>{const I={size:1,height:1},{size:c,height:B}=Object.assign({},I,a);a.delta=c,a.offset=[0,0,B];const l=i.toOutlines(g);if(l.length===0)throw new Error("the given geometry cannot be empty");const Q=l.map(h=>(e(h)<0&&h.reverse(),o(a,n.fromPoints({closed:!0},h)))).reduce((h,u)=>h.concat(i.toSides(u)),[]),E=i.create(Q);return s(a,E)};A.exports=r}}),xgt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,A){var e=Fo(),i=Ko(),n=dg(),o=Sgt(),s=bgt(),r=(a,...g)=>{const I={size:1,height:1},{size:c,height:B}=Object.assign({},I,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(c<=0)throw new Error("size must be positive");if(B<=0)throw new Error("height must be positive");const l=g.map(C=>n.isA(C)?o(a,C):i.isA(C)?s(a,C):C);return l.length===1?l[0]:l};A.exports=r}}),kgt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,A){var{TAU:e}=Br(),i=Hg(),n=Ko(),o=zO(),s=UM(),r=(a,g)=>{const I={angle:e,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:c,startAngle:B,pitch:l,height:C,endOffset:Q,segmentsPerRotation:E}=Object.assign({},I,a);if(C!=0&&(l=C/(c/e)),E<3)throw new Error("The number of segments per rotation needs to be at least 3.");const u=n.toSides(g);if(u.length===0)throw new Error("The given geometry cannot be empty");const d=u.filter(k=>k[0][0]>=0);let f=s.fromSides(u);d.length===0&&(f=s.reverse(f));const w=Math.round(E/e*Math.abs(c)),S=w>=2?w:2,D=i.create(),x=i.create(),F=(k,v,M)=>{const L=B+c/S*v,K=Q/S*v,Y=(L-B)/e*l;return i.multiply(D,i.fromTranslation(i.create(),[K,0,Y*Math.sign(c)]),i.fromXRotation(i.create(),-e/4*Math.sign(c))),i.multiply(x,i.fromZRotation(i.create(),L),D),s.transform(x,M)};return o({numberOfSlices:S+1,callback:F},f)};A.exports=r}}),Ggt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,A){var e=Fo(),i=qBA(),n=xw(),o=Hg(),s=Ko(),r=qo(),a=Xs(),g=px(),I=VWA(),c=(l,C)=>{const Q=n.fromNormalAndPoint(n.create(),l.axis,l.origin);if(Number.isNaN(Q[0])||Number.isNaN(Q[1])||Number.isNaN(Q[2])||Number.isNaN(Q[3]))throw new Error("project: invalid axis or origin");const E=g(C),h=E*E*Math.sqrt(3)/4;if(E===0)return s.create();const u=r.toPolygons(C);let d=[];for(let w=0;w<u.length;w++){const S=u[w].vertices.map(F=>n.projectionOfPoint(Q,F)),D=a.create(S),x=a.plane(D);i(Q,x)&&(a.measureArea(D)<h||d.push(D))}if(!i(Q,[0,0,1])){const w=o.fromVectorRotation(o.create(),Q,[0,0,1]);d=d.map(S=>a.transform(w,S))}d=d.sort((w,S)=>a.measureArea(S)-a.measureArea(w));const f=d.map(w=>s.fromPoints(w.vertices));return I(f)},B=(l,...C)=>{const Q={axis:[0,0,1],origin:[0,0,0]},{axis:E,origin:h}=Object.assign({},Q,l);if(C=e(C),C.length===0)throw new Error("wrong number of arguments");l={axis:E,origin:h};const u=C.map(d=>r.isA(d)?c(l,d):d);return u.length===1?u[0]:u};A.exports=B}}),qU=ne({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,A){A.exports={extrudeFromSlices:zO(),extrudeLinear:Dgt(),extrudeRectangular:xgt(),extrudeRotate:YWA(),extrudeHelical:kgt(),project:Ggt(),slice:UM()}}}),nlA=ne({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,A){var e=ls(),i=s=>{let r=e.fromValues(1/0,1/0);s.forEach(I=>{(I[1]<r[1]||I[1]===r[1]&&I[0]<r[0])&&(r=I)});const a=[];s.forEach(I=>{const c=o(I[1]-r[1],I[0]-r[0]),B=e.squaredDistance(I,r);a.push({point:I,angle:c,distSq:B})}),a.sort((I,c)=>I.angle!==c.angle?I.angle-c.angle:I.distSq-c.distSq);const g=[];return a.forEach(I=>{let c=g.length;for(;c>1&&n(g[c-2],g[c-1],I.point)<=Number.EPSILON;)g.pop(),c=g.length;g.push(I.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}}),olA=ne({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,A){var e=Ko(),i=qo(),n=dg(),o=s=>{const r=new Set,a=[],g=I=>{const c=I.toString();r.has(c)||(a.push(I),r.add(c))};return s.forEach(I=>{e.isA(I)?e.toPoints(I).forEach(g):i.isA(I)?i.toPoints(I).forEach(c=>c.forEach(g)):n.isA(I)&&n.toPoints(I).forEach(g)}),a};A.exports=o}}),Fgt=ne({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,A){var e=Fo(),i=dg(),n=nlA(),o=olA(),s=(...r)=>{r=e(r);const a=o(r),g=n(a);return i.fromPoints({closed:!0},g)};A.exports=s}}),Rgt=ne({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,A){var e=Fo(),i=Ko(),n=nlA(),o=olA(),s=(...r)=>{r=e(r);const a=o(r),g=n(a);return g.length<3?i.create():i.fromPoints(g)};A.exports=s}}),jWA=ne({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,A){var e=Xs(),i=V8A(),n=o=>i(o,{skipTriangulation:!0}).map(a=>{const g=a.map(I=>o[I]);return e.create(g)});A.exports=n}}),Ngt=ne({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,A){var e=Fo(),i=qo(),n=olA(),o=jWA(),s=(...r)=>{r=e(r);const a=n(r);return a.length===0?i.create():i.create(o(a))};A.exports=s}}),zWA=ne({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,A){var e=Fo(),i=TU(),n=Ko(),o=qo(),s=dg(),r=Fgt(),a=Rgt(),g=Ngt(),I=(...c)=>{if(c=e(c),c.length===0)throw new Error("wrong number of arguments");if(!i(c))throw new Error("only hulls of the same type are supported");const B=c[0];return s.isA(B)?r(c):n.isA(B)?a(c):o.isA(B)?g(c):B};A.exports=I}}),Mgt=ne({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,A){var e=Fo(),i=elA(),n=zWA(),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}}),_gt=ne({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,A){A.exports={hull:zWA(),hullChain:Mgt(),hullPoints2:nlA(),hullPoints3:jWA()}}}),XWA=ne({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,A){var e=dn(),i=Xs(),n=(s,r)=>{const a=Math.abs(i.measureArea(r));return Number.isFinite(a)&&a>s},o=(s,r)=>{let a=r.map(I=>{const c=I.vertices.map(C=>e.snap(e.create(),C,s)),B=[];for(let C=0;C<c.length;C++){const Q=(C+1)%c.length;e.equals(c[C],c[Q])||B.push(c[C])}const l=i.create(B);return I.color&&(l.color=I.color),l});const g=s*s*Math.sqrt(3)/4;return a=a.filter(I=>n(g,I)),a};A.exports=o}}),vgt=ne({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,A){var e=qBA(),i=dn(),n=Xs(),o=h=>{const u=n.toPoints(h),d=[];for(let f=0;f<u.length;f++){const w=(f+1)%u.length,S={v1:u[f],v2:u[w]};d.push(S)}for(let f=0;f<d.length;f++){const w=(f+1)%u.length;d[f].next=d[w],d[w].prev=d[f]}return d},s=(h,u)=>{const d=`${u.v1}:${u.v2}`;h.set(d,u)},r=(h,u)=>{const d=`${u.v1}:${u.v2}`;h.delete(d)},a=(h,u)=>{const d=`${u.v2}:${u.v1}`;return h.get(d)},g=(h,u,d)=>{let f=h.prev.v1,w=h.prev.v2,S=u.next.v2;const D=B(f,w,S,d);f=u.prev.v1,w=u.prev.v2,S=h.next.v2;const x=B(f,w,S,d);return[D,x]},I=i.create(),c=i.create(),B=(h,u,d,f)=>{const w=i.subtract(I,u,h),S=i.subtract(c,d,u);return i.cross(w,w,S),i.dot(w,f)},l=h=>{let u;const d=[];for(;h.next;){const f=h.next;d.push(h.v1),h.v1=null,h.v2=null,h.next=null,h.prev=null,h=f}return d.length>0&&(u=n.create(d)),u},C=h=>{if(h.length<2)return h;const u=h[0].plane,d=h.slice(),f=new Map;for(;d.length>0;){const S=d.shift(),D=o(S);for(let x=0;x<D.length;x++){const F=D[x],k=a(f,F);if(k){const v=g(F,k,u);if(v[0]>=0&&v[1]>=0){const M=k.next,L=F.next;F.prev.next=k.next,F.next.prev=k.prev,k.prev.next=F.next,k.next.prev=F.prev,F.v1=null,F.v2=null,F.next=null,F.prev=null,r(f,k),k.v1=null,k.v2=null,k.next=null,k.prev=null;const K=(Y,W,Z)=>{const AA={v1:Z.v1,v2:W.v2,next:W.next,prev:Z.prev};Z.prev.next=AA,W.next.prev=AA,r(Y,W),W.v1=null,W.v2=null,W.next=null,W.prev=null,r(Y,Z),Z.v1=null,Z.v2=null,Z.next=null,Z.prev=null};v[0]===0&&K(f,M,M.prev),v[1]===0&&K(f,L,L.prev)}}else F.next&&s(f,F)}}const w=[];return f.forEach(S=>{const D=l(S);D&&w.push(D)}),f.clear(),w},Q=(h,u)=>Math.abs(h[3]-u[3])<15e-8?e(h,u):!1,E=(h,u)=>{const d=[];u.forEach(w=>{const S=d.find(D=>Q(D[0],n.plane(w)));S?S[1].push(w):d.push([n.plane(w),[w]])});let f=[];return d.forEach(w=>{const S=w[1],D=C(S);f=f.concat(D)}),f};A.exports=E}}),Ugt=ne({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,A){var e=Br(),i=dn(),n=Xs(),o=g=>`${g}`,s=(g,I,c,B,l,C)=>{const Q=o(B),E=o(l),h=`${Q}/${E}`,u=`${E}/${Q}`;if(g.has(u))return r(g,I,c,l,B,null),null;const d={vertex0:B,vertex1:l,polygonindex:C};return g.has(h)?g.get(h).push(d):g.set(h,[d]),I.has(Q)?I.get(Q).push(h):I.set(Q,[h]),c.has(E)?c.get(E).push(h):c.set(E,[h]),h},r=(g,I,c,B,l,C)=>{const Q=o(B),E=o(l),h=`${Q}/${E}`;let u=-1;const d=g.get(h);for(let f=0;f<d.length;f++){const w=d[f];let S=o(w.vertex0);if(S===Q&&(S=o(w.vertex1),S===E&&!(C!==null&&w.polygonindex!==C))){u=f;break}}d.splice(u,1),d.length===0&&g.delete(h),u=I.get(Q).indexOf(h),I.get(Q).splice(u,1),I.get(Q).length===0&&I.delete(Q),u=c.get(E).indexOf(h),c.get(E).splice(u,1),c.get(E).length===0&&c.delete(E)},a=g=>{const I=new Map;for(let c=0;c<g.length;c++){const B=g[c],l=B.vertices.length;if(l>=3){let C=B.vertices[0],Q=o(C);for(let E=0;E<l;E++){let h=E+1;h===l&&(h=0);const u=B.vertices[h],d=o(u),f=`${Q}/${d}`,w=`${d}/${Q}`;if(I.has(w)){const S=I.get(w);S.splice(-1,1),S.length===0&&I.delete(w)}else{const S={vertex0:C,vertex1:u,polygonindex:c};I.has(f)?I.get(f).push(S):I.set(f,[S])}C=u,Q=d}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(I.size>0){const c=new Map,B=new Map,l=new Map;for(const[Q,E]of I)l.set(Q,!0),E.forEach(h=>{const u=o(h.vertex0),d=o(h.vertex1);c.has(u)?c.get(u).push(Q):c.set(u,[Q]),B.has(d)?B.get(d).push(Q):B.set(d,[Q])});const C=g.slice(0);for(;I.size!==0;){for(const E of I.keys())l.set(E,!0);let Q=!1;for(;;){const E=Array.from(l.keys());if(E.length===0)break;const h=E[0];let u=!0;if(I.has(h)){const f=I.get(h)[0];for(let w=0;w<2;w++){const S=w===0?f.vertex0:f.vertex1,D=w===0?f.vertex1:f.vertex0,x=o(S),F=o(D);let k=[];w===0?B.has(x)&&(k=B.get(x)):c.has(x)&&(k=c.get(x));for(let v=0;v<k.length;v++){const M=k[v],L=I.get(M)[0],K=w===0?L.vertex0:L.vertex1;if(w===0?L.vertex1:L.vertex0,o(K)===F){r(I,c,B,S,D,null),r(I,c,B,D,S,null),u=!1,w=2,Q=!0;break}else{const W=S,Z=D,AA=K,nA=i.subtract(i.create(),AA,W),cA=i.dot(i.subtract(i.create(),Z,W),nA)/i.dot(nA,nA);if(cA>0&&cA<1){const tA=i.scale(i.create(),nA,cA);if(i.add(tA,tA,W),i.squaredDistance(tA,Z)<e.EPS*e.EPS){const rA=L.polygonindex,CA=C[rA],dA=o(L.vertex1);let bA=-1;for(let EA=0;EA<CA.vertices.length;EA++)if(o(CA.vertices[EA])===dA){bA=EA;break}const kA=CA.vertices.slice(0);kA.splice(bA,0,D);const JA=n.create(kA);C[rA]=JA,r(I,c,B,L.vertex0,L.vertex1,rA);const gA=s(I,c,B,L.vertex0,D,rA),yA=s(I,c,B,D,L.vertex1,rA);gA!==null&&l.set(gA,!0),yA!==null&&l.set(yA,!0),u=!1,w=2,Q=!0;break}}}}}}u&&l.delete(h)}if(!Q)break}g=C}return I.clear(),g};A.exports=a}}),Lgt=ne({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,A){var e=dn(),i=Xs(),n=(s,r,a)=>{const g=r.vertices.length;if(g>3){if(g>4){const B=[0,0,0];r.vertices.forEach(l=>e.add(B,B,l)),e.snap(B,e.divide(B,B,[g,g,g]),s);for(let l=0;l<g;l++){const C=i.create([B,r.vertices[l],r.vertices[(l+1)%g]]);r.color&&(C.color=r.color),a.push(C)}return}const I=i.create([r.vertices[0],r.vertices[1],r.vertices[2]]),c=i.create([r.vertices[0],r.vertices[2],r.vertices[3]]);r.color&&(I.color=r.color,c.color=r.color),a.push(I,c);return}a.push(r)},o=(s,r)=>{const a=[];return r.forEach(g=>{n(s,g,a)}),a};A.exports=o}}),Hgt=ne({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,A){var e=Fo(),i=px(),n=Ko(),o=qo(),s=dg(),r=XWA(),a=vgt(),g=Ugt(),I=Lgt(),c=(Q,E)=>E,B=(Q,E)=>E,l=(Q,E)=>{const h={snap:!1,simplify:!1,triangulate:!1},{snap:u,simplify:d,triangulate:f}=Object.assign({},h,Q),w=i(E);let S=o.toPolygons(E);u&&(S=r(w,S)),d&&(S=a(w,S)),f&&(S=g(S),S=I(w,S));const D=Object.assign({},E);return D.polygons=S,D},C=(Q,...E)=>{if(E=e(E),E.length===0)throw new Error("wrong number of arguments");const h=E.map(u=>{if(s.isA(u))return c(Q,u);if(n.isA(u))return B(Q,u);if(o.isA(u))return l(Q,u);throw new Error("invalid geometry")});return h.length===1?h[0]:h};A.exports=C}}),Ygt=ne({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,A){var e=Fo(),i=ls(),n=Ko(),o=qo(),s=dg(),r=px(),a=XWA(),g=l=>{const C=r(l),E=s.toPoints(l).map(h=>i.snap(i.create(),h,C));return s.create(E)},I=l=>{const C=r(l);let E=n.toSides(l).map(h=>[i.snap(i.create(),h[0],C),i.snap(i.create(),h[1],C)]);return E=E.filter(h=>!i.equals(h[0],h[1])),n.create(E)},c=l=>{const C=r(l),Q=o.toPolygons(l),E=a(C,Q);return o.create(E)},B=(...l)=>{if(l=e(l),l.length===0)throw new Error("wrong number of arguments");const C=l.map(Q=>s.isA(Q)?g(Q):n.isA(Q)?I(Q):o.isA(Q)?c(Q):Q);return C.length===1?C[0]:C};A.exports=B}}),Jgt=ne({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,A){A.exports={generalize:Hgt(),snap:Ygt(),retessellate:KU()}}}),Tgt=ne({"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}}),Kgt=ne({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,A){var e=Fo(),i=Tgt(),n=OBA(),{translate:o}=WG(),s=I=>{if(!Array.isArray(I.modes)||I.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(I.modes=i(I.modes,"none",3),I.modes.filter(c=>["center","max","min","none"].includes(c)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(I.relativeTo)||I.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(I.relativeTo=i(I.relativeTo,0,3),I.relativeTo.filter(c=>Number.isFinite(c)||c==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof I.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return I},r=(I,c,B)=>{for(let l=0;l<3;l++)I[l]==null&&(c[l]==="center"?I[l]=(B[0][l]+B[1][l])/2:c[l]==="max"?I[l]=B[1][l]:c[l]==="min"&&(I[l]=B[0][l]));return I},a=(I,c,B)=>{const l=n(I),C=[0,0,0];for(let Q=0;Q<3;Q++)c[Q]==="center"?C[Q]=B[Q]-(l[0][Q]+l[1][Q])/2:c[Q]==="max"?C[Q]=B[Q]-l[1][Q]:c[Q]==="min"&&(C[Q]=B[Q]-l[0][Q]);return o(C,I)},g=(I,...c)=>{I=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},I),I=s(I);let{modes:l,relativeTo:C,grouped:Q}=I;if(c=e(c),c.length===0)throw new Error("align(): No geometries were provided to act upon");if(C.filter(E=>E==null).length){const E=n(c);C=r(C,l,E)}return Q?c=a(c,l,C):c=c.map(E=>a(E,l,C)),c.length===1?c[0]:c};A.exports=g}}),A5=ne({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,A){var e=Fo(),i=Ko(),n=qo(),o=dg(),s=PG(),{translate:r}=WG(),a=(l,C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,l),u=s(C),d=[0,0,0];return E[0]&&(d[0]=h[0]-(u[0][0]+(u[1][0]-u[0][0])/2)),E[1]&&(d[1]=h[1]-(u[0][1]+(u[1][1]-u[0][1])/2)),E[2]&&(d[2]=h[2]-(u[0][2]+(u[1][2]-u[0][2])/2)),r(d,C)},g=(l,...C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,l);if(C=e(C),C.length===0)throw new Error("wrong number of arguments");if(h.length!==3)throw new Error("relativeTo must be an array of length 3");l={axes:E,relativeTo:h};const u=C.map(d=>o.isA(d)||i.isA(d)||n.isA(d)?a(l,d):d);return u.length===1?u[0]:u},I=(...l)=>g({axes:[!0,!1,!1]},l),c=(...l)=>g({axes:[!1,!0,!1]},l),B=(...l)=>g({axes:[!1,!1,!0]},l);A.exports={center:g,centerX:I,centerY:c,centerZ:B}}}),e5=ne({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,A){var e=Fo(),i=Hg(),n=Ko(),o=qo(),s=dg(),r=(c,...B)=>{if(!Array.isArray(c))throw new Error("factors must be an array");if(B=e(B),B.length===0)throw new Error("wrong number of arguments");for(c=c.slice();c.length<3;)c.push(1);if(c[0]<=0||c[1]<=0||c[2]<=0)throw new Error("factors must be positive");const l=i.fromScaling(i.create(),c),C=B.map(Q=>s.isA(Q)?s.transform(l,Q):n.isA(Q)?n.transform(l,Q):o.isA(Q)?o.transform(l,Q):Q);return C.length===1?C[0]:C},a=(c,...B)=>r([c,1,1],B),g=(c,...B)=>r([1,c,1],B),I=(c,...B)=>r([1,1,c],B);A.exports={scale:r,scaleX:a,scaleY:g,scaleZ:I}}}),qgt=ne({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,A){var e=Fo(),i=Ko(),n=qo(),o=dg(),s=(r,...a)=>{if(a=e(a),a.length===0)throw new Error("wrong number of arguments");const g=a.map(I=>o.isA(I)?o.transform(r,I):i.isA(I)?i.transform(r,I):n.isA(I)?n.transform(r,I):I);return g.length===1?g[0]:g};A.exports=s}}),ZG=ne({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,A){A.exports={align:Kgt(),center:A5().center,centerX:A5().centerX,centerY:A5().centerY,centerZ:A5().centerZ,mirror:YU().mirror,mirrorX:YU().mirrorX,mirrorY:YU().mirrorY,mirrorZ:YU().mirrorZ,rotate:JU().rotate,rotateX:JU().rotateX,rotateY:JU().rotateY,rotateZ:JU().rotateZ,scale:e5().scale,scaleX:e5().scaleX,scaleY:e5().scaleY,scaleZ:e5().scaleZ,transform:qgt(),translate:WG().translate,translateX:WG().translateX,translateY:WG().translateY,translateZ:WG().translateZ}}}),t5=ne({"node_modules/@jscad/modeling/src/index.js"(t,A){A.exports={colors:ZO(),curves:Yrt(),geometries:JBA(),maths:cat(),measurements:dat(),primitives:fx(),text:jBA(),utils:qWA(),booleans:LM(),expansions:ilA(),extrusions:qU(),hulls:_gt(),modifiers:Jgt(),transforms:ZG()}}}),Pgt=ne({"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(B,l){l=l||{};var C=typeof B;if(C==="string"&&B.length>0)return a(B);if(C==="number"&&isFinite(B))return l.long?I(B):g(B);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(B))};function a(B){if(B=String(B),!(B.length>100)){var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(B);if(l){var C=parseFloat(l[1]),Q=(l[2]||"ms").toLowerCase();switch(Q){case"years":case"year":case"yrs":case"yr":case"y":return C*r;case"weeks":case"week":case"w":return C*s;case"days":case"day":case"d":return C*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(B){var l=Math.abs(B);return l>=o?Math.round(B/o)+"d":l>=n?Math.round(B/n)+"h":l>=i?Math.round(B/i)+"m":l>=e?Math.round(B/e)+"s":B+"ms"}function I(B){var l=Math.abs(B);return l>=o?c(B,l,o,"day"):l>=n?c(B,l,n,"hour"):l>=i?c(B,l,i,"minute"):l>=e?c(B,l,e,"second"):B+" ms"}function c(B,l,C,Q){var E=l>=C*1.5;return Math.round(B/C)+" "+Q+(E?"s":"")}}}),Ogt=ne({"node_modules/debug/src/common.js"(t,A){function e(i){o.debug=o,o.default=o,o.coerce=c,o.disable=g,o.enable=r,o.enabled=I,o.humanize=Pgt(),o.destroy=B,Object.keys(i).forEach(l=>{o[l]=i[l]}),o.names=[],o.skips=[],o.formatters={};function n(l){let C=0;for(let Q=0;Q<l.length;Q++)C=(C<<5)-C+l.charCodeAt(Q),C|=0;return o.colors[Math.abs(C)%o.colors.length]}o.selectColor=n;function o(l){let C,Q=null,E,h;function u(...d){if(!u.enabled)return;const f=u,w=Number(new Date),S=w-(C||w);f.diff=S,f.prev=C,f.curr=w,C=w,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,(F,k)=>{if(F==="%%")return"%";D++;const v=o.formatters[k];if(typeof v=="function"){const M=d[D];F=v.call(f,M),d.splice(D,1),D--}return F}),o.formatArgs.call(f,d),(f.log||o.log).apply(f,d)}return u.namespace=l,u.useColors=o.useColors(),u.color=o.selectColor(l),u.extend=s,u.destroy=o.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>Q!==null?Q:(E!==o.namespaces&&(E=o.namespaces,h=o.enabled(l)),h),set:d=>{Q=d}}),typeof o.init=="function"&&o.init(u),u}function s(l,C){const Q=o(this.namespace+(typeof C>"u"?":":C)+l);return Q.log=this.log,Q}function r(l){o.save(l),o.namespaces=l,o.names=[],o.skips=[];const C=(typeof l=="string"?l:"").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(l,C){let Q=0,E=0,h=-1,u=0;for(;Q<l.length;)if(E<C.length&&(C[E]===l[Q]||C[E]==="*"))C[E]==="*"?(h=E,u=Q,E++):(Q++,E++);else if(h!==-1)E=h+1,u++,Q=u;else return!1;for(;E<C.length&&C[E]==="*";)E++;return E===C.length}function g(){const l=[...o.names,...o.skips.map(C=>"-"+C)].join(",");return o.enable(""),l}function I(l){for(const C of o.skips)if(a(l,C))return!1;for(const C of o.names)if(a(l,C))return!0;return!1}function c(l){return l instanceof Error?l.stack||l.message:l}function B(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}A.exports=e}}),Wgt=ne({"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 I=0,c=0;a[0].replace(/%[a-zA-Z%]/g,B=>{B!=="%%"&&(I++,B==="%c"&&(c=I))}),a.splice(c,0,g)}t.log=console.debug||console.log||(()=>{});function 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 RBA<"u"&&"env"in RBA&&(a=RBA.env.DEBUG),a}function s(){try{return localStorage}catch{}}A.exports=Ogt()(t);var{formatters:r}=A.exports;r.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}}}),$WA=z.createContext(null),yu=()=>{const t=z.useContext($WA);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},PU=(t,A=[])=>{const{addFrameListener:e,removeFrameListener:i}=yu();zi.useEffect(()=>(e(t),()=>i(t)),[e,i,...A])},AZA=z.createContext(null),Zgt=()=>{const t=z.useContext(AZA);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},Vgt=({children:t})=>{const{camera:A,renderer:e}=yu(),[i,n]=z.useState([]),o=z.useMemo(()=>new sXe,[]),s=z.useMemo(()=>new on,[]),r=z.useRef(i);r.current=i;const a=z.useRef(null),g=z.useCallback(C=>{n(Q=>[...Q,C])},[]),I=z.useCallback(C=>{if(a.current){let Q=!1,E=a.current.object;for(;E;){if(E===C){Q=!0;break}E=E.parent}Q&&(a.current.onUnhover(),a.current=null)}n(Q=>Q.filter(E=>E.object!==C))},[]),c=z.useCallback(C=>{let Q=C;for(;Q;){const E=r.current.find(h=>h.object===Q);if(E)return E;Q=Q.parent}},[]),B=z.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 E=r.current.map(u=>u.object);if(E.length===0){a.current&&(a.current.onUnhover(),a.current=null);return}const h=o.intersectObjects(E,!0);if(h.length>0){const u=h[0],d=c(u.object);if(d){const f={mousePosition:[u.point.x,u.point.y,u.point.z]};a.current!==d?(a.current?.onUnhover(),d.onHover(f),a.current=d):d.onHover(f)}else a.current&&(a.current.onUnhover(),a.current=null)}else a.current&&(a.current.onUnhover(),a.current=null)},[A,e,o,s,c]);z.useEffect(()=>{const C=e.domElement;return C.addEventListener("mousemove",B),()=>{C.removeEventListener("mousemove",B)}},[e,B]);const l=z.useMemo(()=>({addHoverable:g,removeHoverable:I}),[g,I]);return O.jsx(AZA.Provider,{value:l,children:t})},jgt=({children:t,object:A,onHover:e,onUnhover:i,isHovered:n})=>{const{addHoverable:o,removeHoverable:s}=Zgt();return z.useEffect(()=>A?(o({object:A,onHover:e,onUnhover:i}),()=>{s(A)}):void 0,[A,e,i,o,s]),O.jsx(O.Fragment,{children:t})},OU=jgt;function zgt(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(A,e,i)=>`${e} ${i.replace(/-/g,"_")}`)}async function Xgt(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 h6e().parse(zgt(e),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function $gt(t){const[A,e]=z.useState(null);return z.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 Xgt(i);const a=await fetch(i);if(!a.ok)throw new Error(`Failed to fetch "${i}": ${a.status} ${a.statusText}`);const g=await a.text(),I=g.match(/newmtl[\s\S]*?endmtl/g),c=new S6e;if(I?.length){const B=I.join(`
5066
- `).replace(/d 0\./g,"d 1."),l=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new C6e;C.setMaterialOptions({invertTrProperty:!0});const Q=C.parse(B.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return c.setMaterials(Q),c.parse(l)}return c.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(n.has(i)){const g=n.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(I=>I instanceof Error?I:I.clone())}const a=s().then(g=>(g instanceof Error||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 AIt({url:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const a=$gt(t),{rootObject:g}=yu(),I=z.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(c=>{if(c instanceof Ao&&c.material){const B=l=>{l.transparent=r,l.opacity=r?.5:1,l.depthWrite=!r,l.needsUpdate=!0};Array.isArray(c.material)?c.material.forEach(B):B(c.material)}}),a):new Ao(new um(.5,.5,.5),new fu({transparent:!0,color:"red",opacity:.25})),[a,r]);if(z.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),z.useEffect(()=>{I&&(A&&(Array.isArray(A)?I.position.fromArray(A):I.position.copy(A)),e&&(Array.isArray(e)?I.rotation.fromArray(e):I.rotation.copy(e)),s!==void 0&&I.scale.setScalar(s))},[I,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,s]),a instanceof Error)throw a;return O.jsx(OU,{isHovered:o,onHover:i,onUnhover:n,object:I})}var eZA=new WeakMap,eIt=()=>{const t=new Lc;return t.name="fallback-environment-map",t.mapping=c3,t},tIt=t=>{if(!t)return null;const A=t,e=eZA.get(A);if(e)return e;let i;if(t instanceof K3){const n=new piA(t);i=n.fromScene(GXe(),.04).texture,n.dispose()}else i=eIt();return eZA.set(A,i),i},tZA=1.25;function iIt({gltfUrl:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=yu(),[I,c]=z.useState(null),[B,l]=z.useState(null);if(z.useEffect(()=>{if(!t)return;const C=new RXe;let Q=!0;return C.load(t,E=>{if(!Q)return;const h=E.scene;h.traverse(u=>{if(u instanceof Ao&&u.material){const d=f=>{f.transparent=r,f.opacity=r?.5:1,f.depthWrite=!r,f.needsUpdate=!0};Array.isArray(u.material)?u.material.forEach(d):d(u.material)}}),c(h)},void 0,E=>{if(!Q)return;console.error(`An error happened loading ${t}`,E);const h=E instanceof Error?E:new Error(`Failed to load glTF model from ${t}`);l(h)}),()=>{Q=!1}},[t,r]),z.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]),z.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),z.useEffect(()=>{if(!I||!a)return;const C=tIt(a);if(!C)return;const Q=[],E=h=>{h instanceof fu&&(Q.push({material:h,envMap:h.envMap??null,envMapIntensity:h.envMapIntensity??1}),h.envMap||(h.envMap=C),(typeof h.envMapIntensity!="number"||h.envMapIntensity<tZA)&&(h.envMapIntensity=tZA),h.needsUpdate=!0)};return I.traverse(h=>{if(!(h instanceof Ao))return;const u=h.material;Array.isArray(u)?u.forEach(E):u&&E(u)}),()=>{Q.forEach(({material:h,envMap:u,envMapIntensity:d})=>{h.envMap=u,h.envMapIntensity=d,h.needsUpdate=!0})}},[I,a]),z.useEffect(()=>{I&&I.traverse(C=>{C instanceof Ao&&C.material instanceof fu&&(o?(C.material.emissive.setHex(255),C.material.emissiveIntensity=.2):C.material.emissiveIntensity=0)})},[o,I]),B)throw B;return I?O.jsx(OU,{isHovered:o,onHover:i,onUnhover:n,object:I}):null}var nIt=fr(G8A()),oIt=fr(t5()),iZA={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},ya=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 iZA)return e*iZA[A];throw new Error(`Unsupported unit: ${A}`)},WU=ya,nZA={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,ms:1,s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},slA=new Set;for(const[t,A]of Object.entries(nZA)){slA.add(t);for(const e of Object.keys(A.variants))slA.add(e)}function sIt(t){for(const[A,e]of Object.entries(nZA))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var oZA={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12};function ym(t){if(t==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:r,unitOfValue:a}=ym(t.x),g=ym(t.x),I=ym(t.y);return g.value===null||I.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:I.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),n=t.slice(0,-i.length);if(i in oZA&&!slA.has(i)){const r=oZA[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(n)*r}}const{baseUnit:o,conversionFactor:s}=sIt(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(n)}}var rlA=J().or(jA()).transform(t=>ym(t).value),sZA=J().or(jA()).transform(t=>ym(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),rIt=J().or(jA()).transform(t=>ym(t).value),HM=J().or(jA()).transform(t=>ym(t).value),ie=J().or(jA()).transform(t=>ym(t).value),alA=J().or(jA()).transform(t=>ym(t).value),wt=ie;J().or(jA()).transform(t=>ym(t).value);var glA=J().or(jA()).transform(t=>ym(t).value),YM=glA,aIt=J().datetime(),$f=J().or(jA()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),gIt=jA().or(J().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const A=t.replace("mAh",""),e=Number.parseFloat(A);if(Number.isNaN(e))throw new Error("Invalid capacity");return e}return t}).describe("Battery capacity in mAh"),Rn=TA({x:wt,y:wt}),IlA=TA({x:wt,y:wt,z:wt}),rZA=TA({width:jA(),height:jA()}),IIt=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},Ai=t=>J().optional().default(()=>`${t}_${IIt(10)}`),JM=lt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),cIt=lt(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),ZB=TA({type:FA("source_component"),ftype:J().optional(),source_component_id:J(),name:J(),manufacturer_part_number:J().optional(),supplier_part_numbers:Ma(cIt,be(J())).optional(),display_value:J().optional(),are_pins_interchangeable:Be().optional(),internally_connected_source_port_ids:be(be(J())).optional(),source_group_id:J().optional(),subcircuit_id:J().optional()}),aZA=ZB.extend({ftype:FA("simple_capacitor"),capacitance:sZA,max_voltage_rating:HM.optional(),display_capacitance:J().optional(),max_decoupling_trace_length:wt.optional()}),gZA=ZB.extend({ftype:FA("simple_resistor"),resistance:rlA,display_resistance:J().optional()}),clA=ZB.extend({ftype:FA("simple_diode")}),BIt=ZB.extend({ftype:FA("simple_fiducial")}),IZA=clA.extend({ftype:FA("simple_led"),color:J().optional(),wavelength:J().optional()}),lIt=ZB.extend({ftype:FA("simple_ground")}),cZA=ZB.extend({ftype:FA("simple_chip")}),BZA=ZB.extend({ftype:FA("simple_power_source"),voltage:HM}),CIt=ZB.extend({ftype:FA("simple_fuse"),current_rating_amps:jA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:jA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),lZA=ZB.extend({ftype:FA("simple_battery"),capacity:gIt}),CZA=ZB.extend({ftype:FA("simple_inductor"),inductance:rIt,max_current_rating:jA().optional()}),QZA=ZB.extend({ftype:FA("simple_push_button")}),EZA=ZB.extend({ftype:FA("simple_potentiometer"),max_resistance:rlA}),QIt=ZB.extend({ftype:FA("simple_crystal"),frequency:jA().describe("Frequency in Hz"),load_capacitance:jA().optional().describe("Load capacitance in pF")}),hZA=ZB.extend({ftype:FA("simple_pin_header"),pin_count:jA(),gender:lt(["male","female"]).optional().default("male")}),uZA=ZB.extend({ftype:FA("simple_pinout")}),dZA=ZB.extend({ftype:FA("simple_resonator"),load_capacitance:sZA,equivalent_series_resistance:rlA.optional(),frequency:alA}),pZA=ZB.extend({ftype:FA("simple_transistor"),transistor_type:lt(["npn","pnp"])}),fZA=ZB.extend({ftype:FA("simple_test_point"),footprint_variant:lt(["pad","through_hole"]).optional(),pad_shape:lt(["rect","circle"]).optional(),pad_diameter:ei([jA(),J()]).optional(),hole_diameter:ei([jA(),J()]).optional(),width:ei([jA(),J()]).optional(),height:ei([jA(),J()]).optional()}),yZA=ZB.extend({ftype:FA("simple_mosfet"),channel_type:lt(["n","p"]),mosfet_mode:lt(["enhancement","depletion"])}),mZA=ZB.extend({ftype:FA("simple_switch")}),wZA=TA({type:FA("source_project_metadata"),name:J().optional(),software_used_string:J().optional(),project_url:J().optional(),created_at:aIt.optional()}),EIt=TA({type:FA("source_missing_property_error"),source_missing_property_error_id:Ai("source_missing_property_error"),source_component_id:J(),property_name:J(),subcircuit_id:J().optional(),error_type:FA("source_missing_property_error").default("source_missing_property_error"),message:J()}).describe("The source code is missing a property"),hIt=TA({type:FA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Ai("source_failed_to_create_component_error"),error_type:FA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:J().optional(),subcircuit_id:J().optional(),parent_source_component_id:J().optional(),message:J(),pcb_center:TA({x:jA().optional(),y:jA().optional()}).optional(),schematic_center:TA({x:jA().optional(),y:jA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),DZA=TA({type:FA("source_trace_not_connected_error"),source_trace_not_connected_error_id:Ai("source_trace_not_connected_error"),error_type:FA("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:J(),subcircuit_id:J().optional(),source_group_id:J().optional(),source_trace_id:J().optional(),connected_source_port_ids:be(J()).optional(),selectors_not_found:be(J()).optional()}).describe("Occurs when a source trace selector does not match any ports"),uIt=TA({type:FA("source_property_ignored_warning"),source_property_ignored_warning_id:Ai("source_property_ignored_warning"),source_component_id:J(),property_name:J(),subcircuit_id:J().optional(),error_type:FA("source_property_ignored_warning").default("source_property_ignored_warning"),message:J()}).describe("The source property was ignored"),SZA=TA({type:FA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Ai("source_pin_missing_trace_warning"),warning_type:FA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:J(),source_component_id:J(),source_port_id:J(),subcircuit_id:J().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),dIt=ZB.extend({ftype:FA("simple_voltage_probe")}),pIt=ZB.extend({ftype:FA("interconnect")}),fIt=ei([gZA,aZA,clA,BIt,IZA,lIt,cZA,BZA,lZA,CZA,QZA,EZA,QIt,hZA,uZA,dZA,mZA,pZA,fZA,yZA,CIt,dIt,pIt,wZA,EIt,hIt,DZA,uIt,SZA]),yIt=TA({type:FA("source_port"),pin_number:jA().optional(),port_hints:be(J()).optional(),name:J(),source_port_id:J(),source_component_id:J().optional(),source_group_id:J().optional(),subcircuit_id:J().optional(),subcircuit_connectivity_map_key:J().optional(),must_be_connected:Be().optional()}),mIt=TA({type:FA("source_component_internal_connection"),source_component_internal_connection_id:J(),source_component_id:J(),source_port_ids:be(J()),subcircuit_id:J().optional()}),wIt=TA({type:FA("source_trace"),source_trace_id:J(),connected_source_port_ids:be(J()),connected_source_net_ids:be(J()),subcircuit_id:J().optional(),subcircuit_connectivity_map_key:J().optional(),max_length:jA().optional(),min_trace_thickness:jA().optional(),display_name:J().optional()}),DIt=TA({type:FA("source_group"),source_group_id:J(),subcircuit_id:J().optional(),parent_subcircuit_id:J().optional(),parent_source_group_id:J().optional(),is_subcircuit:Be().optional(),show_as_schematic_box:Be().optional(),name:J().optional(),was_automatically_named:Be().optional()}),SIt=TA({type:FA("source_net"),source_net_id:J(),name:J(),member_source_group_ids:be(J()),is_power:Be().optional(),is_ground:Be().optional(),is_digital_signal:Be().optional(),is_analog_signal:Be().optional(),is_positive_voltage_source:Be().optional(),trace_width:jA().optional(),subcircuit_id:J().optional(),subcircuit_connectivity_map_key:J().optional()}),bIt=TA({type:FA("source_board"),source_board_id:J(),source_group_id:J(),title:J().optional()}).describe("Defines a board in the source domain"),xIt=TA({type:FA("source_pcb_ground_plane"),source_pcb_ground_plane_id:J(),source_group_id:J(),source_net_id:J(),subcircuit_id:J().optional()}).describe("Defines a ground plane in the source domain"),kIt=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],bZA=lt(kIt),Zr=bZA.or(TA({name:bZA})).transform(t=>typeof t=="string"?t:t.name),kw=lt(["top","bottom"]),GIt=TA({type:FA("source_manually_placed_via"),source_manually_placed_via_id:J(),source_group_id:J(),source_net_id:J(),subcircuit_id:J().optional(),source_trace_id:J().optional()}).describe("Defines a via that is manually placed in the source domain"),FIt=TA({type:FA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:Ai("source_pin_must_be_connected_error"),error_type:FA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),message:J(),source_component_id:J(),source_port_id:J(),subcircuit_id:J().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),RIt=TA({type:FA("unknown_error_finding_part"),unknown_error_finding_part_id:Ai("unknown_error_finding_part"),error_type:FA("unknown_error_finding_part").default("unknown_error_finding_part"),message:J(),source_component_id:J().optional(),subcircuit_id:J().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),NIt=TA({type:FA("schematic_box"),schematic_component_id:J().optional(),width:wt,height:wt,is_dashed:Be().default(!1),x:wt,y:wt,subcircuit_id:J().optional()}).describe("Draws a box on the schematic"),MIt=TA({type:FA("schematic_path"),schematic_component_id:J(),fill_color:lt(["red","blue"]).optional(),is_filled:Be().optional(),points:be(Rn),subcircuit_id:J().optional()}),_It=Ma(TA({left_margin:ie.optional(),right_margin:ie.optional(),top_margin:ie.optional(),bottom_margin:ie.optional()})),vIt=TA({left_size:jA(),right_size:jA(),top_size:jA().optional(),bottom_size:jA().optional()}),UIt=TA({left_side:TA({pins:be(jA()),direction:lt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:TA({pins:be(jA()),direction:lt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:TA({pins:be(jA()),direction:lt(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:TA({pins:be(jA()),direction:lt(["left-to-right","right-to-left"]).optional()}).optional()}),LIt=ei([vIt,UIt]),HIt=TA({type:FA("schematic_component"),size:rZA,center:Rn,source_component_id:J().optional(),schematic_component_id:J(),pin_spacing:ie.optional(),pin_styles:_It.optional(),box_width:ie.optional(),symbol_name:J().optional(),port_arrangement:LIt.optional(),port_labels:Ma(J()).optional(),symbol_display_value:J().optional(),subcircuit_id:J().optional(),schematic_group_id:J().optional(),is_schematic_group:Be().optional(),source_group_id:J().optional(),is_box_with_pins:Be().optional().default(!0)}),YIt=TA({type:FA("schematic_line"),schematic_line_id:Ai("schematic_line"),schematic_component_id:J(),x1:wt,y1:wt,x2:wt,y2:wt,stroke_width:wt.nullable().optional(),color:J().default("#000000"),is_dashed:Be().default(!1),subcircuit_id:J().optional()}).describe("Draws a styled line on the schematic"),JIt=TA({type:FA("schematic_rect"),schematic_rect_id:Ai("schematic_rect"),schematic_component_id:J(),center:Rn,width:wt,height:wt,rotation:$f.default(0),stroke_width:wt.nullable().optional(),color:J().default("#000000"),is_filled:Be().default(!1),fill_color:J().optional(),is_dashed:Be().default(!1),subcircuit_id:J().optional()}).describe("Draws a styled rectangle on the schematic"),TIt=TA({type:FA("schematic_circle"),schematic_circle_id:Ai("schematic_circle"),schematic_component_id:J(),center:Rn,radius:wt,stroke_width:wt.nullable().optional(),color:J().default("#000000"),is_filled:Be().default(!1),fill_color:J().optional(),is_dashed:Be().default(!1),subcircuit_id:J().optional()}).describe("Draws a styled circle on the schematic"),KIt=TA({type:FA("schematic_arc"),schematic_arc_id:Ai("schematic_arc"),schematic_component_id:J(),center:Rn,radius:wt,start_angle_degrees:$f,end_angle_degrees:$f,direction:lt(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:wt.nullable().optional(),color:J().default("#000000"),is_dashed:Be().default(!1),subcircuit_id:J().optional()}).describe("Draws a styled arc on the schematic"),qIt=TA({type:FA("schematic_trace"),schematic_trace_id:J(),source_trace_id:J().optional(),junctions:be(TA({x:jA(),y:jA()})),edges:be(TA({from:TA({x:jA(),y:jA()}),to:TA({x:jA(),y:jA()}),is_crossing:Be().optional(),from_schematic_port_id:J().optional(),to_schematic_port_id:J().optional()})),subcircuit_id:J().optional(),subcircuit_connectivity_map_key:J().optional()}),PIt=lt(["center","left","right","top","bottom"]),OIt=TA({type:FA("schematic_text"),schematic_component_id:J().optional(),schematic_text_id:J(),text:J(),font_size:jA().default(.18),position:TA({x:wt,y:wt}),rotation:jA().default(0),anchor:ei([PIt.describe("legacy"),JM]).default("center"),color:J().default("#000000"),subcircuit_id:J().optional()}),WIt=TA({type:FA("schematic_port"),schematic_port_id:J(),source_port_id:J(),schematic_component_id:J().optional(),center:Rn,facing_direction:lt(["up","down","left","right"]).optional(),distance_from_component_edge:jA().optional(),side_of_component:lt(["top","bottom","left","right"]).optional(),true_ccw_index:jA().optional(),pin_number:jA().optional(),display_pin_label:J().optional(),subcircuit_id:J().optional(),is_connected:Be().optional(),has_input_arrow:Be().optional(),has_output_arrow:Be().optional()}).describe("Defines a port on a schematic component"),ZIt=TA({type:FA("schematic_net_label"),schematic_net_label_id:Ai("schematic_net_label"),schematic_trace_id:J().optional(),source_trace_id:J().optional(),source_net_id:J(),center:Rn,anchor_position:Rn.optional(),anchor_side:lt(["top","bottom","left","right"]),text:J(),symbol_name:J().optional(),is_movable:Be().optional(),subcircuit_id:J().optional()}),VIt=TA({type:FA("schematic_error"),schematic_error_id:J(),error_type:FA("schematic_port_not_found").default("schematic_port_not_found"),message:J(),subcircuit_id:J().optional()}).describe("Defines a schematic error on the schematic"),jIt=TA({type:FA("schematic_layout_error"),schematic_layout_error_id:Ai("schematic_layout_error"),error_type:FA("schematic_layout_error").default("schematic_layout_error"),message:J(),source_group_id:J(),schematic_group_id:J(),subcircuit_id:J().optional()}).describe("Error emitted when schematic layout fails for a group"),BlA=TA({type:FA("schematic_debug_object"),label:J().optional(),subcircuit_id:J().optional()}),zIt=BlA.extend({shape:FA("rect"),center:Rn,size:rZA}),XIt=BlA.extend({shape:FA("line"),start:Rn,end:Rn}),$It=BlA.extend({shape:FA("point"),center:Rn}),Act=Gp("shape",[zIt,XIt,$It]),ect=TA({type:FA("schematic_voltage_probe"),schematic_voltage_probe_id:J(),source_component_id:J().optional(),name:J().optional(),position:Rn,schematic_trace_id:J(),voltage:HM.optional(),subcircuit_id:J().optional(),color:J().optional(),label_alignment:JM.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),tct=TA({type:FA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Ai("schematic_manual_edit_conflict_warning"),warning_type:FA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:J(),schematic_component_id:J(),schematic_group_id:J().optional(),subcircuit_id:J().optional(),source_component_id:J()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),ict=TA({type:FA("schematic_group"),schematic_group_id:Ai("schematic_group"),source_group_id:J(),is_subcircuit:Be().optional(),subcircuit_id:J().optional(),width:ie,height:ie,center:Rn,schematic_component_ids:be(J()),show_as_schematic_box:Be().optional(),name:J().optional(),description:J().optional()}).describe("Defines a group of components on the schematic"),nct=TA({type:FA("schematic_table"),schematic_table_id:Ai("schematic_table"),anchor_position:Rn,column_widths:be(wt),row_heights:be(wt),cell_padding:wt.optional(),border_width:wt.optional(),subcircuit_id:J().optional(),schematic_component_id:J().optional(),anchor:JM.optional()}).describe("Defines a table on the schematic"),oct=TA({type:FA("schematic_table_cell"),schematic_table_cell_id:Ai("schematic_table_cell"),schematic_table_id:J(),start_row_index:jA(),end_row_index:jA(),start_column_index:jA(),end_column_index:jA(),text:J().optional(),center:Rn,width:wt,height:wt,horizontal_align:lt(["left","center","right"]).optional(),vertical_align:lt(["top","middle","bottom"]).optional(),font_size:wt.optional(),subcircuit_id:J().optional()}).describe("Defines a cell within a schematic_table"),sct=TA({type:FA("schematic_sheet"),schematic_sheet_id:Ai("schematic_sheet"),name:J().optional(),subcircuit_id:J().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),rct=TA({x:wt,y:wt,bulge:jA().optional()}),xZA=TA({vertices:be(rct)}),act=TA({outer_ring:xZA,inner_rings:be(xZA).default([])}),gct=TA({x:wt,y:wt,via:Be().optional(),via_to_layer:Zr.optional()});be(gct);var Ict=TA({x:wt,y:wt,via:Be().optional(),to_layer:Zr.optional(),trace_width:wt.optional()}),cct=TA({type:FA("pcb_component"),pcb_component_id:Ai("pcb_component"),source_component_id:J(),center:Rn,layer:Zr,rotation:$f,display_offset_x:J().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:J().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:ie,height:ie,do_not_place:Be().optional(),subcircuit_id:J().optional(),pcb_group_id:J().optional(),position_mode:lt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:J().optional(),positioned_relative_to_pcb_board_id:J().optional(),obstructs_within_bounds:Be().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),kZA=TA({type:FA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("circle"),hole_diameter:jA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});kZA.describe("Defines a circular hole on the PCB");var GZA=TA({type:FA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("rect"),hole_width:jA(),hole_height:jA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});GZA.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square.");var FZA=TA({type:FA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:lt(["circle","square"]),hole_diameter:jA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});FZA.describe("Defines a circular or square hole on the PCB");var RZA=TA({type:FA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("oval"),hole_width:jA(),hole_height:jA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});RZA.describe("Defines an oval hole on the PCB");var NZA=TA({type:FA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("pill"),hole_width:jA(),hole_height:jA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});NZA.describe("Defines a pill-shaped hole on the PCB");var MZA=TA({type:FA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("rotated_pill"),hole_width:jA(),hole_height:jA(),x:wt,y:wt,ccw_rotation:$f,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});MZA.describe("Defines a rotated pill-shaped hole on the PCB");var Bct=FZA.or(RZA).or(NZA).or(MZA).or(kZA).or(GZA),lct=TA({type:FA("pcb_plated_hole"),shape:FA("circle"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),outer_diameter:jA(),hole_diameter:jA(),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Zr),port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Cct=TA({type:FA("pcb_plated_hole"),shape:lt(["oval","pill"]),pcb_group_id:J().optional(),subcircuit_id:J().optional(),outer_width:jA(),outer_height:jA(),hole_width:jA(),hole_height:jA(),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,ccw_rotation:$f,layers:be(Zr),port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Qct=TA({type:FA("pcb_plated_hole"),shape:FA("circular_hole_with_rect_pad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("circle"),pad_shape:FA("rect"),hole_diameter:jA(),rect_pad_width:jA(),rect_pad_height:jA(),rect_border_radius:jA().optional(),hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Zr),port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Ect=TA({type:FA("pcb_plated_hole"),shape:FA("pill_hole_with_rect_pad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("pill"),pad_shape:FA("rect"),hole_width:jA(),hole_height:jA(),rect_pad_width:jA(),rect_pad_height:jA(),rect_border_radius:jA().optional(),hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Zr),port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),hct=TA({type:FA("pcb_plated_hole"),shape:FA("rotated_pill_hole_with_rect_pad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("rotated_pill"),pad_shape:FA("rect"),hole_width:jA(),hole_height:jA(),hole_ccw_rotation:$f,rect_pad_width:jA(),rect_pad_height:jA(),rect_border_radius:jA().optional(),rect_ccw_rotation:$f,hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Zr),port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),uct=TA({type:FA("pcb_plated_hole"),shape:FA("hole_with_polygon_pad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:lt(["circle","oval","pill","rotated_pill"]),hole_diameter:jA().optional(),hole_width:jA().optional(),hole_height:jA().optional(),pad_outline:be(TA({x:wt,y:wt})).min(3),hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Zr),port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),dct=ei([lct,Cct,Qct,Ect,hct,uct]),pct=TA({type:FA("pcb_port"),pcb_port_id:Ai("pcb_port"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),source_port_id:J(),pcb_component_id:J().optional(),x:wt,y:wt,layers:be(Zr),is_board_pinout:Be().optional()}).describe("Defines a port on the PCB"),fct=TA({type:FA("pcb_smtpad"),shape:FA("circle"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,radius:jA(),layer:Zr,port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),yct=TA({type:FA("pcb_smtpad"),shape:FA("rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),rect_border_radius:jA().optional(),corner_radius:jA().optional(),layer:Zr,port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),mct=TA({type:FA("pcb_smtpad"),shape:FA("rotated_rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),rect_border_radius:jA().optional(),corner_radius:jA().optional(),ccw_rotation:$f,layer:Zr,port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),wct=TA({type:FA("pcb_smtpad"),shape:FA("pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),radius:jA(),layer:Zr,port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Dct=TA({type:FA("pcb_smtpad"),shape:FA("rotated_pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),radius:jA(),ccw_rotation:$f,layer:Zr,port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Sct=TA({type:FA("pcb_smtpad"),shape:FA("polygon"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),points:be(Rn),layer:Zr,port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),bct=Gp("shape",[fct,yct,mct,Dct,wct,Sct]).describe("Defines an SMT pad on the PCB"),xct=TA({type:FA("pcb_solder_paste"),shape:FA("circle"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,radius:jA(),layer:Zr,pcb_component_id:J().optional(),pcb_smtpad_id:J().optional()}),kct=TA({type:FA("pcb_solder_paste"),shape:FA("rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),layer:Zr,pcb_component_id:J().optional(),pcb_smtpad_id:J().optional()}),Gct=TA({type:FA("pcb_solder_paste"),shape:FA("pill"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),radius:jA(),layer:Zr,pcb_component_id:J().optional(),pcb_smtpad_id:J().optional()}),Fct=TA({type:FA("pcb_solder_paste"),shape:FA("rotated_rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),ccw_rotation:wt,layer:Zr,pcb_component_id:J().optional(),pcb_smtpad_id:J().optional()}),Rct=TA({type:FA("pcb_solder_paste"),shape:FA("oval"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),layer:Zr,pcb_component_id:J().optional(),pcb_smtpad_id:J().optional()}),Nct=ei([xct,kct,Gct,Fct,Rct]).describe("Defines solderpaste on the PCB"),Mct=TA({type:FA("pcb_text"),pcb_text_id:Ai("pcb_text"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),text:J(),center:Rn,layer:Zr,width:ie,height:ie,lines:jA(),align:lt(["bottom-left"])}).describe("Defines text on the PCB"),_ct=TA({route_type:FA("wire"),x:wt,y:wt,width:wt,start_pcb_port_id:J().optional(),end_pcb_port_id:J().optional(),layer:Zr}),vct=TA({route_type:FA("via"),x:wt,y:wt,hole_diameter:wt.optional(),outer_diameter:wt.optional(),from_layer:J(),to_layer:J()}),Uct=ei([_ct,vct]),Lct=TA({type:FA("pcb_trace"),source_trace_id:J().optional(),pcb_component_id:J().optional(),pcb_trace_id:Ai("pcb_trace"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),route_thickness_mode:lt(["constant","interpolated"]).default("constant").optional(),route_order_index:jA().optional(),should_round_corners:Be().optional(),trace_length:jA().optional(),highlight_color:J().optional(),route:be(Uct)}).describe("Defines a trace on the PCB"),Hct=TA({type:FA("pcb_trace_error"),pcb_trace_error_id:Ai("pcb_trace_error"),error_type:FA("pcb_trace_error").default("pcb_trace_error"),message:J(),center:Rn.optional(),pcb_trace_id:J(),source_trace_id:J(),pcb_component_ids:be(J()),pcb_port_ids:be(J()),subcircuit_id:J().optional()}).describe("Defines a trace error on the PCB"),Yct=TA({type:FA("pcb_trace_missing_error"),pcb_trace_missing_error_id:Ai("pcb_trace_missing_error"),error_type:FA("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:J(),center:Rn.optional(),source_trace_id:J(),pcb_component_ids:be(J()),pcb_port_ids:be(J()),subcircuit_id:J().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),Jct=TA({type:FA("pcb_port_not_matched_error"),pcb_error_id:Ai("pcb_error"),error_type:FA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:J(),pcb_component_ids:be(J()),subcircuit_id:J().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Tct=TA({type:FA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Ai("pcb_port_not_connected_error"),error_type:FA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:J(),pcb_port_ids:be(J()),pcb_component_ids:be(J()),subcircuit_id:J().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),Kct=TA({type:FA("pcb_net"),pcb_net_id:Ai("pcb_net"),source_net_id:J().optional(),highlight_color:J().optional()}).describe("Defines a net on the PCB"),qct=TA({type:FA("pcb_via"),pcb_via_id:Ai("pcb_via"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),subcircuit_connectivity_map_key:J().optional(),x:wt,y:wt,outer_diameter:wt.default("0.6mm"),hole_diameter:wt.default("0.25mm"),from_layer:Zr.optional(),to_layer:Zr.optional(),layers:be(Zr),pcb_trace_id:J().optional(),net_is_assignable:Be().optional(),net_assigned:Be().optional(),is_tented:Be().optional()}).describe("Defines a via on the PCB"),Pct=TA({type:FA("pcb_board"),pcb_board_id:Ai("pcb_board"),pcb_panel_id:J().optional(),is_subcircuit:Be().optional(),subcircuit_id:J().optional(),width:ie.optional(),height:ie.optional(),center:Rn,thickness:ie.optional().default(1.4),num_layers:jA().optional().default(4),outline:be(Rn).optional(),shape:lt(["rect","polygon"]).optional(),material:lt(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),Oct=TA({type:FA("pcb_panel"),pcb_panel_id:Ai("pcb_panel"),width:ie,height:ie,center:Rn,covered_with_solder_mask:Be().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),Wct=TA({type:FA("pcb_placement_error"),pcb_placement_error_id:Ai("pcb_placement_error"),error_type:FA("pcb_placement_error").default("pcb_placement_error"),message:J(),subcircuit_id:J().optional()}).describe("Defines a placement error on the PCB"),Zct=TA({type:FA("pcb_trace_hint"),pcb_trace_hint_id:Ai("pcb_trace_hint"),pcb_port_id:J(),pcb_component_id:J(),route:be(Ict),subcircuit_id:J().optional()}).describe("A hint that can be used during generation of a PCB trace"),Vct=TA({type:FA("pcb_silkscreen_line"),pcb_silkscreen_line_id:Ai("pcb_silkscreen_line"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),stroke_width:wt.default("0.1mm"),x1:wt,y1:wt,x2:wt,y2:wt,layer:kw}).describe("Defines a silkscreen line on the PCB"),jct=TA({type:FA("pcb_silkscreen_path"),pcb_silkscreen_path_id:Ai("pcb_silkscreen_path"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),layer:kw,route:be(Rn),stroke_width:ie}).describe("Defines a silkscreen path on the PCB"),zct=TA({type:FA("pcb_silkscreen_text"),pcb_silkscreen_text_id:Ai("pcb_silkscreen_text"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("0.2mm"),pcb_component_id:J(),text:J(),is_knockout:Be().default(!1).optional(),knockout_padding:TA({left:ie,top:ie,bottom:ie,right:ie}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:jA().optional(),layer:Zr,is_mirrored:Be().default(!1).optional(),anchor_position:Rn.default({x:0,y:0}),anchor_alignment:JM.default("center")}).describe("Defines silkscreen text on the PCB"),Xct=TA({type:FA("pcb_copper_text"),pcb_copper_text_id:Ai("pcb_copper_text"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("0.2mm"),pcb_component_id:J(),text:J(),is_knockout:Be().default(!1).optional(),knockout_padding:TA({left:ie,top:ie,bottom:ie,right:ie}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:jA().optional(),layer:Zr,is_mirrored:Be().default(!1).optional(),anchor_position:Rn.default({x:0,y:0}),anchor_alignment:JM.default("center")}).describe("Defines copper text on the PCB"),$ct=TA({type:FA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Ai("pcb_silkscreen_rect"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,width:ie,height:ie,layer:Zr,stroke_width:ie.default("1mm"),corner_radius:ie.optional(),is_filled:Be().default(!0).optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional()}).describe("Defines a silkscreen rect on the PCB"),ABt=TA({type:FA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Ai("pcb_silkscreen_circle"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,radius:ie,layer:kw,stroke_width:ie.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),eBt=TA({type:FA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Ai("pcb_silkscreen_oval"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,radius_x:wt,radius_y:wt,layer:kw}).describe("Defines a silkscreen oval on the PCB"),tBt=TA({type:FA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Ai("pcb_fabrication_note_text"),subcircuit_id:J().optional(),pcb_group_id:J().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("1mm"),pcb_component_id:J(),text:J(),layer:kw,anchor_position:Rn.default({x:0,y:0}),anchor_alignment:lt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:J().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),iBt=TA({type:FA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Ai("pcb_fabrication_note_path"),pcb_component_id:J(),subcircuit_id:J().optional(),layer:Zr,route:be(Rn),stroke_width:ie,color:J().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),nBt=TA({type:FA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Ai("pcb_fabrication_note_rect"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,width:ie,height:ie,layer:kw,stroke_width:ie.default("0.1mm"),corner_radius:ie.optional(),is_filled:Be().optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),color:J().optional()}).describe("Defines a fabrication note rectangle on the PCB"),oBt=TA({type:FA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Ai("pcb_fabrication_note_dimension"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),layer:kw,from:Rn,to:Rn,text:J().optional(),text_ccw_rotation:jA().optional(),offset:ie.optional(),offset_distance:ie.optional(),offset_direction:TA({x:jA(),y:jA()}).optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:ie.default("1mm"),color:J().optional(),arrow_size:ie.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),sBt=TA({type:FA("pcb_note_text"),pcb_note_text_id:Ai("pcb_note_text"),pcb_component_id:J().optional(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),name:J().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("1mm"),text:J().optional(),anchor_position:Rn.default({x:0,y:0}),anchor_alignment:lt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:J().optional()}).describe("Defines a documentation note in text on the PCB"),rBt=TA({type:FA("pcb_note_rect"),pcb_note_rect_id:Ai("pcb_note_rect"),pcb_component_id:J().optional(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),name:J().optional(),text:J().optional(),center:Rn,width:ie,height:ie,stroke_width:ie.default("0.1mm"),corner_radius:ie.optional(),is_filled:Be().optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),color:J().optional()}).describe("Defines a rectangular documentation note on the PCB"),aBt=TA({type:FA("pcb_note_path"),pcb_note_path_id:Ai("pcb_note_path"),pcb_component_id:J().optional(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),name:J().optional(),text:J().optional(),route:be(Rn),stroke_width:ie.default("0.1mm"),color:J().optional()}).describe("Defines a polyline documentation note on the PCB"),gBt=TA({type:FA("pcb_note_line"),pcb_note_line_id:Ai("pcb_note_line"),pcb_component_id:J().optional(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),name:J().optional(),text:J().optional(),x1:wt,y1:wt,x2:wt,y2:wt,stroke_width:wt.default("0.1mm"),color:J().optional(),is_dashed:Be().optional()}).describe("Defines a straight documentation note line on the PCB"),IBt=TA({type:FA("pcb_note_dimension"),pcb_note_dimension_id:Ai("pcb_note_dimension"),pcb_component_id:J().optional(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),name:J().optional(),from:Rn,to:Rn,text:J().optional(),text_ccw_rotation:jA().optional(),offset_distance:ie.optional(),offset_direction:TA({x:jA(),y:jA()}).optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:ie.default("1mm"),color:J().optional(),arrow_size:ie.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),cBt=TA({type:FA("pcb_footprint_overlap_error"),pcb_error_id:Ai("pcb_error"),error_type:FA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:J(),pcb_smtpad_ids:be(J()).optional(),pcb_plated_hole_ids:be(J()).optional(),pcb_hole_ids:be(J()).optional(),pcb_keepout_ids:be(J()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),BBt=TA({type:FA("pcb_keepout"),shape:FA("rect"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,width:wt,height:wt,pcb_keepout_id:J(),layers:be(J()),description:J().optional()}).or(TA({type:FA("pcb_keepout"),shape:FA("circle"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,radius:wt,pcb_keepout_id:J(),layers:be(J()),description:J().optional()})),i5=TA({type:FA("pcb_cutout"),pcb_cutout_id:Ai("pcb_cutout"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),pcb_board_id:J().optional(),pcb_panel_id:J().optional()}),lBt=i5.extend({shape:FA("rect"),center:Rn,width:ie,height:ie,rotation:$f.optional(),corner_radius:ie.optional()}),CBt=i5.extend({shape:FA("circle"),center:Rn,radius:ie}),QBt=i5.extend({shape:FA("polygon"),points:be(Rn)}),EBt=i5.extend({shape:FA("path"),route:be(Rn),slot_width:ie,slot_length:ie.optional(),space_between_slots:ie.optional(),slot_corner_radius:ie.optional()}),hBt=Gp("shape",[lBt,CBt,QBt,EBt]).describe("Defines a cutout on the PCB, removing board material."),uBt=TA({type:FA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Ai("pcb_missing_footprint_error"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),error_type:FA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:J(),message:J()}).describe("Defines a missing footprint error on the PCB"),dBt=TA({type:FA("external_footprint_load_error"),external_footprint_load_error_id:Ai("external_footprint_load_error"),pcb_component_id:J(),source_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),footprinter_string:J().optional(),error_type:FA("external_footprint_load_error").default("external_footprint_load_error"),message:J()}).describe("Defines an error when an external footprint fails to load"),pBt=TA({type:FA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Ai("circuit_json_footprint_load_error"),pcb_component_id:J(),source_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),error_type:FA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:J(),circuit_json:be(vI()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),fBt=TA({type:FA("pcb_group"),pcb_group_id:Ai("pcb_group"),source_group_id:J(),is_subcircuit:Be().optional(),subcircuit_id:J().optional(),width:ie.optional(),height:ie.optional(),center:Rn,display_offset_x:J().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:J().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:be(Rn).optional(),anchor_position:Rn.optional(),anchor_alignment:JM.default("center"),position_mode:lt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:J().optional(),positioned_relative_to_pcb_board_id:J().optional(),pcb_component_ids:be(J()),child_layout_mode:lt(["packed","none"]).optional(),name:J().optional(),description:J().optional(),layout_mode:J().optional(),autorouter_configuration:TA({trace_clearance:ie}).optional(),autorouter_used_string:J().optional()}).describe("Defines a group of components on the PCB"),yBt=TA({type:FA("pcb_autorouting_error"),pcb_error_id:Ai("pcb_autorouting_error"),error_type:FA("pcb_autorouting_error").default("pcb_autorouting_error"),message:J(),subcircuit_id:J().optional()}).describe("The autorouting has failed to route a portion of the board"),mBt=TA({type:FA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Ai("pcb_manual_edit_conflict_warning"),warning_type:FA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:J(),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),source_component_id:J()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),wBt=TA({type:FA("pcb_breakout_point"),pcb_breakout_point_id:Ai("pcb_breakout_point"),pcb_group_id:J(),subcircuit_id:J().optional(),source_trace_id:J().optional(),source_port_id:J().optional(),source_net_id:J().optional(),x:wt,y:wt}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),DBt=TA({type:FA("pcb_ground_plane"),pcb_ground_plane_id:Ai("pcb_ground_plane"),source_pcb_ground_plane_id:J(),source_net_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional()}).describe("Defines a ground plane on the PCB"),SBt=TA({type:FA("pcb_ground_plane_region"),pcb_ground_plane_region_id:Ai("pcb_ground_plane_region"),pcb_ground_plane_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),layer:Zr,points:be(Rn)}).describe("Defines a polygon region of a ground plane"),bBt=TA({type:FA("pcb_thermal_spoke"),pcb_thermal_spoke_id:Ai("pcb_thermal_spoke"),pcb_ground_plane_id:J(),shape:J(),spoke_count:jA(),spoke_thickness:wt,spoke_inner_diameter:wt,spoke_outer_diameter:wt,pcb_plated_hole_id:J().optional(),subcircuit_id:J().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),llA=TA({type:FA("pcb_copper_pour"),pcb_copper_pour_id:Ai("pcb_copper_pour"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),layer:Zr,source_net_id:J().optional(),covered_with_solder_mask:Be().optional().default(!0)}),xBt=llA.extend({shape:FA("rect"),center:Rn,width:ie,height:ie,rotation:$f.optional()}),kBt=llA.extend({shape:FA("brep"),brep_shape:act}),GBt=llA.extend({shape:FA("polygon"),points:be(Rn)}),FBt=Gp("shape",[xBt,kBt,GBt]).describe("Defines a copper pour on the PCB."),RBt=TA({type:FA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Ai("pcb_component_outside_board_error"),error_type:FA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:J(),pcb_component_id:J(),pcb_board_id:J(),component_center:Rn,component_bounds:TA({min_x:jA(),max_x:jA(),min_y:jA(),max_y:jA()}),subcircuit_id:J().optional(),source_component_id:J().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),NBt=TA({type:FA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Ai("pcb_component_invalid_layer_error"),error_type:FA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:J(),pcb_component_id:J().optional(),source_component_id:J(),layer:Zr,subcircuit_id:J().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),MBt=TA({type:FA("pcb_via_clearance_error"),pcb_error_id:Ai("pcb_error"),error_type:FA("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:J(),pcb_via_ids:be(J()).min(2),minimum_clearance:wt.optional(),actual_clearance:wt.optional(),pcb_center:TA({x:jA().optional(),y:jA().optional()}).optional(),subcircuit_id:J().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),_Bt=TA({type:FA("pcb_courtyard_rect"),pcb_courtyard_rect_id:Ai("pcb_courtyard_rect"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,width:ie,height:ie,layer:kw,color:J().optional()}).describe("Defines a courtyard rectangle on the PCB"),vBt=TA({type:FA("pcb_courtyard_outline"),pcb_courtyard_outline_id:Ai("pcb_courtyard_outline"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),layer:kw,outline:be(Rn).min(2),stroke_width:ie.default("0.1mm"),is_closed:Be().optional(),is_stroke_dashed:Be().optional(),color:J().optional()}).describe("Defines a courtyard outline on the PCB"),UBt=TA({type:FA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Ai("pcb_courtyard_polygon"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),layer:kw,points:be(Rn).min(3),color:J().optional()}).describe("Defines a courtyard polygon on the PCB"),LBt=TA({type:FA("cad_component"),cad_component_id:J(),pcb_component_id:J(),source_component_id:J(),position:IlA,rotation:IlA.optional(),size:IlA.optional(),layer:Zr.optional(),subcircuit_id:J().optional(),footprinter_string:J().optional(),model_obj_url:J().optional(),model_stl_url:J().optional(),model_3mf_url:J().optional(),model_gltf_url:J().optional(),model_glb_url:J().optional(),model_step_url:J().optional(),model_wrl_url:J().optional(),model_unit_to_mm_scale_factor:jA().optional(),model_jscad:vI().optional(),show_as_translucent_model:Be().optional()}).describe("Defines a component on the PCB"),HBt=lt(["sinewave","square","triangle","sawtooth"]),YBt=ei([J(),jA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(jA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),JBt=TA({type:FA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:FA(!0).optional().default(!0),positive_source_port_id:J().optional(),negative_source_port_id:J().optional(),positive_source_net_id:J().optional(),negative_source_net_id:J().optional(),voltage:HM}).describe("Defines a DC voltage source for simulation"),TBt=TA({type:FA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:FA(!1),terminal1_source_port_id:J().optional(),terminal2_source_port_id:J().optional(),terminal1_source_net_id:J().optional(),terminal2_source_net_id:J().optional(),voltage:HM.optional(),frequency:alA.optional(),peak_to_peak_voltage:HM.optional(),wave_shape:HBt.optional(),phase:$f.optional(),duty_cycle:YBt.optional()}).describe("Defines an AC voltage source for simulation"),KBt=ei([JBt,TBt]).describe("Defines a voltage source for simulation"),qBt=ei([FA("spice_dc_sweep"),FA("spice_dc_operating_point"),FA("spice_transient_analysis"),FA("spice_ac_analysis")]),PBt=TA({type:FA("simulation_experiment"),simulation_experiment_id:Ai("simulation_experiment"),name:J(),experiment_type:qBt,time_per_step:glA.optional(),start_time_ms:YM.optional(),end_time_ms:YM.optional()}).describe("Defines a simulation experiment configuration"),OBt=TA({type:FA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Ai("simulation_transient_voltage_graph"),simulation_experiment_id:J(),timestamps_ms:be(jA()).optional(),voltage_levels:be(jA()),source_component_id:J().optional(),subcircuit_connectivity_map_key:J().optional(),time_per_step:glA,start_time_ms:YM,end_time_ms:YM,name:J().optional(),color:J().optional()}).describe("Stores voltage measurements over time for a simulation"),WBt=TA({type:FA("simulation_switch"),simulation_switch_id:Ai("simulation_switch"),source_component_id:J().optional(),closes_at:YM.optional(),opens_at:YM.optional(),starts_closed:Be().optional(),switching_frequency:alA.optional()}).describe("Defines a switch for simulation timing control"),ZBt=TA({type:FA("simulation_voltage_probe"),simulation_voltage_probe_id:Ai("simulation_voltage_probe"),source_component_id:J().optional(),name:J().optional(),signal_input_source_port_id:J().optional(),signal_input_source_net_id:J().optional(),reference_input_source_port_id:J().optional(),reference_input_source_net_id:J().optional(),subcircuit_id:J().optional(),color:J().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,n=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&n?A.addIssue({code:Wt.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:Wt.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):n&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:Wt.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:Wt.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),VBt=TA({type:FA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Ai("simulation_unknown_experiment_error"),error_type:FA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:J(),simulation_experiment_id:J().optional(),subcircuit_id:J().optional()}).describe("An unknown error occurred during the simulation experiment.");ei([wIt,yIt,mIt,fIt,SIt,DIt,cZA,aZA,clA,IZA,gZA,BZA,lZA,CZA,hZA,uZA,dZA,mZA,pZA,fZA,yZA,EZA,QZA,xIt,GIt,bIt,wZA,DZA,SZA,FIt,RIt,cct,Bct,uBt,dBt,pBt,mBt,dct,BBt,pct,Kct,Mct,Lct,qct,bct,Nct,Pct,Oct,fBt,Zct,Vct,jct,zct,Xct,$ct,ABt,eBt,Hct,Yct,Wct,Jct,Tct,MBt,iBt,tBt,nBt,oBt,sBt,rBt,aBt,gBt,IBt,yBt,cBt,wBt,hBt,DBt,SBt,bBt,FBt,RBt,NBt,_Bt,vBt,UBt,NIt,OIt,YIt,JIt,TIt,KIt,HIt,WIt,qIt,MIt,VIt,jIt,ZIt,Act,ect,tct,ict,sct,nct,oct,LBt,KBt,PBt,OBt,WBt,ZBt,VBt]);var jBt=Object.defineProperty,zBt=(t,A)=>{for(var e in A)jBt(t,e,{get:A[e],enumerable:!0})},gS={};zBt(gS,{axial:()=>zlt,bga:()=>glt,breakoutheaders:()=>rCt,cap:()=>nlt,dfn:()=>Rlt,diode:()=>ilt,dip:()=>Alt,electrolytic:()=>KEt,hc49:()=>gCt,jst:()=>lEt,led:()=>olt,lqfp:()=>oCt,m2host:()=>sht,melf:()=>yQt,micromelf:()=>SQt,minimelf:()=>CQt,mlp:()=>hlt,ms012:()=>Hlt,ms013:()=>Jlt,msop:()=>mEt,pad:()=>ICt,pinrow:()=>_lt,platedhole:()=>eht,potentiometer:()=>YEt,pushbutton:()=>$lt,qfn:()=>Qlt,qfp:()=>Elt,quad:()=>ZU,res:()=>slt,sma:()=>GQt,smb:()=>LQt,smbf:()=>PEt,smc:()=>TQt,smf:()=>MQt,smtpad:()=>$Et,sod110:()=>QEt,sod123:()=>Wlt,sod123f:()=>OCt,sod123fl:()=>jCt,sod123w:()=>SCt,sod128:()=>nQt,sod323:()=>GCt,sod323f:()=>TCt,sod323fl:()=>kEt,sod323w:()=>DEt,sod523:()=>ECt,sod723:()=>AQt,sod80:()=>yCt,sod882:()=>LCt,sod882d:()=>uQt,sod923:()=>MCt,soic:()=>clt,solderjumper:()=>MEt,son:()=>NEt,sop8:()=>pCt,sot:()=>iht,sot223:()=>OQt,sot23:()=>Dlt,sot23w:()=>eEt,sot25:()=>klt,sot323:()=>VEt,sot363:()=>mlt,sot457:()=>UEt,sot563:()=>Ult,sot723:()=>Klt,sot89:()=>IQt,ssop:()=>dlt,stampboard:()=>eCt,stampreceiver:()=>nCt,to220:()=>BQt,to92:()=>CCt,to92s:()=>rEt,tssop:()=>flt,vssop:()=>pEt});var Cn=(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"}),Ro=(t,A,e,i,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:ya(i),outer_diameter:ya(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),_ZA=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 yx(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var n5=ei([J(),jA()]).transform(t=>yx(t)),XBt=t=>TA({fn:J(),num_pins:jA().optional().default(6),wide:Be().optional(),narrow:Be().optional(),w:n5.optional(),p:n5.default(t.p??"2.54mm"),id:n5.optional(),od:n5.optional()}).transform(A=>(!A.id&&!A.od?Math.abs(A.p-1.27)<.01?(A.id=yx("0.55mm"),A.od=yx("0.95mm")):(A.id=yx("1.0mm"),A.od=yx("1.5mm")):A.id?A.od||(A.od=A.id*(1.5/1)):A.id=A.od*(1/1.5),A.w||(A.wide?A.w=yx("600mil"):A.narrow?A.w=yx("300mil"):A.w=yx(t.w??"300mil")),A)),$Bt=XBt({}),vZA=(t,A,e,i)=>{const n=t/2,o=A<=n,s=n-1,r=i,a=r*s;return o?{x:-e/2,y:a/2-(A-1)*r}:{x:e/2,y:-a/2+(A-n-1)*r}},Alt=t=>{const A=$Bt.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:I,y:c}=vZA(A.num_pins,g+1,A.w,A.p??2.54);e.push(Ro(g+1,I,c,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},..._ZA.map(({x:g,y:I})=>({x:g*n/6,y:I*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 I=g<A.num_pins/2,c=.6,{y:B}=vZA(A.num_pins,g+1,A.w,A.p??2.54),l=I?-A.w/2-A.od/2-c:A.w/2+A.od/2+c,C=B;r.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${g+1}`,layer:"top",pcb_component_id:`pin_${g+1}`,text:`{pin${g+1}}`,anchor_position:{x:l,y:C},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Cn(0,o/2+.5,.4);return{circuitJson:[...e,s,a,...r],parameters:A}},xi=(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()]}),UZA=[{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}],elt=Object.fromEntries(UZA.map(t=>[t.metric,t])),tlt=Object.fromEntries(UZA.map(t=>[t.imperial,t]));TA({tht:Be(),p:ie.optional(),pw:ie.optional(),ph:ie.optional(),metric:wt.optional(),imperial:wt.optional(),w:ie.optional(),h:ie.optional(),textbottom:Be().optional()});var o5=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=WU(r)),typeof a=="string"&&(a=WU(a)),typeof e=="string"&&(e=WU(e)),typeof i=="string"&&(i=WU(i)),typeof n=="string"&&(n=WU(n)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let I;if(o&&(I=elt[o]),s&&(I=tlt[s]),I&&(r=I.w_mm_min,a=I.h_mm_min,e=I.p_mm_min,i=I.pw_mm_min,n=I.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 c={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:""},B=g?-n/2-.9:n/2+.9,l=Cn(0,B,.2);return A?[Ro(1,-e/2,0,i,i*1/.8),Ro(2,e/2,0,i,i*1/.8),c,l]:[xi(["1","left"],-e/2,0,i,n),xi(["2","right"],e/2,0,i,n),c,l]},ilt=t=>({circuitJson:o5(t),parameters:t}),nlt=t=>({circuitJson:o5(t),parameters:t}),olt=t=>({circuitJson:o5(t),parameters:t}),slt=t=>({circuitJson:o5(t),parameters:t}),LZA=(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()]}),HZA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",YZA=J().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A),y:parseFloat(e)}}).pipe(TA({x:jA(),y:jA()})),rlt=J().or(be(vI())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(A=>{const e=Number(A);return isNaN(e)?A:e}))).pipe(be(J().or(jA()))),alt=TA({fn:J(),num_pins:jA().optional().default(64),grid:YZA.optional(),p:wt.default("0.8mm"),w:ie.optional(),h:ie.optional(),ball:ie.optional().describe("ball diameter"),pad:ie.optional().describe("pad width/height"),circularpads:Be().optional().describe("use circular pads"),tlorigin:Be().optional(),blorigin:Be().optional(),trorigin:Be().optional(),brorigin:Be().optional(),missing:rlt.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=HZA.indexOf(n[1]),s=Number.parseInt(n[2])-1;return o*t.grid.x+s+1})),{...t,origin:A}}),glt=t=>{const A=alt.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 I=[],c=(g??[]).filter(w=>typeof w=="number"),B=i.x*i.y-e;if(g.length===0&&B>0&&(Math.sqrt(B)%1===0?g.push("center"):B===1&&g.push("topleft")),g?.includes("center")){const w=Math.floor(Math.sqrt(B)),S=Math.floor((i.x-w)/2),D=Math.floor((i.y-w)/2);for(let x=D;x<D+w;x++)for(let F=S;F<S+w;F++)c.push(x*i.x+F+1)}g?.includes("topleft")&&c.push(1);const l=new Set(c);let C=0;for(let w=0;w<i.y;w++)for(let S=0;S<i.x;S++){const D=(S-(i.x-1)/2)*n,x=(w-(i.y-1)/2)*n;let F=S,k=w;switch(A.origin){case"bl":F=S,k=i.y-1-w;break;case"br":F=i.x-1-S,k=i.y-1-w;break;case"tr":F=i.x-1-S,k=w;break}let v=k*i.x+F+1;if(l.has(v)){C++;continue}v-=C;const M=[v,`${HZA[k]}${F+1}`];I.push(A.circularpads?LZA(M,{x:D,y:x,radius:a/2}):xi(M,D,x,a,a))}const Q=Cn(0,i.y*n/2,.2),E=n/6;let h;const u=i.x*n/2,d=i.y*n/2;switch(A.origin){case"bl":h=[{x:-u,y:-d},{x:-u,y:-d-E},{x:-u-E,y:-d},{x:-u,y:-d}];break;case"br":h=[{x:u,y:-d},{x:u,y:-d-E},{x:u+E,y:-d},{x:u,y:-d}];break;case"tr":h=[{x:u,y:d},{x:u,y:d+E},{x:u+E,y:d},{x:u,y:d}];break;default:h=[{x:-u,y:d},{x:-u,y:d+E},{x:-u-E,y:d},{x:-u,y:d}];break}const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:h,stroke_width:.05};return{circuitJson:[...I,Q,f],parameters:A}},s5=(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()]}),mm=t=>TA({fn:J(),num_pins:jA().optional().default(8),w:ie.default(ie.parse(t.w??"5.3mm")),p:ie.default(ie.parse(t.p??"1.27mm")),pw:ie.default(ie.parse(t.pw??"0.6mm")),pl:ie.default(ie.parse(t.pl??"1.0mm")),legsoutside:Be().optional().default(t.legsoutside??!1),pillpads:Be().optional().default(t.pillpads??!1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=ie.parse("0.6mm"),A.pl=ie.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),Ilt=mm({}),ClA=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,I=n,c=I*g,B=s?o/2:-o/2;return a?{x:-i/2-B,y:c/2-(e-1)*I}:{x:i/2+B,y:-c/2+(e-r-1)*I}},clt=t=>{const A=Ilt.parse(t);return{circuitJson:IS(A),parameters:A}},IS=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=ClA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push(s5(r+1,a,g,t.pl,t.pw)):A.push(xi(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=Cn(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:.1,route:[{x:-i/2,y:-n/2},{x:-i/2,y:n/2},..._ZA.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]},JZA=lt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),Blt=({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},QlA=TA({fn:J(),cc:Be().default(!0).optional(),ccw:Be().default(!0).optional(),startingpin:J().or(be(JZA)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(be(JZA)).optional(),num_pins:jA().optional().default(64),w:ie.optional(),h:ie.optional(),p:ie.default(ie.parse("0.5mm")),pw:ie.optional(),pl:ie.optional(),thermalpad:ei([FA(!0),YZA]).optional(),legsoutside:Be().default(!1)}),ElA=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},TZA=QlA.transform(ElA),llt=["left","bottom","right","top"],Clt=t=>{const{pin_count:A,pn:e,w:i,h:n,p:o,pl:s,legsoutside:r}=t,a=A/4,g=llt[Math.floor((e-1)/a)],I=(e-1)%a,c=o*(a-1),B=o*(a-1),l=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-l,y:B/2-I*o,o:"vert"};case"bottom":return{x:-c/2+I*o,y:-n/2-l,o:"horz"};case"right":return{x:i/2+l,y:-B/2+I*o,o:"vert"};case"top":return{x:c/2-I*o,y:n/2+l,o:"horz"};default:throw new Error("Invalid pin number")}},ZU=t=>{const A=TZA.parse(t),e=[],i=Blt(A),n=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:I}=Clt({pin_count:A.num_pins,pn:r+1,w:A.w,h:A.h,p:A.p??.5,pl:A.pl,legsoutside:A.legsoutside});let c=A.pw,B=A.pl;I==="vert"&&([c,B]=[B,c]);const l=i[r+1];e.push(xi(l,a,g,c,B))}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(xi(["thermalpad"],0,0,r,a))}else e.push(xi(["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 I=A.w/2*a,c=A.h/2*g;let B="none",l=I,C=c;const Q=A.pw*2;i[1]===1&&r==="top-left"?B="in1":i[n*4]===1&&r==="top-left"||i[n*3+1]===1&&r==="top-right"?B="in2":i[n*3]===1&&r==="top-right"||i[n]===1&&r==="bottom-left"?B="in1":i[n+1]===1&&r==="bottom-left"?B="in2":i[n*2]===1&&r==="bottom-right"?B="in1":i[n*2+1]===1&&r==="bottom-right"&&(B="in2");const E=B==="in1"?1:-1;if(A.legsoutside){const h=B==="in1"?A.pl/2:A.pw/2,u=B==="in1"?A.pw/2:A.pl/2;l+=h*a*E,C-=u*g*E}(B==="none"||A.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:I-Q*a,y:c},{x:I,y:c},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&!A.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:I-Q*a,y:c},{x:I-Q*a/2,y:c}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:I,y:c-Q*g/2},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:l-.2*-a,y:C+.2*E},{x:l,y:C},{x:l+.2*E*-a,y:C+.2},{x:l-.2*-a,y:C+.2*E}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Cn(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...o,s],parameters:A}};QlA.extend({}).transform(ElA);var Qlt=t=>(t.legsoutside=!1,ZU(t)),Elt=t=>{t.legsoutside=!0;const A=TZA.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 ZU(t)};QlA.extend({}).transform(ElA);var hlt=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),ZU(t)),ult=mm({w:"3.9mm",p:"1.27mm"}),dlt=t=>{const A=ult.parse(t);return{circuitJson:IS(A),parameters:A}},plt=mm({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),flt=t=>{const A=plt.parse(t);return{circuitJson:IS(A),parameters:A}},ylt=mm({}),mlt=t=>{const A=ylt.parse({fn:"sot363",num_pins:6,w:1.94,p:.65,pw:.3,pl:.7,legoutside:!0});return{circuitJson:IS(A),parameters:A}},KZA=TA({fn:J(),num_pins:jA().default(3),w:J().default("1.92mm"),h:J().default("2.74mm"),pl:J().default("0.8mm"),pw:J().default("0.764mm"),p:J().default("0.95mm"),string:J().optional()}),wlt=mm({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Dlt=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const n=wlt.parse({...t,num_pins:e});return{circuitJson:IS(n),parameters:n}}const i=KZA.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:blt(i),parameters:i};if(i.num_pins===5)return{circuitJson:PZA(i),parameters:i};throw new Error("Invalid number of pins")},Slt=t=>{const{pn:A}=t;return A===1?{x:-1.7,y:0}:A===2?{x:1.7,y:-.95}:{x:1.7,y:.95}},blt=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:n,y:o}=Slt({num_pins:t.num_pins,pn:i+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});A.push(xi(i+1,n,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Cn(0,Number.parseInt(t.h),.3);return[...A,e]},qZA=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")},PZA=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:l}=qZA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(xi(c,B,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),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=Cn(0,i+.3,.3),r=qZA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,n,o,I]},xlt=KZA.extend({}),klt=t=>{const A=xlt.parse({...t,num_pins:5});return{circuitJson:PZA(A),parameters:A}},Glt=[{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}],Flt=mm({}),Rlt=t=>{const A=Flt.parse(t),e=[];for(let c=0;c<A.num_pins;c++){const{x:B,y:l}=ClA({num_pins:A.num_pins,pn:c+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(xi(c+1,B,l,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 c of Glt){const{dx:B,dy:l}=c;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:B*n/2-B*A.p,y:l*o/2},{x:B*n/2,y:l*o/2},{x:B*n/2,y:l*o/2-l*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 I=Cn(0,o/2+.4,o/12);return{circuitJson:[...e,I,...s],parameters:A}},r5=(t,A,e,i,n,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:A,y:e,hole_diameter:ya(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:ya(n),rect_pad_height:ya(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),hlA=({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 Nlt({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 Mlt=TA({fn:J(),num_pins:jA().optional().default(6),rows:ei([J(),jA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:ie.default("0.1in").describe("pitch"),id:ie.default("1.0mm").describe("inner diameter"),od:ie.default("1.5mm").describe("outer diameter"),male:Be().optional().describe("for male pin headers"),female:Be().optional().describe("for female pin headers"),pinlabeltextalignleft:Be().optional().default(!1),pinlabeltextaligncenter:Be().optional().default(!1),pinlabeltextalignright:Be().optional().default(!1),pinlabelverticallyinverted:Be().optional().default(!1),pinlabelorthogonal:Be().optional().default(!1),nosquareplating:Be().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Be().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Be().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Be().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=Nlt(t);return{...t,pinlabelAnchorSide:A,male:t.male??!t.female,female:t.female??!1}}).superRefine((t,A)=>{t.male&&t.female&&A.addIssue({code:Wt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),_lt=t=>{const A=Mlt.parse(t),{p:e,id:i,od:n,rows:o,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:I,pinlabeltextalignright:c,nopinlabels:B,doublesidedpinlabel:l,bottomsidepinlabel:C}=A;let Q="center";I?Q="left":c&&(Q="right");const E=[],h=Math.ceil(s/o),u=-e,d=({xoff:x,yoff:F,od:k,anchorSide:v})=>{let M=0,L=0;const K=k*.75;switch(v){case"right":M=K;break;case"top":L=K;break;case"bottom":L=-K;break;case"left":M=-K;break}return{anchor_x:x+M,anchor_y:F+L}},f=(x,F,k)=>{x===1&&!A.nosquareplating?E.push(r5(x,F,k,i,n,n)):E.push(Ro(x,F,k,i,n));const{anchor_x:v,anchor_y:M}=d({xoff:F,yoff:k,od:n,anchorSide:r});B||(C?E.push(hlA({fs:n/5,pn:x,anchor_x:v,anchor_y:M,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):E.push(hlA({fs:n/5,pn:x,anchor_x:v,anchor_y:M,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),l&&E.push(hlA({fs:n/5,pn:x,anchor_x:v,anchor_y:M,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},w=new Set,S=o>2&&h>2;if(o===1){const x=-((s-1)/2)*e;for(let F=0;F<s;F++){const k=F+1,v=x+F*e,M=`${v},0`;if(w.has(M))throw new Error(`Overlap at ${M}`);w.add(M),f(k,v,0)}}else if(S){const x=-((h-1)/2)*e;let F=1;for(let k=0;k<o&&F<=s;k++)for(let v=0;v<h&&F<=s;v++){const M=x+v*e,L=k*u,K=`${M},${L}`;if(w.has(K))throw new Error(`Overlap at ${K}`);w.add(K),f(F++,M,L)}}else{const x=-((h-1)/2)*e;let F=1,k=0,v=o-1,M=0,L=h-1;for(;F<=s&&k<=v&&M<=L;){for(let K=k;K<=v&&F<=s;K++){const Y=x+M*e,W=K*u,Z=`${Y},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,Y,W)}M++;for(let K=M;K<=L&&F<=s;K++){const Y=x+K*e,W=v*u,Z=`${Y},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,Y,W)}if(v--,M<=L){for(let K=v;K>=k&&F<=s;K--){const Y=x+L*e,W=K*u,Z=`${Y},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,Y,W)}L--}if(k<=v){for(let K=L;K>=M&&F<=s;K--){const Y=x+K*e,W=k*u,Z=`${Y},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,Y,W)}k++}}if(F-1<s)throw new Error(`Missing pins: assigned ${F-1}, expected ${s}`)}const D=Cn(0,e,.5);return{circuitJson:[...E,D],parameters:A}},vlt=mm({}),Ult=t=>{const A=vlt.parse({fn:"sot563",num_pins:6,w:1.94,p:.5,pw:.3,pl:.67,legoutside:!0});return{circuitJson:IS(A),parameters:A}},Llt=mm({p:"1.27mm",w:"3.9mm",legsoutside:!0}),Hlt=t=>{const A=Llt.parse({...t,num_pins:8});return{circuitJson:IS(A),parameters:A}},Ylt=mm({p:"1.27mm",w:"7.5mm",legsoutside:!0}),Jlt=t=>{const A=Ylt.parse({...t,num_pins:16});return{circuitJson:IS(A),parameters:A}},Tlt=TA({fn:J(),num_pins:FA(3).default(3),w:J().default("1.2mm"),h:J().default("1.2mm"),pl:J().default("0.3mm"),pw:J().default("0.32mm")}),Klt=t=>{const A=Tlt.parse(t),e=Plt(A),i=Cn(.4,ie.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},qlt=t=>{const{pn:A}=t;return A===1?{x:0,y:0}:A===2?{x:1,y:-.4}:{x:1,y:.4}},Plt=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:n}=qlt({num_pins:t.num_pins,pn:e+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});A.push(xi(e+1,i,n,Number.parseFloat(t.pl),e!==0?Number.parseFloat(t.pw):.42))}return A},Olt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("2.36mm"),h:J().default("1.22mm"),pl:J().default("0.9mm"),pw:J().default("0.9mm"),p:J().default("4.19mm")}),Wlt=t=>{const A=Olt.parse(t),e=Cn(0,ie.parse(A.h)/4+.4,.3);return{circuitJson:Vlt(A).concat(e),parameters:A}},Zlt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Vlt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Zlt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},jlt=TA({fn:J(),p:ie.optional().default("2.54mm"),id:ie.optional().default("0.7mm"),od:ie.optional().default("1mm")}),zlt=t=>{const A=jlt.parse(t),{p:e,id:i,od:n}=A,o=[Ro(1,-e/2,0,i,n),Ro(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=Cn(0,e/4,.5);return{circuitJson:[...o,s,r],parameters:A}},a5=(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}),Xlt=TA({fn:FA("pushbutton"),w:ie.default(4.5),h:ie.default(6.5),id:ie.default(1),od:ie.default(1.2)}),$lt=t=>{const A=Xlt.parse(t),e=A.w,i=A.h,n=A.id,o=[Ro(1,-e/2,i/2,n,n*1.5),Ro(2,-e/2,-i/2,n,n*1.5),Ro(3,e/2,-i/2,n,n*1.5),Ro(4,e/2,i/2,n,n*1.5)],s=[a5([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),a5([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),a5([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),a5([{x:e/2,y:0},{x:e/5,y:0}])],r=Cn(0,i/2+.4,.5);return{circuitJson:[...o,...s,r],parameters:A}},OZA=TA({fn:J(),w:ie.default("22.58mm"),h:ie.optional(),left:ie.optional().default(20),right:ie.optional().default(20),top:ie.optional().default(2),bottom:ie.optional().default(2),p:ie.default(ie.parse("2.54mm")),pw:ie.default(ie.parse("1.6mm")),pl:ie.default(ie.parse("2.4mm")),innerhole:Be().default(!1),innerholeedgedistance:ie.default(ie.parse("1.61mm")),silkscreenlabels:Be().default(!1),silkscreenlabelmargin:ie.default(ie.parse("0.1mm"))}),ACt=t=>{const A=OZA.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},g5=(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},eCt=t=>{const A=OZA.parse(t),e=A.h??ACt(A),i=[],n=[],o=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),c=`pin${g}`.length*.7/2;if(A.right){const Q=-((A.right-1)/2)*A.p;for(let E=0;E<A.right;E++){if(E===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=g5(A.w/2-A.pl*1.4,Q+E*A.p,"right")),i.push(xi(E+1+A.left+(A.bottom??0),A.w/2-A.pl/2,Q+E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+1+A.left+(A.bottom??0),u=`pin${h}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl-(c+A.silkscreenlabelmargin),y:Q+E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(Ro(E+1+A.left+(A.bottom??0)+g,A.w/2,Q+E*A.p,r,a)),n.push(Ro(E+1+A.left+(A.bottom??0)+g*2,A.w/2-A.innerholeedgedistance,Q+E*A.p,r,a)))}}if(A.left){const Q=(A.left-1)/2*A.p;for(let E=0;E<A.left;E++){if(E===0&&!A.silkscreenlabels&&(s=g5(-A.w/2+A.pl*1.4,Q-E*A.p,"left")),i.push(xi(E+1,-A.w/2+A.pl/2,Q-E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+1,u=`pin${h}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl+(c+A.silkscreenlabelmargin),y:Q-E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(Ro(E+1+g,-A.w/2,Q-E*A.p,r,a)),n.push(Ro(E+1+g*2,-A.w/2+A.innerholeedgedistance,Q-E*A.p,r,a)))}}if(A.top){const Q=(A.top-1)/2*A.p;for(let E=0;E<A.top;E++){if(E===0&&!A.left&&!A.bottom&&!A.right&&!A.silkscreenlabels&&(s=g5(Q-E*A.p,e/2-A.pl*1.4,"top")),i.push(xi(E+1+A.left+A.right+(A.bottom??0),Q-E*A.p,e/2-A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+1+A.left+A.right+(A.bottom??0),u=`pin${h}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q-E*A.p,y:e/2-A.pl-(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(n.push(Ro(E+1+A.left+A.right+(A.bottom??0)+g,Q-E*A.p,e/2,r,a)),n.push(Ro(E+1+A.left+A.right+(A.bottom??0)+g*2,Q-E*A.p,e/2-A.innerholeedgedistance,r,a)))}}if(A.bottom){const Q=-((A.bottom-1)/2)*A.p;for(let E=0;E<A.bottom;E++){if(E===0&&!A.left&&!A.silkscreenlabels&&(s=g5(Q+E*A.p,-e/2+A.pl*1.4,"bottom")),i.push(xi(E+1+A.left,Q+E*A.p,-e/2+A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+1+A.left,u=`pin${h}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q+E*A.p,y:-e/2+A.pl+(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(n.push(Ro(E+1+A.left+g,Q+E*A.p,-e/2,r,a)),n.push(Ro(E+1+A.left+g*2,Q+E*A.p,-e/2+A.innerholeedgedistance,r,a)))}}const B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2,y:e/2},{x:A.w/2,y:e/2},{x:A.w/2,y:-e/2},{x:-A.w/2,y:-e/2},{x:-A.w/2,y:e/2}],stroke_width:.1,layer:"top"},C=Cn(0,e/1.8,e/25);return{circuitJson:[...i,...n,...o,l,...A.silkscreenlabels?[]:[B],C],parameters:A}},WZA=TA({fn:J(),w:ie.default("22.58mm"),h:ie.optional(),left:ie.optional().default(20),right:ie.optional().default(20),top:ie.optional().default(2),bottom:ie.optional().default(2),p:ie.default(ie.parse("2.54mm")),pw:ie.default(ie.parse("1.6mm")),pl:ie.default(ie.parse("3.2mm")),innerhole:Be().default(!1),innerholeedgedistance:ie.default(ie.parse("1.61mm"))}),tCt=t=>{const A=WZA.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},iCt=(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]},nCt=t=>{const A=WZA.parse(t),e=A.h??tCt(A),i=[],n=[],o=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],I=1;if(A.left){const C=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++)Q===0&&(g=iCt(-A.w/2-A.pl/2,C-Q*A.p,"left")),i.push(xi(I,-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_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:C-Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Ro(I+a,-A.w/2+A.innerholeedgedistance,C-Q*A.p,s,r))}if(A.bottom){const C=(A.bottom-1)/2*A.p;for(let Q=A.bottom-1;Q>=0;Q--)i.push(xi(I,C-Q*A.p,-e/2+A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C-Q*A.p,y:-e/2+A.pl/2-3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Ro(I+a,C-Q*A.p,-e/2+A.innerholeedgedistance,s,r))}if(A.right){const C=-((A.right-1)/2)*A.p;for(let Q=0;Q<A.right;Q++)i.push(xi(I,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_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:C+Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Ro(I+a,A.w/2-A.innerholeedgedistance,C+Q*A.p,s,r))}if(A.top){const C=-((A.top-1)/2)*A.p;for(let Q=A.top-1;Q>=0;Q--)i.push(xi(I,C+Q*A.p,e/2-A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C+Q*A.p,y:e/2-A.pl/2+3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Ro(I+a,C+Q*A.p,e/2-A.innerholeedgedistance,s,r))}const c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:g,stroke_width:.1},B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:e/2+A.pl/3}],stroke_width:.1,layer:"top"},l=Cn(0,e/1.8,e/25);return{circuitJson:[...o,...i,...n,B,c,l],parameters:A}},oCt=t=>(t.legsoutside=!0,ZU(t)),ZZA=TA({fn:J(),w:ie.default("10mm"),h:ie.optional(),left:ie.optional().default(20),right:ie.optional().default(20),top:ie.optional().default(0),bottom:ie.optional().default(0),p:ie.default(ie.parse("2.54mm")),id:ie.optional().default(ie.parse("1mm")),od:ie.optional().default(ie.parse("1.5mm"))}),sCt=t=>{const A=ZZA.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},I5=(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]},rCt=t=>{const A=ZZA.parse(t),e=A.h??sCt(A),i=[],n=A.id,o=A.od;let s=[];if(A.right){const I=-((A.right-1)/2)*A.p;for(let c=0;c<A.right;c++)c===0&&!A.left&&!A.bottom&&(s=I5(A.w/2+o*1.4,I+c*A.p,"right")),i.push(Ro(c+1+A.left+(A.bottom??0),A.w/2,I+c*A.p,n,o))}if(A.left){const I=-((A.left-1)/2)*A.p;for(let c=0;c<A.left;c++)c===A.left-1&&(s=I5(-A.w/2-o*1.4,I+c*A.p,"left")),i.push(Ro(c+1,-A.w/2,I+c*A.p,n,o))}if(A.top){const I=-((A.top-1)/2)*A.p;for(let c=0;c<A.top;c++)c===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=I5(I+c*A.p,e/2+o*1.4,"top")),i.push(Ro(c+1+A.right+(A.bottom??0)+A.left,I+c*A.p,e/2,n,o))}if(A.bottom){const I=-((A.bottom-1)/2)*A.p;for(let c=0;c<A.bottom;c++)c===0&&!A.left&&(s=I5(I+c*A.p,-e/2-o*1.4,"bottom")),i.push(Ro(c+1+A.left,I+c*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=Cn(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},VZA=(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}}),aCt=TA({fn:J(),p:ie.optional().default("4.88mm"),id:ie.optional().default("0.6mm"),od:ie.optional().default("1.2mm"),w:ie.optional().default("5.6mm"),h:ie.optional().default("3.5mm")}),gCt=t=>{const A=aCt.parse(t),{p:e,id:i,od:n,w:o,h:s}=A,r=s/2,a=[Ro(1,-e/2,0,i,n),Ro(2,e/2,0,i,n)],g=VZA(-o/2,0,r,"left"),I=VZA(o/2,0,r,"right"),c={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},...I,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},B=Cn(0,e/4,.5);return{circuitJson:[...a,c,B],parameters:A}};TA({w:ie,h:ie});var ICt=t=>{const{w:A,h:e}=t,i=ya(A),n=ya(e);return{circuitJson:[xi(1,0,0,i,n),Cn(0,n/2+.5,.2)],parameters:t}},cCt=TA({fn:J(),num_pins:ei([FA(3),FA(2)]).default(3),p:J().default("1.27mm"),id:J().default("0.72mm"),od:J().default("0.95mm"),w:J().default("4.5mm"),h:J().default("4.5mm"),inline:Be().default(!1),string:J().optional()}),BCt=(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}}),lCt=t=>{const{p:A,id:e,od:i,h:n}=t,o=Number.parseFloat(n)/2,s=Number.parseFloat(A);return[Ro(1,-s,o-s,e,i),Ro(2,s,o-s,e,i)]},CCt=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=cCt.parse({...t,num_pins:e}),{p:n,id:o,od:s,w:r,h:a,inline:g}=i,I=Number.parseFloat(a)/2,c=Number.parseFloat(n);let B=[];if(i.num_pins===3)B=g?[Ro(1,-c,I-c,o,s),Ro(2,0,I-c,o,s),Ro(3,c,I-c,o,s)]:[Ro(1,0,I,o,s),Ro(2,-c,I-c,o,s),Ro(3,c,I-c,o,s)];else if(i.num_pins===2)B=lCt(i);else throw new Error("Invalid number of pins for TO-92");const l=Number.parseFloat(r)/2,C=BCt(0,I,l),Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...C,{x:-l,y:0},{x:l,y:0},C[0]],stroke_width:.1,pcb_silkscreen_path_id:""},E=Cn(0,I+1,.5);return{circuitJson:[...B,Q,E],parameters:i}},QCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("2.15mm"),h:J().default("1.20mm"),pl:J().default("0.5mm"),pw:J().default("0.6mm"),p:J().default("1.4mm")}),ECt=t=>{const A=QCt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:uCt(A).concat(i,e),parameters:A}},hCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},uCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=hCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},dCt=mm({}),pCt=t=>{const A=dCt.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=ClA({num_pins:A.num_pins,pn:s+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(xi(s+1,r,a,A.pl??"1.5mm",A.pw??"0.6mm"))}const i=(A.num_pins/2-1)*A.p+A.pw,n=Cn(0,i/2-.5,i/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-A.w/3,y:i/2+.2},{x:A.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...e,n,o],parameters:A}},fCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("5.0mm"),h:J().default("2.30mm"),pl:J().default("1.25mm"),pw:J().default("2mm"),p:J().default("3.75mm")}),yCt=t=>{const A=fCt.parse(t),e=Cn(0,ie.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.5,y:ie.parse(A.h)/2+.5},{x:-ie.parse(A.w)/2-.5,y:ie.parse(A.h)/2+.5},{x:-ie.parse(A.w)/2-.5,y:-ie.parse(A.h)/2-.5},{x:ie.parse(A.p)/2+.5,y:-ie.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:wCt(A).concat(i,e),parameters:A}},mCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},wCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=mCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},DCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("4.4mm"),h:J().default("2.1mm"),pl:J().default("1.2mm"),pw:J().default("1.2mm"),p:J().default("2.9mm")}),SCt=t=>{const A=DCt.parse(t),e=Cn(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:xCt(A).concat(i,e),parameters:A}},bCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},xCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=bCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},kCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("3.30mm"),h:J().default("1.80mm"),pl:J().default("0.60mm"),pw:J().default("0.45mm"),p:J().default("2.1mm")}),GCt=t=>{const A=kCt.parse(t),e=Cn(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:RCt(A).concat(i,e),parameters:A}},FCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},RCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=FCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},NCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("1.4mm"),h:J().default("0.9mm"),pl:J().default("0.35mm"),pw:J().default("0.25mm"),p:J().default("1.2mm")}),MCt=t=>{const A=NCt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.15,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.4,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.4,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2+.15,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:vCt(A).concat(i,e),parameters:A}},_Ct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},vCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=_Ct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},UCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("1.3mm"),h:J().default("0.9mm"),pl:J().default("0.4mm"),pw:J().default("0.7mm"),p:J().default("0.7mm")}),LCt=t=>{const A=UCt.parse(t),e=Cn(0,ie.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.2,y:ie.parse(A.h)/2+.2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2+.2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2-.2},{x:ie.parse(A.p)/2+.2,y:-ie.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:YCt(A).concat(i,e),parameters:A}},HCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},YCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=HCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},JCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("3,05mm"),h:J().default("1.65mm"),pl:J().default("0.6mm"),pw:J().default("0.6mm"),pad_spacing:J().default("2.2mm")}),TCt=t=>{const A=JCt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.pad_spacing)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.pad_spacing)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:qCt(A).concat(i,e),parameters:A}},KCt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},qCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=KCt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},PCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("4.4mm"),h:J().default("2.1mm"),pl:J().default("1.2mm"),pw:J().default("1.2mm"),p:J().default("2.9mm")}),OCt=t=>{const A=PCt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ZCt(A).concat(i,e),parameters:A}},WCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},ZCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=WCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},VCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("4.4mm"),h:J().default("2.1mm"),pl:J().default("0.91mm"),pw:J().default("1.22mm"),p:J().default("3.146mm")}),jCt=t=>{const A=VCt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:XCt(A).concat(i,e),parameters:A}},zCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},XCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=zCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},$Ct=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("1.80mm"),h:J().default("1.00mm"),pl:J().default("0.66mm"),pw:J().default("0.5mm"),p:J().default("0.8mm")}),AQt=t=>{const A=$Ct.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:tQt(A).concat(i,e),parameters:A}},eQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},tQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=eQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},iQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("6.2mm"),h:J().default("3.4mm"),pl:J().default("1.4mm"),pw:J().default("2.1mm"),p:J().default("4.4mm")}),nQt=t=>{const A=iQt.parse(t),e=Cn(0,ie.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:sQt(A).concat(i,e),parameters:A}},oQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},sQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=oQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},rQt=TA({fn:J(),num_pins:ei([FA(3),FA(5)]).default(3),w:J().default("4.80mm"),h:J().default("4.80mm"),pl:J().default("1.3mm"),pw:J().default("0.9mm"),p:J().default("1.5mm"),string:J().optional()}),aQt=t=>{const A=[],e=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),n=Number.parseFloat(t.w),o=Number.parseFloat(t.pl);A.push(xi(1,-n/2,e,o,i),xi(2,-n/2+(1.5-1.3)/2,0,1.5,i),xi(3,-n/2,-e,o,i));const s=Cn(0,0,.3),r=Number.parseFloat(t.w)/2-1,a=Number.parseFloat(t.h)/2,g={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r,y:a},{x:r,y:a},{x:r,y:a/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},I={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-r,y:-a},{x:r,y:-a},{x:r,y:-a/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,g,I,s]},gQt=t=>{const A=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),A.push(xi(1,-1.85,-1.5,1.5,.7),xi(2,-1.85,1.5,1.5,.7),xi(3,0,0,.8,2),xi(4,1.85,-1.5,1.5,.7),xi(5,1.85,1.5,1.5,.7));const e=Cn(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]},IQt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=rQt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:aQt(i),parameters:i};if(i.num_pins===5)return{circuitJson:gQt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},cQt=TA({fn:J(),p:ie.optional().default("5.0mm"),id:ie.optional().default("1.0mm"),od:ie.optional().default("1.9mm"),w:ie.optional().default("13mm"),h:ie.optional().default("7mm"),num_pins:jA().optional(),string:J().optional()}),BQt=t=>{const A=cQt.parse(t),{fn:e,id:i,od:n,w:o,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,I=o/2,c=s/2,B=2.5,l=o*.4,C=Math.max(B,l/(a-1)),Q=Array.from({length:a},(w,S)=>{const D=a%2===0?(S-a/2+.5)*C:(S-Math.floor(a/2))*C;return Ro(S+1,D,g,i,n)}),E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:-c},{x:I,y:-c},{x:I,y:c},{x:-I,y:c},{x:-I,y:-c}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-c+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:h},{x:I,y:h}],stroke_width:.1,pcb_silkscreen_path_id:""},d=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:h},{x:-o/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:h},{x:o/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Cn(0,s/2+.6,.5);return{circuitJson:[...Q,E,u,...d,f],parameters:{...A,p:C}}},lQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("5.40mm"),h:J().default("2.30mm"),pl:J().default("1.30mm"),pw:J().default("1.70mm"),p:J().default("3.5mm")}),CQt=t=>{const A=lQt.parse(t),e=Cn(0,ie.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:EQt(A).concat(i,e),parameters:A}},QQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},EQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=QQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},hQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("1.90mm"),h:J().default("1.33mm"),pl:J().default("0.5mm"),pw:J().default("0.7mm"),p:J().default("0.8mm")}),uQt=t=>{const A=hQt.parse(t),e=Cn(0,ie.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2+.1,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:pQt(A).concat(i,e),parameters:A}},dQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},pQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=dQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},fQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("7.0mm"),h:J().default("3.35mm"),pl:J().default("1.50mm"),pw:J().default("2.70mm"),p:J().default("4.8mm")}),yQt=t=>{const A=fQt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:wQt(A).concat(i,e),parameters:A}},mQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},wQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=mQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},DQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("3.0mm"),h:J().default("1.80mm"),pl:J().default("0.80mm"),pw:J().default("1.20mm"),p:J().default("1.6mm")}),SQt=t=>{const A=DQt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:xQt(A).concat(i,e),parameters:A}},bQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},xQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=bQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},kQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("7.10mm"),h:J().default("3.40mm"),pl:J().default("2.45mm"),pw:J().default("1.80mm"),p:J().default("4.05mm")}),GQt=t=>{const A=kQt.parse(t),e=Cn(0,ie.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.5,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.5,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:RQt(A).concat(i,e),parameters:A}},FQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},RQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=FQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},NQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("4.80mm"),h:J().default("2.10mm"),pl:J().default("1.30mm"),pw:J().default("1.40mm"),p:J().default("2.9mm")}),MQt=t=>{const A=NQt.parse(t),e=Cn(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:vQt(A).concat(i,e),parameters:A}},_Qt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},vQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=_Qt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},UQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("7.30mm"),h:J().default("4.40mm"),pl:J().default("2.50mm"),pw:J().default("2.30mm"),p:J().default("4.30mm")}),LQt=t=>{const A=UQt.parse(t),e=Cn(0,ie.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:YQt(A).concat(i,e),parameters:A}},HQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},YQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=HQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},JQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("10.70mm"),h:J().default("6.60mm"),pl:J().default("3.30mm"),pw:J().default("2.50mm"),p:J().default("6.80mm")}),TQt=t=>{const A=JQt.parse(t),e=Cn(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2-.8},{x:-ie.parse(A.w)/2-.8,y:ie.parse(A.h)/2-.8},{x:-ie.parse(A.w)/2-.8,y:-ie.parse(A.h)/2+.8},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:qQt(A).concat(i,e),parameters:A}},KQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},qQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=KQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},PQt=TA({fn:J(),num_pins:jA().default(4),w:J().default("8.50mm"),h:J().default("6.90mm"),pl:J().default("2mm"),pw:J().default("1.5mm"),p:J().default("2.30mm"),string:J().optional()}),OQt=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const n=VQt.parse({...t,num_pins:e});return{circuitJson:IS(n),parameters:n}}const i=PQt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:ZQt(i),parameters:i};if(i.num_pins===5)return{circuitJson:zQt(i),parameters:i};if(i.num_pins===6)return{circuitJson:$Qt(i),parameters:i};throw new Error("Invalid number of pins")},WQt=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}},ZQt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=WQt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),I=r===3?3.8:Number.parseFloat(t.pw);A.push(xi(r+1,a,g,Number.parseFloat(t.pl),I))}const e=Cn(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]},VQt=mm({p:"0.90mm",w:"2.8mm",legsoutside:!0}),jQt=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")},zQt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=jQt({h:Number.parseFloat(t.h),p:1.5,pn:r,w:Number.parseFloat(t.w)});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===5?(I=3.4,c=1.8):(I=1,c=2.2),A.push(xi(r,a,g,c,I))}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=Cn(0,0,.3);return[...A,n,o,s]},XQt=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")},$Qt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=XQt({h:Number.parseFloat(t.h),p:1.3,pn:r,w:8.7});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===6?(I=3.4,c=2.15):(I=.6,c=2.2),A.push(xi(r,a,g,c,I))}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=Cn(0,0,.3);return[...A,n,o,s]},AEt=TA({fn:J(),num_pins:jA().default(3),w:J().default("3.40mm"),h:J().default("3.30mm"),pl:J().default("1mm"),pw:J().default("0.7mm"),p:J().default("1.2mm"),string:J().optional()}),eEt=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=AEt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:iEt(i),parameters:i};throw new Error("Invalid number of pins")},tEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},iEt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=tEt({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(xi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Cn(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]},nEt=TA({fn:J(),num_pins:ei([FA(3),FA(2)]).default(3),p:J().default("1.27mm"),id:J().default("0.72mm"),od:J().default("0.95mm"),w:J().default("2.5mm"),h:J().default("4.2mm"),string:J().optional()}),oEt=t=>{const{p:A,id:e,od:i,w:n,h:o}=t,s=Number.parseFloat(o)/2,r=Number.parseFloat(A);return[Ro(1,-r,s-r,e,i),Ro(2,0,s-r,e,i),Ro(3,r,s-r,e,i)]},sEt=t=>{const{p:A,id:e,od:i,h:n}=t,o=Number.parseFloat(n)/2,s=Number.parseFloat(A);return[Ro(1,-s,o-s,e,i),Ro(2,s,o-s,e,i)]},rEt=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=nEt.parse({...t,num_pins:e});let n=[];if(i.num_pins===3)n=oEt(i);else if(i.num_pins===2)n=sEt(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=Cn(0,o+1,.5);return{circuitJson:[...n,r,a],parameters:i}},aEt=TA({fn:J(),p:ie.optional(),id:ie.optional(),pw:ie.optional(),pl:ie.optional(),w:ie.optional(),h:ie.optional(),sh:ei([Be(),J(),jA()]).optional().transform(t=>{if(typeof t=="string"){const A=Number(t);return Number.isNaN(A)?!0:A}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Be().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:J().optional()}),gEt={ph:{p:ie.parse("2.2mm"),id:ie.parse("0.70mm"),pw:ie.parse("1.20mm"),pl:ie.parse("1.20mm"),w:ie.parse("6mm"),h:ie.parse("5mm")},sh:{p:ie.parse("1mm"),pw:ie.parse("0.6mm"),pl:ie.parse("1.55mm"),w:ie.parse("5.8mm"),h:ie.parse("7.8mm")}};function IEt(t){return t.sh?"sh":(t.ph,"ph")}function cEt(t,A,e,i,n,o){const s=[];if(t==="ph"){const r=e/2;s.push(r5(1,-r,2,i,n,o)),s.push(r5(2,r,2,i,n,o))}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const I=r+g*e;console.log("x si",I),s.push(xi(g+1,I,-1.325,n,o))}const a=(A-1)/2*e+1.3;console.log("offset",a),s.push(xi(A+1,-a,1.22,1.2,1.8)),s.push(xi(A+2,a,1.22,1.2,1.8))}return s}function BEt(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 lEt=t=>{const A=aEt.parse(t),e=IEt(A),i=gEt[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 I=e==="sh"?4:2;if(e==="sh"){const Q=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(Q&&Q[1]){const E=parseInt(Q[1],10);Number.isNaN(E)||(I=E)}else typeof A.sh=="number"&&(I=A.sh)}const c=cEt(e,I,n,o,s,r),B=BEt(e),l=Cn(0,g/2+1,.5);return{circuitJson:[...c,B,l],parameters:{...A,p:n,id:o,pw:s,pl:r,w:a,h:g,num_pins:I,sh:e==="sh",ph:e==="ph"}}},CEt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("3.30mm"),h:J().default("1.70mm"),pl:J().default("0.80mm"),pw:J().default("1mm"),p:J().default("1.90mm")}),QEt=t=>{const A=CEt.parse(t),e=Cn(0,ie.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:hEt(A).concat(i,e),parameters:A}},EEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},hEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=EEt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},uEt=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"}}},dEt=TA({fn:J(),num_pins:ei([FA(8),FA(10)]).default(8),w:J().optional(),h:J().optional(),p:J().optional(),pl:J().optional(),pw:J().optional(),string:J().optional()}),pEt=t=>{const A=dEt.parse(t),e=uEt(A.num_pins),i=ie.parse(A.w||e.w),n=ie.parse(A.h||e.h),o=ie.parse(A.p||e.p),s=ie.parse(A.pl||e.pl),r=ie.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}=jZA(A.num_pins,u+1,i,o),w=u<g?u+1:A.num_pins-(u-g);a.push(xi(w,d,f,s,r))}const I=i,c=n,B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:c/2},{x:I/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:-c/2},{x:I/2,y:-c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=jZA(A.num_pins,1,I,o),Q={x:C.x-.8,y:C.y},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:Q.x-.4,y:Q.y},{x:Q.x-.7,y:Q.y+.3},{x:Q.x-.7,y:Q.y-.3},{x:Q.x-.4,y:Q.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Cn(0,c/2+.5,.3);return{circuitJson:[...a,B,l,h,E],parameters:A}},jZA=(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*ie.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},fEt=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"}}},yEt=TA({fn:J(),num_pins:ei([FA(8),FA(10),FA(12),FA(16)]).default(8),w:J().optional(),h:J().optional(),p:J().optional(),pl:J().optional(),pw:J().optional(),string:J().optional()}),zZA=(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*ie.parse("2mm"),y:r*i}},mEt=t=>{const A=yEt.parse(t),e=fEt(A.num_pins),i=ie.parse(A.w||e.w),n=ie.parse(A.h||e.h),o=ie.parse(A.p||e.p),s=ie.parse(A.pl||e.pl),r=ie.parse(A.pw||e.pw),a=[];for(let h=0;h<A.num_pins;h++){const{x:u,y:d}=zZA(A.num_pins,h+1,i,o);a.push(xi(h+1,u,d,s,r))}const g=i,I=n,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:I/2},{x:g/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-I/2},{x:g/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=zZA(A.num_pins,1,g,o),C={x:l.x-.8,y:l.y},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:C.x-.4,y:C.y},{x:C.x-.7,y:C.y+.3},{x:C.x-.7,y:C.y-.3},{x:C.x-.4,y:C.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},E=Cn(0,I/2+.5,.3);return{circuitJson:[...a,c,B,E,Q],parameters:A}},wEt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("3.8mm"),h:J().default("1.65mm"),pl:J().default("1.2mm"),pw:J().default("1.2mm"),pad_spacing:J().default("2.6mm")}),DEt=t=>{const A=wEt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.pad_spacing)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.pad_spacing)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bEt(A).concat(i,e),parameters:A}},SEt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},bEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=SEt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},xEt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("3.20mm"),h:J().default("1.65mm"),pl:J().default("0.8mm"),pw:J().default("0.9mm"),pad_spacing:J().default("2.1mm")}),kEt=t=>{const A=xEt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.pad_spacing)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.pad_spacing)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:FEt(A).concat(i,e),parameters:A}},GEt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},FEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=GEt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},REt=TA({fn:J(),num_pins:ei([FA(6),FA(8)]).default(8),w:J().default("3mm"),h:J().default("3mm"),p:J().default("0.5mm"),pl:J().default("0.52mm"),pw:J().default("0.35mm"),epw:J().default("1.40mm"),eph:J().default("1.60mm"),string:J().optional(),ep:Be().default(!1)}),NEt=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=REt.parse({...t,num_pins:e}),n=ie.parse(i.w),o=ie.parse(i.h),s=ie.parse(i.p),r=ie.parse(i.pl),a=ie.parse(i.pw),g=ie.parse(i.epw),I=ie.parse(i.eph),c=[];for(let f=0;f<i.num_pins;f++){const{x:w,y:S}=XZA(i.num_pins,f+1,n,s);c.push(xi(f+1,w,S,r,a))}i.ep&&c.push(xi(i.num_pins+1,0,0,g,I));const B=n,l=o,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:l/2},{x:B/2,y:l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:-l/2},{x:B/2,y:-l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},E=XZA(i.num_pins,1,B,s),h={x:E.x-.4,y:E.y},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:h.x-.4,y:h.y},{x:h.x-.7,y:h.y+.3},{x:h.x-.7,y:h.y-.3},{x:h.x-.4,y:h.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Cn(0,l/2+.5,.3);return{circuitJson:[...c,C,Q,d,u],parameters:i}},XZA=(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*ie.parse("1.4mm"),y:r*i}},MEt=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:n=1.5,ph:o=1.5}=t,s=ie.parse(i),r=ie.parse(n),a=ie.parse(o),g=Math.min(a/4,.5),I=[];for(let f=0;f<A;f++)I.push(xi(f+1,f*s,0,r,a));let c=[];if(e){const f=e.split("").map(Number);if(f.length>1)for(let w=0;w<f.length-1;w++){const S=f[w],D=f[w+1];if(typeof S=="number"&&typeof D=="number"&&!isNaN(S)&&!isNaN(D)){const x=(S-1)*s,F=(D-1)*s,k=Math.sign(F-x),v=x+k*(r/2),M=F-k*(r/2);c.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${S}}`,x:v,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${D}}`,x:M,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const B=(A-1)*s+r+.7,l=a+1,C=(A-1)*s/2,Q=0,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:C-B/2,y:Q-l/2},{x:C+B/2,y:Q-l/2},{x:C+B/2,y:Q+l/2},{x:C-B/2,y:Q+l/2},{x:C-B/2,y:Q-l/2}],stroke_width:.15},u=Q+l/2+.6,d=Cn(C,u,.4);return{circuitJson:[...I,...c,E,d],parameters:t}},$ZA={fn:FA("sot457"),num_pins:FA(6).default(6),pillh:J().default("0.45mm"),pillw:J().default("1.45mm"),pl:J(),pw:J(),p:J(),wave:Be().optional(),reflow:Be().optional()},_Et=TA({...$ZA,h:J().default("2.5mm"),w:J().default("2.7mm"),pl:J().default("0.8mm"),pw:J().default("0.55mm"),p:J().default("0.95mm")}),vEt=TA({...$ZA,h:J().default("3mm"),w:J().default("4mm"),pillr:J().default("0.225mm"),pl:J().default("1.45mm"),pw:J().default("1.5mm"),p:J().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)})),cS=t=>Number.parseFloat(t.replace("mm","")),AVA=({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},eVA=t=>{const A=[],e=cS(t.p),i=cS(t.pl),n=cS(t.pw),o=cS(t.w),s=cS(t.h);if(t.wave){const C={1:({padWidth:Q,padHeight:E})=>xi(1,-e,e,E,Q),2:({padWidth:Q,padHeight:E})=>xi(2,-e,-e,E,Q),3:({padWidth:Q,padHeight:E})=>s5(3,-e,0,cS(t.pillw),cS(t.pillh)),4:({padWidth:Q,padHeight:E})=>s5(4,e,0,cS(t.pillw),cS(t.pillh)),5:({padWidth:Q,padHeight:E})=>xi(5,e,e,E,Q),6:({padWidth:Q,padHeight:E})=>xi(6,e,-e,E,Q)};for(let Q=1;Q<=t.num_pins;Q++){const E=C[Q];E&&A.push(E({padWidth:i,padHeight:n}))}}else for(let C=1;C<=t.num_pins;C++){const{x:Q,y:E}=AVA({pitch:e,width:o,pinNumber:C});A.push(xi(C,Q,E,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=Cn(0,s+.5,.3),I=AVA({pitch:e,width:o,pinNumber:1}),c=t.wave?1:.5,B=t.wave?.7:.3;I.x-=t.wave?n:n*1.7;const l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:I.x+c/2,y:I.y},{x:I.x-c/2,y:I.y+B/2},{x:I.x-c/2,y:I.y-B/2},{x:I.x+c/2,y:I.y}],stroke_width:.05};return[g,r,a,l,...A]},UEt=t=>{if(t.wave){const e=vEt.parse({...t,fn:"sot457"});return{circuitJson:eVA(e),parameters:e}}const A=_Et.parse(t);return{circuitJson:eVA(A),parameters:A}},LEt=TA({fn:J(),num_pins:ei([FA(3),FA(2)]).default(3),p:J().default("3.8mm"),id:J().default("1.25mm"),od:J().default("2.35mm"),ca:J().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:J().default("5.35mm"),h:J().default("4mm"),string:J().optional()}),HEt=t=>{const{p:A,id:e,od:i,h:n,ca:o}=t,s=Number.parseFloat(n),r=Number.parseFloat(o);return[Ro(1,0,r/4+.3,e,i),Ro(2,s,0,e,i),Ro(3,0,-r/4-.3,e,i)]},YEt=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=LEt.parse({...t,num_pins:e});let n=[];i.num_pins===3&&(n=HEt(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:""},I=Number.parseFloat(i.w)/2,c=Cn(I,o+1,.5);return{circuitJson:[...n,a,g,c],parameters:i}},JEt=TA({fn:J(),p:ie.optional().default("7.5mm"),id:ie.optional().default("1mm"),od:ie.optional().default("2mm"),d:ie.optional().default("10.5mm")}),TEt=(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,I=A+Math.sin(a)*e;g<t-i&&I>=A-n/2&&I<=A+n/2||o.push({x:g,y:I})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-n/2&&I<=A+n/2||s.push({x:g,y:I})}return{topArc:o,bottomArc:s}},KEt=t=>{const A=JEt.parse(t),{p:e,id:i,od:n,d:o}=A,s=[Ro(1,-e/2,0,i,n),Ro(2,e/2,0,i,n)],{topArc:r,bottomArc:a}=TEt(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:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},B=-(o/2+.5),l=n/2+1.5,C=.5,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B-C,y:l},{x:B+C,y:l}],stroke_width:.1,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B,y:l-C},{x:B,y:l+C}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Cn(0,o/2+1,.5);return{circuitJson:[...s,g,I,c,Q,E,h],parameters:A}},qEt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("6.5mm"),h:J().default("3mm"),pl:J().default("1.75mm"),pw:J().default("2.40mm"),p:J().default("4.75mm")}),PEt=t=>{const A=qEt.parse(t),e=Cn(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.3,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.3,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:WEt(A).concat(i,e),parameters:A}},OEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},WEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=OEt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ZEt=TA({fn:J(),num_pins:jA().default(3),w:J().default("2.45mm"),h:J().default("2.40mm"),pl:J().default("0.45mm"),pw:J().default("0.70mm"),p:J().default("1mm"),string:J().optional()}),VEt=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=ZEt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:zEt(i),parameters:i};throw new Error("Invalid number of pins")},jEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},zEt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=jEt({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(xi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Cn(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]},XEt=TA({fn:J(),circle:Be().optional(),rect:Be().optional(),square:Be().optional(),pill:Be().optional(),d:ie.optional(),pd:ie.optional(),diameter:ie.optional(),r:ie.optional(),pr:ie.optional(),radius:ie.optional(),w:ie.optional(),pw:ie.optional(),width:ie.optional(),h:ie.optional(),ph:ie.optional(),height:ie.optional(),s:ie.optional(),size:ie.optional(),string:J().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=ya(t.r):t.pr!==void 0?e=ya(t.pr):t.radius!==void 0?e=ya(t.radius):t.d!==void 0?e=ya(t.d)/2:t.pd!==void 0?e=ya(t.pd)/2:t.diameter!==void 0?e=ya(t.diameter)/2:e=ya("1mm")/2:(t.w!==void 0?i=ya(t.w):t.pw!==void 0?i=ya(t.pw):t.width!==void 0?i=ya(t.width):t.s!==void 0?i=ya(t.s):t.size!==void 0?i=ya(t.size):i=ya("1mm"),t.h!==void 0?n=ya(t.h):t.ph!==void 0?n=ya(t.ph):t.height!==void 0?n=ya(t.height):A==="square"||A==="rect"?n=i:n=ya("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:n}}),$Et=t=>{const A=XEt.parse(t),{shape:e,radius:i,width:n,height:o}=A;let s,r;return e==="circle"?(s=LZA(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=s5(1,0,0,n,o),r=Math.max(n,o)/2+.5):(s=xi(1,0,0,n,o),r=o/2+.5),{circuitJson:[s,Cn(0,r,.2)],parameters:A}},Aht=TA({fn:J(),d:ie.optional(),hd:ie.optional(),r:ie.optional(),hr:ie.optional(),pd:ie.optional(),pr:ie.optional(),squarepad:Be().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=ya(t.d):t.hd!==void 0?A=ya(t.hd):t.r!==void 0?A=ya(t.r)*2:t.hr!==void 0?A=ya(t.hr)*2:A=ya("1mm");let e;return t.pd!==void 0?e=ya(t.pd):t.pr!==void 0?e=ya(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),eht=t=>{const A=Aht.parse(t),{d:e,pd:i,squarepad:n}=A;return{circuitJson:[n?r5(1,0,0,e,i,i):Ro(1,0,0,e,i),Cn(0,i/2+.5,.2)],parameters:A}},tht=TA({fn:J(),num_pins:FA(6).default(6),h:J().default("1.6mm"),pl:J().default("1mm"),pw:J().default("0.7mm"),p:J().default("0.95mm")}),iht=t=>{const A=tht.parse(t);return{circuitJson:nht(A),parameters:A}},tVA=t=>{const{p:A,h:e,pn:i}=t;if(i===1)return{x:-e/2-.5,y:A};if(i===2)return{x:-e/2-.5,y:0};if(i===3)return{x:-e/2-.5,y:-A};if(i===4)return{x:e/2+.5,y:-A};if(i===5)return{x:e/2+.5,y:0};if(i===6)return{x:e/2+.5,y:A};throw new Error("Invalid pin number")},nht=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:l}=tVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(xi(c,B,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),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=Cn(0,i+.3,.3),r=tVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,n,o,I]},oht=TA({fn:J()}),sht=t=>{const A=oht.parse(t),e=[],i=.5-.15,n=1.5,s=.5/2,r=75,a=-37/2;for(let D=0;D<r;D++){const x=D+1;if(x>=24&&x<=31)continue;const F=a-D*s,k=x%2===0,v=n+(k?.25:0),L=.5-v/2,K=xi(x,L,F,v,i);K.layer=k?"bottom":"top",e.push(K)}const g=46*.0254,I=137*.0254,c=261*.0254,B={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-I/2+n/2,y:a-c},width:I,height:g},l={x:-.5,y:a},C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-.4,y:l.y},{x:l.x-.7,y:l.y+.3},{x:l.x-.7,y:l.y-.3},{x:l.x-.4,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let Q=1/0,E=-1/0,h=1/0,u=-1/0;const d=(D,x,F=0,k=0)=>{Q=Math.min(Q,D-F/2),E=Math.max(E,D+F/2),h=Math.min(h,x-k/2),u=Math.max(u,x+k/2)};for(const D of e)d(D.x,D.y,D.width,D.height);d(B.center.x,B.center.y,B.width,B.height);for(const D of C.route)d(D.x,D.y);const f=(Q+E)/2,w=(h+u)/2,S=D=>{typeof D.x=="number"&&(D.x-=f),typeof D.y=="number"&&(D.y-=w),D.center&&(D.center.x-=f,D.center.y-=w),Array.isArray(D.route)&&(D.route=D.route.map(x=>({x:x.x-f,y:x.y-w})))};for(const D of e)S(D);return S(B),S(C),{circuitJson:[...e,B,C],parameters:A}};function rht(t){return t!=null}var aht=(t,A)=>{if(!A)return t;const e=t.filter(I=>I.type==="pcb_smtpad"||I.type==="pcb_plated_hole"||I.type==="pcb_thtpad");if(e.length===0)return t;let i=1/0,n=-1/0,o=1/0,s=-1/0;const r=(I,c,B=0,l=0)=>{const C=I-B/2,Q=I+B/2,E=c-l/2,h=c+l/2;i=Math.min(i,C),n=Math.max(n,Q),o=Math.min(o,E),s=Math.max(s,h)};for(const I of e)if(I.type==="pcb_smtpad"){const c=I.shape==="circle"?I.radius*2:I.width,B=I.shape==="circle"?I.radius*2:I.height;r(I.x,I.y,c,B)}else if(I.type==="pcb_plated_hole"){const c=I.outer_diameter??I.hole_diameter;r(I.x,I.y,c,c)}else if(I.type==="pcb_thtpad"){const c=I.diameter;r(I.x,I.y,c,c)}let a=0,g=0;switch(A){case"center":a=(i+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 I=e.find(c=>c.port_hints?.[0]==="1")||e[0];a=I.x,g=I.y;break}if(a===0&&g===0)return t;for(const I of t){if(typeof I.x=="number"&&(I.x-=a),typeof I.y=="number"&&(I.y-=g),I.center&&typeof I.center.x=="number"&&(I.center.x-=a,I.center.y-=g),I.type==="pcb_silkscreen_path")for(const c of I.route)c.x-=a,c.y-=g;I.type==="pcb_silkscreen_text"&&I.anchor_position&&(I.anchor_position.x-=a,I.anchor_position.y-=g)}return t},ght=t=>{let A=c5();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(n=>{const o=n.match(/([a-z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,r]=o;return!s||r?.includes("?")?null:{fn:s,v:r}}).filter(rht);for(const{fn:n,v:o}of i)A=A[n](o);return A.setString(t),A},Iht=()=>Object.keys(gS),c5=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&gS[A.fn])return()=>{const{circuitJson:i}=gS[A.fn](A);return aht(i,A.origin)};if(!gS[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(!gS[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>gS[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(gS):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in gS?(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};c5.string=ght,c5.getFootprintNames=Iht;var cht=c5,iVA=Symbol("Fragment");function ulA(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 ht=Symbol("Cuboid"),nVA=Symbol("Cube"),qp=Symbol("Cylinder"),oVA=Symbol("Sphere"),VU=Symbol("RoundedCuboid"),Wi=Symbol("Translate"),lQ=Symbol("Rotate"),rE=Symbol("Union"),VG=Symbol("Subtract"),rI=Symbol("Hull"),ys=Symbol("Colorize"),jU=Symbol("Polygon"),zU=Symbol("ExtrudeLinear"),Pp=Symbol("RoundedCylinder"),Yn=iVA,$A=(t,A,e)=>ulA(t,A),Ot=(t,A,e)=>ulA(t,A),VB=({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:I,notchPosition:c,notchRotation:B=[0,0,0],notchLength:l=.5,notchWidth:C=.25,chamferSize:Q=0})=>{const E=i*a,h=i-E,u=Math.min(A,e)*s,d=Math.max(A-u,A*r),f=Math.max(e-u,e*r),w=Math.min(A,e)*.12,S=I??w,D={x:0,y:e/2-S*.25,z:i},x=c??D,F=Ot(rE,{children:[Ot(rI,{children:[$A(Wi,{z:.005,children:$A(ht,{size:[d,f,.01]})}),$A(Wi,{z:E,children:$A(ht,{size:[A,e,.01]})})]}),Ot(rI,{children:[$A(Wi,{z:E,children:$A(ht,{size:[A,e,.01]})}),$A(Wi,{z:E+h,children:$A(ht,{size:[d,f,.01]})})]})]}),k=(M,L)=>$A(Wi,{offset:{x:M,y:L,z:0},children:$A(lQ,{rotation:[0,0,Math.PI/4],children:$A(ht,{size:[Q*Math.SQRT2,Q*Math.SQRT2,i*3]})})});let v=F;if(Q>0){const M=A/2,L=e/2;v=Ot(VG,{children:[F,k(M,L),k(-M,L),k(M,-L),k(-M,-L)]})}return $A(ys,{color:o,children:$A(Wi,{offset:t,children:$A(Wi,{offset:{x:0,y:0,z:n},children:g?Ot(VG,{children:[v,$A(Wi,{offset:x,children:$A(lQ,{rotation:B,children:$A(qp,{radius:S,height:C})})})]}):v})})})},Bht=t=>Array.from({length:t},(A,e)=>e);function dlA(t,A){if(t.length<2)throw new Error("Stroke must have at least two points");const e=Array.isArray(t[0])?t.map(([I,c])=>({x:I,y:c})):t,i=A/2,n=[],o=[];function s(I,c){const B=c.x-I.x,l=c.y-I.y,C=Math.sqrt(B*B+l*l);return{x:-l/C,y:B/C}}function r(I,c,B){const l={x:I.x+c.x*i*B,y:I.y+c.y*i*B};B>0?n.push(l):o.unshift(l)}const a=s(e[0],e[1]);r(e[0],a,1),r(e[0],a,-1);for(let I=1;I<e.length-1;I++){const c=e[I-1],B=e[I],l=e[I+1],C=s(c,B),Q=s(B,l),E=C.x+Q.x,h=C.y+Q.y,u=Math.sqrt(E*E+h*h);if(u/2>2*i)r(B,C,1),r(B,Q,1),r(B,C,-1),r(B,Q,-1);else{const f=1/u;r(B,{x:E*f,y:h*f},1),r(B,{x:E*f,y:h*f},-1)}}const g=s(e[e.length-2],e[e.length-1]);return r(e[e.length-1],g,1),r(e[e.length-1],g,-1),[...n,...o]}var lht=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}))},Cht=lht([{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}]),sVA=5.47,B5=.5,Qht=({x:t,y:A,z:e})=>{const i=t>0;return Ot(Yn,{children:[$A(Wi,{offset:{x:t+.25/2,y:A,z:e},children:$A(lQ,{rotation:["-90deg",0,"90deg"],children:$A(zU,{height:.25,children:$A(jU,{points:Cht.slice().reverse().map(n=>[n.x,n.y])})})})}),$A(Wi,{offset:{x:t,y:A+(i?1:-1),z:e},children:$A(lQ,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:$A(zU,{height:2,children:$A(jU,{points:dlA([[0,0],[-1,0],[-1,-1]],.25).map(n=>[n.x,n.y])})})})})]})},Eht=({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 Ot(Yn,{children:[Bht(t).map(r=>{const a=r%n,g=(Math.floor(r/n)-.5)*2;return $A(Qht,{x:g*o/2,y:a*A-(n-1)/2*A,z:sVA/2+B5})}),$A(VB,{width:s,length:n*A+.5,height:sVA-B5,heightAboveSurface:B5,center:{x:0,y:0,z:B5}})]})};function hht(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 Kn=t=>{const{thickness:A,width:e,padContactLength:i,bodyDistance:n,height:o,rotation:s}=t,r=15,a=Array.from({length:r}).map((I,c)=>c/(r-1)*n).map(I=>[I,hht(I,t)]),g=dlA(a,A);return $A(ys,{color:"#fff",children:$A(Wi,{offset:{z:0,y:0,x:0,...t.position},children:$A(lQ,{rotation:["90deg",0,s??0],children:$A(Wi,{offset:{x:0,y:0,z:-e/2},children:$A(zU,{height:e,children:$A(jU,{points:g.map(I=>[I.x,I.y])})})})})})})},uht=({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 Ot(Yn,{children:[Array.from({length:o}).map((g,I)=>$A(Kn,{position:{x:-n/2-A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:o}).map((g,I)=>$A(Kn,{rotation:Math.PI,position:{x:n/2+A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),$A(VB,{center:{x:0,y:0,z:a/2},width:n-e-1,length:s,height:1.5})]})},dht=({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 Ot(Yn,{children:[Array.from({length:o}).map((a,g)=>$A(Kn,{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)=>$A(Kn,{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})),$A(VB,{center:{x:0,y:0,z:r/2},width:n,length:n,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},plA=1,flA=.5,TM=.5,XU=.2,pht=plA-XU*2,rVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[pht,flA,TM],offset:[0,0,TM/2],color:t}),$A(ht,{size:[XU,TM,flA],offset:[plA/2-XU/2,0,TM/2],color:"#ccc"}),$A(ht,{size:[XU,TM,flA],offset:[-plA/2+XU/2,0,TM/2],color:"#ccc"})]}),ylA=1.6,fht=ylA-.3*2,l5=.3,mlA=.85,KM=.6,aVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[fht,mlA,KM],offset:[0,0,KM/2],color:t}),$A(ht,{size:[l5,mlA,KM],offset:[ylA/2-l5/2,0,KM/2],color:"#ccc"}),$A(ht,{size:[l5,mlA,KM],offset:[-ylA/2+l5/2,0,KM/2],color:"#ccc"})]}),wlA=2,DlA=1.25,qM=.55,$U=.5,yht=wlA-$U*2,gVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[yht,DlA,qM],offset:[0,0,qM/2],color:t}),$A(ht,{size:[$U,DlA,qM],offset:[wlA/2-$U/2,0,qM/2],color:"#ccc"}),$A(ht,{size:[$U,DlA,qM],offset:[-wlA/2+$U/2,0,qM/2],color:"#ccc"})]}),mht=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:n})=>{const o=t/4;A||(A=wht(t,n)),i||(i=Dht(t)),e||(e=Sht(t,n)),n||(n=A*(o+4));const s=n,r=(o-1)*A/2,a=s+2*i,g=a,I=.8,c=.15,B=(g-n)/2+.5;return Ot(Yn,{children:[Array.from({length:o}).map((l,C)=>$A(Kn,{position:{x:-g/2-.4,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:Math.PI,position:{x:g/2+.4,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),$A(VB,{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})]})},wht=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},Dht=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}},Sht=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},bht=({numberOfPins:t,pitch:A=2.54,longSidePinLength:e=6,invert:i,faceup:n,rows:o=1})=>{const a=Math.ceil(t/o),g=2.54,I=a*A,c=o>1?(o-1)*g+.63*3:.63*3,B=3,l=-((a-1)/2)*A,C=o>1?-((o-1)*g)/2:0,Q=E=>i||n?-E+2:E;return Ot(Yn,{children:[$A(ht,{color:"#222",size:[I,c,2],center:[0,C,Q(2/2)]}),Array.from({length:t},(E,h)=>{const u=Math.floor(h/a),d=h%a,f=l+d*A,w=-u*g;return Ot(Yn,{children:[!n&&$A(ys,{color:"gold",children:Ot(rI,{children:[$A(ht,{color:"gold",size:[.63,.63,B*.9],center:[f,w,Q(2*.9+2/2)]}),$A(ht,{color:"gold",size:[.63/1.8,.63/1.8,B],center:[f,w,Q(2+2/2)]})]})}),$A(ys,{color:"gold",children:Ot(rI,{children:[$A(ht,{color:"gold",size:[.63,.63,e*.9],center:[f,w,Q(-e/2*.9)]}),$A(ht,{color:"gold",size:[.63/1.8,.63/1.8,e],center:[f,w,Q(-e/2)]})]})})]})})]})},xht=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)],I=(i-1)%a,c=s*(a-1),B=s*(a-1),l=-r/2;switch(g){case"left":return{x:-n/2-l,y:B/2-I*s,o:"vert"};case"bottom":return{x:-c/2+I*s,y:-o/2-l,o:"horz"};case"right":return{x:n/2+l,y:-B/2+I*s,o:"vert"};case"top":return{x:c/2-I*s,y:o/2+l,o:"horz"};default:throw new Error("Invalid pin number")}},kht=({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},Ght=({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=kht({num_pins:t,cw:!0,ccw:!0}),I=[];for(let c=0;c<t;c++){const{x:B,y:l,o:C}=xht({pin_count:t,pn:c+1,w:A,h:e,p:r,pl:s});let Q=o,E=s;C==="vert"&&([Q,E]=[E,Q]);const h=g[c+1];I.push({pn:h,x:B,y:l,pw:Q,pl:E})}return Ot(Yn,{children:[$A(ys,{color:"grey",children:$A(ht,{center:{x:0,y:0,z:i/2},size:[A,e,i]})}),I.map((c,B)=>$A(ht,{center:{x:c.x,y:c.y,z:a/2},size:[c.pw,c.pl,a]})),n?.length!==void 0&&n?.width!==void 0&&$A(ht,{center:{x:0,y:0,z:a/2},size:[n.width,n.length,a]})]})},Fht=Ght,Rht=()=>{const a=1.1999999999999997;return Ot(Yn,{children:[$A(Kn,{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}),$A(Kn,{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}),$A(Kn,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(Kn,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(Kn,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(VB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},Nht=Rht,Mht=({fullWidth:t=2.9,fullLength:A=2.8})=>{const I=(t-1.92)/2+.3;return Ot(Yn,{children:[$A(Kn,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),$A(Kn,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),$A(Kn,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),$A(VB,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},SlA=.6,blA=.3,PM=.33,AL=.1,_ht=SlA-AL*2,IVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[_ht,blA,PM],offset:[0,0,PM/2],color:t}),$A(ht,{size:[AL,blA,PM],offset:[SlA/2-AL/2,0,PM/2],color:"#ccc"}),$A(ht,{size:[AL,blA,PM],offset:[-SlA/2+AL/2,0,PM/2],color:"#ccc"})]}),xlA=.4,klA=.2,OM=.13,eL=.07,vht=xlA-eL*2,cVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[vht,klA,OM],offset:[0,0,OM/2],color:t}),$A(ht,{size:[eL,klA,OM],offset:[xlA/2-eL/2,0,OM/2],color:"#ccc"}),$A(ht,{size:[eL,klA,OM],offset:[-xlA/2+eL/2,0,OM/2],color:"#ccc"})]}),GlA=3.2,FlA=1.6,WM=.9,tL=.5,Uht=GlA-tL*2,BVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[Uht,FlA,WM],offset:[0,0,WM/2],color:t}),$A(ht,{size:[tL,FlA,WM],offset:[GlA/2-tL/2,0,WM/2],color:"#ccc"}),$A(ht,{size:[tL,FlA,WM],offset:[-GlA/2+tL/2,0,WM/2],color:"#ccc"})]}),RlA=3.2,NlA=2.5,ZM=1,iL=.6,Lht=RlA-iL*2,lVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[Lht,NlA,ZM],offset:[0,0,ZM/2],color:t}),$A(ht,{size:[iL,NlA,ZM],offset:[RlA/2-iL/2,0,ZM/2],color:"#ccc"}),$A(ht,{size:[iL,NlA,ZM],offset:[-RlA/2+iL/2,0,ZM/2],color:"#ccc"})]}),MlA=5,_lA=2.5,VM=1.4,nL=.6,Hht=MlA-nL*2,CVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[Hht,_lA,VM],offset:[0,0,VM/2],color:t}),$A(ht,{size:[nL,_lA,VM],offset:[MlA/2-nL/2,0,VM/2],color:"#ccc"}),$A(ht,{size:[nL,_lA,VM],offset:[-MlA/2+nL/2,0,VM/2],color:"#ccc"})]}),vlA=6.3,UlA=3.2,jM=1.8,oL=.8,Yht=vlA-oL*2,QVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[Yht,UlA,jM],offset:[0,0,jM/2],color:t}),$A(ht,{size:[oL,UlA,jM],offset:[vlA/2-oL/2,0,jM/2],color:"#ccc"}),$A(ht,{size:[oL,UlA,jM],offset:[-vlA/2+oL/2,0,jM/2],color:"#ccc"})]}),Jht=({numberOfPins:t,pitch:A=2.54,legsLength:e=3,outerDiameter:i=.945,innerDiameter:n=.945,rows:o=1})=>{const s=n/1.5,r=s*2+i,a=5,g=Math.ceil(t/o),I=2.54,c=(g-1)*A+i+A/2,B=o>1?(o-1)*I+r:r,l=s*1.6,C=-((g-1)/2)*A,Q=o>1?-((o-1)*I)/2:0,E=$A(ys,{color:"#1a1a1a",children:Ot(VG,{children:[$A(ht,{color:"#000",size:[c,B,a],center:[0,Q,a/2]}),Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,w=C+f*A,S=-d*I;return n?$A(qp,{height:a+.1,radius:n/2,center:[w,S,a/2],color:"#222"},u):$A(ht,{size:[l,l,a],center:[w,S,a/2]},u)})]})});return Ot(Yn,{children:[E,Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,w=C+f*A,S=-d*I;return Ot(ys,{color:"silver",children:[Ot(rI,{children:[$A(ht,{color:"silver",size:[s,s,e*.9],center:[w,S,-e/2*.9]}),$A(ht,{color:"silver",size:[s/1.8,s/1.8,e],center:[w,S,-e/2]})]}),$A(ht,{color:"silver",size:[l,l,l*.5],center:[w,S,l/2*.5]})]},u)})]})},Tht=({width:t,length:A,innerDiameter:e=1})=>{const i=t,n=A,o=t*.7,s=e/2.5;return Ot(Yn,{children:[$A(VU,{color:"#1a1a1f",center:[0,0,o/2],size:[n,n,o],roundRadius:.3}),$A(VU,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[n,n,o*.1],roundRadius:.14}),$A(qp,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),$A(qp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,n/3,o+o*.1/2]}),$A(qp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,-n/3,o+o*.1/2]}),$A(qp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,n/3,o+o*.1/2]}),$A(qp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,-n/3,o+o*.1/2]}),$A(C5,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:-n/2,z:-o*1.2}}),$A(C5,{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}),$A(C5,{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}),$A(C5,{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}})]})},C5=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=dlA(r,A);return $A(ys,{color:"#f2f2f2",children:$A(Wi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:$A(lQ,{rotation:[0,55,o],children:$A(zU,{height:e,children:$A(jU,{points:a.map(g=>[g.y,g.x])})})})})})},Kht=({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,I=A*0,c=i*(o-1)+e+.2,B=n*.55;return Ot(Yn,{children:[Array.from({length:o}).map((l,C)=>$A(Kn,{position:{x:-n/2-I,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:Math.PI,position:{x:n/2+I,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),$A(VB,{center:{x:0,y:0,z:r/2},width:B,length:c,height:a})]})},qht=({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,I=isNaN(parseFloat(o))?2+Number(r)*1.4:parseFloat(o),c=t/2,B=(c-1)*r/2,l=.15,C=.8,Q=4.5,E=(Q-g)/2,h=E*.5;return Ot(Yn,{children:[Array.from({length:c}).map((u,d)=>$A(Kn,{position:{x:-Q/2,y:B-d*r,z:l/2},width:a,thickness:l,padContactLength:h+.05,bodyDistance:E+.1,height:C})),Array.from({length:c}).map((u,d)=>$A(Kn,{rotation:Math.PI,position:{x:Q/2,y:B-d*r,z:l/2},width:a,thickness:l,padContactLength:h+.05,bodyDistance:E+.1,height:C})),$A(VB,{center:{x:0,y:0,z:l/2},width:g,length:I,height:1})]})},Pht=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),$A(ht,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[$A(Wi,{z:.3/2,children:$A(ht,{size:[1.65,.8,.3]})}),Ot(rI,{children:[$A(Wi,{z:.3,children:$A(ht,{size:[1.65,.8,.01]})}),$A(Wi,{z:.6,children:$A(ht,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),Oht=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),$A(ht,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),$A(ys,{color:"#222",children:$A(Wi,{z:.47/2+.02,children:$A(ht,{size:[.98,.58,.47]})})}),$A(ht,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),$A(ht,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),$A(ht,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),$A(ht,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),Wht=()=>{const g=$A(ys,{color:"#1a1a1a",children:Ot(rE,{children:[Ot(rI,{children:[$A(Wi,{z:.13,children:$A(ht,{size:[4,3,.03]})}),$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})})]}),Ot(rI,{children:[$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})}),$A(Wi,{z:2.3,children:$A(ht,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const C=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return $A(ys,{color:"#c0c0c0",children:Ot(rE,{children:[$A(ht,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),$A(ht,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),$A(ht,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Yn,{children:[$A(I,{xDir:1}),$A(I,{xDir:-1}),g]})},Zht=()=>{const g=$A(ys,{color:"#1a1a1a",children:Ot(rE,{children:[Ot(rI,{children:[$A(Wi,{z:.13,children:$A(ht,{size:[4,3,.03]})}),$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})})]}),Ot(rI,{children:[$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})}),$A(Wi,{z:2.3,children:$A(ht,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const C=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return $A(ys,{color:"#c0c0c0",children:Ot(rE,{children:[$A(ht,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),$A(ht,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),$A(ht,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Yn,{children:[$A(I,{xDir:1}),$A(I,{xDir:-1}),g]})},Vht=()=>{const g=$A(ys,{color:"#1a1a1a",children:Ot(rE,{children:[Ot(rI,{children:[$A(Wi,{z:.21000000000000002,children:$A(ht,{size:[6.3999999999999995,5.6,.03]})}),$A(Wi,{z:1.15,children:$A(ht,{size:[6.8,6,.01]})})]}),Ot(rI,{children:[$A(Wi,{z:1.15,children:$A(ht,{size:[6.8,6,.01]})}),$A(Wi,{z:2.3,children:$A(ht,{size:[6.3999999999999995,5.6,.01]})})]})]})}),I=({xDir:c})=>{const C=c*3.08,Q=c*(6/2-.2/2+1),E=c*(6/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return $A(ys,{color:"#c0c0c0",children:Ot(rE,{children:[$A(ht,{size:[2.3*.8,2.95,.2],center:[C,0,.2/2]}),$A(ht,{size:[.2,2.95,1.14],center:[Q,0,1.14/2+.2]}),$A(ht,{size:[h,2.95,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Yn,{children:[$A(I,{xDir:1}),$A(I,{xDir:-1}),g]})},jht=()=>{const c=$A(ys,{color:"#222",children:Ot(rE,{children:[$A(Wi,{z:.27,children:$A(ht,{size:[2.9,1.9,.54]})}),Ot(rI,{children:[$A(Wi,{z:.54,children:$A(ht,{size:[2.9,1.9,.01]})}),$A(Wi,{z:1.08,children:$A(ht,{size:[2.6999999999999997,1.7,.01]})})]})]})});return Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),$A(ht,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),c]})},zht=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),$A(ht,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[$A(Wi,{z:.55/2,children:$A(ht,{size:[2.7,1.6,.55]})}),Ot(rI,{children:[$A(Wi,{z:.55,children:$A(ht,{size:[2.7,1.6,.01]})}),$A(Wi,{z:1.1,children:$A(ht,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),Xht=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),$A(ht,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[$A(Wi,{z:.2/2,children:$A(ht,{size:[2.75,1.8,.2]})}),Ot(rI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[2.75,1.8,.01]})}),$A(Wi,{z:1,children:$A(ht,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),$A(ht,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),$ht=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),$A(ht,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[Ot(rI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[2.6-.1/2,1.7-.1/2,.01]})}),$A(Wi,{z:.01,children:$A(ht,{size:[2.6-.1,1.7-.1,.01]})})]}),Ot(rI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[2.6,1.7,.01]})}),$A(Wi,{z:1,children:$A(ht,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),$A(ht,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),Aut=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),$A(ht,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[Ot(rI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[3.8-.05/2,2.5-.05/2,.01]})}),$A(Wi,{z:.01,children:$A(ht,{size:[3.8-.05,2.5-.05,.01]})})]}),Ot(rI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[3.8,2.5,.01]})}),$A(Wi,{z:1,children:$A(ht,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),$A(ht,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),eut=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),$A(ht,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[$A(Wi,{z:.14/2,children:$A(ht,{size:[.8,.6,.14]})}),Ot(rI,{children:[$A(Wi,{z:.14,children:$A(ht,{size:[.8,.6,.01]})}),$A(Wi,{z:.37,children:$A(ht,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),tut=()=>{const I=3.0999999999999996;return Ot(Yn,{children:[$A(Kn,{rotation:Math.PI,position:{x:6.6/2+I/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(Kn,{position:{x:-6.6/2-I/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(Kn,{position:{x:-6.6/2-I/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(Kn,{position:{x:-6.6/2-I/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(VB,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},iut=()=>Ot(Yn,{children:[Array.from({length:16}).map((l,C)=>$A(Kn,{position:{x:-10.5/2,y:C*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((l,C)=>$A(Kn,{rotation:Math.PI,position:{x:10.5/2,y:C*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((l,C)=>$A(Kn,{rotation:Math.PI/2,position:{x:C*.5-3.75,y:-10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((l,C)=>$A(Kn,{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})),$A(VB,{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})]}),nut=iut,out=()=>{const g=.7999999999999998;return Ot(Yn,{children:[$A(Kn,{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}),$A(Kn,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),$A(Kn,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),$A(VB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},sut=({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,I=.8,c=.2,B=(g-n)/2+.4;return Ot(Yn,{children:[Array.from({length:o}).map((l,C)=>$A(Kn,{position:{x:-g/2-.36,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:Math.PI,position:{x:g/2+.36,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),$A(VB,{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})]})},rut=()=>{const i=.20900000000000002,n=.1,o=.3,s=.1,r=.2;return Ot(Yn,{children:[$A(ys,{color:"#222",children:Ot(rE,{children:[$A(ht,{size:[.85,1.2,i],center:[0,0,i/2]}),Ot(rI,{children:[$A(Wi,{z:i,children:$A(ht,{size:[.85,1.2,.01]})}),$A(Wi,{z:.38,children:$A(ht,{size:[.85-n,1.2-n,.01]})})]})]})}),$A(ht,{color:"#ccc",size:[o,.25,s],center:[.55,0,s/2]}),$A(ht,{color:"#ccc",size:[o,r,s],center:[-.55,.4,s/2]}),$A(ht,{color:"#ccc",size:[o,r,s],center:[-.55,-.4,s/2]})]})},aut=({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=[],I=Math.floor(t/2),c=r*(I-1);for(let B=0;B<t;B++){const l=B<I?"left":"right",C=B%I,Q=c/2-C*r,E=s,h=o,u=l==="left"?-A/2+E/2:A/2-E/2,d=B+1;g.push({pinNumber:d,x:u,y:Q,padSizeX:E,padSizeY:h})}return Ot(Yn,{children:[$A(VB,{center:{x:0,y:0,z:0},width:A,length:e,height:i,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(A/2-s),y:e/2-s,z:i}}),g.map((B,l)=>$A(ht,{center:[B.x,B.y,a/2],size:[B.padSizeX,B.padSizeY,a]})),n?.length!==void 0&&n?.width!==void 0&&$A(ht,{center:[0,0,a/2],size:[n.width,n.length,a]})]})},gut=({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,I=a-g,c=i/2,B=.85;return Ot(Yn,{children:[Ot(ys,{color:s,children:[Ot(rI,{children:[$A(Pp,{height:e,roundRadius:.5,radius:g,center:[-I,0,e]}),$A(Pp,{height:e,roundRadius:.5,radius:g,center:[I,0,e]})]}),Ot(rI,{children:[$A(Pp,{height:B,roundRadius:.1,radius:g+.85,center:[-I,0,e/2+B/2]}),$A(Pp,{height:B,roundRadius:.1,radius:g+.85,center:[I,0,e/2+B/2]})]})]}),Ot(ys,{color:r,children:[$A(qp,{height:o+e/2,radius:n/2,center:[-c+.06,0,-(o/2)+e/2]}),$A(qp,{height:o+e/2,radius:n/2,center:[c-.06,0,-(o/2)+e/2]})]})]})},Iut=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:n="#111"})=>Ot(Yn,{children:[$A(ys,{color:e,children:Ot(lQ,{rotation:[0,"90deg",0],children:[$A(VU,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),$A(qp,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),$A(ys,{color:n,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(VU,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),$A(ys,{color:i,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),$A(ys,{color:i,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),cut=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Yn,{children:[$A(ys,{color:e,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),$A(ys,{color:i,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),$A(ys,{color:i,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),But=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Yn,{children:[$A(ys,{color:e,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),$A(ys,{color:i,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),$A(ys,{color:i,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),lut=({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 Ot(Yn,{children:[Array.from({length:n}).map((g,I)=>$A(Kn,{position:{x:-s/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,I)=>$A(Kn,{rotation:Math.PI,position:{x:s/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),$A(VB,{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})]})},Cut=({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 Ot(Yn,{children:[Array.from({length:n}).map((g,I)=>$A(Kn,{position:{x:-o/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,I)=>$A(Kn,{rotation:Math.PI,position:{x:o/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),$A(VB,{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})]})},Qut=()=>{const Q=7.050000000000001,E=24.95+6.5/2;return $A(Wi,{center:[0,0,1],children:Ot(Yn,{children:[Ot(lQ,{rotation:[0,55,-55],children:[Ot(VG,{children:[$A(ht,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[E,0,1.3-2]}),$A(qp,{color:"black",center:[E,0,1.3-2],radius:3/2,height:1.3*1.2})]}),$A(ys,{color:"#222",children:$A(VB,{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})})]}),$A(lQ,{rotation:[0,55,55],children:Array.from({length:3}).map((h,u)=>{const d=Q,f=(u-1)*2.7,w=-.5-.6;return Ot(ys,{color:"gold",children:[Ot(rI,{children:[$A(Wi,{center:[15.05-4.5/2+.1,f,w],children:$A(ht,{size:[4.5,.81+1,.5]})}),$A(Wi,{center:[15.05-4.5/2-1+.1,f,w],children:$A(ht,{size:[4.5,.81,.5]})})]}),$A(Wi,{center:[d,f,w],children:$A(ht,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},Eut=()=>{const g=1.1999999999999997;return Ot(Yn,{children:[$A(Kn,{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}),$A(Kn,{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}),$A(Kn,{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}),$A(Kn,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Kn,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Kn,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(VB,{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})]})},hut=()=>Ot(Yn,{children:[$A(VB,{center:{x:0,y:0,z:0},width:.8,length:1,height:.37,heightAboveSurface:0,color:"#1a1a1a",taperRatio:.15,straightHeightRatio:0,notchPosition:{x:-.8/4,y:.7/2.2,z:.37+.1}}),[0,1,2].map(g=>{const I=-.35+g*.35;return $A(ht,{center:[-.8/2+.19/2-.1,I,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(g=>{const I=-.35+g*.35;return $A(ht,{center:[.8/2-.19/2+.1,I,.12/2],size:[.19,.15,.12]})})]}),uut=()=>{const s="#222",a=[.43,.4,1.32],g=[.43,.4,.25],I=[0,0,-.66],c=[0,0,-1.32],B=[0,1.28,-2.72],l=[0,1.28,-8.9],C=-7.5;return Ot(Wi,{center:[0,1,10.5],children:[$A(ys,{color:s,children:Ot(VG,{children:[$A(Wi,{center:[0,0,2.25],children:$A(qp,{radius:2.4,height:4.5})}),$A(Wi,{center:[0,-1.8499999999999999,2.25],children:$A(ht,{size:[2.4*2,1.1,4.5+.2]})})]})}),$A(Wi,{center:I,children:$A(ht,{size:a})}),Ot(rI,{children:[$A(Wi,{center:c,children:$A(ht,{size:g})}),$A(Wi,{center:B,children:$A(ht,{size:g})})]}),$A(Wi,{center:l,children:$A(ht,{size:[.43,.4,12.2]})}),$A(Wi,{center:[1.3,0,C],children:$A(ht,{size:[.43,.4,15]})}),$A(Wi,{center:[-1.3,0,C],children:$A(ht,{size:[.43,.4,15]})})]})},dut=()=>Ot(Yn,{children:[$A(Kn,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Kn,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Kn,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Kn,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Kn,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Kn,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(VB,{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})]}),put=dut,fut=()=>Ot(Yn,{children:[$A(VB,{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 $A(ht,{center:[-1/2+.3/2,a,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(r=>{const a=-.5+r*.5;return $A(ht,{center:[1/2-.3/2,a,.05/2],size:[.3,.2,.05]})})]}),yut=()=>Ot(Yn,{children:[$A(Kn,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),$A(Kn,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),$A(ys,{color:"#222",children:$A(VB,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),$A(ht,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),mut=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),$A(ht,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[$A(Wi,{z:.175/2,children:$A(ht,{size:[1.7,1.25,.175]})}),Ot(rI,{children:[$A(Wi,{z:.175,children:$A(ht,{size:[1.7,1.25,.01]})}),$A(Wi,{z:.725,children:$A(ht,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),$A(ht,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),wut=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),$A(ht,{color:"#ccc",size:[.4,.325,.13],center:[r,0,.13/2]}),$A(ys,{color:"#222",children:$A(VB,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),$A(ht,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},Dut=({footprint:t})=>{const A=cht.string(t).json();switch(A.fn){case"dip":return $A(Eht,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"tssop":return $A(uht,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return $A(dht,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return $A(qht,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return $A(mht,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return $A(nut,{});case"lqfp":return $A(sut,{pinCount:A.num_pins});case"qfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return $A(Fht,{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 $A(aut,{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 $A(bht,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:o});if(A.female)return $A(Jht,{numberOfPins:A.num_pins,pitch:A.p,rows:o})}case"cap":switch(A.imperial){case"0402":return $A(rVA,{color:"#856c4d"});case"0603":return $A(aVA,{color:"#856c4d"});case"0805":return $A(gVA,{color:"#856c4d"});case"0201":return $A(IVA,{color:"#856c4d"});case"01005":return $A(cVA,{color:"#856c4d"});case"1206":return $A(BVA,{color:"#856c4d"});case"1210":return $A(lVA,{color:"#856c4d"});case"2010":return $A(CVA,{color:"#856c4d"});case"2512":return $A(QVA,{color:"#856c4d"})}case"sot235":return $A(Nht,{});case"sot457":return $A(Eut,{});case"sot223":return $A(tut,{});case"sot23w":return $A(Mht,{});case"sot323":return $A(out,{});case"sod323f":return $A(mut,{});case"sod323fl":return $A(wut,{});case"sot363":return $A(put,{});case"sot886":return $A(fut,{});case"sot963":return $A(hut,{});case"pushbutton":return $A(Tht,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return $A(Kht,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return $A(Pht,{});case"sod882":return $A(Oht,{});case"sma":return $A(Wht,{});case"smb":return $A(Zht,{});case"smc":return $A(Vht,{});case"smf":return $A(jht,{});case"sod123f":return $A(zht,{});case"sod123fl":return $A(Xht,{});case"sod123w":return $A($ht,{});case"sod128":return $A(Aut,{});case"sod323":return $A(yut,{});case"sod923":return $A(eut,{});case"hc49":return $A(gut,{});case"micromelf":return $A(Iut,{});case"minimelf":return $A(cut,{});case"melf":return $A(But,{});case"ms012":return $A(lut,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return $A(Cut,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return $A(rut,{});case"to220":return $A(Qut,{});case"to92":return $A(uut,{})}const e=t.match(/_color\(([^)]+)\)/),i=e?e[1]:void 0;switch(A.imperial){case"0402":return $A(rVA,{color:i});case"0603":return $A(aVA,{color:i});case"0805":return $A(gVA,{color:i});case"0201":return $A(IVA,{color:i});case"01005":return $A(cVA,{color:i});case"1206":return $A(BVA,{color:i});case"1210":return $A(lVA,{color:i});case"2010":return $A(CVA,{color:i});case"2512":return $A(QVA,{color:i})}return null},Sut=t=>t&&typeof t=="object"&&"type"in t,zM=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},but=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 Gw(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(B=>Gw(B,A,e));if(!Sut(t))return[];const{type:g,props:I,children:c}=t;if(g===iVA)return(c??[]).flatMap(B=>Gw(B,A,e));if(g===ys){const B=I?.color;return(c??[]).flatMap(l=>Gw(l,B??A,e))}if(g===Wi){const B=but(I?.offset??I?.center??{x:I?.x,y:I?.y,z:I?.z});return(c??[]).flatMap(C=>Gw(C,A,e)).map(({geom:C,color:Q})=>({geom:a.translate(B,C),color:Q??A}))}if(g===lQ){const B=Array.isArray(I?.rotation)?[zM(I.rotation[0]),zM(I.rotation[1]),zM(I.rotation[2])]:[zM(I?.x??0),zM(I?.y??0),zM(I?.z??0)];return(c??[]).flatMap(C=>Gw(C,A,e)).map(({geom:C,color:Q})=>({geom:a.rotateZ(B[2],a.rotateY(B[1],a.rotateX(B[0],C))),color:Q}))}if(g===rE||g===VG||g===rI){const B=(c??[]).flatMap(C=>Gw(C,A,e)).map(C=>C.geom);if(B.length===0)return[];let l;return g===rE?l=n.union(B):g===VG?l=n.subtract(B[0],B.slice(1)):l=o.hull(B),[{geom:l,color:A}]}if(g===jU){const B=I?.points??[];return[{geom:s.geom2.fromPoints(B),color:A??I?.color}]}if(g===zU){const B=(c??[]).flatMap(E=>Gw(E,A,e)).map(E=>E.geom);if(B.length===0)return[];const l=B.length>1?n.union(B):B[0],C=I?.height??I?.h??1;let Q=r.extrudeLinear({height:C},l);if(Q.polygons)for(const E of Q.polygons)!E.plane||!E.vertices||E.vertices.length<3||E.vertices.reverse();return[{geom:Q,color:A??I?.color}]}if(g===ht||g===nVA||g===qp||g===oVA||g===VU||g===Pp){let B;if(g===ht){const l=I?.size??[1,1,1],C=I?.offset,Q=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);B=i.cuboid({size:l,center:Q})}else if(g===nVA){const l=I?.size??1,C=I?.offset,Q=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);B=i.cube({size:l,center:Q})}else if(g===qp){const l=I?.height??1,C=I?.radius??1,Q=I?.center??[0,0,0];B=i.cylinder({height:l,radius:C,center:Q})}else if(g===oVA){const l=I?.radius??1,C=I?.center??[0,0,0];B=i.sphere({radius:l,center:C})}else if(g===Pp){const l=I?.height??1,C=I?.radius??1,Q=I?.roundRadius??.1,E=I?.center??[0,0,0];B=i.roundedCylinder({height:l,radius:C,roundRadius:Q,center:E})}else{const l=I?.size??[1,1,1],C=I?.roundRadius??.1,Q=I?.center??[0,0,0];B=i.roundedCuboid({size:l,roundRadius:C,center:Q})}return[{geom:B,color:A??I?.color}]}if(typeof g=="function"){const B=g(I??{});return Gw(B,A,e)}return(c??[]).flatMap(B=>Gw(B,A,e))}function xut(t,A){return{geometries:Gw(t,void 0,{jscad:A})}}function EVA(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,I=s.vertices[a].index;e.push(r,g,I)}}const o=new Ug;if(o.setAttribute("position",new sI(new Float32Array(A),3)),o.setIndex(e),i.length>0&&o.setAttribute("color",new sI(new Float32Array(i),3)),t.transforms){const s=new As;s.fromArray(t.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(t.sides){const A=[],e=[];for(const n of t.sides)A.push(n[0][0],n[0][1],0),t.color&&t.color.length>=3?e.push(t.color[0],t.color[1],t.color[2]):e.push(1,1,1);const i=new Ug;if(i.setAttribute("position",new sI(new Float32Array(A),3)),e.length>0&&i.setAttribute("color",new sI(new Float32Array(e),3)),t.transforms){const n=new As;n.fromArray(t.transforms),i.applyMatrix4(n)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Ug}function kut(t,A){const e=ulA(Dut,{footprint:t});return xut(e,A)}var Gut=({jscadPlan:t,positionOffset:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=yu(),{threeGeom:g,material:I}=z.useMemo(()=>{const B=(0,nIt.executeJscadOperations)(oIt.default,t);if(!B||!B.polygons&&!B.sides)return{threeGeom:null,material:null};const l=EVA(B),C=new fu({vertexColors:!0,side:vl,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:l,material:C}},[t,r]),c=z.useMemo(()=>g?new Ao(g,I):null,[g,I]);return z.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),z.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]),z.useMemo(()=>{if(I)if(o){const B=new Ji(I.color.getHex());I.emissive.copy(B),I.emissive.setRGB(0,0,1),I.emissiveIntensity=.2}else I.emissiveIntensity=0},[o,I]),g?O.jsx(OU,{isHovered:o,onHover:i,onUnhover:n,object:c}):null},Fut=fr(t5()),Rut=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=yu(),g=z.useMemo(()=>{if(!A)return null;const{geometries:I}=kut(A,Fut),c=new zf;for(const B of I.flat(1/0)){const l=B.geom;if(!l||!l.polygons&&!l.sides)continue;const C=new Ji(B.color);C.convertLinearToSRGB();const Q={...l,color:[C.r,C.g,C.b]},E=EVA(Q),h=new fu({vertexColors:!0,side:vl,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new Ao(E,h);c.add(u)}return c},[A,r]);return z.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),z.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]),z.useEffect(()=>{g&&g.traverse(I=>{I instanceof Ao&&I.material instanceof fu&&(o?(I.material.emissive.setHex(255),I.material.emissiveIntensity=.2):I.material.emissiveIntensity=0)})},[o,g]),g?O.jsx(OU,{isHovered:o,onHover:i,onUnhover:n,object:g}):null},Nut=(...t)=>t,sL={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},hVA=({children:t,position:A,style:e})=>{const{camera:i,renderer:n}=yu(),o=z.useRef(document.createElement("div")),[s,r]=z.useState(null);return z.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(bP.createPortal(t,o.current)),()=>{a.contains(o.current)&&a.removeChild(o.current)}},[n,t]),PU(()=>{if(!i||!o.current||!n)return;const a=new Re(...A);a.project(i);const g=n.domElement.getBoundingClientRect(),I=Math.round((a.x+1)/2*g.width),c=Math.round((-a.y+1)/2*g.height);o.current.style.position="absolute",o.current.style.left=`${I}px`,o.current.style.top=`${c}px`,o.current.style.pointerEvents="none",o.current.style.zIndex=sL.htmlElements.toString(),e&&Object.assign(o.current.style,e)},[i,n,A,e]),s},uVA={boardBody:!0,topCopper:!0,bottomCopper:!0,adhesive:!1,solderPaste:!1,topSilkscreen:!0,bottomSilkscreen:!0,topMask:!0,bottomMask:!0,throughHoleModels:!0,smtModels:!0,translucentModels:!0,modelsNotInPosFile:!1,modelsMarkedDNP:!1,modelBoundingBoxes:!1,threedAxis:!1,backgroundStart:!0,backgroundEnd:!0},dVA=z.createContext(void 0),Mut=({children:t})=>{const[A,e]=z.useState(uVA),i=z.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),n=z.useCallback(()=>{e(uVA)},[]),o=z.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:n}),[A,i,n]);return O.jsx(dVA.Provider,{value:o,children:t})},XM=()=>{const t=z.useContext(dVA);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},pVA=({cad_component:t,circuitJson:A})=>{const[e,i]=z.useState(!1),{visibility:n}=XM(),[o,s]=z.useState(null),r=z.useCallback(Q=>{Q?.mousePosition?(i(!0),s(Q.mousePosition)):(i(!1),s(null))},[]),a=z.useCallback(()=>{i(!1),s(null)},[]),g=z.useMemo(()=>yi(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),I=z.useMemo(()=>A.filter(E=>E.type==="pcb_plated_hole"&&E.pcb_component_id===t.pcb_component_id).length>0,[A,t.pcb_component_id]),c=t.model_obj_url??t.model_wrl_url??t.model_stl_url,B=t.model_glb_url??t.model_gltf_url,l=t.rotation?Nut(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):void 0;let C=null;if(c?C=O.jsx(AIt,{url:c,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:l,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):B?C=O.jsx(iIt,{gltfUrl:B,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:l,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.model_jscad?C=O.jsx(Gut,{jscadPlan:t.model_jscad,rotationOffset:l,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(C=O.jsx(Rut,{positionOffset:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotationOffset:l,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model})),t.show_as_translucent_model){if(!n.translucentModels)return null}else if(I&&!n.throughHoleModels||!I&&!n.smtModels)return null;return O.jsxs(O.Fragment,{children:[C,e&&o?O.jsx(hVA,{position:o,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:g??"<unknown>"}):null]})},fVA={version:"0.0.480"};function _ut(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var vut=t=>{t.outputColorSpace=gm,t.toneMapping=UUA,t.toneMappingExposure=1},yVA="cadViewerCameraStateSession",mVA=(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(yVA,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},LlA=(t,A)=>{try{const e=sessionStorage.getItem(yVA);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}},wVA=z.createContext(void 0),Uut=({children:t,defaultTarget:A,initialCameraPosition:e})=>{const i=z.useRef(null),n=z.useRef(null),[o,s]=z.useState(null),[r,a]=z.useState("perspective"),[g,I]=z.useState(e??null),[c,B]=z.useState(new Tp(0,0,0)),l=z.useMemo(()=>{const[h,u,d]=e??[5,-5,5],f=Math.hypot(h-A.x,u-A.y,d-A.z);return f>0?f:5},[e,A]),C=z.useCallback(h=>{const u=[A.x,A.y,A.z],d=n.current,f=i.current;let w=l;switch(d&&f&&(w=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const S=w/Math.sqrt(2);return{position:[A.x,A.y-S,A.z+S],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+w],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-w*.6,A.y-w*.6,A.z+w*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+w*.6,A.y-w*.6,A.z+w*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-w,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+w,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-w,A.z],target:u,up:[0,0,1]};default:return null}},[l,A,n,i]),Q=z.useCallback(h=>{i.current=h},[]),E=z.useMemo(()=>({controlsRef:i,mainCameraRef:n,defaultTarget:A,baseDistance:l,controller:o,setController:s,getPresetConfig:C,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:I,cameraRotation:c,setCameraRotation:B,saveCameraToSession:mVA,loadCameraFromSession:LlA}),[A,l,o,C,Q,r,g,c]);return O.jsx(wVA.Provider,{value:E,children:t})},mx=()=>{const t=z.useContext(wVA);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},Lut=z.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:n},o)=>{const{cameraType:s}=mx(),r=z.useRef(null),[a,g]=z.useState(null),I=z.useRef([]),c=z.useRef(void 0);c.current=n;const B=z.useRef(null),l=z.useCallback(h=>{I.current.push(h)},[]),C=z.useCallback(h=>{I.current=I.current.filter(u=>u!==h)},[]),Q=z.useMemo(()=>new MG,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const E=z.useRef(new hg);return z.useImperativeHandle(o,()=>E.current),z.useEffect(()=>{if(!r.current)return;_ut(r.current);const h=new K3({antialias:!0,alpha:!0});vut(h),h.setSize(r.current.clientWidth,r.current.clientHeight),h.setPixelRatio(window.devicePixelRatio),r.current.appendChild(h.domElement);const u=r.current.clientWidth/r.current.clientHeight,d=s==="perspective"?new sE(75,u,.1,1e3):new oU(-10*u,10*u,10,-10,-1e3,1e3);B.current?(d.position.copy(B.current.position),d.quaternion.copy(B.current.quaternion),d.up.copy(B.current.up)):(e?.up&&d.up.set(e.up[0],e.up[1],e.up[2]),e?.position&&d.position.set(e.position[0],e.position[1],e.position[2]),d.lookAt(0,0,0)),Q.add(E.current),window.__TSCIRCUIT_THREE_OBJECT=E.current,g({scene:Q,camera:d,renderer:h,rootObject:E.current,addFrameListener:l,removeFrameListener:C}),c.current?.({camera:d,renderer:h});let f;const w=new jze,S=()=>{const x=w.getElapsedTime(),F=w.getDelta();I.current.forEach(k=>k(x,F)),h.render(Q,d),f=requestAnimationFrame(S)};S();const D=()=>{if(r.current){const x=r.current.clientWidth/r.current.clientHeight;d instanceof sE?d.aspect=x:d instanceof oU&&(d.left=-10*x,d.right=10*x,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),h.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",D),()=>{B.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",D),cancelAnimationFrame(f),r.current&&h.domElement&&r.current.removeChild(h.domElement),h.dispose(),Q.remove(E.current),window.__TSCIRCUIT_THREE_OBJECT===E.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,l,C,s]),O.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&O.jsx($WA.Provider,{value:a,children:O.jsx(Vgt,{children:t})})})}),Hut=({autoRotate:t,autoRotateSpeed:A,onStart:e,panSpeed:i,rotateSpeed:n,zoomSpeed:o,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:I,renderer:c}=yu(),B=z.useMemo(()=>!I||!c?null:new x6e(I,c.domElement),[I,c]);return z.useEffect(()=>(g?.(B??null),()=>g?.(null)),[B,g]),z.useEffect(()=>{if(!B)return;const l=()=>{g?.(B)};return B.addEventListener("change",l),()=>{B.removeEventListener("change",l)}},[B,g]),z.useEffect(()=>{B&&(B.autoRotate=t||!1,B.autoRotateSpeed=A||1,i!==void 0&&(B.panSpeed=i),n!==void 0&&(B.rotateSpeed=n),o!==void 0&&(B.zoomSpeed=o),s!==void 0&&(B.enableDamping=s),r!==void 0&&(B.dampingFactor=r),B.zoomToCursor=!0,B.mouseButtons={LEFT:Xb.ROTATE,MIDDLE:Xb.PAN,RIGHT:null},a&&(B.target.set(a[0],a[1],a[2]),B.update()))},[B,t,A,i,n,o,s,r,a]),z.useEffect(()=>{if(!(!B||!e))return B.addEventListener("start",e),()=>{B.removeEventListener("start",e)}},[B,e]),z.useEffect(()=>{if(B)return()=>{B.dispose()}},[B]),PU(()=>{B?.update()},[B]),null},Yut=`
5066
+ `).replace(/d 0\./g,"d 1."),l=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new C6e;C.setMaterialOptions({invertTrProperty:!0});const Q=C.parse(B.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return c.setMaterials(Q),c.parse(l)}return c.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(n.has(i)){const g=n.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(I=>I instanceof Error?I:I.clone())}const a=s().then(g=>(g instanceof Error||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 AIt({url:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const a=$gt(t),{rootObject:g}=yu(),I=z.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(c=>{if(c instanceof Ao&&c.material){const B=l=>{l.transparent=r,l.opacity=r?.5:1,l.depthWrite=!r,l.needsUpdate=!0};Array.isArray(c.material)?c.material.forEach(B):B(c.material)}}),a):new Ao(new um(.5,.5,.5),new fu({transparent:!0,color:"red",opacity:.25})),[a,r]);if(z.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),z.useEffect(()=>{I&&(A&&(Array.isArray(A)?I.position.fromArray(A):I.position.copy(A)),e&&(Array.isArray(e)?I.rotation.fromArray(e):I.rotation.copy(e)),s!==void 0&&I.scale.setScalar(s))},[I,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,s]),a instanceof Error)throw a;return O.jsx(OU,{isHovered:o,onHover:i,onUnhover:n,object:I})}var eZA=new WeakMap,eIt=()=>{const t=new Lc;return t.name="fallback-environment-map",t.mapping=c3,t},tIt=t=>{if(!t)return null;const A=t,e=eZA.get(A);if(e)return e;let i;if(t instanceof K3){const n=new piA(t);i=n.fromScene(GXe(),.04).texture,n.dispose()}else i=eIt();return eZA.set(A,i),i},tZA=1.25;function iIt({gltfUrl:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=yu(),[I,c]=z.useState(null),[B,l]=z.useState(null);if(z.useEffect(()=>{if(!t)return;const C=new RXe;let Q=!0;return C.load(t,E=>{if(!Q)return;const h=E.scene;h.traverse(u=>{if(u instanceof Ao&&u.material){const d=f=>{f.transparent=r,f.opacity=r?.5:1,f.depthWrite=!r,f.needsUpdate=!0};Array.isArray(u.material)?u.material.forEach(d):d(u.material)}}),c(h)},void 0,E=>{if(!Q)return;console.error(`An error happened loading ${t}`,E);const h=E instanceof Error?E:new Error(`Failed to load glTF model from ${t}`);l(h)}),()=>{Q=!1}},[t,r]),z.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]),z.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),z.useEffect(()=>{if(!I||!a)return;const C=tIt(a);if(!C)return;const Q=[],E=h=>{h instanceof fu&&(Q.push({material:h,envMap:h.envMap??null,envMapIntensity:h.envMapIntensity??1}),h.envMap=C,(typeof h.envMapIntensity!="number"||h.envMapIntensity<tZA)&&(h.envMapIntensity=tZA),h.needsUpdate=!0)};return I.traverse(h=>{if(!(h instanceof Ao))return;const u=h.material;Array.isArray(u)?u.forEach(E):u&&E(u)}),()=>{Q.forEach(({material:h,envMap:u,envMapIntensity:d})=>{h.envMap=u,h.envMapIntensity=d,h.needsUpdate=!0})}},[I,a]),z.useEffect(()=>{I&&I.traverse(C=>{C instanceof Ao&&C.material instanceof fu&&(o?(C.material.emissive.setHex(255),C.material.emissiveIntensity=.2):C.material.emissiveIntensity=0)})},[o,I]),B)throw B;return I?O.jsx(OU,{isHovered:o,onHover:i,onUnhover:n,object:I}):null}var nIt=fr(G8A()),oIt=fr(t5()),iZA={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},ya=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 iZA)return e*iZA[A];throw new Error(`Unsupported unit: ${A}`)},WU=ya,nZA={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,ms:1,s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},slA=new Set;for(const[t,A]of Object.entries(nZA)){slA.add(t);for(const e of Object.keys(A.variants))slA.add(e)}function sIt(t){for(const[A,e]of Object.entries(nZA))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var oZA={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12};function ym(t){if(t==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:r,unitOfValue:a}=ym(t.x),g=ym(t.x),I=ym(t.y);return g.value===null||I.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:I.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),n=t.slice(0,-i.length);if(i in oZA&&!slA.has(i)){const r=oZA[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(n)*r}}const{baseUnit:o,conversionFactor:s}=sIt(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(n)}}var rlA=J().or(jA()).transform(t=>ym(t).value),sZA=J().or(jA()).transform(t=>ym(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),rIt=J().or(jA()).transform(t=>ym(t).value),HM=J().or(jA()).transform(t=>ym(t).value),ie=J().or(jA()).transform(t=>ym(t).value),alA=J().or(jA()).transform(t=>ym(t).value),wt=ie;J().or(jA()).transform(t=>ym(t).value);var glA=J().or(jA()).transform(t=>ym(t).value),YM=glA,aIt=J().datetime(),$f=J().or(jA()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),gIt=jA().or(J().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const A=t.replace("mAh",""),e=Number.parseFloat(A);if(Number.isNaN(e))throw new Error("Invalid capacity");return e}return t}).describe("Battery capacity in mAh"),Rn=TA({x:wt,y:wt}),IlA=TA({x:wt,y:wt,z:wt}),rZA=TA({width:jA(),height:jA()}),IIt=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},Ai=t=>J().optional().default(()=>`${t}_${IIt(10)}`),JM=lt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),cIt=lt(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),ZB=TA({type:FA("source_component"),ftype:J().optional(),source_component_id:J(),name:J(),manufacturer_part_number:J().optional(),supplier_part_numbers:Ma(cIt,be(J())).optional(),display_value:J().optional(),are_pins_interchangeable:Be().optional(),internally_connected_source_port_ids:be(be(J())).optional(),source_group_id:J().optional(),subcircuit_id:J().optional()}),aZA=ZB.extend({ftype:FA("simple_capacitor"),capacitance:sZA,max_voltage_rating:HM.optional(),display_capacitance:J().optional(),max_decoupling_trace_length:wt.optional()}),gZA=ZB.extend({ftype:FA("simple_resistor"),resistance:rlA,display_resistance:J().optional()}),clA=ZB.extend({ftype:FA("simple_diode")}),BIt=ZB.extend({ftype:FA("simple_fiducial")}),IZA=clA.extend({ftype:FA("simple_led"),color:J().optional(),wavelength:J().optional()}),lIt=ZB.extend({ftype:FA("simple_ground")}),cZA=ZB.extend({ftype:FA("simple_chip")}),BZA=ZB.extend({ftype:FA("simple_power_source"),voltage:HM}),CIt=ZB.extend({ftype:FA("simple_fuse"),current_rating_amps:jA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:jA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),lZA=ZB.extend({ftype:FA("simple_battery"),capacity:gIt}),CZA=ZB.extend({ftype:FA("simple_inductor"),inductance:rIt,max_current_rating:jA().optional()}),QZA=ZB.extend({ftype:FA("simple_push_button")}),EZA=ZB.extend({ftype:FA("simple_potentiometer"),max_resistance:rlA}),QIt=ZB.extend({ftype:FA("simple_crystal"),frequency:jA().describe("Frequency in Hz"),load_capacitance:jA().optional().describe("Load capacitance in pF")}),hZA=ZB.extend({ftype:FA("simple_pin_header"),pin_count:jA(),gender:lt(["male","female"]).optional().default("male")}),uZA=ZB.extend({ftype:FA("simple_pinout")}),dZA=ZB.extend({ftype:FA("simple_resonator"),load_capacitance:sZA,equivalent_series_resistance:rlA.optional(),frequency:alA}),pZA=ZB.extend({ftype:FA("simple_transistor"),transistor_type:lt(["npn","pnp"])}),fZA=ZB.extend({ftype:FA("simple_test_point"),footprint_variant:lt(["pad","through_hole"]).optional(),pad_shape:lt(["rect","circle"]).optional(),pad_diameter:ei([jA(),J()]).optional(),hole_diameter:ei([jA(),J()]).optional(),width:ei([jA(),J()]).optional(),height:ei([jA(),J()]).optional()}),yZA=ZB.extend({ftype:FA("simple_mosfet"),channel_type:lt(["n","p"]),mosfet_mode:lt(["enhancement","depletion"])}),mZA=ZB.extend({ftype:FA("simple_switch")}),wZA=TA({type:FA("source_project_metadata"),name:J().optional(),software_used_string:J().optional(),project_url:J().optional(),created_at:aIt.optional()}),EIt=TA({type:FA("source_missing_property_error"),source_missing_property_error_id:Ai("source_missing_property_error"),source_component_id:J(),property_name:J(),subcircuit_id:J().optional(),error_type:FA("source_missing_property_error").default("source_missing_property_error"),message:J()}).describe("The source code is missing a property"),hIt=TA({type:FA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Ai("source_failed_to_create_component_error"),error_type:FA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:J().optional(),subcircuit_id:J().optional(),parent_source_component_id:J().optional(),message:J(),pcb_center:TA({x:jA().optional(),y:jA().optional()}).optional(),schematic_center:TA({x:jA().optional(),y:jA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),DZA=TA({type:FA("source_trace_not_connected_error"),source_trace_not_connected_error_id:Ai("source_trace_not_connected_error"),error_type:FA("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:J(),subcircuit_id:J().optional(),source_group_id:J().optional(),source_trace_id:J().optional(),connected_source_port_ids:be(J()).optional(),selectors_not_found:be(J()).optional()}).describe("Occurs when a source trace selector does not match any ports"),uIt=TA({type:FA("source_property_ignored_warning"),source_property_ignored_warning_id:Ai("source_property_ignored_warning"),source_component_id:J(),property_name:J(),subcircuit_id:J().optional(),error_type:FA("source_property_ignored_warning").default("source_property_ignored_warning"),message:J()}).describe("The source property was ignored"),SZA=TA({type:FA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Ai("source_pin_missing_trace_warning"),warning_type:FA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:J(),source_component_id:J(),source_port_id:J(),subcircuit_id:J().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),dIt=ZB.extend({ftype:FA("simple_voltage_probe")}),pIt=ZB.extend({ftype:FA("interconnect")}),fIt=ei([gZA,aZA,clA,BIt,IZA,lIt,cZA,BZA,lZA,CZA,QZA,EZA,QIt,hZA,uZA,dZA,mZA,pZA,fZA,yZA,CIt,dIt,pIt,wZA,EIt,hIt,DZA,uIt,SZA]),yIt=TA({type:FA("source_port"),pin_number:jA().optional(),port_hints:be(J()).optional(),name:J(),source_port_id:J(),source_component_id:J().optional(),source_group_id:J().optional(),subcircuit_id:J().optional(),subcircuit_connectivity_map_key:J().optional(),must_be_connected:Be().optional()}),mIt=TA({type:FA("source_component_internal_connection"),source_component_internal_connection_id:J(),source_component_id:J(),source_port_ids:be(J()),subcircuit_id:J().optional()}),wIt=TA({type:FA("source_trace"),source_trace_id:J(),connected_source_port_ids:be(J()),connected_source_net_ids:be(J()),subcircuit_id:J().optional(),subcircuit_connectivity_map_key:J().optional(),max_length:jA().optional(),min_trace_thickness:jA().optional(),display_name:J().optional()}),DIt=TA({type:FA("source_group"),source_group_id:J(),subcircuit_id:J().optional(),parent_subcircuit_id:J().optional(),parent_source_group_id:J().optional(),is_subcircuit:Be().optional(),show_as_schematic_box:Be().optional(),name:J().optional(),was_automatically_named:Be().optional()}),SIt=TA({type:FA("source_net"),source_net_id:J(),name:J(),member_source_group_ids:be(J()),is_power:Be().optional(),is_ground:Be().optional(),is_digital_signal:Be().optional(),is_analog_signal:Be().optional(),is_positive_voltage_source:Be().optional(),trace_width:jA().optional(),subcircuit_id:J().optional(),subcircuit_connectivity_map_key:J().optional()}),bIt=TA({type:FA("source_board"),source_board_id:J(),source_group_id:J(),title:J().optional()}).describe("Defines a board in the source domain"),xIt=TA({type:FA("source_pcb_ground_plane"),source_pcb_ground_plane_id:J(),source_group_id:J(),source_net_id:J(),subcircuit_id:J().optional()}).describe("Defines a ground plane in the source domain"),kIt=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],bZA=lt(kIt),Zr=bZA.or(TA({name:bZA})).transform(t=>typeof t=="string"?t:t.name),kw=lt(["top","bottom"]),GIt=TA({type:FA("source_manually_placed_via"),source_manually_placed_via_id:J(),source_group_id:J(),source_net_id:J(),subcircuit_id:J().optional(),source_trace_id:J().optional()}).describe("Defines a via that is manually placed in the source domain"),FIt=TA({type:FA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:Ai("source_pin_must_be_connected_error"),error_type:FA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),message:J(),source_component_id:J(),source_port_id:J(),subcircuit_id:J().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),RIt=TA({type:FA("unknown_error_finding_part"),unknown_error_finding_part_id:Ai("unknown_error_finding_part"),error_type:FA("unknown_error_finding_part").default("unknown_error_finding_part"),message:J(),source_component_id:J().optional(),subcircuit_id:J().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),NIt=TA({type:FA("schematic_box"),schematic_component_id:J().optional(),width:wt,height:wt,is_dashed:Be().default(!1),x:wt,y:wt,subcircuit_id:J().optional()}).describe("Draws a box on the schematic"),MIt=TA({type:FA("schematic_path"),schematic_component_id:J(),fill_color:lt(["red","blue"]).optional(),is_filled:Be().optional(),points:be(Rn),subcircuit_id:J().optional()}),_It=Ma(TA({left_margin:ie.optional(),right_margin:ie.optional(),top_margin:ie.optional(),bottom_margin:ie.optional()})),vIt=TA({left_size:jA(),right_size:jA(),top_size:jA().optional(),bottom_size:jA().optional()}),UIt=TA({left_side:TA({pins:be(jA()),direction:lt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:TA({pins:be(jA()),direction:lt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:TA({pins:be(jA()),direction:lt(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:TA({pins:be(jA()),direction:lt(["left-to-right","right-to-left"]).optional()}).optional()}),LIt=ei([vIt,UIt]),HIt=TA({type:FA("schematic_component"),size:rZA,center:Rn,source_component_id:J().optional(),schematic_component_id:J(),pin_spacing:ie.optional(),pin_styles:_It.optional(),box_width:ie.optional(),symbol_name:J().optional(),port_arrangement:LIt.optional(),port_labels:Ma(J()).optional(),symbol_display_value:J().optional(),subcircuit_id:J().optional(),schematic_group_id:J().optional(),is_schematic_group:Be().optional(),source_group_id:J().optional(),is_box_with_pins:Be().optional().default(!0)}),YIt=TA({type:FA("schematic_line"),schematic_line_id:Ai("schematic_line"),schematic_component_id:J(),x1:wt,y1:wt,x2:wt,y2:wt,stroke_width:wt.nullable().optional(),color:J().default("#000000"),is_dashed:Be().default(!1),subcircuit_id:J().optional()}).describe("Draws a styled line on the schematic"),JIt=TA({type:FA("schematic_rect"),schematic_rect_id:Ai("schematic_rect"),schematic_component_id:J(),center:Rn,width:wt,height:wt,rotation:$f.default(0),stroke_width:wt.nullable().optional(),color:J().default("#000000"),is_filled:Be().default(!1),fill_color:J().optional(),is_dashed:Be().default(!1),subcircuit_id:J().optional()}).describe("Draws a styled rectangle on the schematic"),TIt=TA({type:FA("schematic_circle"),schematic_circle_id:Ai("schematic_circle"),schematic_component_id:J(),center:Rn,radius:wt,stroke_width:wt.nullable().optional(),color:J().default("#000000"),is_filled:Be().default(!1),fill_color:J().optional(),is_dashed:Be().default(!1),subcircuit_id:J().optional()}).describe("Draws a styled circle on the schematic"),KIt=TA({type:FA("schematic_arc"),schematic_arc_id:Ai("schematic_arc"),schematic_component_id:J(),center:Rn,radius:wt,start_angle_degrees:$f,end_angle_degrees:$f,direction:lt(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:wt.nullable().optional(),color:J().default("#000000"),is_dashed:Be().default(!1),subcircuit_id:J().optional()}).describe("Draws a styled arc on the schematic"),qIt=TA({type:FA("schematic_trace"),schematic_trace_id:J(),source_trace_id:J().optional(),junctions:be(TA({x:jA(),y:jA()})),edges:be(TA({from:TA({x:jA(),y:jA()}),to:TA({x:jA(),y:jA()}),is_crossing:Be().optional(),from_schematic_port_id:J().optional(),to_schematic_port_id:J().optional()})),subcircuit_id:J().optional(),subcircuit_connectivity_map_key:J().optional()}),PIt=lt(["center","left","right","top","bottom"]),OIt=TA({type:FA("schematic_text"),schematic_component_id:J().optional(),schematic_text_id:J(),text:J(),font_size:jA().default(.18),position:TA({x:wt,y:wt}),rotation:jA().default(0),anchor:ei([PIt.describe("legacy"),JM]).default("center"),color:J().default("#000000"),subcircuit_id:J().optional()}),WIt=TA({type:FA("schematic_port"),schematic_port_id:J(),source_port_id:J(),schematic_component_id:J().optional(),center:Rn,facing_direction:lt(["up","down","left","right"]).optional(),distance_from_component_edge:jA().optional(),side_of_component:lt(["top","bottom","left","right"]).optional(),true_ccw_index:jA().optional(),pin_number:jA().optional(),display_pin_label:J().optional(),subcircuit_id:J().optional(),is_connected:Be().optional(),has_input_arrow:Be().optional(),has_output_arrow:Be().optional()}).describe("Defines a port on a schematic component"),ZIt=TA({type:FA("schematic_net_label"),schematic_net_label_id:Ai("schematic_net_label"),schematic_trace_id:J().optional(),source_trace_id:J().optional(),source_net_id:J(),center:Rn,anchor_position:Rn.optional(),anchor_side:lt(["top","bottom","left","right"]),text:J(),symbol_name:J().optional(),is_movable:Be().optional(),subcircuit_id:J().optional()}),VIt=TA({type:FA("schematic_error"),schematic_error_id:J(),error_type:FA("schematic_port_not_found").default("schematic_port_not_found"),message:J(),subcircuit_id:J().optional()}).describe("Defines a schematic error on the schematic"),jIt=TA({type:FA("schematic_layout_error"),schematic_layout_error_id:Ai("schematic_layout_error"),error_type:FA("schematic_layout_error").default("schematic_layout_error"),message:J(),source_group_id:J(),schematic_group_id:J(),subcircuit_id:J().optional()}).describe("Error emitted when schematic layout fails for a group"),BlA=TA({type:FA("schematic_debug_object"),label:J().optional(),subcircuit_id:J().optional()}),zIt=BlA.extend({shape:FA("rect"),center:Rn,size:rZA}),XIt=BlA.extend({shape:FA("line"),start:Rn,end:Rn}),$It=BlA.extend({shape:FA("point"),center:Rn}),Act=Gp("shape",[zIt,XIt,$It]),ect=TA({type:FA("schematic_voltage_probe"),schematic_voltage_probe_id:J(),source_component_id:J().optional(),name:J().optional(),position:Rn,schematic_trace_id:J(),voltage:HM.optional(),subcircuit_id:J().optional(),color:J().optional(),label_alignment:JM.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),tct=TA({type:FA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Ai("schematic_manual_edit_conflict_warning"),warning_type:FA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:J(),schematic_component_id:J(),schematic_group_id:J().optional(),subcircuit_id:J().optional(),source_component_id:J()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),ict=TA({type:FA("schematic_group"),schematic_group_id:Ai("schematic_group"),source_group_id:J(),is_subcircuit:Be().optional(),subcircuit_id:J().optional(),width:ie,height:ie,center:Rn,schematic_component_ids:be(J()),show_as_schematic_box:Be().optional(),name:J().optional(),description:J().optional()}).describe("Defines a group of components on the schematic"),nct=TA({type:FA("schematic_table"),schematic_table_id:Ai("schematic_table"),anchor_position:Rn,column_widths:be(wt),row_heights:be(wt),cell_padding:wt.optional(),border_width:wt.optional(),subcircuit_id:J().optional(),schematic_component_id:J().optional(),anchor:JM.optional()}).describe("Defines a table on the schematic"),oct=TA({type:FA("schematic_table_cell"),schematic_table_cell_id:Ai("schematic_table_cell"),schematic_table_id:J(),start_row_index:jA(),end_row_index:jA(),start_column_index:jA(),end_column_index:jA(),text:J().optional(),center:Rn,width:wt,height:wt,horizontal_align:lt(["left","center","right"]).optional(),vertical_align:lt(["top","middle","bottom"]).optional(),font_size:wt.optional(),subcircuit_id:J().optional()}).describe("Defines a cell within a schematic_table"),sct=TA({type:FA("schematic_sheet"),schematic_sheet_id:Ai("schematic_sheet"),name:J().optional(),subcircuit_id:J().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),rct=TA({x:wt,y:wt,bulge:jA().optional()}),xZA=TA({vertices:be(rct)}),act=TA({outer_ring:xZA,inner_rings:be(xZA).default([])}),gct=TA({x:wt,y:wt,via:Be().optional(),via_to_layer:Zr.optional()});be(gct);var Ict=TA({x:wt,y:wt,via:Be().optional(),to_layer:Zr.optional(),trace_width:wt.optional()}),cct=TA({type:FA("pcb_component"),pcb_component_id:Ai("pcb_component"),source_component_id:J(),center:Rn,layer:Zr,rotation:$f,display_offset_x:J().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:J().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:ie,height:ie,do_not_place:Be().optional(),subcircuit_id:J().optional(),pcb_group_id:J().optional(),position_mode:lt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:J().optional(),positioned_relative_to_pcb_board_id:J().optional(),obstructs_within_bounds:Be().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),kZA=TA({type:FA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("circle"),hole_diameter:jA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});kZA.describe("Defines a circular hole on the PCB");var GZA=TA({type:FA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("rect"),hole_width:jA(),hole_height:jA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});GZA.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square.");var FZA=TA({type:FA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:lt(["circle","square"]),hole_diameter:jA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});FZA.describe("Defines a circular or square hole on the PCB");var RZA=TA({type:FA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("oval"),hole_width:jA(),hole_height:jA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});RZA.describe("Defines an oval hole on the PCB");var NZA=TA({type:FA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("pill"),hole_width:jA(),hole_height:jA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});NZA.describe("Defines a pill-shaped hole on the PCB");var MZA=TA({type:FA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("rotated_pill"),hole_width:jA(),hole_height:jA(),x:wt,y:wt,ccw_rotation:$f,is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()});MZA.describe("Defines a rotated pill-shaped hole on the PCB");var Bct=FZA.or(RZA).or(NZA).or(MZA).or(kZA).or(GZA),lct=TA({type:FA("pcb_plated_hole"),shape:FA("circle"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),outer_diameter:jA(),hole_diameter:jA(),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Zr),port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Cct=TA({type:FA("pcb_plated_hole"),shape:lt(["oval","pill"]),pcb_group_id:J().optional(),subcircuit_id:J().optional(),outer_width:jA(),outer_height:jA(),hole_width:jA(),hole_height:jA(),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,ccw_rotation:$f,layers:be(Zr),port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Qct=TA({type:FA("pcb_plated_hole"),shape:FA("circular_hole_with_rect_pad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("circle"),pad_shape:FA("rect"),hole_diameter:jA(),rect_pad_width:jA(),rect_pad_height:jA(),rect_border_radius:jA().optional(),hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Zr),port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),Ect=TA({type:FA("pcb_plated_hole"),shape:FA("pill_hole_with_rect_pad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("pill"),pad_shape:FA("rect"),hole_width:jA(),hole_height:jA(),rect_pad_width:jA(),rect_pad_height:jA(),rect_border_radius:jA().optional(),hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Zr),port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),hct=TA({type:FA("pcb_plated_hole"),shape:FA("rotated_pill_hole_with_rect_pad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:FA("rotated_pill"),pad_shape:FA("rect"),hole_width:jA(),hole_height:jA(),hole_ccw_rotation:$f,rect_pad_width:jA(),rect_pad_height:jA(),rect_border_radius:jA().optional(),rect_ccw_rotation:$f,hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Zr),port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),uct=TA({type:FA("pcb_plated_hole"),shape:FA("hole_with_polygon_pad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),hole_shape:lt(["circle","oval","pill","rotated_pill"]),hole_diameter:jA().optional(),hole_width:jA().optional(),hole_height:jA().optional(),pad_outline:be(TA({x:wt,y:wt})).min(3),hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Zr),port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:jA().optional()}),dct=ei([lct,Cct,Qct,Ect,hct,uct]),pct=TA({type:FA("pcb_port"),pcb_port_id:Ai("pcb_port"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),source_port_id:J(),pcb_component_id:J().optional(),x:wt,y:wt,layers:be(Zr),is_board_pinout:Be().optional()}).describe("Defines a port on the PCB"),fct=TA({type:FA("pcb_smtpad"),shape:FA("circle"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,radius:jA(),layer:Zr,port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),yct=TA({type:FA("pcb_smtpad"),shape:FA("rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),rect_border_radius:jA().optional(),corner_radius:jA().optional(),layer:Zr,port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),mct=TA({type:FA("pcb_smtpad"),shape:FA("rotated_rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),rect_border_radius:jA().optional(),corner_radius:jA().optional(),ccw_rotation:$f,layer:Zr,port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),wct=TA({type:FA("pcb_smtpad"),shape:FA("pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),radius:jA(),layer:Zr,port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Dct=TA({type:FA("pcb_smtpad"),shape:FA("rotated_pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),radius:jA(),ccw_rotation:$f,layer:Zr,port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),Sct=TA({type:FA("pcb_smtpad"),shape:FA("polygon"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),points:be(Rn),layer:Zr,port_hints:be(J()).optional(),pcb_component_id:J().optional(),pcb_port_id:J().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:jA().optional()}),bct=Gp("shape",[fct,yct,mct,Dct,wct,Sct]).describe("Defines an SMT pad on the PCB"),xct=TA({type:FA("pcb_solder_paste"),shape:FA("circle"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,radius:jA(),layer:Zr,pcb_component_id:J().optional(),pcb_smtpad_id:J().optional()}),kct=TA({type:FA("pcb_solder_paste"),shape:FA("rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),layer:Zr,pcb_component_id:J().optional(),pcb_smtpad_id:J().optional()}),Gct=TA({type:FA("pcb_solder_paste"),shape:FA("pill"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),radius:jA(),layer:Zr,pcb_component_id:J().optional(),pcb_smtpad_id:J().optional()}),Fct=TA({type:FA("pcb_solder_paste"),shape:FA("rotated_rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),ccw_rotation:wt,layer:Zr,pcb_component_id:J().optional(),pcb_smtpad_id:J().optional()}),Rct=TA({type:FA("pcb_solder_paste"),shape:FA("oval"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),x:wt,y:wt,width:jA(),height:jA(),layer:Zr,pcb_component_id:J().optional(),pcb_smtpad_id:J().optional()}),Nct=ei([xct,kct,Gct,Fct,Rct]).describe("Defines solderpaste on the PCB"),Mct=TA({type:FA("pcb_text"),pcb_text_id:Ai("pcb_text"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),text:J(),center:Rn,layer:Zr,width:ie,height:ie,lines:jA(),align:lt(["bottom-left"])}).describe("Defines text on the PCB"),_ct=TA({route_type:FA("wire"),x:wt,y:wt,width:wt,start_pcb_port_id:J().optional(),end_pcb_port_id:J().optional(),layer:Zr}),vct=TA({route_type:FA("via"),x:wt,y:wt,hole_diameter:wt.optional(),outer_diameter:wt.optional(),from_layer:J(),to_layer:J()}),Uct=ei([_ct,vct]),Lct=TA({type:FA("pcb_trace"),source_trace_id:J().optional(),pcb_component_id:J().optional(),pcb_trace_id:Ai("pcb_trace"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),route_thickness_mode:lt(["constant","interpolated"]).default("constant").optional(),route_order_index:jA().optional(),should_round_corners:Be().optional(),trace_length:jA().optional(),highlight_color:J().optional(),route:be(Uct)}).describe("Defines a trace on the PCB"),Hct=TA({type:FA("pcb_trace_error"),pcb_trace_error_id:Ai("pcb_trace_error"),error_type:FA("pcb_trace_error").default("pcb_trace_error"),message:J(),center:Rn.optional(),pcb_trace_id:J(),source_trace_id:J(),pcb_component_ids:be(J()),pcb_port_ids:be(J()),subcircuit_id:J().optional()}).describe("Defines a trace error on the PCB"),Yct=TA({type:FA("pcb_trace_missing_error"),pcb_trace_missing_error_id:Ai("pcb_trace_missing_error"),error_type:FA("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:J(),center:Rn.optional(),source_trace_id:J(),pcb_component_ids:be(J()),pcb_port_ids:be(J()),subcircuit_id:J().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),Jct=TA({type:FA("pcb_port_not_matched_error"),pcb_error_id:Ai("pcb_error"),error_type:FA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:J(),pcb_component_ids:be(J()),subcircuit_id:J().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Tct=TA({type:FA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Ai("pcb_port_not_connected_error"),error_type:FA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:J(),pcb_port_ids:be(J()),pcb_component_ids:be(J()),subcircuit_id:J().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),Kct=TA({type:FA("pcb_net"),pcb_net_id:Ai("pcb_net"),source_net_id:J().optional(),highlight_color:J().optional()}).describe("Defines a net on the PCB"),qct=TA({type:FA("pcb_via"),pcb_via_id:Ai("pcb_via"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),subcircuit_connectivity_map_key:J().optional(),x:wt,y:wt,outer_diameter:wt.default("0.6mm"),hole_diameter:wt.default("0.25mm"),from_layer:Zr.optional(),to_layer:Zr.optional(),layers:be(Zr),pcb_trace_id:J().optional(),net_is_assignable:Be().optional(),net_assigned:Be().optional(),is_tented:Be().optional()}).describe("Defines a via on the PCB"),Pct=TA({type:FA("pcb_board"),pcb_board_id:Ai("pcb_board"),pcb_panel_id:J().optional(),is_subcircuit:Be().optional(),subcircuit_id:J().optional(),width:ie.optional(),height:ie.optional(),center:Rn,thickness:ie.optional().default(1.4),num_layers:jA().optional().default(4),outline:be(Rn).optional(),shape:lt(["rect","polygon"]).optional(),material:lt(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),Oct=TA({type:FA("pcb_panel"),pcb_panel_id:Ai("pcb_panel"),width:ie,height:ie,center:Rn,covered_with_solder_mask:Be().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),Wct=TA({type:FA("pcb_placement_error"),pcb_placement_error_id:Ai("pcb_placement_error"),error_type:FA("pcb_placement_error").default("pcb_placement_error"),message:J(),subcircuit_id:J().optional()}).describe("Defines a placement error on the PCB"),Zct=TA({type:FA("pcb_trace_hint"),pcb_trace_hint_id:Ai("pcb_trace_hint"),pcb_port_id:J(),pcb_component_id:J(),route:be(Ict),subcircuit_id:J().optional()}).describe("A hint that can be used during generation of a PCB trace"),Vct=TA({type:FA("pcb_silkscreen_line"),pcb_silkscreen_line_id:Ai("pcb_silkscreen_line"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),stroke_width:wt.default("0.1mm"),x1:wt,y1:wt,x2:wt,y2:wt,layer:kw}).describe("Defines a silkscreen line on the PCB"),jct=TA({type:FA("pcb_silkscreen_path"),pcb_silkscreen_path_id:Ai("pcb_silkscreen_path"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),layer:kw,route:be(Rn),stroke_width:ie}).describe("Defines a silkscreen path on the PCB"),zct=TA({type:FA("pcb_silkscreen_text"),pcb_silkscreen_text_id:Ai("pcb_silkscreen_text"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("0.2mm"),pcb_component_id:J(),text:J(),is_knockout:Be().default(!1).optional(),knockout_padding:TA({left:ie,top:ie,bottom:ie,right:ie}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:jA().optional(),layer:Zr,is_mirrored:Be().default(!1).optional(),anchor_position:Rn.default({x:0,y:0}),anchor_alignment:JM.default("center")}).describe("Defines silkscreen text on the PCB"),Xct=TA({type:FA("pcb_copper_text"),pcb_copper_text_id:Ai("pcb_copper_text"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("0.2mm"),pcb_component_id:J(),text:J(),is_knockout:Be().default(!1).optional(),knockout_padding:TA({left:ie,top:ie,bottom:ie,right:ie}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:jA().optional(),layer:Zr,is_mirrored:Be().default(!1).optional(),anchor_position:Rn.default({x:0,y:0}),anchor_alignment:JM.default("center")}).describe("Defines copper text on the PCB"),$ct=TA({type:FA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Ai("pcb_silkscreen_rect"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,width:ie,height:ie,layer:Zr,stroke_width:ie.default("1mm"),corner_radius:ie.optional(),is_filled:Be().default(!0).optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional()}).describe("Defines a silkscreen rect on the PCB"),ABt=TA({type:FA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Ai("pcb_silkscreen_circle"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,radius:ie,layer:kw,stroke_width:ie.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),eBt=TA({type:FA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Ai("pcb_silkscreen_oval"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,radius_x:wt,radius_y:wt,layer:kw}).describe("Defines a silkscreen oval on the PCB"),tBt=TA({type:FA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Ai("pcb_fabrication_note_text"),subcircuit_id:J().optional(),pcb_group_id:J().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("1mm"),pcb_component_id:J(),text:J(),layer:kw,anchor_position:Rn.default({x:0,y:0}),anchor_alignment:lt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:J().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),iBt=TA({type:FA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Ai("pcb_fabrication_note_path"),pcb_component_id:J(),subcircuit_id:J().optional(),layer:Zr,route:be(Rn),stroke_width:ie,color:J().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),nBt=TA({type:FA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Ai("pcb_fabrication_note_rect"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,width:ie,height:ie,layer:kw,stroke_width:ie.default("0.1mm"),corner_radius:ie.optional(),is_filled:Be().optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),color:J().optional()}).describe("Defines a fabrication note rectangle on the PCB"),oBt=TA({type:FA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Ai("pcb_fabrication_note_dimension"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),layer:kw,from:Rn,to:Rn,text:J().optional(),text_ccw_rotation:jA().optional(),offset:ie.optional(),offset_distance:ie.optional(),offset_direction:TA({x:jA(),y:jA()}).optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:ie.default("1mm"),color:J().optional(),arrow_size:ie.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),sBt=TA({type:FA("pcb_note_text"),pcb_note_text_id:Ai("pcb_note_text"),pcb_component_id:J().optional(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),name:J().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("1mm"),text:J().optional(),anchor_position:Rn.default({x:0,y:0}),anchor_alignment:lt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:J().optional()}).describe("Defines a documentation note in text on the PCB"),rBt=TA({type:FA("pcb_note_rect"),pcb_note_rect_id:Ai("pcb_note_rect"),pcb_component_id:J().optional(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),name:J().optional(),text:J().optional(),center:Rn,width:ie,height:ie,stroke_width:ie.default("0.1mm"),corner_radius:ie.optional(),is_filled:Be().optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),color:J().optional()}).describe("Defines a rectangular documentation note on the PCB"),aBt=TA({type:FA("pcb_note_path"),pcb_note_path_id:Ai("pcb_note_path"),pcb_component_id:J().optional(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),name:J().optional(),text:J().optional(),route:be(Rn),stroke_width:ie.default("0.1mm"),color:J().optional()}).describe("Defines a polyline documentation note on the PCB"),gBt=TA({type:FA("pcb_note_line"),pcb_note_line_id:Ai("pcb_note_line"),pcb_component_id:J().optional(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),name:J().optional(),text:J().optional(),x1:wt,y1:wt,x2:wt,y2:wt,stroke_width:wt.default("0.1mm"),color:J().optional(),is_dashed:Be().optional()}).describe("Defines a straight documentation note line on the PCB"),IBt=TA({type:FA("pcb_note_dimension"),pcb_note_dimension_id:Ai("pcb_note_dimension"),pcb_component_id:J().optional(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),name:J().optional(),from:Rn,to:Rn,text:J().optional(),text_ccw_rotation:jA().optional(),offset_distance:ie.optional(),offset_direction:TA({x:jA(),y:jA()}).optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:ie.default("1mm"),color:J().optional(),arrow_size:ie.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),cBt=TA({type:FA("pcb_footprint_overlap_error"),pcb_error_id:Ai("pcb_error"),error_type:FA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:J(),pcb_smtpad_ids:be(J()).optional(),pcb_plated_hole_ids:be(J()).optional(),pcb_hole_ids:be(J()).optional(),pcb_keepout_ids:be(J()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),BBt=TA({type:FA("pcb_keepout"),shape:FA("rect"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,width:wt,height:wt,pcb_keepout_id:J(),layers:be(J()),description:J().optional()}).or(TA({type:FA("pcb_keepout"),shape:FA("circle"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,radius:wt,pcb_keepout_id:J(),layers:be(J()),description:J().optional()})),i5=TA({type:FA("pcb_cutout"),pcb_cutout_id:Ai("pcb_cutout"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),pcb_board_id:J().optional(),pcb_panel_id:J().optional()}),lBt=i5.extend({shape:FA("rect"),center:Rn,width:ie,height:ie,rotation:$f.optional(),corner_radius:ie.optional()}),CBt=i5.extend({shape:FA("circle"),center:Rn,radius:ie}),QBt=i5.extend({shape:FA("polygon"),points:be(Rn)}),EBt=i5.extend({shape:FA("path"),route:be(Rn),slot_width:ie,slot_length:ie.optional(),space_between_slots:ie.optional(),slot_corner_radius:ie.optional()}),hBt=Gp("shape",[lBt,CBt,QBt,EBt]).describe("Defines a cutout on the PCB, removing board material."),uBt=TA({type:FA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Ai("pcb_missing_footprint_error"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),error_type:FA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:J(),message:J()}).describe("Defines a missing footprint error on the PCB"),dBt=TA({type:FA("external_footprint_load_error"),external_footprint_load_error_id:Ai("external_footprint_load_error"),pcb_component_id:J(),source_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),footprinter_string:J().optional(),error_type:FA("external_footprint_load_error").default("external_footprint_load_error"),message:J()}).describe("Defines an error when an external footprint fails to load"),pBt=TA({type:FA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Ai("circuit_json_footprint_load_error"),pcb_component_id:J(),source_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),error_type:FA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:J(),circuit_json:be(vI()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),fBt=TA({type:FA("pcb_group"),pcb_group_id:Ai("pcb_group"),source_group_id:J(),is_subcircuit:Be().optional(),subcircuit_id:J().optional(),width:ie.optional(),height:ie.optional(),center:Rn,display_offset_x:J().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:J().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:be(Rn).optional(),anchor_position:Rn.optional(),anchor_alignment:JM.default("center"),position_mode:lt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:J().optional(),positioned_relative_to_pcb_board_id:J().optional(),pcb_component_ids:be(J()),child_layout_mode:lt(["packed","none"]).optional(),name:J().optional(),description:J().optional(),layout_mode:J().optional(),autorouter_configuration:TA({trace_clearance:ie}).optional(),autorouter_used_string:J().optional()}).describe("Defines a group of components on the PCB"),yBt=TA({type:FA("pcb_autorouting_error"),pcb_error_id:Ai("pcb_autorouting_error"),error_type:FA("pcb_autorouting_error").default("pcb_autorouting_error"),message:J(),subcircuit_id:J().optional()}).describe("The autorouting has failed to route a portion of the board"),mBt=TA({type:FA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Ai("pcb_manual_edit_conflict_warning"),warning_type:FA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:J(),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),source_component_id:J()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),wBt=TA({type:FA("pcb_breakout_point"),pcb_breakout_point_id:Ai("pcb_breakout_point"),pcb_group_id:J(),subcircuit_id:J().optional(),source_trace_id:J().optional(),source_port_id:J().optional(),source_net_id:J().optional(),x:wt,y:wt}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),DBt=TA({type:FA("pcb_ground_plane"),pcb_ground_plane_id:Ai("pcb_ground_plane"),source_pcb_ground_plane_id:J(),source_net_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional()}).describe("Defines a ground plane on the PCB"),SBt=TA({type:FA("pcb_ground_plane_region"),pcb_ground_plane_region_id:Ai("pcb_ground_plane_region"),pcb_ground_plane_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),layer:Zr,points:be(Rn)}).describe("Defines a polygon region of a ground plane"),bBt=TA({type:FA("pcb_thermal_spoke"),pcb_thermal_spoke_id:Ai("pcb_thermal_spoke"),pcb_ground_plane_id:J(),shape:J(),spoke_count:jA(),spoke_thickness:wt,spoke_inner_diameter:wt,spoke_outer_diameter:wt,pcb_plated_hole_id:J().optional(),subcircuit_id:J().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),llA=TA({type:FA("pcb_copper_pour"),pcb_copper_pour_id:Ai("pcb_copper_pour"),pcb_group_id:J().optional(),subcircuit_id:J().optional(),layer:Zr,source_net_id:J().optional(),covered_with_solder_mask:Be().optional().default(!0)}),xBt=llA.extend({shape:FA("rect"),center:Rn,width:ie,height:ie,rotation:$f.optional()}),kBt=llA.extend({shape:FA("brep"),brep_shape:act}),GBt=llA.extend({shape:FA("polygon"),points:be(Rn)}),FBt=Gp("shape",[xBt,kBt,GBt]).describe("Defines a copper pour on the PCB."),RBt=TA({type:FA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Ai("pcb_component_outside_board_error"),error_type:FA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:J(),pcb_component_id:J(),pcb_board_id:J(),component_center:Rn,component_bounds:TA({min_x:jA(),max_x:jA(),min_y:jA(),max_y:jA()}),subcircuit_id:J().optional(),source_component_id:J().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),NBt=TA({type:FA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Ai("pcb_component_invalid_layer_error"),error_type:FA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:J(),pcb_component_id:J().optional(),source_component_id:J(),layer:Zr,subcircuit_id:J().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),MBt=TA({type:FA("pcb_via_clearance_error"),pcb_error_id:Ai("pcb_error"),error_type:FA("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:J(),pcb_via_ids:be(J()).min(2),minimum_clearance:wt.optional(),actual_clearance:wt.optional(),pcb_center:TA({x:jA().optional(),y:jA().optional()}).optional(),subcircuit_id:J().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),_Bt=TA({type:FA("pcb_courtyard_rect"),pcb_courtyard_rect_id:Ai("pcb_courtyard_rect"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),center:Rn,width:ie,height:ie,layer:kw,color:J().optional()}).describe("Defines a courtyard rectangle on the PCB"),vBt=TA({type:FA("pcb_courtyard_outline"),pcb_courtyard_outline_id:Ai("pcb_courtyard_outline"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),layer:kw,outline:be(Rn).min(2),stroke_width:ie.default("0.1mm"),is_closed:Be().optional(),is_stroke_dashed:Be().optional(),color:J().optional()}).describe("Defines a courtyard outline on the PCB"),UBt=TA({type:FA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Ai("pcb_courtyard_polygon"),pcb_component_id:J(),pcb_group_id:J().optional(),subcircuit_id:J().optional(),layer:kw,points:be(Rn).min(3),color:J().optional()}).describe("Defines a courtyard polygon on the PCB"),LBt=TA({type:FA("cad_component"),cad_component_id:J(),pcb_component_id:J(),source_component_id:J(),position:IlA,rotation:IlA.optional(),size:IlA.optional(),layer:Zr.optional(),subcircuit_id:J().optional(),footprinter_string:J().optional(),model_obj_url:J().optional(),model_stl_url:J().optional(),model_3mf_url:J().optional(),model_gltf_url:J().optional(),model_glb_url:J().optional(),model_step_url:J().optional(),model_wrl_url:J().optional(),model_unit_to_mm_scale_factor:jA().optional(),model_jscad:vI().optional(),show_as_translucent_model:Be().optional()}).describe("Defines a component on the PCB"),HBt=lt(["sinewave","square","triangle","sawtooth"]),YBt=ei([J(),jA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(jA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),JBt=TA({type:FA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:FA(!0).optional().default(!0),positive_source_port_id:J().optional(),negative_source_port_id:J().optional(),positive_source_net_id:J().optional(),negative_source_net_id:J().optional(),voltage:HM}).describe("Defines a DC voltage source for simulation"),TBt=TA({type:FA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:FA(!1),terminal1_source_port_id:J().optional(),terminal2_source_port_id:J().optional(),terminal1_source_net_id:J().optional(),terminal2_source_net_id:J().optional(),voltage:HM.optional(),frequency:alA.optional(),peak_to_peak_voltage:HM.optional(),wave_shape:HBt.optional(),phase:$f.optional(),duty_cycle:YBt.optional()}).describe("Defines an AC voltage source for simulation"),KBt=ei([JBt,TBt]).describe("Defines a voltage source for simulation"),qBt=ei([FA("spice_dc_sweep"),FA("spice_dc_operating_point"),FA("spice_transient_analysis"),FA("spice_ac_analysis")]),PBt=TA({type:FA("simulation_experiment"),simulation_experiment_id:Ai("simulation_experiment"),name:J(),experiment_type:qBt,time_per_step:glA.optional(),start_time_ms:YM.optional(),end_time_ms:YM.optional()}).describe("Defines a simulation experiment configuration"),OBt=TA({type:FA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Ai("simulation_transient_voltage_graph"),simulation_experiment_id:J(),timestamps_ms:be(jA()).optional(),voltage_levels:be(jA()),source_component_id:J().optional(),subcircuit_connectivity_map_key:J().optional(),time_per_step:glA,start_time_ms:YM,end_time_ms:YM,name:J().optional(),color:J().optional()}).describe("Stores voltage measurements over time for a simulation"),WBt=TA({type:FA("simulation_switch"),simulation_switch_id:Ai("simulation_switch"),source_component_id:J().optional(),closes_at:YM.optional(),opens_at:YM.optional(),starts_closed:Be().optional(),switching_frequency:alA.optional()}).describe("Defines a switch for simulation timing control"),ZBt=TA({type:FA("simulation_voltage_probe"),simulation_voltage_probe_id:Ai("simulation_voltage_probe"),source_component_id:J().optional(),name:J().optional(),signal_input_source_port_id:J().optional(),signal_input_source_net_id:J().optional(),reference_input_source_port_id:J().optional(),reference_input_source_net_id:J().optional(),subcircuit_id:J().optional(),color:J().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,n=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&n?A.addIssue({code:Wt.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:Wt.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):n&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:Wt.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:Wt.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),VBt=TA({type:FA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Ai("simulation_unknown_experiment_error"),error_type:FA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:J(),simulation_experiment_id:J().optional(),subcircuit_id:J().optional()}).describe("An unknown error occurred during the simulation experiment.");ei([wIt,yIt,mIt,fIt,SIt,DIt,cZA,aZA,clA,IZA,gZA,BZA,lZA,CZA,hZA,uZA,dZA,mZA,pZA,fZA,yZA,EZA,QZA,xIt,GIt,bIt,wZA,DZA,SZA,FIt,RIt,cct,Bct,uBt,dBt,pBt,mBt,dct,BBt,pct,Kct,Mct,Lct,qct,bct,Nct,Pct,Oct,fBt,Zct,Vct,jct,zct,Xct,$ct,ABt,eBt,Hct,Yct,Wct,Jct,Tct,MBt,iBt,tBt,nBt,oBt,sBt,rBt,aBt,gBt,IBt,yBt,cBt,wBt,hBt,DBt,SBt,bBt,FBt,RBt,NBt,_Bt,vBt,UBt,NIt,OIt,YIt,JIt,TIt,KIt,HIt,WIt,qIt,MIt,VIt,jIt,ZIt,Act,ect,tct,ict,sct,nct,oct,LBt,KBt,PBt,OBt,WBt,ZBt,VBt]);var jBt=Object.defineProperty,zBt=(t,A)=>{for(var e in A)jBt(t,e,{get:A[e],enumerable:!0})},gS={};zBt(gS,{axial:()=>zlt,bga:()=>glt,breakoutheaders:()=>rCt,cap:()=>nlt,dfn:()=>Rlt,diode:()=>ilt,dip:()=>Alt,electrolytic:()=>KEt,hc49:()=>gCt,jst:()=>lEt,led:()=>olt,lqfp:()=>oCt,m2host:()=>sht,melf:()=>yQt,micromelf:()=>SQt,minimelf:()=>CQt,mlp:()=>hlt,ms012:()=>Hlt,ms013:()=>Jlt,msop:()=>mEt,pad:()=>ICt,pinrow:()=>_lt,platedhole:()=>eht,potentiometer:()=>YEt,pushbutton:()=>$lt,qfn:()=>Qlt,qfp:()=>Elt,quad:()=>ZU,res:()=>slt,sma:()=>GQt,smb:()=>LQt,smbf:()=>PEt,smc:()=>TQt,smf:()=>MQt,smtpad:()=>$Et,sod110:()=>QEt,sod123:()=>Wlt,sod123f:()=>OCt,sod123fl:()=>jCt,sod123w:()=>SCt,sod128:()=>nQt,sod323:()=>GCt,sod323f:()=>TCt,sod323fl:()=>kEt,sod323w:()=>DEt,sod523:()=>ECt,sod723:()=>AQt,sod80:()=>yCt,sod882:()=>LCt,sod882d:()=>uQt,sod923:()=>MCt,soic:()=>clt,solderjumper:()=>MEt,son:()=>NEt,sop8:()=>pCt,sot:()=>iht,sot223:()=>OQt,sot23:()=>Dlt,sot23w:()=>eEt,sot25:()=>klt,sot323:()=>VEt,sot363:()=>mlt,sot457:()=>UEt,sot563:()=>Ult,sot723:()=>Klt,sot89:()=>IQt,ssop:()=>dlt,stampboard:()=>eCt,stampreceiver:()=>nCt,to220:()=>BQt,to92:()=>CCt,to92s:()=>rEt,tssop:()=>flt,vssop:()=>pEt});var Cn=(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"}),Ro=(t,A,e,i,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:ya(i),outer_diameter:ya(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),_ZA=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 yx(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var n5=ei([J(),jA()]).transform(t=>yx(t)),XBt=t=>TA({fn:J(),num_pins:jA().optional().default(6),wide:Be().optional(),narrow:Be().optional(),w:n5.optional(),p:n5.default(t.p??"2.54mm"),id:n5.optional(),od:n5.optional()}).transform(A=>(!A.id&&!A.od?Math.abs(A.p-1.27)<.01?(A.id=yx("0.55mm"),A.od=yx("0.95mm")):(A.id=yx("1.0mm"),A.od=yx("1.5mm")):A.id?A.od||(A.od=A.id*(1.5/1)):A.id=A.od*(1/1.5),A.w||(A.wide?A.w=yx("600mil"):A.narrow?A.w=yx("300mil"):A.w=yx(t.w??"300mil")),A)),$Bt=XBt({}),vZA=(t,A,e,i)=>{const n=t/2,o=A<=n,s=n-1,r=i,a=r*s;return o?{x:-e/2,y:a/2-(A-1)*r}:{x:e/2,y:-a/2+(A-n-1)*r}},Alt=t=>{const A=$Bt.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:I,y:c}=vZA(A.num_pins,g+1,A.w,A.p??2.54);e.push(Ro(g+1,I,c,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},..._ZA.map(({x:g,y:I})=>({x:g*n/6,y:I*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 I=g<A.num_pins/2,c=.6,{y:B}=vZA(A.num_pins,g+1,A.w,A.p??2.54),l=I?-A.w/2-A.od/2-c:A.w/2+A.od/2+c,C=B;r.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${g+1}`,layer:"top",pcb_component_id:`pin_${g+1}`,text:`{pin${g+1}}`,anchor_position:{x:l,y:C},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Cn(0,o/2+.5,.4);return{circuitJson:[...e,s,a,...r],parameters:A}},xi=(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()]}),UZA=[{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}],elt=Object.fromEntries(UZA.map(t=>[t.metric,t])),tlt=Object.fromEntries(UZA.map(t=>[t.imperial,t]));TA({tht:Be(),p:ie.optional(),pw:ie.optional(),ph:ie.optional(),metric:wt.optional(),imperial:wt.optional(),w:ie.optional(),h:ie.optional(),textbottom:Be().optional()});var o5=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=WU(r)),typeof a=="string"&&(a=WU(a)),typeof e=="string"&&(e=WU(e)),typeof i=="string"&&(i=WU(i)),typeof n=="string"&&(n=WU(n)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let I;if(o&&(I=elt[o]),s&&(I=tlt[s]),I&&(r=I.w_mm_min,a=I.h_mm_min,e=I.p_mm_min,i=I.pw_mm_min,n=I.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 c={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:""},B=g?-n/2-.9:n/2+.9,l=Cn(0,B,.2);return A?[Ro(1,-e/2,0,i,i*1/.8),Ro(2,e/2,0,i,i*1/.8),c,l]:[xi(["1","left"],-e/2,0,i,n),xi(["2","right"],e/2,0,i,n),c,l]},ilt=t=>({circuitJson:o5(t),parameters:t}),nlt=t=>({circuitJson:o5(t),parameters:t}),olt=t=>({circuitJson:o5(t),parameters:t}),slt=t=>({circuitJson:o5(t),parameters:t}),LZA=(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()]}),HZA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",YZA=J().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A),y:parseFloat(e)}}).pipe(TA({x:jA(),y:jA()})),rlt=J().or(be(vI())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(A=>{const e=Number(A);return isNaN(e)?A:e}))).pipe(be(J().or(jA()))),alt=TA({fn:J(),num_pins:jA().optional().default(64),grid:YZA.optional(),p:wt.default("0.8mm"),w:ie.optional(),h:ie.optional(),ball:ie.optional().describe("ball diameter"),pad:ie.optional().describe("pad width/height"),circularpads:Be().optional().describe("use circular pads"),tlorigin:Be().optional(),blorigin:Be().optional(),trorigin:Be().optional(),brorigin:Be().optional(),missing:rlt.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=HZA.indexOf(n[1]),s=Number.parseInt(n[2])-1;return o*t.grid.x+s+1})),{...t,origin:A}}),glt=t=>{const A=alt.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 I=[],c=(g??[]).filter(w=>typeof w=="number"),B=i.x*i.y-e;if(g.length===0&&B>0&&(Math.sqrt(B)%1===0?g.push("center"):B===1&&g.push("topleft")),g?.includes("center")){const w=Math.floor(Math.sqrt(B)),S=Math.floor((i.x-w)/2),D=Math.floor((i.y-w)/2);for(let x=D;x<D+w;x++)for(let F=S;F<S+w;F++)c.push(x*i.x+F+1)}g?.includes("topleft")&&c.push(1);const l=new Set(c);let C=0;for(let w=0;w<i.y;w++)for(let S=0;S<i.x;S++){const D=(S-(i.x-1)/2)*n,x=(w-(i.y-1)/2)*n;let F=S,k=w;switch(A.origin){case"bl":F=S,k=i.y-1-w;break;case"br":F=i.x-1-S,k=i.y-1-w;break;case"tr":F=i.x-1-S,k=w;break}let v=k*i.x+F+1;if(l.has(v)){C++;continue}v-=C;const M=[v,`${HZA[k]}${F+1}`];I.push(A.circularpads?LZA(M,{x:D,y:x,radius:a/2}):xi(M,D,x,a,a))}const Q=Cn(0,i.y*n/2,.2),E=n/6;let h;const u=i.x*n/2,d=i.y*n/2;switch(A.origin){case"bl":h=[{x:-u,y:-d},{x:-u,y:-d-E},{x:-u-E,y:-d},{x:-u,y:-d}];break;case"br":h=[{x:u,y:-d},{x:u,y:-d-E},{x:u+E,y:-d},{x:u,y:-d}];break;case"tr":h=[{x:u,y:d},{x:u,y:d+E},{x:u+E,y:d},{x:u,y:d}];break;default:h=[{x:-u,y:d},{x:-u,y:d+E},{x:-u-E,y:d},{x:-u,y:d}];break}const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:h,stroke_width:.05};return{circuitJson:[...I,Q,f],parameters:A}},s5=(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()]}),mm=t=>TA({fn:J(),num_pins:jA().optional().default(8),w:ie.default(ie.parse(t.w??"5.3mm")),p:ie.default(ie.parse(t.p??"1.27mm")),pw:ie.default(ie.parse(t.pw??"0.6mm")),pl:ie.default(ie.parse(t.pl??"1.0mm")),legsoutside:Be().optional().default(t.legsoutside??!1),pillpads:Be().optional().default(t.pillpads??!1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=ie.parse("0.6mm"),A.pl=ie.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),Ilt=mm({}),ClA=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,I=n,c=I*g,B=s?o/2:-o/2;return a?{x:-i/2-B,y:c/2-(e-1)*I}:{x:i/2+B,y:-c/2+(e-r-1)*I}},clt=t=>{const A=Ilt.parse(t);return{circuitJson:IS(A),parameters:A}},IS=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=ClA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push(s5(r+1,a,g,t.pl,t.pw)):A.push(xi(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=Cn(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:.1,route:[{x:-i/2,y:-n/2},{x:-i/2,y:n/2},..._ZA.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]},JZA=lt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),Blt=({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},QlA=TA({fn:J(),cc:Be().default(!0).optional(),ccw:Be().default(!0).optional(),startingpin:J().or(be(JZA)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(be(JZA)).optional(),num_pins:jA().optional().default(64),w:ie.optional(),h:ie.optional(),p:ie.default(ie.parse("0.5mm")),pw:ie.optional(),pl:ie.optional(),thermalpad:ei([FA(!0),YZA]).optional(),legsoutside:Be().default(!1)}),ElA=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},TZA=QlA.transform(ElA),llt=["left","bottom","right","top"],Clt=t=>{const{pin_count:A,pn:e,w:i,h:n,p:o,pl:s,legsoutside:r}=t,a=A/4,g=llt[Math.floor((e-1)/a)],I=(e-1)%a,c=o*(a-1),B=o*(a-1),l=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-l,y:B/2-I*o,o:"vert"};case"bottom":return{x:-c/2+I*o,y:-n/2-l,o:"horz"};case"right":return{x:i/2+l,y:-B/2+I*o,o:"vert"};case"top":return{x:c/2-I*o,y:n/2+l,o:"horz"};default:throw new Error("Invalid pin number")}},ZU=t=>{const A=TZA.parse(t),e=[],i=Blt(A),n=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:I}=Clt({pin_count:A.num_pins,pn:r+1,w:A.w,h:A.h,p:A.p??.5,pl:A.pl,legsoutside:A.legsoutside});let c=A.pw,B=A.pl;I==="vert"&&([c,B]=[B,c]);const l=i[r+1];e.push(xi(l,a,g,c,B))}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(xi(["thermalpad"],0,0,r,a))}else e.push(xi(["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 I=A.w/2*a,c=A.h/2*g;let B="none",l=I,C=c;const Q=A.pw*2;i[1]===1&&r==="top-left"?B="in1":i[n*4]===1&&r==="top-left"||i[n*3+1]===1&&r==="top-right"?B="in2":i[n*3]===1&&r==="top-right"||i[n]===1&&r==="bottom-left"?B="in1":i[n+1]===1&&r==="bottom-left"?B="in2":i[n*2]===1&&r==="bottom-right"?B="in1":i[n*2+1]===1&&r==="bottom-right"&&(B="in2");const E=B==="in1"?1:-1;if(A.legsoutside){const h=B==="in1"?A.pl/2:A.pw/2,u=B==="in1"?A.pw/2:A.pl/2;l+=h*a*E,C-=u*g*E}(B==="none"||A.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:I-Q*a,y:c},{x:I,y:c},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&!A.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:I-Q*a,y:c},{x:I-Q*a/2,y:c}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:I,y:c-Q*g/2},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:l-.2*-a,y:C+.2*E},{x:l,y:C},{x:l+.2*E*-a,y:C+.2},{x:l-.2*-a,y:C+.2*E}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Cn(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...o,s],parameters:A}};QlA.extend({}).transform(ElA);var Qlt=t=>(t.legsoutside=!1,ZU(t)),Elt=t=>{t.legsoutside=!0;const A=TZA.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 ZU(t)};QlA.extend({}).transform(ElA);var hlt=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),ZU(t)),ult=mm({w:"3.9mm",p:"1.27mm"}),dlt=t=>{const A=ult.parse(t);return{circuitJson:IS(A),parameters:A}},plt=mm({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),flt=t=>{const A=plt.parse(t);return{circuitJson:IS(A),parameters:A}},ylt=mm({}),mlt=t=>{const A=ylt.parse({fn:"sot363",num_pins:6,w:1.94,p:.65,pw:.3,pl:.7,legoutside:!0});return{circuitJson:IS(A),parameters:A}},KZA=TA({fn:J(),num_pins:jA().default(3),w:J().default("1.92mm"),h:J().default("2.74mm"),pl:J().default("0.8mm"),pw:J().default("0.764mm"),p:J().default("0.95mm"),string:J().optional()}),wlt=mm({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Dlt=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const n=wlt.parse({...t,num_pins:e});return{circuitJson:IS(n),parameters:n}}const i=KZA.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:blt(i),parameters:i};if(i.num_pins===5)return{circuitJson:PZA(i),parameters:i};throw new Error("Invalid number of pins")},Slt=t=>{const{pn:A}=t;return A===1?{x:-1.7,y:0}:A===2?{x:1.7,y:-.95}:{x:1.7,y:.95}},blt=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:n,y:o}=Slt({num_pins:t.num_pins,pn:i+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});A.push(xi(i+1,n,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Cn(0,Number.parseInt(t.h),.3);return[...A,e]},qZA=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")},PZA=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:l}=qZA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(xi(c,B,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),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=Cn(0,i+.3,.3),r=qZA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,n,o,I]},xlt=KZA.extend({}),klt=t=>{const A=xlt.parse({...t,num_pins:5});return{circuitJson:PZA(A),parameters:A}},Glt=[{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}],Flt=mm({}),Rlt=t=>{const A=Flt.parse(t),e=[];for(let c=0;c<A.num_pins;c++){const{x:B,y:l}=ClA({num_pins:A.num_pins,pn:c+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(xi(c+1,B,l,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 c of Glt){const{dx:B,dy:l}=c;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:B*n/2-B*A.p,y:l*o/2},{x:B*n/2,y:l*o/2},{x:B*n/2,y:l*o/2-l*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 I=Cn(0,o/2+.4,o/12);return{circuitJson:[...e,I,...s],parameters:A}},r5=(t,A,e,i,n,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:A,y:e,hole_diameter:ya(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:ya(n),rect_pad_height:ya(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),hlA=({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 Nlt({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 Mlt=TA({fn:J(),num_pins:jA().optional().default(6),rows:ei([J(),jA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:ie.default("0.1in").describe("pitch"),id:ie.default("1.0mm").describe("inner diameter"),od:ie.default("1.5mm").describe("outer diameter"),male:Be().optional().describe("for male pin headers"),female:Be().optional().describe("for female pin headers"),pinlabeltextalignleft:Be().optional().default(!1),pinlabeltextaligncenter:Be().optional().default(!1),pinlabeltextalignright:Be().optional().default(!1),pinlabelverticallyinverted:Be().optional().default(!1),pinlabelorthogonal:Be().optional().default(!1),nosquareplating:Be().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Be().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Be().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Be().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=Nlt(t);return{...t,pinlabelAnchorSide:A,male:t.male??!t.female,female:t.female??!1}}).superRefine((t,A)=>{t.male&&t.female&&A.addIssue({code:Wt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),_lt=t=>{const A=Mlt.parse(t),{p:e,id:i,od:n,rows:o,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:I,pinlabeltextalignright:c,nopinlabels:B,doublesidedpinlabel:l,bottomsidepinlabel:C}=A;let Q="center";I?Q="left":c&&(Q="right");const E=[],h=Math.ceil(s/o),u=-e,d=({xoff:x,yoff:F,od:k,anchorSide:v})=>{let M=0,L=0;const K=k*.75;switch(v){case"right":M=K;break;case"top":L=K;break;case"bottom":L=-K;break;case"left":M=-K;break}return{anchor_x:x+M,anchor_y:F+L}},f=(x,F,k)=>{x===1&&!A.nosquareplating?E.push(r5(x,F,k,i,n,n)):E.push(Ro(x,F,k,i,n));const{anchor_x:v,anchor_y:M}=d({xoff:F,yoff:k,od:n,anchorSide:r});B||(C?E.push(hlA({fs:n/5,pn:x,anchor_x:v,anchor_y:M,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):E.push(hlA({fs:n/5,pn:x,anchor_x:v,anchor_y:M,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),l&&E.push(hlA({fs:n/5,pn:x,anchor_x:v,anchor_y:M,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},w=new Set,S=o>2&&h>2;if(o===1){const x=-((s-1)/2)*e;for(let F=0;F<s;F++){const k=F+1,v=x+F*e,M=`${v},0`;if(w.has(M))throw new Error(`Overlap at ${M}`);w.add(M),f(k,v,0)}}else if(S){const x=-((h-1)/2)*e;let F=1;for(let k=0;k<o&&F<=s;k++)for(let v=0;v<h&&F<=s;v++){const M=x+v*e,L=k*u,K=`${M},${L}`;if(w.has(K))throw new Error(`Overlap at ${K}`);w.add(K),f(F++,M,L)}}else{const x=-((h-1)/2)*e;let F=1,k=0,v=o-1,M=0,L=h-1;for(;F<=s&&k<=v&&M<=L;){for(let K=k;K<=v&&F<=s;K++){const Y=x+M*e,W=K*u,Z=`${Y},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,Y,W)}M++;for(let K=M;K<=L&&F<=s;K++){const Y=x+K*e,W=v*u,Z=`${Y},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,Y,W)}if(v--,M<=L){for(let K=v;K>=k&&F<=s;K--){const Y=x+L*e,W=K*u,Z=`${Y},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,Y,W)}L--}if(k<=v){for(let K=L;K>=M&&F<=s;K--){const Y=x+K*e,W=k*u,Z=`${Y},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,Y,W)}k++}}if(F-1<s)throw new Error(`Missing pins: assigned ${F-1}, expected ${s}`)}const D=Cn(0,e,.5);return{circuitJson:[...E,D],parameters:A}},vlt=mm({}),Ult=t=>{const A=vlt.parse({fn:"sot563",num_pins:6,w:1.94,p:.5,pw:.3,pl:.67,legoutside:!0});return{circuitJson:IS(A),parameters:A}},Llt=mm({p:"1.27mm",w:"3.9mm",legsoutside:!0}),Hlt=t=>{const A=Llt.parse({...t,num_pins:8});return{circuitJson:IS(A),parameters:A}},Ylt=mm({p:"1.27mm",w:"7.5mm",legsoutside:!0}),Jlt=t=>{const A=Ylt.parse({...t,num_pins:16});return{circuitJson:IS(A),parameters:A}},Tlt=TA({fn:J(),num_pins:FA(3).default(3),w:J().default("1.2mm"),h:J().default("1.2mm"),pl:J().default("0.3mm"),pw:J().default("0.32mm")}),Klt=t=>{const A=Tlt.parse(t),e=Plt(A),i=Cn(.4,ie.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},qlt=t=>{const{pn:A}=t;return A===1?{x:0,y:0}:A===2?{x:1,y:-.4}:{x:1,y:.4}},Plt=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:n}=qlt({num_pins:t.num_pins,pn:e+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl)});A.push(xi(e+1,i,n,Number.parseFloat(t.pl),e!==0?Number.parseFloat(t.pw):.42))}return A},Olt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("2.36mm"),h:J().default("1.22mm"),pl:J().default("0.9mm"),pw:J().default("0.9mm"),p:J().default("4.19mm")}),Wlt=t=>{const A=Olt.parse(t),e=Cn(0,ie.parse(A.h)/4+.4,.3);return{circuitJson:Vlt(A).concat(e),parameters:A}},Zlt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Vlt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Zlt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},jlt=TA({fn:J(),p:ie.optional().default("2.54mm"),id:ie.optional().default("0.7mm"),od:ie.optional().default("1mm")}),zlt=t=>{const A=jlt.parse(t),{p:e,id:i,od:n}=A,o=[Ro(1,-e/2,0,i,n),Ro(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=Cn(0,e/4,.5);return{circuitJson:[...o,s,r],parameters:A}},a5=(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}),Xlt=TA({fn:FA("pushbutton"),w:ie.default(4.5),h:ie.default(6.5),id:ie.default(1),od:ie.default(1.2)}),$lt=t=>{const A=Xlt.parse(t),e=A.w,i=A.h,n=A.id,o=[Ro(1,-e/2,i/2,n,n*1.5),Ro(2,-e/2,-i/2,n,n*1.5),Ro(3,e/2,-i/2,n,n*1.5),Ro(4,e/2,i/2,n,n*1.5)],s=[a5([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),a5([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),a5([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),a5([{x:e/2,y:0},{x:e/5,y:0}])],r=Cn(0,i/2+.4,.5);return{circuitJson:[...o,...s,r],parameters:A}},OZA=TA({fn:J(),w:ie.default("22.58mm"),h:ie.optional(),left:ie.optional().default(20),right:ie.optional().default(20),top:ie.optional().default(2),bottom:ie.optional().default(2),p:ie.default(ie.parse("2.54mm")),pw:ie.default(ie.parse("1.6mm")),pl:ie.default(ie.parse("2.4mm")),innerhole:Be().default(!1),innerholeedgedistance:ie.default(ie.parse("1.61mm")),silkscreenlabels:Be().default(!1),silkscreenlabelmargin:ie.default(ie.parse("0.1mm"))}),ACt=t=>{const A=OZA.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},g5=(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},eCt=t=>{const A=OZA.parse(t),e=A.h??ACt(A),i=[],n=[],o=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),c=`pin${g}`.length*.7/2;if(A.right){const Q=-((A.right-1)/2)*A.p;for(let E=0;E<A.right;E++){if(E===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=g5(A.w/2-A.pl*1.4,Q+E*A.p,"right")),i.push(xi(E+1+A.left+(A.bottom??0),A.w/2-A.pl/2,Q+E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+1+A.left+(A.bottom??0),u=`pin${h}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl-(c+A.silkscreenlabelmargin),y:Q+E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(Ro(E+1+A.left+(A.bottom??0)+g,A.w/2,Q+E*A.p,r,a)),n.push(Ro(E+1+A.left+(A.bottom??0)+g*2,A.w/2-A.innerholeedgedistance,Q+E*A.p,r,a)))}}if(A.left){const Q=(A.left-1)/2*A.p;for(let E=0;E<A.left;E++){if(E===0&&!A.silkscreenlabels&&(s=g5(-A.w/2+A.pl*1.4,Q-E*A.p,"left")),i.push(xi(E+1,-A.w/2+A.pl/2,Q-E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+1,u=`pin${h}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl+(c+A.silkscreenlabelmargin),y:Q-E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(Ro(E+1+g,-A.w/2,Q-E*A.p,r,a)),n.push(Ro(E+1+g*2,-A.w/2+A.innerholeedgedistance,Q-E*A.p,r,a)))}}if(A.top){const Q=(A.top-1)/2*A.p;for(let E=0;E<A.top;E++){if(E===0&&!A.left&&!A.bottom&&!A.right&&!A.silkscreenlabels&&(s=g5(Q-E*A.p,e/2-A.pl*1.4,"top")),i.push(xi(E+1+A.left+A.right+(A.bottom??0),Q-E*A.p,e/2-A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+1+A.left+A.right+(A.bottom??0),u=`pin${h}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q-E*A.p,y:e/2-A.pl-(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(n.push(Ro(E+1+A.left+A.right+(A.bottom??0)+g,Q-E*A.p,e/2,r,a)),n.push(Ro(E+1+A.left+A.right+(A.bottom??0)+g*2,Q-E*A.p,e/2-A.innerholeedgedistance,r,a)))}}if(A.bottom){const Q=-((A.bottom-1)/2)*A.p;for(let E=0;E<A.bottom;E++){if(E===0&&!A.left&&!A.silkscreenlabels&&(s=g5(Q+E*A.p,-e/2+A.pl*1.4,"bottom")),i.push(xi(E+1+A.left,Q+E*A.p,-e/2+A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+1+A.left,u=`pin${h}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q+E*A.p,y:-e/2+A.pl+(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(n.push(Ro(E+1+A.left+g,Q+E*A.p,-e/2,r,a)),n.push(Ro(E+1+A.left+g*2,Q+E*A.p,-e/2+A.innerholeedgedistance,r,a)))}}const B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2,y:e/2},{x:A.w/2,y:e/2},{x:A.w/2,y:-e/2},{x:-A.w/2,y:-e/2},{x:-A.w/2,y:e/2}],stroke_width:.1,layer:"top"},C=Cn(0,e/1.8,e/25);return{circuitJson:[...i,...n,...o,l,...A.silkscreenlabels?[]:[B],C],parameters:A}},WZA=TA({fn:J(),w:ie.default("22.58mm"),h:ie.optional(),left:ie.optional().default(20),right:ie.optional().default(20),top:ie.optional().default(2),bottom:ie.optional().default(2),p:ie.default(ie.parse("2.54mm")),pw:ie.default(ie.parse("1.6mm")),pl:ie.default(ie.parse("3.2mm")),innerhole:Be().default(!1),innerholeedgedistance:ie.default(ie.parse("1.61mm"))}),tCt=t=>{const A=WZA.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},iCt=(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]},nCt=t=>{const A=WZA.parse(t),e=A.h??tCt(A),i=[],n=[],o=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],I=1;if(A.left){const C=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++)Q===0&&(g=iCt(-A.w/2-A.pl/2,C-Q*A.p,"left")),i.push(xi(I,-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_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:C-Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Ro(I+a,-A.w/2+A.innerholeedgedistance,C-Q*A.p,s,r))}if(A.bottom){const C=(A.bottom-1)/2*A.p;for(let Q=A.bottom-1;Q>=0;Q--)i.push(xi(I,C-Q*A.p,-e/2+A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C-Q*A.p,y:-e/2+A.pl/2-3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Ro(I+a,C-Q*A.p,-e/2+A.innerholeedgedistance,s,r))}if(A.right){const C=-((A.right-1)/2)*A.p;for(let Q=0;Q<A.right;Q++)i.push(xi(I,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_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:C+Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Ro(I+a,A.w/2-A.innerholeedgedistance,C+Q*A.p,s,r))}if(A.top){const C=-((A.top-1)/2)*A.p;for(let Q=A.top-1;Q>=0;Q--)i.push(xi(I,C+Q*A.p,e/2-A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C+Q*A.p,y:e/2-A.pl/2+3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Ro(I+a,C+Q*A.p,e/2-A.innerholeedgedistance,s,r))}const c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:g,stroke_width:.1},B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:e/2+A.pl/3}],stroke_width:.1,layer:"top"},l=Cn(0,e/1.8,e/25);return{circuitJson:[...o,...i,...n,B,c,l],parameters:A}},oCt=t=>(t.legsoutside=!0,ZU(t)),ZZA=TA({fn:J(),w:ie.default("10mm"),h:ie.optional(),left:ie.optional().default(20),right:ie.optional().default(20),top:ie.optional().default(0),bottom:ie.optional().default(0),p:ie.default(ie.parse("2.54mm")),id:ie.optional().default(ie.parse("1mm")),od:ie.optional().default(ie.parse("1.5mm"))}),sCt=t=>{const A=ZZA.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},I5=(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]},rCt=t=>{const A=ZZA.parse(t),e=A.h??sCt(A),i=[],n=A.id,o=A.od;let s=[];if(A.right){const I=-((A.right-1)/2)*A.p;for(let c=0;c<A.right;c++)c===0&&!A.left&&!A.bottom&&(s=I5(A.w/2+o*1.4,I+c*A.p,"right")),i.push(Ro(c+1+A.left+(A.bottom??0),A.w/2,I+c*A.p,n,o))}if(A.left){const I=-((A.left-1)/2)*A.p;for(let c=0;c<A.left;c++)c===A.left-1&&(s=I5(-A.w/2-o*1.4,I+c*A.p,"left")),i.push(Ro(c+1,-A.w/2,I+c*A.p,n,o))}if(A.top){const I=-((A.top-1)/2)*A.p;for(let c=0;c<A.top;c++)c===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=I5(I+c*A.p,e/2+o*1.4,"top")),i.push(Ro(c+1+A.right+(A.bottom??0)+A.left,I+c*A.p,e/2,n,o))}if(A.bottom){const I=-((A.bottom-1)/2)*A.p;for(let c=0;c<A.bottom;c++)c===0&&!A.left&&(s=I5(I+c*A.p,-e/2-o*1.4,"bottom")),i.push(Ro(c+1+A.left,I+c*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=Cn(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},VZA=(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}}),aCt=TA({fn:J(),p:ie.optional().default("4.88mm"),id:ie.optional().default("0.6mm"),od:ie.optional().default("1.2mm"),w:ie.optional().default("5.6mm"),h:ie.optional().default("3.5mm")}),gCt=t=>{const A=aCt.parse(t),{p:e,id:i,od:n,w:o,h:s}=A,r=s/2,a=[Ro(1,-e/2,0,i,n),Ro(2,e/2,0,i,n)],g=VZA(-o/2,0,r,"left"),I=VZA(o/2,0,r,"right"),c={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},...I,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},B=Cn(0,e/4,.5);return{circuitJson:[...a,c,B],parameters:A}};TA({w:ie,h:ie});var ICt=t=>{const{w:A,h:e}=t,i=ya(A),n=ya(e);return{circuitJson:[xi(1,0,0,i,n),Cn(0,n/2+.5,.2)],parameters:t}},cCt=TA({fn:J(),num_pins:ei([FA(3),FA(2)]).default(3),p:J().default("1.27mm"),id:J().default("0.72mm"),od:J().default("0.95mm"),w:J().default("4.5mm"),h:J().default("4.5mm"),inline:Be().default(!1),string:J().optional()}),BCt=(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}}),lCt=t=>{const{p:A,id:e,od:i,h:n}=t,o=Number.parseFloat(n)/2,s=Number.parseFloat(A);return[Ro(1,-s,o-s,e,i),Ro(2,s,o-s,e,i)]},CCt=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=cCt.parse({...t,num_pins:e}),{p:n,id:o,od:s,w:r,h:a,inline:g}=i,I=Number.parseFloat(a)/2,c=Number.parseFloat(n);let B=[];if(i.num_pins===3)B=g?[Ro(1,-c,I-c,o,s),Ro(2,0,I-c,o,s),Ro(3,c,I-c,o,s)]:[Ro(1,0,I,o,s),Ro(2,-c,I-c,o,s),Ro(3,c,I-c,o,s)];else if(i.num_pins===2)B=lCt(i);else throw new Error("Invalid number of pins for TO-92");const l=Number.parseFloat(r)/2,C=BCt(0,I,l),Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...C,{x:-l,y:0},{x:l,y:0},C[0]],stroke_width:.1,pcb_silkscreen_path_id:""},E=Cn(0,I+1,.5);return{circuitJson:[...B,Q,E],parameters:i}},QCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("2.15mm"),h:J().default("1.20mm"),pl:J().default("0.5mm"),pw:J().default("0.6mm"),p:J().default("1.4mm")}),ECt=t=>{const A=QCt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:uCt(A).concat(i,e),parameters:A}},hCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},uCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=hCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},dCt=mm({}),pCt=t=>{const A=dCt.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=ClA({num_pins:A.num_pins,pn:s+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(xi(s+1,r,a,A.pl??"1.5mm",A.pw??"0.6mm"))}const i=(A.num_pins/2-1)*A.p+A.pw,n=Cn(0,i/2-.5,i/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-A.w/3,y:i/2+.2},{x:A.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...e,n,o],parameters:A}},fCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("5.0mm"),h:J().default("2.30mm"),pl:J().default("1.25mm"),pw:J().default("2mm"),p:J().default("3.75mm")}),yCt=t=>{const A=fCt.parse(t),e=Cn(0,ie.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.5,y:ie.parse(A.h)/2+.5},{x:-ie.parse(A.w)/2-.5,y:ie.parse(A.h)/2+.5},{x:-ie.parse(A.w)/2-.5,y:-ie.parse(A.h)/2-.5},{x:ie.parse(A.p)/2+.5,y:-ie.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:wCt(A).concat(i,e),parameters:A}},mCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},wCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=mCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},DCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("4.4mm"),h:J().default("2.1mm"),pl:J().default("1.2mm"),pw:J().default("1.2mm"),p:J().default("2.9mm")}),SCt=t=>{const A=DCt.parse(t),e=Cn(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:xCt(A).concat(i,e),parameters:A}},bCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},xCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=bCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},kCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("3.30mm"),h:J().default("1.80mm"),pl:J().default("0.60mm"),pw:J().default("0.45mm"),p:J().default("2.1mm")}),GCt=t=>{const A=kCt.parse(t),e=Cn(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:RCt(A).concat(i,e),parameters:A}},FCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},RCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=FCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},NCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("1.4mm"),h:J().default("0.9mm"),pl:J().default("0.35mm"),pw:J().default("0.25mm"),p:J().default("1.2mm")}),MCt=t=>{const A=NCt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.15,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.4,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.4,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2+.15,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:vCt(A).concat(i,e),parameters:A}},_Ct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},vCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=_Ct({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},UCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("1.3mm"),h:J().default("0.9mm"),pl:J().default("0.4mm"),pw:J().default("0.7mm"),p:J().default("0.7mm")}),LCt=t=>{const A=UCt.parse(t),e=Cn(0,ie.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.2,y:ie.parse(A.h)/2+.2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2+.2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2-.2},{x:ie.parse(A.p)/2+.2,y:-ie.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:YCt(A).concat(i,e),parameters:A}},HCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},YCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=HCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},JCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("3,05mm"),h:J().default("1.65mm"),pl:J().default("0.6mm"),pw:J().default("0.6mm"),pad_spacing:J().default("2.2mm")}),TCt=t=>{const A=JCt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.pad_spacing)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.pad_spacing)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:qCt(A).concat(i,e),parameters:A}},KCt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},qCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=KCt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},PCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("4.4mm"),h:J().default("2.1mm"),pl:J().default("1.2mm"),pw:J().default("1.2mm"),p:J().default("2.9mm")}),OCt=t=>{const A=PCt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ZCt(A).concat(i,e),parameters:A}},WCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},ZCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=WCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},VCt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("4.4mm"),h:J().default("2.1mm"),pl:J().default("0.91mm"),pw:J().default("1.22mm"),p:J().default("3.146mm")}),jCt=t=>{const A=VCt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:XCt(A).concat(i,e),parameters:A}},zCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},XCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=zCt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},$Ct=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("1.80mm"),h:J().default("1.00mm"),pl:J().default("0.66mm"),pw:J().default("0.5mm"),p:J().default("0.8mm")}),AQt=t=>{const A=$Ct.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:tQt(A).concat(i,e),parameters:A}},eQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},tQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=eQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},iQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("6.2mm"),h:J().default("3.4mm"),pl:J().default("1.4mm"),pw:J().default("2.1mm"),p:J().default("4.4mm")}),nQt=t=>{const A=iQt.parse(t),e=Cn(0,ie.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:sQt(A).concat(i,e),parameters:A}},oQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},sQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=oQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},rQt=TA({fn:J(),num_pins:ei([FA(3),FA(5)]).default(3),w:J().default("4.80mm"),h:J().default("4.80mm"),pl:J().default("1.3mm"),pw:J().default("0.9mm"),p:J().default("1.5mm"),string:J().optional()}),aQt=t=>{const A=[],e=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),n=Number.parseFloat(t.w),o=Number.parseFloat(t.pl);A.push(xi(1,-n/2,e,o,i),xi(2,-n/2+(1.5-1.3)/2,0,1.5,i),xi(3,-n/2,-e,o,i));const s=Cn(0,0,.3),r=Number.parseFloat(t.w)/2-1,a=Number.parseFloat(t.h)/2,g={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r,y:a},{x:r,y:a},{x:r,y:a/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},I={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-r,y:-a},{x:r,y:-a},{x:r,y:-a/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,g,I,s]},gQt=t=>{const A=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),A.push(xi(1,-1.85,-1.5,1.5,.7),xi(2,-1.85,1.5,1.5,.7),xi(3,0,0,.8,2),xi(4,1.85,-1.5,1.5,.7),xi(5,1.85,1.5,1.5,.7));const e=Cn(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]},IQt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=rQt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:aQt(i),parameters:i};if(i.num_pins===5)return{circuitJson:gQt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},cQt=TA({fn:J(),p:ie.optional().default("5.0mm"),id:ie.optional().default("1.0mm"),od:ie.optional().default("1.9mm"),w:ie.optional().default("13mm"),h:ie.optional().default("7mm"),num_pins:jA().optional(),string:J().optional()}),BQt=t=>{const A=cQt.parse(t),{fn:e,id:i,od:n,w:o,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,I=o/2,c=s/2,B=2.5,l=o*.4,C=Math.max(B,l/(a-1)),Q=Array.from({length:a},(w,S)=>{const D=a%2===0?(S-a/2+.5)*C:(S-Math.floor(a/2))*C;return Ro(S+1,D,g,i,n)}),E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:-c},{x:I,y:-c},{x:I,y:c},{x:-I,y:c},{x:-I,y:-c}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-c+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:h},{x:I,y:h}],stroke_width:.1,pcb_silkscreen_path_id:""},d=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:h},{x:-o/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:h},{x:o/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Cn(0,s/2+.6,.5);return{circuitJson:[...Q,E,u,...d,f],parameters:{...A,p:C}}},lQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("5.40mm"),h:J().default("2.30mm"),pl:J().default("1.30mm"),pw:J().default("1.70mm"),p:J().default("3.5mm")}),CQt=t=>{const A=lQt.parse(t),e=Cn(0,ie.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:EQt(A).concat(i,e),parameters:A}},QQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},EQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=QQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},hQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("1.90mm"),h:J().default("1.33mm"),pl:J().default("0.5mm"),pw:J().default("0.7mm"),p:J().default("0.8mm")}),uQt=t=>{const A=hQt.parse(t),e=Cn(0,ie.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2+.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2+.1,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:pQt(A).concat(i,e),parameters:A}},dQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},pQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=dQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},fQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("7.0mm"),h:J().default("3.35mm"),pl:J().default("1.50mm"),pw:J().default("2.70mm"),p:J().default("4.8mm")}),yQt=t=>{const A=fQt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:wQt(A).concat(i,e),parameters:A}},mQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},wQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=mQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},DQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("3.0mm"),h:J().default("1.80mm"),pl:J().default("0.80mm"),pw:J().default("1.20mm"),p:J().default("1.6mm")}),SQt=t=>{const A=DQt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:xQt(A).concat(i,e),parameters:A}},bQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},xQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=bQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},kQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("7.10mm"),h:J().default("3.40mm"),pl:J().default("2.45mm"),pw:J().default("1.80mm"),p:J().default("4.05mm")}),GQt=t=>{const A=kQt.parse(t),e=Cn(0,ie.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.5,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.5,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:RQt(A).concat(i,e),parameters:A}},FQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},RQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=FQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},NQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("4.80mm"),h:J().default("2.10mm"),pl:J().default("1.30mm"),pw:J().default("1.40mm"),p:J().default("2.9mm")}),MQt=t=>{const A=NQt.parse(t),e=Cn(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:vQt(A).concat(i,e),parameters:A}},_Qt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},vQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=_Qt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},UQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("7.30mm"),h:J().default("4.40mm"),pl:J().default("2.50mm"),pw:J().default("2.30mm"),p:J().default("4.30mm")}),LQt=t=>{const A=UQt.parse(t),e=Cn(0,ie.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.1,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:YQt(A).concat(i,e),parameters:A}},HQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},YQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=HQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},JQt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("10.70mm"),h:J().default("6.60mm"),pl:J().default("3.30mm"),pw:J().default("2.50mm"),p:J().default("6.80mm")}),TQt=t=>{const A=JQt.parse(t),e=Cn(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2-.8},{x:-ie.parse(A.w)/2-.8,y:ie.parse(A.h)/2-.8},{x:-ie.parse(A.w)/2-.8,y:-ie.parse(A.h)/2+.8},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:qQt(A).concat(i,e),parameters:A}},KQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},qQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=KQt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},PQt=TA({fn:J(),num_pins:jA().default(4),w:J().default("8.50mm"),h:J().default("6.90mm"),pl:J().default("2mm"),pw:J().default("1.5mm"),p:J().default("2.30mm"),string:J().optional()}),OQt=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const n=VQt.parse({...t,num_pins:e});return{circuitJson:IS(n),parameters:n}}const i=PQt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:ZQt(i),parameters:i};if(i.num_pins===5)return{circuitJson:zQt(i),parameters:i};if(i.num_pins===6)return{circuitJson:$Qt(i),parameters:i};throw new Error("Invalid number of pins")},WQt=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}},ZQt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=WQt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),I=r===3?3.8:Number.parseFloat(t.pw);A.push(xi(r+1,a,g,Number.parseFloat(t.pl),I))}const e=Cn(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]},VQt=mm({p:"0.90mm",w:"2.8mm",legsoutside:!0}),jQt=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")},zQt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=jQt({h:Number.parseFloat(t.h),p:1.5,pn:r,w:Number.parseFloat(t.w)});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===5?(I=3.4,c=1.8):(I=1,c=2.2),A.push(xi(r,a,g,c,I))}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=Cn(0,0,.3);return[...A,n,o,s]},XQt=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")},$Qt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=XQt({h:Number.parseFloat(t.h),p:1.3,pn:r,w:8.7});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===6?(I=3.4,c=2.15):(I=.6,c=2.2),A.push(xi(r,a,g,c,I))}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=Cn(0,0,.3);return[...A,n,o,s]},AEt=TA({fn:J(),num_pins:jA().default(3),w:J().default("3.40mm"),h:J().default("3.30mm"),pl:J().default("1mm"),pw:J().default("0.7mm"),p:J().default("1.2mm"),string:J().optional()}),eEt=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=AEt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:iEt(i),parameters:i};throw new Error("Invalid number of pins")},tEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},iEt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=tEt({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(xi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Cn(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]},nEt=TA({fn:J(),num_pins:ei([FA(3),FA(2)]).default(3),p:J().default("1.27mm"),id:J().default("0.72mm"),od:J().default("0.95mm"),w:J().default("2.5mm"),h:J().default("4.2mm"),string:J().optional()}),oEt=t=>{const{p:A,id:e,od:i,w:n,h:o}=t,s=Number.parseFloat(o)/2,r=Number.parseFloat(A);return[Ro(1,-r,s-r,e,i),Ro(2,0,s-r,e,i),Ro(3,r,s-r,e,i)]},sEt=t=>{const{p:A,id:e,od:i,h:n}=t,o=Number.parseFloat(n)/2,s=Number.parseFloat(A);return[Ro(1,-s,o-s,e,i),Ro(2,s,o-s,e,i)]},rEt=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=nEt.parse({...t,num_pins:e});let n=[];if(i.num_pins===3)n=oEt(i);else if(i.num_pins===2)n=sEt(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=Cn(0,o+1,.5);return{circuitJson:[...n,r,a],parameters:i}},aEt=TA({fn:J(),p:ie.optional(),id:ie.optional(),pw:ie.optional(),pl:ie.optional(),w:ie.optional(),h:ie.optional(),sh:ei([Be(),J(),jA()]).optional().transform(t=>{if(typeof t=="string"){const A=Number(t);return Number.isNaN(A)?!0:A}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Be().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:J().optional()}),gEt={ph:{p:ie.parse("2.2mm"),id:ie.parse("0.70mm"),pw:ie.parse("1.20mm"),pl:ie.parse("1.20mm"),w:ie.parse("6mm"),h:ie.parse("5mm")},sh:{p:ie.parse("1mm"),pw:ie.parse("0.6mm"),pl:ie.parse("1.55mm"),w:ie.parse("5.8mm"),h:ie.parse("7.8mm")}};function IEt(t){return t.sh?"sh":(t.ph,"ph")}function cEt(t,A,e,i,n,o){const s=[];if(t==="ph"){const r=e/2;s.push(r5(1,-r,2,i,n,o)),s.push(r5(2,r,2,i,n,o))}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const I=r+g*e;console.log("x si",I),s.push(xi(g+1,I,-1.325,n,o))}const a=(A-1)/2*e+1.3;console.log("offset",a),s.push(xi(A+1,-a,1.22,1.2,1.8)),s.push(xi(A+2,a,1.22,1.2,1.8))}return s}function BEt(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 lEt=t=>{const A=aEt.parse(t),e=IEt(A),i=gEt[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 I=e==="sh"?4:2;if(e==="sh"){const Q=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(Q&&Q[1]){const E=parseInt(Q[1],10);Number.isNaN(E)||(I=E)}else typeof A.sh=="number"&&(I=A.sh)}const c=cEt(e,I,n,o,s,r),B=BEt(e),l=Cn(0,g/2+1,.5);return{circuitJson:[...c,B,l],parameters:{...A,p:n,id:o,pw:s,pl:r,w:a,h:g,num_pins:I,sh:e==="sh",ph:e==="ph"}}},CEt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("3.30mm"),h:J().default("1.70mm"),pl:J().default("0.80mm"),pw:J().default("1mm"),p:J().default("1.90mm")}),QEt=t=>{const A=CEt.parse(t),e=Cn(0,ie.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:hEt(A).concat(i,e),parameters:A}},EEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},hEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=EEt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},uEt=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"}}},dEt=TA({fn:J(),num_pins:ei([FA(8),FA(10)]).default(8),w:J().optional(),h:J().optional(),p:J().optional(),pl:J().optional(),pw:J().optional(),string:J().optional()}),pEt=t=>{const A=dEt.parse(t),e=uEt(A.num_pins),i=ie.parse(A.w||e.w),n=ie.parse(A.h||e.h),o=ie.parse(A.p||e.p),s=ie.parse(A.pl||e.pl),r=ie.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}=jZA(A.num_pins,u+1,i,o),w=u<g?u+1:A.num_pins-(u-g);a.push(xi(w,d,f,s,r))}const I=i,c=n,B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:c/2},{x:I/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:-c/2},{x:I/2,y:-c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=jZA(A.num_pins,1,I,o),Q={x:C.x-.8,y:C.y},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:Q.x-.4,y:Q.y},{x:Q.x-.7,y:Q.y+.3},{x:Q.x-.7,y:Q.y-.3},{x:Q.x-.4,y:Q.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Cn(0,c/2+.5,.3);return{circuitJson:[...a,B,l,h,E],parameters:A}},jZA=(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*ie.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},fEt=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"}}},yEt=TA({fn:J(),num_pins:ei([FA(8),FA(10),FA(12),FA(16)]).default(8),w:J().optional(),h:J().optional(),p:J().optional(),pl:J().optional(),pw:J().optional(),string:J().optional()}),zZA=(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*ie.parse("2mm"),y:r*i}},mEt=t=>{const A=yEt.parse(t),e=fEt(A.num_pins),i=ie.parse(A.w||e.w),n=ie.parse(A.h||e.h),o=ie.parse(A.p||e.p),s=ie.parse(A.pl||e.pl),r=ie.parse(A.pw||e.pw),a=[];for(let h=0;h<A.num_pins;h++){const{x:u,y:d}=zZA(A.num_pins,h+1,i,o);a.push(xi(h+1,u,d,s,r))}const g=i,I=n,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:I/2},{x:g/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-I/2},{x:g/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=zZA(A.num_pins,1,g,o),C={x:l.x-.8,y:l.y},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:C.x-.4,y:C.y},{x:C.x-.7,y:C.y+.3},{x:C.x-.7,y:C.y-.3},{x:C.x-.4,y:C.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},E=Cn(0,I/2+.5,.3);return{circuitJson:[...a,c,B,E,Q],parameters:A}},wEt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("3.8mm"),h:J().default("1.65mm"),pl:J().default("1.2mm"),pw:J().default("1.2mm"),pad_spacing:J().default("2.6mm")}),DEt=t=>{const A=wEt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.pad_spacing)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.pad_spacing)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bEt(A).concat(i,e),parameters:A}},SEt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},bEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=SEt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},xEt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("3.20mm"),h:J().default("1.65mm"),pl:J().default("0.8mm"),pw:J().default("0.9mm"),pad_spacing:J().default("2.1mm")}),kEt=t=>{const A=xEt.parse(t),e=Cn(0,ie.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.pad_spacing)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.2,y:-ie.parse(A.h)/2},{x:ie.parse(A.pad_spacing)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:FEt(A).concat(i,e),parameters:A}},GEt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},FEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=GEt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},REt=TA({fn:J(),num_pins:ei([FA(6),FA(8)]).default(8),w:J().default("3mm"),h:J().default("3mm"),p:J().default("0.5mm"),pl:J().default("0.52mm"),pw:J().default("0.35mm"),epw:J().default("1.40mm"),eph:J().default("1.60mm"),string:J().optional(),ep:Be().default(!1)}),NEt=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=REt.parse({...t,num_pins:e}),n=ie.parse(i.w),o=ie.parse(i.h),s=ie.parse(i.p),r=ie.parse(i.pl),a=ie.parse(i.pw),g=ie.parse(i.epw),I=ie.parse(i.eph),c=[];for(let f=0;f<i.num_pins;f++){const{x:w,y:S}=XZA(i.num_pins,f+1,n,s);c.push(xi(f+1,w,S,r,a))}i.ep&&c.push(xi(i.num_pins+1,0,0,g,I));const B=n,l=o,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:l/2},{x:B/2,y:l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:-l/2},{x:B/2,y:-l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},E=XZA(i.num_pins,1,B,s),h={x:E.x-.4,y:E.y},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:h.x-.4,y:h.y},{x:h.x-.7,y:h.y+.3},{x:h.x-.7,y:h.y-.3},{x:h.x-.4,y:h.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Cn(0,l/2+.5,.3);return{circuitJson:[...c,C,Q,d,u],parameters:i}},XZA=(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*ie.parse("1.4mm"),y:r*i}},MEt=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:n=1.5,ph:o=1.5}=t,s=ie.parse(i),r=ie.parse(n),a=ie.parse(o),g=Math.min(a/4,.5),I=[];for(let f=0;f<A;f++)I.push(xi(f+1,f*s,0,r,a));let c=[];if(e){const f=e.split("").map(Number);if(f.length>1)for(let w=0;w<f.length-1;w++){const S=f[w],D=f[w+1];if(typeof S=="number"&&typeof D=="number"&&!isNaN(S)&&!isNaN(D)){const x=(S-1)*s,F=(D-1)*s,k=Math.sign(F-x),v=x+k*(r/2),M=F-k*(r/2);c.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${S}}`,x:v,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${D}}`,x:M,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const B=(A-1)*s+r+.7,l=a+1,C=(A-1)*s/2,Q=0,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:C-B/2,y:Q-l/2},{x:C+B/2,y:Q-l/2},{x:C+B/2,y:Q+l/2},{x:C-B/2,y:Q+l/2},{x:C-B/2,y:Q-l/2}],stroke_width:.15},u=Q+l/2+.6,d=Cn(C,u,.4);return{circuitJson:[...I,...c,E,d],parameters:t}},$ZA={fn:FA("sot457"),num_pins:FA(6).default(6),pillh:J().default("0.45mm"),pillw:J().default("1.45mm"),pl:J(),pw:J(),p:J(),wave:Be().optional(),reflow:Be().optional()},_Et=TA({...$ZA,h:J().default("2.5mm"),w:J().default("2.7mm"),pl:J().default("0.8mm"),pw:J().default("0.55mm"),p:J().default("0.95mm")}),vEt=TA({...$ZA,h:J().default("3mm"),w:J().default("4mm"),pillr:J().default("0.225mm"),pl:J().default("1.45mm"),pw:J().default("1.5mm"),p:J().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)})),cS=t=>Number.parseFloat(t.replace("mm","")),AVA=({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},eVA=t=>{const A=[],e=cS(t.p),i=cS(t.pl),n=cS(t.pw),o=cS(t.w),s=cS(t.h);if(t.wave){const C={1:({padWidth:Q,padHeight:E})=>xi(1,-e,e,E,Q),2:({padWidth:Q,padHeight:E})=>xi(2,-e,-e,E,Q),3:({padWidth:Q,padHeight:E})=>s5(3,-e,0,cS(t.pillw),cS(t.pillh)),4:({padWidth:Q,padHeight:E})=>s5(4,e,0,cS(t.pillw),cS(t.pillh)),5:({padWidth:Q,padHeight:E})=>xi(5,e,e,E,Q),6:({padWidth:Q,padHeight:E})=>xi(6,e,-e,E,Q)};for(let Q=1;Q<=t.num_pins;Q++){const E=C[Q];E&&A.push(E({padWidth:i,padHeight:n}))}}else for(let C=1;C<=t.num_pins;C++){const{x:Q,y:E}=AVA({pitch:e,width:o,pinNumber:C});A.push(xi(C,Q,E,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=Cn(0,s+.5,.3),I=AVA({pitch:e,width:o,pinNumber:1}),c=t.wave?1:.5,B=t.wave?.7:.3;I.x-=t.wave?n:n*1.7;const l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:I.x+c/2,y:I.y},{x:I.x-c/2,y:I.y+B/2},{x:I.x-c/2,y:I.y-B/2},{x:I.x+c/2,y:I.y}],stroke_width:.05};return[g,r,a,l,...A]},UEt=t=>{if(t.wave){const e=vEt.parse({...t,fn:"sot457"});return{circuitJson:eVA(e),parameters:e}}const A=_Et.parse(t);return{circuitJson:eVA(A),parameters:A}},LEt=TA({fn:J(),num_pins:ei([FA(3),FA(2)]).default(3),p:J().default("3.8mm"),id:J().default("1.25mm"),od:J().default("2.35mm"),ca:J().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:J().default("5.35mm"),h:J().default("4mm"),string:J().optional()}),HEt=t=>{const{p:A,id:e,od:i,h:n,ca:o}=t,s=Number.parseFloat(n),r=Number.parseFloat(o);return[Ro(1,0,r/4+.3,e,i),Ro(2,s,0,e,i),Ro(3,0,-r/4-.3,e,i)]},YEt=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=LEt.parse({...t,num_pins:e});let n=[];i.num_pins===3&&(n=HEt(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:""},I=Number.parseFloat(i.w)/2,c=Cn(I,o+1,.5);return{circuitJson:[...n,a,g,c],parameters:i}},JEt=TA({fn:J(),p:ie.optional().default("7.5mm"),id:ie.optional().default("1mm"),od:ie.optional().default("2mm"),d:ie.optional().default("10.5mm")}),TEt=(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,I=A+Math.sin(a)*e;g<t-i&&I>=A-n/2&&I<=A+n/2||o.push({x:g,y:I})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-n/2&&I<=A+n/2||s.push({x:g,y:I})}return{topArc:o,bottomArc:s}},KEt=t=>{const A=JEt.parse(t),{p:e,id:i,od:n,d:o}=A,s=[Ro(1,-e/2,0,i,n),Ro(2,e/2,0,i,n)],{topArc:r,bottomArc:a}=TEt(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:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},B=-(o/2+.5),l=n/2+1.5,C=.5,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B-C,y:l},{x:B+C,y:l}],stroke_width:.1,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B,y:l-C},{x:B,y:l+C}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Cn(0,o/2+1,.5);return{circuitJson:[...s,g,I,c,Q,E,h],parameters:A}},qEt=TA({fn:J(),num_pins:FA(2).default(2),w:J().default("6.5mm"),h:J().default("3mm"),pl:J().default("1.75mm"),pw:J().default("2.40mm"),p:J().default("4.75mm")}),PEt=t=>{const A=qEt.parse(t),e=Cn(0,ie.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ie.parse(A.p)/2,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.3,y:ie.parse(A.h)/2},{x:-ie.parse(A.w)/2-.3,y:-ie.parse(A.h)/2},{x:ie.parse(A.p)/2,y:-ie.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:WEt(A).concat(i,e),parameters:A}},OEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},WEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=OEt({pn:e,p:Number.parseFloat(t.p)});A.push(xi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ZEt=TA({fn:J(),num_pins:jA().default(3),w:J().default("2.45mm"),h:J().default("2.40mm"),pl:J().default("0.45mm"),pw:J().default("0.70mm"),p:J().default("1mm"),string:J().optional()}),VEt=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=ZEt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:zEt(i),parameters:i};throw new Error("Invalid number of pins")},jEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},zEt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=jEt({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(xi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Cn(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]},XEt=TA({fn:J(),circle:Be().optional(),rect:Be().optional(),square:Be().optional(),pill:Be().optional(),d:ie.optional(),pd:ie.optional(),diameter:ie.optional(),r:ie.optional(),pr:ie.optional(),radius:ie.optional(),w:ie.optional(),pw:ie.optional(),width:ie.optional(),h:ie.optional(),ph:ie.optional(),height:ie.optional(),s:ie.optional(),size:ie.optional(),string:J().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=ya(t.r):t.pr!==void 0?e=ya(t.pr):t.radius!==void 0?e=ya(t.radius):t.d!==void 0?e=ya(t.d)/2:t.pd!==void 0?e=ya(t.pd)/2:t.diameter!==void 0?e=ya(t.diameter)/2:e=ya("1mm")/2:(t.w!==void 0?i=ya(t.w):t.pw!==void 0?i=ya(t.pw):t.width!==void 0?i=ya(t.width):t.s!==void 0?i=ya(t.s):t.size!==void 0?i=ya(t.size):i=ya("1mm"),t.h!==void 0?n=ya(t.h):t.ph!==void 0?n=ya(t.ph):t.height!==void 0?n=ya(t.height):A==="square"||A==="rect"?n=i:n=ya("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:n}}),$Et=t=>{const A=XEt.parse(t),{shape:e,radius:i,width:n,height:o}=A;let s,r;return e==="circle"?(s=LZA(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=s5(1,0,0,n,o),r=Math.max(n,o)/2+.5):(s=xi(1,0,0,n,o),r=o/2+.5),{circuitJson:[s,Cn(0,r,.2)],parameters:A}},Aht=TA({fn:J(),d:ie.optional(),hd:ie.optional(),r:ie.optional(),hr:ie.optional(),pd:ie.optional(),pr:ie.optional(),squarepad:Be().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=ya(t.d):t.hd!==void 0?A=ya(t.hd):t.r!==void 0?A=ya(t.r)*2:t.hr!==void 0?A=ya(t.hr)*2:A=ya("1mm");let e;return t.pd!==void 0?e=ya(t.pd):t.pr!==void 0?e=ya(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),eht=t=>{const A=Aht.parse(t),{d:e,pd:i,squarepad:n}=A;return{circuitJson:[n?r5(1,0,0,e,i,i):Ro(1,0,0,e,i),Cn(0,i/2+.5,.2)],parameters:A}},tht=TA({fn:J(),num_pins:FA(6).default(6),h:J().default("1.6mm"),pl:J().default("1mm"),pw:J().default("0.7mm"),p:J().default("0.95mm")}),iht=t=>{const A=tht.parse(t);return{circuitJson:nht(A),parameters:A}},tVA=t=>{const{p:A,h:e,pn:i}=t;if(i===1)return{x:-e/2-.5,y:A};if(i===2)return{x:-e/2-.5,y:0};if(i===3)return{x:-e/2-.5,y:-A};if(i===4)return{x:e/2+.5,y:-A};if(i===5)return{x:e/2+.5,y:0};if(i===6)return{x:e/2+.5,y:A};throw new Error("Invalid pin number")},nht=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:l}=tVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(xi(c,B,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),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=Cn(0,i+.3,.3),r=tVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,n,o,I]},oht=TA({fn:J()}),sht=t=>{const A=oht.parse(t),e=[],i=.5-.15,n=1.5,s=.5/2,r=75,a=-37/2;for(let D=0;D<r;D++){const x=D+1;if(x>=24&&x<=31)continue;const F=a-D*s,k=x%2===0,v=n+(k?.25:0),L=.5-v/2,K=xi(x,L,F,v,i);K.layer=k?"bottom":"top",e.push(K)}const g=46*.0254,I=137*.0254,c=261*.0254,B={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-I/2+n/2,y:a-c},width:I,height:g},l={x:-.5,y:a},C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-.4,y:l.y},{x:l.x-.7,y:l.y+.3},{x:l.x-.7,y:l.y-.3},{x:l.x-.4,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let Q=1/0,E=-1/0,h=1/0,u=-1/0;const d=(D,x,F=0,k=0)=>{Q=Math.min(Q,D-F/2),E=Math.max(E,D+F/2),h=Math.min(h,x-k/2),u=Math.max(u,x+k/2)};for(const D of e)d(D.x,D.y,D.width,D.height);d(B.center.x,B.center.y,B.width,B.height);for(const D of C.route)d(D.x,D.y);const f=(Q+E)/2,w=(h+u)/2,S=D=>{typeof D.x=="number"&&(D.x-=f),typeof D.y=="number"&&(D.y-=w),D.center&&(D.center.x-=f,D.center.y-=w),Array.isArray(D.route)&&(D.route=D.route.map(x=>({x:x.x-f,y:x.y-w})))};for(const D of e)S(D);return S(B),S(C),{circuitJson:[...e,B,C],parameters:A}};function rht(t){return t!=null}var aht=(t,A)=>{if(!A)return t;const e=t.filter(I=>I.type==="pcb_smtpad"||I.type==="pcb_plated_hole"||I.type==="pcb_thtpad");if(e.length===0)return t;let i=1/0,n=-1/0,o=1/0,s=-1/0;const r=(I,c,B=0,l=0)=>{const C=I-B/2,Q=I+B/2,E=c-l/2,h=c+l/2;i=Math.min(i,C),n=Math.max(n,Q),o=Math.min(o,E),s=Math.max(s,h)};for(const I of e)if(I.type==="pcb_smtpad"){const c=I.shape==="circle"?I.radius*2:I.width,B=I.shape==="circle"?I.radius*2:I.height;r(I.x,I.y,c,B)}else if(I.type==="pcb_plated_hole"){const c=I.outer_diameter??I.hole_diameter;r(I.x,I.y,c,c)}else if(I.type==="pcb_thtpad"){const c=I.diameter;r(I.x,I.y,c,c)}let a=0,g=0;switch(A){case"center":a=(i+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 I=e.find(c=>c.port_hints?.[0]==="1")||e[0];a=I.x,g=I.y;break}if(a===0&&g===0)return t;for(const I of t){if(typeof I.x=="number"&&(I.x-=a),typeof I.y=="number"&&(I.y-=g),I.center&&typeof I.center.x=="number"&&(I.center.x-=a,I.center.y-=g),I.type==="pcb_silkscreen_path")for(const c of I.route)c.x-=a,c.y-=g;I.type==="pcb_silkscreen_text"&&I.anchor_position&&(I.anchor_position.x-=a,I.anchor_position.y-=g)}return t},ght=t=>{let A=c5();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(n=>{const o=n.match(/([a-z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,r]=o;return!s||r?.includes("?")?null:{fn:s,v:r}}).filter(rht);for(const{fn:n,v:o}of i)A=A[n](o);return A.setString(t),A},Iht=()=>Object.keys(gS),c5=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&gS[A.fn])return()=>{const{circuitJson:i}=gS[A.fn](A);return aht(i,A.origin)};if(!gS[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(!gS[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>gS[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(gS):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in gS?(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};c5.string=ght,c5.getFootprintNames=Iht;var cht=c5,iVA=Symbol("Fragment");function ulA(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 ht=Symbol("Cuboid"),nVA=Symbol("Cube"),qp=Symbol("Cylinder"),oVA=Symbol("Sphere"),VU=Symbol("RoundedCuboid"),Wi=Symbol("Translate"),lQ=Symbol("Rotate"),rE=Symbol("Union"),VG=Symbol("Subtract"),rI=Symbol("Hull"),ys=Symbol("Colorize"),jU=Symbol("Polygon"),zU=Symbol("ExtrudeLinear"),Pp=Symbol("RoundedCylinder"),Yn=iVA,$A=(t,A,e)=>ulA(t,A),Ot=(t,A,e)=>ulA(t,A),VB=({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:I,notchPosition:c,notchRotation:B=[0,0,0],notchLength:l=.5,notchWidth:C=.25,chamferSize:Q=0})=>{const E=i*a,h=i-E,u=Math.min(A,e)*s,d=Math.max(A-u,A*r),f=Math.max(e-u,e*r),w=Math.min(A,e)*.12,S=I??w,D={x:0,y:e/2-S*.25,z:i},x=c??D,F=Ot(rE,{children:[Ot(rI,{children:[$A(Wi,{z:.005,children:$A(ht,{size:[d,f,.01]})}),$A(Wi,{z:E,children:$A(ht,{size:[A,e,.01]})})]}),Ot(rI,{children:[$A(Wi,{z:E,children:$A(ht,{size:[A,e,.01]})}),$A(Wi,{z:E+h,children:$A(ht,{size:[d,f,.01]})})]})]}),k=(M,L)=>$A(Wi,{offset:{x:M,y:L,z:0},children:$A(lQ,{rotation:[0,0,Math.PI/4],children:$A(ht,{size:[Q*Math.SQRT2,Q*Math.SQRT2,i*3]})})});let v=F;if(Q>0){const M=A/2,L=e/2;v=Ot(VG,{children:[F,k(M,L),k(-M,L),k(M,-L),k(-M,-L)]})}return $A(ys,{color:o,children:$A(Wi,{offset:t,children:$A(Wi,{offset:{x:0,y:0,z:n},children:g?Ot(VG,{children:[v,$A(Wi,{offset:x,children:$A(lQ,{rotation:B,children:$A(qp,{radius:S,height:C})})})]}):v})})})},Bht=t=>Array.from({length:t},(A,e)=>e);function dlA(t,A){if(t.length<2)throw new Error("Stroke must have at least two points");const e=Array.isArray(t[0])?t.map(([I,c])=>({x:I,y:c})):t,i=A/2,n=[],o=[];function s(I,c){const B=c.x-I.x,l=c.y-I.y,C=Math.sqrt(B*B+l*l);return{x:-l/C,y:B/C}}function r(I,c,B){const l={x:I.x+c.x*i*B,y:I.y+c.y*i*B};B>0?n.push(l):o.unshift(l)}const a=s(e[0],e[1]);r(e[0],a,1),r(e[0],a,-1);for(let I=1;I<e.length-1;I++){const c=e[I-1],B=e[I],l=e[I+1],C=s(c,B),Q=s(B,l),E=C.x+Q.x,h=C.y+Q.y,u=Math.sqrt(E*E+h*h);if(u/2>2*i)r(B,C,1),r(B,Q,1),r(B,C,-1),r(B,Q,-1);else{const f=1/u;r(B,{x:E*f,y:h*f},1),r(B,{x:E*f,y:h*f},-1)}}const g=s(e[e.length-2],e[e.length-1]);return r(e[e.length-1],g,1),r(e[e.length-1],g,-1),[...n,...o]}var lht=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}))},Cht=lht([{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}]),sVA=5.47,B5=.5,Qht=({x:t,y:A,z:e})=>{const i=t>0;return Ot(Yn,{children:[$A(Wi,{offset:{x:t+.25/2,y:A,z:e},children:$A(lQ,{rotation:["-90deg",0,"90deg"],children:$A(zU,{height:.25,children:$A(jU,{points:Cht.slice().reverse().map(n=>[n.x,n.y])})})})}),$A(Wi,{offset:{x:t,y:A+(i?1:-1),z:e},children:$A(lQ,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:$A(zU,{height:2,children:$A(jU,{points:dlA([[0,0],[-1,0],[-1,-1]],.25).map(n=>[n.x,n.y])})})})})]})},Eht=({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 Ot(Yn,{children:[Bht(t).map(r=>{const a=r%n,g=(Math.floor(r/n)-.5)*2;return $A(Qht,{x:g*o/2,y:a*A-(n-1)/2*A,z:sVA/2+B5})}),$A(VB,{width:s,length:n*A+.5,height:sVA-B5,heightAboveSurface:B5,center:{x:0,y:0,z:B5}})]})};function hht(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 Kn=t=>{const{thickness:A,width:e,padContactLength:i,bodyDistance:n,height:o,rotation:s}=t,r=15,a=Array.from({length:r}).map((I,c)=>c/(r-1)*n).map(I=>[I,hht(I,t)]),g=dlA(a,A);return $A(ys,{color:"#fff",children:$A(Wi,{offset:{z:0,y:0,x:0,...t.position},children:$A(lQ,{rotation:["90deg",0,s??0],children:$A(Wi,{offset:{x:0,y:0,z:-e/2},children:$A(zU,{height:e,children:$A(jU,{points:g.map(I=>[I.x,I.y])})})})})})})},uht=({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 Ot(Yn,{children:[Array.from({length:o}).map((g,I)=>$A(Kn,{position:{x:-n/2-A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:o}).map((g,I)=>$A(Kn,{rotation:Math.PI,position:{x:n/2+A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),$A(VB,{center:{x:0,y:0,z:a/2},width:n-e-1,length:s,height:1.5})]})},dht=({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 Ot(Yn,{children:[Array.from({length:o}).map((a,g)=>$A(Kn,{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)=>$A(Kn,{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})),$A(VB,{center:{x:0,y:0,z:r/2},width:n,length:n,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},plA=1,flA=.5,TM=.5,XU=.2,pht=plA-XU*2,rVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[pht,flA,TM],offset:[0,0,TM/2],color:t}),$A(ht,{size:[XU,TM,flA],offset:[plA/2-XU/2,0,TM/2],color:"#ccc"}),$A(ht,{size:[XU,TM,flA],offset:[-plA/2+XU/2,0,TM/2],color:"#ccc"})]}),ylA=1.6,fht=ylA-.3*2,l5=.3,mlA=.85,KM=.6,aVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[fht,mlA,KM],offset:[0,0,KM/2],color:t}),$A(ht,{size:[l5,mlA,KM],offset:[ylA/2-l5/2,0,KM/2],color:"#ccc"}),$A(ht,{size:[l5,mlA,KM],offset:[-ylA/2+l5/2,0,KM/2],color:"#ccc"})]}),wlA=2,DlA=1.25,qM=.55,$U=.5,yht=wlA-$U*2,gVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[yht,DlA,qM],offset:[0,0,qM/2],color:t}),$A(ht,{size:[$U,DlA,qM],offset:[wlA/2-$U/2,0,qM/2],color:"#ccc"}),$A(ht,{size:[$U,DlA,qM],offset:[-wlA/2+$U/2,0,qM/2],color:"#ccc"})]}),mht=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:n})=>{const o=t/4;A||(A=wht(t,n)),i||(i=Dht(t)),e||(e=Sht(t,n)),n||(n=A*(o+4));const s=n,r=(o-1)*A/2,a=s+2*i,g=a,I=.8,c=.15,B=(g-n)/2+.5;return Ot(Yn,{children:[Array.from({length:o}).map((l,C)=>$A(Kn,{position:{x:-g/2-.4,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:Math.PI,position:{x:g/2+.4,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),$A(VB,{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})]})},wht=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},Dht=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}},Sht=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},bht=({numberOfPins:t,pitch:A=2.54,longSidePinLength:e=6,invert:i,faceup:n,rows:o=1})=>{const a=Math.ceil(t/o),g=2.54,I=a*A,c=o>1?(o-1)*g+.63*3:.63*3,B=3,l=-((a-1)/2)*A,C=o>1?-((o-1)*g)/2:0,Q=E=>i||n?-E+2:E;return Ot(Yn,{children:[$A(ht,{color:"#222",size:[I,c,2],center:[0,C,Q(2/2)]}),Array.from({length:t},(E,h)=>{const u=Math.floor(h/a),d=h%a,f=l+d*A,w=-u*g;return Ot(Yn,{children:[!n&&$A(ys,{color:"gold",children:Ot(rI,{children:[$A(ht,{color:"gold",size:[.63,.63,B*.9],center:[f,w,Q(2*.9+2/2)]}),$A(ht,{color:"gold",size:[.63/1.8,.63/1.8,B],center:[f,w,Q(2+2/2)]})]})}),$A(ys,{color:"gold",children:Ot(rI,{children:[$A(ht,{color:"gold",size:[.63,.63,e*.9],center:[f,w,Q(-e/2*.9)]}),$A(ht,{color:"gold",size:[.63/1.8,.63/1.8,e],center:[f,w,Q(-e/2)]})]})})]})})]})},xht=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)],I=(i-1)%a,c=s*(a-1),B=s*(a-1),l=-r/2;switch(g){case"left":return{x:-n/2-l,y:B/2-I*s,o:"vert"};case"bottom":return{x:-c/2+I*s,y:-o/2-l,o:"horz"};case"right":return{x:n/2+l,y:-B/2+I*s,o:"vert"};case"top":return{x:c/2-I*s,y:o/2+l,o:"horz"};default:throw new Error("Invalid pin number")}},kht=({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},Ght=({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=kht({num_pins:t,cw:!0,ccw:!0}),I=[];for(let c=0;c<t;c++){const{x:B,y:l,o:C}=xht({pin_count:t,pn:c+1,w:A,h:e,p:r,pl:s});let Q=o,E=s;C==="vert"&&([Q,E]=[E,Q]);const h=g[c+1];I.push({pn:h,x:B,y:l,pw:Q,pl:E})}return Ot(Yn,{children:[$A(ys,{color:"grey",children:$A(ht,{center:{x:0,y:0,z:i/2},size:[A,e,i]})}),I.map((c,B)=>$A(ht,{center:{x:c.x,y:c.y,z:a/2},size:[c.pw,c.pl,a]})),n?.length!==void 0&&n?.width!==void 0&&$A(ht,{center:{x:0,y:0,z:a/2},size:[n.width,n.length,a]})]})},Fht=Ght,Rht=()=>{const a=1.1999999999999997;return Ot(Yn,{children:[$A(Kn,{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}),$A(Kn,{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}),$A(Kn,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(Kn,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(Kn,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),$A(VB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},Nht=Rht,Mht=({fullWidth:t=2.9,fullLength:A=2.8})=>{const I=(t-1.92)/2+.3;return Ot(Yn,{children:[$A(Kn,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),$A(Kn,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),$A(Kn,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),$A(VB,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},SlA=.6,blA=.3,PM=.33,AL=.1,_ht=SlA-AL*2,IVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[_ht,blA,PM],offset:[0,0,PM/2],color:t}),$A(ht,{size:[AL,blA,PM],offset:[SlA/2-AL/2,0,PM/2],color:"#ccc"}),$A(ht,{size:[AL,blA,PM],offset:[-SlA/2+AL/2,0,PM/2],color:"#ccc"})]}),xlA=.4,klA=.2,OM=.13,eL=.07,vht=xlA-eL*2,cVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[vht,klA,OM],offset:[0,0,OM/2],color:t}),$A(ht,{size:[eL,klA,OM],offset:[xlA/2-eL/2,0,OM/2],color:"#ccc"}),$A(ht,{size:[eL,klA,OM],offset:[-xlA/2+eL/2,0,OM/2],color:"#ccc"})]}),GlA=3.2,FlA=1.6,WM=.9,tL=.5,Uht=GlA-tL*2,BVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[Uht,FlA,WM],offset:[0,0,WM/2],color:t}),$A(ht,{size:[tL,FlA,WM],offset:[GlA/2-tL/2,0,WM/2],color:"#ccc"}),$A(ht,{size:[tL,FlA,WM],offset:[-GlA/2+tL/2,0,WM/2],color:"#ccc"})]}),RlA=3.2,NlA=2.5,ZM=1,iL=.6,Lht=RlA-iL*2,lVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[Lht,NlA,ZM],offset:[0,0,ZM/2],color:t}),$A(ht,{size:[iL,NlA,ZM],offset:[RlA/2-iL/2,0,ZM/2],color:"#ccc"}),$A(ht,{size:[iL,NlA,ZM],offset:[-RlA/2+iL/2,0,ZM/2],color:"#ccc"})]}),MlA=5,_lA=2.5,VM=1.4,nL=.6,Hht=MlA-nL*2,CVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[Hht,_lA,VM],offset:[0,0,VM/2],color:t}),$A(ht,{size:[nL,_lA,VM],offset:[MlA/2-nL/2,0,VM/2],color:"#ccc"}),$A(ht,{size:[nL,_lA,VM],offset:[-MlA/2+nL/2,0,VM/2],color:"#ccc"})]}),vlA=6.3,UlA=3.2,jM=1.8,oL=.8,Yht=vlA-oL*2,QVA=({color:t="#333"})=>Ot(Yn,{children:[$A(ht,{size:[Yht,UlA,jM],offset:[0,0,jM/2],color:t}),$A(ht,{size:[oL,UlA,jM],offset:[vlA/2-oL/2,0,jM/2],color:"#ccc"}),$A(ht,{size:[oL,UlA,jM],offset:[-vlA/2+oL/2,0,jM/2],color:"#ccc"})]}),Jht=({numberOfPins:t,pitch:A=2.54,legsLength:e=3,outerDiameter:i=.945,innerDiameter:n=.945,rows:o=1})=>{const s=n/1.5,r=s*2+i,a=5,g=Math.ceil(t/o),I=2.54,c=(g-1)*A+i+A/2,B=o>1?(o-1)*I+r:r,l=s*1.6,C=-((g-1)/2)*A,Q=o>1?-((o-1)*I)/2:0,E=$A(ys,{color:"#1a1a1a",children:Ot(VG,{children:[$A(ht,{color:"#000",size:[c,B,a],center:[0,Q,a/2]}),Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,w=C+f*A,S=-d*I;return n?$A(qp,{height:a+.1,radius:n/2,center:[w,S,a/2],color:"#222"},u):$A(ht,{size:[l,l,a],center:[w,S,a/2]},u)})]})});return Ot(Yn,{children:[E,Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,w=C+f*A,S=-d*I;return Ot(ys,{color:"silver",children:[Ot(rI,{children:[$A(ht,{color:"silver",size:[s,s,e*.9],center:[w,S,-e/2*.9]}),$A(ht,{color:"silver",size:[s/1.8,s/1.8,e],center:[w,S,-e/2]})]}),$A(ht,{color:"silver",size:[l,l,l*.5],center:[w,S,l/2*.5]})]},u)})]})},Tht=({width:t,length:A,innerDiameter:e=1})=>{const i=t,n=A,o=t*.7,s=e/2.5;return Ot(Yn,{children:[$A(VU,{color:"#1a1a1f",center:[0,0,o/2],size:[n,n,o],roundRadius:.3}),$A(VU,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[n,n,o*.1],roundRadius:.14}),$A(qp,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),$A(qp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,n/3,o+o*.1/2]}),$A(qp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,-n/3,o+o*.1/2]}),$A(qp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,n/3,o+o*.1/2]}),$A(qp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,-n/3,o+o*.1/2]}),$A(C5,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:-n/2,z:-o*1.2}}),$A(C5,{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}),$A(C5,{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}),$A(C5,{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}})]})},C5=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=dlA(r,A);return $A(ys,{color:"#f2f2f2",children:$A(Wi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:$A(lQ,{rotation:[0,55,o],children:$A(zU,{height:e,children:$A(jU,{points:a.map(g=>[g.y,g.x])})})})})})},Kht=({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,I=A*0,c=i*(o-1)+e+.2,B=n*.55;return Ot(Yn,{children:[Array.from({length:o}).map((l,C)=>$A(Kn,{position:{x:-n/2-I,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:Math.PI,position:{x:n/2+I,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),$A(VB,{center:{x:0,y:0,z:r/2},width:B,length:c,height:a})]})},qht=({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,I=isNaN(parseFloat(o))?2+Number(r)*1.4:parseFloat(o),c=t/2,B=(c-1)*r/2,l=.15,C=.8,Q=4.5,E=(Q-g)/2,h=E*.5;return Ot(Yn,{children:[Array.from({length:c}).map((u,d)=>$A(Kn,{position:{x:-Q/2,y:B-d*r,z:l/2},width:a,thickness:l,padContactLength:h+.05,bodyDistance:E+.1,height:C})),Array.from({length:c}).map((u,d)=>$A(Kn,{rotation:Math.PI,position:{x:Q/2,y:B-d*r,z:l/2},width:a,thickness:l,padContactLength:h+.05,bodyDistance:E+.1,height:C})),$A(VB,{center:{x:0,y:0,z:l/2},width:g,length:I,height:1})]})},Pht=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),$A(ht,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[$A(Wi,{z:.3/2,children:$A(ht,{size:[1.65,.8,.3]})}),Ot(rI,{children:[$A(Wi,{z:.3,children:$A(ht,{size:[1.65,.8,.01]})}),$A(Wi,{z:.6,children:$A(ht,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),Oht=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),$A(ht,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),$A(ys,{color:"#222",children:$A(Wi,{z:.47/2+.02,children:$A(ht,{size:[.98,.58,.47]})})}),$A(ht,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),$A(ht,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),$A(ht,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),$A(ht,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),Wht=()=>{const g=$A(ys,{color:"#1a1a1a",children:Ot(rE,{children:[Ot(rI,{children:[$A(Wi,{z:.13,children:$A(ht,{size:[4,3,.03]})}),$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})})]}),Ot(rI,{children:[$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})}),$A(Wi,{z:2.3,children:$A(ht,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const C=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return $A(ys,{color:"#c0c0c0",children:Ot(rE,{children:[$A(ht,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),$A(ht,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),$A(ht,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Yn,{children:[$A(I,{xDir:1}),$A(I,{xDir:-1}),g]})},Zht=()=>{const g=$A(ys,{color:"#1a1a1a",children:Ot(rE,{children:[Ot(rI,{children:[$A(Wi,{z:.13,children:$A(ht,{size:[4,3,.03]})}),$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})})]}),Ot(rI,{children:[$A(Wi,{z:1.15,children:$A(ht,{size:[4.4,3.4,.01]})}),$A(Wi,{z:2.3,children:$A(ht,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const C=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return $A(ys,{color:"#c0c0c0",children:Ot(rE,{children:[$A(ht,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),$A(ht,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),$A(ht,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Yn,{children:[$A(I,{xDir:1}),$A(I,{xDir:-1}),g]})},Vht=()=>{const g=$A(ys,{color:"#1a1a1a",children:Ot(rE,{children:[Ot(rI,{children:[$A(Wi,{z:.21000000000000002,children:$A(ht,{size:[6.3999999999999995,5.6,.03]})}),$A(Wi,{z:1.15,children:$A(ht,{size:[6.8,6,.01]})})]}),Ot(rI,{children:[$A(Wi,{z:1.15,children:$A(ht,{size:[6.8,6,.01]})}),$A(Wi,{z:2.3,children:$A(ht,{size:[6.3999999999999995,5.6,.01]})})]})]})}),I=({xDir:c})=>{const C=c*3.08,Q=c*(6/2-.2/2+1),E=c*(6/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return $A(ys,{color:"#c0c0c0",children:Ot(rE,{children:[$A(ht,{size:[2.3*.8,2.95,.2],center:[C,0,.2/2]}),$A(ht,{size:[.2,2.95,1.14],center:[Q,0,1.14/2+.2]}),$A(ht,{size:[h,2.95,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Yn,{children:[$A(I,{xDir:1}),$A(I,{xDir:-1}),g]})},jht=()=>{const c=$A(ys,{color:"#222",children:Ot(rE,{children:[$A(Wi,{z:.27,children:$A(ht,{size:[2.9,1.9,.54]})}),Ot(rI,{children:[$A(Wi,{z:.54,children:$A(ht,{size:[2.9,1.9,.01]})}),$A(Wi,{z:1.08,children:$A(ht,{size:[2.6999999999999997,1.7,.01]})})]})]})});return Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),$A(ht,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),c]})},zht=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),$A(ht,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[$A(Wi,{z:.55/2,children:$A(ht,{size:[2.7,1.6,.55]})}),Ot(rI,{children:[$A(Wi,{z:.55,children:$A(ht,{size:[2.7,1.6,.01]})}),$A(Wi,{z:1.1,children:$A(ht,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),Xht=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),$A(ht,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[$A(Wi,{z:.2/2,children:$A(ht,{size:[2.75,1.8,.2]})}),Ot(rI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[2.75,1.8,.01]})}),$A(Wi,{z:1,children:$A(ht,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),$A(ht,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),$ht=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),$A(ht,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[Ot(rI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[2.6-.1/2,1.7-.1/2,.01]})}),$A(Wi,{z:.01,children:$A(ht,{size:[2.6-.1,1.7-.1,.01]})})]}),Ot(rI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[2.6,1.7,.01]})}),$A(Wi,{z:1,children:$A(ht,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),$A(ht,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),Aut=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),$A(ht,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[Ot(rI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[3.8-.05/2,2.5-.05/2,.01]})}),$A(Wi,{z:.01,children:$A(ht,{size:[3.8-.05,2.5-.05,.01]})})]}),Ot(rI,{children:[$A(Wi,{z:.2,children:$A(ht,{size:[3.8,2.5,.01]})}),$A(Wi,{z:1,children:$A(ht,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),$A(ht,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),eut=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),$A(ht,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[$A(Wi,{z:.14/2,children:$A(ht,{size:[.8,.6,.14]})}),Ot(rI,{children:[$A(Wi,{z:.14,children:$A(ht,{size:[.8,.6,.01]})}),$A(Wi,{z:.37,children:$A(ht,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),tut=()=>{const I=3.0999999999999996;return Ot(Yn,{children:[$A(Kn,{rotation:Math.PI,position:{x:6.6/2+I/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(Kn,{position:{x:-6.6/2-I/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(Kn,{position:{x:-6.6/2-I/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(Kn,{position:{x:-6.6/2-I/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),$A(VB,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},iut=()=>Ot(Yn,{children:[Array.from({length:16}).map((l,C)=>$A(Kn,{position:{x:-10.5/2,y:C*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((l,C)=>$A(Kn,{rotation:Math.PI,position:{x:10.5/2,y:C*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((l,C)=>$A(Kn,{rotation:Math.PI/2,position:{x:C*.5-3.75,y:-10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((l,C)=>$A(Kn,{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})),$A(VB,{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})]}),nut=iut,out=()=>{const g=.7999999999999998;return Ot(Yn,{children:[$A(Kn,{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}),$A(Kn,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),$A(Kn,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),$A(VB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},sut=({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,I=.8,c=.2,B=(g-n)/2+.4;return Ot(Yn,{children:[Array.from({length:o}).map((l,C)=>$A(Kn,{position:{x:-g/2-.36,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:Math.PI,position:{x:g/2+.36,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>$A(Kn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),$A(VB,{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})]})},rut=()=>{const i=.20900000000000002,n=.1,o=.3,s=.1,r=.2;return Ot(Yn,{children:[$A(ys,{color:"#222",children:Ot(rE,{children:[$A(ht,{size:[.85,1.2,i],center:[0,0,i/2]}),Ot(rI,{children:[$A(Wi,{z:i,children:$A(ht,{size:[.85,1.2,.01]})}),$A(Wi,{z:.38,children:$A(ht,{size:[.85-n,1.2-n,.01]})})]})]})}),$A(ht,{color:"#ccc",size:[o,.25,s],center:[.55,0,s/2]}),$A(ht,{color:"#ccc",size:[o,r,s],center:[-.55,.4,s/2]}),$A(ht,{color:"#ccc",size:[o,r,s],center:[-.55,-.4,s/2]})]})},aut=({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=[],I=Math.floor(t/2),c=r*(I-1);for(let B=0;B<t;B++){const l=B<I?"left":"right",C=B%I,Q=c/2-C*r,E=s,h=o,u=l==="left"?-A/2+E/2:A/2-E/2,d=B+1;g.push({pinNumber:d,x:u,y:Q,padSizeX:E,padSizeY:h})}return Ot(Yn,{children:[$A(VB,{center:{x:0,y:0,z:0},width:A,length:e,height:i,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(A/2-s),y:e/2-s,z:i}}),g.map((B,l)=>$A(ht,{center:[B.x,B.y,a/2],size:[B.padSizeX,B.padSizeY,a]})),n?.length!==void 0&&n?.width!==void 0&&$A(ht,{center:[0,0,a/2],size:[n.width,n.length,a]})]})},gut=({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,I=a-g,c=i/2,B=.85;return Ot(Yn,{children:[Ot(ys,{color:s,children:[Ot(rI,{children:[$A(Pp,{height:e,roundRadius:.5,radius:g,center:[-I,0,e]}),$A(Pp,{height:e,roundRadius:.5,radius:g,center:[I,0,e]})]}),Ot(rI,{children:[$A(Pp,{height:B,roundRadius:.1,radius:g+.85,center:[-I,0,e/2+B/2]}),$A(Pp,{height:B,roundRadius:.1,radius:g+.85,center:[I,0,e/2+B/2]})]})]}),Ot(ys,{color:r,children:[$A(qp,{height:o+e/2,radius:n/2,center:[-c+.06,0,-(o/2)+e/2]}),$A(qp,{height:o+e/2,radius:n/2,center:[c-.06,0,-(o/2)+e/2]})]})]})},Iut=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:n="#111"})=>Ot(Yn,{children:[$A(ys,{color:e,children:Ot(lQ,{rotation:[0,"90deg",0],children:[$A(VU,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),$A(qp,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),$A(ys,{color:n,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(VU,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),$A(ys,{color:i,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),$A(ys,{color:i,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),cut=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Yn,{children:[$A(ys,{color:e,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),$A(ys,{color:i,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),$A(ys,{color:i,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),But=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Yn,{children:[$A(ys,{color:e,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),$A(ys,{color:i,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),$A(ys,{color:i,children:$A(lQ,{rotation:[0,"90deg",0],children:$A(Pp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),lut=({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 Ot(Yn,{children:[Array.from({length:n}).map((g,I)=>$A(Kn,{position:{x:-s/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,I)=>$A(Kn,{rotation:Math.PI,position:{x:s/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),$A(VB,{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})]})},Cut=({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 Ot(Yn,{children:[Array.from({length:n}).map((g,I)=>$A(Kn,{position:{x:-o/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,I)=>$A(Kn,{rotation:Math.PI,position:{x:o/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),$A(VB,{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})]})},Qut=()=>{const Q=7.050000000000001,E=24.95+6.5/2;return $A(Wi,{center:[0,0,1],children:Ot(Yn,{children:[Ot(lQ,{rotation:[0,55,-55],children:[Ot(VG,{children:[$A(ht,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[E,0,1.3-2]}),$A(qp,{color:"black",center:[E,0,1.3-2],radius:3/2,height:1.3*1.2})]}),$A(ys,{color:"#222",children:$A(VB,{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})})]}),$A(lQ,{rotation:[0,55,55],children:Array.from({length:3}).map((h,u)=>{const d=Q,f=(u-1)*2.7,w=-.5-.6;return Ot(ys,{color:"gold",children:[Ot(rI,{children:[$A(Wi,{center:[15.05-4.5/2+.1,f,w],children:$A(ht,{size:[4.5,.81+1,.5]})}),$A(Wi,{center:[15.05-4.5/2-1+.1,f,w],children:$A(ht,{size:[4.5,.81,.5]})})]}),$A(Wi,{center:[d,f,w],children:$A(ht,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},Eut=()=>{const g=1.1999999999999997;return Ot(Yn,{children:[$A(Kn,{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}),$A(Kn,{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}),$A(Kn,{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}),$A(Kn,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Kn,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(Kn,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),$A(VB,{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})]})},hut=()=>Ot(Yn,{children:[$A(VB,{center:{x:0,y:0,z:0},width:.8,length:1,height:.37,heightAboveSurface:0,color:"#1a1a1a",taperRatio:.15,straightHeightRatio:0,notchPosition:{x:-.8/4,y:.7/2.2,z:.37+.1}}),[0,1,2].map(g=>{const I=-.35+g*.35;return $A(ht,{center:[-.8/2+.19/2-.1,I,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(g=>{const I=-.35+g*.35;return $A(ht,{center:[.8/2-.19/2+.1,I,.12/2],size:[.19,.15,.12]})})]}),uut=()=>{const s="#222",a=[.43,.4,1.32],g=[.43,.4,.25],I=[0,0,-.66],c=[0,0,-1.32],B=[0,1.28,-2.72],l=[0,1.28,-8.9],C=-7.5;return Ot(Wi,{center:[0,1,10.5],children:[$A(ys,{color:s,children:Ot(VG,{children:[$A(Wi,{center:[0,0,2.25],children:$A(qp,{radius:2.4,height:4.5})}),$A(Wi,{center:[0,-1.8499999999999999,2.25],children:$A(ht,{size:[2.4*2,1.1,4.5+.2]})})]})}),$A(Wi,{center:I,children:$A(ht,{size:a})}),Ot(rI,{children:[$A(Wi,{center:c,children:$A(ht,{size:g})}),$A(Wi,{center:B,children:$A(ht,{size:g})})]}),$A(Wi,{center:l,children:$A(ht,{size:[.43,.4,12.2]})}),$A(Wi,{center:[1.3,0,C],children:$A(ht,{size:[.43,.4,15]})}),$A(Wi,{center:[-1.3,0,C],children:$A(ht,{size:[.43,.4,15]})})]})},dut=()=>Ot(Yn,{children:[$A(Kn,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Kn,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Kn,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Kn,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Kn,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(Kn,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),$A(VB,{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})]}),put=dut,fut=()=>Ot(Yn,{children:[$A(VB,{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 $A(ht,{center:[-1/2+.3/2,a,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(r=>{const a=-.5+r*.5;return $A(ht,{center:[1/2-.3/2,a,.05/2],size:[.3,.2,.05]})})]}),yut=()=>Ot(Yn,{children:[$A(Kn,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),$A(Kn,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),$A(ys,{color:"#222",children:$A(VB,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),$A(ht,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),mut=()=>Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),$A(ht,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),$A(ys,{color:"#222",children:Ot(rE,{children:[$A(Wi,{z:.175/2,children:$A(ht,{size:[1.7,1.25,.175]})}),Ot(rI,{children:[$A(Wi,{z:.175,children:$A(ht,{size:[1.7,1.25,.01]})}),$A(Wi,{z:.725,children:$A(ht,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),$A(ht,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),wut=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return Ot(Yn,{children:[$A(ht,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),$A(ht,{color:"#ccc",size:[.4,.325,.13],center:[r,0,.13/2]}),$A(ys,{color:"#222",children:$A(VB,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),$A(ht,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},Dut=({footprint:t})=>{const A=cht.string(t).json();switch(A.fn){case"dip":return $A(Eht,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"tssop":return $A(uht,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return $A(dht,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return $A(qht,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return $A(mht,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return $A(nut,{});case"lqfp":return $A(sut,{pinCount:A.num_pins});case"qfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return $A(Fht,{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 $A(aut,{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 $A(bht,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:o});if(A.female)return $A(Jht,{numberOfPins:A.num_pins,pitch:A.p,rows:o})}case"cap":switch(A.imperial){case"0402":return $A(rVA,{color:"#856c4d"});case"0603":return $A(aVA,{color:"#856c4d"});case"0805":return $A(gVA,{color:"#856c4d"});case"0201":return $A(IVA,{color:"#856c4d"});case"01005":return $A(cVA,{color:"#856c4d"});case"1206":return $A(BVA,{color:"#856c4d"});case"1210":return $A(lVA,{color:"#856c4d"});case"2010":return $A(CVA,{color:"#856c4d"});case"2512":return $A(QVA,{color:"#856c4d"})}case"sot235":return $A(Nht,{});case"sot457":return $A(Eut,{});case"sot223":return $A(tut,{});case"sot23w":return $A(Mht,{});case"sot323":return $A(out,{});case"sod323f":return $A(mut,{});case"sod323fl":return $A(wut,{});case"sot363":return $A(put,{});case"sot886":return $A(fut,{});case"sot963":return $A(hut,{});case"pushbutton":return $A(Tht,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return $A(Kht,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return $A(Pht,{});case"sod882":return $A(Oht,{});case"sma":return $A(Wht,{});case"smb":return $A(Zht,{});case"smc":return $A(Vht,{});case"smf":return $A(jht,{});case"sod123f":return $A(zht,{});case"sod123fl":return $A(Xht,{});case"sod123w":return $A($ht,{});case"sod128":return $A(Aut,{});case"sod323":return $A(yut,{});case"sod923":return $A(eut,{});case"hc49":return $A(gut,{});case"micromelf":return $A(Iut,{});case"minimelf":return $A(cut,{});case"melf":return $A(But,{});case"ms012":return $A(lut,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return $A(Cut,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return $A(rut,{});case"to220":return $A(Qut,{});case"to92":return $A(uut,{})}const e=t.match(/_color\(([^)]+)\)/),i=e?e[1]:void 0;switch(A.imperial){case"0402":return $A(rVA,{color:i});case"0603":return $A(aVA,{color:i});case"0805":return $A(gVA,{color:i});case"0201":return $A(IVA,{color:i});case"01005":return $A(cVA,{color:i});case"1206":return $A(BVA,{color:i});case"1210":return $A(lVA,{color:i});case"2010":return $A(CVA,{color:i});case"2512":return $A(QVA,{color:i})}return null},Sut=t=>t&&typeof t=="object"&&"type"in t,zM=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},but=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 Gw(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(B=>Gw(B,A,e));if(!Sut(t))return[];const{type:g,props:I,children:c}=t;if(g===iVA)return(c??[]).flatMap(B=>Gw(B,A,e));if(g===ys){const B=I?.color;return(c??[]).flatMap(l=>Gw(l,B??A,e))}if(g===Wi){const B=but(I?.offset??I?.center??{x:I?.x,y:I?.y,z:I?.z});return(c??[]).flatMap(C=>Gw(C,A,e)).map(({geom:C,color:Q})=>({geom:a.translate(B,C),color:Q??A}))}if(g===lQ){const B=Array.isArray(I?.rotation)?[zM(I.rotation[0]),zM(I.rotation[1]),zM(I.rotation[2])]:[zM(I?.x??0),zM(I?.y??0),zM(I?.z??0)];return(c??[]).flatMap(C=>Gw(C,A,e)).map(({geom:C,color:Q})=>({geom:a.rotateZ(B[2],a.rotateY(B[1],a.rotateX(B[0],C))),color:Q}))}if(g===rE||g===VG||g===rI){const B=(c??[]).flatMap(C=>Gw(C,A,e)).map(C=>C.geom);if(B.length===0)return[];let l;return g===rE?l=n.union(B):g===VG?l=n.subtract(B[0],B.slice(1)):l=o.hull(B),[{geom:l,color:A}]}if(g===jU){const B=I?.points??[];return[{geom:s.geom2.fromPoints(B),color:A??I?.color}]}if(g===zU){const B=(c??[]).flatMap(E=>Gw(E,A,e)).map(E=>E.geom);if(B.length===0)return[];const l=B.length>1?n.union(B):B[0],C=I?.height??I?.h??1;let Q=r.extrudeLinear({height:C},l);if(Q.polygons)for(const E of Q.polygons)!E.plane||!E.vertices||E.vertices.length<3||E.vertices.reverse();return[{geom:Q,color:A??I?.color}]}if(g===ht||g===nVA||g===qp||g===oVA||g===VU||g===Pp){let B;if(g===ht){const l=I?.size??[1,1,1],C=I?.offset,Q=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);B=i.cuboid({size:l,center:Q})}else if(g===nVA){const l=I?.size??1,C=I?.offset,Q=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);B=i.cube({size:l,center:Q})}else if(g===qp){const l=I?.height??1,C=I?.radius??1,Q=I?.center??[0,0,0];B=i.cylinder({height:l,radius:C,center:Q})}else if(g===oVA){const l=I?.radius??1,C=I?.center??[0,0,0];B=i.sphere({radius:l,center:C})}else if(g===Pp){const l=I?.height??1,C=I?.radius??1,Q=I?.roundRadius??.1,E=I?.center??[0,0,0];B=i.roundedCylinder({height:l,radius:C,roundRadius:Q,center:E})}else{const l=I?.size??[1,1,1],C=I?.roundRadius??.1,Q=I?.center??[0,0,0];B=i.roundedCuboid({size:l,roundRadius:C,center:Q})}return[{geom:B,color:A??I?.color}]}if(typeof g=="function"){const B=g(I??{});return Gw(B,A,e)}return(c??[]).flatMap(B=>Gw(B,A,e))}function xut(t,A){return{geometries:Gw(t,void 0,{jscad:A})}}function EVA(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,I=s.vertices[a].index;e.push(r,g,I)}}const o=new Ug;if(o.setAttribute("position",new sI(new Float32Array(A),3)),o.setIndex(e),i.length>0&&o.setAttribute("color",new sI(new Float32Array(i),3)),t.transforms){const s=new As;s.fromArray(t.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(t.sides){const A=[],e=[];for(const n of t.sides)A.push(n[0][0],n[0][1],0),t.color&&t.color.length>=3?e.push(t.color[0],t.color[1],t.color[2]):e.push(1,1,1);const i=new Ug;if(i.setAttribute("position",new sI(new Float32Array(A),3)),e.length>0&&i.setAttribute("color",new sI(new Float32Array(e),3)),t.transforms){const n=new As;n.fromArray(t.transforms),i.applyMatrix4(n)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Ug}function kut(t,A){const e=ulA(Dut,{footprint:t});return xut(e,A)}var Gut=({jscadPlan:t,positionOffset:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=yu(),{threeGeom:g,material:I}=z.useMemo(()=>{const B=(0,nIt.executeJscadOperations)(oIt.default,t);if(!B||!B.polygons&&!B.sides)return{threeGeom:null,material:null};const l=EVA(B),C=new fu({vertexColors:!0,side:vl,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:l,material:C}},[t,r]),c=z.useMemo(()=>g?new Ao(g,I):null,[g,I]);return z.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),z.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]),z.useMemo(()=>{if(I)if(o){const B=new Ji(I.color.getHex());I.emissive.copy(B),I.emissive.setRGB(0,0,1),I.emissiveIntensity=.2}else I.emissiveIntensity=0},[o,I]),g?O.jsx(OU,{isHovered:o,onHover:i,onUnhover:n,object:c}):null},Fut=fr(t5()),Rut=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=yu(),g=z.useMemo(()=>{if(!A)return null;const{geometries:I}=kut(A,Fut),c=new zf;for(const B of I.flat(1/0)){const l=B.geom;if(!l||!l.polygons&&!l.sides)continue;const C=new Ji(B.color);C.convertLinearToSRGB();const Q={...l,color:[C.r,C.g,C.b]},E=EVA(Q),h=new fu({vertexColors:!0,side:vl,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new Ao(E,h);c.add(u)}return c},[A,r]);return z.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),z.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]),z.useEffect(()=>{g&&g.traverse(I=>{I instanceof Ao&&I.material instanceof fu&&(o?(I.material.emissive.setHex(255),I.material.emissiveIntensity=.2):I.material.emissiveIntensity=0)})},[o,g]),g?O.jsx(OU,{isHovered:o,onHover:i,onUnhover:n,object:g}):null},Nut=(...t)=>t,sL={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},hVA=({children:t,position:A,style:e})=>{const{camera:i,renderer:n}=yu(),o=z.useRef(document.createElement("div")),[s,r]=z.useState(null);return z.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(bP.createPortal(t,o.current)),()=>{a.contains(o.current)&&a.removeChild(o.current)}},[n,t]),PU(()=>{if(!i||!o.current||!n)return;const a=new Re(...A);a.project(i);const g=n.domElement.getBoundingClientRect(),I=Math.round((a.x+1)/2*g.width),c=Math.round((-a.y+1)/2*g.height);o.current.style.position="absolute",o.current.style.left=`${I}px`,o.current.style.top=`${c}px`,o.current.style.pointerEvents="none",o.current.style.zIndex=sL.htmlElements.toString(),e&&Object.assign(o.current.style,e)},[i,n,A,e]),s},uVA={boardBody:!0,topCopper:!0,bottomCopper:!0,adhesive:!1,solderPaste:!1,topSilkscreen:!0,bottomSilkscreen:!0,topMask:!0,bottomMask:!0,throughHoleModels:!0,smtModels:!0,translucentModels:!0,modelsNotInPosFile:!1,modelsMarkedDNP:!1,modelBoundingBoxes:!1,threedAxis:!1,backgroundStart:!0,backgroundEnd:!0},dVA=z.createContext(void 0),Mut=({children:t})=>{const[A,e]=z.useState(uVA),i=z.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),n=z.useCallback(()=>{e(uVA)},[]),o=z.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:n}),[A,i,n]);return O.jsx(dVA.Provider,{value:o,children:t})},XM=()=>{const t=z.useContext(dVA);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},pVA=({cad_component:t,circuitJson:A})=>{const[e,i]=z.useState(!1),{visibility:n}=XM(),[o,s]=z.useState(null),r=z.useCallback(Q=>{Q?.mousePosition?(i(!0),s(Q.mousePosition)):(i(!1),s(null))},[]),a=z.useCallback(()=>{i(!1),s(null)},[]),g=z.useMemo(()=>yi(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),I=z.useMemo(()=>A.filter(E=>E.type==="pcb_plated_hole"&&E.pcb_component_id===t.pcb_component_id).length>0,[A,t.pcb_component_id]),c=t.model_obj_url??t.model_wrl_url??t.model_stl_url,B=t.model_glb_url??t.model_gltf_url,l=t.rotation?Nut(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):void 0;let C=null;if(c?C=O.jsx(AIt,{url:c,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:l,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):B?C=O.jsx(iIt,{gltfUrl:B,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:l,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.model_jscad?C=O.jsx(Gut,{jscadPlan:t.model_jscad,rotationOffset:l,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(C=O.jsx(Rut,{positionOffset:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotationOffset:l,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model})),t.show_as_translucent_model){if(!n.translucentModels)return null}else if(I&&!n.throughHoleModels||!I&&!n.smtModels)return null;return O.jsxs(O.Fragment,{children:[C,e&&o?O.jsx(hVA,{position:o,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:g??"<unknown>"}):null]})},fVA={version:"0.0.481"};function _ut(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var vut=t=>{t.outputColorSpace=gm,t.toneMapping=UUA,t.toneMappingExposure=1},yVA="cadViewerCameraStateSession",mVA=(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(yVA,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},LlA=(t,A)=>{try{const e=sessionStorage.getItem(yVA);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}},wVA=z.createContext(void 0),Uut=({children:t,defaultTarget:A,initialCameraPosition:e})=>{const i=z.useRef(null),n=z.useRef(null),[o,s]=z.useState(null),[r,a]=z.useState("perspective"),[g,I]=z.useState(e??null),[c,B]=z.useState(new Tp(0,0,0)),l=z.useMemo(()=>{const[h,u,d]=e??[5,-5,5],f=Math.hypot(h-A.x,u-A.y,d-A.z);return f>0?f:5},[e,A]),C=z.useCallback(h=>{const u=[A.x,A.y,A.z],d=n.current,f=i.current;let w=l;switch(d&&f&&(w=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const S=w/Math.sqrt(2);return{position:[A.x,A.y-S,A.z+S],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+w],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-w*.6,A.y-w*.6,A.z+w*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+w*.6,A.y-w*.6,A.z+w*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-w,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+w,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-w,A.z],target:u,up:[0,0,1]};default:return null}},[l,A,n,i]),Q=z.useCallback(h=>{i.current=h},[]),E=z.useMemo(()=>({controlsRef:i,mainCameraRef:n,defaultTarget:A,baseDistance:l,controller:o,setController:s,getPresetConfig:C,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:I,cameraRotation:c,setCameraRotation:B,saveCameraToSession:mVA,loadCameraFromSession:LlA}),[A,l,o,C,Q,r,g,c]);return O.jsx(wVA.Provider,{value:E,children:t})},mx=()=>{const t=z.useContext(wVA);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},Lut=z.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:n},o)=>{const{cameraType:s}=mx(),r=z.useRef(null),[a,g]=z.useState(null),I=z.useRef([]),c=z.useRef(void 0);c.current=n;const B=z.useRef(null),l=z.useCallback(h=>{I.current.push(h)},[]),C=z.useCallback(h=>{I.current=I.current.filter(u=>u!==h)},[]),Q=z.useMemo(()=>new MG,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const E=z.useRef(new hg);return z.useImperativeHandle(o,()=>E.current),z.useEffect(()=>{if(!r.current)return;_ut(r.current);const h=new K3({antialias:!0,alpha:!0});vut(h),h.setSize(r.current.clientWidth,r.current.clientHeight),h.setPixelRatio(window.devicePixelRatio),r.current.appendChild(h.domElement);const u=r.current.clientWidth/r.current.clientHeight,d=s==="perspective"?new sE(75,u,.1,1e3):new oU(-10*u,10*u,10,-10,-1e3,1e3);B.current?(d.position.copy(B.current.position),d.quaternion.copy(B.current.quaternion),d.up.copy(B.current.up)):(e?.up&&d.up.set(e.up[0],e.up[1],e.up[2]),e?.position&&d.position.set(e.position[0],e.position[1],e.position[2]),d.lookAt(0,0,0)),Q.add(E.current),window.__TSCIRCUIT_THREE_OBJECT=E.current,g({scene:Q,camera:d,renderer:h,rootObject:E.current,addFrameListener:l,removeFrameListener:C}),c.current?.({camera:d,renderer:h});let f;const w=new jze,S=()=>{const x=w.getElapsedTime(),F=w.getDelta();I.current.forEach(k=>k(x,F)),h.render(Q,d),f=requestAnimationFrame(S)};S();const D=()=>{if(r.current){const x=r.current.clientWidth/r.current.clientHeight;d instanceof sE?d.aspect=x:d instanceof oU&&(d.left=-10*x,d.right=10*x,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),h.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",D),()=>{B.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",D),cancelAnimationFrame(f),r.current&&h.domElement&&r.current.removeChild(h.domElement),h.dispose(),Q.remove(E.current),window.__TSCIRCUIT_THREE_OBJECT===E.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,l,C,s]),O.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&O.jsx($WA.Provider,{value:a,children:O.jsx(Vgt,{children:t})})})}),Hut=({autoRotate:t,autoRotateSpeed:A,onStart:e,panSpeed:i,rotateSpeed:n,zoomSpeed:o,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:I,renderer:c}=yu(),B=z.useMemo(()=>!I||!c?null:new x6e(I,c.domElement),[I,c]);return z.useEffect(()=>(g?.(B??null),()=>g?.(null)),[B,g]),z.useEffect(()=>{if(!B)return;const l=()=>{g?.(B)};return B.addEventListener("change",l),()=>{B.removeEventListener("change",l)}},[B,g]),z.useEffect(()=>{B&&(B.autoRotate=t||!1,B.autoRotateSpeed=A||1,i!==void 0&&(B.panSpeed=i),n!==void 0&&(B.rotateSpeed=n),o!==void 0&&(B.zoomSpeed=o),s!==void 0&&(B.enableDamping=s),r!==void 0&&(B.dampingFactor=r),B.zoomToCursor=!0,B.mouseButtons={LEFT:Xb.ROTATE,MIDDLE:Xb.PAN,RIGHT:null},a&&(B.target.set(a[0],a[1],a[2]),B.update()))},[B,t,A,i,n,o,s,r,a]),z.useEffect(()=>{if(!(!B||!e))return B.addEventListener("start",e),()=>{B.removeEventListener("start",e)}},[B,e]),z.useEffect(()=>{if(B)return()=>{B.dispose()}},[B]),PU(()=>{B?.update()},[B]),null},Yut=`
5067
5067
  varying vec3 worldPosition;
5068
5068
  void main() {
5069
5069
  worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
@@ -5602,7 +5602,7 @@ test("${g} should solve problem correctly", () => {
5602
5602
  // Add more specific assertions based on expected output
5603
5603
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5604
5604
  })
5605
- `,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),l=document.createElement("a");l.href=B,l.download=`${g}.test.ts`,l.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return O.jsxs("div",{className:`relative ${A}`,ref:n,children:[O.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&O.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Tee=t=>t.activeSubSolver?[t,...Tee(t.activeSubSolver)]:[t],DHt=({solver:t})=>{const A=Tee(t);return O.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>O.jsxs("div",{className:"flex items-center",children:[i>0&&O.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),O.jsx(wHt,{solver:e})]},e.constructor.name))})},SHt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=z.useReducer(Q=>!Q,!1),r=z.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))},I=()=>{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))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};z.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),z.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const l=t.getCurrentPhase!==void 0,C=l?t.getCurrentPhase():null;return O.jsxs("div",{className:"space-y-2 p-2 border-b",children:[O.jsx("div",{className:"flex items-center",children:O.jsx(DHt,{solver:t})}),O.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[O.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"}),O.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"}),O.jsx("button",{onClick:I,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"}),O.jsx("button",{onClick:B,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"}),l&&O.jsx("button",{onClick:c,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"}),O.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",O.jsx("span",{className:"font-medium",children:C})]}),t.solved&&O.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&O.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&O.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},bHt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},xHt=(t,A)=>{const i=t.pipelineDef[A].solverName,n=bHt(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const B=t.pipelineDef[A+1],l=B?t.firstIterationOfPhase?.[B.solverName]:void 0;l!==void 0&&s!==null?a=l-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;n==="Completed"?I=1:n==="In Progress"&&o&&(I=o.progress??0);const c=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:o??null}},kHt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return O.jsx("span",{className:`font-medium ${A[t]}`,children:t})},GHt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:O.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),O.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},FHt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),RHt=({stats:t})=>{if(!t||Object.keys(t).length===0)return O.jsx("span",{children:"-"});const A=Object.entries(t),e=FHt(t);return O.jsxs("details",{className:"cursor-pointer",children:[O.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),O.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>O.jsxs("div",{children:[i,": ",String(n)]},i))})]})},ehA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(ehA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=ehA(i));return A},NHt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=ehA(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)}`)}},MHt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>xHt(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):NHt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return O.jsxs("div",{className:"border-t border-gray-200",children:[O.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:O.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),O.jsx("div",{className:"overflow-x-auto",children:O.jsxs("table",{className:"w-full text-sm",children:[O.jsx("thead",{children:O.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),O.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",O.jsx("sub",{children:"0"})]}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),O.jsx("tbody",{children:i.map(r=>O.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[O.jsx("td",{className:"px-4 py-2",children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),O.jsx("button",{onClick:()=>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:O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),O.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(kHt,{status:r.status})}),O.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(GHt,{progress:r.progress})}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),O.jsx("td",{className:"px-4 py-2 text-gray-500",children:O.jsx(RHt,{stats:r.stats})}),O.jsx("td",{className:"px-4 py-2",children:r.solverInstance?O.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:[O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),O.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},_Ht=class extends zi.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 vHt({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 I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of n){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of o)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,l=r-c,C=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return O.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${l} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>O.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>O.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),n.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),o.map((E,h)=>O.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var UHt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=z.useReducer(I=>I+1,0),s=z.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=z.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);z.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();o()}};return O.jsxs("div",{children:[O.jsx(SHt,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?O.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):O.jsx(_Ht,{fallback:O.jsx(vHt,{graphics:s}),children:O.jsx(mHt,{graphics:s})}),a&&O.jsx(MHt,{solver:t,onStepUntilPhase:g})]})};const LHt=()=>{z.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)},[])},HHt=t=>t.toLowerCase().includes("pack")?Nwt:t.toLowerCase().includes("rout")?Lwt:uwt,YHt=({solverEvents:t=[]})=>{const[A,e]=z.useState(null);LHt();const i=z.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=z.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=z.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=$AA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys($AA).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?O.jsx("div",{className:"rf-p-4",children:O.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:O.jsxs("div",{className:"rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),O.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):O.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[O.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[O.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return O.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=HHt(a.solverName);return O.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[O.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),O.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[O.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),O.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),O.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?O.jsx(uy,{fallback:O.jsx("div",{className:"rf-p-4",children:O.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),O.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:O.jsx(UHt,{solver:s.instance})}):O.jsxs("div",{className:"rf-p-4",children:[O.jsxs("div",{className:"rf-mb-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),O.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&O.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:O.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),O.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[O.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:O.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),O.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:O.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):O.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:O.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Kee=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{z.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{s3.captureException(i)}catch{}}},[t,A]),z.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{s3.captureException(n,{error_type:i.type})}catch{}}},[e])},qee="0.0.1458",JHt={version:qee},PW=SvA()(bvA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),THt=t=>{const[A,e]=z.useState([]),[i,n]=z.useState(null),[o,s]=z.useState(""),[r,a]=v_("eval-version-selection",null),g=PW(l=>l.setLastRunEvalVersion),I=PW(l=>l.lastRunEvalVersion);return z.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(l=>l.json()).then(l=>{if(Array.isArray(l?.versions)){let C=[...l.versions];l.tags?.latest&&(n(l.tags.latest),C=C.filter(Q=>Q!==l.tags.latest)),e(C)}}).catch(()=>{})},[t]),z.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:z.useMemo(()=>A.filter(l=>l.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:I,search:o,setSearch:s,selectVersion:l=>{a(l),s("")}}},KHt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=z.useState(""),[s,r]=z.useState("");if(!i)return null;const a=t.filter(c=>c.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),I=c=>{c.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return O.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:O.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[O.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),O.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:c=>r(c.target.value),onKeyDown:I}),O.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(c=>O.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===c?"bg-blue-50":""}`,onClick:()=>o(c),children:c},c)),g&&O.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),O.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},qHt=t=>{const A=z.useRef(null),e=Uc(i=>i.recentEvents);z.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 PHt(t){const A=OHt(t),e=z.forwardRef((i,n)=>{const{children:o,...s}=i,r=z.Children.toArray(o),a=r.find(ZHt);if(a){const g=a.props.children,I=r.map(c=>c===a?z.Children.count(g)>1?z.Children.only(null):z.isValidElement(g)?g.props.children:null:c);return O.jsx(A,{...s,ref:n,children:z.isValidElement(g)?z.cloneElement(g,void 0,I):null})}return O.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function OHt(t){const A=z.forwardRef((e,i)=>{const{children:n,...o}=e;if(z.isValidElement(n)){const s=jHt(n),r=VHt(o,n.props);return n.type!==z.Fragment&&(r.ref=i?Lp(i,s):s),z.cloneElement(n,r)}return z.Children.count(n)>1?z.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var WHt=Symbol("radix.slottable");function ZHt(t){return z.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===WHt}function VHt(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 jHt(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 OW="Dialog",[Pee,Oee]=Qw(OW),[zHt,Fm]=Pee(OW),Wee=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=z.useRef(null),a=z.useRef(null),[g,I]=QG({prop:i,defaultProp:n??!1,onChange:o,caller:OW});return O.jsx(zHt,{scope:A,triggerRef:r,contentRef:a,contentId:Cu(),titleId:Cu(),descriptionId:Cu(),open:g,onOpenChange:I,onOpenToggle:z.useCallback(()=>I(c=>!c),[I]),modal:s,children:e})};Wee.displayName=OW;var Zee="DialogTrigger",Vee=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Fm(Zee,e),o=dB(A,n.triggerRef);return O.jsx(Bg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":nhA(n.open),...i,ref:o,onClick:go(t.onClick,n.onOpenToggle)})});Vee.displayName=Zee;var thA="DialogPortal",[XHt,jee]=Pee(thA,{forceMount:void 0}),zee=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Fm(thA,A);return O.jsx(XHt,{scope:A,forceMount:e,children:z.Children.map(i,s=>O.jsx(oy,{present:e||o.open,children:O.jsx(h8,{asChild:!0,container:n,children:s})}))})};zee.displayName=thA;var WW="DialogOverlay",Xee=z.forwardRef((t,A)=>{const e=jee(WW,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Fm(WW,t.__scopeDialog);return o.modal?O.jsx(oy,{present:i||o.open,children:O.jsx(AYt,{...n,ref:A})}):null});Xee.displayName=WW;var $Ht=PHt("DialogOverlay.RemoveScroll"),AYt=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Fm(WW,e);return O.jsx(D8,{as:$Ht,allowPinchZoom:!0,shards:[n.contentRef],children:O.jsx(Bg.div,{"data-state":nhA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),wF="DialogContent",$ee=z.forwardRef((t,A)=>{const e=jee(wF,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Fm(wF,t.__scopeDialog);return O.jsx(oy,{present:i||o.open,children:o.modal?O.jsx(eYt,{...n,ref:A}):O.jsx(tYt,{...n,ref:A})})});$ee.displayName=wF;var eYt=z.forwardRef((t,A)=>{const e=Fm(wF,t.__scopeDialog),i=z.useRef(null),n=dB(A,e.contentRef,i);return z.useEffect(()=>{const o=i.current;if(o)return tQA(o)},[]),O.jsx(Ate,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:go(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:go(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:go(t.onFocusOutside,o=>o.preventDefault())})}),tYt=z.forwardRef((t,A)=>{const e=Fm(wF,t.__scopeDialog),i=z.useRef(!1),n=z.useRef(!1);return O.jsx(Ate,{...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()}})}),Ate=z.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Fm(wF,e),a=z.useRef(null),g=dB(A,a);return UCA(),O.jsxs(O.Fragment,{children:[O.jsx(o8,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:O.jsx(n8,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":nhA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),O.jsxs(O.Fragment,{children:[O.jsx(nYt,{titleId:r.titleId}),O.jsx(sYt,{contentRef:a,descriptionId:r.descriptionId})]})]})}),ihA="DialogTitle",ete=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Fm(ihA,e);return O.jsx(Bg.h2,{id:n.titleId,...i,ref:A})});ete.displayName=ihA;var tte="DialogDescription",ite=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Fm(tte,e);return O.jsx(Bg.p,{id:n.descriptionId,...i,ref:A})});ite.displayName=tte;var nte="DialogClose",ote=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Fm(nte,e);return O.jsx(Bg.button,{type:"button",...i,ref:A,onClick:go(t.onClick,()=>n.onOpenChange(!1))})});ote.displayName=nte;function nhA(t){return t?"open":"closed"}var ste="DialogTitleWarning",[iYt,rte]=xPe(ste,{contentName:wF,titleName:ihA,docsSlug:"dialog"}),nYt=({titleId:t})=>{const A=rte(ste),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5605
+ `,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),l=document.createElement("a");l.href=B,l.download=`${g}.test.ts`,l.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return O.jsxs("div",{className:`relative ${A}`,ref:n,children:[O.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&O.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Tee=t=>t.activeSubSolver?[t,...Tee(t.activeSubSolver)]:[t],DHt=({solver:t})=>{const A=Tee(t);return O.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>O.jsxs("div",{className:"flex items-center",children:[i>0&&O.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),O.jsx(wHt,{solver:e})]},e.constructor.name))})},SHt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=z.useReducer(Q=>!Q,!1),r=z.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))},I=()=>{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))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};z.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),z.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const l=t.getCurrentPhase!==void 0,C=l?t.getCurrentPhase():null;return O.jsxs("div",{className:"space-y-2 p-2 border-b",children:[O.jsx("div",{className:"flex items-center",children:O.jsx(DHt,{solver:t})}),O.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[O.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"}),O.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"}),O.jsx("button",{onClick:I,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"}),O.jsx("button",{onClick:B,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"}),l&&O.jsx("button",{onClick:c,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"}),O.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",O.jsx("span",{className:"font-medium",children:C})]}),t.solved&&O.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&O.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&O.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},bHt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},xHt=(t,A)=>{const i=t.pipelineDef[A].solverName,n=bHt(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const B=t.pipelineDef[A+1],l=B?t.firstIterationOfPhase?.[B.solverName]:void 0;l!==void 0&&s!==null?a=l-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;n==="Completed"?I=1:n==="In Progress"&&o&&(I=o.progress??0);const c=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:o??null}},kHt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return O.jsx("span",{className:`font-medium ${A[t]}`,children:t})},GHt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:O.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),O.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},FHt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),RHt=({stats:t})=>{if(!t||Object.keys(t).length===0)return O.jsx("span",{children:"-"});const A=Object.entries(t),e=FHt(t);return O.jsxs("details",{className:"cursor-pointer",children:[O.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),O.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>O.jsxs("div",{children:[i,": ",String(n)]},i))})]})},ehA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(ehA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=ehA(i));return A},NHt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=ehA(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)}`)}},MHt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>xHt(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):NHt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return O.jsxs("div",{className:"border-t border-gray-200",children:[O.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:O.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),O.jsx("div",{className:"overflow-x-auto",children:O.jsxs("table",{className:"w-full text-sm",children:[O.jsx("thead",{children:O.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),O.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",O.jsx("sub",{children:"0"})]}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),O.jsx("tbody",{children:i.map(r=>O.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[O.jsx("td",{className:"px-4 py-2",children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),O.jsx("button",{onClick:()=>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:O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),O.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(kHt,{status:r.status})}),O.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(GHt,{progress:r.progress})}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),O.jsx("td",{className:"px-4 py-2 text-gray-500",children:O.jsx(RHt,{stats:r.stats})}),O.jsx("td",{className:"px-4 py-2",children:r.solverInstance?O.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:[O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),O.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},_Ht=class extends zi.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 vHt({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 I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of n){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of o)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,l=r-c,C=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return O.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${l} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>O.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>O.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),n.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),o.map((E,h)=>O.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var UHt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=z.useReducer(I=>I+1,0),s=z.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=z.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);z.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();o()}};return O.jsxs("div",{children:[O.jsx(SHt,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?O.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):O.jsx(_Ht,{fallback:O.jsx(vHt,{graphics:s}),children:O.jsx(mHt,{graphics:s})}),a&&O.jsx(MHt,{solver:t,onStepUntilPhase:g})]})};const LHt=()=>{z.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)},[])},HHt=t=>t.toLowerCase().includes("pack")?Nwt:t.toLowerCase().includes("rout")?Lwt:uwt,YHt=({solverEvents:t=[]})=>{const[A,e]=z.useState(null);LHt();const i=z.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=z.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=z.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=$AA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys($AA).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?O.jsx("div",{className:"rf-p-4",children:O.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:O.jsxs("div",{className:"rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),O.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):O.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[O.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[O.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return O.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=HHt(a.solverName);return O.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[O.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),O.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[O.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),O.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),O.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?O.jsx(uy,{fallback:O.jsx("div",{className:"rf-p-4",children:O.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),O.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:O.jsx(UHt,{solver:s.instance})}):O.jsxs("div",{className:"rf-p-4",children:[O.jsxs("div",{className:"rf-mb-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),O.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&O.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:O.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),O.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[O.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:O.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),O.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:O.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):O.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:O.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Kee=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{z.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{s3.captureException(i)}catch{}}},[t,A]),z.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{s3.captureException(n,{error_type:i.type})}catch{}}},[e])},qee="0.0.1459",JHt={version:qee},PW=SvA()(bvA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),THt=t=>{const[A,e]=z.useState([]),[i,n]=z.useState(null),[o,s]=z.useState(""),[r,a]=v_("eval-version-selection",null),g=PW(l=>l.setLastRunEvalVersion),I=PW(l=>l.lastRunEvalVersion);return z.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(l=>l.json()).then(l=>{if(Array.isArray(l?.versions)){let C=[...l.versions];l.tags?.latest&&(n(l.tags.latest),C=C.filter(Q=>Q!==l.tags.latest)),e(C)}}).catch(()=>{})},[t]),z.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:z.useMemo(()=>A.filter(l=>l.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:I,search:o,setSearch:s,selectVersion:l=>{a(l),s("")}}},KHt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=z.useState(""),[s,r]=z.useState("");if(!i)return null;const a=t.filter(c=>c.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),I=c=>{c.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return O.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:O.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[O.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),O.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:c=>r(c.target.value),onKeyDown:I}),O.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(c=>O.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===c?"bg-blue-50":""}`,onClick:()=>o(c),children:c},c)),g&&O.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),O.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},qHt=t=>{const A=z.useRef(null),e=Uc(i=>i.recentEvents);z.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 PHt(t){const A=OHt(t),e=z.forwardRef((i,n)=>{const{children:o,...s}=i,r=z.Children.toArray(o),a=r.find(ZHt);if(a){const g=a.props.children,I=r.map(c=>c===a?z.Children.count(g)>1?z.Children.only(null):z.isValidElement(g)?g.props.children:null:c);return O.jsx(A,{...s,ref:n,children:z.isValidElement(g)?z.cloneElement(g,void 0,I):null})}return O.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function OHt(t){const A=z.forwardRef((e,i)=>{const{children:n,...o}=e;if(z.isValidElement(n)){const s=jHt(n),r=VHt(o,n.props);return n.type!==z.Fragment&&(r.ref=i?Lp(i,s):s),z.cloneElement(n,r)}return z.Children.count(n)>1?z.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var WHt=Symbol("radix.slottable");function ZHt(t){return z.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===WHt}function VHt(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 jHt(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 OW="Dialog",[Pee,Oee]=Qw(OW),[zHt,Fm]=Pee(OW),Wee=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=z.useRef(null),a=z.useRef(null),[g,I]=QG({prop:i,defaultProp:n??!1,onChange:o,caller:OW});return O.jsx(zHt,{scope:A,triggerRef:r,contentRef:a,contentId:Cu(),titleId:Cu(),descriptionId:Cu(),open:g,onOpenChange:I,onOpenToggle:z.useCallback(()=>I(c=>!c),[I]),modal:s,children:e})};Wee.displayName=OW;var Zee="DialogTrigger",Vee=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Fm(Zee,e),o=dB(A,n.triggerRef);return O.jsx(Bg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":nhA(n.open),...i,ref:o,onClick:go(t.onClick,n.onOpenToggle)})});Vee.displayName=Zee;var thA="DialogPortal",[XHt,jee]=Pee(thA,{forceMount:void 0}),zee=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Fm(thA,A);return O.jsx(XHt,{scope:A,forceMount:e,children:z.Children.map(i,s=>O.jsx(oy,{present:e||o.open,children:O.jsx(h8,{asChild:!0,container:n,children:s})}))})};zee.displayName=thA;var WW="DialogOverlay",Xee=z.forwardRef((t,A)=>{const e=jee(WW,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Fm(WW,t.__scopeDialog);return o.modal?O.jsx(oy,{present:i||o.open,children:O.jsx(AYt,{...n,ref:A})}):null});Xee.displayName=WW;var $Ht=PHt("DialogOverlay.RemoveScroll"),AYt=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Fm(WW,e);return O.jsx(D8,{as:$Ht,allowPinchZoom:!0,shards:[n.contentRef],children:O.jsx(Bg.div,{"data-state":nhA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),wF="DialogContent",$ee=z.forwardRef((t,A)=>{const e=jee(wF,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Fm(wF,t.__scopeDialog);return O.jsx(oy,{present:i||o.open,children:o.modal?O.jsx(eYt,{...n,ref:A}):O.jsx(tYt,{...n,ref:A})})});$ee.displayName=wF;var eYt=z.forwardRef((t,A)=>{const e=Fm(wF,t.__scopeDialog),i=z.useRef(null),n=dB(A,e.contentRef,i);return z.useEffect(()=>{const o=i.current;if(o)return tQA(o)},[]),O.jsx(Ate,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:go(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:go(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:go(t.onFocusOutside,o=>o.preventDefault())})}),tYt=z.forwardRef((t,A)=>{const e=Fm(wF,t.__scopeDialog),i=z.useRef(!1),n=z.useRef(!1);return O.jsx(Ate,{...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()}})}),Ate=z.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Fm(wF,e),a=z.useRef(null),g=dB(A,a);return UCA(),O.jsxs(O.Fragment,{children:[O.jsx(o8,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:O.jsx(n8,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":nhA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),O.jsxs(O.Fragment,{children:[O.jsx(nYt,{titleId:r.titleId}),O.jsx(sYt,{contentRef:a,descriptionId:r.descriptionId})]})]})}),ihA="DialogTitle",ete=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Fm(ihA,e);return O.jsx(Bg.h2,{id:n.titleId,...i,ref:A})});ete.displayName=ihA;var tte="DialogDescription",ite=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Fm(tte,e);return O.jsx(Bg.p,{id:n.descriptionId,...i,ref:A})});ite.displayName=tte;var nte="DialogClose",ote=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Fm(nte,e);return O.jsx(Bg.button,{type:"button",...i,ref:A,onClick:go(t.onClick,()=>n.onOpenChange(!1))})});ote.displayName=nte;function nhA(t){return t?"open":"closed"}var ste="DialogTitleWarning",[iYt,rte]=xPe(ste,{contentName:wF,titleName:ihA,docsSlug:"dialog"}),nYt=({titleId:t})=>{const A=rte(ste),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5606
5606
 
5607
5607
  If you want to hide the \`${A.titleName}\`, you can wrap it with our VisuallyHidden component.
5608
5608