@tscircuit/runframe 0.0.1467 → 0.0.1469
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.
|
@@ -5059,7 +5059,7 @@ ${a.join(`
|
|
|
5059
5059
|
${Q}polygon: ${l.polygon.vertices}
|
|
5060
5060
|
`:a+=`
|
|
5061
5061
|
`,l.children.length>0&&I.push(l.children)}return a}};A.exports=s}}),Mst=oe({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,A){var e=Fst(),i=_st(),o=class{constructor(n){this.polygonTree=new i,this.rootnode=new e(null),n&&this.addPolygons(n)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(n,s=!1){this.rootnode.clipTo(n,s)}allPolygons(){const n=[];return this.polygonTree.getPolygons(n),n}addPolygons(n){const s=new Array(n.length);for(let r=0;r<n.length;r++)s[r]=this.polygonTree.addChild(n[r]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};A.exports=o}}),oBA=oe({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,A){A.exports={Tree:Mst()}}}),vst=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,A){var e=qn(),i=iBA(),{Tree:o}=oBA(),n=(s,r)=>{if(!i(s,r))return e.create();const a=new o(e.toPolygons(s)),g=new o(e.toPolygons(r));a.invert(),g.clipTo(a),g.invert(),a.clipTo(g),g.clipTo(a),a.addPolygons(g.allPolygons()),a.invert();const I=a.allPolygons();return e.create(I)};A.exports=n}}),p8A=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,A){var e=Fn(),i=bU(),o=vst(),n=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=o(r,a)}),r=i(r),r};A.exports=n}}),Ust=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,A){var e=Fn(),i=qn(),o=Qx(),n=eBA(),s=tBA(),r=p8A(),a=(...g)=>{g=e(g);const I=g.map(C=>s({z0:-1,z1:1},C)),c=r(I),B=o(c);return n(B,i.toPolygons(c))};A.exports=a}}),Lst=oe({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,A){var e=Fn(),i=SU(),o=Tn(),n=qn(),s=Ust(),r=p8A(),a=(...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only intersect of the types are supported");const I=g[0];return o.isA(I)?s(g):n.isA(I)?r(g):I};A.exports=a}}),Hst=oe({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,A){var e=uo(),i=Qx(),o=qn(),n=g=>g.sort((I,c)=>I-c).filter((I,c,B)=>!c||I!==B[c-1]),s=(g,I,c)=>{const B=`${I}`,C=g.get(B);C===void 0?g.set(B,[c]):C.push(c)},r=(g,I)=>{const c=`${I}`;return g.get(c)},a=g=>{const I=i(g),c=o.toPolygons(g),B=c.length,C=new Map,l=e.create();c.forEach((d,f)=>{d.vertices.forEach(D=>{s(C,e.snap(l,D,I),f)})});const Q=c.map(d=>{let f=[];return d.vertices.forEach(D=>{f=f.concat(r(C,e.snap(l,D,I)))}),{e:1,d:n(f)}});C.clear();let E=0;const h=Q.length;for(let d=0;d<h;d++){const f=Q[d];if(f.e>0){const D=new Array(B);D[d]=!0;do E=0,D.forEach((b,m)=>{const x=Q[m];if(x.e>0){x.e=-1;for(let F=0;F<x.d.length;F++)D[x.d[F]]=!0;E++}});while(E>0);f.indexes=D}}const u=[];for(let d=0;d<h;d++)if(Q[d].indexes){const f=[];Q[d].indexes.forEach((D,b)=>f.push(c[b])),u.push(o.create(f))}return u};A.exports=a}}),Yst=oe({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,A){var e=Fn(),i=qn(),o=Hst(),n=(...s)=>{if(s=e(s),s.length===0)throw new Error("wrong number of arguments");const r=s.map(a=>i.isA(a)?o(a):a);return r.length===1?r[0]:r};A.exports=n}}),Jst=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,A){var e=qn(),i=iBA(),{Tree:o}=oBA(),n=(s,r)=>{if(!i(s,r))return e.clone(s);const a=new o(e.toPolygons(s)),g=new o(e.toPolygons(r));a.invert(),a.clipTo(g),g.clipTo(a,!0),a.addPolygons(g.allPolygons()),a.invert();const I=a.allPolygons();return e.create(I)};A.exports=n}}),f8A=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,A){var e=Fn(),i=bU(),o=Jst(),n=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=o(r,a)}),r=i(r),r};A.exports=n}}),Kst=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,A){var e=Fn(),i=qn(),o=Qx(),n=eBA(),s=tBA(),r=f8A(),a=(...g)=>{g=e(g);const I=g.map(C=>s({z0:-1,z1:1},C)),c=r(I),B=o(c);return n(B,i.toPolygons(c))};A.exports=a}}),Tst=oe({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,A){var e=Fn(),i=SU(),o=Tn(),n=qn(),s=Kst(),r=f8A(),a=(...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only subtract of the types are supported");const I=g[0];return o.isA(I)?s(g):n.isA(I)?r(g):I};A.exports=a}}),y8A=oe({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,A){var e=qn(),i=iBA(),{Tree:o}=oBA(),n=(r,a)=>{if(!i(r,a))return s(r,a);const g=new o(e.toPolygons(r)),I=new o(e.toPolygons(a));g.clipTo(I,!1),I.clipTo(g),I.invert(),I.clipTo(g),I.invert();const c=g.allPolygons().concat(I.allPolygons());return e.create(c)},s=(r,a)=>{let g=e.toPolygons(r);return g=g.concat(e.toPolygons(a)),e.create(g)};A.exports=n}}),w8A=oe({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,A){var e=Fn(),i=bU(),o=y8A(),n=(...s)=>{s=e(s);let r;for(r=1;r<s.length;r+=2)s.push(o(s[r-1],s[r]));let a=s[r-1];return a=i(a),a};A.exports=n}}),m8A=oe({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,A){var e=Fn(),i=qn(),o=Qx(),n=eBA(),s=tBA(),r=w8A(),a=(...g)=>{g=e(g);const I=g.map(C=>s({z0:-1,z1:1},C)),c=r(I),B=o(c);return n(B,i.toPolygons(c))};A.exports=a}}),nBA=oe({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,A){var e=Fn(),i=SU(),o=Tn(),n=qn(),s=m8A(),r=w8A(),a=(...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only unions of the same type are supported");const I=g[0];return o.isA(I)?s(g):n.isA(I)?r(g):I};A.exports=a}}),x_=oe({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,A){A.exports={intersect:Lst(),scission:Yst(),subtract:Tst(),union:nBA()}}}),yO=oe({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,A){var{EPS:e,TAU:i}=Cr(),o=$5A(),n=VcA(),s=Cs(),r=dO(),a=(g,I)=>{const c={delta:1,corners:"edge",closed:!1,segments:16};let{delta:B,corners:C,closed:l,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=[],D=s.create(),b=I.length;for(let m=0;m<b;m++){const x=(m+1)%b,F=I[m],k=I[x];h?s.subtract(D,F,k):s.subtract(D,k,F),s.normal(D,D),s.normalize(D,D),s.scale(D,D,B);const v=s.add(s.create(),F,D),_=s.add(s.create(),k,D),Y=[v,_];if(u!=null&&(l||!l&&x!==0)){const P=o(u[0],u[1],Y[0],Y[1]);P?(d.pop(),Y[0]=P):f.push({c:F,s0:u,s1:Y})}u=[v,_],!(x===0&&!l)&&(d.push(Y[0]),d.push(Y[1]))}if(l&&u!=null){const m=d[0],x=d[1],F=o(u[0],u[1],m,x);if(F)d[0]=F,d.pop();else{const k=I[0],v=[m,x];f.push({c:k,s0:u,s1:v})}}if(C==="edge"){const m=new Map;d.forEach((k,v)=>m.set(k,v));const x=n.create(),F=n.create();f.forEach(k=>{n.fromPoints(x,k.s0[0],k.s0[1]),n.fromPoints(F,k.s1[0],k.s1[1]);const v=n.intersectPointOfLines(x,F);if(Number.isFinite(v[0])&&Number.isFinite(v[1])){const _=k.s0[1],Y=m.get(_);d[Y]=v,d[(Y+1)%d.length]=void 0}else{const _=k.s1[0],Y=m.get(_);d[Y]=void 0}}),d=d.filter(k=>k!==void 0)}if(C==="round"){let m=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){m=Math.floor(Q*(Math.abs(k)/i));const v=k/m,_=s.angle(s.subtract(x,F.s0[1],F.c)),Y=[];for(let P=1;P<m;P++){const K=_+v*P,O=s.fromAngleRadians(s.create(),K);s.scale(O,O,B),s.add(O,O,F.c),Y.push(O)}if(Y.length>0){const P=F.s0[1];let K=d.findIndex(O=>s.equals(P,O));K=(K+1)%d.length,d.splice(K,0,...Y)}}else{const v=F.s1[0],_=d.findIndex(Y=>s.equals(v,Y));d.splice(_,1)}})}return d};A.exports=a}}),qst=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,A){var e=Tn(),i=yO(),o=(n,s)=>{const r={delta:1,corners:"edge",segments:16},{delta:a,corners:g,segments:I}=Object.assign({},r,n);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const C=e.toOutlines(s).map(l=>(n={delta:a,corners:g,closed:!0,segments:I},i(n,l))).reduce((l,Q)=>l.concat(e.toSides(e.fromPoints(Q))),[]);return e.create(C)};A.exports=o}}),Pst=oe({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,A){var e=vg(),i=uo(),o=qn(),n=$s(),s=(r,a)=>{i.dot(n.plane(a),r)>0&&(a=n.invert(a));const I=[a],c=n.transform(e.fromTranslation(e.create(),r),a),B=a.vertices.length;for(let C=0;C<B;C++){const l=C<B-1?C+1:0,Q=n.create([a.vertices[C],c.vertices[C],c.vertices[l],a.vertices[l]]);I.push(Q)}return I.push(n.invert(c)),o.create(I)};A.exports=s}}),Ost=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,A){var{EPS:e,TAU:i}=Cr(),o=vg(),n=uo(),s=u8A(),r=qn(),a=$s(),g=c8A(),I=bU(),c=y8A(),B=Pst(),C=(h,u,d)=>{const f=u.toString();if(h.has(f))h.get(f)[1].push(d);else{const D=[u,[d]];h.set(f,D)}},l=(h,u,d)=>{const f=u[0].toString(),D=u[1].toString(),b=f<D?`${f},${D}`:`${D},${f}`;if(h.has(b))h.get(b)[1].push(d);else{const m=[u,[d]];h.set(b,m)}},Q=(h,u)=>{h.findIndex(f=>f===u)<0&&h.push(u)},E=(h,u)=>{const d={delta:1,segments:12},{delta:f,segments:D}=Object.assign({},d,h);let b=r.create();const m=new Map,x=new Map,F=n.create(),k=n.create();return r.toPolygons(u).forEach((_,Y)=>{const P=n.scale(n.create(),a.plane(_),2*f),K=a.transform(o.fromTranslation(o.create(),n.scale(n.create(),P,-.5)),_),O=B(P,K);b=c(b,O);const W=_.vertices;for(let $=0;$<W.length;$++){C(m,W[$],a.plane(_));const oA=($+1)%W.length,IA=[W[$],W[oA]];l(x,IA,a.plane(_))}}),x.forEach(_=>{const Y=_[0],P=_[1],K=Y[0],O=Y[1],W=n.subtract(n.create(),O,K);n.normalize(W,W);const $=P[0],oA=n.cross(n.create(),$,W);let IA=[];for(let TA=0;TA<D;TA++)Q(IA,TA*i/D);for(let TA=0,BA=P.length;TA<BA;TA++){const fA=P[TA],hA=n.dot(oA,fA),KA=n.dot($,fA);let te=Math.atan2(hA,KA);te<0&&(te+=i),Q(IA,te),te=Math.atan2(-hA,-KA),te<0&&(te+=i),Q(IA,te)}IA=IA.sort(s);const tA=IA.length;let sA,gA;const dA=[],SA=[],RA=[];for(let TA=-1;TA<tA;TA++){const BA=IA[TA<0?TA+tA:TA],fA=Math.sin(BA),hA=Math.cos(BA);n.scale(F,$,hA*f),n.scale(k,oA,fA*f),n.add(F,F,k);const KA=n.add(n.create(),K,F),te=n.add(n.create(),O,F);let Be=!1;if(TA>=0&&n.distance(KA,sA)<e&&(Be=!0),!Be){if(TA>=0){dA.push(KA),SA.push(te);const yA=[gA,te,KA,sA],OA=a.create(yA);RA.push(OA)}sA=KA,gA=te}}SA.reverse(),RA.push(a.create(dA)),RA.push(a.create(SA));const NA=r.create(RA);b=c(b,NA)}),m.forEach(_=>{const Y=_[0],P=_[1],K=P[0];let O=null,W=0;for(let tA=1;tA<P.length;tA++){const sA=P[tA],gA=n.cross(F,K,sA),dA=n.length(gA);dA>.05&&dA>W&&(W=dA,O=sA)}O||(O=n.orthogonal(F,K));const $=n.cross(F,K,O);n.normalize($,$);const oA=n.cross(k,$,K),IA=g({center:[Y[0],Y[1],Y[2]],radius:f,segments:D,axes:[K,$,oA]});b=c(b,IA)}),I(b)};A.exports=E}}),Wst=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,A){var e=qn(),i=nBA(),o=Ost(),n=(s,r)=>{const a={delta:1,corners:"round",segments:12},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(I!=="round")throw new Error('corners must be "round" for 3D geometries');if(e.toPolygons(r).length===0)throw new Error("the given geometry cannot be empty");s={delta:g,corners:I,segments:c};const C=o(s,r);return i(r,C)};A.exports=n}}),Zst=oe({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,A){var e=dO(),i=Cs(),o=Tn(),n=hg(),s=yO(),r=I=>{let{external:c,internal:B}=I;e(c)<0?c=c.reverse():B=B.reverse();const C=n.fromPoints({closed:!0},c),l=n.fromPoints({closed:!0},B),Q=o.toSides(o.fromPoints(n.toPoints(C))),E=o.toSides(o.fromPoints(n.toPoints(l)));return Q.push(...E),o.create(Q)},a=(I,c,B,C)=>{const{points:l,external:Q,internal:E}=I,h=Math.floor(c/2),u=[],d=[];if(B==="round"&&h>0){const D=Math.PI/h,b=l[l.length-1],m=i.angle(i.subtract(i.create(),Q[Q.length-1],b)),x=l[0],F=i.angle(i.subtract(i.create(),E[0],x));for(let k=1;k<h;k++){let v=m+D*k,_=i.fromAngleRadians(i.create(),v);i.scale(_,_,C),i.add(_,_,b),u.push(_),v=F+D*k,_=i.fromAngleRadians(i.create(),v),i.scale(_,_,C),i.add(_,_,x),d.push(_)}}const f=[];return f.push(...Q,...u,...E.reverse(),...d),o.fromPoints(f)},g=(I,c)=>{I=Object.assign({},{delta:1,corners:"edge",segments:16},I);const{delta:C,corners:l,segments:Q}=I;if(C<=0)throw new Error("the given delta must be positive for paths");if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const E=c.isClosed,h=n.toPoints(c);if(h.length===0)throw new Error("the given geometry cannot be empty");const u={points:h,external:s({delta:C,corners:l,segments:Q,closed:E},h),internal:s({delta:-C,corners:l,segments:Q,closed:E},h)};return c.isClosed?r(u):a(u,Q,l,C)};A.exports=g}}),sBA=oe({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,A){var e=Fn(),i=Tn(),o=qn(),n=hg(),s=qst(),r=Wst(),a=Zst(),g=(I,...c)=>{if(c=e(c),c.length===0)throw new Error("wrong number of arguments");const B=c.map(C=>n.isA(C)?a(I,C):i.isA(C)?s(I,C):o.isA(C)?r(I,C):C);return B.length===1?B[0]:B};A.exports=g}}),Vst=oe({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,A){var e=Tn(),i=qcA(),o=yO(),n=(s,r)=>{const a={delta:1,corners:"edge",segments:0},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(!(I==="edge"||I==="chamfer"||I==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const B=e.toOutlines(r),l=B.map(Q=>(s={delta:B.reduce((u,d)=>u+i.arePointsInside(Q,i.create(d)),0)%2===0?g:-g,corners:I,closed:!0,segments:c},o(s,Q))).reduce((Q,E)=>Q.concat(e.toSides(e.fromPoints(E))),[]);return e.create(l)};A.exports=n}}),jst=oe({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,A){var e=hg(),i=yO(),o=(n,s)=>{const r={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:a,corners:g,closed:I,segments:c}=Object.assign({},r,n);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');n={delta:a,corners:g,closed:I,segments:c};const B=i(n,e.toPoints(s));return e.fromPoints({closed:I},B)};A.exports=o}}),zst=oe({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,A){var e=Fn(),i=Tn(),o=hg(),n=Vst(),s=jst(),r=(a,...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");const I=g.map(c=>o.isA(c)?s(a,c):i.isA(c)?n(a,c):c);return I.length===1?I[0]:I};A.exports=r}}),rBA=oe({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,A){A.exports={expand:sBA(),offset:zst()}}}),wO=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,A){var e=vg(),i=uo(),o=Tn(),n=b_(),s=fO(),r=(a,g)=>{const I={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:c,twistAngle:B,twistSteps:C,repair:l}=Object.assign({},I,a);if(C<1)throw new Error("twistSteps must be 1 or more");B===0&&(C=1);const Q=i.clone(c),E=o.toSides(g);if(E.length===0)throw new Error("the given geometry cannot be empty");const h=n.fromSides(E);Q[2]<0&&n.reverse(h,h);const u=e.create(),d=(f,D,b)=>{const m=D/C*B,x=i.scale(i.create(),Q,D/C);return e.multiply(u,e.fromZRotation(u,m),e.fromTranslation(e.create(),x)),n.transform(u,b)};return a={numberOfSlices:C+1,capStart:!0,capEnd:!0,repair:l,callback:d},s(a,h)};A.exports=r}}),Xst=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,A){var e=Tn(),i=hg(),o=wO(),n=(s,r)=>{if(!r.isClosed)throw new Error("extruded path must be closed");const a=i.toPoints(r),g=e.fromPoints(a);return o(s,g)};A.exports=n}}),$st=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,A){var e=Fn(),i=Tn(),o=hg(),n=wO(),s=Xst(),r=(a,...g)=>{const I={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:c,twistAngle:B,twistSteps:C,repair:l}=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:C,repair:l};const Q=g.map(E=>o.isA(E)?s(a,E):i.isA(E)?n(a,E):E);return Q.length===1?Q[0]:Q};A.exports=r}}),Art=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,A){var e=hg(),i=sBA(),o=wO(),n=(s,r)=>{const a={size:1,height:1},{size:g,height:I}=Object.assign({},a,s);if(s.delta=g,s.offset=[0,0,I],e.toPoints(r).length===0)throw new Error("the given geometry cannot be empty");const B=i(s,r);return o(s,B)};A.exports=n}}),ert=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,A){var{area:e}=yU(),i=Tn(),o=hg(),n=sBA(),s=wO(),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 C=i.toOutlines(g);if(C.length===0)throw new Error("the given geometry cannot be empty");const Q=C.map(h=>(e(h)<0&&h.reverse(),n(a,o.fromPoints({closed:!0},h)))).reduce((h,u)=>h.concat(i.toSides(u)),[]),E=i.create(Q);return s(a,E)};A.exports=r}}),trt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,A){var e=Fn(),i=Tn(),o=hg(),n=Art(),s=ert(),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 C=g.map(l=>o.isA(l)?n(a,l):i.isA(l)?s(a,l):l);return C.length===1?C[0]:C};A.exports=r}}),irt=oe({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,A){var{TAU:e}=Cr(),i=vg(),o=Tn(),n=fO(),s=b_(),r=(a,g)=>{const I={angle:e,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:c,startAngle:B,pitch:C,height:l,endOffset:Q,segmentsPerRotation:E}=Object.assign({},I,a);if(l!=0&&(C=l/(c/e)),E<3)throw new Error("The number of segments per rotation needs to be at least 3.");const u=o.toSides(g);if(u.length===0)throw new Error("The given geometry cannot be empty");const d=u.filter(k=>k[0][0]>=0);let f=s.fromSides(u);d.length===0&&(f=s.reverse(f));const D=Math.round(E/e*Math.abs(c)),b=D>=2?D:2,m=i.create(),x=i.create(),F=(k,v,_)=>{const Y=B+c/b*v,P=Q/b*v,K=(Y-B)/e*C;return i.multiply(m,i.fromTranslation(i.create(),[P,0,K*Math.sign(c)]),i.fromXRotation(i.create(),-e/4*Math.sign(c))),i.multiply(x,i.fromZRotation(i.create(),Y),m),s.transform(x,_)};return n({numberOfSlices:b+1,callback:F},f)};A.exports=r}}),ort=oe({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,A){var e=Fn(),i=ZcA(),o=hm(),n=vg(),s=Tn(),r=qn(),a=$s(),g=Qx(),I=m8A(),c=(C,l)=>{const Q=o.fromNormalAndPoint(o.create(),C.axis,C.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(l),h=E*E*Math.sqrt(3)/4;if(E===0)return s.create();const u=r.toPolygons(l);let d=[];for(let D=0;D<u.length;D++){const b=u[D].vertices.map(F=>o.projectionOfPoint(Q,F)),m=a.create(b),x=a.plane(m);i(Q,x)&&(a.measureArea(m)<h||d.push(m))}if(!i(Q,[0,0,1])){const D=n.fromVectorRotation(n.create(),Q,[0,0,1]);d=d.map(b=>a.transform(D,b))}d=d.sort((D,b)=>a.measureArea(b)-a.measureArea(D));const f=d.map(D=>s.fromPoints(D.vertices));return I(f)},B=(C,...l)=>{const Q={axis:[0,0,1],origin:[0,0,0]},{axis:E,origin:h}=Object.assign({},Q,C);if(l=e(l),l.length===0)throw new Error("wrong number of arguments");C={axis:E,origin:h};const u=l.map(d=>r.isA(d)?c(C,d):d);return u.length===1?u[0]:u};A.exports=B}}),xU=oe({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,A){A.exports={extrudeFromSlices:fO(),extrudeLinear:$st(),extrudeRectangular:trt(),extrudeRotate:Q8A(),extrudeHelical:irt(),project:ort(),slice:b_()}}}),aBA=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,A){var e=Cs(),i=s=>{let r=e.fromValues(1/0,1/0);s.forEach(I=>{(I[1]<r[1]||I[1]===r[1]&&I[0]<r[0])&&(r=I)});const a=[];s.forEach(I=>{const c=n(I[1]-r[1],I[0]-r[0]),B=e.squaredDistance(I,r);a.push({point:I,angle:c,distSq:B})}),a.sort((I,c)=>I.angle!==c.angle?I.angle-c.angle:I.distSq-c.distSq);const g=[];return a.forEach(I=>{let c=g.length;for(;c>1&&o(g[c-2],g[c-1],I.point)<=Number.EPSILON;)g.pop(),c=g.length;g.push(I.point)}),g},o=(s,r,a)=>(r[0]-s[0])*(a[1]-s[1])-(r[1]-s[1])*(a[0]-s[0]),n=(s,r)=>s===0&&r===0?-1/0:-r/s;A.exports=i}}),gBA=oe({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,A){var e=Tn(),i=qn(),o=hg(),n=s=>{const r=new Set,a=[],g=I=>{const c=I.toString();r.has(c)||(a.push(I),r.add(c))};return s.forEach(I=>{e.isA(I)?e.toPoints(I).forEach(g):i.isA(I)?i.toPoints(I).forEach(c=>c.forEach(g)):o.isA(I)&&o.toPoints(I).forEach(g)}),a};A.exports=n}}),nrt=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,A){var e=Fn(),i=hg(),o=aBA(),n=gBA(),s=(...r)=>{r=e(r);const a=n(r),g=o(a);return i.fromPoints({closed:!0},g)};A.exports=s}}),srt=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,A){var e=Fn(),i=Tn(),o=aBA(),n=gBA(),s=(...r)=>{r=e(r);const a=n(r),g=o(a);return g.length<3?i.create():i.fromPoints(g)};A.exports=s}}),D8A=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,A){var e=$s(),i=m5A(),o=n=>i(n,{skipTriangulation:!0}).map(a=>{const g=a.map(I=>n[I]);return e.create(g)});A.exports=o}}),rrt=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,A){var e=Fn(),i=qn(),o=gBA(),n=D8A(),s=(...r)=>{r=e(r);const a=o(r);return a.length===0?i.create():i.create(n(a))};A.exports=s}}),S8A=oe({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,A){var e=Fn(),i=SU(),o=Tn(),n=qn(),s=hg(),r=nrt(),a=srt(),g=rrt(),I=(...c)=>{if(c=e(c),c.length===0)throw new Error("wrong number of arguments");if(!i(c))throw new Error("only hulls of the same type are supported");const B=c[0];return s.isA(B)?r(c):o.isA(B)?a(c):n.isA(B)?g(c):B};A.exports=I}}),art=oe({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,A){var e=Fn(),i=nBA(),o=S8A(),n=(...s)=>{if(s=e(s),s.length<2)throw new Error("wrong number of arguments");const r=[];for(let a=1;a<s.length;a++)r.push(o(s[a-1],s[a]));return i(r)};A.exports=n}}),grt=oe({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,A){A.exports={hull:S8A(),hullChain:art(),hullPoints2:aBA(),hullPoints3:D8A()}}}),b8A=oe({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,A){var e=uo(),i=$s(),o=(s,r)=>{const a=Math.abs(i.measureArea(r));return Number.isFinite(a)&&a>s},n=(s,r)=>{let a=r.map(I=>{const c=I.vertices.map(l=>e.snap(e.create(),l,s)),B=[];for(let l=0;l<c.length;l++){const Q=(l+1)%c.length;e.equals(c[l],c[Q])||B.push(c[l])}const C=i.create(B);return I.color&&(C.color=I.color),C});const g=s*s*Math.sqrt(3)/4;return a=a.filter(I=>o(g,I)),a};A.exports=n}}),Irt=oe({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,A){var e=ZcA(),i=uo(),o=$s(),n=h=>{const u=o.toPoints(h),d=[];for(let f=0;f<u.length;f++){const D=(f+1)%u.length,b={v1:u[f],v2:u[D]};d.push(b)}for(let f=0;f<d.length;f++){const D=(f+1)%u.length;d[f].next=d[D],d[D].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,D=h.prev.v2,b=u.next.v2;const m=B(f,D,b,d);f=u.prev.v1,D=u.prev.v2,b=h.next.v2;const x=B(f,D,b,d);return[m,x]},I=i.create(),c=i.create(),B=(h,u,d,f)=>{const D=i.subtract(I,u,h),b=i.subtract(c,d,u);return i.cross(D,D,b),i.dot(D,f)},C=h=>{let u;const d=[];for(;h.next;){const f=h.next;d.push(h.v1),h.v1=null,h.v2=null,h.next=null,h.prev=null,h=f}return d.length>0&&(u=o.create(d)),u},l=h=>{if(h.length<2)return h;const u=h[0].plane,d=h.slice(),f=new Map;for(;d.length>0;){const b=d.shift(),m=n(b);for(let x=0;x<m.length;x++){const F=m[x],k=a(f,F);if(k){const v=g(F,k,u);if(v[0]>=0&&v[1]>=0){const _=k.next,Y=F.next;F.prev.next=k.next,F.next.prev=k.prev,k.prev.next=F.next,k.next.prev=F.prev,F.v1=null,F.v2=null,F.next=null,F.prev=null,r(f,k),k.v1=null,k.v2=null,k.next=null,k.prev=null;const P=(K,O,W)=>{const $={v1:W.v1,v2:O.v2,next:O.next,prev:W.prev};W.prev.next=$,O.next.prev=$,r(K,O),O.v1=null,O.v2=null,O.next=null,O.prev=null,r(K,W),W.v1=null,W.v2=null,W.next=null,W.prev=null};v[0]===0&&P(f,_,_.prev),v[1]===0&&P(f,Y,Y.prev)}}else F.next&&s(f,F)}}const D=[];return f.forEach(b=>{const m=C(b);m&&D.push(m)}),f.clear(),D},Q=(h,u)=>Math.abs(h[3]-u[3])<15e-8?e(h,u):!1,E=(h,u)=>{const d=[];u.forEach(D=>{const b=d.find(m=>Q(m[0],o.plane(D)));b?b[1].push(D):d.push([o.plane(D),[D]])});let f=[];return d.forEach(D=>{const b=D[1],m=l(b);f=f.concat(m)}),f};A.exports=E}}),crt=oe({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,A){var e=Cr(),i=uo(),o=$s(),n=g=>`${g}`,s=(g,I,c,B,C,l)=>{const Q=n(B),E=n(C),h=`${Q}/${E}`,u=`${E}/${Q}`;if(g.has(u))return r(g,I,c,C,B,null),null;const d={vertex0:B,vertex1:C,polygonindex:l};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,C,l)=>{const Q=n(B),E=n(C),h=`${Q}/${E}`;let u=-1;const d=g.get(h);for(let f=0;f<d.length;f++){const D=d[f];let b=n(D.vertex0);if(b===Q&&(b=n(D.vertex1),b===E&&!(l!==null&&D.polygonindex!==l))){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],C=B.vertices.length;if(C>=3){let l=B.vertices[0],Q=n(l);for(let E=0;E<C;E++){let h=E+1;h===C&&(h=0);const u=B.vertices[h],d=n(u),f=`${Q}/${d}`,D=`${d}/${Q}`;if(I.has(D)){const b=I.get(D);b.splice(-1,1),b.length===0&&I.delete(D)}else{const b={vertex0:l,vertex1:u,polygonindex:c};I.has(f)?I.get(f).push(b):I.set(f,[b])}l=u,Q=d}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(I.size>0){const c=new Map,B=new Map,C=new Map;for(const[Q,E]of I)C.set(Q,!0),E.forEach(h=>{const u=n(h.vertex0),d=n(h.vertex1);c.has(u)?c.get(u).push(Q):c.set(u,[Q]),B.has(d)?B.get(d).push(Q):B.set(d,[Q])});const l=g.slice(0);for(;I.size!==0;){for(const E of I.keys())C.set(E,!0);let Q=!1;for(;;){const E=Array.from(C.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 D=0;D<2;D++){const b=D===0?f.vertex0:f.vertex1,m=D===0?f.vertex1:f.vertex0,x=n(b),F=n(m);let k=[];D===0?B.has(x)&&(k=B.get(x)):c.has(x)&&(k=c.get(x));for(let v=0;v<k.length;v++){const _=k[v],Y=I.get(_)[0],P=D===0?Y.vertex0:Y.vertex1;if(D===0?Y.vertex1:Y.vertex0,n(P)===F){r(I,c,B,b,m,null),r(I,c,B,m,b,null),u=!1,D=2,Q=!0;break}else{const O=b,W=m,$=P,oA=i.subtract(i.create(),$,O),IA=i.dot(i.subtract(i.create(),W,O),oA)/i.dot(oA,oA);if(IA>0&&IA<1){const tA=i.scale(i.create(),oA,IA);if(i.add(tA,tA,O),i.squaredDistance(tA,W)<e.EPS*e.EPS){const gA=Y.polygonindex,dA=l[gA],SA=n(Y.vertex1);let RA=-1;for(let hA=0;hA<dA.vertices.length;hA++)if(n(dA.vertices[hA])===SA){RA=hA;break}const NA=dA.vertices.slice(0);NA.splice(RA,0,m);const TA=o.create(NA);l[gA]=TA,r(I,c,B,Y.vertex0,Y.vertex1,gA);const BA=s(I,c,B,Y.vertex0,m,gA),fA=s(I,c,B,m,Y.vertex1,gA);BA!==null&&C.set(BA,!0),fA!==null&&C.set(fA,!0),u=!1,D=2,Q=!0;break}}}}}}u&&C.delete(h)}if(!Q)break}g=l}return I.clear(),g};A.exports=a}}),Brt=oe({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,A){var e=uo(),i=$s(),o=(s,r,a)=>{const g=r.vertices.length;if(g>3){if(g>4){const B=[0,0,0];r.vertices.forEach(C=>e.add(B,B,C)),e.snap(B,e.divide(B,B,[g,g,g]),s);for(let C=0;C<g;C++){const l=i.create([B,r.vertices[C],r.vertices[(C+1)%g]]);r.color&&(l.color=r.color),a.push(l)}return}const I=i.create([r.vertices[0],r.vertices[1],r.vertices[2]]),c=i.create([r.vertices[0],r.vertices[2],r.vertices[3]]);r.color&&(I.color=r.color,c.color=r.color),a.push(I,c);return}a.push(r)},n=(s,r)=>{const a=[];return r.forEach(g=>{o(s,g,a)}),a};A.exports=n}}),Crt=oe({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,A){var e=Fn(),i=Qx(),o=Tn(),n=qn(),s=hg(),r=b8A(),a=Irt(),g=crt(),I=Brt(),c=(Q,E)=>E,B=(Q,E)=>E,C=(Q,E)=>{const h={snap:!1,simplify:!1,triangulate:!1},{snap:u,simplify:d,triangulate:f}=Object.assign({},h,Q),D=i(E);let b=n.toPolygons(E);u&&(b=r(D,b)),d&&(b=a(D,b)),f&&(b=g(b),b=I(D,b));const m=Object.assign({},E);return m.polygons=b,m},l=(Q,...E)=>{if(E=e(E),E.length===0)throw new Error("wrong number of arguments");const h=E.map(u=>{if(s.isA(u))return c(Q,u);if(o.isA(u))return B(Q,u);if(n.isA(u))return C(Q,u);throw new Error("invalid geometry")});return h.length===1?h[0]:h};A.exports=l}}),lrt=oe({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,A){var e=Fn(),i=Cs(),o=Tn(),n=qn(),s=hg(),r=Qx(),a=b8A(),g=C=>{const l=r(C),E=s.toPoints(C).map(h=>i.snap(i.create(),h,l));return s.create(E)},I=C=>{const l=r(C);let E=o.toSides(C).map(h=>[i.snap(i.create(),h[0],l),i.snap(i.create(),h[1],l)]);return E=E.filter(h=>!i.equals(h[0],h[1])),o.create(E)},c=C=>{const l=r(C),Q=n.toPolygons(C),E=a(l,Q);return n.create(E)},B=(...C)=>{if(C=e(C),C.length===0)throw new Error("wrong number of arguments");const l=C.map(Q=>s.isA(Q)?g(Q):o.isA(Q)?I(Q):n.isA(Q)?c(Q):Q);return l.length===1?l[0]:l};A.exports=B}}),Qrt=oe({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,A){A.exports={generalize:Crt(),snap:lrt(),retessellate:bU()}}}),Ert=oe({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,A){var e=(i,o,n)=>{for(i=i.slice();i.length<n;)i.push(o);return i};A.exports=e}}),hrt=oe({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,A){var e=Fn(),i=Ert(),o=jcA(),{translate:n}=LG(),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 C=0;C<3;C++)I[C]==null&&(c[C]==="center"?I[C]=(B[0][C]+B[1][C])/2:c[C]==="max"?I[C]=B[1][C]:c[C]==="min"&&(I[C]=B[0][C]));return I},a=(I,c,B)=>{const C=o(I),l=[0,0,0];for(let Q=0;Q<3;Q++)c[Q]==="center"?l[Q]=B[Q]-(C[0][Q]+C[1][Q])/2:c[Q]==="max"?l[Q]=B[Q]-C[1][Q]:c[Q]==="min"&&(l[Q]=B[Q]-C[0][Q]);return n(l,I)},g=(I,...c)=>{I=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},I),I=s(I);let{modes:C,relativeTo:l,grouped:Q}=I;if(c=e(c),c.length===0)throw new Error("align(): No geometries were provided to act upon");if(l.filter(E=>E==null).length){const E=o(c);l=r(l,C,E)}return Q?c=a(c,C,l):c=c.map(E=>a(E,C,l)),c.length===1?c[0]:c};A.exports=g}}),mO=oe({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,A){var e=Fn(),i=Tn(),o=qn(),n=hg(),s=vG(),{translate:r}=LG(),a=(C,l)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,C),u=s(l),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,l)},g=(C,...l)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,C);if(l=e(l),l.length===0)throw new Error("wrong number of arguments");if(h.length!==3)throw new Error("relativeTo must be an array of length 3");C={axes:E,relativeTo:h};const u=l.map(d=>n.isA(d)||i.isA(d)||o.isA(d)?a(C,d):d);return u.length===1?u[0]:u},I=(...C)=>g({axes:[!0,!1,!1]},C),c=(...C)=>g({axes:[!1,!0,!1]},C),B=(...C)=>g({axes:[!1,!1,!0]},C);A.exports={center:g,centerX:I,centerY:c,centerZ:B}}}),DO=oe({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,A){var e=Fn(),i=vg(),o=Tn(),n=qn(),s=hg(),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 C=i.fromScaling(i.create(),c),l=B.map(Q=>s.isA(Q)?s.transform(C,Q):o.isA(Q)?o.transform(C,Q):n.isA(Q)?n.transform(C,Q):Q);return l.length===1?l[0]:l},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}}}),urt=oe({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,A){var e=Fn(),i=Tn(),o=qn(),n=hg(),s=(r,...a)=>{if(a=e(a),a.length===0)throw new Error("wrong number of arguments");const g=a.map(I=>n.isA(I)?n.transform(r,I):i.isA(I)?i.transform(r,I):o.isA(I)?o.transform(r,I):I);return g.length===1?g[0]:g};A.exports=s}}),HG=oe({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,A){A.exports={align:hrt(),center:mO().center,centerX:mO().centerX,centerY:mO().centerY,centerZ:mO().centerZ,mirror:mU().mirror,mirrorX:mU().mirrorX,mirrorY:mU().mirrorY,mirrorZ:mU().mirrorZ,rotate:DU().rotate,rotateX:DU().rotateX,rotateY:DU().rotateY,rotateZ:DU().rotateZ,scale:DO().scale,scaleX:DO().scaleX,scaleY:DO().scaleY,scaleZ:DO().scaleZ,transform:urt(),translate:LG().translate,translateX:LG().translateX,translateY:LG().translateY,translateZ:LG().translateZ}}}),SO=oe({"node_modules/@jscad/modeling/src/index.js"(t,A){A.exports={colors:uO(),curves:lnt(),geometries:PcA(),maths:Hnt(),measurements:Wnt(),primitives:Ex(),text:ABA(),utils:d8A(),booleans:x_(),expansions:rBA(),extrusions:xU(),hulls:grt(),modifiers:Qrt(),transforms:HG()}}}),drt=oe({"node_modules/ms/index.js"(t,A){var e=1e3,i=e*60,o=i*60,n=o*24,s=n*7,r=n*365.25;A.exports=function(B,C){C=C||{};var l=typeof B;if(l==="string"&&B.length>0)return a(B);if(l==="number"&&isFinite(B))return C.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 C=/^(-?(?:\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(C){var l=parseFloat(C[1]),Q=(C[2]||"ms").toLowerCase();switch(Q){case"years":case"year":case"yrs":case"yr":case"y":return l*r;case"weeks":case"week":case"w":return l*s;case"days":case"day":case"d":return l*n;case"hours":case"hour":case"hrs":case"hr":case"h":return l*o;case"minutes":case"minute":case"mins":case"min":case"m":return l*i;case"seconds":case"second":case"secs":case"sec":case"s":return l*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return}}}}function g(B){var C=Math.abs(B);return C>=n?Math.round(B/n)+"d":C>=o?Math.round(B/o)+"h":C>=i?Math.round(B/i)+"m":C>=e?Math.round(B/e)+"s":B+"ms"}function I(B){var C=Math.abs(B);return C>=n?c(B,C,n,"day"):C>=o?c(B,C,o,"hour"):C>=i?c(B,C,i,"minute"):C>=e?c(B,C,e,"second"):B+" ms"}function c(B,C,l,Q){var E=C>=l*1.5;return Math.round(B/l)+" "+Q+(E?"s":"")}}}),prt=oe({"node_modules/debug/src/common.js"(t,A){function e(i){n.debug=n,n.default=n,n.coerce=c,n.disable=g,n.enable=r,n.enabled=I,n.humanize=drt(),n.destroy=B,Object.keys(i).forEach(C=>{n[C]=i[C]}),n.names=[],n.skips=[],n.formatters={};function o(C){let l=0;for(let Q=0;Q<C.length;Q++)l=(l<<5)-l+C.charCodeAt(Q),l|=0;return n.colors[Math.abs(l)%n.colors.length]}n.selectColor=o;function n(C){let l,Q=null,E,h;function u(...d){if(!u.enabled)return;const f=u,D=Number(new Date),b=D-(l||D);f.diff=b,f.prev=l,f.curr=D,l=D,d[0]=n.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let m=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(F,k)=>{if(F==="%%")return"%";m++;const v=n.formatters[k];if(typeof v=="function"){const _=d[m];F=v.call(f,_),d.splice(m,1),m--}return F}),n.formatArgs.call(f,d),(f.log||n.log).apply(f,d)}return u.namespace=C,u.useColors=n.useColors(),u.color=n.selectColor(C),u.extend=s,u.destroy=n.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>Q!==null?Q:(E!==n.namespaces&&(E=n.namespaces,h=n.enabled(C)),h),set:d=>{Q=d}}),typeof n.init=="function"&&n.init(u),u}function s(C,l){const Q=n(this.namespace+(typeof l>"u"?":":l)+C);return Q.log=this.log,Q}function r(C){n.save(C),n.namespaces=C,n.names=[],n.skips=[];const l=(typeof C=="string"?C:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const Q of l)Q[0]==="-"?n.skips.push(Q.slice(1)):n.names.push(Q)}function a(C,l){let Q=0,E=0,h=-1,u=0;for(;Q<C.length;)if(E<l.length&&(l[E]===C[Q]||l[E]==="*"))l[E]==="*"?(h=E,u=Q,E++):(Q++,E++);else if(h!==-1)E=h+1,u++,Q=u;else return!1;for(;E<l.length&&l[E]==="*";)E++;return E===l.length}function g(){const C=[...n.names,...n.skips.map(l=>"-"+l)].join(",");return n.enable(""),C}function I(C){for(const l of n.skips)if(a(C,l))return!1;for(const l of n.names)if(a(C,l))return!0;return!1}function c(C){return C instanceof Error?C.stack||C.message:C}function B(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}A.exports=e}}),frt=oe({"node_modules/debug/src/browser.js"(t,A){t.formatArgs=i,t.save=o,t.load=n,t.useColors=e,t.storage=s(),t.destroy=(()=>{let a=!1;return()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function e(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let a;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(a=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(a[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function i(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+A.exports.humanize(this.diff),!this.useColors)return;const g="color: "+this.color;a.splice(1,0,g,"color: inherit");let I=0,c=0;a[0].replace(/%[a-zA-Z%]/g,B=>{B!=="%%"&&(I++,B==="%c"&&(c=I))}),a.splice(c,0,g)}t.log=console.debug||console.log||(()=>{});function o(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function n(){let a;try{a=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!a&&typeof vcA<"u"&&"env"in vcA&&(a=vcA.env.DEBUG),a}function s(){try{return localStorage}catch{}}A.exports=prt()(t);var{formatters:r}=A.exports;r.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}}}),x8A=AA.createContext(null),fu=()=>{const t=AA.useContext(x8A);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},kU=(t,A=[])=>{const{addFrameListener:e,removeFrameListener:i}=fu();$i.useEffect(()=>(e(t),()=>i(t)),[e,i,...A])},k8A=AA.createContext(null),yrt=()=>{const t=AA.useContext(k8A);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},wrt=({children:t})=>{const{camera:A,renderer:e}=fu(),[i,o]=AA.useState([]),n=AA.useMemo(()=>new lme,[]),s=AA.useMemo(()=>new co,[]),r=AA.useRef(i);r.current=i;const a=AA.useRef(null),g=AA.useCallback(l=>{o(Q=>[...Q,l])},[]),I=AA.useCallback(l=>{if(a.current){let Q=!1,E=a.current.object;for(;E;){if(E===l){Q=!0;break}E=E.parent}Q&&(a.current.onUnhover(),a.current=null)}o(Q=>Q.filter(E=>E.object!==l))},[]),c=AA.useCallback(l=>{let Q=l;for(;Q;){const E=r.current.find(h=>h.object===Q);if(E)return E;Q=Q.parent}},[]),B=AA.useCallback(l=>{if(!e.domElement)return;const Q=e.domElement.getBoundingClientRect();s.x=(l.clientX-Q.left)/Q.width*2-1,s.y=-((l.clientY-Q.top)/Q.height)*2+1,n.setFromCamera(s,A);const E=r.current.map(u=>u.object);if(E.length===0){a.current&&(a.current.onUnhover(),a.current=null);return}const h=n.intersectObjects(E,!0);if(h.length>0){const u=h[0],d=c(u.object);if(d){const f={mousePosition:[u.point.x,u.point.y,u.point.z]};a.current!==d?(a.current?.onUnhover(),d.onHover(f),a.current=d):d.onHover(f)}else a.current&&(a.current.onUnhover(),a.current=null)}else a.current&&(a.current.onUnhover(),a.current=null)},[A,e,n,s,c]);AA.useEffect(()=>{const l=e.domElement;return l.addEventListener("mousemove",B),()=>{l.removeEventListener("mousemove",B)}},[e,B]);const C=AA.useMemo(()=>({addHoverable:g,removeHoverable:I}),[g,I]);return V.jsx(k8A.Provider,{value:C,children:t})},mrt=({children:t,object:A,onHover:e,onUnhover:i,isHovered:o})=>{const{addHoverable:n,removeHoverable:s}=yrt();return AA.useEffect(()=>A?(n({object:A,onHover:e,onUnhover:i}),()=>{s(A)}):void 0,[A,e,i,n,s]),V.jsx(V.Fragment,{children:t})},GU=mrt;function Drt(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(A,e,i)=>`${e} ${i.replace(/-/g,"_")}`)}async function Srt(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 tbe().parse(Drt(e),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function brt(t){const[A,e]=AA.useState(null);return AA.useEffect(()=>{if(!t)return;const i=t.replace(/&cachebust_origin=$/,""),o=window.TSCIRCUIT_OBJ_LOADER_CACHE;let n=!1;async function s(){try{if(i.endsWith(".wrl"))return await Srt(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 cbe;if(I?.length){const B=I.join(`
|
|
5062
|
-
`).replace(/d 0\./g,"d 1."),C=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),l=new $Se;l.setMaterialOptions({invertTrProperty:!0});const Q=l.parse(B.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return c.setMaterials(Q),c.parse(C)}return c.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(o.has(i)){const g=o.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(I=>I instanceof Error?I:I.clone())}const a=s().then(g=>(g instanceof Error||o.set(i,{...o.get(i),result:g}),g));return o.set(i,{promise:a,result:null}),a}return r().then(a=>{n||e(a)}).catch(a=>{console.error(a)}),()=>{n=!0}},[t]),A}function xrt({url:t,position:A,rotation:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const a=brt(t),{rootObject:g}=fu(),I=AA.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(c=>{if(c instanceof Oo&&c.material){const B=C=>{C.transparent=r,C.opacity=r?.5:1,C.depthWrite=!r,C.needsUpdate=!0};Array.isArray(c.material)?c.material.forEach(B):B(c.material)}}),a):new Oo(new tw(.5,.5,.5),new ih({transparent:!0,color:"red",opacity:.25})),[a,r]);if(AA.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),AA.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 V.jsx(GU,{isHovered:n,onHover:i,onUnhover:o,object:I})}var G8A=new WeakMap,krt=()=>{const t=new Uc;return t.name="fallback-environment-map",t.mapping=ZJ,t},Grt=t=>{if(!t)return null;const A=t,e=G8A.get(A);if(e)return e;let i;if(t instanceof SK){const o=new zj(t);i=o.fromScene(QSe(),.04).texture,o.dispose()}else i=krt();return G8A.set(A,i),i},F8A=1.25;function R8A({gltfUrl:t,position:A,rotation:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=fu(),[I,c]=AA.useState(null),[B,C]=AA.useState(null);if(AA.useEffect(()=>{if(!t)return;const l=new hSe;let Q=!0;return l.load(t,E=>{if(!Q)return;const h=E.scene;h.traverse(u=>{if(u instanceof Oo&&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}`);C(h)}),()=>{Q=!1}},[t,r]),AA.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]),AA.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),AA.useEffect(()=>{if(!I||!a)return;const l=Grt(a);if(!l)return;const Q=[],E=h=>{h instanceof ih&&(Q.push({material:h,envMap:h.envMap??null,envMapIntensity:h.envMapIntensity??1}),h.envMap=l,(typeof h.envMapIntensity!="number"||h.envMapIntensity<F8A)&&(h.envMapIntensity=F8A),h.needsUpdate=!0)};return I.traverse(h=>{if(!(h instanceof Oo))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]),AA.useEffect(()=>{I&&I.traverse(l=>{l instanceof Oo&&l.material instanceof ih&&(n?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[n,I]),B)throw B;return I?V.jsx(GU,{isHovered:n,onHover:i,onUnhover:o,object:I}):null}var Frt=yr(n5A()),Rrt=yr(SO()),N8A={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},wr=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 N8A)return e*N8A[A];throw new Error(`Unsupported unit: ${A}`)},fB=wr,_8A={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}}},IBA=new Set;for(const[t,A]of Object.entries(_8A)){IBA.add(t);for(const e of Object.keys(A.variants))IBA.add(e)}function Nrt(t){for(const[A,e]of Object.entries(_8A))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var M8A={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 Bw(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}=Bw(t.x),g=Bw(t.x),I=Bw(t.y);return g.value===null||I.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:I.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),o=t.slice(0,-i.length);if(i in M8A&&!IBA.has(i)){const r=M8A[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(o)*r}}const{baseUnit:n,conversionFactor:s}=Nrt(i);return{parsedUnit:i,unitOfValue:n,value:s*Number.parseFloat(o)}}var cBA=H().or(ZA()).transform(t=>Bw(t).value),v8A=H().or(ZA()).transform(t=>Bw(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),_rt=H().or(ZA()).transform(t=>Bw(t).value),k_=H().or(ZA()).transform(t=>Bw(t).value),$A=H().or(ZA()).transform(t=>Bw(t).value),bO=H().or(ZA()).transform(t=>Bw(t).value),mt=$A,BBA=H().or(ZA()).transform(t=>Bw(t).value),CBA=H().or(ZA()).transform(t=>Bw(t).value),G_=CBA,Mrt=H().datetime(),pd=H().or(ZA()).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)),vrt=ZA().or(H().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"),xo=PA({x:mt,y:mt}),lBA=PA({x:mt,y:mt,z:mt}),U8A=PA({width:ZA(),height:ZA()}),Urt=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},jt=t=>H().optional().default(()=>`${t}_${Urt(10)}`),YG=Ct(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]);Ct(["top_silkscreen","bottom_silkscreen","top_copper","bottom_copper","top_soldermask","bottom_soldermask","top_fabrication_note","bottom_fabrication_note","inner1_copper","inner2_copper","inner3_copper","inner4_copper","inner5_copper","inner6_copper"]);var Lrt=Ct(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),yB=PA({type:kA("source_component"),ftype:H().optional(),source_component_id:H(),name:H(),manufacturer_part_number:H().optional(),supplier_part_numbers:Na(Lrt,be(H())).optional(),display_value:H().optional(),are_pins_interchangeable:ce().optional(),internally_connected_source_port_ids:be(be(H())).optional(),source_group_id:H().optional(),subcircuit_id:H().optional()}),L8A=yB.extend({ftype:kA("simple_capacitor"),capacitance:v8A,max_voltage_rating:k_.optional(),display_capacitance:H().optional(),max_decoupling_trace_length:mt.optional()}),H8A=yB.extend({ftype:kA("simple_resistor"),resistance:cBA,display_resistance:H().optional()}),QBA=yB.extend({ftype:kA("simple_diode")}),Hrt=yB.extend({ftype:kA("simple_fiducial")}),Y8A=QBA.extend({ftype:kA("simple_led"),color:H().optional(),wavelength:H().optional()}),Yrt=yB.extend({ftype:kA("simple_ground")}),J8A=yB.extend({ftype:kA("simple_chip")}),K8A=yB.extend({ftype:kA("simple_power_source"),voltage:k_}),Jrt=yB.extend({ftype:kA("simple_fuse"),current_rating_amps:ZA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:ZA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),T8A=yB.extend({ftype:kA("simple_battery"),capacity:vrt}),q8A=yB.extend({ftype:kA("simple_inductor"),inductance:_rt,max_current_rating:ZA().optional()}),P8A=yB.extend({ftype:kA("simple_push_button")}),O8A=yB.extend({ftype:kA("simple_potentiometer"),max_resistance:cBA}),Krt=yB.extend({ftype:kA("simple_crystal"),frequency:ZA().describe("Frequency in Hz"),load_capacitance:ZA().optional().describe("Load capacitance in pF")}),W8A=yB.extend({ftype:kA("simple_pin_header"),pin_count:ZA(),gender:Ct(["male","female"]).optional().default("male")}),Z8A=yB.extend({ftype:kA("simple_pinout")}),V8A=yB.extend({ftype:kA("simple_resonator"),load_capacitance:v8A,equivalent_series_resistance:cBA.optional(),frequency:bO}),j8A=yB.extend({ftype:kA("simple_transistor"),transistor_type:Ct(["npn","pnp"])}),z8A=yB.extend({ftype:kA("simple_test_point"),footprint_variant:Ct(["pad","through_hole"]).optional(),pad_shape:Ct(["rect","circle"]).optional(),pad_diameter:Ai([ZA(),H()]).optional(),hole_diameter:Ai([ZA(),H()]).optional(),width:Ai([ZA(),H()]).optional(),height:Ai([ZA(),H()]).optional()}),X8A=yB.extend({ftype:kA("simple_mosfet"),channel_type:Ct(["n","p"]),mosfet_mode:Ct(["enhancement","depletion"])}),$8A=yB.extend({ftype:kA("simple_op_amp")}),AWA=yB.extend({ftype:kA("simple_switch")}),eWA=PA({type:kA("source_project_metadata"),name:H().optional(),software_used_string:H().optional(),project_url:H().optional(),created_at:Mrt.optional()}),Trt=PA({type:kA("source_missing_property_error"),source_missing_property_error_id:jt("source_missing_property_error"),source_component_id:H(),property_name:H(),subcircuit_id:H().optional(),error_type:kA("source_missing_property_error").default("source_missing_property_error"),message:H()}).describe("The source code is missing a property"),qrt=PA({type:kA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:jt("source_failed_to_create_component_error"),error_type:kA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:H().optional(),subcircuit_id:H().optional(),parent_source_component_id:H().optional(),message:H(),pcb_center:PA({x:ZA().optional(),y:ZA().optional()}).optional(),schematic_center:PA({x:ZA().optional(),y:ZA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),tWA=PA({type:kA("source_trace_not_connected_error"),source_trace_not_connected_error_id:jt("source_trace_not_connected_error"),error_type:kA("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:H(),subcircuit_id:H().optional(),source_group_id:H().optional(),source_trace_id:H().optional(),connected_source_port_ids:be(H()).optional(),selectors_not_found:be(H()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Prt=PA({type:kA("source_property_ignored_warning"),source_property_ignored_warning_id:jt("source_property_ignored_warning"),source_component_id:H(),property_name:H(),subcircuit_id:H().optional(),error_type:kA("source_property_ignored_warning").default("source_property_ignored_warning"),message:H()}).describe("The source property was ignored"),iWA=PA({type:kA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:jt("source_pin_missing_trace_warning"),warning_type:kA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:H(),source_component_id:H(),source_port_id:H(),subcircuit_id:H().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),Ort=yB.extend({ftype:kA("simple_voltage_probe")}),Wrt=yB.extend({ftype:kA("interconnect")}),Zrt=Ai([H8A,L8A,QBA,Hrt,Y8A,Yrt,J8A,K8A,T8A,q8A,P8A,O8A,Krt,W8A,Z8A,V8A,AWA,j8A,z8A,X8A,$8A,Jrt,Ort,Wrt,eWA,Trt,qrt,tWA,Prt,iWA]),Vrt=PA({type:kA("source_port"),pin_number:ZA().optional(),port_hints:be(H()).optional(),name:H(),source_port_id:H(),source_component_id:H().optional(),source_group_id:H().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),must_be_connected:ce().optional()}),jrt=PA({type:kA("source_component_internal_connection"),source_component_internal_connection_id:H(),source_component_id:H(),source_port_ids:be(H()),subcircuit_id:H().optional()}),zrt=PA({type:kA("source_trace"),source_trace_id:H(),connected_source_port_ids:be(H()),connected_source_net_ids:be(H()),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),max_length:ZA().optional(),min_trace_thickness:ZA().optional(),display_name:H().optional()}),Xrt=PA({type:kA("source_group"),source_group_id:H(),subcircuit_id:H().optional(),parent_subcircuit_id:H().optional(),parent_source_group_id:H().optional(),is_subcircuit:ce().optional(),show_as_schematic_box:ce().optional(),name:H().optional(),was_automatically_named:ce().optional()}),$rt=PA({type:kA("source_net"),source_net_id:H(),name:H(),member_source_group_ids:be(H()),is_power:ce().optional(),is_ground:ce().optional(),is_digital_signal:ce().optional(),is_analog_signal:ce().optional(),is_positive_voltage_source:ce().optional(),trace_width:ZA().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional()}),Aat=PA({type:kA("source_board"),source_board_id:H(),source_group_id:H(),title:H().optional()}).describe("Defines a board in the source domain"),eat=PA({type:kA("source_pcb_ground_plane"),source_pcb_ground_plane_id:H(),source_group_id:H(),source_net_id:H(),subcircuit_id:H().optional()}).describe("Defines a ground plane in the source domain"),tat=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],oWA=Ct(tat),Mr=oWA.or(PA({name:oWA})).transform(t=>typeof t=="string"?t:t.name),um=Ct(["top","bottom"]),iat=PA({type:kA("source_manually_placed_via"),source_manually_placed_via_id:H(),source_group_id:H(),source_net_id:H(),subcircuit_id:H().optional(),source_trace_id:H().optional()}).describe("Defines a via that is manually placed in the source domain"),oat=PA({type:kA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:jt("source_pin_must_be_connected_error"),error_type:kA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),message:H(),source_component_id:H(),source_port_id:H(),subcircuit_id:H().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),nat=PA({type:kA("unknown_error_finding_part"),unknown_error_finding_part_id:jt("unknown_error_finding_part"),error_type:kA("unknown_error_finding_part").default("unknown_error_finding_part"),message:H(),source_component_id:H().optional(),subcircuit_id:H().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),sat=PA({type:kA("schematic_box"),schematic_component_id:H().optional(),width:mt,height:mt,is_dashed:ce().default(!1),x:mt,y:mt,subcircuit_id:H().optional()}).describe("Draws a box on the schematic"),rat=PA({type:kA("schematic_path"),schematic_component_id:H(),fill_color:Ct(["red","blue"]).optional(),is_filled:ce().optional(),points:be(xo),subcircuit_id:H().optional()}),aat=Na(PA({left_margin:$A.optional(),right_margin:$A.optional(),top_margin:$A.optional(),bottom_margin:$A.optional()})),gat=PA({left_size:ZA(),right_size:ZA(),top_size:ZA().optional(),bottom_size:ZA().optional()}),Iat=PA({left_side:PA({pins:be(ZA()),direction:Ct(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:PA({pins:be(ZA()),direction:Ct(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:PA({pins:be(ZA()),direction:Ct(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:PA({pins:be(ZA()),direction:Ct(["left-to-right","right-to-left"]).optional()}).optional()}),cat=Ai([gat,Iat]),Bat=PA({type:kA("schematic_component"),size:U8A,center:xo,source_component_id:H().optional(),schematic_component_id:H(),pin_spacing:$A.optional(),pin_styles:aat.optional(),box_width:$A.optional(),symbol_name:H().optional(),port_arrangement:cat.optional(),port_labels:Na(H()).optional(),symbol_display_value:H().optional(),subcircuit_id:H().optional(),schematic_group_id:H().optional(),is_schematic_group:ce().optional(),source_group_id:H().optional(),is_box_with_pins:ce().optional().default(!0)}),Cat=PA({type:kA("schematic_line"),schematic_line_id:jt("schematic_line"),schematic_component_id:H(),x1:mt,y1:mt,x2:mt,y2:mt,stroke_width:mt.nullable().optional(),color:H().default("#000000"),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled line on the schematic"),lat=PA({type:kA("schematic_rect"),schematic_rect_id:jt("schematic_rect"),schematic_component_id:H(),center:xo,width:mt,height:mt,rotation:pd.default(0),stroke_width:mt.nullable().optional(),color:H().default("#000000"),is_filled:ce().default(!1),fill_color:H().optional(),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled rectangle on the schematic"),Qat=PA({type:kA("schematic_circle"),schematic_circle_id:jt("schematic_circle"),schematic_component_id:H(),center:xo,radius:mt,stroke_width:mt.nullable().optional(),color:H().default("#000000"),is_filled:ce().default(!1),fill_color:H().optional(),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled circle on the schematic"),Eat=PA({type:kA("schematic_arc"),schematic_arc_id:jt("schematic_arc"),schematic_component_id:H(),center:xo,radius:mt,start_angle_degrees:pd,end_angle_degrees:pd,direction:Ct(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:mt.nullable().optional(),color:H().default("#000000"),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled arc on the schematic"),hat=PA({type:kA("schematic_trace"),schematic_trace_id:H(),source_trace_id:H().optional(),junctions:be(PA({x:ZA(),y:ZA()})),edges:be(PA({from:PA({x:ZA(),y:ZA()}),to:PA({x:ZA(),y:ZA()}),is_crossing:ce().optional(),from_schematic_port_id:H().optional(),to_schematic_port_id:H().optional()})),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional()}),uat=Ct(["center","left","right","top","bottom"]),dat=PA({type:kA("schematic_text"),schematic_component_id:H().optional(),schematic_text_id:H(),text:H(),font_size:ZA().default(.18),position:PA({x:mt,y:mt}),rotation:ZA().default(0),anchor:Ai([uat.describe("legacy"),YG]).default("center"),color:H().default("#000000"),subcircuit_id:H().optional()}),pat=PA({type:kA("schematic_port"),schematic_port_id:H(),source_port_id:H(),schematic_component_id:H().optional(),center:xo,facing_direction:Ct(["up","down","left","right"]).optional(),distance_from_component_edge:ZA().optional(),side_of_component:Ct(["top","bottom","left","right"]).optional(),true_ccw_index:ZA().optional(),pin_number:ZA().optional(),display_pin_label:H().optional(),subcircuit_id:H().optional(),is_connected:ce().optional(),has_input_arrow:ce().optional(),has_output_arrow:ce().optional()}).describe("Defines a port on a schematic component"),fat=PA({type:kA("schematic_net_label"),schematic_net_label_id:jt("schematic_net_label"),schematic_trace_id:H().optional(),source_trace_id:H().optional(),source_net_id:H(),center:xo,anchor_position:xo.optional(),anchor_side:Ct(["top","bottom","left","right"]),text:H(),symbol_name:H().optional(),is_movable:ce().optional(),subcircuit_id:H().optional()}),yat=PA({type:kA("schematic_error"),schematic_error_id:H(),error_type:kA("schematic_port_not_found").default("schematic_port_not_found"),message:H(),subcircuit_id:H().optional()}).describe("Defines a schematic error on the schematic"),wat=PA({type:kA("schematic_layout_error"),schematic_layout_error_id:jt("schematic_layout_error"),error_type:kA("schematic_layout_error").default("schematic_layout_error"),message:H(),source_group_id:H(),schematic_group_id:H(),subcircuit_id:H().optional()}).describe("Error emitted when schematic layout fails for a group"),EBA=PA({type:kA("schematic_debug_object"),label:H().optional(),subcircuit_id:H().optional()}),mat=EBA.extend({shape:kA("rect"),center:xo,size:U8A}),Dat=EBA.extend({shape:kA("line"),start:xo,end:xo}),Sat=EBA.extend({shape:kA("point"),center:xo}),bat=Mp("shape",[mat,Dat,Sat]),xat=PA({type:kA("schematic_voltage_probe"),schematic_voltage_probe_id:H(),source_component_id:H().optional(),name:H().optional(),position:xo,schematic_trace_id:H(),voltage:k_.optional(),subcircuit_id:H().optional(),color:H().optional(),label_alignment:YG.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),kat=PA({type:kA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:jt("schematic_manual_edit_conflict_warning"),warning_type:kA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:H(),schematic_component_id:H(),schematic_group_id:H().optional(),subcircuit_id:H().optional(),source_component_id:H()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),Gat=PA({type:kA("schematic_group"),schematic_group_id:jt("schematic_group"),source_group_id:H(),is_subcircuit:ce().optional(),subcircuit_id:H().optional(),width:$A,height:$A,center:xo,schematic_component_ids:be(H()),show_as_schematic_box:ce().optional(),name:H().optional(),description:H().optional()}).describe("Defines a group of components on the schematic"),Fat=PA({type:kA("schematic_table"),schematic_table_id:jt("schematic_table"),anchor_position:xo,column_widths:be(mt),row_heights:be(mt),cell_padding:mt.optional(),border_width:mt.optional(),subcircuit_id:H().optional(),schematic_component_id:H().optional(),anchor:YG.optional()}).describe("Defines a table on the schematic"),Rat=PA({type:kA("schematic_table_cell"),schematic_table_cell_id:jt("schematic_table_cell"),schematic_table_id:H(),start_row_index:ZA(),end_row_index:ZA(),start_column_index:ZA(),end_column_index:ZA(),text:H().optional(),center:xo,width:mt,height:mt,horizontal_align:Ct(["left","center","right"]).optional(),vertical_align:Ct(["top","middle","bottom"]).optional(),font_size:mt.optional(),subcircuit_id:H().optional()}).describe("Defines a cell within a schematic_table"),Nat=PA({type:kA("schematic_sheet"),schematic_sheet_id:jt("schematic_sheet"),name:H().optional(),subcircuit_id:H().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),_at=PA({x:mt,y:mt,bulge:ZA().optional()}),nWA=PA({vertices:be(_at)}),Mat=PA({outer_ring:nWA,inner_rings:be(nWA).default([])}),vat=PA({x:mt,y:mt,via:ce().optional(),via_to_layer:Mr.optional()});be(vat);var Uat=PA({x:mt,y:mt,via:ce().optional(),to_layer:Mr.optional(),trace_width:mt.optional()}),Lat=PA({type:kA("pcb_component"),pcb_component_id:jt("pcb_component"),source_component_id:H(),center:xo,layer:Mr,rotation:pd,display_offset_x:H().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:$A,height:$A,do_not_place:ce().optional(),subcircuit_id:H().optional(),pcb_group_id:H().optional(),position_mode:Ct(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:H().optional(),positioned_relative_to_pcb_board_id:H().optional(),obstructs_within_bounds:ce().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),sWA=PA({type:kA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:kA("circle"),hole_diameter:ZA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()});sWA.describe("Defines a circular hole on the PCB");var rWA=PA({type:kA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:kA("rect"),hole_width:ZA(),hole_height:ZA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()});rWA.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square.");var aWA=PA({type:kA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:Ct(["circle","square"]),hole_diameter:ZA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()});aWA.describe("Defines a circular or square hole on the PCB");var gWA=PA({type:kA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:kA("oval"),hole_width:ZA(),hole_height:ZA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()});gWA.describe("Defines an oval hole on the PCB");var IWA=PA({type:kA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:kA("pill"),hole_width:ZA(),hole_height:ZA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()});IWA.describe("Defines a pill-shaped hole on the PCB");var cWA=PA({type:kA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:kA("rotated_pill"),hole_width:ZA(),hole_height:ZA(),x:mt,y:mt,ccw_rotation:pd,is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()});cWA.describe("Defines a rotated pill-shaped hole on the PCB");var Hat=aWA.or(gWA).or(IWA).or(cWA).or(sWA).or(rWA),Yat=PA({type:kA("pcb_plated_hole"),shape:kA("circle"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),outer_diameter:ZA(),hole_diameter:ZA(),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(Mr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:ZA().optional()}),Jat=PA({type:kA("pcb_plated_hole"),shape:Ct(["oval","pill"]),pcb_group_id:H().optional(),subcircuit_id:H().optional(),outer_width:ZA(),outer_height:ZA(),hole_width:ZA(),hole_height:ZA(),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,ccw_rotation:pd,layers:be(Mr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:ZA().optional()}),Kat=PA({type:kA("pcb_plated_hole"),shape:kA("circular_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:kA("circle"),pad_shape:kA("rect"),hole_diameter:ZA(),rect_pad_width:ZA(),rect_pad_height:ZA(),rect_border_radius:ZA().optional(),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(Mr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:ZA().optional()}),Tat=PA({type:kA("pcb_plated_hole"),shape:kA("pill_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:kA("pill"),pad_shape:kA("rect"),hole_width:ZA(),hole_height:ZA(),rect_pad_width:ZA(),rect_pad_height:ZA(),rect_border_radius:ZA().optional(),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(Mr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:ZA().optional()}),qat=PA({type:kA("pcb_plated_hole"),shape:kA("rotated_pill_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:kA("rotated_pill"),pad_shape:kA("rect"),hole_width:ZA(),hole_height:ZA(),hole_ccw_rotation:pd,rect_pad_width:ZA(),rect_pad_height:ZA(),rect_border_radius:ZA().optional(),rect_ccw_rotation:pd,hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(Mr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:ZA().optional()}),Pat=PA({type:kA("pcb_plated_hole"),shape:kA("hole_with_polygon_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:Ct(["circle","oval","pill","rotated_pill"]),hole_diameter:ZA().optional(),hole_width:ZA().optional(),hole_height:ZA().optional(),pad_outline:be(PA({x:mt,y:mt})).min(3),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(Mr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:ZA().optional()}),Oat=Ai([Yat,Jat,Kat,Tat,qat,Pat]),Wat=PA({type:kA("pcb_port"),pcb_port_id:jt("pcb_port"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),source_port_id:H(),pcb_component_id:H().optional(),x:mt,y:mt,layers:be(Mr),is_board_pinout:ce().optional()}).describe("Defines a port on the PCB"),Zat=PA({type:kA("pcb_smtpad"),shape:kA("circle"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,radius:ZA(),layer:Mr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()}),Vat=PA({type:kA("pcb_smtpad"),shape:kA("rect"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),rect_border_radius:ZA().optional(),corner_radius:ZA().optional(),layer:Mr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()}),jat=PA({type:kA("pcb_smtpad"),shape:kA("rotated_rect"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),rect_border_radius:ZA().optional(),corner_radius:ZA().optional(),ccw_rotation:pd,layer:Mr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()}),zat=PA({type:kA("pcb_smtpad"),shape:kA("pill"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),radius:ZA(),layer:Mr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()}),Xat=PA({type:kA("pcb_smtpad"),shape:kA("rotated_pill"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),radius:ZA(),ccw_rotation:pd,layer:Mr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()}),$at=PA({type:kA("pcb_smtpad"),shape:kA("polygon"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),points:be(xo),layer:Mr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()}),Agt=Mp("shape",[Zat,Vat,jat,Xat,zat,$at]).describe("Defines an SMT pad on the PCB"),egt=PA({type:kA("pcb_solder_paste"),shape:kA("circle"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,radius:ZA(),layer:Mr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),tgt=PA({type:kA("pcb_solder_paste"),shape:kA("rect"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),layer:Mr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),igt=PA({type:kA("pcb_solder_paste"),shape:kA("pill"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),radius:ZA(),layer:Mr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),ogt=PA({type:kA("pcb_solder_paste"),shape:kA("rotated_rect"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),ccw_rotation:mt,layer:Mr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),ngt=PA({type:kA("pcb_solder_paste"),shape:kA("oval"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),layer:Mr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),sgt=Ai([egt,tgt,igt,ogt,ngt]).describe("Defines solderpaste on the PCB"),rgt=PA({type:kA("pcb_text"),pcb_text_id:jt("pcb_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),text:H(),center:xo,layer:Mr,width:$A,height:$A,lines:ZA(),align:Ct(["bottom-left"])}).describe("Defines text on the PCB"),agt=PA({route_type:kA("wire"),x:mt,y:mt,width:mt,start_pcb_port_id:H().optional(),end_pcb_port_id:H().optional(),layer:Mr}),ggt=PA({route_type:kA("via"),x:mt,y:mt,hole_diameter:mt.optional(),outer_diameter:mt.optional(),from_layer:H(),to_layer:H()}),Igt=Ai([agt,ggt]),cgt=PA({type:kA("pcb_trace"),source_trace_id:H().optional(),pcb_component_id:H().optional(),pcb_trace_id:jt("pcb_trace"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),route_thickness_mode:Ct(["constant","interpolated"]).default("constant").optional(),route_order_index:ZA().optional(),should_round_corners:ce().optional(),trace_length:ZA().optional(),highlight_color:H().optional(),route:be(Igt)}).describe("Defines a trace on the PCB"),Bgt=PA({type:kA("pcb_trace_error"),pcb_trace_error_id:jt("pcb_trace_error"),error_type:kA("pcb_trace_error").default("pcb_trace_error"),message:H(),center:xo.optional(),pcb_trace_id:H(),source_trace_id:H(),pcb_component_ids:be(H()),pcb_port_ids:be(H()),subcircuit_id:H().optional()}).describe("Defines a trace error on the PCB"),Cgt=PA({type:kA("pcb_trace_missing_error"),pcb_trace_missing_error_id:jt("pcb_trace_missing_error"),error_type:kA("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:H(),center:xo.optional(),source_trace_id:H(),pcb_component_ids:be(H()),pcb_port_ids:be(H()),subcircuit_id:H().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),lgt=PA({type:kA("pcb_port_not_matched_error"),pcb_error_id:jt("pcb_error"),error_type:kA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:H(),pcb_component_ids:be(H()),subcircuit_id:H().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Qgt=PA({type:kA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:jt("pcb_port_not_connected_error"),error_type:kA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:H(),pcb_port_ids:be(H()),pcb_component_ids:be(H()),subcircuit_id:H().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),Egt=PA({type:kA("pcb_net"),pcb_net_id:jt("pcb_net"),source_net_id:H().optional(),highlight_color:H().optional()}).describe("Defines a net on the PCB"),hgt=PA({type:kA("pcb_via"),pcb_via_id:jt("pcb_via"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),x:mt,y:mt,outer_diameter:mt.default("0.6mm"),hole_diameter:mt.default("0.25mm"),from_layer:Mr.optional(),to_layer:Mr.optional(),layers:be(Mr),pcb_trace_id:H().optional(),net_is_assignable:ce().optional(),net_assigned:ce().optional(),is_tented:ce().optional()}).describe("Defines a via on the PCB"),ugt=PA({type:kA("pcb_board"),pcb_board_id:jt("pcb_board"),pcb_panel_id:H().optional(),is_subcircuit:ce().optional(),subcircuit_id:H().optional(),width:$A.optional(),height:$A.optional(),center:xo,display_offset_x:H().optional().describe("How to display the x offset for this board, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this board, usually corresponding with how the user specified it"),thickness:$A.optional().default(1.4),num_layers:ZA().optional().default(4),outline:be(xo).optional(),shape:Ct(["rect","polygon"]).optional(),material:Ct(["fr4","fr1"]).default("fr4"),anchor_position:xo.optional(),anchor_alignment:YG.optional(),position_mode:Ct(["relative_to_panel_anchor","none"]).optional()}).describe("Defines the board outline of the PCB"),dgt=PA({type:kA("pcb_panel"),pcb_panel_id:jt("pcb_panel"),width:$A,height:$A,center:xo,covered_with_solder_mask:ce().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),pgt=PA({type:kA("pcb_placement_error"),pcb_placement_error_id:jt("pcb_placement_error"),error_type:kA("pcb_placement_error").default("pcb_placement_error"),message:H(),subcircuit_id:H().optional()}).describe("Defines a placement error on the PCB"),fgt=PA({type:kA("pcb_trace_hint"),pcb_trace_hint_id:jt("pcb_trace_hint"),pcb_port_id:H(),pcb_component_id:H(),route:be(Uat),subcircuit_id:H().optional()}).describe("A hint that can be used during generation of a PCB trace"),ygt=PA({type:kA("pcb_silkscreen_line"),pcb_silkscreen_line_id:jt("pcb_silkscreen_line"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),stroke_width:mt.default("0.1mm"),x1:mt,y1:mt,x2:mt,y2:mt,layer:um}).describe("Defines a silkscreen line on the PCB"),wgt=PA({type:kA("pcb_silkscreen_path"),pcb_silkscreen_path_id:jt("pcb_silkscreen_path"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:um,route:be(xo),stroke_width:$A}).describe("Defines a silkscreen path on the PCB"),mgt=PA({type:kA("pcb_silkscreen_text"),pcb_silkscreen_text_id:jt("pcb_silkscreen_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("0.2mm"),pcb_component_id:H(),text:H(),is_knockout:ce().default(!1).optional(),knockout_padding:PA({left:$A,top:$A,bottom:$A,right:$A}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:ZA().optional(),layer:Mr,is_mirrored:ce().default(!1).optional(),anchor_position:xo.default({x:0,y:0}),anchor_alignment:YG.default("center")}).describe("Defines silkscreen text on the PCB"),Dgt=PA({type:kA("pcb_copper_text"),pcb_copper_text_id:jt("pcb_copper_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("0.2mm"),pcb_component_id:H(),text:H(),is_knockout:ce().default(!1).optional(),knockout_padding:PA({left:$A,top:$A,bottom:$A,right:$A}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:ZA().optional(),layer:Mr,is_mirrored:ce().default(!1).optional(),anchor_position:xo.default({x:0,y:0}),anchor_alignment:YG.default("center")}).describe("Defines copper text on the PCB"),Sgt=PA({type:kA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:jt("pcb_silkscreen_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,width:$A,height:$A,layer:Mr,stroke_width:$A.default("1mm"),corner_radius:$A.optional(),is_filled:ce().default(!0).optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),ccw_rotation:ZA().optional()}).describe("Defines a silkscreen rect on the PCB"),bgt=PA({type:kA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:jt("pcb_silkscreen_circle"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,radius:$A,layer:um,stroke_width:$A.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),xgt=PA({type:kA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:jt("pcb_silkscreen_oval"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,radius_x:mt,radius_y:mt,layer:um,ccw_rotation:pd.optional()}).describe("Defines a silkscreen oval on the PCB"),kgt=PA({type:kA("pcb_silkscreen_pill"),pcb_silkscreen_pill_id:jt("pcb_silkscreen_pill"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,width:$A,height:$A,layer:Mr,ccw_rotation:ZA().optional()}).describe("Defines a silkscreen pill on the PCB"),Ggt=PA({type:kA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:jt("pcb_fabrication_note_text"),subcircuit_id:H().optional(),pcb_group_id:H().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("1mm"),pcb_component_id:H(),text:H(),layer:um,anchor_position:xo.default({x:0,y:0}),anchor_alignment:Ct(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:H().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),Fgt=PA({type:kA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:jt("pcb_fabrication_note_path"),pcb_component_id:H(),subcircuit_id:H().optional(),layer:Mr,route:be(xo),stroke_width:$A,color:H().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),Rgt=PA({type:kA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:jt("pcb_fabrication_note_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,width:$A,height:$A,layer:um,stroke_width:$A.default("0.1mm"),corner_radius:$A.optional(),is_filled:ce().optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),color:H().optional()}).describe("Defines a fabrication note rectangle on the PCB"),Ngt=PA({type:kA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:jt("pcb_fabrication_note_dimension"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:um,from:xo,to:xo,text:H().optional(),text_ccw_rotation:ZA().optional(),offset:$A.optional(),offset_distance:$A.optional(),offset_direction:PA({x:ZA(),y:ZA()}).optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:$A.default("1mm"),color:H().optional(),arrow_size:$A.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),_gt=PA({type:kA("pcb_note_text"),pcb_note_text_id:jt("pcb_note_text"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("1mm"),text:H().optional(),anchor_position:xo.default({x:0,y:0}),anchor_alignment:Ct(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:H().optional()}).describe("Defines a documentation note in text on the PCB"),Mgt=PA({type:kA("pcb_note_rect"),pcb_note_rect_id:jt("pcb_note_rect"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),center:xo,width:$A,height:$A,stroke_width:$A.default("0.1mm"),corner_radius:$A.optional(),is_filled:ce().optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),color:H().optional()}).describe("Defines a rectangular documentation note on the PCB"),vgt=PA({type:kA("pcb_note_path"),pcb_note_path_id:jt("pcb_note_path"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),route:be(xo),stroke_width:$A.default("0.1mm"),color:H().optional()}).describe("Defines a polyline documentation note on the PCB"),Ugt=PA({type:kA("pcb_note_line"),pcb_note_line_id:jt("pcb_note_line"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),x1:mt,y1:mt,x2:mt,y2:mt,stroke_width:mt.default("0.1mm"),color:H().optional(),is_dashed:ce().optional()}).describe("Defines a straight documentation note line on the PCB"),Lgt=PA({type:kA("pcb_note_dimension"),pcb_note_dimension_id:jt("pcb_note_dimension"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),from:xo,to:xo,text:H().optional(),text_ccw_rotation:ZA().optional(),offset_distance:$A.optional(),offset_direction:PA({x:ZA(),y:ZA()}).optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:$A.default("1mm"),color:H().optional(),arrow_size:$A.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),Hgt=PA({type:kA("pcb_footprint_overlap_error"),pcb_error_id:jt("pcb_error"),error_type:kA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:H(),pcb_smtpad_ids:be(H()).optional(),pcb_plated_hole_ids:be(H()).optional(),pcb_hole_ids:be(H()).optional(),pcb_keepout_ids:be(H()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),Ygt=PA({type:kA("pcb_keepout"),shape:kA("rect"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,width:mt,height:mt,pcb_keepout_id:H(),layers:be(H()),description:H().optional()}).or(PA({type:kA("pcb_keepout"),shape:kA("circle"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,radius:mt,pcb_keepout_id:H(),layers:be(H()),description:H().optional()})),xO=PA({type:kA("pcb_cutout"),pcb_cutout_id:jt("pcb_cutout"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_board_id:H().optional(),pcb_panel_id:H().optional()}),Jgt=xO.extend({shape:kA("rect"),center:xo,width:$A,height:$A,rotation:pd.optional(),corner_radius:$A.optional()}),Kgt=xO.extend({shape:kA("circle"),center:xo,radius:$A}),Tgt=xO.extend({shape:kA("polygon"),points:be(xo)}),qgt=xO.extend({shape:kA("path"),route:be(xo),slot_width:$A,slot_length:$A.optional(),space_between_slots:$A.optional(),slot_corner_radius:$A.optional()}),Pgt=Mp("shape",[Jgt,Kgt,Tgt,qgt]).describe("Defines a cutout on the PCB, removing board material."),Ogt=PA({type:kA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:jt("pcb_missing_footprint_error"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),error_type:kA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:H(),message:H()}).describe("Defines a missing footprint error on the PCB"),Wgt=PA({type:kA("external_footprint_load_error"),external_footprint_load_error_id:jt("external_footprint_load_error"),pcb_component_id:H(),source_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),footprinter_string:H().optional(),error_type:kA("external_footprint_load_error").default("external_footprint_load_error"),message:H()}).describe("Defines an error when an external footprint fails to load"),Zgt=PA({type:kA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:jt("circuit_json_footprint_load_error"),pcb_component_id:H(),source_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),error_type:kA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:H(),circuit_json:be(vI()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),Vgt=PA({type:kA("pcb_group"),pcb_group_id:jt("pcb_group"),source_group_id:H(),is_subcircuit:ce().optional(),subcircuit_id:H().optional(),width:$A.optional(),height:$A.optional(),center:xo,display_offset_x:H().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:be(xo).optional(),anchor_position:xo.optional(),anchor_alignment:YG.default("center"),position_mode:Ct(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:H().optional(),positioned_relative_to_pcb_board_id:H().optional(),pcb_component_ids:be(H()),child_layout_mode:Ct(["packed","none"]).optional(),name:H().optional(),description:H().optional(),layout_mode:H().optional(),autorouter_configuration:PA({trace_clearance:$A}).optional(),autorouter_used_string:H().optional()}).describe("Defines a group of components on the PCB"),jgt=PA({type:kA("pcb_autorouting_error"),pcb_error_id:jt("pcb_autorouting_error"),error_type:kA("pcb_autorouting_error").default("pcb_autorouting_error"),message:H(),subcircuit_id:H().optional()}).describe("The autorouting has failed to route a portion of the board"),zgt=PA({type:kA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:jt("pcb_manual_edit_conflict_warning"),warning_type:kA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:H(),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),source_component_id:H()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),Xgt=PA({type:kA("pcb_breakout_point"),pcb_breakout_point_id:jt("pcb_breakout_point"),pcb_group_id:H(),subcircuit_id:H().optional(),source_trace_id:H().optional(),source_port_id:H().optional(),source_net_id:H().optional(),x:mt,y:mt}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),$gt=PA({type:kA("pcb_ground_plane"),pcb_ground_plane_id:jt("pcb_ground_plane"),source_pcb_ground_plane_id:H(),source_net_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional()}).describe("Defines a ground plane on the PCB"),AIt=PA({type:kA("pcb_ground_plane_region"),pcb_ground_plane_region_id:jt("pcb_ground_plane_region"),pcb_ground_plane_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:Mr,points:be(xo)}).describe("Defines a polygon region of a ground plane"),eIt=PA({type:kA("pcb_thermal_spoke"),pcb_thermal_spoke_id:jt("pcb_thermal_spoke"),pcb_ground_plane_id:H(),shape:H(),spoke_count:ZA(),spoke_thickness:mt,spoke_inner_diameter:mt,spoke_outer_diameter:mt,pcb_plated_hole_id:H().optional(),subcircuit_id:H().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),hBA=PA({type:kA("pcb_copper_pour"),pcb_copper_pour_id:jt("pcb_copper_pour"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:Mr,source_net_id:H().optional(),covered_with_solder_mask:ce().optional().default(!0)}),tIt=hBA.extend({shape:kA("rect"),center:xo,width:$A,height:$A,rotation:pd.optional()}),iIt=hBA.extend({shape:kA("brep"),brep_shape:Mat}),oIt=hBA.extend({shape:kA("polygon"),points:be(xo)}),nIt=Mp("shape",[tIt,iIt,oIt]).describe("Defines a copper pour on the PCB."),sIt=PA({type:kA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:jt("pcb_component_outside_board_error"),error_type:kA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:H(),pcb_component_id:H(),pcb_board_id:H(),component_center:xo,component_bounds:PA({min_x:ZA(),max_x:ZA(),min_y:ZA(),max_y:ZA()}),subcircuit_id:H().optional(),source_component_id:H().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),rIt=PA({type:kA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:jt("pcb_component_invalid_layer_error"),error_type:kA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:H(),pcb_component_id:H().optional(),source_component_id:H(),layer:Mr,subcircuit_id:H().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),aIt=PA({type:kA("pcb_via_clearance_error"),pcb_error_id:jt("pcb_error"),error_type:kA("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:H(),pcb_via_ids:be(H()).min(2),minimum_clearance:mt.optional(),actual_clearance:mt.optional(),pcb_center:PA({x:ZA().optional(),y:ZA().optional()}).optional(),subcircuit_id:H().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),gIt=PA({type:kA("pcb_courtyard_rect"),pcb_courtyard_rect_id:jt("pcb_courtyard_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,width:$A,height:$A,layer:um,color:H().optional()}).describe("Defines a courtyard rectangle on the PCB"),IIt=PA({type:kA("pcb_courtyard_outline"),pcb_courtyard_outline_id:jt("pcb_courtyard_outline"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:um,outline:be(xo).min(2),stroke_width:$A.default("0.1mm"),is_closed:ce().optional(),is_stroke_dashed:ce().optional(),color:H().optional()}).describe("Defines a courtyard outline on the PCB"),cIt=PA({type:kA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:jt("pcb_courtyard_polygon"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:um,points:be(xo).min(3),color:H().optional()}).describe("Defines a courtyard polygon on the PCB"),BIt=PA({type:kA("cad_component"),cad_component_id:H(),pcb_component_id:H(),source_component_id:H(),position:lBA,rotation:lBA.optional(),size:lBA.optional(),layer:Mr.optional(),subcircuit_id:H().optional(),footprinter_string:H().optional(),model_obj_url:H().optional(),model_stl_url:H().optional(),model_3mf_url:H().optional(),model_gltf_url:H().optional(),model_glb_url:H().optional(),model_step_url:H().optional(),model_wrl_url:H().optional(),model_unit_to_mm_scale_factor:ZA().optional(),model_jscad:vI().optional(),show_as_translucent_model:ce().optional()}).describe("Defines a component on the PCB"),BWA=Ct(["sinewave","square","triangle","sawtooth"]),CIt=Ai([H(),ZA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(ZA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),lIt=PA({type:kA("simulation_voltage_source"),simulation_voltage_source_id:jt("simulation_voltage_source"),is_dc_source:kA(!0).optional().default(!0),positive_source_port_id:H().optional(),negative_source_port_id:H().optional(),positive_source_net_id:H().optional(),negative_source_net_id:H().optional(),voltage:k_}).describe("Defines a DC voltage source for simulation"),QIt=PA({type:kA("simulation_voltage_source"),simulation_voltage_source_id:jt("simulation_voltage_source"),is_dc_source:kA(!1),terminal1_source_port_id:H().optional(),terminal2_source_port_id:H().optional(),terminal1_source_net_id:H().optional(),terminal2_source_net_id:H().optional(),voltage:k_.optional(),frequency:bO.optional(),peak_to_peak_voltage:k_.optional(),wave_shape:BWA.optional(),phase:pd.optional(),duty_cycle:CIt.optional()}).describe("Defines an AC voltage source for simulation"),EIt=Ai([lIt,QIt]).describe("Defines a voltage source for simulation"),hIt=Ai([H(),ZA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(ZA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),uIt=PA({type:kA("simulation_current_source"),simulation_current_source_id:jt("simulation_current_source"),is_dc_source:kA(!0).optional().default(!0),positive_source_port_id:H().optional(),negative_source_port_id:H().optional(),positive_source_net_id:H().optional(),negative_source_net_id:H().optional(),current:BBA}).describe("Defines a DC current source for simulation"),dIt=PA({type:kA("simulation_current_source"),simulation_current_source_id:jt("simulation_current_source"),is_dc_source:kA(!1),terminal1_source_port_id:H().optional(),terminal2_source_port_id:H().optional(),terminal1_source_net_id:H().optional(),terminal2_source_net_id:H().optional(),current:BBA.optional(),frequency:bO.optional(),peak_to_peak_current:BBA.optional(),wave_shape:BWA.optional(),phase:pd.optional(),duty_cycle:hIt.optional()}).describe("Defines an AC current source for simulation"),pIt=Ai([uIt,dIt]).describe("Defines a current source for simulation"),fIt=Ai([kA("spice_dc_sweep"),kA("spice_dc_operating_point"),kA("spice_transient_analysis"),kA("spice_ac_analysis")]),yIt=PA({type:kA("simulation_experiment"),simulation_experiment_id:jt("simulation_experiment"),name:H(),experiment_type:fIt,time_per_step:CBA.optional(),start_time_ms:G_.optional(),end_time_ms:G_.optional()}).describe("Defines a simulation experiment configuration"),wIt=PA({type:kA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:jt("simulation_transient_voltage_graph"),simulation_experiment_id:H(),timestamps_ms:be(ZA()).optional(),voltage_levels:be(ZA()),source_component_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),time_per_step:CBA,start_time_ms:G_,end_time_ms:G_,name:H().optional(),color:H().optional()}).describe("Stores voltage measurements over time for a simulation"),mIt=PA({type:kA("simulation_switch"),simulation_switch_id:jt("simulation_switch"),source_component_id:H().optional(),closes_at:G_.optional(),opens_at:G_.optional(),starts_closed:ce().optional(),switching_frequency:bO.optional()}).describe("Defines a switch for simulation timing control"),DIt=PA({type:kA("simulation_voltage_probe"),simulation_voltage_probe_id:jt("simulation_voltage_probe"),source_component_id:H().optional(),name:H().optional(),signal_input_source_port_id:H().optional(),signal_input_source_net_id:H().optional(),reference_input_source_port_id:H().optional(),reference_input_source_net_id:H().optional(),subcircuit_id:H().optional(),color:H().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,o=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&o?A.addIssue({code: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."}):o&&(!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."})}),SIt=PA({type:kA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:jt("simulation_unknown_experiment_error"),error_type:kA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:H(),simulation_experiment_id:H().optional(),subcircuit_id:H().optional()}).describe("An unknown error occurred during the simulation experiment."),bIt=PA({type:kA("simulation_op_amp"),simulation_op_amp_id:jt("simulation_op_amp"),source_component_id:H().optional(),inverting_input_source_port_id:H(),non_inverting_input_source_port_id:H(),output_source_port_id:H(),positive_supply_source_port_id:H(),negative_supply_source_port_id:H()}).describe("Defines a simple ideal operational amplifier for simulation");Ai([zrt,Vrt,jrt,Zrt,$rt,Xrt,J8A,L8A,QBA,Y8A,H8A,K8A,T8A,q8A,W8A,Z8A,V8A,AWA,j8A,z8A,X8A,$8A,O8A,P8A,eat,iat,Aat,eWA,tWA,iWA,oat,nat,Lat,Hat,Ogt,Wgt,Zgt,zgt,Oat,Ygt,Wat,Egt,rgt,cgt,hgt,Agt,sgt,ugt,dgt,Vgt,fgt,ygt,wgt,mgt,kgt,Dgt,Sgt,bgt,xgt,Bgt,Cgt,pgt,lgt,Qgt,aIt,Fgt,Ggt,Rgt,Ngt,_gt,Mgt,vgt,Ugt,Lgt,jgt,Hgt,Xgt,Pgt,$gt,AIt,eIt,nIt,sIt,rIt,gIt,IIt,cIt,sat,dat,Cat,lat,Qat,Eat,Bat,pat,hat,rat,yat,wat,fat,bat,xat,kat,Gat,Nat,Fat,Rat,BIt,EIt,pIt,yIt,wIt,mIt,DIt,SIt,bIt]);var xIt=Object.defineProperty,kIt=(t,A)=>{for(var e in A)xIt(t,e,{get:A[e],enumerable:!0})},iS={};kIt(iS,{axial:()=>Xct,bga:()=>rct,breakoutheaders:()=>cBt,cap:()=>vIt,dfn:()=>Nct,diode:()=>MIt,dip:()=>RIt,electrolytic:()=>Zlt,hc49:()=>CBt,jst:()=>Elt,led:()=>UIt,lqfp:()=>gBt,m2host:()=>QQt,melf:()=>DCt,micromelf:()=>kCt,minimelf:()=>hCt,mlp:()=>Ect,ms012:()=>Yct,ms013:()=>Kct,msop:()=>Slt,pad:()=>lBt,pinrow:()=>vct,platedhole:()=>sQt,potentiometer:()=>Plt,pushbutton:()=>iBt,qfn:()=>Cct,qfp:()=>Qct,quad:()=>R_,radial:()=>eBt,res:()=>oct,sma:()=>NCt,smb:()=>JCt,smbf:()=>jlt,smc:()=>PCt,smf:()=>UCt,smtpad:()=>oQt,sod110:()=>ult,sod123:()=>Zct,sod123f:()=>VBt,sod123fl:()=>$Bt,sod123w:()=>kBt,sod128:()=>rCt,sod323:()=>NBt,sod323f:()=>PBt,sod323fl:()=>Rlt,sod323w:()=>xlt,sod523:()=>dBt,sod723:()=>iCt,sod80:()=>DBt,sod882:()=>JBt,sod882d:()=>fCt,sod923:()=>UBt,soic:()=>gct,solderjumper:()=>Ult,son:()=>vlt,sop8:()=>wBt,sot:()=>aQt,sot223:()=>VCt,sot23:()=>Sct,sot23w:()=>olt,sot25:()=>Gct,sot323:()=>AQt,sot343:()=>cQt,sot363:()=>yct,sot457:()=>Ylt,sot563:()=>Lct,sot723:()=>qct,sot886:()=>mct,sot89:()=>CCt,sot963:()=>Klt,ssop:()=>uct,stampboard:()=>nBt,stampreceiver:()=>aBt,to220:()=>QCt,to92:()=>hBt,to92l:()=>hQt,to92s:()=>Ilt,tqfp:()=>lct,tssop:()=>pct,vssop:()=>wlt});var Li=(t,A,e)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:e,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:A},anchor_alignment:"center"}),Hi=PA({norefdes:ce().optional().describe("disable reference designator label"),invert:ce().optional().describe("hint to invert the orientation of the 3D model"),faceup:ce().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:ce().optional().describe("omit all silkscreen elements from the footprint")}),Pn=(t,A,e,i,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:wr(i),outer_diameter:wr(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),oS=(t,A,e,i,o,n,s,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:A,y:e,hole_diameter:wr(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:wr(o),rect_pad_height:wr(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],hole_offset_x:s,hole_offset_y:r}),CWA=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 hx(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var kO=Ai([H(),ZA()]).transform(t=>hx(t)),GIt=t=>Hi.extend({fn:H(),num_pins:ZA().optional().default(6),wide:ce().optional(),narrow:ce().optional(),w:kO.optional(),p:kO.default(t.p??"2.54mm"),id:kO.optional(),od:kO.optional(),nosquareplating:ce().optional().default(!1).describe("do not use rectangular pad for pin 1")}).transform(A=>(!A.id&&!A.od?Math.abs(A.p-1.27)<.01?(A.id=hx("0.55mm"),A.od=hx("0.95mm")):(A.id=hx("0.8mm"),A.od=hx("1.6mm")):A.id?A.od||(A.od=A.id*(1.5/1)):A.id=A.od*(1/1.5),A.w||(A.wide?A.w=hx("600mil"):A.narrow?A.w=hx("300mil"):A.w=hx(t.w??"300mil")),A)),FIt=GIt({}),lWA=(t,A,e,i,o)=>{const n=t/2,s=A<=n,r=n-1,a=i,g=a*r;return s?{x:-e/2,y:g/2-(A-1)*a}:{x:e/2,y:-g/2+(A-n-1)*a}},RIt=t=>{const A=FIt.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:I,y:c}=lWA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating);if(g===0&&!A.nosquareplating){e.push(oS(g+1,I,c,A.id??"0.8mm",A.od??"1mm",A.od??"1mm"));continue}e.push(Pn(g+1,I,c,A.id??"0.8mm",A.od??"1mm"))}(A.num_pins/2-1)*A.p+A.od;const o=A.w-A.od-1,n=(A.num_pins/2-1)*A.p+A.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/2,y:-n/2},{x:-o/2,y:n/2},...CWA.map(({x:g,y:I})=>({x:g*o/6,y:I*o/6+n/2})),{x:o/2,y:n/2},{x:o/2,y:-n/2},{x:-o/2,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1},r=[];for(let g=0;g<A.num_pins;g++){const I=g<A.num_pins/2,c=.6,{y:B}=lWA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating),C=I?-A.w/2-A.od/2-c:A.w/2+A.od/2+c,l=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:C,y:l},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Li(0,n/2+.5,.4);return{circuitJson:[...e,s,a,...r],parameters:A}},Qi=(t,A,e,i,o)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:o,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),QWA=[{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}],NIt=Object.fromEntries(QWA.map(t=>[t.metric,t])),_It=Object.fromEntries(QWA.map(t=>[t.imperial,t]));Hi.extend({tht:ce(),p:$A.optional(),pw:$A.optional(),ph:$A.optional(),metric:mt.optional(),imperial:mt.optional(),w:$A.optional(),h:$A.optional(),textbottom:ce().optional()});var GO=t=>{let{tht:A,p:e,pw:i,ph:o,metric:n,imperial:s,w:r,h:a,textbottom:g}=t;if(typeof r=="string"&&(r=fB(r)),typeof a=="string"&&(a=fB(a)),typeof e=="string"&&(e=fB(e)),typeof i=="string"&&(i=fB(i)),typeof o=="string"&&(o=fB(o)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let I;if(n&&(I=NIt[n]),s&&(I=_It[s]),I&&(r=I.w_mm_min,a=I.h_mm_min,e=I.p_mm_min,i=I.pw_mm_min,o=I.ph_mm_min),e===void 0||i===void 0||o===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:e/2,y:o/2+.4},{x:-e/2-i/2-.2,y:o/2+.4},{x:-e/2-i/2-.2,y:-o/2-.4},{x:e/2,y:-o/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},B=g?-o/2-.9:o/2+.9,C=Li(0,B,.2);return A?[Pn(1,-e/2,0,i,i*1/.8),Pn(2,e/2,0,i,i*1/.8),c,C]:[Qi(["1","left"],-e/2,0,i,o),Qi(["2","right"],e/2,0,i,o),c,C]},MIt=t=>({circuitJson:GO(t),parameters:t}),vIt=t=>({circuitJson:GO(t),parameters:t}),UIt=t=>({circuitJson:GO(t),parameters:t}),F_=t=>{const{padSpacing:A,padWidth:e,padHeight:i,padPitch:o,numRows:n,textbottom:s}=t,r=[],a=(n-1)*(o/2);for(let x=0;x<n;x++)r.push(a-x*o);const g=[];r.forEach((x,F)=>{g.push(Qi(F+1,-A/2,x,e,i))}),r.slice().reverse().forEach((x,F)=>{g.push(Qi(F+n+1,A/2,x,e,i))});const I=Math.max(...r)+i/2+.4,c=Math.min(...r)-i/2-.4,B=-A/2-e/2-.4,C=A/2+e/2+.4,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C*.5,y:I},{x:B*.5,y:I}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C*.5,y:c},{x:B*.5,y:c}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},E=-A/2,h=Math.max(...r),u=.2,d=E-e/2-.1,f=h+i/2+.1,D={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:[{x:d,y:f},{x:d-u,y:f},{x:d,y:f+u},{x:d,y:f}],stroke_width:.1},b=s?c-.9:I+.9,m=Li(0,b,.2);return[...g,l,Q,D,m]},LIt=Hi.extend({pw:H().default("0.5mm"),ph:H().default("0.4mm"),p:H().default("0.7mm"),textbottom:ce().optional()}),HIt=1,YIt=t=>{const A=LIt.parse(t),e=fB(A.pw),i=fB(A.ph),o=fB(A.p);return F_({padSpacing:HIt,padWidth:e,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},JIt=Hi.extend({pw:H().default("0.5mm"),ph:H().default("0.32mm"),p:H().default("0.5mm"),textbottom:ce().optional()}),KIt=1,TIt=t=>{const A=JIt.parse(t),e=fB(A.pw),i=fB(A.ph),o=fB(A.p);return F_({padSpacing:KIt,padWidth:e,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},qIt=Hi.extend({pw:H().default("0.9mm"),ph:H().default("0.4mm"),p:H().default("0.8mm"),textbottom:ce().optional()}),PIt=1.7,OIt=t=>{const A=qIt.parse(t),e=fB(A.pw),i=fB(A.ph),o=fB(A.p);return F_({padSpacing:PIt,padWidth:e,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},WIt=Hi.extend({pw:H().default("0.9mm"),ph:H().default("0.4mm"),p:H().default("0.8mm"),textbottom:ce().optional()}),ZIt=1.7,VIt=t=>{const A=WIt.parse(t),e=fB(A.pw),i=fB(A.ph),o=fB(A.p);return F_({padSpacing:ZIt,padWidth:e,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},jIt=Hi.extend({pw:H().default("0.7mm"),ph:H().default("0.64mm"),p:H().default("0.94mm"),textbottom:ce().optional()}),zIt=1.4,XIt=t=>{const A=jIt.parse(t),e=fB(A.pw),i=fB(A.ph),o=fB(A.p);return F_({padSpacing:zIt,padWidth:e,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},$It=Hi.extend({pw:H().default("0.9mm"),ph:H().default("0.9mm"),p:H().default("1.34mm"),textbottom:ce().optional()}),Act=3,ect=t=>{const A=$It.parse(t),e=fB(A.pw),i=fB(A.ph),o=fB(A.p);return F_({padSpacing:Act,padWidth:e,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},tct=t=>{const A=t.array??t.x;if(typeof A=="number")return Number.isNaN(A)?void 0:A;if(typeof A=="string"){const e=Number.parseInt(A,10);return Number.isNaN(e)?void 0:e}if(typeof t.imperial=="string"){const i=t.imperial.match(/(?:array|x)(2|4)$/)?.[1];if(i)return Number.parseInt(i,10)}},ict=t=>t?(typeof t=="number"?`${t}`:t).split("_")[0]:void 0,oct=t=>{const A=tct(t),e=ict(t.imperial);return A===2&&e==="0402"?{circuitJson:YIt(t),parameters:t}:A===4&&e==="0402"?{circuitJson:TIt(t),parameters:t}:A===2&&e==="0603"?{circuitJson:OIt(t),parameters:t}:A===4&&e==="0603"?{circuitJson:VIt(t),parameters:t}:A===2&&e==="0606"?{circuitJson:XIt(t),parameters:t}:A===4&&e==="1206"?{circuitJson:ect(t),parameters:t}:{circuitJson:GO(t),parameters:t}},EWA=(t,{x:A,y:e,radius:i})=>({type:"pcb_smtpad",x:A,y:e,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),hWA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",uWA=H().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A),y:parseFloat(e)}}).pipe(PA({x:ZA(),y:ZA()})),nct=H().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(H().or(ZA()))),sct=Hi.extend({fn:H(),num_pins:ZA().optional().default(64),grid:uWA.optional(),p:mt.default("0.8mm"),w:$A.optional(),h:$A.optional(),ball:$A.optional().describe("ball diameter"),pad:$A.optional().describe("pad width/height"),circularpads:ce().optional().describe("use circular pads"),tlorigin:ce().optional(),blorigin:ce().optional(),trorigin:ce().optional(),brorigin:ce().optional(),missing:nct.default([])}).transform(t=>{let A="tl";if(t.blorigin&&(A="bl"),t.trorigin&&(A="tr"),t.brorigin&&(A="br"),!t.grid){const i=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:i,y:i}}return t.missing&&(t.missing=t.missing.map(i=>{if(typeof i=="number")return i;if(i==="center")return"center";if(i==="topleft")return"topleft";const o=i.match(/([A-Z]+)(\d+)/);if(!o)return i;const n=hWA.indexOf(o[1]),s=Number.parseInt(o[2])-1;return n*t.grid.x+s+1})),{...t,origin:A}}),rct=t=>{const A=sct.parse(t);let{num_pins:e,grid:i,p:o,w:n,h:s,ball:r,pad:a,missing:g}=A;r??=.75/1.27*o,a??=r*.8;const I=[],c=(g??[]).filter(D=>typeof D=="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 D=Math.floor(Math.sqrt(B)),b=Math.floor((i.x-D)/2),m=Math.floor((i.y-D)/2);for(let x=m;x<m+D;x++)for(let F=b;F<b+D;F++)c.push(x*i.x+F+1)}g?.includes("topleft")&&c.push(1);const C=new Set(c);let l=0;for(let D=0;D<i.y;D++)for(let b=0;b<i.x;b++){const m=(b-(i.x-1)/2)*o,x=(D-(i.y-1)/2)*o;let F=b,k=D;switch(A.origin){case"bl":F=b,k=i.y-1-D;break;case"br":F=i.x-1-b,k=i.y-1-D;break;case"tr":F=i.x-1-b,k=D;break}let v=k*i.x+F+1;if(C.has(v)){l++;continue}v-=l;const _=[v,`${hWA[k]}${F+1}`];I.push(A.circularpads?EWA(_,{x:m,y:x,radius:a/2}):Qi(_,m,x,a,a))}const Q=Li(0,i.y*o/2,.2),E=o/6;let h;const u=i.x*o/2,d=i.y*o/2;switch(A.origin){case"bl":h=[{x:-u,y:-d},{x:-u,y:-d-E},{x:-u-E,y:-d},{x:-u,y:-d}];break;case"br":h=[{x:u,y:-d},{x:u,y:-d-E},{x:u+E,y:-d},{x:u,y:-d}];break;case"tr":h=[{x:u,y:d},{x:u,y:d+E},{x:u+E,y:d},{x:u,y:d}];break;default:h=[{x:-u,y:d},{x:-u,y:d+E},{x:-u-E,y:d},{x:-u,y:d}];break}const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:h,stroke_width:.05};return{circuitJson:[...I,Q,f],parameters:A}},FO=(t,A,e,i,o)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:o,radius:o/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),dm=t=>Hi.extend({fn:H(),num_pins:ZA().optional().default(8),w:$A.default($A.parse(t.w??"5.3mm")),p:$A.default($A.parse(t.p??"1.27mm")),pw:$A.default($A.parse(t.pw??"0.6mm")),pl:$A.default($A.parse(t.pl??"1.0mm")),legsoutside:ce().optional().default(t.legsoutside??!1),pillpads:ce().optional().default(t.pillpads??!1),silkscreen_stroke_width:ZA().optional().default(.1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=$A.parse("0.6mm"),A.pl=$A.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),act=dm({}),uBA=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:A,pn:e,w:i,p:o,pl:n,legsoutside:s}=t,r=A/2,a=e<=r,g=r-1,I=o,c=I*g,B=s?n/2:-n/2;return a?{x:-i/2-B,y:c/2-(e-1)*I}:{x:i/2+B,y:-c/2+(e-r-1)*I}},gct=t=>{const A=act.parse(t);return{circuitJson:ux(A),parameters:A}},ux=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=uBA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push(FO(r+1,a,g,t.pl,t.pw)):A.push(Qi(r+1,a,g,t.pl,t.pw))}const e=Math.min(1,t.p/2),i=t.w-(t.legsoutside?0:t.pl*2)-.2,o=(t.num_pins/2-1)*t.p+t.pw+e,n=Li(0,o/2+.4,o/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:t.silkscreen_stroke_width??.1,route:[{x:-i/2,y:-o/2},{x:-i/2,y:o/2},...CWA.map(({x:r,y:a})=>({x:r*i/6,y:a*i/6+o/2})),{x:i/2,y:o/2},{x:i/2,y:-o/2},{x:-i/2,y:-o/2}]};return[...A,s,n]},dWA=Ct(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),Ict=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const o=[],n=t/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=n:r.bottomside&&r.leftpin?s=n+1:r.bottomside&&r.rightpin?s=n*2:r.rightside&&r.bottompin?s=n*2+1:r.rightside&&r.toppin?s=n*3:r.topside&&r.rightpin?s=n*3+1:r.topside&&r.leftpin&&(s=n*4),o.push(-1);for(let a=0;a<t;a++)o[s]=a+1,e||!A?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return o},dBA=Hi.extend({fn:H(),cc:ce().default(!0).optional(),ccw:ce().default(!0).optional(),startingpin:H().or(be(dWA)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(be(dWA)).optional(),num_pins:ZA().optional().default(64),w:$A.optional(),h:$A.optional(),p:$A.default($A.parse("0.5mm")),pw:$A.optional(),pl:$A.optional(),thermalpad:Ai([kA(!0),uWA]).optional(),legsoutside:ce().default(!1)}),pBA=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},pWA=dBA.transform(pBA),cct=["left","bottom","right","top"],Bct=t=>{const{pin_count:A,pn:e,w:i,h:o,p:n,pl:s,legsoutside:r}=t,a=A/4,g=cct[Math.floor((e-1)/a)],I=(e-1)%a,c=n*(a-1),B=n*(a-1),C=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-C+.1,y:B/2-I*n,o:"vert"};case"bottom":return{x:-c/2+I*n,y:-o/2-C+.1,o:"horz"};case"right":return{x:i/2+C-.1,y:-B/2+I*n,o:"vert"};case"top":return{x:c/2-I*n,y:o/2+C-.1,o:"horz"};default:throw new Error("Invalid pin number")}},R_=t=>{const A=pWA.parse(t),e=[],i=Ict(A),o=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:I}=Bct({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 C=i[r+1];e.push(Qi(C,a,g,c,B))}if(A.thermalpad)if(typeof A.thermalpad=="boolean"){const r=A.p*(o-1)+A.pw,a=A.p*(o-1)+A.pw;e.push(Qi(["thermalpad"],0,0,r,a))}else e.push(Qi(["thermalpad"],0,0,A.thermalpad.x,A.thermalpad.y));const n=[];for(const[r,a,g]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const I=A.w/2*a,c=A.h/2*g;let B="none",C=I,l=c;const Q=A.pw*2;i[1]===1&&r==="top-left"?B="in1":i[o*4]===1&&r==="top-left"||i[o*3+1]===1&&r==="top-right"?B="in2":i[o*3]===1&&r==="top-right"||i[o]===1&&r==="bottom-left"?B="in1":i[o+1]===1&&r==="bottom-left"?B="in2":i[o*2]===1&&r==="bottom-right"?B="in1":i[o*2+1]===1&&r==="bottom-right"&&(B="in2");const E=B==="in1"?1:-1;if(A.legsoutside){const h=B==="in1"?A.pl/2:A.pw/2,u=B==="in1"?A.pw/2:A.pl/2;C+=h*a*E,l-=u*g*E}(B==="none"||A.legsoutside)&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:I-Q*a,y:c},{x:I,y:c},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&!A.legsoutside&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:I-Q*a,y:c},{x:I-Q*a/2,y:c}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:I,y:c-Q*g/2},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:C-.2*-a,y:l+.2*E},{x:C,y:l},{x:C+.2*E*-a,y:l+.2},{x:C-.2*-a,y:l+.2*E}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Li(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...n,s],parameters:A}};dBA.extend({}).transform(pBA);var Cct=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),R_(t)),lct=t=>{if(t.legsoutside=!0,!t.p)switch(t.num_pins){case 32:t.p=.8;break;case 44:case 48:t.p=.5;break;case 64:case 80:case 100:t.p=.5;break;case 144:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 32:case 44:case 48:case 64:case 80:case 100:t.pl=1.475;break;case 144:t.pl=1.6;break}if(!t.pw)switch(t.num_pins){case 32:t.pw=.55;break;case 44:case 48:case 64:case 80:case 100:t.pw=.3;break;case 144:t.pw=.25;break}return R_(t)},Qct=t=>{t.legsoutside=!0;const A=pWA.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 R_(t)};dBA.extend({}).transform(pBA);var Ect=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),R_(t)),hct=dm({w:"3.9mm",p:"1.27mm"}),uct=t=>{const A=hct.parse(t);return{circuitJson:ux(A),parameters:A}},dct=dm({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),pct=t=>{const A=dct.parse(t);return{circuitJson:ux(A),parameters:A}},fct=dm({}),yct=t=>{const A=fct.parse({fn:"sot363",num_pins:6,w:2.56,p:.65,pw:.4,pl:.65,legoutside:!0});return{circuitJson:ux(A),parameters:A}},wct=Hi.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("1.01mm"),h:H().default("1.45mm"),p:H().default("0.5mm"),pl:H().default("0.33mm"),pw:H().default("0.27mm"),string:H().optional()}),mct=t=>{const A=wct.parse({fn:"sot886",...t}),e=$A.parse(A.w),i=$A.parse(A.h),o=$A.parse(A.p),n=$A.parse(A.pl),s=$A.parse(A.pw),r=[];for(let C=0;C<6;C++){const{x:l,y:Q}=fWA(C+1,e,o,n);r.push(Qi(C+1,l,Q,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=fWA(1,e,o,n),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-n/2-.3,y:I.y},{x:I.x-n/2-.45,y:I.y+.15},{x:I.x-n/2-.45,y:I.y-.15},{x:I.x-n/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},B=Li(0,i/2+.4,.25);return{circuitJson:[...r,a,g,B,c],parameters:A}},fWA=(t,A,e,i)=>{const o=A/2-i/2;return t<=3?{x:-o,y:e-(t-1)*e}:{x:o,y:-e+(t-4)*e}},yWA=Hi.extend({fn:H(),num_pins:ZA().default(3),w:H().default("1.92mm"),h:H().default("2.74mm"),pl:H().default("1.32mm"),pw:H().default("0.6mm"),p:H().default("0.95mm"),string:H().optional()}),Dct=dm({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Sct=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const o=Dct.parse({...t,num_pins:e});return{circuitJson:ux(o),parameters:o}}const i=yWA.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:xct(i),parameters:i};if(i.num_pins===5)return{circuitJson:mWA(i),parameters:i};throw new Error("Invalid number of pins")},bct=t=>{const{pn:A,p:e}=t;return A===1?{x:-1.155,y:e}:A===2?{x:-1.155,y:-e}:{x:1.15,y:0}},xct=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:o,y:n}=bct({num_pins:t.num_pins,pn:i+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(i+1,o,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Li(0,Number.parseInt(t.h),.3);return[...A,e]},wWA=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")},mWA=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:C}=wWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(Qi(c,B,C,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Li(0,i+.3,.3),r=wWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.3,g=.4,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,o,n,I]},kct=yWA.extend({}),Gct=t=>{const A=kct.parse({...t,num_pins:5});return{circuitJson:mWA(A),parameters:A}},Fct=[{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}],Rct=dm({}),Nct=t=>{const A=Rct.parse(t),e=[];for(let c=0;c<A.num_pins;c++){const{x:B,y:C}=uBA({num_pins:A.num_pins,pn:c+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(Qi(c+1,B,C,A.pl??"1mm",A.pw??"0.6mm"))}const i=Math.min(1,A.p/2),o=A.w+i,n=(A.num_pins/2-1)*A.p+A.pw+i,s=[];for(const c of Fct){const{dx:B,dy:C}=c;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:B*o/2-B*A.p,y:C*n/2},{x:B*o/2,y:C*n/2},{x:B*o/2,y:C*n/2-C*A.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const r=A.p/4,a=-o/2-r/2,g=n/2-A.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:a,y:g},{x:a-r,y:g+r},{x:a-r,y:g-r},{x:a,y:g}],stroke_width:.1});const I=Li(0,n/2+.4,n/12);return{circuitJson:[...e,I,...s],parameters:A}},fBA=({fs:t,pn:A,anchor_x:e,anchor_y:i,textalign:o="center",orthogonal:n=!1,verticallyinverted:s=!1,layer:r="top"})=>{let a=0;n&&s?a=270:s?a=180:n?a=90:a=0;let g="center";return o==="left"&&(s?g="center_right":g="center_left"),o==="right"&&(s?g="center_left":g="center_right"),r==="bottom"&&(g==="center_left"?g="center_right":g==="center_right"&&(g="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:`{PIN${A}}`,layer:r,anchor_position:{x:e,y:i},anchor_alignment:g,ccw_rotation:a}};function _ct({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 Mct=Hi.extend({fn:H(),num_pins:ZA().optional().default(6),rows:Ai([H(),ZA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:$A.default("0.1in").describe("pitch"),id:$A.default("1.0mm").describe("inner diameter"),od:$A.default("1.5mm").describe("outer diameter"),male:ce().optional().describe("for male pin headers"),female:ce().optional().describe("for female pin headers"),smd:ce().optional().describe("surface mount device"),surfacemount:ce().optional().describe("surface mount device (verbose)"),rightangle:ce().optional().describe("right angle"),pw:$A.optional().default("1.0mm").describe("pad width for SMD"),pl:$A.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:ce().optional().default(!1),pinlabeltextaligncenter:ce().optional().default(!1),pinlabeltextalignright:ce().optional().default(!1),pinlabelverticallyinverted:ce().optional().default(!1),pinlabelorthogonal:ce().optional().default(!1),nosquareplating:ce().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:ce().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:ce().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:ce().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=_ct(t);return{...t,pinlabelAnchorSide:A,male:t.male??!t.female,female:t.female??!1,smd:t.smd??t.surfacemount??!1,rightangle:t.rightangle??!1}}).superRefine((t,A)=>{t.male&&t.female&&A.addIssue({code:Wt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),vct=t=>{const A=Mct.parse(t),{p:e,id:i,od:o,rows:n,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:I,pinlabeltextalignright:c,nopinlabels:B,doublesidedpinlabel:C,bottomsidepinlabel:l}=A;let Q="center";I?Q="left":c&&(Q="right");const E=[],h=Math.ceil(s/n),u=-e,d=({xoff:x,yoff:F,od:k,anchorSide:v,smd:_,pw:Y,pl:P})=>{let K=0,O=0;if(_){const W=k/5;switch(v){case"right":K=Y/2+W;break;case"top":O=P/2+W;break;case"bottom":O=-(P/2+W);break;case"left":K=-(Y/2+W);break}}else{const W=k*.75;switch(v){case"right":K=W;break;case"top":O=W;break;case"bottom":O=-W;break;case"left":K=-W;break}}return{anchor_x:x+K,anchor_y:F+O}},f=(x,F,k)=>{A.smd?E.push(Qi(x,F,k,A.pw,A.pl)):x===1&&!A.nosquareplating?E.push(oS(x,F,k,i,o,o,0,0)):E.push(Pn(x,F,k,i,o));const{anchor_x:v,anchor_y:_}=d({xoff:F,yoff:k,od:o,anchorSide:r,smd:A.smd,pw:A.pw,pl:A.pl});B||(l?E.push(fBA({fs:o/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):E.push(fBA({fs:o/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),C&&E.push(fBA({fs:o/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},D=new Set,b=n>2&&h>2;if(n===1){const x=-((s-1)/2)*e;for(let F=0;F<s;F++){const k=F+1,v=x+F*e,_=`${v},0`;if(D.has(_))throw new Error(`Overlap at ${_}`);D.add(_),f(k,v,0)}}else if(b){const x=-((h-1)/2)*e;let F=1;for(let k=0;k<n&&F<=s;k++)for(let v=0;v<h&&F<=s;v++){const _=x+v*e,Y=k*u,P=`${_},${Y}`;if(D.has(P))throw new Error(`Overlap at ${P}`);D.add(P),f(F++,_,Y)}}else{const x=-((h-1)/2)*e;let F=1,k=0,v=n-1,_=0,Y=h-1;for(;F<=s&&k<=v&&_<=Y;){for(let P=k;P<=v&&F<=s;P++){const K=x+_*e,O=P*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}_++;for(let P=_;P<=Y&&F<=s;P++){const K=x+P*e,O=v*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}if(v--,_<=Y){for(let P=v;P>=k&&F<=s;P--){const K=x+Y*e,O=P*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}Y--}if(k<=v){for(let P=Y;P>=_&&F<=s;P--){const K=x+P*e,O=k*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}k++}}if(F-1<s)throw new Error(`Missing pins: assigned ${F-1}, expected ${s}`)}const m=Li(0,e,.5);return{circuitJson:[...E,m],parameters:A}},Uct=Hi.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("2.1mm"),h:H().default("2.45mm"),p:H().default("0.5mm"),pl:H().default("0.675mm"),pw:H().default("0.35mm"),string:H().optional()}),Lct=t=>{const A=Uct.parse({...t,fn:"sot563"}),e=$A.parse(A.w),i=$A.parse(A.h),o=$A.parse(A.p),n=$A.parse(A.pl),s=$A.parse(A.pw),r=[];for(let C=0;C<6;C++){const{x:l,y:Q}=DWA(C+1,e,o,n);r.push(Qi(C+1,l,Q,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=DWA(1,e,o,n),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-n/2-.3,y:I.y},{x:I.x-n/2-.45,y:I.y+.15},{x:I.x-n/2-.45,y:I.y-.15},{x:I.x-n/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},B=Li(0,i/2+.4,.25);return{circuitJson:[...r,a,g,B,c],parameters:A}},DWA=(t,A,e,i)=>{const o=A/2-i/2;return t<=3?{x:-o,y:e-(t-1)*e}:{x:o,y:-e+(t-4)*e}},Hct=dm({p:"1.27mm",w:"3.9mm",legsoutside:!0}),Yct=t=>{const A=Hct.parse({...t,num_pins:8});return{circuitJson:ux(A),parameters:A}},Jct=dm({p:"1.27mm",w:"7.5mm",legsoutside:!0}),Kct=t=>{const A=Jct.parse({...t,num_pins:16});return{circuitJson:ux(A),parameters:A}},Tct=Hi.extend({fn:H(),num_pins:kA(3).default(3),w:H().default("1.2mm"),h:H().default("1.2mm"),pw:H().default("0.40mm"),pl:H().default("0.45mm"),p:H().default("0.575mm")}),qct=t=>{const A=Tct.parse(t),e=Oct(A),i=Li(0,$A.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},Pct=t=>{const{pn:A,p:e}=t;return A===1?{x:e,y:0}:A===2?{x:-e,y:-.4}:{x:-e,y:.4}},Oct=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:o}=Pct({num_pins:t.num_pins,pn:e+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(e+1,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Wct=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("2.36mm"),h:H().default("1.22mm"),pl:H().default("0.9mm"),pw:H().default("1.2mm"),p:H().default("3.30mm")}),Zct=t=>{const A=Wct.parse(t),e=Li(0,$A.parse(A.h)/4+.4,.3);return{circuitJson:jct(A).concat(e),parameters:A}},Vct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},jct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Vct({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},zct=Hi.extend({fn:H(),p:$A.optional().default("2.54mm"),id:$A.optional().default("0.7mm"),od:$A.optional().default("1.4mm")}),Xct=t=>{const A=zct.parse(t),{p:e,id:i,od:o}=A,n=[Pn(1,-e/2,0,i,o),Pn(2,e/2,0,i,o)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2+o+i/2,y:0},{x:e/2-o-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},r=Li(0,1.5,.5);return{circuitJson:[...n,s,r],parameters:A}},$ct=(t,A,e,i,o,n=.1)=>{const s=[],r=[],a=Math.max(1,Math.ceil(Math.PI*e/n)),g=Math.PI/a;for(let I=0;I<=a;I++){const c=I*g,B=t+Math.cos(c)*e,C=A+Math.sin(c)*e;B<t-i&&C>=A-o/2&&C<=A+o/2||s.push({x:B,y:C})}for(let I=0;I<=a;I++){const c=Math.PI+I*g,B=t+Math.cos(c)*e,C=A+Math.sin(c)*e;B<t-i&&C>=A-o/2&&C<=A+o/2||r.push({x:B,y:C})}return{topArc:s,bottomArc:r}},ABt=Hi.extend({fn:H(),p:$A.optional().default("5mm"),id:$A.optional().default("0.8mm"),od:$A.optional().default("1.6mm"),ceramic:ce().optional(),electrolytic:ce().optional(),polarized:ce().optional()}),eBt=t=>{const A=ABt.parse(t),{p:e,id:i,od:o}=A;i===.8&&o===1.6&&(A.id=e===5?.8:e*.25,A.od=e===5?1.6:e*.5);const n=[Pn(1,-e/2,0,A.id,A.od),Pn(2,e/2,0,A.id,A.od)],s=e+.1,{topArc:r,bottomArc:a}=$ct(0,0,s,A.od/2,A.od),g=.02*e,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:g,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:g,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:s},{x:0,y:-s}],stroke_width:g,pcb_silkscreen_path_id:""},C=.1*e,l=-(e+C+.04*e),Q=s-C-.08*e,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l-C,y:Q},{x:l+C,y:Q}],stroke_width:g,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l,y:Q-C},{x:l,y:Q+C}],stroke_width:g,pcb_silkscreen_path_id:""},u=Li(0,s+.12*e,.1*e),d=[...n,I,c,B,u];return(A.electrolytic===!0||A.polarized===!0)&&d.push(E,h),{circuitJson:d,parameters:A}},RO=(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}),tBt=Hi.extend({fn:kA("pushbutton"),w:$A.default(4.5),h:$A.default(6.5),id:$A.default(1),od:$A.default(1.2)}),iBt=t=>{const A=tBt.parse(t),e=A.w,i=A.h,o=A.id,n=[Pn(1,-e/2,i/2,o,o*1.5),Pn(2,-e/2,-i/2,o,o*1.5),Pn(3,e/2,-i/2,o,o*1.5),Pn(4,e/2,i/2,o,o*1.5)],s=[RO([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),RO([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),RO([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),RO([{x:e/2,y:0},{x:e/5,y:0}])],r=Li(0,i/2+.4,.5);return{circuitJson:[...n,...s,r],parameters:A}},SWA=Hi.extend({fn:H(),w:$A.default("22.58mm"),h:$A.optional(),left:$A.optional().default(20),right:$A.optional().default(20),top:$A.optional().default(2),bottom:$A.optional().default(2),p:$A.default($A.parse("2.54mm")),pw:$A.default($A.parse("1.6mm")),pl:$A.default($A.parse("2.4mm")),innerhole:ce().default(!1),innerholeedgedistance:$A.default($A.parse("1.61mm")),silkscreenlabels:ce().default(!1),silkscreenlabelmargin:$A.default($A.parse("0.1mm"))}),oBt=t=>{const A=SWA.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},NO=(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},nBt=t=>{const A=SWA.parse(t),e=A.h??oBt(A),i=[],o=[],n=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),c=`pin${g}`.length*.7/2;if(A.right){const Q=-((A.right-1)/2)*A.p;for(let E=0;E<A.right;E++){if(E===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=NO(A.w/2-A.pl*1.4,Q+E*A.p,"right")),i.push(Qi(E+1+A.left+(A.bottom??0),A.w/2-A.pl/2,Q+E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+1+A.left+(A.bottom??0),u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl-(c+A.silkscreenlabelmargin),y:Q+E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push(Pn(E+1+A.left+(A.bottom??0)+g,A.w/2,Q+E*A.p,r,a)),o.push(Pn(E+1+A.left+(A.bottom??0)+g*2,A.w/2-A.innerholeedgedistance,Q+E*A.p,r,a)))}}if(A.left){const Q=(A.left-1)/2*A.p;for(let E=0;E<A.left;E++){if(E===0&&!A.silkscreenlabels&&(s=NO(-A.w/2+A.pl*1.4,Q-E*A.p,"left")),i.push(Qi(E+1,-A.w/2+A.pl/2,Q-E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+1,u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl+(c+A.silkscreenlabelmargin),y:Q-E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push(Pn(E+1+g,-A.w/2,Q-E*A.p,r,a)),o.push(Pn(E+1+g*2,-A.w/2+A.innerholeedgedistance,Q-E*A.p,r,a)))}}if(A.top){const Q=(A.top-1)/2*A.p;for(let E=0;E<A.top;E++){if(E===0&&!A.left&&!A.bottom&&!A.right&&!A.silkscreenlabels&&(s=NO(Q-E*A.p,e/2-A.pl*1.4,"top")),i.push(Qi(E+1+A.left+A.right+(A.bottom??0),Q-E*A.p,e/2-A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+1+A.left+A.right+(A.bottom??0),u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q-E*A.p,y:e/2-A.pl-(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(o.push(Pn(E+1+A.left+A.right+(A.bottom??0)+g,Q-E*A.p,e/2,r,a)),o.push(Pn(E+1+A.left+A.right+(A.bottom??0)+g*2,Q-E*A.p,e/2-A.innerholeedgedistance,r,a)))}}if(A.bottom){const Q=-((A.bottom-1)/2)*A.p;for(let E=0;E<A.bottom;E++){if(E===0&&!A.left&&!A.silkscreenlabels&&(s=NO(Q+E*A.p,-e/2+A.pl*1.4,"bottom")),i.push(Qi(E+1+A.left,Q+E*A.p,-e/2+A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+1+A.left,u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q+E*A.p,y:-e/2+A.pl+(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(o.push(Pn(E+1+A.left+g,Q+E*A.p,-e/2,r,a)),o.push(Pn(E+1+A.left+g*2,Q+E*A.p,-e/2+A.innerholeedgedistance,r,a)))}}const B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},C={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"},l=Li(0,e/1.8,e/25);return{circuitJson:[...i,...o,...n,C,...A.silkscreenlabels?[]:[B],l],parameters:A}},bWA=Hi.extend({fn:H(),w:$A.default("22.58mm"),h:$A.optional(),left:$A.optional().default(20),right:$A.optional().default(20),top:$A.optional().default(2),bottom:$A.optional().default(2),p:$A.default($A.parse("2.54mm")),pw:$A.default($A.parse("1.6mm")),pl:$A.default($A.parse("3.2mm")),innerhole:ce().default(!1),innerholeedgedistance:$A.default($A.parse("1.61mm"))}),sBt=t=>{const A=bWA.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},rBt=(t,A,e,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:t+n,y:A},{x:t-n,y:A+s},{x:t-n,y:A-s},{x:t+n,y:A}],right:[{x:t-n,y:A},{x:t+n,y:A+s},{x:t+n,y:A-s},{x:t-n,y:A}],top:[{x:t,y:A-n},{x:t-s,y:A+n},{x:t+s,y:A+n},{x:t,y:A-n}],bottom:[{x:t,y:A+n},{x:t-s,y:A-n},{x:t+s,y:A-n},{x:t,y:A+n}]}[e]},aBt=t=>{const A=bWA.parse(t),e=A.h??sBt(A),i=[],o=[],n=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],I=1;if(A.left){const l=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++)Q===0&&(g=rBt(-A.w/2-A.pl/2,l-Q*A.p,"left")),i.push(Qi(I,-A.w/2+A.pl/2,l-Q*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:l-Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,-A.w/2+A.innerholeedgedistance,l-Q*A.p,s,r))}if(A.bottom){const l=(A.bottom-1)/2*A.p;for(let Q=A.bottom-1;Q>=0;Q--)i.push(Qi(I,l-Q*A.p,-e/2+A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:l-Q*A.p,y:-e/2+A.pl/2-3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,l-Q*A.p,-e/2+A.innerholeedgedistance,s,r))}if(A.right){const l=-((A.right-1)/2)*A.p;for(let Q=0;Q<A.right;Q++)i.push(Qi(I,A.w/2-A.pl/2,l+Q*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:l+Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,A.w/2-A.innerholeedgedistance,l+Q*A.p,s,r))}if(A.top){const l=-((A.top-1)/2)*A.p;for(let Q=A.top-1;Q>=0;Q--)i.push(Qi(I,l+Q*A.p,e/2-A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:l+Q*A.p,y:e/2-A.pl/2+3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,l+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"},C=Li(0,e/1.8,e/25);return{circuitJson:[...n,...i,...o,B,c,C],parameters:A}},gBt=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),R_(t)),xWA=Hi.extend({fn:H(),w:$A.default("10mm"),h:$A.optional(),left:$A.optional().default(20),right:$A.optional().default(20),top:$A.optional().default(0),bottom:$A.optional().default(0),p:$A.default($A.parse("2.54mm")),id:$A.optional().default($A.parse("1mm")),od:$A.optional().default($A.parse("1.5mm"))}),IBt=t=>{const A=xWA.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},_O=(t,A,e,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:t+n,y:A},{x:t-n,y:A+s},{x:t-n,y:A-s},{x:t+n,y:A}],right:[{x:t-n,y:A},{x:t+n,y:A+s},{x:t+n,y:A-s},{x:t-n,y:A}],top:[{x:t,y:A-n},{x:t-s,y:A+n},{x:t+s,y:A+n},{x:t,y:A-n}],bottom:[{x:t,y:A+n},{x:t-s,y:A-n},{x:t+s,y:A-n},{x:t,y:A+n}]}[e]},cBt=t=>{const A=xWA.parse(t),e=A.h??IBt(A),i=[],o=A.id,n=A.od;let s=[];if(A.right){const I=-((A.right-1)/2)*A.p;for(let c=0;c<A.right;c++)c===0&&!A.left&&!A.bottom&&(s=_O(A.w/2+n*1.4,I+c*A.p,"right")),i.push(Pn(c+1+A.left+(A.bottom??0),A.w/2,I+c*A.p,o,n))}if(A.left){const I=-((A.left-1)/2)*A.p;for(let c=0;c<A.left;c++)c===A.left-1&&(s=_O(-A.w/2-n*1.4,I+c*A.p,"left")),i.push(Pn(c+1,-A.w/2,I+c*A.p,o,n))}if(A.top){const I=-((A.top-1)/2)*A.p;for(let c=0;c<A.top;c++)c===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=_O(I+c*A.p,e/2+n*1.4,"top")),i.push(Pn(c+1+A.right+(A.bottom??0)+A.left,I+c*A.p,e/2,o,n))}if(A.bottom){const I=-((A.bottom-1)/2)*A.p;for(let c=0;c<A.bottom;c++)c===0&&!A.left&&(s=_O(I+c*A.p,-e/2-n*1.4,"bottom")),i.push(Pn(c+1+A.left,I+c*A.p,-e/2,o,n))}const r={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-n,y:e/2+n},{x:A.w/2+n,y:e/2+n},{x:A.w/2+n,y:-e/2-n},{x:-A.w/2-n,y:-e/2-n},{x:-A.w/2-n,y:e/2+n}],stroke_width:.1,layer:"top"},g=Li(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},kWA=(t,A,e,i)=>Array.from({length:25},(o,n)=>{const s=n/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*e,y:A+Math.sin(s)*e}}),BBt=Hi.extend({fn:H(),p:$A.optional().default("4.88mm"),id:$A.optional().default("0.8mm"),od:$A.optional().default("1.5mm"),w:$A.optional().default("5.6mm"),h:$A.optional().default("3.5mm")}),CBt=t=>{const A=BBt.parse(t),{p:e,id:i,od:o,w:n,h:s}=A,r=s/2,a=[Pn(1,-e/2,0,i,o),Pn(2,e/2,0,i,o)],g=kWA(-n/2,0,r,"left"),I=kWA(n/2,0,r,"right"),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...g,...g.slice(1).reverse(),{x:-n/2,y:-s/2},{x:n/2,y:-s/2},...I,{x:n/2,y:s/2},{x:-n/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},B=Li(0,e/4,.5);return{circuitJson:[...a,c,B],parameters:A}};Hi.extend({w:$A,h:$A});var lBt=t=>{const{w:A,h:e}=t,i=wr(A),o=wr(e);return{circuitJson:[Qi(1,0,0,i,o),Li(0,o/2+.5,.2)],parameters:t}},FU=(t,A,e,i,o,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:A,y:e,outer_width:wr(o),outer_height:wr(n),hole_width:wr(i),hole_height:wr(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),QBt=Hi.extend({fn:H(),num_pins:Ai([kA(3),kA(2)]).default(3),p:H().default("1.27mm"),id:H().default("0.72mm"),od:H().default("0.95mm"),w:H().default("4.5mm"),h:H().default("4.5mm"),inline:ce().default(!1),string:H().optional()}),EBt=(t,A,e)=>Array.from({length:25},(i,o)=>{const n=o/24*Math.PI;return{x:t+Math.cos(n)*e,y:A+Math.sin(n)*e}}),hBt=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=QBt.parse({...t,num_pins:e}),{p:o,id:n,od:s,w:r,h:a,inline:g}=i,I=Number.parseFloat(a)/2,c=Number.parseFloat(o),B=Number.parseFloat(n),C=Number.parseFloat(s),l=C,Q=C*(1.5/1.05);let E=[];if(i.num_pins===3)g?E=[oS(1,-c,I-c,B,C,Q,0,0),FU(2,0,I-c,B,l,Q),FU(3,c,I-c,B,l,Q)]:E=[oS(1,-c,I-c,B,C,C,0,0),Pn(2,0,I,B,C),Pn(3,c,I-c,B,C)];else if(i.num_pins===2)E=[oS(1,-c,I-c,B,l,Q,0,0),FU(2,c,I-c,B,l,Q)];else throw new Error("Invalid number of pins for TO-92");const h=Number.parseFloat(r)/2,u=EBt(0,I,h),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...u,{x:-h,y:0},{x:h,y:0},u[0]],stroke_width:.1,pcb_silkscreen_path_id:""},f=Li(0,I+1,.5);return{circuitJson:[...E,d,f],parameters:i}},uBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("2.15mm"),h:H().default("1.20mm"),pl:H().default("0.5mm"),pw:H().default("0.6mm"),p:H().default("1.4mm")}),dBt=t=>{const A=uBt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:fBt(A).concat(i,e),parameters:A}},pBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},fBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=pBt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},yBt=dm({}),wBt=t=>{const A=yBt.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=uBA({num_pins:A.num_pins,pn:s+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(Qi(s+1,r,a,A.pl??"1.5mm",A.pw??"0.6mm"))}const i=(A.num_pins/2-1)*A.p+A.pw,o=Li(0,i/2-.5,i/12),n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-A.w/3,y:i/2+.2},{x:A.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...e,o,n],parameters:A}},mBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("5.0mm"),h:H().default("2.30mm"),pl:H().default("1.25mm"),pw:H().default("2mm"),p:H().default("3.75mm")}),DBt=t=>{const A=mBt.parse(t),e=Li(0,$A.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2+.5,y:$A.parse(A.h)/2+.5},{x:-$A.parse(A.w)/2-.5,y:$A.parse(A.h)/2+.5},{x:-$A.parse(A.w)/2-.5,y:-$A.parse(A.h)/2-.5},{x:$A.parse(A.p)/2+.5,y:-$A.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bBt(A).concat(i,e),parameters:A}},SBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},bBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=SBt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},xBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("1.2mm"),pw:H().default("1.2mm"),p:H().default("2.9mm")}),kBt=t=>{const A=xBt.parse(t),e=Li(0,$A.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:FBt(A).concat(i,e),parameters:A}},GBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},FBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=GBt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},RBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.30mm"),h:H().default("1.80mm"),pl:H().default("0.60mm"),pw:H().default("0.45mm"),p:H().default("2.1mm")}),NBt=t=>{const A=RBt.parse(t),e=Li(0,$A.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:MBt(A).concat(i,e),parameters:A}},_Bt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},MBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=_Bt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},vBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.4mm"),h:H().default("0.9mm"),pl:H().default("0.36mm"),pw:H().default("0.25mm"),p:H().default("0.85mm")}),UBt=t=>{const A=vBt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2+.15,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.15,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.15,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2+.15,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:HBt(A).concat(i,e),parameters:A}},LBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},HBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=LBt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},YBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.3mm"),h:H().default("0.9mm"),pl:H().default("0.4mm"),pw:H().default("0.7mm"),p:H().default("0.7mm")}),JBt=t=>{const A=YBt.parse(t),e=Li(0,$A.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2+.2,y:$A.parse(A.h)/2+.2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2+.2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2-.2},{x:$A.parse(A.p)/2+.2,y:-$A.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:TBt(A).concat(i,e),parameters:A}},KBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},TBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=KBt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},qBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3,05mm"),h:H().default("1.65mm"),pl:H().default("0.6mm"),pw:H().default("0.6mm"),pad_spacing:H().default("2.2mm")}),PBt=t=>{const A=qBt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.pad_spacing)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.pad_spacing)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:WBt(A).concat(i,e),parameters:A}},OBt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},WBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=OBt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ZBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("1.2mm"),pw:H().default("1.2mm"),p:H().default("2.9mm")}),VBt=t=>{const A=ZBt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:zBt(A).concat(i,e),parameters:A}},jBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},zBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=jBt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},XBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("0.91mm"),pw:H().default("1.22mm"),p:H().default("3.146mm")}),$Bt=t=>{const A=XBt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eCt(A).concat(i,e),parameters:A}},ACt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=ACt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.80mm"),h:H().default("1.00mm"),pl:H().default("0.66mm"),pw:H().default("0.5mm"),p:H().default("0.8mm")}),iCt=t=>{const A=tCt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.1,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.1,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:nCt(A).concat(i,e),parameters:A}},oCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},nCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=oCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},sCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("6.2mm"),h:H().default("3.4mm"),pl:H().default("1.4mm"),pw:H().default("2.1mm"),p:H().default("4.4mm")}),rCt=t=>{const A=sCt.parse(t),e=Li(0,$A.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gCt(A).concat(i,e),parameters:A}},aCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},gCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=aCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ICt=Hi.extend({fn:H(),num_pins:Ai([kA(3),kA(5)]).default(3),w:H().default("4.20mm"),h:H().default("4.80mm"),pl:H().default("1.3mm"),pw:H().default("0.9mm"),p:H().default("1.5mm"),string:H().optional()}),cCt=t=>{const A=[],e=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),o=Number.parseFloat(t.w),n=Number.parseFloat(t.pl),s=.175,r=(n-(n+s))/2;A.push(Qi(1,-o/2+r,e,n,i),Qi(2,-o/2,0,n+s,i),Qi(3,-o/2+r,-e,n,i));const a=Li(0,0,.3),g=Number.parseFloat(t.w)/2-1,I=Number.parseFloat(t.h)/2,c={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-g,y:I},{x:g,y:I},{x:g,y:I/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},B={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-g,y:-I},{x:g,y:-I},{x:g,y:-I/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,c,B,a]},BCt=t=>{const A=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),A.push(Qi(1,-1.85,-1.5,1.5,.7),Qi(2,-1.85,1.5,1.5,.7),Qi(3,0,0,.8,2),Qi(4,1.85,-1.5,1.5,.7),Qi(5,1.85,1.5,1.5,.7));const e=Li(0,Number.parseFloat(t.h)/2+.5,.3),i=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i,y:o}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o},{x:i,y:-o}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},CCt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=ICt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:cCt(i),parameters:i};if(i.num_pins===5)return{circuitJson:BCt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},lCt=Hi.extend({fn:H(),p:$A.optional().default("5.0mm"),id:$A.optional().default("1.0mm"),od:$A.optional().default("1.9mm"),w:$A.optional().default("13mm"),h:$A.optional().default("7mm"),num_pins:ZA().optional(),string:H().optional()}),QCt=t=>{const A=lCt.parse(t),{fn:e,id:i,od:o,w:n,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,I=n/2,c=s/2,B=2.5,C=n*.4,l=Math.max(B,C/(a-1)),Q=Array.from({length:a},(D,b)=>{const m=a%2===0?(b-a/2+.5)*l:(b-Math.floor(a/2))*l;return Pn(b+1,m,g,i,o)}),E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:-c},{x:I,y:-c},{x:I,y:c},{x:-I,y:c},{x:-I,y:-c}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-c+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:h},{x:I,y:h}],stroke_width:.1,pcb_silkscreen_path_id:""},d=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/6,y:h},{x:-n/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:n/6,y:h},{x:n/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Li(0,s/2+.6,.5);return{circuitJson:[...Q,E,u,...d,f],parameters:{...A,p:l}}},ECt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("5.40mm"),h:H().default("2.30mm"),pl:H().default("1.30mm"),pw:H().default("1.70mm"),p:H().default("3.5mm")}),hCt=t=>{const A=ECt.parse(t),e=Li(0,$A.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:dCt(A).concat(i,e),parameters:A}},uCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},dCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=uCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},pCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.90mm"),h:H().default("1.33mm"),pl:H().default("0.5mm"),pw:H().default("0.7mm"),p:H().default("0.8mm")}),fCt=t=>{const A=pCt.parse(t),e=Li(0,$A.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2+.1,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2+.1,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:wCt(A).concat(i,e),parameters:A}},yCt=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:o}=yCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},mCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("7.0mm"),h:H().default("3.35mm"),pl:H().default("1.50mm"),pw:H().default("2.70mm"),p:H().default("4.8mm")}),DCt=t=>{const A=mCt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bCt(A).concat(i,e),parameters:A}},SCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},bCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=SCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},xCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.0mm"),h:H().default("1.80mm"),pl:H().default("0.80mm"),pw:H().default("1.20mm"),p:H().default("1.6mm")}),kCt=t=>{const A=xCt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.1,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.1,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:FCt(A).concat(i,e),parameters:A}},GCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},FCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=GCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},RCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("7.10mm"),h:H().default("3.40mm"),pl:H().default("2.45mm"),pw:H().default("1.80mm"),p:H().default("4.05mm")}),NCt=t=>{const A=RCt.parse(t),e=Li(0,$A.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.5,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.5,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:MCt(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}},MCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=_Ct({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},vCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.80mm"),h:H().default("2.10mm"),pl:H().default("1.30mm"),pw:H().default("1.40mm"),p:H().default("2.9mm")}),UCt=t=>{const A=vCt.parse(t),e=Li(0,$A.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:HCt(A).concat(i,e),parameters:A}},LCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},HCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=LCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},YCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("7.30mm"),h:H().default("4.40mm"),pl:H().default("2.50mm"),pw:H().default("2.30mm"),p:H().default("4.30mm")}),JCt=t=>{const A=YCt.parse(t),e=Li(0,$A.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.1,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.1,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:TCt(A).concat(i,e),parameters:A}},KCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},TCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=KCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},qCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("10.70mm"),h:H().default("6.60mm"),pl:H().default("3.30mm"),pw:H().default("2.50mm"),p:H().default("6.80mm")}),PCt=t=>{const A=qCt.parse(t),e=Li(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2-.8},{x:-$A.parse(A.w)/2-.8,y:$A.parse(A.h)/2-.8},{x:-$A.parse(A.w)/2-.8,y:-$A.parse(A.h)/2+.8},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:WCt(A).concat(i,e),parameters:A}},OCt=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:o}=OCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ZCt=Hi.extend({fn:H(),num_pins:ZA().default(4),w:H().default("8.50mm"),h:H().default("6.90mm"),pl:H().default("2mm"),pw:H().default("1.5mm"),p:H().default("2.30mm"),string:H().optional()}),VCt=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const o=XCt.parse({...t,num_pins:e});return{circuitJson:ux(o),parameters:o}}const i=ZCt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:zCt(i),parameters:i};if(i.num_pins===5)return{circuitJson:Alt(i),parameters:i};if(i.num_pins===6)return{circuitJson:tlt(i),parameters:i};throw new Error("Invalid number of pins")},jCt=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}},zCt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=jCt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),I=r===3?3.8:Number.parseFloat(t.pw);A.push(Qi(r+1,a,g,Number.parseFloat(t.pl),I))}const e=Li(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i,y:o},{x:i,y:o/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o},{x:i,y:-o},{x:i,y:-o/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},XCt=dm({p:"0.90mm",w:"2.8mm",legsoutside:!0}),$Ct=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")},Alt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=$Ct({h:Number.parseFloat(t.h),p:1.5,pn:r,w:Number.parseFloat(t.w)});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===5?(I=3.4,c=1.8):(I=1,c=2.2),A.push(Qi(r,a,g,c,I))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Li(0,0,.3);return[...A,o,n,s]},elt=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")},tlt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=elt({h:Number.parseFloat(t.h),p:1.3,pn:r,w:8.7});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===6?(I=3.4,c=2.15):(I=.6,c=2.2),A.push(Qi(r,a,g,c,I))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Li(0,0,.3);return[...A,o,n,s]},ilt=Hi.extend({fn:H(),num_pins:ZA().default(3),w:H().default("3.40mm"),h:H().default("3.30mm"),pl:H().default("1mm"),pw:H().default("0.7mm"),p:H().default("1.2mm"),string:H().optional()}),olt=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=ilt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:slt(i),parameters:i};throw new Error("Invalid number of pins")},nlt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},slt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=nlt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Li(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i+.3,y:o},{x:i+.3,y:o/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o},{x:i+.3,y:-o},{x:i+.3,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},rlt=Hi.extend({fn:H(),num_pins:Ai([kA(3),kA(2)]).default(3),p:H().default("1.27mm"),id:H().default("0.72mm"),od:H().default("0.95mm"),w:H().default("2.5mm"),h:H().default("4.2mm"),string:H().optional()}),alt=t=>{const{p:A,id:e,od:i,w:o,h:n}=t,s=Number.parseFloat(n)/2,r=Number.parseFloat(A);return[Pn(1,-r,s-r,e,i),Pn(2,0,s-r,e,i),Pn(3,r,s-r,e,i)]},glt=t=>{const{p:A,id:e,od:i,h:o}=t,n=Number.parseFloat(o)/2,s=Number.parseFloat(A);return[Pn(1,-s,n-s,e,i),Pn(2,s,n-s,e,i)]},Ilt=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=rlt.parse({...t,num_pins:e});let o=[];if(i.num_pins===3)o=alt(i);else if(i.num_pins===2)o=glt(i);else throw new Error("Invalid number of pins for TO-92");const n=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n,y:n-s},{x:-1.9,y:0},{x:1.9,y:0},{x:n,y:n-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-n,y:n-s}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Li(0,n+1,.5);return{circuitJson:[...o,r,a],parameters:i}},clt=Hi.extend({fn:H(),p:$A.optional(),id:$A.optional(),pw:$A.optional(),pl:$A.optional(),w:$A.optional(),h:$A.optional(),sh:Ai([ce(),H(),ZA()]).optional().transform(t=>{if(typeof t=="string"){const A=Number(t);return Number.isNaN(A)?!0:A}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:ce().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:H().optional()}),Blt={ph:{p:$A.parse("2.2mm"),id:$A.parse("0.70mm"),pw:$A.parse("1.20mm"),pl:$A.parse("1.20mm"),w:$A.parse("6mm"),h:$A.parse("5mm")},sh:{p:$A.parse("1mm"),pw:$A.parse("0.6mm"),pl:$A.parse("1.55mm"),w:$A.parse("5.8mm"),h:$A.parse("7.8mm")}};function Clt(t){return t.sh?"sh":(t.ph,"ph")}function llt(t,A,e,i,o,n){const s=[];if(t==="ph"){const r=e/2;s.push(oS(1,-r,2,i,o,n)),s.push(oS(2,r,2,i,o,n))}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const I=r+g*e;console.log("x si",I),s.push(Qi(g+1,I,-1.325,o,n))}const a=(A-1)/2*e+1.3;console.log("offset",a),s.push(Qi(A+1,-a,1.22,1.2,1.8)),s.push(Qi(A+2,a,1.22,1.2,1.8))}return s}function Qlt(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 Elt=t=>{const A=clt.parse(t),e=Clt(A),i=Blt[e],o=A.p??i.p,n=A.id??i.id,s=A.pw??i.pw,r=A.pl??i.pl,a=A.w??i.w,g=A.h??i.h;let I=e==="sh"?4:2;if(e==="sh"){const Q=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(Q&&Q[1]){const E=parseInt(Q[1],10);Number.isNaN(E)||(I=E)}else typeof A.sh=="number"&&(I=A.sh)}const c=llt(e,I,o,n,s,r),B=Qlt(e),C=Li(0,g/2+1,.5);return{circuitJson:[...c,B,C],parameters:{...A,p:o,id:n,pw:s,pl:r,w:a,h:g,num_pins:I,sh:e==="sh",ph:e==="ph"}}},hlt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.30mm"),h:H().default("1.70mm"),pl:H().default("0.80mm"),pw:H().default("1mm"),p:H().default("1.90mm")}),ult=t=>{const A=hlt.parse(t),e=Li(0,$A.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:plt(A).concat(i,e),parameters:A}},dlt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},plt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=dlt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},flt=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"}}},ylt=Hi.extend({fn:H(),num_pins:Ai([kA(8),kA(10)]).default(8),w:H().optional(),h:H().optional(),p:H().optional(),pl:H().optional(),pw:H().optional(),string:H().optional()}),wlt=t=>{const A=ylt.parse(t),e=flt(A.num_pins),i=$A.parse(A.w||e.w),o=$A.parse(A.h||e.h),n=$A.parse(A.p||e.p),s=$A.parse(A.pl||e.pl),r=$A.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}=GWA(A.num_pins,u+1,i,n),D=u<g?u+1:A.num_pins-(u-g);a.push(Qi(D,d,f,s,r))}const I=i,c=o,B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:c/2},{x:I/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C={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=GWA(A.num_pins,1,I,n),Q={x:l.x-.8,y:l.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=Li(0,c/2+.5,.3);return{circuitJson:[...a,B,C,h,E],parameters:A}},GWA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*$A.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},mlt=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"}}},Dlt=Hi.extend({fn:H(),num_pins:Ai([kA(8),kA(10),kA(12),kA(16)]).default(8),w:H().optional(),h:H().optional(),p:H().optional(),pl:H().optional(),pw:H().optional(),string:H().optional()}),FWA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*$A.parse("2mm"),y:r*i}},Slt=t=>{const A=Dlt.parse(t),e=mlt(A.num_pins),i=$A.parse(A.w||e.w),o=$A.parse(A.h||e.h),n=$A.parse(A.p||e.p),s=$A.parse(A.pl||e.pl),r=$A.parse(A.pw||e.pw),a=[];for(let h=0;h<A.num_pins;h++){const{x:u,y:d}=FWA(A.num_pins,h+1,i,n);a.push(Qi(h+1,u,d,s,r))}const g=i,I=o,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:I/2},{x:g/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-I/2},{x:g/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=FWA(A.num_pins,1,g,n),l={x:C.x-.8,y:C.y},Q={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"},E=Li(0,I/2+.5,.3);return{circuitJson:[...a,c,B,E,Q],parameters:A}},blt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.8mm"),h:H().default("1.65mm"),pl:H().default("1.2mm"),pw:H().default("1.2mm"),pad_spacing:H().default("2.6mm")}),xlt=t=>{const A=blt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.pad_spacing)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.pad_spacing)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Glt(A).concat(i,e),parameters:A}},klt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Glt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=klt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Flt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.20mm"),h:H().default("1.65mm"),pl:H().default("0.8mm"),pw:H().default("0.9mm"),pad_spacing:H().default("2.1mm")}),Rlt=t=>{const A=Flt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.pad_spacing)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.pad_spacing)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:_lt(A).concat(i,e),parameters:A}},Nlt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},_lt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Nlt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Mlt=Hi.extend({fn:H(),num_pins:Ai([kA(6),kA(8)]).default(8),w:H().default("3mm"),h:H().default("3mm"),p:H().default("0.5mm"),pl:H().default("0.52mm"),pw:H().default("0.35mm"),epw:H().default("1.40mm"),eph:H().default("1.60mm"),string:H().optional(),ep:ce().default(!1)}),vlt=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=Mlt.parse({...t,num_pins:e}),o=$A.parse(i.w),n=$A.parse(i.h),s=$A.parse(i.p),r=$A.parse(i.pl),a=$A.parse(i.pw),g=$A.parse(i.epw),I=$A.parse(i.eph),c=[];for(let f=0;f<i.num_pins;f++){const{x:D,y:b}=RWA(i.num_pins,f+1,o,s);c.push(Qi(f+1,D,b,r,a))}i.ep&&c.push(Qi(i.num_pins+1,0,0,g,I));const B=o,C=n,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:C/2},{x:B/2,y:C/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:-C/2},{x:B/2,y:-C/2}],stroke_width:.05,pcb_silkscreen_path_id:""},E=RWA(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=Li(0,C/2+.5,.3);return{circuitJson:[...c,l,Q,d,u],parameters:i}},RWA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*$A.parse("1.4mm"),y:r*i}},Ult=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:o=1.5,ph:n=1.5}=t,s=$A.parse(i),r=$A.parse(o),a=$A.parse(n),g=Math.min(a/4,.5),I=[];for(let f=0;f<A;f++)I.push(Qi(f+1,f*s,0,r,a));let c=[];if(e){const f=e.split("").map(Number);if(f.length>1)for(let D=0;D<f.length-1;D++){const b=f[D],m=f[D+1];if(typeof b=="number"&&typeof m=="number"&&!isNaN(b)&&!isNaN(m)){const x=(b-1)*s,F=(m-1)*s,k=Math.sign(F-x),v=x+k*(r/2),_=F-k*(r/2);c.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${b}}`,x:v,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${m}}`,x:_,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const B=(A-1)*s+r+.7,C=a+1,l=(A-1)*s/2,Q=0,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:l-B/2,y:Q-C/2},{x:l+B/2,y:Q-C/2},{x:l+B/2,y:Q+C/2},{x:l-B/2,y:Q+C/2},{x:l-B/2,y:Q-C/2}],stroke_width:.15},u=Q+C/2+.6,d=Li(l,u,.4);return{circuitJson:[...I,...c,E,d],parameters:t}},NWA={fn:kA("sot457"),num_pins:kA(6).default(6),pillh:H().default("0.45mm"),pillw:H().default("1.45mm"),pl:H(),pw:H(),p:H(),wave:ce().optional(),reflow:ce().optional()},Llt=Hi.extend({...NWA,h:H().default("2.5mm"),w:H().default("2.7mm"),pl:H().default("0.8mm"),pw:H().default("0.55mm"),p:H().default("0.95mm")}),Hlt=Hi.extend({...NWA,h:H().default("3mm"),w:H().default("4mm"),pillr:H().default("0.225mm"),pl:H().default("1.45mm"),pw:H().default("1.5mm"),p:H().default("1.475mm")}).transform(t=>({...t,wave:t.wave??(t.reflow===void 0?!0:!t.reflow),reflow:t.reflow??(t.wave===void 0?!1:!t.wave)})),nS=t=>Number.parseFloat(t.replace("mm","")),_WA=({pitch:t,width:A,pinNumber:e})=>{const n={1:{x:-A/2-.1,y:t},2:{x:-A/2-.1,y:0},3:{x:-A/2-.1,y:-t},4:{x:A/2+.1,y:-t},5:{x:A/2+.1,y:0},6:{x:A/2+.1,y:t}}[e];if(!n)throw new Error(`Invalid pin number: ${e}`);return n},MWA=t=>{const A=[],e=nS(t.p),i=nS(t.pl),o=nS(t.pw),n=nS(t.w),s=nS(t.h);if(t.wave){const l={1:({padWidth:Q,padHeight:E})=>Qi(1,-e,e,E,Q),2:({padWidth:Q,padHeight:E})=>Qi(2,-e,-e,E,Q),3:({padWidth:Q,padHeight:E})=>FO(3,-e,0,nS(t.pillw),nS(t.pillh)),4:({padWidth:Q,padHeight:E})=>FO(4,e,0,nS(t.pillw),nS(t.pillh)),5:({padWidth:Q,padHeight:E})=>Qi(5,e,e,E,Q),6:({padWidth:Q,padHeight:E})=>Qi(6,e,-e,E,Q)};for(let Q=1;Q<=t.num_pins;Q++){const E=l[Q];E&&A.push(E({padWidth:i,padHeight:o}))}}else for(let l=1;l<=t.num_pins;l++){const{x:Q,y:E}=_WA({pitch:e,width:n,pinNumber:l});A.push(Qi(l,Q,E,i,o))}const r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:s/2+e/1.3},{x:n/3,y:s/2+e/1.3}],stroke_width:.05},a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-s/2-e/1.3},{x:n/3,y:-s/2-e/1.3}],stroke_width:.05},g=Li(0,s+.5,.3),I=_WA({pitch:e,width:n,pinNumber:1}),c=t.wave?1:.5,B=t.wave?.7:.3;I.x-=t.wave?o:o*1.7;const C={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,C,...A]},Ylt=t=>{if(t.wave){const e=Hlt.parse({...t,fn:"sot457"});return{circuitJson:MWA(e),parameters:e}}const A=Llt.parse(t);return{circuitJson:MWA(A),parameters:A}},Jlt=Hi.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("1.1mm"),h:H().default("1.45mm"),p:H().default("0.35mm"),pl:H().default("0.2mm"),pw:H().default("0.2mm"),string:H().optional()}),Klt=t=>{const A=Jlt.parse({...t,fn:"sot963"}),e=$A.parse(A.w),i=$A.parse(A.h),o=$A.parse(A.p),n=$A.parse(A.pl),s=$A.parse(A.pw),r=[];for(let C=0;C<6;C++){const{x:l,y:Q}=vWA(C+1,e,o,n);r.push(Qi(C+1,l,Q,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=vWA(1,e,o,n),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-n/2-.3,y:I.y},{x:I.x-n/2-.45,y:I.y+.15},{x:I.x-n/2-.45,y:I.y-.15},{x:I.x-n/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},B=Li(0,i/2+.4,.25);return{circuitJson:[...r,a,g,B,c],parameters:A}},vWA=(t,A,e,i)=>{const o=A/2-i/2;return t<=3?{x:-o,y:e-(t-1)*e}:{x:o,y:-e+(t-4)*e}},Tlt=Hi.extend({fn:H(),num_pins:Ai([kA(3),kA(2)]).default(3),p:H().default("3.8mm"),id:H().default("1.25mm"),od:H().default("2.35mm"),ca:H().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:H().default("5.35mm"),h:H().default("4mm"),string:H().optional()}),qlt=t=>{const{p:A,id:e,od:i,h:o,ca:n}=t,s=Number.parseFloat(o),r=Number.parseFloat(n);return[Pn(1,0,r/4+.3,e,i),Pn(2,s,0,e,i),Pn(3,0,-r/4-.3,e,i)]},Plt=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=Tlt.parse({...t,num_pins:e});let o=[];i.num_pins===3&&(o=qlt(i));const n=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),r=Number.parseFloat(i.od)/2+.35,a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:n-1.75},{x:0,y:n},{x:s,y:n},{x:s,y:r}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-r},{x:s,y:-n},{x:0,y:-n},{x:0,y:-n+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},I=Number.parseFloat(i.w)/2,c=Li(I,n+1,.5);return{circuitJson:[...o,a,g,c],parameters:i}},Olt=Hi.extend({fn:H(),p:$A.optional().default("7.5mm"),id:$A.optional().default("1mm"),od:$A.optional().default("2mm"),d:$A.optional().default("10.5mm")}),Wlt=(t,A,e,i,o)=>{const n=[],s=[];for(let r=0;r<=50;r++){const a=r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-o/2&&I<=A+o/2||n.push({x:g,y:I})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-o/2&&I<=A+o/2||s.push({x:g,y:I})}return{topArc:n,bottomArc:s}},Zlt=t=>{const A=Olt.parse(t),{p:e,id:i,od:o,d:n}=A,s=[Pn(1,-e/2,0,i,o),Pn(2,e/2,0,i,o)],{topArc:r,bottomArc:a}=Wlt(0,0,n/2+.1,o/2,o),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:.1,pcb_silkscreen_path_id:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:n/2+.1},{x:0,y:-(n/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},B=-(n/2+.5),C=o/2+1.5,l=.5,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B-l,y:C},{x:B+l,y:C}],stroke_width:.1,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B,y:C-l},{x:B,y:C+l}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Li(0,n/2+1,.5);return{circuitJson:[...s,g,I,c,Q,E,h],parameters:A}},Vlt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("6.5mm"),h:H().default("3mm"),pl:H().default("1.75mm"),pw:H().default("2.40mm"),p:H().default("4.75mm")}),jlt=t=>{const A=Vlt.parse(t),e=Li(0,$A.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.3,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.3,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Xlt(A).concat(i,e),parameters:A}},zlt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Xlt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=zlt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},$lt=Hi.extend({fn:H(),num_pins:ZA().default(3),w:H().default("2.45mm"),h:H().default("2.40mm"),pl:H().default("1.225mm"),pw:H().default("0.5mm"),p:H().default("0.95mm"),string:H().optional()}),AQt=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=$lt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:tQt(i),parameters:i};throw new Error("Invalid number of pins")},eQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},tQt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=eQt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Li(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o+.3},{x:i,y:o+.3},{x:i,y:o/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o-.3},{x:i,y:-o-.3},{x:i,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},iQt=Hi.extend({fn:H(),circle:ce().optional(),rect:ce().optional(),square:ce().optional(),pill:ce().optional(),d:$A.optional(),pd:$A.optional(),diameter:$A.optional(),r:$A.optional(),pr:$A.optional(),radius:$A.optional(),w:$A.optional(),pw:$A.optional(),width:$A.optional(),h:$A.optional(),ph:$A.optional(),height:$A.optional(),s:$A.optional(),size:$A.optional(),string:H().optional()}).transform(t=>{let A="rect";t.circle&&(A="circle"),t.square&&(A="square"),t.rect&&(A="rect"),t.pill&&(A="pill");let e,i,o;return A==="circle"?t.r!==void 0?e=wr(t.r):t.pr!==void 0?e=wr(t.pr):t.radius!==void 0?e=wr(t.radius):t.d!==void 0?e=wr(t.d)/2:t.pd!==void 0?e=wr(t.pd)/2:t.diameter!==void 0?e=wr(t.diameter)/2:e=wr("1mm")/2:(t.w!==void 0?i=wr(t.w):t.pw!==void 0?i=wr(t.pw):t.width!==void 0?i=wr(t.width):t.s!==void 0?i=wr(t.s):t.size!==void 0?i=wr(t.size):i=wr("1mm"),t.h!==void 0?o=wr(t.h):t.ph!==void 0?o=wr(t.ph):t.height!==void 0?o=wr(t.height):A==="square"||A==="rect"?o=i:o=wr("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:o}}),oQt=t=>{const A=iQt.parse(t),{shape:e,radius:i,width:o,height:n}=A;let s,r;return e==="circle"?(s=EWA(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=FO(1,0,0,o,n),r=Math.max(o,n)/2+.5):(s=Qi(1,0,0,o,n),r=n/2+.5),{circuitJson:[s,Li(0,r,.2)],parameters:A}},nQt=Hi.extend({fn:H(),d:$A.optional(),hd:$A.optional(),r:$A.optional(),hr:$A.optional(),pd:$A.optional(),pr:$A.optional(),squarepad:ce().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=wr(t.d):t.hd!==void 0?A=wr(t.hd):t.r!==void 0?A=wr(t.r)*2:t.hr!==void 0?A=wr(t.hr)*2:A=wr("1mm");let e;return t.pd!==void 0?e=wr(t.pd):t.pr!==void 0?e=wr(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),sQt=t=>{const A=nQt.parse(t),{d:e,pd:i,squarepad:o}=A;return{circuitJson:[o?oS(1,0,0,e,i,i):Pn(1,0,0,e,i),Li(0,i/2+.5,.2)],parameters:A}},rQt=Hi.extend({fn:H(),num_pins:kA(6).default(6),h:H().default("1.6mm"),pl:H().default("1mm"),pw:H().default("0.7mm"),p:H().default("0.95mm")}),aQt=t=>{const A=rQt.parse(t);return{circuitJson:gQt(A),parameters:A}},UWA=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")},gQt=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:C}=UWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(Qi(c,B,C,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Li(0,i+.3,.3),r=UWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,o,n,I]},IQt=Hi.extend({fn:H(),num_pins:ZA().default(4),w:H().default("3.2mm"),h:H().default("2.6mm"),pl:H().default("1.35mm"),pw:H().default("0.50mm"),p:H().default("0.6mm"),string:H().optional()}),cQt=t=>{const A=t.string?.match(/^sot343_(\d+)/),e=A?Number.parseInt(A[1],4):4,i=IQt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:CQt(i),parameters:i};throw new Error("Invalid number of pins")},BQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e*1.92,y:-.65}:A===2?{x:-e*1.92,y:.65}:A===3?{x:e,y:.65}:A===4?{x:e,y:-.65}:{x:0,y:0}},CQt=t=>{const A=[],e=Number.parseFloat(t.w),i=Number.parseFloat(t.h),o=Number.parseFloat(t.pl),n=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let r=1/0,a=-1/0,g=1/0,I=-1/0;for(let d=0;d<t.num_pins;d++){const{x:f,y:D}=BQt({num_pins:t.num_pins,pn:d+1,p:s});A.push(Qi(d+1,f,D,o,n)),f<r&&(r=f),f>a&&(a=f),D<g&&(g=D),D>I&&(I=D)}const c=(r+a)/2,B=I-g,C=i*.3,l=B/2+C;let Q=e*.8;i<=2.6&&(Q/=2);const E=Li(c,l+.5,.3),h={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:c-Q/2,y:l},{x:c+Q/2,y:l}],type:"pcb_silkscreen_path",stroke_width:.1},u={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_bottom",route:[{x:c-Q/2,y:-l},{x:c+Q/2,y:-l}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,h,u,E]},lQt=Hi.extend({fn:H()}),QQt=t=>{const A=lQt.parse(t),e=[],i=.5-.15,o=1.5,s=.5/2,r=75,a=-37/2;for(let m=0;m<r;m++){const x=m+1;if(x>=24&&x<=31)continue;const F=a-m*s,k=x%2===0,v=o+(k?.25:0),Y=.5-v/2,P=Qi(x,Y,F,v,i);P.layer=k?"bottom":"top",e.push(P)}const g=46*.0254,I=137*.0254,c=261*.0254,B={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-I/2+o/2,y:a-c},width:I,height:g},C={x:-.5,y:a},l={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"};let Q=1/0,E=-1/0,h=1/0,u=-1/0;const d=(m,x,F=0,k=0)=>{Q=Math.min(Q,m-F/2),E=Math.max(E,m+F/2),h=Math.min(h,x-k/2),u=Math.max(u,x+k/2)};for(const m of e)d(m.x,m.y,m.width,m.height);d(B.center.x,B.center.y,B.width,B.height);for(const m of l.route)d(m.x,m.y);const f=(Q+E)/2,D=(h+u)/2,b=m=>{typeof m.x=="number"&&(m.x-=f),typeof m.y=="number"&&(m.y-=D),m.center&&(m.center.x-=f,m.center.y-=D),Array.isArray(m.route)&&(m.route=m.route.map(x=>({x:x.x-f,y:x.y-D})))};for(const m of e)b(m);return b(B),b(l),{circuitJson:[...e,B,l],parameters:A}},EQt=Hi.extend({fn:H(),num_pins:ZA().default(3),inline:ce().default(!1),p:H().default("1.27mm"),id:H().default("0.75mm"),od:H().default("1.3mm"),w:H().default("4.8mm"),h:H().default("4.0mm")}),hQt=t=>{const A=EQt.parse(t),e=Number.parseFloat(A.p),i=Number.parseFloat(A.w),o=Number.parseFloat(A.h),n=A.inline?1.05:Number.parseFloat(A.od),s=A.inline?1.5:n,r=[oS(1,0,0,A.id,n,s,0,0),A.inline?FU(2,e,0,A.id,n,s):Pn(2,e,e,A.id,n),A.inline?FU(3,e*2,0,A.id,n,s):Pn(3,e*2,0,A.id,n)],a=i/2,g=A.inline?e-.09:e,I=.2,c=I+a-o,B=Array.from({length:32},(Q,E)=>{const h=Math.PI*E/31;return{x:g+a*Math.cos(h),y:I+a*Math.sin(h)}}),C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",stroke_width:.12,route:[...B,{x:g-a,y:c},{x:g+a,y:c},B[0]]},l=Li(g,I+a+1,.5);return{circuitJson:[...r,C,l],parameters:A}};function uQt(t){return t!=null}var dQt=(t,A)=>{if(!A)return t;const e=t.filter(I=>I.type==="pcb_smtpad"||I.type==="pcb_plated_hole"||I.type==="pcb_thtpad");if(e.length===0)return t;let i=1/0,o=-1/0,n=1/0,s=-1/0;const r=(I,c,B=0,C=0)=>{const l=I-B/2,Q=I+B/2,E=c-C/2,h=c+C/2;i=Math.min(i,l),o=Math.max(o,Q),n=Math.min(n,E),s=Math.max(s,h)};for(const I of e)if(I.type==="pcb_smtpad"){const c=I.shape==="circle"?I.radius*2:I.width,B=I.shape==="circle"?I.radius*2:I.height;r(I.x,I.y,c,B)}else if(I.type==="pcb_plated_hole"){const c=I.outer_diameter??I.hole_diameter;r(I.x,I.y,c,c)}else if(I.type==="pcb_thtpad"){const c=I.diameter;r(I.x,I.y,c,c)}let a=0,g=0;switch(A){case"center":a=(i+o)/2,g=(n+s)/2;break;case"bottomleft":a=i,g=n;break;case"bottomcenter":case"centerbottom":a=(i+o)/2,g=n;break;case"topcenter":case"centertop":a=(i+o)/2,g=s;break;case"leftcenter":case"centerleft":a=i,g=(n+s)/2;break;case"rightcenter":case"centerright":a=o,g=(n+s)/2;break;case"pin1":const I=e.find(c=>c.port_hints?.[0]==="1")||e[0];a=I.x,g=I.y;break}if(a===0&&g===0)return t;for(const I of t){if(typeof I.x=="number"&&(I.x-=a),typeof I.y=="number"&&(I.y-=g),I.center&&typeof I.center.x=="number"&&(I.center.x-=a,I.center.y-=g),I.type==="pcb_silkscreen_path")for(const c of I.route)c.x-=a,c.y-=g;I.type==="pcb_silkscreen_text"&&I.anchor_position&&(I.anchor_position.x-=a,I.anchor_position.y-=g)}return t},pQt=(t,A)=>{const e=t.filter(i=>i.type==="pcb_silkscreen_text");if(e.length===0)return t;for(const i of e)A.norefdes&&(i.text="");return t},fQt=(t,A)=>A.nosilkscreen?t.filter(e=>e.type!=="pcb_silkscreen_path"&&e.type!=="pcb_silkscreen_text"):t,yQt=t=>{let A=MO();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(o=>{const n=o.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!n)return null;const[,s,r]=n;if(!s)return null;const a=s.toLowerCase();return r?.includes("?")?null:{fn:a,v:r}}).filter(uQt);for(const{fn:o,v:n}of i)A=A[o](n);return A.setString(t),A},wQt=()=>Object.keys(iS),MO=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&iS[A.fn])return()=>{const{circuitJson:i}=iS[A.fn](A),o=fQt(i,A),n=pQt(o,A);return dQt(n,A.origin)};if(!iS[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(!iS[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>iS[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(iS):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in iS?(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};MO.string=yQt,MO.getFootprintNames=wQt;var mQt=MO,LWA=Symbol("Fragment");function yBA(t,A,...e){const i=e.length?e:A?.children!==void 0?[A.children]:[],o=[],n=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of n)s==null||s===!1||(Array.isArray(s)?o.push(...s):o.push(s));return{type:t,props:(A&&A.children!==void 0?{...A,children:void 0}:A)||{},children:o}}var ht=Symbol("Cuboid"),HWA=Symbol("Cube"),Jp=Symbol("Cylinder"),YWA=Symbol("Sphere"),RU=Symbol("RoundedCuboid"),Vi=Symbol("Translate"),QQ=Symbol("Rotate"),aE=Symbol("Union"),JG=Symbol("Subtract"),sI=Symbol("Hull"),ys=Symbol("Colorize"),NU=Symbol("Polygon"),_U=Symbol("ExtrudeLinear"),Kp=Symbol("RoundedCylinder"),Yo=LWA,Ae=(t,A,e)=>yBA(t,A),Ot=(t,A,e)=>yBA(t,A),VB=({center:t,width:A,length:e,height:i,heightAboveSurface:o=.15,color:n="#555",taperRatio:s=.12,faceRatio:r=.75,straightHeightRatio:a=.5,includeNotch:g=!0,notchRadius:I,notchPosition:c,notchRotation:B=[0,0,0],notchLength:C=.5,notchWidth:l=.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),D=Math.min(A,e)*.12,b=I??D,m={x:0,y:e/2-b*.25,z:i},x=c??m,F=Ot(aE,{children:[Ot(sI,{children:[Ae(Vi,{z:.005,children:Ae(ht,{size:[d,f,.01]})}),Ae(Vi,{z:E,children:Ae(ht,{size:[A,e,.01]})})]}),Ot(sI,{children:[Ae(Vi,{z:E,children:Ae(ht,{size:[A,e,.01]})}),Ae(Vi,{z:E+h,children:Ae(ht,{size:[d,f,.01]})})]})]}),k=(_,Y)=>Ae(Vi,{offset:{x:_,y:Y,z:0},children:Ae(QQ,{rotation:[0,0,Math.PI/4],children:Ae(ht,{size:[Q*Math.SQRT2,Q*Math.SQRT2,i*3]})})});let v=F;if(Q>0){const _=A/2,Y=e/2;v=Ot(JG,{children:[F,k(_,Y),k(-_,Y),k(_,-Y),k(-_,-Y)]})}return Ae(ys,{color:n,children:Ae(Vi,{offset:t,children:Ae(Vi,{offset:{x:0,y:0,z:o},children:g?Ot(JG,{children:[v,Ae(Vi,{offset:x,children:Ae(QQ,{rotation:B,children:Ae(Jp,{radius:b,height:l})})})]}):v})})})},DQt=t=>Array.from({length:t},(A,e)=>e);function wBA(t,A){if(t.length<2)throw new Error("Stroke must have at least two points");const e=Array.isArray(t[0])?t.map(([I,c])=>({x:I,y:c})):t,i=A/2,o=[],n=[];function s(I,c){const B=c.x-I.x,C=c.y-I.y,l=Math.sqrt(B*B+C*C);return{x:-C/l,y:B/l}}function r(I,c,B){const C={x:I.x+c.x*i*B,y:I.y+c.y*i*B};B>0?o.push(C):n.unshift(C)}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],C=e[I+1],l=s(c,B),Q=s(B,C),E=l.x+Q.x,h=l.y+Q.y,u=Math.sqrt(E*E+h*h);if(u/2>2*i)r(B,l,1),r(B,Q,1),r(B,l,-1),r(B,Q,-1);else{const f=1/u;r(B,{x:E*f,y:h*f},1),r(B,{x:E*f,y:h*f},-1)}}const g=s(e[e.length-2],e[e.length-1]);return r(e[e.length-1],g,1),r(e[e.length-1],g,-1),[...o,...n]}var SQt=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}))},bQt=SQt([{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}]),JWA=5.47,vO=.5,xQt=({x:t,y:A,z:e})=>{const i=t>0;return Ot(Yo,{children:[Ae(Vi,{offset:{x:t+.25/2,y:A,z:e},children:Ae(QQ,{rotation:["-90deg",0,"90deg"],children:Ae(_U,{height:.25,children:Ae(NU,{points:bQt.slice().reverse().map(o=>[o.x,o.y])})})})}),Ae(Vi,{offset:{x:t,y:A+(i?1:-1),z:e},children:Ae(QQ,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:Ae(_U,{height:2,children:Ae(NU,{points:wBA([[0,0],[-1,0],[-1,-1]],.25).map(o=>[o.x,o.y])})})})})]})},kQt=({numPins:t=8,pitch:A=2.54,bodyWidth:e=6.4,rowSpacing:i})=>{const o=Math.floor(t/2),n=i??(e>=7?e:e+1.22),s=e>=7?n-1.22:e;return Ot(Yo,{children:[DQt(t).map(r=>{const a=r%o,g=(Math.floor(r/o)-.5)*2;return Ae(xQt,{x:g*n/2,y:a*A-(o-1)/2*A,z:JWA/2+vO})}),Ae(VB,{width:s,length:o*A+.5,height:JWA-vO,heightAboveSurface:vO,center:{x:0,y:0,z:vO}})]})};function GQt(t,{height:A,padContactLength:e,curveLength:i,bodyDistance:o,steepness:n=10}){i||(i=o*.3);let s=o-e-i;s<0&&(i+=s,s=0);const r=e*.75,a=e+i+(o-e-i)*.25;if(t<=r)return 0;if(t>=a)return A;const g=(t-r)/(a-r);return A/(1+Math.exp(-n*(g-.5)))}var To=t=>{const{thickness:A,width:e,padContactLength:i,bodyDistance:o,height:n,rotation:s}=t,r=15,a=Array.from({length:r}).map((I,c)=>c/(r-1)*o).map(I=>[I,GQt(I,t)]),g=wBA(a,A);return Ae(ys,{color:"#fff",children:Ae(Vi,{offset:{z:0,y:0,x:0,...t.position},children:Ae(QQ,{rotation:["90deg",0,s??0],children:Ae(Vi,{offset:{x:0,y:0,z:-e/2},children:Ae(_U,{height:e,children:Ae(NU,{points:g.map(I=>[I.x,I.y])})})})})})})},FQt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:o})=>{const n=Math.ceil(t/2),s=i*t/2+e/2,r=(n-1)*i/2,a=.25;return Ot(Yo,{children:[Array.from({length:n}).map((g,I)=>Ae(To,{position:{x:-o/2-A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:n}).map((g,I)=>Ae(To,{rotation:Math.PI,position:{x:o/2+A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Ae(VB,{center:{x:0,y:0,z:a/2},width:o-e-1,length:s,height:1.5})]})},RQt=({pinCount:t,padContactLength:A=.4,leadWidth:e=.2,pitch:i=.65,bodyWidth:o=3})=>{const n=Math.ceil(t/2),s=(n-1)*i/2,r=.2;return Ot(Yo,{children:[Array.from({length:n}).map((a,g)=>Ae(To,{position:{x:-o/2-A-.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Array.from({length:n}).map((a,g)=>Ae(To,{rotation:Math.PI,position:{x:o/2+A+.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Ae(VB,{center:{x:0,y:0,z:r/2},width:o,length:o,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},mBA=1,DBA=.5,N_=.5,MU=.2,NQt=mBA-MU*2,KWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[NQt,DBA,N_],offset:[0,0,N_/2],color:t}),Ae(ht,{size:[MU,N_,DBA],offset:[mBA/2-MU/2,0,N_/2],color:"#ccc"}),Ae(ht,{size:[MU,N_,DBA],offset:[-mBA/2+MU/2,0,N_/2],color:"#ccc"})]}),SBA=1.6,_Qt=SBA-.3*2,UO=.3,bBA=.85,__=.6,TWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[_Qt,bBA,__],offset:[0,0,__/2],color:t}),Ae(ht,{size:[UO,bBA,__],offset:[SBA/2-UO/2,0,__/2],color:"#ccc"}),Ae(ht,{size:[UO,bBA,__],offset:[-SBA/2+UO/2,0,__/2],color:"#ccc"})]}),xBA=2,kBA=1.25,M_=.55,vU=.5,MQt=xBA-vU*2,qWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[MQt,kBA,M_],offset:[0,0,M_/2],color:t}),Ae(ht,{size:[vU,kBA,M_],offset:[xBA/2-vU/2,0,M_/2],color:"#ccc"}),Ae(ht,{size:[vU,kBA,M_],offset:[-xBA/2+vU/2,0,M_/2],color:"#ccc"})]}),vQt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:o})=>{const n=t/4;A||(A=UQt(t,o)),i||(i=LQt(t)),e||(e=HQt(t,o)),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+2*i,g=a,I=.8,c=.15,B=(g-o)/2+.5;return Ot(Yo,{children:[Array.from({length:n}).map((C,l)=>Ae(To,{position:{x:-g/2-.4,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:Math.PI,position:{x:g/2+.4,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:Math.PI/2,position:{x:l*A-r,y:-a/2-.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:-Math.PI/2,position:{x:l*A-r,y:a/2+.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Ae(VB,{center:{x:0,y:0,z:0},width:o,length:s,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:o/2-1.5,z:1.5},notchRadius:1.5/2})]})},UQt=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},LQt=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}},HQt=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},YQt=({numberOfPins:t,pitch:A=2.54,longSidePinLength:e=6,invert:i,faceup:o,rows:n=1})=>{const a=Math.ceil(t/n),g=2.54,I=a*A,c=n>1?(n-1)*g+.63*3:.63*3,B=3,C=-((a-1)/2)*A,l=n>1?-((n-1)*g)/2:0,Q=E=>i||o?-E+2:E;return Ot(Yo,{children:[Ae(ht,{color:"#222",size:[I,c,2],center:[0,l,Q(2/2)]}),Array.from({length:t},(E,h)=>{const u=Math.floor(h/a),d=h%a,f=C+d*A,D=-u*g;return Ot(Yo,{children:[!o&&Ae(ys,{color:"gold",children:Ot(sI,{children:[Ae(ht,{color:"gold",size:[.63,.63,B*.9],center:[f,D,Q(2*.9+2/2)]}),Ae(ht,{color:"gold",size:[.63/1.8,.63/1.8,B],center:[f,D,Q(2+2/2)]})]})}),Ae(ys,{color:"gold",children:Ot(sI,{children:[Ae(ht,{color:"gold",size:[.63,.63,e*.9],center:[f,D,Q(-e/2*.9)]}),Ae(ht,{color:"gold",size:[.63/1.8,.63/1.8,e],center:[f,D,Q(-e/2)]})]})})]})})]})},JQt=t=>{const A=["left","bottom","right","top"],{pin_count:e,pn:i,w:o,h:n,p:s,pl:r}=t,a=e/4,g=A[Math.floor((i-1)/a)],I=(i-1)%a,c=s*(a-1),B=s*(a-1),C=-r/2;switch(g){case"left":return{x:-o/2-C,y:B/2-I*s,o:"vert"};case"bottom":return{x:-c/2+I*s,y:-n/2-C,o:"horz"};case"right":return{x:o/2+C,y:-B/2+I*s,o:"vert"};case"top":return{x:c/2-I*s,y:n/2+C,o:"horz"};default:throw new Error("Invalid pin number")}},KQt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const o=[],n=t/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=n:r.bottomside&&r.leftpin?s=n+1:r.bottomside&&r.rightpin?s=n*2:r.rightside&&r.bottompin?s=n*2+1:r.rightside&&r.toppin?s=n*3:r.topside&&r.rightpin?s=n*3+1:r.topside&&r.leftpin&&(s=n*4),o.push(-1);for(let a=0;a<t;a++)o[s]=a+1,s++,s>t&&(s=1);return o},TQt=({num_pins:t=16,bodyWidth:A=9,bodyLength:e=9,bodyThickness:i=.8,thermalPadSize:o,padWidth:n=.25,padLength:s=.25,pitch:r=.5,thermalPadThickness:a=.05})=>{const g=KQt({num_pins:t,cw:!0,ccw:!0}),I=[];for(let c=0;c<t;c++){const{x:B,y:C,o:l}=JQt({pin_count:t,pn:c+1,w:A,h:e,p:r,pl:s});let Q=n,E=s;l==="vert"&&([Q,E]=[E,Q]);const h=g[c+1];I.push({pn:h,x:B,y:C,pw:Q,pl:E})}return Ot(Yo,{children:[Ae(ys,{color:"grey",children:Ae(ht,{center:{x:0,y:0,z:i/2},size:[A,e,i]})}),I.map((c,B)=>Ae(ht,{center:{x:c.x,y:c.y,z:a/2},size:[c.pw,c.pl,a]})),o?.length!==void 0&&o?.width!==void 0&&Ae(ht,{center:{x:0,y:0,z:a/2},size:[o.width,o.length,a]})]})},qQt=TQt,PQt=()=>{const a=1.1999999999999997;return Ot(Yo,{children:[Ae(To,{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}),Ae(To,{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}),Ae(To,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),Ae(To,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),Ae(To,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),Ae(VB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},OQt=PQt,WQt=({fullWidth:t=2.9,fullLength:A=2.8})=>{const I=(t-1.92)/2+.3;return Ot(Yo,{children:[Ae(To,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),Ae(To,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),Ae(To,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),Ae(VB,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},GBA=.6,FBA=.3,v_=.33,UU=.1,ZQt=GBA-UU*2,PWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[ZQt,FBA,v_],offset:[0,0,v_/2],color:t}),Ae(ht,{size:[UU,FBA,v_],offset:[GBA/2-UU/2,0,v_/2],color:"#ccc"}),Ae(ht,{size:[UU,FBA,v_],offset:[-GBA/2+UU/2,0,v_/2],color:"#ccc"})]}),RBA=.4,NBA=.2,U_=.13,LU=.07,VQt=RBA-LU*2,OWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[VQt,NBA,U_],offset:[0,0,U_/2],color:t}),Ae(ht,{size:[LU,NBA,U_],offset:[RBA/2-LU/2,0,U_/2],color:"#ccc"}),Ae(ht,{size:[LU,NBA,U_],offset:[-RBA/2+LU/2,0,U_/2],color:"#ccc"})]}),_BA=3.2,MBA=1.6,L_=.9,HU=.5,jQt=_BA-HU*2,WWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[jQt,MBA,L_],offset:[0,0,L_/2],color:t}),Ae(ht,{size:[HU,MBA,L_],offset:[_BA/2-HU/2,0,L_/2],color:"#ccc"}),Ae(ht,{size:[HU,MBA,L_],offset:[-_BA/2+HU/2,0,L_/2],color:"#ccc"})]}),vBA=3.2,UBA=2.5,H_=1,YU=.6,zQt=vBA-YU*2,ZWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[zQt,UBA,H_],offset:[0,0,H_/2],color:t}),Ae(ht,{size:[YU,UBA,H_],offset:[vBA/2-YU/2,0,H_/2],color:"#ccc"}),Ae(ht,{size:[YU,UBA,H_],offset:[-vBA/2+YU/2,0,H_/2],color:"#ccc"})]}),LBA=5,HBA=2.5,Y_=1.4,JU=.6,XQt=LBA-JU*2,VWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[XQt,HBA,Y_],offset:[0,0,Y_/2],color:t}),Ae(ht,{size:[JU,HBA,Y_],offset:[LBA/2-JU/2,0,Y_/2],color:"#ccc"}),Ae(ht,{size:[JU,HBA,Y_],offset:[-LBA/2+JU/2,0,Y_/2],color:"#ccc"})]}),YBA=6.3,JBA=3.2,J_=1.8,KU=.8,$Qt=YBA-KU*2,jWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[$Qt,JBA,J_],offset:[0,0,J_/2],color:t}),Ae(ht,{size:[KU,JBA,J_],offset:[YBA/2-KU/2,0,J_/2],color:"#ccc"}),Ae(ht,{size:[KU,JBA,J_],offset:[-YBA/2+KU/2,0,J_/2],color:"#ccc"})]}),AEt=({numberOfPins:t,pitch:A=2.54,legsLength:e=3,outerDiameter:i=.945,innerDiameter:o=.945,rows:n=1})=>{const s=o/1.5,r=s*2+i,a=5,g=Math.ceil(t/n),I=2.54,c=(g-1)*A+i+A/2,B=n>1?(n-1)*I+r:r,C=s*1.6,l=-((g-1)/2)*A,Q=n>1?-((n-1)*I)/2:0,E=Ae(ys,{color:"#1a1a1a",children:Ot(JG,{children:[Ae(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,D=l+f*A,b=-d*I;return o?Ae(Jp,{height:a+.1,radius:o/2,center:[D,b,a/2],color:"#222"},u):Ae(ht,{size:[C,C,a],center:[D,b,a/2]},u)})]})});return Ot(Yo,{children:[E,Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,D=l+f*A,b=-d*I;return Ot(ys,{color:"silver",children:[Ot(sI,{children:[Ae(ht,{color:"silver",size:[s,s,e*.9],center:[D,b,-e/2*.9]}),Ae(ht,{color:"silver",size:[s/1.8,s/1.8,e],center:[D,b,-e/2]})]}),Ae(ht,{color:"silver",size:[C,C,C*.5],center:[D,b,C/2*.5]})]},u)})]})},eEt=({width:t,length:A,innerDiameter:e=1})=>{const i=t,o=A,n=t*.7,s=e/2.5;return Ot(Yo,{children:[Ae(RU,{color:"#1a1a1f",center:[0,0,n/2],size:[o,o,n],roundRadius:.3}),Ae(RU,{color:"#f2f2f2",center:[0,0,n+n*.1/2.5],size:[o,o,n*.1],roundRadius:.14}),Ae(Jp,{color:"#1a1a1f",height:n*.8,radius:i/3,center:[0,0,n+n*.8/2]}),Ae(Jp,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[o/3,o/3,n+n*.1/2]}),Ae(Jp,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[-o/3,-o/3,n+n*.1/2]}),Ae(Jp,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[-o/3,o/3,n+n*.1/2]}),Ae(Jp,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[o/3,-o/3,n+n*.1/2]}),Ae(LO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:-o/2,z:-n*1.2}}),Ae(LO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),Ae(LO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),Ae(LO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2+e/3.6,y:-o/2,z:-n*1.2}})]})},LO=t=>{const{thickness:A,width:e,horizontalLength:i,verticalLength:o,rotation:n=0,position:s}=t,r=[[0,i],[-o/3,i/3],[-o/5,i/4],[0,0]],a=wBA(r,A);return Ae(ys,{color:"#f2f2f2",children:Ae(Vi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Ae(QQ,{rotation:[0,55,n],children:Ae(_U,{height:e,children:Ae(NU,{points:a.map(g=>[g.y,g.x])})})})})})},tEt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:o})=>{const n=Math.ceil(t/2),s=(n-1)*i/2,r=.25,a=1,g=.8,I=A*0,c=i*(n-1)+e+.2,B=o*.55;return Ot(Yo,{children:[Array.from({length:n}).map((C,l)=>Ae(To,{position:{x:-o/2-I,y:l*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:Math.PI,position:{x:o/2+I,y:l*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Ae(VB,{center:{x:0,y:0,z:r/2},width:B,length:c,height:a})]})},iEt=({pinCount:t,pitch:A,leadWidth:e,leadLength:i,bodyWidth:o,bodyLength:n})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},r=isNaN(parseFloat(A))?s.pitch:parseFloat(A),a=isNaN(parseFloat(e))?s.leadWidth:parseFloat(e)*.8,g=isNaN(parseFloat(o))?2.6:parseFloat(o)*.8,I=isNaN(parseFloat(n))?2+Number(r)*1.4:parseFloat(n),c=t/2,B=(c-1)*r/2,C=.15,l=.8,Q=4.5,E=(Q-g)/2,h=E*.5;return Ot(Yo,{children:[Array.from({length:c}).map((u,d)=>Ae(To,{position:{x:-Q/2,y:B-d*r,z:C/2},width:a,thickness:C,padContactLength:h+.05,bodyDistance:E+.1,height:l})),Array.from({length:c}).map((u,d)=>Ae(To,{rotation:Math.PI,position:{x:Q/2,y:B-d*r,z:C/2},width:a,thickness:C,padContactLength:h+.05,bodyDistance:E+.1,height:l})),Ae(VB,{center:{x:0,y:0,z:C/2},width:g,length:I,height:1})]})},oEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),Ae(ht,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(Vi,{z:.3/2,children:Ae(ht,{size:[1.65,.8,.3]})}),Ot(sI,{children:[Ae(Vi,{z:.3,children:Ae(ht,{size:[1.65,.8,.01]})}),Ae(Vi,{z:.6,children:Ae(ht,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),nEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),Ae(ht,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),Ae(ys,{color:"#222",children:Ae(Vi,{z:.47/2+.02,children:Ae(ht,{size:[.98,.58,.47]})})}),Ae(ht,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),Ae(ht,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),Ae(ht,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),Ae(ht,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),sEt=()=>{const g=Ae(ys,{color:"#1a1a1a",children:Ot(aE,{children:[Ot(sI,{children:[Ae(Vi,{z:.13,children:Ae(ht,{size:[4,3,.03]})}),Ae(Vi,{z:1.15,children:Ae(ht,{size:[4.4,3.4,.01]})})]}),Ot(sI,{children:[Ae(Vi,{z:1.15,children:Ae(ht,{size:[4.4,3.4,.01]})}),Ae(Vi,{z:2.3,children:Ae(ht,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const l=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 Ae(ys,{color:"#c0c0c0",children:Ot(aE,{children:[Ae(ht,{size:[2.3*.8,1.45,.2],center:[l,0,.2/2]}),Ae(ht,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),Ae(ht,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Yo,{children:[Ae(I,{xDir:1}),Ae(I,{xDir:-1}),g]})},rEt=()=>{const g=Ae(ys,{color:"#1a1a1a",children:Ot(aE,{children:[Ot(sI,{children:[Ae(Vi,{z:.13,children:Ae(ht,{size:[4,3,.03]})}),Ae(Vi,{z:1.15,children:Ae(ht,{size:[4.4,3.4,.01]})})]}),Ot(sI,{children:[Ae(Vi,{z:1.15,children:Ae(ht,{size:[4.4,3.4,.01]})}),Ae(Vi,{z:2.3,children:Ae(ht,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const l=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 Ae(ys,{color:"#c0c0c0",children:Ot(aE,{children:[Ae(ht,{size:[2.3*.8,1.45,.2],center:[l,0,.2/2]}),Ae(ht,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),Ae(ht,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Yo,{children:[Ae(I,{xDir:1}),Ae(I,{xDir:-1}),g]})},aEt=()=>{const g=Ae(ys,{color:"#1a1a1a",children:Ot(aE,{children:[Ot(sI,{children:[Ae(Vi,{z:.21000000000000002,children:Ae(ht,{size:[6.3999999999999995,5.6,.03]})}),Ae(Vi,{z:1.15,children:Ae(ht,{size:[6.8,6,.01]})})]}),Ot(sI,{children:[Ae(Vi,{z:1.15,children:Ae(ht,{size:[6.8,6,.01]})}),Ae(Vi,{z:2.3,children:Ae(ht,{size:[6.3999999999999995,5.6,.01]})})]})]})}),I=({xDir:c})=>{const l=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 Ae(ys,{color:"#c0c0c0",children:Ot(aE,{children:[Ae(ht,{size:[2.3*.8,2.95,.2],center:[l,0,.2/2]}),Ae(ht,{size:[.2,2.95,1.14],center:[Q,0,1.14/2+.2]}),Ae(ht,{size:[h,2.95,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Yo,{children:[Ae(I,{xDir:1}),Ae(I,{xDir:-1}),g]})},gEt=()=>{const c=Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(Vi,{z:.27,children:Ae(ht,{size:[2.9,1.9,.54]})}),Ot(sI,{children:[Ae(Vi,{z:.54,children:Ae(ht,{size:[2.9,1.9,.01]})}),Ae(Vi,{z:1.08,children:Ae(ht,{size:[2.6999999999999997,1.7,.01]})})]})]})});return Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),Ae(ht,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),c]})},IEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),Ae(ht,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(Vi,{z:.55/2,children:Ae(ht,{size:[2.7,1.6,.55]})}),Ot(sI,{children:[Ae(Vi,{z:.55,children:Ae(ht,{size:[2.7,1.6,.01]})}),Ae(Vi,{z:1.1,children:Ae(ht,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),cEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),Ae(ht,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(Vi,{z:.2/2,children:Ae(ht,{size:[2.75,1.8,.2]})}),Ot(sI,{children:[Ae(Vi,{z:.2,children:Ae(ht,{size:[2.75,1.8,.01]})}),Ae(Vi,{z:1,children:Ae(ht,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),Ae(ht,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),BEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),Ae(ht,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ot(sI,{children:[Ae(Vi,{z:.2,children:Ae(ht,{size:[2.6-.1/2,1.7-.1/2,.01]})}),Ae(Vi,{z:.01,children:Ae(ht,{size:[2.6-.1,1.7-.1,.01]})})]}),Ot(sI,{children:[Ae(Vi,{z:.2,children:Ae(ht,{size:[2.6,1.7,.01]})}),Ae(Vi,{z:1,children:Ae(ht,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),Ae(ht,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),CEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),Ae(ht,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ot(sI,{children:[Ae(Vi,{z:.2,children:Ae(ht,{size:[3.8-.05/2,2.5-.05/2,.01]})}),Ae(Vi,{z:.01,children:Ae(ht,{size:[3.8-.05,2.5-.05,.01]})})]}),Ot(sI,{children:[Ae(Vi,{z:.2,children:Ae(ht,{size:[3.8,2.5,.01]})}),Ae(Vi,{z:1,children:Ae(ht,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),Ae(ht,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),lEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),Ae(ht,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(Vi,{z:.14/2,children:Ae(ht,{size:[.8,.6,.14]})}),Ot(sI,{children:[Ae(Vi,{z:.14,children:Ae(ht,{size:[.8,.6,.01]})}),Ae(Vi,{z:.37,children:Ae(ht,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),QEt=()=>{const I=3.0999999999999996;return Ot(Yo,{children:[Ae(To,{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}),Ae(To,{position:{x:-6.6/2-I/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),Ae(To,{position:{x:-6.6/2-I/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),Ae(To,{position:{x:-6.6/2-I/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),Ae(VB,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},EEt=()=>Ot(Yo,{children:[Array.from({length:16}).map((C,l)=>Ae(To,{position:{x:-10.5/2,y:l*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((C,l)=>Ae(To,{rotation:Math.PI,position:{x:10.5/2,y:l*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((C,l)=>Ae(To,{rotation:Math.PI/2,position:{x:l*.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((C,l)=>Ae(To,{rotation:-Math.PI/2,position:{x:l*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Ae(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})]}),hEt=EEt,uEt=()=>{const g=.7999999999999998;return Ot(Yo,{children:[Ae(To,{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}),Ae(To,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),Ae(To,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),Ae(VB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},dEt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:o})=>{const n=t/4;if(n!==Math.floor(n))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);A||(A=.5),i||(i=.6),e||(e=.22),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+3.3*i,g=a,I=.8,c=.2,B=(g-o)/2+.4;return Ot(Yo,{children:[Array.from({length:n}).map((C,l)=>Ae(To,{position:{x:-g/2-.36,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:Math.PI,position:{x:g/2+.36,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:Math.PI/2,position:{x:l*A-r,y:-a/2-.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:-Math.PI/2,position:{x:l*A-r,y:a/2+.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Ae(VB,{center:{x:0,y:0,z:0},width:o,length:s,height:1.5,heightAboveSurface:.1,taperRatio:.04,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:s/2-1.5,z:1.5},notchRadius:1.5/2})]})},pEt=()=>{const i=.20900000000000002,o=.1,n=.3,s=.1,r=.2;return Ot(Yo,{children:[Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(ht,{size:[.85,1.2,i],center:[0,0,i/2]}),Ot(sI,{children:[Ae(Vi,{z:i,children:Ae(ht,{size:[.85,1.2,.01]})}),Ae(Vi,{z:.38,children:Ae(ht,{size:[.85-o,1.2-o,.01]})})]})]})}),Ae(ht,{color:"#ccc",size:[n,.25,s],center:[.55,0,s/2]}),Ae(ht,{color:"#ccc",size:[n,r,s],center:[-.55,.4,s/2]}),Ae(ht,{color:"#ccc",size:[n,r,s],center:[-.55,-.4,s/2]})]})},fEt=({num_pins:t,bodyWidth:A=5.3,bodyLength:e=5.3,bodyThickness:i=1,thermalPadSize:o,padWidth:n=e/5.3*.6,padLength:s=e/5.3*1,pitch:r=.5,thermalPadThickness:a=.2})=>{const g=[],I=Math.floor(t/2),c=r*(I-1);for(let B=0;B<t;B++){const C=B<I?"left":"right",l=B%I,Q=c/2-l*r,E=s,h=n,u=C==="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(Yo,{children:[Ae(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,C)=>Ae(ht,{center:[B.x,B.y,a/2],size:[B.padSizeX,B.padSizeY,a]})),o?.length!==void 0&&o?.width!==void 0&&Ae(ht,{center:[0,0,a/2],size:[o.width,o.length,a]})]})},yEt=({bodyLength:t=10.2,bodyWidth:A=4.65,bodyHeight:e=13.46,leadSpacing:i=5,leadDiameter:o=.8,leadLength:n=12.7,color:s="#ddd",leadColor:r="#b87333"})=>{const a=t/2,g=A/2,I=a-g,c=i/2,B=.85;return Ot(Yo,{children:[Ot(ys,{color:s,children:[Ot(sI,{children:[Ae(Kp,{height:e,roundRadius:.5,radius:g,center:[-I,0,e]}),Ae(Kp,{height:e,roundRadius:.5,radius:g,center:[I,0,e]})]}),Ot(sI,{children:[Ae(Kp,{height:B,roundRadius:.1,radius:g+.85,center:[-I,0,e/2+B/2]}),Ae(Kp,{height:B,roundRadius:.1,radius:g+.85,center:[I,0,e/2+B/2]})]})]}),Ot(ys,{color:r,children:[Ae(Jp,{height:n+e/2,radius:o/2,center:[-c+.06,0,-(n/2)+e/2]}),Ae(Jp,{height:n+e/2,radius:o/2,center:[c-.06,0,-(n/2)+e/2]})]})]})},wEt=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:o="#111"})=>Ot(Yo,{children:[Ae(ys,{color:e,children:Ot(QQ,{rotation:[0,"90deg",0],children:[Ae(RU,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),Ae(Jp,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),Ae(ys,{color:o,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(RU,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),Ae(ys,{color:i,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),Ae(ys,{color:i,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),mEt=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Yo,{children:[Ae(ys,{color:e,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),Ae(ys,{color:i,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),Ae(ys,{color:i,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),DEt=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Yo,{children:[Ae(ys,{color:e,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),Ae(ys,{color:i,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),Ae(ys,{color:i,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),SEt=({pinCount:t,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t%2!==0)throw new Error("MS012 pinCount must be even");const o=t/2,n=4.9,s=3.9,r=(o-1)*i/2,a=.2;return Ot(Yo,{children:[Array.from({length:o}).map((g,I)=>Ae(To,{position:{x:-s/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,I)=>Ae(To,{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})),Ae(VB,{center:{x:0,y:0,z:a/2},width:s,length:n,height:1.55,notchPosition:{x:-.95,y:n/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},bEt=({pinCount:t=16,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t!==16)throw new Error("MS013 only supports 16 pins");const o=t/2,n=7.5,s=10.3,r=(o-1)*i/2,a=.2;return Ot(Yo,{children:[Array.from({length:o}).map((g,I)=>Ae(To,{position:{x:-n/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,I)=>Ae(To,{rotation:Math.PI,position:{x:n/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Ae(VB,{center:{x:0,y:0,z:a/2},width:n,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},xEt=()=>{const Q=7.050000000000001,E=24.95+6.5/2;return Ae(Vi,{center:[0,0,1],children:Ot(Yo,{children:[Ot(QQ,{rotation:[0,55,-55],children:[Ot(JG,{children:[Ae(ht,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[E,0,1.3-2]}),Ae(Jp,{color:"black",center:[E,0,1.3-2],radius:3/2,height:1.3*1.2})]}),Ae(ys,{color:"#222",children:Ae(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})})]}),Ae(QQ,{rotation:[0,55,55],children:Array.from({length:3}).map((h,u)=>{const d=Q,f=(u-1)*2.7,D=-.5-.6;return Ot(ys,{color:"gold",children:[Ot(sI,{children:[Ae(Vi,{center:[15.05-4.5/2+.1,f,D],children:Ae(ht,{size:[4.5,.81+1,.5]})}),Ae(Vi,{center:[15.05-4.5/2-1+.1,f,D],children:Ae(ht,{size:[4.5,.81,.5]})})]}),Ae(Vi,{center:[d,f,D],children:Ae(ht,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},kEt=()=>{const g=1.1999999999999997;return Ot(Yo,{children:[Ae(To,{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}),Ae(To,{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}),Ae(To,{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}),Ae(To,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),Ae(To,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),Ae(To,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),Ae(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})]})},GEt=()=>Ot(Yo,{children:[Ae(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 Ae(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 Ae(ht,{center:[.8/2-.19/2+.1,I,.12/2],size:[.19,.15,.12]})})]}),FEt=()=>{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],C=[0,1.28,-8.9],l=-7.5;return Ot(Vi,{center:[0,1,10.5],children:[Ae(ys,{color:s,children:Ot(JG,{children:[Ae(Vi,{center:[0,0,2.25],children:Ae(Jp,{radius:2.4,height:4.5})}),Ae(Vi,{center:[0,-1.8499999999999999,2.25],children:Ae(ht,{size:[2.4*2,1.1,4.5+.2]})})]})}),Ae(Vi,{center:I,children:Ae(ht,{size:a})}),Ot(sI,{children:[Ae(Vi,{center:c,children:Ae(ht,{size:g})}),Ae(Vi,{center:B,children:Ae(ht,{size:g})})]}),Ae(Vi,{center:C,children:Ae(ht,{size:[.43,.4,12.2]})}),Ae(Vi,{center:[1.3,0,l],children:Ae(ht,{size:[.43,.4,15]})}),Ae(Vi,{center:[-1.3,0,l],children:Ae(ht,{size:[.43,.4,15]})})]})},REt=()=>Ot(Yo,{children:[Ae(To,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(To,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(To,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(To,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(To,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(To,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(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})]}),NEt=REt,_Et=()=>Ot(Yo,{children:[Ae(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 Ae(ht,{center:[-1/2+.3/2,a,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(r=>{const a=-.5+r*.5;return Ae(ht,{center:[1/2-.3/2,a,.05/2],size:[.3,.2,.05]})})]}),MEt=()=>Ot(Yo,{children:[Ae(To,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ae(To,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ae(ys,{color:"#222",children:Ae(VB,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),Ae(ht,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),vEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),Ae(ht,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(Vi,{z:.175/2,children:Ae(ht,{size:[1.7,1.25,.175]})}),Ot(sI,{children:[Ae(Vi,{z:.175,children:Ae(ht,{size:[1.7,1.25,.01]})}),Ae(Vi,{z:.725,children:Ae(ht,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),Ae(ht,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),UEt=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),Ae(ht,{color:"#ccc",size:[.4,.325,.13],center:[r,0,.13/2]}),Ae(ys,{color:"#222",children:Ae(VB,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),Ae(ht,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},LEt=({footprint:t})=>{const A=mQt.string(t).json();switch(A.fn){case"dip":return Ae(kQt,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"tssop":return Ae(FQt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return Ae(RQt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return Ae(iEt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return Ae(vQt,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return Ae(hEt,{});case"lqfp":return Ae(dEt,{pinCount:A.num_pins});case"qfn":{const o=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return Ae(qQt,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:o?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"dfn":{const o=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return Ae(fEt,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:o?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"pinrow":{const o=t.match(/_rows(\d+)/),n=o&&o[1]?parseInt(o[1],10):1;if(A.male)return Ae(YQt,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:n});if(A.female)return Ae(AEt,{numberOfPins:A.num_pins,pitch:A.p,rows:n})}case"cap":switch(A.imperial){case"0402":return Ae(KWA,{color:"#856c4d"});case"0603":return Ae(TWA,{color:"#856c4d"});case"0805":return Ae(qWA,{color:"#856c4d"});case"0201":return Ae(PWA,{color:"#856c4d"});case"01005":return Ae(OWA,{color:"#856c4d"});case"1206":return Ae(WWA,{color:"#856c4d"});case"1210":return Ae(ZWA,{color:"#856c4d"});case"2010":return Ae(VWA,{color:"#856c4d"});case"2512":return Ae(jWA,{color:"#856c4d"})}case"sot235":return Ae(OQt,{});case"sot457":return Ae(kEt,{});case"sot223":return Ae(QEt,{});case"sot23w":return Ae(WQt,{});case"sot323":return Ae(uEt,{});case"sod323f":return Ae(vEt,{});case"sod323fl":return Ae(UEt,{});case"sot363":return Ae(NEt,{});case"sot886":return Ae(_Et,{});case"sot963":return Ae(GEt,{});case"pushbutton":return Ae(eEt,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return Ae(tEt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return Ae(oEt,{});case"sod882":return Ae(nEt,{});case"sma":return Ae(sEt,{});case"smb":return Ae(rEt,{});case"smc":return Ae(aEt,{});case"smf":return Ae(gEt,{});case"sod123f":return Ae(IEt,{});case"sod123fl":return Ae(cEt,{});case"sod123w":return Ae(BEt,{});case"sod128":return Ae(CEt,{});case"sod323":return Ae(MEt,{});case"sod923":return Ae(lEt,{});case"hc49":return Ae(yEt,{});case"micromelf":return Ae(wEt,{});case"minimelf":return Ae(mEt,{});case"melf":return Ae(DEt,{});case"ms012":return Ae(SEt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return Ae(bEt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return Ae(pEt,{});case"to220":return Ae(xEt,{});case"to92":return Ae(FEt,{})}const e=t.match(/_color\(([^)]+)\)/),i=e?e[1]:void 0;switch(A.imperial){case"0402":return Ae(KWA,{color:i});case"0603":return Ae(TWA,{color:i});case"0805":return Ae(qWA,{color:i});case"0201":return Ae(PWA,{color:i});case"01005":return Ae(OWA,{color:i});case"1206":return Ae(WWA,{color:i});case"1210":return Ae(ZWA,{color:i});case"2010":return Ae(VWA,{color:i});case"2512":return Ae(jWA,{color:i})}return null},HEt=t=>t&&typeof t=="object"&&"type"in t,K_=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},YEt=t=>Array.isArray(t)?[Number(t[0])||0,Number(t[1])||0,Number(t[2])||0]:typeof t=="object"&&t?[Number(t.x)||0,Number(t.y)||0,Number(t.z)||0]:[0,0,0];function pm(t,A,e){const{jscad:{primitives:i,booleans:o,hulls:n,geometries:s,extrusions:r,transforms:a}}=e;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(B=>pm(B,A,e));if(!HEt(t))return[];const{type:g,props:I,children:c}=t;if(g===LWA)return(c??[]).flatMap(B=>pm(B,A,e));if(g===ys){const B=I?.color;return(c??[]).flatMap(C=>pm(C,B??A,e))}if(g===Vi){const B=YEt(I?.offset??I?.center??{x:I?.x,y:I?.y,z:I?.z});return(c??[]).flatMap(l=>pm(l,A,e)).map(({geom:l,color:Q})=>({geom:a.translate(B,l),color:Q??A}))}if(g===QQ){const B=Array.isArray(I?.rotation)?[K_(I.rotation[0]),K_(I.rotation[1]),K_(I.rotation[2])]:[K_(I?.x??0),K_(I?.y??0),K_(I?.z??0)];return(c??[]).flatMap(l=>pm(l,A,e)).map(({geom:l,color:Q})=>({geom:a.rotateZ(B[2],a.rotateY(B[1],a.rotateX(B[0],l))),color:Q}))}if(g===aE||g===JG||g===sI){const B=(c??[]).flatMap(l=>pm(l,A,e)).map(l=>l.geom);if(B.length===0)return[];let C;return g===aE?C=o.union(B):g===JG?C=o.subtract(B[0],B.slice(1)):C=n.hull(B),[{geom:C,color:A}]}if(g===NU){const B=I?.points??[];return[{geom:s.geom2.fromPoints(B),color:A??I?.color}]}if(g===_U){const B=(c??[]).flatMap(E=>pm(E,A,e)).map(E=>E.geom);if(B.length===0)return[];const C=B.length>1?o.union(B):B[0],l=I?.height??I?.h??1;let Q=r.extrudeLinear({height:l},C);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===HWA||g===Jp||g===YWA||g===RU||g===Kp){let B;if(g===ht){const C=I?.size??[1,1,1],l=I?.offset,Q=I?.center??(l?[l[0],l[1],l[2]]:[0,0,0]);B=i.cuboid({size:C,center:Q})}else if(g===HWA){const C=I?.size??1,l=I?.offset,Q=I?.center??(l?[l[0],l[1],l[2]]:[0,0,0]);B=i.cube({size:C,center:Q})}else if(g===Jp){const C=I?.height??1,l=I?.radius??1,Q=I?.center??[0,0,0];B=i.cylinder({height:C,radius:l,center:Q})}else if(g===YWA){const C=I?.radius??1,l=I?.center??[0,0,0];B=i.sphere({radius:C,center:l})}else if(g===Kp){const C=I?.height??1,l=I?.radius??1,Q=I?.roundRadius??.1,E=I?.center??[0,0,0];B=i.roundedCylinder({height:C,radius:l,roundRadius:Q,center:E})}else{const C=I?.size??[1,1,1],l=I?.roundRadius??.1,Q=I?.center??[0,0,0];B=i.roundedCuboid({size:C,roundRadius:l,center:Q})}return[{geom:B,color:A??I?.color}]}if(typeof g=="function"){const B=g(I??{});return pm(B,A,e)}return(c??[]).flatMap(B=>pm(B,A,e))}function JEt(t,A){return{geometries:pm(t,void 0,{jscad:A})}}function zWA(t){if(t.polygons){const A=[],e=[],i=[];let o=0;for(const s of t.polygons){for(const a of s.vertices)a.index=o,A.push(a[0],a[1],a[2]),t.color&&t.color.length>=3?i.push(t.color[0],t.color[1],t.color[2]):i.push(1,1,1),o++;const r=s.vertices[0].index;for(let a=2;a<s.vertices.length;a++){const g=s.vertices[a-1].index,I=s.vertices[a].index;e.push(r,g,I)}}const n=new Cg;if(n.setAttribute("position",new oI(new Float32Array(A),3)),n.setIndex(e),i.length>0&&n.setAttribute("color",new oI(new Float32Array(i),3)),t.transforms){const s=new ts;s.fromArray(t.transforms),n.applyMatrix4(s)}return n.computeVertexNormals(),n}if(t.sides){const A=[],e=[];for(const o of t.sides)A.push(o[0][0],o[0][1],0),t.color&&t.color.length>=3?e.push(t.color[0],t.color[1],t.color[2]):e.push(1,1,1);const i=new Cg;if(i.setAttribute("position",new oI(new Float32Array(A),3)),e.length>0&&i.setAttribute("color",new oI(new Float32Array(e),3)),t.transforms){const o=new ts;o.fromArray(t.transforms),i.applyMatrix4(o)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Cg}function KEt(t,A){const e=yBA(LEt,{footprint:t});return JEt(e,A)}var TEt=({jscadPlan:t,positionOffset:A,rotationOffset:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=fu(),{threeGeom:g,material:I}=AA.useMemo(()=>{const B=(0,Frt.executeJscadOperations)(Rrt.default,t);if(!B||!B.polygons&&!B.sides)return{threeGeom:null,material:null};const C=zWA(B),l=new ih({vertexColors:!0,side:UC,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:C,material:l}},[t,r]),c=AA.useMemo(()=>g?new Oo(g,I):null,[g,I]);return AA.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),AA.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]),AA.useMemo(()=>{if(I)if(n){const B=new Ui(I.color.getHex());I.emissive.copy(B),I.emissive.setRGB(0,0,1),I.emissiveIntensity=.2}else I.emissiveIntensity=0},[n,I]),g?V.jsx(GU,{isHovered:n,onHover:i,onUnhover:o,object:c}):null},qEt=yr(SO()),PEt=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=fu(),g=AA.useMemo(()=>{if(!A)return null;const{geometries:I}=KEt(A,qEt),c=new Np;for(const B of I.flat(1/0)){const C=B.geom;if(!C||!C.polygons&&!C.sides)continue;const l=new Ui(B.color);l.convertLinearToSRGB();const Q={...C,color:[l.r,l.g,l.b]},E=zWA(Q),h=new ih({vertexColors:!0,side:UC,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new Oo(E,h);c.add(u)}return c},[A,r]);return AA.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),AA.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]),AA.useEffect(()=>{g&&g.traverse(I=>{I instanceof Oo&&I.material instanceof ih&&(n?(I.material.emissive.setHex(255),I.material.emissiveIntensity=.2):I.material.emissiveIntensity=0)})},[n,g]),g?V.jsx(GU,{isHovered:n,onHover:i,onUnhover:o,object:g}):null},OEt=(...t)=>t,TU={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},XWA=({children:t,position:A,style:e})=>{const{camera:i,renderer:o}=fu(),n=AA.useRef(document.createElement("div")),[s,r]=AA.useState(null);return AA.useEffect(()=>{const a=o?.domElement.parentNode;if(a)return a.style.position!=="relative"&&a.style.position!=="absolute"&&(a.style.position="relative"),a.appendChild(n.current),r(BJ.createPortal(t,n.current)),()=>{a.contains(n.current)&&a.removeChild(n.current)}},[o,t]),kU(()=>{if(!i||!n.current||!o)return;const a=new Re(...A);a.project(i);const g=o.domElement.getBoundingClientRect(),I=Math.round((a.x+1)/2*g.width),c=Math.round((-a.y+1)/2*g.height);n.current.style.position="absolute",n.current.style.left=`${I}px`,n.current.style.top=`${c}px`,n.current.style.pointerEvents="none",n.current.style.zIndex=TU.htmlElements.toString(),e&&Object.assign(n.current.style,e)},[i,o,A,e]),s},$WA={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},AZA=AA.createContext(void 0),WEt=({children:t})=>{const[A,e]=AA.useState($WA),i=AA.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),o=AA.useCallback(()=>{e($WA)},[]),n=AA.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:o}),[A,i,o]);return V.jsx(AZA.Provider,{value:n,children:t})},T_=()=>{const t=AA.useContext(AZA);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},KBA,ZEt="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function VEt(t){if(typeof t=="function")return t;if(t&&typeof t=="object"&&"default"in t&&typeof t.default=="function")return t.default;throw new Error("Unable to resolve occt-import-js factory export")}async function jEt(){if(!KBA){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");KBA=VEt(t)({locateFile:e=>`${ZEt}/${e}`})}return KBA}function zEt(t){const A=new Np;for(const e of t){const i=e.attributes.position?.array??[],o=e.index?.array??[];if(!i.length||!o.length)continue;const n=new Cg;n.setAttribute("position",new Un(i,3));const s=e.attributes.normal?.array??[];s.length?n.setAttribute("normal",new Un(s,3)):n.computeVertexNormals(),n.setIndex(o);const r=new ih({color:e.color?new Ui(e.color[0],e.color[1],e.color[2]):new Ui(.82,.82,.82)}),a=new Oo(n,r);a.name=e.name,A.add(a)}return A}async function XEt(t){const A=await fetch(t);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const e=await A.arrayBuffer(),o=(await jEt()).ReadStepFile(new Uint8Array(e),null);if(!o.success||!o.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const n=zEt(o.meshes),s=new dX,r=await new Promise((a,g)=>{s.parse(n,I=>{I instanceof ArrayBuffer?a(I):g(new Error("GLTFExporter did not return binary output"))},I=>{g(I)},{binary:!0})});return URL.createObjectURL(new Blob([r],{type:"model/gltf-binary"}))}var eZA="step-glb-cache:";function $Et(t){const A=new Uint8Array(t),e=32768;let i="";for(let o=0;o<A.length;o+=e){const n=A.subarray(o,o+e);i+=String.fromCharCode(...n)}return btoa(i)}function Aht(t){const A=atob(t),e=new Uint8Array(A.length);for(let i=0;i<A.length;i+=1)e[i]=A.charCodeAt(i);return e.buffer}function eht(t){try{const A=localStorage.getItem(`${eZA}${t}`);return A?Aht(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function tht(t,A){try{const e=$Et(A);localStorage.setItem(`${eZA}${t}`,e)}catch(e){console.warn("Failed to write STEP GLB cache",e)}}var iht=({stepUrl:t,position:A,rotation:e,scale:i,onHover:o,onUnhover:n,isHovered:s,isTranslucent:r})=>{const[a,g]=AA.useState(null);return AA.useEffect(()=>{let I=!0,c=null;const B=eht(t);return B?(c=URL.createObjectURL(new Blob([B],{type:"model/gltf-binary"})),g(c),()=>{I=!1,c&&URL.revokeObjectURL(c)}):(XEt(t).then(C=>{if(!I){URL.revokeObjectURL(C);return}c=C,g(C),fetch(C).then(l=>l.arrayBuffer()).then(l=>{tht(t,l)}).catch(l=>{console.warn("Failed to cache STEP GLB",l)})}).catch(C=>{console.error("Failed to convert STEP file to GLB",C),I&&g(null)}),()=>{I=!1,c&&URL.revokeObjectURL(c)})},[t]),a?V.jsx(R8A,{gltfUrl:a,position:A,rotation:e,scale:i,onHover:o,onUnhover:n,isHovered:s,isTranslucent:r}):null},tZA=({cad_component:t,circuitJson:A})=>{const[e,i]=AA.useState(!1),{visibility:o}=T_(),[n,s]=AA.useState(null),r=AA.useCallback(E=>{E?.mousePosition?(i(!0),s(E.mousePosition)):(i(!1),s(null))},[]),a=AA.useCallback(()=>{i(!1),s(null)},[]),g=AA.useMemo(()=>wi(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),I=AA.useMemo(()=>A.filter(h=>h.type==="pcb_plated_hole"&&h.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,C=t.model_step_url,l=t.rotation?OEt(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):void 0;let Q=null;if(c?Q=V.jsx(xrt,{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?Q=V.jsx(R8A,{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):C&&!t.model_jscad&&!t.footprinter_string?Q=V.jsx(iht,{stepUrl: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.model_jscad?Q=V.jsx(TEt,{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&&(Q=V.jsx(PEt,{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(!o.translucentModels)return null}else if(I&&!o.throughHoleModels||!I&&!o.smtModels)return null;return V.jsxs(V.Fragment,{children:[Q,e&&n?V.jsx(XWA,{position:n,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]})},iZA={version:"0.0.483"};function oht(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var nht=t=>{t.outputColorSpace=Wy,t.toneMapping=gDA,t.toneMappingExposure=1},oZA="cadViewerCameraStateSession",nZA=(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(oZA,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},TBA=(t,A)=>{try{const e=sessionStorage.getItem(oZA);if(!e)return!1;const i=JSON.parse(e);if(t.position.fromArray(i.position),t.quaternion.fromArray(i.quaternion),t.up.fromArray(i.up),"fov"in t){const o=t;o.fov=i.fov,o.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),t.updateMatrixWorld(),!0}catch(e){return console.warn("Failed to restore camera:",e),!1}},sZA=AA.createContext(void 0),sht=({children:t,defaultTarget:A,initialCameraPosition:e})=>{const i=AA.useRef(null),o=AA.useRef(null),[n,s]=AA.useState(null),[r,a]=AA.useState("perspective"),[g,I]=AA.useState(e??null),[c,B]=AA.useState(new Fp(0,0,0)),C=AA.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]),l=AA.useCallback(h=>{const u=[A.x,A.y,A.z],d=o.current,f=i.current;let D=C;switch(d&&f&&(D=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const b=D/Math.sqrt(2);return{position:[A.x,A.y-b,A.z+b],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+D],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-D*.6,A.y-D*.6,A.z+D*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+D*.6,A.y-D*.6,A.z+D*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-D,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+D,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-D,A.z],target:u,up:[0,0,1]};default:return null}},[C,A,o,i]),Q=AA.useCallback(h=>{i.current=h},[]),E=AA.useMemo(()=>({controlsRef:i,mainCameraRef:o,defaultTarget:A,baseDistance:C,controller:n,setController:s,getPresetConfig:l,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:I,cameraRotation:c,setCameraRotation:B,saveCameraToSession:nZA,loadCameraFromSession:TBA}),[A,C,n,l,Q,r,g,c]);return V.jsx(sZA.Provider,{value:E,children:t})},dx=()=>{const t=AA.useContext(sZA);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},rht=AA.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:o},n)=>{const{cameraType:s}=dx(),r=AA.useRef(null),[a,g]=AA.useState(null),I=AA.useRef([]),c=AA.useRef(void 0);c.current=o;const B=AA.useRef(null),C=AA.useCallback(h=>{I.current.push(h)},[]),l=AA.useCallback(h=>{I.current=I.current.filter(u=>u!==h)},[]),Q=AA.useMemo(()=>new $k,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const E=AA.useRef(new Bg);return AA.useImperativeHandle(n,()=>E.current),AA.useEffect(()=>{if(!r.current)return;oht(r.current);const h=new SK({antialias:!0,alpha:!0});nht(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 tE(75,u,.1,1e3):new G1(-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:C,removeFrameListener:l}),c.current?.({camera:d,renderer:h});let f;const D=new ome,b=()=>{const x=D.getElapsedTime(),F=D.getDelta();I.current.forEach(k=>k(x,F)),h.render(Q,d),f=requestAnimationFrame(b)};b();const m=()=>{if(r.current){const x=r.current.clientWidth/r.current.clientHeight;d instanceof tE?d.aspect=x:d instanceof G1&&(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",m),()=>{B.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",m),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,C,l,s]),V.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&V.jsx(x8A.Provider,{value:a,children:V.jsx(wrt,{children:t})})})}),aht=({autoRotate:t,autoRotateSpeed:A,onStart:e,panSpeed:i,rotateSpeed:o,zoomSpeed:n,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:I,renderer:c}=fu(),B=AA.useMemo(()=>!I||!c?null:new Cbe(I,c.domElement),[I,c]);return AA.useEffect(()=>(g?.(B??null),()=>g?.(null)),[B,g]),AA.useEffect(()=>{if(!B)return;const C=()=>{g?.(B)};return B.addEventListener("change",C),()=>{B.removeEventListener("change",C)}},[B,g]),AA.useEffect(()=>{B&&(B.autoRotate=t||!1,B.autoRotateSpeed=A||1,i!==void 0&&(B.panSpeed=i),o!==void 0&&(B.rotateSpeed=o),n!==void 0&&(B.zoomSpeed=n),s!==void 0&&(B.enableDamping=s),r!==void 0&&(B.dampingFactor=r),B.zoomToCursor=!0,B.mouseButtons={LEFT:lb.ROTATE,MIDDLE:lb.PAN,RIGHT:null},a&&(B.target.set(a[0],a[1],a[2]),B.update()))},[B,t,A,i,o,n,s,r,a]),AA.useEffect(()=>{if(!(!B||!e))return B.addEventListener("start",e),()=>{B.removeEventListener("start",e)}},[B,e]),AA.useEffect(()=>{if(B)return()=>{B.dispose()}},[B]),kU(()=>{B?.update()},[B]),null},ght=`
|
|
5062
|
+
`).replace(/d 0\./g,"d 1."),C=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),l=new $Se;l.setMaterialOptions({invertTrProperty:!0});const Q=l.parse(B.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return c.setMaterials(Q),c.parse(C)}return c.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(o.has(i)){const g=o.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(I=>I instanceof Error?I:I.clone())}const a=s().then(g=>(g instanceof Error||o.set(i,{...o.get(i),result:g}),g));return o.set(i,{promise:a,result:null}),a}return r().then(a=>{n||e(a)}).catch(a=>{console.error(a)}),()=>{n=!0}},[t]),A}function xrt({url:t,position:A,rotation:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const a=brt(t),{rootObject:g}=fu(),I=AA.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(c=>{if(c instanceof Oo&&c.material){const B=C=>{C.transparent=r,C.opacity=r?.5:1,C.depthWrite=!r,C.needsUpdate=!0};Array.isArray(c.material)?c.material.forEach(B):B(c.material)}}),a):new Oo(new tw(.5,.5,.5),new ih({transparent:!0,color:"red",opacity:.25})),[a,r]);if(AA.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),AA.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 V.jsx(GU,{isHovered:n,onHover:i,onUnhover:o,object:I})}var G8A=new WeakMap,krt=()=>{const t=new Uc;return t.name="fallback-environment-map",t.mapping=ZJ,t},Grt=t=>{if(!t)return null;const A=t,e=G8A.get(A);if(e)return e;let i;if(t instanceof SK){const o=new zj(t);i=o.fromScene(QSe(),.04).texture,o.dispose()}else i=krt();return G8A.set(A,i),i},F8A=1.25;function R8A({gltfUrl:t,position:A,rotation:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=fu(),[I,c]=AA.useState(null),[B,C]=AA.useState(null);if(AA.useEffect(()=>{if(!t)return;const l=new hSe;let Q=!0;return l.load(t,E=>{if(!Q)return;const h=E.scene;h.traverse(u=>{if(u instanceof Oo&&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}`);C(h)}),()=>{Q=!1}},[t,r]),AA.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]),AA.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),AA.useEffect(()=>{if(!I||!a)return;const l=Grt(a);if(!l)return;const Q=[],E=h=>{h instanceof ih&&(Q.push({material:h,envMap:h.envMap??null,envMapIntensity:h.envMapIntensity??1}),h.envMap=l,(typeof h.envMapIntensity!="number"||h.envMapIntensity<F8A)&&(h.envMapIntensity=F8A),h.needsUpdate=!0)};return I.traverse(h=>{if(!(h instanceof Oo))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]),AA.useEffect(()=>{I&&I.traverse(l=>{l instanceof Oo&&l.material instanceof ih&&(n?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[n,I]),B)throw B;return I?V.jsx(GU,{isHovered:n,onHover:i,onUnhover:o,object:I}):null}var Frt=yr(n5A()),Rrt=yr(SO()),N8A={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},wr=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 N8A)return e*N8A[A];throw new Error(`Unsupported unit: ${A}`)},fB=wr,_8A={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}}},IBA=new Set;for(const[t,A]of Object.entries(_8A)){IBA.add(t);for(const e of Object.keys(A.variants))IBA.add(e)}function Nrt(t){for(const[A,e]of Object.entries(_8A))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var M8A={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 Bw(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}=Bw(t.x),g=Bw(t.x),I=Bw(t.y);return g.value===null||I.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:I.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),o=t.slice(0,-i.length);if(i in M8A&&!IBA.has(i)){const r=M8A[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(o)*r}}const{baseUnit:n,conversionFactor:s}=Nrt(i);return{parsedUnit:i,unitOfValue:n,value:s*Number.parseFloat(o)}}var cBA=H().or(ZA()).transform(t=>Bw(t).value),v8A=H().or(ZA()).transform(t=>Bw(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),_rt=H().or(ZA()).transform(t=>Bw(t).value),k_=H().or(ZA()).transform(t=>Bw(t).value),$A=H().or(ZA()).transform(t=>Bw(t).value),bO=H().or(ZA()).transform(t=>Bw(t).value),mt=$A,BBA=H().or(ZA()).transform(t=>Bw(t).value),CBA=H().or(ZA()).transform(t=>Bw(t).value),G_=CBA,Mrt=H().datetime(),pd=H().or(ZA()).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)),vrt=ZA().or(H().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"),xo=PA({x:mt,y:mt}),lBA=PA({x:mt,y:mt,z:mt}),U8A=PA({width:ZA(),height:ZA()}),Urt=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},jt=t=>H().optional().default(()=>`${t}_${Urt(10)}`),YG=Ct(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]);Ct(["top_silkscreen","bottom_silkscreen","top_copper","bottom_copper","top_soldermask","bottom_soldermask","top_fabrication_note","bottom_fabrication_note","inner1_copper","inner2_copper","inner3_copper","inner4_copper","inner5_copper","inner6_copper"]);var Lrt=Ct(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),yB=PA({type:kA("source_component"),ftype:H().optional(),source_component_id:H(),name:H(),manufacturer_part_number:H().optional(),supplier_part_numbers:Na(Lrt,be(H())).optional(),display_value:H().optional(),are_pins_interchangeable:ce().optional(),internally_connected_source_port_ids:be(be(H())).optional(),source_group_id:H().optional(),subcircuit_id:H().optional()}),L8A=yB.extend({ftype:kA("simple_capacitor"),capacitance:v8A,max_voltage_rating:k_.optional(),display_capacitance:H().optional(),max_decoupling_trace_length:mt.optional()}),H8A=yB.extend({ftype:kA("simple_resistor"),resistance:cBA,display_resistance:H().optional()}),QBA=yB.extend({ftype:kA("simple_diode")}),Hrt=yB.extend({ftype:kA("simple_fiducial")}),Y8A=QBA.extend({ftype:kA("simple_led"),color:H().optional(),wavelength:H().optional()}),Yrt=yB.extend({ftype:kA("simple_ground")}),J8A=yB.extend({ftype:kA("simple_chip")}),K8A=yB.extend({ftype:kA("simple_power_source"),voltage:k_}),Jrt=yB.extend({ftype:kA("simple_fuse"),current_rating_amps:ZA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:ZA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),T8A=yB.extend({ftype:kA("simple_battery"),capacity:vrt}),q8A=yB.extend({ftype:kA("simple_inductor"),inductance:_rt,max_current_rating:ZA().optional()}),P8A=yB.extend({ftype:kA("simple_push_button")}),O8A=yB.extend({ftype:kA("simple_potentiometer"),max_resistance:cBA}),Krt=yB.extend({ftype:kA("simple_crystal"),frequency:ZA().describe("Frequency in Hz"),load_capacitance:ZA().optional().describe("Load capacitance in pF")}),W8A=yB.extend({ftype:kA("simple_pin_header"),pin_count:ZA(),gender:Ct(["male","female"]).optional().default("male")}),Z8A=yB.extend({ftype:kA("simple_pinout")}),V8A=yB.extend({ftype:kA("simple_resonator"),load_capacitance:v8A,equivalent_series_resistance:cBA.optional(),frequency:bO}),j8A=yB.extend({ftype:kA("simple_transistor"),transistor_type:Ct(["npn","pnp"])}),z8A=yB.extend({ftype:kA("simple_test_point"),footprint_variant:Ct(["pad","through_hole"]).optional(),pad_shape:Ct(["rect","circle"]).optional(),pad_diameter:Ai([ZA(),H()]).optional(),hole_diameter:Ai([ZA(),H()]).optional(),width:Ai([ZA(),H()]).optional(),height:Ai([ZA(),H()]).optional()}),X8A=yB.extend({ftype:kA("simple_mosfet"),channel_type:Ct(["n","p"]),mosfet_mode:Ct(["enhancement","depletion"])}),$8A=yB.extend({ftype:kA("simple_op_amp")}),AWA=yB.extend({ftype:kA("simple_switch")}),eWA=PA({type:kA("source_project_metadata"),name:H().optional(),software_used_string:H().optional(),project_url:H().optional(),created_at:Mrt.optional()}),Trt=PA({type:kA("source_missing_property_error"),source_missing_property_error_id:jt("source_missing_property_error"),source_component_id:H(),property_name:H(),subcircuit_id:H().optional(),error_type:kA("source_missing_property_error").default("source_missing_property_error"),message:H()}).describe("The source code is missing a property"),qrt=PA({type:kA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:jt("source_failed_to_create_component_error"),error_type:kA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:H().optional(),subcircuit_id:H().optional(),parent_source_component_id:H().optional(),message:H(),pcb_center:PA({x:ZA().optional(),y:ZA().optional()}).optional(),schematic_center:PA({x:ZA().optional(),y:ZA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),tWA=PA({type:kA("source_trace_not_connected_error"),source_trace_not_connected_error_id:jt("source_trace_not_connected_error"),error_type:kA("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:H(),subcircuit_id:H().optional(),source_group_id:H().optional(),source_trace_id:H().optional(),connected_source_port_ids:be(H()).optional(),selectors_not_found:be(H()).optional()}).describe("Occurs when a source trace selector does not match any ports"),Prt=PA({type:kA("source_property_ignored_warning"),source_property_ignored_warning_id:jt("source_property_ignored_warning"),source_component_id:H(),property_name:H(),subcircuit_id:H().optional(),error_type:kA("source_property_ignored_warning").default("source_property_ignored_warning"),message:H()}).describe("The source property was ignored"),iWA=PA({type:kA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:jt("source_pin_missing_trace_warning"),warning_type:kA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:H(),source_component_id:H(),source_port_id:H(),subcircuit_id:H().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),Ort=yB.extend({ftype:kA("simple_voltage_probe")}),Wrt=yB.extend({ftype:kA("interconnect")}),Zrt=Ai([H8A,L8A,QBA,Hrt,Y8A,Yrt,J8A,K8A,T8A,q8A,P8A,O8A,Krt,W8A,Z8A,V8A,AWA,j8A,z8A,X8A,$8A,Jrt,Ort,Wrt,eWA,Trt,qrt,tWA,Prt,iWA]),Vrt=PA({type:kA("source_port"),pin_number:ZA().optional(),port_hints:be(H()).optional(),name:H(),source_port_id:H(),source_component_id:H().optional(),source_group_id:H().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),must_be_connected:ce().optional()}),jrt=PA({type:kA("source_component_internal_connection"),source_component_internal_connection_id:H(),source_component_id:H(),source_port_ids:be(H()),subcircuit_id:H().optional()}),zrt=PA({type:kA("source_trace"),source_trace_id:H(),connected_source_port_ids:be(H()),connected_source_net_ids:be(H()),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),max_length:ZA().optional(),min_trace_thickness:ZA().optional(),display_name:H().optional()}),Xrt=PA({type:kA("source_group"),source_group_id:H(),subcircuit_id:H().optional(),parent_subcircuit_id:H().optional(),parent_source_group_id:H().optional(),is_subcircuit:ce().optional(),show_as_schematic_box:ce().optional(),name:H().optional(),was_automatically_named:ce().optional()}),$rt=PA({type:kA("source_net"),source_net_id:H(),name:H(),member_source_group_ids:be(H()),is_power:ce().optional(),is_ground:ce().optional(),is_digital_signal:ce().optional(),is_analog_signal:ce().optional(),is_positive_voltage_source:ce().optional(),trace_width:ZA().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional()}),Aat=PA({type:kA("source_board"),source_board_id:H(),source_group_id:H(),title:H().optional()}).describe("Defines a board in the source domain"),eat=PA({type:kA("source_pcb_ground_plane"),source_pcb_ground_plane_id:H(),source_group_id:H(),source_net_id:H(),subcircuit_id:H().optional()}).describe("Defines a ground plane in the source domain"),tat=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],oWA=Ct(tat),Mr=oWA.or(PA({name:oWA})).transform(t=>typeof t=="string"?t:t.name),um=Ct(["top","bottom"]),iat=PA({type:kA("source_manually_placed_via"),source_manually_placed_via_id:H(),source_group_id:H(),source_net_id:H(),subcircuit_id:H().optional(),source_trace_id:H().optional()}).describe("Defines a via that is manually placed in the source domain"),oat=PA({type:kA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:jt("source_pin_must_be_connected_error"),error_type:kA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),message:H(),source_component_id:H(),source_port_id:H(),subcircuit_id:H().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),nat=PA({type:kA("unknown_error_finding_part"),unknown_error_finding_part_id:jt("unknown_error_finding_part"),error_type:kA("unknown_error_finding_part").default("unknown_error_finding_part"),message:H(),source_component_id:H().optional(),subcircuit_id:H().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),sat=PA({type:kA("schematic_box"),schematic_component_id:H().optional(),width:mt,height:mt,is_dashed:ce().default(!1),x:mt,y:mt,subcircuit_id:H().optional()}).describe("Draws a box on the schematic"),rat=PA({type:kA("schematic_path"),schematic_component_id:H(),fill_color:Ct(["red","blue"]).optional(),is_filled:ce().optional(),points:be(xo),subcircuit_id:H().optional()}),aat=Na(PA({left_margin:$A.optional(),right_margin:$A.optional(),top_margin:$A.optional(),bottom_margin:$A.optional()})),gat=PA({left_size:ZA(),right_size:ZA(),top_size:ZA().optional(),bottom_size:ZA().optional()}),Iat=PA({left_side:PA({pins:be(ZA()),direction:Ct(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:PA({pins:be(ZA()),direction:Ct(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:PA({pins:be(ZA()),direction:Ct(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:PA({pins:be(ZA()),direction:Ct(["left-to-right","right-to-left"]).optional()}).optional()}),cat=Ai([gat,Iat]),Bat=PA({type:kA("schematic_component"),size:U8A,center:xo,source_component_id:H().optional(),schematic_component_id:H(),pin_spacing:$A.optional(),pin_styles:aat.optional(),box_width:$A.optional(),symbol_name:H().optional(),port_arrangement:cat.optional(),port_labels:Na(H()).optional(),symbol_display_value:H().optional(),subcircuit_id:H().optional(),schematic_group_id:H().optional(),is_schematic_group:ce().optional(),source_group_id:H().optional(),is_box_with_pins:ce().optional().default(!0)}),Cat=PA({type:kA("schematic_line"),schematic_line_id:jt("schematic_line"),schematic_component_id:H(),x1:mt,y1:mt,x2:mt,y2:mt,stroke_width:mt.nullable().optional(),color:H().default("#000000"),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled line on the schematic"),lat=PA({type:kA("schematic_rect"),schematic_rect_id:jt("schematic_rect"),schematic_component_id:H(),center:xo,width:mt,height:mt,rotation:pd.default(0),stroke_width:mt.nullable().optional(),color:H().default("#000000"),is_filled:ce().default(!1),fill_color:H().optional(),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled rectangle on the schematic"),Qat=PA({type:kA("schematic_circle"),schematic_circle_id:jt("schematic_circle"),schematic_component_id:H(),center:xo,radius:mt,stroke_width:mt.nullable().optional(),color:H().default("#000000"),is_filled:ce().default(!1),fill_color:H().optional(),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled circle on the schematic"),Eat=PA({type:kA("schematic_arc"),schematic_arc_id:jt("schematic_arc"),schematic_component_id:H(),center:xo,radius:mt,start_angle_degrees:pd,end_angle_degrees:pd,direction:Ct(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:mt.nullable().optional(),color:H().default("#000000"),is_dashed:ce().default(!1),subcircuit_id:H().optional()}).describe("Draws a styled arc on the schematic"),hat=PA({type:kA("schematic_trace"),schematic_trace_id:H(),source_trace_id:H().optional(),junctions:be(PA({x:ZA(),y:ZA()})),edges:be(PA({from:PA({x:ZA(),y:ZA()}),to:PA({x:ZA(),y:ZA()}),is_crossing:ce().optional(),from_schematic_port_id:H().optional(),to_schematic_port_id:H().optional()})),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional()}),uat=Ct(["center","left","right","top","bottom"]),dat=PA({type:kA("schematic_text"),schematic_component_id:H().optional(),schematic_text_id:H(),text:H(),font_size:ZA().default(.18),position:PA({x:mt,y:mt}),rotation:ZA().default(0),anchor:Ai([uat.describe("legacy"),YG]).default("center"),color:H().default("#000000"),subcircuit_id:H().optional()}),pat=PA({type:kA("schematic_port"),schematic_port_id:H(),source_port_id:H(),schematic_component_id:H().optional(),center:xo,facing_direction:Ct(["up","down","left","right"]).optional(),distance_from_component_edge:ZA().optional(),side_of_component:Ct(["top","bottom","left","right"]).optional(),true_ccw_index:ZA().optional(),pin_number:ZA().optional(),display_pin_label:H().optional(),subcircuit_id:H().optional(),is_connected:ce().optional(),has_input_arrow:ce().optional(),has_output_arrow:ce().optional()}).describe("Defines a port on a schematic component"),fat=PA({type:kA("schematic_net_label"),schematic_net_label_id:jt("schematic_net_label"),schematic_trace_id:H().optional(),source_trace_id:H().optional(),source_net_id:H(),center:xo,anchor_position:xo.optional(),anchor_side:Ct(["top","bottom","left","right"]),text:H(),symbol_name:H().optional(),is_movable:ce().optional(),subcircuit_id:H().optional()}),yat=PA({type:kA("schematic_error"),schematic_error_id:H(),error_type:kA("schematic_port_not_found").default("schematic_port_not_found"),message:H(),subcircuit_id:H().optional()}).describe("Defines a schematic error on the schematic"),wat=PA({type:kA("schematic_layout_error"),schematic_layout_error_id:jt("schematic_layout_error"),error_type:kA("schematic_layout_error").default("schematic_layout_error"),message:H(),source_group_id:H(),schematic_group_id:H(),subcircuit_id:H().optional()}).describe("Error emitted when schematic layout fails for a group"),EBA=PA({type:kA("schematic_debug_object"),label:H().optional(),subcircuit_id:H().optional()}),mat=EBA.extend({shape:kA("rect"),center:xo,size:U8A}),Dat=EBA.extend({shape:kA("line"),start:xo,end:xo}),Sat=EBA.extend({shape:kA("point"),center:xo}),bat=Mp("shape",[mat,Dat,Sat]),xat=PA({type:kA("schematic_voltage_probe"),schematic_voltage_probe_id:H(),source_component_id:H().optional(),name:H().optional(),position:xo,schematic_trace_id:H(),voltage:k_.optional(),subcircuit_id:H().optional(),color:H().optional(),label_alignment:YG.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),kat=PA({type:kA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:jt("schematic_manual_edit_conflict_warning"),warning_type:kA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:H(),schematic_component_id:H(),schematic_group_id:H().optional(),subcircuit_id:H().optional(),source_component_id:H()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),Gat=PA({type:kA("schematic_group"),schematic_group_id:jt("schematic_group"),source_group_id:H(),is_subcircuit:ce().optional(),subcircuit_id:H().optional(),width:$A,height:$A,center:xo,schematic_component_ids:be(H()),show_as_schematic_box:ce().optional(),name:H().optional(),description:H().optional()}).describe("Defines a group of components on the schematic"),Fat=PA({type:kA("schematic_table"),schematic_table_id:jt("schematic_table"),anchor_position:xo,column_widths:be(mt),row_heights:be(mt),cell_padding:mt.optional(),border_width:mt.optional(),subcircuit_id:H().optional(),schematic_component_id:H().optional(),anchor:YG.optional()}).describe("Defines a table on the schematic"),Rat=PA({type:kA("schematic_table_cell"),schematic_table_cell_id:jt("schematic_table_cell"),schematic_table_id:H(),start_row_index:ZA(),end_row_index:ZA(),start_column_index:ZA(),end_column_index:ZA(),text:H().optional(),center:xo,width:mt,height:mt,horizontal_align:Ct(["left","center","right"]).optional(),vertical_align:Ct(["top","middle","bottom"]).optional(),font_size:mt.optional(),subcircuit_id:H().optional()}).describe("Defines a cell within a schematic_table"),Nat=PA({type:kA("schematic_sheet"),schematic_sheet_id:jt("schematic_sheet"),name:H().optional(),subcircuit_id:H().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),_at=PA({x:mt,y:mt,bulge:ZA().optional()}),nWA=PA({vertices:be(_at)}),Mat=PA({outer_ring:nWA,inner_rings:be(nWA).default([])}),vat=PA({x:mt,y:mt,via:ce().optional(),via_to_layer:Mr.optional()});be(vat);var Uat=PA({x:mt,y:mt,via:ce().optional(),to_layer:Mr.optional(),trace_width:mt.optional()}),Lat=PA({type:kA("pcb_component"),pcb_component_id:jt("pcb_component"),source_component_id:H(),center:xo,layer:Mr,rotation:pd,display_offset_x:H().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:$A,height:$A,do_not_place:ce().optional(),subcircuit_id:H().optional(),pcb_group_id:H().optional(),position_mode:Ct(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:H().optional(),positioned_relative_to_pcb_board_id:H().optional(),obstructs_within_bounds:ce().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),sWA=PA({type:kA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:kA("circle"),hole_diameter:ZA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()});sWA.describe("Defines a circular hole on the PCB");var rWA=PA({type:kA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:kA("rect"),hole_width:ZA(),hole_height:ZA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()});rWA.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square.");var aWA=PA({type:kA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:Ct(["circle","square"]),hole_diameter:ZA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()});aWA.describe("Defines a circular or square hole on the PCB");var gWA=PA({type:kA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:kA("oval"),hole_width:ZA(),hole_height:ZA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()});gWA.describe("Defines an oval hole on the PCB");var IWA=PA({type:kA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:kA("pill"),hole_width:ZA(),hole_height:ZA(),x:mt,y:mt,is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()});IWA.describe("Defines a pill-shaped hole on the PCB");var cWA=PA({type:kA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_component_id:H().optional(),hole_shape:kA("rotated_pill"),hole_width:ZA(),hole_height:ZA(),x:mt,y:mt,ccw_rotation:pd,is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()});cWA.describe("Defines a rotated pill-shaped hole on the PCB");var Hat=aWA.or(gWA).or(IWA).or(cWA).or(sWA).or(rWA),Yat=PA({type:kA("pcb_plated_hole"),shape:kA("circle"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),outer_diameter:ZA(),hole_diameter:ZA(),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(Mr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:ZA().optional()}),Jat=PA({type:kA("pcb_plated_hole"),shape:Ct(["oval","pill"]),pcb_group_id:H().optional(),subcircuit_id:H().optional(),outer_width:ZA(),outer_height:ZA(),hole_width:ZA(),hole_height:ZA(),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,ccw_rotation:pd,layers:be(Mr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:ZA().optional()}),Kat=PA({type:kA("pcb_plated_hole"),shape:kA("circular_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:kA("circle"),pad_shape:kA("rect"),hole_diameter:ZA(),rect_pad_width:ZA(),rect_pad_height:ZA(),rect_border_radius:ZA().optional(),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(Mr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:ZA().optional()}),Tat=PA({type:kA("pcb_plated_hole"),shape:kA("pill_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:kA("pill"),pad_shape:kA("rect"),hole_width:ZA(),hole_height:ZA(),rect_pad_width:ZA(),rect_pad_height:ZA(),rect_border_radius:ZA().optional(),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(Mr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:ZA().optional()}),qat=PA({type:kA("pcb_plated_hole"),shape:kA("rotated_pill_hole_with_rect_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:kA("rotated_pill"),pad_shape:kA("rect"),hole_width:ZA(),hole_height:ZA(),hole_ccw_rotation:pd,rect_pad_width:ZA(),rect_pad_height:ZA(),rect_border_radius:ZA().optional(),rect_ccw_rotation:pd,hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(Mr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:ZA().optional()}),Pat=PA({type:kA("pcb_plated_hole"),shape:kA("hole_with_polygon_pad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),hole_shape:Ct(["circle","oval","pill","rotated_pill"]),hole_diameter:ZA().optional(),hole_width:ZA().optional(),hole_height:ZA().optional(),pad_outline:be(PA({x:mt,y:mt})).min(3),hole_offset_x:mt.default(0),hole_offset_y:mt.default(0),is_covered_with_solder_mask:ce().optional(),x:mt,y:mt,layers:be(Mr),port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:ZA().optional()}),Oat=Ai([Yat,Jat,Kat,Tat,qat,Pat]),Wat=PA({type:kA("pcb_port"),pcb_port_id:jt("pcb_port"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),source_port_id:H(),pcb_component_id:H().optional(),x:mt,y:mt,layers:be(Mr),is_board_pinout:ce().optional()}).describe("Defines a port on the PCB"),Zat=PA({type:kA("pcb_smtpad"),shape:kA("circle"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,radius:ZA(),layer:Mr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()}),Vat=PA({type:kA("pcb_smtpad"),shape:kA("rect"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),rect_border_radius:ZA().optional(),corner_radius:ZA().optional(),layer:Mr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()}),jat=PA({type:kA("pcb_smtpad"),shape:kA("rotated_rect"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),rect_border_radius:ZA().optional(),corner_radius:ZA().optional(),ccw_rotation:pd,layer:Mr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()}),zat=PA({type:kA("pcb_smtpad"),shape:kA("pill"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),radius:ZA(),layer:Mr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()}),Xat=PA({type:kA("pcb_smtpad"),shape:kA("rotated_pill"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),radius:ZA(),ccw_rotation:pd,layer:Mr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()}),$at=PA({type:kA("pcb_smtpad"),shape:kA("polygon"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),points:be(xo),layer:Mr,port_hints:be(H()).optional(),pcb_component_id:H().optional(),pcb_port_id:H().optional(),is_covered_with_solder_mask:ce().optional(),soldermask_margin:ZA().optional()}),Agt=Mp("shape",[Zat,Vat,jat,Xat,zat,$at]).describe("Defines an SMT pad on the PCB"),egt=PA({type:kA("pcb_solder_paste"),shape:kA("circle"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,radius:ZA(),layer:Mr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),tgt=PA({type:kA("pcb_solder_paste"),shape:kA("rect"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),layer:Mr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),igt=PA({type:kA("pcb_solder_paste"),shape:kA("pill"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),radius:ZA(),layer:Mr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),ogt=PA({type:kA("pcb_solder_paste"),shape:kA("rotated_rect"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),ccw_rotation:mt,layer:Mr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),ngt=PA({type:kA("pcb_solder_paste"),shape:kA("oval"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),x:mt,y:mt,width:ZA(),height:ZA(),layer:Mr,pcb_component_id:H().optional(),pcb_smtpad_id:H().optional()}),sgt=Ai([egt,tgt,igt,ogt,ngt]).describe("Defines solderpaste on the PCB"),rgt=PA({type:kA("pcb_text"),pcb_text_id:jt("pcb_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),text:H(),center:xo,layer:Mr,width:$A,height:$A,lines:ZA(),align:Ct(["bottom-left"])}).describe("Defines text on the PCB"),agt=PA({route_type:kA("wire"),x:mt,y:mt,width:mt,start_pcb_port_id:H().optional(),end_pcb_port_id:H().optional(),layer:Mr}),ggt=PA({route_type:kA("via"),x:mt,y:mt,hole_diameter:mt.optional(),outer_diameter:mt.optional(),from_layer:H(),to_layer:H()}),Igt=Ai([agt,ggt]),cgt=PA({type:kA("pcb_trace"),source_trace_id:H().optional(),pcb_component_id:H().optional(),pcb_trace_id:jt("pcb_trace"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),route_thickness_mode:Ct(["constant","interpolated"]).default("constant").optional(),route_order_index:ZA().optional(),should_round_corners:ce().optional(),trace_length:ZA().optional(),highlight_color:H().optional(),route:be(Igt)}).describe("Defines a trace on the PCB"),Bgt=PA({type:kA("pcb_trace_error"),pcb_trace_error_id:jt("pcb_trace_error"),error_type:kA("pcb_trace_error").default("pcb_trace_error"),message:H(),center:xo.optional(),pcb_trace_id:H(),source_trace_id:H(),pcb_component_ids:be(H()),pcb_port_ids:be(H()),subcircuit_id:H().optional()}).describe("Defines a trace error on the PCB"),Cgt=PA({type:kA("pcb_trace_missing_error"),pcb_trace_missing_error_id:jt("pcb_trace_missing_error"),error_type:kA("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:H(),center:xo.optional(),source_trace_id:H(),pcb_component_ids:be(H()),pcb_port_ids:be(H()),subcircuit_id:H().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),lgt=PA({type:kA("pcb_port_not_matched_error"),pcb_error_id:jt("pcb_error"),error_type:kA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:H(),pcb_component_ids:be(H()),subcircuit_id:H().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Qgt=PA({type:kA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:jt("pcb_port_not_connected_error"),error_type:kA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:H(),pcb_port_ids:be(H()),pcb_component_ids:be(H()),subcircuit_id:H().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),Egt=PA({type:kA("pcb_net"),pcb_net_id:jt("pcb_net"),source_net_id:H().optional(),highlight_color:H().optional()}).describe("Defines a net on the PCB"),hgt=PA({type:kA("pcb_via"),pcb_via_id:jt("pcb_via"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),x:mt,y:mt,outer_diameter:mt.default("0.6mm"),hole_diameter:mt.default("0.25mm"),from_layer:Mr.optional(),to_layer:Mr.optional(),layers:be(Mr),pcb_trace_id:H().optional(),net_is_assignable:ce().optional(),net_assigned:ce().optional(),is_tented:ce().optional()}).describe("Defines a via on the PCB"),ugt=PA({type:kA("pcb_board"),pcb_board_id:jt("pcb_board"),pcb_panel_id:H().optional(),is_subcircuit:ce().optional(),subcircuit_id:H().optional(),width:$A.optional(),height:$A.optional(),center:xo,display_offset_x:H().optional().describe("How to display the x offset for this board, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this board, usually corresponding with how the user specified it"),thickness:$A.optional().default(1.4),num_layers:ZA().optional().default(4),outline:be(xo).optional(),shape:Ct(["rect","polygon"]).optional(),material:Ct(["fr4","fr1"]).default("fr4"),anchor_position:xo.optional(),anchor_alignment:YG.optional(),position_mode:Ct(["relative_to_panel_anchor","none"]).optional()}).describe("Defines the board outline of the PCB"),dgt=PA({type:kA("pcb_panel"),pcb_panel_id:jt("pcb_panel"),width:$A,height:$A,center:xo,covered_with_solder_mask:ce().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),pgt=PA({type:kA("pcb_placement_error"),pcb_placement_error_id:jt("pcb_placement_error"),error_type:kA("pcb_placement_error").default("pcb_placement_error"),message:H(),subcircuit_id:H().optional()}).describe("Defines a placement error on the PCB"),fgt=PA({type:kA("pcb_trace_hint"),pcb_trace_hint_id:jt("pcb_trace_hint"),pcb_port_id:H(),pcb_component_id:H(),route:be(Uat),subcircuit_id:H().optional()}).describe("A hint that can be used during generation of a PCB trace"),ygt=PA({type:kA("pcb_silkscreen_line"),pcb_silkscreen_line_id:jt("pcb_silkscreen_line"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),stroke_width:mt.default("0.1mm"),x1:mt,y1:mt,x2:mt,y2:mt,layer:um}).describe("Defines a silkscreen line on the PCB"),wgt=PA({type:kA("pcb_silkscreen_path"),pcb_silkscreen_path_id:jt("pcb_silkscreen_path"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:um,route:be(xo),stroke_width:$A}).describe("Defines a silkscreen path on the PCB"),mgt=PA({type:kA("pcb_silkscreen_text"),pcb_silkscreen_text_id:jt("pcb_silkscreen_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("0.2mm"),pcb_component_id:H(),text:H(),is_knockout:ce().default(!1).optional(),knockout_padding:PA({left:$A,top:$A,bottom:$A,right:$A}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:ZA().optional(),layer:Mr,is_mirrored:ce().default(!1).optional(),anchor_position:xo.default({x:0,y:0}),anchor_alignment:YG.default("center")}).describe("Defines silkscreen text on the PCB"),Dgt=PA({type:kA("pcb_copper_text"),pcb_copper_text_id:jt("pcb_copper_text"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("0.2mm"),pcb_component_id:H(),text:H(),is_knockout:ce().default(!1).optional(),knockout_padding:PA({left:$A,top:$A,bottom:$A,right:$A}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:ZA().optional(),layer:Mr,is_mirrored:ce().default(!1).optional(),anchor_position:xo.default({x:0,y:0}),anchor_alignment:YG.default("center")}).describe("Defines copper text on the PCB"),Sgt=PA({type:kA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:jt("pcb_silkscreen_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,width:$A,height:$A,layer:Mr,stroke_width:$A.default("1mm"),corner_radius:$A.optional(),is_filled:ce().default(!0).optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),ccw_rotation:ZA().optional()}).describe("Defines a silkscreen rect on the PCB"),bgt=PA({type:kA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:jt("pcb_silkscreen_circle"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,radius:$A,layer:um,stroke_width:$A.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),xgt=PA({type:kA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:jt("pcb_silkscreen_oval"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,radius_x:mt,radius_y:mt,layer:um,ccw_rotation:pd.optional()}).describe("Defines a silkscreen oval on the PCB"),kgt=PA({type:kA("pcb_silkscreen_pill"),pcb_silkscreen_pill_id:jt("pcb_silkscreen_pill"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,width:$A,height:$A,layer:Mr,ccw_rotation:ZA().optional()}).describe("Defines a silkscreen pill on the PCB"),Ggt=PA({type:kA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:jt("pcb_fabrication_note_text"),subcircuit_id:H().optional(),pcb_group_id:H().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("1mm"),pcb_component_id:H(),text:H(),layer:um,anchor_position:xo.default({x:0,y:0}),anchor_alignment:Ct(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:H().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),Fgt=PA({type:kA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:jt("pcb_fabrication_note_path"),pcb_component_id:H(),subcircuit_id:H().optional(),layer:Mr,route:be(xo),stroke_width:$A,color:H().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),Rgt=PA({type:kA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:jt("pcb_fabrication_note_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,width:$A,height:$A,layer:um,stroke_width:$A.default("0.1mm"),corner_radius:$A.optional(),is_filled:ce().optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),color:H().optional()}).describe("Defines a fabrication note rectangle on the PCB"),Ngt=PA({type:kA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:jt("pcb_fabrication_note_dimension"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:um,from:xo,to:xo,text:H().optional(),text_ccw_rotation:ZA().optional(),offset:$A.optional(),offset_distance:$A.optional(),offset_direction:PA({x:ZA(),y:ZA()}).optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:$A.default("1mm"),color:H().optional(),arrow_size:$A.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),_gt=PA({type:kA("pcb_note_text"),pcb_note_text_id:jt("pcb_note_text"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:mt.default("1mm"),text:H().optional(),anchor_position:xo.default({x:0,y:0}),anchor_alignment:Ct(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:H().optional()}).describe("Defines a documentation note in text on the PCB"),Mgt=PA({type:kA("pcb_note_rect"),pcb_note_rect_id:jt("pcb_note_rect"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),center:xo,width:$A,height:$A,stroke_width:$A.default("0.1mm"),corner_radius:$A.optional(),is_filled:ce().optional(),has_stroke:ce().optional(),is_stroke_dashed:ce().optional(),color:H().optional()}).describe("Defines a rectangular documentation note on the PCB"),vgt=PA({type:kA("pcb_note_path"),pcb_note_path_id:jt("pcb_note_path"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),route:be(xo),stroke_width:$A.default("0.1mm"),color:H().optional()}).describe("Defines a polyline documentation note on the PCB"),Ugt=PA({type:kA("pcb_note_line"),pcb_note_line_id:jt("pcb_note_line"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),text:H().optional(),x1:mt,y1:mt,x2:mt,y2:mt,stroke_width:mt.default("0.1mm"),color:H().optional(),is_dashed:ce().optional()}).describe("Defines a straight documentation note line on the PCB"),Lgt=PA({type:kA("pcb_note_dimension"),pcb_note_dimension_id:jt("pcb_note_dimension"),pcb_component_id:H().optional(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),name:H().optional(),from:xo,to:xo,text:H().optional(),text_ccw_rotation:ZA().optional(),offset_distance:$A.optional(),offset_direction:PA({x:ZA(),y:ZA()}).optional(),font:kA("tscircuit2024").default("tscircuit2024"),font_size:$A.default("1mm"),color:H().optional(),arrow_size:$A.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),Hgt=PA({type:kA("pcb_footprint_overlap_error"),pcb_error_id:jt("pcb_error"),error_type:kA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:H(),pcb_smtpad_ids:be(H()).optional(),pcb_plated_hole_ids:be(H()).optional(),pcb_hole_ids:be(H()).optional(),pcb_keepout_ids:be(H()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),Ygt=PA({type:kA("pcb_keepout"),shape:kA("rect"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,width:mt,height:mt,pcb_keepout_id:H(),layers:be(H()),description:H().optional()}).or(PA({type:kA("pcb_keepout"),shape:kA("circle"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,radius:mt,pcb_keepout_id:H(),layers:be(H()),description:H().optional()})),xO=PA({type:kA("pcb_cutout"),pcb_cutout_id:jt("pcb_cutout"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),pcb_board_id:H().optional(),pcb_panel_id:H().optional()}),Jgt=xO.extend({shape:kA("rect"),center:xo,width:$A,height:$A,rotation:pd.optional(),corner_radius:$A.optional()}),Kgt=xO.extend({shape:kA("circle"),center:xo,radius:$A}),Tgt=xO.extend({shape:kA("polygon"),points:be(xo)}),qgt=xO.extend({shape:kA("path"),route:be(xo),slot_width:$A,slot_length:$A.optional(),space_between_slots:$A.optional(),slot_corner_radius:$A.optional()}),Pgt=Mp("shape",[Jgt,Kgt,Tgt,qgt]).describe("Defines a cutout on the PCB, removing board material."),Ogt=PA({type:kA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:jt("pcb_missing_footprint_error"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),error_type:kA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:H(),message:H()}).describe("Defines a missing footprint error on the PCB"),Wgt=PA({type:kA("external_footprint_load_error"),external_footprint_load_error_id:jt("external_footprint_load_error"),pcb_component_id:H(),source_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),footprinter_string:H().optional(),error_type:kA("external_footprint_load_error").default("external_footprint_load_error"),message:H()}).describe("Defines an error when an external footprint fails to load"),Zgt=PA({type:kA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:jt("circuit_json_footprint_load_error"),pcb_component_id:H(),source_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),error_type:kA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:H(),circuit_json:be(vI()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),Vgt=PA({type:kA("pcb_group"),pcb_group_id:jt("pcb_group"),source_group_id:H(),is_subcircuit:ce().optional(),subcircuit_id:H().optional(),width:$A.optional(),height:$A.optional(),center:xo,display_offset_x:H().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:H().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:be(xo).optional(),anchor_position:xo.optional(),anchor_alignment:YG.default("center"),position_mode:Ct(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:H().optional(),positioned_relative_to_pcb_board_id:H().optional(),pcb_component_ids:be(H()),child_layout_mode:Ct(["packed","none"]).optional(),name:H().optional(),description:H().optional(),layout_mode:H().optional(),autorouter_configuration:PA({trace_clearance:$A}).optional(),autorouter_used_string:H().optional()}).describe("Defines a group of components on the PCB"),jgt=PA({type:kA("pcb_autorouting_error"),pcb_error_id:jt("pcb_autorouting_error"),error_type:kA("pcb_autorouting_error").default("pcb_autorouting_error"),message:H(),subcircuit_id:H().optional()}).describe("The autorouting has failed to route a portion of the board"),zgt=PA({type:kA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:jt("pcb_manual_edit_conflict_warning"),warning_type:kA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:H(),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),source_component_id:H()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),Xgt=PA({type:kA("pcb_breakout_point"),pcb_breakout_point_id:jt("pcb_breakout_point"),pcb_group_id:H(),subcircuit_id:H().optional(),source_trace_id:H().optional(),source_port_id:H().optional(),source_net_id:H().optional(),x:mt,y:mt}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),$gt=PA({type:kA("pcb_ground_plane"),pcb_ground_plane_id:jt("pcb_ground_plane"),source_pcb_ground_plane_id:H(),source_net_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional()}).describe("Defines a ground plane on the PCB"),AIt=PA({type:kA("pcb_ground_plane_region"),pcb_ground_plane_region_id:jt("pcb_ground_plane_region"),pcb_ground_plane_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:Mr,points:be(xo)}).describe("Defines a polygon region of a ground plane"),eIt=PA({type:kA("pcb_thermal_spoke"),pcb_thermal_spoke_id:jt("pcb_thermal_spoke"),pcb_ground_plane_id:H(),shape:H(),spoke_count:ZA(),spoke_thickness:mt,spoke_inner_diameter:mt,spoke_outer_diameter:mt,pcb_plated_hole_id:H().optional(),subcircuit_id:H().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),hBA=PA({type:kA("pcb_copper_pour"),pcb_copper_pour_id:jt("pcb_copper_pour"),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:Mr,source_net_id:H().optional(),covered_with_solder_mask:ce().optional().default(!0)}),tIt=hBA.extend({shape:kA("rect"),center:xo,width:$A,height:$A,rotation:pd.optional()}),iIt=hBA.extend({shape:kA("brep"),brep_shape:Mat}),oIt=hBA.extend({shape:kA("polygon"),points:be(xo)}),nIt=Mp("shape",[tIt,iIt,oIt]).describe("Defines a copper pour on the PCB."),sIt=PA({type:kA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:jt("pcb_component_outside_board_error"),error_type:kA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:H(),pcb_component_id:H(),pcb_board_id:H(),component_center:xo,component_bounds:PA({min_x:ZA(),max_x:ZA(),min_y:ZA(),max_y:ZA()}),subcircuit_id:H().optional(),source_component_id:H().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),rIt=PA({type:kA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:jt("pcb_component_invalid_layer_error"),error_type:kA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:H(),pcb_component_id:H().optional(),source_component_id:H(),layer:Mr,subcircuit_id:H().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),aIt=PA({type:kA("pcb_via_clearance_error"),pcb_error_id:jt("pcb_error"),error_type:kA("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:H(),pcb_via_ids:be(H()).min(2),minimum_clearance:mt.optional(),actual_clearance:mt.optional(),pcb_center:PA({x:ZA().optional(),y:ZA().optional()}).optional(),subcircuit_id:H().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),gIt=PA({type:kA("pcb_courtyard_rect"),pcb_courtyard_rect_id:jt("pcb_courtyard_rect"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),center:xo,width:$A,height:$A,layer:um,color:H().optional()}).describe("Defines a courtyard rectangle on the PCB"),IIt=PA({type:kA("pcb_courtyard_outline"),pcb_courtyard_outline_id:jt("pcb_courtyard_outline"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:um,outline:be(xo).min(2),stroke_width:$A.default("0.1mm"),is_closed:ce().optional(),is_stroke_dashed:ce().optional(),color:H().optional()}).describe("Defines a courtyard outline on the PCB"),cIt=PA({type:kA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:jt("pcb_courtyard_polygon"),pcb_component_id:H(),pcb_group_id:H().optional(),subcircuit_id:H().optional(),layer:um,points:be(xo).min(3),color:H().optional()}).describe("Defines a courtyard polygon on the PCB"),BIt=PA({type:kA("cad_component"),cad_component_id:H(),pcb_component_id:H(),source_component_id:H(),position:lBA,rotation:lBA.optional(),size:lBA.optional(),layer:Mr.optional(),subcircuit_id:H().optional(),footprinter_string:H().optional(),model_obj_url:H().optional(),model_stl_url:H().optional(),model_3mf_url:H().optional(),model_gltf_url:H().optional(),model_glb_url:H().optional(),model_step_url:H().optional(),model_wrl_url:H().optional(),model_unit_to_mm_scale_factor:ZA().optional(),model_jscad:vI().optional(),show_as_translucent_model:ce().optional()}).describe("Defines a component on the PCB"),BWA=Ct(["sinewave","square","triangle","sawtooth"]),CIt=Ai([H(),ZA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(ZA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),lIt=PA({type:kA("simulation_voltage_source"),simulation_voltage_source_id:jt("simulation_voltage_source"),is_dc_source:kA(!0).optional().default(!0),positive_source_port_id:H().optional(),negative_source_port_id:H().optional(),positive_source_net_id:H().optional(),negative_source_net_id:H().optional(),voltage:k_}).describe("Defines a DC voltage source for simulation"),QIt=PA({type:kA("simulation_voltage_source"),simulation_voltage_source_id:jt("simulation_voltage_source"),is_dc_source:kA(!1),terminal1_source_port_id:H().optional(),terminal2_source_port_id:H().optional(),terminal1_source_net_id:H().optional(),terminal2_source_net_id:H().optional(),voltage:k_.optional(),frequency:bO.optional(),peak_to_peak_voltage:k_.optional(),wave_shape:BWA.optional(),phase:pd.optional(),duty_cycle:CIt.optional()}).describe("Defines an AC voltage source for simulation"),EIt=Ai([lIt,QIt]).describe("Defines a voltage source for simulation"),hIt=Ai([H(),ZA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(ZA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),uIt=PA({type:kA("simulation_current_source"),simulation_current_source_id:jt("simulation_current_source"),is_dc_source:kA(!0).optional().default(!0),positive_source_port_id:H().optional(),negative_source_port_id:H().optional(),positive_source_net_id:H().optional(),negative_source_net_id:H().optional(),current:BBA}).describe("Defines a DC current source for simulation"),dIt=PA({type:kA("simulation_current_source"),simulation_current_source_id:jt("simulation_current_source"),is_dc_source:kA(!1),terminal1_source_port_id:H().optional(),terminal2_source_port_id:H().optional(),terminal1_source_net_id:H().optional(),terminal2_source_net_id:H().optional(),current:BBA.optional(),frequency:bO.optional(),peak_to_peak_current:BBA.optional(),wave_shape:BWA.optional(),phase:pd.optional(),duty_cycle:hIt.optional()}).describe("Defines an AC current source for simulation"),pIt=Ai([uIt,dIt]).describe("Defines a current source for simulation"),fIt=Ai([kA("spice_dc_sweep"),kA("spice_dc_operating_point"),kA("spice_transient_analysis"),kA("spice_ac_analysis")]),yIt=PA({type:kA("simulation_experiment"),simulation_experiment_id:jt("simulation_experiment"),name:H(),experiment_type:fIt,time_per_step:CBA.optional(),start_time_ms:G_.optional(),end_time_ms:G_.optional()}).describe("Defines a simulation experiment configuration"),wIt=PA({type:kA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:jt("simulation_transient_voltage_graph"),simulation_experiment_id:H(),timestamps_ms:be(ZA()).optional(),voltage_levels:be(ZA()),source_component_id:H().optional(),subcircuit_connectivity_map_key:H().optional(),time_per_step:CBA,start_time_ms:G_,end_time_ms:G_,name:H().optional(),color:H().optional()}).describe("Stores voltage measurements over time for a simulation"),mIt=PA({type:kA("simulation_switch"),simulation_switch_id:jt("simulation_switch"),source_component_id:H().optional(),closes_at:G_.optional(),opens_at:G_.optional(),starts_closed:ce().optional(),switching_frequency:bO.optional()}).describe("Defines a switch for simulation timing control"),DIt=PA({type:kA("simulation_voltage_probe"),simulation_voltage_probe_id:jt("simulation_voltage_probe"),source_component_id:H().optional(),name:H().optional(),signal_input_source_port_id:H().optional(),signal_input_source_net_id:H().optional(),reference_input_source_port_id:H().optional(),reference_input_source_net_id:H().optional(),subcircuit_id:H().optional(),color:H().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,o=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&o?A.addIssue({code: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."}):o&&(!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."})}),SIt=PA({type:kA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:jt("simulation_unknown_experiment_error"),error_type:kA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:H(),simulation_experiment_id:H().optional(),subcircuit_id:H().optional()}).describe("An unknown error occurred during the simulation experiment."),bIt=PA({type:kA("simulation_op_amp"),simulation_op_amp_id:jt("simulation_op_amp"),source_component_id:H().optional(),inverting_input_source_port_id:H(),non_inverting_input_source_port_id:H(),output_source_port_id:H(),positive_supply_source_port_id:H(),negative_supply_source_port_id:H()}).describe("Defines a simple ideal operational amplifier for simulation");Ai([zrt,Vrt,jrt,Zrt,$rt,Xrt,J8A,L8A,QBA,Y8A,H8A,K8A,T8A,q8A,W8A,Z8A,V8A,AWA,j8A,z8A,X8A,$8A,O8A,P8A,eat,iat,Aat,eWA,tWA,iWA,oat,nat,Lat,Hat,Ogt,Wgt,Zgt,zgt,Oat,Ygt,Wat,Egt,rgt,cgt,hgt,Agt,sgt,ugt,dgt,Vgt,fgt,ygt,wgt,mgt,kgt,Dgt,Sgt,bgt,xgt,Bgt,Cgt,pgt,lgt,Qgt,aIt,Fgt,Ggt,Rgt,Ngt,_gt,Mgt,vgt,Ugt,Lgt,jgt,Hgt,Xgt,Pgt,$gt,AIt,eIt,nIt,sIt,rIt,gIt,IIt,cIt,sat,dat,Cat,lat,Qat,Eat,Bat,pat,hat,rat,yat,wat,fat,bat,xat,kat,Gat,Nat,Fat,Rat,BIt,EIt,pIt,yIt,wIt,mIt,DIt,SIt,bIt]);var xIt=Object.defineProperty,kIt=(t,A)=>{for(var e in A)xIt(t,e,{get:A[e],enumerable:!0})},iS={};kIt(iS,{axial:()=>Xct,bga:()=>rct,breakoutheaders:()=>cBt,cap:()=>vIt,dfn:()=>Nct,diode:()=>MIt,dip:()=>RIt,electrolytic:()=>Zlt,hc49:()=>CBt,jst:()=>Elt,led:()=>UIt,lqfp:()=>gBt,m2host:()=>QQt,melf:()=>DCt,micromelf:()=>kCt,minimelf:()=>hCt,mlp:()=>Ect,ms012:()=>Yct,ms013:()=>Kct,msop:()=>Slt,pad:()=>lBt,pinrow:()=>vct,platedhole:()=>sQt,potentiometer:()=>Plt,pushbutton:()=>iBt,qfn:()=>Cct,qfp:()=>Qct,quad:()=>R_,radial:()=>eBt,res:()=>oct,sma:()=>NCt,smb:()=>JCt,smbf:()=>jlt,smc:()=>PCt,smf:()=>UCt,smtpad:()=>oQt,sod110:()=>ult,sod123:()=>Zct,sod123f:()=>VBt,sod123fl:()=>$Bt,sod123w:()=>kBt,sod128:()=>rCt,sod323:()=>NBt,sod323f:()=>PBt,sod323fl:()=>Rlt,sod323w:()=>xlt,sod523:()=>dBt,sod723:()=>iCt,sod80:()=>DBt,sod882:()=>JBt,sod882d:()=>fCt,sod923:()=>UBt,soic:()=>gct,solderjumper:()=>Ult,son:()=>vlt,sop8:()=>wBt,sot:()=>aQt,sot223:()=>VCt,sot23:()=>Sct,sot23w:()=>olt,sot25:()=>Gct,sot323:()=>AQt,sot343:()=>cQt,sot363:()=>yct,sot457:()=>Ylt,sot563:()=>Lct,sot723:()=>qct,sot886:()=>mct,sot89:()=>CCt,sot963:()=>Klt,ssop:()=>uct,stampboard:()=>nBt,stampreceiver:()=>aBt,to220:()=>QCt,to92:()=>hBt,to92l:()=>hQt,to92s:()=>Ilt,tqfp:()=>lct,tssop:()=>pct,vssop:()=>wlt});var Li=(t,A,e)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:e,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:A},anchor_alignment:"center"}),Hi=PA({norefdes:ce().optional().describe("disable reference designator label"),invert:ce().optional().describe("hint to invert the orientation of the 3D model"),faceup:ce().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:ce().optional().describe("omit all silkscreen elements from the footprint")}),Pn=(t,A,e,i,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:wr(i),outer_diameter:wr(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),oS=(t,A,e,i,o,n,s,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:A,y:e,hole_diameter:wr(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:wr(o),rect_pad_height:wr(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],hole_offset_x:s,hole_offset_y:r}),CWA=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 hx(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var kO=Ai([H(),ZA()]).transform(t=>hx(t)),GIt=t=>Hi.extend({fn:H(),num_pins:ZA().optional().default(6),wide:ce().optional(),narrow:ce().optional(),w:kO.optional(),p:kO.default(t.p??"2.54mm"),id:kO.optional(),od:kO.optional(),nosquareplating:ce().optional().default(!1).describe("do not use rectangular pad for pin 1")}).transform(A=>(!A.id&&!A.od?Math.abs(A.p-1.27)<.01?(A.id=hx("0.55mm"),A.od=hx("0.95mm")):(A.id=hx("0.8mm"),A.od=hx("1.6mm")):A.id?A.od||(A.od=A.id*(1.5/1)):A.id=A.od*(1/1.5),A.w||(A.wide?A.w=hx("600mil"):A.narrow?A.w=hx("300mil"):A.w=hx(t.w??"300mil")),A)),FIt=GIt({}),lWA=(t,A,e,i,o)=>{const n=t/2,s=A<=n,r=n-1,a=i,g=a*r;return s?{x:-e/2,y:g/2-(A-1)*a}:{x:e/2,y:-g/2+(A-n-1)*a}},RIt=t=>{const A=FIt.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:I,y:c}=lWA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating);if(g===0&&!A.nosquareplating){e.push(oS(g+1,I,c,A.id??"0.8mm",A.od??"1mm",A.od??"1mm"));continue}e.push(Pn(g+1,I,c,A.id??"0.8mm",A.od??"1mm"))}(A.num_pins/2-1)*A.p+A.od;const o=A.w-A.od-1,n=(A.num_pins/2-1)*A.p+A.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/2,y:-n/2},{x:-o/2,y:n/2},...CWA.map(({x:g,y:I})=>({x:g*o/6,y:I*o/6+n/2})),{x:o/2,y:n/2},{x:o/2,y:-n/2},{x:-o/2,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1},r=[];for(let g=0;g<A.num_pins;g++){const I=g<A.num_pins/2,c=.6,{y:B}=lWA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating),C=I?-A.w/2-A.od/2-c:A.w/2+A.od/2+c,l=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:C,y:l},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Li(0,n/2+.5,.4);return{circuitJson:[...e,s,a,...r],parameters:A}},Qi=(t,A,e,i,o)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:o,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),QWA=[{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}],NIt=Object.fromEntries(QWA.map(t=>[t.metric,t])),_It=Object.fromEntries(QWA.map(t=>[t.imperial,t]));Hi.extend({tht:ce(),p:$A.optional(),pw:$A.optional(),ph:$A.optional(),metric:mt.optional(),imperial:mt.optional(),w:$A.optional(),h:$A.optional(),textbottom:ce().optional()});var GO=t=>{let{tht:A,p:e,pw:i,ph:o,metric:n,imperial:s,w:r,h:a,textbottom:g}=t;if(typeof r=="string"&&(r=fB(r)),typeof a=="string"&&(a=fB(a)),typeof e=="string"&&(e=fB(e)),typeof i=="string"&&(i=fB(i)),typeof o=="string"&&(o=fB(o)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let I;if(n&&(I=NIt[n]),s&&(I=_It[s]),I&&(r=I.w_mm_min,a=I.h_mm_min,e=I.p_mm_min,i=I.pw_mm_min,o=I.ph_mm_min),e===void 0||i===void 0||o===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:e/2,y:o/2+.4},{x:-e/2-i/2-.2,y:o/2+.4},{x:-e/2-i/2-.2,y:-o/2-.4},{x:e/2,y:-o/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},B=g?-o/2-.9:o/2+.9,C=Li(0,B,.2);return A?[Pn(1,-e/2,0,i,i*1/.8),Pn(2,e/2,0,i,i*1/.8),c,C]:[Qi(["1","left"],-e/2,0,i,o),Qi(["2","right"],e/2,0,i,o),c,C]},MIt=t=>({circuitJson:GO(t),parameters:t}),vIt=t=>({circuitJson:GO(t),parameters:t}),UIt=t=>({circuitJson:GO(t),parameters:t}),F_=t=>{const{padSpacing:A,padWidth:e,padHeight:i,padPitch:o,numRows:n,textbottom:s}=t,r=[],a=(n-1)*(o/2);for(let x=0;x<n;x++)r.push(a-x*o);const g=[];r.forEach((x,F)=>{g.push(Qi(F+1,-A/2,x,e,i))}),r.slice().reverse().forEach((x,F)=>{g.push(Qi(F+n+1,A/2,x,e,i))});const I=Math.max(...r)+i/2+.4,c=Math.min(...r)-i/2-.4,B=-A/2-e/2-.4,C=A/2+e/2+.4,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C*.5,y:I},{x:B*.5,y:I}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C*.5,y:c},{x:B*.5,y:c}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},E=-A/2,h=Math.max(...r),u=.2,d=E-e/2-.1,f=h+i/2+.1,D={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:[{x:d,y:f},{x:d-u,y:f},{x:d,y:f+u},{x:d,y:f}],stroke_width:.1},b=s?c-.9:I+.9,m=Li(0,b,.2);return[...g,l,Q,D,m]},LIt=Hi.extend({pw:H().default("0.5mm"),ph:H().default("0.4mm"),p:H().default("0.7mm"),textbottom:ce().optional()}),HIt=1,YIt=t=>{const A=LIt.parse(t),e=fB(A.pw),i=fB(A.ph),o=fB(A.p);return F_({padSpacing:HIt,padWidth:e,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},JIt=Hi.extend({pw:H().default("0.5mm"),ph:H().default("0.32mm"),p:H().default("0.5mm"),textbottom:ce().optional()}),KIt=1,TIt=t=>{const A=JIt.parse(t),e=fB(A.pw),i=fB(A.ph),o=fB(A.p);return F_({padSpacing:KIt,padWidth:e,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},qIt=Hi.extend({pw:H().default("0.9mm"),ph:H().default("0.4mm"),p:H().default("0.8mm"),textbottom:ce().optional()}),PIt=1.7,OIt=t=>{const A=qIt.parse(t),e=fB(A.pw),i=fB(A.ph),o=fB(A.p);return F_({padSpacing:PIt,padWidth:e,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},WIt=Hi.extend({pw:H().default("0.9mm"),ph:H().default("0.4mm"),p:H().default("0.8mm"),textbottom:ce().optional()}),ZIt=1.7,VIt=t=>{const A=WIt.parse(t),e=fB(A.pw),i=fB(A.ph),o=fB(A.p);return F_({padSpacing:ZIt,padWidth:e,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},jIt=Hi.extend({pw:H().default("0.7mm"),ph:H().default("0.64mm"),p:H().default("0.94mm"),textbottom:ce().optional()}),zIt=1.4,XIt=t=>{const A=jIt.parse(t),e=fB(A.pw),i=fB(A.ph),o=fB(A.p);return F_({padSpacing:zIt,padWidth:e,padHeight:i,padPitch:o,numRows:2,textbottom:A.textbottom})},$It=Hi.extend({pw:H().default("0.9mm"),ph:H().default("0.9mm"),p:H().default("1.34mm"),textbottom:ce().optional()}),Act=3,ect=t=>{const A=$It.parse(t),e=fB(A.pw),i=fB(A.ph),o=fB(A.p);return F_({padSpacing:Act,padWidth:e,padHeight:i,padPitch:o,numRows:4,textbottom:A.textbottom})},tct=t=>{const A=t.array??t.x;if(typeof A=="number")return Number.isNaN(A)?void 0:A;if(typeof A=="string"){const e=Number.parseInt(A,10);return Number.isNaN(e)?void 0:e}if(typeof t.imperial=="string"){const i=t.imperial.match(/(?:array|x)(2|4)$/)?.[1];if(i)return Number.parseInt(i,10)}},ict=t=>t?(typeof t=="number"?`${t}`:t).split("_")[0]:void 0,oct=t=>{const A=tct(t),e=ict(t.imperial);return A===2&&e==="0402"?{circuitJson:YIt(t),parameters:t}:A===4&&e==="0402"?{circuitJson:TIt(t),parameters:t}:A===2&&e==="0603"?{circuitJson:OIt(t),parameters:t}:A===4&&e==="0603"?{circuitJson:VIt(t),parameters:t}:A===2&&e==="0606"?{circuitJson:XIt(t),parameters:t}:A===4&&e==="1206"?{circuitJson:ect(t),parameters:t}:{circuitJson:GO(t),parameters:t}},EWA=(t,{x:A,y:e,radius:i})=>({type:"pcb_smtpad",x:A,y:e,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),hWA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",uWA=H().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A),y:parseFloat(e)}}).pipe(PA({x:ZA(),y:ZA()})),nct=H().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(H().or(ZA()))),sct=Hi.extend({fn:H(),num_pins:ZA().optional().default(64),grid:uWA.optional(),p:mt.default("0.8mm"),w:$A.optional(),h:$A.optional(),ball:$A.optional().describe("ball diameter"),pad:$A.optional().describe("pad width/height"),circularpads:ce().optional().describe("use circular pads"),tlorigin:ce().optional(),blorigin:ce().optional(),trorigin:ce().optional(),brorigin:ce().optional(),missing:nct.default([])}).transform(t=>{let A="tl";if(t.blorigin&&(A="bl"),t.trorigin&&(A="tr"),t.brorigin&&(A="br"),!t.grid){const i=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:i,y:i}}return t.missing&&(t.missing=t.missing.map(i=>{if(typeof i=="number")return i;if(i==="center")return"center";if(i==="topleft")return"topleft";const o=i.match(/([A-Z]+)(\d+)/);if(!o)return i;const n=hWA.indexOf(o[1]),s=Number.parseInt(o[2])-1;return n*t.grid.x+s+1})),{...t,origin:A}}),rct=t=>{const A=sct.parse(t);let{num_pins:e,grid:i,p:o,w:n,h:s,ball:r,pad:a,missing:g}=A;r??=.75/1.27*o,a??=r*.8;const I=[],c=(g??[]).filter(D=>typeof D=="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 D=Math.floor(Math.sqrt(B)),b=Math.floor((i.x-D)/2),m=Math.floor((i.y-D)/2);for(let x=m;x<m+D;x++)for(let F=b;F<b+D;F++)c.push(x*i.x+F+1)}g?.includes("topleft")&&c.push(1);const C=new Set(c);let l=0;for(let D=0;D<i.y;D++)for(let b=0;b<i.x;b++){const m=(b-(i.x-1)/2)*o,x=(D-(i.y-1)/2)*o;let F=b,k=D;switch(A.origin){case"bl":F=b,k=i.y-1-D;break;case"br":F=i.x-1-b,k=i.y-1-D;break;case"tr":F=i.x-1-b,k=D;break}let v=k*i.x+F+1;if(C.has(v)){l++;continue}v-=l;const _=[v,`${hWA[k]}${F+1}`];I.push(A.circularpads?EWA(_,{x:m,y:x,radius:a/2}):Qi(_,m,x,a,a))}const Q=Li(0,i.y*o/2,.2),E=o/6;let h;const u=i.x*o/2,d=i.y*o/2;switch(A.origin){case"bl":h=[{x:-u,y:-d},{x:-u,y:-d-E},{x:-u-E,y:-d},{x:-u,y:-d}];break;case"br":h=[{x:u,y:-d},{x:u,y:-d-E},{x:u+E,y:-d},{x:u,y:-d}];break;case"tr":h=[{x:u,y:d},{x:u,y:d+E},{x:u+E,y:d},{x:u,y:d}];break;default:h=[{x:-u,y:d},{x:-u,y:d+E},{x:-u-E,y:d},{x:-u,y:d}];break}const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:h,stroke_width:.05};return{circuitJson:[...I,Q,f],parameters:A}},FO=(t,A,e,i,o)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:o,radius:o/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),dm=t=>Hi.extend({fn:H(),num_pins:ZA().optional().default(8),w:$A.default($A.parse(t.w??"5.3mm")),p:$A.default($A.parse(t.p??"1.27mm")),pw:$A.default($A.parse(t.pw??"0.6mm")),pl:$A.default($A.parse(t.pl??"1.0mm")),legsoutside:ce().optional().default(t.legsoutside??!1),pillpads:ce().optional().default(t.pillpads??!1),silkscreen_stroke_width:ZA().optional().default(.1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=$A.parse("0.6mm"),A.pl=$A.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),act=dm({}),uBA=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:A,pn:e,w:i,p:o,pl:n,legsoutside:s}=t,r=A/2,a=e<=r,g=r-1,I=o,c=I*g,B=s?n/2:-n/2;return a?{x:-i/2-B,y:c/2-(e-1)*I}:{x:i/2+B,y:-c/2+(e-r-1)*I}},gct=t=>{const A=act.parse(t);return{circuitJson:ux(A),parameters:A}},ux=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=uBA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push(FO(r+1,a,g,t.pl,t.pw)):A.push(Qi(r+1,a,g,t.pl,t.pw))}const e=Math.min(1,t.p/2),i=t.w-(t.legsoutside?0:t.pl*2)-.2,o=(t.num_pins/2-1)*t.p+t.pw+e,n=Li(0,o/2+.4,o/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:t.silkscreen_stroke_width??.1,route:[{x:-i/2,y:-o/2},{x:-i/2,y:o/2},...CWA.map(({x:r,y:a})=>({x:r*i/6,y:a*i/6+o/2})),{x:i/2,y:o/2},{x:i/2,y:-o/2},{x:-i/2,y:-o/2}]};return[...A,s,n]},dWA=Ct(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),Ict=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const o=[],n=t/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=n:r.bottomside&&r.leftpin?s=n+1:r.bottomside&&r.rightpin?s=n*2:r.rightside&&r.bottompin?s=n*2+1:r.rightside&&r.toppin?s=n*3:r.topside&&r.rightpin?s=n*3+1:r.topside&&r.leftpin&&(s=n*4),o.push(-1);for(let a=0;a<t;a++)o[s]=a+1,e||!A?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return o},dBA=Hi.extend({fn:H(),cc:ce().default(!0).optional(),ccw:ce().default(!0).optional(),startingpin:H().or(be(dWA)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(be(dWA)).optional(),num_pins:ZA().optional().default(64),w:$A.optional(),h:$A.optional(),p:$A.default($A.parse("0.5mm")),pw:$A.optional(),pl:$A.optional(),thermalpad:Ai([kA(!0),uWA]).optional(),legsoutside:ce().default(!1)}),pBA=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},pWA=dBA.transform(pBA),cct=["left","bottom","right","top"],Bct=t=>{const{pin_count:A,pn:e,w:i,h:o,p:n,pl:s,legsoutside:r}=t,a=A/4,g=cct[Math.floor((e-1)/a)],I=(e-1)%a,c=n*(a-1),B=n*(a-1),C=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-C+.1,y:B/2-I*n,o:"vert"};case"bottom":return{x:-c/2+I*n,y:-o/2-C+.1,o:"horz"};case"right":return{x:i/2+C-.1,y:-B/2+I*n,o:"vert"};case"top":return{x:c/2-I*n,y:o/2+C-.1,o:"horz"};default:throw new Error("Invalid pin number")}},R_=t=>{const A=pWA.parse(t),e=[],i=Ict(A),o=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:I}=Bct({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 C=i[r+1];e.push(Qi(C,a,g,c,B))}if(A.thermalpad)if(typeof A.thermalpad=="boolean"){const r=A.p*(o-1)+A.pw,a=A.p*(o-1)+A.pw;e.push(Qi(["thermalpad"],0,0,r,a))}else e.push(Qi(["thermalpad"],0,0,A.thermalpad.x,A.thermalpad.y));const n=[];for(const[r,a,g]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const I=A.w/2*a,c=A.h/2*g;let B="none",C=I,l=c;const Q=A.pw*2;i[1]===1&&r==="top-left"?B="in1":i[o*4]===1&&r==="top-left"||i[o*3+1]===1&&r==="top-right"?B="in2":i[o*3]===1&&r==="top-right"||i[o]===1&&r==="bottom-left"?B="in1":i[o+1]===1&&r==="bottom-left"?B="in2":i[o*2]===1&&r==="bottom-right"?B="in1":i[o*2+1]===1&&r==="bottom-right"&&(B="in2");const E=B==="in1"?1:-1;if(A.legsoutside){const h=B==="in1"?A.pl/2:A.pw/2,u=B==="in1"?A.pw/2:A.pl/2;C+=h*a*E,l-=u*g*E}(B==="none"||A.legsoutside)&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:I-Q*a,y:c},{x:I,y:c},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&!A.legsoutside&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:I-Q*a,y:c},{x:I-Q*a/2,y:c}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:I,y:c-Q*g/2},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&n.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:C-.2*-a,y:l+.2*E},{x:C,y:l},{x:C+.2*E*-a,y:l+.2},{x:C-.2*-a,y:l+.2*E}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Li(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...n,s],parameters:A}};dBA.extend({}).transform(pBA);var Cct=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),R_(t)),lct=t=>{if(t.legsoutside=!0,!t.p)switch(t.num_pins){case 32:t.p=.8;break;case 44:case 48:t.p=.5;break;case 64:case 80:case 100:t.p=.5;break;case 144:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 32:case 44:case 48:case 64:case 80:case 100:t.pl=1.475;break;case 144:t.pl=1.6;break}if(!t.pw)switch(t.num_pins){case 32:t.pw=.55;break;case 44:case 48:case 64:case 80:case 100:t.pw=.3;break;case 144:t.pw=.25;break}return R_(t)},Qct=t=>{t.legsoutside=!0;const A=pWA.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 R_(t)};dBA.extend({}).transform(pBA);var Ect=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),R_(t)),hct=dm({w:"3.9mm",p:"1.27mm"}),uct=t=>{const A=hct.parse(t);return{circuitJson:ux(A),parameters:A}},dct=dm({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),pct=t=>{const A=dct.parse(t);return{circuitJson:ux(A),parameters:A}},fct=dm({}),yct=t=>{const A=fct.parse({fn:"sot363",num_pins:6,w:2.56,p:.65,pw:.4,pl:.65,legoutside:!0});return{circuitJson:ux(A),parameters:A}},wct=Hi.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("1.01mm"),h:H().default("1.45mm"),p:H().default("0.5mm"),pl:H().default("0.33mm"),pw:H().default("0.27mm"),string:H().optional()}),mct=t=>{const A=wct.parse({fn:"sot886",...t}),e=$A.parse(A.w),i=$A.parse(A.h),o=$A.parse(A.p),n=$A.parse(A.pl),s=$A.parse(A.pw),r=[];for(let C=0;C<6;C++){const{x:l,y:Q}=fWA(C+1,e,o,n);r.push(Qi(C+1,l,Q,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=fWA(1,e,o,n),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-n/2-.3,y:I.y},{x:I.x-n/2-.45,y:I.y+.15},{x:I.x-n/2-.45,y:I.y-.15},{x:I.x-n/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},B=Li(0,i/2+.4,.25);return{circuitJson:[...r,a,g,B,c],parameters:A}},fWA=(t,A,e,i)=>{const o=A/2-i/2;return t<=3?{x:-o,y:e-(t-1)*e}:{x:o,y:-e+(t-4)*e}},yWA=Hi.extend({fn:H(),num_pins:ZA().default(3),w:H().default("1.92mm"),h:H().default("2.74mm"),pl:H().default("1.32mm"),pw:H().default("0.6mm"),p:H().default("0.95mm"),string:H().optional()}),Dct=dm({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Sct=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const o=Dct.parse({...t,num_pins:e});return{circuitJson:ux(o),parameters:o}}const i=yWA.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:xct(i),parameters:i};if(i.num_pins===5)return{circuitJson:mWA(i),parameters:i};throw new Error("Invalid number of pins")},bct=t=>{const{pn:A,p:e}=t;return A===1?{x:-1.155,y:e}:A===2?{x:-1.155,y:-e}:{x:1.15,y:0}},xct=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:o,y:n}=bct({num_pins:t.num_pins,pn:i+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(i+1,o,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Li(0,Number.parseInt(t.h),.3);return[...A,e]},wWA=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")},mWA=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:C}=wWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(Qi(c,B,C,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Li(0,i+.3,.3),r=wWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.3,g=.4,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,o,n,I]},kct=yWA.extend({}),Gct=t=>{const A=kct.parse({...t,num_pins:5});return{circuitJson:mWA(A),parameters:A}},Fct=[{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}],Rct=dm({}),Nct=t=>{const A=Rct.parse(t),e=[];for(let c=0;c<A.num_pins;c++){const{x:B,y:C}=uBA({num_pins:A.num_pins,pn:c+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(Qi(c+1,B,C,A.pl??"1mm",A.pw??"0.6mm"))}const i=Math.min(1,A.p/2),o=A.w+i,n=(A.num_pins/2-1)*A.p+A.pw+i,s=[];for(const c of Fct){const{dx:B,dy:C}=c;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:B*o/2-B*A.p,y:C*n/2},{x:B*o/2,y:C*n/2},{x:B*o/2,y:C*n/2-C*A.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const r=A.p/4,a=-o/2-r/2,g=n/2-A.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:a,y:g},{x:a-r,y:g+r},{x:a-r,y:g-r},{x:a,y:g}],stroke_width:.1});const I=Li(0,n/2+.4,n/12);return{circuitJson:[...e,I,...s],parameters:A}},fBA=({fs:t,pn:A,anchor_x:e,anchor_y:i,textalign:o="center",orthogonal:n=!1,verticallyinverted:s=!1,layer:r="top"})=>{let a=0;n&&s?a=270:s?a=180:n?a=90:a=0;let g="center";return o==="left"&&(s?g="center_right":g="center_left"),o==="right"&&(s?g="center_left":g="center_right"),r==="bottom"&&(g==="center_left"?g="center_right":g==="center_right"&&(g="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:`{PIN${A}}`,layer:r,anchor_position:{x:e,y:i},anchor_alignment:g,ccw_rotation:a}};function _ct({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 Mct=Hi.extend({fn:H(),num_pins:ZA().optional().default(6),rows:Ai([H(),ZA()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:$A.default("0.1in").describe("pitch"),id:$A.default("1.0mm").describe("inner diameter"),od:$A.default("1.5mm").describe("outer diameter"),male:ce().optional().describe("for male pin headers"),female:ce().optional().describe("for female pin headers"),smd:ce().optional().describe("surface mount device"),surfacemount:ce().optional().describe("surface mount device (verbose)"),rightangle:ce().optional().describe("right angle"),pw:$A.optional().default("1.0mm").describe("pad width for SMD"),pl:$A.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:ce().optional().default(!1),pinlabeltextaligncenter:ce().optional().default(!1),pinlabeltextalignright:ce().optional().default(!1),pinlabelverticallyinverted:ce().optional().default(!1),pinlabelorthogonal:ce().optional().default(!1),nosquareplating:ce().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:ce().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:ce().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:ce().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=_ct(t);return{...t,pinlabelAnchorSide:A,male:t.male??!t.female,female:t.female??!1,smd:t.smd??t.surfacemount??!1,rightangle:t.rightangle??!1}}).superRefine((t,A)=>{t.male&&t.female&&A.addIssue({code:Wt.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),vct=t=>{const A=Mct.parse(t),{p:e,id:i,od:o,rows:n,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:I,pinlabeltextalignright:c,nopinlabels:B,doublesidedpinlabel:C,bottomsidepinlabel:l}=A;let Q="center";I?Q="left":c&&(Q="right");const E=[],h=Math.ceil(s/n),u=-e,d=({xoff:x,yoff:F,od:k,anchorSide:v,smd:_,pw:Y,pl:P})=>{let K=0,O=0;if(_){const W=k/5;switch(v){case"right":K=Y/2+W;break;case"top":O=P/2+W;break;case"bottom":O=-(P/2+W);break;case"left":K=-(Y/2+W);break}}else{const W=k*.75;switch(v){case"right":K=W;break;case"top":O=W;break;case"bottom":O=-W;break;case"left":K=-W;break}}return{anchor_x:x+K,anchor_y:F+O}},f=(x,F,k)=>{A.smd?E.push(Qi(x,F,k,A.pw,A.pl)):x===1&&!A.nosquareplating?E.push(oS(x,F,k,i,o,o,0,0)):E.push(Pn(x,F,k,i,o));const{anchor_x:v,anchor_y:_}=d({xoff:F,yoff:k,od:o,anchorSide:r,smd:A.smd,pw:A.pw,pl:A.pl});B||(l?E.push(fBA({fs:o/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):E.push(fBA({fs:o/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),C&&E.push(fBA({fs:o/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},D=new Set,b=n>2&&h>2;if(n===1){const x=-((s-1)/2)*e;for(let F=0;F<s;F++){const k=F+1,v=x+F*e,_=`${v},0`;if(D.has(_))throw new Error(`Overlap at ${_}`);D.add(_),f(k,v,0)}}else if(b){const x=-((h-1)/2)*e;let F=1;for(let k=0;k<n&&F<=s;k++)for(let v=0;v<h&&F<=s;v++){const _=x+v*e,Y=k*u,P=`${_},${Y}`;if(D.has(P))throw new Error(`Overlap at ${P}`);D.add(P),f(F++,_,Y)}}else{const x=-((h-1)/2)*e;let F=1,k=0,v=n-1,_=0,Y=h-1;for(;F<=s&&k<=v&&_<=Y;){for(let P=k;P<=v&&F<=s;P++){const K=x+_*e,O=P*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}_++;for(let P=_;P<=Y&&F<=s;P++){const K=x+P*e,O=v*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}if(v--,_<=Y){for(let P=v;P>=k&&F<=s;P--){const K=x+Y*e,O=P*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}Y--}if(k<=v){for(let P=Y;P>=_&&F<=s;P--){const K=x+P*e,O=k*u,W=`${K},${O}`;if(D.has(W))throw new Error(`Overlap at ${W}`);D.add(W),f(F++,K,O)}k++}}if(F-1<s)throw new Error(`Missing pins: assigned ${F-1}, expected ${s}`)}const m=Li(0,e,.5);return{circuitJson:[...E,m],parameters:A}},Uct=Hi.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("2.1mm"),h:H().default("2.45mm"),p:H().default("0.5mm"),pl:H().default("0.675mm"),pw:H().default("0.35mm"),string:H().optional()}),Lct=t=>{const A=Uct.parse({...t,fn:"sot563"}),e=$A.parse(A.w),i=$A.parse(A.h),o=$A.parse(A.p),n=$A.parse(A.pl),s=$A.parse(A.pw),r=[];for(let C=0;C<6;C++){const{x:l,y:Q}=DWA(C+1,e,o,n);r.push(Qi(C+1,l,Q,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=DWA(1,e,o,n),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-n/2-.3,y:I.y},{x:I.x-n/2-.45,y:I.y+.15},{x:I.x-n/2-.45,y:I.y-.15},{x:I.x-n/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},B=Li(0,i/2+.4,.25);return{circuitJson:[...r,a,g,B,c],parameters:A}},DWA=(t,A,e,i)=>{const o=A/2-i/2;return t<=3?{x:-o,y:e-(t-1)*e}:{x:o,y:-e+(t-4)*e}},Hct=dm({p:"1.27mm",w:"3.9mm",legsoutside:!0}),Yct=t=>{const A=Hct.parse({...t,num_pins:8});return{circuitJson:ux(A),parameters:A}},Jct=dm({p:"1.27mm",w:"7.5mm",legsoutside:!0}),Kct=t=>{const A=Jct.parse({...t,num_pins:16});return{circuitJson:ux(A),parameters:A}},Tct=Hi.extend({fn:H(),num_pins:kA(3).default(3),w:H().default("1.2mm"),h:H().default("1.2mm"),pw:H().default("0.40mm"),pl:H().default("0.45mm"),p:H().default("0.575mm")}),qct=t=>{const A=Tct.parse(t),e=Oct(A),i=Li(0,$A.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},Pct=t=>{const{pn:A,p:e}=t;return A===1?{x:e,y:0}:A===2?{x:-e,y:-.4}:{x:-e,y:.4}},Oct=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:o}=Pct({num_pins:t.num_pins,pn:e+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(e+1,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Wct=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("2.36mm"),h:H().default("1.22mm"),pl:H().default("0.9mm"),pw:H().default("1.2mm"),p:H().default("3.30mm")}),Zct=t=>{const A=Wct.parse(t),e=Li(0,$A.parse(A.h)/4+.4,.3);return{circuitJson:jct(A).concat(e),parameters:A}},Vct=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},jct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Vct({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},zct=Hi.extend({fn:H(),p:$A.optional().default("2.54mm"),id:$A.optional().default("0.7mm"),od:$A.optional().default("1.4mm")}),Xct=t=>{const A=zct.parse(t),{p:e,id:i,od:o}=A,n=[Pn(1,-e/2,0,i,o),Pn(2,e/2,0,i,o)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2+o+i/2,y:0},{x:e/2-o-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},r=Li(0,1.5,.5);return{circuitJson:[...n,s,r],parameters:A}},$ct=(t,A,e,i,o,n=.1)=>{const s=[],r=[],a=Math.max(1,Math.ceil(Math.PI*e/n)),g=Math.PI/a;for(let I=0;I<=a;I++){const c=I*g,B=t+Math.cos(c)*e,C=A+Math.sin(c)*e;B<t-i&&C>=A-o/2&&C<=A+o/2||s.push({x:B,y:C})}for(let I=0;I<=a;I++){const c=Math.PI+I*g,B=t+Math.cos(c)*e,C=A+Math.sin(c)*e;B<t-i&&C>=A-o/2&&C<=A+o/2||r.push({x:B,y:C})}return{topArc:s,bottomArc:r}},ABt=Hi.extend({fn:H(),p:$A.optional().default("5mm"),id:$A.optional().default("0.8mm"),od:$A.optional().default("1.6mm"),ceramic:ce().optional(),electrolytic:ce().optional(),polarized:ce().optional()}),eBt=t=>{const A=ABt.parse(t),{p:e,id:i,od:o}=A;i===.8&&o===1.6&&(A.id=e===5?.8:e*.25,A.od=e===5?1.6:e*.5);const n=[Pn(1,-e/2,0,A.id,A.od),Pn(2,e/2,0,A.id,A.od)],s=e+.1,{topArc:r,bottomArc:a}=$ct(0,0,s,A.od/2,A.od),g=.02*e,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:g,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:g,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:s},{x:0,y:-s}],stroke_width:g,pcb_silkscreen_path_id:""},C=.1*e,l=-(e+C+.04*e),Q=s-C-.08*e,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l-C,y:Q},{x:l+C,y:Q}],stroke_width:g,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l,y:Q-C},{x:l,y:Q+C}],stroke_width:g,pcb_silkscreen_path_id:""},u=Li(0,s+.12*e,.1*e),d=[...n,I,c,B,u];return(A.electrolytic===!0||A.polarized===!0)&&d.push(E,h),{circuitJson:d,parameters:A}},RO=(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}),tBt=Hi.extend({fn:kA("pushbutton"),w:$A.default(4.5),h:$A.default(6.5),id:$A.default(1),od:$A.default(1.2)}),iBt=t=>{const A=tBt.parse(t),e=A.w,i=A.h,o=A.id,n=[Pn(1,-e/2,i/2,o,o*1.5),Pn(2,-e/2,-i/2,o,o*1.5),Pn(3,e/2,-i/2,o,o*1.5),Pn(4,e/2,i/2,o,o*1.5)],s=[RO([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),RO([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),RO([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),RO([{x:e/2,y:0},{x:e/5,y:0}])],r=Li(0,i/2+.4,.5);return{circuitJson:[...n,...s,r],parameters:A}},SWA=Hi.extend({fn:H(),w:$A.default("22.58mm"),h:$A.optional(),left:$A.optional().default(20),right:$A.optional().default(20),top:$A.optional().default(2),bottom:$A.optional().default(2),p:$A.default($A.parse("2.54mm")),pw:$A.default($A.parse("1.6mm")),pl:$A.default($A.parse("2.4mm")),innerhole:ce().default(!1),innerholeedgedistance:$A.default($A.parse("1.61mm")),silkscreenlabels:ce().default(!1),silkscreenlabelmargin:$A.default($A.parse("0.1mm"))}),oBt=t=>{const A=SWA.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},NO=(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},nBt=t=>{const A=SWA.parse(t),e=A.h??oBt(A),i=[],o=[],n=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),c=`pin${g}`.length*.7/2;if(A.right){const Q=-((A.right-1)/2)*A.p;for(let E=0;E<A.right;E++){if(E===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=NO(A.w/2-A.pl*1.4,Q+E*A.p,"right")),i.push(Qi(E+1+A.left+(A.bottom??0),A.w/2-A.pl/2,Q+E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+1+A.left+(A.bottom??0),u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl-(c+A.silkscreenlabelmargin),y:Q+E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push(Pn(E+1+A.left+(A.bottom??0)+g,A.w/2,Q+E*A.p,r,a)),o.push(Pn(E+1+A.left+(A.bottom??0)+g*2,A.w/2-A.innerholeedgedistance,Q+E*A.p,r,a)))}}if(A.left){const Q=(A.left-1)/2*A.p;for(let E=0;E<A.left;E++){if(E===0&&!A.silkscreenlabels&&(s=NO(-A.w/2+A.pl*1.4,Q-E*A.p,"left")),i.push(Qi(E+1,-A.w/2+A.pl/2,Q-E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+1,u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl+(c+A.silkscreenlabelmargin),y:Q-E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(o.push(Pn(E+1+g,-A.w/2,Q-E*A.p,r,a)),o.push(Pn(E+1+g*2,-A.w/2+A.innerholeedgedistance,Q-E*A.p,r,a)))}}if(A.top){const Q=(A.top-1)/2*A.p;for(let E=0;E<A.top;E++){if(E===0&&!A.left&&!A.bottom&&!A.right&&!A.silkscreenlabels&&(s=NO(Q-E*A.p,e/2-A.pl*1.4,"top")),i.push(Qi(E+1+A.left+A.right+(A.bottom??0),Q-E*A.p,e/2-A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+1+A.left+A.right+(A.bottom??0),u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q-E*A.p,y:e/2-A.pl-(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(o.push(Pn(E+1+A.left+A.right+(A.bottom??0)+g,Q-E*A.p,e/2,r,a)),o.push(Pn(E+1+A.left+A.right+(A.bottom??0)+g*2,Q-E*A.p,e/2-A.innerholeedgedistance,r,a)))}}if(A.bottom){const Q=-((A.bottom-1)/2)*A.p;for(let E=0;E<A.bottom;E++){if(E===0&&!A.left&&!A.silkscreenlabels&&(s=NO(Q+E*A.p,-e/2+A.pl*1.4,"bottom")),i.push(Qi(E+1+A.left,Q+E*A.p,-e/2+A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+1+A.left,u=`pin${h}`;n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q+E*A.p,y:-e/2+A.pl+(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(o.push(Pn(E+1+A.left+g,Q+E*A.p,-e/2,r,a)),o.push(Pn(E+1+A.left+g*2,Q+E*A.p,-e/2+A.innerholeedgedistance,r,a)))}}const B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},C={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"},l=Li(0,e/1.8,e/25);return{circuitJson:[...i,...o,...n,C,...A.silkscreenlabels?[]:[B],l],parameters:A}},bWA=Hi.extend({fn:H(),w:$A.default("22.58mm"),h:$A.optional(),left:$A.optional().default(20),right:$A.optional().default(20),top:$A.optional().default(2),bottom:$A.optional().default(2),p:$A.default($A.parse("2.54mm")),pw:$A.default($A.parse("1.6mm")),pl:$A.default($A.parse("3.2mm")),innerhole:ce().default(!1),innerholeedgedistance:$A.default($A.parse("1.61mm"))}),sBt=t=>{const A=bWA.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},rBt=(t,A,e,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:t+n,y:A},{x:t-n,y:A+s},{x:t-n,y:A-s},{x:t+n,y:A}],right:[{x:t-n,y:A},{x:t+n,y:A+s},{x:t+n,y:A-s},{x:t-n,y:A}],top:[{x:t,y:A-n},{x:t-s,y:A+n},{x:t+s,y:A+n},{x:t,y:A-n}],bottom:[{x:t,y:A+n},{x:t-s,y:A-n},{x:t+s,y:A-n},{x:t,y:A+n}]}[e]},aBt=t=>{const A=bWA.parse(t),e=A.h??sBt(A),i=[],o=[],n=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],I=1;if(A.left){const l=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++)Q===0&&(g=rBt(-A.w/2-A.pl/2,l-Q*A.p,"left")),i.push(Qi(I,-A.w/2+A.pl/2,l-Q*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:l-Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,-A.w/2+A.innerholeedgedistance,l-Q*A.p,s,r))}if(A.bottom){const l=(A.bottom-1)/2*A.p;for(let Q=A.bottom-1;Q>=0;Q--)i.push(Qi(I,l-Q*A.p,-e/2+A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:l-Q*A.p,y:-e/2+A.pl/2-3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,l-Q*A.p,-e/2+A.innerholeedgedistance,s,r))}if(A.right){const l=-((A.right-1)/2)*A.p;for(let Q=0;Q<A.right;Q++)i.push(Qi(I,A.w/2-A.pl/2,l+Q*A.p,A.pl,A.pw)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:l+Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,A.w/2-A.innerholeedgedistance,l+Q*A.p,s,r))}if(A.top){const l=-((A.top-1)/2)*A.p;for(let Q=A.top-1;Q>=0;Q--)i.push(Qi(I,l+Q*A.p,e/2-A.pl/2,A.pw,A.pl)),o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:l+Q*A.p,y:e/2-A.pl/2+3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&n.push(Pn(I+a,l+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"},C=Li(0,e/1.8,e/25);return{circuitJson:[...n,...i,...o,B,c,C],parameters:A}},gBt=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),R_(t)),xWA=Hi.extend({fn:H(),w:$A.default("10mm"),h:$A.optional(),left:$A.optional().default(20),right:$A.optional().default(20),top:$A.optional().default(0),bottom:$A.optional().default(0),p:$A.default($A.parse("2.54mm")),id:$A.optional().default($A.parse("1mm")),od:$A.optional().default($A.parse("1.5mm"))}),IBt=t=>{const A=xWA.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},_O=(t,A,e,i=1,o=.6)=>{const n=i/2,s=o/2;return{left:[{x:t+n,y:A},{x:t-n,y:A+s},{x:t-n,y:A-s},{x:t+n,y:A}],right:[{x:t-n,y:A},{x:t+n,y:A+s},{x:t+n,y:A-s},{x:t-n,y:A}],top:[{x:t,y:A-n},{x:t-s,y:A+n},{x:t+s,y:A+n},{x:t,y:A-n}],bottom:[{x:t,y:A+n},{x:t-s,y:A-n},{x:t+s,y:A-n},{x:t,y:A+n}]}[e]},cBt=t=>{const A=xWA.parse(t),e=A.h??IBt(A),i=[],o=A.id,n=A.od;let s=[];if(A.right){const I=-((A.right-1)/2)*A.p;for(let c=0;c<A.right;c++)c===0&&!A.left&&!A.bottom&&(s=_O(A.w/2+n*1.4,I+c*A.p,"right")),i.push(Pn(c+1+A.left+(A.bottom??0),A.w/2,I+c*A.p,o,n))}if(A.left){const I=-((A.left-1)/2)*A.p;for(let c=0;c<A.left;c++)c===A.left-1&&(s=_O(-A.w/2-n*1.4,I+c*A.p,"left")),i.push(Pn(c+1,-A.w/2,I+c*A.p,o,n))}if(A.top){const I=-((A.top-1)/2)*A.p;for(let c=0;c<A.top;c++)c===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=_O(I+c*A.p,e/2+n*1.4,"top")),i.push(Pn(c+1+A.right+(A.bottom??0)+A.left,I+c*A.p,e/2,o,n))}if(A.bottom){const I=-((A.bottom-1)/2)*A.p;for(let c=0;c<A.bottom;c++)c===0&&!A.left&&(s=_O(I+c*A.p,-e/2-n*1.4,"bottom")),i.push(Pn(c+1+A.left,I+c*A.p,-e/2,o,n))}const r={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-n,y:e/2+n},{x:A.w/2+n,y:e/2+n},{x:A.w/2+n,y:-e/2-n},{x:-A.w/2-n,y:-e/2-n},{x:-A.w/2-n,y:e/2+n}],stroke_width:.1,layer:"top"},g=Li(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},kWA=(t,A,e,i)=>Array.from({length:25},(o,n)=>{const s=n/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*e,y:A+Math.sin(s)*e}}),BBt=Hi.extend({fn:H(),p:$A.optional().default("4.88mm"),id:$A.optional().default("0.8mm"),od:$A.optional().default("1.5mm"),w:$A.optional().default("5.6mm"),h:$A.optional().default("3.5mm")}),CBt=t=>{const A=BBt.parse(t),{p:e,id:i,od:o,w:n,h:s}=A,r=s/2,a=[Pn(1,-e/2,0,i,o),Pn(2,e/2,0,i,o)],g=kWA(-n/2,0,r,"left"),I=kWA(n/2,0,r,"right"),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...g,...g.slice(1).reverse(),{x:-n/2,y:-s/2},{x:n/2,y:-s/2},...I,{x:n/2,y:s/2},{x:-n/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},B=Li(0,e/4,.5);return{circuitJson:[...a,c,B],parameters:A}};Hi.extend({w:$A,h:$A});var lBt=t=>{const{w:A,h:e}=t,i=wr(A),o=wr(e);return{circuitJson:[Qi(1,0,0,i,o),Li(0,o/2+.5,.2)],parameters:t}},FU=(t,A,e,i,o,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:A,y:e,outer_width:wr(o),outer_height:wr(n),hole_width:wr(i),hole_height:wr(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),QBt=Hi.extend({fn:H(),num_pins:Ai([kA(3),kA(2)]).default(3),p:H().default("1.27mm"),id:H().default("0.72mm"),od:H().default("0.95mm"),w:H().default("4.5mm"),h:H().default("4.5mm"),inline:ce().default(!1),string:H().optional()}),EBt=(t,A,e)=>Array.from({length:25},(i,o)=>{const n=o/24*Math.PI;return{x:t+Math.cos(n)*e,y:A+Math.sin(n)*e}}),hBt=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=QBt.parse({...t,num_pins:e}),{p:o,id:n,od:s,w:r,h:a,inline:g}=i,I=Number.parseFloat(a)/2,c=Number.parseFloat(o),B=Number.parseFloat(n),C=Number.parseFloat(s),l=C,Q=C*(1.5/1.05);let E=[];if(i.num_pins===3)g?E=[oS(1,-c,I-c,B,C,Q,0,0),FU(2,0,I-c,B,l,Q),FU(3,c,I-c,B,l,Q)]:E=[oS(1,-c,I-c,B,C,C,0,0),Pn(2,0,I,B,C),Pn(3,c,I-c,B,C)];else if(i.num_pins===2)E=[oS(1,-c,I-c,B,l,Q,0,0),FU(2,c,I-c,B,l,Q)];else throw new Error("Invalid number of pins for TO-92");const h=Number.parseFloat(r)/2,u=EBt(0,I,h),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...u,{x:-h,y:0},{x:h,y:0},u[0]],stroke_width:.1,pcb_silkscreen_path_id:""},f=Li(0,I+1,.5);return{circuitJson:[...E,d,f],parameters:i}},uBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("2.15mm"),h:H().default("1.20mm"),pl:H().default("0.5mm"),pw:H().default("0.6mm"),p:H().default("1.4mm")}),dBt=t=>{const A=uBt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:fBt(A).concat(i,e),parameters:A}},pBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},fBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=pBt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},yBt=dm({}),wBt=t=>{const A=yBt.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=uBA({num_pins:A.num_pins,pn:s+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});e.push(Qi(s+1,r,a,A.pl??"1.5mm",A.pw??"0.6mm"))}const i=(A.num_pins/2-1)*A.p+A.pw,o=Li(0,i/2-.5,i/12),n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-A.w/3,y:i/2+.2},{x:A.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...e,o,n],parameters:A}},mBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("5.0mm"),h:H().default("2.30mm"),pl:H().default("1.25mm"),pw:H().default("2mm"),p:H().default("3.75mm")}),DBt=t=>{const A=mBt.parse(t),e=Li(0,$A.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2+.5,y:$A.parse(A.h)/2+.5},{x:-$A.parse(A.w)/2-.5,y:$A.parse(A.h)/2+.5},{x:-$A.parse(A.w)/2-.5,y:-$A.parse(A.h)/2-.5},{x:$A.parse(A.p)/2+.5,y:-$A.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bBt(A).concat(i,e),parameters:A}},SBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},bBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=SBt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},xBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("1.2mm"),pw:H().default("1.2mm"),p:H().default("2.9mm")}),kBt=t=>{const A=xBt.parse(t),e=Li(0,$A.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:FBt(A).concat(i,e),parameters:A}},GBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},FBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=GBt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},RBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.30mm"),h:H().default("1.80mm"),pl:H().default("0.60mm"),pw:H().default("0.45mm"),p:H().default("2.1mm")}),NBt=t=>{const A=RBt.parse(t),e=Li(0,$A.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:MBt(A).concat(i,e),parameters:A}},_Bt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},MBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=_Bt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},vBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.4mm"),h:H().default("0.9mm"),pl:H().default("0.36mm"),pw:H().default("0.25mm"),p:H().default("0.85mm")}),UBt=t=>{const A=vBt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2+.15,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.15,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.15,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2+.15,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:HBt(A).concat(i,e),parameters:A}},LBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},HBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=LBt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},YBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.3mm"),h:H().default("0.9mm"),pl:H().default("0.4mm"),pw:H().default("0.7mm"),p:H().default("0.7mm")}),JBt=t=>{const A=YBt.parse(t),e=Li(0,$A.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2+.2,y:$A.parse(A.h)/2+.2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2+.2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2-.2},{x:$A.parse(A.p)/2+.2,y:-$A.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:TBt(A).concat(i,e),parameters:A}},KBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},TBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=KBt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},qBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3,05mm"),h:H().default("1.65mm"),pl:H().default("0.6mm"),pw:H().default("0.6mm"),pad_spacing:H().default("2.2mm")}),PBt=t=>{const A=qBt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.pad_spacing)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.pad_spacing)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:WBt(A).concat(i,e),parameters:A}},OBt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},WBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=OBt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ZBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("1.2mm"),pw:H().default("1.2mm"),p:H().default("2.9mm")}),VBt=t=>{const A=ZBt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:zBt(A).concat(i,e),parameters:A}},jBt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},zBt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=jBt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},XBt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("0.91mm"),pw:H().default("1.22mm"),p:H().default("3.146mm")}),$Bt=t=>{const A=XBt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:eCt(A).concat(i,e),parameters:A}},ACt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=ACt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.80mm"),h:H().default("1.00mm"),pl:H().default("0.66mm"),pw:H().default("0.5mm"),p:H().default("0.8mm")}),iCt=t=>{const A=tCt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.1,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.1,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:nCt(A).concat(i,e),parameters:A}},oCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},nCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=oCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},sCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("6.2mm"),h:H().default("3.4mm"),pl:H().default("1.4mm"),pw:H().default("2.1mm"),p:H().default("4.4mm")}),rCt=t=>{const A=sCt.parse(t),e=Li(0,$A.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:gCt(A).concat(i,e),parameters:A}},aCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},gCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=aCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ICt=Hi.extend({fn:H(),num_pins:Ai([kA(3),kA(5)]).default(3),w:H().default("4.20mm"),h:H().default("4.80mm"),pl:H().default("1.3mm"),pw:H().default("0.9mm"),p:H().default("1.5mm"),string:H().optional()}),cCt=t=>{const A=[],e=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),o=Number.parseFloat(t.w),n=Number.parseFloat(t.pl),s=.175,r=(n-(n+s))/2;A.push(Qi(1,-o/2+r,e,n,i),Qi(2,-o/2,0,n+s,i),Qi(3,-o/2+r,-e,n,i));const a=Li(0,0,.3),g=Number.parseFloat(t.w)/2-1,I=Number.parseFloat(t.h)/2,c={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-g,y:I},{x:g,y:I},{x:g,y:I/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},B={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-g,y:-I},{x:g,y:-I},{x:g,y:-I/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,c,B,a]},BCt=t=>{const A=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),A.push(Qi(1,-1.85,-1.5,1.5,.7),Qi(2,-1.85,1.5,1.5,.7),Qi(3,0,0,.8,2),Qi(4,1.85,-1.5,1.5,.7),Qi(5,1.85,1.5,1.5,.7));const e=Li(0,Number.parseFloat(t.h)/2+.5,.3),i=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i,y:o}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o},{x:i,y:-o}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},CCt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=ICt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:cCt(i),parameters:i};if(i.num_pins===5)return{circuitJson:BCt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},lCt=Hi.extend({fn:H(),p:$A.optional().default("5.0mm"),id:$A.optional().default("1.0mm"),od:$A.optional().default("1.9mm"),w:$A.optional().default("13mm"),h:$A.optional().default("7mm"),num_pins:ZA().optional(),string:H().optional()}),QCt=t=>{const A=lCt.parse(t),{fn:e,id:i,od:o,w:n,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,I=n/2,c=s/2,B=2.5,C=n*.4,l=Math.max(B,C/(a-1)),Q=Array.from({length:a},(D,b)=>{const m=a%2===0?(b-a/2+.5)*l:(b-Math.floor(a/2))*l;return Pn(b+1,m,g,i,o)}),E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:-c},{x:I,y:-c},{x:I,y:c},{x:-I,y:c},{x:-I,y:-c}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-c+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:h},{x:I,y:h}],stroke_width:.1,pcb_silkscreen_path_id:""},d=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/6,y:h},{x:-n/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:n/6,y:h},{x:n/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Li(0,s/2+.6,.5);return{circuitJson:[...Q,E,u,...d,f],parameters:{...A,p:l}}},ECt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("5.40mm"),h:H().default("2.30mm"),pl:H().default("1.30mm"),pw:H().default("1.70mm"),p:H().default("3.5mm")}),hCt=t=>{const A=ECt.parse(t),e=Li(0,$A.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:dCt(A).concat(i,e),parameters:A}},uCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},dCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=uCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},pCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("1.90mm"),h:H().default("1.33mm"),pl:H().default("0.5mm"),pw:H().default("0.7mm"),p:H().default("0.8mm")}),fCt=t=>{const A=pCt.parse(t),e=Li(0,$A.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2+.1,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2+.1,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:wCt(A).concat(i,e),parameters:A}},yCt=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:o}=yCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},mCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("7.0mm"),h:H().default("3.35mm"),pl:H().default("1.50mm"),pw:H().default("2.70mm"),p:H().default("4.8mm")}),DCt=t=>{const A=mCt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bCt(A).concat(i,e),parameters:A}},SCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},bCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=SCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},xCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.0mm"),h:H().default("1.80mm"),pl:H().default("0.80mm"),pw:H().default("1.20mm"),p:H().default("1.6mm")}),kCt=t=>{const A=xCt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.1,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.1,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:FCt(A).concat(i,e),parameters:A}},GCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},FCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=GCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},RCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("7.10mm"),h:H().default("3.40mm"),pl:H().default("2.45mm"),pw:H().default("1.80mm"),p:H().default("4.05mm")}),NCt=t=>{const A=RCt.parse(t),e=Li(0,$A.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.5,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.5,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:MCt(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}},MCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=_Ct({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},vCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("4.80mm"),h:H().default("2.10mm"),pl:H().default("1.30mm"),pw:H().default("1.40mm"),p:H().default("2.9mm")}),UCt=t=>{const A=vCt.parse(t),e=Li(0,$A.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:HCt(A).concat(i,e),parameters:A}},LCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},HCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=LCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},YCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("7.30mm"),h:H().default("4.40mm"),pl:H().default("2.50mm"),pw:H().default("2.30mm"),p:H().default("4.30mm")}),JCt=t=>{const A=YCt.parse(t),e=Li(0,$A.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.1,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.1,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:TCt(A).concat(i,e),parameters:A}},KCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},TCt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=KCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},qCt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("10.70mm"),h:H().default("6.60mm"),pl:H().default("3.30mm"),pw:H().default("2.50mm"),p:H().default("6.80mm")}),PCt=t=>{const A=qCt.parse(t),e=Li(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2-.8},{x:-$A.parse(A.w)/2-.8,y:$A.parse(A.h)/2-.8},{x:-$A.parse(A.w)/2-.8,y:-$A.parse(A.h)/2+.8},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:WCt(A).concat(i,e),parameters:A}},OCt=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:o}=OCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},ZCt=Hi.extend({fn:H(),num_pins:ZA().default(4),w:H().default("8.50mm"),h:H().default("6.90mm"),pl:H().default("2mm"),pw:H().default("1.5mm"),p:H().default("2.30mm"),string:H().optional()}),VCt=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const o=XCt.parse({...t,num_pins:e});return{circuitJson:ux(o),parameters:o}}const i=ZCt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:zCt(i),parameters:i};if(i.num_pins===5)return{circuitJson:Alt(i),parameters:i};if(i.num_pins===6)return{circuitJson:tlt(i),parameters:i};throw new Error("Invalid number of pins")},jCt=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}},zCt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=jCt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),I=r===3?3.8:Number.parseFloat(t.pw);A.push(Qi(r+1,a,g,Number.parseFloat(t.pl),I))}const e=Li(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i,y:o},{x:i,y:o/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o},{x:i,y:-o},{x:i,y:-o/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},XCt=dm({p:"0.90mm",w:"2.8mm",legsoutside:!0}),$Ct=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")},Alt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=$Ct({h:Number.parseFloat(t.h),p:1.5,pn:r,w:Number.parseFloat(t.w)});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===5?(I=3.4,c=1.8):(I=1,c=2.2),A.push(Qi(r,a,g,c,I))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Li(0,0,.3);return[...A,o,n,s]},elt=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")},tlt=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=elt({h:Number.parseFloat(t.h),p:1.3,pn:r,w:8.7});let I=Number.parseFloat(t.pw),c=Number.parseFloat(t.pl);r===6?(I=3.4,c=2.15):(I=.6,c=2.2),A.push(Qi(r,a,g,c,I))}const e=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Li(0,0,.3);return[...A,o,n,s]},ilt=Hi.extend({fn:H(),num_pins:ZA().default(3),w:H().default("3.40mm"),h:H().default("3.30mm"),pl:H().default("1mm"),pw:H().default("0.7mm"),p:H().default("1.2mm"),string:H().optional()}),olt=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=ilt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:slt(i),parameters:i};throw new Error("Invalid number of pins")},nlt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},slt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=nlt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Li(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o},{x:i+.3,y:o},{x:i+.3,y:o/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o},{x:i+.3,y:-o},{x:i+.3,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},rlt=Hi.extend({fn:H(),num_pins:Ai([kA(3),kA(2)]).default(3),p:H().default("1.27mm"),id:H().default("0.72mm"),od:H().default("0.95mm"),w:H().default("2.5mm"),h:H().default("4.2mm"),string:H().optional()}),alt=t=>{const{p:A,id:e,od:i,w:o,h:n}=t,s=Number.parseFloat(n)/2,r=Number.parseFloat(A);return[Pn(1,-r,s-r,e,i),Pn(2,0,s-r,e,i),Pn(3,r,s-r,e,i)]},glt=t=>{const{p:A,id:e,od:i,h:o}=t,n=Number.parseFloat(o)/2,s=Number.parseFloat(A);return[Pn(1,-s,n-s,e,i),Pn(2,s,n-s,e,i)]},Ilt=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=rlt.parse({...t,num_pins:e});let o=[];if(i.num_pins===3)o=alt(i);else if(i.num_pins===2)o=glt(i);else throw new Error("Invalid number of pins for TO-92");const n=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n,y:n-s},{x:-1.9,y:0},{x:1.9,y:0},{x:n,y:n-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-n,y:n-s}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Li(0,n+1,.5);return{circuitJson:[...o,r,a],parameters:i}},clt=Hi.extend({fn:H(),p:$A.optional(),id:$A.optional(),pw:$A.optional(),pl:$A.optional(),w:$A.optional(),h:$A.optional(),sh:Ai([ce(),H(),ZA()]).optional().transform(t=>{if(typeof t=="string"){const A=Number(t);return Number.isNaN(A)?!0:A}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:ce().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:H().optional()}),Blt={ph:{p:$A.parse("2.2mm"),id:$A.parse("0.70mm"),pw:$A.parse("1.20mm"),pl:$A.parse("1.20mm"),w:$A.parse("6mm"),h:$A.parse("5mm")},sh:{p:$A.parse("1mm"),pw:$A.parse("0.6mm"),pl:$A.parse("1.55mm"),w:$A.parse("5.8mm"),h:$A.parse("7.8mm")}};function Clt(t){return t.sh?"sh":(t.ph,"ph")}function llt(t,A,e,i,o,n){const s=[];if(t==="ph"){const r=e/2;s.push(oS(1,-r,2,i,o,n)),s.push(oS(2,r,2,i,o,n))}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const I=r+g*e;console.log("x si",I),s.push(Qi(g+1,I,-1.325,o,n))}const a=(A-1)/2*e+1.3;console.log("offset",a),s.push(Qi(A+1,-a,1.22,1.2,1.8)),s.push(Qi(A+2,a,1.22,1.2,1.8))}return s}function Qlt(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 Elt=t=>{const A=clt.parse(t),e=Clt(A),i=Blt[e],o=A.p??i.p,n=A.id??i.id,s=A.pw??i.pw,r=A.pl??i.pl,a=A.w??i.w,g=A.h??i.h;let I=e==="sh"?4:2;if(e==="sh"){const Q=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(Q&&Q[1]){const E=parseInt(Q[1],10);Number.isNaN(E)||(I=E)}else typeof A.sh=="number"&&(I=A.sh)}const c=llt(e,I,o,n,s,r),B=Qlt(e),C=Li(0,g/2+1,.5);return{circuitJson:[...c,B,C],parameters:{...A,p:o,id:n,pw:s,pl:r,w:a,h:g,num_pins:I,sh:e==="sh",ph:e==="ph"}}},hlt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.30mm"),h:H().default("1.70mm"),pl:H().default("0.80mm"),pw:H().default("1mm"),p:H().default("1.90mm")}),ult=t=>{const A=hlt.parse(t),e=Li(0,$A.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:plt(A).concat(i,e),parameters:A}},dlt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},plt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=dlt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},flt=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"}}},ylt=Hi.extend({fn:H(),num_pins:Ai([kA(8),kA(10)]).default(8),w:H().optional(),h:H().optional(),p:H().optional(),pl:H().optional(),pw:H().optional(),string:H().optional()}),wlt=t=>{const A=ylt.parse(t),e=flt(A.num_pins),i=$A.parse(A.w||e.w),o=$A.parse(A.h||e.h),n=$A.parse(A.p||e.p),s=$A.parse(A.pl||e.pl),r=$A.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}=GWA(A.num_pins,u+1,i,n),D=u<g?u+1:A.num_pins-(u-g);a.push(Qi(D,d,f,s,r))}const I=i,c=o,B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:c/2},{x:I/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C={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=GWA(A.num_pins,1,I,n),Q={x:l.x-.8,y:l.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=Li(0,c/2+.5,.3);return{circuitJson:[...a,B,C,h,E],parameters:A}},GWA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*$A.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},mlt=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"}}},Dlt=Hi.extend({fn:H(),num_pins:Ai([kA(8),kA(10),kA(12),kA(16)]).default(8),w:H().optional(),h:H().optional(),p:H().optional(),pl:H().optional(),pw:H().optional(),string:H().optional()}),FWA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*$A.parse("2mm"),y:r*i}},Slt=t=>{const A=Dlt.parse(t),e=mlt(A.num_pins),i=$A.parse(A.w||e.w),o=$A.parse(A.h||e.h),n=$A.parse(A.p||e.p),s=$A.parse(A.pl||e.pl),r=$A.parse(A.pw||e.pw),a=[];for(let h=0;h<A.num_pins;h++){const{x:u,y:d}=FWA(A.num_pins,h+1,i,n);a.push(Qi(h+1,u,d,s,r))}const g=i,I=o,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:I/2},{x:g/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-I/2},{x:g/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=FWA(A.num_pins,1,g,n),l={x:C.x-.8,y:C.y},Q={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"},E=Li(0,I/2+.5,.3);return{circuitJson:[...a,c,B,E,Q],parameters:A}},blt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.8mm"),h:H().default("1.65mm"),pl:H().default("1.2mm"),pw:H().default("1.2mm"),pad_spacing:H().default("2.6mm")}),xlt=t=>{const A=blt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.pad_spacing)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.pad_spacing)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Glt(A).concat(i,e),parameters:A}},klt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Glt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=klt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Flt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("3.20mm"),h:H().default("1.65mm"),pl:H().default("0.8mm"),pw:H().default("0.9mm"),pad_spacing:H().default("2.1mm")}),Rlt=t=>{const A=Flt.parse(t),e=Li(0,$A.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.pad_spacing)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.2,y:-$A.parse(A.h)/2},{x:$A.parse(A.pad_spacing)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:_lt(A).concat(i,e),parameters:A}},Nlt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},_lt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=Nlt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Mlt=Hi.extend({fn:H(),num_pins:Ai([kA(6),kA(8)]).default(8),w:H().default("3mm"),h:H().default("3mm"),p:H().default("0.5mm"),pl:H().default("0.52mm"),pw:H().default("0.35mm"),epw:H().default("1.40mm"),eph:H().default("1.60mm"),string:H().optional(),ep:ce().default(!1)}),vlt=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=Mlt.parse({...t,num_pins:e}),o=$A.parse(i.w),n=$A.parse(i.h),s=$A.parse(i.p),r=$A.parse(i.pl),a=$A.parse(i.pw),g=$A.parse(i.epw),I=$A.parse(i.eph),c=[];for(let f=0;f<i.num_pins;f++){const{x:D,y:b}=RWA(i.num_pins,f+1,o,s);c.push(Qi(f+1,D,b,r,a))}i.ep&&c.push(Qi(i.num_pins+1,0,0,g,I));const B=o,C=n,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:C/2},{x:B/2,y:C/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:-C/2},{x:B/2,y:-C/2}],stroke_width:.05,pcb_silkscreen_path_id:""},E=RWA(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=Li(0,C/2+.5,.3);return{circuitJson:[...c,l,Q,d,u],parameters:i}},RWA=(t,A,e,i)=>{const o=t/2,n=(A-1)%o,s=A<=o?-1:1,r=(o-1)/2-n;return{x:s*$A.parse("1.4mm"),y:r*i}},Ult=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:o=1.5,ph:n=1.5}=t,s=$A.parse(i),r=$A.parse(o),a=$A.parse(n),g=Math.min(a/4,.5),I=[];for(let f=0;f<A;f++)I.push(Qi(f+1,f*s,0,r,a));let c=[];if(e){const f=e.split("").map(Number);if(f.length>1)for(let D=0;D<f.length-1;D++){const b=f[D],m=f[D+1];if(typeof b=="number"&&typeof m=="number"&&!isNaN(b)&&!isNaN(m)){const x=(b-1)*s,F=(m-1)*s,k=Math.sign(F-x),v=x+k*(r/2),_=F-k*(r/2);c.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${b}}`,x:v,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${m}}`,x:_,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const B=(A-1)*s+r+.7,C=a+1,l=(A-1)*s/2,Q=0,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:l-B/2,y:Q-C/2},{x:l+B/2,y:Q-C/2},{x:l+B/2,y:Q+C/2},{x:l-B/2,y:Q+C/2},{x:l-B/2,y:Q-C/2}],stroke_width:.15},u=Q+C/2+.6,d=Li(l,u,.4);return{circuitJson:[...I,...c,E,d],parameters:t}},NWA={fn:kA("sot457"),num_pins:kA(6).default(6),pillh:H().default("0.45mm"),pillw:H().default("1.45mm"),pl:H(),pw:H(),p:H(),wave:ce().optional(),reflow:ce().optional()},Llt=Hi.extend({...NWA,h:H().default("2.5mm"),w:H().default("2.7mm"),pl:H().default("0.8mm"),pw:H().default("0.55mm"),p:H().default("0.95mm")}),Hlt=Hi.extend({...NWA,h:H().default("3mm"),w:H().default("4mm"),pillr:H().default("0.225mm"),pl:H().default("1.45mm"),pw:H().default("1.5mm"),p:H().default("1.475mm")}).transform(t=>({...t,wave:t.wave??(t.reflow===void 0?!0:!t.reflow),reflow:t.reflow??(t.wave===void 0?!1:!t.wave)})),nS=t=>Number.parseFloat(t.replace("mm","")),_WA=({pitch:t,width:A,pinNumber:e})=>{const n={1:{x:-A/2-.1,y:t},2:{x:-A/2-.1,y:0},3:{x:-A/2-.1,y:-t},4:{x:A/2+.1,y:-t},5:{x:A/2+.1,y:0},6:{x:A/2+.1,y:t}}[e];if(!n)throw new Error(`Invalid pin number: ${e}`);return n},MWA=t=>{const A=[],e=nS(t.p),i=nS(t.pl),o=nS(t.pw),n=nS(t.w),s=nS(t.h);if(t.wave){const l={1:({padWidth:Q,padHeight:E})=>Qi(1,-e,e,E,Q),2:({padWidth:Q,padHeight:E})=>Qi(2,-e,-e,E,Q),3:({padWidth:Q,padHeight:E})=>FO(3,-e,0,nS(t.pillw),nS(t.pillh)),4:({padWidth:Q,padHeight:E})=>FO(4,e,0,nS(t.pillw),nS(t.pillh)),5:({padWidth:Q,padHeight:E})=>Qi(5,e,e,E,Q),6:({padWidth:Q,padHeight:E})=>Qi(6,e,-e,E,Q)};for(let Q=1;Q<=t.num_pins;Q++){const E=l[Q];E&&A.push(E({padWidth:i,padHeight:o}))}}else for(let l=1;l<=t.num_pins;l++){const{x:Q,y:E}=_WA({pitch:e,width:n,pinNumber:l});A.push(Qi(l,Q,E,i,o))}const r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:s/2+e/1.3},{x:n/3,y:s/2+e/1.3}],stroke_width:.05},a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-s/2-e/1.3},{x:n/3,y:-s/2-e/1.3}],stroke_width:.05},g=Li(0,s+.5,.3),I=_WA({pitch:e,width:n,pinNumber:1}),c=t.wave?1:.5,B=t.wave?.7:.3;I.x-=t.wave?o:o*1.7;const C={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,C,...A]},Ylt=t=>{if(t.wave){const e=Hlt.parse({...t,fn:"sot457"});return{circuitJson:MWA(e),parameters:e}}const A=Llt.parse(t);return{circuitJson:MWA(A),parameters:A}},Jlt=Hi.extend({fn:H(),num_pins:kA(6).default(6),w:H().default("1.1mm"),h:H().default("1.45mm"),p:H().default("0.35mm"),pl:H().default("0.2mm"),pw:H().default("0.2mm"),string:H().optional()}),Klt=t=>{const A=Jlt.parse({...t,fn:"sot963"}),e=$A.parse(A.w),i=$A.parse(A.h),o=$A.parse(A.p),n=$A.parse(A.pl),s=$A.parse(A.pw),r=[];for(let C=0;C<6;C++){const{x:l,y:Q}=vWA(C+1,e,o,n);r.push(Qi(C+1,l,Q,n,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=vWA(1,e,o,n),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-n/2-.3,y:I.y},{x:I.x-n/2-.45,y:I.y+.15},{x:I.x-n/2-.45,y:I.y-.15},{x:I.x-n/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},B=Li(0,i/2+.4,.25);return{circuitJson:[...r,a,g,B,c],parameters:A}},vWA=(t,A,e,i)=>{const o=A/2-i/2;return t<=3?{x:-o,y:e-(t-1)*e}:{x:o,y:-e+(t-4)*e}},Tlt=Hi.extend({fn:H(),num_pins:Ai([kA(3),kA(2)]).default(3),p:H().default("3.8mm"),id:H().default("1.25mm"),od:H().default("2.35mm"),ca:H().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:H().default("5.35mm"),h:H().default("4mm"),string:H().optional()}),qlt=t=>{const{p:A,id:e,od:i,h:o,ca:n}=t,s=Number.parseFloat(o),r=Number.parseFloat(n);return[Pn(1,0,r/4+.3,e,i),Pn(2,s,0,e,i),Pn(3,0,-r/4-.3,e,i)]},Plt=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=Tlt.parse({...t,num_pins:e});let o=[];i.num_pins===3&&(o=qlt(i));const n=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),r=Number.parseFloat(i.od)/2+.35,a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:n-1.75},{x:0,y:n},{x:s,y:n},{x:s,y:r}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-r},{x:s,y:-n},{x:0,y:-n},{x:0,y:-n+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},I=Number.parseFloat(i.w)/2,c=Li(I,n+1,.5);return{circuitJson:[...o,a,g,c],parameters:i}},Olt=Hi.extend({fn:H(),p:$A.optional().default("7.5mm"),id:$A.optional().default("1mm"),od:$A.optional().default("2mm"),d:$A.optional().default("10.5mm")}),Wlt=(t,A,e,i,o)=>{const n=[],s=[];for(let r=0;r<=50;r++){const a=r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-o/2&&I<=A+o/2||n.push({x:g,y:I})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-o/2&&I<=A+o/2||s.push({x:g,y:I})}return{topArc:n,bottomArc:s}},Zlt=t=>{const A=Olt.parse(t),{p:e,id:i,od:o,d:n}=A,s=[Pn(1,-e/2,0,i,o),Pn(2,e/2,0,i,o)],{topArc:r,bottomArc:a}=Wlt(0,0,n/2+.1,o/2,o),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:.1,pcb_silkscreen_path_id:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:n/2+.1},{x:0,y:-(n/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},B=-(n/2+.5),C=o/2+1.5,l=.5,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B-l,y:C},{x:B+l,y:C}],stroke_width:.1,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B,y:C-l},{x:B,y:C+l}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Li(0,n/2+1,.5);return{circuitJson:[...s,g,I,c,Q,E,h],parameters:A}},Vlt=Hi.extend({fn:H(),num_pins:kA(2).default(2),w:H().default("6.5mm"),h:H().default("3mm"),pl:H().default("1.75mm"),pw:H().default("2.40mm"),p:H().default("4.75mm")}),jlt=t=>{const A=Vlt.parse(t),e=Li(0,$A.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:$A.parse(A.p)/2,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.3,y:$A.parse(A.h)/2},{x:-$A.parse(A.w)/2-.3,y:-$A.parse(A.h)/2},{x:$A.parse(A.p)/2,y:-$A.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Xlt(A).concat(i,e),parameters:A}},zlt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Xlt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:o}=zlt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},$lt=Hi.extend({fn:H(),num_pins:ZA().default(3),w:H().default("2.45mm"),h:H().default("2.40mm"),pl:H().default("1.225mm"),pw:H().default("0.5mm"),p:H().default("0.95mm"),string:H().optional()}),AQt=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=$lt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:tQt(i),parameters:i};throw new Error("Invalid number of pins")},eQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},tQt=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=eQt({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});A.push(Qi(r+1,a,g,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Li(0,Number.parseInt(t.h)/2+1,.3),i=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),o=Number.parseFloat(t.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:o+.3},{x:i,y:o+.3},{x:i,y:o/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-o-.3},{x:i,y:-o-.3},{x:i,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,n,s,e]},iQt=Hi.extend({fn:H(),circle:ce().optional(),rect:ce().optional(),square:ce().optional(),pill:ce().optional(),d:$A.optional(),pd:$A.optional(),diameter:$A.optional(),r:$A.optional(),pr:$A.optional(),radius:$A.optional(),w:$A.optional(),pw:$A.optional(),width:$A.optional(),h:$A.optional(),ph:$A.optional(),height:$A.optional(),s:$A.optional(),size:$A.optional(),string:H().optional()}).transform(t=>{let A="rect";t.circle&&(A="circle"),t.square&&(A="square"),t.rect&&(A="rect"),t.pill&&(A="pill");let e,i,o;return A==="circle"?t.r!==void 0?e=wr(t.r):t.pr!==void 0?e=wr(t.pr):t.radius!==void 0?e=wr(t.radius):t.d!==void 0?e=wr(t.d)/2:t.pd!==void 0?e=wr(t.pd)/2:t.diameter!==void 0?e=wr(t.diameter)/2:e=wr("1mm")/2:(t.w!==void 0?i=wr(t.w):t.pw!==void 0?i=wr(t.pw):t.width!==void 0?i=wr(t.width):t.s!==void 0?i=wr(t.s):t.size!==void 0?i=wr(t.size):i=wr("1mm"),t.h!==void 0?o=wr(t.h):t.ph!==void 0?o=wr(t.ph):t.height!==void 0?o=wr(t.height):A==="square"||A==="rect"?o=i:o=wr("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:o}}),oQt=t=>{const A=iQt.parse(t),{shape:e,radius:i,width:o,height:n}=A;let s,r;return e==="circle"?(s=EWA(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=FO(1,0,0,o,n),r=Math.max(o,n)/2+.5):(s=Qi(1,0,0,o,n),r=n/2+.5),{circuitJson:[s,Li(0,r,.2)],parameters:A}},nQt=Hi.extend({fn:H(),d:$A.optional(),hd:$A.optional(),r:$A.optional(),hr:$A.optional(),pd:$A.optional(),pr:$A.optional(),squarepad:ce().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=wr(t.d):t.hd!==void 0?A=wr(t.hd):t.r!==void 0?A=wr(t.r)*2:t.hr!==void 0?A=wr(t.hr)*2:A=wr("1mm");let e;return t.pd!==void 0?e=wr(t.pd):t.pr!==void 0?e=wr(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),sQt=t=>{const A=nQt.parse(t),{d:e,pd:i,squarepad:o}=A;return{circuitJson:[o?oS(1,0,0,e,i,i):Pn(1,0,0,e,i),Li(0,i/2+.5,.2)],parameters:A}},rQt=Hi.extend({fn:H(),num_pins:kA(6).default(6),h:H().default("1.6mm"),pl:H().default("1mm"),pw:H().default("0.7mm"),p:H().default("0.95mm")}),aQt=t=>{const A=rQt.parse(t);return{circuitJson:gQt(A),parameters:A}},UWA=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")},gQt=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:C}=UWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(Qi(c,B,C,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Li(0,i+.3,.3),r=UWA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,o,n,I]},IQt=Hi.extend({fn:H(),num_pins:ZA().default(4),w:H().default("3.2mm"),h:H().default("2.6mm"),pl:H().default("1.35mm"),pw:H().default("0.50mm"),p:H().default("0.6mm"),string:H().optional()}),cQt=t=>{const A=t.string?.match(/^sot343_(\d+)/),e=A?Number.parseInt(A[1],4):4,i=IQt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:CQt(i),parameters:i};throw new Error("Invalid number of pins")},BQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e*1.92,y:-.65}:A===2?{x:-e*1.92,y:.65}:A===3?{x:e,y:.65}:A===4?{x:e,y:-.65}:{x:0,y:0}},CQt=t=>{const A=[],e=Number.parseFloat(t.w),i=Number.parseFloat(t.h),o=Number.parseFloat(t.pl),n=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let r=1/0,a=-1/0,g=1/0,I=-1/0;for(let d=0;d<t.num_pins;d++){const{x:f,y:D}=BQt({num_pins:t.num_pins,pn:d+1,p:s});A.push(Qi(d+1,f,D,o,n)),f<r&&(r=f),f>a&&(a=f),D<g&&(g=D),D>I&&(I=D)}const c=(r+a)/2,B=I-g,C=i*.3,l=B/2+C;let Q=e*.8;i<=2.6&&(Q/=2);const E=Li(c,l+.5,.3),h={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:c-Q/2,y:l},{x:c+Q/2,y:l}],type:"pcb_silkscreen_path",stroke_width:.1},u={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_bottom",route:[{x:c-Q/2,y:-l},{x:c+Q/2,y:-l}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,h,u,E]},lQt=Hi.extend({fn:H()}),QQt=t=>{const A=lQt.parse(t),e=[],i=.5-.15,o=1.5,s=.5/2,r=75,a=-37/2;for(let m=0;m<r;m++){const x=m+1;if(x>=24&&x<=31)continue;const F=a-m*s,k=x%2===0,v=o+(k?.25:0),Y=.5-v/2,P=Qi(x,Y,F,v,i);P.layer=k?"bottom":"top",e.push(P)}const g=46*.0254,I=137*.0254,c=261*.0254,B={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-I/2+o/2,y:a-c},width:I,height:g},C={x:-.5,y:a},l={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"};let Q=1/0,E=-1/0,h=1/0,u=-1/0;const d=(m,x,F=0,k=0)=>{Q=Math.min(Q,m-F/2),E=Math.max(E,m+F/2),h=Math.min(h,x-k/2),u=Math.max(u,x+k/2)};for(const m of e)d(m.x,m.y,m.width,m.height);d(B.center.x,B.center.y,B.width,B.height);for(const m of l.route)d(m.x,m.y);const f=(Q+E)/2,D=(h+u)/2,b=m=>{typeof m.x=="number"&&(m.x-=f),typeof m.y=="number"&&(m.y-=D),m.center&&(m.center.x-=f,m.center.y-=D),Array.isArray(m.route)&&(m.route=m.route.map(x=>({x:x.x-f,y:x.y-D})))};for(const m of e)b(m);return b(B),b(l),{circuitJson:[...e,B,l],parameters:A}},EQt=Hi.extend({fn:H(),num_pins:ZA().default(3),inline:ce().default(!1),p:H().default("1.27mm"),id:H().default("0.75mm"),od:H().default("1.3mm"),w:H().default("4.8mm"),h:H().default("4.0mm")}),hQt=t=>{const A=EQt.parse(t),e=Number.parseFloat(A.p),i=Number.parseFloat(A.w),o=Number.parseFloat(A.h),n=A.inline?1.05:Number.parseFloat(A.od),s=A.inline?1.5:n,r=[oS(1,0,0,A.id,n,s,0,0),A.inline?FU(2,e,0,A.id,n,s):Pn(2,e,e,A.id,n),A.inline?FU(3,e*2,0,A.id,n,s):Pn(3,e*2,0,A.id,n)],a=i/2,g=A.inline?e-.09:e,I=.2,c=I+a-o,B=Array.from({length:32},(Q,E)=>{const h=Math.PI*E/31;return{x:g+a*Math.cos(h),y:I+a*Math.sin(h)}}),C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",stroke_width:.12,route:[...B,{x:g-a,y:c},{x:g+a,y:c},B[0]]},l=Li(g,I+a+1,.5);return{circuitJson:[...r,C,l],parameters:A}};function uQt(t){return t!=null}var dQt=(t,A)=>{if(!A)return t;const e=t.filter(I=>I.type==="pcb_smtpad"||I.type==="pcb_plated_hole"||I.type==="pcb_thtpad");if(e.length===0)return t;let i=1/0,o=-1/0,n=1/0,s=-1/0;const r=(I,c,B=0,C=0)=>{const l=I-B/2,Q=I+B/2,E=c-C/2,h=c+C/2;i=Math.min(i,l),o=Math.max(o,Q),n=Math.min(n,E),s=Math.max(s,h)};for(const I of e)if(I.type==="pcb_smtpad"){const c=I.shape==="circle"?I.radius*2:I.width,B=I.shape==="circle"?I.radius*2:I.height;r(I.x,I.y,c,B)}else if(I.type==="pcb_plated_hole"){const c=I.outer_diameter??I.hole_diameter;r(I.x,I.y,c,c)}else if(I.type==="pcb_thtpad"){const c=I.diameter;r(I.x,I.y,c,c)}let a=0,g=0;switch(A){case"center":a=(i+o)/2,g=(n+s)/2;break;case"bottomleft":a=i,g=n;break;case"bottomcenter":case"centerbottom":a=(i+o)/2,g=n;break;case"topcenter":case"centertop":a=(i+o)/2,g=s;break;case"leftcenter":case"centerleft":a=i,g=(n+s)/2;break;case"rightcenter":case"centerright":a=o,g=(n+s)/2;break;case"pin1":const I=e.find(c=>c.port_hints?.[0]==="1")||e[0];a=I.x,g=I.y;break}if(a===0&&g===0)return t;for(const I of t){if(typeof I.x=="number"&&(I.x-=a),typeof I.y=="number"&&(I.y-=g),I.center&&typeof I.center.x=="number"&&(I.center.x-=a,I.center.y-=g),I.type==="pcb_silkscreen_path")for(const c of I.route)c.x-=a,c.y-=g;I.type==="pcb_silkscreen_text"&&I.anchor_position&&(I.anchor_position.x-=a,I.anchor_position.y-=g)}return t},pQt=(t,A)=>{const e=t.filter(i=>i.type==="pcb_silkscreen_text");if(e.length===0)return t;for(const i of e)A.norefdes&&(i.text="");return t},fQt=(t,A)=>A.nosilkscreen?t.filter(e=>e.type!=="pcb_silkscreen_path"&&e.type!=="pcb_silkscreen_text"):t,yQt=t=>{let A=MO();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(o=>{const n=o.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!n)return null;const[,s,r]=n;if(!s)return null;const a=s.toLowerCase();return r?.includes("?")?null:{fn:a,v:r}}).filter(uQt);for(const{fn:o,v:n}of i)A=A[o](n);return A.setString(t),A},wQt=()=>Object.keys(iS),MO=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&iS[A.fn])return()=>{const{circuitJson:i}=iS[A.fn](A),o=fQt(i,A),n=pQt(o,A);return dQt(n,A.origin)};if(!iS[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(!iS[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>iS[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(iS):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in iS?(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};MO.string=yQt,MO.getFootprintNames=wQt;var mQt=MO,LWA=Symbol("Fragment");function yBA(t,A,...e){const i=e.length?e:A?.children!==void 0?[A.children]:[],o=[],n=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of n)s==null||s===!1||(Array.isArray(s)?o.push(...s):o.push(s));return{type:t,props:(A&&A.children!==void 0?{...A,children:void 0}:A)||{},children:o}}var ht=Symbol("Cuboid"),HWA=Symbol("Cube"),Jp=Symbol("Cylinder"),YWA=Symbol("Sphere"),RU=Symbol("RoundedCuboid"),Vi=Symbol("Translate"),QQ=Symbol("Rotate"),aE=Symbol("Union"),JG=Symbol("Subtract"),sI=Symbol("Hull"),ys=Symbol("Colorize"),NU=Symbol("Polygon"),_U=Symbol("ExtrudeLinear"),Kp=Symbol("RoundedCylinder"),Yo=LWA,Ae=(t,A,e)=>yBA(t,A),Ot=(t,A,e)=>yBA(t,A),VB=({center:t,width:A,length:e,height:i,heightAboveSurface:o=.15,color:n="#555",taperRatio:s=.12,faceRatio:r=.75,straightHeightRatio:a=.5,includeNotch:g=!0,notchRadius:I,notchPosition:c,notchRotation:B=[0,0,0],notchLength:C=.5,notchWidth:l=.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),D=Math.min(A,e)*.12,b=I??D,m={x:0,y:e/2-b*.25,z:i},x=c??m,F=Ot(aE,{children:[Ot(sI,{children:[Ae(Vi,{z:.005,children:Ae(ht,{size:[d,f,.01]})}),Ae(Vi,{z:E,children:Ae(ht,{size:[A,e,.01]})})]}),Ot(sI,{children:[Ae(Vi,{z:E,children:Ae(ht,{size:[A,e,.01]})}),Ae(Vi,{z:E+h,children:Ae(ht,{size:[d,f,.01]})})]})]}),k=(_,Y)=>Ae(Vi,{offset:{x:_,y:Y,z:0},children:Ae(QQ,{rotation:[0,0,Math.PI/4],children:Ae(ht,{size:[Q*Math.SQRT2,Q*Math.SQRT2,i*3]})})});let v=F;if(Q>0){const _=A/2,Y=e/2;v=Ot(JG,{children:[F,k(_,Y),k(-_,Y),k(_,-Y),k(-_,-Y)]})}return Ae(ys,{color:n,children:Ae(Vi,{offset:t,children:Ae(Vi,{offset:{x:0,y:0,z:o},children:g?Ot(JG,{children:[v,Ae(Vi,{offset:x,children:Ae(QQ,{rotation:B,children:Ae(Jp,{radius:b,height:l})})})]}):v})})})},DQt=t=>Array.from({length:t},(A,e)=>e);function wBA(t,A){if(t.length<2)throw new Error("Stroke must have at least two points");const e=Array.isArray(t[0])?t.map(([I,c])=>({x:I,y:c})):t,i=A/2,o=[],n=[];function s(I,c){const B=c.x-I.x,C=c.y-I.y,l=Math.sqrt(B*B+C*C);return{x:-C/l,y:B/l}}function r(I,c,B){const C={x:I.x+c.x*i*B,y:I.y+c.y*i*B};B>0?o.push(C):n.unshift(C)}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],C=e[I+1],l=s(c,B),Q=s(B,C),E=l.x+Q.x,h=l.y+Q.y,u=Math.sqrt(E*E+h*h);if(u/2>2*i)r(B,l,1),r(B,Q,1),r(B,l,-1),r(B,Q,-1);else{const f=1/u;r(B,{x:E*f,y:h*f},1),r(B,{x:E*f,y:h*f},-1)}}const g=s(e[e.length-2],e[e.length-1]);return r(e[e.length-1],g,1),r(e[e.length-1],g,-1),[...o,...n]}var SQt=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}))},bQt=SQt([{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}]),JWA=5.47,vO=.5,xQt=({x:t,y:A,z:e})=>{const i=t>0;return Ot(Yo,{children:[Ae(Vi,{offset:{x:t+.25/2,y:A,z:e},children:Ae(QQ,{rotation:["-90deg",0,"90deg"],children:Ae(_U,{height:.25,children:Ae(NU,{points:bQt.slice().reverse().map(o=>[o.x,o.y])})})})}),Ae(Vi,{offset:{x:t,y:A+(i?1:-1),z:e},children:Ae(QQ,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:Ae(_U,{height:2,children:Ae(NU,{points:wBA([[0,0],[-1,0],[-1,-1]],.25).map(o=>[o.x,o.y])})})})})]})},kQt=({numPins:t=8,pitch:A=2.54,bodyWidth:e=6.4,rowSpacing:i})=>{const o=Math.floor(t/2),n=i??(e>=7?e:e+1.22),s=e>=7?n-1.22:e;return Ot(Yo,{children:[DQt(t).map(r=>{const a=r%o,g=(Math.floor(r/o)-.5)*2;return Ae(xQt,{x:g*n/2,y:a*A-(o-1)/2*A,z:JWA/2+vO})}),Ae(VB,{width:s,length:o*A+.5,height:JWA-vO,heightAboveSurface:vO,center:{x:0,y:0,z:vO}})]})};function GQt(t,{height:A,padContactLength:e,curveLength:i,bodyDistance:o,steepness:n=10}){i||(i=o*.3);let s=o-e-i;s<0&&(i+=s,s=0);const r=e*.75,a=e+i+(o-e-i)*.25;if(t<=r)return 0;if(t>=a)return A;const g=(t-r)/(a-r);return A/(1+Math.exp(-n*(g-.5)))}var To=t=>{const{thickness:A,width:e,padContactLength:i,bodyDistance:o,height:n,rotation:s}=t,r=15,a=Array.from({length:r}).map((I,c)=>c/(r-1)*o).map(I=>[I,GQt(I,t)]),g=wBA(a,A);return Ae(ys,{color:"#fff",children:Ae(Vi,{offset:{z:0,y:0,x:0,...t.position},children:Ae(QQ,{rotation:["90deg",0,s??0],children:Ae(Vi,{offset:{x:0,y:0,z:-e/2},children:Ae(_U,{height:e,children:Ae(NU,{points:g.map(I=>[I.x,I.y])})})})})})})},FQt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:o})=>{const n=Math.ceil(t/2),s=i*t/2+e/2,r=(n-1)*i/2,a=.25;return Ot(Yo,{children:[Array.from({length:n}).map((g,I)=>Ae(To,{position:{x:-o/2-A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:n}).map((g,I)=>Ae(To,{rotation:Math.PI,position:{x:o/2+A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Ae(VB,{center:{x:0,y:0,z:a/2},width:o-e-1,length:s,height:1.5})]})},RQt=({pinCount:t,padContactLength:A=.4,leadWidth:e=.2,pitch:i=.65,bodyWidth:o=3})=>{const n=Math.ceil(t/2),s=(n-1)*i/2,r=.2;return Ot(Yo,{children:[Array.from({length:n}).map((a,g)=>Ae(To,{position:{x:-o/2-A-.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Array.from({length:n}).map((a,g)=>Ae(To,{rotation:Math.PI,position:{x:o/2+A+.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Ae(VB,{center:{x:0,y:0,z:r/2},width:o,length:o,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},mBA=1,DBA=.5,N_=.5,MU=.2,NQt=mBA-MU*2,KWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[NQt,DBA,N_],offset:[0,0,N_/2],color:t}),Ae(ht,{size:[MU,N_,DBA],offset:[mBA/2-MU/2,0,N_/2],color:"#ccc"}),Ae(ht,{size:[MU,N_,DBA],offset:[-mBA/2+MU/2,0,N_/2],color:"#ccc"})]}),SBA=1.6,_Qt=SBA-.3*2,UO=.3,bBA=.85,__=.6,TWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[_Qt,bBA,__],offset:[0,0,__/2],color:t}),Ae(ht,{size:[UO,bBA,__],offset:[SBA/2-UO/2,0,__/2],color:"#ccc"}),Ae(ht,{size:[UO,bBA,__],offset:[-SBA/2+UO/2,0,__/2],color:"#ccc"})]}),xBA=2,kBA=1.25,M_=.55,vU=.5,MQt=xBA-vU*2,qWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[MQt,kBA,M_],offset:[0,0,M_/2],color:t}),Ae(ht,{size:[vU,kBA,M_],offset:[xBA/2-vU/2,0,M_/2],color:"#ccc"}),Ae(ht,{size:[vU,kBA,M_],offset:[-xBA/2+vU/2,0,M_/2],color:"#ccc"})]}),vQt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:o})=>{const n=t/4;A||(A=UQt(t,o)),i||(i=LQt(t)),e||(e=HQt(t,o)),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+2*i,g=a,I=.8,c=.15,B=(g-o)/2+.5;return Ot(Yo,{children:[Array.from({length:n}).map((C,l)=>Ae(To,{position:{x:-g/2-.4,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:Math.PI,position:{x:g/2+.4,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:Math.PI/2,position:{x:l*A-r,y:-a/2-.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:-Math.PI/2,position:{x:l*A-r,y:a/2+.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Ae(VB,{center:{x:0,y:0,z:0},width:o,length:s,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:o/2-1.5,z:1.5},notchRadius:1.5/2})]})},UQt=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},LQt=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}},HQt=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},YQt=({numberOfPins:t,pitch:A=2.54,longSidePinLength:e=6,invert:i,faceup:o,rows:n=1})=>{const a=Math.ceil(t/n),g=2.54,I=a*A,c=n>1?(n-1)*g+.63*3:.63*3,B=3,C=-((a-1)/2)*A,l=n>1?-((n-1)*g)/2:0,Q=E=>i||o?-E+2:E;return Ot(Yo,{children:[Ae(ht,{color:"#222",size:[I,c,2],center:[0,l,Q(2/2)]}),Array.from({length:t},(E,h)=>{const u=Math.floor(h/a),d=h%a,f=C+d*A,D=-u*g;return Ot(Yo,{children:[!o&&Ae(ys,{color:"gold",children:Ot(sI,{children:[Ae(ht,{color:"gold",size:[.63,.63,B*.9],center:[f,D,Q(2*.9+2/2)]}),Ae(ht,{color:"gold",size:[.63/1.8,.63/1.8,B],center:[f,D,Q(2+2/2)]})]})}),Ae(ys,{color:"gold",children:Ot(sI,{children:[Ae(ht,{color:"gold",size:[.63,.63,e*.9],center:[f,D,Q(-e/2*.9)]}),Ae(ht,{color:"gold",size:[.63/1.8,.63/1.8,e],center:[f,D,Q(-e/2)]})]})})]})})]})},JQt=t=>{const A=["left","bottom","right","top"],{pin_count:e,pn:i,w:o,h:n,p:s,pl:r}=t,a=e/4,g=A[Math.floor((i-1)/a)],I=(i-1)%a,c=s*(a-1),B=s*(a-1),C=-r/2;switch(g){case"left":return{x:-o/2-C,y:B/2-I*s,o:"vert"};case"bottom":return{x:-c/2+I*s,y:-n/2-C,o:"horz"};case"right":return{x:o/2+C,y:-B/2+I*s,o:"vert"};case"top":return{x:c/2-I*s,y:n/2+C,o:"horz"};default:throw new Error("Invalid pin number")}},KQt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const o=[],n=t/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=n:r.bottomside&&r.leftpin?s=n+1:r.bottomside&&r.rightpin?s=n*2:r.rightside&&r.bottompin?s=n*2+1:r.rightside&&r.toppin?s=n*3:r.topside&&r.rightpin?s=n*3+1:r.topside&&r.leftpin&&(s=n*4),o.push(-1);for(let a=0;a<t;a++)o[s]=a+1,s++,s>t&&(s=1);return o},TQt=({num_pins:t=16,bodyWidth:A=9,bodyLength:e=9,bodyThickness:i=.8,thermalPadSize:o,padWidth:n=.25,padLength:s=.25,pitch:r=.5,thermalPadThickness:a=.05})=>{const g=KQt({num_pins:t,cw:!0,ccw:!0}),I=[];for(let c=0;c<t;c++){const{x:B,y:C,o:l}=JQt({pin_count:t,pn:c+1,w:A,h:e,p:r,pl:s});let Q=n,E=s;l==="vert"&&([Q,E]=[E,Q]);const h=g[c+1];I.push({pn:h,x:B,y:C,pw:Q,pl:E})}return Ot(Yo,{children:[Ae(ys,{color:"grey",children:Ae(ht,{center:{x:0,y:0,z:i/2},size:[A,e,i]})}),I.map((c,B)=>Ae(ht,{center:{x:c.x,y:c.y,z:a/2},size:[c.pw,c.pl,a]})),o?.length!==void 0&&o?.width!==void 0&&Ae(ht,{center:{x:0,y:0,z:a/2},size:[o.width,o.length,a]})]})},qQt=TQt,PQt=()=>{const a=1.1999999999999997;return Ot(Yo,{children:[Ae(To,{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}),Ae(To,{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}),Ae(To,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),Ae(To,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),Ae(To,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),Ae(VB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},OQt=PQt,WQt=({fullWidth:t=2.9,fullLength:A=2.8})=>{const I=(t-1.92)/2+.3;return Ot(Yo,{children:[Ae(To,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),Ae(To,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),Ae(To,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),Ae(VB,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},GBA=.6,FBA=.3,v_=.33,UU=.1,ZQt=GBA-UU*2,PWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[ZQt,FBA,v_],offset:[0,0,v_/2],color:t}),Ae(ht,{size:[UU,FBA,v_],offset:[GBA/2-UU/2,0,v_/2],color:"#ccc"}),Ae(ht,{size:[UU,FBA,v_],offset:[-GBA/2+UU/2,0,v_/2],color:"#ccc"})]}),RBA=.4,NBA=.2,U_=.13,LU=.07,VQt=RBA-LU*2,OWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[VQt,NBA,U_],offset:[0,0,U_/2],color:t}),Ae(ht,{size:[LU,NBA,U_],offset:[RBA/2-LU/2,0,U_/2],color:"#ccc"}),Ae(ht,{size:[LU,NBA,U_],offset:[-RBA/2+LU/2,0,U_/2],color:"#ccc"})]}),_BA=3.2,MBA=1.6,L_=.9,HU=.5,jQt=_BA-HU*2,WWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[jQt,MBA,L_],offset:[0,0,L_/2],color:t}),Ae(ht,{size:[HU,MBA,L_],offset:[_BA/2-HU/2,0,L_/2],color:"#ccc"}),Ae(ht,{size:[HU,MBA,L_],offset:[-_BA/2+HU/2,0,L_/2],color:"#ccc"})]}),vBA=3.2,UBA=2.5,H_=1,YU=.6,zQt=vBA-YU*2,ZWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[zQt,UBA,H_],offset:[0,0,H_/2],color:t}),Ae(ht,{size:[YU,UBA,H_],offset:[vBA/2-YU/2,0,H_/2],color:"#ccc"}),Ae(ht,{size:[YU,UBA,H_],offset:[-vBA/2+YU/2,0,H_/2],color:"#ccc"})]}),LBA=5,HBA=2.5,Y_=1.4,JU=.6,XQt=LBA-JU*2,VWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[XQt,HBA,Y_],offset:[0,0,Y_/2],color:t}),Ae(ht,{size:[JU,HBA,Y_],offset:[LBA/2-JU/2,0,Y_/2],color:"#ccc"}),Ae(ht,{size:[JU,HBA,Y_],offset:[-LBA/2+JU/2,0,Y_/2],color:"#ccc"})]}),YBA=6.3,JBA=3.2,J_=1.8,KU=.8,$Qt=YBA-KU*2,jWA=({color:t="#333"})=>Ot(Yo,{children:[Ae(ht,{size:[$Qt,JBA,J_],offset:[0,0,J_/2],color:t}),Ae(ht,{size:[KU,JBA,J_],offset:[YBA/2-KU/2,0,J_/2],color:"#ccc"}),Ae(ht,{size:[KU,JBA,J_],offset:[-YBA/2+KU/2,0,J_/2],color:"#ccc"})]}),AEt=({numberOfPins:t,pitch:A=2.54,legsLength:e=3,outerDiameter:i=.945,innerDiameter:o=.945,rows:n=1})=>{const s=o/1.5,r=s*2+i,a=5,g=Math.ceil(t/n),I=2.54,c=(g-1)*A+i+A/2,B=n>1?(n-1)*I+r:r,C=s*1.6,l=-((g-1)/2)*A,Q=n>1?-((n-1)*I)/2:0,E=Ae(ys,{color:"#1a1a1a",children:Ot(JG,{children:[Ae(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,D=l+f*A,b=-d*I;return o?Ae(Jp,{height:a+.1,radius:o/2,center:[D,b,a/2],color:"#222"},u):Ae(ht,{size:[C,C,a],center:[D,b,a/2]},u)})]})});return Ot(Yo,{children:[E,Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,D=l+f*A,b=-d*I;return Ot(ys,{color:"silver",children:[Ot(sI,{children:[Ae(ht,{color:"silver",size:[s,s,e*.9],center:[D,b,-e/2*.9]}),Ae(ht,{color:"silver",size:[s/1.8,s/1.8,e],center:[D,b,-e/2]})]}),Ae(ht,{color:"silver",size:[C,C,C*.5],center:[D,b,C/2*.5]})]},u)})]})},eEt=({width:t,length:A,innerDiameter:e=1})=>{const i=t,o=A,n=t*.7,s=e/2.5;return Ot(Yo,{children:[Ae(RU,{color:"#1a1a1f",center:[0,0,n/2],size:[o,o,n],roundRadius:.3}),Ae(RU,{color:"#f2f2f2",center:[0,0,n+n*.1/2.5],size:[o,o,n*.1],roundRadius:.14}),Ae(Jp,{color:"#1a1a1f",height:n*.8,radius:i/3,center:[0,0,n+n*.8/2]}),Ae(Jp,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[o/3,o/3,n+n*.1/2]}),Ae(Jp,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[-o/3,-o/3,n+n*.1/2]}),Ae(Jp,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[-o/3,o/3,n+n*.1/2]}),Ae(Jp,{color:"#1a1a1f",height:n*.2,radius:e/2,center:[o/3,-o/3,n+n*.1/2]}),Ae(LO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:-o/2,z:-n*1.2}}),Ae(LO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:-i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),Ae(LO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2,y:o/2,z:-n*1.2},rotation:Math.PI}),Ae(LO,{thickness:e/3,width:s,horizontalLength:o*.8,verticalLength:n/2,position:{x:i/2+e/3.6,y:-o/2,z:-n*1.2}})]})},LO=t=>{const{thickness:A,width:e,horizontalLength:i,verticalLength:o,rotation:n=0,position:s}=t,r=[[0,i],[-o/3,i/3],[-o/5,i/4],[0,0]],a=wBA(r,A);return Ae(ys,{color:"#f2f2f2",children:Ae(Vi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Ae(QQ,{rotation:[0,55,n],children:Ae(_U,{height:e,children:Ae(NU,{points:a.map(g=>[g.y,g.x])})})})})})},tEt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:o})=>{const n=Math.ceil(t/2),s=(n-1)*i/2,r=.25,a=1,g=.8,I=A*0,c=i*(n-1)+e+.2,B=o*.55;return Ot(Yo,{children:[Array.from({length:n}).map((C,l)=>Ae(To,{position:{x:-o/2-I,y:l*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:Math.PI,position:{x:o/2+I,y:l*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Ae(VB,{center:{x:0,y:0,z:r/2},width:B,length:c,height:a})]})},iEt=({pinCount:t,pitch:A,leadWidth:e,leadLength:i,bodyWidth:o,bodyLength:n})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},r=isNaN(parseFloat(A))?s.pitch:parseFloat(A),a=isNaN(parseFloat(e))?s.leadWidth:parseFloat(e)*.8,g=isNaN(parseFloat(o))?2.6:parseFloat(o)*.8,I=isNaN(parseFloat(n))?2+Number(r)*1.4:parseFloat(n),c=t/2,B=(c-1)*r/2,C=.15,l=.8,Q=4.5,E=(Q-g)/2,h=E*.5;return Ot(Yo,{children:[Array.from({length:c}).map((u,d)=>Ae(To,{position:{x:-Q/2,y:B-d*r,z:C/2},width:a,thickness:C,padContactLength:h+.05,bodyDistance:E+.1,height:l})),Array.from({length:c}).map((u,d)=>Ae(To,{rotation:Math.PI,position:{x:Q/2,y:B-d*r,z:C/2},width:a,thickness:C,padContactLength:h+.05,bodyDistance:E+.1,height:l})),Ae(VB,{center:{x:0,y:0,z:C/2},width:g,length:I,height:1})]})},oEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),Ae(ht,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(Vi,{z:.3/2,children:Ae(ht,{size:[1.65,.8,.3]})}),Ot(sI,{children:[Ae(Vi,{z:.3,children:Ae(ht,{size:[1.65,.8,.01]})}),Ae(Vi,{z:.6,children:Ae(ht,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),nEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),Ae(ht,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),Ae(ys,{color:"#222",children:Ae(Vi,{z:.47/2+.02,children:Ae(ht,{size:[.98,.58,.47]})})}),Ae(ht,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),Ae(ht,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),Ae(ht,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),Ae(ht,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),sEt=()=>{const g=Ae(ys,{color:"#1a1a1a",children:Ot(aE,{children:[Ot(sI,{children:[Ae(Vi,{z:.13,children:Ae(ht,{size:[4,3,.03]})}),Ae(Vi,{z:1.15,children:Ae(ht,{size:[4.4,3.4,.01]})})]}),Ot(sI,{children:[Ae(Vi,{z:1.15,children:Ae(ht,{size:[4.4,3.4,.01]})}),Ae(Vi,{z:2.3,children:Ae(ht,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const l=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 Ae(ys,{color:"#c0c0c0",children:Ot(aE,{children:[Ae(ht,{size:[2.3*.8,1.45,.2],center:[l,0,.2/2]}),Ae(ht,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),Ae(ht,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Yo,{children:[Ae(I,{xDir:1}),Ae(I,{xDir:-1}),g]})},rEt=()=>{const g=Ae(ys,{color:"#1a1a1a",children:Ot(aE,{children:[Ot(sI,{children:[Ae(Vi,{z:.13,children:Ae(ht,{size:[4,3,.03]})}),Ae(Vi,{z:1.15,children:Ae(ht,{size:[4.4,3.4,.01]})})]}),Ot(sI,{children:[Ae(Vi,{z:1.15,children:Ae(ht,{size:[4.4,3.4,.01]})}),Ae(Vi,{z:2.3,children:Ae(ht,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const l=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 Ae(ys,{color:"#c0c0c0",children:Ot(aE,{children:[Ae(ht,{size:[2.3*.8,1.45,.2],center:[l,0,.2/2]}),Ae(ht,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),Ae(ht,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Yo,{children:[Ae(I,{xDir:1}),Ae(I,{xDir:-1}),g]})},aEt=()=>{const g=Ae(ys,{color:"#1a1a1a",children:Ot(aE,{children:[Ot(sI,{children:[Ae(Vi,{z:.21000000000000002,children:Ae(ht,{size:[6.3999999999999995,5.6,.03]})}),Ae(Vi,{z:1.15,children:Ae(ht,{size:[6.8,6,.01]})})]}),Ot(sI,{children:[Ae(Vi,{z:1.15,children:Ae(ht,{size:[6.8,6,.01]})}),Ae(Vi,{z:2.3,children:Ae(ht,{size:[6.3999999999999995,5.6,.01]})})]})]})}),I=({xDir:c})=>{const l=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 Ae(ys,{color:"#c0c0c0",children:Ot(aE,{children:[Ae(ht,{size:[2.3*.8,2.95,.2],center:[l,0,.2/2]}),Ae(ht,{size:[.2,2.95,1.14],center:[Q,0,1.14/2+.2]}),Ae(ht,{size:[h,2.95,.2],center:[u,0,.2/2+1.14]})]})})};return Ot(Yo,{children:[Ae(I,{xDir:1}),Ae(I,{xDir:-1}),g]})},gEt=()=>{const c=Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(Vi,{z:.27,children:Ae(ht,{size:[2.9,1.9,.54]})}),Ot(sI,{children:[Ae(Vi,{z:.54,children:Ae(ht,{size:[2.9,1.9,.01]})}),Ae(Vi,{z:1.08,children:Ae(ht,{size:[2.6999999999999997,1.7,.01]})})]})]})});return Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),Ae(ht,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),c]})},IEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),Ae(ht,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(Vi,{z:.55/2,children:Ae(ht,{size:[2.7,1.6,.55]})}),Ot(sI,{children:[Ae(Vi,{z:.55,children:Ae(ht,{size:[2.7,1.6,.01]})}),Ae(Vi,{z:1.1,children:Ae(ht,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),cEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),Ae(ht,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(Vi,{z:.2/2,children:Ae(ht,{size:[2.75,1.8,.2]})}),Ot(sI,{children:[Ae(Vi,{z:.2,children:Ae(ht,{size:[2.75,1.8,.01]})}),Ae(Vi,{z:1,children:Ae(ht,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),Ae(ht,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),BEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),Ae(ht,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ot(sI,{children:[Ae(Vi,{z:.2,children:Ae(ht,{size:[2.6-.1/2,1.7-.1/2,.01]})}),Ae(Vi,{z:.01,children:Ae(ht,{size:[2.6-.1,1.7-.1,.01]})})]}),Ot(sI,{children:[Ae(Vi,{z:.2,children:Ae(ht,{size:[2.6,1.7,.01]})}),Ae(Vi,{z:1,children:Ae(ht,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),Ae(ht,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),CEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),Ae(ht,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ot(sI,{children:[Ae(Vi,{z:.2,children:Ae(ht,{size:[3.8-.05/2,2.5-.05/2,.01]})}),Ae(Vi,{z:.01,children:Ae(ht,{size:[3.8-.05,2.5-.05,.01]})})]}),Ot(sI,{children:[Ae(Vi,{z:.2,children:Ae(ht,{size:[3.8,2.5,.01]})}),Ae(Vi,{z:1,children:Ae(ht,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),Ae(ht,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),lEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),Ae(ht,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(Vi,{z:.14/2,children:Ae(ht,{size:[.8,.6,.14]})}),Ot(sI,{children:[Ae(Vi,{z:.14,children:Ae(ht,{size:[.8,.6,.01]})}),Ae(Vi,{z:.37,children:Ae(ht,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),QEt=()=>{const I=3.0999999999999996;return Ot(Yo,{children:[Ae(To,{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}),Ae(To,{position:{x:-6.6/2-I/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),Ae(To,{position:{x:-6.6/2-I/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),Ae(To,{position:{x:-6.6/2-I/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),Ae(VB,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},EEt=()=>Ot(Yo,{children:[Array.from({length:16}).map((C,l)=>Ae(To,{position:{x:-10.5/2,y:l*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((C,l)=>Ae(To,{rotation:Math.PI,position:{x:10.5/2,y:l*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((C,l)=>Ae(To,{rotation:Math.PI/2,position:{x:l*.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((C,l)=>Ae(To,{rotation:-Math.PI/2,position:{x:l*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Ae(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})]}),hEt=EEt,uEt=()=>{const g=.7999999999999998;return Ot(Yo,{children:[Ae(To,{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}),Ae(To,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),Ae(To,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),Ae(VB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},dEt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:o})=>{const n=t/4;if(n!==Math.floor(n))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);A||(A=.5),i||(i=.6),e||(e=.22),o||(o=A*(n+4));const s=o,r=(n-1)*A/2,a=s+3.3*i,g=a,I=.8,c=.2,B=(g-o)/2+.4;return Ot(Yo,{children:[Array.from({length:n}).map((C,l)=>Ae(To,{position:{x:-g/2-.36,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:Math.PI,position:{x:g/2+.36,y:l*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:Math.PI/2,position:{x:l*A-r,y:-a/2-.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:n}).map((C,l)=>Ae(To,{rotation:-Math.PI/2,position:{x:l*A-r,y:a/2+.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Ae(VB,{center:{x:0,y:0,z:0},width:o,length:s,height:1.5,heightAboveSurface:.1,taperRatio:.04,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:s/2-1.5,z:1.5},notchRadius:1.5/2})]})},pEt=()=>{const i=.20900000000000002,o=.1,n=.3,s=.1,r=.2;return Ot(Yo,{children:[Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(ht,{size:[.85,1.2,i],center:[0,0,i/2]}),Ot(sI,{children:[Ae(Vi,{z:i,children:Ae(ht,{size:[.85,1.2,.01]})}),Ae(Vi,{z:.38,children:Ae(ht,{size:[.85-o,1.2-o,.01]})})]})]})}),Ae(ht,{color:"#ccc",size:[n,.25,s],center:[.55,0,s/2]}),Ae(ht,{color:"#ccc",size:[n,r,s],center:[-.55,.4,s/2]}),Ae(ht,{color:"#ccc",size:[n,r,s],center:[-.55,-.4,s/2]})]})},fEt=({num_pins:t,bodyWidth:A=5.3,bodyLength:e=5.3,bodyThickness:i=1,thermalPadSize:o,padWidth:n=e/5.3*.6,padLength:s=e/5.3*1,pitch:r=.5,thermalPadThickness:a=.2})=>{const g=[],I=Math.floor(t/2),c=r*(I-1);for(let B=0;B<t;B++){const C=B<I?"left":"right",l=B%I,Q=c/2-l*r,E=s,h=n,u=C==="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(Yo,{children:[Ae(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,C)=>Ae(ht,{center:[B.x,B.y,a/2],size:[B.padSizeX,B.padSizeY,a]})),o?.length!==void 0&&o?.width!==void 0&&Ae(ht,{center:[0,0,a/2],size:[o.width,o.length,a]})]})},yEt=({bodyLength:t=10.2,bodyWidth:A=4.65,bodyHeight:e=13.46,leadSpacing:i=5,leadDiameter:o=.8,leadLength:n=12.7,color:s="#ddd",leadColor:r="#b87333"})=>{const a=t/2,g=A/2,I=a-g,c=i/2,B=.85;return Ot(Yo,{children:[Ot(ys,{color:s,children:[Ot(sI,{children:[Ae(Kp,{height:e,roundRadius:.5,radius:g,center:[-I,0,e]}),Ae(Kp,{height:e,roundRadius:.5,radius:g,center:[I,0,e]})]}),Ot(sI,{children:[Ae(Kp,{height:B,roundRadius:.1,radius:g+.85,center:[-I,0,e/2+B/2]}),Ae(Kp,{height:B,roundRadius:.1,radius:g+.85,center:[I,0,e/2+B/2]})]})]}),Ot(ys,{color:r,children:[Ae(Jp,{height:n+e/2,radius:o/2,center:[-c+.06,0,-(n/2)+e/2]}),Ae(Jp,{height:n+e/2,radius:o/2,center:[c-.06,0,-(n/2)+e/2]})]})]})},wEt=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:o="#111"})=>Ot(Yo,{children:[Ae(ys,{color:e,children:Ot(QQ,{rotation:[0,"90deg",0],children:[Ae(RU,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),Ae(Jp,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),Ae(ys,{color:o,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(RU,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),Ae(ys,{color:i,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),Ae(ys,{color:i,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),mEt=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Yo,{children:[Ae(ys,{color:e,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),Ae(ys,{color:i,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),Ae(ys,{color:i,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),DEt=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Yo,{children:[Ae(ys,{color:e,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),Ae(ys,{color:i,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),Ae(ys,{color:i,children:Ae(QQ,{rotation:[0,"90deg",0],children:Ae(Kp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),SEt=({pinCount:t,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t%2!==0)throw new Error("MS012 pinCount must be even");const o=t/2,n=4.9,s=3.9,r=(o-1)*i/2,a=.2;return Ot(Yo,{children:[Array.from({length:o}).map((g,I)=>Ae(To,{position:{x:-s/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,I)=>Ae(To,{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})),Ae(VB,{center:{x:0,y:0,z:a/2},width:s,length:n,height:1.55,notchPosition:{x:-.95,y:n/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},bEt=({pinCount:t=16,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t!==16)throw new Error("MS013 only supports 16 pins");const o=t/2,n=7.5,s=10.3,r=(o-1)*i/2,a=.2;return Ot(Yo,{children:[Array.from({length:o}).map((g,I)=>Ae(To,{position:{x:-n/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:o}).map((g,I)=>Ae(To,{rotation:Math.PI,position:{x:n/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Ae(VB,{center:{x:0,y:0,z:a/2},width:n,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},xEt=()=>{const Q=7.050000000000001,E=24.95+6.5/2;return Ae(Vi,{center:[0,0,1],children:Ot(Yo,{children:[Ot(QQ,{rotation:[0,55,-55],children:[Ot(JG,{children:[Ae(ht,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[E,0,1.3-2]}),Ae(Jp,{color:"black",center:[E,0,1.3-2],radius:3/2,height:1.3*1.2})]}),Ae(ys,{color:"#222",children:Ae(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})})]}),Ae(QQ,{rotation:[0,55,55],children:Array.from({length:3}).map((h,u)=>{const d=Q,f=(u-1)*2.7,D=-.5-.6;return Ot(ys,{color:"gold",children:[Ot(sI,{children:[Ae(Vi,{center:[15.05-4.5/2+.1,f,D],children:Ae(ht,{size:[4.5,.81+1,.5]})}),Ae(Vi,{center:[15.05-4.5/2-1+.1,f,D],children:Ae(ht,{size:[4.5,.81,.5]})})]}),Ae(Vi,{center:[d,f,D],children:Ae(ht,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},kEt=()=>{const g=1.1999999999999997;return Ot(Yo,{children:[Ae(To,{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}),Ae(To,{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}),Ae(To,{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}),Ae(To,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),Ae(To,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),Ae(To,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),Ae(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})]})},GEt=()=>Ot(Yo,{children:[Ae(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 Ae(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 Ae(ht,{center:[.8/2-.19/2+.1,I,.12/2],size:[.19,.15,.12]})})]}),FEt=()=>{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],C=[0,1.28,-8.9],l=-7.5;return Ot(Vi,{center:[0,1,10.5],children:[Ae(ys,{color:s,children:Ot(JG,{children:[Ae(Vi,{center:[0,0,2.25],children:Ae(Jp,{radius:2.4,height:4.5})}),Ae(Vi,{center:[0,-1.8499999999999999,2.25],children:Ae(ht,{size:[2.4*2,1.1,4.5+.2]})})]})}),Ae(Vi,{center:I,children:Ae(ht,{size:a})}),Ot(sI,{children:[Ae(Vi,{center:c,children:Ae(ht,{size:g})}),Ae(Vi,{center:B,children:Ae(ht,{size:g})})]}),Ae(Vi,{center:C,children:Ae(ht,{size:[.43,.4,12.2]})}),Ae(Vi,{center:[1.3,0,l],children:Ae(ht,{size:[.43,.4,15]})}),Ae(Vi,{center:[-1.3,0,l],children:Ae(ht,{size:[.43,.4,15]})})]})},REt=()=>Ot(Yo,{children:[Ae(To,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(To,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(To,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(To,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(To,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(To,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(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})]}),NEt=REt,_Et=()=>Ot(Yo,{children:[Ae(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 Ae(ht,{center:[-1/2+.3/2,a,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(r=>{const a=-.5+r*.5;return Ae(ht,{center:[1/2-.3/2,a,.05/2],size:[.3,.2,.05]})})]}),MEt=()=>Ot(Yo,{children:[Ae(To,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ae(To,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ae(ys,{color:"#222",children:Ae(VB,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),Ae(ht,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),vEt=()=>Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),Ae(ht,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),Ae(ys,{color:"#222",children:Ot(aE,{children:[Ae(Vi,{z:.175/2,children:Ae(ht,{size:[1.7,1.25,.175]})}),Ot(sI,{children:[Ae(Vi,{z:.175,children:Ae(ht,{size:[1.7,1.25,.01]})}),Ae(Vi,{z:.725,children:Ae(ht,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),Ae(ht,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),UEt=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return Ot(Yo,{children:[Ae(ht,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),Ae(ht,{color:"#ccc",size:[.4,.325,.13],center:[r,0,.13/2]}),Ae(ys,{color:"#222",children:Ae(VB,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),Ae(ht,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},LEt=({footprint:t})=>{const A=mQt.string(t).json();switch(A.fn){case"dip":return Ae(kQt,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"tssop":return Ae(FQt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return Ae(RQt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return Ae(iEt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return Ae(vQt,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return Ae(hEt,{});case"lqfp":return Ae(dEt,{pinCount:A.num_pins});case"qfn":{const o=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return Ae(qQt,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:o?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"dfn":{const o=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return Ae(fEt,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:o?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"pinrow":{const o=t.match(/_rows(\d+)/),n=o&&o[1]?parseInt(o[1],10):1;if(A.male)return Ae(YQt,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:n});if(A.female)return Ae(AEt,{numberOfPins:A.num_pins,pitch:A.p,rows:n})}case"cap":switch(A.imperial){case"0402":return Ae(KWA,{color:"#856c4d"});case"0603":return Ae(TWA,{color:"#856c4d"});case"0805":return Ae(qWA,{color:"#856c4d"});case"0201":return Ae(PWA,{color:"#856c4d"});case"01005":return Ae(OWA,{color:"#856c4d"});case"1206":return Ae(WWA,{color:"#856c4d"});case"1210":return Ae(ZWA,{color:"#856c4d"});case"2010":return Ae(VWA,{color:"#856c4d"});case"2512":return Ae(jWA,{color:"#856c4d"})}case"sot235":return Ae(OQt,{});case"sot457":return Ae(kEt,{});case"sot223":return Ae(QEt,{});case"sot23w":return Ae(WQt,{});case"sot323":return Ae(uEt,{});case"sod323f":return Ae(vEt,{});case"sod323fl":return Ae(UEt,{});case"sot363":return Ae(NEt,{});case"sot886":return Ae(_Et,{});case"sot963":return Ae(GEt,{});case"pushbutton":return Ae(eEt,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return Ae(tEt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return Ae(oEt,{});case"sod882":return Ae(nEt,{});case"sma":return Ae(sEt,{});case"smb":return Ae(rEt,{});case"smc":return Ae(aEt,{});case"smf":return Ae(gEt,{});case"sod123f":return Ae(IEt,{});case"sod123fl":return Ae(cEt,{});case"sod123w":return Ae(BEt,{});case"sod128":return Ae(CEt,{});case"sod323":return Ae(MEt,{});case"sod923":return Ae(lEt,{});case"hc49":return Ae(yEt,{});case"micromelf":return Ae(wEt,{});case"minimelf":return Ae(mEt,{});case"melf":return Ae(DEt,{});case"ms012":return Ae(SEt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return Ae(bEt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return Ae(pEt,{});case"to220":return Ae(xEt,{});case"to92":return Ae(FEt,{})}const e=t.match(/_color\(([^)]+)\)/),i=e?e[1]:void 0;switch(A.imperial){case"0402":return Ae(KWA,{color:i});case"0603":return Ae(TWA,{color:i});case"0805":return Ae(qWA,{color:i});case"0201":return Ae(PWA,{color:i});case"01005":return Ae(OWA,{color:i});case"1206":return Ae(WWA,{color:i});case"1210":return Ae(ZWA,{color:i});case"2010":return Ae(VWA,{color:i});case"2512":return Ae(jWA,{color:i})}return null},HEt=t=>t&&typeof t=="object"&&"type"in t,K_=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},YEt=t=>Array.isArray(t)?[Number(t[0])||0,Number(t[1])||0,Number(t[2])||0]:typeof t=="object"&&t?[Number(t.x)||0,Number(t.y)||0,Number(t.z)||0]:[0,0,0];function pm(t,A,e){const{jscad:{primitives:i,booleans:o,hulls:n,geometries:s,extrusions:r,transforms:a}}=e;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(B=>pm(B,A,e));if(!HEt(t))return[];const{type:g,props:I,children:c}=t;if(g===LWA)return(c??[]).flatMap(B=>pm(B,A,e));if(g===ys){const B=I?.color;return(c??[]).flatMap(C=>pm(C,B??A,e))}if(g===Vi){const B=YEt(I?.offset??I?.center??{x:I?.x,y:I?.y,z:I?.z});return(c??[]).flatMap(l=>pm(l,A,e)).map(({geom:l,color:Q})=>({geom:a.translate(B,l),color:Q??A}))}if(g===QQ){const B=Array.isArray(I?.rotation)?[K_(I.rotation[0]),K_(I.rotation[1]),K_(I.rotation[2])]:[K_(I?.x??0),K_(I?.y??0),K_(I?.z??0)];return(c??[]).flatMap(l=>pm(l,A,e)).map(({geom:l,color:Q})=>({geom:a.rotateZ(B[2],a.rotateY(B[1],a.rotateX(B[0],l))),color:Q}))}if(g===aE||g===JG||g===sI){const B=(c??[]).flatMap(l=>pm(l,A,e)).map(l=>l.geom);if(B.length===0)return[];let C;return g===aE?C=o.union(B):g===JG?C=o.subtract(B[0],B.slice(1)):C=n.hull(B),[{geom:C,color:A}]}if(g===NU){const B=I?.points??[];return[{geom:s.geom2.fromPoints(B),color:A??I?.color}]}if(g===_U){const B=(c??[]).flatMap(E=>pm(E,A,e)).map(E=>E.geom);if(B.length===0)return[];const C=B.length>1?o.union(B):B[0],l=I?.height??I?.h??1;let Q=r.extrudeLinear({height:l},C);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===HWA||g===Jp||g===YWA||g===RU||g===Kp){let B;if(g===ht){const C=I?.size??[1,1,1],l=I?.offset,Q=I?.center??(l?[l[0],l[1],l[2]]:[0,0,0]);B=i.cuboid({size:C,center:Q})}else if(g===HWA){const C=I?.size??1,l=I?.offset,Q=I?.center??(l?[l[0],l[1],l[2]]:[0,0,0]);B=i.cube({size:C,center:Q})}else if(g===Jp){const C=I?.height??1,l=I?.radius??1,Q=I?.center??[0,0,0];B=i.cylinder({height:C,radius:l,center:Q})}else if(g===YWA){const C=I?.radius??1,l=I?.center??[0,0,0];B=i.sphere({radius:C,center:l})}else if(g===Kp){const C=I?.height??1,l=I?.radius??1,Q=I?.roundRadius??.1,E=I?.center??[0,0,0];B=i.roundedCylinder({height:C,radius:l,roundRadius:Q,center:E})}else{const C=I?.size??[1,1,1],l=I?.roundRadius??.1,Q=I?.center??[0,0,0];B=i.roundedCuboid({size:C,roundRadius:l,center:Q})}return[{geom:B,color:A??I?.color}]}if(typeof g=="function"){const B=g(I??{});return pm(B,A,e)}return(c??[]).flatMap(B=>pm(B,A,e))}function JEt(t,A){return{geometries:pm(t,void 0,{jscad:A})}}function zWA(t){if(t.polygons){const A=[],e=[],i=[];let o=0;for(const s of t.polygons){for(const a of s.vertices)a.index=o,A.push(a[0],a[1],a[2]),t.color&&t.color.length>=3?i.push(t.color[0],t.color[1],t.color[2]):i.push(1,1,1),o++;const r=s.vertices[0].index;for(let a=2;a<s.vertices.length;a++){const g=s.vertices[a-1].index,I=s.vertices[a].index;e.push(r,g,I)}}const n=new Cg;if(n.setAttribute("position",new oI(new Float32Array(A),3)),n.setIndex(e),i.length>0&&n.setAttribute("color",new oI(new Float32Array(i),3)),t.transforms){const s=new ts;s.fromArray(t.transforms),n.applyMatrix4(s)}return n.computeVertexNormals(),n}if(t.sides){const A=[],e=[];for(const o of t.sides)A.push(o[0][0],o[0][1],0),t.color&&t.color.length>=3?e.push(t.color[0],t.color[1],t.color[2]):e.push(1,1,1);const i=new Cg;if(i.setAttribute("position",new oI(new Float32Array(A),3)),e.length>0&&i.setAttribute("color",new oI(new Float32Array(e),3)),t.transforms){const o=new ts;o.fromArray(t.transforms),i.applyMatrix4(o)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new Cg}function KEt(t,A){const e=yBA(LEt,{footprint:t});return JEt(e,A)}var TEt=({jscadPlan:t,positionOffset:A,rotationOffset:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=fu(),{threeGeom:g,material:I}=AA.useMemo(()=>{const B=(0,Frt.executeJscadOperations)(Rrt.default,t);if(!B||!B.polygons&&!B.sides)return{threeGeom:null,material:null};const C=zWA(B),l=new ih({vertexColors:!0,side:UC,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:C,material:l}},[t,r]),c=AA.useMemo(()=>g?new Oo(g,I):null,[g,I]);return AA.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),AA.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]),AA.useMemo(()=>{if(I)if(n){const B=new Ui(I.color.getHex());I.emissive.copy(B),I.emissive.setRGB(0,0,1),I.emissiveIntensity=.2}else I.emissiveIntensity=0},[n,I]),g?V.jsx(GU,{isHovered:n,onHover:i,onUnhover:o,object:c}):null},qEt=yr(SO()),PEt=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:o,isHovered:n,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=fu(),g=AA.useMemo(()=>{if(!A)return null;const{geometries:I}=KEt(A,qEt),c=new Np;for(const B of I.flat(1/0)){const C=B.geom;if(!C||!C.polygons&&!C.sides)continue;const l=new Ui(B.color);l.convertLinearToSRGB();const Q={...C,color:[l.r,l.g,l.b]},E=zWA(Q),h=new ih({vertexColors:!0,side:UC,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new Oo(E,h);c.add(u)}return c},[A,r]);return AA.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),AA.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]),AA.useEffect(()=>{g&&g.traverse(I=>{I instanceof Oo&&I.material instanceof ih&&(n?(I.material.emissive.setHex(255),I.material.emissiveIntensity=.2):I.material.emissiveIntensity=0)})},[n,g]),g?V.jsx(GU,{isHovered:n,onHover:i,onUnhover:o,object:g}):null},OEt=(...t)=>t,TU={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},XWA=({children:t,position:A,style:e})=>{const{camera:i,renderer:o}=fu(),n=AA.useRef(document.createElement("div")),[s,r]=AA.useState(null);return AA.useEffect(()=>{const a=o?.domElement.parentNode;if(a)return a.style.position!=="relative"&&a.style.position!=="absolute"&&(a.style.position="relative"),a.appendChild(n.current),r(BJ.createPortal(t,n.current)),()=>{a.contains(n.current)&&a.removeChild(n.current)}},[o,t]),kU(()=>{if(!i||!n.current||!o)return;const a=new Re(...A);a.project(i);const g=o.domElement.getBoundingClientRect(),I=Math.round((a.x+1)/2*g.width),c=Math.round((-a.y+1)/2*g.height);n.current.style.position="absolute",n.current.style.left=`${I}px`,n.current.style.top=`${c}px`,n.current.style.pointerEvents="none",n.current.style.zIndex=TU.htmlElements.toString(),e&&Object.assign(n.current.style,e)},[i,o,A,e]),s},$WA={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},AZA=AA.createContext(void 0),WEt=({children:t})=>{const[A,e]=AA.useState($WA),i=AA.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),o=AA.useCallback(()=>{e($WA)},[]),n=AA.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:o}),[A,i,o]);return V.jsx(AZA.Provider,{value:n,children:t})},T_=()=>{const t=AA.useContext(AZA);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},KBA,ZEt="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function VEt(t){if(typeof t=="function")return t;if(t&&typeof t=="object"&&"default"in t&&typeof t.default=="function")return t.default;throw new Error("Unable to resolve occt-import-js factory export")}async function jEt(){if(!KBA){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");KBA=VEt(t)({locateFile:e=>`${ZEt}/${e}`})}return KBA}function zEt(t){const A=new Np;for(const e of t){const i=e.attributes.position?.array??[],o=e.index?.array??[];if(!i.length||!o.length)continue;const n=new Cg;n.setAttribute("position",new Un(i,3));const s=e.attributes.normal?.array??[];s.length?n.setAttribute("normal",new Un(s,3)):n.computeVertexNormals(),n.setIndex(o);const r=new ih({color:e.color?new Ui(e.color[0],e.color[1],e.color[2]):new Ui(.82,.82,.82)}),a=new Oo(n,r);a.name=e.name,A.add(a)}return A}async function XEt(t){const A=await fetch(t);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const e=await A.arrayBuffer(),o=(await jEt()).ReadStepFile(new Uint8Array(e),null);if(!o.success||!o.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const n=zEt(o.meshes),s=new dX,r=await new Promise((a,g)=>{s.parse(n,I=>{I instanceof ArrayBuffer?a(I):g(new Error("GLTFExporter did not return binary output"))},I=>{g(I)},{binary:!0})});return URL.createObjectURL(new Blob([r],{type:"model/gltf-binary"}))}var eZA="step-glb-cache:";function $Et(t){const A=new Uint8Array(t),e=32768;let i="";for(let o=0;o<A.length;o+=e){const n=A.subarray(o,o+e);i+=String.fromCharCode(...n)}return btoa(i)}function Aht(t){const A=atob(t),e=new Uint8Array(A.length);for(let i=0;i<A.length;i+=1)e[i]=A.charCodeAt(i);return e.buffer}function eht(t){try{const A=localStorage.getItem(`${eZA}${t}`);return A?Aht(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function tht(t,A){try{const e=$Et(A);localStorage.setItem(`${eZA}${t}`,e)}catch(e){console.warn("Failed to write STEP GLB cache",e)}}var iht=({stepUrl:t,position:A,rotation:e,scale:i,onHover:o,onUnhover:n,isHovered:s,isTranslucent:r})=>{const[a,g]=AA.useState(null);return AA.useEffect(()=>{let I=!0,c=null;const B=eht(t);return B?(c=URL.createObjectURL(new Blob([B],{type:"model/gltf-binary"})),g(c),()=>{I=!1,c&&URL.revokeObjectURL(c)}):(XEt(t).then(C=>{if(!I){URL.revokeObjectURL(C);return}c=C,g(C),fetch(C).then(l=>l.arrayBuffer()).then(l=>{tht(t,l)}).catch(l=>{console.warn("Failed to cache STEP GLB",l)})}).catch(C=>{console.error("Failed to convert STEP file to GLB",C),I&&g(null)}),()=>{I=!1,c&&URL.revokeObjectURL(c)})},[t]),a?V.jsx(R8A,{gltfUrl:a,position:A,rotation:e,scale:i,onHover:o,onUnhover:n,isHovered:s,isTranslucent:r}):null},tZA=({cad_component:t,circuitJson:A})=>{const[e,i]=AA.useState(!1),{visibility:o}=T_(),[n,s]=AA.useState(null),r=AA.useCallback(E=>{E?.mousePosition?(i(!0),s(E.mousePosition)):(i(!1),s(null))},[]),a=AA.useCallback(()=>{i(!1),s(null)},[]),g=AA.useMemo(()=>wi(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),I=AA.useMemo(()=>A.filter(h=>h.type==="pcb_plated_hole"&&h.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,C=t.model_step_url,l=t.rotation?OEt(t.rotation.x*Math.PI/180,t.rotation.y*Math.PI/180,t.rotation.z*Math.PI/180):void 0;let Q=null;if(c?Q=V.jsx(xrt,{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?Q=V.jsx(R8A,{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):C&&!t.model_jscad&&!t.footprinter_string?Q=V.jsx(iht,{stepUrl: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.model_jscad?Q=V.jsx(TEt,{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&&(Q=V.jsx(PEt,{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(!o.translucentModels)return null}else if(I&&!o.throughHoleModels||!I&&!o.smtModels)return null;return V.jsxs(V.Fragment,{children:[Q,e&&n?V.jsx(XWA,{position:n,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]})},iZA={version:"0.0.484"};function oht(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var nht=t=>{t.outputColorSpace=Wy,t.toneMapping=gDA,t.toneMappingExposure=1},oZA="cadViewerCameraStateSession",nZA=(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(oZA,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},TBA=(t,A)=>{try{const e=sessionStorage.getItem(oZA);if(!e)return!1;const i=JSON.parse(e);if(t.position.fromArray(i.position),t.quaternion.fromArray(i.quaternion),t.up.fromArray(i.up),"fov"in t){const o=t;o.fov=i.fov,o.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),t.updateMatrixWorld(),!0}catch(e){return console.warn("Failed to restore camera:",e),!1}},sZA=AA.createContext(void 0),sht=({children:t,defaultTarget:A,initialCameraPosition:e})=>{const i=AA.useRef(null),o=AA.useRef(null),[n,s]=AA.useState(null),[r,a]=AA.useState("perspective"),[g,I]=AA.useState(e??null),[c,B]=AA.useState(new Fp(0,0,0)),C=AA.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]),l=AA.useCallback(h=>{const u=[A.x,A.y,A.z],d=o.current,f=i.current;let D=C;switch(d&&f&&(D=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const b=D/Math.sqrt(2);return{position:[A.x,A.y-b,A.z+b],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+D],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-D*.6,A.y-D*.6,A.z+D*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+D*.6,A.y-D*.6,A.z+D*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-D,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+D,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-D,A.z],target:u,up:[0,0,1]};default:return null}},[C,A,o,i]),Q=AA.useCallback(h=>{i.current=h},[]),E=AA.useMemo(()=>({controlsRef:i,mainCameraRef:o,defaultTarget:A,baseDistance:C,controller:n,setController:s,getPresetConfig:l,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:I,cameraRotation:c,setCameraRotation:B,saveCameraToSession:nZA,loadCameraFromSession:TBA}),[A,C,n,l,Q,r,g,c]);return V.jsx(sZA.Provider,{value:E,children:t})},dx=()=>{const t=AA.useContext(sZA);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},rht=AA.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:o},n)=>{const{cameraType:s}=dx(),r=AA.useRef(null),[a,g]=AA.useState(null),I=AA.useRef([]),c=AA.useRef(void 0);c.current=o;const B=AA.useRef(null),C=AA.useCallback(h=>{I.current.push(h)},[]),l=AA.useCallback(h=>{I.current=I.current.filter(u=>u!==h)},[]),Q=AA.useMemo(()=>new $k,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const E=AA.useRef(new Bg);return AA.useImperativeHandle(n,()=>E.current),AA.useEffect(()=>{if(!r.current)return;oht(r.current);const h=new SK({antialias:!0,alpha:!0});nht(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 tE(75,u,.1,1e3):new G1(-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:C,removeFrameListener:l}),c.current?.({camera:d,renderer:h});let f;const D=new ome,b=()=>{const x=D.getElapsedTime(),F=D.getDelta();I.current.forEach(k=>k(x,F)),h.render(Q,d),f=requestAnimationFrame(b)};b();const m=()=>{if(r.current){const x=r.current.clientWidth/r.current.clientHeight;d instanceof tE?d.aspect=x:d instanceof G1&&(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",m),()=>{B.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",m),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,C,l,s]),V.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&V.jsx(x8A.Provider,{value:a,children:V.jsx(wrt,{children:t})})})}),aht=({autoRotate:t,autoRotateSpeed:A,onStart:e,panSpeed:i,rotateSpeed:o,zoomSpeed:n,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:I,renderer:c}=fu(),B=AA.useMemo(()=>!I||!c?null:new Cbe(I,c.domElement),[I,c]);return AA.useEffect(()=>(g?.(B??null),()=>g?.(null)),[B,g]),AA.useEffect(()=>{if(!B)return;const C=()=>{g?.(B)};return B.addEventListener("change",C),()=>{B.removeEventListener("change",C)}},[B,g]),AA.useEffect(()=>{B&&(B.autoRotate=t||!1,B.autoRotateSpeed=A||1,i!==void 0&&(B.panSpeed=i),o!==void 0&&(B.rotateSpeed=o),n!==void 0&&(B.zoomSpeed=n),s!==void 0&&(B.enableDamping=s),r!==void 0&&(B.dampingFactor=r),B.zoomToCursor=!0,B.mouseButtons={LEFT:lb.ROTATE,MIDDLE:lb.PAN,RIGHT:null},a&&(B.target.set(a[0],a[1],a[2]),B.update()))},[B,t,A,i,o,n,s,r,a]),AA.useEffect(()=>{if(!(!B||!e))return B.addEventListener("start",e),()=>{B.removeEventListener("start",e)}},[B,e]),AA.useEffect(()=>{if(B)return()=>{B.dispose()}},[B]),kU(()=>{B?.update()},[B]),null},ght=`
|
|
5063
5063
|
varying vec3 worldPosition;
|
|
5064
5064
|
void main() {
|
|
5065
5065
|
worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
@@ -5093,12 +5093,12 @@ ${a.join(`
|
|
|
5093
5093
|
gl_FragColor = vec4(color, max(g1, g2) * a);
|
|
5094
5094
|
if (gl_FragColor.a <= 0.0) discard;
|
|
5095
5095
|
}
|
|
5096
|
-
`,cht=({rotation:t,infiniteGrid:A,cellSize:e=1,sectionSize:i=10})=>{const{scene:o,camera:n}=fu(),s=1e3,r=AA.useMemo(()=>{const a=new iw(s,s);a.rotateX(-Math.PI/2);const g=new Zw({vertexShader:ght,fragmentShader:Iht,uniforms:{cellSize:{value:e},sectionSize:{value:i},gridColor:{value:new Ui(15658734)},sectionColor:{value:new Ui(13421823)},fadeDistance:{value:100},fadeStrength:{value:1.5}},transparent:!0,side:UC}),I=new Oo(a,g);return t&&I.rotation.fromArray(t),I},[s,e,i,t]);return kU(()=>{A&&r.position.set(n.position.x,n.position.y,0)}),AA.useEffect(()=>{if(!(!o||!r))return o.add(r),()=>{o.remove(r),r.geometry.dispose(),Array.isArray(r.material)?r.material.forEach(a=>a.dispose()):r.material.dispose()}},[o,r]),null},Bht=()=>{const{scene:t}=fu(),A=AA.useMemo(()=>new RbA(16777215,Math.PI/2),[]),e=AA.useMemo(()=>{const i=new fz(16777215,Math.PI/4);return i.position.set(-10,-10,10),i.decay=0,i},[]);return AA.useEffect(()=>{if(t)return t.add(A),t.add(e),()=>{t.remove(A),t.remove(e)}},[t,A,e]),null},Cht=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,lht=()=>{const{controlsRef:t,mainCameraRef:A,defaultTarget:e,setController:i,getPresetConfig:o}=dx(),n=AA.useRef(null),s=AA.useRef(new Cd),r=AA.useRef(new Re),a=AA.useRef(new Re),g=AA.useRef(new Cd),I=AA.useRef(new Cd),c=AA.useRef(new Bg),B=AA.useRef(new Bg),C=AA.useCallback(({position:Q,target:E,up:h,durationMs:u=600})=>{if(!A.current)return;const d=t.current?.target??e,f=new Re(Q[0],Q[1],Q[2]),D=E?new Re(E[0],E[1],E[2]):e.clone(),b=new Re(...h??[0,0,1]).normalize(),m=B.current;m.position.copy(f),m.up.copy(b),m.lookAt(D);const x=m.quaternion.clone(),F=A.current.quaternion.clone(),k=A.current.position.clone(),v=d.clone(),_=c.current;_.up.set(0,0,1),_.position.copy(k),_.lookAt(v);const Y=_.quaternion.clone();_.up.set(0,0,1),_.position.copy(f),_.lookAt(D);const P=_.quaternion.clone(),K=Y.clone().invert().multiply(F).normalize(),O=P.clone().invert().multiply(x).normalize();n.current={fromPosition:k,toPosition:f,fromTarget:v,toTarget:D,toQuaternion:x,rollFrom:K,rollTo:O,startTime:performance.now(),duration:u}},[A,t,e]),l=AA.useCallback(Q=>{if(Q==="Custom")return;const E=o(Q);E&&C(E)},[C,o]);return AA.useEffect(()=>A.current?(i({animateTo:C,animateToPreset:l}),()=>{i(null)}):void 0,[C,l,A,i]),kU(()=>{if(!A.current||!n.current)return;const{fromPosition:Q,toPosition:E,fromTarget:h,toTarget:u,toQuaternion:d,rollFrom:f,rollTo:D,startTime:b,duration:m}=n.current,x=performance.now()-b,F=m<=0?1:Math.min(x/m,1),k=Cht(F);A.current.position.lerpVectors(Q,E,k);const v=r.current;v.copy(h).lerp(u,k);const _=c.current;_.up.set(0,0,1),_.position.copy(A.current.position),_.lookAt(v);const Y=s.current;Y.copy(_.quaternion);const P=g.current;P.copy(f);const K=I.current;K.copy(D),f.dot(D)<0&&(K.x*=-1,K.y*=-1,K.z*=-1,K.w*=-1),K.normalize(),P.slerp(K,k),A.current.quaternion.copy(Y).multiply(P).normalize();const O=a.current;O.set(0,1,0).applyQuaternion(A.current.quaternion).normalize(),A.current.up.copy(O),t.current?.target.copy(v),A.current.updateMatrixWorld(),t.current?.update(),F>=1&&(A.current.position.copy(E),A.current.quaternion.copy(d),A.current.up.set(0,0,1),A.current.updateMatrixWorld(),t.current?.target.copy(u),t.current?.update(),n.current=null)}),null},Qht=()=>{const{controlsRef:t}=dx(),A=AA.useRef(null),e=AA.useRef(!1),i=AA.useRef(null),o=AA.useCallback(s=>{A.current=s,!e.current&&t.current&&TBA(s,t.current)&&(e.current=!0)},[t]),n=AA.useCallback(()=>{if(!(!A.current||!t.current)){if(!e.current&&TBA(A.current,t.current)){e.current=!0;return}clearTimeout(i.current),i.current=setTimeout(()=>{A.current&&t.current&&nZA(A.current,t.current)},150)}},[t]);return{handleCameraCreated:o,handleControlsChange:n}};function Eht(t,A){const e=new Cd().setFromEuler(new Fp(t.x,t.y,t.z)),i=new Re(0,0,1);return i.applyQuaternion(e),i.multiplyScalar(A)}var hht=()=>{const{mainCameraRef:t}=dx(),A=AA.useRef(null),e=AA.useRef(null),i=AA.useRef(null),o=AA.useRef(null),n=AA.useRef(null),s=AA.useRef(null);return AA.useEffect(()=>{if(!A.current)return;const r=document.createElement("canvas");e.current=r,A.current.appendChild(r);const a=new SK({canvas:r,antialias:!0,alpha:!0});a.setSize(120,120),a.setPixelRatio(window.devicePixelRatio),i.current=a;const g=new $k;o.current=g;const I=new tE(75,1,.1,1e3);I.up.set(0,0,1),n.current=I;const c=new RbA(16777215,Math.PI/2);g.add(c);const B=new Np;B.rotation.fromArray([Math.PI/2,0,0]);const C=1,l=new Oo(new tw(C,C,C),new ih({color:"white"}));B.add(l);const Q=new M1(new fwe(new tw(C,C,C)),new AG({color:0,linewidth:2}));B.add(Q),g.add(B);const E=.51,h=(F,k,v)=>{const _=new LX;return _.text=F,_.position.fromArray(k),v&&_.rotation.fromArray(v),_.color="black",_.fontSize=.25,_.anchorX="center",_.anchorY="middle",_.depthOffset=0,_.font=null,_.sync(),_},u=h("Front",[0,0,E]),d=h("Back",[0,0,-E],[0,Math.PI,0]),f=h("Right",[E,0,0],[0,Math.PI/2,0]),D=h("Left",[-E,0,0],[0,-Math.PI/2,0]),b=h("Top",[0,E,0],[-Math.PI/2,0,0]),m=h("Bottom",[0,-E,0],[Math.PI/2,0,0]);B.add(u),B.add(d),B.add(f),B.add(D),B.add(b),B.add(m);const x=()=>{if(t.current){const F=Eht(t.current.rotation??new Fp(0,0,0),2);F.equals(I.position)||(I.position.copy(F),I.lookAt(0,0,0))}a.render(g,I),s.current=requestAnimationFrame(x)};return x(),()=>{s.current&&cancelAnimationFrame(s.current),u.dispose(),d.dispose(),f.dispose(),D.dispose(),b.dispose(),m.dispose(),l.geometry.dispose(),l.material.dispose(),Q.geometry.dispose(),Q.material.dispose(),g.clear(),a.dispose(),e.current&&A.current&&A.current.removeChild(e.current)}},[t]),V.jsx("div",{ref:A,style:{position:"absolute",top:0,left:0,width:120,height:120,zIndex:TU.orientationCube}})},uht=()=>{const{camera:t}=fu(),{setCameraRotation:A}=dx();return kU(()=>{t&&A(t.rotation)}),null},rZA=AA.forwardRef(({children:t,initialCameraPosition:A=[5,-5,5],autoRotateDisabled:e,clickToInteractEnabled:i=!1,boardDimensions:o,boardCenter:n,onUserInteraction:s,onCameraControllerReady:r},a)=>{const[g,I]=AA.useState(!i),{mainCameraRef:c,handleControlsChange:B,controller:C}=dx(),{handleCameraCreated:l,handleControlsChange:Q}=Qht();AA.useEffect(()=>{r&&r(C)},[C,r]);const E=AA.useMemo(()=>{if(!o)return 10;const u=o.width??0,d=o.height??0,D=Math.max(u,d)*1.5;return D>10?D:10},[o]),h=AA.useMemo(()=>{if(n)return[n.x,n.y,0]},[n]);return V.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[V.jsx(hht,{}),V.jsxs(rht,{ref:a,scene:{up:new Re(0,0,1)},camera:{up:[0,0,1],position:A},onCreated:({camera:u})=>{c.current=u,l(u)},children:[V.jsx(lht,{}),V.jsx(uht,{}),g&&V.jsx(aht,{autoRotate:!e,autoRotateSpeed:1,onStart:s,rotateSpeed:.5,panSpeed:.75,zoomSpeed:.5,enableDamping:!0,dampingFactor:.1,target:h,onControlsChange:u=>{B(u),Q()}}),V.jsx(Bht,{}),V.jsx(cht,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:3,sectionSize:E,args:[E,E]}),t]}),V.jsxs("div",{style:{position:"absolute",right:24,bottom:24,fontFamily:"sans-serif",color:"white",WebkitTextStroke:"0.5px rgba(0, 0, 0, 0.5)",fontSize:11},children:["@",iZA.version]}),i&&!g&&V.jsx("button",{type:"button",onClick:()=>I(!0),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&I(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:TU.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center"},children:V.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",fontFamily:"sans-serif",pointerEvents:"none"},children:"Click to Interact"})})]})}),aZA=t=>AA.useMemo(()=>{if(!t)return[];const A=new jze;return A.add(t),A.render(),A.getCircuitJson()},[t]),dht=t=>{const[A,e]=AA.useState([]),[i,o]=AA.useState(!0);return AA.useEffect(()=>{if(!t)return;(async()=>{o(!0);const r=(Array.isArray(t)?t:[t]).map(async(a,g)=>{const I=ZAt.serialize({binary:!0},[a]),B=await new Blob(I).arrayBuffer(),l=a.layerType||(g===0?"board":void 0);return{stlData:B,color:a.color,layerType:l}});try{const a=await Promise.all(r);e(a)}catch(a){console.error("Error generating STLs:",a),e([])}finally{o(!1)}})()},[t]),{stls:A,loading:i}},pht=yr(Ex()),fht=yr(uO()),Wo=.01,rI={traces:.001,copper:.002},No={copper:[.9,.6,.2],fr4Tan:[.6,.43,.28],fr4SolderMaskGreen:[.02,.1,.04],fr4TracesWithMaskGreen:[0,.5,.25],fr4TracesWithoutMaskTan:[.6,.43,.28],fr1Tan:[.8,.4,.2],fr1TracesWithMaskCopper:[.9,.6,.2],fr1SolderMaskGreen:[.02,.1,.04]},ry=.001,wl=32,HO=.035,lc=150,YO=.6,qBA={fr1:No.fr1Tan,fr4:No.fr4Tan},yht={fr1:No.fr1TracesWithMaskCopper,fr4:No.fr4TracesWithoutMaskTan},gZA={fr1:No.fr1SolderMaskGreen,fr4:No.fr4SolderMaskGreen},wht=yr(xU()),mht=yr(Ex()),Dht=yr(HG()),Sht=yr(rBA()),PBA=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1]}return A/2<=0},OBA=(t,A=1.2,e={})=>{const{xyOutset:i=0}=e,{outline:o}=t;let n=o.map(a=>[a.x,a.y]);PBA(n)&&(n=n.reverse());let s=(0,mht.polygon)({points:n});i!==0&&(s=(0,Sht.expand)({delta:i,corners:"edge"},s));let r=(0,wht.extrudeLinear)({height:A},s);return r=(0,Dht.translate)([0,0,-A/2],r),r},bht=t=>{const A=t.filter(a=>a.type==="pcb_panel"),e=wi(t).pcb_board.list();let i,o=1.2;if(A.length>0)i=A[0],o=e.find(g=>g.pcb_panel_id===i.pcb_panel_id)?.thickness??1.2;else{if(i=e.filter(g=>!g.pcb_panel_id)[0],!i)return console.warn("No pcb_board or pcb_panel found for simplified geometry"),[];o=i.thickness??1.2}let n;"outline"in i&&i.outline&&i.outline.length>0?n=OBA({outline:i.outline},o):n=(0,pht.cuboid)({size:[i.width??10,i.height??10,o],center:[i.center.x,i.center.y,0]});const s="material"in i&&i.material?i.material:A.length>0?e.find(a=>a.pcb_panel_id===i.pcb_panel_id)?.material??"fr4":"fr4",r=qBA[s]??No.fr4Tan;return[(0,fht.colorize)(r,n)]},yu=yr(HG()),aI=yr(Ex()),wu=yr(uO()),gI=yr(x_()),Ug=yr(Ex()),sS=yr(uO()),HI=yr(x_()),IZA=yr(HG()),JO=yr(xU()),rS=yr(HG());function ay(t,A,e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return 0;const i=t/2,o=A/2;return Math.max(0,Math.min(e,i,o))}function Ch(t){if(!(!t||typeof t!="object"))return t.corner_radius??t.cornerRadius??t.rect_pad_border_radius??t.rectPadBorderRadius??t.rect_border_radius??t.rectBorderRadius??void 0}var px=yr(Ex()),xht=yr(xU()),KO=yr(HG()),kht=yr(x_()),Ght=64,Fht=(t,A,e)=>{const i=(0,px.ellipse)({center:[0,0],radius:[Math.max(t/2,Wo/2),Math.max(A/2,Wo/2)],segments:Ght}),o=(0,xht.extrudeLinear)({height:e},i);return(0,KO.translate)([0,0,-e/2],o)},Rht=(t,A,e)=>{const i=Math.max(t,Wo),o=Math.max(A,Wo);if(Math.abs(i-o)<1e-6)return(0,px.cylinder)({center:[0,0,0],radius:i/2,height:e});const n=i>=o,s=n?i:o,r=n?o:i,a=Math.max(s-r,0),g=(0,px.cuboid)({center:[0,0,0],size:n?[a,r,e]:[r,a,e]});if(a<=1e-6)return(0,px.cylinder)({center:[0,0,0],radius:r/2,height:e});const I=a/2,c=(0,px.cylinder)({center:n?[-I,0,0]:[0,-I,0],radius:r/2,height:e}),B=(0,px.cylinder)({center:n?[I,0,0]:[0,I,0],radius:r/2,height:e});return(0,kht.union)(g,c,B)},TO=(t,A,e={})=>{const i=t.hole_shape||"circle",o=e.sizeDelta??0,n=t.hole_offset_x||0,s=t.hole_offset_y||0,r=[t.x+n,t.y+s,0];if(i==="circle"){const C=Math.max((t.hole_diameter??0)+o,Wo),l=Math.max(C/2,Wo/2);return(0,px.cylinder)({center:r,radius:l,height:A})}const a=t.hole_width??t.hole_diameter,g=t.hole_height??t.hole_diameter;if(!a||!g)return null;const I=Math.max(a+o,Wo),c=Math.max(g+o,Wo);if(i==="oval"){const C=Fht(I,c,A);return(0,KO.translate)([r[0],r[1],0],C)}if(i==="pill"||i==="rotated_pill"){let C=Rht(I,c,A);if(!C)return null;const l=t.ccw_rotation||0;return l&&(C=(0,KO.rotateZ)(l*Math.PI/180,C)),(0,KO.translate)(r,C)}const B=Math.max((t.hole_diameter??a??g??Wo)+o,Wo);return(0,px.cylinder)({center:r,radius:B/2,height:A})},fm=.02,WBA=64,q_=(t,A)=>A?(0,HI.intersect)(A,t):t,qO=({width:t,height:A,thickness:e,center:i,borderRadius:o})=>{const n=ay(t,A,o);if(n<=0)return(0,Ug.cuboid)({center:i,size:[t,A,e]});const s=(0,Ug.roundedRectangle)({size:[t,A],roundRadius:n,segments:WBA}),r=(0,JO.extrudeLinear)({height:e},s),a=i[2]-e/2;return(0,rS.translate)([i[0],i[1],a],r)},PO=(t,A,e={})=>{const{clipGeom:i}=e;t.shape||(t.shape="circle");const o=A.pcbThickness+2*fm+4*Wo,n=A.pcbThickness/2+rI.copper,s=-A.pcbThickness/2-rI.copper,r=n-s;if(t.shape==="circle"){const a=t.outer_diameter??Math.max(t.hole_diameter,0),g=r+.01,I=(0,Ug.cylinder)({center:[t.x,t.y,0],radius:a/2,height:g}),c=q_(I,i),B=(0,Ug.cylinder)({center:[t.x,t.y,0],radius:Math.max(t.hole_diameter/2,.01),height:o});return(0,sS.colorize)(No.copper,(0,HI.subtract)(c,B))}if(t.shape==="oval"){const a=t.outer_width||t.hole_width||0,g=t.outer_height||t.hole_height||0,I=t.hole_width||0,c=t.hole_height||0,B=(()=>{const Q=(0,Ug.cylinder)({center:[0,0,0],radius:1,height:r+.01,segments:64}),E=(0,IZA.scale)([a/2,g/2,1],Q);return(0,rS.translate)([t.x,t.y,0],E)})(),C=q_(B,i),l=(()=>{const Q=(0,Ug.cylinder)({center:[0,0,0],radius:1,height:o,segments:64}),E=(0,IZA.scale)([Math.max(I/2,.01),Math.max(c/2,.01),1],Q);return(0,rS.translate)([t.x,t.y,0],E)})();return(0,sS.colorize)(No.copper,(0,HI.subtract)(C,l))}if(t.shape==="circular_hole_with_rect_pad"){const a=t.hole_offset_x||0,g=t.hole_offset_y||0,I=t.rect_pad_width||t.hole_diameter,c=t.rect_pad_height||t.hole_diameter,B=Ch(t),C=q_((0,HI.union)(qO({width:I,height:c,thickness:fm,center:[t.x,t.y,n],borderRadius:B}),qO({width:I,height:c,thickness:fm,center:[t.x,t.y,s],borderRadius:B}),(()=>{const h=Math.max(r-fm*2,Wo),f=(n+s)/2,D=(0,Ug.roundedRectangle)({size:[I,c],roundRadius:B||0,segments:WBA}),b=(0,JO.extrudeLinear)({height:h},D);return(0,rS.translate)([t.x,t.y,f-h/2],b)})(),(0,Ug.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:t.hole_diameter/2,height:r})),i),l=(0,Ug.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:Math.max(t.hole_diameter/2-Wo,.01),height:o}),Q=(0,Ug.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:t.hole_diameter/2,height:r});let E=(0,HI.union)((0,HI.subtract)(C,Q),Q);return e.clipGeom?(E=(0,HI.subtract)(E,l),E=(0,HI.intersect)(E,e.clipGeom),(0,sS.colorize)(No.copper,E)):(0,sS.colorize)(No.copper,(0,HI.subtract)(E,l))}if(t.shape==="pill"){const a=(t.ccw_rotation||0)*Math.PI/180,g=k=>{if(!a)return k;const v=(0,rS.translate)([-t.x,-t.y,0],k),_=(0,rS.rotate)([0,0,a],v);return(0,rS.translate)([t.x,t.y,0],_)},I=t.hole_height>t.hole_width,c=I?t.hole_height:t.hole_width,B=I?t.hole_width:t.hole_height,C=I?t.outer_height||B+.2:t.outer_width||c+.2,l=I?t.outer_width||c+.2:t.outer_height||B+.2,Q=B/2,E=Math.abs(c-B),h=r+.01,d=((k,v,_)=>{const Y=v/2,P=Math.abs(k-v);if(P<=1e-6)return(0,Ug.cylinder)({center:[t.x,t.y,0],radius:Y,height:_});const K=(0,Ug.cuboid)({center:[t.x,t.y,0],size:I?[v,P,_]:[P,v,_]}),O=(0,Ug.cylinder)({center:I?[t.x,t.y-P/2,0]:[t.x-P/2,t.y,0],radius:Y,height:_}),W=(0,Ug.cylinder)({center:I?[t.x,t.y+P/2,0]:[t.x+P/2,t.y,0],radius:Y,height:_});return(0,HI.union)(K,O,W)})(C,l,h),f=(0,Ug.cuboid)({center:[t.x,t.y,0],size:I?[B-2*Wo,E,o]:[E,B-2*Wo,o]}),D=(0,Ug.cylinder)({center:I?[t.x,t.y-E/2,0]:[t.x-E/2,t.y,0],radius:Q-Wo,height:o}),b=(0,Ug.cylinder)({center:I?[t.x,t.y+E/2,0]:[t.x+E/2,t.y,0],radius:Q-Wo,height:o}),m=(0,HI.union)(f,D,b),x=q_(g(d),i),F=g(m);return(0,sS.colorize)(No.copper,(0,HI.subtract)(x,F))}if(t.shape==="pill_hole_with_rect_pad"){const a=t.hole_offset_x||0,g=t.hole_offset_y||0,I=t.hole_height>t.hole_width,c=I?t.hole_height:t.hole_width,B=I?t.hole_width:t.hole_height,C=B/2,l=Math.abs(c-B),Q=t.rect_pad_width||c+.2,E=t.rect_pad_height||B+.2,h=Ch(t),u=.03,d=(0,HI.union)((0,Ug.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B+2*u,l+2*u,r]:[l+2*u,B+2*u,r]}),(0,Ug.cylinder)({center:I?[t.x+a,t.y+g-l/2,0]:[t.x+a-l/2,t.y+g,0],radius:C+u,height:r}),(0,Ug.cylinder)({center:I?[t.x+a,t.y+g+l/2,0]:[t.x+a+l/2,t.y+g,0],radius:C+u,height:r})),f=(0,HI.union)((0,Ug.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B,l,o*1.1]:[l,B,o*1.1]}),(0,Ug.cylinder)({center:I?[t.x+a,t.y+g-l/2,0]:[t.x+a-l/2,t.y+g,0],radius:C,height:o*1.1}),(0,Ug.cylinder)({center:I?[t.x+a,t.y+g+l/2,0]:[t.x+a+l/2,t.y+g,0],radius:C,height:o*1.1})),D=qO({width:Q,height:E,thickness:fm,center:[t.x,t.y,n],borderRadius:h}),b=qO({width:Q,height:E,thickness:fm,center:[t.x,t.y,s],borderRadius:h}),m=(()=>{const P=Math.max(r-fm*2,Wo),W=(n+s)/2,$=(0,Ug.roundedRectangle)({size:[Q,E],roundRadius:h||0,segments:WBA}),oA=(0,JO.extrudeLinear)({height:P},$);return(0,rS.translate)([t.x,t.y,W-P/2],oA)})(),x=(0,HI.subtract)(D,f),F=(0,HI.subtract)(b,f),k=(0,HI.subtract)(m,f),v=(0,HI.union)((0,Ug.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B-2*Wo,l-2*Wo,o*1.1]:[l-2*Wo,B-2*Wo,o*1.1]}),(0,Ug.cylinder)({center:I?[t.x+a,t.y+g-l/2,0]:[t.x+a-l/2,t.y+g,0],radius:C-Wo,height:o*1.1}),(0,Ug.cylinder)({center:I?[t.x+a,t.y+g+l/2,0]:[t.x+a+l/2,t.y+g,0],radius:C-Wo,height:o*1.1})),_=(0,HI.subtract)(d,v),Y=q_((0,HI.union)(x,F,k,_),i);return(0,sS.colorize)(No.copper,Y)}else if(t.shape==="hole_with_polygon_pad"){const a=t.pad_outline;if(!Array.isArray(a)||a.length<3)throw new Error(`Invalid pad_outline for plated hole at (${t.x}, ${t.y})`);const g=a.map(f=>[f.x,f.y]),I=(0,Ug.polygon)({points:g}),c=(n+s)/2,B=(f,D)=>{const b=Math.max(f,Wo),m=(0,JO.extrudeLinear)({height:b},I);return(0,rS.translate)([t.x,t.y,D-b/2],m)},C=B(Math.max(r-fm*2,Wo),c),l=B(fm,n),Q=B(fm,s),E=q_((0,HI.union)(C,l,Q),i),h=TO(t,r);if(!h)return(0,sS.colorize)(No.copper,E);const u=TO(t,o,{sizeDelta:-2*Wo})||h;let d=(0,HI.union)((0,HI.subtract)(E,h),h);return e.clipGeom?(d=(0,HI.subtract)(d,u),d=(0,HI.intersect)(d,e.clipGeom),(0,sS.colorize)(No.copper,d)):(0,sS.colorize)(No.copper,(0,HI.subtract)(d,u))}else throw new Error(`Unsupported plated hole shape: ${t.shape}`)},qU=yr(xU()),Nht=yr(rBA()),cZA=yr(Ex()),_ht=yr(x_());function Mht(t,A,e,i){if(!e||Math.abs(e)<1e-9)return[];const o=4*Math.atan(e),n=A[0]-t[0],s=A[1]-t[1],r=Math.sqrt(n*n+s*s);if(r<1e-9)return[];const a=Math.abs(r/(2*Math.sin(o/2))),g=Math.sqrt(Math.max(0,a*a-r/2*(r/2))),I=[(t[0]+A[0])/2,(t[1]+A[1])/2],c=n/r,C=-(s/r),l=c,Q=I[0]+C*g*Math.sign(e),E=I[1]+l*g*Math.sign(e),h=Math.atan2(t[1]-E,t[0]-Q),u=[],d=Math.max(2,Math.ceil(i*Math.abs(o)/(Math.PI*2)*4)),f=o/d;for(let D=1;D<d;D++){const b=h+f*D;u.push([Q+a*Math.cos(b),E+a*Math.sin(b)])}return u}function OO(t,A){const e=[],i=t.vertices;for(let o=0;o<i.length;o++){const n=i[o],s=i[(o+1)%i.length];if(e.push([n.x,n.y]),n.bulge){const r=Mht([n.x,n.y],[s.x,s.y],n.bulge,A);e.push(...r)}}return e}function BZA(t){let A=0;for(let e=0;e<t.length;e++){const i=(e+1)%t.length;A+=t[e][0]*t[i][1],A-=t[i][0]*t[e][1]}return A/2<=0}function vht(t,A=16){let e=OO(t.outer_ring,A);BZA(e)&&e.reverse();const i=(0,cZA.polygon)({points:e});if(!t.inner_rings||t.inner_rings.length===0)return i;const o=t.inner_rings.map(n=>{let s=OO(n,A);return BZA(s)&&s.reverse(),(0,cZA.polygon)({points:s})});return o.length===0?i:(0,_ht.subtract)(i,o)}var CZA=yr(x_()),Uht=yr(HG()),PU=yr(Ex());function Lht({x:t,y:A,outerDiameter:e,holeDiameter:i,thickness:o}){if(e<=i)throw new Error(`Invalid via geometry: outerDiameter (${e}) must be > holeDiameter (${i})`);const n=Wo,s=Wo,r=Math.min(e/2,i/2+s),a=(0,PU.cylinder)({center:[0,0,0],radius:r,height:o,segments:wl}),g=(0,PU.cylinder)({center:[0,0,o/2],radius:e/2,height:n,segments:wl}),I=(0,PU.cylinder)({center:[0,0,-o/2],radius:e/2,height:n,segments:wl}),c=(0,CZA.union)([a,g,I]),B=o+n*2,C=(0,PU.cylinder)({center:[0,0,0],radius:i/2,height:B,segments:wl}),l=(0,CZA.subtract)(c,C);return(0,Uht.translate)([t,A,0],l)}function Hht({x:t,y:A,holeDiameter:e,thickness:i}){const o=i*1.5,n=e/2+Wo;return(0,PU.cylinder)({center:[t,A,0],radius:n,height:o,segments:wl})}var lZA=64,Yht=1,ZBA=.05,QZA=(t,A,e,i)=>{const o=ay(t,A,i);if(o<=0)return(0,aI.cuboid)({center:[0,0,0],size:[t,A,e]});const n=(0,aI.roundedRectangle)({size:[t,A],roundRadius:o,segments:lZA}),s=(0,qU.extrudeLinear)({height:e},n);return(0,yu.translate)([0,0,-e/2],s)},EZA=["initializing","processing_pads","processing_copper_pours","processing_plated_holes","processing_holes","processing_cutouts","processing_vias","finalizing","done"],Jht=class{circuitJson;board;plated_holes;holes;pads;traces;pcb_vias;pcb_cutouts;pcb_copper_pours;boardGeom=null;platedHoleGeoms=[];padGeoms=[];viaGeoms=[];copperPourGeoms=[];boardClipGeom=null;state="initializing";currentIndex=0;ctx;onCompleteCallback;finalGeoms=[];getHoleToCut(t,A){const e=Wo/10;for(const i of this.pcb_vias)if(Math.abs(i.x-t)<e&&Math.abs(i.y-A)<e&&i.hole_diameter)return{diameter:i.hole_diameter};for(const i of this.plated_holes)if(i.shape==="circle"&&Math.abs(i.x-t)<e&&Math.abs(i.y-A)<e&&i.hole_diameter)return{diameter:i.hole_diameter};return null}constructor(t,A){this.circuitJson=t,this.onCompleteCallback=A;const e=t.filter(o=>o.type==="pcb_panel"),i=wi(t).pcb_board.list();if(e.length>0){const o=e[0],n=i.find(s=>s.pcb_panel_id===o.pcb_panel_id);this.board={type:"pcb_board",pcb_board_id:o.pcb_panel_id,center:o.center,width:o.width,height:o.height,thickness:n?.thickness??1.6,material:n?.material??"fr4",num_layers:n?.num_layers??2}}else{const o=i.filter(n=>!n.pcb_panel_id);this.board=o[0]}this.plated_holes=wi(t).pcb_plated_hole.list(),this.holes=wi(t).pcb_hole.list(),this.pads=wi(t).pcb_smtpad.list(),this.traces=wi(t).pcb_trace.list(),this.pcb_vias=wi(t).pcb_via.list(),this.pcb_cutouts=wi(t).pcb_cutout.list(),this.pcb_copper_pours=t.filter(o=>o.type==="pcb_copper_pour"),this.ctx={pcbThickness:this.board.thickness??1.2},this.initializeBoard()}initializeBoard(){const t=this.ctx.pcbThickness+2*Yht;this.board.outline&&this.board.outline.length>0?(this.boardGeom=OBA({outline:this.board.outline},this.ctx.pcbThickness),this.boardClipGeom=OBA({outline:this.board.outline},t,{xyOutset:ZBA})):(this.boardGeom=(0,aI.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.boardClipGeom=(0,aI.cuboid)({size:[this.board.width+2*ZBA,this.board.height+2*ZBA,t],center:[this.board.center.x,this.board.center.y,0]})),this.state="processing_pads",this.currentIndex=0}goToNextState(){const t=EZA.indexOf(this.state);t!==-1&&(this.state=EZA[t+1],this.currentIndex=0)}step(t=1){if(this.state==="done"||!this.boardGeom)return!0;for(let A=0;A<t&&this.state!=="done";A++)switch(this.state){case"processing_plated_holes":this.currentIndex<this.plated_holes.length?(this.processPlatedHole(this.plated_holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_holes":this.currentIndex<this.holes.length?(this.processHole(this.holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_pads":this.currentIndex<this.pads.length?(this.processPad(this.pads[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_vias":this.currentIndex<this.pcb_vias.length?(this.processVia(this.pcb_vias[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_cutouts":this.currentIndex<this.pcb_cutouts.length?(this.processCutout(this.pcb_cutouts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_copper_pours":this.currentIndex<this.pcb_copper_pours.length?(this.processCopperPour(this.pcb_copper_pours[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"finalizing":this.finalize(),this.state="done";break}return this.state==="done"}processCutout(t){if(!this.boardGeom)return;let A=null;const e=this.ctx.pcbThickness*1.5;switch(t.shape){case"rect":{const i=ay(t.width,t.height,Ch(t));if(i>0){const o=(0,aI.roundedRectangle)({size:[t.width,t.height],roundRadius:i,segments:lZA});A=(0,qU.extrudeLinear)({height:e},o),A=(0,yu.translate)([0,0,-e/2],A)}else A=(0,aI.cuboid)({center:[0,0,0],size:[t.width,t.height,e]});if(t.rotation){const o=t.rotation*Math.PI/180;A=(0,yu.rotateZ)(o,A)}A=(0,yu.translate)([t.center.x,t.center.y,0],A);break}case"circle":A=(0,aI.cylinder)({center:[t.center.x,t.center.y,0],radius:t.radius,height:e});break;case"polygon":{let i=t.points.map(n=>[n.x,n.y]);if(i.length<3){console.warn(`PCB Cutout [${t.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}PBA(i)&&(i=i.reverse());const o=(0,aI.polygon)({points:i});A=(0,qU.extrudeLinear)({height:e},o),A=(0,yu.translate)([0,0,-e/2],A);break}}A&&(this.boardGeom=(0,gI.subtract)(this.boardGeom,A))}processCopperPour(t){const A=t.layer==="bottom"?-1:1,e=A*this.ctx.pcbThickness/2+A*rI.copper;let i=null;if(t.shape==="rect"){let o=(0,aI.cuboid)({center:[0,0,0],size:[t.width,t.height,Wo]});if("rotation"in t&&t.rotation){const n=t.rotation*Math.PI/180;o=(0,yu.rotateZ)(n,o)}i=(0,yu.translate)([t.center.x,t.center.y,e],o)}else if(t.shape==="brep"){const o=t.brep_shape;if(o?.outer_ring){const n=vht(o);i=(0,qU.extrudeLinear)({height:Wo},n),i=(0,yu.translate)([0,0,e],i)}}else if(t.shape==="polygon"){let o=t.points.map(s=>[s.x,s.y]);if(o.length<3){console.warn(`PCB Copper Pour [${t.pcb_copper_pour_id}] polygon has fewer than 3 points, skipping.`);return}PBA(o)&&(o=o.reverse());const n=(0,aI.polygon)({points:o});i=(0,qU.extrudeLinear)({height:Wo},n),i=(0,yu.translate)([0,0,e],i)}if(i){this.boardClipGeom&&(i=(0,gI.intersect)(this.boardClipGeom,i));const n=t.covered_with_solder_mask!==!1?yht[this.board.material]??No.fr4TracesWithoutMaskTan:No.copper,s=(0,wu.colorize)(n,i);this.copperPourGeoms.push(s)}}processPlatedHole(t,A={}){if(this.boardGeom){if(t.shape==="circle"||t.shape==="circular_hole_with_rect_pad"){let e=null;t.shape==="circular_hole_with_rect_pad"?e=(0,aI.cylinder)({center:[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0),0],radius:t.hole_diameter/2+Wo,height:this.ctx.pcbThickness*1.5}):e=(0,aI.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+Wo,height:this.ctx.pcbThickness*1.5}),A.dontCutBoard||(this.boardGeom=(0,gI.subtract)(this.boardGeom,e)),this.padGeoms=this.padGeoms.map(o=>(0,wu.colorize)(No.copper,(0,gI.subtract)(o,e)));const i=PO(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(i)}else if(t.shape==="pill"||t.shape==="oval"){const e=t.hole_height>t.hole_width,i=e?t.hole_height:t.hole_width,o=e?t.hole_width:t.hole_height,n=o/2,s=Math.abs(i-o);let r;if(r=(0,gI.union)((0,aI.cuboid)({center:[t.x,t.y,0],size:e?[o,s,this.ctx.pcbThickness*1.5]:[s,o,this.ctx.pcbThickness*1.5]}),(0,aI.cylinder)({center:e?[t.x,t.y-s/2,0]:[t.x-s/2,t.y,0],radius:n,height:this.ctx.pcbThickness*1.5}),(0,aI.cylinder)({center:e?[t.x,t.y+s/2,0]:[t.x+s/2,t.y,0],radius:n,height:this.ctx.pcbThickness*1.5})),t.ccw_rotation){const g=t.ccw_rotation*Math.PI/180;r=(0,yu.translate)([t.x,t.y,0],(0,yu.rotateZ)(g,(0,yu.translate)([-t.x,-t.y,0],r)))}A.dontCutBoard||(this.boardGeom=(0,gI.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,wu.colorize)(No.copper,(0,gI.subtract)(g,r)));const a=PO(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(a)}else if(t.shape==="pill_hole_with_rect_pad"){const e=t.hole_height>t.hole_width,i=e?t.hole_height:t.hole_width,o=e?t.hole_width:t.hole_height,n=o/2,s=Math.abs(i-o);let r;r=(0,gI.union)((0,aI.cuboid)({center:[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0),0],size:e?[o,s,this.ctx.pcbThickness*1.5]:[s,o,this.ctx.pcbThickness*1.5]}),(0,aI.cylinder)({center:e?[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0)-s/2,0]:[t.x+(t.hole_offset_x||0)-s/2,t.y+(t.hole_offset_y||0),0],radius:n,height:this.ctx.pcbThickness*1.5}),(0,aI.cylinder)({center:e?[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0)+s/2,0]:[t.x+(t.hole_offset_x||0)+s/2,t.y+(t.hole_offset_y||0),0],radius:n,height:this.ctx.pcbThickness*1.5})),A.dontCutBoard||(this.boardGeom=(0,gI.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,wu.colorize)(No.copper,(0,gI.subtract)(g,r)));const a=PO(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(a)}else if(t.shape==="hole_with_polygon_pad"){const e=t.pad_outline;if(!Array.isArray(e)||e.length<3)return;const i=this.ctx.pcbThickness*1.5,o=TO(t,i,{sizeDelta:2*Wo}),n=TO(t,i,{sizeDelta:-2*Wo});if(!o||!n)return;A.dontCutBoard||(this.boardGeom=(0,gI.subtract)(this.boardGeom,o)),this.padGeoms=this.padGeoms.map(r=>(0,wu.colorize)(No.copper,(0,gI.subtract)(r,o))),this.platedHoleGeoms=this.platedHoleGeoms.map(r=>(0,wu.colorize)(No.copper,(0,gI.subtract)(r,n)));const s=PO(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(s)}}}processHole(t){if(!this.boardGeom)return;const A=this.ctx.pcbThickness*1.5;if(t.hole_shape==="round"||t.hole_shape==="circle"){const e=(0,aI.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+Wo,height:A});this.boardGeom=(0,gI.subtract)(this.boardGeom,e),this.padGeoms=this.padGeoms.map(o=>(0,wu.colorize)(No.copper,(0,gI.subtract)(o,e)));const i=(0,aI.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+Wo/2,height:A});this.platedHoleGeoms=this.platedHoleGeoms.map(o=>(0,wu.colorize)(No.copper,(0,gI.subtract)(o,i)))}else if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const e=t.hole_width,i=t.hole_height,o=Math.min(e,i)/2,n=Math.abs(e-i),s=t.hole_shape==="rotated_pill";let r;if(e>i?r=(0,gI.union)((0,aI.cuboid)({center:[t.x,t.y,0],size:[n,i,A]}),(0,aI.cylinder)({center:[t.x-n/2,t.y,0],radius:o,height:A}),(0,aI.cylinder)({center:[t.x+n/2,t.y,0],radius:o,height:A})):r=(0,gI.union)((0,aI.cuboid)({center:[t.x,t.y,0],size:[e,n,A]}),(0,aI.cylinder)({center:[t.x,t.y-n/2,0],radius:o,height:A}),(0,aI.cylinder)({center:[t.x,t.y+n/2,0],radius:o,height:A})),s){const g=t.ccw_rotation*Math.PI/180;r=(0,yu.rotateZ)(g,r)}this.boardGeom=(0,gI.subtract)(this.boardGeom,r),this.padGeoms=this.padGeoms.map(g=>(0,wu.colorize)(No.copper,(0,gI.subtract)(g,r)));const a=(0,Nht.expand)({delta:-.02},r);this.platedHoleGeoms=this.platedHoleGeoms.map(g=>(0,wu.colorize)(No.copper,(0,gI.subtract)(g,a)))}}processPad(t){const A=t.layer==="bottom"?-1:1,e=A*this.ctx.pcbThickness/2+A*rI.copper,i=Ch(t);if(t.shape==="rect"){const o=QZA(t.width,t.height,Wo,i);let s=(0,yu.translate)([t.x,t.y,e],o);this.boardClipGeom&&(s=(0,gI.intersect)(this.boardClipGeom,s)),s=(0,wu.colorize)(No.copper,s),this.padGeoms.push(s)}else if(t.shape==="rotated_rect"){let o=QZA(t.width,t.height,Wo,i);const n=t.ccw_rotation*Math.PI/180;o=(0,yu.rotateZ)(n,o);let r=(0,yu.translate)([t.x,t.y,e],o);this.boardClipGeom&&(r=(0,gI.intersect)(this.boardClipGeom,r)),r=(0,wu.colorize)(No.copper,r),this.padGeoms.push(r)}else if(t.shape==="circle"){let o=(0,aI.cylinder)({center:[t.x,t.y,e],radius:t.radius,height:Wo});this.boardClipGeom&&(o=(0,gI.intersect)(this.boardClipGeom,o)),o=(0,wu.colorize)(No.copper,o),this.padGeoms.push(o)}}processVia(t){if(this.boardGeom){if(typeof t.outer_diameter=="number"&&typeof t.hole_diameter=="number"){const A=Lht({x:t.x,y:t.y,outerDiameter:t.outer_diameter,holeDiameter:t.hole_diameter,thickness:this.ctx.pcbThickness});let e=A;this.boardClipGeom&&(e=(0,gI.intersect)(this.boardClipGeom,A),e=(0,wu.colorize)(No.copper,e)),this.viaGeoms.push(e)}if(typeof t.hole_diameter=="number"){const A=Hht({x:t.x,y:t.y,holeDiameter:t.hole_diameter,thickness:this.ctx.pcbThickness});this.boardGeom=(0,gI.subtract)(this.boardGeom,A),this.padGeoms=this.padGeoms.map(e=>(0,wu.colorize)(No.copper,(0,gI.subtract)(e,A)))}}}finalize(){if(!this.boardGeom)return;const t=qBA[this.board.material]??No.fr4Tan;this.boardGeom=(0,wu.colorize)(t,this.boardGeom),this.finalGeoms=[this.boardGeom,...this.platedHoleGeoms,...this.padGeoms,...this.viaGeoms,...this.copperPourGeoms],this.onCompleteCallback&&this.onCompleteCallback(this.finalGeoms)}getGeoms(){return this.finalGeoms}},Kht=t=>{const[A,e]=AA.useState(null),i=AA.useRef(!1);return AA.useEffect(()=>{let o=!1;if(!t){e(null);return}if(!t.some(g=>g.type==="pcb_board"||g.type==="pcb_panel")){e(null);return}const s=bht(t);e(s);const r=new Jht(t,g=>{});return(async()=>{if(!i.current){i.current=!0;try{let g=!1;for(;!g&&!o;)g=r.step(1),g||await new Promise(I=>setTimeout(I,0));o||e(r.getGeoms())}catch(g){console.error("Error during board geometry building:",g)}finally{i.current=!1}}})(),()=>{o=!0}},[t]),A},VBA=1.2;function Tht(t){return AA.useMemo(()=>{if(!t)return VBA;try{return wi(t).pcb_board.list()[0]?.thickness??VBA}catch{return VBA}},[t])}var qht=({children:t,parent:A,position:e,rotation:i,scale:o,color:n,fontSize:s,anchorX:r,anchorY:a,depthOffset:g})=>{const{rootObject:I}=fu(),c=AA.useMemo(()=>{const B=new LX;return B.text=t,e&&B.position.fromArray(e),i&&B.rotation.fromArray(i),o&&B.scale.fromArray(o),B.color=n||"white",B.fontSize=s||1,B.anchorX=r||"center",B.anchorY=a||"middle",B.depthOffset=g||0,B.font=null,B.sync(),B},[t,e,i,o,n,s,r,a,g]);return AA.useEffect(()=>{const B=A||I;if(!(!B||!c))return B.add(c),()=>{B.remove(c),c.dispose()}},[I,A,c]),null},hZA=({error:t,cad_component:A})=>{const{rootObject:e}=fu(),[i,o]=AA.useState(!1),[n,s]=AA.useState(null),r=AA.useCallback(c=>{c?.mousePosition?(o(!0),s(c.mousePosition)):(o(!1),s(null))},[]),a=AA.useCallback(()=>{o(!1),s(null)},[]),g=AA.useMemo(()=>A?.position?[A.position.x,A.position.y,A.position.z].map(B=>Number.isNaN(B)?0:B):[0,0,0],[A]),I=AA.useMemo(()=>{const c=new Np;return c.position.fromArray(g),c},[g]);return AA.useEffect(()=>{if(e)return e.add(I),()=>{e.remove(I)}},[e,I]),V.jsxs(V.Fragment,{children:[V.jsxs(GU,{isHovered:i,onHover:r,onUnhover:a,object:I,children:[V.jsx(Pht,{parent:I}),V.jsx(qht,{parent:I,scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:`${t.toString().slice(0,50)}...`})]}),i&&n?V.jsx(XWA,{position:n,style:{fontFamily:"sans-serif",transform:"translate3d(-1rem, 0rem, 0)",backgroundColor:"white",padding:"6px",borderRadius:"4px",color:"red",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:t.toString()}):null]})},Pht=({parent:t})=>{const A=AA.useMemo(()=>{const e=new Oo(new tw(.5,.5,.5),new ih({depthTest:!1,transparent:!0,color:"red",opacity:.5}));return e.renderOrder=999999,e.rotation.fromArray([Math.PI/4,Math.PI/4,0]),e},[]);return AA.useEffect(()=>(t.add(A),()=>{t.remove(A)}),[t,A]),null};function Oht({stlUrl:t,stlData:A,mtlUrl:e,color:i,opacity:o=1}){const{rootObject:n}=fu(),[s,r]=AA.useState(null);AA.useEffect(()=>{const g=new XSe;if(A){try{const I=g.parse(A);r(I)}catch(I){console.error("Failed to parse STL data",I),r(null)}return}t&&g.load(t,I=>{r(I)})},[t,A]);const a=AA.useMemo(()=>{if(!s)return null;const g=new ih({color:Array.isArray(i)?new Ui(i[0],i[1],i[2]):i,transparent:o!==1,opacity:o});return new Oo(s,g)},[s,i,o]);return AA.useEffect(()=>{if(!(!n||!a))return n.add(a),()=>{n.remove(a),a.geometry.dispose(),Array.isArray(a.material)?a.material.forEach(g=>g.dispose()):a.material.dispose()}},[n,a]),null}function Wht({stlData:t,color:A,opacity:e=1,layerType:i}){const{visibility:o}=T_();let n=!0;return i==="board"?n=o.boardBody:i==="top-copper"?n=o.topCopper:i==="bottom-copper"?n=o.bottomCopper:i==="top-silkscreen"?n=o.topSilkscreen:i==="bottom-silkscreen"&&(n=o.bottomSilkscreen),n?V.jsx(Oht,{stlData:t,color:A,opacity:e}):null}var uZA=class extends $i.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},Zht=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,o=t[0].y;for(let n=1;n<t.length;n++){const s=t[n];s.x<A&&(A=s.x),s.y<e&&(e=s.y),s.x>i&&(i=s.x),s.y>o&&(o=s.y)}return{minX:A,minY:e,maxX:i,maxY:o}};function KG(t){if(t.outline&&t.outline.length>=3){const s=Zht(t.outline);return{...s,width:s.maxX-s.minX,height:s.maxY-s.minY,centerX:(s.minX+s.maxX)/2,centerY:(s.minY+s.maxY)/2}}const A=t.width??0,e=t.height??0,i=t.center?.x??0,o=t.center?.y??0;return{...{minX:i-A/2,maxX:i+A/2,minY:o-e/2,maxY:o+e/2},width:A,height:e,centerX:i,centerY:o}}function WO({layer:t,circuitJson:A,boardData:e,soldermaskColor:i,traceTextureResolution:o}){const n=KG(e),s=document.createElement("canvas"),r=Math.floor(n.width*o),a=Math.floor(n.height*o);s.width=r,s.height=a;const g=s.getContext("2d");if(!g)return null;t==="bottom"&&(g.translate(0,a),g.scale(1,-1));const I=f=>(f-n.minX)*o,c=f=>(n.maxY-f)*o;if(g.fillStyle=i,e.outline&&e.outline.length>=3){g.beginPath();const f=e.outline[0];g.moveTo(I(f.x),c(f.y));for(let D=1;D<e.outline.length;D++){const b=e.outline[D];g.lineTo(I(b.x),c(b.y))}g.closePath(),g.fill()}else g.fillRect(0,0,r,a);g.globalCompositeOperation="destination-out",g.fillStyle="black",wi(A).pcb_smtpad.list().filter(f=>f.layer===t).forEach(f=>{if(f.shape==="polygon"&&f.points){g.beginPath(),f.points.forEach((F,k)=>{const v=I(F.x),_=c(F.y);k===0?g.moveTo(v,_):g.lineTo(v,_)}),g.closePath(),g.fill();return}if(f.x===void 0||f.y===void 0)return;if(Number.isNaN(f.x)||Number.isNaN(f.y)){console.warn(`[soldermask-texture] Skipping pad ${f.pcb_smtpad_id} with NaN coordinates`);return}const D=f.x,b=f.y,m=I(D),x=c(b);if(f.shape==="rect"){const F=f.width*o,k=f.height*o,v=Ch(f),_=ay(f.width,f.height,v)*o;_>0?(g.beginPath(),g.roundRect(m-F/2,x-k/2,F,k,_),g.fill()):g.fillRect(m-F/2,x-k/2,F,k)}else if(f.shape==="circle"){const F=(f.radius??f.width/2)*o;g.beginPath(),g.arc(m,x,F,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const F=f.width*o,k=f.height*o,v=Ch(f),_=ay(f.width,f.height,v)*o;g.beginPath(),g.roundRect(m-F/2,x-k/2,F,k,_),g.fill()}else if(f.shape==="rotated_rect"){const F=f.width*o,k=f.height*o,v=Ch(f),_=ay(f.width,f.height,v)*o,P=-(f.ccw_rotation||0)*(Math.PI/180);g.save(),g.translate(m,x),g.rotate(P),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()}}),wi(A).pcb_via.list().forEach(f=>{const D=I(f.x),b=c(f.y),m=f.outer_diameter/2*o;g.beginPath(),g.arc(D,b,m,0,2*Math.PI),g.fill()}),wi(A).pcb_plated_hole.list().forEach(f=>{if(!f.layers?.includes(t))return;const D=f.x,b=f.y,m=I(D),x=c(b);if(f.shape==="circle"){const k=f.outer_diameter/2*o;g.beginPath(),g.arc(m,x,k,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const F=(f.outer_width??f.outer_diameter??f.hole_width)*o,k=(f.outer_height??f.outer_diameter??f.hole_height)*o,v=Math.min(F,k)/2,Y=-(f.ccw_rotation||0);Y?(g.save(),g.translate(m,x),g.rotate(Y*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,v),g.fill(),g.restore()):(g.beginPath(),g.roundRect(m-F/2,x-k/2,F,k,v),g.fill())}else if(f.shape==="oval"){const F=(f.outer_width??f.outer_diameter??f.hole_width)*o,k=(f.outer_height??f.outer_diameter??f.hole_height)*o,v=F/2,_=k/2,P=-(f.ccw_rotation||0);P?(g.save(),g.translate(m,x),g.rotate(P*Math.PI/180),g.beginPath(),g.ellipse(0,0,v,_,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(m,x,v,_,0,0,2*Math.PI),g.fill())}else if(f.shape==="hole_with_polygon_pad"){const F=f.hole_shape||"circle",k=f.hole_offset_x||0,v=f.hole_offset_y||0,_=I(f.x+k),Y=c(f.y+v);if(F==="pill"||F==="rotated_pill"){const P=(f.outer_width??f.outer_diameter??f.hole_width)*o,K=(f.outer_height??f.outer_diameter??f.hole_height)*o,O=Math.min(P,K)/2,$=-(f.ccw_rotation||0);$?(g.save(),g.translate(_,Y),g.rotate($*Math.PI/180),g.beginPath(),g.roundRect(-P/2,-K/2,P,K,O),g.fill(),g.restore()):(g.beginPath(),g.roundRect(_-P/2,Y-K/2,P,K,O),g.fill())}else if(F==="oval"){const P=(f.outer_width??f.outer_diameter??f.hole_width)*o,K=(f.outer_height??f.outer_diameter??f.hole_height)*o,O=P/2,W=K/2,oA=-(f.ccw_rotation||0);oA?(g.save(),g.translate(_,Y),g.rotate(oA*Math.PI/180),g.beginPath(),g.ellipse(0,0,O,W,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(_,Y,O,W,0,0,2*Math.PI),g.fill())}else if(F==="circle"){const K=(f.outer_diameter??f.hole_diameter??0)*o/2;g.beginPath(),g.arc(_,Y,K,0,2*Math.PI),g.fill()}}else if(f.shape==="circular_hole_with_rect_pad"){const F=(f.rect_pad_width??f.hole_diameter??0)*o,k=(f.rect_pad_height??f.hole_diameter??0)*o,v=Ch(f),_=ay(f.rect_pad_width??f.hole_diameter??0,f.rect_pad_height??f.hole_diameter??0,v)*o;_>0?(g.beginPath(),g.roundRect(m-F/2,x-k/2,F,k,_),g.fill()):g.fillRect(m-F/2,x-k/2,F,k)}else if(f.shape==="pill_hole_with_rect_pad"){const F=(f.rect_pad_width??f.hole_width??0)*o,k=(f.rect_pad_height??f.hole_height??0)*o,v=Ch(f),_=ay(f.rect_pad_width??f.hole_width??0,f.rect_pad_height??f.hole_height??0,v)*o,P=-(f.ccw_rotation||0);P?(g.save(),g.translate(m,x),g.rotate(P*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(m-F/2,x-k/2,F,k,_),g.fill())}}),wi(A).pcb_hole.list().forEach(f=>{const D=f.x,b=f.y,m=I(D),x=c(b),F=f.hole_shape||f.shape;if(F==="circle"&&typeof f.hole_diameter=="number"){const k=f.hole_diameter/2*o;g.beginPath(),g.arc(m,x,k,0,2*Math.PI),g.fill()}else if((F==="pill"||F==="rotated_pill")&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const k=f.hole_width*o,v=f.hole_height*o,_=Math.min(k,v)/2,P=-(f.ccw_rotation||0)*(Math.PI/180);P?(g.save(),g.translate(m,x),g.rotate(P),g.beginPath(),g.roundRect(-k/2,-v/2,k,v,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(m-k/2,x-v/2,k,v,_),g.fill())}}),wi(A).pcb_copper_pour.list().forEach(f=>{if(f.layer===t&&f.covered_with_solder_mask===!1)if(f.shape==="rect"){const D=I(f.center.x),b=c(f.center.y),m=f.width*o,x=f.height*o;g.fillRect(D-m/2,b-x/2,m,x)}else f.shape==="polygon"&&f.points&&(g.beginPath(),f.points.forEach((D,b)=>{const m=I(D.x),x=c(D.y);b===0?g.moveTo(m,x):g.lineTo(m,x)}),g.closePath(),g.fill())}),wi(A).pcb_cutout.list().forEach(f=>{switch(f.shape){case"rect":{const D=I(f.center.x),b=c(f.center.y),m=f.width*o,x=f.height*o,F=Ch(f),k=ay(f.width,f.height,F);if(f.rotation){g.save(),g.translate(D,b);const v=-f.rotation*(Math.PI/180);g.rotate(v),k>0?(g.beginPath(),g.roundRect(-m/2,-x/2,m,x,k*o),g.fill()):g.fillRect(-m/2,-x/2,m,x),g.restore()}else k>0?(g.beginPath(),g.roundRect(D-m/2,b-x/2,m,x,k*o),g.fill()):g.fillRect(D-m/2,b-x/2,m,x);break}case"circle":{const D=I(f.center.x),b=c(f.center.y),m=f.radius*o;g.beginPath(),g.arc(D,b,m,0,2*Math.PI),g.fill();break}case"polygon":{if(!f.points||f.points.length<3){console.warn(`PCB Cutout [${f.pcb_cutout_id}] polygon has fewer than 3 points, skipping in soldermask texture.`);break}g.beginPath(),f.points.forEach((D,b)=>{const m=I(D.x),x=c(D.y);b===0?g.moveTo(m,x):g.lineTo(m,x)}),g.closePath(),g.fill();break}default:console.warn(`Unsupported cutout shape: ${f.shape} for cutout ${f.pcb_cutout_id} in soldermask texture.`)}}),g.globalCompositeOperation="source-over";const d=new tN(s);return d.generateMipmaps=!0,d.minFilter=Qu,d.magFilter=WB,d.anisotropy=16,d.needsUpdate=!0,d}var Vht=yr(ABA());function dZA(t,A){return Array.isArray(A)?[t.a*A[0]+t.c*A[1]+t.e,t.b*A[0]+t.d*A[1]+t.f]:{x:t.a*A.x+t.c*A.y+t.e,y:t.b*A.x+t.d*A.y+t.f}}function fx(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function pZA(...t){t=Array.isArray(t[0])?t[0]:t;const A=(e,i)=>({a:e.a*i.a+e.c*i.b,c:e.a*i.c+e.c*i.d,e:e.a*i.e+e.c*i.f+e.e,b:e.b*i.a+e.d*i.b,d:e.b*i.c+e.d*i.d,f:e.b*i.e+e.d*i.f+e.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return A(t[0],t[1]);default:{const[e,i,...o]=t,n=A(e,i);return pZA(n,...o)}}}function fZA(...t){return pZA(...t)}var{cos:jht,sin:zht}=Math;function yZA(t,A,e){const i=jht(t),o=zht(t);return{a:i,c:-o,e:0,b:o,d:i,f:0}}function Xht(t,A){function e(){this.constructor=t}e.prototype=A.prototype,t.prototype=new e}function ZO(t,A,e,i){var o=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(o,ZO.prototype),o.expected=A,o.found=e,o.location=i,o.name="SyntaxError",o}Xht(ZO,Error);function jBA(t,A,e){return e=e||" ",t.length>A?t:(A-=t.length,e+=e.repeat(A),t+e.slice(0,A))}ZO.prototype.format=function(t){var A="Error: "+this.message;if(this.location){var e=null,i;for(i=0;i<t.length;i++)if(t[i].source===this.location.source){e=t[i].text.split(/\r\n|\n|\r/g);break}var o=this.location.start,n=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(o):o,s=this.location.source+":"+n.line+":"+n.column;if(e){var r=this.location.end,a=jBA("",n.line.toString().length," "),g=e[o.line-1],I=o.line===r.line?r.column:g.length+1,c=I-o.column||1;A+=`
|
|
5096
|
+
`,cht=({rotation:t,infiniteGrid:A,cellSize:e=1,sectionSize:i=10})=>{const{scene:o,camera:n}=fu(),s=1e3,r=AA.useMemo(()=>{const a=new iw(s,s);a.rotateX(-Math.PI/2);const g=new Zw({vertexShader:ght,fragmentShader:Iht,uniforms:{cellSize:{value:e},sectionSize:{value:i},gridColor:{value:new Ui(15658734)},sectionColor:{value:new Ui(13421823)},fadeDistance:{value:100},fadeStrength:{value:1.5}},transparent:!0,side:UC}),I=new Oo(a,g);return t&&I.rotation.fromArray(t),I},[s,e,i,t]);return kU(()=>{A&&r.position.set(n.position.x,n.position.y,0)}),AA.useEffect(()=>{if(!(!o||!r))return o.add(r),()=>{o.remove(r),r.geometry.dispose(),Array.isArray(r.material)?r.material.forEach(a=>a.dispose()):r.material.dispose()}},[o,r]),null},Bht=()=>{const{scene:t}=fu(),A=AA.useMemo(()=>new RbA(16777215,Math.PI/2),[]),e=AA.useMemo(()=>{const i=new fz(16777215,Math.PI/4);return i.position.set(-10,-10,10),i.decay=0,i},[]);return AA.useEffect(()=>{if(t)return t.add(A),t.add(e),()=>{t.remove(A),t.remove(e)}},[t,A,e]),null},Cht=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,lht=()=>{const{controlsRef:t,mainCameraRef:A,defaultTarget:e,setController:i,getPresetConfig:o}=dx(),n=AA.useRef(null),s=AA.useRef(new Cd),r=AA.useRef(new Re),a=AA.useRef(new Re),g=AA.useRef(new Cd),I=AA.useRef(new Cd),c=AA.useRef(new Bg),B=AA.useRef(new Bg),C=AA.useCallback(({position:Q,target:E,up:h,durationMs:u=600})=>{if(!A.current)return;const d=t.current?.target??e,f=new Re(Q[0],Q[1],Q[2]),D=E?new Re(E[0],E[1],E[2]):e.clone(),b=new Re(...h??[0,0,1]).normalize(),m=B.current;m.position.copy(f),m.up.copy(b),m.lookAt(D);const x=m.quaternion.clone(),F=A.current.quaternion.clone(),k=A.current.position.clone(),v=d.clone(),_=c.current;_.up.set(0,0,1),_.position.copy(k),_.lookAt(v);const Y=_.quaternion.clone();_.up.set(0,0,1),_.position.copy(f),_.lookAt(D);const P=_.quaternion.clone(),K=Y.clone().invert().multiply(F).normalize(),O=P.clone().invert().multiply(x).normalize();n.current={fromPosition:k,toPosition:f,fromTarget:v,toTarget:D,toQuaternion:x,rollFrom:K,rollTo:O,startTime:performance.now(),duration:u}},[A,t,e]),l=AA.useCallback(Q=>{if(Q==="Custom")return;const E=o(Q);E&&C(E)},[C,o]);return AA.useEffect(()=>A.current?(i({animateTo:C,animateToPreset:l}),()=>{i(null)}):void 0,[C,l,A,i]),kU(()=>{if(!A.current||!n.current)return;const{fromPosition:Q,toPosition:E,fromTarget:h,toTarget:u,toQuaternion:d,rollFrom:f,rollTo:D,startTime:b,duration:m}=n.current,x=performance.now()-b,F=m<=0?1:Math.min(x/m,1),k=Cht(F);A.current.position.lerpVectors(Q,E,k);const v=r.current;v.copy(h).lerp(u,k);const _=c.current;_.up.set(0,0,1),_.position.copy(A.current.position),_.lookAt(v);const Y=s.current;Y.copy(_.quaternion);const P=g.current;P.copy(f);const K=I.current;K.copy(D),f.dot(D)<0&&(K.x*=-1,K.y*=-1,K.z*=-1,K.w*=-1),K.normalize(),P.slerp(K,k),A.current.quaternion.copy(Y).multiply(P).normalize();const O=a.current;O.set(0,1,0).applyQuaternion(A.current.quaternion).normalize(),A.current.up.copy(O),t.current?.target.copy(v),A.current.updateMatrixWorld(),t.current?.update(),F>=1&&(A.current.position.copy(E),A.current.quaternion.copy(d),A.current.up.set(0,0,1),A.current.updateMatrixWorld(),t.current?.target.copy(u),t.current?.update(),n.current=null)}),null},Qht=()=>{const{controlsRef:t}=dx(),A=AA.useRef(null),e=AA.useRef(!1),i=AA.useRef(null),o=AA.useCallback(s=>{A.current=s,!e.current&&t.current&&TBA(s,t.current)&&(e.current=!0)},[t]),n=AA.useCallback(()=>{if(!(!A.current||!t.current)){if(!e.current&&TBA(A.current,t.current)){e.current=!0;return}clearTimeout(i.current),i.current=setTimeout(()=>{A.current&&t.current&&nZA(A.current,t.current)},150)}},[t]);return{handleCameraCreated:o,handleControlsChange:n}};function Eht(t,A){const e=new Cd().setFromEuler(new Fp(t.x,t.y,t.z)),i=new Re(0,0,1);return i.applyQuaternion(e),i.multiplyScalar(A)}var hht=()=>{const{mainCameraRef:t}=dx(),A=AA.useRef(null),e=AA.useRef(null),i=AA.useRef(null),o=AA.useRef(null),n=AA.useRef(null),s=AA.useRef(null);return AA.useEffect(()=>{if(!A.current)return;const r=document.createElement("canvas");e.current=r,A.current.appendChild(r);const a=new SK({canvas:r,antialias:!0,alpha:!0});a.setSize(120,120),a.setPixelRatio(window.devicePixelRatio),i.current=a;const g=new $k;o.current=g;const I=new tE(75,1,.1,1e3);I.up.set(0,0,1),n.current=I;const c=new RbA(16777215,Math.PI/2);g.add(c);const B=new Np;B.rotation.fromArray([Math.PI/2,0,0]);const C=1,l=new Oo(new tw(C,C,C),new ih({color:"white"}));B.add(l);const Q=new M1(new fwe(new tw(C,C,C)),new AG({color:0,linewidth:2}));B.add(Q),g.add(B);const E=.51,h=(F,k,v)=>{const _=new LX;return _.text=F,_.position.fromArray(k),v&&_.rotation.fromArray(v),_.color="black",_.fontSize=.25,_.anchorX="center",_.anchorY="middle",_.depthOffset=0,_.font=null,_.sync(),_},u=h("Front",[0,0,E]),d=h("Back",[0,0,-E],[0,Math.PI,0]),f=h("Right",[E,0,0],[0,Math.PI/2,0]),D=h("Left",[-E,0,0],[0,-Math.PI/2,0]),b=h("Top",[0,E,0],[-Math.PI/2,0,0]),m=h("Bottom",[0,-E,0],[Math.PI/2,0,0]);B.add(u),B.add(d),B.add(f),B.add(D),B.add(b),B.add(m);const x=()=>{if(t.current){const F=Eht(t.current.rotation??new Fp(0,0,0),2);F.equals(I.position)||(I.position.copy(F),I.lookAt(0,0,0))}a.render(g,I),s.current=requestAnimationFrame(x)};return x(),()=>{s.current&&cancelAnimationFrame(s.current),u.dispose(),d.dispose(),f.dispose(),D.dispose(),b.dispose(),m.dispose(),l.geometry.dispose(),l.material.dispose(),Q.geometry.dispose(),Q.material.dispose(),g.clear(),a.dispose(),e.current&&A.current&&A.current.removeChild(e.current)}},[t]),V.jsx("div",{ref:A,style:{position:"absolute",top:0,left:0,width:120,height:120,zIndex:TU.orientationCube}})},uht=()=>{const{camera:t}=fu(),{setCameraRotation:A}=dx();return kU(()=>{t&&A(t.rotation)}),null},rZA=AA.forwardRef(({children:t,initialCameraPosition:A=[5,-5,5],autoRotateDisabled:e,clickToInteractEnabled:i=!1,boardDimensions:o,boardCenter:n,onUserInteraction:s,onCameraControllerReady:r},a)=>{const[g,I]=AA.useState(!i),{mainCameraRef:c,handleControlsChange:B,controller:C}=dx(),{handleCameraCreated:l,handleControlsChange:Q}=Qht();AA.useEffect(()=>{r&&r(C)},[C,r]);const E=AA.useMemo(()=>{if(!o)return 10;const u=o.width??0,d=o.height??0,D=Math.max(u,d)*1.5;return D>10?D:10},[o]),h=AA.useMemo(()=>{if(n)return[n.x,n.y,0]},[n]);return V.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[V.jsx(hht,{}),V.jsxs(rht,{ref:a,scene:{up:new Re(0,0,1)},camera:{up:[0,0,1],position:A},onCreated:({camera:u})=>{c.current=u,l(u)},children:[V.jsx(lht,{}),V.jsx(uht,{}),g&&V.jsx(aht,{autoRotate:!e,autoRotateSpeed:1,onStart:s,rotateSpeed:.5,panSpeed:.75,zoomSpeed:.5,enableDamping:!0,dampingFactor:.1,target:h,onControlsChange:u=>{B(u),Q()}}),V.jsx(Bht,{}),V.jsx(cht,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:3,sectionSize:E,args:[E,E]}),t]}),V.jsxs("div",{style:{position:"absolute",right:24,bottom:24,fontFamily:"sans-serif",color:"white",WebkitTextStroke:"0.5px rgba(0, 0, 0, 0.5)",fontSize:11},children:["@",iZA.version]}),i&&!g&&V.jsx("button",{type:"button",onClick:()=>I(!0),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&I(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:TU.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center"},children:V.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",fontFamily:"sans-serif",pointerEvents:"none"},children:"Click to Interact"})})]})}),aZA=t=>AA.useMemo(()=>{if(!t)return[];const A=new jze;return A.add(t),A.render(),A.getCircuitJson()},[t]),dht=t=>{const[A,e]=AA.useState([]),[i,o]=AA.useState(!0);return AA.useEffect(()=>{if(!t)return;(async()=>{o(!0);const r=(Array.isArray(t)?t:[t]).map(async(a,g)=>{const I=ZAt.serialize({binary:!0},[a]),B=await new Blob(I).arrayBuffer(),l=a.layerType||(g===0?"board":void 0);return{stlData:B,color:a.color,layerType:l}});try{const a=await Promise.all(r);e(a)}catch(a){console.error("Error generating STLs:",a),e([])}finally{o(!1)}})()},[t]),{stls:A,loading:i}},pht=yr(Ex()),fht=yr(uO()),Wo=.01,rI={traces:.001,copper:.002},No={copper:[.9,.6,.2],fr4Tan:[.6,.43,.28],fr4SolderMaskGreen:[.02,.1,.04],fr4TracesWithMaskGreen:[0,.5,.25],fr4TracesWithoutMaskTan:[.6,.43,.28],fr1Tan:[.8,.4,.2],fr1TracesWithMaskCopper:[.9,.6,.2],fr1SolderMaskGreen:[.02,.1,.04]},ry=.001,wl=32,HO=.035,lc=150,YO=.6,qBA={fr1:No.fr1Tan,fr4:No.fr4Tan},yht={fr1:No.fr1TracesWithMaskCopper,fr4:No.fr4TracesWithoutMaskTan},gZA={fr1:No.fr1SolderMaskGreen,fr4:No.fr4SolderMaskGreen},wht=yr(xU()),mht=yr(Ex()),Dht=yr(HG()),Sht=yr(rBA()),PBA=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1]}return A/2<=0},OBA=(t,A=1.2,e={})=>{const{xyOutset:i=0}=e,{outline:o}=t;let n=o.map(a=>[a.x,a.y]);PBA(n)&&(n=n.reverse());let s=(0,mht.polygon)({points:n});i!==0&&(s=(0,Sht.expand)({delta:i,corners:"edge"},s));let r=(0,wht.extrudeLinear)({height:A},s);return r=(0,Dht.translate)([0,0,-A/2],r),r},bht=t=>{const A=t.filter(a=>a.type==="pcb_panel"),e=wi(t).pcb_board.list();let i,o=1.2;if(A.length>0)i=A[0],o=e.find(g=>g.pcb_panel_id===i.pcb_panel_id)?.thickness??1.2;else{if(i=e.filter(g=>!g.pcb_panel_id)[0],!i)return console.warn("No pcb_board or pcb_panel found for simplified geometry"),[];o=i.thickness??1.2}let n;"outline"in i&&i.outline&&i.outline.length>0?n=OBA({outline:i.outline},o):n=(0,pht.cuboid)({size:[i.width??10,i.height??10,o],center:[i.center.x,i.center.y,0]});const s="material"in i&&i.material?i.material:A.length>0?e.find(a=>a.pcb_panel_id===i.pcb_panel_id)?.material??"fr4":"fr4",r=qBA[s]??No.fr4Tan;return[(0,fht.colorize)(r,n)]},yu=yr(HG()),aI=yr(Ex()),wu=yr(uO()),gI=yr(x_()),Ug=yr(Ex()),sS=yr(uO()),HI=yr(x_()),IZA=yr(HG()),JO=yr(xU()),rS=yr(HG());function ay(t,A,e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return 0;const i=t/2,o=A/2;return Math.max(0,Math.min(e,i,o))}function Ch(t){if(!(!t||typeof t!="object"))return t.corner_radius??t.cornerRadius??t.rect_pad_border_radius??t.rectPadBorderRadius??t.rect_border_radius??t.rectBorderRadius??void 0}var px=yr(Ex()),xht=yr(xU()),KO=yr(HG()),kht=yr(x_()),Ght=64,Fht=(t,A,e)=>{const i=(0,px.ellipse)({center:[0,0],radius:[Math.max(t/2,Wo/2),Math.max(A/2,Wo/2)],segments:Ght}),o=(0,xht.extrudeLinear)({height:e},i);return(0,KO.translate)([0,0,-e/2],o)},Rht=(t,A,e)=>{const i=Math.max(t,Wo),o=Math.max(A,Wo);if(Math.abs(i-o)<1e-6)return(0,px.cylinder)({center:[0,0,0],radius:i/2,height:e});const n=i>=o,s=n?i:o,r=n?o:i,a=Math.max(s-r,0),g=(0,px.cuboid)({center:[0,0,0],size:n?[a,r,e]:[r,a,e]});if(a<=1e-6)return(0,px.cylinder)({center:[0,0,0],radius:r/2,height:e});const I=a/2,c=(0,px.cylinder)({center:n?[-I,0,0]:[0,-I,0],radius:r/2,height:e}),B=(0,px.cylinder)({center:n?[I,0,0]:[0,I,0],radius:r/2,height:e});return(0,kht.union)(g,c,B)},TO=(t,A,e={})=>{const i=t.hole_shape||"circle",o=e.sizeDelta??0,n=t.hole_offset_x||0,s=t.hole_offset_y||0,r=[t.x+n,t.y+s,0];if(i==="circle"){const C=Math.max((t.hole_diameter??0)+o,Wo),l=Math.max(C/2,Wo/2);return(0,px.cylinder)({center:r,radius:l,height:A})}const a=t.hole_width??t.hole_diameter,g=t.hole_height??t.hole_diameter;if(!a||!g)return null;const I=Math.max(a+o,Wo),c=Math.max(g+o,Wo);if(i==="oval"){const C=Fht(I,c,A);return(0,KO.translate)([r[0],r[1],0],C)}if(i==="pill"||i==="rotated_pill"){let C=Rht(I,c,A);if(!C)return null;const l=t.ccw_rotation||0;return l&&(C=(0,KO.rotateZ)(l*Math.PI/180,C)),(0,KO.translate)(r,C)}const B=Math.max((t.hole_diameter??a??g??Wo)+o,Wo);return(0,px.cylinder)({center:r,radius:B/2,height:A})},fm=.02,WBA=64,q_=(t,A)=>A?(0,HI.intersect)(A,t):t,qO=({width:t,height:A,thickness:e,center:i,borderRadius:o})=>{const n=ay(t,A,o);if(n<=0)return(0,Ug.cuboid)({center:i,size:[t,A,e]});const s=(0,Ug.roundedRectangle)({size:[t,A],roundRadius:n,segments:WBA}),r=(0,JO.extrudeLinear)({height:e},s),a=i[2]-e/2;return(0,rS.translate)([i[0],i[1],a],r)},PO=(t,A,e={})=>{const{clipGeom:i}=e;t.shape||(t.shape="circle");const o=A.pcbThickness+2*fm+4*Wo,n=A.pcbThickness/2+rI.copper,s=-A.pcbThickness/2-rI.copper,r=n-s;if(t.shape==="circle"){const a=t.outer_diameter??Math.max(t.hole_diameter,0),g=r+.01,I=(0,Ug.cylinder)({center:[t.x,t.y,0],radius:a/2,height:g}),c=q_(I,i),B=(0,Ug.cylinder)({center:[t.x,t.y,0],radius:Math.max(t.hole_diameter/2,.01),height:o});return(0,sS.colorize)(No.copper,(0,HI.subtract)(c,B))}if(t.shape==="oval"){const a=t.outer_width||t.hole_width||0,g=t.outer_height||t.hole_height||0,I=t.hole_width||0,c=t.hole_height||0,B=(()=>{const Q=(0,Ug.cylinder)({center:[0,0,0],radius:1,height:r+.01,segments:64}),E=(0,IZA.scale)([a/2,g/2,1],Q);return(0,rS.translate)([t.x,t.y,0],E)})(),C=q_(B,i),l=(()=>{const Q=(0,Ug.cylinder)({center:[0,0,0],radius:1,height:o,segments:64}),E=(0,IZA.scale)([Math.max(I/2,.01),Math.max(c/2,.01),1],Q);return(0,rS.translate)([t.x,t.y,0],E)})();return(0,sS.colorize)(No.copper,(0,HI.subtract)(C,l))}if(t.shape==="circular_hole_with_rect_pad"){const a=t.hole_offset_x||0,g=t.hole_offset_y||0,I=t.rect_pad_width||t.hole_diameter,c=t.rect_pad_height||t.hole_diameter,B=Ch(t),C=q_((0,HI.union)(qO({width:I,height:c,thickness:fm,center:[t.x,t.y,n],borderRadius:B}),qO({width:I,height:c,thickness:fm,center:[t.x,t.y,s],borderRadius:B}),(()=>{const h=Math.max(r-fm*2,Wo),f=(n+s)/2,D=(0,Ug.roundedRectangle)({size:[I,c],roundRadius:B||0,segments:WBA}),b=(0,JO.extrudeLinear)({height:h},D);return(0,rS.translate)([t.x,t.y,f-h/2],b)})(),(0,Ug.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:t.hole_diameter/2,height:r})),i),l=(0,Ug.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:Math.max(t.hole_diameter/2-Wo,.01),height:o}),Q=(0,Ug.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:t.hole_diameter/2,height:r});let E=(0,HI.union)((0,HI.subtract)(C,Q),Q);return e.clipGeom?(E=(0,HI.subtract)(E,l),E=(0,HI.intersect)(E,e.clipGeom),(0,sS.colorize)(No.copper,E)):(0,sS.colorize)(No.copper,(0,HI.subtract)(E,l))}if(t.shape==="pill"){const a=(t.ccw_rotation||0)*Math.PI/180,g=k=>{if(!a)return k;const v=(0,rS.translate)([-t.x,-t.y,0],k),_=(0,rS.rotate)([0,0,a],v);return(0,rS.translate)([t.x,t.y,0],_)},I=t.hole_height>t.hole_width,c=I?t.hole_height:t.hole_width,B=I?t.hole_width:t.hole_height,C=I?t.outer_height||B+.2:t.outer_width||c+.2,l=I?t.outer_width||c+.2:t.outer_height||B+.2,Q=B/2,E=Math.abs(c-B),h=r+.01,d=((k,v,_)=>{const Y=v/2,P=Math.abs(k-v);if(P<=1e-6)return(0,Ug.cylinder)({center:[t.x,t.y,0],radius:Y,height:_});const K=(0,Ug.cuboid)({center:[t.x,t.y,0],size:I?[v,P,_]:[P,v,_]}),O=(0,Ug.cylinder)({center:I?[t.x,t.y-P/2,0]:[t.x-P/2,t.y,0],radius:Y,height:_}),W=(0,Ug.cylinder)({center:I?[t.x,t.y+P/2,0]:[t.x+P/2,t.y,0],radius:Y,height:_});return(0,HI.union)(K,O,W)})(C,l,h),f=(0,Ug.cuboid)({center:[t.x,t.y,0],size:I?[B-2*Wo,E,o]:[E,B-2*Wo,o]}),D=(0,Ug.cylinder)({center:I?[t.x,t.y-E/2,0]:[t.x-E/2,t.y,0],radius:Q-Wo,height:o}),b=(0,Ug.cylinder)({center:I?[t.x,t.y+E/2,0]:[t.x+E/2,t.y,0],radius:Q-Wo,height:o}),m=(0,HI.union)(f,D,b),x=q_(g(d),i),F=g(m);return(0,sS.colorize)(No.copper,(0,HI.subtract)(x,F))}if(t.shape==="pill_hole_with_rect_pad"){const a=t.hole_offset_x||0,g=t.hole_offset_y||0,I=t.hole_height>t.hole_width,c=I?t.hole_height:t.hole_width,B=I?t.hole_width:t.hole_height,C=B/2,l=Math.abs(c-B),Q=t.rect_pad_width||c+.2,E=t.rect_pad_height||B+.2,h=Ch(t),u=.03,d=(0,HI.union)((0,Ug.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B+2*u,l+2*u,r]:[l+2*u,B+2*u,r]}),(0,Ug.cylinder)({center:I?[t.x+a,t.y+g-l/2,0]:[t.x+a-l/2,t.y+g,0],radius:C+u,height:r}),(0,Ug.cylinder)({center:I?[t.x+a,t.y+g+l/2,0]:[t.x+a+l/2,t.y+g,0],radius:C+u,height:r})),f=(0,HI.union)((0,Ug.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B,l,o*1.1]:[l,B,o*1.1]}),(0,Ug.cylinder)({center:I?[t.x+a,t.y+g-l/2,0]:[t.x+a-l/2,t.y+g,0],radius:C,height:o*1.1}),(0,Ug.cylinder)({center:I?[t.x+a,t.y+g+l/2,0]:[t.x+a+l/2,t.y+g,0],radius:C,height:o*1.1})),D=qO({width:Q,height:E,thickness:fm,center:[t.x,t.y,n],borderRadius:h}),b=qO({width:Q,height:E,thickness:fm,center:[t.x,t.y,s],borderRadius:h}),m=(()=>{const P=Math.max(r-fm*2,Wo),W=(n+s)/2,$=(0,Ug.roundedRectangle)({size:[Q,E],roundRadius:h||0,segments:WBA}),oA=(0,JO.extrudeLinear)({height:P},$);return(0,rS.translate)([t.x,t.y,W-P/2],oA)})(),x=(0,HI.subtract)(D,f),F=(0,HI.subtract)(b,f),k=(0,HI.subtract)(m,f),v=(0,HI.union)((0,Ug.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B-2*Wo,l-2*Wo,o*1.1]:[l-2*Wo,B-2*Wo,o*1.1]}),(0,Ug.cylinder)({center:I?[t.x+a,t.y+g-l/2,0]:[t.x+a-l/2,t.y+g,0],radius:C-Wo,height:o*1.1}),(0,Ug.cylinder)({center:I?[t.x+a,t.y+g+l/2,0]:[t.x+a+l/2,t.y+g,0],radius:C-Wo,height:o*1.1})),_=(0,HI.subtract)(d,v),Y=q_((0,HI.union)(x,F,k,_),i);return(0,sS.colorize)(No.copper,Y)}else if(t.shape==="hole_with_polygon_pad"){const a=t.pad_outline;if(!Array.isArray(a)||a.length<3)throw new Error(`Invalid pad_outline for plated hole at (${t.x}, ${t.y})`);const g=a.map(f=>[f.x,f.y]),I=(0,Ug.polygon)({points:g}),c=(n+s)/2,B=(f,D)=>{const b=Math.max(f,Wo),m=(0,JO.extrudeLinear)({height:b},I);return(0,rS.translate)([t.x,t.y,D-b/2],m)},C=B(Math.max(r-fm*2,Wo),c),l=B(fm,n),Q=B(fm,s),E=q_((0,HI.union)(C,l,Q),i),h=TO(t,r);if(!h)return(0,sS.colorize)(No.copper,E);const u=TO(t,o,{sizeDelta:-2*Wo})||h;let d=(0,HI.union)((0,HI.subtract)(E,h),h);return e.clipGeom?(d=(0,HI.subtract)(d,u),d=(0,HI.intersect)(d,e.clipGeom),(0,sS.colorize)(No.copper,d)):(0,sS.colorize)(No.copper,(0,HI.subtract)(d,u))}else throw new Error(`Unsupported plated hole shape: ${t.shape}`)},qU=yr(xU()),Nht=yr(rBA()),cZA=yr(Ex()),_ht=yr(x_());function Mht(t,A,e,i){if(!e||Math.abs(e)<1e-9)return[];const o=4*Math.atan(e),n=A[0]-t[0],s=A[1]-t[1],r=Math.sqrt(n*n+s*s);if(r<1e-9)return[];const a=Math.abs(r/(2*Math.sin(o/2))),g=Math.sqrt(Math.max(0,a*a-r/2*(r/2))),I=[(t[0]+A[0])/2,(t[1]+A[1])/2],c=n/r,C=-(s/r),l=c,Q=I[0]+C*g*Math.sign(e),E=I[1]+l*g*Math.sign(e),h=Math.atan2(t[1]-E,t[0]-Q),u=[],d=Math.max(2,Math.ceil(i*Math.abs(o)/(Math.PI*2)*4)),f=o/d;for(let D=1;D<d;D++){const b=h+f*D;u.push([Q+a*Math.cos(b),E+a*Math.sin(b)])}return u}function OO(t,A){const e=[],i=t.vertices;for(let o=0;o<i.length;o++){const n=i[o],s=i[(o+1)%i.length];if(e.push([n.x,n.y]),n.bulge){const r=Mht([n.x,n.y],[s.x,s.y],n.bulge,A);e.push(...r)}}return e}function BZA(t){let A=0;for(let e=0;e<t.length;e++){const i=(e+1)%t.length;A+=t[e][0]*t[i][1],A-=t[i][0]*t[e][1]}return A/2<=0}function vht(t,A=16){let e=OO(t.outer_ring,A);BZA(e)&&e.reverse();const i=(0,cZA.polygon)({points:e});if(!t.inner_rings||t.inner_rings.length===0)return i;const o=t.inner_rings.map(n=>{let s=OO(n,A);return BZA(s)&&s.reverse(),(0,cZA.polygon)({points:s})});return o.length===0?i:(0,_ht.subtract)(i,o)}var CZA=yr(x_()),Uht=yr(HG()),PU=yr(Ex());function Lht({x:t,y:A,outerDiameter:e,holeDiameter:i,thickness:o}){if(e<=i)throw new Error(`Invalid via geometry: outerDiameter (${e}) must be > holeDiameter (${i})`);const n=Wo,s=Wo,r=Math.min(e/2,i/2+s),a=(0,PU.cylinder)({center:[0,0,0],radius:r,height:o,segments:wl}),g=(0,PU.cylinder)({center:[0,0,o/2],radius:e/2,height:n,segments:wl}),I=(0,PU.cylinder)({center:[0,0,-o/2],radius:e/2,height:n,segments:wl}),c=(0,CZA.union)([a,g,I]),B=o+n*2,C=(0,PU.cylinder)({center:[0,0,0],radius:i/2,height:B,segments:wl}),l=(0,CZA.subtract)(c,C);return(0,Uht.translate)([t,A,0],l)}function Hht({x:t,y:A,holeDiameter:e,thickness:i}){const o=i*1.5,n=e/2+Wo;return(0,PU.cylinder)({center:[t,A,0],radius:n,height:o,segments:wl})}var lZA=64,Yht=1,ZBA=.05,QZA=(t,A,e,i)=>{const o=ay(t,A,i);if(o<=0)return(0,aI.cuboid)({center:[0,0,0],size:[t,A,e]});const n=(0,aI.roundedRectangle)({size:[t,A],roundRadius:o,segments:lZA}),s=(0,qU.extrudeLinear)({height:e},n);return(0,yu.translate)([0,0,-e/2],s)},EZA=["initializing","processing_pads","processing_copper_pours","processing_plated_holes","processing_holes","processing_cutouts","processing_vias","finalizing","done"],Jht=class{circuitJson;board;plated_holes;holes;pads;traces;pcb_vias;pcb_cutouts;pcb_copper_pours;boardGeom=null;platedHoleGeoms=[];padGeoms=[];viaGeoms=[];copperPourGeoms=[];boardClipGeom=null;state="initializing";currentIndex=0;ctx;onCompleteCallback;finalGeoms=[];getHoleToCut(t,A){const e=Wo/10;for(const i of this.pcb_vias)if(Math.abs(i.x-t)<e&&Math.abs(i.y-A)<e&&i.hole_diameter)return{diameter:i.hole_diameter};for(const i of this.plated_holes)if(i.shape==="circle"&&Math.abs(i.x-t)<e&&Math.abs(i.y-A)<e&&i.hole_diameter)return{diameter:i.hole_diameter};return null}constructor(t,A){this.circuitJson=t,this.onCompleteCallback=A;const e=t.filter(o=>o.type==="pcb_panel"),i=wi(t).pcb_board.list();if(e.length>0){const o=e[0],n=i.find(s=>s.pcb_panel_id===o.pcb_panel_id);this.board={type:"pcb_board",pcb_board_id:o.pcb_panel_id,center:o.center,width:o.width,height:o.height,thickness:n?.thickness??1.6,material:n?.material??"fr4",num_layers:n?.num_layers??2}}else{const o=i.filter(n=>!n.pcb_panel_id);this.board=o[0]}this.plated_holes=wi(t).pcb_plated_hole.list(),this.holes=wi(t).pcb_hole.list(),this.pads=wi(t).pcb_smtpad.list(),this.traces=wi(t).pcb_trace.list(),this.pcb_vias=wi(t).pcb_via.list(),this.pcb_cutouts=wi(t).pcb_cutout.list(),this.pcb_copper_pours=t.filter(o=>o.type==="pcb_copper_pour"),this.ctx={pcbThickness:this.board.thickness??1.2},this.initializeBoard()}initializeBoard(){const t=this.ctx.pcbThickness+2*Yht;this.board.outline&&this.board.outline.length>0?(this.boardGeom=OBA({outline:this.board.outline},this.ctx.pcbThickness),this.boardClipGeom=OBA({outline:this.board.outline},t,{xyOutset:ZBA})):(this.boardGeom=(0,aI.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.boardClipGeom=(0,aI.cuboid)({size:[this.board.width+2*ZBA,this.board.height+2*ZBA,t],center:[this.board.center.x,this.board.center.y,0]})),this.state="processing_pads",this.currentIndex=0}goToNextState(){const t=EZA.indexOf(this.state);t!==-1&&(this.state=EZA[t+1],this.currentIndex=0)}step(t=1){if(this.state==="done"||!this.boardGeom)return!0;for(let A=0;A<t&&this.state!=="done";A++)switch(this.state){case"processing_plated_holes":this.currentIndex<this.plated_holes.length?(this.processPlatedHole(this.plated_holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_holes":this.currentIndex<this.holes.length?(this.processHole(this.holes[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_pads":this.currentIndex<this.pads.length?(this.processPad(this.pads[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_vias":this.currentIndex<this.pcb_vias.length?(this.processVia(this.pcb_vias[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_cutouts":this.currentIndex<this.pcb_cutouts.length?(this.processCutout(this.pcb_cutouts[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"processing_copper_pours":this.currentIndex<this.pcb_copper_pours.length?(this.processCopperPour(this.pcb_copper_pours[this.currentIndex]),this.currentIndex++):this.goToNextState();break;case"finalizing":this.finalize(),this.state="done";break}return this.state==="done"}processCutout(t){if(!this.boardGeom)return;let A=null;const e=this.ctx.pcbThickness*1.5;switch(t.shape){case"rect":{const i=ay(t.width,t.height,Ch(t));if(i>0){const o=(0,aI.roundedRectangle)({size:[t.width,t.height],roundRadius:i,segments:lZA});A=(0,qU.extrudeLinear)({height:e},o),A=(0,yu.translate)([0,0,-e/2],A)}else A=(0,aI.cuboid)({center:[0,0,0],size:[t.width,t.height,e]});if(t.rotation){const o=t.rotation*Math.PI/180;A=(0,yu.rotateZ)(o,A)}A=(0,yu.translate)([t.center.x,t.center.y,0],A);break}case"circle":A=(0,aI.cylinder)({center:[t.center.x,t.center.y,0],radius:t.radius,height:e});break;case"polygon":{let i=t.points.map(n=>[n.x,n.y]);if(i.length<3){console.warn(`PCB Cutout [${t.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}PBA(i)&&(i=i.reverse());const o=(0,aI.polygon)({points:i});A=(0,qU.extrudeLinear)({height:e},o),A=(0,yu.translate)([0,0,-e/2],A);break}}A&&(this.boardGeom=(0,gI.subtract)(this.boardGeom,A))}processCopperPour(t){const A=t.layer==="bottom"?-1:1,e=A*this.ctx.pcbThickness/2+A*rI.copper;let i=null;if(t.shape==="rect"){let o=(0,aI.cuboid)({center:[0,0,0],size:[t.width,t.height,Wo]});if("rotation"in t&&t.rotation){const n=t.rotation*Math.PI/180;o=(0,yu.rotateZ)(n,o)}i=(0,yu.translate)([t.center.x,t.center.y,e],o)}else if(t.shape==="brep"){const o=t.brep_shape;if(o?.outer_ring){const n=vht(o);i=(0,qU.extrudeLinear)({height:Wo},n),i=(0,yu.translate)([0,0,e],i)}}else if(t.shape==="polygon"){let o=t.points.map(s=>[s.x,s.y]);if(o.length<3){console.warn(`PCB Copper Pour [${t.pcb_copper_pour_id}] polygon has fewer than 3 points, skipping.`);return}PBA(o)&&(o=o.reverse());const n=(0,aI.polygon)({points:o});i=(0,qU.extrudeLinear)({height:Wo},n),i=(0,yu.translate)([0,0,e],i)}if(i){this.boardClipGeom&&(i=(0,gI.intersect)(this.boardClipGeom,i));const n=t.covered_with_solder_mask!==!1?yht[this.board.material]??No.fr4TracesWithoutMaskTan:No.copper,s=(0,wu.colorize)(n,i);this.copperPourGeoms.push(s)}}processPlatedHole(t,A={}){if(this.boardGeom){if(t.shape==="circle"||t.shape==="circular_hole_with_rect_pad"){let e=null;t.shape==="circular_hole_with_rect_pad"?e=(0,aI.cylinder)({center:[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0),0],radius:t.hole_diameter/2+Wo,height:this.ctx.pcbThickness*1.5}):e=(0,aI.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+Wo,height:this.ctx.pcbThickness*1.5}),A.dontCutBoard||(this.boardGeom=(0,gI.subtract)(this.boardGeom,e)),this.padGeoms=this.padGeoms.map(o=>(0,wu.colorize)(No.copper,(0,gI.subtract)(o,e)));const i=PO(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(i)}else if(t.shape==="pill"||t.shape==="oval"){const e=t.hole_height>t.hole_width,i=e?t.hole_height:t.hole_width,o=e?t.hole_width:t.hole_height,n=o/2,s=Math.abs(i-o);let r;if(r=(0,gI.union)((0,aI.cuboid)({center:[t.x,t.y,0],size:e?[o,s,this.ctx.pcbThickness*1.5]:[s,o,this.ctx.pcbThickness*1.5]}),(0,aI.cylinder)({center:e?[t.x,t.y-s/2,0]:[t.x-s/2,t.y,0],radius:n,height:this.ctx.pcbThickness*1.5}),(0,aI.cylinder)({center:e?[t.x,t.y+s/2,0]:[t.x+s/2,t.y,0],radius:n,height:this.ctx.pcbThickness*1.5})),t.ccw_rotation){const g=t.ccw_rotation*Math.PI/180;r=(0,yu.translate)([t.x,t.y,0],(0,yu.rotateZ)(g,(0,yu.translate)([-t.x,-t.y,0],r)))}A.dontCutBoard||(this.boardGeom=(0,gI.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,wu.colorize)(No.copper,(0,gI.subtract)(g,r)));const a=PO(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(a)}else if(t.shape==="pill_hole_with_rect_pad"){const e=t.hole_height>t.hole_width,i=e?t.hole_height:t.hole_width,o=e?t.hole_width:t.hole_height,n=o/2,s=Math.abs(i-o);let r;r=(0,gI.union)((0,aI.cuboid)({center:[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0),0],size:e?[o,s,this.ctx.pcbThickness*1.5]:[s,o,this.ctx.pcbThickness*1.5]}),(0,aI.cylinder)({center:e?[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0)-s/2,0]:[t.x+(t.hole_offset_x||0)-s/2,t.y+(t.hole_offset_y||0),0],radius:n,height:this.ctx.pcbThickness*1.5}),(0,aI.cylinder)({center:e?[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0)+s/2,0]:[t.x+(t.hole_offset_x||0)+s/2,t.y+(t.hole_offset_y||0),0],radius:n,height:this.ctx.pcbThickness*1.5})),A.dontCutBoard||(this.boardGeom=(0,gI.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,wu.colorize)(No.copper,(0,gI.subtract)(g,r)));const a=PO(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(a)}else if(t.shape==="hole_with_polygon_pad"){const e=t.pad_outline;if(!Array.isArray(e)||e.length<3)return;const i=this.ctx.pcbThickness*1.5,o=TO(t,i,{sizeDelta:2*Wo}),n=TO(t,i,{sizeDelta:-2*Wo});if(!o||!n)return;A.dontCutBoard||(this.boardGeom=(0,gI.subtract)(this.boardGeom,o)),this.padGeoms=this.padGeoms.map(r=>(0,wu.colorize)(No.copper,(0,gI.subtract)(r,o))),this.platedHoleGeoms=this.platedHoleGeoms.map(r=>(0,wu.colorize)(No.copper,(0,gI.subtract)(r,n)));const s=PO(t,this.ctx,{clipGeom:this.boardClipGeom});this.platedHoleGeoms.push(s)}}}processHole(t){if(!this.boardGeom)return;const A=this.ctx.pcbThickness*1.5;if(t.hole_shape==="circle"){const e=(0,aI.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+Wo,height:A});this.boardGeom=(0,gI.subtract)(this.boardGeom,e),this.padGeoms=this.padGeoms.map(o=>(0,wu.colorize)(No.copper,(0,gI.subtract)(o,e)));const i=(0,aI.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+Wo/2,height:A});this.platedHoleGeoms=this.platedHoleGeoms.map(o=>(0,wu.colorize)(No.copper,(0,gI.subtract)(o,i)))}else if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const e=t.hole_width,i=t.hole_height,o=Math.min(e,i)/2,n=Math.abs(e-i),s=t.hole_shape==="rotated_pill";let r;if(e>i?r=(0,gI.union)((0,aI.cuboid)({center:[t.x,t.y,0],size:[n,i,A]}),(0,aI.cylinder)({center:[t.x-n/2,t.y,0],radius:o,height:A}),(0,aI.cylinder)({center:[t.x+n/2,t.y,0],radius:o,height:A})):r=(0,gI.union)((0,aI.cuboid)({center:[t.x,t.y,0],size:[e,n,A]}),(0,aI.cylinder)({center:[t.x,t.y-n/2,0],radius:o,height:A}),(0,aI.cylinder)({center:[t.x,t.y+n/2,0],radius:o,height:A})),s){const g=t.ccw_rotation*Math.PI/180;r=(0,yu.rotateZ)(g,r)}this.boardGeom=(0,gI.subtract)(this.boardGeom,r),this.padGeoms=this.padGeoms.map(g=>(0,wu.colorize)(No.copper,(0,gI.subtract)(g,r)));const a=(0,Nht.expand)({delta:-.02},r);this.platedHoleGeoms=this.platedHoleGeoms.map(g=>(0,wu.colorize)(No.copper,(0,gI.subtract)(g,a)))}}processPad(t){const A=t.layer==="bottom"?-1:1,e=A*this.ctx.pcbThickness/2+A*rI.copper,i=Ch(t);if(t.shape==="rect"){const o=QZA(t.width,t.height,Wo,i);let s=(0,yu.translate)([t.x,t.y,e],o);this.boardClipGeom&&(s=(0,gI.intersect)(this.boardClipGeom,s)),s=(0,wu.colorize)(No.copper,s),this.padGeoms.push(s)}else if(t.shape==="rotated_rect"){let o=QZA(t.width,t.height,Wo,i);const n=t.ccw_rotation*Math.PI/180;o=(0,yu.rotateZ)(n,o);let r=(0,yu.translate)([t.x,t.y,e],o);this.boardClipGeom&&(r=(0,gI.intersect)(this.boardClipGeom,r)),r=(0,wu.colorize)(No.copper,r),this.padGeoms.push(r)}else if(t.shape==="circle"){let o=(0,aI.cylinder)({center:[t.x,t.y,e],radius:t.radius,height:Wo});this.boardClipGeom&&(o=(0,gI.intersect)(this.boardClipGeom,o)),o=(0,wu.colorize)(No.copper,o),this.padGeoms.push(o)}}processVia(t){if(this.boardGeom){if(typeof t.outer_diameter=="number"&&typeof t.hole_diameter=="number"){const A=Lht({x:t.x,y:t.y,outerDiameter:t.outer_diameter,holeDiameter:t.hole_diameter,thickness:this.ctx.pcbThickness});let e=A;this.boardClipGeom&&(e=(0,gI.intersect)(this.boardClipGeom,A),e=(0,wu.colorize)(No.copper,e)),this.viaGeoms.push(e)}if(typeof t.hole_diameter=="number"){const A=Hht({x:t.x,y:t.y,holeDiameter:t.hole_diameter,thickness:this.ctx.pcbThickness});this.boardGeom=(0,gI.subtract)(this.boardGeom,A),this.padGeoms=this.padGeoms.map(e=>(0,wu.colorize)(No.copper,(0,gI.subtract)(e,A)))}}}finalize(){if(!this.boardGeom)return;const t=qBA[this.board.material]??No.fr4Tan;this.boardGeom=(0,wu.colorize)(t,this.boardGeom),this.finalGeoms=[this.boardGeom,...this.platedHoleGeoms,...this.padGeoms,...this.viaGeoms,...this.copperPourGeoms],this.onCompleteCallback&&this.onCompleteCallback(this.finalGeoms)}getGeoms(){return this.finalGeoms}},Kht=t=>{const[A,e]=AA.useState(null),i=AA.useRef(!1);return AA.useEffect(()=>{let o=!1;if(!t){e(null);return}if(!t.some(g=>g.type==="pcb_board"||g.type==="pcb_panel")){e(null);return}const s=bht(t);e(s);const r=new Jht(t,g=>{});return(async()=>{if(!i.current){i.current=!0;try{let g=!1;for(;!g&&!o;)g=r.step(1),g||await new Promise(I=>setTimeout(I,0));o||e(r.getGeoms())}catch(g){console.error("Error during board geometry building:",g)}finally{i.current=!1}}})(),()=>{o=!0}},[t]),A},VBA=1.2;function Tht(t){return AA.useMemo(()=>{if(!t)return VBA;try{return wi(t).pcb_board.list()[0]?.thickness??VBA}catch{return VBA}},[t])}var qht=({children:t,parent:A,position:e,rotation:i,scale:o,color:n,fontSize:s,anchorX:r,anchorY:a,depthOffset:g})=>{const{rootObject:I}=fu(),c=AA.useMemo(()=>{const B=new LX;return B.text=t,e&&B.position.fromArray(e),i&&B.rotation.fromArray(i),o&&B.scale.fromArray(o),B.color=n||"white",B.fontSize=s||1,B.anchorX=r||"center",B.anchorY=a||"middle",B.depthOffset=g||0,B.font=null,B.sync(),B},[t,e,i,o,n,s,r,a,g]);return AA.useEffect(()=>{const B=A||I;if(!(!B||!c))return B.add(c),()=>{B.remove(c),c.dispose()}},[I,A,c]),null},hZA=({error:t,cad_component:A})=>{const{rootObject:e}=fu(),[i,o]=AA.useState(!1),[n,s]=AA.useState(null),r=AA.useCallback(c=>{c?.mousePosition?(o(!0),s(c.mousePosition)):(o(!1),s(null))},[]),a=AA.useCallback(()=>{o(!1),s(null)},[]),g=AA.useMemo(()=>A?.position?[A.position.x,A.position.y,A.position.z].map(B=>Number.isNaN(B)?0:B):[0,0,0],[A]),I=AA.useMemo(()=>{const c=new Np;return c.position.fromArray(g),c},[g]);return AA.useEffect(()=>{if(e)return e.add(I),()=>{e.remove(I)}},[e,I]),V.jsxs(V.Fragment,{children:[V.jsxs(GU,{isHovered:i,onHover:r,onUnhover:a,object:I,children:[V.jsx(Pht,{parent:I}),V.jsx(qht,{parent:I,scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:`${t.toString().slice(0,50)}...`})]}),i&&n?V.jsx(XWA,{position:n,style:{fontFamily:"sans-serif",transform:"translate3d(-1rem, 0rem, 0)",backgroundColor:"white",padding:"6px",borderRadius:"4px",color:"red",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:t.toString()}):null]})},Pht=({parent:t})=>{const A=AA.useMemo(()=>{const e=new Oo(new tw(.5,.5,.5),new ih({depthTest:!1,transparent:!0,color:"red",opacity:.5}));return e.renderOrder=999999,e.rotation.fromArray([Math.PI/4,Math.PI/4,0]),e},[]);return AA.useEffect(()=>(t.add(A),()=>{t.remove(A)}),[t,A]),null};function Oht({stlUrl:t,stlData:A,mtlUrl:e,color:i,opacity:o=1}){const{rootObject:n}=fu(),[s,r]=AA.useState(null);AA.useEffect(()=>{const g=new XSe;if(A){try{const I=g.parse(A);r(I)}catch(I){console.error("Failed to parse STL data",I),r(null)}return}t&&g.load(t,I=>{r(I)})},[t,A]);const a=AA.useMemo(()=>{if(!s)return null;const g=new ih({color:Array.isArray(i)?new Ui(i[0],i[1],i[2]):i,transparent:o!==1,opacity:o});return new Oo(s,g)},[s,i,o]);return AA.useEffect(()=>{if(!(!n||!a))return n.add(a),()=>{n.remove(a),a.geometry.dispose(),Array.isArray(a.material)?a.material.forEach(g=>g.dispose()):a.material.dispose()}},[n,a]),null}function Wht({stlData:t,color:A,opacity:e=1,layerType:i}){const{visibility:o}=T_();let n=!0;return i==="board"?n=o.boardBody:i==="top-copper"?n=o.topCopper:i==="bottom-copper"?n=o.bottomCopper:i==="top-silkscreen"?n=o.topSilkscreen:i==="bottom-silkscreen"&&(n=o.bottomSilkscreen),n?V.jsx(Oht,{stlData:t,color:A,opacity:e}):null}var uZA=class extends $i.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},Zht=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,o=t[0].y;for(let n=1;n<t.length;n++){const s=t[n];s.x<A&&(A=s.x),s.y<e&&(e=s.y),s.x>i&&(i=s.x),s.y>o&&(o=s.y)}return{minX:A,minY:e,maxX:i,maxY:o}};function KG(t){if(t.outline&&t.outline.length>=3){const s=Zht(t.outline);return{...s,width:s.maxX-s.minX,height:s.maxY-s.minY,centerX:(s.minX+s.maxX)/2,centerY:(s.minY+s.maxY)/2}}const A=t.width??0,e=t.height??0,i=t.center?.x??0,o=t.center?.y??0;return{...{minX:i-A/2,maxX:i+A/2,minY:o-e/2,maxY:o+e/2},width:A,height:e,centerX:i,centerY:o}}function WO({layer:t,circuitJson:A,boardData:e,soldermaskColor:i,traceTextureResolution:o}){const n=KG(e),s=document.createElement("canvas"),r=Math.floor(n.width*o),a=Math.floor(n.height*o);s.width=r,s.height=a;const g=s.getContext("2d");if(!g)return null;t==="bottom"&&(g.translate(0,a),g.scale(1,-1));const I=f=>(f-n.minX)*o,c=f=>(n.maxY-f)*o;if(g.fillStyle=i,e.outline&&e.outline.length>=3){g.beginPath();const f=e.outline[0];g.moveTo(I(f.x),c(f.y));for(let D=1;D<e.outline.length;D++){const b=e.outline[D];g.lineTo(I(b.x),c(b.y))}g.closePath(),g.fill()}else g.fillRect(0,0,r,a);g.globalCompositeOperation="destination-out",g.fillStyle="black",wi(A).pcb_smtpad.list().filter(f=>f.layer===t).forEach(f=>{if(f.shape==="polygon"&&f.points){g.beginPath(),f.points.forEach((F,k)=>{const v=I(F.x),_=c(F.y);k===0?g.moveTo(v,_):g.lineTo(v,_)}),g.closePath(),g.fill();return}if(f.x===void 0||f.y===void 0)return;if(Number.isNaN(f.x)||Number.isNaN(f.y)){console.warn(`[soldermask-texture] Skipping pad ${f.pcb_smtpad_id} with NaN coordinates`);return}const D=f.x,b=f.y,m=I(D),x=c(b);if(f.shape==="rect"){const F=f.width*o,k=f.height*o,v=Ch(f),_=ay(f.width,f.height,v)*o;_>0?(g.beginPath(),g.roundRect(m-F/2,x-k/2,F,k,_),g.fill()):g.fillRect(m-F/2,x-k/2,F,k)}else if(f.shape==="circle"){const F=(f.radius??f.width/2)*o;g.beginPath(),g.arc(m,x,F,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const F=f.width*o,k=f.height*o,v=Ch(f),_=ay(f.width,f.height,v)*o;g.beginPath(),g.roundRect(m-F/2,x-k/2,F,k,_),g.fill()}else if(f.shape==="rotated_rect"){const F=f.width*o,k=f.height*o,v=Ch(f),_=ay(f.width,f.height,v)*o,P=-(f.ccw_rotation||0)*(Math.PI/180);g.save(),g.translate(m,x),g.rotate(P),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()}}),wi(A).pcb_via.list().forEach(f=>{const D=I(f.x),b=c(f.y),m=f.outer_diameter/2*o;g.beginPath(),g.arc(D,b,m,0,2*Math.PI),g.fill()}),wi(A).pcb_plated_hole.list().forEach(f=>{if(!f.layers?.includes(t))return;const D=f.x,b=f.y,m=I(D),x=c(b);if(f.shape==="circle"){const k=f.outer_diameter/2*o;g.beginPath(),g.arc(m,x,k,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const F=(f.outer_width??f.outer_diameter??f.hole_width)*o,k=(f.outer_height??f.outer_diameter??f.hole_height)*o,v=Math.min(F,k)/2,Y=-(f.ccw_rotation||0);Y?(g.save(),g.translate(m,x),g.rotate(Y*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,v),g.fill(),g.restore()):(g.beginPath(),g.roundRect(m-F/2,x-k/2,F,k,v),g.fill())}else if(f.shape==="oval"){const F=(f.outer_width??f.outer_diameter??f.hole_width)*o,k=(f.outer_height??f.outer_diameter??f.hole_height)*o,v=F/2,_=k/2,P=-(f.ccw_rotation||0);P?(g.save(),g.translate(m,x),g.rotate(P*Math.PI/180),g.beginPath(),g.ellipse(0,0,v,_,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(m,x,v,_,0,0,2*Math.PI),g.fill())}else if(f.shape==="hole_with_polygon_pad"){const F=f.hole_shape||"circle",k=f.hole_offset_x||0,v=f.hole_offset_y||0,_=I(f.x+k),Y=c(f.y+v);if(F==="pill"||F==="rotated_pill"){const P=(f.outer_width??f.outer_diameter??f.hole_width)*o,K=(f.outer_height??f.outer_diameter??f.hole_height)*o,O=Math.min(P,K)/2,$=-(f.ccw_rotation||0);$?(g.save(),g.translate(_,Y),g.rotate($*Math.PI/180),g.beginPath(),g.roundRect(-P/2,-K/2,P,K,O),g.fill(),g.restore()):(g.beginPath(),g.roundRect(_-P/2,Y-K/2,P,K,O),g.fill())}else if(F==="oval"){const P=(f.outer_width??f.outer_diameter??f.hole_width)*o,K=(f.outer_height??f.outer_diameter??f.hole_height)*o,O=P/2,W=K/2,oA=-(f.ccw_rotation||0);oA?(g.save(),g.translate(_,Y),g.rotate(oA*Math.PI/180),g.beginPath(),g.ellipse(0,0,O,W,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(_,Y,O,W,0,0,2*Math.PI),g.fill())}else if(F==="circle"){const K=(f.outer_diameter??f.hole_diameter??0)*o/2;g.beginPath(),g.arc(_,Y,K,0,2*Math.PI),g.fill()}}else if(f.shape==="circular_hole_with_rect_pad"){const F=(f.rect_pad_width??f.hole_diameter??0)*o,k=(f.rect_pad_height??f.hole_diameter??0)*o,v=Ch(f),_=ay(f.rect_pad_width??f.hole_diameter??0,f.rect_pad_height??f.hole_diameter??0,v)*o;_>0?(g.beginPath(),g.roundRect(m-F/2,x-k/2,F,k,_),g.fill()):g.fillRect(m-F/2,x-k/2,F,k)}else if(f.shape==="pill_hole_with_rect_pad"){const F=(f.rect_pad_width??f.hole_width??0)*o,k=(f.rect_pad_height??f.hole_height??0)*o,v=Ch(f),_=ay(f.rect_pad_width??f.hole_width??0,f.rect_pad_height??f.hole_height??0,v)*o,P=-(f.ccw_rotation||0);P?(g.save(),g.translate(m,x),g.rotate(P*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(m-F/2,x-k/2,F,k,_),g.fill())}}),wi(A).pcb_hole.list().forEach(f=>{const D=f.x,b=f.y,m=I(D),x=c(b),F=f.hole_shape||f.shape;if(F==="circle"&&typeof f.hole_diameter=="number"){const k=f.hole_diameter/2*o;g.beginPath(),g.arc(m,x,k,0,2*Math.PI),g.fill()}else if((F==="pill"||F==="rotated_pill")&&typeof f.hole_width=="number"&&typeof f.hole_height=="number"){const k=f.hole_width*o,v=f.hole_height*o,_=Math.min(k,v)/2,P=-(f.ccw_rotation||0)*(Math.PI/180);P?(g.save(),g.translate(m,x),g.rotate(P),g.beginPath(),g.roundRect(-k/2,-v/2,k,v,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(m-k/2,x-v/2,k,v,_),g.fill())}}),wi(A).pcb_copper_pour.list().forEach(f=>{if(f.layer===t&&f.covered_with_solder_mask===!1)if(f.shape==="rect"){const D=I(f.center.x),b=c(f.center.y),m=f.width*o,x=f.height*o;g.fillRect(D-m/2,b-x/2,m,x)}else f.shape==="polygon"&&f.points&&(g.beginPath(),f.points.forEach((D,b)=>{const m=I(D.x),x=c(D.y);b===0?g.moveTo(m,x):g.lineTo(m,x)}),g.closePath(),g.fill())}),wi(A).pcb_cutout.list().forEach(f=>{switch(f.shape){case"rect":{const D=I(f.center.x),b=c(f.center.y),m=f.width*o,x=f.height*o,F=Ch(f),k=ay(f.width,f.height,F);if(f.rotation){g.save(),g.translate(D,b);const v=-f.rotation*(Math.PI/180);g.rotate(v),k>0?(g.beginPath(),g.roundRect(-m/2,-x/2,m,x,k*o),g.fill()):g.fillRect(-m/2,-x/2,m,x),g.restore()}else k>0?(g.beginPath(),g.roundRect(D-m/2,b-x/2,m,x,k*o),g.fill()):g.fillRect(D-m/2,b-x/2,m,x);break}case"circle":{const D=I(f.center.x),b=c(f.center.y),m=f.radius*o;g.beginPath(),g.arc(D,b,m,0,2*Math.PI),g.fill();break}case"polygon":{if(!f.points||f.points.length<3){console.warn(`PCB Cutout [${f.pcb_cutout_id}] polygon has fewer than 3 points, skipping in soldermask texture.`);break}g.beginPath(),f.points.forEach((D,b)=>{const m=I(D.x),x=c(D.y);b===0?g.moveTo(m,x):g.lineTo(m,x)}),g.closePath(),g.fill();break}default:console.warn(`Unsupported cutout shape: ${f.shape} for cutout ${f.pcb_cutout_id} in soldermask texture.`)}}),g.globalCompositeOperation="source-over";const d=new tN(s);return d.generateMipmaps=!0,d.minFilter=Qu,d.magFilter=WB,d.anisotropy=16,d.needsUpdate=!0,d}var Vht=yr(ABA());function dZA(t,A){return Array.isArray(A)?[t.a*A[0]+t.c*A[1]+t.e,t.b*A[0]+t.d*A[1]+t.f]:{x:t.a*A.x+t.c*A.y+t.e,y:t.b*A.x+t.d*A.y+t.f}}function fx(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function pZA(...t){t=Array.isArray(t[0])?t[0]:t;const A=(e,i)=>({a:e.a*i.a+e.c*i.b,c:e.a*i.c+e.c*i.d,e:e.a*i.e+e.c*i.f+e.e,b:e.b*i.a+e.d*i.b,d:e.b*i.c+e.d*i.d,f:e.b*i.e+e.d*i.f+e.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return A(t[0],t[1]);default:{const[e,i,...o]=t,n=A(e,i);return pZA(n,...o)}}}function fZA(...t){return pZA(...t)}var{cos:jht,sin:zht}=Math;function yZA(t,A,e){const i=jht(t),o=zht(t);return{a:i,c:-o,e:0,b:o,d:i,f:0}}function Xht(t,A){function e(){this.constructor=t}e.prototype=A.prototype,t.prototype=new e}function ZO(t,A,e,i){var o=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(o,ZO.prototype),o.expected=A,o.found=e,o.location=i,o.name="SyntaxError",o}Xht(ZO,Error);function jBA(t,A,e){return e=e||" ",t.length>A?t:(A-=t.length,e+=e.repeat(A),t+e.slice(0,A))}ZO.prototype.format=function(t){var A="Error: "+this.message;if(this.location){var e=null,i;for(i=0;i<t.length;i++)if(t[i].source===this.location.source){e=t[i].text.split(/\r\n|\n|\r/g);break}var o=this.location.start,n=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(o):o,s=this.location.source+":"+n.line+":"+n.column;if(e){var r=this.location.end,a=jBA("",n.line.toString().length," "),g=e[o.line-1],I=o.line===r.line?r.column:g.length+1,c=I-o.column||1;A+=`
|
|
5097
5097
|
--> `+s+`
|
|
5098
5098
|
`+a+` |
|
|
5099
5099
|
`+n.line+" | "+g+`
|
|
5100
5100
|
`+a+" | "+jBA("",o.column-1," ")+jBA("",c,"^")}else A+=`
|
|
5101
|
-
at `+s}return A},ZO.buildMessage=function(t,A){var e={literal:function(g){return'"'+o(g.text)+'"'},class:function(g){var I=g.parts.map(function(c){return Array.isArray(c)?n(c[0])+"-"+n(c[1]):n(c)});return"["+(g.inverted?"^":"")+I.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(g){return g.description}};function i(g){return g.charCodeAt(0).toString(16).toUpperCase()}function o(g){return g.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(I){return"\\x0"+i(I)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(I){return"\\x"+i(I)})}function n(g){return g.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(I){return"\\x0"+i(I)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(I){return"\\x"+i(I)})}function s(g){return e[g.type](g)}function r(g){var I=g.map(s),c,B;if(I.sort(),I.length>0){for(c=1,B=1;c<I.length;c++)I[c-1]!==I[c]&&(I[B]=I[c],B++);I.length=B}switch(I.length){case 1:return I[0];case 2:return I[0]+" or "+I[1];default:return I.slice(0,-1).join(", ")+", or "+I[I.length-1]}}function a(g){return g?'"'+o(g)+'"':"end of input"}return"Expected "+r(t)+" but "+a(A)+" found."};var wZA=25.4,$ht=wZA/1e3,Aut=/^\s*(-?\d*(?:\.\d+)?)(?:\s*(mm|mil|inch|in|"))?\s*$/i;function eut(t){if(!t)return;const A=t.trim().toLowerCase();return A==='"'||A==="inch"?"in":A}function EQ(t){if(t==null)return;if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(typeof t!="string")return;const A=t.trim();if(A.length===0)return;const e=A.match(Aut);if(!e){const r=Number.parseFloat(A);return Number.isFinite(r)?r:void 0}const[,i,o]=e,n=Number.parseFloat(i||"0");if(!Number.isFinite(n))return;switch(eut(o)){case"mil":return n*$ht;case"in":return n*wZA;case"mm":case void 0:return n;default:return n}}function Cw(t,A){const e=EQ(t);return e===void 0?A:e}function mZA(t){let A=t;if(A.startsWith("#")&&(A=A.slice(1)),A.length===6){const e=parseInt(A.slice(0,2),16),i=parseInt(A.slice(2,4),16),o=parseInt(A.slice(4,6),16);return`rgb(${e}, ${i}, ${o})`}return t.startsWith("rgb")?t:"rgb(255, 243, 204)"}function VO({layer:t,circuitJson:A,boardData:e,silkscreenColor:i="rgb(255,255,255)",traceTextureResolution:o}){const n=wi(A).pcb_silkscreen_text.list(),s=wi(A).pcb_silkscreen_path.list(),r=wi(A).pcb_silkscreen_line.list(),a=wi(A).pcb_silkscreen_rect.list(),g=wi(A).pcb_silkscreen_circle.list(),I=wi(A).pcb_fabrication_note_rect.list(),c=wi(A).pcb_note_line.list(),B=n.filter(v=>v.layer===t),C=s.filter(v=>v.layer===t),l=r.filter(v=>v.layer===t),Q=a.filter(v=>v.layer===t),E=g.filter(v=>v.layer===t),h=I.filter(v=>v.layer===t),u=c.filter(v=>v.layer===t);if(B.length===0&&C.length===0&&l.length===0&&Q.length===0&&E.length===0&&h.length===0&&u.length===0)return null;const d=KG(e),f=document.createElement("canvas"),D=Math.floor(d.width*o),b=Math.floor(d.height*o);f.width=D,f.height=b;const m=f.getContext("2d");if(!m)return null;t==="bottom"&&(m.translate(0,b),m.scale(1,-1)),m.strokeStyle=i,m.fillStyle=i;const x=v=>(v-d.minX)*o,F=v=>(d.maxY-v)*o;l.forEach(v=>{const _=EQ(v.x1)??0,Y=EQ(v.y1)??0,P=EQ(v.x2)??0,K=EQ(v.y2)??0;_===P&&Y===K||(m.beginPath(),m.lineWidth=Cw(v.stroke_width,.1)*o,m.lineCap="round",m.moveTo(x(_),F(Y)),m.lineTo(x(P),F(K)),m.stroke())}),u.forEach(v=>{const _=EQ(v.x1)??0,Y=EQ(v.y1)??0,P=EQ(v.x2)??0,K=EQ(v.y2)??0;if(_===P&&Y===K)return;m.save();let O=i;v.color?O=mZA(v.color):O="rgb(255, 243, 204)",m.strokeStyle=O,m.beginPath(),m.lineWidth=Cw(v.stroke_width,.1)*o,m.lineCap="round";const W=v.is_dashed??!1;if(W){const $=Math.max(m.lineWidth*2,1);m.setLineDash([$,$])}m.moveTo(x(_),F(Y)),m.lineTo(x(P),F(K)),m.stroke(),W&&m.setLineDash([]),m.restore()}),C.forEach(v=>{v.route.length<2||(m.beginPath(),m.lineWidth=Cw(v.stroke_width,.1)*o,m.lineCap="round",m.lineJoin="round",v.route.forEach((_,Y)=>{const P=x(EQ(_.x)??0),K=F(EQ(_.y)??0);Y===0?m.moveTo(P,K):m.lineTo(P,K)}),m.stroke())}),E.forEach(v=>{const _=Cw(v.radius,0);if(_<=0)return;const Y=Cw(v.stroke_width,.12),P=Y>0,K=EQ(v.center?.x)??0,O=EQ(v.center?.y)??0,W=x(K),$=F(O),oA=_*o;if(m.save(),m.translate(W,$),P){const IA=oA+Y/2*o,tA=Math.max(0,oA-Y/2*o);tA>0?(m.beginPath(),m.arc(0,0,IA,0,2*Math.PI),m.arc(0,0,tA,0,2*Math.PI,!0),m.fill("evenodd")):(m.beginPath(),m.arc(0,0,IA,0,2*Math.PI),m.fill())}else m.beginPath(),m.arc(0,0,oA,0,2*Math.PI),m.fill();m.restore()}),Q.forEach(v=>{const _=Cw(v.width,0),Y=Cw(v.height,0);if(_<=0||Y<=0)return;const P=EQ(v.center?.x)??0,K=EQ(v.center?.y)??0,O=x(P),W=F(K),$=Ch(v),oA=typeof $=="string"?EQ($):$,IA=ay(_,Y,oA);m.save(),m.translate(O,W);const tA=_/2*o,sA=Y/2*o,gA=Math.min(IA*o,tA,sA),dA=v.stroke_width??!1,SA=v.is_filled??!0,RA=v.is_stroke_dashed??!1,NA=dA?Cw(v.stroke_width,.1)*o:0;if(((BA,fA,hA,KA,te)=>{if(m.beginPath(),te<=0)m.rect(BA,fA,hA,KA);else{const Be=te,yA=BA+hA,OA=fA+KA;m.moveTo(BA+Be,fA),m.lineTo(yA-Be,fA),m.quadraticCurveTo(yA,fA,yA,fA+Be),m.lineTo(yA,OA-Be),m.quadraticCurveTo(yA,OA,yA-Be,OA),m.lineTo(BA+Be,OA),m.quadraticCurveTo(BA,OA,BA,OA-Be),m.lineTo(BA,fA+Be),m.quadraticCurveTo(BA,fA,BA+Be,fA),m.closePath()}})(-tA,-sA,tA*2,sA*2,gA),SA&&m.fill(),dA&&NA>0){if(m.lineWidth=NA,RA){const BA=Math.max(NA*2,1);m.setLineDash([BA,BA])}m.stroke(),RA&&m.setLineDash([])}m.restore()}),h.forEach(v=>{const _=Cw(v.width,0),Y=Cw(v.height,0);if(_<=0||Y<=0)return;const P=EQ(v.center?.x)??0,K=EQ(v.center?.y)??0,O=x(P),W=F(K),$=Ch(v),oA=typeof $=="string"?EQ($):$,IA=ay(_,Y,oA);m.save(),m.translate(O,W);const tA=_/2*o,sA=Y/2*o,gA=Math.min(IA*o,tA,sA),dA=v.has_stroke??!1,SA=v.is_filled??!0,RA=v.is_stroke_dashed??!1,NA=dA?Cw(v.stroke_width,.1)*o:0;let TA=i,BA=i;if(v.color){const hA=mZA(v.color);TA=hA,BA=hA}else TA="rgb(255, 243, 204)",BA="rgb(255, 243, 204)";if(((hA,KA,te,Be,yA)=>{if(m.beginPath(),yA<=0)m.rect(hA,KA,te,Be);else{const OA=yA,YA=hA+te,HA=KA+Be;m.moveTo(hA+OA,KA),m.lineTo(YA-OA,KA),m.quadraticCurveTo(YA,KA,YA,KA+OA),m.lineTo(YA,HA-OA),m.quadraticCurveTo(YA,HA,YA-OA,HA),m.lineTo(hA+OA,HA),m.quadraticCurveTo(hA,HA,hA,HA-OA),m.lineTo(hA,KA+OA),m.quadraticCurveTo(hA,KA,hA+OA,KA),m.closePath()}})(-tA,-sA,tA*2,sA*2,gA),SA&&(m.fillStyle=TA,m.fill()),dA&&NA>0){if(m.strokeStyle=BA,m.lineWidth=NA,RA){const hA=Math.max(NA*2,1);m.setLineDash([hA,hA])}m.stroke(),RA&&m.setLineDash([])}m.restore()}),B.forEach(v=>{const _=v.font_size||.25,Y=Math.min(Math.max(.01,_*.1),_*.05)*o;m.lineWidth=Y,m.lineCap="butt",m.lineJoin="miter";const P=(0,Vht.vectorText)({height:_*.45,input:v.text}),K=[];P.forEach(RA=>{RA.length===29?(K.push(RA.slice(0,15)),K.push(RA.slice(14,29))):RA.length===17?(K.push(RA.slice(0,10)),K.push(RA.slice(9,17))):K.push(RA)});const O=K.flat(),W={minX:O.length>0?Math.min(...O.map(RA=>RA[0])):0,maxX:O.length>0?Math.max(...O.map(RA=>RA[0])):0,minY:O.length>0?Math.min(...O.map(RA=>RA[1])):0,maxY:O.length>0?Math.max(...O.map(RA=>RA[1])):0},$=(W.minX+W.maxX)/2,oA=(W.minY+W.maxY)/2;let IA=-$,tA=-oA;const sA=v.anchor_alignment||"center";sA.includes("left")?IA=-W.minX:sA.includes("right")&&(IA=-W.maxX),sA.includes("top")?tA=-W.maxY:sA.includes("bottom")&&(tA=-W.minY);const gA=[];let dA=v.ccw_rotation??0;if(v.layer==="bottom"&&(gA.push(fx($,oA),{a:-1,b:0,c:0,d:1,e:0,f:0},fx(-$,-oA)),dA=-dA),dA){const RA=dA*Math.PI/180;gA.push(fx($,oA),yZA(RA),fx(-$,-oA))}const SA=gA.length>0?fZA(...gA):void 0;K.forEach(RA=>{m.beginPath(),RA.forEach((NA,TA)=>{let BA={x:NA[0],y:NA[1]};SA&&(BA=dZA(SA,BA));const fA=BA.x+IA+v.anchor_position.x,hA=BA.y+tA+v.anchor_position.y,KA=x(fA),te=F(hA);TA===0?m.moveTo(KA,te):m.lineTo(KA,te)}),m.stroke()})});const k=new tN(f);return k.generateMipmaps=!0,k.minFilter=Qu,k.magFilter=WB,k.anisotropy=16,k.needsUpdate=!0,k}function DZA(t){return t&&t.route_type==="wire"&&typeof t.layer=="string"&&typeof t.width=="number"}function P_({layer:t,circuitJson:A,boardData:e,traceColor:i,traceTextureResolution:o}){const n=wi(A).pcb_trace.list(),s=wi(A).pcb_via.list(),r=wi(A).pcb_plated_hole.list(),a=n.filter(Q=>Q.route.some(E=>DZA(E)&&E.layer===t));if(a.length===0)return null;const g=KG(e),I=document.createElement("canvas"),c=Math.floor(g.width*o),B=Math.floor(g.height*o);I.width=c,I.height=B;const C=I.getContext("2d");if(!C)return null;t==="bottom"&&(C.translate(0,B),C.scale(1,-1)),a.forEach(Q=>{let E=!0;C.beginPath(),C.strokeStyle=i,C.lineCap="round",C.lineJoin="round";let h=0;for(const u of Q.route){if(!DZA(u)||u.layer!==t){E||C.stroke(),E=!0;continue}const d=u.x,f=u.y;h=u.width*o,C.lineWidth=h;const D=(d-g.minX)*o,b=(g.maxY-f)*o;E?(C.moveTo(D,b),E=!1):C.lineTo(D,b)}E||C.stroke()}),C.globalCompositeOperation="destination-out",C.fillStyle="black",s.forEach(Q=>{const E=(Q.x-g.minX)*o,h=(g.maxY-Q.y)*o,u=Q.outer_diameter/2*o;C.beginPath(),C.arc(E,h,u,0,2*Math.PI,!1),C.fill()}),r.forEach(Q=>{if(Q.layers.includes(t)&&Q.shape==="circle"){const E=(Q.x-g.minX)*o,h=(g.maxY-Q.y)*o,u=Q.outer_diameter/2*o;C.beginPath(),C.arc(E,h,u,0,2*Math.PI,!1),C.fill()}}),C.globalCompositeOperation="source-over";const l=new tN(I);return l.generateMipmaps=!0,l.minFilter=Qu,l.magFilter=WB,l.anisotropy=16,l.needsUpdate=!0,l}var tut=yr(ABA());function jO(t,A){if(t===void 0)return A;if(typeof t=="number")return t;const e=parseFloat(t.replace(/mm$/,""));return isNaN(e)?A:e}function iut(t){return t.layer==="bottom"?t.is_mirrored!==!1:t.is_mirrored===!0}function out(t){const A=t.flat();if(A.length===0)return{minX:0,maxX:0,minY:0,maxY:0,width:0,height:0,centerX:0,centerY:0};const e=Math.min(...A.map(s=>s[0])),i=Math.max(...A.map(s=>s[0])),o=Math.min(...A.map(s=>s[1])),n=Math.max(...A.map(s=>s[1]));return{minX:e,maxX:i,minY:o,maxY:n,width:i-e,height:n-o,centerX:(e+i)/2,centerY:(o+n)/2}}function nut(t){const A=[];return t.forEach(e=>{e.length===29?(A.push(e.slice(0,15)),A.push(e.slice(14,29))):e.length===17?(A.push(e.slice(0,10)),A.push(e.slice(9,17))):A.push(e)}),A}function sut(t,A){let e=-t.centerX,i=-t.centerY;return A.includes("left")?e=-t.minX:A.includes("right")&&(e=-t.maxX),A.includes("top")?i=-t.maxY:A.includes("bottom")&&(i=-t.minY),{x:e,y:i}}function rut(t,A){const e=[];let i=t.ccw_rotation??0;if(iut(t)&&(e.push(fx(A.centerX,A.centerY),{a:-1,b:0,c:0,d:1,e:0,f:0},fx(-A.centerX,-A.centerY)),i=-i),i){const s=i*Math.PI/180;e.push(fx(A.centerX,A.centerY),yZA(s),fx(-A.centerX,-A.centerY))}return{matrix:e.length>0?fZA(...e):void 0,rotationDeg:i}}function SZA(t,A,e,i,o,n,s){A.forEach(r=>{t.beginPath(),r.forEach((a,g)=>{let I={x:a[0],y:a[1]};e&&(I=dZA(e,I));const c=I.x+i.x+o.x,B=I.y+i.y+o.y,C=n(c),l=s(B);g===0?t.moveTo(C,l):t.lineTo(C,l)}),t.stroke()})}function aut(t,A,e,i,o,n){t.save(),t.translate(A,e),t.rotate(-n),t.fillRect(-i/2,-o/2,i,o),t.restore()}function gut(t,A,e,i,o,n,s,r,a,g){const I=typeof A.font_size=="number"?A.font_size:.2,c={left:jO(A.knockout_padding?.left,I*.5),right:jO(A.knockout_padding?.right,I*.5),top:jO(A.knockout_padding?.top,I*.3),bottom:jO(A.knockout_padding?.bottom,I*.3)},B=i.width+c.left+c.right,C=i.height+c.top+c.bottom,l=s(A.anchor_position.x),Q=r(A.anchor_position.y),E=B*a,h=C*a;t.fillStyle=g;const u=n*Math.PI/180;aut(t,l,Q,E,h,u);const d={x:-i.centerX,y:-i.centerY};t.globalCompositeOperation="destination-out",SZA(t,e,o,d,A.anchor_position,s,r),t.globalCompositeOperation="source-over"}function zO({layer:t,circuitJson:A,boardData:e,copperColor:i="rgb(230, 153, 51)",traceTextureResolution:o}){const s=A.filter(Q=>Q.type==="pcb_copper_text").filter(Q=>Q.layer===t);if(s.length===0)return null;const r=KG(e),a=document.createElement("canvas"),g=Math.floor(r.width*o),I=Math.floor(r.height*o);a.width=g,a.height=I;const c=a.getContext("2d");if(!c)return null;t==="bottom"&&(c.translate(0,I),c.scale(1,-1)),c.strokeStyle=i,c.fillStyle=i;const B=Q=>(Q-r.minX)*o,C=Q=>(r.maxY-Q)*o;s.forEach(Q=>{const E=typeof Q.font_size=="number"?Q.font_size:.2,h=Math.max(.02,E*.08)*o;c.lineWidth=h,c.lineCap="round",c.lineJoin="round";const u=(0,tut.vectorText)({height:E*.45,input:Q.text}),d=nut(u),f=out(d),{matrix:D,rotationDeg:b}=rut(Q,f);if(Q.is_knockout)gut(c,Q,d,f,D,b,B,C,o,i);else{const m=Q.anchor_alignment||"center",x=sut(f,m);SZA(c,d,D,x,Q.anchor_position,B,C)}});const l=new tN(a);return l.generateMipmaps=!0,l.minFilter=Qu,l.magFilter=WB,l.anisotropy=16,l.needsUpdate=!0,l}function XO({layer:t,circuitJson:A,panelData:e,outlineColor:i="black",traceTextureResolution:o}){const n=wi(A).pcb_board.list().filter(C=>C.pcb_panel_id===e.pcb_board_id);if(n.length===0)return null;const s=document.createElement("canvas"),r=Math.floor(e.width*o),a=Math.floor(e.height*o);s.width=r,s.height=a;const g=s.getContext("2d");if(!g)return null;t==="bottom"&&(g.translate(0,a),g.scale(1,-1)),g.strokeStyle=i,g.lineWidth=.05*o;const I=C=>(C-e.center.x+e.width/2)*o,c=C=>(-(C-e.center.y)+e.height/2)*o;n.forEach(C=>{if(C.outline&&C.outline.length>=2)g.beginPath(),C.outline.forEach((l,Q)=>{const E=I(l.x),h=c(l.y);Q===0?g.moveTo(E,h):g.lineTo(E,h)}),g.closePath(),g.stroke();else{const l=C.width,Q=C.height,{x:E,y:h}=C.center,u=I(E-l/2),d=c(h+Q/2);g.strokeRect(u,d,l*o,Q*o)}});const B=new tN(s);return B.generateMipmaps=!0,B.minFilter=Qu,B.magFilter=WB,B.anisotropy=16,B.needsUpdate=!0,B}function Iut({circuitJson:t,pcbThickness:A,isFaux:e=!1}){const{rootObject:i}=fu(),{visibility:o}=T_(),n=AA.useMemo(()=>{const r=t.filter(I=>I.type==="pcb_panel"),a=wi(t).pcb_board.list();if(r.length>0){const I=r[0],c=a.find(B=>B.pcb_panel_id===I.pcb_panel_id);return{type:"pcb_board",pcb_board_id:I.pcb_panel_id,center:I.center,width:I.width,height:I.height,thickness:c?.thickness??1.6,material:c?.material??"fr4",num_layers:c?.num_layers??2}}const g=a.filter(I=>!I.pcb_panel_id);return g.length>0?g[0]:null},[t]),s=AA.useMemo(()=>{if(!n||!n.width||!n.height)return null;const r=gZA[n.material]??No.fr4SolderMaskGreen,a=`rgb(${Math.round(r[0]*255)}, ${Math.round(r[1]*255)}, ${Math.round(r[2]*255)})`,g="rgb(255,255,255)",I=No.fr4TracesWithMaskGreen,c=`rgb(${Math.round(I[0]*255)}, ${Math.round(I[1]*255)}, ${Math.round(I[2]*255)})`;return{topSoldermask:WO({layer:"top",circuitJson:t,boardData:n,soldermaskColor:a,traceTextureResolution:lc}),bottomSoldermask:WO({layer:"bottom",circuitJson:t,boardData:n,soldermaskColor:a,traceTextureResolution:lc}),topSilkscreen:VO({layer:"top",circuitJson:t,boardData:n,silkscreenColor:g,traceTextureResolution:lc}),bottomSilkscreen:VO({layer:"bottom",circuitJson:t,boardData:n,silkscreenColor:g,traceTextureResolution:lc}),topTraceWithMask:P_({layer:"top",circuitJson:t,boardData:n,traceColor:c,traceTextureResolution:lc}),bottomTraceWithMask:P_({layer:"bottom",circuitJson:t,boardData:n,traceColor:c,traceTextureResolution:lc}),topCopperText:zO({layer:"top",circuitJson:t,boardData:n,copperColor:`rgb(${Math.round(No.copper[0]*255)}, ${Math.round(No.copper[1]*255)}, ${Math.round(No.copper[2]*255)})`,traceTextureResolution:lc}),bottomCopperText:zO({layer:"bottom",circuitJson:t,boardData:n,copperColor:`rgb(${Math.round(No.copper[0]*255)}, ${Math.round(No.copper[1]*255)}, ${Math.round(No.copper[2]*255)})`,traceTextureResolution:lc}),topPanelOutlines:XO({layer:"top",circuitJson:t,panelData:n,traceTextureResolution:lc}),bottomPanelOutlines:XO({layer:"bottom",circuitJson:t,panelData:n,traceTextureResolution:lc})}},[t,n]);return AA.useEffect(()=>{if(!i||!n||!s)return;const r=[],a=(I,c,B,C,l=!1,Q=!1)=>{if(!I)return null;const E=KG(n),h=new iw(E.width,E.height),u=new ld({map:I,transparent:!0,side:UC,depthWrite:Q,polygonOffset:l,polygonOffsetFactor:l?-1:0,polygonOffsetUnits:l?-1:0,opacity:e?YO:1}),d=new Oo(h,u);return d.position.set(E.centerX,E.centerY,c),B&&d.rotation.set(Math.PI,0,0),d.name=C,d},g=.001;if(o.topMask){const I=a(s.topSoldermask,A/2+g,!1,"jscad-top-soldermask",!0);I&&(r.push(I),i.add(I))}if(o.bottomMask){const I=a(s.bottomSoldermask,-A/2-g,!0,"jscad-bottom-soldermask",!0);I&&(r.push(I),i.add(I))}if(o.topCopper&&o.topMask){const I=a(s.topTraceWithMask,A/2+rI.traces+.004,!1,"jscad-top-trace-with-mask");I&&(r.push(I),i.add(I))}if(o.bottomCopper&&o.bottomMask){const I=a(s.bottomTraceWithMask,-A/2-rI.traces-.005,!0,"jscad-bottom-trace-with-mask");I&&(r.push(I),i.add(I))}if(o.topSilkscreen){const I=a(s.topSilkscreen,A/2+g+.002,!1,"jscad-top-silkscreen");I&&(r.push(I),i.add(I))}if(o.bottomSilkscreen){const I=a(s.bottomSilkscreen,-A/2-g-.002,!0,"jscad-bottom-silkscreen");I&&(r.push(I),i.add(I))}if(o.topCopper){const I=a(s.topCopperText,A/2+rI.copper,!1,"jscad-top-copper-text");I&&(r.push(I),i.add(I))}if(o.bottomCopper){const I=a(s.bottomCopperText,-A/2-rI.copper,!0,"jscad-bottom-copper-text");I&&(r.push(I),i.add(I))}if(o.boardBody){const I=a(s.topPanelOutlines,A/2+g+.003,!1,"jscad-top-panel-outlines",!1,!0);I&&(r.push(I),i.add(I));const c=a(s.bottomPanelOutlines,-A/2-g-.003,!0,"jscad-bottom-panel-outlines",!1,!0);c&&(r.push(c),i.add(c))}return()=>{r.forEach(I=>{I.parent===i&&i.remove(I),I.geometry.dispose(),I.material instanceof Rp&&I.material.dispose()})}},[i,n,s,A,o]),null}function cut(t){const A=wi(t).cad_component.list(),e=wi(t).pcb_smtpad.list(),i=wi(t).pcb_hole.list(),o=wi(t).pcb_plated_hole.list(),n=wi(t).pcb_via.list();if(A.length===0&&e.length===0&&i.length===0&&o.length===0&&n.length===0)return null;const s=[...i,...o,...n,...e],r=e2(s);let a=r.minX,g=r.maxX,I=r.minY,c=r.maxY;for(const u of A)if(u.position){const d=u.position.x,f=u.position.y;a=Math.min(a,d),g=Math.max(g,d),I=Math.min(I,f),c=Math.max(c,f)}a===1/0&&(a=-10,g=10,I=-10,c=10);const B=2,C=Math.max(Math.abs(a),Math.abs(g))+B,l=Math.max(Math.abs(I),Math.abs(c))+B,Q=Math.max(2*C,10),E=Math.max(2*l,10);return{type:"pcb_board",pcb_board_id:"faux-board",center:{x:0,y:0},width:Q,height:E,thickness:1.6,material:"fr4",num_layers:2}}function bZA(t){if(wi(t).pcb_board.list().length>0)return t;const e=cut(t);if(!e)return t;const o=e.thickness/2;return[...t.map(s=>{if(s.type==="cad_component"){const r=s;if(r.position){const a=r.position.z??0;return{...r,position:{...r.position,z:a+o}}}}return s}),e]}var But=AA.forwardRef(({soup:t,circuitJson:A,children:e,autoRotateDisabled:i,clickToInteractEnabled:o,onUserInteraction:n,onCameraControllerReady:s},r)=>{const a=aZA(e),g=AA.useMemo(()=>bZA(t??A??a),[t,A,a]),I=Kht(g),c=AA.useMemo(()=>{if(!g)return[5,-5,5];try{const u=wi(g).pcb_board.list()[0];if(!u)return[5,-5,5];const{width:d,height:f}=u;if(!d&&!f)return[5,-5,5];const D=5,b=Math.max(d,D),m=Math.max(f,D),x=Math.max(b,m);return[x*.4,-x*.7,x*.9]}catch(u){return console.error(u),[5,-5,5]}},[g]),B=AA.useMemo(()=>{if(!g)return!1;try{const u=wi(g).pcb_board.list()[0];return!!u&&u.pcb_board_id==="faux-board"}catch{return!1}},[g]),C=AA.useMemo(()=>{if(g)try{const u=wi(g).pcb_board.list()[0];return u?{width:u.width??0,height:u.height??0}:void 0}catch(u){console.error(u);return}},[g]),l=AA.useMemo(()=>{if(g)try{const u=wi(g).pcb_board.list()[0];return!u||!u.center?void 0:{x:u.center.x,y:u.center.y}}catch(u){console.error(u);return}},[g]),Q=Tht(g),{stls:E}=dht(I),h=wi(g).cad_component.list();return V.jsxs(rZA,{ref:r,autoRotateDisabled:i,initialCameraPosition:c,clickToInteractEnabled:o,boardDimensions:C,boardCenter:l,onUserInteraction:n,onCameraControllerReady:s,children:[E.map(({stlData:u,color:d,layerType:f},D)=>V.jsx(Wht,{stlData:u,color:d,opacity:D===0?B?.8:.95:1,layerType:f},`board-${D}`)),V.jsx(Iut,{circuitJson:g,pcbThickness:Q,isFaux:B}),h.map(u=>V.jsx(uZA,{fallback:({error:d})=>V.jsx(hZA,{cad_component:u,error:d}),children:V.jsx(tZA,{cad_component:u,circuitJson:g},u.cad_component_id)},u.cad_component_id))]})}),Cut=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;t[i]&&t[o]&&(A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1])}return A/2<=0};function lut(t,A,e,i,o){let n,s=null;if(e.outline&&e.outline.length>=3){let r=e.outline.map(g=>[g.x,g.y]);Cut(r)&&(r=r.reverse());const a=A.ofPolygons([r]);o.push(a),s=a,n=t.extrude(a,i,void 0,void 0,void 0,!0),o.push(n)}else e.outline&&e.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),n=t.cube([e.width,e.height,i],!0),o.push(n),n=n.translate([e.center.x,e.center.y,0]),o.push(n);return{boardOp:n,outlineCrossSection:s}}var Qut=64;function gy({Manifold:t,width:A,height:e,thickness:i,borderRadius:o}){const n=ay(A,e,o);if(n<=0)return t.cube([A,e,i],!0);const s=[],r=A-2*n,a=e-2*n;return r>0&&s.push(t.cube([r,e,i],!0)),a>0&&s.push(t.cube([A,a,i],!0)),[[A/2-n,e/2-n],[-A/2+n,e/2-n],[-A/2+n,-e/2+n],[A/2-n,-e/2+n]].forEach(([I,c])=>{s.push(t.cylinder(i,n,n,Qut,!0).translate([I,c,0]))}),t.union(s)}function Eut({Manifold:t,pad:A,padBaseThickness:e}){if(A.shape==="rect"){const i=Ch(A);return gy({Manifold:t,width:A.width,height:A.height,thickness:e,borderRadius:i})}else if(A.shape==="rotated_rect"){const i=Ch(A);let o=gy({Manifold:t,width:A.width,height:A.height,thickness:e,borderRadius:i});const n=A.ccw_rotation??0;return n&&(o=o.rotate([0,0,n])),o}else if(A.shape==="circle"&&A.radius)return t.cylinder(e,A.radius,-1,32,!0);return null}var hut=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;t[i]&&t[o]&&(A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1])}return A/2<=0};function uut(t,A,e,i,o){const n=[],s=wi(e).pcb_cutout.list();for(const r of s){let a;const g=i*1.5;switch(r.shape){case"rect":{const B=Ch(r);if(typeof B=="number"&&B>0?a=gy({Manifold:t,width:r.width,height:r.height,thickness:g,borderRadius:B}):a=t.cube([r.width,r.height,g],!0),o.push(a),r.rotation){const C=a.rotate([0,0,r.rotation]);o.push(C),a=C}a=a.translate([r.center.x,r.center.y,0]),o.push(a);break}case"circle":a=t.cylinder(g,r.radius,-1,wl,!0),o.push(a),a=a.translate([r.center.x,r.center.y,0]),o.push(a);break;case"polygon":if(r.points.length<3){console.warn(`PCB Cutout [${r.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);continue}let I=r.points.map(B=>[B.x,B.y]);hut(I)&&(I=I.reverse());const c=A.ofPolygons([I]);o.push(c),a=t.extrude(c,g,0,0,[1,1],!0),o.push(a);break;default:console.warn(`Unsupported cutout shape: ${r.shape} for cutout ${r.pcb_cutout_id}`);continue}a&&n.push(a)}return{cutoutOps:n}}function xZA({Manifold:t,x:A,y:e,diameter:i,thickness:o,segments:n=32}){return t.cylinder(o*1.2,i/2,i/2,n,!0).translate([A,e,0])}function kZA({Manifold:t,x:A,y:e,holeDiameter:i,thickness:o,zOffset:n=.001,segments:s=32}){const r=i/2+n;return t.cylinder(o*1.2,r,r,s,!0).translate([A,e,0])}function dut(t){return(t.shape==="circle"||t.hole_shape==="circle")&&typeof t.hole_diameter=="number"}function put(t){return(t.shape==="pill"||t.hole_shape==="pill")&&typeof t.hole_width=="number"&&typeof t.hole_height=="number"}function fut(t){return(t.shape==="rotated_pill"||t.hole_shape==="rotated_pill")&&typeof t.hole_width=="number"&&typeof t.hole_height=="number"&&typeof t.ccw_rotation=="number"}function yut(t,A,e,i){const o=[],n=wi(A).pcb_hole.list(),s=(r,a,g)=>{const I=gy({Manifold:t,width:r,height:a,thickness:g,borderRadius:Math.min(r,a)/2});return i.push(I),I};return n.forEach(r=>{if(dut(r)){const a=xZA({Manifold:t,x:r.x,y:r.y,diameter:r.hole_diameter,thickness:e,segments:wl});i.push(a),o.push(a)}else if(put(r)){const a=r.hole_width,g=r.hole_height,I=e*1.2,B=s(a,g,I).translate([r.x,r.y,0]);i.push(B),o.push(B)}else if(fut(r)){const a=r.hole_width,g=r.hole_height,I=e*1.2;let c=s(a,g,I);const B=c.rotate([0,0,r.ccw_rotation]);i.push(B),c=B;const C=c.translate([r.x,r.y,0]);i.push(C),o.push(C)}}),{nonPlatedHoleBoardDrills:o}}function ym(t){const A=new Cg;if(A.setAttribute("position",new Un(t.vertProperties,3)),A.setIndex(new Jj(t.triVerts,1)),t.runIndex&&t.runIndex.length>1&&t.runOriginalID)for(let e=0;e<t.runIndex.length-1;e++){const i=t.runIndex[e],o=t.runIndex[e+1]-i;A.addGroup(i,o,0)}else A.addGroup(0,t.triVerts.length,0);return A}var OU=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;t[i]&&t[o]&&(A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1])}return A/2<=0},$O=(t,A,e)=>{const i=[];for(let o=0;o<e;o++){const n=2*Math.PI*o/e;i.push([t/2*Math.cos(n),A/2*Math.sin(n)])}return i},O_=new Ui(...No.copper),GZA=.05;function wut(t,A,e,i,o,n){const s=[],r=wi(e).pcb_plated_hole.list(),a=[],g=[],I=(l,Q,E)=>{const h=gy({Manifold:t,width:l,height:Q,thickness:E,borderRadius:Math.min(l,Q)/2});return o.push(h),h},c=({padOutline:l,thickness:Q})=>{if(!Array.isArray(l)||l.length<3)return null;let E=l.map(d=>[d.x,d.y]);OU(E)&&(E=E.reverse());const h=A.ofPolygons([E]);o.push(h);const u=t.extrude(h,Q,0,0,[1,1],!0);return o.push(u),u},B=({ph:l,depth:Q,sizeDelta:E=0})=>{if(l.shape!=="hole_with_polygon_pad")return null;const u=l.pad_outline;if(!Array.isArray(u)||u.length<3)return null;const d=l.hole_shape||"circle",f=l.hole_offset_x||0,D=l.hole_offset_y||0;let b=null;if(d==="circle"){const m=Math.max((l.hole_diameter??0)+E,Wo),x=Math.max(m/2,Wo/2);b=t.cylinder(Q,x,x,wl,!0),o.push(b)}else{const m=l.hole_width??l.hole_diameter,x=l.hole_height??l.hole_diameter;if(!m||!x)return null;const F=Math.max(m+E,Wo),k=Math.max(x+E,Wo);if(d==="oval"){let v=$O(F,k,wl);OU(v)&&(v=v.reverse());const _=A.ofPolygons([v]);o.push(_),b=t.extrude(_,Q,0,0,[1,1],!0),o.push(b)}else(d==="pill"||d==="rotated_pill")&&(b=gy({Manifold:t,width:F,height:k,thickness:Q,borderRadius:Math.min(F,k)/2}),o.push(b))}if(!b)return null;if(f||D){const m=b.translate([f,D,0]);o.push(m),b=m}return b};r.forEach((l,Q)=>{if(l.shape==="circle"){const E=kZA({Manifold:t,x:l.x,y:l.y,holeDiameter:l.hole_diameter*1.02,thickness:i,zOffset:ry,segments:wl});o.push(E),s.push(E);const h=i+2*ry,u=t.cylinder(h,l.outer_diameter/2,l.outer_diameter/2,wl,!0);o.push(u);const d=t.cylinder(h*1.05,l.hole_diameter/2,l.hole_diameter/2,wl,!0);o.push(d);const f=u.subtract(d);o.push(f);const D=f.translate([l.x,l.y,0]);o.push(D);let b=D;if(n){const x=t.intersection([D,n]);o.push(x),b=x}g.push(b);const m=ym(b.getMesh());a.push({key:`ph-${l.pcb_plated_hole_id||Q}`,geometry:m,color:O_})}else if(l.shape==="pill"){const E=l.hole_width,h=l.hole_height,u=.4,d=l.outer_width??E+u,f=l.outer_height??h+u,D=E+2*ry,b=h+2*ry,m=i*1.2;let x=I(D,b,m);if(l.ccw_rotation){const W=x.rotate([0,0,l.ccw_rotation]);o.push(W),x=W}const F=x.translate([l.x,l.y,0]);o.push(F),s.push(F);const k=i+2*ry,v=I(d,f,k),_=I(E,h,k*1.05);let Y=v.subtract(_);if(o.push(Y),l.ccw_rotation){const W=Y.rotate([0,0,l.ccw_rotation]);o.push(W),Y=W}const P=Y.translate([l.x,l.y,0]);o.push(P);let K=P;if(n){const W=t.intersection([P,n]);o.push(W),K=W}g.push(K);const O=ym(K.getMesh());a.push({key:`ph-${l.pcb_plated_hole_id||Q}`,geometry:O,color:O_})}else if(l.shape==="pill_hole_with_rect_pad"){const E=l.hole_width,h=l.hole_height,u=l.hole_offset_x||0,d=l.hole_offset_y||0,f=l.rect_pad_width,D=l.rect_pad_height,b=Ch(l),m=HO,x=E+2*ry,F=h+2*ry,k=i*1.2,_=I(x,F,k).translate([u,d,0]).translate([l.x,l.y,0]);o.push(_),s.push(_);const Y=gy({Manifold:t,width:f,height:D,thickness:i-2*m-2*rI.copper+.1,borderRadius:b});o.push(Y);const P=gy({Manifold:t,width:f,height:D,thickness:m,borderRadius:b}).translate([0,0,i/2/2+rI.copper]),K=gy({Manifold:t,width:f,height:D,thickness:m,borderRadius:b}).translate([0,0,-i/2/2-rI.copper]);o.push(P,K);const O=I(E,h,i*1.02).translate([u,d,0]);o.push(O);const W=t.union([Y,P,K,O]);o.push(W);const $=I(Math.max(E-2*GZA,.01),Math.max(h-2*GZA,.01),i*1.2).translate([u,d,0]);o.push($);const oA=W.subtract($);o.push(oA);const IA=oA.translate([l.x,l.y,0]);o.push(IA);let tA=IA;if(n){const gA=t.intersection([IA,n]);o.push(gA),tA=gA}g.push(tA);const sA=ym(tA.getMesh());a.push({key:`ph-${l.pcb_plated_hole_id||Q}`,geometry:sA,color:O_})}else if(l.shape==="hole_with_polygon_pad"){const E=l.pad_outline;if(!Array.isArray(E)||E.length<3)return;const h=B({ph:l,depth:i*1.2,sizeDelta:2*Wo});if(!h)return;const u=h.translate([l.x,l.y,0]);o.push(u),s.push(u);const d=HO,f=Math.max(i-2*d-2*rI.copper+.1,Wo),D=c({padOutline:E,thickness:f}),b=c({padOutline:E,thickness:d}),m=c({padOutline:E,thickness:d});if(!D||!b||!m)return;const x=b.translate([0,0,i/2/2+rI.copper]),F=m.translate([0,0,-i/2/2-rI.copper]);o.push(x,F);const k=B({ph:l,depth:i*1.02});if(!k)return;const v=B({ph:l,depth:i*1.2,sizeDelta:-2*Wo})||k,_=t.union([D,x,F,k]);o.push(_);const Y=_.subtract(v);o.push(Y);const P=Y.translate([l.x,l.y,0]);o.push(P);let K=P;if(n){const W=t.intersection([P,n]);o.push(W),K=W}g.push(K);const O=ym(K.getMesh());a.push({key:`ph-${l.pcb_plated_hole_id||Q}`,geometry:O,color:O_})}else if(l.shape==="oval"){const E=l.hole_width,h=l.hole_height,u=l.outer_width??E+.4,d=l.outer_height??h+.4,f=E+2*ry,D=h+2*ry,b=i*1.2;let m=$O(f,D,wl);OU(m)&&(m=m.reverse());const x=A.ofPolygons([m]);o.push(x);let F=t.extrude(x,b,0,0,[1,1],!0);if(o.push(F),l.ccw_rotation){const sA=F.rotate([0,0,l.ccw_rotation]);o.push(sA),F=sA}const k=F.translate([l.x,l.y,0]);o.push(k),s.push(k);const v=i+2*ry;let _=$O(u,d,wl);OU(_)&&(_=_.reverse());const Y=A.ofPolygons([_]);o.push(Y);let P=t.extrude(Y,v,0,0,[1,1],!0);o.push(P);let K=$O(E,h,wl);OU(K)&&(K=K.reverse());const O=A.ofPolygons([K]);o.push(O);let W=t.extrude(O,v*1.05,0,0,[1,1],!0);o.push(W);let $=P.subtract(W);if(o.push($),l.ccw_rotation){const sA=$.rotate([0,0,l.ccw_rotation]);o.push(sA),$=sA}const oA=$.translate([l.x,l.y,0]);o.push(oA);let IA=oA;if(n){const sA=t.intersection([oA,n]);o.push(sA),IA=sA}g.push(IA);const tA=ym(IA.getMesh());a.push({key:`ph-${l.pcb_plated_hole_id||Q}`,geometry:tA,color:O_})}else if(l.shape==="circular_hole_with_rect_pad"){const E=l.hole_offset_x||0,h=l.hole_offset_y||0,u=xZA({Manifold:t,x:l.x+E,y:l.y+h,diameter:l.hole_diameter,thickness:i,segments:wl});o.push(u),s.push(u);const d=l.rect_pad_width??l.hole_diameter,f=l.rect_pad_height??l.hole_diameter,D=Ch(l),b=HO,m=l.hole_diameter/2,x=gy({Manifold:t,width:d,height:f,thickness:i-2*b-2*rI.copper+.1,borderRadius:D});o.push(x);const F=gy({Manifold:t,width:d,height:f,thickness:b,borderRadius:D}).translate([0,0,i/2/2+rI.copper]),k=gy({Manifold:t,width:d,height:f,thickness:b,borderRadius:D}).translate([0,0,-i/2/2-rI.copper]);o.push(F,k);const v=t.cylinder(i*1.02,m,m,wl,!0).translate([E,h,0]);o.push(v);const _=t.union([x,F,k,v]);o.push(_);const Y=t.cylinder(i*1.2,Math.max(m-Wo,.01),Math.max(m-Wo,.01),wl,!0).translate([E,h,0]);o.push(Y);const P=_.subtract(Y);o.push(P);const K=P.translate([l.x,l.y,0]);o.push(K);let O=K;if(n){const $=t.intersection([K,n]);o.push($),O=$}g.push(O);const W=ym(O.getMesh());a.push({key:`ph-${l.pcb_plated_hole_id||Q}`,geometry:W,color:O_})}});let C;return g.length>0&&(C=t.union(g),o.push(C)),{platedHoleBoardDrills:s,platedHoleCopperGeoms:a,platedHoleSubtractOp:C}}var mut=new Ui(...No.copper);function Dut(t,A,e,i,o,n){const s=[];return wi(A).pcb_smtpad.list().forEach((a,g)=>{const I=HO,c=a.layer==="bottom"?-e/2-rI.copper:e/2+rI.copper;let B=Eut({Manifold:t,pad:a,padBaseThickness:I});if(B){i.push(B);const C=B.translate([a.x,a.y,c]);i.push(C);let l=C;if(o&&(l=C.subtract(o),i.push(l)),n){const E=t.intersection([l,n]);i.push(E),l=E}const Q=ym(l.getMesh());s.push({key:`smt_pad-${a.layer||"top"}-${a.pcb_smtpad_id||g}`,geometry:Q,color:mut})}}),{smtPadGeoms:s}}function Sut({Manifold:t,x:A,y:e,outerDiameter:i,holeDiameter:o,thickness:n,zOffset:s=.001,segments:r=32}){const a=s,g=s;if(i<o)throw new Error(`Invalid via geometry: outerDiameter (${i}) must be >= holeDiameter (${o})`);const I=Math.min(i/2,o/2+g),c=t.cylinder(n,I,-1,r,!0),B=t.cylinder(a,i/2,-1,r,!0).translate([0,0,n/2]),C=t.cylinder(a,i/2,-1,r,!0).translate([0,0,-n/2]),l=t.union([c,B,C]),Q=n+a*2,E=t.cylinder(Q,o/2,-1,r,!0);return l.subtract(E).translate([A,e,0])}var but=new Ui(...No.copper);function xut(t,A,e,i,o){const n=[],s=wi(A).pcb_via.list(),r=[];return s.forEach((a,g)=>{if(typeof a.hole_diameter=="number"){const I=kZA({Manifold:t,x:a.x,y:a.y,holeDiameter:a.hole_diameter,thickness:e,zOffset:ry,segments:wl});i.push(I),n.push(I)}if(typeof a.outer_diameter=="number"&&typeof a.hole_diameter=="number"){const I=Sut({Manifold:t,x:a.x,y:a.y,outerDiameter:a.outer_diameter,holeDiameter:a.hole_diameter,thickness:e,zOffset:ry,segments:wl});i.push(I);let c=I;if(o){const C=t.intersection([I,o]);i.push(C),c=C}const B=ym(c.getMesh());r.push({key:`via-${a.pcb_via_id||g}`,geometry:B,color:but})}}),{viaBoardDrills:n,viaCopperGeoms:r}}function FZA({ctx:t,points:A,canvasXFromPcb:e,canvasYFromPcb:i}){A.length<3||(t.beginPath(),A.forEach((o,n)=>{const s=e(o[0]),r=i(o[1]);n===0?t.moveTo(s,r):t.lineTo(s,r)}),t.closePath(),t.fill())}function kut({ctx:t,pour:A,canvasXFromPcb:e,canvasYFromPcb:i}){const o=A.brep_shape;if(!o||!o.outer_ring)return;const n=OO(o.outer_ring,32);if(n.length>=3&&FZA({ctx:t,points:n,canvasXFromPcb:e,canvasYFromPcb:i}),o.inner_rings&&o.inner_rings.length>0){t.globalCompositeOperation="destination-out";for(const s of o.inner_rings){const r=OO(s,32);r.length>=3&&FZA({ctx:t,points:r,canvasXFromPcb:e,canvasYFromPcb:i})}t.globalCompositeOperation="source-over"}}function RZA({layer:t,circuitJson:A,boardData:e,traceTextureResolution:i=lc}){const n=A.filter(E=>E.type==="pcb_copper_pour").filter(E=>E.layer===t);if(n.length===0)return null;const s=KG(e),r=document.createElement("canvas"),a=Math.floor(s.width*i),g=Math.floor(s.height*i);r.width=a,r.height=g;const I=r.getContext("2d");if(!I)return null;t==="bottom"&&(I.translate(0,g),I.scale(1,-1));const c=E=>(E-s.minX)*i,B=E=>(s.maxY-E)*i,C=n.filter(E=>E.shape==="rect"||E.shape==="polygon"),l=n.filter(E=>E.shape==="brep");if(C.length>0){const E=new qet(I);E.setCameraBounds({minX:s.minX,maxX:s.maxX,minY:s.minY,maxY:s.maxY});const h=C.filter(D=>D.covered_with_solder_mask!==!1),u=C.filter(D=>D.covered_with_solder_mask===!1),d=`rgb(${No.fr4TracesWithMaskGreen.map(D=>D*255).join(",")})`,f=`rgb(${No.copper.map(D=>D*255).join(",")})`;h.length>0&&(E.configure({colorOverrides:{copper:{top:d,bottom:d,inner1:d,inner2:d,inner3:d,inner4:d,inner5:d,inner6:d}}}),E.drawElements(h,{layers:[t]})),u.length>0&&(E.configure({colorOverrides:{copper:{top:f,bottom:f,inner1:f,inner2:f,inner3:f,inner4:f,inner5:f,inner6:f}}}),E.drawElements(u,{layers:[t]}))}for(const E of l){const u=E.covered_with_solder_mask!==!1?No.fr4TracesWithMaskGreen:No.copper,d=`rgb(${u[0]*255}, ${u[1]*255}, ${u[2]*255})`;I.fillStyle=d,kut({ctx:I,pour:E,canvasXFromPcb:c,canvasYFromPcb:B})}const Q=new tN(r);return Q.generateMipmaps=!0,Q.minFilter=Qu,Q.magFilter=WB,Q.anisotropy=16,Q.needsUpdate=!0,Q}function Tp(t,A){const{texture:e,yOffset:i,isBottomLayer:o,textureType:n,usePolygonOffset:s=!1,renderOrder:r=0,isFaux:a=!1}=t;if(!e)return null;const g=KG(A),I=new iw(g.width,g.height),c=new ld({map:e,transparent:!0,side:UC,depthWrite:n==="panel-outlines",polygonOffset:s,polygonOffsetFactor:s?-4:0,polygonOffsetUnits:s?-4:0,opacity:a?YO:1}),B=new Oo(I,c);return B.position.set(g.centerX,g.centerY,i),o&&B.rotation.set(Math.PI,0,0),B.name=`${o?"bottom":"top"}-${n}-texture-plane`,B.renderOrder=r,B}function Gut(t,A,e,i=!1){const o=[];if(!t||!A||e===null)return o;const n=Tp({texture:t.topTrace,yOffset:e/2+rI.traces,isBottomLayer:!1,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);n&&o.push(n);const s=Tp({texture:t.topTraceWithMask,yOffset:e/2+rI.traces,isBottomLayer:!1,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);s&&o.push(s);const r=Tp({texture:t.topSilkscreen,yOffset:e/2+.003,isBottomLayer:!1,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);r&&o.push(r);const a=Tp({texture:t.bottomTrace,yOffset:-e/2-rI.traces,isBottomLayer:!0,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);a&&o.push(a);const g=Tp({texture:t.bottomTraceWithMask,yOffset:-e/2-rI.traces,isBottomLayer:!0,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);g&&o.push(g);const I=Tp({texture:t.bottomSilkscreen,yOffset:-e/2-.003,isBottomLayer:!0,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);I&&o.push(I);const c=Tp({texture:t.topSoldermask,yOffset:e/2+.001,isBottomLayer:!1,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);c&&o.push(c);const B=Tp({texture:t.bottomSoldermask,yOffset:-e/2-.001,isBottomLayer:!0,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);B&&o.push(B);const C=Tp({texture:t.topCopperText,yOffset:e/2+rI.copper,isBottomLayer:!1,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);C&&o.push(C);const l=Tp({texture:t.bottomCopperText,yOffset:-e/2-rI.copper,isBottomLayer:!0,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);l&&o.push(l);const Q=Tp({texture:t.topCopper,yOffset:e/2+rI.copper,isBottomLayer:!1,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);Q&&o.push(Q);const E=Tp({texture:t.bottomCopper,yOffset:-e/2-rI.copper,isBottomLayer:!0,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);E&&o.push(E);const h=Tp({texture:t.topPanelOutlines,yOffset:e/2+.004,isBottomLayer:!1,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);h&&o.push(h);const u=Tp({texture:t.bottomPanelOutlines,yOffset:-e/2-.004,isBottomLayer:!0,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);return u&&o.push(u),o}var Fut=(t,A)=>{const[e,i]=AA.useState(null),[o,n]=AA.useState(null),[s,r]=AA.useState(null),[a,g]=AA.useState(null),[I,c]=AA.useState(!0),B=AA.useRef([]),C=AA.useMemo(()=>{const Q=A.filter(u=>u.type==="pcb_panel"),E=wi(A).pcb_board.list();if(Q.length>0){const u=Q[0],d=E.find(f=>f.pcb_panel_id===u.pcb_panel_id);return{type:"pcb_board",pcb_board_id:u.pcb_panel_id,center:u.center,width:u.width,height:u.height,thickness:d?.thickness??1.6,material:d?.material??"fr4",num_layers:d?.num_layers??2}}const h=E.filter(u=>!u.pcb_panel_id);return h.length>0?h[0]:null},[A]),l=AA.useMemo(()=>{const Q=wi(A).pcb_board.list();return Q.length>0&&Q[0].pcb_board_id==="faux-board"},[A]);return AA.useEffect(()=>{if(!t||!C){i(null),n(null),r(null),c(!1);return}if((C.width===0||!C.width)&&(C.height===0||!C.height)&&(!C.outline||C.outline.length<3)){i({platedHoles:[],smtPads:[],vias:[]}),n({}),r(C.thickness??0),c(!1);return}c(!0),g(null);const Q=t.Manifold,E=t.CrossSection,h=D=>{if(!(!D||typeof D.delete!="function"))try{D.delete()}catch(b){(!(b instanceof Error)||!b.message?.includes("Manifold instance already deleted"))&&console.warn("Failed to delete Manifold instance",b)}};B.current.forEach(h),B.current=[];let u=null;const d={},f={};try{const D=C.thickness||1.6;r(D);const{boardOp:b,outlineCrossSection:m}=lut(Q,E,C,D,B.current);let x=b;const k=D+2*1;let v=null;const _=.01;if(m){let KA=m;if(_>0){const Be=m.offset(_);B.current.push(Be),KA=Be}const te=Q.extrude(KA,k,void 0,void 0,void 0,!0);B.current.push(te),v=te}else{const KA=(C.width||0)+2*_,te=(C.height||0)+2*_,Be=Q.cube([KA,te,k],!0);B.current.push(Be);const yA=Be.translate([C.center.x,C.center.y,0]);B.current.push(yA),v=yA}const Y=[];let P=null;const{nonPlatedHoleBoardDrills:K}=yut(Q,A,D,B.current);Y.push(...K);const{platedHoleBoardDrills:O,platedHoleCopperGeoms:W,platedHoleSubtractOp:$}=wut(Q,E,A,D,B.current,v);Y.push(...O),d.platedHoles=W;const{viaBoardDrills:oA,viaCopperGeoms:IA}=xut(Q,A,D,B.current,v);if(Y.push(...oA),d.vias=IA,Y.length>0){P=Q.union(Y),B.current.push(P);const KA=$?Q.union([P,$]):P;B.current.push(KA);const te=x.subtract(KA);if(B.current.push(te),x=te,$){const Be=$.subtract(P);B.current.push(Be);const yA=Be.getMesh(),OA=ym(yA);d.platedHoles=[{key:"plated-holes-union",geometry:OA,color:new Ui(No.copper[0],No.copper[1],No.copper[2])}]}}const{cutoutOps:tA}=uut(Q,E,A,D,B.current);if(tA.length>0){const KA=Q.union(tA);B.current.push(KA);const te=x.subtract(KA);B.current.push(te),x=te}if(u=x,u){const KA=u.getMesh(),te=ym(KA),Be=qBA[C.material]??No.fr4Tan;d.board={geometry:te,color:new Ui(Be[0],Be[1],Be[2]),material:C.material,isFaux:l}}const{smtPadGeoms:sA}=Dut(Q,A,D,B.current,P,v);d.smtPads=sA,i(d);const gA=No.fr4TracesWithoutMaskTan,dA=`rgb(${Math.round(gA[0]*255)}, ${Math.round(gA[1]*255)}, ${Math.round(gA[2]*255)})`;f.topTrace=P_({layer:"top",circuitJson:A,boardData:C,traceColor:dA,traceTextureResolution:lc}),f.bottomTrace=P_({layer:"bottom",circuitJson:A,boardData:C,traceColor:dA,traceTextureResolution:lc});const SA=No.fr4TracesWithMaskGreen,RA=`rgb(${Math.round(SA[0]*255)}, ${Math.round(SA[1]*255)}, ${Math.round(SA[2]*255)})`;f.topTraceWithMask=P_({layer:"top",circuitJson:A,boardData:C,traceColor:RA,traceTextureResolution:lc}),f.bottomTraceWithMask=P_({layer:"bottom",circuitJson:A,boardData:C,traceColor:RA,traceTextureResolution:lc});const NA="rgb(255,255,255)";f.topSilkscreen=VO({layer:"top",circuitJson:A,boardData:C,silkscreenColor:NA,traceTextureResolution:lc}),f.bottomSilkscreen=VO({layer:"bottom",circuitJson:A,boardData:C,silkscreenColor:NA,traceTextureResolution:lc});const TA=gZA[C.material]??No.fr4SolderMaskGreen,BA=`rgb(${Math.round(TA[0]*255)}, ${Math.round(TA[1]*255)}, ${Math.round(TA[2]*255)})`;f.topSoldermask=WO({layer:"top",circuitJson:A,boardData:C,soldermaskColor:BA,traceTextureResolution:lc}),f.bottomSoldermask=WO({layer:"bottom",circuitJson:A,boardData:C,soldermaskColor:BA,traceTextureResolution:lc});const fA=No.copper,hA=`rgb(${Math.round(fA[0]*255)}, ${Math.round(fA[1]*255)}, ${Math.round(fA[2]*255)})`;f.topCopperText=zO({layer:"top",circuitJson:A,boardData:C,copperColor:hA,traceTextureResolution:lc}),f.bottomCopperText=zO({layer:"bottom",circuitJson:A,boardData:C,copperColor:hA,traceTextureResolution:lc}),f.topPanelOutlines=XO({layer:"top",circuitJson:A,panelData:C,traceTextureResolution:lc}),f.bottomPanelOutlines=XO({layer:"bottom",circuitJson:A,panelData:C,traceTextureResolution:lc}),f.topCopper=RZA({layer:"top",circuitJson:A,boardData:C,traceTextureResolution:lc}),f.bottomCopper=RZA({layer:"bottom",circuitJson:A,boardData:C,traceTextureResolution:lc}),n(f)}catch(D){console.error("Error processing geometry with Manifold in hook:",D),g(D.message||"An unknown error occurred while processing geometry in hook."),i(null),n(null)}finally{c(!1)}return()=>{B.current.forEach(h),B.current=[]}},[t,A,C]),{geoms:e,textures:o,pcbThickness:s,error:a,isLoading:I,boardData:C,isFauxBoard:l}},Rut=UC,Nut=({material:t,color:A,side:e=Rut,isFaux:i=!1})=>t==="fr4"?new ow({color:A,side:e,metalness:0,roughness:.8,specularIntensity:.2,ior:1.45,sheen:0,clearcoat:0,transparent:i,opacity:i?YO:1,flatShading:!0}):new ih({color:A,side:e,flatShading:!0,metalness:.1,roughness:.8,transparent:!0,opacity:i?YO:.9});function _ut(t){const A=[];if(!t)return A;if(t.board&&t.board.geometry){const i=new Oo(t.board.geometry,Nut({material:t.board.material,color:t.board.color,side:UC,isFaux:t.board.isFaux}));i.name="board-geom",A.push(i)}const e=i=>{i&&i.forEach(o=>{const n=new Oo(o.geometry,new ih({color:o.color,side:UC,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}));n.name=o.key,A.push(n)})};return e(t.platedHoles),e(t.smtPads),e(t.vias),A}var Mut=({geometryMeshes:t,textureMeshes:A})=>{const{rootObject:e}=fu(),{visibility:i}=T_();return AA.useEffect(()=>{if(e)return t.forEach(o=>{let n=!0;o.name==="board-geom"?n=i.boardBody:o.name.includes("smt_pad")?o.name.includes("smt_pad-top")?n=i.topCopper:o.name.includes("smt_pad-bottom")?n=i.bottomCopper:n=i.topCopper||i.bottomCopper:(o.name.includes("plated_hole")||o.name.includes("via"))&&(n=i.topCopper||i.bottomCopper),n&&e.add(o)}),A.forEach(o=>{let n=!0;o.name.includes("top-trace-texture-plane")&&!o.name.includes("with-mask")?n=i.topCopper&&!i.topMask:o.name.includes("top-trace-with-mask")?n=i.topCopper&&i.topMask:o.name.includes("bottom-trace-texture-plane")&&!o.name.includes("with-mask")?n=i.bottomCopper&&!i.bottomMask:o.name.includes("bottom-trace-with-mask")?n=i.bottomCopper&&i.bottomMask:o.name.includes("top-silkscreen")?n=i.topSilkscreen:o.name.includes("bottom-silkscreen")?n=i.bottomSilkscreen:o.name.includes("top-soldermask")?n=i.topMask:o.name.includes("bottom-soldermask")?n=i.bottomMask:o.name.includes("top-copper-text")?n=i.topCopper:o.name.includes("bottom-copper-text")?n=i.bottomCopper:o.name.includes("top-copper")?n=i.topCopper:o.name.includes("bottom-copper")?n=i.bottomCopper:o.name.includes("panel-outlines")&&(n=i.boardBody),n&&e.add(o)}),()=>{t.forEach(o=>{o.parent===e&&e.remove(o)}),A.forEach(o=>{o.parent===e&&e.remove(o)})}},[e,t,A,i]),null},vut="https://cdn.jsdelivr.net/npm/manifold-3d@3.2.1",Uut=({circuitJson:t,autoRotateDisabled:A,clickToInteractEnabled:e,onUserInteraction:i,children:o,onCameraControllerReady:n})=>{const s=aZA(o),r=AA.useMemo(()=>bZA(t??s),[t,s]),[a,g]=AA.useState(null),[I,c]=AA.useState(null);AA.useEffect(()=>{if(window.ManifoldModule&&typeof window.ManifoldModule=="object"&&window.ManifoldModule.setup){g(window.ManifoldModule);return}const F=async K=>{try{const O=await K();O.setup(),window.ManifoldModule=O,g(O)}catch(O){console.error("Failed to initialize Manifold:",O),c(`Failed to initialize Manifold: ${O instanceof Error?O.message:"Unknown error"}`)}},k=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(k){window.ManifoldModule=k,F(window.ManifoldModule);return}const v="manifoldLoaded",_=()=>{const K=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(K)window.ManifoldModule=K,F(window.ManifoldModule);else{const O="ManifoldModule not found on window after script load.";console.error(O),c(O)}};window.addEventListener(v,_,{once:!0});const Y=document.createElement("script");Y.type="module",Y.innerHTML=`
|
|
5101
|
+
at `+s}return A},ZO.buildMessage=function(t,A){var e={literal:function(g){return'"'+o(g.text)+'"'},class:function(g){var I=g.parts.map(function(c){return Array.isArray(c)?n(c[0])+"-"+n(c[1]):n(c)});return"["+(g.inverted?"^":"")+I.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(g){return g.description}};function i(g){return g.charCodeAt(0).toString(16).toUpperCase()}function o(g){return g.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(I){return"\\x0"+i(I)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(I){return"\\x"+i(I)})}function n(g){return g.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(I){return"\\x0"+i(I)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(I){return"\\x"+i(I)})}function s(g){return e[g.type](g)}function r(g){var I=g.map(s),c,B;if(I.sort(),I.length>0){for(c=1,B=1;c<I.length;c++)I[c-1]!==I[c]&&(I[B]=I[c],B++);I.length=B}switch(I.length){case 1:return I[0];case 2:return I[0]+" or "+I[1];default:return I.slice(0,-1).join(", ")+", or "+I[I.length-1]}}function a(g){return g?'"'+o(g)+'"':"end of input"}return"Expected "+r(t)+" but "+a(A)+" found."};var wZA=25.4,$ht=wZA/1e3,Aut=/^\s*(-?\d*(?:\.\d+)?)(?:\s*(mm|mil|inch|in|"))?\s*$/i;function eut(t){if(!t)return;const A=t.trim().toLowerCase();return A==='"'||A==="inch"?"in":A}function EQ(t){if(t==null)return;if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(typeof t!="string")return;const A=t.trim();if(A.length===0)return;const e=A.match(Aut);if(!e){const r=Number.parseFloat(A);return Number.isFinite(r)?r:void 0}const[,i,o]=e,n=Number.parseFloat(i||"0");if(!Number.isFinite(n))return;switch(eut(o)){case"mil":return n*$ht;case"in":return n*wZA;case"mm":case void 0:return n;default:return n}}function Cw(t,A){const e=EQ(t);return e===void 0?A:e}function mZA(t){let A=t;if(A.startsWith("#")&&(A=A.slice(1)),A.length===6){const e=parseInt(A.slice(0,2),16),i=parseInt(A.slice(2,4),16),o=parseInt(A.slice(4,6),16);return`rgb(${e}, ${i}, ${o})`}return t.startsWith("rgb")?t:"rgb(255, 243, 204)"}function VO({layer:t,circuitJson:A,boardData:e,silkscreenColor:i="rgb(255,255,255)",traceTextureResolution:o}){const n=wi(A).pcb_silkscreen_text.list(),s=wi(A).pcb_silkscreen_path.list(),r=wi(A).pcb_silkscreen_line.list(),a=wi(A).pcb_silkscreen_rect.list(),g=wi(A).pcb_silkscreen_circle.list(),I=wi(A).pcb_fabrication_note_rect.list(),c=wi(A).pcb_note_line.list(),B=n.filter(v=>v.layer===t),C=s.filter(v=>v.layer===t),l=r.filter(v=>v.layer===t),Q=a.filter(v=>v.layer===t),E=g.filter(v=>v.layer===t),h=I.filter(v=>v.layer===t),u=c.filter(v=>v.layer===t);if(B.length===0&&C.length===0&&l.length===0&&Q.length===0&&E.length===0&&h.length===0&&u.length===0)return null;const d=KG(e),f=document.createElement("canvas"),D=Math.floor(d.width*o),b=Math.floor(d.height*o);f.width=D,f.height=b;const m=f.getContext("2d");if(!m)return null;t==="bottom"&&(m.translate(0,b),m.scale(1,-1)),m.strokeStyle=i,m.fillStyle=i;const x=v=>(v-d.minX)*o,F=v=>(d.maxY-v)*o;l.forEach(v=>{const _=EQ(v.x1)??0,Y=EQ(v.y1)??0,P=EQ(v.x2)??0,K=EQ(v.y2)??0;_===P&&Y===K||(m.beginPath(),m.lineWidth=Cw(v.stroke_width,.1)*o,m.lineCap="round",m.moveTo(x(_),F(Y)),m.lineTo(x(P),F(K)),m.stroke())}),u.forEach(v=>{const _=EQ(v.x1)??0,Y=EQ(v.y1)??0,P=EQ(v.x2)??0,K=EQ(v.y2)??0;if(_===P&&Y===K)return;m.save();let O=i;v.color?O=mZA(v.color):O="rgb(255, 243, 204)",m.strokeStyle=O,m.beginPath(),m.lineWidth=Cw(v.stroke_width,.1)*o,m.lineCap="round";const W=v.is_dashed??!1;if(W){const $=Math.max(m.lineWidth*2,1);m.setLineDash([$,$])}m.moveTo(x(_),F(Y)),m.lineTo(x(P),F(K)),m.stroke(),W&&m.setLineDash([]),m.restore()}),C.forEach(v=>{v.route.length<2||(m.beginPath(),m.lineWidth=Cw(v.stroke_width,.1)*o,m.lineCap="round",m.lineJoin="round",v.route.forEach((_,Y)=>{const P=x(EQ(_.x)??0),K=F(EQ(_.y)??0);Y===0?m.moveTo(P,K):m.lineTo(P,K)}),m.stroke())}),E.forEach(v=>{const _=Cw(v.radius,0);if(_<=0)return;const Y=Cw(v.stroke_width,.12),P=Y>0,K=EQ(v.center?.x)??0,O=EQ(v.center?.y)??0,W=x(K),$=F(O),oA=_*o;if(m.save(),m.translate(W,$),P){const IA=oA+Y/2*o,tA=Math.max(0,oA-Y/2*o);tA>0?(m.beginPath(),m.arc(0,0,IA,0,2*Math.PI),m.arc(0,0,tA,0,2*Math.PI,!0),m.fill("evenodd")):(m.beginPath(),m.arc(0,0,IA,0,2*Math.PI),m.fill())}else m.beginPath(),m.arc(0,0,oA,0,2*Math.PI),m.fill();m.restore()}),Q.forEach(v=>{const _=Cw(v.width,0),Y=Cw(v.height,0);if(_<=0||Y<=0)return;const P=EQ(v.center?.x)??0,K=EQ(v.center?.y)??0,O=x(P),W=F(K),$=Ch(v),oA=typeof $=="string"?EQ($):$,IA=ay(_,Y,oA);m.save(),m.translate(O,W);const tA=_/2*o,sA=Y/2*o,gA=Math.min(IA*o,tA,sA),dA=v.stroke_width??!1,SA=v.is_filled??!0,RA=v.is_stroke_dashed??!1,NA=dA?Cw(v.stroke_width,.1)*o:0;if(((BA,fA,hA,KA,te)=>{if(m.beginPath(),te<=0)m.rect(BA,fA,hA,KA);else{const Be=te,yA=BA+hA,OA=fA+KA;m.moveTo(BA+Be,fA),m.lineTo(yA-Be,fA),m.quadraticCurveTo(yA,fA,yA,fA+Be),m.lineTo(yA,OA-Be),m.quadraticCurveTo(yA,OA,yA-Be,OA),m.lineTo(BA+Be,OA),m.quadraticCurveTo(BA,OA,BA,OA-Be),m.lineTo(BA,fA+Be),m.quadraticCurveTo(BA,fA,BA+Be,fA),m.closePath()}})(-tA,-sA,tA*2,sA*2,gA),SA&&m.fill(),dA&&NA>0){if(m.lineWidth=NA,RA){const BA=Math.max(NA*2,1);m.setLineDash([BA,BA])}m.stroke(),RA&&m.setLineDash([])}m.restore()}),h.forEach(v=>{const _=Cw(v.width,0),Y=Cw(v.height,0);if(_<=0||Y<=0)return;const P=EQ(v.center?.x)??0,K=EQ(v.center?.y)??0,O=x(P),W=F(K),$=Ch(v),oA=typeof $=="string"?EQ($):$,IA=ay(_,Y,oA);m.save(),m.translate(O,W);const tA=_/2*o,sA=Y/2*o,gA=Math.min(IA*o,tA,sA),dA=v.has_stroke??!1,SA=v.is_filled??!0,RA=v.is_stroke_dashed??!1,NA=dA?Cw(v.stroke_width,.1)*o:0;let TA=i,BA=i;if(v.color){const hA=mZA(v.color);TA=hA,BA=hA}else TA="rgb(255, 243, 204)",BA="rgb(255, 243, 204)";if(((hA,KA,te,Be,yA)=>{if(m.beginPath(),yA<=0)m.rect(hA,KA,te,Be);else{const OA=yA,YA=hA+te,HA=KA+Be;m.moveTo(hA+OA,KA),m.lineTo(YA-OA,KA),m.quadraticCurveTo(YA,KA,YA,KA+OA),m.lineTo(YA,HA-OA),m.quadraticCurveTo(YA,HA,YA-OA,HA),m.lineTo(hA+OA,HA),m.quadraticCurveTo(hA,HA,hA,HA-OA),m.lineTo(hA,KA+OA),m.quadraticCurveTo(hA,KA,hA+OA,KA),m.closePath()}})(-tA,-sA,tA*2,sA*2,gA),SA&&(m.fillStyle=TA,m.fill()),dA&&NA>0){if(m.strokeStyle=BA,m.lineWidth=NA,RA){const hA=Math.max(NA*2,1);m.setLineDash([hA,hA])}m.stroke(),RA&&m.setLineDash([])}m.restore()}),B.forEach(v=>{const _=v.font_size||.25,Y=Math.min(Math.max(.01,_*.1),_*.05)*o;m.lineWidth=Y,m.lineCap="butt",m.lineJoin="miter";const P=(0,Vht.vectorText)({height:_*.45,input:v.text}),K=[];P.forEach(RA=>{RA.length===29?(K.push(RA.slice(0,15)),K.push(RA.slice(14,29))):RA.length===17?(K.push(RA.slice(0,10)),K.push(RA.slice(9,17))):K.push(RA)});const O=K.flat(),W={minX:O.length>0?Math.min(...O.map(RA=>RA[0])):0,maxX:O.length>0?Math.max(...O.map(RA=>RA[0])):0,minY:O.length>0?Math.min(...O.map(RA=>RA[1])):0,maxY:O.length>0?Math.max(...O.map(RA=>RA[1])):0},$=(W.minX+W.maxX)/2,oA=(W.minY+W.maxY)/2;let IA=-$,tA=-oA;const sA=v.anchor_alignment||"center";sA.includes("left")?IA=-W.minX:sA.includes("right")&&(IA=-W.maxX),sA.includes("top")?tA=-W.maxY:sA.includes("bottom")&&(tA=-W.minY);const gA=[];let dA=v.ccw_rotation??0;if(v.layer==="bottom"&&(gA.push(fx($,oA),{a:-1,b:0,c:0,d:1,e:0,f:0},fx(-$,-oA)),dA=-dA),dA){const RA=dA*Math.PI/180;gA.push(fx($,oA),yZA(RA),fx(-$,-oA))}const SA=gA.length>0?fZA(...gA):void 0;K.forEach(RA=>{m.beginPath(),RA.forEach((NA,TA)=>{let BA={x:NA[0],y:NA[1]};SA&&(BA=dZA(SA,BA));const fA=BA.x+IA+v.anchor_position.x,hA=BA.y+tA+v.anchor_position.y,KA=x(fA),te=F(hA);TA===0?m.moveTo(KA,te):m.lineTo(KA,te)}),m.stroke()})});const k=new tN(f);return k.generateMipmaps=!0,k.minFilter=Qu,k.magFilter=WB,k.anisotropy=16,k.needsUpdate=!0,k}function DZA(t){return t&&t.route_type==="wire"&&typeof t.layer=="string"&&typeof t.width=="number"}function P_({layer:t,circuitJson:A,boardData:e,traceColor:i,traceTextureResolution:o}){const n=wi(A).pcb_trace.list(),s=wi(A).pcb_via.list(),r=wi(A).pcb_plated_hole.list(),a=n.filter(Q=>Q.route.some(E=>DZA(E)&&E.layer===t));if(a.length===0)return null;const g=KG(e),I=document.createElement("canvas"),c=Math.floor(g.width*o),B=Math.floor(g.height*o);I.width=c,I.height=B;const C=I.getContext("2d");if(!C)return null;t==="bottom"&&(C.translate(0,B),C.scale(1,-1)),a.forEach(Q=>{let E=!0;C.beginPath(),C.strokeStyle=i,C.lineCap="round",C.lineJoin="round";let h=0;for(const u of Q.route){if(!DZA(u)||u.layer!==t){E||C.stroke(),E=!0;continue}const d=u.x,f=u.y;h=u.width*o,C.lineWidth=h;const D=(d-g.minX)*o,b=(g.maxY-f)*o;E?(C.moveTo(D,b),E=!1):C.lineTo(D,b)}E||C.stroke()}),C.globalCompositeOperation="destination-out",C.fillStyle="black",s.forEach(Q=>{const E=(Q.x-g.minX)*o,h=(g.maxY-Q.y)*o,u=Q.outer_diameter/2*o;C.beginPath(),C.arc(E,h,u,0,2*Math.PI,!1),C.fill()}),r.forEach(Q=>{if(Q.layers.includes(t)&&Q.shape==="circle"){const E=(Q.x-g.minX)*o,h=(g.maxY-Q.y)*o,u=Q.outer_diameter/2*o;C.beginPath(),C.arc(E,h,u,0,2*Math.PI,!1),C.fill()}}),C.globalCompositeOperation="source-over";const l=new tN(I);return l.generateMipmaps=!0,l.minFilter=Qu,l.magFilter=WB,l.anisotropy=16,l.needsUpdate=!0,l}var tut=yr(ABA());function jO(t,A){if(t===void 0)return A;if(typeof t=="number")return t;const e=parseFloat(t.replace(/mm$/,""));return isNaN(e)?A:e}function iut(t){return t.layer==="bottom"?t.is_mirrored!==!1:t.is_mirrored===!0}function out(t){const A=t.flat();if(A.length===0)return{minX:0,maxX:0,minY:0,maxY:0,width:0,height:0,centerX:0,centerY:0};const e=Math.min(...A.map(s=>s[0])),i=Math.max(...A.map(s=>s[0])),o=Math.min(...A.map(s=>s[1])),n=Math.max(...A.map(s=>s[1]));return{minX:e,maxX:i,minY:o,maxY:n,width:i-e,height:n-o,centerX:(e+i)/2,centerY:(o+n)/2}}function nut(t){const A=[];return t.forEach(e=>{e.length===29?(A.push(e.slice(0,15)),A.push(e.slice(14,29))):e.length===17?(A.push(e.slice(0,10)),A.push(e.slice(9,17))):A.push(e)}),A}function sut(t,A){let e=-t.centerX,i=-t.centerY;return A.includes("left")?e=-t.minX:A.includes("right")&&(e=-t.maxX),A.includes("top")?i=-t.maxY:A.includes("bottom")&&(i=-t.minY),{x:e,y:i}}function rut(t,A){const e=[];let i=t.ccw_rotation??0;if(iut(t)&&(e.push(fx(A.centerX,A.centerY),{a:-1,b:0,c:0,d:1,e:0,f:0},fx(-A.centerX,-A.centerY)),i=-i),i){const s=i*Math.PI/180;e.push(fx(A.centerX,A.centerY),yZA(s),fx(-A.centerX,-A.centerY))}return{matrix:e.length>0?fZA(...e):void 0,rotationDeg:i}}function SZA(t,A,e,i,o,n,s){A.forEach(r=>{t.beginPath(),r.forEach((a,g)=>{let I={x:a[0],y:a[1]};e&&(I=dZA(e,I));const c=I.x+i.x+o.x,B=I.y+i.y+o.y,C=n(c),l=s(B);g===0?t.moveTo(C,l):t.lineTo(C,l)}),t.stroke()})}function aut(t,A,e,i,o,n){t.save(),t.translate(A,e),t.rotate(-n),t.fillRect(-i/2,-o/2,i,o),t.restore()}function gut(t,A,e,i,o,n,s,r,a,g){const I=typeof A.font_size=="number"?A.font_size:.2,c={left:jO(A.knockout_padding?.left,I*.5),right:jO(A.knockout_padding?.right,I*.5),top:jO(A.knockout_padding?.top,I*.3),bottom:jO(A.knockout_padding?.bottom,I*.3)},B=i.width+c.left+c.right,C=i.height+c.top+c.bottom,l=s(A.anchor_position.x),Q=r(A.anchor_position.y),E=B*a,h=C*a;t.fillStyle=g;const u=n*Math.PI/180;aut(t,l,Q,E,h,u);const d={x:-i.centerX,y:-i.centerY};t.globalCompositeOperation="destination-out",SZA(t,e,o,d,A.anchor_position,s,r),t.globalCompositeOperation="source-over"}function zO({layer:t,circuitJson:A,boardData:e,copperColor:i="rgb(230, 153, 51)",traceTextureResolution:o}){const s=A.filter(Q=>Q.type==="pcb_copper_text").filter(Q=>Q.layer===t);if(s.length===0)return null;const r=KG(e),a=document.createElement("canvas"),g=Math.floor(r.width*o),I=Math.floor(r.height*o);a.width=g,a.height=I;const c=a.getContext("2d");if(!c)return null;t==="bottom"&&(c.translate(0,I),c.scale(1,-1)),c.strokeStyle=i,c.fillStyle=i;const B=Q=>(Q-r.minX)*o,C=Q=>(r.maxY-Q)*o;s.forEach(Q=>{const E=typeof Q.font_size=="number"?Q.font_size:.2,h=Math.max(.02,E*.08)*o;c.lineWidth=h,c.lineCap="round",c.lineJoin="round";const u=(0,tut.vectorText)({height:E*.45,input:Q.text}),d=nut(u),f=out(d),{matrix:D,rotationDeg:b}=rut(Q,f);if(Q.is_knockout)gut(c,Q,d,f,D,b,B,C,o,i);else{const m=Q.anchor_alignment||"center",x=sut(f,m);SZA(c,d,D,x,Q.anchor_position,B,C)}});const l=new tN(a);return l.generateMipmaps=!0,l.minFilter=Qu,l.magFilter=WB,l.anisotropy=16,l.needsUpdate=!0,l}function XO({layer:t,circuitJson:A,panelData:e,outlineColor:i="black",traceTextureResolution:o}){const n=wi(A).pcb_board.list().filter(C=>C.pcb_panel_id===e.pcb_board_id);if(n.length===0)return null;const s=document.createElement("canvas"),r=Math.floor(e.width*o),a=Math.floor(e.height*o);s.width=r,s.height=a;const g=s.getContext("2d");if(!g)return null;t==="bottom"&&(g.translate(0,a),g.scale(1,-1)),g.strokeStyle=i,g.lineWidth=.05*o;const I=C=>(C-e.center.x+e.width/2)*o,c=C=>(-(C-e.center.y)+e.height/2)*o;n.forEach(C=>{if(C.outline&&C.outline.length>=2)g.beginPath(),C.outline.forEach((l,Q)=>{const E=I(l.x),h=c(l.y);Q===0?g.moveTo(E,h):g.lineTo(E,h)}),g.closePath(),g.stroke();else{const l=C.width,Q=C.height,{x:E,y:h}=C.center,u=I(E-l/2),d=c(h+Q/2);g.strokeRect(u,d,l*o,Q*o)}});const B=new tN(s);return B.generateMipmaps=!0,B.minFilter=Qu,B.magFilter=WB,B.anisotropy=16,B.needsUpdate=!0,B}function Iut({circuitJson:t,pcbThickness:A,isFaux:e=!1}){const{rootObject:i}=fu(),{visibility:o}=T_(),n=AA.useMemo(()=>{const r=t.filter(I=>I.type==="pcb_panel"),a=wi(t).pcb_board.list();if(r.length>0){const I=r[0],c=a.find(B=>B.pcb_panel_id===I.pcb_panel_id);return{type:"pcb_board",pcb_board_id:I.pcb_panel_id,center:I.center,width:I.width,height:I.height,thickness:c?.thickness??1.6,material:c?.material??"fr4",num_layers:c?.num_layers??2}}const g=a.filter(I=>!I.pcb_panel_id);return g.length>0?g[0]:null},[t]),s=AA.useMemo(()=>{if(!n||!n.width||!n.height)return null;const r=gZA[n.material]??No.fr4SolderMaskGreen,a=`rgb(${Math.round(r[0]*255)}, ${Math.round(r[1]*255)}, ${Math.round(r[2]*255)})`,g="rgb(255,255,255)",I=No.fr4TracesWithMaskGreen,c=`rgb(${Math.round(I[0]*255)}, ${Math.round(I[1]*255)}, ${Math.round(I[2]*255)})`;return{topSoldermask:WO({layer:"top",circuitJson:t,boardData:n,soldermaskColor:a,traceTextureResolution:lc}),bottomSoldermask:WO({layer:"bottom",circuitJson:t,boardData:n,soldermaskColor:a,traceTextureResolution:lc}),topSilkscreen:VO({layer:"top",circuitJson:t,boardData:n,silkscreenColor:g,traceTextureResolution:lc}),bottomSilkscreen:VO({layer:"bottom",circuitJson:t,boardData:n,silkscreenColor:g,traceTextureResolution:lc}),topTraceWithMask:P_({layer:"top",circuitJson:t,boardData:n,traceColor:c,traceTextureResolution:lc}),bottomTraceWithMask:P_({layer:"bottom",circuitJson:t,boardData:n,traceColor:c,traceTextureResolution:lc}),topCopperText:zO({layer:"top",circuitJson:t,boardData:n,copperColor:`rgb(${Math.round(No.copper[0]*255)}, ${Math.round(No.copper[1]*255)}, ${Math.round(No.copper[2]*255)})`,traceTextureResolution:lc}),bottomCopperText:zO({layer:"bottom",circuitJson:t,boardData:n,copperColor:`rgb(${Math.round(No.copper[0]*255)}, ${Math.round(No.copper[1]*255)}, ${Math.round(No.copper[2]*255)})`,traceTextureResolution:lc}),topPanelOutlines:XO({layer:"top",circuitJson:t,panelData:n,traceTextureResolution:lc}),bottomPanelOutlines:XO({layer:"bottom",circuitJson:t,panelData:n,traceTextureResolution:lc})}},[t,n]);return AA.useEffect(()=>{if(!i||!n||!s)return;const r=[],a=(I,c,B,C,l=!1,Q=!1)=>{if(!I)return null;const E=KG(n),h=new iw(E.width,E.height),u=new ld({map:I,transparent:!0,side:UC,depthWrite:Q,polygonOffset:l,polygonOffsetFactor:l?-1:0,polygonOffsetUnits:l?-1:0,opacity:e?YO:1}),d=new Oo(h,u);return d.position.set(E.centerX,E.centerY,c),B&&d.rotation.set(Math.PI,0,0),d.name=C,d},g=.001;if(o.topMask){const I=a(s.topSoldermask,A/2+g,!1,"jscad-top-soldermask",!0);I&&(r.push(I),i.add(I))}if(o.bottomMask){const I=a(s.bottomSoldermask,-A/2-g,!0,"jscad-bottom-soldermask",!0);I&&(r.push(I),i.add(I))}if(o.topCopper&&o.topMask){const I=a(s.topTraceWithMask,A/2+rI.traces+.004,!1,"jscad-top-trace-with-mask");I&&(r.push(I),i.add(I))}if(o.bottomCopper&&o.bottomMask){const I=a(s.bottomTraceWithMask,-A/2-rI.traces-.005,!0,"jscad-bottom-trace-with-mask");I&&(r.push(I),i.add(I))}if(o.topSilkscreen){const I=a(s.topSilkscreen,A/2+g+.002,!1,"jscad-top-silkscreen");I&&(r.push(I),i.add(I))}if(o.bottomSilkscreen){const I=a(s.bottomSilkscreen,-A/2-g-.002,!0,"jscad-bottom-silkscreen");I&&(r.push(I),i.add(I))}if(o.topCopper){const I=a(s.topCopperText,A/2+rI.copper,!1,"jscad-top-copper-text");I&&(r.push(I),i.add(I))}if(o.bottomCopper){const I=a(s.bottomCopperText,-A/2-rI.copper,!0,"jscad-bottom-copper-text");I&&(r.push(I),i.add(I))}if(o.boardBody){const I=a(s.topPanelOutlines,A/2+g+.003,!1,"jscad-top-panel-outlines",!1,!0);I&&(r.push(I),i.add(I));const c=a(s.bottomPanelOutlines,-A/2-g-.003,!0,"jscad-bottom-panel-outlines",!1,!0);c&&(r.push(c),i.add(c))}return()=>{r.forEach(I=>{I.parent===i&&i.remove(I),I.geometry.dispose(),I.material instanceof Rp&&I.material.dispose()})}},[i,n,s,A,o]),null}function cut(t){const A=wi(t).cad_component.list(),e=wi(t).pcb_smtpad.list(),i=wi(t).pcb_hole.list(),o=wi(t).pcb_plated_hole.list(),n=wi(t).pcb_via.list();if(A.length===0&&e.length===0&&i.length===0&&o.length===0&&n.length===0)return null;const s=[...i,...o,...n,...e],r=e2(s);let a=r.minX,g=r.maxX,I=r.minY,c=r.maxY;for(const u of A)if(u.position){const d=u.position.x,f=u.position.y;a=Math.min(a,d),g=Math.max(g,d),I=Math.min(I,f),c=Math.max(c,f)}a===1/0&&(a=-10,g=10,I=-10,c=10);const B=2,C=Math.max(Math.abs(a),Math.abs(g))+B,l=Math.max(Math.abs(I),Math.abs(c))+B,Q=Math.max(2*C,10),E=Math.max(2*l,10);return{type:"pcb_board",pcb_board_id:"faux-board",center:{x:0,y:0},width:Q,height:E,thickness:1.6,material:"fr4",num_layers:2}}function bZA(t){if(wi(t).pcb_board.list().length>0)return t;const e=cut(t);if(!e)return t;const o=e.thickness/2;return[...t.map(s=>{if(s.type==="cad_component"){const r=s;if(r.position){const a=r.position.z??0;return{...r,position:{...r.position,z:a+o}}}}return s}),e]}var But=AA.forwardRef(({soup:t,circuitJson:A,children:e,autoRotateDisabled:i,clickToInteractEnabled:o,onUserInteraction:n,onCameraControllerReady:s},r)=>{const a=aZA(e),g=AA.useMemo(()=>bZA(t??A??a),[t,A,a]),I=Kht(g),c=AA.useMemo(()=>{if(!g)return[5,-5,5];try{const u=wi(g).pcb_board.list()[0];if(!u)return[5,-5,5];const{width:d,height:f}=u;if(!d&&!f)return[5,-5,5];const D=5,b=Math.max(d,D),m=Math.max(f,D),x=Math.max(b,m);return[x*.4,-x*.7,x*.9]}catch(u){return console.error(u),[5,-5,5]}},[g]),B=AA.useMemo(()=>{if(!g)return!1;try{const u=wi(g).pcb_board.list()[0];return!!u&&u.pcb_board_id==="faux-board"}catch{return!1}},[g]),C=AA.useMemo(()=>{if(g)try{const u=wi(g).pcb_board.list()[0];return u?{width:u.width??0,height:u.height??0}:void 0}catch(u){console.error(u);return}},[g]),l=AA.useMemo(()=>{if(g)try{const u=wi(g).pcb_board.list()[0];return!u||!u.center?void 0:{x:u.center.x,y:u.center.y}}catch(u){console.error(u);return}},[g]),Q=Tht(g),{stls:E}=dht(I),h=wi(g).cad_component.list();return V.jsxs(rZA,{ref:r,autoRotateDisabled:i,initialCameraPosition:c,clickToInteractEnabled:o,boardDimensions:C,boardCenter:l,onUserInteraction:n,onCameraControllerReady:s,children:[E.map(({stlData:u,color:d,layerType:f},D)=>V.jsx(Wht,{stlData:u,color:d,opacity:D===0?B?.8:.95:1,layerType:f},`board-${D}`)),V.jsx(Iut,{circuitJson:g,pcbThickness:Q,isFaux:B}),h.map(u=>V.jsx(uZA,{fallback:({error:d})=>V.jsx(hZA,{cad_component:u,error:d}),children:V.jsx(tZA,{cad_component:u,circuitJson:g},u.cad_component_id)},u.cad_component_id))]})}),Cut=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;t[i]&&t[o]&&(A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1])}return A/2<=0};function lut(t,A,e,i,o){let n,s=null;if(e.outline&&e.outline.length>=3){let r=e.outline.map(g=>[g.x,g.y]);Cut(r)&&(r=r.reverse());const a=A.ofPolygons([r]);o.push(a),s=a,n=t.extrude(a,i,void 0,void 0,void 0,!0),o.push(n)}else e.outline&&e.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),n=t.cube([e.width,e.height,i],!0),o.push(n),n=n.translate([e.center.x,e.center.y,0]),o.push(n);return{boardOp:n,outlineCrossSection:s}}var Qut=64;function gy({Manifold:t,width:A,height:e,thickness:i,borderRadius:o}){const n=ay(A,e,o);if(n<=0)return t.cube([A,e,i],!0);const s=[],r=A-2*n,a=e-2*n;return r>0&&s.push(t.cube([r,e,i],!0)),a>0&&s.push(t.cube([A,a,i],!0)),[[A/2-n,e/2-n],[-A/2+n,e/2-n],[-A/2+n,-e/2+n],[A/2-n,-e/2+n]].forEach(([I,c])=>{s.push(t.cylinder(i,n,n,Qut,!0).translate([I,c,0]))}),t.union(s)}function Eut({Manifold:t,pad:A,padBaseThickness:e}){if(A.shape==="rect"){const i=Ch(A);return gy({Manifold:t,width:A.width,height:A.height,thickness:e,borderRadius:i})}else if(A.shape==="rotated_rect"){const i=Ch(A);let o=gy({Manifold:t,width:A.width,height:A.height,thickness:e,borderRadius:i});const n=A.ccw_rotation??0;return n&&(o=o.rotate([0,0,n])),o}else if(A.shape==="circle"&&A.radius)return t.cylinder(e,A.radius,-1,32,!0);return null}var hut=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;t[i]&&t[o]&&(A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1])}return A/2<=0};function uut(t,A,e,i,o){const n=[],s=wi(e).pcb_cutout.list();for(const r of s){let a;const g=i*1.5;switch(r.shape){case"rect":{const B=Ch(r);if(typeof B=="number"&&B>0?a=gy({Manifold:t,width:r.width,height:r.height,thickness:g,borderRadius:B}):a=t.cube([r.width,r.height,g],!0),o.push(a),r.rotation){const C=a.rotate([0,0,r.rotation]);o.push(C),a=C}a=a.translate([r.center.x,r.center.y,0]),o.push(a);break}case"circle":a=t.cylinder(g,r.radius,-1,wl,!0),o.push(a),a=a.translate([r.center.x,r.center.y,0]),o.push(a);break;case"polygon":if(r.points.length<3){console.warn(`PCB Cutout [${r.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);continue}let I=r.points.map(B=>[B.x,B.y]);hut(I)&&(I=I.reverse());const c=A.ofPolygons([I]);o.push(c),a=t.extrude(c,g,0,0,[1,1],!0),o.push(a);break;default:console.warn(`Unsupported cutout shape: ${r.shape} for cutout ${r.pcb_cutout_id}`);continue}a&&n.push(a)}return{cutoutOps:n}}function xZA({Manifold:t,x:A,y:e,diameter:i,thickness:o,segments:n=32}){return t.cylinder(o*1.2,i/2,i/2,n,!0).translate([A,e,0])}function kZA({Manifold:t,x:A,y:e,holeDiameter:i,thickness:o,zOffset:n=.001,segments:s=32}){const r=i/2+n;return t.cylinder(o*1.2,r,r,s,!0).translate([A,e,0])}function dut(t){return t.hole_shape==="circle"&&typeof t.hole_diameter=="number"}function put(t){return(t.shape==="pill"||t.hole_shape==="pill")&&typeof t.hole_width=="number"&&typeof t.hole_height=="number"}function fut(t){return(t.shape==="rotated_pill"||t.hole_shape==="rotated_pill")&&typeof t.hole_width=="number"&&typeof t.hole_height=="number"&&typeof t.ccw_rotation=="number"}function yut(t,A,e,i){const o=[],n=wi(A).pcb_hole.list(),s=(r,a,g)=>{const I=gy({Manifold:t,width:r,height:a,thickness:g,borderRadius:Math.min(r,a)/2});return i.push(I),I};return n.forEach(r=>{if(dut(r)){const a=xZA({Manifold:t,x:r.x,y:r.y,diameter:r.hole_diameter,thickness:e,segments:wl});i.push(a),o.push(a)}else if(put(r)){const a=r.hole_width,g=r.hole_height,I=e*1.2,B=s(a,g,I).translate([r.x,r.y,0]);i.push(B),o.push(B)}else if(fut(r)){const a=r.hole_width,g=r.hole_height,I=e*1.2;let c=s(a,g,I);const B=c.rotate([0,0,r.ccw_rotation]);i.push(B),c=B;const C=c.translate([r.x,r.y,0]);i.push(C),o.push(C)}}),{nonPlatedHoleBoardDrills:o}}function ym(t){const A=new Cg;if(A.setAttribute("position",new Un(t.vertProperties,3)),A.setIndex(new Jj(t.triVerts,1)),t.runIndex&&t.runIndex.length>1&&t.runOriginalID)for(let e=0;e<t.runIndex.length-1;e++){const i=t.runIndex[e],o=t.runIndex[e+1]-i;A.addGroup(i,o,0)}else A.addGroup(0,t.triVerts.length,0);return A}var OU=t=>{let A=0;for(let i=0;i<t.length;i++){const o=(i+1)%t.length;t[i]&&t[o]&&(A+=t[i][0]*t[o][1],A-=t[o][0]*t[i][1])}return A/2<=0},$O=(t,A,e)=>{const i=[];for(let o=0;o<e;o++){const n=2*Math.PI*o/e;i.push([t/2*Math.cos(n),A/2*Math.sin(n)])}return i},O_=new Ui(...No.copper),GZA=.05;function wut(t,A,e,i,o,n){const s=[],r=wi(e).pcb_plated_hole.list(),a=[],g=[],I=(l,Q,E)=>{const h=gy({Manifold:t,width:l,height:Q,thickness:E,borderRadius:Math.min(l,Q)/2});return o.push(h),h},c=({padOutline:l,thickness:Q})=>{if(!Array.isArray(l)||l.length<3)return null;let E=l.map(d=>[d.x,d.y]);OU(E)&&(E=E.reverse());const h=A.ofPolygons([E]);o.push(h);const u=t.extrude(h,Q,0,0,[1,1],!0);return o.push(u),u},B=({ph:l,depth:Q,sizeDelta:E=0})=>{if(l.shape!=="hole_with_polygon_pad")return null;const u=l.pad_outline;if(!Array.isArray(u)||u.length<3)return null;const d=l.hole_shape||"circle",f=l.hole_offset_x||0,D=l.hole_offset_y||0;let b=null;if(d==="circle"){const m=Math.max((l.hole_diameter??0)+E,Wo),x=Math.max(m/2,Wo/2);b=t.cylinder(Q,x,x,wl,!0),o.push(b)}else{const m=l.hole_width??l.hole_diameter,x=l.hole_height??l.hole_diameter;if(!m||!x)return null;const F=Math.max(m+E,Wo),k=Math.max(x+E,Wo);if(d==="oval"){let v=$O(F,k,wl);OU(v)&&(v=v.reverse());const _=A.ofPolygons([v]);o.push(_),b=t.extrude(_,Q,0,0,[1,1],!0),o.push(b)}else(d==="pill"||d==="rotated_pill")&&(b=gy({Manifold:t,width:F,height:k,thickness:Q,borderRadius:Math.min(F,k)/2}),o.push(b))}if(!b)return null;if(f||D){const m=b.translate([f,D,0]);o.push(m),b=m}return b};r.forEach((l,Q)=>{if(l.shape==="circle"){const E=kZA({Manifold:t,x:l.x,y:l.y,holeDiameter:l.hole_diameter*1.02,thickness:i,zOffset:ry,segments:wl});o.push(E),s.push(E);const h=i+2*ry,u=t.cylinder(h,l.outer_diameter/2,l.outer_diameter/2,wl,!0);o.push(u);const d=t.cylinder(h*1.05,l.hole_diameter/2,l.hole_diameter/2,wl,!0);o.push(d);const f=u.subtract(d);o.push(f);const D=f.translate([l.x,l.y,0]);o.push(D);let b=D;if(n){const x=t.intersection([D,n]);o.push(x),b=x}g.push(b);const m=ym(b.getMesh());a.push({key:`ph-${l.pcb_plated_hole_id||Q}`,geometry:m,color:O_})}else if(l.shape==="pill"){const E=l.hole_width,h=l.hole_height,u=.4,d=l.outer_width??E+u,f=l.outer_height??h+u,D=E+2*ry,b=h+2*ry,m=i*1.2;let x=I(D,b,m);if(l.ccw_rotation){const W=x.rotate([0,0,l.ccw_rotation]);o.push(W),x=W}const F=x.translate([l.x,l.y,0]);o.push(F),s.push(F);const k=i+2*ry,v=I(d,f,k),_=I(E,h,k*1.05);let Y=v.subtract(_);if(o.push(Y),l.ccw_rotation){const W=Y.rotate([0,0,l.ccw_rotation]);o.push(W),Y=W}const P=Y.translate([l.x,l.y,0]);o.push(P);let K=P;if(n){const W=t.intersection([P,n]);o.push(W),K=W}g.push(K);const O=ym(K.getMesh());a.push({key:`ph-${l.pcb_plated_hole_id||Q}`,geometry:O,color:O_})}else if(l.shape==="pill_hole_with_rect_pad"){const E=l.hole_width,h=l.hole_height,u=l.hole_offset_x||0,d=l.hole_offset_y||0,f=l.rect_pad_width,D=l.rect_pad_height,b=Ch(l),m=HO,x=E+2*ry,F=h+2*ry,k=i*1.2,_=I(x,F,k).translate([u,d,0]).translate([l.x,l.y,0]);o.push(_),s.push(_);const Y=gy({Manifold:t,width:f,height:D,thickness:i-2*m-2*rI.copper+.1,borderRadius:b});o.push(Y);const P=gy({Manifold:t,width:f,height:D,thickness:m,borderRadius:b}).translate([0,0,i/2/2+rI.copper]),K=gy({Manifold:t,width:f,height:D,thickness:m,borderRadius:b}).translate([0,0,-i/2/2-rI.copper]);o.push(P,K);const O=I(E,h,i*1.02).translate([u,d,0]);o.push(O);const W=t.union([Y,P,K,O]);o.push(W);const $=I(Math.max(E-2*GZA,.01),Math.max(h-2*GZA,.01),i*1.2).translate([u,d,0]);o.push($);const oA=W.subtract($);o.push(oA);const IA=oA.translate([l.x,l.y,0]);o.push(IA);let tA=IA;if(n){const gA=t.intersection([IA,n]);o.push(gA),tA=gA}g.push(tA);const sA=ym(tA.getMesh());a.push({key:`ph-${l.pcb_plated_hole_id||Q}`,geometry:sA,color:O_})}else if(l.shape==="hole_with_polygon_pad"){const E=l.pad_outline;if(!Array.isArray(E)||E.length<3)return;const h=B({ph:l,depth:i*1.2,sizeDelta:2*Wo});if(!h)return;const u=h.translate([l.x,l.y,0]);o.push(u),s.push(u);const d=HO,f=Math.max(i-2*d-2*rI.copper+.1,Wo),D=c({padOutline:E,thickness:f}),b=c({padOutline:E,thickness:d}),m=c({padOutline:E,thickness:d});if(!D||!b||!m)return;const x=b.translate([0,0,i/2/2+rI.copper]),F=m.translate([0,0,-i/2/2-rI.copper]);o.push(x,F);const k=B({ph:l,depth:i*1.02});if(!k)return;const v=B({ph:l,depth:i*1.2,sizeDelta:-2*Wo})||k,_=t.union([D,x,F,k]);o.push(_);const Y=_.subtract(v);o.push(Y);const P=Y.translate([l.x,l.y,0]);o.push(P);let K=P;if(n){const W=t.intersection([P,n]);o.push(W),K=W}g.push(K);const O=ym(K.getMesh());a.push({key:`ph-${l.pcb_plated_hole_id||Q}`,geometry:O,color:O_})}else if(l.shape==="oval"){const E=l.hole_width,h=l.hole_height,u=l.outer_width??E+.4,d=l.outer_height??h+.4,f=E+2*ry,D=h+2*ry,b=i*1.2;let m=$O(f,D,wl);OU(m)&&(m=m.reverse());const x=A.ofPolygons([m]);o.push(x);let F=t.extrude(x,b,0,0,[1,1],!0);if(o.push(F),l.ccw_rotation){const sA=F.rotate([0,0,l.ccw_rotation]);o.push(sA),F=sA}const k=F.translate([l.x,l.y,0]);o.push(k),s.push(k);const v=i+2*ry;let _=$O(u,d,wl);OU(_)&&(_=_.reverse());const Y=A.ofPolygons([_]);o.push(Y);let P=t.extrude(Y,v,0,0,[1,1],!0);o.push(P);let K=$O(E,h,wl);OU(K)&&(K=K.reverse());const O=A.ofPolygons([K]);o.push(O);let W=t.extrude(O,v*1.05,0,0,[1,1],!0);o.push(W);let $=P.subtract(W);if(o.push($),l.ccw_rotation){const sA=$.rotate([0,0,l.ccw_rotation]);o.push(sA),$=sA}const oA=$.translate([l.x,l.y,0]);o.push(oA);let IA=oA;if(n){const sA=t.intersection([oA,n]);o.push(sA),IA=sA}g.push(IA);const tA=ym(IA.getMesh());a.push({key:`ph-${l.pcb_plated_hole_id||Q}`,geometry:tA,color:O_})}else if(l.shape==="circular_hole_with_rect_pad"){const E=l.hole_offset_x||0,h=l.hole_offset_y||0,u=xZA({Manifold:t,x:l.x+E,y:l.y+h,diameter:l.hole_diameter,thickness:i,segments:wl});o.push(u),s.push(u);const d=l.rect_pad_width??l.hole_diameter,f=l.rect_pad_height??l.hole_diameter,D=Ch(l),b=HO,m=l.hole_diameter/2,x=gy({Manifold:t,width:d,height:f,thickness:i-2*b-2*rI.copper+.1,borderRadius:D});o.push(x);const F=gy({Manifold:t,width:d,height:f,thickness:b,borderRadius:D}).translate([0,0,i/2/2+rI.copper]),k=gy({Manifold:t,width:d,height:f,thickness:b,borderRadius:D}).translate([0,0,-i/2/2-rI.copper]);o.push(F,k);const v=t.cylinder(i*1.02,m,m,wl,!0).translate([E,h,0]);o.push(v);const _=t.union([x,F,k,v]);o.push(_);const Y=t.cylinder(i*1.2,Math.max(m-Wo,.01),Math.max(m-Wo,.01),wl,!0).translate([E,h,0]);o.push(Y);const P=_.subtract(Y);o.push(P);const K=P.translate([l.x,l.y,0]);o.push(K);let O=K;if(n){const $=t.intersection([K,n]);o.push($),O=$}g.push(O);const W=ym(O.getMesh());a.push({key:`ph-${l.pcb_plated_hole_id||Q}`,geometry:W,color:O_})}});let C;return g.length>0&&(C=t.union(g),o.push(C)),{platedHoleBoardDrills:s,platedHoleCopperGeoms:a,platedHoleSubtractOp:C}}var mut=new Ui(...No.copper);function Dut(t,A,e,i,o,n){const s=[];return wi(A).pcb_smtpad.list().forEach((a,g)=>{const I=HO,c=a.layer==="bottom"?-e/2-rI.copper:e/2+rI.copper;let B=Eut({Manifold:t,pad:a,padBaseThickness:I});if(B){i.push(B);const C=B.translate([a.x,a.y,c]);i.push(C);let l=C;if(o&&(l=C.subtract(o),i.push(l)),n){const E=t.intersection([l,n]);i.push(E),l=E}const Q=ym(l.getMesh());s.push({key:`smt_pad-${a.layer||"top"}-${a.pcb_smtpad_id||g}`,geometry:Q,color:mut})}}),{smtPadGeoms:s}}function Sut({Manifold:t,x:A,y:e,outerDiameter:i,holeDiameter:o,thickness:n,zOffset:s=.001,segments:r=32}){const a=s,g=s;if(i<o)throw new Error(`Invalid via geometry: outerDiameter (${i}) must be >= holeDiameter (${o})`);const I=Math.min(i/2,o/2+g),c=t.cylinder(n,I,-1,r,!0),B=t.cylinder(a,i/2,-1,r,!0).translate([0,0,n/2]),C=t.cylinder(a,i/2,-1,r,!0).translate([0,0,-n/2]),l=t.union([c,B,C]),Q=n+a*2,E=t.cylinder(Q,o/2,-1,r,!0);return l.subtract(E).translate([A,e,0])}var but=new Ui(...No.copper);function xut(t,A,e,i,o){const n=[],s=wi(A).pcb_via.list(),r=[];return s.forEach((a,g)=>{if(typeof a.hole_diameter=="number"){const I=kZA({Manifold:t,x:a.x,y:a.y,holeDiameter:a.hole_diameter,thickness:e,zOffset:ry,segments:wl});i.push(I),n.push(I)}if(typeof a.outer_diameter=="number"&&typeof a.hole_diameter=="number"){const I=Sut({Manifold:t,x:a.x,y:a.y,outerDiameter:a.outer_diameter,holeDiameter:a.hole_diameter,thickness:e,zOffset:ry,segments:wl});i.push(I);let c=I;if(o){const C=t.intersection([I,o]);i.push(C),c=C}const B=ym(c.getMesh());r.push({key:`via-${a.pcb_via_id||g}`,geometry:B,color:but})}}),{viaBoardDrills:n,viaCopperGeoms:r}}function FZA({ctx:t,points:A,canvasXFromPcb:e,canvasYFromPcb:i}){A.length<3||(t.beginPath(),A.forEach((o,n)=>{const s=e(o[0]),r=i(o[1]);n===0?t.moveTo(s,r):t.lineTo(s,r)}),t.closePath(),t.fill())}function kut({ctx:t,pour:A,canvasXFromPcb:e,canvasYFromPcb:i}){const o=A.brep_shape;if(!o||!o.outer_ring)return;const n=OO(o.outer_ring,32);if(n.length>=3&&FZA({ctx:t,points:n,canvasXFromPcb:e,canvasYFromPcb:i}),o.inner_rings&&o.inner_rings.length>0){t.globalCompositeOperation="destination-out";for(const s of o.inner_rings){const r=OO(s,32);r.length>=3&&FZA({ctx:t,points:r,canvasXFromPcb:e,canvasYFromPcb:i})}t.globalCompositeOperation="source-over"}}function RZA({layer:t,circuitJson:A,boardData:e,traceTextureResolution:i=lc}){const n=A.filter(E=>E.type==="pcb_copper_pour").filter(E=>E.layer===t);if(n.length===0)return null;const s=KG(e),r=document.createElement("canvas"),a=Math.floor(s.width*i),g=Math.floor(s.height*i);r.width=a,r.height=g;const I=r.getContext("2d");if(!I)return null;t==="bottom"&&(I.translate(0,g),I.scale(1,-1));const c=E=>(E-s.minX)*i,B=E=>(s.maxY-E)*i,C=n.filter(E=>E.shape==="rect"||E.shape==="polygon"),l=n.filter(E=>E.shape==="brep");if(C.length>0){const E=new qet(I);E.setCameraBounds({minX:s.minX,maxX:s.maxX,minY:s.minY,maxY:s.maxY});const h=C.filter(D=>D.covered_with_solder_mask!==!1),u=C.filter(D=>D.covered_with_solder_mask===!1),d=`rgb(${No.fr4TracesWithMaskGreen.map(D=>D*255).join(",")})`,f=`rgb(${No.copper.map(D=>D*255).join(",")})`;h.length>0&&(E.configure({colorOverrides:{copper:{top:d,bottom:d,inner1:d,inner2:d,inner3:d,inner4:d,inner5:d,inner6:d}}}),E.drawElements(h,{layers:[t]})),u.length>0&&(E.configure({colorOverrides:{copper:{top:f,bottom:f,inner1:f,inner2:f,inner3:f,inner4:f,inner5:f,inner6:f}}}),E.drawElements(u,{layers:[t]}))}for(const E of l){const u=E.covered_with_solder_mask!==!1?No.fr4TracesWithMaskGreen:No.copper,d=`rgb(${u[0]*255}, ${u[1]*255}, ${u[2]*255})`;I.fillStyle=d,kut({ctx:I,pour:E,canvasXFromPcb:c,canvasYFromPcb:B})}const Q=new tN(r);return Q.generateMipmaps=!0,Q.minFilter=Qu,Q.magFilter=WB,Q.anisotropy=16,Q.needsUpdate=!0,Q}function Tp(t,A){const{texture:e,yOffset:i,isBottomLayer:o,textureType:n,usePolygonOffset:s=!1,renderOrder:r=0,isFaux:a=!1}=t;if(!e)return null;const g=KG(A),I=new iw(g.width,g.height),c=new ld({map:e,transparent:!0,side:UC,depthWrite:n==="panel-outlines",polygonOffset:s,polygonOffsetFactor:s?-4:0,polygonOffsetUnits:s?-4:0,opacity:a?YO:1}),B=new Oo(I,c);return B.position.set(g.centerX,g.centerY,i),o&&B.rotation.set(Math.PI,0,0),B.name=`${o?"bottom":"top"}-${n}-texture-plane`,B.renderOrder=r,B}function Gut(t,A,e,i=!1){const o=[];if(!t||!A||e===null)return o;const n=Tp({texture:t.topTrace,yOffset:e/2+rI.traces,isBottomLayer:!1,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);n&&o.push(n);const s=Tp({texture:t.topTraceWithMask,yOffset:e/2+rI.traces,isBottomLayer:!1,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);s&&o.push(s);const r=Tp({texture:t.topSilkscreen,yOffset:e/2+.003,isBottomLayer:!1,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);r&&o.push(r);const a=Tp({texture:t.bottomTrace,yOffset:-e/2-rI.traces,isBottomLayer:!0,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);a&&o.push(a);const g=Tp({texture:t.bottomTraceWithMask,yOffset:-e/2-rI.traces,isBottomLayer:!0,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);g&&o.push(g);const I=Tp({texture:t.bottomSilkscreen,yOffset:-e/2-.003,isBottomLayer:!0,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);I&&o.push(I);const c=Tp({texture:t.topSoldermask,yOffset:e/2+.001,isBottomLayer:!1,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);c&&o.push(c);const B=Tp({texture:t.bottomSoldermask,yOffset:-e/2-.001,isBottomLayer:!0,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);B&&o.push(B);const C=Tp({texture:t.topCopperText,yOffset:e/2+rI.copper,isBottomLayer:!1,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);C&&o.push(C);const l=Tp({texture:t.bottomCopperText,yOffset:-e/2-rI.copper,isBottomLayer:!0,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);l&&o.push(l);const Q=Tp({texture:t.topCopper,yOffset:e/2+rI.copper,isBottomLayer:!1,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);Q&&o.push(Q);const E=Tp({texture:t.bottomCopper,yOffset:-e/2-rI.copper,isBottomLayer:!0,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);E&&o.push(E);const h=Tp({texture:t.topPanelOutlines,yOffset:e/2+.004,isBottomLayer:!1,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);h&&o.push(h);const u=Tp({texture:t.bottomPanelOutlines,yOffset:-e/2-.004,isBottomLayer:!0,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);return u&&o.push(u),o}var Fut=(t,A)=>{const[e,i]=AA.useState(null),[o,n]=AA.useState(null),[s,r]=AA.useState(null),[a,g]=AA.useState(null),[I,c]=AA.useState(!0),B=AA.useRef([]),C=AA.useMemo(()=>{const Q=A.filter(u=>u.type==="pcb_panel"),E=wi(A).pcb_board.list();if(Q.length>0){const u=Q[0],d=E.find(f=>f.pcb_panel_id===u.pcb_panel_id);return{type:"pcb_board",pcb_board_id:u.pcb_panel_id,center:u.center,width:u.width,height:u.height,thickness:d?.thickness??1.6,material:d?.material??"fr4",num_layers:d?.num_layers??2}}const h=E.filter(u=>!u.pcb_panel_id);return h.length>0?h[0]:null},[A]),l=AA.useMemo(()=>{const Q=wi(A).pcb_board.list();return Q.length>0&&Q[0].pcb_board_id==="faux-board"},[A]);return AA.useEffect(()=>{if(!t||!C){i(null),n(null),r(null),c(!1);return}if((C.width===0||!C.width)&&(C.height===0||!C.height)&&(!C.outline||C.outline.length<3)){i({platedHoles:[],smtPads:[],vias:[]}),n({}),r(C.thickness??0),c(!1);return}c(!0),g(null);const Q=t.Manifold,E=t.CrossSection,h=D=>{if(!(!D||typeof D.delete!="function"))try{D.delete()}catch(b){(!(b instanceof Error)||!b.message?.includes("Manifold instance already deleted"))&&console.warn("Failed to delete Manifold instance",b)}};B.current.forEach(h),B.current=[];let u=null;const d={},f={};try{const D=C.thickness||1.6;r(D);const{boardOp:b,outlineCrossSection:m}=lut(Q,E,C,D,B.current);let x=b;const k=D+2*1;let v=null;const _=.01;if(m){let KA=m;if(_>0){const Be=m.offset(_);B.current.push(Be),KA=Be}const te=Q.extrude(KA,k,void 0,void 0,void 0,!0);B.current.push(te),v=te}else{const KA=(C.width||0)+2*_,te=(C.height||0)+2*_,Be=Q.cube([KA,te,k],!0);B.current.push(Be);const yA=Be.translate([C.center.x,C.center.y,0]);B.current.push(yA),v=yA}const Y=[];let P=null;const{nonPlatedHoleBoardDrills:K}=yut(Q,A,D,B.current);Y.push(...K);const{platedHoleBoardDrills:O,platedHoleCopperGeoms:W,platedHoleSubtractOp:$}=wut(Q,E,A,D,B.current,v);Y.push(...O),d.platedHoles=W;const{viaBoardDrills:oA,viaCopperGeoms:IA}=xut(Q,A,D,B.current,v);if(Y.push(...oA),d.vias=IA,Y.length>0){P=Q.union(Y),B.current.push(P);const KA=$?Q.union([P,$]):P;B.current.push(KA);const te=x.subtract(KA);if(B.current.push(te),x=te,$){const Be=$.subtract(P);B.current.push(Be);const yA=Be.getMesh(),OA=ym(yA);d.platedHoles=[{key:"plated-holes-union",geometry:OA,color:new Ui(No.copper[0],No.copper[1],No.copper[2])}]}}const{cutoutOps:tA}=uut(Q,E,A,D,B.current);if(tA.length>0){const KA=Q.union(tA);B.current.push(KA);const te=x.subtract(KA);B.current.push(te),x=te}if(u=x,u){const KA=u.getMesh(),te=ym(KA),Be=qBA[C.material]??No.fr4Tan;d.board={geometry:te,color:new Ui(Be[0],Be[1],Be[2]),material:C.material,isFaux:l}}const{smtPadGeoms:sA}=Dut(Q,A,D,B.current,P,v);d.smtPads=sA,i(d);const gA=No.fr4TracesWithoutMaskTan,dA=`rgb(${Math.round(gA[0]*255)}, ${Math.round(gA[1]*255)}, ${Math.round(gA[2]*255)})`;f.topTrace=P_({layer:"top",circuitJson:A,boardData:C,traceColor:dA,traceTextureResolution:lc}),f.bottomTrace=P_({layer:"bottom",circuitJson:A,boardData:C,traceColor:dA,traceTextureResolution:lc});const SA=No.fr4TracesWithMaskGreen,RA=`rgb(${Math.round(SA[0]*255)}, ${Math.round(SA[1]*255)}, ${Math.round(SA[2]*255)})`;f.topTraceWithMask=P_({layer:"top",circuitJson:A,boardData:C,traceColor:RA,traceTextureResolution:lc}),f.bottomTraceWithMask=P_({layer:"bottom",circuitJson:A,boardData:C,traceColor:RA,traceTextureResolution:lc});const NA="rgb(255,255,255)";f.topSilkscreen=VO({layer:"top",circuitJson:A,boardData:C,silkscreenColor:NA,traceTextureResolution:lc}),f.bottomSilkscreen=VO({layer:"bottom",circuitJson:A,boardData:C,silkscreenColor:NA,traceTextureResolution:lc});const TA=gZA[C.material]??No.fr4SolderMaskGreen,BA=`rgb(${Math.round(TA[0]*255)}, ${Math.round(TA[1]*255)}, ${Math.round(TA[2]*255)})`;f.topSoldermask=WO({layer:"top",circuitJson:A,boardData:C,soldermaskColor:BA,traceTextureResolution:lc}),f.bottomSoldermask=WO({layer:"bottom",circuitJson:A,boardData:C,soldermaskColor:BA,traceTextureResolution:lc});const fA=No.copper,hA=`rgb(${Math.round(fA[0]*255)}, ${Math.round(fA[1]*255)}, ${Math.round(fA[2]*255)})`;f.topCopperText=zO({layer:"top",circuitJson:A,boardData:C,copperColor:hA,traceTextureResolution:lc}),f.bottomCopperText=zO({layer:"bottom",circuitJson:A,boardData:C,copperColor:hA,traceTextureResolution:lc}),f.topPanelOutlines=XO({layer:"top",circuitJson:A,panelData:C,traceTextureResolution:lc}),f.bottomPanelOutlines=XO({layer:"bottom",circuitJson:A,panelData:C,traceTextureResolution:lc}),f.topCopper=RZA({layer:"top",circuitJson:A,boardData:C,traceTextureResolution:lc}),f.bottomCopper=RZA({layer:"bottom",circuitJson:A,boardData:C,traceTextureResolution:lc}),n(f)}catch(D){console.error("Error processing geometry with Manifold in hook:",D),g(D.message||"An unknown error occurred while processing geometry in hook."),i(null),n(null)}finally{c(!1)}return()=>{B.current.forEach(h),B.current=[]}},[t,A,C]),{geoms:e,textures:o,pcbThickness:s,error:a,isLoading:I,boardData:C,isFauxBoard:l}},Rut=UC,Nut=({material:t,color:A,side:e=Rut,isFaux:i=!1})=>t==="fr4"?new ow({color:A,side:e,metalness:0,roughness:.8,specularIntensity:.2,ior:1.45,sheen:0,clearcoat:0,transparent:i,opacity:i?YO:1,flatShading:!0}):new ih({color:A,side:e,flatShading:!0,metalness:.1,roughness:.8,transparent:!0,opacity:i?YO:.9});function _ut(t){const A=[];if(!t)return A;if(t.board&&t.board.geometry){const i=new Oo(t.board.geometry,Nut({material:t.board.material,color:t.board.color,side:UC,isFaux:t.board.isFaux}));i.name="board-geom",A.push(i)}const e=i=>{i&&i.forEach(o=>{const n=new Oo(o.geometry,new ih({color:o.color,side:UC,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}));n.name=o.key,A.push(n)})};return e(t.platedHoles),e(t.smtPads),e(t.vias),A}var Mut=({geometryMeshes:t,textureMeshes:A})=>{const{rootObject:e}=fu(),{visibility:i}=T_();return AA.useEffect(()=>{if(e)return t.forEach(o=>{let n=!0;o.name==="board-geom"?n=i.boardBody:o.name.includes("smt_pad")?o.name.includes("smt_pad-top")?n=i.topCopper:o.name.includes("smt_pad-bottom")?n=i.bottomCopper:n=i.topCopper||i.bottomCopper:(o.name.includes("plated_hole")||o.name.includes("via"))&&(n=i.topCopper||i.bottomCopper),n&&e.add(o)}),A.forEach(o=>{let n=!0;o.name.includes("top-trace-texture-plane")&&!o.name.includes("with-mask")?n=i.topCopper&&!i.topMask:o.name.includes("top-trace-with-mask")?n=i.topCopper&&i.topMask:o.name.includes("bottom-trace-texture-plane")&&!o.name.includes("with-mask")?n=i.bottomCopper&&!i.bottomMask:o.name.includes("bottom-trace-with-mask")?n=i.bottomCopper&&i.bottomMask:o.name.includes("top-silkscreen")?n=i.topSilkscreen:o.name.includes("bottom-silkscreen")?n=i.bottomSilkscreen:o.name.includes("top-soldermask")?n=i.topMask:o.name.includes("bottom-soldermask")?n=i.bottomMask:o.name.includes("top-copper-text")?n=i.topCopper:o.name.includes("bottom-copper-text")?n=i.bottomCopper:o.name.includes("top-copper")?n=i.topCopper:o.name.includes("bottom-copper")?n=i.bottomCopper:o.name.includes("panel-outlines")&&(n=i.boardBody),n&&e.add(o)}),()=>{t.forEach(o=>{o.parent===e&&e.remove(o)}),A.forEach(o=>{o.parent===e&&e.remove(o)})}},[e,t,A,i]),null},vut="https://cdn.jsdelivr.net/npm/manifold-3d@3.2.1",Uut=({circuitJson:t,autoRotateDisabled:A,clickToInteractEnabled:e,onUserInteraction:i,children:o,onCameraControllerReady:n})=>{const s=aZA(o),r=AA.useMemo(()=>bZA(t??s),[t,s]),[a,g]=AA.useState(null),[I,c]=AA.useState(null);AA.useEffect(()=>{if(window.ManifoldModule&&typeof window.ManifoldModule=="object"&&window.ManifoldModule.setup){g(window.ManifoldModule);return}const F=async K=>{try{const O=await K();O.setup(),window.ManifoldModule=O,g(O)}catch(O){console.error("Failed to initialize Manifold:",O),c(`Failed to initialize Manifold: ${O instanceof Error?O.message:"Unknown error"}`)}},k=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(k){window.ManifoldModule=k,F(window.ManifoldModule);return}const v="manifoldLoaded",_=()=>{const K=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(K)window.ManifoldModule=K,F(window.ManifoldModule);else{const O="ManifoldModule not found on window after script load.";console.error(O),c(O)}};window.addEventListener(v,_,{once:!0});const Y=document.createElement("script");Y.type="module",Y.innerHTML=`
|
|
5102
5102
|
try {
|
|
5103
5103
|
const { default: ManifoldModule } = await import('${vut}/manifold.js');
|
|
5104
5104
|
window.ManifoldModule = ManifoldModule;
|
|
@@ -5598,7 +5598,7 @@ test("${g} should solve problem correctly", () => {
|
|
|
5598
5598
|
// Add more specific assertions based on expected output
|
|
5599
5599
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5600
5600
|
})
|
|
5601
|
-
`,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),C=document.createElement("a");C.href=B,C.download=`${g}.test.ts`,C.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 V.jsxs("div",{className:`relative ${A}`,ref:o,children:[V.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&&V.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:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},JAe=t=>t.activeSubSolver?[t,...JAe(t.activeSubSolver)]:[t],eLt=({solver:t})=>{const A=JAe(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>V.jsxs("div",{className:"flex items-center",children:[i>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(ALt,{solver:e})]},e.constructor.name))})},tLt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const C=t.getCurrentPhase!==void 0,l=C?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(eLt,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),V.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),C&&V.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),l&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:l})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},iLt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},oLt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=iLt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],C=B?t.firstIterationOfPhase?.[B.solverName]:void 0;C!==void 0&&s!==null?a=C-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},nLt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${A[t]}`,children:t})},sLt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},rLt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),aLt=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const A=Object.entries(t),e=rLt(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),V.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>V.jsxs("div",{children:[i,": ",String(o)]},i))})]})},gEA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(gEA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=gEA(i));return A},gLt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=gEA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},ILt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>oLt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):gLt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:i.map(r=>V.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.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"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(nLt,{status:r.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(sLt,{progress:r.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(aLt,{stats:r.stats})}),V.jsx("td",{className:"px-4 py-2",children:r.solverInstance?V.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.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"})}),V.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},cLt=class extends $i.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 BLt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,C=r-c,l=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${C} ${l} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>V.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)=>V.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((E,h)=>V.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)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>V.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var CLt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return V.jsxs("div",{children:[V.jsx(tLt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(cLt,{fallback:V.jsx(BLt,{graphics:s}),children:V.jsx($Ut,{graphics:s})}),a&&V.jsx(ILt,{solver:t,onStepUntilPhase:g})]})};const lLt=()=>{AA.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)},[])},QLt=t=>t.toLowerCase().includes("pack")?Vyt:t.toLowerCase().includes("rout")?ewt:Yyt,ELt=({solverEvents:t=[]})=>{const[A,e]=AA.useState(null);lLt();const i=AA.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=AA.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=AA.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=BiA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(BiA).join(", ")}`,classFound:!1};try{const a=n.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[n]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.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."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return V.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=QLt(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?V.jsx(Gm,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:V.jsx(CLt,{solver:s.instance})}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&V.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:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},KAe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{AA.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{TJ.captureException(i)}catch{}}},[t,A]),AA.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{TJ.captureException(o,{error_type:i.type})}catch{}}},[e])},TAe="0.0.1466",hLt={version:TAe},IEA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},cEA=new Map,cW=t=>{const A=cEA.get(t);return A?Object.fromEntries(Object.entries(A.stores).map(([e,i])=>[e,i.getState()])):{}},uLt=(t,A,e)=>{if(t===void 0)return{type:"untracked",connection:A.connect(e)};const i=cEA.get(e.name);if(i)return{type:"tracked",store:t,...i};const o={connection:A.connect(e),stores:{}};return cEA.set(e.name,o),{type:"tracked",store:t,...o}},qAe=(t,A={})=>(e,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(IEA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(IEA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(e,i,o);const{connection:I,...c}=uLt(r,g,a);let B=!0;o.setState=(Q,E,h)=>{const u=e(Q,E);if(!B)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...cW(a.name),[r]:o.getState()}),u)};const C=(...Q)=>{const E=B;B=!1,e(...Q),B=E},l=t(o.setState,i,o);if(c.type==="untracked"?I?.init(l):(c.stores[c.store]=o,I?.init(Object.fromEntries(Object.entries(c.stores).map(([Q,E])=>[Q,Q===c.store?l:E.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let Q=!1;const E=o.dispatch;o.dispatch=(...h)=>{(IEA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),E(...h)}}return I.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return BEA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){C(h.state);return}Object.keys(h.state).length!==1&&console.error(`
|
|
5601
|
+
`,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),C=document.createElement("a");C.href=B,C.download=`${g}.test.ts`,C.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 V.jsxs("div",{className:`relative ${A}`,ref:o,children:[V.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&&V.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:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},JAe=t=>t.activeSubSolver?[t,...JAe(t.activeSubSolver)]:[t],eLt=({solver:t})=>{const A=JAe(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>V.jsxs("div",{className:"flex items-center",children:[i>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(ALt,{solver:e})]},e.constructor.name))})},tLt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const C=t.getCurrentPhase!==void 0,l=C?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(eLt,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),V.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),C&&V.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),l&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:l})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},iLt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},oLt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=iLt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],C=B?t.firstIterationOfPhase?.[B.solverName]:void 0;C!==void 0&&s!==null?a=C-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},nLt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${A[t]}`,children:t})},sLt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},rLt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),aLt=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const A=Object.entries(t),e=rLt(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),V.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>V.jsxs("div",{children:[i,": ",String(o)]},i))})]})},gEA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(gEA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=gEA(i));return A},gLt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=gEA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},ILt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>oLt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):gLt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:i.map(r=>V.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.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"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(nLt,{status:r.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(sLt,{progress:r.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(aLt,{stats:r.stats})}),V.jsx("td",{className:"px-4 py-2",children:r.solverInstance?V.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.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"})}),V.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},cLt=class extends $i.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 BLt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,C=r-c,l=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${C} ${l} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>V.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)=>V.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((E,h)=>V.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)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>V.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var CLt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return V.jsxs("div",{children:[V.jsx(tLt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(cLt,{fallback:V.jsx(BLt,{graphics:s}),children:V.jsx($Ut,{graphics:s})}),a&&V.jsx(ILt,{solver:t,onStepUntilPhase:g})]})};const lLt=()=>{AA.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)},[])},QLt=t=>t.toLowerCase().includes("pack")?Vyt:t.toLowerCase().includes("rout")?ewt:Yyt,ELt=({solverEvents:t=[]})=>{const[A,e]=AA.useState(null);lLt();const i=AA.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=AA.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=AA.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=BiA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(BiA).join(", ")}`,classFound:!1};try{const a=n.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[n]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.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."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return V.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=QLt(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?V.jsx(Gm,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:V.jsx(CLt,{solver:s.instance})}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&V.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:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},KAe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{AA.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{TJ.captureException(i)}catch{}}},[t,A]),AA.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{TJ.captureException(o,{error_type:i.type})}catch{}}},[e])},TAe="0.0.1468",hLt={version:TAe},IEA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},cEA=new Map,cW=t=>{const A=cEA.get(t);return A?Object.fromEntries(Object.entries(A.stores).map(([e,i])=>[e,i.getState()])):{}},uLt=(t,A,e)=>{if(t===void 0)return{type:"untracked",connection:A.connect(e)};const i=cEA.get(e.name);if(i)return{type:"tracked",store:t,...i};const o={connection:A.connect(e),stores:{}};return cEA.set(e.name,o),{type:"tracked",store:t,...o}},qAe=(t,A={})=>(e,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(IEA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(IEA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(e,i,o);const{connection:I,...c}=uLt(r,g,a);let B=!0;o.setState=(Q,E,h)=>{const u=e(Q,E);if(!B)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...cW(a.name),[r]:o.getState()}),u)};const C=(...Q)=>{const E=B;B=!1,e(...Q),B=E},l=t(o.setState,i,o);if(c.type==="untracked"?I?.init(l):(c.stores[c.store]=o,I?.init(Object.fromEntries(Object.entries(c.stores).map(([Q,E])=>[Q,Q===c.store?l:E.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let Q=!1;const E=o.dispatch;o.dispatch=(...h)=>{(IEA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),E(...h)}}return I.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return BEA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){C(h.state);return}Object.keys(h.state).length!==1&&console.error(`
|
|
5602
5602
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5603
5603
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5604
5604
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|