tscircuit 0.0.1129 → 0.0.1130-libonly

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5063,7 +5063,7 @@ ${a.join(`
5063
5063
  ${Q}polygon: ${C.polygon.vertices}
5064
5064
  `:a+=`
5065
5065
  `,C.children.length>0&&I.push(C.children)}return a}};A.exports=s}}),Lgt=ne({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,A){var e=_gt(),i=Ugt(),n=class{constructor(o){this.polygonTree=new i,this.rootnode=new e(null),o&&this.addPolygons(o)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(o,s=!1){this.rootnode.clipTo(o,s)}allPolygons(){const o=[];return this.polygonTree.getPolygons(o),o}addPolygons(o){const s=new Array(o.length);for(let r=0;r<o.length;r++)s[r]=this.polygonTree.addChild(o[r]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};A.exports=n}}),llA=ne({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,A){A.exports={Tree:Lgt()}}}),Hgt=ne({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,A){var e=Po(),i=BlA(),{Tree:n}=llA(),o=(s,r)=>{if(!i(s,r))return e.create();const a=new n(e.toPolygons(s)),g=new n(e.toPolygons(r));a.invert(),g.clipTo(a),g.invert(),a.clipTo(g),g.clipTo(a),a.addPolygons(g.allPolygons()),a.invert();const I=a.allPolygons();return e.create(I)};A.exports=o}}),sZA=ne({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,A){var e=Ro(),i=jU(),n=Hgt(),o=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),Ygt=ne({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,A){var e=Ro(),i=Po(),n=mx(),o=IlA(),s=clA(),r=sZA(),a=(...g)=>{g=e(g);const I=g.map(l=>s({z0:-1,z1:1},l)),c=r(I),B=n(c);return o(B,i.toPolygons(c))};A.exports=a}}),Jgt=ne({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,A){var e=Ro(),i=VU(),n=qo(),o=Po(),s=Ygt(),r=sZA(),a=(...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only intersect of the types are supported");const I=g[0];return n.isA(I)?s(g):o.isA(I)?r(g):I};A.exports=a}}),Tgt=ne({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,A){var e=pn(),i=mx(),n=Po(),o=g=>g.sort((I,c)=>I-c).filter((I,c,B)=>!c||I!==B[c-1]),s=(g,I,c)=>{const B=`${I}`,l=g.get(B);l===void 0?g.set(B,[c]):l.push(c)},r=(g,I)=>{const c=`${I}`;return g.get(c)},a=g=>{const I=i(g),c=n.toPolygons(g),B=c.length,l=new Map,C=e.create();c.forEach((d,f)=>{d.vertices.forEach(w=>{s(l,e.snap(C,w,I),f)})});const Q=c.map(d=>{let f=[];return d.vertices.forEach(w=>{f=f.concat(r(l,e.snap(C,w,I)))}),{e:1,d:o(f)}});l.clear();let E=0;const h=Q.length;for(let d=0;d<h;d++){const f=Q[d];if(f.e>0){const w=new Array(B);w[d]=!0;do E=0,w.forEach((S,D)=>{const x=Q[D];if(x.e>0){x.e=-1;for(let F=0;F<x.d.length;F++)w[x.d[F]]=!0;E++}});while(E>0);f.indexes=w}}const u=[];for(let d=0;d<h;d++)if(Q[d].indexes){const f=[];Q[d].indexes.forEach((w,S)=>f.push(c[S])),u.push(n.create(f))}return u};A.exports=a}}),Kgt=ne({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,A){var e=Ro(),i=Po(),n=Tgt(),o=(...s)=>{if(s=e(s),s.length===0)throw new Error("wrong number of arguments");const r=s.map(a=>i.isA(a)?n(a):a);return r.length===1?r[0]:r};A.exports=o}}),qgt=ne({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,A){var e=Po(),i=BlA(),{Tree:n}=llA(),o=(s,r)=>{if(!i(s,r))return e.clone(s);const a=new n(e.toPolygons(s)),g=new n(e.toPolygons(r));a.invert(),a.clipTo(g),g.clipTo(a,!0),a.addPolygons(g.allPolygons()),a.invert();const I=a.allPolygons();return e.create(I)};A.exports=o}}),rZA=ne({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,A){var e=Ro(),i=jU(),n=qgt(),o=(...s)=>{s=e(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),Pgt=ne({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,A){var e=Ro(),i=Po(),n=mx(),o=IlA(),s=clA(),r=rZA(),a=(...g)=>{g=e(g);const I=g.map(l=>s({z0:-1,z1:1},l)),c=r(I),B=n(c);return o(B,i.toPolygons(c))};A.exports=a}}),Ogt=ne({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,A){var e=Ro(),i=VU(),n=qo(),o=Po(),s=Pgt(),r=rZA(),a=(...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only subtract of the types are supported");const I=g[0];return n.isA(I)?s(g):o.isA(I)?r(g):I};A.exports=a}}),aZA=ne({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,A){var e=Po(),i=BlA(),{Tree:n}=llA(),o=(r,a)=>{if(!i(r,a))return s(r,a);const g=new n(e.toPolygons(r)),I=new n(e.toPolygons(a));g.clipTo(I,!1),I.clipTo(g),I.invert(),I.clipTo(g),I.invert();const c=g.allPolygons().concat(I.allPolygons());return e.create(c)},s=(r,a)=>{let g=e.toPolygons(r);return g=g.concat(e.toPolygons(a)),e.create(g)};A.exports=o}}),gZA=ne({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,A){var e=Ro(),i=jU(),n=aZA(),o=(...s)=>{s=e(s);let r;for(r=1;r<s.length;r+=2)s.push(n(s[r-1],s[r]));let a=s[r-1];return a=i(a),a};A.exports=o}}),IZA=ne({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,A){var e=Ro(),i=Po(),n=mx(),o=IlA(),s=clA(),r=gZA(),a=(...g)=>{g=e(g);const I=g.map(l=>s({z0:-1,z1:1},l)),c=r(I),B=n(c);return o(B,i.toPolygons(c))};A.exports=a}}),ClA=ne({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,A){var e=Ro(),i=VU(),n=qo(),o=Po(),s=IZA(),r=gZA(),a=(...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only unions of the same type are supported");const I=g[0];return n.isA(I)?s(g):o.isA(I)?r(g):I};A.exports=a}}),T_=ne({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,A){A.exports={intersect:Jgt(),scission:Kgt(),subtract:Ogt(),union:ClA()}}}),s5=ne({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,A){var{EPS:e,TAU:i}=lr(),n=HWA(),o=nlA(),s=Cs(),r=i5(),a=(g,I)=>{const c={delta:1,corners:"edge",closed:!1,segments:16};let{delta:B,corners:l,closed:C,segments:Q}=Object.assign({},c,g);if(Math.abs(B)<e)return I;let E=g.closed?r(I):1;E===0&&(E=1);const h=E>0&&B>=0||E<0&&B<0;B=Math.abs(B);let u=null,d=[];const f=[],w=s.create(),S=I.length;for(let D=0;D<S;D++){const x=(D+1)%S,F=I[D],k=I[x];h?s.subtract(w,F,k):s.subtract(w,k,F),s.normal(w,w),s.normalize(w,w),s.scale(w,w,B);const v=s.add(s.create(),F,w),_=s.add(s.create(),k,w),L=[v,_];if(u!=null&&(C||!C&&x!==0)){const K=n(u[0],u[1],L[0],L[1]);K?(d.pop(),L[0]=K):f.push({c:F,s0:u,s1:L})}u=[v,_],!(x===0&&!C)&&(d.push(L[0]),d.push(L[1]))}if(C&&u!=null){const D=d[0],x=d[1],F=n(u[0],u[1],D,x);if(F)d[0]=F,d.pop();else{const k=I[0],v=[D,x];f.push({c:k,s0:u,s1:v})}}if(l==="edge"){const D=new Map;d.forEach((k,v)=>D.set(k,v));const x=o.create(),F=o.create();f.forEach(k=>{o.fromPoints(x,k.s0[0],k.s0[1]),o.fromPoints(F,k.s1[0],k.s1[1]);const v=o.intersectPointOfLines(x,F);if(Number.isFinite(v[0])&&Number.isFinite(v[1])){const _=k.s0[1],L=D.get(_);d[L]=v,d[(L+1)%d.length]=void 0}else{const _=k.s1[0],L=D.get(_);d[L]=void 0}}),d=d.filter(k=>k!==void 0)}if(l==="round"){let D=Math.floor(Q/4);const x=s.create();f.forEach(F=>{let k=s.angle(s.subtract(x,F.s1[0],F.c));if(k-=s.angle(s.subtract(x,F.s0[1],F.c)),h&&k<0&&(k=k+Math.PI,k<0&&(k=k+Math.PI)),!h&&k>0&&(k=k-Math.PI,k>0&&(k=k-Math.PI)),k!==0){D=Math.floor(Q*(Math.abs(k)/i));const v=k/D,_=s.angle(s.subtract(x,F.s0[1],F.c)),L=[];for(let K=1;K<D;K++){const J=_+v*K,W=s.fromAngleRadians(s.create(),J);s.scale(W,W,B),s.add(W,W,F.c),L.push(W)}if(L.length>0){const K=F.s0[1];let J=d.findIndex(W=>s.equals(K,W));J=(J+1)%d.length,d.splice(J,0,...L)}}else{const v=F.s1[0],_=d.findIndex(L=>s.equals(v,L));d.splice(_,1)}})}return d};A.exports=a}}),Wgt=ne({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,A){var e=qo(),i=s5(),n=(o,s)=>{const r={delta:1,corners:"edge",segments:16},{delta:a,corners:g,segments:I}=Object.assign({},r,o);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const l=e.toOutlines(s).map(C=>(o={delta:a,corners:g,closed:!0,segments:I},i(o,C))).reduce((C,Q)=>C.concat(e.toSides(e.fromPoints(Q))),[]);return e.create(l)};A.exports=n}}),Zgt=ne({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,A){var e=Yg(),i=pn(),n=Po(),o=$s(),s=(r,a)=>{i.dot(o.plane(a),r)>0&&(a=o.invert(a));const I=[a],c=o.transform(e.fromTranslation(e.create(),r),a),B=a.vertices.length;for(let l=0;l<B;l++){const C=l<B-1?l+1:0,Q=o.create([a.vertices[l],c.vertices[l],c.vertices[C],a.vertices[C]]);I.push(Q)}return I.push(o.invert(c)),n.create(I)};A.exports=s}}),Vgt=ne({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,A){var{EPS:e,TAU:i}=lr(),n=Yg(),o=pn(),s=nZA(),r=Po(),a=$s(),g=zWA(),I=jU(),c=aZA(),B=Zgt(),l=(h,u,d)=>{const f=u.toString();if(h.has(f))h.get(f)[1].push(d);else{const w=[u,[d]];h.set(f,w)}},C=(h,u,d)=>{const f=u[0].toString(),w=u[1].toString(),S=f<w?`${f},${w}`:`${w},${f}`;if(h.has(S))h.get(S)[1].push(d);else{const D=[u,[d]];h.set(S,D)}},Q=(h,u)=>{h.findIndex(f=>f===u)<0&&h.push(u)},E=(h,u)=>{const d={delta:1,segments:12},{delta:f,segments:w}=Object.assign({},d,h);let S=r.create();const D=new Map,x=new Map,F=o.create(),k=o.create();return r.toPolygons(u).forEach((_,L)=>{const K=o.scale(o.create(),a.plane(_),2*f),J=a.transform(n.fromTranslation(n.create(),o.scale(o.create(),K,-.5)),_),W=B(K,J);S=c(S,W);const Z=_.vertices;for(let AA=0;AA<Z.length;AA++){l(D,Z[AA],a.plane(_));const nA=(AA+1)%Z.length,cA=[Z[AA],Z[nA]];C(x,cA,a.plane(_))}}),x.forEach(_=>{const L=_[0],K=_[1],J=L[0],W=L[1],Z=o.subtract(o.create(),W,J);o.normalize(Z,Z);const AA=K[0],nA=o.cross(o.create(),AA,Z);let cA=[];for(let JA=0;JA<w;JA++)Q(cA,JA*i/w);for(let JA=0,gA=K.length;JA<gA;JA++){const yA=K[JA],EA=o.dot(nA,yA),TA=o.dot(AA,yA);let te=Math.atan2(EA,TA);te<0&&(te+=i),Q(cA,te),te=Math.atan2(-EA,-TA),te<0&&(te+=i),Q(cA,te)}cA=cA.sort(s);const tA=cA.length;let oA,rA;const CA=[],dA=[],bA=[];for(let JA=-1;JA<tA;JA++){const gA=cA[JA<0?JA+tA:JA],yA=Math.sin(gA),EA=Math.cos(gA);o.scale(F,AA,EA*f),o.scale(k,nA,yA*f),o.add(F,F,k);const TA=o.add(o.create(),J,F),te=o.add(o.create(),W,F);let ce=!1;if(JA>=0&&o.distance(TA,oA)<e&&(ce=!0),!ce){if(JA>=0){CA.push(TA),dA.push(te);const mA=[rA,te,TA,oA],qA=a.create(mA);bA.push(qA)}oA=TA,rA=te}}dA.reverse(),bA.push(a.create(CA)),bA.push(a.create(dA));const kA=r.create(bA);S=c(S,kA)}),D.forEach(_=>{const L=_[0],K=_[1],J=K[0];let W=null,Z=0;for(let tA=1;tA<K.length;tA++){const oA=K[tA],rA=o.cross(F,J,oA),CA=o.length(rA);CA>.05&&CA>Z&&(Z=CA,W=oA)}W||(W=o.orthogonal(F,J));const AA=o.cross(F,J,W);o.normalize(AA,AA);const nA=o.cross(k,AA,J),cA=g({center:[L[0],L[1],L[2]],radius:f,segments:w,axes:[J,AA,nA]});S=c(S,cA)}),I(S)};A.exports=E}}),jgt=ne({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,A){var e=Po(),i=ClA(),n=Vgt(),o=(s,r)=>{const a={delta:1,corners:"round",segments:12},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(I!=="round")throw new Error('corners must be "round" for 3D geometries');if(e.toPolygons(r).length===0)throw new Error("the given geometry cannot be empty");s={delta:g,corners:I,segments:c};const l=n(s,r);return i(r,l)};A.exports=o}}),zgt=ne({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,A){var e=i5(),i=Cs(),n=qo(),o=fg(),s=s5(),r=I=>{let{external:c,internal:B}=I;e(c)<0?c=c.reverse():B=B.reverse();const l=o.fromPoints({closed:!0},c),C=o.fromPoints({closed:!0},B),Q=n.toSides(n.fromPoints(o.toPoints(l))),E=n.toSides(n.fromPoints(o.toPoints(C)));return Q.push(...E),n.create(Q)},a=(I,c,B,l)=>{const{points:C,external:Q,internal:E}=I,h=Math.floor(c/2),u=[],d=[];if(B==="round"&&h>0){const w=Math.PI/h,S=C[C.length-1],D=i.angle(i.subtract(i.create(),Q[Q.length-1],S)),x=C[0],F=i.angle(i.subtract(i.create(),E[0],x));for(let k=1;k<h;k++){let v=D+w*k,_=i.fromAngleRadians(i.create(),v);i.scale(_,_,l),i.add(_,_,S),u.push(_),v=F+w*k,_=i.fromAngleRadians(i.create(),v),i.scale(_,_,l),i.add(_,_,x),d.push(_)}}const f=[];return f.push(...Q,...u,...E.reverse(),...d),n.fromPoints(f)},g=(I,c)=>{I=Object.assign({},{delta:1,corners:"edge",segments:16},I);const{delta:l,corners:C,segments:Q}=I;if(l<=0)throw new Error("the given delta must be positive for paths");if(!(C==="edge"||C==="chamfer"||C==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const E=c.isClosed,h=o.toPoints(c);if(h.length===0)throw new Error("the given geometry cannot be empty");const u={points:h,external:s({delta:l,corners:C,segments:Q,closed:E},h),internal:s({delta:-l,corners:C,segments:Q,closed:E},h)};return c.isClosed?r(u):a(u,Q,C,l)};A.exports=g}}),QlA=ne({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,A){var e=Ro(),i=qo(),n=Po(),o=fg(),s=Wgt(),r=jgt(),a=zgt(),g=(I,...c)=>{if(c=e(c),c.length===0)throw new Error("wrong number of arguments");const B=c.map(l=>o.isA(l)?a(I,l):i.isA(l)?s(I,l):n.isA(l)?r(I,l):l);return B.length===1?B[0]:B};A.exports=g}}),Xgt=ne({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,A){var e=qo(),i=$BA(),n=s5(),o=(s,r)=>{const a={delta:1,corners:"edge",segments:0},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(!(I==="edge"||I==="chamfer"||I==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const B=e.toOutlines(r),C=B.map(Q=>(s={delta:B.reduce((u,d)=>u+i.arePointsInside(Q,i.create(d)),0)%2===0?g:-g,corners:I,closed:!0,segments:c},n(s,Q))).reduce((Q,E)=>Q.concat(e.toSides(e.fromPoints(E))),[]);return e.create(C)};A.exports=o}}),$gt=ne({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,A){var e=fg(),i=s5(),n=(o,s)=>{const r={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:a,corners:g,closed:I,segments:c}=Object.assign({},r,o);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');o={delta:a,corners:g,closed:I,segments:c};const B=i(o,e.toPoints(s));return e.fromPoints({closed:I},B)};A.exports=n}}),AIt=ne({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,A){var e=Ro(),i=qo(),n=fg(),o=Xgt(),s=$gt(),r=(a,...g)=>{if(g=e(g),g.length===0)throw new Error("wrong number of arguments");const I=g.map(c=>n.isA(c)?s(a,c):i.isA(c)?o(a,c):c);return I.length===1?I[0]:I};A.exports=r}}),ElA=ne({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,A){A.exports={expand:QlA(),offset:AIt()}}}),r5=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,A){var e=Yg(),i=pn(),n=qo(),o=J_(),s=o5(),r=(a,g)=>{const I={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:c,twistAngle:B,twistSteps:l,repair:C}=Object.assign({},I,a);if(l<1)throw new Error("twistSteps must be 1 or more");B===0&&(l=1);const Q=i.clone(c),E=n.toSides(g);if(E.length===0)throw new Error("the given geometry cannot be empty");const h=o.fromSides(E);Q[2]<0&&o.reverse(h,h);const u=e.create(),d=(f,w,S)=>{const D=w/l*B,x=i.scale(i.create(),Q,w/l);return e.multiply(u,e.fromZRotation(u,D),e.fromTranslation(e.create(),x)),o.transform(u,S)};return a={numberOfSlices:l+1,capStart:!0,capEnd:!0,repair:C,callback:d},s(a,h)};A.exports=r}}),eIt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,A){var e=qo(),i=fg(),n=r5(),o=(s,r)=>{if(!r.isClosed)throw new Error("extruded path must be closed");const a=i.toPoints(r),g=e.fromPoints(a);return n(s,g)};A.exports=o}}),tIt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,A){var e=Ro(),i=qo(),n=fg(),o=r5(),s=eIt(),r=(a,...g)=>{const I={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:c,twistAngle:B,twistSteps:l,repair:C}=Object.assign({},I,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");a={offset:[0,0,c],twistAngle:B,twistSteps:l,repair:C};const Q=g.map(E=>n.isA(E)?s(a,E):i.isA(E)?o(a,E):E);return Q.length===1?Q[0]:Q};A.exports=r}}),iIt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,A){var e=fg(),i=QlA(),n=r5(),o=(s,r)=>{const a={size:1,height:1},{size:g,height:I}=Object.assign({},a,s);if(s.delta=g,s.offset=[0,0,I],e.toPoints(r).length===0)throw new Error("the given geometry cannot be empty");const B=i(s,r);return n(s,B)};A.exports=o}}),nIt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,A){var{area:e}=PU(),i=qo(),n=fg(),o=QlA(),s=r5(),r=(a,g)=>{const I={size:1,height:1},{size:c,height:B}=Object.assign({},I,a);a.delta=c,a.offset=[0,0,B];const l=i.toOutlines(g);if(l.length===0)throw new Error("the given geometry cannot be empty");const Q=l.map(h=>(e(h)<0&&h.reverse(),o(a,n.fromPoints({closed:!0},h)))).reduce((h,u)=>h.concat(i.toSides(u)),[]),E=i.create(Q);return s(a,E)};A.exports=r}}),oIt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,A){var e=Ro(),i=qo(),n=fg(),o=iIt(),s=nIt(),r=(a,...g)=>{const I={size:1,height:1},{size:c,height:B}=Object.assign({},I,a);if(g=e(g),g.length===0)throw new Error("wrong number of arguments");if(c<=0)throw new Error("size must be positive");if(B<=0)throw new Error("height must be positive");const l=g.map(C=>n.isA(C)?o(a,C):i.isA(C)?s(a,C):C);return l.length===1?l[0]:l};A.exports=r}}),sIt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,A){var{TAU:e}=lr(),i=Yg(),n=qo(),o=o5(),s=J_(),r=(a,g)=>{const I={angle:e,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:c,startAngle:B,pitch:l,height:C,endOffset:Q,segmentsPerRotation:E}=Object.assign({},I,a);if(C!=0&&(l=C/(c/e)),E<3)throw new Error("The number of segments per rotation needs to be at least 3.");const u=n.toSides(g);if(u.length===0)throw new Error("The given geometry cannot be empty");const d=u.filter(k=>k[0][0]>=0);let f=s.fromSides(u);d.length===0&&(f=s.reverse(f));const w=Math.round(E/e*Math.abs(c)),S=w>=2?w:2,D=i.create(),x=i.create(),F=(k,v,_)=>{const L=B+c/S*v,K=Q/S*v,J=(L-B)/e*l;return i.multiply(D,i.fromTranslation(i.create(),[K,0,J*Math.sign(c)]),i.fromXRotation(i.create(),-e/4*Math.sign(c))),i.multiply(x,i.fromZRotation(i.create(),L),D),s.transform(x,_)};return o({numberOfSlices:S+1,callback:F},f)};A.exports=r}}),rIt=ne({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,A){var e=Ro(),i=ilA(),n=kw(),o=Yg(),s=qo(),r=Po(),a=$s(),g=mx(),I=IZA(),c=(l,C)=>{const Q=n.fromNormalAndPoint(n.create(),l.axis,l.origin);if(Number.isNaN(Q[0])||Number.isNaN(Q[1])||Number.isNaN(Q[2])||Number.isNaN(Q[3]))throw new Error("project: invalid axis or origin");const E=g(C),h=E*E*Math.sqrt(3)/4;if(E===0)return s.create();const u=r.toPolygons(C);let d=[];for(let w=0;w<u.length;w++){const S=u[w].vertices.map(F=>n.projectionOfPoint(Q,F)),D=a.create(S),x=a.plane(D);i(Q,x)&&(a.measureArea(D)<h||d.push(D))}if(!i(Q,[0,0,1])){const w=o.fromVectorRotation(o.create(),Q,[0,0,1]);d=d.map(S=>a.transform(w,S))}d=d.sort((w,S)=>a.measureArea(S)-a.measureArea(w));const f=d.map(w=>s.fromPoints(w.vertices));return I(f)},B=(l,...C)=>{const Q={axis:[0,0,1],origin:[0,0,0]},{axis:E,origin:h}=Object.assign({},Q,l);if(C=e(C),C.length===0)throw new Error("wrong number of arguments");l={axis:E,origin:h};const u=C.map(d=>r.isA(d)?c(l,d):d);return u.length===1?u[0]:u};A.exports=B}}),zU=ne({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,A){A.exports={extrudeFromSlices:o5(),extrudeLinear:tIt(),extrudeRectangular:oIt(),extrudeRotate:eZA(),extrudeHelical:sIt(),project:rIt(),slice:J_()}}}),hlA=ne({"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=o(I[1]-r[1],I[0]-r[0]),B=e.squaredDistance(I,r);a.push({point:I,angle:c,distSq:B})}),a.sort((I,c)=>I.angle!==c.angle?I.angle-c.angle:I.distSq-c.distSq);const g=[];return a.forEach(I=>{let c=g.length;for(;c>1&&n(g[c-2],g[c-1],I.point)<=Number.EPSILON;)g.pop(),c=g.length;g.push(I.point)}),g},n=(s,r,a)=>(r[0]-s[0])*(a[1]-s[1])-(r[1]-s[1])*(a[0]-s[0]),o=(s,r)=>s===0&&r===0?-1/0:-r/s;A.exports=i}}),ulA=ne({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,A){var e=qo(),i=Po(),n=fg(),o=s=>{const r=new Set,a=[],g=I=>{const c=I.toString();r.has(c)||(a.push(I),r.add(c))};return s.forEach(I=>{e.isA(I)?e.toPoints(I).forEach(g):i.isA(I)?i.toPoints(I).forEach(c=>c.forEach(g)):n.isA(I)&&n.toPoints(I).forEach(g)}),a};A.exports=o}}),aIt=ne({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,A){var e=Ro(),i=fg(),n=hlA(),o=ulA(),s=(...r)=>{r=e(r);const a=o(r),g=n(a);return i.fromPoints({closed:!0},g)};A.exports=s}}),gIt=ne({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,A){var e=Ro(),i=qo(),n=hlA(),o=ulA(),s=(...r)=>{r=e(r);const a=o(r),g=n(a);return g.length<3?i.create():i.fromPoints(g)};A.exports=s}}),cZA=ne({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,A){var e=$s(),i=IWA(),n=o=>i(o,{skipTriangulation:!0}).map(a=>{const g=a.map(I=>o[I]);return e.create(g)});A.exports=n}}),IIt=ne({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,A){var e=Ro(),i=Po(),n=ulA(),o=cZA(),s=(...r)=>{r=e(r);const a=n(r);return a.length===0?i.create():i.create(o(a))};A.exports=s}}),BZA=ne({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,A){var e=Ro(),i=VU(),n=qo(),o=Po(),s=fg(),r=aIt(),a=gIt(),g=IIt(),I=(...c)=>{if(c=e(c),c.length===0)throw new Error("wrong number of arguments");if(!i(c))throw new Error("only hulls of the same type are supported");const B=c[0];return s.isA(B)?r(c):n.isA(B)?a(c):o.isA(B)?g(c):B};A.exports=I}}),cIt=ne({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,A){var e=Ro(),i=ClA(),n=BZA(),o=(...s)=>{if(s=e(s),s.length<2)throw new Error("wrong number of arguments");const r=[];for(let a=1;a<s.length;a++)r.push(n(s[a-1],s[a]));return i(r)};A.exports=o}}),BIt=ne({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,A){A.exports={hull:BZA(),hullChain:cIt(),hullPoints2:hlA(),hullPoints3:cZA()}}}),lZA=ne({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,A){var e=pn(),i=$s(),n=(s,r)=>{const a=Math.abs(i.measureArea(r));return Number.isFinite(a)&&a>s},o=(s,r)=>{let a=r.map(I=>{const c=I.vertices.map(C=>e.snap(e.create(),C,s)),B=[];for(let C=0;C<c.length;C++){const Q=(C+1)%c.length;e.equals(c[C],c[Q])||B.push(c[C])}const l=i.create(B);return I.color&&(l.color=I.color),l});const g=s*s*Math.sqrt(3)/4;return a=a.filter(I=>n(g,I)),a};A.exports=o}}),lIt=ne({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,A){var e=ilA(),i=pn(),n=$s(),o=h=>{const u=n.toPoints(h),d=[];for(let f=0;f<u.length;f++){const w=(f+1)%u.length,S={v1:u[f],v2:u[w]};d.push(S)}for(let f=0;f<d.length;f++){const w=(f+1)%u.length;d[f].next=d[w],d[w].prev=d[f]}return d},s=(h,u)=>{const d=`${u.v1}:${u.v2}`;h.set(d,u)},r=(h,u)=>{const d=`${u.v1}:${u.v2}`;h.delete(d)},a=(h,u)=>{const d=`${u.v2}:${u.v1}`;return h.get(d)},g=(h,u,d)=>{let f=h.prev.v1,w=h.prev.v2,S=u.next.v2;const D=B(f,w,S,d);f=u.prev.v1,w=u.prev.v2,S=h.next.v2;const x=B(f,w,S,d);return[D,x]},I=i.create(),c=i.create(),B=(h,u,d,f)=>{const w=i.subtract(I,u,h),S=i.subtract(c,d,u);return i.cross(w,w,S),i.dot(w,f)},l=h=>{let u;const d=[];for(;h.next;){const f=h.next;d.push(h.v1),h.v1=null,h.v2=null,h.next=null,h.prev=null,h=f}return d.length>0&&(u=n.create(d)),u},C=h=>{if(h.length<2)return h;const u=h[0].plane,d=h.slice(),f=new Map;for(;d.length>0;){const S=d.shift(),D=o(S);for(let x=0;x<D.length;x++){const F=D[x],k=a(f,F);if(k){const v=g(F,k,u);if(v[0]>=0&&v[1]>=0){const _=k.next,L=F.next;F.prev.next=k.next,F.next.prev=k.prev,k.prev.next=F.next,k.next.prev=F.prev,F.v1=null,F.v2=null,F.next=null,F.prev=null,r(f,k),k.v1=null,k.v2=null,k.next=null,k.prev=null;const K=(J,W,Z)=>{const AA={v1:Z.v1,v2:W.v2,next:W.next,prev:Z.prev};Z.prev.next=AA,W.next.prev=AA,r(J,W),W.v1=null,W.v2=null,W.next=null,W.prev=null,r(J,Z),Z.v1=null,Z.v2=null,Z.next=null,Z.prev=null};v[0]===0&&K(f,_,_.prev),v[1]===0&&K(f,L,L.prev)}}else F.next&&s(f,F)}}const w=[];return f.forEach(S=>{const D=l(S);D&&w.push(D)}),f.clear(),w},Q=(h,u)=>Math.abs(h[3]-u[3])<15e-8?e(h,u):!1,E=(h,u)=>{const d=[];u.forEach(w=>{const S=d.find(D=>Q(D[0],n.plane(w)));S?S[1].push(w):d.push([n.plane(w),[w]])});let f=[];return d.forEach(w=>{const S=w[1],D=C(S);f=f.concat(D)}),f};A.exports=E}}),CIt=ne({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,A){var e=lr(),i=pn(),n=$s(),o=g=>`${g}`,s=(g,I,c,B,l,C)=>{const Q=o(B),E=o(l),h=`${Q}/${E}`,u=`${E}/${Q}`;if(g.has(u))return r(g,I,c,l,B,null),null;const d={vertex0:B,vertex1:l,polygonindex:C};return g.has(h)?g.get(h).push(d):g.set(h,[d]),I.has(Q)?I.get(Q).push(h):I.set(Q,[h]),c.has(E)?c.get(E).push(h):c.set(E,[h]),h},r=(g,I,c,B,l,C)=>{const Q=o(B),E=o(l),h=`${Q}/${E}`;let u=-1;const d=g.get(h);for(let f=0;f<d.length;f++){const w=d[f];let S=o(w.vertex0);if(S===Q&&(S=o(w.vertex1),S===E&&!(C!==null&&w.polygonindex!==C))){u=f;break}}d.splice(u,1),d.length===0&&g.delete(h),u=I.get(Q).indexOf(h),I.get(Q).splice(u,1),I.get(Q).length===0&&I.delete(Q),u=c.get(E).indexOf(h),c.get(E).splice(u,1),c.get(E).length===0&&c.delete(E)},a=g=>{const I=new Map;for(let c=0;c<g.length;c++){const B=g[c],l=B.vertices.length;if(l>=3){let C=B.vertices[0],Q=o(C);for(let E=0;E<l;E++){let h=E+1;h===l&&(h=0);const u=B.vertices[h],d=o(u),f=`${Q}/${d}`,w=`${d}/${Q}`;if(I.has(w)){const S=I.get(w);S.splice(-1,1),S.length===0&&I.delete(w)}else{const S={vertex0:C,vertex1:u,polygonindex:c};I.has(f)?I.get(f).push(S):I.set(f,[S])}C=u,Q=d}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(I.size>0){const c=new Map,B=new Map,l=new Map;for(const[Q,E]of I)l.set(Q,!0),E.forEach(h=>{const u=o(h.vertex0),d=o(h.vertex1);c.has(u)?c.get(u).push(Q):c.set(u,[Q]),B.has(d)?B.get(d).push(Q):B.set(d,[Q])});const C=g.slice(0);for(;I.size!==0;){for(const E of I.keys())l.set(E,!0);let Q=!1;for(;;){const E=Array.from(l.keys());if(E.length===0)break;const h=E[0];let u=!0;if(I.has(h)){const f=I.get(h)[0];for(let w=0;w<2;w++){const S=w===0?f.vertex0:f.vertex1,D=w===0?f.vertex1:f.vertex0,x=o(S),F=o(D);let k=[];w===0?B.has(x)&&(k=B.get(x)):c.has(x)&&(k=c.get(x));for(let v=0;v<k.length;v++){const _=k[v],L=I.get(_)[0],K=w===0?L.vertex0:L.vertex1;if(w===0?L.vertex1:L.vertex0,o(K)===F){r(I,c,B,S,D,null),r(I,c,B,D,S,null),u=!1,w=2,Q=!0;break}else{const W=S,Z=D,AA=K,nA=i.subtract(i.create(),AA,W),cA=i.dot(i.subtract(i.create(),Z,W),nA)/i.dot(nA,nA);if(cA>0&&cA<1){const tA=i.scale(i.create(),nA,cA);if(i.add(tA,tA,W),i.squaredDistance(tA,Z)<e.EPS*e.EPS){const rA=L.polygonindex,CA=C[rA],dA=o(L.vertex1);let bA=-1;for(let EA=0;EA<CA.vertices.length;EA++)if(o(CA.vertices[EA])===dA){bA=EA;break}const kA=CA.vertices.slice(0);kA.splice(bA,0,D);const JA=n.create(kA);C[rA]=JA,r(I,c,B,L.vertex0,L.vertex1,rA);const gA=s(I,c,B,L.vertex0,D,rA),yA=s(I,c,B,D,L.vertex1,rA);gA!==null&&l.set(gA,!0),yA!==null&&l.set(yA,!0),u=!1,w=2,Q=!0;break}}}}}}u&&l.delete(h)}if(!Q)break}g=C}return I.clear(),g};A.exports=a}}),QIt=ne({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,A){var e=pn(),i=$s(),n=(s,r,a)=>{const g=r.vertices.length;if(g>3){if(g>4){const B=[0,0,0];r.vertices.forEach(l=>e.add(B,B,l)),e.snap(B,e.divide(B,B,[g,g,g]),s);for(let l=0;l<g;l++){const C=i.create([B,r.vertices[l],r.vertices[(l+1)%g]]);r.color&&(C.color=r.color),a.push(C)}return}const I=i.create([r.vertices[0],r.vertices[1],r.vertices[2]]),c=i.create([r.vertices[0],r.vertices[2],r.vertices[3]]);r.color&&(I.color=r.color,c.color=r.color),a.push(I,c);return}a.push(r)},o=(s,r)=>{const a=[];return r.forEach(g=>{n(s,g,a)}),a};A.exports=o}}),EIt=ne({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,A){var e=Ro(),i=mx(),n=qo(),o=Po(),s=fg(),r=lZA(),a=lIt(),g=CIt(),I=QIt(),c=(Q,E)=>E,B=(Q,E)=>E,l=(Q,E)=>{const h={snap:!1,simplify:!1,triangulate:!1},{snap:u,simplify:d,triangulate:f}=Object.assign({},h,Q),w=i(E);let S=o.toPolygons(E);u&&(S=r(w,S)),d&&(S=a(w,S)),f&&(S=g(S),S=I(w,S));const D=Object.assign({},E);return D.polygons=S,D},C=(Q,...E)=>{if(E=e(E),E.length===0)throw new Error("wrong number of arguments");const h=E.map(u=>{if(s.isA(u))return c(Q,u);if(n.isA(u))return B(Q,u);if(o.isA(u))return l(Q,u);throw new Error("invalid geometry")});return h.length===1?h[0]:h};A.exports=C}}),hIt=ne({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,A){var e=Ro(),i=Cs(),n=qo(),o=Po(),s=fg(),r=mx(),a=lZA(),g=l=>{const C=r(l),E=s.toPoints(l).map(h=>i.snap(i.create(),h,C));return s.create(E)},I=l=>{const C=r(l);let E=n.toSides(l).map(h=>[i.snap(i.create(),h[0],C),i.snap(i.create(),h[1],C)]);return E=E.filter(h=>!i.equals(h[0],h[1])),n.create(E)},c=l=>{const C=r(l),Q=o.toPolygons(l),E=a(C,Q);return o.create(E)},B=(...l)=>{if(l=e(l),l.length===0)throw new Error("wrong number of arguments");const C=l.map(Q=>s.isA(Q)?g(Q):n.isA(Q)?I(Q):o.isA(Q)?c(Q):Q);return C.length===1?C[0]:C};A.exports=B}}),uIt=ne({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,A){A.exports={generalize:EIt(),snap:hIt(),retessellate:jU()}}}),dIt=ne({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,A){var e=(i,n,o)=>{for(i=i.slice();i.length<o;)i.push(n);return i};A.exports=e}}),pIt=ne({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,A){var e=Ro(),i=dIt(),n=olA(),{translate:o}=jG(),s=I=>{if(!Array.isArray(I.modes)||I.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(I.modes=i(I.modes,"none",3),I.modes.filter(c=>["center","max","min","none"].includes(c)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(I.relativeTo)||I.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(I.relativeTo=i(I.relativeTo,0,3),I.relativeTo.filter(c=>Number.isFinite(c)||c==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof I.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return I},r=(I,c,B)=>{for(let l=0;l<3;l++)I[l]==null&&(c[l]==="center"?I[l]=(B[0][l]+B[1][l])/2:c[l]==="max"?I[l]=B[1][l]:c[l]==="min"&&(I[l]=B[0][l]));return I},a=(I,c,B)=>{const l=n(I),C=[0,0,0];for(let Q=0;Q<3;Q++)c[Q]==="center"?C[Q]=B[Q]-(l[0][Q]+l[1][Q])/2:c[Q]==="max"?C[Q]=B[Q]-l[1][Q]:c[Q]==="min"&&(C[Q]=B[Q]-l[0][Q]);return o(C,I)},g=(I,...c)=>{I=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},I),I=s(I);let{modes:l,relativeTo:C,grouped:Q}=I;if(c=e(c),c.length===0)throw new Error("align(): No geometries were provided to act upon");if(C.filter(E=>E==null).length){const E=n(c);C=r(C,l,E)}return Q?c=a(c,l,C):c=c.map(E=>a(E,l,C)),c.length===1?c[0]:c};A.exports=g}}),a5=ne({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,A){var e=Ro(),i=qo(),n=Po(),o=fg(),s=ZG(),{translate:r}=jG(),a=(l,C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,l),u=s(C),d=[0,0,0];return E[0]&&(d[0]=h[0]-(u[0][0]+(u[1][0]-u[0][0])/2)),E[1]&&(d[1]=h[1]-(u[0][1]+(u[1][1]-u[0][1])/2)),E[2]&&(d[2]=h[2]-(u[0][2]+(u[1][2]-u[0][2])/2)),r(d,C)},g=(l,...C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,l);if(C=e(C),C.length===0)throw new Error("wrong number of arguments");if(h.length!==3)throw new Error("relativeTo must be an array of length 3");l={axes:E,relativeTo:h};const u=C.map(d=>o.isA(d)||i.isA(d)||n.isA(d)?a(l,d):d);return u.length===1?u[0]:u},I=(...l)=>g({axes:[!0,!1,!1]},l),c=(...l)=>g({axes:[!1,!0,!1]},l),B=(...l)=>g({axes:[!1,!1,!0]},l);A.exports={center:g,centerX:I,centerY:c,centerZ:B}}}),g5=ne({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,A){var e=Ro(),i=Yg(),n=qo(),o=Po(),s=fg(),r=(c,...B)=>{if(!Array.isArray(c))throw new Error("factors must be an array");if(B=e(B),B.length===0)throw new Error("wrong number of arguments");for(c=c.slice();c.length<3;)c.push(1);if(c[0]<=0||c[1]<=0||c[2]<=0)throw new Error("factors must be positive");const l=i.fromScaling(i.create(),c),C=B.map(Q=>s.isA(Q)?s.transform(l,Q):n.isA(Q)?n.transform(l,Q):o.isA(Q)?o.transform(l,Q):Q);return C.length===1?C[0]:C},a=(c,...B)=>r([c,1,1],B),g=(c,...B)=>r([1,c,1],B),I=(c,...B)=>r([1,1,c],B);A.exports={scale:r,scaleX:a,scaleY:g,scaleZ:I}}}),fIt=ne({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,A){var e=Ro(),i=qo(),n=Po(),o=fg(),s=(r,...a)=>{if(a=e(a),a.length===0)throw new Error("wrong number of arguments");const g=a.map(I=>o.isA(I)?o.transform(r,I):i.isA(I)?i.transform(r,I):n.isA(I)?n.transform(r,I):I);return g.length===1?g[0]:g};A.exports=s}}),zG=ne({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,A){A.exports={align:pIt(),center:a5().center,centerX:a5().centerX,centerY:a5().centerY,centerZ:a5().centerZ,mirror:WU().mirror,mirrorX:WU().mirrorX,mirrorY:WU().mirrorY,mirrorZ:WU().mirrorZ,rotate:ZU().rotate,rotateX:ZU().rotateX,rotateY:ZU().rotateY,rotateZ:ZU().rotateZ,scale:g5().scale,scaleX:g5().scaleX,scaleY:g5().scaleY,scaleZ:g5().scaleZ,transform:fIt(),translate:jG().translate,translateX:jG().translateX,translateY:jG().translateY,translateZ:jG().translateZ}}}),I5=ne({"node_modules/@jscad/modeling/src/index.js"(t,A){A.exports={colors:t5(),curves:hat(),geometries:AlA(),maths:Tat(),measurements:jat(),primitives:wx(),text:glA(),utils:oZA(),booleans:T_(),expansions:ElA(),extrusions:zU(),hulls:BIt(),modifiers:uIt(),transforms:zG()}}}),yIt=ne({"node_modules/ms/index.js"(t,A){var e=1e3,i=e*60,n=i*60,o=n*24,s=o*7,r=o*365.25;A.exports=function(B,l){l=l||{};var C=typeof B;if(C==="string"&&B.length>0)return a(B);if(C==="number"&&isFinite(B))return l.long?I(B):g(B);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(B))};function a(B){if(B=String(B),!(B.length>100)){var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(B);if(l){var C=parseFloat(l[1]),Q=(l[2]||"ms").toLowerCase();switch(Q){case"years":case"year":case"yrs":case"yr":case"y":return C*r;case"weeks":case"week":case"w":return C*s;case"days":case"day":case"d":return C*o;case"hours":case"hour":case"hrs":case"hr":case"h":return C*n;case"minutes":case"minute":case"mins":case"min":case"m":return C*i;case"seconds":case"second":case"secs":case"sec":case"s":return C*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return C;default:return}}}}function g(B){var l=Math.abs(B);return l>=o?Math.round(B/o)+"d":l>=n?Math.round(B/n)+"h":l>=i?Math.round(B/i)+"m":l>=e?Math.round(B/e)+"s":B+"ms"}function I(B){var l=Math.abs(B);return l>=o?c(B,l,o,"day"):l>=n?c(B,l,n,"hour"):l>=i?c(B,l,i,"minute"):l>=e?c(B,l,e,"second"):B+" ms"}function c(B,l,C,Q){var E=l>=C*1.5;return Math.round(B/C)+" "+Q+(E?"s":"")}}}),mIt=ne({"node_modules/debug/src/common.js"(t,A){function e(i){o.debug=o,o.default=o,o.coerce=c,o.disable=g,o.enable=r,o.enabled=I,o.humanize=yIt(),o.destroy=B,Object.keys(i).forEach(l=>{o[l]=i[l]}),o.names=[],o.skips=[],o.formatters={};function n(l){let C=0;for(let Q=0;Q<l.length;Q++)C=(C<<5)-C+l.charCodeAt(Q),C|=0;return o.colors[Math.abs(C)%o.colors.length]}o.selectColor=n;function o(l){let C,Q=null,E,h;function u(...d){if(!u.enabled)return;const f=u,w=Number(new Date),S=w-(C||w);f.diff=S,f.prev=C,f.curr=w,C=w,d[0]=o.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let D=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(F,k)=>{if(F==="%%")return"%";D++;const v=o.formatters[k];if(typeof v=="function"){const _=d[D];F=v.call(f,_),d.splice(D,1),D--}return F}),o.formatArgs.call(f,d),(f.log||o.log).apply(f,d)}return u.namespace=l,u.useColors=o.useColors(),u.color=o.selectColor(l),u.extend=s,u.destroy=o.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>Q!==null?Q:(E!==o.namespaces&&(E=o.namespaces,h=o.enabled(l)),h),set:d=>{Q=d}}),typeof o.init=="function"&&o.init(u),u}function s(l,C){const Q=o(this.namespace+(typeof C>"u"?":":C)+l);return Q.log=this.log,Q}function r(l){o.save(l),o.namespaces=l,o.names=[],o.skips=[];const C=(typeof l=="string"?l:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const Q of C)Q[0]==="-"?o.skips.push(Q.slice(1)):o.names.push(Q)}function a(l,C){let Q=0,E=0,h=-1,u=0;for(;Q<l.length;)if(E<C.length&&(C[E]===l[Q]||C[E]==="*"))C[E]==="*"?(h=E,u=Q,E++):(Q++,E++);else if(h!==-1)E=h+1,u++,Q=u;else return!1;for(;E<C.length&&C[E]==="*";)E++;return E===C.length}function g(){const l=[...o.names,...o.skips.map(C=>"-"+C)].join(",");return o.enable(""),l}function I(l){for(const C of o.skips)if(a(l,C))return!1;for(const C of o.names)if(a(l,C))return!0;return!1}function c(l){return l instanceof Error?l.stack||l.message:l}function B(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}A.exports=e}}),wIt=ne({"node_modules/debug/src/browser.js"(t,A){t.formatArgs=i,t.save=n,t.load=o,t.useColors=e,t.storage=s(),t.destroy=(()=>{let a=!1;return()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function e(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let a;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(a=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(a[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function i(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+A.exports.humanize(this.diff),!this.useColors)return;const g="color: "+this.color;a.splice(1,0,g,"color: inherit");let I=0,c=0;a[0].replace(/%[a-zA-Z%]/g,B=>{B!=="%%"&&(I++,B==="%c"&&(c=I))}),a.splice(c,0,g)}t.log=console.debug||console.log||(()=>{});function n(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function o(){let a;try{a=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!a&&typeof PBA<"u"&&"env"in PBA&&(a=PBA.env.DEBUG),a}function s(){try{return localStorage}catch{}}A.exports=mIt()(t);var{formatters:r}=A.exports;r.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}}}),CZA=j.createContext(null),wu=()=>{const t=j.useContext(CZA);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},XU=(t,A=[])=>{const{addFrameListener:e,removeFrameListener:i}=wu();$i.useEffect(()=>(e(t),()=>i(t)),[e,i,...A])},QZA=j.createContext(null),DIt=()=>{const t=j.useContext(QZA);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},SIt=({children:t})=>{const{camera:A,renderer:e}=wu(),[i,n]=j.useState([]),o=j.useMemo(()=>new UXe,[]),s=j.useMemo(()=>new an,[]),r=j.useRef(i);r.current=i;const a=j.useRef(null),g=j.useCallback(C=>{n(Q=>[...Q,C])},[]),I=j.useCallback(C=>{if(a.current){let Q=!1,E=a.current.object;for(;E;){if(E===C){Q=!0;break}E=E.parent}Q&&(a.current.onUnhover(),a.current=null)}n(Q=>Q.filter(E=>E.object!==C))},[]),c=j.useCallback(C=>{let Q=C;for(;Q;){const E=r.current.find(h=>h.object===Q);if(E)return E;Q=Q.parent}},[]),B=j.useCallback(C=>{if(!e.domElement)return;const Q=e.domElement.getBoundingClientRect();s.x=(C.clientX-Q.left)/Q.width*2-1,s.y=-((C.clientY-Q.top)/Q.height)*2+1,o.setFromCamera(s,A);const E=r.current.map(u=>u.object);if(E.length===0){a.current&&(a.current.onUnhover(),a.current=null);return}const h=o.intersectObjects(E,!0);if(h.length>0){const u=h[0],d=c(u.object);if(d){const f={mousePosition:[u.point.x,u.point.y,u.point.z]};a.current!==d?(a.current?.onUnhover(),d.onHover(f),a.current=d):d.onHover(f)}else a.current&&(a.current.onUnhover(),a.current=null)}else a.current&&(a.current.onUnhover(),a.current=null)},[A,e,o,s,c]);j.useEffect(()=>{const C=e.domElement;return C.addEventListener("mousemove",B),()=>{C.removeEventListener("mousemove",B)}},[e,B]);const l=j.useMemo(()=>({addHoverable:g,removeHoverable:I}),[g,I]);return O.jsx(QZA.Provider,{value:l,children:t})},bIt=({children:t,object:A,onHover:e,onUnhover:i,isHovered:n})=>{const{addHoverable:o,removeHoverable:s}=DIt();return j.useEffect(()=>A?(o({object:A,onHover:e,onUnhover:i}),()=>{s(A)}):void 0,[A,e,i,o,s]),O.jsx(O.Fragment,{children:t})},$U=bIt;function xIt(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(A,e,i)=>`${e} ${i.replace(/-/g,"_")}`)}async function kIt(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 Z6e().parse(xIt(e),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function GIt(t){const[A,e]=j.useState(null);return j.useEffect(()=>{if(!t)return;const i=t.replace(/&cachebust_origin=$/,""),n=window.TSCIRCUIT_OBJ_LOADER_CACHE;let o=!1;async function s(){try{if(i.endsWith(".wrl"))return await kIt(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 i7e;if(I?.length){const B=I.join(`
5066
- `).replace(/d 0\./g,"d 1."),l=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new P6e;C.setMaterialOptions({invertTrProperty:!0});const Q=C.parse(B.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return c.setMaterials(Q),c.parse(l)}return c.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(n.has(i)){const g=n.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(I=>I instanceof Error?I:I.clone())}const a=s().then(g=>(g instanceof Error||n.set(i,{...n.get(i),result:g}),g));return n.set(i,{promise:a,result:null}),a}return r().then(a=>{o||e(a)}).catch(a=>{console.error(a)}),()=>{o=!0}},[t]),A}function FIt({url:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const a=GIt(t),{rootObject:g}=wu(),I=j.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(c=>{if(c instanceof Zn&&c.material){const B=l=>{l.transparent=r,l.opacity=r?.5:1,l.depthWrite=!r,l.needsUpdate=!0};Array.isArray(c.material)?c.material.forEach(B):B(c.material)}}),a):new Zn(new fm(.5,.5,.5),new Ih({transparent:!0,color:"red",opacity:.25})),[a,r]);if(j.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),j.useEffect(()=>{I&&(A&&(Array.isArray(A)?I.position.fromArray(A):I.position.copy(A)),e&&(Array.isArray(e)?I.rotation.fromArray(e):I.rotation.copy(e)),s!==void 0&&I.scale.setScalar(s))},[I,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,s]),a instanceof Error)throw a;return O.jsx($U,{isHovered:o,onHover:i,onUnhover:n,object:I})}var EZA=new WeakMap,RIt=()=>{const t=new Yc;return t.name="fallback-environment-map",t.mapping=d3,t},NIt=t=>{if(!t)return null;const A=t,e=EZA.get(A);if(e)return e;let i;if(t instanceof z3){const n=new RiA(t);i=n.fromScene(r6e(),.04).texture,n.dispose()}else i=RIt();return EZA.set(A,i),i},hZA=1.25;function uZA({gltfUrl:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=wu(),[I,c]=j.useState(null),[B,l]=j.useState(null);if(j.useEffect(()=>{if(!t)return;const C=new g6e;let Q=!0;return C.load(t,E=>{if(!Q)return;const h=E.scene;h.traverse(u=>{if(u instanceof Zn&&u.material){const d=f=>{f.transparent=r,f.opacity=r?.5:1,f.depthWrite=!r,f.needsUpdate=!0};Array.isArray(u.material)?u.material.forEach(d):d(u.material)}}),c(h)},void 0,E=>{if(!Q)return;console.error(`An error happened loading ${t}`,E);const h=E instanceof Error?E:new Error(`Failed to load glTF model from ${t}`);l(h)}),()=>{Q=!1}},[t,r]),j.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]),j.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),j.useEffect(()=>{if(!I||!a)return;const C=NIt(a);if(!C)return;const Q=[],E=h=>{h instanceof Ih&&(Q.push({material:h,envMap:h.envMap??null,envMapIntensity:h.envMapIntensity??1}),h.envMap=C,(typeof h.envMapIntensity!="number"||h.envMapIntensity<hZA)&&(h.envMapIntensity=hZA),h.needsUpdate=!0)};return I.traverse(h=>{if(!(h instanceof Zn))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]),j.useEffect(()=>{I&&I.traverse(C=>{C instanceof Zn&&C.material instanceof Ih&&(o?(C.material.emissive.setHex(255),C.material.emissiveIntensity=.2):C.material.emissiveIntensity=0)})},[o,I]),B)throw B;return I?O.jsx($U,{isHovered:o,onHover:i,onUnhover:n,object:I}):null}var _It=yr(P8A()),MIt=yr(I5()),dZA={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},mr=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 dZA)return e*dZA[A];throw new Error(`Unsupported unit: ${A}`)},mB=mr,pZA={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}}},dlA=new Set;for(const[t,A]of Object.entries(pZA)){dlA.add(t);for(const e of Object.keys(A.variants))dlA.add(e)}function vIt(t){for(const[A,e]of Object.entries(pZA))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var fZA={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 Dm(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}=Dm(t.x),g=Dm(t.x),I=Dm(t.y);return g.value===null||I.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:I.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),n=t.slice(0,-i.length);if(i in fZA&&!dlA.has(i)){const r=fZA[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(n)*r}}const{baseUnit:o,conversionFactor:s}=vIt(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(n)}}var plA=Y().or(VA()).transform(t=>Dm(t).value),yZA=Y().or(VA()).transform(t=>Dm(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),UIt=Y().or(VA()).transform(t=>Dm(t).value),K_=Y().or(VA()).transform(t=>Dm(t).value),$A=Y().or(VA()).transform(t=>Dm(t).value),c5=Y().or(VA()).transform(t=>Dm(t).value),wt=$A,flA=Y().or(VA()).transform(t=>Dm(t).value),ylA=Y().or(VA()).transform(t=>Dm(t).value),q_=ylA,LIt=Y().datetime(),md=Y().or(VA()).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)),HIt=VA().or(Y().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"),kn=OA({x:wt,y:wt}),mlA=OA({x:wt,y:wt,z:wt}),mZA=OA({width:VA(),height:VA()}),YIt=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},jt=t=>Y().optional().default(()=>`${t}_${YIt(10)}`),XG=lt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]);lt(["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 JIt=lt(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),wB=OA({type:FA("source_component"),ftype:Y().optional(),source_component_id:Y(),name:Y(),manufacturer_part_number:Y().optional(),supplier_part_numbers:Ma(JIt,be(Y())).optional(),display_value:Y().optional(),are_pins_interchangeable:Be().optional(),internally_connected_source_port_ids:be(be(Y())).optional(),source_group_id:Y().optional(),subcircuit_id:Y().optional()}),wZA=wB.extend({ftype:FA("simple_capacitor"),capacitance:yZA,max_voltage_rating:K_.optional(),display_capacitance:Y().optional(),max_decoupling_trace_length:wt.optional()}),DZA=wB.extend({ftype:FA("simple_resistor"),resistance:plA,display_resistance:Y().optional()}),wlA=wB.extend({ftype:FA("simple_diode")}),TIt=wB.extend({ftype:FA("simple_fiducial")}),SZA=wlA.extend({ftype:FA("simple_led"),color:Y().optional(),wavelength:Y().optional()}),KIt=wB.extend({ftype:FA("simple_ground")}),bZA=wB.extend({ftype:FA("simple_chip")}),xZA=wB.extend({ftype:FA("simple_power_source"),voltage:K_}),qIt=wB.extend({ftype:FA("simple_fuse"),current_rating_amps:VA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:VA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),kZA=wB.extend({ftype:FA("simple_battery"),capacity:HIt}),GZA=wB.extend({ftype:FA("simple_inductor"),inductance:UIt,max_current_rating:VA().optional()}),FZA=wB.extend({ftype:FA("simple_push_button")}),RZA=wB.extend({ftype:FA("simple_potentiometer"),max_resistance:plA}),PIt=wB.extend({ftype:FA("simple_crystal"),frequency:VA().describe("Frequency in Hz"),load_capacitance:VA().optional().describe("Load capacitance in pF")}),NZA=wB.extend({ftype:FA("simple_pin_header"),pin_count:VA(),gender:lt(["male","female"]).optional().default("male")}),_ZA=wB.extend({ftype:FA("simple_pinout")}),MZA=wB.extend({ftype:FA("simple_resonator"),load_capacitance:yZA,equivalent_series_resistance:plA.optional(),frequency:c5}),vZA=wB.extend({ftype:FA("simple_transistor"),transistor_type:lt(["npn","pnp"])}),UZA=wB.extend({ftype:FA("simple_test_point"),footprint_variant:lt(["pad","through_hole"]).optional(),pad_shape:lt(["rect","circle"]).optional(),pad_diameter:Ai([VA(),Y()]).optional(),hole_diameter:Ai([VA(),Y()]).optional(),width:Ai([VA(),Y()]).optional(),height:Ai([VA(),Y()]).optional()}),LZA=wB.extend({ftype:FA("simple_mosfet"),channel_type:lt(["n","p"]),mosfet_mode:lt(["enhancement","depletion"])}),HZA=wB.extend({ftype:FA("simple_op_amp")}),YZA=wB.extend({ftype:FA("simple_switch")}),JZA=OA({type:FA("source_project_metadata"),name:Y().optional(),software_used_string:Y().optional(),project_url:Y().optional(),created_at:LIt.optional()}),OIt=OA({type:FA("source_missing_property_error"),source_missing_property_error_id:jt("source_missing_property_error"),source_component_id:Y(),property_name:Y(),subcircuit_id:Y().optional(),error_type:FA("source_missing_property_error").default("source_missing_property_error"),message:Y()}).describe("The source code is missing a property"),WIt=OA({type:FA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:jt("source_failed_to_create_component_error"),error_type:FA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:Y().optional(),subcircuit_id:Y().optional(),parent_source_component_id:Y().optional(),message:Y(),pcb_center:OA({x:VA().optional(),y:VA().optional()}).optional(),schematic_center:OA({x:VA().optional(),y:VA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),TZA=OA({type:FA("source_trace_not_connected_error"),source_trace_not_connected_error_id:jt("source_trace_not_connected_error"),error_type:FA("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:Y(),subcircuit_id:Y().optional(),source_group_id:Y().optional(),source_trace_id:Y().optional(),connected_source_port_ids:be(Y()).optional(),selectors_not_found:be(Y()).optional()}).describe("Occurs when a source trace selector does not match any ports"),ZIt=OA({type:FA("source_property_ignored_warning"),source_property_ignored_warning_id:jt("source_property_ignored_warning"),source_component_id:Y(),property_name:Y(),subcircuit_id:Y().optional(),error_type:FA("source_property_ignored_warning").default("source_property_ignored_warning"),message:Y()}).describe("The source property was ignored"),KZA=OA({type:FA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:jt("source_pin_missing_trace_warning"),warning_type:FA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:Y(),source_component_id:Y(),source_port_id:Y(),subcircuit_id:Y().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),VIt=wB.extend({ftype:FA("simple_voltage_probe")}),jIt=wB.extend({ftype:FA("interconnect")}),zIt=Ai([DZA,wZA,wlA,TIt,SZA,KIt,bZA,xZA,kZA,GZA,FZA,RZA,PIt,NZA,_ZA,MZA,YZA,vZA,UZA,LZA,HZA,qIt,VIt,jIt,JZA,OIt,WIt,TZA,ZIt,KZA]),XIt=OA({type:FA("source_port"),pin_number:VA().optional(),port_hints:be(Y()).optional(),name:Y(),source_port_id:Y(),source_component_id:Y().optional(),source_group_id:Y().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),must_be_connected:Be().optional()}),$It=OA({type:FA("source_component_internal_connection"),source_component_internal_connection_id:Y(),source_component_id:Y(),source_port_ids:be(Y()),subcircuit_id:Y().optional()}),Act=OA({type:FA("source_trace"),source_trace_id:Y(),connected_source_port_ids:be(Y()),connected_source_net_ids:be(Y()),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),max_length:VA().optional(),min_trace_thickness:VA().optional(),display_name:Y().optional()}),ect=OA({type:FA("source_group"),source_group_id:Y(),subcircuit_id:Y().optional(),parent_subcircuit_id:Y().optional(),parent_source_group_id:Y().optional(),is_subcircuit:Be().optional(),show_as_schematic_box:Be().optional(),name:Y().optional(),was_automatically_named:Be().optional()}),tct=OA({type:FA("source_net"),source_net_id:Y(),name:Y(),member_source_group_ids:be(Y()),is_power:Be().optional(),is_ground:Be().optional(),is_digital_signal:Be().optional(),is_analog_signal:Be().optional(),is_positive_voltage_source:Be().optional(),trace_width:VA().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional()}),ict=OA({type:FA("source_board"),source_board_id:Y(),source_group_id:Y(),title:Y().optional()}).describe("Defines a board in the source domain"),nct=OA({type:FA("source_pcb_ground_plane"),source_pcb_ground_plane_id:Y(),source_group_id:Y(),source_net_id:Y(),subcircuit_id:Y().optional()}).describe("Defines a ground plane in the source domain"),oct=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],qZA=lt(oct),Mr=qZA.or(OA({name:qZA})).transform(t=>typeof t=="string"?t:t.name),Gw=lt(["top","bottom"]),sct=OA({type:FA("source_manually_placed_via"),source_manually_placed_via_id:Y(),source_group_id:Y(),source_net_id:Y(),subcircuit_id:Y().optional(),source_trace_id:Y().optional()}).describe("Defines a via that is manually placed in the source domain"),rct=OA({type:FA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:jt("source_pin_must_be_connected_error"),error_type:FA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),message:Y(),source_component_id:Y(),source_port_id:Y(),subcircuit_id:Y().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),act=OA({type:FA("unknown_error_finding_part"),unknown_error_finding_part_id:jt("unknown_error_finding_part"),error_type:FA("unknown_error_finding_part").default("unknown_error_finding_part"),message:Y(),source_component_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),gct=OA({type:FA("schematic_box"),schematic_component_id:Y().optional(),width:wt,height:wt,is_dashed:Be().default(!1),x:wt,y:wt,subcircuit_id:Y().optional()}).describe("Draws a box on the schematic"),Ict=OA({type:FA("schematic_path"),schematic_component_id:Y(),fill_color:lt(["red","blue"]).optional(),is_filled:Be().optional(),points:be(kn),subcircuit_id:Y().optional()}),cct=Ma(OA({left_margin:$A.optional(),right_margin:$A.optional(),top_margin:$A.optional(),bottom_margin:$A.optional()})),Bct=OA({left_size:VA(),right_size:VA(),top_size:VA().optional(),bottom_size:VA().optional()}),lct=OA({left_side:OA({pins:be(VA()),direction:lt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:OA({pins:be(VA()),direction:lt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:OA({pins:be(VA()),direction:lt(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:OA({pins:be(VA()),direction:lt(["left-to-right","right-to-left"]).optional()}).optional()}),Cct=Ai([Bct,lct]),Qct=OA({type:FA("schematic_component"),size:mZA,center:kn,source_component_id:Y().optional(),schematic_component_id:Y(),pin_spacing:$A.optional(),pin_styles:cct.optional(),box_width:$A.optional(),symbol_name:Y().optional(),port_arrangement:Cct.optional(),port_labels:Ma(Y()).optional(),symbol_display_value:Y().optional(),subcircuit_id:Y().optional(),schematic_group_id:Y().optional(),is_schematic_group:Be().optional(),source_group_id:Y().optional(),is_box_with_pins:Be().optional().default(!0)}),Ect=OA({type:FA("schematic_line"),schematic_line_id:jt("schematic_line"),schematic_component_id:Y(),x1:wt,y1:wt,x2:wt,y2:wt,stroke_width:wt.nullable().optional(),color:Y().default("#000000"),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled line on the schematic"),hct=OA({type:FA("schematic_rect"),schematic_rect_id:jt("schematic_rect"),schematic_component_id:Y(),center:kn,width:wt,height:wt,rotation:md.default(0),stroke_width:wt.nullable().optional(),color:Y().default("#000000"),is_filled:Be().default(!1),fill_color:Y().optional(),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled rectangle on the schematic"),uct=OA({type:FA("schematic_circle"),schematic_circle_id:jt("schematic_circle"),schematic_component_id:Y(),center:kn,radius:wt,stroke_width:wt.nullable().optional(),color:Y().default("#000000"),is_filled:Be().default(!1),fill_color:Y().optional(),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled circle on the schematic"),dct=OA({type:FA("schematic_arc"),schematic_arc_id:jt("schematic_arc"),schematic_component_id:Y(),center:kn,radius:wt,start_angle_degrees:md,end_angle_degrees:md,direction:lt(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:wt.nullable().optional(),color:Y().default("#000000"),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled arc on the schematic"),pct=OA({type:FA("schematic_trace"),schematic_trace_id:Y(),source_trace_id:Y().optional(),junctions:be(OA({x:VA(),y:VA()})),edges:be(OA({from:OA({x:VA(),y:VA()}),to:OA({x:VA(),y:VA()}),is_crossing:Be().optional(),from_schematic_port_id:Y().optional(),to_schematic_port_id:Y().optional()})),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional()}),fct=lt(["center","left","right","top","bottom"]),yct=OA({type:FA("schematic_text"),schematic_component_id:Y().optional(),schematic_text_id:Y(),text:Y(),font_size:VA().default(.18),position:OA({x:wt,y:wt}),rotation:VA().default(0),anchor:Ai([fct.describe("legacy"),XG]).default("center"),color:Y().default("#000000"),subcircuit_id:Y().optional()}),mct=OA({type:FA("schematic_port"),schematic_port_id:Y(),source_port_id:Y(),schematic_component_id:Y().optional(),center:kn,facing_direction:lt(["up","down","left","right"]).optional(),distance_from_component_edge:VA().optional(),side_of_component:lt(["top","bottom","left","right"]).optional(),true_ccw_index:VA().optional(),pin_number:VA().optional(),display_pin_label:Y().optional(),subcircuit_id:Y().optional(),is_connected:Be().optional(),has_input_arrow:Be().optional(),has_output_arrow:Be().optional()}).describe("Defines a port on a schematic component"),wct=OA({type:FA("schematic_net_label"),schematic_net_label_id:jt("schematic_net_label"),schematic_trace_id:Y().optional(),source_trace_id:Y().optional(),source_net_id:Y(),center:kn,anchor_position:kn.optional(),anchor_side:lt(["top","bottom","left","right"]),text:Y(),symbol_name:Y().optional(),is_movable:Be().optional(),subcircuit_id:Y().optional()}),Dct=OA({type:FA("schematic_error"),schematic_error_id:Y(),error_type:FA("schematic_port_not_found").default("schematic_port_not_found"),message:Y(),subcircuit_id:Y().optional()}).describe("Defines a schematic error on the schematic"),Sct=OA({type:FA("schematic_layout_error"),schematic_layout_error_id:jt("schematic_layout_error"),error_type:FA("schematic_layout_error").default("schematic_layout_error"),message:Y(),source_group_id:Y(),schematic_group_id:Y(),subcircuit_id:Y().optional()}).describe("Error emitted when schematic layout fails for a group"),DlA=OA({type:FA("schematic_debug_object"),label:Y().optional(),subcircuit_id:Y().optional()}),bct=DlA.extend({shape:FA("rect"),center:kn,size:mZA}),xct=DlA.extend({shape:FA("line"),start:kn,end:kn}),kct=DlA.extend({shape:FA("point"),center:kn}),Gct=Np("shape",[bct,xct,kct]),Fct=OA({type:FA("schematic_voltage_probe"),schematic_voltage_probe_id:Y(),source_component_id:Y().optional(),name:Y().optional(),position:kn,schematic_trace_id:Y(),voltage:K_.optional(),subcircuit_id:Y().optional(),color:Y().optional(),label_alignment:XG.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),Rct=OA({type:FA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:jt("schematic_manual_edit_conflict_warning"),warning_type:FA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:Y(),schematic_component_id:Y(),schematic_group_id:Y().optional(),subcircuit_id:Y().optional(),source_component_id:Y()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),Nct=OA({type:FA("schematic_group"),schematic_group_id:jt("schematic_group"),source_group_id:Y(),is_subcircuit:Be().optional(),subcircuit_id:Y().optional(),width:$A,height:$A,center:kn,schematic_component_ids:be(Y()),show_as_schematic_box:Be().optional(),name:Y().optional(),description:Y().optional()}).describe("Defines a group of components on the schematic"),_ct=OA({type:FA("schematic_table"),schematic_table_id:jt("schematic_table"),anchor_position:kn,column_widths:be(wt),row_heights:be(wt),cell_padding:wt.optional(),border_width:wt.optional(),subcircuit_id:Y().optional(),schematic_component_id:Y().optional(),anchor:XG.optional()}).describe("Defines a table on the schematic"),Mct=OA({type:FA("schematic_table_cell"),schematic_table_cell_id:jt("schematic_table_cell"),schematic_table_id:Y(),start_row_index:VA(),end_row_index:VA(),start_column_index:VA(),end_column_index:VA(),text:Y().optional(),center:kn,width:wt,height:wt,horizontal_align:lt(["left","center","right"]).optional(),vertical_align:lt(["top","middle","bottom"]).optional(),font_size:wt.optional(),subcircuit_id:Y().optional()}).describe("Defines a cell within a schematic_table"),vct=OA({type:FA("schematic_sheet"),schematic_sheet_id:jt("schematic_sheet"),name:Y().optional(),subcircuit_id:Y().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),Uct=OA({x:wt,y:wt,bulge:VA().optional()}),PZA=OA({vertices:be(Uct)}),Lct=OA({outer_ring:PZA,inner_rings:be(PZA).default([])}),Hct=OA({x:wt,y:wt,via:Be().optional(),via_to_layer:Mr.optional()});be(Hct);var Yct=OA({x:wt,y:wt,via:Be().optional(),to_layer:Mr.optional(),trace_width:wt.optional()}),Jct=OA({type:FA("pcb_component"),pcb_component_id:jt("pcb_component"),source_component_id:Y(),center:kn,layer:Mr,rotation:md,display_offset_x:Y().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:Y().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:Be().optional(),subcircuit_id:Y().optional(),pcb_group_id:Y().optional(),position_mode:lt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:Y().optional(),positioned_relative_to_pcb_board_id:Y().optional(),obstructs_within_bounds:Be().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),OZA=OA({type:FA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:FA("circle"),hole_diameter:VA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()});OZA.describe("Defines a circular hole on the PCB");var WZA=OA({type:FA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:FA("rect"),hole_width:VA(),hole_height:VA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()});WZA.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square.");var ZZA=OA({type:FA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:lt(["circle","square"]),hole_diameter:VA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()});ZZA.describe("Defines a circular or square hole on the PCB");var VZA=OA({type:FA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:FA("oval"),hole_width:VA(),hole_height:VA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()});VZA.describe("Defines an oval hole on the PCB");var jZA=OA({type:FA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:FA("pill"),hole_width:VA(),hole_height:VA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()});jZA.describe("Defines a pill-shaped hole on the PCB");var zZA=OA({type:FA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:FA("rotated_pill"),hole_width:VA(),hole_height:VA(),x:wt,y:wt,ccw_rotation:md,is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()});zZA.describe("Defines a rotated pill-shaped hole on the PCB");var Tct=ZZA.or(VZA).or(jZA).or(zZA).or(OZA).or(WZA),Kct=OA({type:FA("pcb_plated_hole"),shape:FA("circle"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),outer_diameter:VA(),hole_diameter:VA(),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Mr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:VA().optional()}),qct=OA({type:FA("pcb_plated_hole"),shape:lt(["oval","pill"]),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),outer_width:VA(),outer_height:VA(),hole_width:VA(),hole_height:VA(),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,ccw_rotation:md,layers:be(Mr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:VA().optional()}),Pct=OA({type:FA("pcb_plated_hole"),shape:FA("circular_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:FA("circle"),pad_shape:FA("rect"),hole_diameter:VA(),rect_pad_width:VA(),rect_pad_height:VA(),rect_border_radius:VA().optional(),hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Mr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:VA().optional()}),Oct=OA({type:FA("pcb_plated_hole"),shape:FA("pill_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:FA("pill"),pad_shape:FA("rect"),hole_width:VA(),hole_height:VA(),rect_pad_width:VA(),rect_pad_height:VA(),rect_border_radius:VA().optional(),hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Mr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:VA().optional()}),Wct=OA({type:FA("pcb_plated_hole"),shape:FA("rotated_pill_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:FA("rotated_pill"),pad_shape:FA("rect"),hole_width:VA(),hole_height:VA(),hole_ccw_rotation:md,rect_pad_width:VA(),rect_pad_height:VA(),rect_border_radius:VA().optional(),rect_ccw_rotation:md,hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Mr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:VA().optional()}),Zct=OA({type:FA("pcb_plated_hole"),shape:FA("hole_with_polygon_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:lt(["circle","oval","pill","rotated_pill"]),hole_diameter:VA().optional(),hole_width:VA().optional(),hole_height:VA().optional(),pad_outline:be(OA({x:wt,y:wt})).min(3),hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Mr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:VA().optional()}),Vct=Ai([Kct,qct,Pct,Oct,Wct,Zct]),jct=OA({type:FA("pcb_port"),pcb_port_id:jt("pcb_port"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),source_port_id:Y(),pcb_component_id:Y().optional(),x:wt,y:wt,layers:be(Mr),is_board_pinout:Be().optional()}).describe("Defines a port on the PCB"),zct=OA({type:FA("pcb_smtpad"),shape:FA("circle"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,radius:VA(),layer:Mr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()}),Xct=OA({type:FA("pcb_smtpad"),shape:FA("rect"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),rect_border_radius:VA().optional(),corner_radius:VA().optional(),layer:Mr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()}),$ct=OA({type:FA("pcb_smtpad"),shape:FA("rotated_rect"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),rect_border_radius:VA().optional(),corner_radius:VA().optional(),ccw_rotation:md,layer:Mr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()}),ABt=OA({type:FA("pcb_smtpad"),shape:FA("pill"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),radius:VA(),layer:Mr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()}),eBt=OA({type:FA("pcb_smtpad"),shape:FA("rotated_pill"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),radius:VA(),ccw_rotation:md,layer:Mr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()}),tBt=OA({type:FA("pcb_smtpad"),shape:FA("polygon"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),points:be(kn),layer:Mr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()}),iBt=Np("shape",[zct,Xct,$ct,eBt,ABt,tBt]).describe("Defines an SMT pad on the PCB"),nBt=OA({type:FA("pcb_solder_paste"),shape:FA("circle"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,radius:VA(),layer:Mr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),oBt=OA({type:FA("pcb_solder_paste"),shape:FA("rect"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),layer:Mr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),sBt=OA({type:FA("pcb_solder_paste"),shape:FA("pill"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),radius:VA(),layer:Mr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),rBt=OA({type:FA("pcb_solder_paste"),shape:FA("rotated_rect"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),ccw_rotation:wt,layer:Mr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),aBt=OA({type:FA("pcb_solder_paste"),shape:FA("oval"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),layer:Mr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),gBt=Ai([nBt,oBt,sBt,rBt,aBt]).describe("Defines solderpaste on the PCB"),IBt=OA({type:FA("pcb_text"),pcb_text_id:jt("pcb_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),text:Y(),center:kn,layer:Mr,width:$A,height:$A,lines:VA(),align:lt(["bottom-left"])}).describe("Defines text on the PCB"),cBt=OA({route_type:FA("wire"),x:wt,y:wt,width:wt,start_pcb_port_id:Y().optional(),end_pcb_port_id:Y().optional(),layer:Mr}),BBt=OA({route_type:FA("via"),x:wt,y:wt,hole_diameter:wt.optional(),outer_diameter:wt.optional(),from_layer:Y(),to_layer:Y()}),lBt=Ai([cBt,BBt]),CBt=OA({type:FA("pcb_trace"),source_trace_id:Y().optional(),pcb_component_id:Y().optional(),pcb_trace_id:jt("pcb_trace"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),route_thickness_mode:lt(["constant","interpolated"]).default("constant").optional(),route_order_index:VA().optional(),should_round_corners:Be().optional(),trace_length:VA().optional(),highlight_color:Y().optional(),route:be(lBt)}).describe("Defines a trace on the PCB"),QBt=OA({type:FA("pcb_trace_error"),pcb_trace_error_id:jt("pcb_trace_error"),error_type:FA("pcb_trace_error").default("pcb_trace_error"),message:Y(),center:kn.optional(),pcb_trace_id:Y(),source_trace_id:Y(),pcb_component_ids:be(Y()),pcb_port_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines a trace error on the PCB"),EBt=OA({type:FA("pcb_trace_missing_error"),pcb_trace_missing_error_id:jt("pcb_trace_missing_error"),error_type:FA("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:Y(),center:kn.optional(),source_trace_id:Y(),pcb_component_ids:be(Y()),pcb_port_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),hBt=OA({type:FA("pcb_port_not_matched_error"),pcb_error_id:jt("pcb_error"),error_type:FA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:Y(),pcb_component_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),uBt=OA({type:FA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:jt("pcb_port_not_connected_error"),error_type:FA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:Y(),pcb_port_ids:be(Y()),pcb_component_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),dBt=OA({type:FA("pcb_net"),pcb_net_id:jt("pcb_net"),source_net_id:Y().optional(),highlight_color:Y().optional()}).describe("Defines a net on the PCB"),pBt=OA({type:FA("pcb_via"),pcb_via_id:jt("pcb_via"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),x:wt,y:wt,outer_diameter:wt.default("0.6mm"),hole_diameter:wt.default("0.25mm"),from_layer:Mr.optional(),to_layer:Mr.optional(),layers:be(Mr),pcb_trace_id:Y().optional(),net_is_assignable:Be().optional(),net_assigned:Be().optional(),is_tented:Be().optional()}).describe("Defines a via on the PCB"),fBt=OA({type:FA("pcb_board"),pcb_board_id:jt("pcb_board"),pcb_panel_id:Y().optional(),is_subcircuit:Be().optional(),subcircuit_id:Y().optional(),width:$A.optional(),height:$A.optional(),center:kn,display_offset_x:Y().optional().describe("How to display the x offset for this board, usually corresponding with how the user specified it"),display_offset_y:Y().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:VA().optional().default(4),outline:be(kn).optional(),shape:lt(["rect","polygon"]).optional(),material:lt(["fr4","fr1"]).default("fr4"),anchor_position:kn.optional(),anchor_alignment:XG.optional(),position_mode:lt(["relative_to_panel_anchor","none"]).optional()}).describe("Defines the board outline of the PCB"),yBt=OA({type:FA("pcb_panel"),pcb_panel_id:jt("pcb_panel"),width:$A,height:$A,center:kn,covered_with_solder_mask:Be().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),mBt=OA({type:FA("pcb_placement_error"),pcb_placement_error_id:jt("pcb_placement_error"),error_type:FA("pcb_placement_error").default("pcb_placement_error"),message:Y(),subcircuit_id:Y().optional()}).describe("Defines a placement error on the PCB"),wBt=OA({type:FA("pcb_trace_hint"),pcb_trace_hint_id:jt("pcb_trace_hint"),pcb_port_id:Y(),pcb_component_id:Y(),route:be(Yct),subcircuit_id:Y().optional()}).describe("A hint that can be used during generation of a PCB trace"),DBt=OA({type:FA("pcb_silkscreen_line"),pcb_silkscreen_line_id:jt("pcb_silkscreen_line"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),stroke_width:wt.default("0.1mm"),x1:wt,y1:wt,x2:wt,y2:wt,layer:Gw}).describe("Defines a silkscreen line on the PCB"),SBt=OA({type:FA("pcb_silkscreen_path"),pcb_silkscreen_path_id:jt("pcb_silkscreen_path"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Gw,route:be(kn),stroke_width:$A}).describe("Defines a silkscreen path on the PCB"),bBt=OA({type:FA("pcb_silkscreen_text"),pcb_silkscreen_text_id:jt("pcb_silkscreen_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("0.2mm"),pcb_component_id:Y(),text:Y(),is_knockout:Be().default(!1).optional(),knockout_padding:OA({left:$A,top:$A,bottom:$A,right:$A}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:VA().optional(),layer:Mr,is_mirrored:Be().default(!1).optional(),anchor_position:kn.default({x:0,y:0}),anchor_alignment:XG.default("center")}).describe("Defines silkscreen text on the PCB"),xBt=OA({type:FA("pcb_copper_text"),pcb_copper_text_id:jt("pcb_copper_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("0.2mm"),pcb_component_id:Y(),text:Y(),is_knockout:Be().default(!1).optional(),knockout_padding:OA({left:$A,top:$A,bottom:$A,right:$A}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:VA().optional(),layer:Mr,is_mirrored:Be().default(!1).optional(),anchor_position:kn.default({x:0,y:0}),anchor_alignment:XG.default("center")}).describe("Defines copper text on the PCB"),kBt=OA({type:FA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:jt("pcb_silkscreen_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,width:$A,height:$A,layer:Mr,stroke_width:$A.default("1mm"),corner_radius:$A.optional(),is_filled:Be().default(!0).optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),ccw_rotation:VA().optional()}).describe("Defines a silkscreen rect on the PCB"),GBt=OA({type:FA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:jt("pcb_silkscreen_circle"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,radius:$A,layer:Gw,stroke_width:$A.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),FBt=OA({type:FA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:jt("pcb_silkscreen_oval"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,radius_x:wt,radius_y:wt,layer:Gw,ccw_rotation:md.optional()}).describe("Defines a silkscreen oval on the PCB"),RBt=OA({type:FA("pcb_silkscreen_pill"),pcb_silkscreen_pill_id:jt("pcb_silkscreen_pill"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,width:$A,height:$A,layer:Mr,ccw_rotation:VA().optional()}).describe("Defines a silkscreen pill on the PCB"),NBt=OA({type:FA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:jt("pcb_fabrication_note_text"),subcircuit_id:Y().optional(),pcb_group_id:Y().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("1mm"),pcb_component_id:Y(),text:Y(),layer:Gw,anchor_position:kn.default({x:0,y:0}),anchor_alignment:lt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Y().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),_Bt=OA({type:FA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:jt("pcb_fabrication_note_path"),pcb_component_id:Y(),subcircuit_id:Y().optional(),layer:Mr,route:be(kn),stroke_width:$A,color:Y().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),MBt=OA({type:FA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:jt("pcb_fabrication_note_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,width:$A,height:$A,layer:Gw,stroke_width:$A.default("0.1mm"),corner_radius:$A.optional(),is_filled:Be().optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),color:Y().optional()}).describe("Defines a fabrication note rectangle on the PCB"),vBt=OA({type:FA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:jt("pcb_fabrication_note_dimension"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Gw,from:kn,to:kn,text:Y().optional(),text_ccw_rotation:VA().optional(),offset:$A.optional(),offset_distance:$A.optional(),offset_direction:OA({x:VA(),y:VA()}).optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:$A.default("1mm"),color:Y().optional(),arrow_size:$A.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),UBt=OA({type:FA("pcb_note_text"),pcb_note_text_id:jt("pcb_note_text"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("1mm"),text:Y().optional(),anchor_position:kn.default({x:0,y:0}),anchor_alignment:lt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Y().optional()}).describe("Defines a documentation note in text on the PCB"),LBt=OA({type:FA("pcb_note_rect"),pcb_note_rect_id:jt("pcb_note_rect"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),center:kn,width:$A,height:$A,stroke_width:$A.default("0.1mm"),corner_radius:$A.optional(),is_filled:Be().optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),color:Y().optional()}).describe("Defines a rectangular documentation note on the PCB"),HBt=OA({type:FA("pcb_note_path"),pcb_note_path_id:jt("pcb_note_path"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),route:be(kn),stroke_width:$A.default("0.1mm"),color:Y().optional()}).describe("Defines a polyline documentation note on the PCB"),YBt=OA({type:FA("pcb_note_line"),pcb_note_line_id:jt("pcb_note_line"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),x1:wt,y1:wt,x2:wt,y2:wt,stroke_width:wt.default("0.1mm"),color:Y().optional(),is_dashed:Be().optional()}).describe("Defines a straight documentation note line on the PCB"),JBt=OA({type:FA("pcb_note_dimension"),pcb_note_dimension_id:jt("pcb_note_dimension"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),from:kn,to:kn,text:Y().optional(),text_ccw_rotation:VA().optional(),offset_distance:$A.optional(),offset_direction:OA({x:VA(),y:VA()}).optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:$A.default("1mm"),color:Y().optional(),arrow_size:$A.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),TBt=OA({type:FA("pcb_footprint_overlap_error"),pcb_error_id:jt("pcb_error"),error_type:FA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:Y(),pcb_smtpad_ids:be(Y()).optional(),pcb_plated_hole_ids:be(Y()).optional(),pcb_hole_ids:be(Y()).optional(),pcb_keepout_ids:be(Y()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),KBt=OA({type:FA("pcb_keepout"),shape:FA("rect"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,width:wt,height:wt,pcb_keepout_id:Y(),layers:be(Y()),description:Y().optional()}).or(OA({type:FA("pcb_keepout"),shape:FA("circle"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,radius:wt,pcb_keepout_id:Y(),layers:be(Y()),description:Y().optional()})),B5=OA({type:FA("pcb_cutout"),pcb_cutout_id:jt("pcb_cutout"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_board_id:Y().optional(),pcb_panel_id:Y().optional()}),qBt=B5.extend({shape:FA("rect"),center:kn,width:$A,height:$A,rotation:md.optional(),corner_radius:$A.optional()}),PBt=B5.extend({shape:FA("circle"),center:kn,radius:$A}),OBt=B5.extend({shape:FA("polygon"),points:be(kn)}),WBt=B5.extend({shape:FA("path"),route:be(kn),slot_width:$A,slot_length:$A.optional(),space_between_slots:$A.optional(),slot_corner_radius:$A.optional()}),ZBt=Np("shape",[qBt,PBt,OBt,WBt]).describe("Defines a cutout on the PCB, removing board material."),VBt=OA({type:FA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:jt("pcb_missing_footprint_error"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),error_type:FA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:Y(),message:Y()}).describe("Defines a missing footprint error on the PCB"),jBt=OA({type:FA("external_footprint_load_error"),external_footprint_load_error_id:jt("external_footprint_load_error"),pcb_component_id:Y(),source_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),footprinter_string:Y().optional(),error_type:FA("external_footprint_load_error").default("external_footprint_load_error"),message:Y()}).describe("Defines an error when an external footprint fails to load"),zBt=OA({type:FA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:jt("circuit_json_footprint_load_error"),pcb_component_id:Y(),source_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),error_type:FA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:Y(),circuit_json:be(UI()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),XBt=OA({type:FA("pcb_group"),pcb_group_id:jt("pcb_group"),source_group_id:Y(),is_subcircuit:Be().optional(),subcircuit_id:Y().optional(),width:$A.optional(),height:$A.optional(),center:kn,display_offset_x:Y().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:Y().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:be(kn).optional(),anchor_position:kn.optional(),anchor_alignment:XG.default("center"),position_mode:lt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:Y().optional(),positioned_relative_to_pcb_board_id:Y().optional(),pcb_component_ids:be(Y()),child_layout_mode:lt(["packed","none"]).optional(),name:Y().optional(),description:Y().optional(),layout_mode:Y().optional(),autorouter_configuration:OA({trace_clearance:$A}).optional(),autorouter_used_string:Y().optional()}).describe("Defines a group of components on the PCB"),$Bt=OA({type:FA("pcb_autorouting_error"),pcb_error_id:jt("pcb_autorouting_error"),error_type:FA("pcb_autorouting_error").default("pcb_autorouting_error"),message:Y(),subcircuit_id:Y().optional()}).describe("The autorouting has failed to route a portion of the board"),Alt=OA({type:FA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:jt("pcb_manual_edit_conflict_warning"),warning_type:FA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:Y(),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),source_component_id:Y()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),elt=OA({type:FA("pcb_breakout_point"),pcb_breakout_point_id:jt("pcb_breakout_point"),pcb_group_id:Y(),subcircuit_id:Y().optional(),source_trace_id:Y().optional(),source_port_id:Y().optional(),source_net_id:Y().optional(),x:wt,y:wt}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),tlt=OA({type:FA("pcb_ground_plane"),pcb_ground_plane_id:jt("pcb_ground_plane"),source_pcb_ground_plane_id:Y(),source_net_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Defines a ground plane on the PCB"),ilt=OA({type:FA("pcb_ground_plane_region"),pcb_ground_plane_region_id:jt("pcb_ground_plane_region"),pcb_ground_plane_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Mr,points:be(kn)}).describe("Defines a polygon region of a ground plane"),nlt=OA({type:FA("pcb_thermal_spoke"),pcb_thermal_spoke_id:jt("pcb_thermal_spoke"),pcb_ground_plane_id:Y(),shape:Y(),spoke_count:VA(),spoke_thickness:wt,spoke_inner_diameter:wt,spoke_outer_diameter:wt,pcb_plated_hole_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),SlA=OA({type:FA("pcb_copper_pour"),pcb_copper_pour_id:jt("pcb_copper_pour"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Mr,source_net_id:Y().optional(),covered_with_solder_mask:Be().optional().default(!0)}),olt=SlA.extend({shape:FA("rect"),center:kn,width:$A,height:$A,rotation:md.optional()}),slt=SlA.extend({shape:FA("brep"),brep_shape:Lct}),rlt=SlA.extend({shape:FA("polygon"),points:be(kn)}),alt=Np("shape",[olt,slt,rlt]).describe("Defines a copper pour on the PCB."),glt=OA({type:FA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:jt("pcb_component_outside_board_error"),error_type:FA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:Y(),pcb_component_id:Y(),pcb_board_id:Y(),component_center:kn,component_bounds:OA({min_x:VA(),max_x:VA(),min_y:VA(),max_y:VA()}),subcircuit_id:Y().optional(),source_component_id:Y().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),Ilt=OA({type:FA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:jt("pcb_component_invalid_layer_error"),error_type:FA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:Y(),pcb_component_id:Y().optional(),source_component_id:Y(),layer:Mr,subcircuit_id:Y().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),clt=OA({type:FA("pcb_via_clearance_error"),pcb_error_id:jt("pcb_error"),error_type:FA("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:Y(),pcb_via_ids:be(Y()).min(2),minimum_clearance:wt.optional(),actual_clearance:wt.optional(),pcb_center:OA({x:VA().optional(),y:VA().optional()}).optional(),subcircuit_id:Y().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),Blt=OA({type:FA("pcb_courtyard_rect"),pcb_courtyard_rect_id:jt("pcb_courtyard_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,width:$A,height:$A,layer:Gw,color:Y().optional()}).describe("Defines a courtyard rectangle on the PCB"),llt=OA({type:FA("pcb_courtyard_outline"),pcb_courtyard_outline_id:jt("pcb_courtyard_outline"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Gw,outline:be(kn).min(2),stroke_width:$A.default("0.1mm"),is_closed:Be().optional(),is_stroke_dashed:Be().optional(),color:Y().optional()}).describe("Defines a courtyard outline on the PCB"),Clt=OA({type:FA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:jt("pcb_courtyard_polygon"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Gw,points:be(kn).min(3),color:Y().optional()}).describe("Defines a courtyard polygon on the PCB"),Qlt=OA({type:FA("cad_component"),cad_component_id:Y(),pcb_component_id:Y(),source_component_id:Y(),position:mlA,rotation:mlA.optional(),size:mlA.optional(),layer:Mr.optional(),subcircuit_id:Y().optional(),footprinter_string:Y().optional(),model_obj_url:Y().optional(),model_stl_url:Y().optional(),model_3mf_url:Y().optional(),model_gltf_url:Y().optional(),model_glb_url:Y().optional(),model_step_url:Y().optional(),model_wrl_url:Y().optional(),model_unit_to_mm_scale_factor:VA().optional(),model_jscad:UI().optional(),show_as_translucent_model:Be().optional()}).describe("Defines a component on the PCB"),XZA=lt(["sinewave","square","triangle","sawtooth"]),Elt=Ai([Y(),VA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(VA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),hlt=OA({type:FA("simulation_voltage_source"),simulation_voltage_source_id:jt("simulation_voltage_source"),is_dc_source:FA(!0).optional().default(!0),positive_source_port_id:Y().optional(),negative_source_port_id:Y().optional(),positive_source_net_id:Y().optional(),negative_source_net_id:Y().optional(),voltage:K_}).describe("Defines a DC voltage source for simulation"),ult=OA({type:FA("simulation_voltage_source"),simulation_voltage_source_id:jt("simulation_voltage_source"),is_dc_source:FA(!1),terminal1_source_port_id:Y().optional(),terminal2_source_port_id:Y().optional(),terminal1_source_net_id:Y().optional(),terminal2_source_net_id:Y().optional(),voltage:K_.optional(),frequency:c5.optional(),peak_to_peak_voltage:K_.optional(),wave_shape:XZA.optional(),phase:md.optional(),duty_cycle:Elt.optional()}).describe("Defines an AC voltage source for simulation"),dlt=Ai([hlt,ult]).describe("Defines a voltage source for simulation"),plt=Ai([Y(),VA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(VA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),flt=OA({type:FA("simulation_current_source"),simulation_current_source_id:jt("simulation_current_source"),is_dc_source:FA(!0).optional().default(!0),positive_source_port_id:Y().optional(),negative_source_port_id:Y().optional(),positive_source_net_id:Y().optional(),negative_source_net_id:Y().optional(),current:flA}).describe("Defines a DC current source for simulation"),ylt=OA({type:FA("simulation_current_source"),simulation_current_source_id:jt("simulation_current_source"),is_dc_source:FA(!1),terminal1_source_port_id:Y().optional(),terminal2_source_port_id:Y().optional(),terminal1_source_net_id:Y().optional(),terminal2_source_net_id:Y().optional(),current:flA.optional(),frequency:c5.optional(),peak_to_peak_current:flA.optional(),wave_shape:XZA.optional(),phase:md.optional(),duty_cycle:plt.optional()}).describe("Defines an AC current source for simulation"),mlt=Ai([flt,ylt]).describe("Defines a current source for simulation"),wlt=Ai([FA("spice_dc_sweep"),FA("spice_dc_operating_point"),FA("spice_transient_analysis"),FA("spice_ac_analysis")]),Dlt=OA({type:FA("simulation_experiment"),simulation_experiment_id:jt("simulation_experiment"),name:Y(),experiment_type:wlt,time_per_step:ylA.optional(),start_time_ms:q_.optional(),end_time_ms:q_.optional()}).describe("Defines a simulation experiment configuration"),Slt=OA({type:FA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:jt("simulation_transient_voltage_graph"),simulation_experiment_id:Y(),timestamps_ms:be(VA()).optional(),voltage_levels:be(VA()),source_component_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),time_per_step:ylA,start_time_ms:q_,end_time_ms:q_,name:Y().optional(),color:Y().optional()}).describe("Stores voltage measurements over time for a simulation"),blt=OA({type:FA("simulation_switch"),simulation_switch_id:jt("simulation_switch"),source_component_id:Y().optional(),closes_at:q_.optional(),opens_at:q_.optional(),starts_closed:Be().optional(),switching_frequency:c5.optional()}).describe("Defines a switch for simulation timing control"),xlt=OA({type:FA("simulation_voltage_probe"),simulation_voltage_probe_id:jt("simulation_voltage_probe"),source_component_id:Y().optional(),name:Y().optional(),signal_input_source_port_id:Y().optional(),signal_input_source_net_id:Y().optional(),reference_input_source_port_id:Y().optional(),reference_input_source_net_id:Y().optional(),subcircuit_id:Y().optional(),color:Y().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,n=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&n?A.addIssue({code:Wt.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:Wt.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):n&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:Wt.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:Wt.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),klt=OA({type:FA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:jt("simulation_unknown_experiment_error"),error_type:FA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:Y(),simulation_experiment_id:Y().optional(),subcircuit_id:Y().optional()}).describe("An unknown error occurred during the simulation experiment."),Glt=OA({type:FA("simulation_op_amp"),simulation_op_amp_id:jt("simulation_op_amp"),source_component_id:Y().optional(),inverting_input_source_port_id:Y(),non_inverting_input_source_port_id:Y(),output_source_port_id:Y(),positive_supply_source_port_id:Y(),negative_supply_source_port_id:Y()}).describe("Defines a simple ideal operational amplifier for simulation");Ai([Act,XIt,$It,zIt,tct,ect,bZA,wZA,wlA,SZA,DZA,xZA,kZA,GZA,NZA,_ZA,MZA,YZA,vZA,UZA,LZA,HZA,RZA,FZA,nct,sct,ict,JZA,TZA,KZA,rct,act,Jct,Tct,VBt,jBt,zBt,Alt,Vct,KBt,jct,dBt,IBt,CBt,pBt,iBt,gBt,fBt,yBt,XBt,wBt,DBt,SBt,bBt,RBt,xBt,kBt,GBt,FBt,QBt,EBt,mBt,hBt,uBt,clt,_Bt,NBt,MBt,vBt,UBt,LBt,HBt,YBt,JBt,$Bt,TBt,elt,ZBt,tlt,ilt,nlt,alt,glt,Ilt,Blt,llt,Clt,gct,yct,Ect,hct,uct,dct,Qct,mct,pct,Ict,Dct,Sct,wct,Gct,Fct,Rct,Nct,vct,_ct,Mct,Qlt,dlt,mlt,Dlt,Slt,blt,xlt,klt,Glt]);var Flt=Object.defineProperty,Rlt=(t,A)=>{for(var e in A)Flt(t,e,{get:A[e],enumerable:!0})},cS={};Rlt(cS,{axial:()=>eQt,bga:()=>ICt,breakoutheaders:()=>CQt,cap:()=>Hlt,dfn:()=>vCt,diode:()=>Llt,dip:()=>Mlt,electrolytic:()=>zht,hc49:()=>EQt,jst:()=>dht,led:()=>Ylt,lqfp:()=>BQt,m2host:()=>uut,melf:()=>xEt,micromelf:()=>REt,minimelf:()=>pEt,mlp:()=>dCt,ms012:()=>KCt,ms013:()=>PCt,msop:()=>kht,pad:()=>hQt,pinrow:()=>HCt,platedhole:()=>gut,potentiometer:()=>Zht,pushbutton:()=>sQt,qfn:()=>ECt,qfp:()=>uCt,quad:()=>O_,radial:()=>nQt,res:()=>rCt,sma:()=>vEt,smb:()=>qEt,smbf:()=>$ht,smc:()=>ZEt,smf:()=>YEt,smtpad:()=>rut,sod110:()=>fht,sod123:()=>zCt,sod123f:()=>XQt,sod123fl:()=>tEt,sod123w:()=>RQt,sod128:()=>IEt,sod323:()=>vQt,sod323f:()=>ZQt,sod323fl:()=>Mht,sod323w:()=>Fht,sod523:()=>yQt,sod723:()=>sEt,sod80:()=>xQt,sod882:()=>qQt,sod882d:()=>wEt,sod923:()=>YQt,soic:()=>BCt,solderjumper:()=>Yht,son:()=>Hht,sop8:()=>SQt,sot:()=>cut,sot223:()=>XEt,sot23:()=>kCt,sot23w:()=>rht,sot25:()=>NCt,sot323:()=>iut,sot343:()=>Cut,sot363:()=>DCt,sot457:()=>Kht,sot563:()=>JCt,sot723:()=>WCt,sot886:()=>bCt,sot89:()=>EEt,sot963:()=>Pht,ssop:()=>fCt,stampboard:()=>aQt,stampreceiver:()=>cQt,to220:()=>uEt,to92:()=>pQt,to92l:()=>put,to92s:()=>lht,tqfp:()=>hCt,tssop:()=>mCt,vssop:()=>Sht});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=OA({norefdes:Be().optional().describe("disable reference designator label"),invert:Be().optional().describe("hint to invert the orientation of the 3D model"),faceup:Be().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:Be().optional().describe("omit all silkscreen elements from the footprint")}),Oo=(t,A,e,i,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:mr(i),outer_diameter:mr(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),BS=(t,A,e,i,n,o,s,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:A,y:e,hole_diameter:mr(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:mr(n),rect_pad_height:mr(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],hole_offset_x:s,hole_offset_y:r}),$ZA=Array.from({length:9},(t,A)=>Math.cos(A/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)}));function Dx(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var l5=Ai([Y(),VA()]).transform(t=>Dx(t)),Nlt=t=>Hi.extend({fn:Y(),num_pins:VA().optional().default(6),wide:Be().optional(),narrow:Be().optional(),w:l5.optional(),p:l5.default(t.p??"2.54mm"),id:l5.optional(),od:l5.optional(),nosquareplating:Be().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=Dx("0.55mm"),A.od=Dx("0.95mm")):(A.id=Dx("0.8mm"),A.od=Dx("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=Dx("600mil"):A.narrow?A.w=Dx("300mil"):A.w=Dx(t.w??"300mil")),A)),_lt=Nlt({}),AVA=(t,A,e,i,n)=>{const o=t/2,s=A<=o,r=o-1,a=i,g=a*r;return s?{x:-e/2,y:g/2-(A-1)*a}:{x:e/2,y:-g/2+(A-o-1)*a}},Mlt=t=>{const A=_lt.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:I,y:c}=AVA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating);if(g===0&&!A.nosquareplating){e.push(BS(g+1,I,c,A.id??"0.8mm",A.od??"1mm",A.od??"1mm"));continue}e.push(Oo(g+1,I,c,A.id??"0.8mm",A.od??"1mm"))}(A.num_pins/2-1)*A.p+A.od;const n=A.w-A.od-1,o=(A.num_pins/2-1)*A.p+A.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/2,y:-o/2},{x:-n/2,y:o/2},...$ZA.map(({x:g,y:I})=>({x:g*n/6,y:I*n/6+o/2})),{x:n/2,y:o/2},{x:n/2,y:-o/2},{x:-n/2,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1},r=[];for(let g=0;g<A.num_pins;g++){const I=g<A.num_pins/2,c=.6,{y:B}=AVA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating),l=I?-A.w/2-A.od/2-c:A.w/2+A.od/2+c,C=B;r.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${g+1}`,layer:"top",pcb_component_id:`pin_${g+1}`,text:`{pin${g+1}}`,anchor_position:{x:l,y:C},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Li(0,o/2+.5,.4);return{circuitJson:[...e,s,a,...r],parameters:A}},Qi=(t,A,e,i,n)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:n,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),eVA=[{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}],vlt=Object.fromEntries(eVA.map(t=>[t.metric,t])),Ult=Object.fromEntries(eVA.map(t=>[t.imperial,t]));Hi.extend({tht:Be(),p:$A.optional(),pw:$A.optional(),ph:$A.optional(),metric:wt.optional(),imperial:wt.optional(),w:$A.optional(),h:$A.optional(),textbottom:Be().optional()});var C5=t=>{let{tht:A,p:e,pw:i,ph:n,metric:o,imperial:s,w:r,h:a,textbottom:g}=t;if(typeof r=="string"&&(r=mB(r)),typeof a=="string"&&(a=mB(a)),typeof e=="string"&&(e=mB(e)),typeof i=="string"&&(i=mB(i)),typeof n=="string"&&(n=mB(n)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let I;if(o&&(I=vlt[o]),s&&(I=Ult[s]),I&&(r=I.w_mm_min,a=I.h_mm_min,e=I.p_mm_min,i=I.pw_mm_min,n=I.ph_mm_min),e===void 0||i===void 0||n===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:e/2,y:n/2+.4},{x:-e/2-i/2-.2,y:n/2+.4},{x:-e/2-i/2-.2,y:-n/2-.4},{x:e/2,y:-n/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},B=g?-n/2-.9:n/2+.9,l=Li(0,B,.2);return A?[Oo(1,-e/2,0,i,i*1/.8),Oo(2,e/2,0,i,i*1/.8),c,l]:[Qi(["1","left"],-e/2,0,i,n),Qi(["2","right"],e/2,0,i,n),c,l]},Llt=t=>({circuitJson:C5(t),parameters:t}),Hlt=t=>({circuitJson:C5(t),parameters:t}),Ylt=t=>({circuitJson:C5(t),parameters:t}),P_=t=>{const{padSpacing:A,padWidth:e,padHeight:i,padPitch:n,numRows:o,textbottom:s}=t,r=[],a=(o-1)*(n/2);for(let x=0;x<o;x++)r.push(a-x*n);const g=[];r.forEach((x,F)=>{g.push(Qi(F+1,-A/2,x,e,i))}),r.slice().reverse().forEach((x,F)=>{g.push(Qi(F+o+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,l=A/2+e/2+.4,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l*.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:l*.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,w={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},S=s?c-.9:I+.9,D=Li(0,S,.2);return[...g,C,Q,w,D]},Jlt=Hi.extend({pw:Y().default("0.5mm"),ph:Y().default("0.4mm"),p:Y().default("0.7mm"),textbottom:Be().optional()}),Tlt=1,Klt=t=>{const A=Jlt.parse(t),e=mB(A.pw),i=mB(A.ph),n=mB(A.p);return P_({padSpacing:Tlt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom})},qlt=Hi.extend({pw:Y().default("0.5mm"),ph:Y().default("0.32mm"),p:Y().default("0.5mm"),textbottom:Be().optional()}),Plt=1,Olt=t=>{const A=qlt.parse(t),e=mB(A.pw),i=mB(A.ph),n=mB(A.p);return P_({padSpacing:Plt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom})},Wlt=Hi.extend({pw:Y().default("0.9mm"),ph:Y().default("0.4mm"),p:Y().default("0.8mm"),textbottom:Be().optional()}),Zlt=1.7,Vlt=t=>{const A=Wlt.parse(t),e=mB(A.pw),i=mB(A.ph),n=mB(A.p);return P_({padSpacing:Zlt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom})},jlt=Hi.extend({pw:Y().default("0.9mm"),ph:Y().default("0.4mm"),p:Y().default("0.8mm"),textbottom:Be().optional()}),zlt=1.7,Xlt=t=>{const A=jlt.parse(t),e=mB(A.pw),i=mB(A.ph),n=mB(A.p);return P_({padSpacing:zlt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom})},$lt=Hi.extend({pw:Y().default("0.7mm"),ph:Y().default("0.64mm"),p:Y().default("0.94mm"),textbottom:Be().optional()}),ACt=1.4,eCt=t=>{const A=$lt.parse(t),e=mB(A.pw),i=mB(A.ph),n=mB(A.p);return P_({padSpacing:ACt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom})},tCt=Hi.extend({pw:Y().default("0.9mm"),ph:Y().default("0.9mm"),p:Y().default("1.34mm"),textbottom:Be().optional()}),iCt=3,nCt=t=>{const A=tCt.parse(t),e=mB(A.pw),i=mB(A.ph),n=mB(A.p);return P_({padSpacing:iCt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom})},oCt=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)}},sCt=t=>t?(typeof t=="number"?`${t}`:t).split("_")[0]:void 0,rCt=t=>{const A=oCt(t),e=sCt(t.imperial);return A===2&&e==="0402"?{circuitJson:Klt(t),parameters:t}:A===4&&e==="0402"?{circuitJson:Olt(t),parameters:t}:A===2&&e==="0603"?{circuitJson:Vlt(t),parameters:t}:A===4&&e==="0603"?{circuitJson:Xlt(t),parameters:t}:A===2&&e==="0606"?{circuitJson:eCt(t),parameters:t}:A===4&&e==="1206"?{circuitJson:nCt(t),parameters:t}:{circuitJson:C5(t),parameters:t}},tVA=(t,{x:A,y:e,radius:i})=>({type:"pcb_smtpad",x:A,y:e,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),iVA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",nVA=Y().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A),y:parseFloat(e)}}).pipe(OA({x:VA(),y:VA()})),aCt=Y().or(be(UI())).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(Y().or(VA()))),gCt=Hi.extend({fn:Y(),num_pins:VA().optional().default(64),grid:nVA.optional(),p:wt.default("0.8mm"),w:$A.optional(),h:$A.optional(),ball:$A.optional().describe("ball diameter"),pad:$A.optional().describe("pad width/height"),circularpads:Be().optional().describe("use circular pads"),tlorigin:Be().optional(),blorigin:Be().optional(),trorigin:Be().optional(),brorigin:Be().optional(),missing:aCt.default([])}).transform(t=>{let A="tl";if(t.blorigin&&(A="bl"),t.trorigin&&(A="tr"),t.brorigin&&(A="br"),!t.grid){const i=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:i,y:i}}return t.missing&&(t.missing=t.missing.map(i=>{if(typeof i=="number")return i;if(i==="center")return"center";if(i==="topleft")return"topleft";const n=i.match(/([A-Z]+)(\d+)/);if(!n)return i;const o=iVA.indexOf(n[1]),s=Number.parseInt(n[2])-1;return o*t.grid.x+s+1})),{...t,origin:A}}),ICt=t=>{const A=gCt.parse(t);let{num_pins:e,grid:i,p:n,w:o,h:s,ball:r,pad:a,missing:g}=A;r??=.75/1.27*n,a??=r*.8;const I=[],c=(g??[]).filter(w=>typeof w=="number"),B=i.x*i.y-e;if(g.length===0&&B>0&&(Math.sqrt(B)%1===0?g.push("center"):B===1&&g.push("topleft")),g?.includes("center")){const w=Math.floor(Math.sqrt(B)),S=Math.floor((i.x-w)/2),D=Math.floor((i.y-w)/2);for(let x=D;x<D+w;x++)for(let F=S;F<S+w;F++)c.push(x*i.x+F+1)}g?.includes("topleft")&&c.push(1);const l=new Set(c);let C=0;for(let w=0;w<i.y;w++)for(let S=0;S<i.x;S++){const D=(S-(i.x-1)/2)*n,x=(w-(i.y-1)/2)*n;let F=S,k=w;switch(A.origin){case"bl":F=S,k=i.y-1-w;break;case"br":F=i.x-1-S,k=i.y-1-w;break;case"tr":F=i.x-1-S,k=w;break}let v=k*i.x+F+1;if(l.has(v)){C++;continue}v-=C;const _=[v,`${iVA[k]}${F+1}`];I.push(A.circularpads?tVA(_,{x:D,y:x,radius:a/2}):Qi(_,D,x,a,a))}const Q=Li(0,i.y*n/2,.2),E=n/6;let h;const u=i.x*n/2,d=i.y*n/2;switch(A.origin){case"bl":h=[{x:-u,y:-d},{x:-u,y:-d-E},{x:-u-E,y:-d},{x:-u,y:-d}];break;case"br":h=[{x:u,y:-d},{x:u,y:-d-E},{x:u+E,y:-d},{x:u,y:-d}];break;case"tr":h=[{x:u,y:d},{x:u,y:d+E},{x:u+E,y:d},{x:u,y:d}];break;default:h=[{x:-u,y:d},{x:-u,y:d+E},{x:-u-E,y:d},{x:-u,y:d}];break}const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:h,stroke_width:.05};return{circuitJson:[...I,Q,f],parameters:A}},Q5=(t,A,e,i,n)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:n,radius:n/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),Fw=t=>Hi.extend({fn:Y(),num_pins:VA().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:Be().optional().default(t.legsoutside??!1),pillpads:Be().optional().default(t.pillpads??!1),silkscreen_stroke_width:VA().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)),cCt=Fw({}),blA=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:A,pn:e,w:i,p:n,pl:o,legsoutside:s}=t,r=A/2,a=e<=r,g=r-1,I=n,c=I*g,B=s?o/2:-o/2;return a?{x:-i/2-B,y:c/2-(e-1)*I}:{x:i/2+B,y:-c/2+(e-r-1)*I}},BCt=t=>{const A=cCt.parse(t);return{circuitJson:Sx(A),parameters:A}},Sx=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=blA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push(Q5(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,n=(t.num_pins/2-1)*t.p+t.pw+e,o=Li(0,n/2+.4,n/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:t.silkscreen_stroke_width??.1,route:[{x:-i/2,y:-n/2},{x:-i/2,y:n/2},...$ZA.map(({x:r,y:a})=>({x:r*i/6,y:a*i/6+n/2})),{x:i/2,y:n/2},{x:i/2,y:-n/2},{x:-i/2,y:-n/2}]};return[...A,s,o]},oVA=lt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),lCt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const n=[],o=t/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=o:r.bottomside&&r.leftpin?s=o+1:r.bottomside&&r.rightpin?s=o*2:r.rightside&&r.bottompin?s=o*2+1:r.rightside&&r.toppin?s=o*3:r.topside&&r.rightpin?s=o*3+1:r.topside&&r.leftpin&&(s=o*4),n.push(-1);for(let a=0;a<t;a++)n[s]=a+1,e||!A?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return n},xlA=Hi.extend({fn:Y(),cc:Be().default(!0).optional(),ccw:Be().default(!0).optional(),startingpin:Y().or(be(oVA)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(be(oVA)).optional(),num_pins:VA().optional().default(64),w:$A.optional(),h:$A.optional(),p:$A.default($A.parse("0.5mm")),pw:$A.optional(),pl:$A.optional(),thermalpad:Ai([FA(!0),nVA]).optional(),legsoutside:Be().default(!1)}),klA=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},sVA=xlA.transform(klA),CCt=["left","bottom","right","top"],QCt=t=>{const{pin_count:A,pn:e,w:i,h:n,p:o,pl:s,legsoutside:r}=t,a=A/4,g=CCt[Math.floor((e-1)/a)],I=(e-1)%a,c=o*(a-1),B=o*(a-1),l=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-l+.1,y:B/2-I*o,o:"vert"};case"bottom":return{x:-c/2+I*o,y:-n/2-l+.1,o:"horz"};case"right":return{x:i/2+l-.1,y:-B/2+I*o,o:"vert"};case"top":return{x:c/2-I*o,y:n/2+l-.1,o:"horz"};default:throw new Error("Invalid pin number")}},O_=t=>{const A=sVA.parse(t),e=[],i=lCt(A),n=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:I}=QCt({pin_count:A.num_pins,pn:r+1,w:A.w,h:A.h,p:A.p??.5,pl:A.pl,legsoutside:A.legsoutside});let c=A.pw,B=A.pl;I==="vert"&&([c,B]=[B,c]);const l=i[r+1];e.push(Qi(l,a,g,c,B))}if(A.thermalpad)if(typeof A.thermalpad=="boolean"){const r=A.p*(n-1)+A.pw,a=A.p*(n-1)+A.pw;e.push(Qi(["thermalpad"],0,0,r,a))}else e.push(Qi(["thermalpad"],0,0,A.thermalpad.x,A.thermalpad.y));const o=[];for(const[r,a,g]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const I=A.w/2*a,c=A.h/2*g;let B="none",l=I,C=c;const Q=A.pw*2;i[1]===1&&r==="top-left"?B="in1":i[n*4]===1&&r==="top-left"||i[n*3+1]===1&&r==="top-right"?B="in2":i[n*3]===1&&r==="top-right"||i[n]===1&&r==="bottom-left"?B="in1":i[n+1]===1&&r==="bottom-left"?B="in2":i[n*2]===1&&r==="bottom-right"?B="in1":i[n*2+1]===1&&r==="bottom-right"&&(B="in2");const E=B==="in1"?1:-1;if(A.legsoutside){const h=B==="in1"?A.pl/2:A.pw/2,u=B==="in1"?A.pw/2:A.pl/2;l+=h*a*E,C-=u*g*E}(B==="none"||A.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:I-Q*a,y:c},{x:I,y:c},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&!A.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:I-Q*a,y:c},{x:I-Q*a/2,y:c}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:I,y:c-Q*g/2},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:l-.2*-a,y:C+.2*E},{x:l,y:C},{x:l+.2*E*-a,y:C+.2},{x:l-.2*-a,y:C+.2*E}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Li(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...o,s],parameters:A}};xlA.extend({}).transform(klA);var ECt=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),O_(t)),hCt=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 O_(t)},uCt=t=>{t.legsoutside=!0;const A=sVA.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 O_(t)};xlA.extend({}).transform(klA);var dCt=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),O_(t)),pCt=Fw({w:"3.9mm",p:"1.27mm"}),fCt=t=>{const A=pCt.parse(t);return{circuitJson:Sx(A),parameters:A}},yCt=Fw({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),mCt=t=>{const A=yCt.parse(t);return{circuitJson:Sx(A),parameters:A}},wCt=Fw({}),DCt=t=>{const A=wCt.parse({fn:"sot363",num_pins:6,w:2.56,p:.65,pw:.4,pl:.65,legoutside:!0});return{circuitJson:Sx(A),parameters:A}},SCt=Hi.extend({fn:Y(),num_pins:FA(6).default(6),w:Y().default("1.01mm"),h:Y().default("1.45mm"),p:Y().default("0.5mm"),pl:Y().default("0.33mm"),pw:Y().default("0.27mm"),string:Y().optional()}),bCt=t=>{const A=SCt.parse({fn:"sot886",...t}),e=$A.parse(A.w),i=$A.parse(A.h),n=$A.parse(A.p),o=$A.parse(A.pl),s=$A.parse(A.pw),r=[];for(let l=0;l<6;l++){const{x:C,y:Q}=rVA(l+1,e,n,o);r.push(Qi(l+1,C,Q,o,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=rVA(1,e,n,o),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-o/2-.3,y:I.y},{x:I.x-o/2-.45,y:I.y+.15},{x:I.x-o/2-.45,y:I.y-.15},{x:I.x-o/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}},rVA=(t,A,e,i)=>{const n=A/2-i/2;return t<=3?{x:-n,y:e-(t-1)*e}:{x:n,y:-e+(t-4)*e}},aVA=Hi.extend({fn:Y(),num_pins:VA().default(3),w:Y().default("1.92mm"),h:Y().default("2.74mm"),pl:Y().default("1.32mm"),pw:Y().default("0.6mm"),p:Y().default("0.95mm"),string:Y().optional()}),xCt=Fw({p:"0.95mm",w:"1.6mm",legsoutside:!0}),kCt=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const n=xCt.parse({...t,num_pins:e});return{circuitJson:Sx(n),parameters:n}}const i=aVA.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:FCt(i),parameters:i};if(i.num_pins===5)return{circuitJson:IVA(i),parameters:i};throw new Error("Invalid number of pins")},GCt=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}},FCt=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:n,y:o}=GCt({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,n,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Li(0,Number.parseInt(t.h),.3);return[...A,e]},gVA=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")},IVA=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:l}=gVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(Qi(c,B,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Li(0,i+.3,.3),r=gVA({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,n,o,I]},RCt=aVA.extend({}),NCt=t=>{const A=RCt.parse({...t,num_pins:5});return{circuitJson:IVA(A),parameters:A}},_Ct=[{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}],MCt=Fw({}),vCt=t=>{const A=MCt.parse(t),e=[];for(let c=0;c<A.num_pins;c++){const{x:B,y:l}=blA({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,l,A.pl??"1mm",A.pw??"0.6mm"))}const i=Math.min(1,A.p/2),n=A.w+i,o=(A.num_pins/2-1)*A.p+A.pw+i,s=[];for(const c of _Ct){const{dx:B,dy:l}=c;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:B*n/2-B*A.p,y:l*o/2},{x:B*n/2,y:l*o/2},{x:B*n/2,y:l*o/2-l*A.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const r=A.p/4,a=-n/2-r/2,g=o/2-A.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:a,y:g},{x:a-r,y:g+r},{x:a-r,y:g-r},{x:a,y:g}],stroke_width:.1});const I=Li(0,o/2+.4,o/12);return{circuitJson:[...e,I,...s],parameters:A}},GlA=({fs:t,pn:A,anchor_x:e,anchor_y:i,textalign:n="center",orthogonal:o=!1,verticallyinverted:s=!1,layer:r="top"})=>{let a=0;o&&s?a=270:s?a=180:o?a=90:a=0;let g="center";return n==="left"&&(s?g="center_right":g="center_left"),n==="right"&&(s?g="center_left":g="center_right"),r==="bottom"&&(g==="center_left"?g="center_right":g==="center_right"&&(g="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:`{PIN${A}}`,layer:r,anchor_position:{x:e,y:i},anchor_alignment:g,ccw_rotation:a}};function UCt({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 LCt=Hi.extend({fn:Y(),num_pins:VA().optional().default(6),rows:Ai([Y(),VA()]).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:Be().optional().describe("for male pin headers"),female:Be().optional().describe("for female pin headers"),smd:Be().optional().describe("surface mount device"),surfacemount:Be().optional().describe("surface mount device (verbose)"),rightangle:Be().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:Be().optional().default(!1),pinlabeltextaligncenter:Be().optional().default(!1),pinlabeltextalignright:Be().optional().default(!1),pinlabelverticallyinverted:Be().optional().default(!1),pinlabelorthogonal:Be().optional().default(!1),nosquareplating:Be().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Be().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Be().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Be().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=UCt(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"]})}),HCt=t=>{const A=LCt.parse(t),{p:e,id:i,od:n,rows:o,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:I,pinlabeltextalignright:c,nopinlabels:B,doublesidedpinlabel:l,bottomsidepinlabel:C}=A;let Q="center";I?Q="left":c&&(Q="right");const E=[],h=Math.ceil(s/o),u=-e,d=({xoff:x,yoff:F,od:k,anchorSide:v,smd:_,pw:L,pl:K})=>{let J=0,W=0;if(_){const Z=k/5;switch(v){case"right":J=L/2+Z;break;case"top":W=K/2+Z;break;case"bottom":W=-(K/2+Z);break;case"left":J=-(L/2+Z);break}}else{const Z=k*.75;switch(v){case"right":J=Z;break;case"top":W=Z;break;case"bottom":W=-Z;break;case"left":J=-Z;break}}return{anchor_x:x+J,anchor_y:F+W}},f=(x,F,k)=>{A.smd?E.push(Qi(x,F,k,A.pw,A.pl)):x===1&&!A.nosquareplating?E.push(BS(x,F,k,i,n,n,0,0)):E.push(Oo(x,F,k,i,n));const{anchor_x:v,anchor_y:_}=d({xoff:F,yoff:k,od:n,anchorSide:r,smd:A.smd,pw:A.pw,pl:A.pl});B||(C?E.push(GlA({fs:n/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):E.push(GlA({fs:n/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),l&&E.push(GlA({fs:n/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},w=new Set,S=o>2&&h>2;if(o===1){const x=-((s-1)/2)*e;for(let F=0;F<s;F++){const k=F+1,v=x+F*e,_=`${v},0`;if(w.has(_))throw new Error(`Overlap at ${_}`);w.add(_),f(k,v,0)}}else if(S){const x=-((h-1)/2)*e;let F=1;for(let k=0;k<o&&F<=s;k++)for(let v=0;v<h&&F<=s;v++){const _=x+v*e,L=k*u,K=`${_},${L}`;if(w.has(K))throw new Error(`Overlap at ${K}`);w.add(K),f(F++,_,L)}}else{const x=-((h-1)/2)*e;let F=1,k=0,v=o-1,_=0,L=h-1;for(;F<=s&&k<=v&&_<=L;){for(let K=k;K<=v&&F<=s;K++){const J=x+_*e,W=K*u,Z=`${J},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,J,W)}_++;for(let K=_;K<=L&&F<=s;K++){const J=x+K*e,W=v*u,Z=`${J},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,J,W)}if(v--,_<=L){for(let K=v;K>=k&&F<=s;K--){const J=x+L*e,W=K*u,Z=`${J},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,J,W)}L--}if(k<=v){for(let K=L;K>=_&&F<=s;K--){const J=x+K*e,W=k*u,Z=`${J},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,J,W)}k++}}if(F-1<s)throw new Error(`Missing pins: assigned ${F-1}, expected ${s}`)}const D=Li(0,e,.5);return{circuitJson:[...E,D],parameters:A}},YCt=Hi.extend({fn:Y(),num_pins:FA(6).default(6),w:Y().default("2.1mm"),h:Y().default("2.45mm"),p:Y().default("0.5mm"),pl:Y().default("0.675mm"),pw:Y().default("0.35mm"),string:Y().optional()}),JCt=t=>{const A=YCt.parse({...t,fn:"sot563"}),e=$A.parse(A.w),i=$A.parse(A.h),n=$A.parse(A.p),o=$A.parse(A.pl),s=$A.parse(A.pw),r=[];for(let l=0;l<6;l++){const{x:C,y:Q}=cVA(l+1,e,n,o);r.push(Qi(l+1,C,Q,o,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=cVA(1,e,n,o),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-o/2-.3,y:I.y},{x:I.x-o/2-.45,y:I.y+.15},{x:I.x-o/2-.45,y:I.y-.15},{x:I.x-o/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}},cVA=(t,A,e,i)=>{const n=A/2-i/2;return t<=3?{x:-n,y:e-(t-1)*e}:{x:n,y:-e+(t-4)*e}},TCt=Fw({p:"1.27mm",w:"3.9mm",legsoutside:!0}),KCt=t=>{const A=TCt.parse({...t,num_pins:8});return{circuitJson:Sx(A),parameters:A}},qCt=Fw({p:"1.27mm",w:"7.5mm",legsoutside:!0}),PCt=t=>{const A=qCt.parse({...t,num_pins:16});return{circuitJson:Sx(A),parameters:A}},OCt=Hi.extend({fn:Y(),num_pins:FA(3).default(3),w:Y().default("1.2mm"),h:Y().default("1.2mm"),pw:Y().default("0.40mm"),pl:Y().default("0.45mm"),p:Y().default("0.575mm")}),WCt=t=>{const A=OCt.parse(t),e=VCt(A),i=Li(0,$A.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},ZCt=t=>{const{pn:A,p:e}=t;return A===1?{x:e,y:0}:A===2?{x:-e,y:-.4}:{x:-e,y:.4}},VCt=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:n}=ZCt({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,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},jCt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("2.36mm"),h:Y().default("1.22mm"),pl:Y().default("0.9mm"),pw:Y().default("1.2mm"),p:Y().default("3.30mm")}),zCt=t=>{const A=jCt.parse(t),e=Li(0,$A.parse(A.h)/4+.4,.3);return{circuitJson:$Ct(A).concat(e),parameters:A}},XCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},$Ct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=XCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},AQt=Hi.extend({fn:Y(),p:$A.optional().default("2.54mm"),id:$A.optional().default("0.7mm"),od:$A.optional().default("1.4mm")}),eQt=t=>{const A=AQt.parse(t),{p:e,id:i,od:n}=A,o=[Oo(1,-e/2,0,i,n),Oo(2,e/2,0,i,n)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2+n+i/2,y:0},{x:e/2-n-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},r=Li(0,1.5,.5);return{circuitJson:[...o,s,r],parameters:A}},tQt=(t,A,e,i,n,o=.1)=>{const s=[],r=[],a=Math.max(1,Math.ceil(Math.PI*e/o)),g=Math.PI/a;for(let I=0;I<=a;I++){const c=I*g,B=t+Math.cos(c)*e,l=A+Math.sin(c)*e;B<t-i&&l>=A-n/2&&l<=A+n/2||s.push({x:B,y:l})}for(let I=0;I<=a;I++){const c=Math.PI+I*g,B=t+Math.cos(c)*e,l=A+Math.sin(c)*e;B<t-i&&l>=A-n/2&&l<=A+n/2||r.push({x:B,y:l})}return{topArc:s,bottomArc:r}},iQt=Hi.extend({fn:Y(),p:$A.optional().default("5mm"),id:$A.optional().default("0.8mm"),od:$A.optional().default("1.6mm"),ceramic:Be().optional(),electrolytic:Be().optional(),polarized:Be().optional()}),nQt=t=>{const A=iQt.parse(t),{p:e,id:i,od:n}=A;i===.8&&n===1.6&&(A.id=e===5?.8:e*.25,A.od=e===5?1.6:e*.5);const o=[Oo(1,-e/2,0,A.id,A.od),Oo(2,e/2,0,A.id,A.od)],s=e+.1,{topArc:r,bottomArc:a}=tQt(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:""},l=.1*e,C=-(e+l+.04*e),Q=s-l-.08*e,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C-l,y:Q},{x:C+l,y:Q}],stroke_width:g,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C,y:Q-l},{x:C,y:Q+l}],stroke_width:g,pcb_silkscreen_path_id:""},u=Li(0,s+.12*e,.1*e),d=[...o,I,c,B,u];return(A.electrolytic===!0||A.polarized===!0)&&d.push(E,h),{circuitJson:d,parameters:A}},E5=(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}),oQt=Hi.extend({fn:FA("pushbutton"),w:$A.default(4.5),h:$A.default(6.5),id:$A.default(1),od:$A.default(1.2)}),sQt=t=>{const A=oQt.parse(t),e=A.w,i=A.h,n=A.id,o=[Oo(1,-e/2,i/2,n,n*1.5),Oo(2,-e/2,-i/2,n,n*1.5),Oo(3,e/2,-i/2,n,n*1.5),Oo(4,e/2,i/2,n,n*1.5)],s=[E5([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),E5([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),E5([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),E5([{x:e/2,y:0},{x:e/5,y:0}])],r=Li(0,i/2+.4,.5);return{circuitJson:[...o,...s,r],parameters:A}},BVA=Hi.extend({fn:Y(),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:Be().default(!1),innerholeedgedistance:$A.default($A.parse("1.61mm")),silkscreenlabels:Be().default(!1),silkscreenlabelmargin:$A.default($A.parse("0.1mm"))}),rQt=t=>{const A=BVA.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},h5=(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},aQt=t=>{const A=BVA.parse(t),e=A.h??rQt(A),i=[],n=[],o=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),c=`pin${g}`.length*.7/2;if(A.right){const Q=-((A.right-1)/2)*A.p;for(let E=0;E<A.right;E++){if(E===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=h5(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}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl-(c+A.silkscreenlabelmargin),y:Q+E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(Oo(E+1+A.left+(A.bottom??0)+g,A.w/2,Q+E*A.p,r,a)),n.push(Oo(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=h5(-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}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl+(c+A.silkscreenlabelmargin),y:Q-E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(Oo(E+1+g,-A.w/2,Q-E*A.p,r,a)),n.push(Oo(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=h5(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}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q-E*A.p,y:e/2-A.pl-(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(n.push(Oo(E+1+A.left+A.right+(A.bottom??0)+g,Q-E*A.p,e/2,r,a)),n.push(Oo(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=h5(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}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q+E*A.p,y:-e/2+A.pl+(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(n.push(Oo(E+1+A.left+g,Q+E*A.p,-e/2,r,a)),n.push(Oo(E+1+A.left+g*2,Q+E*A.p,-e/2+A.innerholeedgedistance,r,a)))}}const B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2,y:e/2},{x:A.w/2,y:e/2},{x:A.w/2,y:-e/2},{x:-A.w/2,y:-e/2},{x:-A.w/2,y:e/2}],stroke_width:.1,layer:"top"},C=Li(0,e/1.8,e/25);return{circuitJson:[...i,...n,...o,l,...A.silkscreenlabels?[]:[B],C],parameters:A}},lVA=Hi.extend({fn:Y(),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:Be().default(!1),innerholeedgedistance:$A.default($A.parse("1.61mm"))}),gQt=t=>{const A=lVA.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},IQt=(t,A,e,i=1,n=.6)=>{const o=i/2,s=n/2;return{left:[{x:t+o,y:A},{x:t-o,y:A+s},{x:t-o,y:A-s},{x:t+o,y:A}],right:[{x:t-o,y:A},{x:t+o,y:A+s},{x:t+o,y:A-s},{x:t-o,y:A}],top:[{x:t,y:A-o},{x:t-s,y:A+o},{x:t+s,y:A+o},{x:t,y:A-o}],bottom:[{x:t,y:A+o},{x:t-s,y:A-o},{x:t+s,y:A-o},{x:t,y:A+o}]}[e]},cQt=t=>{const A=lVA.parse(t),e=A.h??gQt(A),i=[],n=[],o=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],I=1;if(A.left){const C=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++)Q===0&&(g=IQt(-A.w/2-A.pl/2,C-Q*A.p,"left")),i.push(Qi(I,-A.w/2+A.pl/2,C-Q*A.p,A.pl,A.pw)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:C-Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Oo(I+a,-A.w/2+A.innerholeedgedistance,C-Q*A.p,s,r))}if(A.bottom){const C=(A.bottom-1)/2*A.p;for(let Q=A.bottom-1;Q>=0;Q--)i.push(Qi(I,C-Q*A.p,-e/2+A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C-Q*A.p,y:-e/2+A.pl/2-3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Oo(I+a,C-Q*A.p,-e/2+A.innerholeedgedistance,s,r))}if(A.right){const C=-((A.right-1)/2)*A.p;for(let Q=0;Q<A.right;Q++)i.push(Qi(I,A.w/2-A.pl/2,C+Q*A.p,A.pl,A.pw)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:C+Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Oo(I+a,A.w/2-A.innerholeedgedistance,C+Q*A.p,s,r))}if(A.top){const C=-((A.top-1)/2)*A.p;for(let Q=A.top-1;Q>=0;Q--)i.push(Qi(I,C+Q*A.p,e/2-A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C+Q*A.p,y:e/2-A.pl/2+3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Oo(I+a,C+Q*A.p,e/2-A.innerholeedgedistance,s,r))}const c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:g,stroke_width:.1},B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:e/2+A.pl/3}],stroke_width:.1,layer:"top"},l=Li(0,e/1.8,e/25);return{circuitJson:[...o,...i,...n,B,c,l],parameters:A}},BQt=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),O_(t)),CVA=Hi.extend({fn:Y(),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"))}),lQt=t=>{const A=CVA.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},u5=(t,A,e,i=1,n=.6)=>{const o=i/2,s=n/2;return{left:[{x:t+o,y:A},{x:t-o,y:A+s},{x:t-o,y:A-s},{x:t+o,y:A}],right:[{x:t-o,y:A},{x:t+o,y:A+s},{x:t+o,y:A-s},{x:t-o,y:A}],top:[{x:t,y:A-o},{x:t-s,y:A+o},{x:t+s,y:A+o},{x:t,y:A-o}],bottom:[{x:t,y:A+o},{x:t-s,y:A-o},{x:t+s,y:A-o},{x:t,y:A+o}]}[e]},CQt=t=>{const A=CVA.parse(t),e=A.h??lQt(A),i=[],n=A.id,o=A.od;let s=[];if(A.right){const I=-((A.right-1)/2)*A.p;for(let c=0;c<A.right;c++)c===0&&!A.left&&!A.bottom&&(s=u5(A.w/2+o*1.4,I+c*A.p,"right")),i.push(Oo(c+1+A.left+(A.bottom??0),A.w/2,I+c*A.p,n,o))}if(A.left){const I=-((A.left-1)/2)*A.p;for(let c=0;c<A.left;c++)c===A.left-1&&(s=u5(-A.w/2-o*1.4,I+c*A.p,"left")),i.push(Oo(c+1,-A.w/2,I+c*A.p,n,o))}if(A.top){const I=-((A.top-1)/2)*A.p;for(let c=0;c<A.top;c++)c===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=u5(I+c*A.p,e/2+o*1.4,"top")),i.push(Oo(c+1+A.right+(A.bottom??0)+A.left,I+c*A.p,e/2,n,o))}if(A.bottom){const I=-((A.bottom-1)/2)*A.p;for(let c=0;c<A.bottom;c++)c===0&&!A.left&&(s=u5(I+c*A.p,-e/2-o*1.4,"bottom")),i.push(Oo(c+1+A.left,I+c*A.p,-e/2,n,o))}const r={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-o,y:e/2+o},{x:A.w/2+o,y:e/2+o},{x:A.w/2+o,y:-e/2-o},{x:-A.w/2-o,y:-e/2-o},{x:-A.w/2-o,y:e/2+o}],stroke_width:.1,layer:"top"},g=Li(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},QVA=(t,A,e,i)=>Array.from({length:25},(n,o)=>{const s=o/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*e,y:A+Math.sin(s)*e}}),QQt=Hi.extend({fn:Y(),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")}),EQt=t=>{const A=QQt.parse(t),{p:e,id:i,od:n,w:o,h:s}=A,r=s/2,a=[Oo(1,-e/2,0,i,n),Oo(2,e/2,0,i,n)],g=QVA(-o/2,0,r,"left"),I=QVA(o/2,0,r,"right"),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...g,...g.slice(1).reverse(),{x:-o/2,y:-s/2},{x:o/2,y:-s/2},...I,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},B=Li(0,e/4,.5);return{circuitJson:[...a,c,B],parameters:A}};Hi.extend({w:$A,h:$A});var hQt=t=>{const{w:A,h:e}=t,i=mr(A),n=mr(e);return{circuitJson:[Qi(1,0,0,i,n),Li(0,n/2+.5,.2)],parameters:t}},AL=(t,A,e,i,n,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:A,y:e,outer_width:mr(n),outer_height:mr(o),hole_width:mr(i),hole_height:mr(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),uQt=Hi.extend({fn:Y(),num_pins:Ai([FA(3),FA(2)]).default(3),p:Y().default("1.27mm"),id:Y().default("0.72mm"),od:Y().default("0.95mm"),w:Y().default("4.5mm"),h:Y().default("4.5mm"),inline:Be().default(!1),string:Y().optional()}),dQt=(t,A,e)=>Array.from({length:25},(i,n)=>{const o=n/24*Math.PI;return{x:t+Math.cos(o)*e,y:A+Math.sin(o)*e}}),pQt=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=uQt.parse({...t,num_pins:e}),{p:n,id:o,od:s,w:r,h:a,inline:g}=i,I=Number.parseFloat(a)/2,c=Number.parseFloat(n),B=Number.parseFloat(o),l=Number.parseFloat(s),C=l,Q=l*(1.5/1.05);let E=[];if(i.num_pins===3)g?E=[BS(1,-c,I-c,B,l,Q,0,0),AL(2,0,I-c,B,C,Q),AL(3,c,I-c,B,C,Q)]:E=[BS(1,-c,I-c,B,l,l,0,0),Oo(2,0,I,B,l),Oo(3,c,I-c,B,l)];else if(i.num_pins===2)E=[BS(1,-c,I-c,B,C,Q,0,0),AL(2,c,I-c,B,C,Q)];else throw new Error("Invalid number of pins for TO-92");const h=Number.parseFloat(r)/2,u=dQt(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}},fQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("2.15mm"),h:Y().default("1.20mm"),pl:Y().default("0.5mm"),pw:Y().default("0.6mm"),p:Y().default("1.4mm")}),yQt=t=>{const A=fQt.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:wQt(A).concat(i,e),parameters:A}},mQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},wQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=mQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},DQt=Fw({}),SQt=t=>{const A=DQt.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=blA({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,n=Li(0,i/2-.5,i/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-A.w/3,y:i/2+.2},{x:A.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...e,n,o],parameters:A}},bQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("5.0mm"),h:Y().default("2.30mm"),pl:Y().default("1.25mm"),pw:Y().default("2mm"),p:Y().default("3.75mm")}),xQt=t=>{const A=bQt.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:GQt(A).concat(i,e),parameters:A}},kQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},GQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=kQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},FQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),p:Y().default("2.9mm")}),RQt=t=>{const A=FQt.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:_Qt(A).concat(i,e),parameters:A}},NQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},_Qt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=NQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},MQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("3.30mm"),h:Y().default("1.80mm"),pl:Y().default("0.60mm"),pw:Y().default("0.45mm"),p:Y().default("2.1mm")}),vQt=t=>{const A=MQt.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:LQt(A).concat(i,e),parameters:A}},UQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},LQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=UQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},HQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("1.4mm"),h:Y().default("0.9mm"),pl:Y().default("0.36mm"),pw:Y().default("0.25mm"),p:Y().default("0.85mm")}),YQt=t=>{const A=HQt.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:TQt(A).concat(i,e),parameters:A}},JQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},TQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=JQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},KQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("1.3mm"),h:Y().default("0.9mm"),pl:Y().default("0.4mm"),pw:Y().default("0.7mm"),p:Y().default("0.7mm")}),qQt=t=>{const A=KQt.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:OQt(A).concat(i,e),parameters:A}},PQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},OQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=PQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},WQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("3,05mm"),h:Y().default("1.65mm"),pl:Y().default("0.6mm"),pw:Y().default("0.6mm"),pad_spacing:Y().default("2.2mm")}),ZQt=t=>{const A=WQt.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:jQt(A).concat(i,e),parameters:A}},VQt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},jQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=VQt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},zQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),p:Y().default("2.9mm")}),XQt=t=>{const A=zQt.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:AEt(A).concat(i,e),parameters:A}},$Qt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},AEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=$Qt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},eEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("0.91mm"),pw:Y().default("1.22mm"),p:Y().default("3.146mm")}),tEt=t=>{const A=eEt.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:nEt(A).concat(i,e),parameters:A}},iEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},nEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=iEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},oEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("1.80mm"),h:Y().default("1.00mm"),pl:Y().default("0.66mm"),pw:Y().default("0.5mm"),p:Y().default("0.8mm")}),sEt=t=>{const A=oEt.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:aEt(A).concat(i,e),parameters:A}},rEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},aEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=rEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},gEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("6.2mm"),h:Y().default("3.4mm"),pl:Y().default("1.4mm"),pw:Y().default("2.1mm"),p:Y().default("4.4mm")}),IEt=t=>{const A=gEt.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:BEt(A).concat(i,e),parameters:A}},cEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},BEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=cEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},lEt=Hi.extend({fn:Y(),num_pins:Ai([FA(3),FA(5)]).default(3),w:Y().default("4.20mm"),h:Y().default("4.80mm"),pl:Y().default("1.3mm"),pw:Y().default("0.9mm"),p:Y().default("1.5mm"),string:Y().optional()}),CEt=t=>{const A=[],e=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),n=Number.parseFloat(t.w),o=Number.parseFloat(t.pl),s=.175,r=(o-(o+s))/2;A.push(Qi(1,-n/2+r,e,o,i),Qi(2,-n/2,0,o+s,i),Qi(3,-n/2+r,-e,o,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]},QEt=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,n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i,y:n}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n},{x:i,y:-n}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},EEt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=lEt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:CEt(i),parameters:i};if(i.num_pins===5)return{circuitJson:QEt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},hEt=Hi.extend({fn:Y(),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:VA().optional(),string:Y().optional()}),uEt=t=>{const A=hEt.parse(t),{fn:e,id:i,od:n,w:o,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,I=o/2,c=s/2,B=2.5,l=o*.4,C=Math.max(B,l/(a-1)),Q=Array.from({length:a},(w,S)=>{const D=a%2===0?(S-a/2+.5)*C:(S-Math.floor(a/2))*C;return Oo(S+1,D,g,i,n)}),E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:-c},{x:I,y:-c},{x:I,y:c},{x:-I,y:c},{x:-I,y:-c}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-c+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:h},{x:I,y:h}],stroke_width:.1,pcb_silkscreen_path_id:""},d=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:h},{x:-o/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:h},{x:o/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Li(0,s/2+.6,.5);return{circuitJson:[...Q,E,u,...d,f],parameters:{...A,p:C}}},dEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("5.40mm"),h:Y().default("2.30mm"),pl:Y().default("1.30mm"),pw:Y().default("1.70mm"),p:Y().default("3.5mm")}),pEt=t=>{const A=dEt.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:yEt(A).concat(i,e),parameters:A}},fEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},yEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=fEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},mEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("1.90mm"),h:Y().default("1.33mm"),pl:Y().default("0.5mm"),pw:Y().default("0.7mm"),p:Y().default("0.8mm")}),wEt=t=>{const A=mEt.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:SEt(A).concat(i,e),parameters:A}},DEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},SEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=DEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},bEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("7.0mm"),h:Y().default("3.35mm"),pl:Y().default("1.50mm"),pw:Y().default("2.70mm"),p:Y().default("4.8mm")}),xEt=t=>{const A=bEt.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:GEt(A).concat(i,e),parameters:A}},kEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},GEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=kEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},FEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("3.0mm"),h:Y().default("1.80mm"),pl:Y().default("0.80mm"),pw:Y().default("1.20mm"),p:Y().default("1.6mm")}),REt=t=>{const A=FEt.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:_Et(A).concat(i,e),parameters:A}},NEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},_Et=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=NEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},MEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("7.10mm"),h:Y().default("3.40mm"),pl:Y().default("2.45mm"),pw:Y().default("1.80mm"),p:Y().default("4.05mm")}),vEt=t=>{const A=MEt.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:LEt(A).concat(i,e),parameters:A}},UEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},LEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=UEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},HEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("4.80mm"),h:Y().default("2.10mm"),pl:Y().default("1.30mm"),pw:Y().default("1.40mm"),p:Y().default("2.9mm")}),YEt=t=>{const A=HEt.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:TEt(A).concat(i,e),parameters:A}},JEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},TEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=JEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},KEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("7.30mm"),h:Y().default("4.40mm"),pl:Y().default("2.50mm"),pw:Y().default("2.30mm"),p:Y().default("4.30mm")}),qEt=t=>{const A=KEt.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:OEt(A).concat(i,e),parameters:A}},PEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},OEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=PEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},WEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("10.70mm"),h:Y().default("6.60mm"),pl:Y().default("3.30mm"),pw:Y().default("2.50mm"),p:Y().default("6.80mm")}),ZEt=t=>{const A=WEt.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:jEt(A).concat(i,e),parameters:A}},VEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},jEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=VEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},zEt=Hi.extend({fn:Y(),num_pins:VA().default(4),w:Y().default("8.50mm"),h:Y().default("6.90mm"),pl:Y().default("2mm"),pw:Y().default("1.5mm"),p:Y().default("2.30mm"),string:Y().optional()}),XEt=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const n=eht.parse({...t,num_pins:e});return{circuitJson:Sx(n),parameters:n}}const i=zEt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:Aht(i),parameters:i};if(i.num_pins===5)return{circuitJson:iht(i),parameters:i};if(i.num_pins===6)return{circuitJson:oht(i),parameters:i};throw new Error("Invalid number of pins")},$Et=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}},Aht=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=$Et({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,n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i,y:n},{x:i,y:n/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n},{x:i,y:-n},{x:i,y:-n/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},eht=Fw({p:"0.90mm",w:"2.8mm",legsoutside:!0}),tht=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")},iht=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=tht({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,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Li(0,0,.3);return[...A,n,o,s]},nht=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")},oht=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=nht({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,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Li(0,0,.3);return[...A,n,o,s]},sht=Hi.extend({fn:Y(),num_pins:VA().default(3),w:Y().default("3.40mm"),h:Y().default("3.30mm"),pl:Y().default("1mm"),pw:Y().default("0.7mm"),p:Y().default("1.2mm"),string:Y().optional()}),rht=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=sht.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:ght(i),parameters:i};throw new Error("Invalid number of pins")},aht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},ght=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=aht({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,n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i+.3,y:n},{x:i+.3,y:n/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n},{x:i+.3,y:-n},{x:i+.3,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},Iht=Hi.extend({fn:Y(),num_pins:Ai([FA(3),FA(2)]).default(3),p:Y().default("1.27mm"),id:Y().default("0.72mm"),od:Y().default("0.95mm"),w:Y().default("2.5mm"),h:Y().default("4.2mm"),string:Y().optional()}),cht=t=>{const{p:A,id:e,od:i,w:n,h:o}=t,s=Number.parseFloat(o)/2,r=Number.parseFloat(A);return[Oo(1,-r,s-r,e,i),Oo(2,0,s-r,e,i),Oo(3,r,s-r,e,i)]},Bht=t=>{const{p:A,id:e,od:i,h:n}=t,o=Number.parseFloat(n)/2,s=Number.parseFloat(A);return[Oo(1,-s,o-s,e,i),Oo(2,s,o-s,e,i)]},lht=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=Iht.parse({...t,num_pins:e});let n=[];if(i.num_pins===3)n=cht(i);else if(i.num_pins===2)n=Bht(i);else throw new Error("Invalid number of pins for TO-92");const o=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o,y:o-s},{x:-1.9,y:0},{x:1.9,y:0},{x:o,y:o-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-o,y:o-s}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Li(0,o+1,.5);return{circuitJson:[...n,r,a],parameters:i}},Cht=Hi.extend({fn:Y(),p:$A.optional(),id:$A.optional(),pw:$A.optional(),pl:$A.optional(),w:$A.optional(),h:$A.optional(),sh:Ai([Be(),Y(),VA()]).optional().transform(t=>{if(typeof t=="string"){const A=Number(t);return Number.isNaN(A)?!0:A}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Be().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:Y().optional()}),Qht={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 Eht(t){return t.sh?"sh":(t.ph,"ph")}function hht(t,A,e,i,n,o){const s=[];if(t==="ph"){const r=e/2;s.push(BS(1,-r,2,i,n,o)),s.push(BS(2,r,2,i,n,o))}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const I=r+g*e;console.log("x si",I),s.push(Qi(g+1,I,-1.325,n,o))}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 uht(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 dht=t=>{const A=Cht.parse(t),e=Eht(A),i=Qht[e],n=A.p??i.p,o=A.id??i.id,s=A.pw??i.pw,r=A.pl??i.pl,a=A.w??i.w,g=A.h??i.h;let I=e==="sh"?4:2;if(e==="sh"){const Q=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(Q&&Q[1]){const E=parseInt(Q[1],10);Number.isNaN(E)||(I=E)}else typeof A.sh=="number"&&(I=A.sh)}const c=hht(e,I,n,o,s,r),B=uht(e),l=Li(0,g/2+1,.5);return{circuitJson:[...c,B,l],parameters:{...A,p:n,id:o,pw:s,pl:r,w:a,h:g,num_pins:I,sh:e==="sh",ph:e==="ph"}}},pht=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("3.30mm"),h:Y().default("1.70mm"),pl:Y().default("0.80mm"),pw:Y().default("1mm"),p:Y().default("1.90mm")}),fht=t=>{const A=pht.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:mht(A).concat(i,e),parameters:A}},yht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},mht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=yht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},wht=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"}}},Dht=Hi.extend({fn:Y(),num_pins:Ai([FA(8),FA(10)]).default(8),w:Y().optional(),h:Y().optional(),p:Y().optional(),pl:Y().optional(),pw:Y().optional(),string:Y().optional()}),Sht=t=>{const A=Dht.parse(t),e=wht(A.num_pins),i=$A.parse(A.w||e.w),n=$A.parse(A.h||e.h),o=$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}=EVA(A.num_pins,u+1,i,o),w=u<g?u+1:A.num_pins-(u-g);a.push(Qi(w,d,f,s,r))}const I=i,c=n,B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:c/2},{x:I/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:-c/2},{x:I/2,y:-c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=EVA(A.num_pins,1,I,o),Q={x:C.x-.8,y:C.y},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:Q.x-.4,y:Q.y},{x:Q.x-.7,y:Q.y+.3},{x:Q.x-.7,y:Q.y-.3},{x:Q.x-.4,y:Q.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Li(0,c/2+.5,.3);return{circuitJson:[...a,B,l,h,E],parameters:A}},EVA=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*$A.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},bht=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"}}},xht=Hi.extend({fn:Y(),num_pins:Ai([FA(8),FA(10),FA(12),FA(16)]).default(8),w:Y().optional(),h:Y().optional(),p:Y().optional(),pl:Y().optional(),pw:Y().optional(),string:Y().optional()}),hVA=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*$A.parse("2mm"),y:r*i}},kht=t=>{const A=xht.parse(t),e=bht(A.num_pins),i=$A.parse(A.w||e.w),n=$A.parse(A.h||e.h),o=$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}=hVA(A.num_pins,h+1,i,o);a.push(Qi(h+1,u,d,s,r))}const g=i,I=n,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:I/2},{x:g/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-I/2},{x:g/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=hVA(A.num_pins,1,g,o),C={x:l.x-.8,y:l.y},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:C.x-.4,y:C.y},{x:C.x-.7,y:C.y+.3},{x:C.x-.7,y:C.y-.3},{x:C.x-.4,y:C.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},E=Li(0,I/2+.5,.3);return{circuitJson:[...a,c,B,E,Q],parameters:A}},Ght=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("3.8mm"),h:Y().default("1.65mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),pad_spacing:Y().default("2.6mm")}),Fht=t=>{const A=Ght.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:Nht(A).concat(i,e),parameters:A}},Rht=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Nht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Rht({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},_ht=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("3.20mm"),h:Y().default("1.65mm"),pl:Y().default("0.8mm"),pw:Y().default("0.9mm"),pad_spacing:Y().default("2.1mm")}),Mht=t=>{const A=_ht.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:Uht(A).concat(i,e),parameters:A}},vht=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Uht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=vht({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Lht=Hi.extend({fn:Y(),num_pins:Ai([FA(6),FA(8)]).default(8),w:Y().default("3mm"),h:Y().default("3mm"),p:Y().default("0.5mm"),pl:Y().default("0.52mm"),pw:Y().default("0.35mm"),epw:Y().default("1.40mm"),eph:Y().default("1.60mm"),string:Y().optional(),ep:Be().default(!1)}),Hht=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=Lht.parse({...t,num_pins:e}),n=$A.parse(i.w),o=$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:w,y:S}=uVA(i.num_pins,f+1,n,s);c.push(Qi(f+1,w,S,r,a))}i.ep&&c.push(Qi(i.num_pins+1,0,0,g,I));const B=n,l=o,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:l/2},{x:B/2,y:l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:-l/2},{x:B/2,y:-l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},E=uVA(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,l/2+.5,.3);return{circuitJson:[...c,C,Q,d,u],parameters:i}},uVA=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*$A.parse("1.4mm"),y:r*i}},Yht=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:n=1.5,ph:o=1.5}=t,s=$A.parse(i),r=$A.parse(n),a=$A.parse(o),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 w=0;w<f.length-1;w++){const S=f[w],D=f[w+1];if(typeof S=="number"&&typeof D=="number"&&!isNaN(S)&&!isNaN(D)){const x=(S-1)*s,F=(D-1)*s,k=Math.sign(F-x),v=x+k*(r/2),_=F-k*(r/2);c.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${S}}`,x:v,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${D}}`,x:_,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const B=(A-1)*s+r+.7,l=a+1,C=(A-1)*s/2,Q=0,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:C-B/2,y:Q-l/2},{x:C+B/2,y:Q-l/2},{x:C+B/2,y:Q+l/2},{x:C-B/2,y:Q+l/2},{x:C-B/2,y:Q-l/2}],stroke_width:.15},u=Q+l/2+.6,d=Li(C,u,.4);return{circuitJson:[...I,...c,E,d],parameters:t}},dVA={fn:FA("sot457"),num_pins:FA(6).default(6),pillh:Y().default("0.45mm"),pillw:Y().default("1.45mm"),pl:Y(),pw:Y(),p:Y(),wave:Be().optional(),reflow:Be().optional()},Jht=Hi.extend({...dVA,h:Y().default("2.5mm"),w:Y().default("2.7mm"),pl:Y().default("0.8mm"),pw:Y().default("0.55mm"),p:Y().default("0.95mm")}),Tht=Hi.extend({...dVA,h:Y().default("3mm"),w:Y().default("4mm"),pillr:Y().default("0.225mm"),pl:Y().default("1.45mm"),pw:Y().default("1.5mm"),p:Y().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)})),lS=t=>Number.parseFloat(t.replace("mm","")),pVA=({pitch:t,width:A,pinNumber:e})=>{const o={1:{x:-A/2-.1,y:t},2:{x:-A/2-.1,y:0},3:{x:-A/2-.1,y:-t},4:{x:A/2+.1,y:-t},5:{x:A/2+.1,y:0},6:{x:A/2+.1,y:t}}[e];if(!o)throw new Error(`Invalid pin number: ${e}`);return o},fVA=t=>{const A=[],e=lS(t.p),i=lS(t.pl),n=lS(t.pw),o=lS(t.w),s=lS(t.h);if(t.wave){const C={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})=>Q5(3,-e,0,lS(t.pillw),lS(t.pillh)),4:({padWidth:Q,padHeight:E})=>Q5(4,e,0,lS(t.pillw),lS(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=C[Q];E&&A.push(E({padWidth:i,padHeight:n}))}}else for(let C=1;C<=t.num_pins;C++){const{x:Q,y:E}=pVA({pitch:e,width:o,pinNumber:C});A.push(Qi(C,Q,E,i,n))}const r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/3,y:s/2+e/1.3},{x:o/3,y:s/2+e/1.3}],stroke_width:.05},a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o/3,y:-s/2-e/1.3},{x:o/3,y:-s/2-e/1.3}],stroke_width:.05},g=Li(0,s+.5,.3),I=pVA({pitch:e,width:o,pinNumber:1}),c=t.wave?1:.5,B=t.wave?.7:.3;I.x-=t.wave?n:n*1.7;const l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:I.x+c/2,y:I.y},{x:I.x-c/2,y:I.y+B/2},{x:I.x-c/2,y:I.y-B/2},{x:I.x+c/2,y:I.y}],stroke_width:.05};return[g,r,a,l,...A]},Kht=t=>{if(t.wave){const e=Tht.parse({...t,fn:"sot457"});return{circuitJson:fVA(e),parameters:e}}const A=Jht.parse(t);return{circuitJson:fVA(A),parameters:A}},qht=Hi.extend({fn:Y(),num_pins:FA(6).default(6),w:Y().default("1.1mm"),h:Y().default("1.45mm"),p:Y().default("0.35mm"),pl:Y().default("0.2mm"),pw:Y().default("0.2mm"),string:Y().optional()}),Pht=t=>{const A=qht.parse({...t,fn:"sot963"}),e=$A.parse(A.w),i=$A.parse(A.h),n=$A.parse(A.p),o=$A.parse(A.pl),s=$A.parse(A.pw),r=[];for(let l=0;l<6;l++){const{x:C,y:Q}=yVA(l+1,e,n,o);r.push(Qi(l+1,C,Q,o,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=yVA(1,e,n,o),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-o/2-.3,y:I.y},{x:I.x-o/2-.45,y:I.y+.15},{x:I.x-o/2-.45,y:I.y-.15},{x:I.x-o/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}},yVA=(t,A,e,i)=>{const n=A/2-i/2;return t<=3?{x:-n,y:e-(t-1)*e}:{x:n,y:-e+(t-4)*e}},Oht=Hi.extend({fn:Y(),num_pins:Ai([FA(3),FA(2)]).default(3),p:Y().default("3.8mm"),id:Y().default("1.25mm"),od:Y().default("2.35mm"),ca:Y().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:Y().default("5.35mm"),h:Y().default("4mm"),string:Y().optional()}),Wht=t=>{const{p:A,id:e,od:i,h:n,ca:o}=t,s=Number.parseFloat(n),r=Number.parseFloat(o);return[Oo(1,0,r/4+.3,e,i),Oo(2,s,0,e,i),Oo(3,0,-r/4-.3,e,i)]},Zht=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=Oht.parse({...t,num_pins:e});let n=[];i.num_pins===3&&(n=Wht(i));const o=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),r=Number.parseFloat(i.od)/2+.35,a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o-1.75},{x:0,y:o},{x:s,y:o},{x:s,y:r}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-r},{x:s,y:-o},{x:0,y:-o},{x:0,y:-o+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},I=Number.parseFloat(i.w)/2,c=Li(I,o+1,.5);return{circuitJson:[...n,a,g,c],parameters:i}},Vht=Hi.extend({fn:Y(),p:$A.optional().default("7.5mm"),id:$A.optional().default("1mm"),od:$A.optional().default("2mm"),d:$A.optional().default("10.5mm")}),jht=(t,A,e,i,n)=>{const o=[],s=[];for(let r=0;r<=50;r++){const a=r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-n/2&&I<=A+n/2||o.push({x:g,y:I})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-n/2&&I<=A+n/2||s.push({x:g,y:I})}return{topArc:o,bottomArc:s}},zht=t=>{const A=Vht.parse(t),{p:e,id:i,od:n,d:o}=A,s=[Oo(1,-e/2,0,i,n),Oo(2,e/2,0,i,n)],{topArc:r,bottomArc:a}=jht(0,0,o/2+.1,n/2,n),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:.1,pcb_silkscreen_path_id:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},B=-(o/2+.5),l=n/2+1.5,C=.5,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B-C,y:l},{x:B+C,y:l}],stroke_width:.1,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B,y:l-C},{x:B,y:l+C}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Li(0,o/2+1,.5);return{circuitJson:[...s,g,I,c,Q,E,h],parameters:A}},Xht=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("6.5mm"),h:Y().default("3mm"),pl:Y().default("1.75mm"),pw:Y().default("2.40mm"),p:Y().default("4.75mm")}),$ht=t=>{const A=Xht.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:eut(A).concat(i,e),parameters:A}},Aut=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eut=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Aut({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tut=Hi.extend({fn:Y(),num_pins:VA().default(3),w:Y().default("2.45mm"),h:Y().default("2.40mm"),pl:Y().default("1.225mm"),pw:Y().default("0.5mm"),p:Y().default("0.95mm"),string:Y().optional()}),iut=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=tut.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:out(i),parameters:i};throw new Error("Invalid number of pins")},nut=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},out=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=nut({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),n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n+.3},{x:i,y:n+.3},{x:i,y:n/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n-.3},{x:i,y:-n-.3},{x:i,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},sut=Hi.extend({fn:Y(),circle:Be().optional(),rect:Be().optional(),square:Be().optional(),pill:Be().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:Y().optional()}).transform(t=>{let A="rect";t.circle&&(A="circle"),t.square&&(A="square"),t.rect&&(A="rect"),t.pill&&(A="pill");let e,i,n;return A==="circle"?t.r!==void 0?e=mr(t.r):t.pr!==void 0?e=mr(t.pr):t.radius!==void 0?e=mr(t.radius):t.d!==void 0?e=mr(t.d)/2:t.pd!==void 0?e=mr(t.pd)/2:t.diameter!==void 0?e=mr(t.diameter)/2:e=mr("1mm")/2:(t.w!==void 0?i=mr(t.w):t.pw!==void 0?i=mr(t.pw):t.width!==void 0?i=mr(t.width):t.s!==void 0?i=mr(t.s):t.size!==void 0?i=mr(t.size):i=mr("1mm"),t.h!==void 0?n=mr(t.h):t.ph!==void 0?n=mr(t.ph):t.height!==void 0?n=mr(t.height):A==="square"||A==="rect"?n=i:n=mr("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:n}}),rut=t=>{const A=sut.parse(t),{shape:e,radius:i,width:n,height:o}=A;let s,r;return e==="circle"?(s=tVA(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=Q5(1,0,0,n,o),r=Math.max(n,o)/2+.5):(s=Qi(1,0,0,n,o),r=o/2+.5),{circuitJson:[s,Li(0,r,.2)],parameters:A}},aut=Hi.extend({fn:Y(),d:$A.optional(),hd:$A.optional(),r:$A.optional(),hr:$A.optional(),pd:$A.optional(),pr:$A.optional(),squarepad:Be().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=mr(t.d):t.hd!==void 0?A=mr(t.hd):t.r!==void 0?A=mr(t.r)*2:t.hr!==void 0?A=mr(t.hr)*2:A=mr("1mm");let e;return t.pd!==void 0?e=mr(t.pd):t.pr!==void 0?e=mr(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),gut=t=>{const A=aut.parse(t),{d:e,pd:i,squarepad:n}=A;return{circuitJson:[n?BS(1,0,0,e,i,i):Oo(1,0,0,e,i),Li(0,i/2+.5,.2)],parameters:A}},Iut=Hi.extend({fn:Y(),num_pins:FA(6).default(6),h:Y().default("1.6mm"),pl:Y().default("1mm"),pw:Y().default("0.7mm"),p:Y().default("0.95mm")}),cut=t=>{const A=Iut.parse(t);return{circuitJson:But(A),parameters:A}},mVA=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")},But=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:l}=mVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(Qi(c,B,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Li(0,i+.3,.3),r=mVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,n,o,I]},lut=Hi.extend({fn:Y(),num_pins:VA().default(4),w:Y().default("3.2mm"),h:Y().default("2.6mm"),pl:Y().default("1.35mm"),pw:Y().default("0.50mm"),p:Y().default("0.6mm"),string:Y().optional()}),Cut=t=>{const A=t.string?.match(/^sot343_(\d+)/),e=A?Number.parseInt(A[1],4):4,i=lut.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:Eut(i),parameters:i};throw new Error("Invalid number of pins")},Qut=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}},Eut=t=>{const A=[],e=Number.parseFloat(t.w),i=Number.parseFloat(t.h),n=Number.parseFloat(t.pl),o=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let r=1/0,a=-1/0,g=1/0,I=-1/0;for(let d=0;d<t.num_pins;d++){const{x:f,y:w}=Qut({num_pins:t.num_pins,pn:d+1,p:s});A.push(Qi(d+1,f,w,n,o)),f<r&&(r=f),f>a&&(a=f),w<g&&(g=w),w>I&&(I=w)}const c=(r+a)/2,B=I-g,l=i*.3,C=B/2+l;let Q=e*.8;i<=2.6&&(Q/=2);const E=Li(c,C+.5,.3),h={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:c-Q/2,y:C},{x:c+Q/2,y:C}],type:"pcb_silkscreen_path",stroke_width:.1},u={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_bottom",route:[{x:c-Q/2,y:-C},{x:c+Q/2,y:-C}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,h,u,E]},hut=Hi.extend({fn:Y()}),uut=t=>{const A=hut.parse(t),e=[],i=.5-.15,n=1.5,s=.5/2,r=75,a=-37/2;for(let D=0;D<r;D++){const x=D+1;if(x>=24&&x<=31)continue;const F=a-D*s,k=x%2===0,v=n+(k?.25:0),L=.5-v/2,K=Qi(x,L,F,v,i);K.layer=k?"bottom":"top",e.push(K)}const g=46*.0254,I=137*.0254,c=261*.0254,B={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-I/2+n/2,y:a-c},width:I,height:g},l={x:-.5,y:a},C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-.4,y:l.y},{x:l.x-.7,y:l.y+.3},{x:l.x-.7,y:l.y-.3},{x:l.x-.4,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let Q=1/0,E=-1/0,h=1/0,u=-1/0;const d=(D,x,F=0,k=0)=>{Q=Math.min(Q,D-F/2),E=Math.max(E,D+F/2),h=Math.min(h,x-k/2),u=Math.max(u,x+k/2)};for(const D of e)d(D.x,D.y,D.width,D.height);d(B.center.x,B.center.y,B.width,B.height);for(const D of C.route)d(D.x,D.y);const f=(Q+E)/2,w=(h+u)/2,S=D=>{typeof D.x=="number"&&(D.x-=f),typeof D.y=="number"&&(D.y-=w),D.center&&(D.center.x-=f,D.center.y-=w),Array.isArray(D.route)&&(D.route=D.route.map(x=>({x:x.x-f,y:x.y-w})))};for(const D of e)S(D);return S(B),S(C),{circuitJson:[...e,B,C],parameters:A}},dut=Hi.extend({fn:Y(),num_pins:VA().default(3),inline:Be().default(!1),p:Y().default("1.27mm"),id:Y().default("0.75mm"),od:Y().default("1.3mm"),w:Y().default("4.8mm"),h:Y().default("4.0mm")}),put=t=>{const A=dut.parse(t),e=Number.parseFloat(A.p),i=Number.parseFloat(A.w),n=Number.parseFloat(A.h),o=A.inline?1.05:Number.parseFloat(A.od),s=A.inline?1.5:o,r=[BS(1,0,0,A.id,o,s,0,0),A.inline?AL(2,e,0,A.id,o,s):Oo(2,e,e,A.id,o),A.inline?AL(3,e*2,0,A.id,o,s):Oo(3,e*2,0,A.id,o)],a=i/2,g=A.inline?e-.09:e,I=.2,c=I+a-n,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)}}),l={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]]},C=Li(g,I+a+1,.5);return{circuitJson:[...r,l,C],parameters:A}};function fut(t){return t!=null}var yut=(t,A)=>{if(!A)return t;const e=t.filter(I=>I.type==="pcb_smtpad"||I.type==="pcb_plated_hole"||I.type==="pcb_thtpad");if(e.length===0)return t;let i=1/0,n=-1/0,o=1/0,s=-1/0;const r=(I,c,B=0,l=0)=>{const C=I-B/2,Q=I+B/2,E=c-l/2,h=c+l/2;i=Math.min(i,C),n=Math.max(n,Q),o=Math.min(o,E),s=Math.max(s,h)};for(const I of e)if(I.type==="pcb_smtpad"){const c=I.shape==="circle"?I.radius*2:I.width,B=I.shape==="circle"?I.radius*2:I.height;r(I.x,I.y,c,B)}else if(I.type==="pcb_plated_hole"){const c=I.outer_diameter??I.hole_diameter;r(I.x,I.y,c,c)}else if(I.type==="pcb_thtpad"){const c=I.diameter;r(I.x,I.y,c,c)}let a=0,g=0;switch(A){case"center":a=(i+n)/2,g=(o+s)/2;break;case"bottomleft":a=i,g=o;break;case"bottomcenter":case"centerbottom":a=(i+n)/2,g=o;break;case"topcenter":case"centertop":a=(i+n)/2,g=s;break;case"leftcenter":case"centerleft":a=i,g=(o+s)/2;break;case"rightcenter":case"centerright":a=n,g=(o+s)/2;break;case"pin1":const I=e.find(c=>c.port_hints?.[0]==="1")||e[0];a=I.x,g=I.y;break}if(a===0&&g===0)return t;for(const I of t){if(typeof I.x=="number"&&(I.x-=a),typeof I.y=="number"&&(I.y-=g),I.center&&typeof I.center.x=="number"&&(I.center.x-=a,I.center.y-=g),I.type==="pcb_silkscreen_path")for(const c of I.route)c.x-=a,c.y-=g;I.type==="pcb_silkscreen_text"&&I.anchor_position&&(I.anchor_position.x-=a,I.anchor_position.y-=g)}return t},mut=(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},wut=(t,A)=>A.nosilkscreen?t.filter(e=>e.type!=="pcb_silkscreen_path"&&e.type!=="pcb_silkscreen_text"):t,Dut=t=>{let A=d5();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(n=>{const o=n.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,r]=o;if(!s)return null;const a=s.toLowerCase();return r?.includes("?")?null:{fn:a,v:r}}).filter(fut);for(const{fn:n,v:o}of i)A=A[n](o);return A.setString(t),A},Sut=()=>Object.keys(cS),d5=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&cS[A.fn])return()=>{const{circuitJson:i}=cS[A.fn](A),n=wut(i,A),o=mut(n,A);return yut(o,A.origin)};if(!cS[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(!cS[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>cS[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(cS):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in cS?(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};d5.string=Dut,d5.getFootprintNames=Sut;var but=d5,wVA=Symbol("Fragment");function FlA(t,A,...e){const i=e.length?e:A?.children!==void 0?[A.children]:[],n=[],o=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of o)s==null||s===!1||(Array.isArray(s)?n.push(...s):n.push(s));return{type:t,props:(A&&A.children!==void 0?{...A,children:void 0}:A)||{},children:n}}var ht=Symbol("Cuboid"),DVA=Symbol("Cube"),Zp=Symbol("Cylinder"),SVA=Symbol("Sphere"),eL=Symbol("RoundedCuboid"),Vi=Symbol("Translate"),EQ=Symbol("Rotate"),gE=Symbol("Union"),$G=Symbol("Subtract"),aI=Symbol("Hull"),ms=Symbol("Colorize"),tL=Symbol("Polygon"),iL=Symbol("ExtrudeLinear"),Vp=Symbol("RoundedCylinder"),Tn=wVA,Ae=(t,A,e)=>FlA(t,A),Ot=(t,A,e)=>FlA(t,A),zB=({center:t,width:A,length:e,height:i,heightAboveSurface:n=.15,color:o="#555",taperRatio:s=.12,faceRatio:r=.75,straightHeightRatio:a=.5,includeNotch:g=!0,notchRadius:I,notchPosition:c,notchRotation:B=[0,0,0],notchLength:l=.5,notchWidth:C=.25,chamferSize:Q=0})=>{const E=i*a,h=i-E,u=Math.min(A,e)*s,d=Math.max(A-u,A*r),f=Math.max(e-u,e*r),w=Math.min(A,e)*.12,S=I??w,D={x:0,y:e/2-S*.25,z:i},x=c??D,F=Ot(gE,{children:[Ot(aI,{children:[Ae(Vi,{z:.005,children:Ae(ht,{size:[d,f,.01]})}),Ae(Vi,{z:E,children:Ae(ht,{size:[A,e,.01]})})]}),Ot(aI,{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=(_,L)=>Ae(Vi,{offset:{x:_,y:L,z:0},children:Ae(EQ,{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,L=e/2;v=Ot($G,{children:[F,k(_,L),k(-_,L),k(_,-L),k(-_,-L)]})}return Ae(ms,{color:o,children:Ae(Vi,{offset:t,children:Ae(Vi,{offset:{x:0,y:0,z:n},children:g?Ot($G,{children:[v,Ae(Vi,{offset:x,children:Ae(EQ,{rotation:B,children:Ae(Zp,{radius:S,height:C})})})]}):v})})})},xut=t=>Array.from({length:t},(A,e)=>e);function RlA(t,A){if(t.length<2)throw new Error("Stroke must have at least two points");const e=Array.isArray(t[0])?t.map(([I,c])=>({x:I,y:c})):t,i=A/2,n=[],o=[];function s(I,c){const B=c.x-I.x,l=c.y-I.y,C=Math.sqrt(B*B+l*l);return{x:-l/C,y:B/C}}function r(I,c,B){const l={x:I.x+c.x*i*B,y:I.y+c.y*i*B};B>0?n.push(l):o.unshift(l)}const a=s(e[0],e[1]);r(e[0],a,1),r(e[0],a,-1);for(let I=1;I<e.length-1;I++){const c=e[I-1],B=e[I],l=e[I+1],C=s(c,B),Q=s(B,l),E=C.x+Q.x,h=C.y+Q.y,u=Math.sqrt(E*E+h*h);if(u/2>2*i)r(B,C,1),r(B,Q,1),r(B,C,-1),r(B,Q,-1);else{const f=1/u;r(B,{x:E*f,y:h*f},1),r(B,{x:E*f,y:h*f},-1)}}const g=s(e[e.length-2],e[e.length-1]);return r(e[e.length-1],g,1),r(e[e.length-1],g,-1),[...n,...o]}var kut=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}))},Gut=kut([{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}]),bVA=5.47,p5=.5,Fut=({x:t,y:A,z:e})=>{const i=t>0;return Ot(Tn,{children:[Ae(Vi,{offset:{x:t+.25/2,y:A,z:e},children:Ae(EQ,{rotation:["-90deg",0,"90deg"],children:Ae(iL,{height:.25,children:Ae(tL,{points:Gut.slice().reverse().map(n=>[n.x,n.y])})})})}),Ae(Vi,{offset:{x:t,y:A+(i?1:-1),z:e},children:Ae(EQ,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:Ae(iL,{height:2,children:Ae(tL,{points:RlA([[0,0],[-1,0],[-1,-1]],.25).map(n=>[n.x,n.y])})})})})]})},Rut=({numPins:t=8,pitch:A=2.54,bodyWidth:e=6.4,rowSpacing:i})=>{const n=Math.floor(t/2),o=i??(e>=7?e:e+1.22),s=e>=7?o-1.22:e;return Ot(Tn,{children:[xut(t).map(r=>{const a=r%n,g=(Math.floor(r/n)-.5)*2;return Ae(Fut,{x:g*o/2,y:a*A-(n-1)/2*A,z:bVA/2+p5})}),Ae(zB,{width:s,length:n*A+.5,height:bVA-p5,heightAboveSurface:p5,center:{x:0,y:0,z:p5}})]})};function Nut(t,{height:A,padContactLength:e,curveLength:i,bodyDistance:n,steepness:o=10}){i||(i=n*.3);let s=n-e-i;s<0&&(i+=s,s=0);const r=e*.75,a=e+i+(n-e-i)*.25;if(t<=r)return 0;if(t>=a)return A;const g=(t-r)/(a-r);return A/(1+Math.exp(-o*(g-.5)))}var Pn=t=>{const{thickness:A,width:e,padContactLength:i,bodyDistance:n,height:o,rotation:s}=t,r=15,a=Array.from({length:r}).map((I,c)=>c/(r-1)*n).map(I=>[I,Nut(I,t)]),g=RlA(a,A);return Ae(ms,{color:"#fff",children:Ae(Vi,{offset:{z:0,y:0,x:0,...t.position},children:Ae(EQ,{rotation:["90deg",0,s??0],children:Ae(Vi,{offset:{x:0,y:0,z:-e/2},children:Ae(iL,{height:e,children:Ae(tL,{points:g.map(I=>[I.x,I.y])})})})})})})},_ut=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:n})=>{const o=Math.ceil(t/2),s=i*t/2+e/2,r=(o-1)*i/2,a=.25;return Ot(Tn,{children:[Array.from({length:o}).map((g,I)=>Ae(Pn,{position:{x:-n/2-A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:o}).map((g,I)=>Ae(Pn,{rotation:Math.PI,position:{x:n/2+A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Ae(zB,{center:{x:0,y:0,z:a/2},width:n-e-1,length:s,height:1.5})]})},Mut=({pinCount:t,padContactLength:A=.4,leadWidth:e=.2,pitch:i=.65,bodyWidth:n=3})=>{const o=Math.ceil(t/2),s=(o-1)*i/2,r=.2;return Ot(Tn,{children:[Array.from({length:o}).map((a,g)=>Ae(Pn,{position:{x:-n/2-A-.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Array.from({length:o}).map((a,g)=>Ae(Pn,{rotation:Math.PI,position:{x:n/2+A+.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Ae(zB,{center:{x:0,y:0,z:r/2},width:n,length:n,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},NlA=1,_lA=.5,W_=.5,nL=.2,vut=NlA-nL*2,xVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[vut,_lA,W_],offset:[0,0,W_/2],color:t}),Ae(ht,{size:[nL,W_,_lA],offset:[NlA/2-nL/2,0,W_/2],color:"#ccc"}),Ae(ht,{size:[nL,W_,_lA],offset:[-NlA/2+nL/2,0,W_/2],color:"#ccc"})]}),MlA=1.6,Uut=MlA-.3*2,f5=.3,vlA=.85,Z_=.6,kVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[Uut,vlA,Z_],offset:[0,0,Z_/2],color:t}),Ae(ht,{size:[f5,vlA,Z_],offset:[MlA/2-f5/2,0,Z_/2],color:"#ccc"}),Ae(ht,{size:[f5,vlA,Z_],offset:[-MlA/2+f5/2,0,Z_/2],color:"#ccc"})]}),UlA=2,LlA=1.25,V_=.55,oL=.5,Lut=UlA-oL*2,GVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[Lut,LlA,V_],offset:[0,0,V_/2],color:t}),Ae(ht,{size:[oL,LlA,V_],offset:[UlA/2-oL/2,0,V_/2],color:"#ccc"}),Ae(ht,{size:[oL,LlA,V_],offset:[-UlA/2+oL/2,0,V_/2],color:"#ccc"})]}),Hut=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:n})=>{const o=t/4;A||(A=Yut(t,n)),i||(i=Jut(t)),e||(e=Tut(t,n)),n||(n=A*(o+4));const s=n,r=(o-1)*A/2,a=s+2*i,g=a,I=.8,c=.15,B=(g-n)/2+.5;return Ot(Tn,{children:[Array.from({length:o}).map((l,C)=>Ae(Pn,{position:{x:-g/2-.4,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:Math.PI,position:{x:g/2+.4,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Ae(zB,{center:{x:0,y:0,z:0},width:n,length:s,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:n/2-1.5,z:1.5},notchRadius:1.5/2})]})},Yut=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},Jut=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}},Tut=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},Kut=({numberOfPins:t,pitch:A=2.54,longSidePinLength:e=6,invert:i,faceup:n,rows:o=1})=>{const a=Math.ceil(t/o),g=2.54,I=a*A,c=o>1?(o-1)*g+.63*3:.63*3,B=3,l=-((a-1)/2)*A,C=o>1?-((o-1)*g)/2:0,Q=E=>i||n?-E+2:E;return Ot(Tn,{children:[Ae(ht,{color:"#222",size:[I,c,2],center:[0,C,Q(2/2)]}),Array.from({length:t},(E,h)=>{const u=Math.floor(h/a),d=h%a,f=l+d*A,w=-u*g;return Ot(Tn,{children:[!n&&Ae(ms,{color:"gold",children:Ot(aI,{children:[Ae(ht,{color:"gold",size:[.63,.63,B*.9],center:[f,w,Q(2*.9+2/2)]}),Ae(ht,{color:"gold",size:[.63/1.8,.63/1.8,B],center:[f,w,Q(2+2/2)]})]})}),Ae(ms,{color:"gold",children:Ot(aI,{children:[Ae(ht,{color:"gold",size:[.63,.63,e*.9],center:[f,w,Q(-e/2*.9)]}),Ae(ht,{color:"gold",size:[.63/1.8,.63/1.8,e],center:[f,w,Q(-e/2)]})]})})]})})]})},qut=t=>{const A=["left","bottom","right","top"],{pin_count:e,pn:i,w:n,h:o,p:s,pl:r}=t,a=e/4,g=A[Math.floor((i-1)/a)],I=(i-1)%a,c=s*(a-1),B=s*(a-1),l=-r/2;switch(g){case"left":return{x:-n/2-l,y:B/2-I*s,o:"vert"};case"bottom":return{x:-c/2+I*s,y:-o/2-l,o:"horz"};case"right":return{x:n/2+l,y:-B/2+I*s,o:"vert"};case"top":return{x:c/2-I*s,y:o/2+l,o:"horz"};default:throw new Error("Invalid pin number")}},Put=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const n=[],o=t/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=o:r.bottomside&&r.leftpin?s=o+1:r.bottomside&&r.rightpin?s=o*2:r.rightside&&r.bottompin?s=o*2+1:r.rightside&&r.toppin?s=o*3:r.topside&&r.rightpin?s=o*3+1:r.topside&&r.leftpin&&(s=o*4),n.push(-1);for(let a=0;a<t;a++)n[s]=a+1,s++,s>t&&(s=1);return n},Out=({num_pins:t=16,bodyWidth:A=9,bodyLength:e=9,bodyThickness:i=.8,thermalPadSize:n,padWidth:o=.25,padLength:s=.25,pitch:r=.5,thermalPadThickness:a=.05})=>{const g=Put({num_pins:t,cw:!0,ccw:!0}),I=[];for(let c=0;c<t;c++){const{x:B,y:l,o:C}=qut({pin_count:t,pn:c+1,w:A,h:e,p:r,pl:s});let Q=o,E=s;C==="vert"&&([Q,E]=[E,Q]);const h=g[c+1];I.push({pn:h,x:B,y:l,pw:Q,pl:E})}return Ot(Tn,{children:[Ae(ms,{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]})),n?.length!==void 0&&n?.width!==void 0&&Ae(ht,{center:{x:0,y:0,z:a/2},size:[n.width,n.length,a]})]})},Wut=Out,Zut=()=>{const a=1.1999999999999997;return Ot(Tn,{children:[Ae(Pn,{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(Pn,{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(Pn,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),Ae(Pn,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),Ae(Pn,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),Ae(zB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},Vut=Zut,jut=({fullWidth:t=2.9,fullLength:A=2.8})=>{const I=(t-1.92)/2+.3;return Ot(Tn,{children:[Ae(Pn,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),Ae(Pn,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),Ae(Pn,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),Ae(zB,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},HlA=.6,YlA=.3,j_=.33,sL=.1,zut=HlA-sL*2,FVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[zut,YlA,j_],offset:[0,0,j_/2],color:t}),Ae(ht,{size:[sL,YlA,j_],offset:[HlA/2-sL/2,0,j_/2],color:"#ccc"}),Ae(ht,{size:[sL,YlA,j_],offset:[-HlA/2+sL/2,0,j_/2],color:"#ccc"})]}),JlA=.4,TlA=.2,z_=.13,rL=.07,Xut=JlA-rL*2,RVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[Xut,TlA,z_],offset:[0,0,z_/2],color:t}),Ae(ht,{size:[rL,TlA,z_],offset:[JlA/2-rL/2,0,z_/2],color:"#ccc"}),Ae(ht,{size:[rL,TlA,z_],offset:[-JlA/2+rL/2,0,z_/2],color:"#ccc"})]}),KlA=3.2,qlA=1.6,X_=.9,aL=.5,$ut=KlA-aL*2,NVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[$ut,qlA,X_],offset:[0,0,X_/2],color:t}),Ae(ht,{size:[aL,qlA,X_],offset:[KlA/2-aL/2,0,X_/2],color:"#ccc"}),Ae(ht,{size:[aL,qlA,X_],offset:[-KlA/2+aL/2,0,X_/2],color:"#ccc"})]}),PlA=3.2,OlA=2.5,$_=1,gL=.6,Adt=PlA-gL*2,_VA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[Adt,OlA,$_],offset:[0,0,$_/2],color:t}),Ae(ht,{size:[gL,OlA,$_],offset:[PlA/2-gL/2,0,$_/2],color:"#ccc"}),Ae(ht,{size:[gL,OlA,$_],offset:[-PlA/2+gL/2,0,$_/2],color:"#ccc"})]}),WlA=5,ZlA=2.5,AM=1.4,IL=.6,edt=WlA-IL*2,MVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[edt,ZlA,AM],offset:[0,0,AM/2],color:t}),Ae(ht,{size:[IL,ZlA,AM],offset:[WlA/2-IL/2,0,AM/2],color:"#ccc"}),Ae(ht,{size:[IL,ZlA,AM],offset:[-WlA/2+IL/2,0,AM/2],color:"#ccc"})]}),VlA=6.3,jlA=3.2,eM=1.8,cL=.8,tdt=VlA-cL*2,vVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[tdt,jlA,eM],offset:[0,0,eM/2],color:t}),Ae(ht,{size:[cL,jlA,eM],offset:[VlA/2-cL/2,0,eM/2],color:"#ccc"}),Ae(ht,{size:[cL,jlA,eM],offset:[-VlA/2+cL/2,0,eM/2],color:"#ccc"})]}),idt=({numberOfPins:t,pitch:A=2.54,legsLength:e=3,outerDiameter:i=.945,innerDiameter:n=.945,rows:o=1})=>{const s=n/1.5,r=s*2+i,a=5,g=Math.ceil(t/o),I=2.54,c=(g-1)*A+i+A/2,B=o>1?(o-1)*I+r:r,l=s*1.6,C=-((g-1)/2)*A,Q=o>1?-((o-1)*I)/2:0,E=Ae(ms,{color:"#1a1a1a",children:Ot($G,{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,w=C+f*A,S=-d*I;return n?Ae(Zp,{height:a+.1,radius:n/2,center:[w,S,a/2],color:"#222"},u):Ae(ht,{size:[l,l,a],center:[w,S,a/2]},u)})]})});return Ot(Tn,{children:[E,Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,w=C+f*A,S=-d*I;return Ot(ms,{color:"silver",children:[Ot(aI,{children:[Ae(ht,{color:"silver",size:[s,s,e*.9],center:[w,S,-e/2*.9]}),Ae(ht,{color:"silver",size:[s/1.8,s/1.8,e],center:[w,S,-e/2]})]}),Ae(ht,{color:"silver",size:[l,l,l*.5],center:[w,S,l/2*.5]})]},u)})]})},ndt=({width:t,length:A,innerDiameter:e=1})=>{const i=t,n=A,o=t*.7,s=e/2.5;return Ot(Tn,{children:[Ae(eL,{color:"#1a1a1f",center:[0,0,o/2],size:[n,n,o],roundRadius:.3}),Ae(eL,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[n,n,o*.1],roundRadius:.14}),Ae(Zp,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),Ae(Zp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,n/3,o+o*.1/2]}),Ae(Zp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,-n/3,o+o*.1/2]}),Ae(Zp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,n/3,o+o*.1/2]}),Ae(Zp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,-n/3,o+o*.1/2]}),Ae(y5,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:-n/2,z:-o*1.2}}),Ae(y5,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:n/2,z:-o*1.2},rotation:Math.PI}),Ae(y5,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:i/2,y:n/2,z:-o*1.2},rotation:Math.PI}),Ae(y5,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:i/2+e/3.6,y:-n/2,z:-o*1.2}})]})},y5=t=>{const{thickness:A,width:e,horizontalLength:i,verticalLength:n,rotation:o=0,position:s}=t,r=[[0,i],[-n/3,i/3],[-n/5,i/4],[0,0]],a=RlA(r,A);return Ae(ms,{color:"#f2f2f2",children:Ae(Vi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Ae(EQ,{rotation:[0,55,o],children:Ae(iL,{height:e,children:Ae(tL,{points:a.map(g=>[g.y,g.x])})})})})})},odt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:n})=>{const o=Math.ceil(t/2),s=(o-1)*i/2,r=.25,a=1,g=.8,I=A*0,c=i*(o-1)+e+.2,B=n*.55;return Ot(Tn,{children:[Array.from({length:o}).map((l,C)=>Ae(Pn,{position:{x:-n/2-I,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:Math.PI,position:{x:n/2+I,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Ae(zB,{center:{x:0,y:0,z:r/2},width:B,length:c,height:a})]})},sdt=({pinCount:t,pitch:A,leadWidth:e,leadLength:i,bodyWidth:n,bodyLength:o})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},r=isNaN(parseFloat(A))?s.pitch:parseFloat(A),a=isNaN(parseFloat(e))?s.leadWidth:parseFloat(e)*.8,g=isNaN(parseFloat(n))?2.6:parseFloat(n)*.8,I=isNaN(parseFloat(o))?2+Number(r)*1.4:parseFloat(o),c=t/2,B=(c-1)*r/2,l=.15,C=.8,Q=4.5,E=(Q-g)/2,h=E*.5;return Ot(Tn,{children:[Array.from({length:c}).map((u,d)=>Ae(Pn,{position:{x:-Q/2,y:B-d*r,z:l/2},width:a,thickness:l,padContactLength:h+.05,bodyDistance:E+.1,height:C})),Array.from({length:c}).map((u,d)=>Ae(Pn,{rotation:Math.PI,position:{x:Q/2,y:B-d*r,z:l/2},width:a,thickness:l,padContactLength:h+.05,bodyDistance:E+.1,height:C})),Ae(zB,{center:{x:0,y:0,z:l/2},width:g,length:I,height:1})]})},rdt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ae(Vi,{z:.3/2,children:Ae(ht,{size:[1.65,.8,.3]})}),Ot(aI,{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]})})]})]})})]}),adt=()=>Ot(Tn,{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(ms,{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]})]}),gdt=()=>{const g=Ae(ms,{color:"#1a1a1a",children:Ot(gE,{children:[Ot(aI,{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(aI,{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 C=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return Ae(ms,{color:"#c0c0c0",children:Ot(gE,{children:[Ae(ht,{size:[2.3*.8,1.45,.2],center:[C,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(Tn,{children:[Ae(I,{xDir:1}),Ae(I,{xDir:-1}),g]})},Idt=()=>{const g=Ae(ms,{color:"#1a1a1a",children:Ot(gE,{children:[Ot(aI,{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(aI,{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 C=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return Ae(ms,{color:"#c0c0c0",children:Ot(gE,{children:[Ae(ht,{size:[2.3*.8,1.45,.2],center:[C,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(Tn,{children:[Ae(I,{xDir:1}),Ae(I,{xDir:-1}),g]})},cdt=()=>{const g=Ae(ms,{color:"#1a1a1a",children:Ot(gE,{children:[Ot(aI,{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(aI,{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 C=c*3.08,Q=c*(6/2-.2/2+1),E=c*(6/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return Ae(ms,{color:"#c0c0c0",children:Ot(gE,{children:[Ae(ht,{size:[2.3*.8,2.95,.2],center:[C,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(Tn,{children:[Ae(I,{xDir:1}),Ae(I,{xDir:-1}),g]})},Bdt=()=>{const c=Ae(ms,{color:"#222",children:Ot(gE,{children:[Ae(Vi,{z:.27,children:Ae(ht,{size:[2.9,1.9,.54]})}),Ot(aI,{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(Tn,{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]})},ldt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ae(Vi,{z:.55/2,children:Ae(ht,{size:[2.7,1.6,.55]})}),Ot(aI,{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]})})]})]})})]}),Cdt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ae(Vi,{z:.2/2,children:Ae(ht,{size:[2.75,1.8,.2]})}),Ot(aI,{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]})]}),Qdt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ot(aI,{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(aI,{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]})]}),Edt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ot(aI,{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(aI,{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]})]}),hdt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ae(Vi,{z:.14/2,children:Ae(ht,{size:[.8,.6,.14]})}),Ot(aI,{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]})})]})]})})]}),udt=()=>{const I=3.0999999999999996;return Ot(Tn,{children:[Ae(Pn,{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(Pn,{position:{x:-6.6/2-I/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),Ae(Pn,{position:{x:-6.6/2-I/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),Ae(Pn,{position:{x:-6.6/2-I/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),Ae(zB,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},ddt=()=>Ot(Tn,{children:[Array.from({length:16}).map((l,C)=>Ae(Pn,{position:{x:-10.5/2,y:C*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((l,C)=>Ae(Pn,{rotation:Math.PI,position:{x:10.5/2,y:C*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((l,C)=>Ae(Pn,{rotation:Math.PI/2,position:{x:C*.5-3.75,y:-10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((l,C)=>Ae(Pn,{rotation:-Math.PI/2,position:{x:C*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Ae(zB,{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})]}),pdt=ddt,fdt=()=>{const g=.7999999999999998;return Ot(Tn,{children:[Ae(Pn,{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(Pn,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),Ae(Pn,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),Ae(zB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},ydt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:n})=>{const o=t/4;if(o!==Math.floor(o))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);A||(A=.5),i||(i=.6),e||(e=.22),n||(n=A*(o+4));const s=n,r=(o-1)*A/2,a=s+3.3*i,g=a,I=.8,c=.2,B=(g-n)/2+.4;return Ot(Tn,{children:[Array.from({length:o}).map((l,C)=>Ae(Pn,{position:{x:-g/2-.36,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:Math.PI,position:{x:g/2+.36,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Ae(zB,{center:{x:0,y:0,z:0},width:n,length:s,height:1.5,heightAboveSurface:.1,taperRatio:.04,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:s/2-1.5,z:1.5},notchRadius:1.5/2})]})},mdt=()=>{const i=.20900000000000002,n=.1,o=.3,s=.1,r=.2;return Ot(Tn,{children:[Ae(ms,{color:"#222",children:Ot(gE,{children:[Ae(ht,{size:[.85,1.2,i],center:[0,0,i/2]}),Ot(aI,{children:[Ae(Vi,{z:i,children:Ae(ht,{size:[.85,1.2,.01]})}),Ae(Vi,{z:.38,children:Ae(ht,{size:[.85-n,1.2-n,.01]})})]})]})}),Ae(ht,{color:"#ccc",size:[o,.25,s],center:[.55,0,s/2]}),Ae(ht,{color:"#ccc",size:[o,r,s],center:[-.55,.4,s/2]}),Ae(ht,{color:"#ccc",size:[o,r,s],center:[-.55,-.4,s/2]})]})},wdt=({num_pins:t,bodyWidth:A=5.3,bodyLength:e=5.3,bodyThickness:i=1,thermalPadSize:n,padWidth:o=e/5.3*.6,padLength:s=e/5.3*1,pitch:r=.5,thermalPadThickness:a=.2})=>{const g=[],I=Math.floor(t/2),c=r*(I-1);for(let B=0;B<t;B++){const l=B<I?"left":"right",C=B%I,Q=c/2-C*r,E=s,h=o,u=l==="left"?-A/2+E/2:A/2-E/2,d=B+1;g.push({pinNumber:d,x:u,y:Q,padSizeX:E,padSizeY:h})}return Ot(Tn,{children:[Ae(zB,{center:{x:0,y:0,z:0},width:A,length:e,height:i,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(A/2-s),y:e/2-s,z:i}}),g.map((B,l)=>Ae(ht,{center:[B.x,B.y,a/2],size:[B.padSizeX,B.padSizeY,a]})),n?.length!==void 0&&n?.width!==void 0&&Ae(ht,{center:[0,0,a/2],size:[n.width,n.length,a]})]})},Ddt=({bodyLength:t=10.2,bodyWidth:A=4.65,bodyHeight:e=13.46,leadSpacing:i=5,leadDiameter:n=.8,leadLength:o=12.7,color:s="#ddd",leadColor:r="#b87333"})=>{const a=t/2,g=A/2,I=a-g,c=i/2,B=.85;return Ot(Tn,{children:[Ot(ms,{color:s,children:[Ot(aI,{children:[Ae(Vp,{height:e,roundRadius:.5,radius:g,center:[-I,0,e]}),Ae(Vp,{height:e,roundRadius:.5,radius:g,center:[I,0,e]})]}),Ot(aI,{children:[Ae(Vp,{height:B,roundRadius:.1,radius:g+.85,center:[-I,0,e/2+B/2]}),Ae(Vp,{height:B,roundRadius:.1,radius:g+.85,center:[I,0,e/2+B/2]})]})]}),Ot(ms,{color:r,children:[Ae(Zp,{height:o+e/2,radius:n/2,center:[-c+.06,0,-(o/2)+e/2]}),Ae(Zp,{height:o+e/2,radius:n/2,center:[c-.06,0,-(o/2)+e/2]})]})]})},Sdt=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:n="#111"})=>Ot(Tn,{children:[Ae(ms,{color:e,children:Ot(EQ,{rotation:[0,"90deg",0],children:[Ae(eL,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),Ae(Zp,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),Ae(ms,{color:n,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(eL,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),Ae(ms,{color:i,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),Ae(ms,{color:i,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),bdt=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Tn,{children:[Ae(ms,{color:e,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),Ae(ms,{color:i,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),Ae(ms,{color:i,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),xdt=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Tn,{children:[Ae(ms,{color:e,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),Ae(ms,{color:i,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),Ae(ms,{color:i,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),kdt=({pinCount:t,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t%2!==0)throw new Error("MS012 pinCount must be even");const n=t/2,o=4.9,s=3.9,r=(n-1)*i/2,a=.2;return Ot(Tn,{children:[Array.from({length:n}).map((g,I)=>Ae(Pn,{position:{x:-s/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,I)=>Ae(Pn,{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(zB,{center:{x:0,y:0,z:a/2},width:s,length:o,height:1.55,notchPosition:{x:-.95,y:o/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},Gdt=({pinCount:t=16,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t!==16)throw new Error("MS013 only supports 16 pins");const n=t/2,o=7.5,s=10.3,r=(n-1)*i/2,a=.2;return Ot(Tn,{children:[Array.from({length:n}).map((g,I)=>Ae(Pn,{position:{x:-o/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,I)=>Ae(Pn,{rotation:Math.PI,position:{x:o/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Ae(zB,{center:{x:0,y:0,z:a/2},width:o,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},Fdt=()=>{const Q=7.050000000000001,E=24.95+6.5/2;return Ae(Vi,{center:[0,0,1],children:Ot(Tn,{children:[Ot(EQ,{rotation:[0,55,-55],children:[Ot($G,{children:[Ae(ht,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[E,0,1.3-2]}),Ae(Zp,{color:"black",center:[E,0,1.3-2],radius:3/2,height:1.3*1.2})]}),Ae(ms,{color:"#222",children:Ae(zB,{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(EQ,{rotation:[0,55,55],children:Array.from({length:3}).map((h,u)=>{const d=Q,f=(u-1)*2.7,w=-.5-.6;return Ot(ms,{color:"gold",children:[Ot(aI,{children:[Ae(Vi,{center:[15.05-4.5/2+.1,f,w],children:Ae(ht,{size:[4.5,.81+1,.5]})}),Ae(Vi,{center:[15.05-4.5/2-1+.1,f,w],children:Ae(ht,{size:[4.5,.81,.5]})})]}),Ae(Vi,{center:[d,f,w],children:Ae(ht,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},Rdt=()=>{const g=1.1999999999999997;return Ot(Tn,{children:[Ae(Pn,{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(Pn,{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(Pn,{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(Pn,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),Ae(Pn,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),Ae(Pn,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),Ae(zB,{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})]})},Ndt=()=>Ot(Tn,{children:[Ae(zB,{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]})})]}),_dt=()=>{const s="#222",a=[.43,.4,1.32],g=[.43,.4,.25],I=[0,0,-.66],c=[0,0,-1.32],B=[0,1.28,-2.72],l=[0,1.28,-8.9],C=-7.5;return Ot(Vi,{center:[0,1,10.5],children:[Ae(ms,{color:s,children:Ot($G,{children:[Ae(Vi,{center:[0,0,2.25],children:Ae(Zp,{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(aI,{children:[Ae(Vi,{center:c,children:Ae(ht,{size:g})}),Ae(Vi,{center:B,children:Ae(ht,{size:g})})]}),Ae(Vi,{center:l,children:Ae(ht,{size:[.43,.4,12.2]})}),Ae(Vi,{center:[1.3,0,C],children:Ae(ht,{size:[.43,.4,15]})}),Ae(Vi,{center:[-1.3,0,C],children:Ae(ht,{size:[.43,.4,15]})})]})},Mdt=()=>Ot(Tn,{children:[Ae(Pn,{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(Pn,{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(Pn,{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(Pn,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(Pn,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(Pn,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(zB,{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})]}),vdt=Mdt,Udt=()=>Ot(Tn,{children:[Ae(zB,{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]})})]}),Ldt=()=>Ot(Tn,{children:[Ae(Pn,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ae(Pn,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ae(ms,{color:"#222",children:Ae(zB,{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]})]}),Hdt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ae(Vi,{z:.175/2,children:Ae(ht,{size:[1.7,1.25,.175]})}),Ot(aI,{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]})]}),Ydt=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return Ot(Tn,{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(ms,{color:"#222",children:Ae(zB,{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]})]})},Jdt=({footprint:t})=>{const A=but.string(t).json();switch(A.fn){case"dip":return Ae(Rut,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"tssop":return Ae(_ut,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return Ae(Mut,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return Ae(sdt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return Ae(Hut,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return Ae(pdt,{});case"lqfp":return Ae(ydt,{pinCount:A.num_pins});case"qfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return Ae(Wut,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:n?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"dfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return Ae(wdt,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:n?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"pinrow":{const n=t.match(/_rows(\d+)/),o=n&&n[1]?parseInt(n[1],10):1;if(A.male)return Ae(Kut,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:o});if(A.female)return Ae(idt,{numberOfPins:A.num_pins,pitch:A.p,rows:o})}case"cap":switch(A.imperial){case"0402":return Ae(xVA,{color:"#856c4d"});case"0603":return Ae(kVA,{color:"#856c4d"});case"0805":return Ae(GVA,{color:"#856c4d"});case"0201":return Ae(FVA,{color:"#856c4d"});case"01005":return Ae(RVA,{color:"#856c4d"});case"1206":return Ae(NVA,{color:"#856c4d"});case"1210":return Ae(_VA,{color:"#856c4d"});case"2010":return Ae(MVA,{color:"#856c4d"});case"2512":return Ae(vVA,{color:"#856c4d"})}case"sot235":return Ae(Vut,{});case"sot457":return Ae(Rdt,{});case"sot223":return Ae(udt,{});case"sot23w":return Ae(jut,{});case"sot323":return Ae(fdt,{});case"sod323f":return Ae(Hdt,{});case"sod323fl":return Ae(Ydt,{});case"sot363":return Ae(vdt,{});case"sot886":return Ae(Udt,{});case"sot963":return Ae(Ndt,{});case"pushbutton":return Ae(ndt,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return Ae(odt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return Ae(rdt,{});case"sod882":return Ae(adt,{});case"sma":return Ae(gdt,{});case"smb":return Ae(Idt,{});case"smc":return Ae(cdt,{});case"smf":return Ae(Bdt,{});case"sod123f":return Ae(ldt,{});case"sod123fl":return Ae(Cdt,{});case"sod123w":return Ae(Qdt,{});case"sod128":return Ae(Edt,{});case"sod323":return Ae(Ldt,{});case"sod923":return Ae(hdt,{});case"hc49":return Ae(Ddt,{});case"micromelf":return Ae(Sdt,{});case"minimelf":return Ae(bdt,{});case"melf":return Ae(xdt,{});case"ms012":return Ae(kdt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return Ae(Gdt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return Ae(mdt,{});case"to220":return Ae(Fdt,{});case"to92":return Ae(_dt,{})}const e=t.match(/_color\(([^)]+)\)/),i=e?e[1]:void 0;switch(A.imperial){case"0402":return Ae(xVA,{color:i});case"0603":return Ae(kVA,{color:i});case"0805":return Ae(GVA,{color:i});case"0201":return Ae(FVA,{color:i});case"01005":return Ae(RVA,{color:i});case"1206":return Ae(NVA,{color:i});case"1210":return Ae(_VA,{color:i});case"2010":return Ae(MVA,{color:i});case"2512":return Ae(vVA,{color:i})}return null},Tdt=t=>t&&typeof t=="object"&&"type"in t,tM=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},Kdt=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 Rw(t,A,e){const{jscad:{primitives:i,booleans:n,hulls:o,geometries:s,extrusions:r,transforms:a}}=e;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(B=>Rw(B,A,e));if(!Tdt(t))return[];const{type:g,props:I,children:c}=t;if(g===wVA)return(c??[]).flatMap(B=>Rw(B,A,e));if(g===ms){const B=I?.color;return(c??[]).flatMap(l=>Rw(l,B??A,e))}if(g===Vi){const B=Kdt(I?.offset??I?.center??{x:I?.x,y:I?.y,z:I?.z});return(c??[]).flatMap(C=>Rw(C,A,e)).map(({geom:C,color:Q})=>({geom:a.translate(B,C),color:Q??A}))}if(g===EQ){const B=Array.isArray(I?.rotation)?[tM(I.rotation[0]),tM(I.rotation[1]),tM(I.rotation[2])]:[tM(I?.x??0),tM(I?.y??0),tM(I?.z??0)];return(c??[]).flatMap(C=>Rw(C,A,e)).map(({geom:C,color:Q})=>({geom:a.rotateZ(B[2],a.rotateY(B[1],a.rotateX(B[0],C))),color:Q}))}if(g===gE||g===$G||g===aI){const B=(c??[]).flatMap(C=>Rw(C,A,e)).map(C=>C.geom);if(B.length===0)return[];let l;return g===gE?l=n.union(B):g===$G?l=n.subtract(B[0],B.slice(1)):l=o.hull(B),[{geom:l,color:A}]}if(g===tL){const B=I?.points??[];return[{geom:s.geom2.fromPoints(B),color:A??I?.color}]}if(g===iL){const B=(c??[]).flatMap(E=>Rw(E,A,e)).map(E=>E.geom);if(B.length===0)return[];const l=B.length>1?n.union(B):B[0],C=I?.height??I?.h??1;let Q=r.extrudeLinear({height:C},l);if(Q.polygons)for(const E of Q.polygons)!E.plane||!E.vertices||E.vertices.length<3||E.vertices.reverse();return[{geom:Q,color:A??I?.color}]}if(g===ht||g===DVA||g===Zp||g===SVA||g===eL||g===Vp){let B;if(g===ht){const l=I?.size??[1,1,1],C=I?.offset,Q=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);B=i.cuboid({size:l,center:Q})}else if(g===DVA){const l=I?.size??1,C=I?.offset,Q=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);B=i.cube({size:l,center:Q})}else if(g===Zp){const l=I?.height??1,C=I?.radius??1,Q=I?.center??[0,0,0];B=i.cylinder({height:l,radius:C,center:Q})}else if(g===SVA){const l=I?.radius??1,C=I?.center??[0,0,0];B=i.sphere({radius:l,center:C})}else if(g===Vp){const l=I?.height??1,C=I?.radius??1,Q=I?.roundRadius??.1,E=I?.center??[0,0,0];B=i.roundedCylinder({height:l,radius:C,roundRadius:Q,center:E})}else{const l=I?.size??[1,1,1],C=I?.roundRadius??.1,Q=I?.center??[0,0,0];B=i.roundedCuboid({size:l,roundRadius:C,center:Q})}return[{geom:B,color:A??I?.color}]}if(typeof g=="function"){const B=g(I??{});return Rw(B,A,e)}return(c??[]).flatMap(B=>Rw(B,A,e))}function qdt(t,A){return{geometries:Rw(t,void 0,{jscad:A})}}function UVA(t){if(t.polygons){const A=[],e=[],i=[];let n=0;for(const s of t.polygons){for(const a of s.vertices)a.index=n,A.push(a[0],a[1],a[2]),t.color&&t.color.length>=3?i.push(t.color[0],t.color[1],t.color[2]):i.push(1,1,1),n++;const r=s.vertices[0].index;for(let a=2;a<s.vertices.length;a++){const g=s.vertices[a-1].index,I=s.vertices[a].index;e.push(r,g,I)}}const o=new dg;if(o.setAttribute("position",new rI(new Float32Array(A),3)),o.setIndex(e),i.length>0&&o.setAttribute("color",new rI(new Float32Array(i),3)),t.transforms){const s=new ts;s.fromArray(t.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(t.sides){const A=[],e=[];for(const n of t.sides)A.push(n[0][0],n[0][1],0),t.color&&t.color.length>=3?e.push(t.color[0],t.color[1],t.color[2]):e.push(1,1,1);const i=new dg;if(i.setAttribute("position",new rI(new Float32Array(A),3)),e.length>0&&i.setAttribute("color",new rI(new Float32Array(e),3)),t.transforms){const n=new ts;n.fromArray(t.transforms),i.applyMatrix4(n)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new dg}function Pdt(t,A){const e=FlA(Jdt,{footprint:t});return qdt(e,A)}var Odt=({jscadPlan:t,positionOffset:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=wu(),{threeGeom:g,material:I}=j.useMemo(()=>{const B=(0,_It.executeJscadOperations)(MIt.default,t);if(!B||!B.polygons&&!B.sides)return{threeGeom:null,material:null};const l=UVA(B),C=new Ih({vertexColors:!0,side:Ll,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:l,material:C}},[t,r]),c=j.useMemo(()=>g?new Zn(g,I):null,[g,I]);return j.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),j.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]),j.useMemo(()=>{if(I)if(o){const B=new Ui(I.color.getHex());I.emissive.copy(B),I.emissive.setRGB(0,0,1),I.emissiveIntensity=.2}else I.emissiveIntensity=0},[o,I]),g?O.jsx($U,{isHovered:o,onHover:i,onUnhover:n,object:c}):null},Wdt=yr(I5()),Zdt=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=wu(),g=j.useMemo(()=>{if(!A)return null;const{geometries:I}=Pdt(A,Wdt),c=new Wp;for(const B of I.flat(1/0)){const l=B.geom;if(!l||!l.polygons&&!l.sides)continue;const C=new Ui(B.color);C.convertLinearToSRGB();const Q={...l,color:[C.r,C.g,C.b]},E=UVA(Q),h=new Ih({vertexColors:!0,side:Ll,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new Zn(E,h);c.add(u)}return c},[A,r]);return j.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),j.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]),j.useEffect(()=>{g&&g.traverse(I=>{I instanceof Zn&&I.material instanceof Ih&&(o?(I.material.emissive.setHex(255),I.material.emissiveIntensity=.2):I.material.emissiveIntensity=0)})},[o,g]),g?O.jsx($U,{isHovered:o,onHover:i,onUnhover:n,object:g}):null},Vdt=(...t)=>t,BL={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},LVA=({children:t,position:A,style:e})=>{const{camera:i,renderer:n}=wu(),o=j.useRef(document.createElement("div")),[s,r]=j.useState(null);return j.useEffect(()=>{const a=n?.domElement.parentNode;if(a)return a.style.position!=="relative"&&a.style.position!=="absolute"&&(a.style.position="relative"),a.appendChild(o.current),r(MP.createPortal(t,o.current)),()=>{a.contains(o.current)&&a.removeChild(o.current)}},[n,t]),XU(()=>{if(!i||!o.current||!n)return;const a=new Re(...A);a.project(i);const g=n.domElement.getBoundingClientRect(),I=Math.round((a.x+1)/2*g.width),c=Math.round((-a.y+1)/2*g.height);o.current.style.position="absolute",o.current.style.left=`${I}px`,o.current.style.top=`${c}px`,o.current.style.pointerEvents="none",o.current.style.zIndex=BL.htmlElements.toString(),e&&Object.assign(o.current.style,e)},[i,n,A,e]),s},HVA={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},YVA=j.createContext(void 0),jdt=({children:t})=>{const[A,e]=j.useState(HVA),i=j.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),n=j.useCallback(()=>{e(HVA)},[]),o=j.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:n}),[A,i,n]);return O.jsx(YVA.Provider,{value:o,children:t})},iM=()=>{const t=j.useContext(YVA);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},zlA,zdt="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function Xdt(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 $dt(){if(!zlA){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");zlA=Xdt(t)({locateFile:e=>`${zdt}/${e}`})}return zlA}function Apt(t){const A=new Wp;for(const e of t){const i=e.attributes.position?.array??[],n=e.index?.array??[];if(!i.length||!n.length)continue;const o=new dg;o.setAttribute("position",new Lo(i,3));const s=e.attributes.normal?.array??[];s.length?o.setAttribute("normal",new Lo(s,3)):o.computeVertexNormals(),o.setIndex(n);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 Zn(o,r);a.name=e.name,A.add(a)}return A}async function ept(t){const A=await fetch(t);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const e=await A.arrayBuffer(),n=(await $dt()).ReadStepFile(new Uint8Array(e),null);if(!n.success||!n.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=Apt(n.meshes),s=new gnA,r=await new Promise((a,g)=>{s.parse(o,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 JVA="step-glb-cache:";function tpt(t){const A=new Uint8Array(t),e=32768;let i="";for(let n=0;n<A.length;n+=e){const o=A.subarray(n,n+e);i+=String.fromCharCode(...o)}return btoa(i)}function ipt(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 npt(t){try{const A=localStorage.getItem(`${JVA}${t}`);return A?ipt(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function opt(t,A){try{const e=tpt(A);localStorage.setItem(`${JVA}${t}`,e)}catch(e){console.warn("Failed to write STEP GLB cache",e)}}var spt=({stepUrl:t,position:A,rotation:e,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r})=>{const[a,g]=j.useState(null);return j.useEffect(()=>{let I=!0,c=null;const B=npt(t);return B?(c=URL.createObjectURL(new Blob([B],{type:"model/gltf-binary"})),g(c),()=>{I=!1,c&&URL.revokeObjectURL(c)}):(ept(t).then(l=>{if(!I){URL.revokeObjectURL(l);return}c=l,g(l),fetch(l).then(C=>C.arrayBuffer()).then(C=>{opt(t,C)}).catch(C=>{console.warn("Failed to cache STEP GLB",C)})}).catch(l=>{console.error("Failed to convert STEP file to GLB",l),I&&g(null)}),()=>{I=!1,c&&URL.revokeObjectURL(c)})},[t]),a?O.jsx(uZA,{gltfUrl:a,position:A,rotation:e,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r}):null},TVA=({cad_component:t,circuitJson:A})=>{const[e,i]=j.useState(!1),{visibility:n}=iM(),[o,s]=j.useState(null),r=j.useCallback(E=>{E?.mousePosition?(i(!0),s(E.mousePosition)):(i(!1),s(null))},[]),a=j.useCallback(()=>{i(!1),s(null)},[]),g=j.useMemo(()=>mi(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),I=j.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,l=t.model_step_url,C=t.rotation?Vdt(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=O.jsx(FIt,{url:c,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:C,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=O.jsx(uZA,{gltfUrl:B,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:C,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):l&&!t.model_jscad&&!t.footprinter_string?Q=O.jsx(spt,{stepUrl:l,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:C,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model}):t.model_jscad?Q=O.jsx(Odt,{jscadPlan:t.model_jscad,rotationOffset:C,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=O.jsx(Zdt,{positionOffset:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotationOffset:C,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model})),t.show_as_translucent_model){if(!n.translucentModels)return null}else if(I&&!n.throughHoleModels||!I&&!n.smtModels)return null;return O.jsxs(O.Fragment,{children:[Q,e&&o?O.jsx(LVA,{position:o,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:g??"<unknown>"}):null]})},KVA={version:"0.0.483"};function rpt(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var apt=t=>{t.outputColorSpace=Bm,t.toneMapping=$UA,t.toneMappingExposure=1},qVA="cadViewerCameraStateSession",PVA=(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(qVA,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},XlA=(t,A)=>{try{const e=sessionStorage.getItem(qVA);if(!e)return!1;const i=JSON.parse(e);if(t.position.fromArray(i.position),t.quaternion.fromArray(i.quaternion),t.up.fromArray(i.up),"fov"in t){const n=t;n.fov=i.fov,n.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),t.updateMatrixWorld(),!0}catch(e){return console.warn("Failed to restore camera:",e),!1}},OVA=j.createContext(void 0),gpt=({children:t,defaultTarget:A,initialCameraPosition:e})=>{const i=j.useRef(null),n=j.useRef(null),[o,s]=j.useState(null),[r,a]=j.useState("perspective"),[g,I]=j.useState(e??null),[c,B]=j.useState(new Pp(0,0,0)),l=j.useMemo(()=>{const[h,u,d]=e??[5,-5,5],f=Math.hypot(h-A.x,u-A.y,d-A.z);return f>0?f:5},[e,A]),C=j.useCallback(h=>{const u=[A.x,A.y,A.z],d=n.current,f=i.current;let w=l;switch(d&&f&&(w=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const S=w/Math.sqrt(2);return{position:[A.x,A.y-S,A.z+S],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+w],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-w*.6,A.y-w*.6,A.z+w*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+w*.6,A.y-w*.6,A.z+w*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-w,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+w,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-w,A.z],target:u,up:[0,0,1]};default:return null}},[l,A,n,i]),Q=j.useCallback(h=>{i.current=h},[]),E=j.useMemo(()=>({controlsRef:i,mainCameraRef:n,defaultTarget:A,baseDistance:l,controller:o,setController:s,getPresetConfig:C,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:I,cameraRotation:c,setCameraRotation:B,saveCameraToSession:PVA,loadCameraFromSession:XlA}),[A,l,o,C,Q,r,g,c]);return O.jsx(OVA.Provider,{value:E,children:t})},bx=()=>{const t=j.useContext(OVA);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},Ipt=j.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:n},o)=>{const{cameraType:s}=bx(),r=j.useRef(null),[a,g]=j.useState(null),I=j.useRef([]),c=j.useRef(void 0);c.current=n;const B=j.useRef(null),l=j.useCallback(h=>{I.current.push(h)},[]),C=j.useCallback(h=>{I.current=I.current.filter(u=>u!==h)},[]),Q=j.useMemo(()=>new UG,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const E=j.useRef(new ug);return j.useImperativeHandle(o,()=>E.current),j.useEffect(()=>{if(!r.current)return;rpt(r.current);const h=new z3({antialias:!0,alpha:!0});apt(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 aE(75,u,.1,1e3):new BU(-10*u,10*u,10,-10,-1e3,1e3);B.current?(d.position.copy(B.current.position),d.quaternion.copy(B.current.quaternion),d.up.copy(B.current.up)):(e?.up&&d.up.set(e.up[0],e.up[1],e.up[2]),e?.position&&d.position.set(e.position[0],e.position[1],e.position[2]),d.lookAt(0,0,0)),Q.add(E.current),window.__TSCIRCUIT_THREE_OBJECT=E.current,g({scene:Q,camera:d,renderer:h,rootObject:E.current,addFrameListener:l,removeFrameListener:C}),c.current?.({camera:d,renderer:h});let f;const w=new bXe,S=()=>{const x=w.getElapsedTime(),F=w.getDelta();I.current.forEach(k=>k(x,F)),h.render(Q,d),f=requestAnimationFrame(S)};S();const D=()=>{if(r.current){const x=r.current.clientWidth/r.current.clientHeight;d instanceof aE?d.aspect=x:d instanceof BU&&(d.left=-10*x,d.right=10*x,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),h.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",D),()=>{B.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",D),cancelAnimationFrame(f),r.current&&h.domElement&&r.current.removeChild(h.domElement),h.dispose(),Q.remove(E.current),window.__TSCIRCUIT_THREE_OBJECT===E.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,l,C,s]),O.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&O.jsx(CZA.Provider,{value:a,children:O.jsx(SIt,{children:t})})})}),cpt=({autoRotate:t,autoRotateSpeed:A,onStart:e,panSpeed:i,rotateSpeed:n,zoomSpeed:o,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:I,renderer:c}=wu(),B=j.useMemo(()=>!I||!c?null:new o7e(I,c.domElement),[I,c]);return j.useEffect(()=>(g?.(B??null),()=>g?.(null)),[B,g]),j.useEffect(()=>{if(!B)return;const l=()=>{g?.(B)};return B.addEventListener("change",l),()=>{B.removeEventListener("change",l)}},[B,g]),j.useEffect(()=>{B&&(B.autoRotate=t||!1,B.autoRotateSpeed=A||1,i!==void 0&&(B.panSpeed=i),n!==void 0&&(B.rotateSpeed=n),o!==void 0&&(B.zoomSpeed=o),s!==void 0&&(B.enableDamping=s),r!==void 0&&(B.dampingFactor=r),B.zoomToCursor=!0,B.mouseButtons={LEFT:ex.ROTATE,MIDDLE:ex.PAN,RIGHT:null},a&&(B.target.set(a[0],a[1],a[2]),B.update()))},[B,t,A,i,n,o,s,r,a]),j.useEffect(()=>{if(!(!B||!e))return B.addEventListener("start",e),()=>{B.removeEventListener("start",e)}},[B,e]),j.useEffect(()=>{if(B)return()=>{B.dispose()}},[B]),XU(()=>{B?.update()},[B]),null},Bpt=`
5066
+ `).replace(/d 0\./g,"d 1."),l=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new P6e;C.setMaterialOptions({invertTrProperty:!0});const Q=C.parse(B.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return c.setMaterials(Q),c.parse(l)}return c.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(n.has(i)){const g=n.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(I=>I instanceof Error?I:I.clone())}const a=s().then(g=>(g instanceof Error||n.set(i,{...n.get(i),result:g}),g));return n.set(i,{promise:a,result:null}),a}return r().then(a=>{o||e(a)}).catch(a=>{console.error(a)}),()=>{o=!0}},[t]),A}function FIt({url:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const a=GIt(t),{rootObject:g}=wu(),I=j.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(c=>{if(c instanceof Zn&&c.material){const B=l=>{l.transparent=r,l.opacity=r?.5:1,l.depthWrite=!r,l.needsUpdate=!0};Array.isArray(c.material)?c.material.forEach(B):B(c.material)}}),a):new Zn(new fm(.5,.5,.5),new Ih({transparent:!0,color:"red",opacity:.25})),[a,r]);if(j.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),j.useEffect(()=>{I&&(A&&(Array.isArray(A)?I.position.fromArray(A):I.position.copy(A)),e&&(Array.isArray(e)?I.rotation.fromArray(e):I.rotation.copy(e)),s!==void 0&&I.scale.setScalar(s))},[I,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(e)?e[0]:e?.x,Array.isArray(e)?e[1]:e?.y,Array.isArray(e)?e[2]:e?.z,s]),a instanceof Error)throw a;return O.jsx($U,{isHovered:o,onHover:i,onUnhover:n,object:I})}var EZA=new WeakMap,RIt=()=>{const t=new Yc;return t.name="fallback-environment-map",t.mapping=d3,t},NIt=t=>{if(!t)return null;const A=t,e=EZA.get(A);if(e)return e;let i;if(t instanceof z3){const n=new RiA(t);i=n.fromScene(r6e(),.04).texture,n.dispose()}else i=RIt();return EZA.set(A,i),i},hZA=1.25;function uZA({gltfUrl:t,position:A,rotation:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=wu(),[I,c]=j.useState(null),[B,l]=j.useState(null);if(j.useEffect(()=>{if(!t)return;const C=new g6e;let Q=!0;return C.load(t,E=>{if(!Q)return;const h=E.scene;h.traverse(u=>{if(u instanceof Zn&&u.material){const d=f=>{f.transparent=r,f.opacity=r?.5:1,f.depthWrite=!r,f.needsUpdate=!0};Array.isArray(u.material)?u.material.forEach(d):d(u.material)}}),c(h)},void 0,E=>{if(!Q)return;console.error(`An error happened loading ${t}`,E);const h=E instanceof Error?E:new Error(`Failed to load glTF model from ${t}`);l(h)}),()=>{Q=!1}},[t,r]),j.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]),j.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),j.useEffect(()=>{if(!I||!a)return;const C=NIt(a);if(!C)return;const Q=[],E=h=>{h instanceof Ih&&(Q.push({material:h,envMap:h.envMap??null,envMapIntensity:h.envMapIntensity??1}),h.envMap=C,(typeof h.envMapIntensity!="number"||h.envMapIntensity<hZA)&&(h.envMapIntensity=hZA),h.needsUpdate=!0)};return I.traverse(h=>{if(!(h instanceof Zn))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]),j.useEffect(()=>{I&&I.traverse(C=>{C instanceof Zn&&C.material instanceof Ih&&(o?(C.material.emissive.setHex(255),C.material.emissiveIntensity=.2):C.material.emissiveIntensity=0)})},[o,I]),B)throw B;return I?O.jsx($U,{isHovered:o,onHover:i,onUnhover:n,object:I}):null}var _It=yr(P8A()),MIt=yr(I5()),dZA={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},mr=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 dZA)return e*dZA[A];throw new Error(`Unsupported unit: ${A}`)},mB=mr,pZA={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}}},dlA=new Set;for(const[t,A]of Object.entries(pZA)){dlA.add(t);for(const e of Object.keys(A.variants))dlA.add(e)}function vIt(t){for(const[A,e]of Object.entries(pZA))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var fZA={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 Dm(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}=Dm(t.x),g=Dm(t.x),I=Dm(t.y);return g.value===null||I.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:I.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),n=t.slice(0,-i.length);if(i in fZA&&!dlA.has(i)){const r=fZA[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(n)*r}}const{baseUnit:o,conversionFactor:s}=vIt(i);return{parsedUnit:i,unitOfValue:o,value:s*Number.parseFloat(n)}}var plA=Y().or(VA()).transform(t=>Dm(t).value),yZA=Y().or(VA()).transform(t=>Dm(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),UIt=Y().or(VA()).transform(t=>Dm(t).value),K_=Y().or(VA()).transform(t=>Dm(t).value),$A=Y().or(VA()).transform(t=>Dm(t).value),c5=Y().or(VA()).transform(t=>Dm(t).value),wt=$A,flA=Y().or(VA()).transform(t=>Dm(t).value),ylA=Y().or(VA()).transform(t=>Dm(t).value),q_=ylA,LIt=Y().datetime(),md=Y().or(VA()).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)),HIt=VA().or(Y().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"),kn=OA({x:wt,y:wt}),mlA=OA({x:wt,y:wt,z:wt}),mZA=OA({width:VA(),height:VA()}),YIt=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},jt=t=>Y().optional().default(()=>`${t}_${YIt(10)}`),XG=lt(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]);lt(["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 JIt=lt(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),wB=OA({type:FA("source_component"),ftype:Y().optional(),source_component_id:Y(),name:Y(),manufacturer_part_number:Y().optional(),supplier_part_numbers:Ma(JIt,be(Y())).optional(),display_value:Y().optional(),are_pins_interchangeable:Be().optional(),internally_connected_source_port_ids:be(be(Y())).optional(),source_group_id:Y().optional(),subcircuit_id:Y().optional()}),wZA=wB.extend({ftype:FA("simple_capacitor"),capacitance:yZA,max_voltage_rating:K_.optional(),display_capacitance:Y().optional(),max_decoupling_trace_length:wt.optional()}),DZA=wB.extend({ftype:FA("simple_resistor"),resistance:plA,display_resistance:Y().optional()}),wlA=wB.extend({ftype:FA("simple_diode")}),TIt=wB.extend({ftype:FA("simple_fiducial")}),SZA=wlA.extend({ftype:FA("simple_led"),color:Y().optional(),wavelength:Y().optional()}),KIt=wB.extend({ftype:FA("simple_ground")}),bZA=wB.extend({ftype:FA("simple_chip")}),xZA=wB.extend({ftype:FA("simple_power_source"),voltage:K_}),qIt=wB.extend({ftype:FA("simple_fuse"),current_rating_amps:VA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:VA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),kZA=wB.extend({ftype:FA("simple_battery"),capacity:HIt}),GZA=wB.extend({ftype:FA("simple_inductor"),inductance:UIt,max_current_rating:VA().optional()}),FZA=wB.extend({ftype:FA("simple_push_button")}),RZA=wB.extend({ftype:FA("simple_potentiometer"),max_resistance:plA}),PIt=wB.extend({ftype:FA("simple_crystal"),frequency:VA().describe("Frequency in Hz"),load_capacitance:VA().optional().describe("Load capacitance in pF")}),NZA=wB.extend({ftype:FA("simple_pin_header"),pin_count:VA(),gender:lt(["male","female"]).optional().default("male")}),_ZA=wB.extend({ftype:FA("simple_pinout")}),MZA=wB.extend({ftype:FA("simple_resonator"),load_capacitance:yZA,equivalent_series_resistance:plA.optional(),frequency:c5}),vZA=wB.extend({ftype:FA("simple_transistor"),transistor_type:lt(["npn","pnp"])}),UZA=wB.extend({ftype:FA("simple_test_point"),footprint_variant:lt(["pad","through_hole"]).optional(),pad_shape:lt(["rect","circle"]).optional(),pad_diameter:Ai([VA(),Y()]).optional(),hole_diameter:Ai([VA(),Y()]).optional(),width:Ai([VA(),Y()]).optional(),height:Ai([VA(),Y()]).optional()}),LZA=wB.extend({ftype:FA("simple_mosfet"),channel_type:lt(["n","p"]),mosfet_mode:lt(["enhancement","depletion"])}),HZA=wB.extend({ftype:FA("simple_op_amp")}),YZA=wB.extend({ftype:FA("simple_switch")}),JZA=OA({type:FA("source_project_metadata"),name:Y().optional(),software_used_string:Y().optional(),project_url:Y().optional(),created_at:LIt.optional()}),OIt=OA({type:FA("source_missing_property_error"),source_missing_property_error_id:jt("source_missing_property_error"),source_component_id:Y(),property_name:Y(),subcircuit_id:Y().optional(),error_type:FA("source_missing_property_error").default("source_missing_property_error"),message:Y()}).describe("The source code is missing a property"),WIt=OA({type:FA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:jt("source_failed_to_create_component_error"),error_type:FA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:Y().optional(),subcircuit_id:Y().optional(),parent_source_component_id:Y().optional(),message:Y(),pcb_center:OA({x:VA().optional(),y:VA().optional()}).optional(),schematic_center:OA({x:VA().optional(),y:VA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),TZA=OA({type:FA("source_trace_not_connected_error"),source_trace_not_connected_error_id:jt("source_trace_not_connected_error"),error_type:FA("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:Y(),subcircuit_id:Y().optional(),source_group_id:Y().optional(),source_trace_id:Y().optional(),connected_source_port_ids:be(Y()).optional(),selectors_not_found:be(Y()).optional()}).describe("Occurs when a source trace selector does not match any ports"),ZIt=OA({type:FA("source_property_ignored_warning"),source_property_ignored_warning_id:jt("source_property_ignored_warning"),source_component_id:Y(),property_name:Y(),subcircuit_id:Y().optional(),error_type:FA("source_property_ignored_warning").default("source_property_ignored_warning"),message:Y()}).describe("The source property was ignored"),KZA=OA({type:FA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:jt("source_pin_missing_trace_warning"),warning_type:FA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:Y(),source_component_id:Y(),source_port_id:Y(),subcircuit_id:Y().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),VIt=wB.extend({ftype:FA("simple_voltage_probe")}),jIt=wB.extend({ftype:FA("interconnect")}),zIt=Ai([DZA,wZA,wlA,TIt,SZA,KIt,bZA,xZA,kZA,GZA,FZA,RZA,PIt,NZA,_ZA,MZA,YZA,vZA,UZA,LZA,HZA,qIt,VIt,jIt,JZA,OIt,WIt,TZA,ZIt,KZA]),XIt=OA({type:FA("source_port"),pin_number:VA().optional(),port_hints:be(Y()).optional(),name:Y(),source_port_id:Y(),source_component_id:Y().optional(),source_group_id:Y().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),must_be_connected:Be().optional()}),$It=OA({type:FA("source_component_internal_connection"),source_component_internal_connection_id:Y(),source_component_id:Y(),source_port_ids:be(Y()),subcircuit_id:Y().optional()}),Act=OA({type:FA("source_trace"),source_trace_id:Y(),connected_source_port_ids:be(Y()),connected_source_net_ids:be(Y()),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),max_length:VA().optional(),min_trace_thickness:VA().optional(),display_name:Y().optional()}),ect=OA({type:FA("source_group"),source_group_id:Y(),subcircuit_id:Y().optional(),parent_subcircuit_id:Y().optional(),parent_source_group_id:Y().optional(),is_subcircuit:Be().optional(),show_as_schematic_box:Be().optional(),name:Y().optional(),was_automatically_named:Be().optional()}),tct=OA({type:FA("source_net"),source_net_id:Y(),name:Y(),member_source_group_ids:be(Y()),is_power:Be().optional(),is_ground:Be().optional(),is_digital_signal:Be().optional(),is_analog_signal:Be().optional(),is_positive_voltage_source:Be().optional(),trace_width:VA().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional()}),ict=OA({type:FA("source_board"),source_board_id:Y(),source_group_id:Y(),title:Y().optional()}).describe("Defines a board in the source domain"),nct=OA({type:FA("source_pcb_ground_plane"),source_pcb_ground_plane_id:Y(),source_group_id:Y(),source_net_id:Y(),subcircuit_id:Y().optional()}).describe("Defines a ground plane in the source domain"),oct=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],qZA=lt(oct),Mr=qZA.or(OA({name:qZA})).transform(t=>typeof t=="string"?t:t.name),Gw=lt(["top","bottom"]),sct=OA({type:FA("source_manually_placed_via"),source_manually_placed_via_id:Y(),source_group_id:Y(),source_net_id:Y(),subcircuit_id:Y().optional(),source_trace_id:Y().optional()}).describe("Defines a via that is manually placed in the source domain"),rct=OA({type:FA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:jt("source_pin_must_be_connected_error"),error_type:FA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),message:Y(),source_component_id:Y(),source_port_id:Y(),subcircuit_id:Y().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),act=OA({type:FA("unknown_error_finding_part"),unknown_error_finding_part_id:jt("unknown_error_finding_part"),error_type:FA("unknown_error_finding_part").default("unknown_error_finding_part"),message:Y(),source_component_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),gct=OA({type:FA("schematic_box"),schematic_component_id:Y().optional(),width:wt,height:wt,is_dashed:Be().default(!1),x:wt,y:wt,subcircuit_id:Y().optional()}).describe("Draws a box on the schematic"),Ict=OA({type:FA("schematic_path"),schematic_component_id:Y(),fill_color:lt(["red","blue"]).optional(),is_filled:Be().optional(),points:be(kn),subcircuit_id:Y().optional()}),cct=Ma(OA({left_margin:$A.optional(),right_margin:$A.optional(),top_margin:$A.optional(),bottom_margin:$A.optional()})),Bct=OA({left_size:VA(),right_size:VA(),top_size:VA().optional(),bottom_size:VA().optional()}),lct=OA({left_side:OA({pins:be(VA()),direction:lt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:OA({pins:be(VA()),direction:lt(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:OA({pins:be(VA()),direction:lt(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:OA({pins:be(VA()),direction:lt(["left-to-right","right-to-left"]).optional()}).optional()}),Cct=Ai([Bct,lct]),Qct=OA({type:FA("schematic_component"),size:mZA,center:kn,source_component_id:Y().optional(),schematic_component_id:Y(),pin_spacing:$A.optional(),pin_styles:cct.optional(),box_width:$A.optional(),symbol_name:Y().optional(),port_arrangement:Cct.optional(),port_labels:Ma(Y()).optional(),symbol_display_value:Y().optional(),subcircuit_id:Y().optional(),schematic_group_id:Y().optional(),is_schematic_group:Be().optional(),source_group_id:Y().optional(),is_box_with_pins:Be().optional().default(!0)}),Ect=OA({type:FA("schematic_line"),schematic_line_id:jt("schematic_line"),schematic_component_id:Y(),x1:wt,y1:wt,x2:wt,y2:wt,stroke_width:wt.nullable().optional(),color:Y().default("#000000"),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled line on the schematic"),hct=OA({type:FA("schematic_rect"),schematic_rect_id:jt("schematic_rect"),schematic_component_id:Y(),center:kn,width:wt,height:wt,rotation:md.default(0),stroke_width:wt.nullable().optional(),color:Y().default("#000000"),is_filled:Be().default(!1),fill_color:Y().optional(),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled rectangle on the schematic"),uct=OA({type:FA("schematic_circle"),schematic_circle_id:jt("schematic_circle"),schematic_component_id:Y(),center:kn,radius:wt,stroke_width:wt.nullable().optional(),color:Y().default("#000000"),is_filled:Be().default(!1),fill_color:Y().optional(),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled circle on the schematic"),dct=OA({type:FA("schematic_arc"),schematic_arc_id:jt("schematic_arc"),schematic_component_id:Y(),center:kn,radius:wt,start_angle_degrees:md,end_angle_degrees:md,direction:lt(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:wt.nullable().optional(),color:Y().default("#000000"),is_dashed:Be().default(!1),subcircuit_id:Y().optional()}).describe("Draws a styled arc on the schematic"),pct=OA({type:FA("schematic_trace"),schematic_trace_id:Y(),source_trace_id:Y().optional(),junctions:be(OA({x:VA(),y:VA()})),edges:be(OA({from:OA({x:VA(),y:VA()}),to:OA({x:VA(),y:VA()}),is_crossing:Be().optional(),from_schematic_port_id:Y().optional(),to_schematic_port_id:Y().optional()})),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional()}),fct=lt(["center","left","right","top","bottom"]),yct=OA({type:FA("schematic_text"),schematic_component_id:Y().optional(),schematic_text_id:Y(),text:Y(),font_size:VA().default(.18),position:OA({x:wt,y:wt}),rotation:VA().default(0),anchor:Ai([fct.describe("legacy"),XG]).default("center"),color:Y().default("#000000"),subcircuit_id:Y().optional()}),mct=OA({type:FA("schematic_port"),schematic_port_id:Y(),source_port_id:Y(),schematic_component_id:Y().optional(),center:kn,facing_direction:lt(["up","down","left","right"]).optional(),distance_from_component_edge:VA().optional(),side_of_component:lt(["top","bottom","left","right"]).optional(),true_ccw_index:VA().optional(),pin_number:VA().optional(),display_pin_label:Y().optional(),subcircuit_id:Y().optional(),is_connected:Be().optional(),has_input_arrow:Be().optional(),has_output_arrow:Be().optional()}).describe("Defines a port on a schematic component"),wct=OA({type:FA("schematic_net_label"),schematic_net_label_id:jt("schematic_net_label"),schematic_trace_id:Y().optional(),source_trace_id:Y().optional(),source_net_id:Y(),center:kn,anchor_position:kn.optional(),anchor_side:lt(["top","bottom","left","right"]),text:Y(),symbol_name:Y().optional(),is_movable:Be().optional(),subcircuit_id:Y().optional()}),Dct=OA({type:FA("schematic_error"),schematic_error_id:Y(),error_type:FA("schematic_port_not_found").default("schematic_port_not_found"),message:Y(),subcircuit_id:Y().optional()}).describe("Defines a schematic error on the schematic"),Sct=OA({type:FA("schematic_layout_error"),schematic_layout_error_id:jt("schematic_layout_error"),error_type:FA("schematic_layout_error").default("schematic_layout_error"),message:Y(),source_group_id:Y(),schematic_group_id:Y(),subcircuit_id:Y().optional()}).describe("Error emitted when schematic layout fails for a group"),DlA=OA({type:FA("schematic_debug_object"),label:Y().optional(),subcircuit_id:Y().optional()}),bct=DlA.extend({shape:FA("rect"),center:kn,size:mZA}),xct=DlA.extend({shape:FA("line"),start:kn,end:kn}),kct=DlA.extend({shape:FA("point"),center:kn}),Gct=Np("shape",[bct,xct,kct]),Fct=OA({type:FA("schematic_voltage_probe"),schematic_voltage_probe_id:Y(),source_component_id:Y().optional(),name:Y().optional(),position:kn,schematic_trace_id:Y(),voltage:K_.optional(),subcircuit_id:Y().optional(),color:Y().optional(),label_alignment:XG.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),Rct=OA({type:FA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:jt("schematic_manual_edit_conflict_warning"),warning_type:FA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:Y(),schematic_component_id:Y(),schematic_group_id:Y().optional(),subcircuit_id:Y().optional(),source_component_id:Y()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),Nct=OA({type:FA("schematic_group"),schematic_group_id:jt("schematic_group"),source_group_id:Y(),is_subcircuit:Be().optional(),subcircuit_id:Y().optional(),width:$A,height:$A,center:kn,schematic_component_ids:be(Y()),show_as_schematic_box:Be().optional(),name:Y().optional(),description:Y().optional()}).describe("Defines a group of components on the schematic"),_ct=OA({type:FA("schematic_table"),schematic_table_id:jt("schematic_table"),anchor_position:kn,column_widths:be(wt),row_heights:be(wt),cell_padding:wt.optional(),border_width:wt.optional(),subcircuit_id:Y().optional(),schematic_component_id:Y().optional(),anchor:XG.optional()}).describe("Defines a table on the schematic"),Mct=OA({type:FA("schematic_table_cell"),schematic_table_cell_id:jt("schematic_table_cell"),schematic_table_id:Y(),start_row_index:VA(),end_row_index:VA(),start_column_index:VA(),end_column_index:VA(),text:Y().optional(),center:kn,width:wt,height:wt,horizontal_align:lt(["left","center","right"]).optional(),vertical_align:lt(["top","middle","bottom"]).optional(),font_size:wt.optional(),subcircuit_id:Y().optional()}).describe("Defines a cell within a schematic_table"),vct=OA({type:FA("schematic_sheet"),schematic_sheet_id:jt("schematic_sheet"),name:Y().optional(),subcircuit_id:Y().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),Uct=OA({x:wt,y:wt,bulge:VA().optional()}),PZA=OA({vertices:be(Uct)}),Lct=OA({outer_ring:PZA,inner_rings:be(PZA).default([])}),Hct=OA({x:wt,y:wt,via:Be().optional(),via_to_layer:Mr.optional()});be(Hct);var Yct=OA({x:wt,y:wt,via:Be().optional(),to_layer:Mr.optional(),trace_width:wt.optional()}),Jct=OA({type:FA("pcb_component"),pcb_component_id:jt("pcb_component"),source_component_id:Y(),center:kn,layer:Mr,rotation:md,display_offset_x:Y().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:Y().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:Be().optional(),subcircuit_id:Y().optional(),pcb_group_id:Y().optional(),position_mode:lt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:Y().optional(),positioned_relative_to_pcb_board_id:Y().optional(),obstructs_within_bounds:Be().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),OZA=OA({type:FA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:FA("circle"),hole_diameter:VA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()});OZA.describe("Defines a circular hole on the PCB");var WZA=OA({type:FA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:FA("rect"),hole_width:VA(),hole_height:VA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()});WZA.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square.");var ZZA=OA({type:FA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:lt(["circle","square"]),hole_diameter:VA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()});ZZA.describe("Defines a circular or square hole on the PCB");var VZA=OA({type:FA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:FA("oval"),hole_width:VA(),hole_height:VA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()});VZA.describe("Defines an oval hole on the PCB");var jZA=OA({type:FA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:FA("pill"),hole_width:VA(),hole_height:VA(),x:wt,y:wt,is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()});jZA.describe("Defines a pill-shaped hole on the PCB");var zZA=OA({type:FA("pcb_hole"),pcb_hole_id:jt("pcb_hole"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_component_id:Y().optional(),hole_shape:FA("rotated_pill"),hole_width:VA(),hole_height:VA(),x:wt,y:wt,ccw_rotation:md,is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()});zZA.describe("Defines a rotated pill-shaped hole on the PCB");var Tct=ZZA.or(VZA).or(jZA).or(zZA).or(OZA).or(WZA),Kct=OA({type:FA("pcb_plated_hole"),shape:FA("circle"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),outer_diameter:VA(),hole_diameter:VA(),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Mr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:VA().optional()}),qct=OA({type:FA("pcb_plated_hole"),shape:lt(["oval","pill"]),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),outer_width:VA(),outer_height:VA(),hole_width:VA(),hole_height:VA(),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,ccw_rotation:md,layers:be(Mr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:VA().optional()}),Pct=OA({type:FA("pcb_plated_hole"),shape:FA("circular_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:FA("circle"),pad_shape:FA("rect"),hole_diameter:VA(),rect_pad_width:VA(),rect_pad_height:VA(),rect_border_radius:VA().optional(),hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Mr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:VA().optional()}),Oct=OA({type:FA("pcb_plated_hole"),shape:FA("pill_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:FA("pill"),pad_shape:FA("rect"),hole_width:VA(),hole_height:VA(),rect_pad_width:VA(),rect_pad_height:VA(),rect_border_radius:VA().optional(),hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Mr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:VA().optional()}),Wct=OA({type:FA("pcb_plated_hole"),shape:FA("rotated_pill_hole_with_rect_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:FA("rotated_pill"),pad_shape:FA("rect"),hole_width:VA(),hole_height:VA(),hole_ccw_rotation:md,rect_pad_width:VA(),rect_pad_height:VA(),rect_border_radius:VA().optional(),rect_ccw_rotation:md,hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Mr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:VA().optional()}),Zct=OA({type:FA("pcb_plated_hole"),shape:FA("hole_with_polygon_pad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),hole_shape:lt(["circle","oval","pill","rotated_pill"]),hole_diameter:VA().optional(),hole_width:VA().optional(),hole_height:VA().optional(),pad_outline:be(OA({x:wt,y:wt})).min(3),hole_offset_x:wt.default(0),hole_offset_y:wt.default(0),is_covered_with_solder_mask:Be().optional(),x:wt,y:wt,layers:be(Mr),port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),pcb_plated_hole_id:jt("pcb_plated_hole"),soldermask_margin:VA().optional()}),Vct=Ai([Kct,qct,Pct,Oct,Wct,Zct]),jct=OA({type:FA("pcb_port"),pcb_port_id:jt("pcb_port"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),source_port_id:Y(),pcb_component_id:Y().optional(),x:wt,y:wt,layers:be(Mr),is_board_pinout:Be().optional()}).describe("Defines a port on the PCB"),zct=OA({type:FA("pcb_smtpad"),shape:FA("circle"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,radius:VA(),layer:Mr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()}),Xct=OA({type:FA("pcb_smtpad"),shape:FA("rect"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),rect_border_radius:VA().optional(),corner_radius:VA().optional(),layer:Mr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()}),$ct=OA({type:FA("pcb_smtpad"),shape:FA("rotated_rect"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),rect_border_radius:VA().optional(),corner_radius:VA().optional(),ccw_rotation:md,layer:Mr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()}),ABt=OA({type:FA("pcb_smtpad"),shape:FA("pill"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),radius:VA(),layer:Mr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()}),eBt=OA({type:FA("pcb_smtpad"),shape:FA("rotated_pill"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),radius:VA(),ccw_rotation:md,layer:Mr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()}),tBt=OA({type:FA("pcb_smtpad"),shape:FA("polygon"),pcb_smtpad_id:jt("pcb_smtpad"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),points:be(kn),layer:Mr,port_hints:be(Y()).optional(),pcb_component_id:Y().optional(),pcb_port_id:Y().optional(),is_covered_with_solder_mask:Be().optional(),soldermask_margin:VA().optional()}),iBt=Np("shape",[zct,Xct,$ct,eBt,ABt,tBt]).describe("Defines an SMT pad on the PCB"),nBt=OA({type:FA("pcb_solder_paste"),shape:FA("circle"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,radius:VA(),layer:Mr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),oBt=OA({type:FA("pcb_solder_paste"),shape:FA("rect"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),layer:Mr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),sBt=OA({type:FA("pcb_solder_paste"),shape:FA("pill"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),radius:VA(),layer:Mr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),rBt=OA({type:FA("pcb_solder_paste"),shape:FA("rotated_rect"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),ccw_rotation:wt,layer:Mr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),aBt=OA({type:FA("pcb_solder_paste"),shape:FA("oval"),pcb_solder_paste_id:jt("pcb_solder_paste"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),x:wt,y:wt,width:VA(),height:VA(),layer:Mr,pcb_component_id:Y().optional(),pcb_smtpad_id:Y().optional()}),gBt=Ai([nBt,oBt,sBt,rBt,aBt]).describe("Defines solderpaste on the PCB"),IBt=OA({type:FA("pcb_text"),pcb_text_id:jt("pcb_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),text:Y(),center:kn,layer:Mr,width:$A,height:$A,lines:VA(),align:lt(["bottom-left"])}).describe("Defines text on the PCB"),cBt=OA({route_type:FA("wire"),x:wt,y:wt,width:wt,start_pcb_port_id:Y().optional(),end_pcb_port_id:Y().optional(),layer:Mr}),BBt=OA({route_type:FA("via"),x:wt,y:wt,hole_diameter:wt.optional(),outer_diameter:wt.optional(),from_layer:Y(),to_layer:Y()}),lBt=Ai([cBt,BBt]),CBt=OA({type:FA("pcb_trace"),source_trace_id:Y().optional(),pcb_component_id:Y().optional(),pcb_trace_id:jt("pcb_trace"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),route_thickness_mode:lt(["constant","interpolated"]).default("constant").optional(),route_order_index:VA().optional(),should_round_corners:Be().optional(),trace_length:VA().optional(),highlight_color:Y().optional(),route:be(lBt)}).describe("Defines a trace on the PCB"),QBt=OA({type:FA("pcb_trace_error"),pcb_trace_error_id:jt("pcb_trace_error"),error_type:FA("pcb_trace_error").default("pcb_trace_error"),message:Y(),center:kn.optional(),pcb_trace_id:Y(),source_trace_id:Y(),pcb_component_ids:be(Y()),pcb_port_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines a trace error on the PCB"),EBt=OA({type:FA("pcb_trace_missing_error"),pcb_trace_missing_error_id:jt("pcb_trace_missing_error"),error_type:FA("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:Y(),center:kn.optional(),source_trace_id:Y(),pcb_component_ids:be(Y()),pcb_port_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),hBt=OA({type:FA("pcb_port_not_matched_error"),pcb_error_id:jt("pcb_error"),error_type:FA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:Y(),pcb_component_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),uBt=OA({type:FA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:jt("pcb_port_not_connected_error"),error_type:FA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:Y(),pcb_port_ids:be(Y()),pcb_component_ids:be(Y()),subcircuit_id:Y().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),dBt=OA({type:FA("pcb_net"),pcb_net_id:jt("pcb_net"),source_net_id:Y().optional(),highlight_color:Y().optional()}).describe("Defines a net on the PCB"),pBt=OA({type:FA("pcb_via"),pcb_via_id:jt("pcb_via"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),x:wt,y:wt,outer_diameter:wt.default("0.6mm"),hole_diameter:wt.default("0.25mm"),from_layer:Mr.optional(),to_layer:Mr.optional(),layers:be(Mr),pcb_trace_id:Y().optional(),net_is_assignable:Be().optional(),net_assigned:Be().optional(),is_tented:Be().optional()}).describe("Defines a via on the PCB"),fBt=OA({type:FA("pcb_board"),pcb_board_id:jt("pcb_board"),pcb_panel_id:Y().optional(),is_subcircuit:Be().optional(),subcircuit_id:Y().optional(),width:$A.optional(),height:$A.optional(),center:kn,display_offset_x:Y().optional().describe("How to display the x offset for this board, usually corresponding with how the user specified it"),display_offset_y:Y().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:VA().optional().default(4),outline:be(kn).optional(),shape:lt(["rect","polygon"]).optional(),material:lt(["fr4","fr1"]).default("fr4"),anchor_position:kn.optional(),anchor_alignment:XG.optional(),position_mode:lt(["relative_to_panel_anchor","none"]).optional()}).describe("Defines the board outline of the PCB"),yBt=OA({type:FA("pcb_panel"),pcb_panel_id:jt("pcb_panel"),width:$A,height:$A,center:kn,covered_with_solder_mask:Be().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),mBt=OA({type:FA("pcb_placement_error"),pcb_placement_error_id:jt("pcb_placement_error"),error_type:FA("pcb_placement_error").default("pcb_placement_error"),message:Y(),subcircuit_id:Y().optional()}).describe("Defines a placement error on the PCB"),wBt=OA({type:FA("pcb_trace_hint"),pcb_trace_hint_id:jt("pcb_trace_hint"),pcb_port_id:Y(),pcb_component_id:Y(),route:be(Yct),subcircuit_id:Y().optional()}).describe("A hint that can be used during generation of a PCB trace"),DBt=OA({type:FA("pcb_silkscreen_line"),pcb_silkscreen_line_id:jt("pcb_silkscreen_line"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),stroke_width:wt.default("0.1mm"),x1:wt,y1:wt,x2:wt,y2:wt,layer:Gw}).describe("Defines a silkscreen line on the PCB"),SBt=OA({type:FA("pcb_silkscreen_path"),pcb_silkscreen_path_id:jt("pcb_silkscreen_path"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Gw,route:be(kn),stroke_width:$A}).describe("Defines a silkscreen path on the PCB"),bBt=OA({type:FA("pcb_silkscreen_text"),pcb_silkscreen_text_id:jt("pcb_silkscreen_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("0.2mm"),pcb_component_id:Y(),text:Y(),is_knockout:Be().default(!1).optional(),knockout_padding:OA({left:$A,top:$A,bottom:$A,right:$A}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:VA().optional(),layer:Mr,is_mirrored:Be().default(!1).optional(),anchor_position:kn.default({x:0,y:0}),anchor_alignment:XG.default("center")}).describe("Defines silkscreen text on the PCB"),xBt=OA({type:FA("pcb_copper_text"),pcb_copper_text_id:jt("pcb_copper_text"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("0.2mm"),pcb_component_id:Y(),text:Y(),is_knockout:Be().default(!1).optional(),knockout_padding:OA({left:$A,top:$A,bottom:$A,right:$A}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:VA().optional(),layer:Mr,is_mirrored:Be().default(!1).optional(),anchor_position:kn.default({x:0,y:0}),anchor_alignment:XG.default("center")}).describe("Defines copper text on the PCB"),kBt=OA({type:FA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:jt("pcb_silkscreen_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,width:$A,height:$A,layer:Mr,stroke_width:$A.default("1mm"),corner_radius:$A.optional(),is_filled:Be().default(!0).optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),ccw_rotation:VA().optional()}).describe("Defines a silkscreen rect on the PCB"),GBt=OA({type:FA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:jt("pcb_silkscreen_circle"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,radius:$A,layer:Gw,stroke_width:$A.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),FBt=OA({type:FA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:jt("pcb_silkscreen_oval"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,radius_x:wt,radius_y:wt,layer:Gw,ccw_rotation:md.optional()}).describe("Defines a silkscreen oval on the PCB"),RBt=OA({type:FA("pcb_silkscreen_pill"),pcb_silkscreen_pill_id:jt("pcb_silkscreen_pill"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,width:$A,height:$A,layer:Mr,ccw_rotation:VA().optional()}).describe("Defines a silkscreen pill on the PCB"),NBt=OA({type:FA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:jt("pcb_fabrication_note_text"),subcircuit_id:Y().optional(),pcb_group_id:Y().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("1mm"),pcb_component_id:Y(),text:Y(),layer:Gw,anchor_position:kn.default({x:0,y:0}),anchor_alignment:lt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Y().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),_Bt=OA({type:FA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:jt("pcb_fabrication_note_path"),pcb_component_id:Y(),subcircuit_id:Y().optional(),layer:Mr,route:be(kn),stroke_width:$A,color:Y().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),MBt=OA({type:FA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:jt("pcb_fabrication_note_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,width:$A,height:$A,layer:Gw,stroke_width:$A.default("0.1mm"),corner_radius:$A.optional(),is_filled:Be().optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),color:Y().optional()}).describe("Defines a fabrication note rectangle on the PCB"),vBt=OA({type:FA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:jt("pcb_fabrication_note_dimension"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Gw,from:kn,to:kn,text:Y().optional(),text_ccw_rotation:VA().optional(),offset:$A.optional(),offset_distance:$A.optional(),offset_direction:OA({x:VA(),y:VA()}).optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:$A.default("1mm"),color:Y().optional(),arrow_size:$A.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),UBt=OA({type:FA("pcb_note_text"),pcb_note_text_id:jt("pcb_note_text"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:wt.default("1mm"),text:Y().optional(),anchor_position:kn.default({x:0,y:0}),anchor_alignment:lt(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Y().optional()}).describe("Defines a documentation note in text on the PCB"),LBt=OA({type:FA("pcb_note_rect"),pcb_note_rect_id:jt("pcb_note_rect"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),center:kn,width:$A,height:$A,stroke_width:$A.default("0.1mm"),corner_radius:$A.optional(),is_filled:Be().optional(),has_stroke:Be().optional(),is_stroke_dashed:Be().optional(),color:Y().optional()}).describe("Defines a rectangular documentation note on the PCB"),HBt=OA({type:FA("pcb_note_path"),pcb_note_path_id:jt("pcb_note_path"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),route:be(kn),stroke_width:$A.default("0.1mm"),color:Y().optional()}).describe("Defines a polyline documentation note on the PCB"),YBt=OA({type:FA("pcb_note_line"),pcb_note_line_id:jt("pcb_note_line"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),text:Y().optional(),x1:wt,y1:wt,x2:wt,y2:wt,stroke_width:wt.default("0.1mm"),color:Y().optional(),is_dashed:Be().optional()}).describe("Defines a straight documentation note line on the PCB"),JBt=OA({type:FA("pcb_note_dimension"),pcb_note_dimension_id:jt("pcb_note_dimension"),pcb_component_id:Y().optional(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),name:Y().optional(),from:kn,to:kn,text:Y().optional(),text_ccw_rotation:VA().optional(),offset_distance:$A.optional(),offset_direction:OA({x:VA(),y:VA()}).optional(),font:FA("tscircuit2024").default("tscircuit2024"),font_size:$A.default("1mm"),color:Y().optional(),arrow_size:$A.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),TBt=OA({type:FA("pcb_footprint_overlap_error"),pcb_error_id:jt("pcb_error"),error_type:FA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:Y(),pcb_smtpad_ids:be(Y()).optional(),pcb_plated_hole_ids:be(Y()).optional(),pcb_hole_ids:be(Y()).optional(),pcb_keepout_ids:be(Y()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),KBt=OA({type:FA("pcb_keepout"),shape:FA("rect"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,width:wt,height:wt,pcb_keepout_id:Y(),layers:be(Y()),description:Y().optional()}).or(OA({type:FA("pcb_keepout"),shape:FA("circle"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,radius:wt,pcb_keepout_id:Y(),layers:be(Y()),description:Y().optional()})),B5=OA({type:FA("pcb_cutout"),pcb_cutout_id:jt("pcb_cutout"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),pcb_board_id:Y().optional(),pcb_panel_id:Y().optional()}),qBt=B5.extend({shape:FA("rect"),center:kn,width:$A,height:$A,rotation:md.optional(),corner_radius:$A.optional()}),PBt=B5.extend({shape:FA("circle"),center:kn,radius:$A}),OBt=B5.extend({shape:FA("polygon"),points:be(kn)}),WBt=B5.extend({shape:FA("path"),route:be(kn),slot_width:$A,slot_length:$A.optional(),space_between_slots:$A.optional(),slot_corner_radius:$A.optional()}),ZBt=Np("shape",[qBt,PBt,OBt,WBt]).describe("Defines a cutout on the PCB, removing board material."),VBt=OA({type:FA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:jt("pcb_missing_footprint_error"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),error_type:FA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:Y(),message:Y()}).describe("Defines a missing footprint error on the PCB"),jBt=OA({type:FA("external_footprint_load_error"),external_footprint_load_error_id:jt("external_footprint_load_error"),pcb_component_id:Y(),source_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),footprinter_string:Y().optional(),error_type:FA("external_footprint_load_error").default("external_footprint_load_error"),message:Y()}).describe("Defines an error when an external footprint fails to load"),zBt=OA({type:FA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:jt("circuit_json_footprint_load_error"),pcb_component_id:Y(),source_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),error_type:FA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:Y(),circuit_json:be(UI()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),XBt=OA({type:FA("pcb_group"),pcb_group_id:jt("pcb_group"),source_group_id:Y(),is_subcircuit:Be().optional(),subcircuit_id:Y().optional(),width:$A.optional(),height:$A.optional(),center:kn,display_offset_x:Y().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:Y().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:be(kn).optional(),anchor_position:kn.optional(),anchor_alignment:XG.default("center"),position_mode:lt(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:Y().optional(),positioned_relative_to_pcb_board_id:Y().optional(),pcb_component_ids:be(Y()),child_layout_mode:lt(["packed","none"]).optional(),name:Y().optional(),description:Y().optional(),layout_mode:Y().optional(),autorouter_configuration:OA({trace_clearance:$A}).optional(),autorouter_used_string:Y().optional()}).describe("Defines a group of components on the PCB"),$Bt=OA({type:FA("pcb_autorouting_error"),pcb_error_id:jt("pcb_autorouting_error"),error_type:FA("pcb_autorouting_error").default("pcb_autorouting_error"),message:Y(),subcircuit_id:Y().optional()}).describe("The autorouting has failed to route a portion of the board"),Alt=OA({type:FA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:jt("pcb_manual_edit_conflict_warning"),warning_type:FA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:Y(),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),source_component_id:Y()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),elt=OA({type:FA("pcb_breakout_point"),pcb_breakout_point_id:jt("pcb_breakout_point"),pcb_group_id:Y(),subcircuit_id:Y().optional(),source_trace_id:Y().optional(),source_port_id:Y().optional(),source_net_id:Y().optional(),x:wt,y:wt}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),tlt=OA({type:FA("pcb_ground_plane"),pcb_ground_plane_id:jt("pcb_ground_plane"),source_pcb_ground_plane_id:Y(),source_net_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Defines a ground plane on the PCB"),ilt=OA({type:FA("pcb_ground_plane_region"),pcb_ground_plane_region_id:jt("pcb_ground_plane_region"),pcb_ground_plane_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Mr,points:be(kn)}).describe("Defines a polygon region of a ground plane"),nlt=OA({type:FA("pcb_thermal_spoke"),pcb_thermal_spoke_id:jt("pcb_thermal_spoke"),pcb_ground_plane_id:Y(),shape:Y(),spoke_count:VA(),spoke_thickness:wt,spoke_inner_diameter:wt,spoke_outer_diameter:wt,pcb_plated_hole_id:Y().optional(),subcircuit_id:Y().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),SlA=OA({type:FA("pcb_copper_pour"),pcb_copper_pour_id:jt("pcb_copper_pour"),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Mr,source_net_id:Y().optional(),covered_with_solder_mask:Be().optional().default(!0)}),olt=SlA.extend({shape:FA("rect"),center:kn,width:$A,height:$A,rotation:md.optional()}),slt=SlA.extend({shape:FA("brep"),brep_shape:Lct}),rlt=SlA.extend({shape:FA("polygon"),points:be(kn)}),alt=Np("shape",[olt,slt,rlt]).describe("Defines a copper pour on the PCB."),glt=OA({type:FA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:jt("pcb_component_outside_board_error"),error_type:FA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:Y(),pcb_component_id:Y(),pcb_board_id:Y(),component_center:kn,component_bounds:OA({min_x:VA(),max_x:VA(),min_y:VA(),max_y:VA()}),subcircuit_id:Y().optional(),source_component_id:Y().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),Ilt=OA({type:FA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:jt("pcb_component_invalid_layer_error"),error_type:FA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:Y(),pcb_component_id:Y().optional(),source_component_id:Y(),layer:Mr,subcircuit_id:Y().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),clt=OA({type:FA("pcb_via_clearance_error"),pcb_error_id:jt("pcb_error"),error_type:FA("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:Y(),pcb_via_ids:be(Y()).min(2),minimum_clearance:wt.optional(),actual_clearance:wt.optional(),pcb_center:OA({x:VA().optional(),y:VA().optional()}).optional(),subcircuit_id:Y().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),Blt=OA({type:FA("pcb_courtyard_rect"),pcb_courtyard_rect_id:jt("pcb_courtyard_rect"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),center:kn,width:$A,height:$A,layer:Gw,color:Y().optional()}).describe("Defines a courtyard rectangle on the PCB"),llt=OA({type:FA("pcb_courtyard_outline"),pcb_courtyard_outline_id:jt("pcb_courtyard_outline"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Gw,outline:be(kn).min(2),stroke_width:$A.default("0.1mm"),is_closed:Be().optional(),is_stroke_dashed:Be().optional(),color:Y().optional()}).describe("Defines a courtyard outline on the PCB"),Clt=OA({type:FA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:jt("pcb_courtyard_polygon"),pcb_component_id:Y(),pcb_group_id:Y().optional(),subcircuit_id:Y().optional(),layer:Gw,points:be(kn).min(3),color:Y().optional()}).describe("Defines a courtyard polygon on the PCB"),Qlt=OA({type:FA("cad_component"),cad_component_id:Y(),pcb_component_id:Y(),source_component_id:Y(),position:mlA,rotation:mlA.optional(),size:mlA.optional(),layer:Mr.optional(),subcircuit_id:Y().optional(),footprinter_string:Y().optional(),model_obj_url:Y().optional(),model_stl_url:Y().optional(),model_3mf_url:Y().optional(),model_gltf_url:Y().optional(),model_glb_url:Y().optional(),model_step_url:Y().optional(),model_wrl_url:Y().optional(),model_unit_to_mm_scale_factor:VA().optional(),model_jscad:UI().optional(),show_as_translucent_model:Be().optional()}).describe("Defines a component on the PCB"),XZA=lt(["sinewave","square","triangle","sawtooth"]),Elt=Ai([Y(),VA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(VA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),hlt=OA({type:FA("simulation_voltage_source"),simulation_voltage_source_id:jt("simulation_voltage_source"),is_dc_source:FA(!0).optional().default(!0),positive_source_port_id:Y().optional(),negative_source_port_id:Y().optional(),positive_source_net_id:Y().optional(),negative_source_net_id:Y().optional(),voltage:K_}).describe("Defines a DC voltage source for simulation"),ult=OA({type:FA("simulation_voltage_source"),simulation_voltage_source_id:jt("simulation_voltage_source"),is_dc_source:FA(!1),terminal1_source_port_id:Y().optional(),terminal2_source_port_id:Y().optional(),terminal1_source_net_id:Y().optional(),terminal2_source_net_id:Y().optional(),voltage:K_.optional(),frequency:c5.optional(),peak_to_peak_voltage:K_.optional(),wave_shape:XZA.optional(),phase:md.optional(),duty_cycle:Elt.optional()}).describe("Defines an AC voltage source for simulation"),dlt=Ai([hlt,ult]).describe("Defines a voltage source for simulation"),plt=Ai([Y(),VA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(VA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),flt=OA({type:FA("simulation_current_source"),simulation_current_source_id:jt("simulation_current_source"),is_dc_source:FA(!0).optional().default(!0),positive_source_port_id:Y().optional(),negative_source_port_id:Y().optional(),positive_source_net_id:Y().optional(),negative_source_net_id:Y().optional(),current:flA}).describe("Defines a DC current source for simulation"),ylt=OA({type:FA("simulation_current_source"),simulation_current_source_id:jt("simulation_current_source"),is_dc_source:FA(!1),terminal1_source_port_id:Y().optional(),terminal2_source_port_id:Y().optional(),terminal1_source_net_id:Y().optional(),terminal2_source_net_id:Y().optional(),current:flA.optional(),frequency:c5.optional(),peak_to_peak_current:flA.optional(),wave_shape:XZA.optional(),phase:md.optional(),duty_cycle:plt.optional()}).describe("Defines an AC current source for simulation"),mlt=Ai([flt,ylt]).describe("Defines a current source for simulation"),wlt=Ai([FA("spice_dc_sweep"),FA("spice_dc_operating_point"),FA("spice_transient_analysis"),FA("spice_ac_analysis")]),Dlt=OA({type:FA("simulation_experiment"),simulation_experiment_id:jt("simulation_experiment"),name:Y(),experiment_type:wlt,time_per_step:ylA.optional(),start_time_ms:q_.optional(),end_time_ms:q_.optional()}).describe("Defines a simulation experiment configuration"),Slt=OA({type:FA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:jt("simulation_transient_voltage_graph"),simulation_experiment_id:Y(),timestamps_ms:be(VA()).optional(),voltage_levels:be(VA()),source_component_id:Y().optional(),subcircuit_connectivity_map_key:Y().optional(),time_per_step:ylA,start_time_ms:q_,end_time_ms:q_,name:Y().optional(),color:Y().optional()}).describe("Stores voltage measurements over time for a simulation"),blt=OA({type:FA("simulation_switch"),simulation_switch_id:jt("simulation_switch"),source_component_id:Y().optional(),closes_at:q_.optional(),opens_at:q_.optional(),starts_closed:Be().optional(),switching_frequency:c5.optional()}).describe("Defines a switch for simulation timing control"),xlt=OA({type:FA("simulation_voltage_probe"),simulation_voltage_probe_id:jt("simulation_voltage_probe"),source_component_id:Y().optional(),name:Y().optional(),signal_input_source_port_id:Y().optional(),signal_input_source_net_id:Y().optional(),reference_input_source_port_id:Y().optional(),reference_input_source_net_id:Y().optional(),subcircuit_id:Y().optional(),color:Y().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,n=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&n?A.addIssue({code:Wt.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:Wt.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):n&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:Wt.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:Wt.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),klt=OA({type:FA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:jt("simulation_unknown_experiment_error"),error_type:FA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:Y(),simulation_experiment_id:Y().optional(),subcircuit_id:Y().optional()}).describe("An unknown error occurred during the simulation experiment."),Glt=OA({type:FA("simulation_op_amp"),simulation_op_amp_id:jt("simulation_op_amp"),source_component_id:Y().optional(),inverting_input_source_port_id:Y(),non_inverting_input_source_port_id:Y(),output_source_port_id:Y(),positive_supply_source_port_id:Y(),negative_supply_source_port_id:Y()}).describe("Defines a simple ideal operational amplifier for simulation");Ai([Act,XIt,$It,zIt,tct,ect,bZA,wZA,wlA,SZA,DZA,xZA,kZA,GZA,NZA,_ZA,MZA,YZA,vZA,UZA,LZA,HZA,RZA,FZA,nct,sct,ict,JZA,TZA,KZA,rct,act,Jct,Tct,VBt,jBt,zBt,Alt,Vct,KBt,jct,dBt,IBt,CBt,pBt,iBt,gBt,fBt,yBt,XBt,wBt,DBt,SBt,bBt,RBt,xBt,kBt,GBt,FBt,QBt,EBt,mBt,hBt,uBt,clt,_Bt,NBt,MBt,vBt,UBt,LBt,HBt,YBt,JBt,$Bt,TBt,elt,ZBt,tlt,ilt,nlt,alt,glt,Ilt,Blt,llt,Clt,gct,yct,Ect,hct,uct,dct,Qct,mct,pct,Ict,Dct,Sct,wct,Gct,Fct,Rct,Nct,vct,_ct,Mct,Qlt,dlt,mlt,Dlt,Slt,blt,xlt,klt,Glt]);var Flt=Object.defineProperty,Rlt=(t,A)=>{for(var e in A)Flt(t,e,{get:A[e],enumerable:!0})},cS={};Rlt(cS,{axial:()=>eQt,bga:()=>ICt,breakoutheaders:()=>CQt,cap:()=>Hlt,dfn:()=>vCt,diode:()=>Llt,dip:()=>Mlt,electrolytic:()=>zht,hc49:()=>EQt,jst:()=>dht,led:()=>Ylt,lqfp:()=>BQt,m2host:()=>uut,melf:()=>xEt,micromelf:()=>REt,minimelf:()=>pEt,mlp:()=>dCt,ms012:()=>KCt,ms013:()=>PCt,msop:()=>kht,pad:()=>hQt,pinrow:()=>HCt,platedhole:()=>gut,potentiometer:()=>Zht,pushbutton:()=>sQt,qfn:()=>ECt,qfp:()=>uCt,quad:()=>O_,radial:()=>nQt,res:()=>rCt,sma:()=>vEt,smb:()=>qEt,smbf:()=>$ht,smc:()=>ZEt,smf:()=>YEt,smtpad:()=>rut,sod110:()=>fht,sod123:()=>zCt,sod123f:()=>XQt,sod123fl:()=>tEt,sod123w:()=>RQt,sod128:()=>IEt,sod323:()=>vQt,sod323f:()=>ZQt,sod323fl:()=>Mht,sod323w:()=>Fht,sod523:()=>yQt,sod723:()=>sEt,sod80:()=>xQt,sod882:()=>qQt,sod882d:()=>wEt,sod923:()=>YQt,soic:()=>BCt,solderjumper:()=>Yht,son:()=>Hht,sop8:()=>SQt,sot:()=>cut,sot223:()=>XEt,sot23:()=>kCt,sot23w:()=>rht,sot25:()=>NCt,sot323:()=>iut,sot343:()=>Cut,sot363:()=>DCt,sot457:()=>Kht,sot563:()=>JCt,sot723:()=>WCt,sot886:()=>bCt,sot89:()=>EEt,sot963:()=>Pht,ssop:()=>fCt,stampboard:()=>aQt,stampreceiver:()=>cQt,to220:()=>uEt,to92:()=>pQt,to92l:()=>put,to92s:()=>lht,tqfp:()=>hCt,tssop:()=>mCt,vssop:()=>Sht});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=OA({norefdes:Be().optional().describe("disable reference designator label"),invert:Be().optional().describe("hint to invert the orientation of the 3D model"),faceup:Be().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:Be().optional().describe("omit all silkscreen elements from the footprint")}),Oo=(t,A,e,i,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:e,hole_diameter:mr(i),outer_diameter:mr(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),BS=(t,A,e,i,n,o,s,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:A,y:e,hole_diameter:mr(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:mr(n),rect_pad_height:mr(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],hole_offset_x:s,hole_offset_y:r}),$ZA=Array.from({length:9},(t,A)=>Math.cos(A/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)}));function Dx(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var l5=Ai([Y(),VA()]).transform(t=>Dx(t)),Nlt=t=>Hi.extend({fn:Y(),num_pins:VA().optional().default(6),wide:Be().optional(),narrow:Be().optional(),w:l5.optional(),p:l5.default(t.p??"2.54mm"),id:l5.optional(),od:l5.optional(),nosquareplating:Be().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=Dx("0.55mm"),A.od=Dx("0.95mm")):(A.id=Dx("0.8mm"),A.od=Dx("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=Dx("600mil"):A.narrow?A.w=Dx("300mil"):A.w=Dx(t.w??"300mil")),A)),_lt=Nlt({}),AVA=(t,A,e,i,n)=>{const o=t/2,s=A<=o,r=o-1,a=i,g=a*r;return s?{x:-e/2,y:g/2-(A-1)*a}:{x:e/2,y:-g/2+(A-o-1)*a}},Mlt=t=>{const A=_lt.parse(t),e=[];for(let g=0;g<A.num_pins;g++){const{x:I,y:c}=AVA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating);if(g===0&&!A.nosquareplating){e.push(BS(g+1,I,c,A.id??"0.8mm",A.od??"1mm",A.od??"1mm"));continue}e.push(Oo(g+1,I,c,A.id??"0.8mm",A.od??"1mm"))}(A.num_pins/2-1)*A.p+A.od;const n=A.w-A.od-1,o=(A.num_pins/2-1)*A.p+A.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/2,y:-o/2},{x:-n/2,y:o/2},...$ZA.map(({x:g,y:I})=>({x:g*n/6,y:I*n/6+o/2})),{x:n/2,y:o/2},{x:n/2,y:-o/2},{x:-n/2,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1},r=[];for(let g=0;g<A.num_pins;g++){const I=g<A.num_pins/2,c=.6,{y:B}=AVA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating),l=I?-A.w/2-A.od/2-c:A.w/2+A.od/2+c,C=B;r.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${g+1}`,layer:"top",pcb_component_id:`pin_${g+1}`,text:`{pin${g+1}}`,anchor_position:{x:l,y:C},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Li(0,o/2+.5,.4);return{circuitJson:[...e,s,a,...r],parameters:A}},Qi=(t,A,e,i,n)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:n,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),eVA=[{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}],vlt=Object.fromEntries(eVA.map(t=>[t.metric,t])),Ult=Object.fromEntries(eVA.map(t=>[t.imperial,t]));Hi.extend({tht:Be(),p:$A.optional(),pw:$A.optional(),ph:$A.optional(),metric:wt.optional(),imperial:wt.optional(),w:$A.optional(),h:$A.optional(),textbottom:Be().optional()});var C5=t=>{let{tht:A,p:e,pw:i,ph:n,metric:o,imperial:s,w:r,h:a,textbottom:g}=t;if(typeof r=="string"&&(r=mB(r)),typeof a=="string"&&(a=mB(a)),typeof e=="string"&&(e=mB(e)),typeof i=="string"&&(i=mB(i)),typeof n=="string"&&(n=mB(n)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let I;if(o&&(I=vlt[o]),s&&(I=Ult[s]),I&&(r=I.w_mm_min,a=I.h_mm_min,e=I.p_mm_min,i=I.pw_mm_min,n=I.ph_mm_min),e===void 0||i===void 0||n===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:e/2,y:n/2+.4},{x:-e/2-i/2-.2,y:n/2+.4},{x:-e/2-i/2-.2,y:-n/2-.4},{x:e/2,y:-n/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},B=g?-n/2-.9:n/2+.9,l=Li(0,B,.2);return A?[Oo(1,-e/2,0,i,i*1/.8),Oo(2,e/2,0,i,i*1/.8),c,l]:[Qi(["1","left"],-e/2,0,i,n),Qi(["2","right"],e/2,0,i,n),c,l]},Llt=t=>({circuitJson:C5(t),parameters:t}),Hlt=t=>({circuitJson:C5(t),parameters:t}),Ylt=t=>({circuitJson:C5(t),parameters:t}),P_=t=>{const{padSpacing:A,padWidth:e,padHeight:i,padPitch:n,numRows:o,textbottom:s}=t,r=[],a=(o-1)*(n/2);for(let x=0;x<o;x++)r.push(a-x*n);const g=[];r.forEach((x,F)=>{g.push(Qi(F+1,-A/2,x,e,i))}),r.slice().reverse().forEach((x,F)=>{g.push(Qi(F+o+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,l=A/2+e/2+.4,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l*.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:l*.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,w={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},S=s?c-.9:I+.9,D=Li(0,S,.2);return[...g,C,Q,w,D]},Jlt=Hi.extend({pw:Y().default("0.5mm"),ph:Y().default("0.4mm"),p:Y().default("0.7mm"),textbottom:Be().optional()}),Tlt=1,Klt=t=>{const A=Jlt.parse(t),e=mB(A.pw),i=mB(A.ph),n=mB(A.p);return P_({padSpacing:Tlt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom})},qlt=Hi.extend({pw:Y().default("0.5mm"),ph:Y().default("0.32mm"),p:Y().default("0.5mm"),textbottom:Be().optional()}),Plt=1,Olt=t=>{const A=qlt.parse(t),e=mB(A.pw),i=mB(A.ph),n=mB(A.p);return P_({padSpacing:Plt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom})},Wlt=Hi.extend({pw:Y().default("0.9mm"),ph:Y().default("0.4mm"),p:Y().default("0.8mm"),textbottom:Be().optional()}),Zlt=1.7,Vlt=t=>{const A=Wlt.parse(t),e=mB(A.pw),i=mB(A.ph),n=mB(A.p);return P_({padSpacing:Zlt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom})},jlt=Hi.extend({pw:Y().default("0.9mm"),ph:Y().default("0.4mm"),p:Y().default("0.8mm"),textbottom:Be().optional()}),zlt=1.7,Xlt=t=>{const A=jlt.parse(t),e=mB(A.pw),i=mB(A.ph),n=mB(A.p);return P_({padSpacing:zlt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom})},$lt=Hi.extend({pw:Y().default("0.7mm"),ph:Y().default("0.64mm"),p:Y().default("0.94mm"),textbottom:Be().optional()}),ACt=1.4,eCt=t=>{const A=$lt.parse(t),e=mB(A.pw),i=mB(A.ph),n=mB(A.p);return P_({padSpacing:ACt,padWidth:e,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom})},tCt=Hi.extend({pw:Y().default("0.9mm"),ph:Y().default("0.9mm"),p:Y().default("1.34mm"),textbottom:Be().optional()}),iCt=3,nCt=t=>{const A=tCt.parse(t),e=mB(A.pw),i=mB(A.ph),n=mB(A.p);return P_({padSpacing:iCt,padWidth:e,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom})},oCt=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)}},sCt=t=>t?(typeof t=="number"?`${t}`:t).split("_")[0]:void 0,rCt=t=>{const A=oCt(t),e=sCt(t.imperial);return A===2&&e==="0402"?{circuitJson:Klt(t),parameters:t}:A===4&&e==="0402"?{circuitJson:Olt(t),parameters:t}:A===2&&e==="0603"?{circuitJson:Vlt(t),parameters:t}:A===4&&e==="0603"?{circuitJson:Xlt(t),parameters:t}:A===2&&e==="0606"?{circuitJson:eCt(t),parameters:t}:A===4&&e==="1206"?{circuitJson:nCt(t),parameters:t}:{circuitJson:C5(t),parameters:t}},tVA=(t,{x:A,y:e,radius:i})=>({type:"pcb_smtpad",x:A,y:e,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),iVA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",nVA=Y().transform(t=>{const[A,e]=t.split(/[x ]/);return{x:parseFloat(A),y:parseFloat(e)}}).pipe(OA({x:VA(),y:VA()})),aCt=Y().or(be(UI())).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(Y().or(VA()))),gCt=Hi.extend({fn:Y(),num_pins:VA().optional().default(64),grid:nVA.optional(),p:wt.default("0.8mm"),w:$A.optional(),h:$A.optional(),ball:$A.optional().describe("ball diameter"),pad:$A.optional().describe("pad width/height"),circularpads:Be().optional().describe("use circular pads"),tlorigin:Be().optional(),blorigin:Be().optional(),trorigin:Be().optional(),brorigin:Be().optional(),missing:aCt.default([])}).transform(t=>{let A="tl";if(t.blorigin&&(A="bl"),t.trorigin&&(A="tr"),t.brorigin&&(A="br"),!t.grid){const i=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:i,y:i}}return t.missing&&(t.missing=t.missing.map(i=>{if(typeof i=="number")return i;if(i==="center")return"center";if(i==="topleft")return"topleft";const n=i.match(/([A-Z]+)(\d+)/);if(!n)return i;const o=iVA.indexOf(n[1]),s=Number.parseInt(n[2])-1;return o*t.grid.x+s+1})),{...t,origin:A}}),ICt=t=>{const A=gCt.parse(t);let{num_pins:e,grid:i,p:n,w:o,h:s,ball:r,pad:a,missing:g}=A;r??=.75/1.27*n,a??=r*.8;const I=[],c=(g??[]).filter(w=>typeof w=="number"),B=i.x*i.y-e;if(g.length===0&&B>0&&(Math.sqrt(B)%1===0?g.push("center"):B===1&&g.push("topleft")),g?.includes("center")){const w=Math.floor(Math.sqrt(B)),S=Math.floor((i.x-w)/2),D=Math.floor((i.y-w)/2);for(let x=D;x<D+w;x++)for(let F=S;F<S+w;F++)c.push(x*i.x+F+1)}g?.includes("topleft")&&c.push(1);const l=new Set(c);let C=0;for(let w=0;w<i.y;w++)for(let S=0;S<i.x;S++){const D=(S-(i.x-1)/2)*n,x=(w-(i.y-1)/2)*n;let F=S,k=w;switch(A.origin){case"bl":F=S,k=i.y-1-w;break;case"br":F=i.x-1-S,k=i.y-1-w;break;case"tr":F=i.x-1-S,k=w;break}let v=k*i.x+F+1;if(l.has(v)){C++;continue}v-=C;const _=[v,`${iVA[k]}${F+1}`];I.push(A.circularpads?tVA(_,{x:D,y:x,radius:a/2}):Qi(_,D,x,a,a))}const Q=Li(0,i.y*n/2,.2),E=n/6;let h;const u=i.x*n/2,d=i.y*n/2;switch(A.origin){case"bl":h=[{x:-u,y:-d},{x:-u,y:-d-E},{x:-u-E,y:-d},{x:-u,y:-d}];break;case"br":h=[{x:u,y:-d},{x:u,y:-d-E},{x:u+E,y:-d},{x:u,y:-d}];break;case"tr":h=[{x:u,y:d},{x:u,y:d+E},{x:u+E,y:d},{x:u,y:d}];break;default:h=[{x:-u,y:d},{x:-u,y:d+E},{x:-u-E,y:d},{x:-u,y:d}];break}const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:h,stroke_width:.05};return{circuitJson:[...I,Q,f],parameters:A}},Q5=(t,A,e,i,n)=>({type:"pcb_smtpad",x:A,y:e,width:i,height:n,radius:n/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),Fw=t=>Hi.extend({fn:Y(),num_pins:VA().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:Be().optional().default(t.legsoutside??!1),pillpads:Be().optional().default(t.pillpads??!1),silkscreen_stroke_width:VA().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)),cCt=Fw({}),blA=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:A,pn:e,w:i,p:n,pl:o,legsoutside:s}=t,r=A/2,a=e<=r,g=r-1,I=n,c=I*g,B=s?o/2:-o/2;return a?{x:-i/2-B,y:c/2-(e-1)*I}:{x:i/2+B,y:-c/2+(e-r-1)*I}},BCt=t=>{const A=cCt.parse(t);return{circuitJson:Sx(A),parameters:A}},Sx=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=blA({num_pins:t.num_pins,pn:r+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?A.push(Q5(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,n=(t.num_pins/2-1)*t.p+t.pw+e,o=Li(0,n/2+.4,n/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:t.silkscreen_stroke_width??.1,route:[{x:-i/2,y:-n/2},{x:-i/2,y:n/2},...$ZA.map(({x:r,y:a})=>({x:r*i/6,y:a*i/6+n/2})),{x:i/2,y:n/2},{x:i/2,y:-n/2},{x:-i/2,y:-n/2}]};return[...A,s,o]},oVA=lt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),lCt=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const n=[],o=t/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=o:r.bottomside&&r.leftpin?s=o+1:r.bottomside&&r.rightpin?s=o*2:r.rightside&&r.bottompin?s=o*2+1:r.rightside&&r.toppin?s=o*3:r.topside&&r.rightpin?s=o*3+1:r.topside&&r.leftpin&&(s=o*4),n.push(-1);for(let a=0;a<t;a++)n[s]=a+1,e||!A?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return n},xlA=Hi.extend({fn:Y(),cc:Be().default(!0).optional(),ccw:Be().default(!0).optional(),startingpin:Y().or(be(oVA)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(be(oVA)).optional(),num_pins:VA().optional().default(64),w:$A.optional(),h:$A.optional(),p:$A.default($A.parse("0.5mm")),pw:$A.optional(),pl:$A.optional(),thermalpad:Ai([FA(!0),nVA]).optional(),legsoutside:Be().default(!1)}),klA=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},sVA=xlA.transform(klA),CCt=["left","bottom","right","top"],QCt=t=>{const{pin_count:A,pn:e,w:i,h:n,p:o,pl:s,legsoutside:r}=t,a=A/4,g=CCt[Math.floor((e-1)/a)],I=(e-1)%a,c=o*(a-1),B=o*(a-1),l=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-l+.1,y:B/2-I*o,o:"vert"};case"bottom":return{x:-c/2+I*o,y:-n/2-l+.1,o:"horz"};case"right":return{x:i/2+l-.1,y:-B/2+I*o,o:"vert"};case"top":return{x:c/2-I*o,y:n/2+l-.1,o:"horz"};default:throw new Error("Invalid pin number")}},O_=t=>{const A=sVA.parse(t),e=[],i=lCt(A),n=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:I}=QCt({pin_count:A.num_pins,pn:r+1,w:A.w,h:A.h,p:A.p??.5,pl:A.pl,legsoutside:A.legsoutside});let c=A.pw,B=A.pl;I==="vert"&&([c,B]=[B,c]);const l=i[r+1];e.push(Qi(l,a,g,c,B))}if(A.thermalpad)if(typeof A.thermalpad=="boolean"){const r=A.p*(n-1)+A.pw,a=A.p*(n-1)+A.pw;e.push(Qi(["thermalpad"],0,0,r,a))}else e.push(Qi(["thermalpad"],0,0,A.thermalpad.x,A.thermalpad.y));const o=[];for(const[r,a,g]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const I=A.w/2*a,c=A.h/2*g;let B="none",l=I,C=c;const Q=A.pw*2;i[1]===1&&r==="top-left"?B="in1":i[n*4]===1&&r==="top-left"||i[n*3+1]===1&&r==="top-right"?B="in2":i[n*3]===1&&r==="top-right"||i[n]===1&&r==="bottom-left"?B="in1":i[n+1]===1&&r==="bottom-left"?B="in2":i[n*2]===1&&r==="bottom-right"?B="in1":i[n*2+1]===1&&r==="bottom-right"&&(B="in2");const E=B==="in1"?1:-1;if(A.legsoutside){const h=B==="in1"?A.pl/2:A.pw/2,u=B==="in1"?A.pw/2:A.pl/2;l+=h*a*E,C-=u*g*E}(B==="none"||A.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:I-Q*a,y:c},{x:I,y:c},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&!A.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:I-Q*a,y:c},{x:I-Q*a/2,y:c}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:I,y:c-Q*g/2},{x:I,y:c-Q*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(B==="in1"||B==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:l-.2*-a,y:C+.2*E},{x:l,y:C},{x:l+.2*E*-a,y:C+.2},{x:l-.2*-a,y:C+.2*E}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Li(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...e,...o,s],parameters:A}};xlA.extend({}).transform(klA);var ECt=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),O_(t)),hCt=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 O_(t)},uCt=t=>{t.legsoutside=!0;const A=sVA.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 O_(t)};xlA.extend({}).transform(klA);var dCt=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),O_(t)),pCt=Fw({w:"3.9mm",p:"1.27mm"}),fCt=t=>{const A=pCt.parse(t);return{circuitJson:Sx(A),parameters:A}},yCt=Fw({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),mCt=t=>{const A=yCt.parse(t);return{circuitJson:Sx(A),parameters:A}},wCt=Fw({}),DCt=t=>{const A=wCt.parse({fn:"sot363",num_pins:6,w:2.56,p:.65,pw:.4,pl:.65,legoutside:!0});return{circuitJson:Sx(A),parameters:A}},SCt=Hi.extend({fn:Y(),num_pins:FA(6).default(6),w:Y().default("1.01mm"),h:Y().default("1.45mm"),p:Y().default("0.5mm"),pl:Y().default("0.33mm"),pw:Y().default("0.27mm"),string:Y().optional()}),bCt=t=>{const A=SCt.parse({fn:"sot886",...t}),e=$A.parse(A.w),i=$A.parse(A.h),n=$A.parse(A.p),o=$A.parse(A.pl),s=$A.parse(A.pw),r=[];for(let l=0;l<6;l++){const{x:C,y:Q}=rVA(l+1,e,n,o);r.push(Qi(l+1,C,Q,o,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=rVA(1,e,n,o),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-o/2-.3,y:I.y},{x:I.x-o/2-.45,y:I.y+.15},{x:I.x-o/2-.45,y:I.y-.15},{x:I.x-o/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}},rVA=(t,A,e,i)=>{const n=A/2-i/2;return t<=3?{x:-n,y:e-(t-1)*e}:{x:n,y:-e+(t-4)*e}},aVA=Hi.extend({fn:Y(),num_pins:VA().default(3),w:Y().default("1.92mm"),h:Y().default("2.74mm"),pl:Y().default("1.32mm"),pw:Y().default("0.6mm"),p:Y().default("0.95mm"),string:Y().optional()}),xCt=Fw({p:"0.95mm",w:"1.6mm",legsoutside:!0}),kCt=t=>{const A=t.string?.match(/^sot23_(\d+)/),e=A?Number.parseInt(A[1],10):3;if(e===6||e===8){const n=xCt.parse({...t,num_pins:e});return{circuitJson:Sx(n),parameters:n}}const i=aVA.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:FCt(i),parameters:i};if(i.num_pins===5)return{circuitJson:IVA(i),parameters:i};throw new Error("Invalid number of pins")},GCt=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}},FCt=t=>{const A=[];for(let i=0;i<t.num_pins;i++){const{x:n,y:o}=GCt({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,n,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=Li(0,Number.parseInt(t.h),.3);return[...A,e]},gVA=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")},IVA=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:l}=gVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(Qi(c,B,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=(t.num_pins+1)/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Li(0,i+.3,.3),r=gVA({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,n,o,I]},RCt=aVA.extend({}),NCt=t=>{const A=RCt.parse({...t,num_pins:5});return{circuitJson:IVA(A),parameters:A}},_Ct=[{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}],MCt=Fw({}),vCt=t=>{const A=MCt.parse(t),e=[];for(let c=0;c<A.num_pins;c++){const{x:B,y:l}=blA({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,l,A.pl??"1mm",A.pw??"0.6mm"))}const i=Math.min(1,A.p/2),n=A.w+i,o=(A.num_pins/2-1)*A.p+A.pw+i,s=[];for(const c of _Ct){const{dx:B,dy:l}=c;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:B*n/2-B*A.p,y:l*o/2},{x:B*n/2,y:l*o/2},{x:B*n/2,y:l*o/2-l*A.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const r=A.p/4,a=-n/2-r/2,g=o/2-A.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:a,y:g},{x:a-r,y:g+r},{x:a-r,y:g-r},{x:a,y:g}],stroke_width:.1});const I=Li(0,o/2+.4,o/12);return{circuitJson:[...e,I,...s],parameters:A}},GlA=({fs:t,pn:A,anchor_x:e,anchor_y:i,textalign:n="center",orthogonal:o=!1,verticallyinverted:s=!1,layer:r="top"})=>{let a=0;o&&s?a=270:s?a=180:o?a=90:a=0;let g="center";return n==="left"&&(s?g="center_right":g="center_left"),n==="right"&&(s?g="center_left":g="center_right"),r==="bottom"&&(g==="center_left"?g="center_right":g==="center_right"&&(g="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:`{PIN${A}}`,layer:r,anchor_position:{x:e,y:i},anchor_alignment:g,ccw_rotation:a}};function UCt({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 LCt=Hi.extend({fn:Y(),num_pins:VA().optional().default(6),rows:Ai([Y(),VA()]).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:Be().optional().describe("for male pin headers"),female:Be().optional().describe("for female pin headers"),smd:Be().optional().describe("surface mount device"),surfacemount:Be().optional().describe("surface mount device (verbose)"),rightangle:Be().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:Be().optional().default(!1),pinlabeltextaligncenter:Be().optional().default(!1),pinlabeltextalignright:Be().optional().default(!1),pinlabelverticallyinverted:Be().optional().default(!1),pinlabelorthogonal:Be().optional().default(!1),nosquareplating:Be().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Be().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Be().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Be().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const A=UCt(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"]})}),HCt=t=>{const A=LCt.parse(t),{p:e,id:i,od:n,rows:o,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:I,pinlabeltextalignright:c,nopinlabels:B,doublesidedpinlabel:l,bottomsidepinlabel:C}=A;let Q="center";I?Q="left":c&&(Q="right");const E=[],h=Math.ceil(s/o),u=-e,d=({xoff:x,yoff:F,od:k,anchorSide:v,smd:_,pw:L,pl:K})=>{let J=0,W=0;if(_){const Z=k/5;switch(v){case"right":J=L/2+Z;break;case"top":W=K/2+Z;break;case"bottom":W=-(K/2+Z);break;case"left":J=-(L/2+Z);break}}else{const Z=k*.75;switch(v){case"right":J=Z;break;case"top":W=Z;break;case"bottom":W=-Z;break;case"left":J=-Z;break}}return{anchor_x:x+J,anchor_y:F+W}},f=(x,F,k)=>{A.smd?E.push(Qi(x,F,k,A.pw,A.pl)):x===1&&!A.nosquareplating?E.push(BS(x,F,k,i,n,n,0,0)):E.push(Oo(x,F,k,i,n));const{anchor_x:v,anchor_y:_}=d({xoff:F,yoff:k,od:n,anchorSide:r,smd:A.smd,pw:A.pw,pl:A.pl});B||(C?E.push(GlA({fs:n/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):E.push(GlA({fs:n/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),l&&E.push(GlA({fs:n/5,pn:x,anchor_x:v,anchor_y:_,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},w=new Set,S=o>2&&h>2;if(o===1){const x=-((s-1)/2)*e;for(let F=0;F<s;F++){const k=F+1,v=x+F*e,_=`${v},0`;if(w.has(_))throw new Error(`Overlap at ${_}`);w.add(_),f(k,v,0)}}else if(S){const x=-((h-1)/2)*e;let F=1;for(let k=0;k<o&&F<=s;k++)for(let v=0;v<h&&F<=s;v++){const _=x+v*e,L=k*u,K=`${_},${L}`;if(w.has(K))throw new Error(`Overlap at ${K}`);w.add(K),f(F++,_,L)}}else{const x=-((h-1)/2)*e;let F=1,k=0,v=o-1,_=0,L=h-1;for(;F<=s&&k<=v&&_<=L;){for(let K=k;K<=v&&F<=s;K++){const J=x+_*e,W=K*u,Z=`${J},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,J,W)}_++;for(let K=_;K<=L&&F<=s;K++){const J=x+K*e,W=v*u,Z=`${J},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,J,W)}if(v--,_<=L){for(let K=v;K>=k&&F<=s;K--){const J=x+L*e,W=K*u,Z=`${J},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,J,W)}L--}if(k<=v){for(let K=L;K>=_&&F<=s;K--){const J=x+K*e,W=k*u,Z=`${J},${W}`;if(w.has(Z))throw new Error(`Overlap at ${Z}`);w.add(Z),f(F++,J,W)}k++}}if(F-1<s)throw new Error(`Missing pins: assigned ${F-1}, expected ${s}`)}const D=Li(0,e,.5);return{circuitJson:[...E,D],parameters:A}},YCt=Hi.extend({fn:Y(),num_pins:FA(6).default(6),w:Y().default("2.1mm"),h:Y().default("2.45mm"),p:Y().default("0.5mm"),pl:Y().default("0.675mm"),pw:Y().default("0.35mm"),string:Y().optional()}),JCt=t=>{const A=YCt.parse({...t,fn:"sot563"}),e=$A.parse(A.w),i=$A.parse(A.h),n=$A.parse(A.p),o=$A.parse(A.pl),s=$A.parse(A.pw),r=[];for(let l=0;l<6;l++){const{x:C,y:Q}=cVA(l+1,e,n,o);r.push(Qi(l+1,C,Q,o,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=cVA(1,e,n,o),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-o/2-.3,y:I.y},{x:I.x-o/2-.45,y:I.y+.15},{x:I.x-o/2-.45,y:I.y-.15},{x:I.x-o/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}},cVA=(t,A,e,i)=>{const n=A/2-i/2;return t<=3?{x:-n,y:e-(t-1)*e}:{x:n,y:-e+(t-4)*e}},TCt=Fw({p:"1.27mm",w:"3.9mm",legsoutside:!0}),KCt=t=>{const A=TCt.parse({...t,num_pins:8});return{circuitJson:Sx(A),parameters:A}},qCt=Fw({p:"1.27mm",w:"7.5mm",legsoutside:!0}),PCt=t=>{const A=qCt.parse({...t,num_pins:16});return{circuitJson:Sx(A),parameters:A}},OCt=Hi.extend({fn:Y(),num_pins:FA(3).default(3),w:Y().default("1.2mm"),h:Y().default("1.2mm"),pw:Y().default("0.40mm"),pl:Y().default("0.45mm"),p:Y().default("0.575mm")}),WCt=t=>{const A=OCt.parse(t),e=VCt(A),i=Li(0,$A.parse(A.h),.2);return{circuitJson:[...e,i],parameters:A}},ZCt=t=>{const{pn:A,p:e}=t;return A===1?{x:e,y:0}:A===2?{x:-e,y:-.4}:{x:-e,y:.4}},VCt=t=>{const A=[];for(let e=0;e<3;e++){const{x:i,y:n}=ZCt({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,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},jCt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("2.36mm"),h:Y().default("1.22mm"),pl:Y().default("0.9mm"),pw:Y().default("1.2mm"),p:Y().default("3.30mm")}),zCt=t=>{const A=jCt.parse(t),e=Li(0,$A.parse(A.h)/4+.4,.3);return{circuitJson:$Ct(A).concat(e),parameters:A}},XCt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},$Ct=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=XCt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},AQt=Hi.extend({fn:Y(),p:$A.optional().default("2.54mm"),id:$A.optional().default("0.7mm"),od:$A.optional().default("1.4mm")}),eQt=t=>{const A=AQt.parse(t),{p:e,id:i,od:n}=A,o=[Oo(1,-e/2,0,i,n),Oo(2,e/2,0,i,n)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2+n+i/2,y:0},{x:e/2-n-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},r=Li(0,1.5,.5);return{circuitJson:[...o,s,r],parameters:A}},tQt=(t,A,e,i,n,o=.1)=>{const s=[],r=[],a=Math.max(1,Math.ceil(Math.PI*e/o)),g=Math.PI/a;for(let I=0;I<=a;I++){const c=I*g,B=t+Math.cos(c)*e,l=A+Math.sin(c)*e;B<t-i&&l>=A-n/2&&l<=A+n/2||s.push({x:B,y:l})}for(let I=0;I<=a;I++){const c=Math.PI+I*g,B=t+Math.cos(c)*e,l=A+Math.sin(c)*e;B<t-i&&l>=A-n/2&&l<=A+n/2||r.push({x:B,y:l})}return{topArc:s,bottomArc:r}},iQt=Hi.extend({fn:Y(),p:$A.optional().default("5mm"),id:$A.optional().default("0.8mm"),od:$A.optional().default("1.6mm"),ceramic:Be().optional(),electrolytic:Be().optional(),polarized:Be().optional()}),nQt=t=>{const A=iQt.parse(t),{p:e,id:i,od:n}=A;i===.8&&n===1.6&&(A.id=e===5?.8:e*.25,A.od=e===5?1.6:e*.5);const o=[Oo(1,-e/2,0,A.id,A.od),Oo(2,e/2,0,A.id,A.od)],s=e+.1,{topArc:r,bottomArc:a}=tQt(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:""},l=.1*e,C=-(e+l+.04*e),Q=s-l-.08*e,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C-l,y:Q},{x:C+l,y:Q}],stroke_width:g,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C,y:Q-l},{x:C,y:Q+l}],stroke_width:g,pcb_silkscreen_path_id:""},u=Li(0,s+.12*e,.1*e),d=[...o,I,c,B,u];return(A.electrolytic===!0||A.polarized===!0)&&d.push(E,h),{circuitJson:d,parameters:A}},E5=(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}),oQt=Hi.extend({fn:FA("pushbutton"),w:$A.default(4.5),h:$A.default(6.5),id:$A.default(1),od:$A.default(1.2)}),sQt=t=>{const A=oQt.parse(t),e=A.w,i=A.h,n=A.id,o=[Oo(1,-e/2,i/2,n,n*1.5),Oo(2,-e/2,-i/2,n,n*1.5),Oo(3,e/2,-i/2,n,n*1.5),Oo(4,e/2,i/2,n,n*1.5)],s=[E5([{x:-e/2,y:-i/2},{x:-e/2,y:i/2}]),E5([{x:e/2,y:-i/2},{x:e/2,y:i/2}]),E5([{x:-e/2,y:0},{x:-e/5,y:0},{x:e/5*1/Math.sqrt(2),y:i/8}]),E5([{x:e/2,y:0},{x:e/5,y:0}])],r=Li(0,i/2+.4,.5);return{circuitJson:[...o,...s,r],parameters:A}},BVA=Hi.extend({fn:Y(),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:Be().default(!1),innerholeedgedistance:$A.default($A.parse("1.61mm")),silkscreenlabels:Be().default(!1),silkscreenlabelmargin:$A.default($A.parse("0.1mm"))}),rQt=t=>{const A=BVA.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},h5=(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},aQt=t=>{const A=BVA.parse(t),e=A.h??rQt(A),i=[],n=[],o=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),c=`pin${g}`.length*.7/2;if(A.right){const Q=-((A.right-1)/2)*A.p;for(let E=0;E<A.right;E++){if(E===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=h5(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}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl-(c+A.silkscreenlabelmargin),y:Q+E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(Oo(E+1+A.left+(A.bottom??0)+g,A.w/2,Q+E*A.p,r,a)),n.push(Oo(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=h5(-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}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl+(c+A.silkscreenlabelmargin),y:Q-E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(Oo(E+1+g,-A.w/2,Q-E*A.p,r,a)),n.push(Oo(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=h5(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}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q-E*A.p,y:e/2-A.pl-(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(n.push(Oo(E+1+A.left+A.right+(A.bottom??0)+g,Q-E*A.p,e/2,r,a)),n.push(Oo(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=h5(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}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:Q+E*A.p,y:-e/2+A.pl+(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(n.push(Oo(E+1+A.left+g,Q+E*A.p,-e/2,r,a)),n.push(Oo(E+1+A.left+g*2,Q+E*A.p,-e/2+A.innerholeedgedistance,r,a)))}}const B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2,y:e/2},{x:A.w/2,y:e/2},{x:A.w/2,y:-e/2},{x:-A.w/2,y:-e/2},{x:-A.w/2,y:e/2}],stroke_width:.1,layer:"top"},C=Li(0,e/1.8,e/25);return{circuitJson:[...i,...n,...o,l,...A.silkscreenlabels?[]:[B],C],parameters:A}},lVA=Hi.extend({fn:Y(),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:Be().default(!1),innerholeedgedistance:$A.default($A.parse("1.61mm"))}),gQt=t=>{const A=lVA.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},IQt=(t,A,e,i=1,n=.6)=>{const o=i/2,s=n/2;return{left:[{x:t+o,y:A},{x:t-o,y:A+s},{x:t-o,y:A-s},{x:t+o,y:A}],right:[{x:t-o,y:A},{x:t+o,y:A+s},{x:t+o,y:A-s},{x:t-o,y:A}],top:[{x:t,y:A-o},{x:t-s,y:A+o},{x:t+s,y:A+o},{x:t,y:A-o}],bottom:[{x:t,y:A+o},{x:t-s,y:A-o},{x:t+s,y:A-o},{x:t,y:A+o}]}[e]},cQt=t=>{const A=lVA.parse(t),e=A.h??gQt(A),i=[],n=[],o=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],I=1;if(A.left){const C=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++)Q===0&&(g=IQt(-A.w/2-A.pl/2,C-Q*A.p,"left")),i.push(Qi(I,-A.w/2+A.pl/2,C-Q*A.p,A.pl,A.pw)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:C-Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Oo(I+a,-A.w/2+A.innerholeedgedistance,C-Q*A.p,s,r))}if(A.bottom){const C=(A.bottom-1)/2*A.p;for(let Q=A.bottom-1;Q>=0;Q--)i.push(Qi(I,C-Q*A.p,-e/2+A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C-Q*A.p,y:-e/2+A.pl/2-3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Oo(I+a,C-Q*A.p,-e/2+A.innerholeedgedistance,s,r))}if(A.right){const C=-((A.right-1)/2)*A.p;for(let Q=0;Q<A.right;Q++)i.push(Qi(I,A.w/2-A.pl/2,C+Q*A.p,A.pl,A.pw)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:C+Q*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Oo(I+a,A.w/2-A.innerholeedgedistance,C+Q*A.p,s,r))}if(A.top){const C=-((A.top-1)/2)*A.p;for(let Q=A.top-1;Q>=0;Q--)i.push(Qi(I,C+Q*A.p,e/2-A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C+Q*A.p,y:e/2-A.pl/2+3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(Oo(I+a,C+Q*A.p,e/2-A.innerholeedgedistance,s,r))}const c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:g,stroke_width:.1},B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:e/2+A.pl/3},{x:A.w/2+A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:-e/2-A.pl/3},{x:-A.w/2-A.pl/3,y:e/2+A.pl/3}],stroke_width:.1,layer:"top"},l=Li(0,e/1.8,e/25);return{circuitJson:[...o,...i,...n,B,c,l],parameters:A}},BQt=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),O_(t)),CVA=Hi.extend({fn:Y(),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"))}),lQt=t=>{const A=CVA.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},u5=(t,A,e,i=1,n=.6)=>{const o=i/2,s=n/2;return{left:[{x:t+o,y:A},{x:t-o,y:A+s},{x:t-o,y:A-s},{x:t+o,y:A}],right:[{x:t-o,y:A},{x:t+o,y:A+s},{x:t+o,y:A-s},{x:t-o,y:A}],top:[{x:t,y:A-o},{x:t-s,y:A+o},{x:t+s,y:A+o},{x:t,y:A-o}],bottom:[{x:t,y:A+o},{x:t-s,y:A-o},{x:t+s,y:A-o},{x:t,y:A+o}]}[e]},CQt=t=>{const A=CVA.parse(t),e=A.h??lQt(A),i=[],n=A.id,o=A.od;let s=[];if(A.right){const I=-((A.right-1)/2)*A.p;for(let c=0;c<A.right;c++)c===0&&!A.left&&!A.bottom&&(s=u5(A.w/2+o*1.4,I+c*A.p,"right")),i.push(Oo(c+1+A.left+(A.bottom??0),A.w/2,I+c*A.p,n,o))}if(A.left){const I=-((A.left-1)/2)*A.p;for(let c=0;c<A.left;c++)c===A.left-1&&(s=u5(-A.w/2-o*1.4,I+c*A.p,"left")),i.push(Oo(c+1,-A.w/2,I+c*A.p,n,o))}if(A.top){const I=-((A.top-1)/2)*A.p;for(let c=0;c<A.top;c++)c===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=u5(I+c*A.p,e/2+o*1.4,"top")),i.push(Oo(c+1+A.right+(A.bottom??0)+A.left,I+c*A.p,e/2,n,o))}if(A.bottom){const I=-((A.bottom-1)/2)*A.p;for(let c=0;c<A.bottom;c++)c===0&&!A.left&&(s=u5(I+c*A.p,-e/2-o*1.4,"bottom")),i.push(Oo(c+1+A.left,I+c*A.p,-e/2,n,o))}const r={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-o,y:e/2+o},{x:A.w/2+o,y:e/2+o},{x:A.w/2+o,y:-e/2-o},{x:-A.w/2-o,y:-e/2-o},{x:-A.w/2-o,y:e/2+o}],stroke_width:.1,layer:"top"},g=Li(0,e/1.7,e/25);return{circuitJson:[...i,a,g,r],parameters:A}},QVA=(t,A,e,i)=>Array.from({length:25},(n,o)=>{const s=o/24*Math.PI-Math.PI/2;return{x:t+(i==="right"?1:-1)*Math.cos(s)*e,y:A+Math.sin(s)*e}}),QQt=Hi.extend({fn:Y(),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")}),EQt=t=>{const A=QQt.parse(t),{p:e,id:i,od:n,w:o,h:s}=A,r=s/2,a=[Oo(1,-e/2,0,i,n),Oo(2,e/2,0,i,n)],g=QVA(-o/2,0,r,"left"),I=QVA(o/2,0,r,"right"),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...g,...g.slice(1).reverse(),{x:-o/2,y:-s/2},{x:o/2,y:-s/2},...I,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},B=Li(0,e/4,.5);return{circuitJson:[...a,c,B],parameters:A}};Hi.extend({w:$A,h:$A});var hQt=t=>{const{w:A,h:e}=t,i=mr(A),n=mr(e);return{circuitJson:[Qi(1,0,0,i,n),Li(0,n/2+.5,.2)],parameters:t}},AL=(t,A,e,i,n,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:A,y:e,outer_width:mr(n),outer_height:mr(o),hole_width:mr(i),hole_height:mr(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),uQt=Hi.extend({fn:Y(),num_pins:Ai([FA(3),FA(2)]).default(3),p:Y().default("1.27mm"),id:Y().default("0.72mm"),od:Y().default("0.95mm"),w:Y().default("4.5mm"),h:Y().default("4.5mm"),inline:Be().default(!1),string:Y().optional()}),dQt=(t,A,e)=>Array.from({length:25},(i,n)=>{const o=n/24*Math.PI;return{x:t+Math.cos(o)*e,y:A+Math.sin(o)*e}}),pQt=t=>{const A=t.string?.match(/^to92_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=uQt.parse({...t,num_pins:e}),{p:n,id:o,od:s,w:r,h:a,inline:g}=i,I=Number.parseFloat(a)/2,c=Number.parseFloat(n),B=Number.parseFloat(o),l=Number.parseFloat(s),C=l,Q=l*(1.5/1.05);let E=[];if(i.num_pins===3)g?E=[BS(1,-c,I-c,B,l,Q,0,0),AL(2,0,I-c,B,C,Q),AL(3,c,I-c,B,C,Q)]:E=[BS(1,-c,I-c,B,l,l,0,0),Oo(2,0,I,B,l),Oo(3,c,I-c,B,l)];else if(i.num_pins===2)E=[BS(1,-c,I-c,B,C,Q,0,0),AL(2,c,I-c,B,C,Q)];else throw new Error("Invalid number of pins for TO-92");const h=Number.parseFloat(r)/2,u=dQt(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}},fQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("2.15mm"),h:Y().default("1.20mm"),pl:Y().default("0.5mm"),pw:Y().default("0.6mm"),p:Y().default("1.4mm")}),yQt=t=>{const A=fQt.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:wQt(A).concat(i,e),parameters:A}},mQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},wQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=mQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},DQt=Fw({}),SQt=t=>{const A=DQt.parse(t),e=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=blA({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,n=Li(0,i/2-.5,i/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-A.w/3,y:i/2+.2},{x:A.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...e,n,o],parameters:A}},bQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("5.0mm"),h:Y().default("2.30mm"),pl:Y().default("1.25mm"),pw:Y().default("2mm"),p:Y().default("3.75mm")}),xQt=t=>{const A=bQt.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:GQt(A).concat(i,e),parameters:A}},kQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},GQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=kQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},FQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),p:Y().default("2.9mm")}),RQt=t=>{const A=FQt.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:_Qt(A).concat(i,e),parameters:A}},NQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},_Qt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=NQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},MQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("3.30mm"),h:Y().default("1.80mm"),pl:Y().default("0.60mm"),pw:Y().default("0.45mm"),p:Y().default("2.1mm")}),vQt=t=>{const A=MQt.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:LQt(A).concat(i,e),parameters:A}},UQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},LQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=UQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},HQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("1.4mm"),h:Y().default("0.9mm"),pl:Y().default("0.36mm"),pw:Y().default("0.25mm"),p:Y().default("0.85mm")}),YQt=t=>{const A=HQt.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:TQt(A).concat(i,e),parameters:A}},JQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},TQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=JQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},KQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("1.3mm"),h:Y().default("0.9mm"),pl:Y().default("0.4mm"),pw:Y().default("0.7mm"),p:Y().default("0.7mm")}),qQt=t=>{const A=KQt.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:OQt(A).concat(i,e),parameters:A}},PQt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},OQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=PQt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},WQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("3,05mm"),h:Y().default("1.65mm"),pl:Y().default("0.6mm"),pw:Y().default("0.6mm"),pad_spacing:Y().default("2.2mm")}),ZQt=t=>{const A=WQt.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:jQt(A).concat(i,e),parameters:A}},VQt=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},jQt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=VQt({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},zQt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),p:Y().default("2.9mm")}),XQt=t=>{const A=zQt.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:AEt(A).concat(i,e),parameters:A}},$Qt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},AEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=$Qt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},eEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("4.4mm"),h:Y().default("2.1mm"),pl:Y().default("0.91mm"),pw:Y().default("1.22mm"),p:Y().default("3.146mm")}),tEt=t=>{const A=eEt.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:nEt(A).concat(i,e),parameters:A}},iEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},nEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=iEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},oEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("1.80mm"),h:Y().default("1.00mm"),pl:Y().default("0.66mm"),pw:Y().default("0.5mm"),p:Y().default("0.8mm")}),sEt=t=>{const A=oEt.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:aEt(A).concat(i,e),parameters:A}},rEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},aEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=rEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},gEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("6.2mm"),h:Y().default("3.4mm"),pl:Y().default("1.4mm"),pw:Y().default("2.1mm"),p:Y().default("4.4mm")}),IEt=t=>{const A=gEt.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:BEt(A).concat(i,e),parameters:A}},cEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},BEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=cEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},lEt=Hi.extend({fn:Y(),num_pins:Ai([FA(3),FA(5)]).default(3),w:Y().default("4.20mm"),h:Y().default("4.80mm"),pl:Y().default("1.3mm"),pw:Y().default("0.9mm"),p:Y().default("1.5mm"),string:Y().optional()}),CEt=t=>{const A=[],e=Number.parseFloat(t.p),i=Number.parseFloat(t.pw),n=Number.parseFloat(t.w),o=Number.parseFloat(t.pl),s=.175,r=(o-(o+s))/2;A.push(Qi(1,-n/2+r,e,o,i),Qi(2,-n/2,0,o+s,i),Qi(3,-n/2+r,-e,o,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]},QEt=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,n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i,y:n}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n},{x:i,y:-n}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},EEt=t=>{const A=t.string?.match(/^sot89_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=lEt.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:CEt(i),parameters:i};if(i.num_pins===5)return{circuitJson:QEt(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},hEt=Hi.extend({fn:Y(),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:VA().optional(),string:Y().optional()}),uEt=t=>{const A=hEt.parse(t),{fn:e,id:i,od:n,w:o,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,I=o/2,c=s/2,B=2.5,l=o*.4,C=Math.max(B,l/(a-1)),Q=Array.from({length:a},(w,S)=>{const D=a%2===0?(S-a/2+.5)*C:(S-Math.floor(a/2))*C;return Oo(S+1,D,g,i,n)}),E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:-c},{x:I,y:-c},{x:I,y:c},{x:-I,y:c},{x:-I,y:-c}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-c+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:h},{x:I,y:h}],stroke_width:.1,pcb_silkscreen_path_id:""},d=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:h},{x:-o/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:h},{x:o/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Li(0,s/2+.6,.5);return{circuitJson:[...Q,E,u,...d,f],parameters:{...A,p:C}}},dEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("5.40mm"),h:Y().default("2.30mm"),pl:Y().default("1.30mm"),pw:Y().default("1.70mm"),p:Y().default("3.5mm")}),pEt=t=>{const A=dEt.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:yEt(A).concat(i,e),parameters:A}},fEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},yEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=fEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},mEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("1.90mm"),h:Y().default("1.33mm"),pl:Y().default("0.5mm"),pw:Y().default("0.7mm"),p:Y().default("0.8mm")}),wEt=t=>{const A=mEt.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:SEt(A).concat(i,e),parameters:A}},DEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},SEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=DEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},bEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("7.0mm"),h:Y().default("3.35mm"),pl:Y().default("1.50mm"),pw:Y().default("2.70mm"),p:Y().default("4.8mm")}),xEt=t=>{const A=bEt.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:GEt(A).concat(i,e),parameters:A}},kEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},GEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=kEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},FEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("3.0mm"),h:Y().default("1.80mm"),pl:Y().default("0.80mm"),pw:Y().default("1.20mm"),p:Y().default("1.6mm")}),REt=t=>{const A=FEt.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:_Et(A).concat(i,e),parameters:A}},NEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},_Et=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=NEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},MEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("7.10mm"),h:Y().default("3.40mm"),pl:Y().default("2.45mm"),pw:Y().default("1.80mm"),p:Y().default("4.05mm")}),vEt=t=>{const A=MEt.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:LEt(A).concat(i,e),parameters:A}},UEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},LEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=UEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},HEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("4.80mm"),h:Y().default("2.10mm"),pl:Y().default("1.30mm"),pw:Y().default("1.40mm"),p:Y().default("2.9mm")}),YEt=t=>{const A=HEt.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:TEt(A).concat(i,e),parameters:A}},JEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},TEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=JEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},KEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("7.30mm"),h:Y().default("4.40mm"),pl:Y().default("2.50mm"),pw:Y().default("2.30mm"),p:Y().default("4.30mm")}),qEt=t=>{const A=KEt.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:OEt(A).concat(i,e),parameters:A}},PEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},OEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=PEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},WEt=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("10.70mm"),h:Y().default("6.60mm"),pl:Y().default("3.30mm"),pw:Y().default("2.50mm"),p:Y().default("6.80mm")}),ZEt=t=>{const A=WEt.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:jEt(A).concat(i,e),parameters:A}},VEt=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},jEt=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=VEt({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},zEt=Hi.extend({fn:Y(),num_pins:VA().default(4),w:Y().default("8.50mm"),h:Y().default("6.90mm"),pl:Y().default("2mm"),pw:Y().default("1.5mm"),p:Y().default("2.30mm"),string:Y().optional()}),XEt=t=>{const A=t.string?.match(/^sot223_(\d+)/),e=A?Number.parseInt(A[1],10):4;if(e===8){const n=eht.parse({...t,num_pins:e});return{circuitJson:Sx(n),parameters:n}}const i=zEt.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:Aht(i),parameters:i};if(i.num_pins===5)return{circuitJson:iht(i),parameters:i};if(i.num_pins===6)return{circuitJson:oht(i),parameters:i};throw new Error("Invalid number of pins")},$Et=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}},Aht=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=$Et({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,n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i,y:n},{x:i,y:n/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n},{x:i,y:-n},{x:i,y:-n/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},eht=Fw({p:"0.90mm",w:"2.8mm",legsoutside:!0}),tht=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")},iht=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=tht({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,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Li(0,0,.3);return[...A,n,o,s]},nht=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")},oht=t=>{const A=[];for(let r=1;r<=t.num_pins;r++){const{x:a,y:g}=nht({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,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e,y:i},{x:e,y:i},{x:e,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e,y:-i},{x:e,y:-i},{x:e,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Li(0,0,.3);return[...A,n,o,s]},sht=Hi.extend({fn:Y(),num_pins:VA().default(3),w:Y().default("3.40mm"),h:Y().default("3.30mm"),pl:Y().default("1mm"),pw:Y().default("0.7mm"),p:Y().default("1.2mm"),string:Y().optional()}),rht=t=>{const A=t.string?.match(/^sot23w_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=sht.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:ght(i),parameters:i};throw new Error("Invalid number of pins")},aht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.95}:A===2?{x:-e,y:-.95}:{x:e,y:0}},ght=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=aht({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,n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i+.3,y:n},{x:i+.3,y:n/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n},{x:i+.3,y:-n},{x:i+.3,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},Iht=Hi.extend({fn:Y(),num_pins:Ai([FA(3),FA(2)]).default(3),p:Y().default("1.27mm"),id:Y().default("0.72mm"),od:Y().default("0.95mm"),w:Y().default("2.5mm"),h:Y().default("4.2mm"),string:Y().optional()}),cht=t=>{const{p:A,id:e,od:i,w:n,h:o}=t,s=Number.parseFloat(o)/2,r=Number.parseFloat(A);return[Oo(1,-r,s-r,e,i),Oo(2,0,s-r,e,i),Oo(3,r,s-r,e,i)]},Bht=t=>{const{p:A,id:e,od:i,h:n}=t,o=Number.parseFloat(n)/2,s=Number.parseFloat(A);return[Oo(1,-s,o-s,e,i),Oo(2,s,o-s,e,i)]},lht=t=>{const A=t.string?.match(/^to92s_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=Iht.parse({...t,num_pins:e});let n=[];if(i.num_pins===3)n=cht(i);else if(i.num_pins===2)n=Bht(i);else throw new Error("Invalid number of pins for TO-92");const o=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o,y:o-s},{x:-1.9,y:0},{x:1.9,y:0},{x:o,y:o-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-o,y:o-s}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Li(0,o+1,.5);return{circuitJson:[...n,r,a],parameters:i}},Cht=Hi.extend({fn:Y(),p:$A.optional(),id:$A.optional(),pw:$A.optional(),pl:$A.optional(),w:$A.optional(),h:$A.optional(),sh:Ai([Be(),Y(),VA()]).optional().transform(t=>{if(typeof t=="string"){const A=Number(t);return Number.isNaN(A)?!0:A}return t}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Be().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:Y().optional()}),Qht={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 Eht(t){return t.sh?"sh":(t.ph,"ph")}function hht(t,A,e,i,n,o){const s=[];if(t==="ph"){const r=e/2;s.push(BS(1,-r,2,i,n,o)),s.push(BS(2,r,2,i,n,o))}else{const r=-((A-1)/2)*e;for(let g=0;g<A;g++){const I=r+g*e;console.log("x si",I),s.push(Qi(g+1,I,-1.325,n,o))}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 uht(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 dht=t=>{const A=Cht.parse(t),e=Eht(A),i=Qht[e],n=A.p??i.p,o=A.id??i.id,s=A.pw??i.pw,r=A.pl??i.pl,a=A.w??i.w,g=A.h??i.h;let I=e==="sh"?4:2;if(e==="sh"){const Q=(typeof t.string=="string"?t.string:"").match(/sh(\d+)/);if(Q&&Q[1]){const E=parseInt(Q[1],10);Number.isNaN(E)||(I=E)}else typeof A.sh=="number"&&(I=A.sh)}const c=hht(e,I,n,o,s,r),B=uht(e),l=Li(0,g/2+1,.5);return{circuitJson:[...c,B,l],parameters:{...A,p:n,id:o,pw:s,pl:r,w:a,h:g,num_pins:I,sh:e==="sh",ph:e==="ph"}}},pht=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("3.30mm"),h:Y().default("1.70mm"),pl:Y().default("0.80mm"),pw:Y().default("1mm"),p:Y().default("1.90mm")}),fht=t=>{const A=pht.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:mht(A).concat(i,e),parameters:A}},yht=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},mht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=yht({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},wht=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"}}},Dht=Hi.extend({fn:Y(),num_pins:Ai([FA(8),FA(10)]).default(8),w:Y().optional(),h:Y().optional(),p:Y().optional(),pl:Y().optional(),pw:Y().optional(),string:Y().optional()}),Sht=t=>{const A=Dht.parse(t),e=wht(A.num_pins),i=$A.parse(A.w||e.w),n=$A.parse(A.h||e.h),o=$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}=EVA(A.num_pins,u+1,i,o),w=u<g?u+1:A.num_pins-(u-g);a.push(Qi(w,d,f,s,r))}const I=i,c=n,B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:c/2},{x:I/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:-c/2},{x:I/2,y:-c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=EVA(A.num_pins,1,I,o),Q={x:C.x-.8,y:C.y},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:Q.x-.4,y:Q.y},{x:Q.x-.7,y:Q.y+.3},{x:Q.x-.7,y:Q.y-.3},{x:Q.x-.4,y:Q.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Li(0,c/2+.5,.3);return{circuitJson:[...a,B,l,h,E],parameters:A}},EVA=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*$A.parse(t===8?"1.8mm":"2.2mm"),y:r*i}},bht=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"}}},xht=Hi.extend({fn:Y(),num_pins:Ai([FA(8),FA(10),FA(12),FA(16)]).default(8),w:Y().optional(),h:Y().optional(),p:Y().optional(),pl:Y().optional(),pw:Y().optional(),string:Y().optional()}),hVA=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*$A.parse("2mm"),y:r*i}},kht=t=>{const A=xht.parse(t),e=bht(A.num_pins),i=$A.parse(A.w||e.w),n=$A.parse(A.h||e.h),o=$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}=hVA(A.num_pins,h+1,i,o);a.push(Qi(h+1,u,d,s,r))}const g=i,I=n,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:I/2},{x:g/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-I/2},{x:g/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=hVA(A.num_pins,1,g,o),C={x:l.x-.8,y:l.y},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:C.x-.4,y:C.y},{x:C.x-.7,y:C.y+.3},{x:C.x-.7,y:C.y-.3},{x:C.x-.4,y:C.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},E=Li(0,I/2+.5,.3);return{circuitJson:[...a,c,B,E,Q],parameters:A}},Ght=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("3.8mm"),h:Y().default("1.65mm"),pl:Y().default("1.2mm"),pw:Y().default("1.2mm"),pad_spacing:Y().default("2.6mm")}),Fht=t=>{const A=Ght.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:Nht(A).concat(i,e),parameters:A}},Rht=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Nht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Rht({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},_ht=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("3.20mm"),h:Y().default("1.65mm"),pl:Y().default("0.8mm"),pw:Y().default("0.9mm"),pad_spacing:Y().default("2.1mm")}),Mht=t=>{const A=_ht.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:Uht(A).concat(i,e),parameters:A}},vht=t=>{const{pn:A,pad_spacing:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},Uht=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=vht({pn:e,pad_spacing:Number.parseFloat(t.pad_spacing)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},Lht=Hi.extend({fn:Y(),num_pins:Ai([FA(6),FA(8)]).default(8),w:Y().default("3mm"),h:Y().default("3mm"),p:Y().default("0.5mm"),pl:Y().default("0.52mm"),pw:Y().default("0.35mm"),epw:Y().default("1.40mm"),eph:Y().default("1.60mm"),string:Y().optional(),ep:Be().default(!1)}),Hht=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=Lht.parse({...t,num_pins:e}),n=$A.parse(i.w),o=$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:w,y:S}=uVA(i.num_pins,f+1,n,s);c.push(Qi(f+1,w,S,r,a))}i.ep&&c.push(Qi(i.num_pins+1,0,0,g,I));const B=n,l=o,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:l/2},{x:B/2,y:l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-B/2,y:-l/2},{x:B/2,y:-l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},E=uVA(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,l/2+.5,.3);return{circuitJson:[...c,C,Q,d,u],parameters:i}},uVA=(t,A,e,i)=>{const n=t/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*$A.parse("1.4mm"),y:r*i}},Yht=t=>{const{num_pins:A,bridged:e,p:i=2.54,pw:n=1.5,ph:o=1.5}=t,s=$A.parse(i),r=$A.parse(n),a=$A.parse(o),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 w=0;w<f.length-1;w++){const S=f[w],D=f[w+1];if(typeof S=="number"&&typeof D=="number"&&!isNaN(S)&&!isNaN(D)){const x=(S-1)*s,F=(D-1)*s,k=Math.sign(F-x),v=x+k*(r/2),_=F-k*(r/2);c.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${S}}`,x:v,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${D}}`,x:_,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const B=(A-1)*s+r+.7,l=a+1,C=(A-1)*s/2,Q=0,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:C-B/2,y:Q-l/2},{x:C+B/2,y:Q-l/2},{x:C+B/2,y:Q+l/2},{x:C-B/2,y:Q+l/2},{x:C-B/2,y:Q-l/2}],stroke_width:.15},u=Q+l/2+.6,d=Li(C,u,.4);return{circuitJson:[...I,...c,E,d],parameters:t}},dVA={fn:FA("sot457"),num_pins:FA(6).default(6),pillh:Y().default("0.45mm"),pillw:Y().default("1.45mm"),pl:Y(),pw:Y(),p:Y(),wave:Be().optional(),reflow:Be().optional()},Jht=Hi.extend({...dVA,h:Y().default("2.5mm"),w:Y().default("2.7mm"),pl:Y().default("0.8mm"),pw:Y().default("0.55mm"),p:Y().default("0.95mm")}),Tht=Hi.extend({...dVA,h:Y().default("3mm"),w:Y().default("4mm"),pillr:Y().default("0.225mm"),pl:Y().default("1.45mm"),pw:Y().default("1.5mm"),p:Y().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)})),lS=t=>Number.parseFloat(t.replace("mm","")),pVA=({pitch:t,width:A,pinNumber:e})=>{const o={1:{x:-A/2-.1,y:t},2:{x:-A/2-.1,y:0},3:{x:-A/2-.1,y:-t},4:{x:A/2+.1,y:-t},5:{x:A/2+.1,y:0},6:{x:A/2+.1,y:t}}[e];if(!o)throw new Error(`Invalid pin number: ${e}`);return o},fVA=t=>{const A=[],e=lS(t.p),i=lS(t.pl),n=lS(t.pw),o=lS(t.w),s=lS(t.h);if(t.wave){const C={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})=>Q5(3,-e,0,lS(t.pillw),lS(t.pillh)),4:({padWidth:Q,padHeight:E})=>Q5(4,e,0,lS(t.pillw),lS(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=C[Q];E&&A.push(E({padWidth:i,padHeight:n}))}}else for(let C=1;C<=t.num_pins;C++){const{x:Q,y:E}=pVA({pitch:e,width:o,pinNumber:C});A.push(Qi(C,Q,E,i,n))}const r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/3,y:s/2+e/1.3},{x:o/3,y:s/2+e/1.3}],stroke_width:.05},a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o/3,y:-s/2-e/1.3},{x:o/3,y:-s/2-e/1.3}],stroke_width:.05},g=Li(0,s+.5,.3),I=pVA({pitch:e,width:o,pinNumber:1}),c=t.wave?1:.5,B=t.wave?.7:.3;I.x-=t.wave?n:n*1.7;const l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:I.x+c/2,y:I.y},{x:I.x-c/2,y:I.y+B/2},{x:I.x-c/2,y:I.y-B/2},{x:I.x+c/2,y:I.y}],stroke_width:.05};return[g,r,a,l,...A]},Kht=t=>{if(t.wave){const e=Tht.parse({...t,fn:"sot457"});return{circuitJson:fVA(e),parameters:e}}const A=Jht.parse(t);return{circuitJson:fVA(A),parameters:A}},qht=Hi.extend({fn:Y(),num_pins:FA(6).default(6),w:Y().default("1.1mm"),h:Y().default("1.45mm"),p:Y().default("0.35mm"),pl:Y().default("0.2mm"),pw:Y().default("0.2mm"),string:Y().optional()}),Pht=t=>{const A=qht.parse({...t,fn:"sot963"}),e=$A.parse(A.w),i=$A.parse(A.h),n=$A.parse(A.p),o=$A.parse(A.pl),s=$A.parse(A.pw),r=[];for(let l=0;l<6;l++){const{x:C,y:Q}=yVA(l+1,e,n,o);r.push(Qi(l+1,C,Q,o,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:i/2},{x:e/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-e/2,y:-i/2},{x:e/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=yVA(1,e,n,o),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-o/2-.3,y:I.y},{x:I.x-o/2-.45,y:I.y+.15},{x:I.x-o/2-.45,y:I.y-.15},{x:I.x-o/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}},yVA=(t,A,e,i)=>{const n=A/2-i/2;return t<=3?{x:-n,y:e-(t-1)*e}:{x:n,y:-e+(t-4)*e}},Oht=Hi.extend({fn:Y(),num_pins:Ai([FA(3),FA(2)]).default(3),p:Y().default("3.8mm"),id:Y().default("1.25mm"),od:Y().default("2.35mm"),ca:Y().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:Y().default("5.35mm"),h:Y().default("4mm"),string:Y().optional()}),Wht=t=>{const{p:A,id:e,od:i,h:n,ca:o}=t,s=Number.parseFloat(n),r=Number.parseFloat(o);return[Oo(1,0,r/4+.3,e,i),Oo(2,s,0,e,i),Oo(3,0,-r/4-.3,e,i)]},Zht=t=>{const A=t.string?.match(/^potentiometer_(\d+)/),e=A?Number.parseInt(A[1],10):3,i=Oht.parse({...t,num_pins:e});let n=[];i.num_pins===3&&(n=Wht(i));const o=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),r=Number.parseFloat(i.od)/2+.35,a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o-1.75},{x:0,y:o},{x:s,y:o},{x:s,y:r}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-r},{x:s,y:-o},{x:0,y:-o},{x:0,y:-o+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},I=Number.parseFloat(i.w)/2,c=Li(I,o+1,.5);return{circuitJson:[...n,a,g,c],parameters:i}},Vht=Hi.extend({fn:Y(),p:$A.optional().default("7.5mm"),id:$A.optional().default("1mm"),od:$A.optional().default("2mm"),d:$A.optional().default("10.5mm")}),jht=(t,A,e,i,n)=>{const o=[],s=[];for(let r=0;r<=50;r++){const a=r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-n/2&&I<=A+n/2||o.push({x:g,y:I})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=t+Math.cos(a)*e,I=A+Math.sin(a)*e;g<t-i&&I>=A-n/2&&I<=A+n/2||s.push({x:g,y:I})}return{topArc:o,bottomArc:s}},zht=t=>{const A=Vht.parse(t),{p:e,id:i,od:n,d:o}=A,s=[Oo(1,-e/2,0,i,n),Oo(2,e/2,0,i,n)],{topArc:r,bottomArc:a}=jht(0,0,o/2+.1,n/2,n),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:.1,pcb_silkscreen_path_id:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},B=-(o/2+.5),l=n/2+1.5,C=.5,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B-C,y:l},{x:B+C,y:l}],stroke_width:.1,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B,y:l-C},{x:B,y:l+C}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Li(0,o/2+1,.5);return{circuitJson:[...s,g,I,c,Q,E,h],parameters:A}},Xht=Hi.extend({fn:Y(),num_pins:FA(2).default(2),w:Y().default("6.5mm"),h:Y().default("3mm"),pl:Y().default("1.75mm"),pw:Y().default("2.40mm"),p:Y().default("4.75mm")}),$ht=t=>{const A=Xht.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:eut(A).concat(i,e),parameters:A}},Aut=t=>{const{pn:A,p:e}=t;return A===1?{x:-e/2,y:0}:{x:e/2,y:0}},eut=t=>{const A=[];for(let e=1;e<=t.num_pins;e++){const{x:i,y:n}=Aut({pn:e,p:Number.parseFloat(t.p)});A.push(Qi(e,i,n,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return A},tut=Hi.extend({fn:Y(),num_pins:VA().default(3),w:Y().default("2.45mm"),h:Y().default("2.40mm"),pl:Y().default("1.225mm"),pw:Y().default("0.5mm"),p:Y().default("0.95mm"),string:Y().optional()}),iut=t=>{const A=t.string?.match(/^sot323_(\d+)/),e=A?Number.parseInt(A[1],3):3,i=tut.parse({...t,num_pins:e});if(i.num_pins===3)return{circuitJson:out(i),parameters:i};throw new Error("Invalid number of pins")},nut=t=>{const{pn:A,p:e}=t;return A===1?{x:-e,y:.65}:A===2?{x:-e,y:-.65}:{x:e,y:0}},out=t=>{const A=[];for(let r=0;r<t.num_pins;r++){const{x:a,y:g}=nut({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),n=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n+.3},{x:i,y:n+.3},{x:i,y:n/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n-.3},{x:i,y:-n-.3},{x:i,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,e]},sut=Hi.extend({fn:Y(),circle:Be().optional(),rect:Be().optional(),square:Be().optional(),pill:Be().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:Y().optional()}).transform(t=>{let A="rect";t.circle&&(A="circle"),t.square&&(A="square"),t.rect&&(A="rect"),t.pill&&(A="pill");let e,i,n;return A==="circle"?t.r!==void 0?e=mr(t.r):t.pr!==void 0?e=mr(t.pr):t.radius!==void 0?e=mr(t.radius):t.d!==void 0?e=mr(t.d)/2:t.pd!==void 0?e=mr(t.pd)/2:t.diameter!==void 0?e=mr(t.diameter)/2:e=mr("1mm")/2:(t.w!==void 0?i=mr(t.w):t.pw!==void 0?i=mr(t.pw):t.width!==void 0?i=mr(t.width):t.s!==void 0?i=mr(t.s):t.size!==void 0?i=mr(t.size):i=mr("1mm"),t.h!==void 0?n=mr(t.h):t.ph!==void 0?n=mr(t.ph):t.height!==void 0?n=mr(t.height):A==="square"||A==="rect"?n=i:n=mr("1mm")),{fn:t.fn,shape:A,radius:e,width:i,height:n}}),rut=t=>{const A=sut.parse(t),{shape:e,radius:i,width:n,height:o}=A;let s,r;return e==="circle"?(s=tVA(1,{x:0,y:0,radius:i}),r=i+.5):e==="pill"?(s=Q5(1,0,0,n,o),r=Math.max(n,o)/2+.5):(s=Qi(1,0,0,n,o),r=o/2+.5),{circuitJson:[s,Li(0,r,.2)],parameters:A}},aut=Hi.extend({fn:Y(),d:$A.optional(),hd:$A.optional(),r:$A.optional(),hr:$A.optional(),pd:$A.optional(),pr:$A.optional(),squarepad:Be().optional().default(!1)}).transform(t=>{let A;t.d!==void 0?A=mr(t.d):t.hd!==void 0?A=mr(t.hd):t.r!==void 0?A=mr(t.r)*2:t.hr!==void 0?A=mr(t.hr)*2:A=mr("1mm");let e;return t.pd!==void 0?e=mr(t.pd):t.pr!==void 0?e=mr(t.pr)*2:e=A*(1.5/1),{fn:t.fn,d:A,pd:e,squarepad:t.squarepad??!1}}),gut=t=>{const A=aut.parse(t),{d:e,pd:i,squarepad:n}=A;return{circuitJson:[n?BS(1,0,0,e,i,i):Oo(1,0,0,e,i),Li(0,i/2+.5,.2)],parameters:A}},Iut=Hi.extend({fn:Y(),num_pins:FA(6).default(6),h:Y().default("1.6mm"),pl:Y().default("1mm"),pw:Y().default("0.7mm"),p:Y().default("0.95mm")}),cut=t=>{const A=Iut.parse(t);return{circuitJson:But(A),parameters:A}},mVA=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")},But=t=>{const A=[];for(let c=1;c<=t.num_pins;c++){const{x:B,y:l}=mVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:c});A.push(Qi(c,B,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const e=t.num_pins/2*Number.parseFloat(t.p),i=Number.parseFloat(t.h),n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-e/3,y:i/2+Number.parseFloat(t.p)/1.3},{x:e/3,y:i/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-e/3,y:-i/2-Number.parseFloat(t.p)/1.3},{x:e/3,y:-i/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Li(0,i+.3,.3),r=mVA({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});r.x=r.x-Number.parseFloat(t.pw)*1.5;const a=.7,g=.3,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,n,o,I]},lut=Hi.extend({fn:Y(),num_pins:VA().default(4),w:Y().default("3.2mm"),h:Y().default("2.6mm"),pl:Y().default("1.35mm"),pw:Y().default("0.50mm"),p:Y().default("0.6mm"),string:Y().optional()}),Cut=t=>{const A=t.string?.match(/^sot343_(\d+)/),e=A?Number.parseInt(A[1],4):4,i=lut.parse({...t,num_pins:e});if(i.num_pins===4)return{circuitJson:Eut(i),parameters:i};throw new Error("Invalid number of pins")},Qut=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}},Eut=t=>{const A=[],e=Number.parseFloat(t.w),i=Number.parseFloat(t.h),n=Number.parseFloat(t.pl),o=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let r=1/0,a=-1/0,g=1/0,I=-1/0;for(let d=0;d<t.num_pins;d++){const{x:f,y:w}=Qut({num_pins:t.num_pins,pn:d+1,p:s});A.push(Qi(d+1,f,w,n,o)),f<r&&(r=f),f>a&&(a=f),w<g&&(g=w),w>I&&(I=w)}const c=(r+a)/2,B=I-g,l=i*.3,C=B/2+l;let Q=e*.8;i<=2.6&&(Q/=2);const E=Li(c,C+.5,.3),h={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:c-Q/2,y:C},{x:c+Q/2,y:C}],type:"pcb_silkscreen_path",stroke_width:.1},u={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_bottom",route:[{x:c-Q/2,y:-C},{x:c+Q/2,y:-C}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,h,u,E]},hut=Hi.extend({fn:Y()}),uut=t=>{const A=hut.parse(t),e=[],i=.5-.15,n=1.5,s=.5/2,r=75,a=-37/2;for(let D=0;D<r;D++){const x=D+1;if(x>=24&&x<=31)continue;const F=a-D*s,k=x%2===0,v=n+(k?.25:0),L=.5-v/2,K=Qi(x,L,F,v,i);K.layer=k?"bottom":"top",e.push(K)}const g=46*.0254,I=137*.0254,c=261*.0254,B={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-I/2+n/2,y:a-c},width:I,height:g},l={x:-.5,y:a},C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-.4,y:l.y},{x:l.x-.7,y:l.y+.3},{x:l.x-.7,y:l.y-.3},{x:l.x-.4,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let Q=1/0,E=-1/0,h=1/0,u=-1/0;const d=(D,x,F=0,k=0)=>{Q=Math.min(Q,D-F/2),E=Math.max(E,D+F/2),h=Math.min(h,x-k/2),u=Math.max(u,x+k/2)};for(const D of e)d(D.x,D.y,D.width,D.height);d(B.center.x,B.center.y,B.width,B.height);for(const D of C.route)d(D.x,D.y);const f=(Q+E)/2,w=(h+u)/2,S=D=>{typeof D.x=="number"&&(D.x-=f),typeof D.y=="number"&&(D.y-=w),D.center&&(D.center.x-=f,D.center.y-=w),Array.isArray(D.route)&&(D.route=D.route.map(x=>({x:x.x-f,y:x.y-w})))};for(const D of e)S(D);return S(B),S(C),{circuitJson:[...e,B,C],parameters:A}},dut=Hi.extend({fn:Y(),num_pins:VA().default(3),inline:Be().default(!1),p:Y().default("1.27mm"),id:Y().default("0.75mm"),od:Y().default("1.3mm"),w:Y().default("4.8mm"),h:Y().default("4.0mm")}),put=t=>{const A=dut.parse(t),e=Number.parseFloat(A.p),i=Number.parseFloat(A.w),n=Number.parseFloat(A.h),o=A.inline?1.05:Number.parseFloat(A.od),s=A.inline?1.5:o,r=[BS(1,0,0,A.id,o,s,0,0),A.inline?AL(2,e,0,A.id,o,s):Oo(2,e,e,A.id,o),A.inline?AL(3,e*2,0,A.id,o,s):Oo(3,e*2,0,A.id,o)],a=i/2,g=A.inline?e-.09:e,I=.2,c=I+a-n,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)}}),l={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]]},C=Li(g,I+a+1,.5);return{circuitJson:[...r,l,C],parameters:A}};function fut(t){return t!=null}var yut=(t,A)=>{if(!A)return t;const e=t.filter(I=>I.type==="pcb_smtpad"||I.type==="pcb_plated_hole"||I.type==="pcb_thtpad");if(e.length===0)return t;let i=1/0,n=-1/0,o=1/0,s=-1/0;const r=(I,c,B=0,l=0)=>{const C=I-B/2,Q=I+B/2,E=c-l/2,h=c+l/2;i=Math.min(i,C),n=Math.max(n,Q),o=Math.min(o,E),s=Math.max(s,h)};for(const I of e)if(I.type==="pcb_smtpad"){const c=I.shape==="circle"?I.radius*2:I.width,B=I.shape==="circle"?I.radius*2:I.height;r(I.x,I.y,c,B)}else if(I.type==="pcb_plated_hole"){const c=I.outer_diameter??I.hole_diameter;r(I.x,I.y,c,c)}else if(I.type==="pcb_thtpad"){const c=I.diameter;r(I.x,I.y,c,c)}let a=0,g=0;switch(A){case"center":a=(i+n)/2,g=(o+s)/2;break;case"bottomleft":a=i,g=o;break;case"bottomcenter":case"centerbottom":a=(i+n)/2,g=o;break;case"topcenter":case"centertop":a=(i+n)/2,g=s;break;case"leftcenter":case"centerleft":a=i,g=(o+s)/2;break;case"rightcenter":case"centerright":a=n,g=(o+s)/2;break;case"pin1":const I=e.find(c=>c.port_hints?.[0]==="1")||e[0];a=I.x,g=I.y;break}if(a===0&&g===0)return t;for(const I of t){if(typeof I.x=="number"&&(I.x-=a),typeof I.y=="number"&&(I.y-=g),I.center&&typeof I.center.x=="number"&&(I.center.x-=a,I.center.y-=g),I.type==="pcb_silkscreen_path")for(const c of I.route)c.x-=a,c.y-=g;I.type==="pcb_silkscreen_text"&&I.anchor_position&&(I.anchor_position.x-=a,I.anchor_position.y-=g)}return t},mut=(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},wut=(t,A)=>A.nosilkscreen?t.filter(e=>e.type!=="pcb_silkscreen_path"&&e.type!=="pcb_silkscreen_text"):t,Dut=t=>{let A=d5();const i=t.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(n=>{const o=n.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,r]=o;if(!s)return null;const a=s.toLowerCase();return r?.includes("?")?null:{fn:a,v:r}}).filter(fut);for(const{fn:n,v:o}of i)A=A[n](o);return A.setString(t),A},Sut=()=>Object.keys(cS),d5=()=>{const t=new Proxy({},{get:(A,e)=>{if(e==="soup"||e==="circuitJson"){if("fn"in A&&cS[A.fn])return()=>{const{circuitJson:i}=cS[A.fn](A),n=wut(i,A),o=mut(n,A);return yut(o,A.origin)};if(!cS[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(!cS[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>cS[A.fn](A).parameters}return e==="getFootprintNames"?()=>Object.keys(cS):e==="params"?()=>A:e==="setString"?i=>(A.string=i,t):i=>(Object.keys(A).length===0?`${e}${i}`in cS?(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};d5.string=Dut,d5.getFootprintNames=Sut;var but=d5,wVA=Symbol("Fragment");function FlA(t,A,...e){const i=e.length?e:A?.children!==void 0?[A.children]:[],n=[],o=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of o)s==null||s===!1||(Array.isArray(s)?n.push(...s):n.push(s));return{type:t,props:(A&&A.children!==void 0?{...A,children:void 0}:A)||{},children:n}}var ht=Symbol("Cuboid"),DVA=Symbol("Cube"),Zp=Symbol("Cylinder"),SVA=Symbol("Sphere"),eL=Symbol("RoundedCuboid"),Vi=Symbol("Translate"),EQ=Symbol("Rotate"),gE=Symbol("Union"),$G=Symbol("Subtract"),aI=Symbol("Hull"),ms=Symbol("Colorize"),tL=Symbol("Polygon"),iL=Symbol("ExtrudeLinear"),Vp=Symbol("RoundedCylinder"),Tn=wVA,Ae=(t,A,e)=>FlA(t,A),Ot=(t,A,e)=>FlA(t,A),zB=({center:t,width:A,length:e,height:i,heightAboveSurface:n=.15,color:o="#555",taperRatio:s=.12,faceRatio:r=.75,straightHeightRatio:a=.5,includeNotch:g=!0,notchRadius:I,notchPosition:c,notchRotation:B=[0,0,0],notchLength:l=.5,notchWidth:C=.25,chamferSize:Q=0})=>{const E=i*a,h=i-E,u=Math.min(A,e)*s,d=Math.max(A-u,A*r),f=Math.max(e-u,e*r),w=Math.min(A,e)*.12,S=I??w,D={x:0,y:e/2-S*.25,z:i},x=c??D,F=Ot(gE,{children:[Ot(aI,{children:[Ae(Vi,{z:.005,children:Ae(ht,{size:[d,f,.01]})}),Ae(Vi,{z:E,children:Ae(ht,{size:[A,e,.01]})})]}),Ot(aI,{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=(_,L)=>Ae(Vi,{offset:{x:_,y:L,z:0},children:Ae(EQ,{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,L=e/2;v=Ot($G,{children:[F,k(_,L),k(-_,L),k(_,-L),k(-_,-L)]})}return Ae(ms,{color:o,children:Ae(Vi,{offset:t,children:Ae(Vi,{offset:{x:0,y:0,z:n},children:g?Ot($G,{children:[v,Ae(Vi,{offset:x,children:Ae(EQ,{rotation:B,children:Ae(Zp,{radius:S,height:C})})})]}):v})})})},xut=t=>Array.from({length:t},(A,e)=>e);function RlA(t,A){if(t.length<2)throw new Error("Stroke must have at least two points");const e=Array.isArray(t[0])?t.map(([I,c])=>({x:I,y:c})):t,i=A/2,n=[],o=[];function s(I,c){const B=c.x-I.x,l=c.y-I.y,C=Math.sqrt(B*B+l*l);return{x:-l/C,y:B/C}}function r(I,c,B){const l={x:I.x+c.x*i*B,y:I.y+c.y*i*B};B>0?n.push(l):o.unshift(l)}const a=s(e[0],e[1]);r(e[0],a,1),r(e[0],a,-1);for(let I=1;I<e.length-1;I++){const c=e[I-1],B=e[I],l=e[I+1],C=s(c,B),Q=s(B,l),E=C.x+Q.x,h=C.y+Q.y,u=Math.sqrt(E*E+h*h);if(u/2>2*i)r(B,C,1),r(B,Q,1),r(B,C,-1),r(B,Q,-1);else{const f=1/u;r(B,{x:E*f,y:h*f},1),r(B,{x:E*f,y:h*f},-1)}}const g=s(e[e.length-2],e[e.length-1]);return r(e[e.length-1],g,1),r(e[e.length-1],g,-1),[...n,...o]}var kut=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}))},Gut=kut([{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}]),bVA=5.47,p5=.5,Fut=({x:t,y:A,z:e})=>{const i=t>0;return Ot(Tn,{children:[Ae(Vi,{offset:{x:t+.25/2,y:A,z:e},children:Ae(EQ,{rotation:["-90deg",0,"90deg"],children:Ae(iL,{height:.25,children:Ae(tL,{points:Gut.slice().reverse().map(n=>[n.x,n.y])})})})}),Ae(Vi,{offset:{x:t,y:A+(i?1:-1),z:e},children:Ae(EQ,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:Ae(iL,{height:2,children:Ae(tL,{points:RlA([[0,0],[-1,0],[-1,-1]],.25).map(n=>[n.x,n.y])})})})})]})},Rut=({numPins:t=8,pitch:A=2.54,bodyWidth:e=6.4,rowSpacing:i})=>{const n=Math.floor(t/2),o=i??(e>=7?e:e+1.22),s=e>=7?o-1.22:e;return Ot(Tn,{children:[xut(t).map(r=>{const a=r%n,g=(Math.floor(r/n)-.5)*2;return Ae(Fut,{x:g*o/2,y:a*A-(n-1)/2*A,z:bVA/2+p5})}),Ae(zB,{width:s,length:n*A+.5,height:bVA-p5,heightAboveSurface:p5,center:{x:0,y:0,z:p5}})]})};function Nut(t,{height:A,padContactLength:e,curveLength:i,bodyDistance:n,steepness:o=10}){i||(i=n*.3);let s=n-e-i;s<0&&(i+=s,s=0);const r=e*.75,a=e+i+(n-e-i)*.25;if(t<=r)return 0;if(t>=a)return A;const g=(t-r)/(a-r);return A/(1+Math.exp(-o*(g-.5)))}var Pn=t=>{const{thickness:A,width:e,padContactLength:i,bodyDistance:n,height:o,rotation:s}=t,r=15,a=Array.from({length:r}).map((I,c)=>c/(r-1)*n).map(I=>[I,Nut(I,t)]),g=RlA(a,A);return Ae(ms,{color:"#fff",children:Ae(Vi,{offset:{z:0,y:0,x:0,...t.position},children:Ae(EQ,{rotation:["90deg",0,s??0],children:Ae(Vi,{offset:{x:0,y:0,z:-e/2},children:Ae(iL,{height:e,children:Ae(tL,{points:g.map(I=>[I.x,I.y])})})})})})})},_ut=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:n})=>{const o=Math.ceil(t/2),s=i*t/2+e/2,r=(o-1)*i/2,a=.25;return Ot(Tn,{children:[Array.from({length:o}).map((g,I)=>Ae(Pn,{position:{x:-n/2-A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:o}).map((g,I)=>Ae(Pn,{rotation:Math.PI,position:{x:n/2+A,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Ae(zB,{center:{x:0,y:0,z:a/2},width:n-e-1,length:s,height:1.5})]})},Mut=({pinCount:t,padContactLength:A=.4,leadWidth:e=.2,pitch:i=.65,bodyWidth:n=3})=>{const o=Math.ceil(t/2),s=(o-1)*i/2,r=.2;return Ot(Tn,{children:[Array.from({length:o}).map((a,g)=>Ae(Pn,{position:{x:-n/2-A-.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Array.from({length:o}).map((a,g)=>Ae(Pn,{rotation:Math.PI,position:{x:n/2+A+.3,y:g*i-s,z:r/2},width:e,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Ae(zB,{center:{x:0,y:0,z:r/2},width:n,length:n,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},NlA=1,_lA=.5,W_=.5,nL=.2,vut=NlA-nL*2,xVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[vut,_lA,W_],offset:[0,0,W_/2],color:t}),Ae(ht,{size:[nL,W_,_lA],offset:[NlA/2-nL/2,0,W_/2],color:"#ccc"}),Ae(ht,{size:[nL,W_,_lA],offset:[-NlA/2+nL/2,0,W_/2],color:"#ccc"})]}),MlA=1.6,Uut=MlA-.3*2,f5=.3,vlA=.85,Z_=.6,kVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[Uut,vlA,Z_],offset:[0,0,Z_/2],color:t}),Ae(ht,{size:[f5,vlA,Z_],offset:[MlA/2-f5/2,0,Z_/2],color:"#ccc"}),Ae(ht,{size:[f5,vlA,Z_],offset:[-MlA/2+f5/2,0,Z_/2],color:"#ccc"})]}),UlA=2,LlA=1.25,V_=.55,oL=.5,Lut=UlA-oL*2,GVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[Lut,LlA,V_],offset:[0,0,V_/2],color:t}),Ae(ht,{size:[oL,LlA,V_],offset:[UlA/2-oL/2,0,V_/2],color:"#ccc"}),Ae(ht,{size:[oL,LlA,V_],offset:[-UlA/2+oL/2,0,V_/2],color:"#ccc"})]}),Hut=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:n})=>{const o=t/4;A||(A=Yut(t,n)),i||(i=Jut(t)),e||(e=Tut(t,n)),n||(n=A*(o+4));const s=n,r=(o-1)*A/2,a=s+2*i,g=a,I=.8,c=.15,B=(g-n)/2+.5;return Ot(Tn,{children:[Array.from({length:o}).map((l,C)=>Ae(Pn,{position:{x:-g/2-.4,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:Math.PI,position:{x:g/2+.4,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.4,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Ae(zB,{center:{x:0,y:0,z:0},width:n,length:s,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:n/2-1.5,z:1.5},notchRadius:1.5/2})]})},Yut=(t,A)=>{switch(t){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},Jut=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}},Tut=(t,A)=>{switch(t){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},Kut=({numberOfPins:t,pitch:A=2.54,longSidePinLength:e=6,invert:i,faceup:n,rows:o=1})=>{const a=Math.ceil(t/o),g=2.54,I=a*A,c=o>1?(o-1)*g+.63*3:.63*3,B=3,l=-((a-1)/2)*A,C=o>1?-((o-1)*g)/2:0,Q=E=>i||n?-E+2:E;return Ot(Tn,{children:[Ae(ht,{color:"#222",size:[I,c,2],center:[0,C,Q(2/2)]}),Array.from({length:t},(E,h)=>{const u=Math.floor(h/a),d=h%a,f=l+d*A,w=-u*g;return Ot(Tn,{children:[!n&&Ae(ms,{color:"gold",children:Ot(aI,{children:[Ae(ht,{color:"gold",size:[.63,.63,B*.9],center:[f,w,Q(2*.9+2/2)]}),Ae(ht,{color:"gold",size:[.63/1.8,.63/1.8,B],center:[f,w,Q(2+2/2)]})]})}),Ae(ms,{color:"gold",children:Ot(aI,{children:[Ae(ht,{color:"gold",size:[.63,.63,e*.9],center:[f,w,Q(-e/2*.9)]}),Ae(ht,{color:"gold",size:[.63/1.8,.63/1.8,e],center:[f,w,Q(-e/2)]})]})})]})})]})},qut=t=>{const A=["left","bottom","right","top"],{pin_count:e,pn:i,w:n,h:o,p:s,pl:r}=t,a=e/4,g=A[Math.floor((i-1)/a)],I=(i-1)%a,c=s*(a-1),B=s*(a-1),l=-r/2;switch(g){case"left":return{x:-n/2-l,y:B/2-I*s,o:"vert"};case"bottom":return{x:-c/2+I*s,y:-o/2-l,o:"horz"};case"right":return{x:n/2+l,y:-B/2+I*s,o:"vert"};case"top":return{x:c/2-I*s,y:o/2+l,o:"horz"};default:throw new Error("Invalid pin number")}},Put=({num_pins:t,cw:A,ccw:e,startingpin:i})=>{const n=[],o=t/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=o:r.bottomside&&r.leftpin?s=o+1:r.bottomside&&r.rightpin?s=o*2:r.rightside&&r.bottompin?s=o*2+1:r.rightside&&r.toppin?s=o*3:r.topside&&r.rightpin?s=o*3+1:r.topside&&r.leftpin&&(s=o*4),n.push(-1);for(let a=0;a<t;a++)n[s]=a+1,s++,s>t&&(s=1);return n},Out=({num_pins:t=16,bodyWidth:A=9,bodyLength:e=9,bodyThickness:i=.8,thermalPadSize:n,padWidth:o=.25,padLength:s=.25,pitch:r=.5,thermalPadThickness:a=.05})=>{const g=Put({num_pins:t,cw:!0,ccw:!0}),I=[];for(let c=0;c<t;c++){const{x:B,y:l,o:C}=qut({pin_count:t,pn:c+1,w:A,h:e,p:r,pl:s});let Q=o,E=s;C==="vert"&&([Q,E]=[E,Q]);const h=g[c+1];I.push({pn:h,x:B,y:l,pw:Q,pl:E})}return Ot(Tn,{children:[Ae(ms,{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]})),n?.length!==void 0&&n?.width!==void 0&&Ae(ht,{center:{x:0,y:0,z:a/2},size:[n.width,n.length,a]})]})},Wut=Out,Zut=()=>{const a=1.1999999999999997;return Ot(Tn,{children:[Ae(Pn,{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(Pn,{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(Pn,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),Ae(Pn,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),Ae(Pn,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),Ae(zB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},Vut=Zut,jut=({fullWidth:t=2.9,fullLength:A=2.8})=>{const I=(t-1.92)/2+.3;return Ot(Tn,{children:[Ae(Pn,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),Ae(Pn,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),Ae(Pn,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),Ae(zB,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},HlA=.6,YlA=.3,j_=.33,sL=.1,zut=HlA-sL*2,FVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[zut,YlA,j_],offset:[0,0,j_/2],color:t}),Ae(ht,{size:[sL,YlA,j_],offset:[HlA/2-sL/2,0,j_/2],color:"#ccc"}),Ae(ht,{size:[sL,YlA,j_],offset:[-HlA/2+sL/2,0,j_/2],color:"#ccc"})]}),JlA=.4,TlA=.2,z_=.13,rL=.07,Xut=JlA-rL*2,RVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[Xut,TlA,z_],offset:[0,0,z_/2],color:t}),Ae(ht,{size:[rL,TlA,z_],offset:[JlA/2-rL/2,0,z_/2],color:"#ccc"}),Ae(ht,{size:[rL,TlA,z_],offset:[-JlA/2+rL/2,0,z_/2],color:"#ccc"})]}),KlA=3.2,qlA=1.6,X_=.9,aL=.5,$ut=KlA-aL*2,NVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[$ut,qlA,X_],offset:[0,0,X_/2],color:t}),Ae(ht,{size:[aL,qlA,X_],offset:[KlA/2-aL/2,0,X_/2],color:"#ccc"}),Ae(ht,{size:[aL,qlA,X_],offset:[-KlA/2+aL/2,0,X_/2],color:"#ccc"})]}),PlA=3.2,OlA=2.5,$_=1,gL=.6,Adt=PlA-gL*2,_VA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[Adt,OlA,$_],offset:[0,0,$_/2],color:t}),Ae(ht,{size:[gL,OlA,$_],offset:[PlA/2-gL/2,0,$_/2],color:"#ccc"}),Ae(ht,{size:[gL,OlA,$_],offset:[-PlA/2+gL/2,0,$_/2],color:"#ccc"})]}),WlA=5,ZlA=2.5,AM=1.4,IL=.6,edt=WlA-IL*2,MVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[edt,ZlA,AM],offset:[0,0,AM/2],color:t}),Ae(ht,{size:[IL,ZlA,AM],offset:[WlA/2-IL/2,0,AM/2],color:"#ccc"}),Ae(ht,{size:[IL,ZlA,AM],offset:[-WlA/2+IL/2,0,AM/2],color:"#ccc"})]}),VlA=6.3,jlA=3.2,eM=1.8,cL=.8,tdt=VlA-cL*2,vVA=({color:t="#333"})=>Ot(Tn,{children:[Ae(ht,{size:[tdt,jlA,eM],offset:[0,0,eM/2],color:t}),Ae(ht,{size:[cL,jlA,eM],offset:[VlA/2-cL/2,0,eM/2],color:"#ccc"}),Ae(ht,{size:[cL,jlA,eM],offset:[-VlA/2+cL/2,0,eM/2],color:"#ccc"})]}),idt=({numberOfPins:t,pitch:A=2.54,legsLength:e=3,outerDiameter:i=.945,innerDiameter:n=.945,rows:o=1})=>{const s=n/1.5,r=s*2+i,a=5,g=Math.ceil(t/o),I=2.54,c=(g-1)*A+i+A/2,B=o>1?(o-1)*I+r:r,l=s*1.6,C=-((g-1)/2)*A,Q=o>1?-((o-1)*I)/2:0,E=Ae(ms,{color:"#1a1a1a",children:Ot($G,{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,w=C+f*A,S=-d*I;return n?Ae(Zp,{height:a+.1,radius:n/2,center:[w,S,a/2],color:"#222"},u):Ae(ht,{size:[l,l,a],center:[w,S,a/2]},u)})]})});return Ot(Tn,{children:[E,Array.from({length:t},(h,u)=>{const d=Math.floor(u/g),f=u%g,w=C+f*A,S=-d*I;return Ot(ms,{color:"silver",children:[Ot(aI,{children:[Ae(ht,{color:"silver",size:[s,s,e*.9],center:[w,S,-e/2*.9]}),Ae(ht,{color:"silver",size:[s/1.8,s/1.8,e],center:[w,S,-e/2]})]}),Ae(ht,{color:"silver",size:[l,l,l*.5],center:[w,S,l/2*.5]})]},u)})]})},ndt=({width:t,length:A,innerDiameter:e=1})=>{const i=t,n=A,o=t*.7,s=e/2.5;return Ot(Tn,{children:[Ae(eL,{color:"#1a1a1f",center:[0,0,o/2],size:[n,n,o],roundRadius:.3}),Ae(eL,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[n,n,o*.1],roundRadius:.14}),Ae(Zp,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),Ae(Zp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,n/3,o+o*.1/2]}),Ae(Zp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,-n/3,o+o*.1/2]}),Ae(Zp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[-n/3,n/3,o+o*.1/2]}),Ae(Zp,{color:"#1a1a1f",height:o*.2,radius:e/2,center:[n/3,-n/3,o+o*.1/2]}),Ae(y5,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:-n/2,z:-o*1.2}}),Ae(y5,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:n/2,z:-o*1.2},rotation:Math.PI}),Ae(y5,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:i/2,y:n/2,z:-o*1.2},rotation:Math.PI}),Ae(y5,{thickness:e/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:i/2+e/3.6,y:-n/2,z:-o*1.2}})]})},y5=t=>{const{thickness:A,width:e,horizontalLength:i,verticalLength:n,rotation:o=0,position:s}=t,r=[[0,i],[-n/3,i/3],[-n/5,i/4],[0,0]],a=RlA(r,A);return Ae(ms,{color:"#f2f2f2",children:Ae(Vi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Ae(EQ,{rotation:[0,55,o],children:Ae(iL,{height:e,children:Ae(tL,{points:a.map(g=>[g.y,g.x])})})})})})},odt=({pinCount:t,leadLength:A,leadWidth:e,pitch:i,bodyWidth:n})=>{const o=Math.ceil(t/2),s=(o-1)*i/2,r=.25,a=1,g=.8,I=A*0,c=i*(o-1)+e+.2,B=n*.55;return Ot(Tn,{children:[Array.from({length:o}).map((l,C)=>Ae(Pn,{position:{x:-n/2-I,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:Math.PI,position:{x:n/2+I,y:C*i-s,z:r/2},width:e,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Ae(zB,{center:{x:0,y:0,z:r/2},width:B,length:c,height:a})]})},sdt=({pinCount:t,pitch:A,leadWidth:e,leadLength:i,bodyWidth:n,bodyLength:o})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},r=isNaN(parseFloat(A))?s.pitch:parseFloat(A),a=isNaN(parseFloat(e))?s.leadWidth:parseFloat(e)*.8,g=isNaN(parseFloat(n))?2.6:parseFloat(n)*.8,I=isNaN(parseFloat(o))?2+Number(r)*1.4:parseFloat(o),c=t/2,B=(c-1)*r/2,l=.15,C=.8,Q=4.5,E=(Q-g)/2,h=E*.5;return Ot(Tn,{children:[Array.from({length:c}).map((u,d)=>Ae(Pn,{position:{x:-Q/2,y:B-d*r,z:l/2},width:a,thickness:l,padContactLength:h+.05,bodyDistance:E+.1,height:C})),Array.from({length:c}).map((u,d)=>Ae(Pn,{rotation:Math.PI,position:{x:Q/2,y:B-d*r,z:l/2},width:a,thickness:l,padContactLength:h+.05,bodyDistance:E+.1,height:C})),Ae(zB,{center:{x:0,y:0,z:l/2},width:g,length:I,height:1})]})},rdt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ae(Vi,{z:.3/2,children:Ae(ht,{size:[1.65,.8,.3]})}),Ot(aI,{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]})})]})]})})]}),adt=()=>Ot(Tn,{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(ms,{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]})]}),gdt=()=>{const g=Ae(ms,{color:"#1a1a1a",children:Ot(gE,{children:[Ot(aI,{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(aI,{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 C=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return Ae(ms,{color:"#c0c0c0",children:Ot(gE,{children:[Ae(ht,{size:[2.3*.8,1.45,.2],center:[C,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(Tn,{children:[Ae(I,{xDir:1}),Ae(I,{xDir:-1}),g]})},Idt=()=>{const g=Ae(ms,{color:"#1a1a1a",children:Ot(gE,{children:[Ot(aI,{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(aI,{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 C=c*1.78,Q=c*(3.4/2-.2/2+1),E=c*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return Ae(ms,{color:"#c0c0c0",children:Ot(gE,{children:[Ae(ht,{size:[2.3*.8,1.45,.2],center:[C,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(Tn,{children:[Ae(I,{xDir:1}),Ae(I,{xDir:-1}),g]})},cdt=()=>{const g=Ae(ms,{color:"#1a1a1a",children:Ot(gE,{children:[Ot(aI,{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(aI,{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 C=c*3.08,Q=c*(6/2-.2/2+1),E=c*(6/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return Ae(ms,{color:"#c0c0c0",children:Ot(gE,{children:[Ae(ht,{size:[2.3*.8,2.95,.2],center:[C,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(Tn,{children:[Ae(I,{xDir:1}),Ae(I,{xDir:-1}),g]})},Bdt=()=>{const c=Ae(ms,{color:"#222",children:Ot(gE,{children:[Ae(Vi,{z:.27,children:Ae(ht,{size:[2.9,1.9,.54]})}),Ot(aI,{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(Tn,{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]})},ldt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ae(Vi,{z:.55/2,children:Ae(ht,{size:[2.7,1.6,.55]})}),Ot(aI,{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]})})]})]})})]}),Cdt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ae(Vi,{z:.2/2,children:Ae(ht,{size:[2.75,1.8,.2]})}),Ot(aI,{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]})]}),Qdt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ot(aI,{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(aI,{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]})]}),Edt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ot(aI,{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(aI,{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]})]}),hdt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ae(Vi,{z:.14/2,children:Ae(ht,{size:[.8,.6,.14]})}),Ot(aI,{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]})})]})]})})]}),udt=()=>{const I=3.0999999999999996;return Ot(Tn,{children:[Ae(Pn,{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(Pn,{position:{x:-6.6/2-I/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),Ae(Pn,{position:{x:-6.6/2-I/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),Ae(Pn,{position:{x:-6.6/2-I/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),Ae(zB,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},ddt=()=>Ot(Tn,{children:[Array.from({length:16}).map((l,C)=>Ae(Pn,{position:{x:-10.5/2,y:C*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((l,C)=>Ae(Pn,{rotation:Math.PI,position:{x:10.5/2,y:C*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((l,C)=>Ae(Pn,{rotation:Math.PI/2,position:{x:C*.5-3.75,y:-10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((l,C)=>Ae(Pn,{rotation:-Math.PI/2,position:{x:C*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Ae(zB,{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})]}),pdt=ddt,fdt=()=>{const g=.7999999999999998;return Ot(Tn,{children:[Ae(Pn,{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(Pn,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),Ae(Pn,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),Ae(zB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},ydt=({pinCount:t,pitch:A,leadWidth:e,padContactLength:i,bodyWidth:n})=>{const o=t/4;if(o!==Math.floor(o))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);A||(A=.5),i||(i=.6),e||(e=.22),n||(n=A*(o+4));const s=n,r=(o-1)*A/2,a=s+3.3*i,g=a,I=.8,c=.2,B=(g-n)/2+.4;return Ot(Tn,{children:[Array.from({length:o}).map((l,C)=>Ae(Pn,{position:{x:-g/2-.36,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:Math.PI,position:{x:g/2+.36,y:C*A-r,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Array.from({length:o}).map((l,C)=>Ae(Pn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.36,z:c/2},width:e,thickness:c,padContactLength:i,bodyDistance:B,height:I})),Ae(zB,{center:{x:0,y:0,z:0},width:n,length:s,height:1.5,heightAboveSurface:.1,taperRatio:.04,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:s/2-1.5,z:1.5},notchRadius:1.5/2})]})},mdt=()=>{const i=.20900000000000002,n=.1,o=.3,s=.1,r=.2;return Ot(Tn,{children:[Ae(ms,{color:"#222",children:Ot(gE,{children:[Ae(ht,{size:[.85,1.2,i],center:[0,0,i/2]}),Ot(aI,{children:[Ae(Vi,{z:i,children:Ae(ht,{size:[.85,1.2,.01]})}),Ae(Vi,{z:.38,children:Ae(ht,{size:[.85-n,1.2-n,.01]})})]})]})}),Ae(ht,{color:"#ccc",size:[o,.25,s],center:[.55,0,s/2]}),Ae(ht,{color:"#ccc",size:[o,r,s],center:[-.55,.4,s/2]}),Ae(ht,{color:"#ccc",size:[o,r,s],center:[-.55,-.4,s/2]})]})},wdt=({num_pins:t,bodyWidth:A=5.3,bodyLength:e=5.3,bodyThickness:i=1,thermalPadSize:n,padWidth:o=e/5.3*.6,padLength:s=e/5.3*1,pitch:r=.5,thermalPadThickness:a=.2})=>{const g=[],I=Math.floor(t/2),c=r*(I-1);for(let B=0;B<t;B++){const l=B<I?"left":"right",C=B%I,Q=c/2-C*r,E=s,h=o,u=l==="left"?-A/2+E/2:A/2-E/2,d=B+1;g.push({pinNumber:d,x:u,y:Q,padSizeX:E,padSizeY:h})}return Ot(Tn,{children:[Ae(zB,{center:{x:0,y:0,z:0},width:A,length:e,height:i,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(A/2-s),y:e/2-s,z:i}}),g.map((B,l)=>Ae(ht,{center:[B.x,B.y,a/2],size:[B.padSizeX,B.padSizeY,a]})),n?.length!==void 0&&n?.width!==void 0&&Ae(ht,{center:[0,0,a/2],size:[n.width,n.length,a]})]})},Ddt=({bodyLength:t=10.2,bodyWidth:A=4.65,bodyHeight:e=13.46,leadSpacing:i=5,leadDiameter:n=.8,leadLength:o=12.7,color:s="#ddd",leadColor:r="#b87333"})=>{const a=t/2,g=A/2,I=a-g,c=i/2,B=.85;return Ot(Tn,{children:[Ot(ms,{color:s,children:[Ot(aI,{children:[Ae(Vp,{height:e,roundRadius:.5,radius:g,center:[-I,0,e]}),Ae(Vp,{height:e,roundRadius:.5,radius:g,center:[I,0,e]})]}),Ot(aI,{children:[Ae(Vp,{height:B,roundRadius:.1,radius:g+.85,center:[-I,0,e/2+B/2]}),Ae(Vp,{height:B,roundRadius:.1,radius:g+.85,center:[I,0,e/2+B/2]})]})]}),Ot(ms,{color:r,children:[Ae(Zp,{height:o+e/2,radius:n/2,center:[-c+.06,0,-(o/2)+e/2]}),Ae(Zp,{height:o+e/2,radius:n/2,center:[c-.06,0,-(o/2)+e/2]})]})]})},Sdt=({bodyLength:t=1.4,bodyDiameter:A=1.1,color:e="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:n="#111"})=>Ot(Tn,{children:[Ae(ms,{color:e,children:Ot(EQ,{rotation:[0,"90deg",0],children:[Ae(eL,{size:[A,A,t-.2],roundRadius:.2,center:[-A/2,0,.05]}),Ae(Zp,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-t/2+.2/2]})]})}),Ae(ms,{color:n,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(eL,{size:[A*1.01,A*1.01,t/3],roundRadius:.2,center:[-A/2,0,-t/4+.1]})})}),Ae(ms,{color:i,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-t/2]})})}),Ae(ms,{color:i,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,t/2]})})})]}),bdt=({bodyLength:t=3.5,bodyDiameter:A=1.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Tn,{children:[Ae(ms,{color:e,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),Ae(ms,{color:i,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),Ae(ms,{color:i,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),xdt=({bodyLength:t=3.9,bodyDiameter:A=2.5,color:e="#3a3a3aff",contactColor:i="#c6c6c6"})=>Ot(Tn,{children:[Ae(ms,{color:e,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:t,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),Ae(ms,{color:i,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-t/2]})})}),Ae(ms,{color:i,children:Ae(EQ,{rotation:[0,"90deg",0],children:Ae(Vp,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,t/2]})})})]}),kdt=({pinCount:t,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t%2!==0)throw new Error("MS012 pinCount must be even");const n=t/2,o=4.9,s=3.9,r=(n-1)*i/2,a=.2;return Ot(Tn,{children:[Array.from({length:n}).map((g,I)=>Ae(Pn,{position:{x:-s/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,I)=>Ae(Pn,{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(zB,{center:{x:0,y:0,z:a/2},width:s,length:o,height:1.55,notchPosition:{x:-.95,y:o/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},Gdt=({pinCount:t=16,padContactLength:A=.6,leadWidth:e=.41,pitch:i=1.27})=>{if(t!==16)throw new Error("MS013 only supports 16 pins");const n=t/2,o=7.5,s=10.3,r=(n-1)*i/2,a=.2;return Ot(Tn,{children:[Array.from({length:n}).map((g,I)=>Ae(Pn,{position:{x:-o/2-A-.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,I)=>Ae(Pn,{rotation:Math.PI,position:{x:o/2+A+.3,y:I*i-r,z:a/2},width:e,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Ae(zB,{center:{x:0,y:0,z:a/2},width:o,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},Fdt=()=>{const Q=7.050000000000001,E=24.95+6.5/2;return Ae(Vi,{center:[0,0,1],children:Ot(Tn,{children:[Ot(EQ,{rotation:[0,55,-55],children:[Ot($G,{children:[Ae(ht,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[E,0,1.3-2]}),Ae(Zp,{color:"black",center:[E,0,1.3-2],radius:3/2,height:1.3*1.2})]}),Ae(ms,{color:"#222",children:Ae(zB,{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(EQ,{rotation:[0,55,55],children:Array.from({length:3}).map((h,u)=>{const d=Q,f=(u-1)*2.7,w=-.5-.6;return Ot(ms,{color:"gold",children:[Ot(aI,{children:[Ae(Vi,{center:[15.05-4.5/2+.1,f,w],children:Ae(ht,{size:[4.5,.81+1,.5]})}),Ae(Vi,{center:[15.05-4.5/2-1+.1,f,w],children:Ae(ht,{size:[4.5,.81,.5]})})]}),Ae(Vi,{center:[d,f,w],children:Ae(ht,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},Rdt=()=>{const g=1.1999999999999997;return Ot(Tn,{children:[Ae(Pn,{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(Pn,{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(Pn,{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(Pn,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),Ae(Pn,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),Ae(Pn,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),Ae(zB,{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})]})},Ndt=()=>Ot(Tn,{children:[Ae(zB,{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]})})]}),_dt=()=>{const s="#222",a=[.43,.4,1.32],g=[.43,.4,.25],I=[0,0,-.66],c=[0,0,-1.32],B=[0,1.28,-2.72],l=[0,1.28,-8.9],C=-7.5;return Ot(Vi,{center:[0,1,10.5],children:[Ae(ms,{color:s,children:Ot($G,{children:[Ae(Vi,{center:[0,0,2.25],children:Ae(Zp,{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(aI,{children:[Ae(Vi,{center:c,children:Ae(ht,{size:g})}),Ae(Vi,{center:B,children:Ae(ht,{size:g})})]}),Ae(Vi,{center:l,children:Ae(ht,{size:[.43,.4,12.2]})}),Ae(Vi,{center:[1.3,0,C],children:Ae(ht,{size:[.43,.4,15]})}),Ae(Vi,{center:[-1.3,0,C],children:Ae(ht,{size:[.43,.4,15]})})]})},Mdt=()=>Ot(Tn,{children:[Ae(Pn,{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(Pn,{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(Pn,{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(Pn,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(Pn,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(Pn,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ae(zB,{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})]}),vdt=Mdt,Udt=()=>Ot(Tn,{children:[Ae(zB,{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]})})]}),Ldt=()=>Ot(Tn,{children:[Ae(Pn,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ae(Pn,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ae(ms,{color:"#222",children:Ae(zB,{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]})]}),Hdt=()=>Ot(Tn,{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(ms,{color:"#222",children:Ot(gE,{children:[Ae(Vi,{z:.175/2,children:Ae(ht,{size:[1.7,1.25,.175]})}),Ot(aI,{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]})]}),Ydt=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return Ot(Tn,{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(ms,{color:"#222",children:Ae(zB,{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]})]})},Jdt=({footprint:t})=>{const A=but.string(t).json();switch(A.fn){case"dip":return Ae(Rut,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"tssop":return Ae(_ut,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return Ae(Mut,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return Ae(sdt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return Ae(Hut,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return Ae(pdt,{});case"lqfp":return Ae(ydt,{pinCount:A.num_pins});case"qfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return Ae(Wut,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:n?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"dfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return Ae(wdt,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:n?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"pinrow":{const n=t.match(/_rows(\d+)/),o=n&&n[1]?parseInt(n[1],10):1;if(A.male)return Ae(Kut,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:o});if(A.female)return Ae(idt,{numberOfPins:A.num_pins,pitch:A.p,rows:o})}case"cap":switch(A.imperial){case"0402":return Ae(xVA,{color:"#856c4d"});case"0603":return Ae(kVA,{color:"#856c4d"});case"0805":return Ae(GVA,{color:"#856c4d"});case"0201":return Ae(FVA,{color:"#856c4d"});case"01005":return Ae(RVA,{color:"#856c4d"});case"1206":return Ae(NVA,{color:"#856c4d"});case"1210":return Ae(_VA,{color:"#856c4d"});case"2010":return Ae(MVA,{color:"#856c4d"});case"2512":return Ae(vVA,{color:"#856c4d"})}case"sot235":return Ae(Vut,{});case"sot457":return Ae(Rdt,{});case"sot223":return Ae(udt,{});case"sot23w":return Ae(jut,{});case"sot323":return Ae(fdt,{});case"sod323f":return Ae(Hdt,{});case"sod323fl":return Ae(Ydt,{});case"sot363":return Ae(vdt,{});case"sot886":return Ae(Udt,{});case"sot963":return Ae(Ndt,{});case"pushbutton":return Ae(ndt,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return Ae(odt,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return Ae(rdt,{});case"sod882":return Ae(adt,{});case"sma":return Ae(gdt,{});case"smb":return Ae(Idt,{});case"smc":return Ae(cdt,{});case"smf":return Ae(Bdt,{});case"sod123f":return Ae(ldt,{});case"sod123fl":return Ae(Cdt,{});case"sod123w":return Ae(Qdt,{});case"sod128":return Ae(Edt,{});case"sod323":return Ae(Ldt,{});case"sod923":return Ae(hdt,{});case"hc49":return Ae(Ddt,{});case"micromelf":return Ae(Sdt,{});case"minimelf":return Ae(bdt,{});case"melf":return Ae(xdt,{});case"ms012":return Ae(kdt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return Ae(Gdt,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return Ae(mdt,{});case"to220":return Ae(Fdt,{});case"to92":return Ae(_dt,{})}const e=t.match(/_color\(([^)]+)\)/),i=e?e[1]:void 0;switch(A.imperial){case"0402":return Ae(xVA,{color:i});case"0603":return Ae(kVA,{color:i});case"0805":return Ae(GVA,{color:i});case"0201":return Ae(FVA,{color:i});case"01005":return Ae(RVA,{color:i});case"1206":return Ae(NVA,{color:i});case"1210":return Ae(_VA,{color:i});case"2010":return Ae(MVA,{color:i});case"2512":return Ae(vVA,{color:i})}return null},Tdt=t=>t&&typeof t=="object"&&"type"in t,tM=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},Kdt=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 Rw(t,A,e){const{jscad:{primitives:i,booleans:n,hulls:o,geometries:s,extrusions:r,transforms:a}}=e;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(B=>Rw(B,A,e));if(!Tdt(t))return[];const{type:g,props:I,children:c}=t;if(g===wVA)return(c??[]).flatMap(B=>Rw(B,A,e));if(g===ms){const B=I?.color;return(c??[]).flatMap(l=>Rw(l,B??A,e))}if(g===Vi){const B=Kdt(I?.offset??I?.center??{x:I?.x,y:I?.y,z:I?.z});return(c??[]).flatMap(C=>Rw(C,A,e)).map(({geom:C,color:Q})=>({geom:a.translate(B,C),color:Q??A}))}if(g===EQ){const B=Array.isArray(I?.rotation)?[tM(I.rotation[0]),tM(I.rotation[1]),tM(I.rotation[2])]:[tM(I?.x??0),tM(I?.y??0),tM(I?.z??0)];return(c??[]).flatMap(C=>Rw(C,A,e)).map(({geom:C,color:Q})=>({geom:a.rotateZ(B[2],a.rotateY(B[1],a.rotateX(B[0],C))),color:Q}))}if(g===gE||g===$G||g===aI){const B=(c??[]).flatMap(C=>Rw(C,A,e)).map(C=>C.geom);if(B.length===0)return[];let l;return g===gE?l=n.union(B):g===$G?l=n.subtract(B[0],B.slice(1)):l=o.hull(B),[{geom:l,color:A}]}if(g===tL){const B=I?.points??[];return[{geom:s.geom2.fromPoints(B),color:A??I?.color}]}if(g===iL){const B=(c??[]).flatMap(E=>Rw(E,A,e)).map(E=>E.geom);if(B.length===0)return[];const l=B.length>1?n.union(B):B[0],C=I?.height??I?.h??1;let Q=r.extrudeLinear({height:C},l);if(Q.polygons)for(const E of Q.polygons)!E.plane||!E.vertices||E.vertices.length<3||E.vertices.reverse();return[{geom:Q,color:A??I?.color}]}if(g===ht||g===DVA||g===Zp||g===SVA||g===eL||g===Vp){let B;if(g===ht){const l=I?.size??[1,1,1],C=I?.offset,Q=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);B=i.cuboid({size:l,center:Q})}else if(g===DVA){const l=I?.size??1,C=I?.offset,Q=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);B=i.cube({size:l,center:Q})}else if(g===Zp){const l=I?.height??1,C=I?.radius??1,Q=I?.center??[0,0,0];B=i.cylinder({height:l,radius:C,center:Q})}else if(g===SVA){const l=I?.radius??1,C=I?.center??[0,0,0];B=i.sphere({radius:l,center:C})}else if(g===Vp){const l=I?.height??1,C=I?.radius??1,Q=I?.roundRadius??.1,E=I?.center??[0,0,0];B=i.roundedCylinder({height:l,radius:C,roundRadius:Q,center:E})}else{const l=I?.size??[1,1,1],C=I?.roundRadius??.1,Q=I?.center??[0,0,0];B=i.roundedCuboid({size:l,roundRadius:C,center:Q})}return[{geom:B,color:A??I?.color}]}if(typeof g=="function"){const B=g(I??{});return Rw(B,A,e)}return(c??[]).flatMap(B=>Rw(B,A,e))}function qdt(t,A){return{geometries:Rw(t,void 0,{jscad:A})}}function UVA(t){if(t.polygons){const A=[],e=[],i=[];let n=0;for(const s of t.polygons){for(const a of s.vertices)a.index=n,A.push(a[0],a[1],a[2]),t.color&&t.color.length>=3?i.push(t.color[0],t.color[1],t.color[2]):i.push(1,1,1),n++;const r=s.vertices[0].index;for(let a=2;a<s.vertices.length;a++){const g=s.vertices[a-1].index,I=s.vertices[a].index;e.push(r,g,I)}}const o=new dg;if(o.setAttribute("position",new rI(new Float32Array(A),3)),o.setIndex(e),i.length>0&&o.setAttribute("color",new rI(new Float32Array(i),3)),t.transforms){const s=new ts;s.fromArray(t.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(t.sides){const A=[],e=[];for(const n of t.sides)A.push(n[0][0],n[0][1],0),t.color&&t.color.length>=3?e.push(t.color[0],t.color[1],t.color[2]):e.push(1,1,1);const i=new dg;if(i.setAttribute("position",new rI(new Float32Array(A),3)),e.length>0&&i.setAttribute("color",new rI(new Float32Array(e),3)),t.transforms){const n=new ts;n.fromArray(t.transforms),i.applyMatrix4(n)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new dg}function Pdt(t,A){const e=FlA(Jdt,{footprint:t});return qdt(e,A)}var Odt=({jscadPlan:t,positionOffset:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=wu(),{threeGeom:g,material:I}=j.useMemo(()=>{const B=(0,_It.executeJscadOperations)(MIt.default,t);if(!B||!B.polygons&&!B.sides)return{threeGeom:null,material:null};const l=UVA(B),C=new Ih({vertexColors:!0,side:Ll,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:l,material:C}},[t,r]),c=j.useMemo(()=>g?new Zn(g,I):null,[g,I]);return j.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),j.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]),j.useMemo(()=>{if(I)if(o){const B=new Ui(I.color.getHex());I.emissive.copy(B),I.emissive.setRGB(0,0,1),I.emissiveIntensity=.2}else I.emissiveIntensity=0},[o,I]),g?O.jsx($U,{isHovered:o,onHover:i,onUnhover:n,object:c}):null},Wdt=yr(I5()),Zdt=({positionOffset:t,footprint:A,rotationOffset:e,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=wu(),g=j.useMemo(()=>{if(!A)return null;const{geometries:I}=Pdt(A,Wdt),c=new Wp;for(const B of I.flat(1/0)){const l=B.geom;if(!l||!l.polygons&&!l.sides)continue;const C=new Ui(B.color);C.convertLinearToSRGB();const Q={...l,color:[C.r,C.g,C.b]},E=UVA(Q),h=new Ih({vertexColors:!0,side:Ll,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new Zn(E,h);c.add(u)}return c},[A,r]);return j.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),j.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]),j.useEffect(()=>{g&&g.traverse(I=>{I instanceof Zn&&I.material instanceof Ih&&(o?(I.material.emissive.setHex(255),I.material.emissiveIntensity=.2):I.material.emissiveIntensity=0)})},[o,g]),g?O.jsx($U,{isHovered:o,onHover:i,onUnhover:n,object:g}):null},Vdt=(...t)=>t,BL={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},LVA=({children:t,position:A,style:e})=>{const{camera:i,renderer:n}=wu(),o=j.useRef(document.createElement("div")),[s,r]=j.useState(null);return j.useEffect(()=>{const a=n?.domElement.parentNode;if(a)return a.style.position!=="relative"&&a.style.position!=="absolute"&&(a.style.position="relative"),a.appendChild(o.current),r(MP.createPortal(t,o.current)),()=>{a.contains(o.current)&&a.removeChild(o.current)}},[n,t]),XU(()=>{if(!i||!o.current||!n)return;const a=new Re(...A);a.project(i);const g=n.domElement.getBoundingClientRect(),I=Math.round((a.x+1)/2*g.width),c=Math.round((-a.y+1)/2*g.height);o.current.style.position="absolute",o.current.style.left=`${I}px`,o.current.style.top=`${c}px`,o.current.style.pointerEvents="none",o.current.style.zIndex=BL.htmlElements.toString(),e&&Object.assign(o.current.style,e)},[i,n,A,e]),s},HVA={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},YVA=j.createContext(void 0),jdt=({children:t})=>{const[A,e]=j.useState(HVA),i=j.useCallback((s,r)=>{e(a=>({...a,[s]:r}))},[]),n=j.useCallback(()=>{e(HVA)},[]),o=j.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:n}),[A,i,n]);return O.jsx(YVA.Provider,{value:o,children:t})},iM=()=>{const t=j.useContext(YVA);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},zlA,zdt="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function Xdt(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 $dt(){if(!zlA){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");zlA=Xdt(t)({locateFile:e=>`${zdt}/${e}`})}return zlA}function Apt(t){const A=new Wp;for(const e of t){const i=e.attributes.position?.array??[],n=e.index?.array??[];if(!i.length||!n.length)continue;const o=new dg;o.setAttribute("position",new Lo(i,3));const s=e.attributes.normal?.array??[];s.length?o.setAttribute("normal",new Lo(s,3)):o.computeVertexNormals(),o.setIndex(n);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 Zn(o,r);a.name=e.name,A.add(a)}return A}async function ept(t){const A=await fetch(t);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const e=await A.arrayBuffer(),n=(await $dt()).ReadStepFile(new Uint8Array(e),null);if(!n.success||!n.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=Apt(n.meshes),s=new gnA,r=await new Promise((a,g)=>{s.parse(o,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 JVA="step-glb-cache:";function tpt(t){const A=new Uint8Array(t),e=32768;let i="";for(let n=0;n<A.length;n+=e){const o=A.subarray(n,n+e);i+=String.fromCharCode(...o)}return btoa(i)}function ipt(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 npt(t){try{const A=localStorage.getItem(`${JVA}${t}`);return A?ipt(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function opt(t,A){try{const e=tpt(A);localStorage.setItem(`${JVA}${t}`,e)}catch(e){console.warn("Failed to write STEP GLB cache",e)}}var spt=({stepUrl:t,position:A,rotation:e,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r})=>{const[a,g]=j.useState(null);return j.useEffect(()=>{let I=!0,c=null;const B=npt(t);return B?(c=URL.createObjectURL(new Blob([B],{type:"model/gltf-binary"})),g(c),()=>{I=!1,c&&URL.revokeObjectURL(c)}):(ept(t).then(l=>{if(!I){URL.revokeObjectURL(l);return}c=l,g(l),fetch(l).then(C=>C.arrayBuffer()).then(C=>{opt(t,C)}).catch(C=>{console.warn("Failed to cache STEP GLB",C)})}).catch(l=>{console.error("Failed to convert STEP file to GLB",l),I&&g(null)}),()=>{I=!1,c&&URL.revokeObjectURL(c)})},[t]),a?O.jsx(uZA,{gltfUrl:a,position:A,rotation:e,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r}):null},TVA=({cad_component:t,circuitJson:A})=>{const[e,i]=j.useState(!1),{visibility:n}=iM(),[o,s]=j.useState(null),r=j.useCallback(E=>{E?.mousePosition?(i(!0),s(E.mousePosition)):(i(!1),s(null))},[]),a=j.useCallback(()=>{i(!1),s(null)},[]),g=j.useMemo(()=>mi(A).source_component.getUsing({source_component_id:t.source_component_id})?.name,[A,t.source_component_id]),I=j.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,l=t.model_step_url,C=t.rotation?Vdt(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=O.jsx(FIt,{url:c,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:C,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=O.jsx(uZA,{gltfUrl:B,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:C,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model},t.cad_component_id):l&&!t.model_jscad&&!t.footprinter_string?Q=O.jsx(spt,{stepUrl:l,position:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotation:C,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model}):t.model_jscad?Q=O.jsx(Odt,{jscadPlan:t.model_jscad,rotationOffset:C,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=O.jsx(Zdt,{positionOffset:t.position?[t.position.x,t.position.y,t.position.z]:void 0,rotationOffset:C,footprint:t.footprinter_string,scale:t.model_unit_to_mm_scale_factor,onHover:r,onUnhover:a,isHovered:e,isTranslucent:t.show_as_translucent_model})),t.show_as_translucent_model){if(!n.translucentModels)return null}else if(I&&!n.throughHoleModels||!I&&!n.smtModels)return null;return O.jsxs(O.Fragment,{children:[Q,e&&o?O.jsx(LVA,{position:o,style:{fontFamily:"sans-serif",transform:"translate3d(1rem, 1rem, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:g??"<unknown>"}):null]})},KVA={version:"0.0.484"};function rpt(t){t.querySelectorAll("canvas").forEach(A=>A.remove())}var apt=t=>{t.outputColorSpace=Bm,t.toneMapping=$UA,t.toneMappingExposure=1},qVA="cadViewerCameraStateSession",PVA=(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(qVA,JSON.stringify(e))}catch(e){console.warn("Failed to save camera:",e)}},XlA=(t,A)=>{try{const e=sessionStorage.getItem(qVA);if(!e)return!1;const i=JSON.parse(e);if(t.position.fromArray(i.position),t.quaternion.fromArray(i.quaternion),t.up.fromArray(i.up),"fov"in t){const n=t;n.fov=i.fov,n.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),t.updateMatrixWorld(),!0}catch(e){return console.warn("Failed to restore camera:",e),!1}},OVA=j.createContext(void 0),gpt=({children:t,defaultTarget:A,initialCameraPosition:e})=>{const i=j.useRef(null),n=j.useRef(null),[o,s]=j.useState(null),[r,a]=j.useState("perspective"),[g,I]=j.useState(e??null),[c,B]=j.useState(new Pp(0,0,0)),l=j.useMemo(()=>{const[h,u,d]=e??[5,-5,5],f=Math.hypot(h-A.x,u-A.y,d-A.z);return f>0?f:5},[e,A]),C=j.useCallback(h=>{const u=[A.x,A.y,A.z],d=n.current,f=i.current;let w=l;switch(d&&f&&(w=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const S=w/Math.sqrt(2);return{position:[A.x,A.y-S,A.z+S],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+w],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-w*.6,A.y-w*.6,A.z+w*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+w*.6,A.y-w*.6,A.z+w*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-w,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+w,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-w,A.z],target:u,up:[0,0,1]};default:return null}},[l,A,n,i]),Q=j.useCallback(h=>{i.current=h},[]),E=j.useMemo(()=>({controlsRef:i,mainCameraRef:n,defaultTarget:A,baseDistance:l,controller:o,setController:s,getPresetConfig:C,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:I,cameraRotation:c,setCameraRotation:B,saveCameraToSession:PVA,loadCameraFromSession:XlA}),[A,l,o,C,Q,r,g,c]);return O.jsx(OVA.Provider,{value:E,children:t})},bx=()=>{const t=j.useContext(OVA);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},Ipt=j.forwardRef(({children:t,scene:A,camera:e,style:i,onCreated:n},o)=>{const{cameraType:s}=bx(),r=j.useRef(null),[a,g]=j.useState(null),I=j.useRef([]),c=j.useRef(void 0);c.current=n;const B=j.useRef(null),l=j.useCallback(h=>{I.current.push(h)},[]),C=j.useCallback(h=>{I.current=I.current.filter(u=>u!==h)},[]),Q=j.useMemo(()=>new UG,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const E=j.useRef(new ug);return j.useImperativeHandle(o,()=>E.current),j.useEffect(()=>{if(!r.current)return;rpt(r.current);const h=new z3({antialias:!0,alpha:!0});apt(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 aE(75,u,.1,1e3):new BU(-10*u,10*u,10,-10,-1e3,1e3);B.current?(d.position.copy(B.current.position),d.quaternion.copy(B.current.quaternion),d.up.copy(B.current.up)):(e?.up&&d.up.set(e.up[0],e.up[1],e.up[2]),e?.position&&d.position.set(e.position[0],e.position[1],e.position[2]),d.lookAt(0,0,0)),Q.add(E.current),window.__TSCIRCUIT_THREE_OBJECT=E.current,g({scene:Q,camera:d,renderer:h,rootObject:E.current,addFrameListener:l,removeFrameListener:C}),c.current?.({camera:d,renderer:h});let f;const w=new bXe,S=()=>{const x=w.getElapsedTime(),F=w.getDelta();I.current.forEach(k=>k(x,F)),h.render(Q,d),f=requestAnimationFrame(S)};S();const D=()=>{if(r.current){const x=r.current.clientWidth/r.current.clientHeight;d instanceof aE?d.aspect=x:d instanceof BU&&(d.left=-10*x,d.right=10*x,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),h.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",D),()=>{B.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",D),cancelAnimationFrame(f),r.current&&h.domElement&&r.current.removeChild(h.domElement),h.dispose(),Q.remove(E.current),window.__TSCIRCUIT_THREE_OBJECT===E.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,l,C,s]),O.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&O.jsx(CZA.Provider,{value:a,children:O.jsx(SIt,{children:t})})})}),cpt=({autoRotate:t,autoRotateSpeed:A,onStart:e,panSpeed:i,rotateSpeed:n,zoomSpeed:o,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:I,renderer:c}=wu(),B=j.useMemo(()=>!I||!c?null:new o7e(I,c.domElement),[I,c]);return j.useEffect(()=>(g?.(B??null),()=>g?.(null)),[B,g]),j.useEffect(()=>{if(!B)return;const l=()=>{g?.(B)};return B.addEventListener("change",l),()=>{B.removeEventListener("change",l)}},[B,g]),j.useEffect(()=>{B&&(B.autoRotate=t||!1,B.autoRotateSpeed=A||1,i!==void 0&&(B.panSpeed=i),n!==void 0&&(B.rotateSpeed=n),o!==void 0&&(B.zoomSpeed=o),s!==void 0&&(B.enableDamping=s),r!==void 0&&(B.dampingFactor=r),B.zoomToCursor=!0,B.mouseButtons={LEFT:ex.ROTATE,MIDDLE:ex.PAN,RIGHT:null},a&&(B.target.set(a[0],a[1],a[2]),B.update()))},[B,t,A,i,n,o,s,r,a]),j.useEffect(()=>{if(!(!B||!e))return B.addEventListener("start",e),()=>{B.removeEventListener("start",e)}},[B,e]),j.useEffect(()=>{if(B)return()=>{B.dispose()}},[B]),XU(()=>{B?.update()},[B]),null},Bpt=`
5067
5067
  varying vec3 worldPosition;
5068
5068
  void main() {
5069
5069
  worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
@@ -5097,12 +5097,12 @@ ${a.join(`
5097
5097
  gl_FragColor = vec4(color, max(g1, g2) * a);
5098
5098
  if (gl_FragColor.a <= 0.0) discard;
5099
5099
  }
5100
- `,Cpt=({rotation:t,infiniteGrid:A,cellSize:e=1,sectionSize:i=10})=>{const{scene:n,camera:o}=wu(),s=1e3,r=j.useMemo(()=>{const a=new ym(s,s);a.rotateX(-Math.PI/2);const g=new mw({vertexShader:Bpt,fragmentShader:lpt,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:Ll}),I=new Zn(a,g);return t&&I.rotation.fromArray(t),I},[s,e,i,t]);return XU(()=>{A&&r.position.set(o.position.x,o.position.y,0)}),j.useEffect(()=>{if(!(!n||!r))return n.add(r),()=>{n.remove(r),r.geometry.dispose(),Array.isArray(r.material)?r.material.forEach(a=>a.dispose()):r.material.dispose()}},[n,r]),null},Qpt=()=>{const{scene:t}=wu(),A=j.useMemo(()=>new yYA(16777215,Math.PI/2),[]),e=j.useMemo(()=>{const i=new tnA(16777215,Math.PI/4);return i.position.set(-10,-10,10),i.decay=0,i},[]);return j.useEffect(()=>{if(t)return t.add(A),t.add(e),()=>{t.remove(A),t.remove(e)}},[t,A,e]),null},Ept=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,hpt=()=>{const{controlsRef:t,mainCameraRef:A,defaultTarget:e,setController:i,getPresetConfig:n}=bx(),o=j.useRef(null),s=j.useRef(new dd),r=j.useRef(new Re),a=j.useRef(new Re),g=j.useRef(new dd),I=j.useRef(new dd),c=j.useRef(new ug),B=j.useRef(new ug),l=j.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]),w=E?new Re(E[0],E[1],E[2]):e.clone(),S=new Re(...h??[0,0,1]).normalize(),D=B.current;D.position.copy(f),D.up.copy(S),D.lookAt(w);const x=D.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 L=_.quaternion.clone();_.up.set(0,0,1),_.position.copy(f),_.lookAt(w);const K=_.quaternion.clone(),J=L.clone().invert().multiply(F).normalize(),W=K.clone().invert().multiply(x).normalize();o.current={fromPosition:k,toPosition:f,fromTarget:v,toTarget:w,toQuaternion:x,rollFrom:J,rollTo:W,startTime:performance.now(),duration:u}},[A,t,e]),C=j.useCallback(Q=>{if(Q==="Custom")return;const E=n(Q);E&&l(E)},[l,n]);return j.useEffect(()=>A.current?(i({animateTo:l,animateToPreset:C}),()=>{i(null)}):void 0,[l,C,A,i]),XU(()=>{if(!A.current||!o.current)return;const{fromPosition:Q,toPosition:E,fromTarget:h,toTarget:u,toQuaternion:d,rollFrom:f,rollTo:w,startTime:S,duration:D}=o.current,x=performance.now()-S,F=D<=0?1:Math.min(x/D,1),k=Ept(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 L=s.current;L.copy(_.quaternion);const K=g.current;K.copy(f);const J=I.current;J.copy(w),f.dot(w)<0&&(J.x*=-1,J.y*=-1,J.z*=-1,J.w*=-1),J.normalize(),K.slerp(J,k),A.current.quaternion.copy(L).multiply(K).normalize();const W=a.current;W.set(0,1,0).applyQuaternion(A.current.quaternion).normalize(),A.current.up.copy(W),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(),o.current=null)}),null},upt=()=>{const{controlsRef:t}=bx(),A=j.useRef(null),e=j.useRef(!1),i=j.useRef(null),n=j.useCallback(s=>{A.current=s,!e.current&&t.current&&XlA(s,t.current)&&(e.current=!0)},[t]),o=j.useCallback(()=>{if(!(!A.current||!t.current)){if(!e.current&&XlA(A.current,t.current)){e.current=!0;return}clearTimeout(i.current),i.current=setTimeout(()=>{A.current&&t.current&&PVA(A.current,t.current)},150)}},[t]);return{handleCameraCreated:n,handleControlsChange:o}};function dpt(t,A){const e=new dd().setFromEuler(new Pp(t.x,t.y,t.z)),i=new Re(0,0,1);return i.applyQuaternion(e),i.multiplyScalar(A)}var ppt=()=>{const{mainCameraRef:t}=bx(),A=j.useRef(null),e=j.useRef(null),i=j.useRef(null),n=j.useRef(null),o=j.useRef(null),s=j.useRef(null);return j.useEffect(()=>{if(!A.current)return;const r=document.createElement("canvas");e.current=r,A.current.appendChild(r);const a=new z3({canvas:r,antialias:!0,alpha:!0});a.setSize(120,120),a.setPixelRatio(window.devicePixelRatio),i.current=a;const g=new UG;n.current=g;const I=new aE(75,1,.1,1e3);I.up.set(0,0,1),o.current=I;const c=new yYA(16777215,Math.PI/2);g.add(c);const B=new Wp;B.rotation.fromArray([Math.PI/2,0,0]);const l=1,C=new Zn(new fm(l,l,l),new Ih({color:"white"}));B.add(C);const Q=new hU(new qze(new fm(l,l,l)),new LG({color:0,linewidth:2}));B.add(Q),g.add(B);const E=.51,h=(F,k,v)=>{const _=new xnA;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]),w=h("Left",[-E,0,0],[0,-Math.PI/2,0]),S=h("Top",[0,E,0],[-Math.PI/2,0,0]),D=h("Bottom",[0,-E,0],[Math.PI/2,0,0]);B.add(u),B.add(d),B.add(f),B.add(w),B.add(S),B.add(D);const x=()=>{if(t.current){const F=dpt(t.current.rotation??new Pp(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(),w.dispose(),S.dispose(),D.dispose(),C.geometry.dispose(),C.material.dispose(),Q.geometry.dispose(),Q.material.dispose(),g.clear(),a.dispose(),e.current&&A.current&&A.current.removeChild(e.current)}},[t]),O.jsx("div",{ref:A,style:{position:"absolute",top:0,left:0,width:120,height:120,zIndex:BL.orientationCube}})},fpt=()=>{const{camera:t}=wu(),{setCameraRotation:A}=bx();return XU(()=>{t&&A(t.rotation)}),null},WVA=j.forwardRef(({children:t,initialCameraPosition:A=[5,-5,5],autoRotateDisabled:e,clickToInteractEnabled:i=!1,boardDimensions:n,boardCenter:o,onUserInteraction:s,onCameraControllerReady:r},a)=>{const[g,I]=j.useState(!i),{mainCameraRef:c,handleControlsChange:B,controller:l}=bx(),{handleCameraCreated:C,handleControlsChange:Q}=upt();j.useEffect(()=>{r&&r(l)},[l,r]);const E=j.useMemo(()=>{if(!n)return 10;const u=n.width??0,d=n.height??0,w=Math.max(u,d)*1.5;return w>10?w:10},[n]),h=j.useMemo(()=>{if(o)return[o.x,o.y,0]},[o]);return O.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[O.jsx(ppt,{}),O.jsxs(Ipt,{ref:a,scene:{up:new Re(0,0,1)},camera:{up:[0,0,1],position:A},onCreated:({camera:u})=>{c.current=u,C(u)},children:[O.jsx(hpt,{}),O.jsx(fpt,{}),g&&O.jsx(cpt,{autoRotate:!e,autoRotateSpeed:1,onStart:s,rotateSpeed:.5,panSpeed:.75,zoomSpeed:.5,enableDamping:!0,dampingFactor:.1,target:h,onControlsChange:u=>{B(u),Q()}}),O.jsx(Qpt,{}),O.jsx(Cpt,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:3,sectionSize:E,args:[E,E]}),t]}),O.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:["@",KVA.version]}),i&&!g&&O.jsx("button",{type:"button",onClick:()=>I(!0),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&I(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:BL.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center"},children:O.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"})})]})}),ZVA=t=>j.useMemo(()=>{if(!t)return[];const A=new HPe;return A.add(t),A.render(),A.getCircuitJson()},[t]),ypt=t=>{const[A,e]=j.useState([]),[i,n]=j.useState(!0);return j.useEffect(()=>{if(!t)return;(async()=>{n(!0);const r=(Array.isArray(t)?t:[t]).map(async(a,g)=>{const I=$it.serialize({binary:!0},[a]),B=await new Blob(I).arrayBuffer(),C=a.layerType||(g===0?"board":void 0);return{stlData:B,color:a.color,layerType:C}});try{const a=await Promise.all(r);e(a)}catch(a){console.error("Error generating STLs:",a),e([])}finally{n(!1)}})()},[t]),{stls:A,loading:i}},mpt=yr(wx()),wpt=yr(t5()),Vn=.01,gI={traces:.001,copper:.002},Mn={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]},Ey=.001,wC=32,m5=.035,hc=150,w5=.6,$lA={fr1:Mn.fr1Tan,fr4:Mn.fr4Tan},Dpt={fr1:Mn.fr1TracesWithMaskCopper,fr4:Mn.fr4TracesWithoutMaskTan},VVA={fr1:Mn.fr1SolderMaskGreen,fr4:Mn.fr4SolderMaskGreen},Spt=yr(zU()),bpt=yr(wx()),xpt=yr(zG()),kpt=yr(ElA()),ACA=t=>{let A=0;for(let i=0;i<t.length;i++){const n=(i+1)%t.length;A+=t[i][0]*t[n][1],A-=t[n][0]*t[i][1]}return A/2<=0},eCA=(t,A=1.2,e={})=>{const{xyOutset:i=0}=e,{outline:n}=t;let o=n.map(a=>[a.x,a.y]);ACA(o)&&(o=o.reverse());let s=(0,bpt.polygon)({points:o});i!==0&&(s=(0,kpt.expand)({delta:i,corners:"edge"},s));let r=(0,Spt.extrudeLinear)({height:A},s);return r=(0,xpt.translate)([0,0,-A/2],r),r},Gpt=t=>{const A=t.filter(a=>a.type==="pcb_panel"),e=mi(t).pcb_board.list();let i,n=1.2;if(A.length>0)i=A[0],n=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"),[];n=i.thickness??1.2}let o;"outline"in i&&i.outline&&i.outline.length>0?o=eCA({outline:i.outline},n):o=(0,mpt.cuboid)({size:[i.width??10,i.height??10,n],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=$lA[s]??Mn.fr4Tan;return[(0,wpt.colorize)(r,o)]},Du=yr(zG()),II=yr(wx()),Su=yr(t5()),cI=yr(T_()),Jg=yr(wx()),CS=yr(t5()),JI=yr(T_()),jVA=yr(zG()),D5=yr(zU()),QS=yr(zG());function hy(t,A,e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return 0;const i=t/2,n=A/2;return Math.max(0,Math.min(e,i,n))}function Qh(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 xx=yr(wx()),Fpt=yr(zU()),S5=yr(zG()),Rpt=yr(T_()),Npt=64,_pt=(t,A,e)=>{const i=(0,xx.ellipse)({center:[0,0],radius:[Math.max(t/2,Vn/2),Math.max(A/2,Vn/2)],segments:Npt}),n=(0,Fpt.extrudeLinear)({height:e},i);return(0,S5.translate)([0,0,-e/2],n)},Mpt=(t,A,e)=>{const i=Math.max(t,Vn),n=Math.max(A,Vn);if(Math.abs(i-n)<1e-6)return(0,xx.cylinder)({center:[0,0,0],radius:i/2,height:e});const o=i>=n,s=o?i:n,r=o?n:i,a=Math.max(s-r,0),g=(0,xx.cuboid)({center:[0,0,0],size:o?[a,r,e]:[r,a,e]});if(a<=1e-6)return(0,xx.cylinder)({center:[0,0,0],radius:r/2,height:e});const I=a/2,c=(0,xx.cylinder)({center:o?[-I,0,0]:[0,-I,0],radius:r/2,height:e}),B=(0,xx.cylinder)({center:o?[I,0,0]:[0,I,0],radius:r/2,height:e});return(0,Rpt.union)(g,c,B)},b5=(t,A,e={})=>{const i=t.hole_shape||"circle",n=e.sizeDelta??0,o=t.hole_offset_x||0,s=t.hole_offset_y||0,r=[t.x+o,t.y+s,0];if(i==="circle"){const l=Math.max((t.hole_diameter??0)+n,Vn),C=Math.max(l/2,Vn/2);return(0,xx.cylinder)({center:r,radius:C,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+n,Vn),c=Math.max(g+n,Vn);if(i==="oval"){const l=_pt(I,c,A);return(0,S5.translate)([r[0],r[1],0],l)}if(i==="pill"||i==="rotated_pill"){let l=Mpt(I,c,A);if(!l)return null;const C=t.ccw_rotation||0;return C&&(l=(0,S5.rotateZ)(C*Math.PI/180,l)),(0,S5.translate)(r,l)}const B=Math.max((t.hole_diameter??a??g??Vn)+n,Vn);return(0,xx.cylinder)({center:r,radius:B/2,height:A})},Nw=.02,tCA=64,nM=(t,A)=>A?(0,JI.intersect)(A,t):t,x5=({width:t,height:A,thickness:e,center:i,borderRadius:n})=>{const o=hy(t,A,n);if(o<=0)return(0,Jg.cuboid)({center:i,size:[t,A,e]});const s=(0,Jg.roundedRectangle)({size:[t,A],roundRadius:o,segments:tCA}),r=(0,D5.extrudeLinear)({height:e},s),a=i[2]-e/2;return(0,QS.translate)([i[0],i[1],a],r)},k5=(t,A,e={})=>{const{clipGeom:i}=e;t.shape||(t.shape="circle");const n=A.pcbThickness+2*Nw+4*Vn,o=A.pcbThickness/2+gI.copper,s=-A.pcbThickness/2-gI.copper,r=o-s;if(t.shape==="circle"){const a=t.outer_diameter??Math.max(t.hole_diameter,0),g=r+.01,I=(0,Jg.cylinder)({center:[t.x,t.y,0],radius:a/2,height:g}),c=nM(I,i),B=(0,Jg.cylinder)({center:[t.x,t.y,0],radius:Math.max(t.hole_diameter/2,.01),height:n});return(0,CS.colorize)(Mn.copper,(0,JI.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,Jg.cylinder)({center:[0,0,0],radius:1,height:r+.01,segments:64}),E=(0,jVA.scale)([a/2,g/2,1],Q);return(0,QS.translate)([t.x,t.y,0],E)})(),l=nM(B,i),C=(()=>{const Q=(0,Jg.cylinder)({center:[0,0,0],radius:1,height:n,segments:64}),E=(0,jVA.scale)([Math.max(I/2,.01),Math.max(c/2,.01),1],Q);return(0,QS.translate)([t.x,t.y,0],E)})();return(0,CS.colorize)(Mn.copper,(0,JI.subtract)(l,C))}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=Qh(t),l=nM((0,JI.union)(x5({width:I,height:c,thickness:Nw,center:[t.x,t.y,o],borderRadius:B}),x5({width:I,height:c,thickness:Nw,center:[t.x,t.y,s],borderRadius:B}),(()=>{const h=Math.max(r-Nw*2,Vn),f=(o+s)/2,w=(0,Jg.roundedRectangle)({size:[I,c],roundRadius:B||0,segments:tCA}),S=(0,D5.extrudeLinear)({height:h},w);return(0,QS.translate)([t.x,t.y,f-h/2],S)})(),(0,Jg.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:t.hole_diameter/2,height:r})),i),C=(0,Jg.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:Math.max(t.hole_diameter/2-Vn,.01),height:n}),Q=(0,Jg.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:t.hole_diameter/2,height:r});let E=(0,JI.union)((0,JI.subtract)(l,Q),Q);return e.clipGeom?(E=(0,JI.subtract)(E,C),E=(0,JI.intersect)(E,e.clipGeom),(0,CS.colorize)(Mn.copper,E)):(0,CS.colorize)(Mn.copper,(0,JI.subtract)(E,C))}if(t.shape==="pill"){const a=(t.ccw_rotation||0)*Math.PI/180,g=k=>{if(!a)return k;const v=(0,QS.translate)([-t.x,-t.y,0],k),_=(0,QS.rotate)([0,0,a],v);return(0,QS.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,l=I?t.outer_height||B+.2:t.outer_width||c+.2,C=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 L=v/2,K=Math.abs(k-v);if(K<=1e-6)return(0,Jg.cylinder)({center:[t.x,t.y,0],radius:L,height:_});const J=(0,Jg.cuboid)({center:[t.x,t.y,0],size:I?[v,K,_]:[K,v,_]}),W=(0,Jg.cylinder)({center:I?[t.x,t.y-K/2,0]:[t.x-K/2,t.y,0],radius:L,height:_}),Z=(0,Jg.cylinder)({center:I?[t.x,t.y+K/2,0]:[t.x+K/2,t.y,0],radius:L,height:_});return(0,JI.union)(J,W,Z)})(l,C,h),f=(0,Jg.cuboid)({center:[t.x,t.y,0],size:I?[B-2*Vn,E,n]:[E,B-2*Vn,n]}),w=(0,Jg.cylinder)({center:I?[t.x,t.y-E/2,0]:[t.x-E/2,t.y,0],radius:Q-Vn,height:n}),S=(0,Jg.cylinder)({center:I?[t.x,t.y+E/2,0]:[t.x+E/2,t.y,0],radius:Q-Vn,height:n}),D=(0,JI.union)(f,w,S),x=nM(g(d),i),F=g(D);return(0,CS.colorize)(Mn.copper,(0,JI.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,l=B/2,C=Math.abs(c-B),Q=t.rect_pad_width||c+.2,E=t.rect_pad_height||B+.2,h=Qh(t),u=.03,d=(0,JI.union)((0,Jg.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B+2*u,C+2*u,r]:[C+2*u,B+2*u,r]}),(0,Jg.cylinder)({center:I?[t.x+a,t.y+g-C/2,0]:[t.x+a-C/2,t.y+g,0],radius:l+u,height:r}),(0,Jg.cylinder)({center:I?[t.x+a,t.y+g+C/2,0]:[t.x+a+C/2,t.y+g,0],radius:l+u,height:r})),f=(0,JI.union)((0,Jg.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B,C,n*1.1]:[C,B,n*1.1]}),(0,Jg.cylinder)({center:I?[t.x+a,t.y+g-C/2,0]:[t.x+a-C/2,t.y+g,0],radius:l,height:n*1.1}),(0,Jg.cylinder)({center:I?[t.x+a,t.y+g+C/2,0]:[t.x+a+C/2,t.y+g,0],radius:l,height:n*1.1})),w=x5({width:Q,height:E,thickness:Nw,center:[t.x,t.y,o],borderRadius:h}),S=x5({width:Q,height:E,thickness:Nw,center:[t.x,t.y,s],borderRadius:h}),D=(()=>{const K=Math.max(r-Nw*2,Vn),Z=(o+s)/2,AA=(0,Jg.roundedRectangle)({size:[Q,E],roundRadius:h||0,segments:tCA}),nA=(0,D5.extrudeLinear)({height:K},AA);return(0,QS.translate)([t.x,t.y,Z-K/2],nA)})(),x=(0,JI.subtract)(w,f),F=(0,JI.subtract)(S,f),k=(0,JI.subtract)(D,f),v=(0,JI.union)((0,Jg.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B-2*Vn,C-2*Vn,n*1.1]:[C-2*Vn,B-2*Vn,n*1.1]}),(0,Jg.cylinder)({center:I?[t.x+a,t.y+g-C/2,0]:[t.x+a-C/2,t.y+g,0],radius:l-Vn,height:n*1.1}),(0,Jg.cylinder)({center:I?[t.x+a,t.y+g+C/2,0]:[t.x+a+C/2,t.y+g,0],radius:l-Vn,height:n*1.1})),_=(0,JI.subtract)(d,v),L=nM((0,JI.union)(x,F,k,_),i);return(0,CS.colorize)(Mn.copper,L)}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,Jg.polygon)({points:g}),c=(o+s)/2,B=(f,w)=>{const S=Math.max(f,Vn),D=(0,D5.extrudeLinear)({height:S},I);return(0,QS.translate)([t.x,t.y,w-S/2],D)},l=B(Math.max(r-Nw*2,Vn),c),C=B(Nw,o),Q=B(Nw,s),E=nM((0,JI.union)(l,C,Q),i),h=b5(t,r);if(!h)return(0,CS.colorize)(Mn.copper,E);const u=b5(t,n,{sizeDelta:-2*Vn})||h;let d=(0,JI.union)((0,JI.subtract)(E,h),h);return e.clipGeom?(d=(0,JI.subtract)(d,u),d=(0,JI.intersect)(d,e.clipGeom),(0,CS.colorize)(Mn.copper,d)):(0,CS.colorize)(Mn.copper,(0,JI.subtract)(d,u))}else throw new Error(`Unsupported plated hole shape: ${t.shape}`)},lL=yr(zU()),vpt=yr(ElA()),zVA=yr(wx()),Upt=yr(T_());function Lpt(t,A,e,i){if(!e||Math.abs(e)<1e-9)return[];const n=4*Math.atan(e),o=A[0]-t[0],s=A[1]-t[1],r=Math.sqrt(o*o+s*s);if(r<1e-9)return[];const a=Math.abs(r/(2*Math.sin(n/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=o/r,l=-(s/r),C=c,Q=I[0]+l*g*Math.sign(e),E=I[1]+C*g*Math.sign(e),h=Math.atan2(t[1]-E,t[0]-Q),u=[],d=Math.max(2,Math.ceil(i*Math.abs(n)/(Math.PI*2)*4)),f=n/d;for(let w=1;w<d;w++){const S=h+f*w;u.push([Q+a*Math.cos(S),E+a*Math.sin(S)])}return u}function G5(t,A){const e=[],i=t.vertices;for(let n=0;n<i.length;n++){const o=i[n],s=i[(n+1)%i.length];if(e.push([o.x,o.y]),o.bulge){const r=Lpt([o.x,o.y],[s.x,s.y],o.bulge,A);e.push(...r)}}return e}function XVA(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 Hpt(t,A=16){let e=G5(t.outer_ring,A);XVA(e)&&e.reverse();const i=(0,zVA.polygon)({points:e});if(!t.inner_rings||t.inner_rings.length===0)return i;const n=t.inner_rings.map(o=>{let s=G5(o,A);return XVA(s)&&s.reverse(),(0,zVA.polygon)({points:s})});return n.length===0?i:(0,Upt.subtract)(i,n)}var $VA=yr(T_()),Ypt=yr(zG()),CL=yr(wx());function Jpt({x:t,y:A,outerDiameter:e,holeDiameter:i,thickness:n}){if(e<=i)throw new Error(`Invalid via geometry: outerDiameter (${e}) must be > holeDiameter (${i})`);const o=Vn,s=Vn,r=Math.min(e/2,i/2+s),a=(0,CL.cylinder)({center:[0,0,0],radius:r,height:n,segments:wC}),g=(0,CL.cylinder)({center:[0,0,n/2],radius:e/2,height:o,segments:wC}),I=(0,CL.cylinder)({center:[0,0,-n/2],radius:e/2,height:o,segments:wC}),c=(0,$VA.union)([a,g,I]),B=n+o*2,l=(0,CL.cylinder)({center:[0,0,0],radius:i/2,height:B,segments:wC}),C=(0,$VA.subtract)(c,l);return(0,Ypt.translate)([t,A,0],C)}function Tpt({x:t,y:A,holeDiameter:e,thickness:i}){const n=i*1.5,o=e/2+Vn;return(0,CL.cylinder)({center:[t,A,0],radius:o,height:n,segments:wC})}var A9A=64,Kpt=1,iCA=.05,e9A=(t,A,e,i)=>{const n=hy(t,A,i);if(n<=0)return(0,II.cuboid)({center:[0,0,0],size:[t,A,e]});const o=(0,II.roundedRectangle)({size:[t,A],roundRadius:n,segments:A9A}),s=(0,lL.extrudeLinear)({height:e},o);return(0,Du.translate)([0,0,-e/2],s)},t9A=["initializing","processing_pads","processing_copper_pours","processing_plated_holes","processing_holes","processing_cutouts","processing_vias","finalizing","done"],qpt=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=Vn/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(n=>n.type==="pcb_panel"),i=mi(t).pcb_board.list();if(e.length>0){const n=e[0],o=i.find(s=>s.pcb_panel_id===n.pcb_panel_id);this.board={type:"pcb_board",pcb_board_id:n.pcb_panel_id,center:n.center,width:n.width,height:n.height,thickness:o?.thickness??1.6,material:o?.material??"fr4",num_layers:o?.num_layers??2}}else{const n=i.filter(o=>!o.pcb_panel_id);this.board=n[0]}this.plated_holes=mi(t).pcb_plated_hole.list(),this.holes=mi(t).pcb_hole.list(),this.pads=mi(t).pcb_smtpad.list(),this.traces=mi(t).pcb_trace.list(),this.pcb_vias=mi(t).pcb_via.list(),this.pcb_cutouts=mi(t).pcb_cutout.list(),this.pcb_copper_pours=t.filter(n=>n.type==="pcb_copper_pour"),this.ctx={pcbThickness:this.board.thickness??1.2},this.initializeBoard()}initializeBoard(){const t=this.ctx.pcbThickness+2*Kpt;this.board.outline&&this.board.outline.length>0?(this.boardGeom=eCA({outline:this.board.outline},this.ctx.pcbThickness),this.boardClipGeom=eCA({outline:this.board.outline},t,{xyOutset:iCA})):(this.boardGeom=(0,II.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.boardClipGeom=(0,II.cuboid)({size:[this.board.width+2*iCA,this.board.height+2*iCA,t],center:[this.board.center.x,this.board.center.y,0]})),this.state="processing_pads",this.currentIndex=0}goToNextState(){const t=t9A.indexOf(this.state);t!==-1&&(this.state=t9A[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=hy(t.width,t.height,Qh(t));if(i>0){const n=(0,II.roundedRectangle)({size:[t.width,t.height],roundRadius:i,segments:A9A});A=(0,lL.extrudeLinear)({height:e},n),A=(0,Du.translate)([0,0,-e/2],A)}else A=(0,II.cuboid)({center:[0,0,0],size:[t.width,t.height,e]});if(t.rotation){const n=t.rotation*Math.PI/180;A=(0,Du.rotateZ)(n,A)}A=(0,Du.translate)([t.center.x,t.center.y,0],A);break}case"circle":A=(0,II.cylinder)({center:[t.center.x,t.center.y,0],radius:t.radius,height:e});break;case"polygon":{let i=t.points.map(o=>[o.x,o.y]);if(i.length<3){console.warn(`PCB Cutout [${t.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}ACA(i)&&(i=i.reverse());const n=(0,II.polygon)({points:i});A=(0,lL.extrudeLinear)({height:e},n),A=(0,Du.translate)([0,0,-e/2],A);break}}A&&(this.boardGeom=(0,cI.subtract)(this.boardGeom,A))}processCopperPour(t){const A=t.layer==="bottom"?-1:1,e=A*this.ctx.pcbThickness/2+A*gI.copper;let i=null;if(t.shape==="rect"){let n=(0,II.cuboid)({center:[0,0,0],size:[t.width,t.height,Vn]});if("rotation"in t&&t.rotation){const o=t.rotation*Math.PI/180;n=(0,Du.rotateZ)(o,n)}i=(0,Du.translate)([t.center.x,t.center.y,e],n)}else if(t.shape==="brep"){const n=t.brep_shape;if(n?.outer_ring){const o=Hpt(n);i=(0,lL.extrudeLinear)({height:Vn},o),i=(0,Du.translate)([0,0,e],i)}}else if(t.shape==="polygon"){let n=t.points.map(s=>[s.x,s.y]);if(n.length<3){console.warn(`PCB Copper Pour [${t.pcb_copper_pour_id}] polygon has fewer than 3 points, skipping.`);return}ACA(n)&&(n=n.reverse());const o=(0,II.polygon)({points:n});i=(0,lL.extrudeLinear)({height:Vn},o),i=(0,Du.translate)([0,0,e],i)}if(i){this.boardClipGeom&&(i=(0,cI.intersect)(this.boardClipGeom,i));const o=t.covered_with_solder_mask!==!1?Dpt[this.board.material]??Mn.fr4TracesWithoutMaskTan:Mn.copper,s=(0,Su.colorize)(o,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,II.cylinder)({center:[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0),0],radius:t.hole_diameter/2+Vn,height:this.ctx.pcbThickness*1.5}):e=(0,II.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+Vn,height:this.ctx.pcbThickness*1.5}),A.dontCutBoard||(this.boardGeom=(0,cI.subtract)(this.boardGeom,e)),this.padGeoms=this.padGeoms.map(n=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(n,e)));const i=k5(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,n=e?t.hole_width:t.hole_height,o=n/2,s=Math.abs(i-n);let r;if(r=(0,cI.union)((0,II.cuboid)({center:[t.x,t.y,0],size:e?[n,s,this.ctx.pcbThickness*1.5]:[s,n,this.ctx.pcbThickness*1.5]}),(0,II.cylinder)({center:e?[t.x,t.y-s/2,0]:[t.x-s/2,t.y,0],radius:o,height:this.ctx.pcbThickness*1.5}),(0,II.cylinder)({center:e?[t.x,t.y+s/2,0]:[t.x+s/2,t.y,0],radius:o,height:this.ctx.pcbThickness*1.5})),t.ccw_rotation){const g=t.ccw_rotation*Math.PI/180;r=(0,Du.translate)([t.x,t.y,0],(0,Du.rotateZ)(g,(0,Du.translate)([-t.x,-t.y,0],r)))}A.dontCutBoard||(this.boardGeom=(0,cI.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(g,r)));const a=k5(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,n=e?t.hole_width:t.hole_height,o=n/2,s=Math.abs(i-n);let r;r=(0,cI.union)((0,II.cuboid)({center:[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0),0],size:e?[n,s,this.ctx.pcbThickness*1.5]:[s,n,this.ctx.pcbThickness*1.5]}),(0,II.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:o,height:this.ctx.pcbThickness*1.5}),(0,II.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:o,height:this.ctx.pcbThickness*1.5})),A.dontCutBoard||(this.boardGeom=(0,cI.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(g,r)));const a=k5(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,n=b5(t,i,{sizeDelta:2*Vn}),o=b5(t,i,{sizeDelta:-2*Vn});if(!n||!o)return;A.dontCutBoard||(this.boardGeom=(0,cI.subtract)(this.boardGeom,n)),this.padGeoms=this.padGeoms.map(r=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(r,n))),this.platedHoleGeoms=this.platedHoleGeoms.map(r=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(r,o)));const s=k5(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,II.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+Vn,height:A});this.boardGeom=(0,cI.subtract)(this.boardGeom,e),this.padGeoms=this.padGeoms.map(n=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(n,e)));const i=(0,II.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+Vn/2,height:A});this.platedHoleGeoms=this.platedHoleGeoms.map(n=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(n,i)))}else if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const e=t.hole_width,i=t.hole_height,n=Math.min(e,i)/2,o=Math.abs(e-i),s=t.hole_shape==="rotated_pill";let r;if(e>i?r=(0,cI.union)((0,II.cuboid)({center:[t.x,t.y,0],size:[o,i,A]}),(0,II.cylinder)({center:[t.x-o/2,t.y,0],radius:n,height:A}),(0,II.cylinder)({center:[t.x+o/2,t.y,0],radius:n,height:A})):r=(0,cI.union)((0,II.cuboid)({center:[t.x,t.y,0],size:[e,o,A]}),(0,II.cylinder)({center:[t.x,t.y-o/2,0],radius:n,height:A}),(0,II.cylinder)({center:[t.x,t.y+o/2,0],radius:n,height:A})),s){const g=t.ccw_rotation*Math.PI/180;r=(0,Du.rotateZ)(g,r)}this.boardGeom=(0,cI.subtract)(this.boardGeom,r),this.padGeoms=this.padGeoms.map(g=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(g,r)));const a=(0,vpt.expand)({delta:-.02},r);this.platedHoleGeoms=this.platedHoleGeoms.map(g=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(g,a)))}}processPad(t){const A=t.layer==="bottom"?-1:1,e=A*this.ctx.pcbThickness/2+A*gI.copper,i=Qh(t);if(t.shape==="rect"){const n=e9A(t.width,t.height,Vn,i);let s=(0,Du.translate)([t.x,t.y,e],n);this.boardClipGeom&&(s=(0,cI.intersect)(this.boardClipGeom,s)),s=(0,Su.colorize)(Mn.copper,s),this.padGeoms.push(s)}else if(t.shape==="rotated_rect"){let n=e9A(t.width,t.height,Vn,i);const o=t.ccw_rotation*Math.PI/180;n=(0,Du.rotateZ)(o,n);let r=(0,Du.translate)([t.x,t.y,e],n);this.boardClipGeom&&(r=(0,cI.intersect)(this.boardClipGeom,r)),r=(0,Su.colorize)(Mn.copper,r),this.padGeoms.push(r)}else if(t.shape==="circle"){let n=(0,II.cylinder)({center:[t.x,t.y,e],radius:t.radius,height:Vn});this.boardClipGeom&&(n=(0,cI.intersect)(this.boardClipGeom,n)),n=(0,Su.colorize)(Mn.copper,n),this.padGeoms.push(n)}}processVia(t){if(this.boardGeom){if(typeof t.outer_diameter=="number"&&typeof t.hole_diameter=="number"){const A=Jpt({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,cI.intersect)(this.boardClipGeom,A),e=(0,Su.colorize)(Mn.copper,e)),this.viaGeoms.push(e)}if(typeof t.hole_diameter=="number"){const A=Tpt({x:t.x,y:t.y,holeDiameter:t.hole_diameter,thickness:this.ctx.pcbThickness});this.boardGeom=(0,cI.subtract)(this.boardGeom,A),this.padGeoms=this.padGeoms.map(e=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(e,A)))}}}finalize(){if(!this.boardGeom)return;const t=$lA[this.board.material]??Mn.fr4Tan;this.boardGeom=(0,Su.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}},Ppt=t=>{const[A,e]=j.useState(null),i=j.useRef(!1);return j.useEffect(()=>{let n=!1;if(!t){e(null);return}if(!t.some(g=>g.type==="pcb_board"||g.type==="pcb_panel")){e(null);return}const s=Gpt(t);e(s);const r=new qpt(t,g=>{});return(async()=>{if(!i.current){i.current=!0;try{let g=!1;for(;!g&&!n;)g=r.step(1),g||await new Promise(I=>setTimeout(I,0));n||e(r.getGeoms())}catch(g){console.error("Error during board geometry building:",g)}finally{i.current=!1}}})(),()=>{n=!0}},[t]),A},nCA=1.2;function Opt(t){return j.useMemo(()=>{if(!t)return nCA;try{return mi(t).pcb_board.list()[0]?.thickness??nCA}catch{return nCA}},[t])}var Wpt=({children:t,parent:A,position:e,rotation:i,scale:n,color:o,fontSize:s,anchorX:r,anchorY:a,depthOffset:g})=>{const{rootObject:I}=wu(),c=j.useMemo(()=>{const B=new xnA;return B.text=t,e&&B.position.fromArray(e),i&&B.rotation.fromArray(i),n&&B.scale.fromArray(n),B.color=o||"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,n,o,s,r,a,g]);return j.useEffect(()=>{const B=A||I;if(!(!B||!c))return B.add(c),()=>{B.remove(c),c.dispose()}},[I,A,c]),null},i9A=({error:t,cad_component:A})=>{const{rootObject:e}=wu(),[i,n]=j.useState(!1),[o,s]=j.useState(null),r=j.useCallback(c=>{c?.mousePosition?(n(!0),s(c.mousePosition)):(n(!1),s(null))},[]),a=j.useCallback(()=>{n(!1),s(null)},[]),g=j.useMemo(()=>A?.position?[A.position.x,A.position.y,A.position.z].map(B=>Number.isNaN(B)?0:B):[0,0,0],[A]),I=j.useMemo(()=>{const c=new Wp;return c.position.fromArray(g),c},[g]);return j.useEffect(()=>{if(e)return e.add(I),()=>{e.remove(I)}},[e,I]),O.jsxs(O.Fragment,{children:[O.jsxs($U,{isHovered:i,onHover:r,onUnhover:a,object:I,children:[O.jsx(Zpt,{parent:I}),O.jsx(Wpt,{parent:I,scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:`${t.toString().slice(0,50)}...`})]}),i&&o?O.jsx(LVA,{position:o,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]})},Zpt=({parent:t})=>{const A=j.useMemo(()=>{const e=new Zn(new fm(.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 j.useEffect(()=>(t.add(A),()=>{t.remove(A)}),[t,A]),null};function Vpt({stlUrl:t,stlData:A,mtlUrl:e,color:i,opacity:n=1}){const{rootObject:o}=wu(),[s,r]=j.useState(null);j.useEffect(()=>{const g=new q6e;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=j.useMemo(()=>{if(!s)return null;const g=new Ih({color:Array.isArray(i)?new Ui(i[0],i[1],i[2]):i,transparent:n!==1,opacity:n});return new Zn(s,g)},[s,i,n]);return j.useEffect(()=>{if(!(!o||!a))return o.add(a),()=>{o.remove(a),a.geometry.dispose(),Array.isArray(a.material)?a.material.forEach(g=>g.dispose()):a.material.dispose()}},[o,a]),null}function jpt({stlData:t,color:A,opacity:e=1,layerType:i}){const{visibility:n}=iM();let o=!0;return i==="board"?o=n.boardBody:i==="top-copper"?o=n.topCopper:i==="bottom-copper"?o=n.bottomCopper:i==="top-silkscreen"?o=n.topSilkscreen:i==="bottom-silkscreen"&&(o=n.bottomSilkscreen),o?O.jsx(Vpt,{stlData:t,color:A,opacity:e}):null}var n9A=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}},zpt=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,n=t[0].y;for(let o=1;o<t.length;o++){const s=t[o];s.x<A&&(A=s.x),s.y<e&&(e=s.y),s.x>i&&(i=s.x),s.y>n&&(n=s.y)}return{minX:A,minY:e,maxX:i,maxY:n}};function AF(t){if(t.outline&&t.outline.length>=3){const s=zpt(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,n=t.center?.y??0;return{...{minX:i-A/2,maxX:i+A/2,minY:n-e/2,maxY:n+e/2},width:A,height:e,centerX:i,centerY:n}}function F5({layer:t,circuitJson:A,boardData:e,soldermaskColor:i,traceTextureResolution:n}){const o=AF(e),s=document.createElement("canvas"),r=Math.floor(o.width*n),a=Math.floor(o.height*n);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-o.minX)*n,c=f=>(o.maxY-f)*n;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 w=1;w<e.outline.length;w++){const S=e.outline[w];g.lineTo(I(S.x),c(S.y))}g.closePath(),g.fill()}else g.fillRect(0,0,r,a);g.globalCompositeOperation="destination-out",g.fillStyle="black",mi(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 w=f.x,S=f.y,D=I(w),x=c(S);if(f.shape==="rect"){const F=f.width*n,k=f.height*n,v=Qh(f),_=hy(f.width,f.height,v)*n;_>0?(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill()):g.fillRect(D-F/2,x-k/2,F,k)}else if(f.shape==="circle"){const F=(f.radius??f.width/2)*n;g.beginPath(),g.arc(D,x,F,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const F=f.width*n,k=f.height*n,v=Qh(f),_=hy(f.width,f.height,v)*n;g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill()}else if(f.shape==="rotated_rect"){const F=f.width*n,k=f.height*n,v=Qh(f),_=hy(f.width,f.height,v)*n,K=-(f.ccw_rotation||0)*(Math.PI/180);g.save(),g.translate(D,x),g.rotate(K),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()}}),mi(A).pcb_via.list().forEach(f=>{const w=I(f.x),S=c(f.y),D=f.outer_diameter/2*n;g.beginPath(),g.arc(w,S,D,0,2*Math.PI),g.fill()}),mi(A).pcb_plated_hole.list().forEach(f=>{if(!f.layers?.includes(t))return;const w=f.x,S=f.y,D=I(w),x=c(S);if(f.shape==="circle"){const k=f.outer_diameter/2*n;g.beginPath(),g.arc(D,x,k,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const F=(f.outer_width??f.outer_diameter??f.hole_width)*n,k=(f.outer_height??f.outer_diameter??f.hole_height)*n,v=Math.min(F,k)/2,L=-(f.ccw_rotation||0);L?(g.save(),g.translate(D,x),g.rotate(L*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,v),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-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)*n,k=(f.outer_height??f.outer_diameter??f.hole_height)*n,v=F/2,_=k/2,K=-(f.ccw_rotation||0);K?(g.save(),g.translate(D,x),g.rotate(K*Math.PI/180),g.beginPath(),g.ellipse(0,0,v,_,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(D,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),L=c(f.y+v);if(F==="pill"||F==="rotated_pill"){const K=(f.outer_width??f.outer_diameter??f.hole_width)*n,J=(f.outer_height??f.outer_diameter??f.hole_height)*n,W=Math.min(K,J)/2,AA=-(f.ccw_rotation||0);AA?(g.save(),g.translate(_,L),g.rotate(AA*Math.PI/180),g.beginPath(),g.roundRect(-K/2,-J/2,K,J,W),g.fill(),g.restore()):(g.beginPath(),g.roundRect(_-K/2,L-J/2,K,J,W),g.fill())}else if(F==="oval"){const K=(f.outer_width??f.outer_diameter??f.hole_width)*n,J=(f.outer_height??f.outer_diameter??f.hole_height)*n,W=K/2,Z=J/2,nA=-(f.ccw_rotation||0);nA?(g.save(),g.translate(_,L),g.rotate(nA*Math.PI/180),g.beginPath(),g.ellipse(0,0,W,Z,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(_,L,W,Z,0,0,2*Math.PI),g.fill())}else if(F==="circle"){const J=(f.outer_diameter??f.hole_diameter??0)*n/2;g.beginPath(),g.arc(_,L,J,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)*n,k=(f.rect_pad_height??f.hole_diameter??0)*n,v=Qh(f),_=hy(f.rect_pad_width??f.hole_diameter??0,f.rect_pad_height??f.hole_diameter??0,v)*n;_>0?(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill()):g.fillRect(D-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)*n,k=(f.rect_pad_height??f.hole_height??0)*n,v=Qh(f),_=hy(f.rect_pad_width??f.hole_width??0,f.rect_pad_height??f.hole_height??0,v)*n,K=-(f.ccw_rotation||0);K?(g.save(),g.translate(D,x),g.rotate(K*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill())}}),mi(A).pcb_hole.list().forEach(f=>{const w=f.x,S=f.y,D=I(w),x=c(S),F=f.hole_shape||f.shape;if(F==="circle"&&typeof f.hole_diameter=="number"){const k=f.hole_diameter/2*n;g.beginPath(),g.arc(D,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*n,v=f.hole_height*n,_=Math.min(k,v)/2,K=-(f.ccw_rotation||0)*(Math.PI/180);K?(g.save(),g.translate(D,x),g.rotate(K),g.beginPath(),g.roundRect(-k/2,-v/2,k,v,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-k/2,x-v/2,k,v,_),g.fill())}}),mi(A).pcb_copper_pour.list().forEach(f=>{if(f.layer===t&&f.covered_with_solder_mask===!1)if(f.shape==="rect"){const w=I(f.center.x),S=c(f.center.y),D=f.width*n,x=f.height*n;g.fillRect(w-D/2,S-x/2,D,x)}else f.shape==="polygon"&&f.points&&(g.beginPath(),f.points.forEach((w,S)=>{const D=I(w.x),x=c(w.y);S===0?g.moveTo(D,x):g.lineTo(D,x)}),g.closePath(),g.fill())}),mi(A).pcb_cutout.list().forEach(f=>{switch(f.shape){case"rect":{const w=I(f.center.x),S=c(f.center.y),D=f.width*n,x=f.height*n,F=Qh(f),k=hy(f.width,f.height,F);if(f.rotation){g.save(),g.translate(w,S);const v=-f.rotation*(Math.PI/180);g.rotate(v),k>0?(g.beginPath(),g.roundRect(-D/2,-x/2,D,x,k*n),g.fill()):g.fillRect(-D/2,-x/2,D,x),g.restore()}else k>0?(g.beginPath(),g.roundRect(w-D/2,S-x/2,D,x,k*n),g.fill()):g.fillRect(w-D/2,S-x/2,D,x);break}case"circle":{const w=I(f.center.x),S=c(f.center.y),D=f.radius*n;g.beginPath(),g.arc(w,S,D,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((w,S)=>{const D=I(w.x),x=c(w.y);S===0?g.moveTo(D,x):g.lineTo(D,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 w_(s);return d.generateMipmaps=!0,d.minFilter=fu,d.magFilter=jB,d.anisotropy=16,d.needsUpdate=!0,d}var Xpt=yr(glA());function o9A(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 kx(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function s9A(...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,...n]=t,o=A(e,i);return s9A(o,...n)}}}function r9A(...t){return s9A(...t)}var{cos:$pt,sin:Aft}=Math;function a9A(t,A,e){const i=$pt(t),n=Aft(t);return{a:i,c:-n,e:0,b:n,d:i,f:0}}function eft(t,A){function e(){this.constructor=t}e.prototype=A.prototype,t.prototype=new e}function R5(t,A,e,i){var n=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(n,R5.prototype),n.expected=A,n.found=e,n.location=i,n.name="SyntaxError",n}eft(R5,Error);function oCA(t,A,e){return e=e||" ",t.length>A?t:(A-=t.length,e+=e.repeat(A),t+e.slice(0,A))}R5.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 n=this.location.start,o=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(n):n,s=this.location.source+":"+o.line+":"+o.column;if(e){var r=this.location.end,a=oCA("",o.line.toString().length," "),g=e[n.line-1],I=n.line===r.line?r.column:g.length+1,c=I-n.column||1;A+=`
5100
+ `,Cpt=({rotation:t,infiniteGrid:A,cellSize:e=1,sectionSize:i=10})=>{const{scene:n,camera:o}=wu(),s=1e3,r=j.useMemo(()=>{const a=new ym(s,s);a.rotateX(-Math.PI/2);const g=new mw({vertexShader:Bpt,fragmentShader:lpt,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:Ll}),I=new Zn(a,g);return t&&I.rotation.fromArray(t),I},[s,e,i,t]);return XU(()=>{A&&r.position.set(o.position.x,o.position.y,0)}),j.useEffect(()=>{if(!(!n||!r))return n.add(r),()=>{n.remove(r),r.geometry.dispose(),Array.isArray(r.material)?r.material.forEach(a=>a.dispose()):r.material.dispose()}},[n,r]),null},Qpt=()=>{const{scene:t}=wu(),A=j.useMemo(()=>new yYA(16777215,Math.PI/2),[]),e=j.useMemo(()=>{const i=new tnA(16777215,Math.PI/4);return i.position.set(-10,-10,10),i.decay=0,i},[]);return j.useEffect(()=>{if(t)return t.add(A),t.add(e),()=>{t.remove(A),t.remove(e)}},[t,A,e]),null},Ept=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,hpt=()=>{const{controlsRef:t,mainCameraRef:A,defaultTarget:e,setController:i,getPresetConfig:n}=bx(),o=j.useRef(null),s=j.useRef(new dd),r=j.useRef(new Re),a=j.useRef(new Re),g=j.useRef(new dd),I=j.useRef(new dd),c=j.useRef(new ug),B=j.useRef(new ug),l=j.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]),w=E?new Re(E[0],E[1],E[2]):e.clone(),S=new Re(...h??[0,0,1]).normalize(),D=B.current;D.position.copy(f),D.up.copy(S),D.lookAt(w);const x=D.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 L=_.quaternion.clone();_.up.set(0,0,1),_.position.copy(f),_.lookAt(w);const K=_.quaternion.clone(),J=L.clone().invert().multiply(F).normalize(),W=K.clone().invert().multiply(x).normalize();o.current={fromPosition:k,toPosition:f,fromTarget:v,toTarget:w,toQuaternion:x,rollFrom:J,rollTo:W,startTime:performance.now(),duration:u}},[A,t,e]),C=j.useCallback(Q=>{if(Q==="Custom")return;const E=n(Q);E&&l(E)},[l,n]);return j.useEffect(()=>A.current?(i({animateTo:l,animateToPreset:C}),()=>{i(null)}):void 0,[l,C,A,i]),XU(()=>{if(!A.current||!o.current)return;const{fromPosition:Q,toPosition:E,fromTarget:h,toTarget:u,toQuaternion:d,rollFrom:f,rollTo:w,startTime:S,duration:D}=o.current,x=performance.now()-S,F=D<=0?1:Math.min(x/D,1),k=Ept(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 L=s.current;L.copy(_.quaternion);const K=g.current;K.copy(f);const J=I.current;J.copy(w),f.dot(w)<0&&(J.x*=-1,J.y*=-1,J.z*=-1,J.w*=-1),J.normalize(),K.slerp(J,k),A.current.quaternion.copy(L).multiply(K).normalize();const W=a.current;W.set(0,1,0).applyQuaternion(A.current.quaternion).normalize(),A.current.up.copy(W),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(),o.current=null)}),null},upt=()=>{const{controlsRef:t}=bx(),A=j.useRef(null),e=j.useRef(!1),i=j.useRef(null),n=j.useCallback(s=>{A.current=s,!e.current&&t.current&&XlA(s,t.current)&&(e.current=!0)},[t]),o=j.useCallback(()=>{if(!(!A.current||!t.current)){if(!e.current&&XlA(A.current,t.current)){e.current=!0;return}clearTimeout(i.current),i.current=setTimeout(()=>{A.current&&t.current&&PVA(A.current,t.current)},150)}},[t]);return{handleCameraCreated:n,handleControlsChange:o}};function dpt(t,A){const e=new dd().setFromEuler(new Pp(t.x,t.y,t.z)),i=new Re(0,0,1);return i.applyQuaternion(e),i.multiplyScalar(A)}var ppt=()=>{const{mainCameraRef:t}=bx(),A=j.useRef(null),e=j.useRef(null),i=j.useRef(null),n=j.useRef(null),o=j.useRef(null),s=j.useRef(null);return j.useEffect(()=>{if(!A.current)return;const r=document.createElement("canvas");e.current=r,A.current.appendChild(r);const a=new z3({canvas:r,antialias:!0,alpha:!0});a.setSize(120,120),a.setPixelRatio(window.devicePixelRatio),i.current=a;const g=new UG;n.current=g;const I=new aE(75,1,.1,1e3);I.up.set(0,0,1),o.current=I;const c=new yYA(16777215,Math.PI/2);g.add(c);const B=new Wp;B.rotation.fromArray([Math.PI/2,0,0]);const l=1,C=new Zn(new fm(l,l,l),new Ih({color:"white"}));B.add(C);const Q=new hU(new qze(new fm(l,l,l)),new LG({color:0,linewidth:2}));B.add(Q),g.add(B);const E=.51,h=(F,k,v)=>{const _=new xnA;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]),w=h("Left",[-E,0,0],[0,-Math.PI/2,0]),S=h("Top",[0,E,0],[-Math.PI/2,0,0]),D=h("Bottom",[0,-E,0],[Math.PI/2,0,0]);B.add(u),B.add(d),B.add(f),B.add(w),B.add(S),B.add(D);const x=()=>{if(t.current){const F=dpt(t.current.rotation??new Pp(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(),w.dispose(),S.dispose(),D.dispose(),C.geometry.dispose(),C.material.dispose(),Q.geometry.dispose(),Q.material.dispose(),g.clear(),a.dispose(),e.current&&A.current&&A.current.removeChild(e.current)}},[t]),O.jsx("div",{ref:A,style:{position:"absolute",top:0,left:0,width:120,height:120,zIndex:BL.orientationCube}})},fpt=()=>{const{camera:t}=wu(),{setCameraRotation:A}=bx();return XU(()=>{t&&A(t.rotation)}),null},WVA=j.forwardRef(({children:t,initialCameraPosition:A=[5,-5,5],autoRotateDisabled:e,clickToInteractEnabled:i=!1,boardDimensions:n,boardCenter:o,onUserInteraction:s,onCameraControllerReady:r},a)=>{const[g,I]=j.useState(!i),{mainCameraRef:c,handleControlsChange:B,controller:l}=bx(),{handleCameraCreated:C,handleControlsChange:Q}=upt();j.useEffect(()=>{r&&r(l)},[l,r]);const E=j.useMemo(()=>{if(!n)return 10;const u=n.width??0,d=n.height??0,w=Math.max(u,d)*1.5;return w>10?w:10},[n]),h=j.useMemo(()=>{if(o)return[o.x,o.y,0]},[o]);return O.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[O.jsx(ppt,{}),O.jsxs(Ipt,{ref:a,scene:{up:new Re(0,0,1)},camera:{up:[0,0,1],position:A},onCreated:({camera:u})=>{c.current=u,C(u)},children:[O.jsx(hpt,{}),O.jsx(fpt,{}),g&&O.jsx(cpt,{autoRotate:!e,autoRotateSpeed:1,onStart:s,rotateSpeed:.5,panSpeed:.75,zoomSpeed:.5,enableDamping:!0,dampingFactor:.1,target:h,onControlsChange:u=>{B(u),Q()}}),O.jsx(Qpt,{}),O.jsx(Cpt,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:3,sectionSize:E,args:[E,E]}),t]}),O.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:["@",KVA.version]}),i&&!g&&O.jsx("button",{type:"button",onClick:()=>I(!0),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&I(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:BL.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center"},children:O.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"})})]})}),ZVA=t=>j.useMemo(()=>{if(!t)return[];const A=new HPe;return A.add(t),A.render(),A.getCircuitJson()},[t]),ypt=t=>{const[A,e]=j.useState([]),[i,n]=j.useState(!0);return j.useEffect(()=>{if(!t)return;(async()=>{n(!0);const r=(Array.isArray(t)?t:[t]).map(async(a,g)=>{const I=$it.serialize({binary:!0},[a]),B=await new Blob(I).arrayBuffer(),C=a.layerType||(g===0?"board":void 0);return{stlData:B,color:a.color,layerType:C}});try{const a=await Promise.all(r);e(a)}catch(a){console.error("Error generating STLs:",a),e([])}finally{n(!1)}})()},[t]),{stls:A,loading:i}},mpt=yr(wx()),wpt=yr(t5()),Vn=.01,gI={traces:.001,copper:.002},Mn={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]},Ey=.001,wC=32,m5=.035,hc=150,w5=.6,$lA={fr1:Mn.fr1Tan,fr4:Mn.fr4Tan},Dpt={fr1:Mn.fr1TracesWithMaskCopper,fr4:Mn.fr4TracesWithoutMaskTan},VVA={fr1:Mn.fr1SolderMaskGreen,fr4:Mn.fr4SolderMaskGreen},Spt=yr(zU()),bpt=yr(wx()),xpt=yr(zG()),kpt=yr(ElA()),ACA=t=>{let A=0;for(let i=0;i<t.length;i++){const n=(i+1)%t.length;A+=t[i][0]*t[n][1],A-=t[n][0]*t[i][1]}return A/2<=0},eCA=(t,A=1.2,e={})=>{const{xyOutset:i=0}=e,{outline:n}=t;let o=n.map(a=>[a.x,a.y]);ACA(o)&&(o=o.reverse());let s=(0,bpt.polygon)({points:o});i!==0&&(s=(0,kpt.expand)({delta:i,corners:"edge"},s));let r=(0,Spt.extrudeLinear)({height:A},s);return r=(0,xpt.translate)([0,0,-A/2],r),r},Gpt=t=>{const A=t.filter(a=>a.type==="pcb_panel"),e=mi(t).pcb_board.list();let i,n=1.2;if(A.length>0)i=A[0],n=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"),[];n=i.thickness??1.2}let o;"outline"in i&&i.outline&&i.outline.length>0?o=eCA({outline:i.outline},n):o=(0,mpt.cuboid)({size:[i.width??10,i.height??10,n],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=$lA[s]??Mn.fr4Tan;return[(0,wpt.colorize)(r,o)]},Du=yr(zG()),II=yr(wx()),Su=yr(t5()),cI=yr(T_()),Jg=yr(wx()),CS=yr(t5()),JI=yr(T_()),jVA=yr(zG()),D5=yr(zU()),QS=yr(zG());function hy(t,A,e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return 0;const i=t/2,n=A/2;return Math.max(0,Math.min(e,i,n))}function Qh(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 xx=yr(wx()),Fpt=yr(zU()),S5=yr(zG()),Rpt=yr(T_()),Npt=64,_pt=(t,A,e)=>{const i=(0,xx.ellipse)({center:[0,0],radius:[Math.max(t/2,Vn/2),Math.max(A/2,Vn/2)],segments:Npt}),n=(0,Fpt.extrudeLinear)({height:e},i);return(0,S5.translate)([0,0,-e/2],n)},Mpt=(t,A,e)=>{const i=Math.max(t,Vn),n=Math.max(A,Vn);if(Math.abs(i-n)<1e-6)return(0,xx.cylinder)({center:[0,0,0],radius:i/2,height:e});const o=i>=n,s=o?i:n,r=o?n:i,a=Math.max(s-r,0),g=(0,xx.cuboid)({center:[0,0,0],size:o?[a,r,e]:[r,a,e]});if(a<=1e-6)return(0,xx.cylinder)({center:[0,0,0],radius:r/2,height:e});const I=a/2,c=(0,xx.cylinder)({center:o?[-I,0,0]:[0,-I,0],radius:r/2,height:e}),B=(0,xx.cylinder)({center:o?[I,0,0]:[0,I,0],radius:r/2,height:e});return(0,Rpt.union)(g,c,B)},b5=(t,A,e={})=>{const i=t.hole_shape||"circle",n=e.sizeDelta??0,o=t.hole_offset_x||0,s=t.hole_offset_y||0,r=[t.x+o,t.y+s,0];if(i==="circle"){const l=Math.max((t.hole_diameter??0)+n,Vn),C=Math.max(l/2,Vn/2);return(0,xx.cylinder)({center:r,radius:C,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+n,Vn),c=Math.max(g+n,Vn);if(i==="oval"){const l=_pt(I,c,A);return(0,S5.translate)([r[0],r[1],0],l)}if(i==="pill"||i==="rotated_pill"){let l=Mpt(I,c,A);if(!l)return null;const C=t.ccw_rotation||0;return C&&(l=(0,S5.rotateZ)(C*Math.PI/180,l)),(0,S5.translate)(r,l)}const B=Math.max((t.hole_diameter??a??g??Vn)+n,Vn);return(0,xx.cylinder)({center:r,radius:B/2,height:A})},Nw=.02,tCA=64,nM=(t,A)=>A?(0,JI.intersect)(A,t):t,x5=({width:t,height:A,thickness:e,center:i,borderRadius:n})=>{const o=hy(t,A,n);if(o<=0)return(0,Jg.cuboid)({center:i,size:[t,A,e]});const s=(0,Jg.roundedRectangle)({size:[t,A],roundRadius:o,segments:tCA}),r=(0,D5.extrudeLinear)({height:e},s),a=i[2]-e/2;return(0,QS.translate)([i[0],i[1],a],r)},k5=(t,A,e={})=>{const{clipGeom:i}=e;t.shape||(t.shape="circle");const n=A.pcbThickness+2*Nw+4*Vn,o=A.pcbThickness/2+gI.copper,s=-A.pcbThickness/2-gI.copper,r=o-s;if(t.shape==="circle"){const a=t.outer_diameter??Math.max(t.hole_diameter,0),g=r+.01,I=(0,Jg.cylinder)({center:[t.x,t.y,0],radius:a/2,height:g}),c=nM(I,i),B=(0,Jg.cylinder)({center:[t.x,t.y,0],radius:Math.max(t.hole_diameter/2,.01),height:n});return(0,CS.colorize)(Mn.copper,(0,JI.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,Jg.cylinder)({center:[0,0,0],radius:1,height:r+.01,segments:64}),E=(0,jVA.scale)([a/2,g/2,1],Q);return(0,QS.translate)([t.x,t.y,0],E)})(),l=nM(B,i),C=(()=>{const Q=(0,Jg.cylinder)({center:[0,0,0],radius:1,height:n,segments:64}),E=(0,jVA.scale)([Math.max(I/2,.01),Math.max(c/2,.01),1],Q);return(0,QS.translate)([t.x,t.y,0],E)})();return(0,CS.colorize)(Mn.copper,(0,JI.subtract)(l,C))}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=Qh(t),l=nM((0,JI.union)(x5({width:I,height:c,thickness:Nw,center:[t.x,t.y,o],borderRadius:B}),x5({width:I,height:c,thickness:Nw,center:[t.x,t.y,s],borderRadius:B}),(()=>{const h=Math.max(r-Nw*2,Vn),f=(o+s)/2,w=(0,Jg.roundedRectangle)({size:[I,c],roundRadius:B||0,segments:tCA}),S=(0,D5.extrudeLinear)({height:h},w);return(0,QS.translate)([t.x,t.y,f-h/2],S)})(),(0,Jg.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:t.hole_diameter/2,height:r})),i),C=(0,Jg.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:Math.max(t.hole_diameter/2-Vn,.01),height:n}),Q=(0,Jg.cylinder)({center:[t.x+(a||0),t.y+(g||0),0],radius:t.hole_diameter/2,height:r});let E=(0,JI.union)((0,JI.subtract)(l,Q),Q);return e.clipGeom?(E=(0,JI.subtract)(E,C),E=(0,JI.intersect)(E,e.clipGeom),(0,CS.colorize)(Mn.copper,E)):(0,CS.colorize)(Mn.copper,(0,JI.subtract)(E,C))}if(t.shape==="pill"){const a=(t.ccw_rotation||0)*Math.PI/180,g=k=>{if(!a)return k;const v=(0,QS.translate)([-t.x,-t.y,0],k),_=(0,QS.rotate)([0,0,a],v);return(0,QS.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,l=I?t.outer_height||B+.2:t.outer_width||c+.2,C=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 L=v/2,K=Math.abs(k-v);if(K<=1e-6)return(0,Jg.cylinder)({center:[t.x,t.y,0],radius:L,height:_});const J=(0,Jg.cuboid)({center:[t.x,t.y,0],size:I?[v,K,_]:[K,v,_]}),W=(0,Jg.cylinder)({center:I?[t.x,t.y-K/2,0]:[t.x-K/2,t.y,0],radius:L,height:_}),Z=(0,Jg.cylinder)({center:I?[t.x,t.y+K/2,0]:[t.x+K/2,t.y,0],radius:L,height:_});return(0,JI.union)(J,W,Z)})(l,C,h),f=(0,Jg.cuboid)({center:[t.x,t.y,0],size:I?[B-2*Vn,E,n]:[E,B-2*Vn,n]}),w=(0,Jg.cylinder)({center:I?[t.x,t.y-E/2,0]:[t.x-E/2,t.y,0],radius:Q-Vn,height:n}),S=(0,Jg.cylinder)({center:I?[t.x,t.y+E/2,0]:[t.x+E/2,t.y,0],radius:Q-Vn,height:n}),D=(0,JI.union)(f,w,S),x=nM(g(d),i),F=g(D);return(0,CS.colorize)(Mn.copper,(0,JI.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,l=B/2,C=Math.abs(c-B),Q=t.rect_pad_width||c+.2,E=t.rect_pad_height||B+.2,h=Qh(t),u=.03,d=(0,JI.union)((0,Jg.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B+2*u,C+2*u,r]:[C+2*u,B+2*u,r]}),(0,Jg.cylinder)({center:I?[t.x+a,t.y+g-C/2,0]:[t.x+a-C/2,t.y+g,0],radius:l+u,height:r}),(0,Jg.cylinder)({center:I?[t.x+a,t.y+g+C/2,0]:[t.x+a+C/2,t.y+g,0],radius:l+u,height:r})),f=(0,JI.union)((0,Jg.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B,C,n*1.1]:[C,B,n*1.1]}),(0,Jg.cylinder)({center:I?[t.x+a,t.y+g-C/2,0]:[t.x+a-C/2,t.y+g,0],radius:l,height:n*1.1}),(0,Jg.cylinder)({center:I?[t.x+a,t.y+g+C/2,0]:[t.x+a+C/2,t.y+g,0],radius:l,height:n*1.1})),w=x5({width:Q,height:E,thickness:Nw,center:[t.x,t.y,o],borderRadius:h}),S=x5({width:Q,height:E,thickness:Nw,center:[t.x,t.y,s],borderRadius:h}),D=(()=>{const K=Math.max(r-Nw*2,Vn),Z=(o+s)/2,AA=(0,Jg.roundedRectangle)({size:[Q,E],roundRadius:h||0,segments:tCA}),nA=(0,D5.extrudeLinear)({height:K},AA);return(0,QS.translate)([t.x,t.y,Z-K/2],nA)})(),x=(0,JI.subtract)(w,f),F=(0,JI.subtract)(S,f),k=(0,JI.subtract)(D,f),v=(0,JI.union)((0,Jg.cuboid)({center:[t.x+a,t.y+g,0],size:I?[B-2*Vn,C-2*Vn,n*1.1]:[C-2*Vn,B-2*Vn,n*1.1]}),(0,Jg.cylinder)({center:I?[t.x+a,t.y+g-C/2,0]:[t.x+a-C/2,t.y+g,0],radius:l-Vn,height:n*1.1}),(0,Jg.cylinder)({center:I?[t.x+a,t.y+g+C/2,0]:[t.x+a+C/2,t.y+g,0],radius:l-Vn,height:n*1.1})),_=(0,JI.subtract)(d,v),L=nM((0,JI.union)(x,F,k,_),i);return(0,CS.colorize)(Mn.copper,L)}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,Jg.polygon)({points:g}),c=(o+s)/2,B=(f,w)=>{const S=Math.max(f,Vn),D=(0,D5.extrudeLinear)({height:S},I);return(0,QS.translate)([t.x,t.y,w-S/2],D)},l=B(Math.max(r-Nw*2,Vn),c),C=B(Nw,o),Q=B(Nw,s),E=nM((0,JI.union)(l,C,Q),i),h=b5(t,r);if(!h)return(0,CS.colorize)(Mn.copper,E);const u=b5(t,n,{sizeDelta:-2*Vn})||h;let d=(0,JI.union)((0,JI.subtract)(E,h),h);return e.clipGeom?(d=(0,JI.subtract)(d,u),d=(0,JI.intersect)(d,e.clipGeom),(0,CS.colorize)(Mn.copper,d)):(0,CS.colorize)(Mn.copper,(0,JI.subtract)(d,u))}else throw new Error(`Unsupported plated hole shape: ${t.shape}`)},lL=yr(zU()),vpt=yr(ElA()),zVA=yr(wx()),Upt=yr(T_());function Lpt(t,A,e,i){if(!e||Math.abs(e)<1e-9)return[];const n=4*Math.atan(e),o=A[0]-t[0],s=A[1]-t[1],r=Math.sqrt(o*o+s*s);if(r<1e-9)return[];const a=Math.abs(r/(2*Math.sin(n/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=o/r,l=-(s/r),C=c,Q=I[0]+l*g*Math.sign(e),E=I[1]+C*g*Math.sign(e),h=Math.atan2(t[1]-E,t[0]-Q),u=[],d=Math.max(2,Math.ceil(i*Math.abs(n)/(Math.PI*2)*4)),f=n/d;for(let w=1;w<d;w++){const S=h+f*w;u.push([Q+a*Math.cos(S),E+a*Math.sin(S)])}return u}function G5(t,A){const e=[],i=t.vertices;for(let n=0;n<i.length;n++){const o=i[n],s=i[(n+1)%i.length];if(e.push([o.x,o.y]),o.bulge){const r=Lpt([o.x,o.y],[s.x,s.y],o.bulge,A);e.push(...r)}}return e}function XVA(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 Hpt(t,A=16){let e=G5(t.outer_ring,A);XVA(e)&&e.reverse();const i=(0,zVA.polygon)({points:e});if(!t.inner_rings||t.inner_rings.length===0)return i;const n=t.inner_rings.map(o=>{let s=G5(o,A);return XVA(s)&&s.reverse(),(0,zVA.polygon)({points:s})});return n.length===0?i:(0,Upt.subtract)(i,n)}var $VA=yr(T_()),Ypt=yr(zG()),CL=yr(wx());function Jpt({x:t,y:A,outerDiameter:e,holeDiameter:i,thickness:n}){if(e<=i)throw new Error(`Invalid via geometry: outerDiameter (${e}) must be > holeDiameter (${i})`);const o=Vn,s=Vn,r=Math.min(e/2,i/2+s),a=(0,CL.cylinder)({center:[0,0,0],radius:r,height:n,segments:wC}),g=(0,CL.cylinder)({center:[0,0,n/2],radius:e/2,height:o,segments:wC}),I=(0,CL.cylinder)({center:[0,0,-n/2],radius:e/2,height:o,segments:wC}),c=(0,$VA.union)([a,g,I]),B=n+o*2,l=(0,CL.cylinder)({center:[0,0,0],radius:i/2,height:B,segments:wC}),C=(0,$VA.subtract)(c,l);return(0,Ypt.translate)([t,A,0],C)}function Tpt({x:t,y:A,holeDiameter:e,thickness:i}){const n=i*1.5,o=e/2+Vn;return(0,CL.cylinder)({center:[t,A,0],radius:o,height:n,segments:wC})}var A9A=64,Kpt=1,iCA=.05,e9A=(t,A,e,i)=>{const n=hy(t,A,i);if(n<=0)return(0,II.cuboid)({center:[0,0,0],size:[t,A,e]});const o=(0,II.roundedRectangle)({size:[t,A],roundRadius:n,segments:A9A}),s=(0,lL.extrudeLinear)({height:e},o);return(0,Du.translate)([0,0,-e/2],s)},t9A=["initializing","processing_pads","processing_copper_pours","processing_plated_holes","processing_holes","processing_cutouts","processing_vias","finalizing","done"],qpt=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=Vn/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(n=>n.type==="pcb_panel"),i=mi(t).pcb_board.list();if(e.length>0){const n=e[0],o=i.find(s=>s.pcb_panel_id===n.pcb_panel_id);this.board={type:"pcb_board",pcb_board_id:n.pcb_panel_id,center:n.center,width:n.width,height:n.height,thickness:o?.thickness??1.6,material:o?.material??"fr4",num_layers:o?.num_layers??2}}else{const n=i.filter(o=>!o.pcb_panel_id);this.board=n[0]}this.plated_holes=mi(t).pcb_plated_hole.list(),this.holes=mi(t).pcb_hole.list(),this.pads=mi(t).pcb_smtpad.list(),this.traces=mi(t).pcb_trace.list(),this.pcb_vias=mi(t).pcb_via.list(),this.pcb_cutouts=mi(t).pcb_cutout.list(),this.pcb_copper_pours=t.filter(n=>n.type==="pcb_copper_pour"),this.ctx={pcbThickness:this.board.thickness??1.2},this.initializeBoard()}initializeBoard(){const t=this.ctx.pcbThickness+2*Kpt;this.board.outline&&this.board.outline.length>0?(this.boardGeom=eCA({outline:this.board.outline},this.ctx.pcbThickness),this.boardClipGeom=eCA({outline:this.board.outline},t,{xyOutset:iCA})):(this.boardGeom=(0,II.cuboid)({size:[this.board.width,this.board.height,this.ctx.pcbThickness],center:[this.board.center.x,this.board.center.y,0]}),this.boardClipGeom=(0,II.cuboid)({size:[this.board.width+2*iCA,this.board.height+2*iCA,t],center:[this.board.center.x,this.board.center.y,0]})),this.state="processing_pads",this.currentIndex=0}goToNextState(){const t=t9A.indexOf(this.state);t!==-1&&(this.state=t9A[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=hy(t.width,t.height,Qh(t));if(i>0){const n=(0,II.roundedRectangle)({size:[t.width,t.height],roundRadius:i,segments:A9A});A=(0,lL.extrudeLinear)({height:e},n),A=(0,Du.translate)([0,0,-e/2],A)}else A=(0,II.cuboid)({center:[0,0,0],size:[t.width,t.height,e]});if(t.rotation){const n=t.rotation*Math.PI/180;A=(0,Du.rotateZ)(n,A)}A=(0,Du.translate)([t.center.x,t.center.y,0],A);break}case"circle":A=(0,II.cylinder)({center:[t.center.x,t.center.y,0],radius:t.radius,height:e});break;case"polygon":{let i=t.points.map(o=>[o.x,o.y]);if(i.length<3){console.warn(`PCB Cutout [${t.pcb_cutout_id}] polygon has fewer than 3 points, skipping.`);break}ACA(i)&&(i=i.reverse());const n=(0,II.polygon)({points:i});A=(0,lL.extrudeLinear)({height:e},n),A=(0,Du.translate)([0,0,-e/2],A);break}}A&&(this.boardGeom=(0,cI.subtract)(this.boardGeom,A))}processCopperPour(t){const A=t.layer==="bottom"?-1:1,e=A*this.ctx.pcbThickness/2+A*gI.copper;let i=null;if(t.shape==="rect"){let n=(0,II.cuboid)({center:[0,0,0],size:[t.width,t.height,Vn]});if("rotation"in t&&t.rotation){const o=t.rotation*Math.PI/180;n=(0,Du.rotateZ)(o,n)}i=(0,Du.translate)([t.center.x,t.center.y,e],n)}else if(t.shape==="brep"){const n=t.brep_shape;if(n?.outer_ring){const o=Hpt(n);i=(0,lL.extrudeLinear)({height:Vn},o),i=(0,Du.translate)([0,0,e],i)}}else if(t.shape==="polygon"){let n=t.points.map(s=>[s.x,s.y]);if(n.length<3){console.warn(`PCB Copper Pour [${t.pcb_copper_pour_id}] polygon has fewer than 3 points, skipping.`);return}ACA(n)&&(n=n.reverse());const o=(0,II.polygon)({points:n});i=(0,lL.extrudeLinear)({height:Vn},o),i=(0,Du.translate)([0,0,e],i)}if(i){this.boardClipGeom&&(i=(0,cI.intersect)(this.boardClipGeom,i));const o=t.covered_with_solder_mask!==!1?Dpt[this.board.material]??Mn.fr4TracesWithoutMaskTan:Mn.copper,s=(0,Su.colorize)(o,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,II.cylinder)({center:[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0),0],radius:t.hole_diameter/2+Vn,height:this.ctx.pcbThickness*1.5}):e=(0,II.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+Vn,height:this.ctx.pcbThickness*1.5}),A.dontCutBoard||(this.boardGeom=(0,cI.subtract)(this.boardGeom,e)),this.padGeoms=this.padGeoms.map(n=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(n,e)));const i=k5(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,n=e?t.hole_width:t.hole_height,o=n/2,s=Math.abs(i-n);let r;if(r=(0,cI.union)((0,II.cuboid)({center:[t.x,t.y,0],size:e?[n,s,this.ctx.pcbThickness*1.5]:[s,n,this.ctx.pcbThickness*1.5]}),(0,II.cylinder)({center:e?[t.x,t.y-s/2,0]:[t.x-s/2,t.y,0],radius:o,height:this.ctx.pcbThickness*1.5}),(0,II.cylinder)({center:e?[t.x,t.y+s/2,0]:[t.x+s/2,t.y,0],radius:o,height:this.ctx.pcbThickness*1.5})),t.ccw_rotation){const g=t.ccw_rotation*Math.PI/180;r=(0,Du.translate)([t.x,t.y,0],(0,Du.rotateZ)(g,(0,Du.translate)([-t.x,-t.y,0],r)))}A.dontCutBoard||(this.boardGeom=(0,cI.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(g,r)));const a=k5(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,n=e?t.hole_width:t.hole_height,o=n/2,s=Math.abs(i-n);let r;r=(0,cI.union)((0,II.cuboid)({center:[t.x+(t.hole_offset_x||0),t.y+(t.hole_offset_y||0),0],size:e?[n,s,this.ctx.pcbThickness*1.5]:[s,n,this.ctx.pcbThickness*1.5]}),(0,II.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:o,height:this.ctx.pcbThickness*1.5}),(0,II.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:o,height:this.ctx.pcbThickness*1.5})),A.dontCutBoard||(this.boardGeom=(0,cI.subtract)(this.boardGeom,r)),this.padGeoms=this.padGeoms.map(g=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(g,r)));const a=k5(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,n=b5(t,i,{sizeDelta:2*Vn}),o=b5(t,i,{sizeDelta:-2*Vn});if(!n||!o)return;A.dontCutBoard||(this.boardGeom=(0,cI.subtract)(this.boardGeom,n)),this.padGeoms=this.padGeoms.map(r=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(r,n))),this.platedHoleGeoms=this.platedHoleGeoms.map(r=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(r,o)));const s=k5(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,II.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+Vn,height:A});this.boardGeom=(0,cI.subtract)(this.boardGeom,e),this.padGeoms=this.padGeoms.map(n=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(n,e)));const i=(0,II.cylinder)({center:[t.x,t.y,0],radius:t.hole_diameter/2+Vn/2,height:A});this.platedHoleGeoms=this.platedHoleGeoms.map(n=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(n,i)))}else if(t.hole_shape==="pill"||t.hole_shape==="rotated_pill"){const e=t.hole_width,i=t.hole_height,n=Math.min(e,i)/2,o=Math.abs(e-i),s=t.hole_shape==="rotated_pill";let r;if(e>i?r=(0,cI.union)((0,II.cuboid)({center:[t.x,t.y,0],size:[o,i,A]}),(0,II.cylinder)({center:[t.x-o/2,t.y,0],radius:n,height:A}),(0,II.cylinder)({center:[t.x+o/2,t.y,0],radius:n,height:A})):r=(0,cI.union)((0,II.cuboid)({center:[t.x,t.y,0],size:[e,o,A]}),(0,II.cylinder)({center:[t.x,t.y-o/2,0],radius:n,height:A}),(0,II.cylinder)({center:[t.x,t.y+o/2,0],radius:n,height:A})),s){const g=t.ccw_rotation*Math.PI/180;r=(0,Du.rotateZ)(g,r)}this.boardGeom=(0,cI.subtract)(this.boardGeom,r),this.padGeoms=this.padGeoms.map(g=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(g,r)));const a=(0,vpt.expand)({delta:-.02},r);this.platedHoleGeoms=this.platedHoleGeoms.map(g=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(g,a)))}}processPad(t){const A=t.layer==="bottom"?-1:1,e=A*this.ctx.pcbThickness/2+A*gI.copper,i=Qh(t);if(t.shape==="rect"){const n=e9A(t.width,t.height,Vn,i);let s=(0,Du.translate)([t.x,t.y,e],n);this.boardClipGeom&&(s=(0,cI.intersect)(this.boardClipGeom,s)),s=(0,Su.colorize)(Mn.copper,s),this.padGeoms.push(s)}else if(t.shape==="rotated_rect"){let n=e9A(t.width,t.height,Vn,i);const o=t.ccw_rotation*Math.PI/180;n=(0,Du.rotateZ)(o,n);let r=(0,Du.translate)([t.x,t.y,e],n);this.boardClipGeom&&(r=(0,cI.intersect)(this.boardClipGeom,r)),r=(0,Su.colorize)(Mn.copper,r),this.padGeoms.push(r)}else if(t.shape==="circle"){let n=(0,II.cylinder)({center:[t.x,t.y,e],radius:t.radius,height:Vn});this.boardClipGeom&&(n=(0,cI.intersect)(this.boardClipGeom,n)),n=(0,Su.colorize)(Mn.copper,n),this.padGeoms.push(n)}}processVia(t){if(this.boardGeom){if(typeof t.outer_diameter=="number"&&typeof t.hole_diameter=="number"){const A=Jpt({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,cI.intersect)(this.boardClipGeom,A),e=(0,Su.colorize)(Mn.copper,e)),this.viaGeoms.push(e)}if(typeof t.hole_diameter=="number"){const A=Tpt({x:t.x,y:t.y,holeDiameter:t.hole_diameter,thickness:this.ctx.pcbThickness});this.boardGeom=(0,cI.subtract)(this.boardGeom,A),this.padGeoms=this.padGeoms.map(e=>(0,Su.colorize)(Mn.copper,(0,cI.subtract)(e,A)))}}}finalize(){if(!this.boardGeom)return;const t=$lA[this.board.material]??Mn.fr4Tan;this.boardGeom=(0,Su.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}},Ppt=t=>{const[A,e]=j.useState(null),i=j.useRef(!1);return j.useEffect(()=>{let n=!1;if(!t){e(null);return}if(!t.some(g=>g.type==="pcb_board"||g.type==="pcb_panel")){e(null);return}const s=Gpt(t);e(s);const r=new qpt(t,g=>{});return(async()=>{if(!i.current){i.current=!0;try{let g=!1;for(;!g&&!n;)g=r.step(1),g||await new Promise(I=>setTimeout(I,0));n||e(r.getGeoms())}catch(g){console.error("Error during board geometry building:",g)}finally{i.current=!1}}})(),()=>{n=!0}},[t]),A},nCA=1.2;function Opt(t){return j.useMemo(()=>{if(!t)return nCA;try{return mi(t).pcb_board.list()[0]?.thickness??nCA}catch{return nCA}},[t])}var Wpt=({children:t,parent:A,position:e,rotation:i,scale:n,color:o,fontSize:s,anchorX:r,anchorY:a,depthOffset:g})=>{const{rootObject:I}=wu(),c=j.useMemo(()=>{const B=new xnA;return B.text=t,e&&B.position.fromArray(e),i&&B.rotation.fromArray(i),n&&B.scale.fromArray(n),B.color=o||"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,n,o,s,r,a,g]);return j.useEffect(()=>{const B=A||I;if(!(!B||!c))return B.add(c),()=>{B.remove(c),c.dispose()}},[I,A,c]),null},i9A=({error:t,cad_component:A})=>{const{rootObject:e}=wu(),[i,n]=j.useState(!1),[o,s]=j.useState(null),r=j.useCallback(c=>{c?.mousePosition?(n(!0),s(c.mousePosition)):(n(!1),s(null))},[]),a=j.useCallback(()=>{n(!1),s(null)},[]),g=j.useMemo(()=>A?.position?[A.position.x,A.position.y,A.position.z].map(B=>Number.isNaN(B)?0:B):[0,0,0],[A]),I=j.useMemo(()=>{const c=new Wp;return c.position.fromArray(g),c},[g]);return j.useEffect(()=>{if(e)return e.add(I),()=>{e.remove(I)}},[e,I]),O.jsxs(O.Fragment,{children:[O.jsxs($U,{isHovered:i,onHover:r,onUnhover:a,object:I,children:[O.jsx(Zpt,{parent:I}),O.jsx(Wpt,{parent:I,scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:`${t.toString().slice(0,50)}...`})]}),i&&o?O.jsx(LVA,{position:o,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]})},Zpt=({parent:t})=>{const A=j.useMemo(()=>{const e=new Zn(new fm(.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 j.useEffect(()=>(t.add(A),()=>{t.remove(A)}),[t,A]),null};function Vpt({stlUrl:t,stlData:A,mtlUrl:e,color:i,opacity:n=1}){const{rootObject:o}=wu(),[s,r]=j.useState(null);j.useEffect(()=>{const g=new q6e;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=j.useMemo(()=>{if(!s)return null;const g=new Ih({color:Array.isArray(i)?new Ui(i[0],i[1],i[2]):i,transparent:n!==1,opacity:n});return new Zn(s,g)},[s,i,n]);return j.useEffect(()=>{if(!(!o||!a))return o.add(a),()=>{o.remove(a),a.geometry.dispose(),Array.isArray(a.material)?a.material.forEach(g=>g.dispose()):a.material.dispose()}},[o,a]),null}function jpt({stlData:t,color:A,opacity:e=1,layerType:i}){const{visibility:n}=iM();let o=!0;return i==="board"?o=n.boardBody:i==="top-copper"?o=n.topCopper:i==="bottom-copper"?o=n.bottomCopper:i==="top-silkscreen"?o=n.topSilkscreen:i==="bottom-silkscreen"&&(o=n.bottomSilkscreen),o?O.jsx(Vpt,{stlData:t,color:A,opacity:e}):null}var n9A=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}},zpt=t=>{if(t.length===0)return null;let A=t[0].x,e=t[0].y,i=t[0].x,n=t[0].y;for(let o=1;o<t.length;o++){const s=t[o];s.x<A&&(A=s.x),s.y<e&&(e=s.y),s.x>i&&(i=s.x),s.y>n&&(n=s.y)}return{minX:A,minY:e,maxX:i,maxY:n}};function AF(t){if(t.outline&&t.outline.length>=3){const s=zpt(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,n=t.center?.y??0;return{...{minX:i-A/2,maxX:i+A/2,minY:n-e/2,maxY:n+e/2},width:A,height:e,centerX:i,centerY:n}}function F5({layer:t,circuitJson:A,boardData:e,soldermaskColor:i,traceTextureResolution:n}){const o=AF(e),s=document.createElement("canvas"),r=Math.floor(o.width*n),a=Math.floor(o.height*n);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-o.minX)*n,c=f=>(o.maxY-f)*n;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 w=1;w<e.outline.length;w++){const S=e.outline[w];g.lineTo(I(S.x),c(S.y))}g.closePath(),g.fill()}else g.fillRect(0,0,r,a);g.globalCompositeOperation="destination-out",g.fillStyle="black",mi(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 w=f.x,S=f.y,D=I(w),x=c(S);if(f.shape==="rect"){const F=f.width*n,k=f.height*n,v=Qh(f),_=hy(f.width,f.height,v)*n;_>0?(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill()):g.fillRect(D-F/2,x-k/2,F,k)}else if(f.shape==="circle"){const F=(f.radius??f.width/2)*n;g.beginPath(),g.arc(D,x,F,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const F=f.width*n,k=f.height*n,v=Qh(f),_=hy(f.width,f.height,v)*n;g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill()}else if(f.shape==="rotated_rect"){const F=f.width*n,k=f.height*n,v=Qh(f),_=hy(f.width,f.height,v)*n,K=-(f.ccw_rotation||0)*(Math.PI/180);g.save(),g.translate(D,x),g.rotate(K),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()}}),mi(A).pcb_via.list().forEach(f=>{const w=I(f.x),S=c(f.y),D=f.outer_diameter/2*n;g.beginPath(),g.arc(w,S,D,0,2*Math.PI),g.fill()}),mi(A).pcb_plated_hole.list().forEach(f=>{if(!f.layers?.includes(t))return;const w=f.x,S=f.y,D=I(w),x=c(S);if(f.shape==="circle"){const k=f.outer_diameter/2*n;g.beginPath(),g.arc(D,x,k,0,2*Math.PI),g.fill()}else if(f.shape==="pill"){const F=(f.outer_width??f.outer_diameter??f.hole_width)*n,k=(f.outer_height??f.outer_diameter??f.hole_height)*n,v=Math.min(F,k)/2,L=-(f.ccw_rotation||0);L?(g.save(),g.translate(D,x),g.rotate(L*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,v),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-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)*n,k=(f.outer_height??f.outer_diameter??f.hole_height)*n,v=F/2,_=k/2,K=-(f.ccw_rotation||0);K?(g.save(),g.translate(D,x),g.rotate(K*Math.PI/180),g.beginPath(),g.ellipse(0,0,v,_,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(D,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),L=c(f.y+v);if(F==="pill"||F==="rotated_pill"){const K=(f.outer_width??f.outer_diameter??f.hole_width)*n,J=(f.outer_height??f.outer_diameter??f.hole_height)*n,W=Math.min(K,J)/2,AA=-(f.ccw_rotation||0);AA?(g.save(),g.translate(_,L),g.rotate(AA*Math.PI/180),g.beginPath(),g.roundRect(-K/2,-J/2,K,J,W),g.fill(),g.restore()):(g.beginPath(),g.roundRect(_-K/2,L-J/2,K,J,W),g.fill())}else if(F==="oval"){const K=(f.outer_width??f.outer_diameter??f.hole_width)*n,J=(f.outer_height??f.outer_diameter??f.hole_height)*n,W=K/2,Z=J/2,nA=-(f.ccw_rotation||0);nA?(g.save(),g.translate(_,L),g.rotate(nA*Math.PI/180),g.beginPath(),g.ellipse(0,0,W,Z,0,0,2*Math.PI),g.fill(),g.restore()):(g.beginPath(),g.ellipse(_,L,W,Z,0,0,2*Math.PI),g.fill())}else if(F==="circle"){const J=(f.outer_diameter??f.hole_diameter??0)*n/2;g.beginPath(),g.arc(_,L,J,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)*n,k=(f.rect_pad_height??f.hole_diameter??0)*n,v=Qh(f),_=hy(f.rect_pad_width??f.hole_diameter??0,f.rect_pad_height??f.hole_diameter??0,v)*n;_>0?(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill()):g.fillRect(D-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)*n,k=(f.rect_pad_height??f.hole_height??0)*n,v=Qh(f),_=hy(f.rect_pad_width??f.hole_width??0,f.rect_pad_height??f.hole_height??0,v)*n,K=-(f.ccw_rotation||0);K?(g.save(),g.translate(D,x),g.rotate(K*Math.PI/180),g.beginPath(),g.roundRect(-F/2,-k/2,F,k,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-F/2,x-k/2,F,k,_),g.fill())}}),mi(A).pcb_hole.list().forEach(f=>{const w=f.x,S=f.y,D=I(w),x=c(S),F=f.hole_shape||f.shape;if(F==="circle"&&typeof f.hole_diameter=="number"){const k=f.hole_diameter/2*n;g.beginPath(),g.arc(D,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*n,v=f.hole_height*n,_=Math.min(k,v)/2,K=-(f.ccw_rotation||0)*(Math.PI/180);K?(g.save(),g.translate(D,x),g.rotate(K),g.beginPath(),g.roundRect(-k/2,-v/2,k,v,_),g.fill(),g.restore()):(g.beginPath(),g.roundRect(D-k/2,x-v/2,k,v,_),g.fill())}}),mi(A).pcb_copper_pour.list().forEach(f=>{if(f.layer===t&&f.covered_with_solder_mask===!1)if(f.shape==="rect"){const w=I(f.center.x),S=c(f.center.y),D=f.width*n,x=f.height*n;g.fillRect(w-D/2,S-x/2,D,x)}else f.shape==="polygon"&&f.points&&(g.beginPath(),f.points.forEach((w,S)=>{const D=I(w.x),x=c(w.y);S===0?g.moveTo(D,x):g.lineTo(D,x)}),g.closePath(),g.fill())}),mi(A).pcb_cutout.list().forEach(f=>{switch(f.shape){case"rect":{const w=I(f.center.x),S=c(f.center.y),D=f.width*n,x=f.height*n,F=Qh(f),k=hy(f.width,f.height,F);if(f.rotation){g.save(),g.translate(w,S);const v=-f.rotation*(Math.PI/180);g.rotate(v),k>0?(g.beginPath(),g.roundRect(-D/2,-x/2,D,x,k*n),g.fill()):g.fillRect(-D/2,-x/2,D,x),g.restore()}else k>0?(g.beginPath(),g.roundRect(w-D/2,S-x/2,D,x,k*n),g.fill()):g.fillRect(w-D/2,S-x/2,D,x);break}case"circle":{const w=I(f.center.x),S=c(f.center.y),D=f.radius*n;g.beginPath(),g.arc(w,S,D,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((w,S)=>{const D=I(w.x),x=c(w.y);S===0?g.moveTo(D,x):g.lineTo(D,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 w_(s);return d.generateMipmaps=!0,d.minFilter=fu,d.magFilter=jB,d.anisotropy=16,d.needsUpdate=!0,d}var Xpt=yr(glA());function o9A(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 kx(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function s9A(...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,...n]=t,o=A(e,i);return s9A(o,...n)}}}function r9A(...t){return s9A(...t)}var{cos:$pt,sin:Aft}=Math;function a9A(t,A,e){const i=$pt(t),n=Aft(t);return{a:i,c:-n,e:0,b:n,d:i,f:0}}function eft(t,A){function e(){this.constructor=t}e.prototype=A.prototype,t.prototype=new e}function R5(t,A,e,i){var n=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(n,R5.prototype),n.expected=A,n.found=e,n.location=i,n.name="SyntaxError",n}eft(R5,Error);function oCA(t,A,e){return e=e||" ",t.length>A?t:(A-=t.length,e+=e.repeat(A),t+e.slice(0,A))}R5.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 n=this.location.start,o=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(n):n,s=this.location.source+":"+o.line+":"+o.column;if(e){var r=this.location.end,a=oCA("",o.line.toString().length," "),g=e[n.line-1],I=n.line===r.line?r.column:g.length+1,c=I-n.column||1;A+=`
5101
5101
  --> `+s+`
5102
5102
  `+a+` |
5103
5103
  `+o.line+" | "+g+`
5104
5104
  `+a+" | "+oCA("",n.column-1," ")+oCA("",c,"^")}else A+=`
5105
- at `+s}return A},R5.buildMessage=function(t,A){var e={literal:function(g){return'"'+n(g.text)+'"'},class:function(g){var I=g.parts.map(function(c){return Array.isArray(c)?o(c[0])+"-"+o(c[1]):o(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 n(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 o(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?'"'+n(g)+'"':"end of input"}return"Expected "+r(t)+" but "+a(A)+" found."};var g9A=25.4,tft=g9A/1e3,ift=/^\s*(-?\d*(?:\.\d+)?)(?:\s*(mm|mil|inch|in|"))?\s*$/i;function nft(t){if(!t)return;const A=t.trim().toLowerCase();return A==='"'||A==="inch"?"in":A}function hQ(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(ift);if(!e){const r=Number.parseFloat(A);return Number.isFinite(r)?r:void 0}const[,i,n]=e,o=Number.parseFloat(i||"0");if(!Number.isFinite(o))return;switch(nft(n)){case"mil":return o*tft;case"in":return o*g9A;case"mm":case void 0:return o;default:return o}}function Sm(t,A){const e=hQ(t);return e===void 0?A:e}function I9A(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),n=parseInt(A.slice(4,6),16);return`rgb(${e}, ${i}, ${n})`}return t.startsWith("rgb")?t:"rgb(255, 243, 204)"}function N5({layer:t,circuitJson:A,boardData:e,silkscreenColor:i="rgb(255,255,255)",traceTextureResolution:n}){const o=mi(A).pcb_silkscreen_text.list(),s=mi(A).pcb_silkscreen_path.list(),r=mi(A).pcb_silkscreen_line.list(),a=mi(A).pcb_silkscreen_rect.list(),g=mi(A).pcb_silkscreen_circle.list(),I=mi(A).pcb_fabrication_note_rect.list(),c=mi(A).pcb_note_line.list(),B=o.filter(v=>v.layer===t),l=s.filter(v=>v.layer===t),C=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&&l.length===0&&C.length===0&&Q.length===0&&E.length===0&&h.length===0&&u.length===0)return null;const d=AF(e),f=document.createElement("canvas"),w=Math.floor(d.width*n),S=Math.floor(d.height*n);f.width=w,f.height=S;const D=f.getContext("2d");if(!D)return null;t==="bottom"&&(D.translate(0,S),D.scale(1,-1)),D.strokeStyle=i,D.fillStyle=i;const x=v=>(v-d.minX)*n,F=v=>(d.maxY-v)*n;C.forEach(v=>{const _=hQ(v.x1)??0,L=hQ(v.y1)??0,K=hQ(v.x2)??0,J=hQ(v.y2)??0;_===K&&L===J||(D.beginPath(),D.lineWidth=Sm(v.stroke_width,.1)*n,D.lineCap="round",D.moveTo(x(_),F(L)),D.lineTo(x(K),F(J)),D.stroke())}),u.forEach(v=>{const _=hQ(v.x1)??0,L=hQ(v.y1)??0,K=hQ(v.x2)??0,J=hQ(v.y2)??0;if(_===K&&L===J)return;D.save();let W=i;v.color?W=I9A(v.color):W="rgb(255, 243, 204)",D.strokeStyle=W,D.beginPath(),D.lineWidth=Sm(v.stroke_width,.1)*n,D.lineCap="round";const Z=v.is_dashed??!1;if(Z){const AA=Math.max(D.lineWidth*2,1);D.setLineDash([AA,AA])}D.moveTo(x(_),F(L)),D.lineTo(x(K),F(J)),D.stroke(),Z&&D.setLineDash([]),D.restore()}),l.forEach(v=>{v.route.length<2||(D.beginPath(),D.lineWidth=Sm(v.stroke_width,.1)*n,D.lineCap="round",D.lineJoin="round",v.route.forEach((_,L)=>{const K=x(hQ(_.x)??0),J=F(hQ(_.y)??0);L===0?D.moveTo(K,J):D.lineTo(K,J)}),D.stroke())}),E.forEach(v=>{const _=Sm(v.radius,0);if(_<=0)return;const L=Sm(v.stroke_width,.12),K=L>0,J=hQ(v.center?.x)??0,W=hQ(v.center?.y)??0,Z=x(J),AA=F(W),nA=_*n;if(D.save(),D.translate(Z,AA),K){const cA=nA+L/2*n,tA=Math.max(0,nA-L/2*n);tA>0?(D.beginPath(),D.arc(0,0,cA,0,2*Math.PI),D.arc(0,0,tA,0,2*Math.PI,!0),D.fill("evenodd")):(D.beginPath(),D.arc(0,0,cA,0,2*Math.PI),D.fill())}else D.beginPath(),D.arc(0,0,nA,0,2*Math.PI),D.fill();D.restore()}),Q.forEach(v=>{const _=Sm(v.width,0),L=Sm(v.height,0);if(_<=0||L<=0)return;const K=hQ(v.center?.x)??0,J=hQ(v.center?.y)??0,W=x(K),Z=F(J),AA=Qh(v),nA=typeof AA=="string"?hQ(AA):AA,cA=hy(_,L,nA);D.save(),D.translate(W,Z);const tA=_/2*n,oA=L/2*n,rA=Math.min(cA*n,tA,oA),CA=v.stroke_width??!1,dA=v.is_filled??!0,bA=v.is_stroke_dashed??!1,kA=CA?Sm(v.stroke_width,.1)*n:0;if(((gA,yA,EA,TA,te)=>{if(D.beginPath(),te<=0)D.rect(gA,yA,EA,TA);else{const ce=te,mA=gA+EA,qA=yA+TA;D.moveTo(gA+ce,yA),D.lineTo(mA-ce,yA),D.quadraticCurveTo(mA,yA,mA,yA+ce),D.lineTo(mA,qA-ce),D.quadraticCurveTo(mA,qA,mA-ce,qA),D.lineTo(gA+ce,qA),D.quadraticCurveTo(gA,qA,gA,qA-ce),D.lineTo(gA,yA+ce),D.quadraticCurveTo(gA,yA,gA+ce,yA),D.closePath()}})(-tA,-oA,tA*2,oA*2,rA),dA&&D.fill(),CA&&kA>0){if(D.lineWidth=kA,bA){const gA=Math.max(kA*2,1);D.setLineDash([gA,gA])}D.stroke(),bA&&D.setLineDash([])}D.restore()}),h.forEach(v=>{const _=Sm(v.width,0),L=Sm(v.height,0);if(_<=0||L<=0)return;const K=hQ(v.center?.x)??0,J=hQ(v.center?.y)??0,W=x(K),Z=F(J),AA=Qh(v),nA=typeof AA=="string"?hQ(AA):AA,cA=hy(_,L,nA);D.save(),D.translate(W,Z);const tA=_/2*n,oA=L/2*n,rA=Math.min(cA*n,tA,oA),CA=v.has_stroke??!1,dA=v.is_filled??!0,bA=v.is_stroke_dashed??!1,kA=CA?Sm(v.stroke_width,.1)*n:0;let JA=i,gA=i;if(v.color){const EA=I9A(v.color);JA=EA,gA=EA}else JA="rgb(255, 243, 204)",gA="rgb(255, 243, 204)";if(((EA,TA,te,ce,mA)=>{if(D.beginPath(),mA<=0)D.rect(EA,TA,te,ce);else{const qA=mA,LA=EA+te,HA=TA+ce;D.moveTo(EA+qA,TA),D.lineTo(LA-qA,TA),D.quadraticCurveTo(LA,TA,LA,TA+qA),D.lineTo(LA,HA-qA),D.quadraticCurveTo(LA,HA,LA-qA,HA),D.lineTo(EA+qA,HA),D.quadraticCurveTo(EA,HA,EA,HA-qA),D.lineTo(EA,TA+qA),D.quadraticCurveTo(EA,TA,EA+qA,TA),D.closePath()}})(-tA,-oA,tA*2,oA*2,rA),dA&&(D.fillStyle=JA,D.fill()),CA&&kA>0){if(D.strokeStyle=gA,D.lineWidth=kA,bA){const EA=Math.max(kA*2,1);D.setLineDash([EA,EA])}D.stroke(),bA&&D.setLineDash([])}D.restore()}),B.forEach(v=>{const _=v.font_size||.25,L=Math.min(Math.max(.01,_*.1),_*.05)*n;D.lineWidth=L,D.lineCap="butt",D.lineJoin="miter";const K=(0,Xpt.vectorText)({height:_*.45,input:v.text}),J=[];K.forEach(bA=>{bA.length===29?(J.push(bA.slice(0,15)),J.push(bA.slice(14,29))):bA.length===17?(J.push(bA.slice(0,10)),J.push(bA.slice(9,17))):J.push(bA)});const W=J.flat(),Z={minX:W.length>0?Math.min(...W.map(bA=>bA[0])):0,maxX:W.length>0?Math.max(...W.map(bA=>bA[0])):0,minY:W.length>0?Math.min(...W.map(bA=>bA[1])):0,maxY:W.length>0?Math.max(...W.map(bA=>bA[1])):0},AA=(Z.minX+Z.maxX)/2,nA=(Z.minY+Z.maxY)/2;let cA=-AA,tA=-nA;const oA=v.anchor_alignment||"center";oA.includes("left")?cA=-Z.minX:oA.includes("right")&&(cA=-Z.maxX),oA.includes("top")?tA=-Z.maxY:oA.includes("bottom")&&(tA=-Z.minY);const rA=[];let CA=v.ccw_rotation??0;if(v.layer==="bottom"&&(rA.push(kx(AA,nA),{a:-1,b:0,c:0,d:1,e:0,f:0},kx(-AA,-nA)),CA=-CA),CA){const bA=CA*Math.PI/180;rA.push(kx(AA,nA),a9A(bA),kx(-AA,-nA))}const dA=rA.length>0?r9A(...rA):void 0;J.forEach(bA=>{D.beginPath(),bA.forEach((kA,JA)=>{let gA={x:kA[0],y:kA[1]};dA&&(gA=o9A(dA,gA));const yA=gA.x+cA+v.anchor_position.x,EA=gA.y+tA+v.anchor_position.y,TA=x(yA),te=F(EA);JA===0?D.moveTo(TA,te):D.lineTo(TA,te)}),D.stroke()})});const k=new w_(f);return k.generateMipmaps=!0,k.minFilter=fu,k.magFilter=jB,k.anisotropy=16,k.needsUpdate=!0,k}function c9A(t){return t&&t.route_type==="wire"&&typeof t.layer=="string"&&typeof t.width=="number"}function oM({layer:t,circuitJson:A,boardData:e,traceColor:i,traceTextureResolution:n}){const o=mi(A).pcb_trace.list(),s=mi(A).pcb_via.list(),r=mi(A).pcb_plated_hole.list(),a=o.filter(Q=>Q.route.some(E=>c9A(E)&&E.layer===t));if(a.length===0)return null;const g=AF(e),I=document.createElement("canvas"),c=Math.floor(g.width*n),B=Math.floor(g.height*n);I.width=c,I.height=B;const l=I.getContext("2d");if(!l)return null;t==="bottom"&&(l.translate(0,B),l.scale(1,-1)),a.forEach(Q=>{let E=!0;l.beginPath(),l.strokeStyle=i,l.lineCap="round",l.lineJoin="round";let h=0;for(const u of Q.route){if(!c9A(u)||u.layer!==t){E||l.stroke(),E=!0;continue}const d=u.x,f=u.y;h=u.width*n,l.lineWidth=h;const w=(d-g.minX)*n,S=(g.maxY-f)*n;E?(l.moveTo(w,S),E=!1):l.lineTo(w,S)}E||l.stroke()}),l.globalCompositeOperation="destination-out",l.fillStyle="black",s.forEach(Q=>{const E=(Q.x-g.minX)*n,h=(g.maxY-Q.y)*n,u=Q.outer_diameter/2*n;l.beginPath(),l.arc(E,h,u,0,2*Math.PI,!1),l.fill()}),r.forEach(Q=>{if(Q.layers.includes(t)&&Q.shape==="circle"){const E=(Q.x-g.minX)*n,h=(g.maxY-Q.y)*n,u=Q.outer_diameter/2*n;l.beginPath(),l.arc(E,h,u,0,2*Math.PI,!1),l.fill()}}),l.globalCompositeOperation="source-over";const C=new w_(I);return C.generateMipmaps=!0,C.minFilter=fu,C.magFilter=jB,C.anisotropy=16,C.needsUpdate=!0,C}var oft=yr(glA());function _5(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 sft(t){return t.layer==="bottom"?t.is_mirrored!==!1:t.is_mirrored===!0}function rft(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])),n=Math.min(...A.map(s=>s[1])),o=Math.max(...A.map(s=>s[1]));return{minX:e,maxX:i,minY:n,maxY:o,width:i-e,height:o-n,centerX:(e+i)/2,centerY:(n+o)/2}}function aft(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 gft(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 Ift(t,A){const e=[];let i=t.ccw_rotation??0;if(sft(t)&&(e.push(kx(A.centerX,A.centerY),{a:-1,b:0,c:0,d:1,e:0,f:0},kx(-A.centerX,-A.centerY)),i=-i),i){const s=i*Math.PI/180;e.push(kx(A.centerX,A.centerY),a9A(s),kx(-A.centerX,-A.centerY))}return{matrix:e.length>0?r9A(...e):void 0,rotationDeg:i}}function B9A(t,A,e,i,n,o,s){A.forEach(r=>{t.beginPath(),r.forEach((a,g)=>{let I={x:a[0],y:a[1]};e&&(I=o9A(e,I));const c=I.x+i.x+n.x,B=I.y+i.y+n.y,l=o(c),C=s(B);g===0?t.moveTo(l,C):t.lineTo(l,C)}),t.stroke()})}function cft(t,A,e,i,n,o){t.save(),t.translate(A,e),t.rotate(-o),t.fillRect(-i/2,-n/2,i,n),t.restore()}function Bft(t,A,e,i,n,o,s,r,a,g){const I=typeof A.font_size=="number"?A.font_size:.2,c={left:_5(A.knockout_padding?.left,I*.5),right:_5(A.knockout_padding?.right,I*.5),top:_5(A.knockout_padding?.top,I*.3),bottom:_5(A.knockout_padding?.bottom,I*.3)},B=i.width+c.left+c.right,l=i.height+c.top+c.bottom,C=s(A.anchor_position.x),Q=r(A.anchor_position.y),E=B*a,h=l*a;t.fillStyle=g;const u=o*Math.PI/180;cft(t,C,Q,E,h,u);const d={x:-i.centerX,y:-i.centerY};t.globalCompositeOperation="destination-out",B9A(t,e,n,d,A.anchor_position,s,r),t.globalCompositeOperation="source-over"}function M5({layer:t,circuitJson:A,boardData:e,copperColor:i="rgb(230, 153, 51)",traceTextureResolution:n}){const s=A.filter(Q=>Q.type==="pcb_copper_text").filter(Q=>Q.layer===t);if(s.length===0)return null;const r=AF(e),a=document.createElement("canvas"),g=Math.floor(r.width*n),I=Math.floor(r.height*n);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)*n,l=Q=>(r.maxY-Q)*n;s.forEach(Q=>{const E=typeof Q.font_size=="number"?Q.font_size:.2,h=Math.max(.02,E*.08)*n;c.lineWidth=h,c.lineCap="round",c.lineJoin="round";const u=(0,oft.vectorText)({height:E*.45,input:Q.text}),d=aft(u),f=rft(d),{matrix:w,rotationDeg:S}=Ift(Q,f);if(Q.is_knockout)Bft(c,Q,d,f,w,S,B,l,n,i);else{const D=Q.anchor_alignment||"center",x=gft(f,D);B9A(c,d,w,x,Q.anchor_position,B,l)}});const C=new w_(a);return C.generateMipmaps=!0,C.minFilter=fu,C.magFilter=jB,C.anisotropy=16,C.needsUpdate=!0,C}function v5({layer:t,circuitJson:A,panelData:e,outlineColor:i="black",traceTextureResolution:n}){const o=mi(A).pcb_board.list().filter(l=>l.pcb_panel_id===e.pcb_board_id);if(o.length===0)return null;const s=document.createElement("canvas"),r=Math.floor(e.width*n),a=Math.floor(e.height*n);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*n;const I=l=>(l-e.center.x+e.width/2)*n,c=l=>(-(l-e.center.y)+e.height/2)*n;o.forEach(l=>{if(l.outline&&l.outline.length>=2)g.beginPath(),l.outline.forEach((C,Q)=>{const E=I(C.x),h=c(C.y);Q===0?g.moveTo(E,h):g.lineTo(E,h)}),g.closePath(),g.stroke();else{const C=l.width,Q=l.height,{x:E,y:h}=l.center,u=I(E-C/2),d=c(h+Q/2);g.strokeRect(u,d,C*n,Q*n)}});const B=new w_(s);return B.generateMipmaps=!0,B.minFilter=fu,B.magFilter=jB,B.anisotropy=16,B.needsUpdate=!0,B}function lft({circuitJson:t,pcbThickness:A,isFaux:e=!1}){const{rootObject:i}=wu(),{visibility:n}=iM(),o=j.useMemo(()=>{const r=t.filter(I=>I.type==="pcb_panel"),a=mi(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=j.useMemo(()=>{if(!o||!o.width||!o.height)return null;const r=VVA[o.material]??Mn.fr4SolderMaskGreen,a=`rgb(${Math.round(r[0]*255)}, ${Math.round(r[1]*255)}, ${Math.round(r[2]*255)})`,g="rgb(255,255,255)",I=Mn.fr4TracesWithMaskGreen,c=`rgb(${Math.round(I[0]*255)}, ${Math.round(I[1]*255)}, ${Math.round(I[2]*255)})`;return{topSoldermask:F5({layer:"top",circuitJson:t,boardData:o,soldermaskColor:a,traceTextureResolution:hc}),bottomSoldermask:F5({layer:"bottom",circuitJson:t,boardData:o,soldermaskColor:a,traceTextureResolution:hc}),topSilkscreen:N5({layer:"top",circuitJson:t,boardData:o,silkscreenColor:g,traceTextureResolution:hc}),bottomSilkscreen:N5({layer:"bottom",circuitJson:t,boardData:o,silkscreenColor:g,traceTextureResolution:hc}),topTraceWithMask:oM({layer:"top",circuitJson:t,boardData:o,traceColor:c,traceTextureResolution:hc}),bottomTraceWithMask:oM({layer:"bottom",circuitJson:t,boardData:o,traceColor:c,traceTextureResolution:hc}),topCopperText:M5({layer:"top",circuitJson:t,boardData:o,copperColor:`rgb(${Math.round(Mn.copper[0]*255)}, ${Math.round(Mn.copper[1]*255)}, ${Math.round(Mn.copper[2]*255)})`,traceTextureResolution:hc}),bottomCopperText:M5({layer:"bottom",circuitJson:t,boardData:o,copperColor:`rgb(${Math.round(Mn.copper[0]*255)}, ${Math.round(Mn.copper[1]*255)}, ${Math.round(Mn.copper[2]*255)})`,traceTextureResolution:hc}),topPanelOutlines:v5({layer:"top",circuitJson:t,panelData:o,traceTextureResolution:hc}),bottomPanelOutlines:v5({layer:"bottom",circuitJson:t,panelData:o,traceTextureResolution:hc})}},[t,o]);return j.useEffect(()=>{if(!i||!o||!s)return;const r=[],a=(I,c,B,l,C=!1,Q=!1)=>{if(!I)return null;const E=AF(o),h=new ym(E.width,E.height),u=new pd({map:I,transparent:!0,side:Ll,depthWrite:Q,polygonOffset:C,polygonOffsetFactor:C?-1:0,polygonOffsetUnits:C?-1:0,opacity:e?w5:1}),d=new Zn(h,u);return d.position.set(E.centerX,E.centerY,c),B&&d.rotation.set(Math.PI,0,0),d.name=l,d},g=.001;if(n.topMask){const I=a(s.topSoldermask,A/2+g,!1,"jscad-top-soldermask",!0);I&&(r.push(I),i.add(I))}if(n.bottomMask){const I=a(s.bottomSoldermask,-A/2-g,!0,"jscad-bottom-soldermask",!0);I&&(r.push(I),i.add(I))}if(n.topCopper&&n.topMask){const I=a(s.topTraceWithMask,A/2+gI.traces+.004,!1,"jscad-top-trace-with-mask");I&&(r.push(I),i.add(I))}if(n.bottomCopper&&n.bottomMask){const I=a(s.bottomTraceWithMask,-A/2-gI.traces-.005,!0,"jscad-bottom-trace-with-mask");I&&(r.push(I),i.add(I))}if(n.topSilkscreen){const I=a(s.topSilkscreen,A/2+g+.002,!1,"jscad-top-silkscreen");I&&(r.push(I),i.add(I))}if(n.bottomSilkscreen){const I=a(s.bottomSilkscreen,-A/2-g-.002,!0,"jscad-bottom-silkscreen");I&&(r.push(I),i.add(I))}if(n.topCopper){const I=a(s.topCopperText,A/2+gI.copper,!1,"jscad-top-copper-text");I&&(r.push(I),i.add(I))}if(n.bottomCopper){const I=a(s.bottomCopperText,-A/2-gI.copper,!0,"jscad-bottom-copper-text");I&&(r.push(I),i.add(I))}if(n.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 Op&&I.material.dispose()})}},[i,o,s,A,n]),null}function Cft(t){const A=mi(t).cad_component.list(),e=mi(t).pcb_smtpad.list(),i=mi(t).pcb_hole.list(),n=mi(t).pcb_plated_hole.list(),o=mi(t).pcb_via.list();if(A.length===0&&e.length===0&&i.length===0&&n.length===0&&o.length===0)return null;const s=[...i,...n,...o,...e],r=M1(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,l=Math.max(Math.abs(a),Math.abs(g))+B,C=Math.max(Math.abs(I),Math.abs(c))+B,Q=Math.max(2*l,10),E=Math.max(2*C,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 l9A(t){if(mi(t).pcb_board.list().length>0)return t;const e=Cft(t);if(!e)return t;const n=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+n}}}}return s}),e]}var Qft=j.forwardRef(({soup:t,circuitJson:A,children:e,autoRotateDisabled:i,clickToInteractEnabled:n,onUserInteraction:o,onCameraControllerReady:s},r)=>{const a=ZVA(e),g=j.useMemo(()=>l9A(t??A??a),[t,A,a]),I=Ppt(g),c=j.useMemo(()=>{if(!g)return[5,-5,5];try{const u=mi(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 w=5,S=Math.max(d,w),D=Math.max(f,w),x=Math.max(S,D);return[x*.4,-x*.7,x*.9]}catch(u){return console.error(u),[5,-5,5]}},[g]),B=j.useMemo(()=>{if(!g)return!1;try{const u=mi(g).pcb_board.list()[0];return!!u&&u.pcb_board_id==="faux-board"}catch{return!1}},[g]),l=j.useMemo(()=>{if(g)try{const u=mi(g).pcb_board.list()[0];return u?{width:u.width??0,height:u.height??0}:void 0}catch(u){console.error(u);return}},[g]),C=j.useMemo(()=>{if(g)try{const u=mi(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=Opt(g),{stls:E}=ypt(I),h=mi(g).cad_component.list();return O.jsxs(WVA,{ref:r,autoRotateDisabled:i,initialCameraPosition:c,clickToInteractEnabled:n,boardDimensions:l,boardCenter:C,onUserInteraction:o,onCameraControllerReady:s,children:[E.map(({stlData:u,color:d,layerType:f},w)=>O.jsx(jpt,{stlData:u,color:d,opacity:w===0?B?.8:.95:1,layerType:f},`board-${w}`)),O.jsx(lft,{circuitJson:g,pcbThickness:Q,isFaux:B}),h.map(u=>O.jsx(n9A,{fallback:({error:d})=>O.jsx(i9A,{cad_component:u,error:d}),children:O.jsx(TVA,{cad_component:u,circuitJson:g},u.cad_component_id)},u.cad_component_id))]})}),Eft=t=>{let A=0;for(let i=0;i<t.length;i++){const n=(i+1)%t.length;t[i]&&t[n]&&(A+=t[i][0]*t[n][1],A-=t[n][0]*t[i][1])}return A/2<=0};function hft(t,A,e,i,n){let o,s=null;if(e.outline&&e.outline.length>=3){let r=e.outline.map(g=>[g.x,g.y]);Eft(r)&&(r=r.reverse());const a=A.ofPolygons([r]);n.push(a),s=a,o=t.extrude(a,i,void 0,void 0,void 0,!0),n.push(o)}else e.outline&&e.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),o=t.cube([e.width,e.height,i],!0),n.push(o),o=o.translate([e.center.x,e.center.y,0]),n.push(o);return{boardOp:o,outlineCrossSection:s}}var uft=64;function uy({Manifold:t,width:A,height:e,thickness:i,borderRadius:n}){const o=hy(A,e,n);if(o<=0)return t.cube([A,e,i],!0);const s=[],r=A-2*o,a=e-2*o;return r>0&&s.push(t.cube([r,e,i],!0)),a>0&&s.push(t.cube([A,a,i],!0)),[[A/2-o,e/2-o],[-A/2+o,e/2-o],[-A/2+o,-e/2+o],[A/2-o,-e/2+o]].forEach(([I,c])=>{s.push(t.cylinder(i,o,o,uft,!0).translate([I,c,0]))}),t.union(s)}function dft({Manifold:t,pad:A,padBaseThickness:e}){if(A.shape==="rect"){const i=Qh(A);return uy({Manifold:t,width:A.width,height:A.height,thickness:e,borderRadius:i})}else if(A.shape==="rotated_rect"){const i=Qh(A);let n=uy({Manifold:t,width:A.width,height:A.height,thickness:e,borderRadius:i});const o=A.ccw_rotation??0;return o&&(n=n.rotate([0,0,o])),n}else if(A.shape==="circle"&&A.radius)return t.cylinder(e,A.radius,-1,32,!0);return null}var pft=t=>{let A=0;for(let i=0;i<t.length;i++){const n=(i+1)%t.length;t[i]&&t[n]&&(A+=t[i][0]*t[n][1],A-=t[n][0]*t[i][1])}return A/2<=0};function fft(t,A,e,i,n){const o=[],s=mi(e).pcb_cutout.list();for(const r of s){let a;const g=i*1.5;switch(r.shape){case"rect":{const B=Qh(r);if(typeof B=="number"&&B>0?a=uy({Manifold:t,width:r.width,height:r.height,thickness:g,borderRadius:B}):a=t.cube([r.width,r.height,g],!0),n.push(a),r.rotation){const l=a.rotate([0,0,r.rotation]);n.push(l),a=l}a=a.translate([r.center.x,r.center.y,0]),n.push(a);break}case"circle":a=t.cylinder(g,r.radius,-1,wC,!0),n.push(a),a=a.translate([r.center.x,r.center.y,0]),n.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]);pft(I)&&(I=I.reverse());const c=A.ofPolygons([I]);n.push(c),a=t.extrude(c,g,0,0,[1,1],!0),n.push(a);break;default:console.warn(`Unsupported cutout shape: ${r.shape} for cutout ${r.pcb_cutout_id}`);continue}a&&o.push(a)}return{cutoutOps:o}}function C9A({Manifold:t,x:A,y:e,diameter:i,thickness:n,segments:o=32}){return t.cylinder(n*1.2,i/2,i/2,o,!0).translate([A,e,0])}function Q9A({Manifold:t,x:A,y:e,holeDiameter:i,thickness:n,zOffset:o=.001,segments:s=32}){const r=i/2+o;return t.cylinder(n*1.2,r,r,s,!0).translate([A,e,0])}function yft(t){return(t.shape==="circle"||t.hole_shape==="circle")&&typeof t.hole_diameter=="number"}function mft(t){return(t.shape==="pill"||t.hole_shape==="pill")&&typeof t.hole_width=="number"&&typeof t.hole_height=="number"}function wft(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 Dft(t,A,e,i){const n=[],o=mi(A).pcb_hole.list(),s=(r,a,g)=>{const I=uy({Manifold:t,width:r,height:a,thickness:g,borderRadius:Math.min(r,a)/2});return i.push(I),I};return o.forEach(r=>{if(yft(r)){const a=C9A({Manifold:t,x:r.x,y:r.y,diameter:r.hole_diameter,thickness:e,segments:wC});i.push(a),n.push(a)}else if(mft(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),n.push(B)}else if(wft(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 l=c.translate([r.x,r.y,0]);i.push(l),n.push(l)}}),{nonPlatedHoleBoardDrills:n}}function _w(t){const A=new dg;if(A.setAttribute("position",new Lo(t.vertProperties,3)),A.setIndex(new yiA(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],n=t.runIndex[e+1]-i;A.addGroup(i,n,0)}else A.addGroup(0,t.triVerts.length,0);return A}var QL=t=>{let A=0;for(let i=0;i<t.length;i++){const n=(i+1)%t.length;t[i]&&t[n]&&(A+=t[i][0]*t[n][1],A-=t[n][0]*t[i][1])}return A/2<=0},U5=(t,A,e)=>{const i=[];for(let n=0;n<e;n++){const o=2*Math.PI*n/e;i.push([t/2*Math.cos(o),A/2*Math.sin(o)])}return i},sM=new Ui(...Mn.copper),E9A=.05;function Sft(t,A,e,i,n,o){const s=[],r=mi(e).pcb_plated_hole.list(),a=[],g=[],I=(C,Q,E)=>{const h=uy({Manifold:t,width:C,height:Q,thickness:E,borderRadius:Math.min(C,Q)/2});return n.push(h),h},c=({padOutline:C,thickness:Q})=>{if(!Array.isArray(C)||C.length<3)return null;let E=C.map(d=>[d.x,d.y]);QL(E)&&(E=E.reverse());const h=A.ofPolygons([E]);n.push(h);const u=t.extrude(h,Q,0,0,[1,1],!0);return n.push(u),u},B=({ph:C,depth:Q,sizeDelta:E=0})=>{if(C.shape!=="hole_with_polygon_pad")return null;const u=C.pad_outline;if(!Array.isArray(u)||u.length<3)return null;const d=C.hole_shape||"circle",f=C.hole_offset_x||0,w=C.hole_offset_y||0;let S=null;if(d==="circle"){const D=Math.max((C.hole_diameter??0)+E,Vn),x=Math.max(D/2,Vn/2);S=t.cylinder(Q,x,x,wC,!0),n.push(S)}else{const D=C.hole_width??C.hole_diameter,x=C.hole_height??C.hole_diameter;if(!D||!x)return null;const F=Math.max(D+E,Vn),k=Math.max(x+E,Vn);if(d==="oval"){let v=U5(F,k,wC);QL(v)&&(v=v.reverse());const _=A.ofPolygons([v]);n.push(_),S=t.extrude(_,Q,0,0,[1,1],!0),n.push(S)}else(d==="pill"||d==="rotated_pill")&&(S=uy({Manifold:t,width:F,height:k,thickness:Q,borderRadius:Math.min(F,k)/2}),n.push(S))}if(!S)return null;if(f||w){const D=S.translate([f,w,0]);n.push(D),S=D}return S};r.forEach((C,Q)=>{if(C.shape==="circle"){const E=Q9A({Manifold:t,x:C.x,y:C.y,holeDiameter:C.hole_diameter*1.02,thickness:i,zOffset:Ey,segments:wC});n.push(E),s.push(E);const h=i+2*Ey,u=t.cylinder(h,C.outer_diameter/2,C.outer_diameter/2,wC,!0);n.push(u);const d=t.cylinder(h*1.05,C.hole_diameter/2,C.hole_diameter/2,wC,!0);n.push(d);const f=u.subtract(d);n.push(f);const w=f.translate([C.x,C.y,0]);n.push(w);let S=w;if(o){const x=t.intersection([w,o]);n.push(x),S=x}g.push(S);const D=_w(S.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:D,color:sM})}else if(C.shape==="pill"){const E=C.hole_width,h=C.hole_height,u=.4,d=C.outer_width??E+u,f=C.outer_height??h+u,w=E+2*Ey,S=h+2*Ey,D=i*1.2;let x=I(w,S,D);if(C.ccw_rotation){const Z=x.rotate([0,0,C.ccw_rotation]);n.push(Z),x=Z}const F=x.translate([C.x,C.y,0]);n.push(F),s.push(F);const k=i+2*Ey,v=I(d,f,k),_=I(E,h,k*1.05);let L=v.subtract(_);if(n.push(L),C.ccw_rotation){const Z=L.rotate([0,0,C.ccw_rotation]);n.push(Z),L=Z}const K=L.translate([C.x,C.y,0]);n.push(K);let J=K;if(o){const Z=t.intersection([K,o]);n.push(Z),J=Z}g.push(J);const W=_w(J.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:W,color:sM})}else if(C.shape==="pill_hole_with_rect_pad"){const E=C.hole_width,h=C.hole_height,u=C.hole_offset_x||0,d=C.hole_offset_y||0,f=C.rect_pad_width,w=C.rect_pad_height,S=Qh(C),D=m5,x=E+2*Ey,F=h+2*Ey,k=i*1.2,_=I(x,F,k).translate([u,d,0]).translate([C.x,C.y,0]);n.push(_),s.push(_);const L=uy({Manifold:t,width:f,height:w,thickness:i-2*D-2*gI.copper+.1,borderRadius:S});n.push(L);const K=uy({Manifold:t,width:f,height:w,thickness:D,borderRadius:S}).translate([0,0,i/2/2+gI.copper]),J=uy({Manifold:t,width:f,height:w,thickness:D,borderRadius:S}).translate([0,0,-i/2/2-gI.copper]);n.push(K,J);const W=I(E,h,i*1.02).translate([u,d,0]);n.push(W);const Z=t.union([L,K,J,W]);n.push(Z);const AA=I(Math.max(E-2*E9A,.01),Math.max(h-2*E9A,.01),i*1.2).translate([u,d,0]);n.push(AA);const nA=Z.subtract(AA);n.push(nA);const cA=nA.translate([C.x,C.y,0]);n.push(cA);let tA=cA;if(o){const rA=t.intersection([cA,o]);n.push(rA),tA=rA}g.push(tA);const oA=_w(tA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:oA,color:sM})}else if(C.shape==="hole_with_polygon_pad"){const E=C.pad_outline;if(!Array.isArray(E)||E.length<3)return;const h=B({ph:C,depth:i*1.2,sizeDelta:2*Vn});if(!h)return;const u=h.translate([C.x,C.y,0]);n.push(u),s.push(u);const d=m5,f=Math.max(i-2*d-2*gI.copper+.1,Vn),w=c({padOutline:E,thickness:f}),S=c({padOutline:E,thickness:d}),D=c({padOutline:E,thickness:d});if(!w||!S||!D)return;const x=S.translate([0,0,i/2/2+gI.copper]),F=D.translate([0,0,-i/2/2-gI.copper]);n.push(x,F);const k=B({ph:C,depth:i*1.02});if(!k)return;const v=B({ph:C,depth:i*1.2,sizeDelta:-2*Vn})||k,_=t.union([w,x,F,k]);n.push(_);const L=_.subtract(v);n.push(L);const K=L.translate([C.x,C.y,0]);n.push(K);let J=K;if(o){const Z=t.intersection([K,o]);n.push(Z),J=Z}g.push(J);const W=_w(J.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:W,color:sM})}else if(C.shape==="oval"){const E=C.hole_width,h=C.hole_height,u=C.outer_width??E+.4,d=C.outer_height??h+.4,f=E+2*Ey,w=h+2*Ey,S=i*1.2;let D=U5(f,w,wC);QL(D)&&(D=D.reverse());const x=A.ofPolygons([D]);n.push(x);let F=t.extrude(x,S,0,0,[1,1],!0);if(n.push(F),C.ccw_rotation){const oA=F.rotate([0,0,C.ccw_rotation]);n.push(oA),F=oA}const k=F.translate([C.x,C.y,0]);n.push(k),s.push(k);const v=i+2*Ey;let _=U5(u,d,wC);QL(_)&&(_=_.reverse());const L=A.ofPolygons([_]);n.push(L);let K=t.extrude(L,v,0,0,[1,1],!0);n.push(K);let J=U5(E,h,wC);QL(J)&&(J=J.reverse());const W=A.ofPolygons([J]);n.push(W);let Z=t.extrude(W,v*1.05,0,0,[1,1],!0);n.push(Z);let AA=K.subtract(Z);if(n.push(AA),C.ccw_rotation){const oA=AA.rotate([0,0,C.ccw_rotation]);n.push(oA),AA=oA}const nA=AA.translate([C.x,C.y,0]);n.push(nA);let cA=nA;if(o){const oA=t.intersection([nA,o]);n.push(oA),cA=oA}g.push(cA);const tA=_w(cA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:tA,color:sM})}else if(C.shape==="circular_hole_with_rect_pad"){const E=C.hole_offset_x||0,h=C.hole_offset_y||0,u=C9A({Manifold:t,x:C.x+E,y:C.y+h,diameter:C.hole_diameter,thickness:i,segments:wC});n.push(u),s.push(u);const d=C.rect_pad_width??C.hole_diameter,f=C.rect_pad_height??C.hole_diameter,w=Qh(C),S=m5,D=C.hole_diameter/2,x=uy({Manifold:t,width:d,height:f,thickness:i-2*S-2*gI.copper+.1,borderRadius:w});n.push(x);const F=uy({Manifold:t,width:d,height:f,thickness:S,borderRadius:w}).translate([0,0,i/2/2+gI.copper]),k=uy({Manifold:t,width:d,height:f,thickness:S,borderRadius:w}).translate([0,0,-i/2/2-gI.copper]);n.push(F,k);const v=t.cylinder(i*1.02,D,D,wC,!0).translate([E,h,0]);n.push(v);const _=t.union([x,F,k,v]);n.push(_);const L=t.cylinder(i*1.2,Math.max(D-Vn,.01),Math.max(D-Vn,.01),wC,!0).translate([E,h,0]);n.push(L);const K=_.subtract(L);n.push(K);const J=K.translate([C.x,C.y,0]);n.push(J);let W=J;if(o){const AA=t.intersection([J,o]);n.push(AA),W=AA}g.push(W);const Z=_w(W.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:Z,color:sM})}});let l;return g.length>0&&(l=t.union(g),n.push(l)),{platedHoleBoardDrills:s,platedHoleCopperGeoms:a,platedHoleSubtractOp:l}}var bft=new Ui(...Mn.copper);function xft(t,A,e,i,n,o){const s=[];return mi(A).pcb_smtpad.list().forEach((a,g)=>{const I=m5,c=a.layer==="bottom"?-e/2-gI.copper:e/2+gI.copper;let B=dft({Manifold:t,pad:a,padBaseThickness:I});if(B){i.push(B);const l=B.translate([a.x,a.y,c]);i.push(l);let C=l;if(n&&(C=l.subtract(n),i.push(C)),o){const E=t.intersection([C,o]);i.push(E),C=E}const Q=_w(C.getMesh());s.push({key:`smt_pad-${a.layer||"top"}-${a.pcb_smtpad_id||g}`,geometry:Q,color:bft})}}),{smtPadGeoms:s}}function kft({Manifold:t,x:A,y:e,outerDiameter:i,holeDiameter:n,thickness:o,zOffset:s=.001,segments:r=32}){const a=s,g=s;if(i<n)throw new Error(`Invalid via geometry: outerDiameter (${i}) must be >= holeDiameter (${n})`);const I=Math.min(i/2,n/2+g),c=t.cylinder(o,I,-1,r,!0),B=t.cylinder(a,i/2,-1,r,!0).translate([0,0,o/2]),l=t.cylinder(a,i/2,-1,r,!0).translate([0,0,-o/2]),C=t.union([c,B,l]),Q=o+a*2,E=t.cylinder(Q,n/2,-1,r,!0);return C.subtract(E).translate([A,e,0])}var Gft=new Ui(...Mn.copper);function Fft(t,A,e,i,n){const o=[],s=mi(A).pcb_via.list(),r=[];return s.forEach((a,g)=>{if(typeof a.hole_diameter=="number"){const I=Q9A({Manifold:t,x:a.x,y:a.y,holeDiameter:a.hole_diameter,thickness:e,zOffset:Ey,segments:wC});i.push(I),o.push(I)}if(typeof a.outer_diameter=="number"&&typeof a.hole_diameter=="number"){const I=kft({Manifold:t,x:a.x,y:a.y,outerDiameter:a.outer_diameter,holeDiameter:a.hole_diameter,thickness:e,zOffset:Ey,segments:wC});i.push(I);let c=I;if(n){const l=t.intersection([I,n]);i.push(l),c=l}const B=_w(c.getMesh());r.push({key:`via-${a.pcb_via_id||g}`,geometry:B,color:Gft})}}),{viaBoardDrills:o,viaCopperGeoms:r}}function h9A({ctx:t,points:A,canvasXFromPcb:e,canvasYFromPcb:i}){A.length<3||(t.beginPath(),A.forEach((n,o)=>{const s=e(n[0]),r=i(n[1]);o===0?t.moveTo(s,r):t.lineTo(s,r)}),t.closePath(),t.fill())}function Rft({ctx:t,pour:A,canvasXFromPcb:e,canvasYFromPcb:i}){const n=A.brep_shape;if(!n||!n.outer_ring)return;const o=G5(n.outer_ring,32);if(o.length>=3&&h9A({ctx:t,points:o,canvasXFromPcb:e,canvasYFromPcb:i}),n.inner_rings&&n.inner_rings.length>0){t.globalCompositeOperation="destination-out";for(const s of n.inner_rings){const r=G5(s,32);r.length>=3&&h9A({ctx:t,points:r,canvasXFromPcb:e,canvasYFromPcb:i})}t.globalCompositeOperation="source-over"}}function u9A({layer:t,circuitJson:A,boardData:e,traceTextureResolution:i=hc}){const o=A.filter(E=>E.type==="pcb_copper_pour").filter(E=>E.layer===t);if(o.length===0)return null;const s=AF(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,l=o.filter(E=>E.shape==="rect"||E.shape==="polygon"),C=o.filter(E=>E.shape==="brep");if(l.length>0){const E=new Wnt(I);E.setCameraBounds({minX:s.minX,maxX:s.maxX,minY:s.minY,maxY:s.maxY});const h=l.filter(w=>w.covered_with_solder_mask!==!1),u=l.filter(w=>w.covered_with_solder_mask===!1),d=`rgb(${Mn.fr4TracesWithMaskGreen.map(w=>w*255).join(",")})`,f=`rgb(${Mn.copper.map(w=>w*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 C){const u=E.covered_with_solder_mask!==!1?Mn.fr4TracesWithMaskGreen:Mn.copper,d=`rgb(${u[0]*255}, ${u[1]*255}, ${u[2]*255})`;I.fillStyle=d,Rft({ctx:I,pour:E,canvasXFromPcb:c,canvasYFromPcb:B})}const Q=new w_(r);return Q.generateMipmaps=!0,Q.minFilter=fu,Q.magFilter=jB,Q.anisotropy=16,Q.needsUpdate=!0,Q}function jp(t,A){const{texture:e,yOffset:i,isBottomLayer:n,textureType:o,usePolygonOffset:s=!1,renderOrder:r=0,isFaux:a=!1}=t;if(!e)return null;const g=AF(A),I=new ym(g.width,g.height),c=new pd({map:e,transparent:!0,side:Ll,depthWrite:o==="panel-outlines",polygonOffset:s,polygonOffsetFactor:s?-4:0,polygonOffsetUnits:s?-4:0,opacity:a?w5:1}),B=new Zn(I,c);return B.position.set(g.centerX,g.centerY,i),n&&B.rotation.set(Math.PI,0,0),B.name=`${n?"bottom":"top"}-${o}-texture-plane`,B.renderOrder=r,B}function Nft(t,A,e,i=!1){const n=[];if(!t||!A||e===null)return n;const o=jp({texture:t.topTrace,yOffset:e/2+gI.traces,isBottomLayer:!1,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);o&&n.push(o);const s=jp({texture:t.topTraceWithMask,yOffset:e/2+gI.traces,isBottomLayer:!1,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);s&&n.push(s);const r=jp({texture:t.topSilkscreen,yOffset:e/2+.003,isBottomLayer:!1,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);r&&n.push(r);const a=jp({texture:t.bottomTrace,yOffset:-e/2-gI.traces,isBottomLayer:!0,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);a&&n.push(a);const g=jp({texture:t.bottomTraceWithMask,yOffset:-e/2-gI.traces,isBottomLayer:!0,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);g&&n.push(g);const I=jp({texture:t.bottomSilkscreen,yOffset:-e/2-.003,isBottomLayer:!0,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);I&&n.push(I);const c=jp({texture:t.topSoldermask,yOffset:e/2+.001,isBottomLayer:!1,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);c&&n.push(c);const B=jp({texture:t.bottomSoldermask,yOffset:-e/2-.001,isBottomLayer:!0,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);B&&n.push(B);const l=jp({texture:t.topCopperText,yOffset:e/2+gI.copper,isBottomLayer:!1,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);l&&n.push(l);const C=jp({texture:t.bottomCopperText,yOffset:-e/2-gI.copper,isBottomLayer:!0,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);C&&n.push(C);const Q=jp({texture:t.topCopper,yOffset:e/2+gI.copper,isBottomLayer:!1,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);Q&&n.push(Q);const E=jp({texture:t.bottomCopper,yOffset:-e/2-gI.copper,isBottomLayer:!0,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);E&&n.push(E);const h=jp({texture:t.topPanelOutlines,yOffset:e/2+.004,isBottomLayer:!1,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);h&&n.push(h);const u=jp({texture:t.bottomPanelOutlines,yOffset:-e/2-.004,isBottomLayer:!0,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);return u&&n.push(u),n}var _ft=(t,A)=>{const[e,i]=j.useState(null),[n,o]=j.useState(null),[s,r]=j.useState(null),[a,g]=j.useState(null),[I,c]=j.useState(!0),B=j.useRef([]),l=j.useMemo(()=>{const Q=A.filter(u=>u.type==="pcb_panel"),E=mi(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]),C=j.useMemo(()=>{const Q=mi(A).pcb_board.list();return Q.length>0&&Q[0].pcb_board_id==="faux-board"},[A]);return j.useEffect(()=>{if(!t||!l){i(null),o(null),r(null),c(!1);return}if((l.width===0||!l.width)&&(l.height===0||!l.height)&&(!l.outline||l.outline.length<3)){i({platedHoles:[],smtPads:[],vias:[]}),o({}),r(l.thickness??0),c(!1);return}c(!0),g(null);const Q=t.Manifold,E=t.CrossSection,h=w=>{if(!(!w||typeof w.delete!="function"))try{w.delete()}catch(S){(!(S instanceof Error)||!S.message?.includes("Manifold instance already deleted"))&&console.warn("Failed to delete Manifold instance",S)}};B.current.forEach(h),B.current=[];let u=null;const d={},f={};try{const w=l.thickness||1.6;r(w);const{boardOp:S,outlineCrossSection:D}=hft(Q,E,l,w,B.current);let x=S;const k=w+2*1;let v=null;const _=.01;if(D){let TA=D;if(_>0){const ce=D.offset(_);B.current.push(ce),TA=ce}const te=Q.extrude(TA,k,void 0,void 0,void 0,!0);B.current.push(te),v=te}else{const TA=(l.width||0)+2*_,te=(l.height||0)+2*_,ce=Q.cube([TA,te,k],!0);B.current.push(ce);const mA=ce.translate([l.center.x,l.center.y,0]);B.current.push(mA),v=mA}const L=[];let K=null;const{nonPlatedHoleBoardDrills:J}=Dft(Q,A,w,B.current);L.push(...J);const{platedHoleBoardDrills:W,platedHoleCopperGeoms:Z,platedHoleSubtractOp:AA}=Sft(Q,E,A,w,B.current,v);L.push(...W),d.platedHoles=Z;const{viaBoardDrills:nA,viaCopperGeoms:cA}=Fft(Q,A,w,B.current,v);if(L.push(...nA),d.vias=cA,L.length>0){K=Q.union(L),B.current.push(K);const TA=AA?Q.union([K,AA]):K;B.current.push(TA);const te=x.subtract(TA);if(B.current.push(te),x=te,AA){const ce=AA.subtract(K);B.current.push(ce);const mA=ce.getMesh(),qA=_w(mA);d.platedHoles=[{key:"plated-holes-union",geometry:qA,color:new Ui(Mn.copper[0],Mn.copper[1],Mn.copper[2])}]}}const{cutoutOps:tA}=fft(Q,E,A,w,B.current);if(tA.length>0){const TA=Q.union(tA);B.current.push(TA);const te=x.subtract(TA);B.current.push(te),x=te}if(u=x,u){const TA=u.getMesh(),te=_w(TA),ce=$lA[l.material]??Mn.fr4Tan;d.board={geometry:te,color:new Ui(ce[0],ce[1],ce[2]),material:l.material,isFaux:C}}const{smtPadGeoms:oA}=xft(Q,A,w,B.current,K,v);d.smtPads=oA,i(d);const rA=Mn.fr4TracesWithoutMaskTan,CA=`rgb(${Math.round(rA[0]*255)}, ${Math.round(rA[1]*255)}, ${Math.round(rA[2]*255)})`;f.topTrace=oM({layer:"top",circuitJson:A,boardData:l,traceColor:CA,traceTextureResolution:hc}),f.bottomTrace=oM({layer:"bottom",circuitJson:A,boardData:l,traceColor:CA,traceTextureResolution:hc});const dA=Mn.fr4TracesWithMaskGreen,bA=`rgb(${Math.round(dA[0]*255)}, ${Math.round(dA[1]*255)}, ${Math.round(dA[2]*255)})`;f.topTraceWithMask=oM({layer:"top",circuitJson:A,boardData:l,traceColor:bA,traceTextureResolution:hc}),f.bottomTraceWithMask=oM({layer:"bottom",circuitJson:A,boardData:l,traceColor:bA,traceTextureResolution:hc});const kA="rgb(255,255,255)";f.topSilkscreen=N5({layer:"top",circuitJson:A,boardData:l,silkscreenColor:kA,traceTextureResolution:hc}),f.bottomSilkscreen=N5({layer:"bottom",circuitJson:A,boardData:l,silkscreenColor:kA,traceTextureResolution:hc});const JA=VVA[l.material]??Mn.fr4SolderMaskGreen,gA=`rgb(${Math.round(JA[0]*255)}, ${Math.round(JA[1]*255)}, ${Math.round(JA[2]*255)})`;f.topSoldermask=F5({layer:"top",circuitJson:A,boardData:l,soldermaskColor:gA,traceTextureResolution:hc}),f.bottomSoldermask=F5({layer:"bottom",circuitJson:A,boardData:l,soldermaskColor:gA,traceTextureResolution:hc});const yA=Mn.copper,EA=`rgb(${Math.round(yA[0]*255)}, ${Math.round(yA[1]*255)}, ${Math.round(yA[2]*255)})`;f.topCopperText=M5({layer:"top",circuitJson:A,boardData:l,copperColor:EA,traceTextureResolution:hc}),f.bottomCopperText=M5({layer:"bottom",circuitJson:A,boardData:l,copperColor:EA,traceTextureResolution:hc}),f.topPanelOutlines=v5({layer:"top",circuitJson:A,panelData:l,traceTextureResolution:hc}),f.bottomPanelOutlines=v5({layer:"bottom",circuitJson:A,panelData:l,traceTextureResolution:hc}),f.topCopper=u9A({layer:"top",circuitJson:A,boardData:l,traceTextureResolution:hc}),f.bottomCopper=u9A({layer:"bottom",circuitJson:A,boardData:l,traceTextureResolution:hc}),o(f)}catch(w){console.error("Error processing geometry with Manifold in hook:",w),g(w.message||"An unknown error occurred while processing geometry in hook."),i(null),o(null)}finally{c(!1)}return()=>{B.current.forEach(h),B.current=[]}},[t,A,l]),{geoms:e,textures:n,pcbThickness:s,error:a,isLoading:I,boardData:l,isFauxBoard:C}},Mft=Ll,vft=({material:t,color:A,side:e=Mft,isFaux:i=!1})=>t==="fr4"?new mm({color:A,side:e,metalness:0,roughness:.8,specularIntensity:.2,ior:1.45,sheen:0,clearcoat:0,transparent:i,opacity:i?w5:1,flatShading:!0}):new Ih({color:A,side:e,flatShading:!0,metalness:.1,roughness:.8,transparent:!0,opacity:i?w5:.9});function Uft(t){const A=[];if(!t)return A;if(t.board&&t.board.geometry){const i=new Zn(t.board.geometry,vft({material:t.board.material,color:t.board.color,side:Ll,isFaux:t.board.isFaux}));i.name="board-geom",A.push(i)}const e=i=>{i&&i.forEach(n=>{const o=new Zn(n.geometry,new Ih({color:n.color,side:Ll,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}));o.name=n.key,A.push(o)})};return e(t.platedHoles),e(t.smtPads),e(t.vias),A}var Lft=({geometryMeshes:t,textureMeshes:A})=>{const{rootObject:e}=wu(),{visibility:i}=iM();return j.useEffect(()=>{if(e)return t.forEach(n=>{let o=!0;n.name==="board-geom"?o=i.boardBody:n.name.includes("smt_pad")?n.name.includes("smt_pad-top")?o=i.topCopper:n.name.includes("smt_pad-bottom")?o=i.bottomCopper:o=i.topCopper||i.bottomCopper:(n.name.includes("plated_hole")||n.name.includes("via"))&&(o=i.topCopper||i.bottomCopper),o&&e.add(n)}),A.forEach(n=>{let o=!0;n.name.includes("top-trace-texture-plane")&&!n.name.includes("with-mask")?o=i.topCopper&&!i.topMask:n.name.includes("top-trace-with-mask")?o=i.topCopper&&i.topMask:n.name.includes("bottom-trace-texture-plane")&&!n.name.includes("with-mask")?o=i.bottomCopper&&!i.bottomMask:n.name.includes("bottom-trace-with-mask")?o=i.bottomCopper&&i.bottomMask:n.name.includes("top-silkscreen")?o=i.topSilkscreen:n.name.includes("bottom-silkscreen")?o=i.bottomSilkscreen:n.name.includes("top-soldermask")?o=i.topMask:n.name.includes("bottom-soldermask")?o=i.bottomMask:n.name.includes("top-copper-text")?o=i.topCopper:n.name.includes("bottom-copper-text")?o=i.bottomCopper:n.name.includes("top-copper")?o=i.topCopper:n.name.includes("bottom-copper")?o=i.bottomCopper:n.name.includes("panel-outlines")&&(o=i.boardBody),o&&e.add(n)}),()=>{t.forEach(n=>{n.parent===e&&e.remove(n)}),A.forEach(n=>{n.parent===e&&e.remove(n)})}},[e,t,A,i]),null},Hft="https://cdn.jsdelivr.net/npm/manifold-3d@3.2.1",Yft=({circuitJson:t,autoRotateDisabled:A,clickToInteractEnabled:e,onUserInteraction:i,children:n,onCameraControllerReady:o})=>{const s=ZVA(n),r=j.useMemo(()=>l9A(t??s),[t,s]),[a,g]=j.useState(null),[I,c]=j.useState(null);j.useEffect(()=>{if(window.ManifoldModule&&typeof window.ManifoldModule=="object"&&window.ManifoldModule.setup){g(window.ManifoldModule);return}const F=async J=>{try{const W=await J();W.setup(),window.ManifoldModule=W,g(W)}catch(W){console.error("Failed to initialize Manifold:",W),c(`Failed to initialize Manifold: ${W instanceof Error?W.message:"Unknown error"}`)}},k=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(k){window.ManifoldModule=k,F(window.ManifoldModule);return}const v="manifoldLoaded",_=()=>{const J=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(J)window.ManifoldModule=J,F(window.ManifoldModule);else{const W="ManifoldModule not found on window after script load.";console.error(W),c(W)}};window.addEventListener(v,_,{once:!0});const L=document.createElement("script");L.type="module",L.innerHTML=`
5105
+ at `+s}return A},R5.buildMessage=function(t,A){var e={literal:function(g){return'"'+n(g.text)+'"'},class:function(g){var I=g.parts.map(function(c){return Array.isArray(c)?o(c[0])+"-"+o(c[1]):o(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 n(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 o(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?'"'+n(g)+'"':"end of input"}return"Expected "+r(t)+" but "+a(A)+" found."};var g9A=25.4,tft=g9A/1e3,ift=/^\s*(-?\d*(?:\.\d+)?)(?:\s*(mm|mil|inch|in|"))?\s*$/i;function nft(t){if(!t)return;const A=t.trim().toLowerCase();return A==='"'||A==="inch"?"in":A}function hQ(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(ift);if(!e){const r=Number.parseFloat(A);return Number.isFinite(r)?r:void 0}const[,i,n]=e,o=Number.parseFloat(i||"0");if(!Number.isFinite(o))return;switch(nft(n)){case"mil":return o*tft;case"in":return o*g9A;case"mm":case void 0:return o;default:return o}}function Sm(t,A){const e=hQ(t);return e===void 0?A:e}function I9A(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),n=parseInt(A.slice(4,6),16);return`rgb(${e}, ${i}, ${n})`}return t.startsWith("rgb")?t:"rgb(255, 243, 204)"}function N5({layer:t,circuitJson:A,boardData:e,silkscreenColor:i="rgb(255,255,255)",traceTextureResolution:n}){const o=mi(A).pcb_silkscreen_text.list(),s=mi(A).pcb_silkscreen_path.list(),r=mi(A).pcb_silkscreen_line.list(),a=mi(A).pcb_silkscreen_rect.list(),g=mi(A).pcb_silkscreen_circle.list(),I=mi(A).pcb_fabrication_note_rect.list(),c=mi(A).pcb_note_line.list(),B=o.filter(v=>v.layer===t),l=s.filter(v=>v.layer===t),C=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&&l.length===0&&C.length===0&&Q.length===0&&E.length===0&&h.length===0&&u.length===0)return null;const d=AF(e),f=document.createElement("canvas"),w=Math.floor(d.width*n),S=Math.floor(d.height*n);f.width=w,f.height=S;const D=f.getContext("2d");if(!D)return null;t==="bottom"&&(D.translate(0,S),D.scale(1,-1)),D.strokeStyle=i,D.fillStyle=i;const x=v=>(v-d.minX)*n,F=v=>(d.maxY-v)*n;C.forEach(v=>{const _=hQ(v.x1)??0,L=hQ(v.y1)??0,K=hQ(v.x2)??0,J=hQ(v.y2)??0;_===K&&L===J||(D.beginPath(),D.lineWidth=Sm(v.stroke_width,.1)*n,D.lineCap="round",D.moveTo(x(_),F(L)),D.lineTo(x(K),F(J)),D.stroke())}),u.forEach(v=>{const _=hQ(v.x1)??0,L=hQ(v.y1)??0,K=hQ(v.x2)??0,J=hQ(v.y2)??0;if(_===K&&L===J)return;D.save();let W=i;v.color?W=I9A(v.color):W="rgb(255, 243, 204)",D.strokeStyle=W,D.beginPath(),D.lineWidth=Sm(v.stroke_width,.1)*n,D.lineCap="round";const Z=v.is_dashed??!1;if(Z){const AA=Math.max(D.lineWidth*2,1);D.setLineDash([AA,AA])}D.moveTo(x(_),F(L)),D.lineTo(x(K),F(J)),D.stroke(),Z&&D.setLineDash([]),D.restore()}),l.forEach(v=>{v.route.length<2||(D.beginPath(),D.lineWidth=Sm(v.stroke_width,.1)*n,D.lineCap="round",D.lineJoin="round",v.route.forEach((_,L)=>{const K=x(hQ(_.x)??0),J=F(hQ(_.y)??0);L===0?D.moveTo(K,J):D.lineTo(K,J)}),D.stroke())}),E.forEach(v=>{const _=Sm(v.radius,0);if(_<=0)return;const L=Sm(v.stroke_width,.12),K=L>0,J=hQ(v.center?.x)??0,W=hQ(v.center?.y)??0,Z=x(J),AA=F(W),nA=_*n;if(D.save(),D.translate(Z,AA),K){const cA=nA+L/2*n,tA=Math.max(0,nA-L/2*n);tA>0?(D.beginPath(),D.arc(0,0,cA,0,2*Math.PI),D.arc(0,0,tA,0,2*Math.PI,!0),D.fill("evenodd")):(D.beginPath(),D.arc(0,0,cA,0,2*Math.PI),D.fill())}else D.beginPath(),D.arc(0,0,nA,0,2*Math.PI),D.fill();D.restore()}),Q.forEach(v=>{const _=Sm(v.width,0),L=Sm(v.height,0);if(_<=0||L<=0)return;const K=hQ(v.center?.x)??0,J=hQ(v.center?.y)??0,W=x(K),Z=F(J),AA=Qh(v),nA=typeof AA=="string"?hQ(AA):AA,cA=hy(_,L,nA);D.save(),D.translate(W,Z);const tA=_/2*n,oA=L/2*n,rA=Math.min(cA*n,tA,oA),CA=v.stroke_width??!1,dA=v.is_filled??!0,bA=v.is_stroke_dashed??!1,kA=CA?Sm(v.stroke_width,.1)*n:0;if(((gA,yA,EA,TA,te)=>{if(D.beginPath(),te<=0)D.rect(gA,yA,EA,TA);else{const ce=te,mA=gA+EA,qA=yA+TA;D.moveTo(gA+ce,yA),D.lineTo(mA-ce,yA),D.quadraticCurveTo(mA,yA,mA,yA+ce),D.lineTo(mA,qA-ce),D.quadraticCurveTo(mA,qA,mA-ce,qA),D.lineTo(gA+ce,qA),D.quadraticCurveTo(gA,qA,gA,qA-ce),D.lineTo(gA,yA+ce),D.quadraticCurveTo(gA,yA,gA+ce,yA),D.closePath()}})(-tA,-oA,tA*2,oA*2,rA),dA&&D.fill(),CA&&kA>0){if(D.lineWidth=kA,bA){const gA=Math.max(kA*2,1);D.setLineDash([gA,gA])}D.stroke(),bA&&D.setLineDash([])}D.restore()}),h.forEach(v=>{const _=Sm(v.width,0),L=Sm(v.height,0);if(_<=0||L<=0)return;const K=hQ(v.center?.x)??0,J=hQ(v.center?.y)??0,W=x(K),Z=F(J),AA=Qh(v),nA=typeof AA=="string"?hQ(AA):AA,cA=hy(_,L,nA);D.save(),D.translate(W,Z);const tA=_/2*n,oA=L/2*n,rA=Math.min(cA*n,tA,oA),CA=v.has_stroke??!1,dA=v.is_filled??!0,bA=v.is_stroke_dashed??!1,kA=CA?Sm(v.stroke_width,.1)*n:0;let JA=i,gA=i;if(v.color){const EA=I9A(v.color);JA=EA,gA=EA}else JA="rgb(255, 243, 204)",gA="rgb(255, 243, 204)";if(((EA,TA,te,ce,mA)=>{if(D.beginPath(),mA<=0)D.rect(EA,TA,te,ce);else{const qA=mA,LA=EA+te,HA=TA+ce;D.moveTo(EA+qA,TA),D.lineTo(LA-qA,TA),D.quadraticCurveTo(LA,TA,LA,TA+qA),D.lineTo(LA,HA-qA),D.quadraticCurveTo(LA,HA,LA-qA,HA),D.lineTo(EA+qA,HA),D.quadraticCurveTo(EA,HA,EA,HA-qA),D.lineTo(EA,TA+qA),D.quadraticCurveTo(EA,TA,EA+qA,TA),D.closePath()}})(-tA,-oA,tA*2,oA*2,rA),dA&&(D.fillStyle=JA,D.fill()),CA&&kA>0){if(D.strokeStyle=gA,D.lineWidth=kA,bA){const EA=Math.max(kA*2,1);D.setLineDash([EA,EA])}D.stroke(),bA&&D.setLineDash([])}D.restore()}),B.forEach(v=>{const _=v.font_size||.25,L=Math.min(Math.max(.01,_*.1),_*.05)*n;D.lineWidth=L,D.lineCap="butt",D.lineJoin="miter";const K=(0,Xpt.vectorText)({height:_*.45,input:v.text}),J=[];K.forEach(bA=>{bA.length===29?(J.push(bA.slice(0,15)),J.push(bA.slice(14,29))):bA.length===17?(J.push(bA.slice(0,10)),J.push(bA.slice(9,17))):J.push(bA)});const W=J.flat(),Z={minX:W.length>0?Math.min(...W.map(bA=>bA[0])):0,maxX:W.length>0?Math.max(...W.map(bA=>bA[0])):0,minY:W.length>0?Math.min(...W.map(bA=>bA[1])):0,maxY:W.length>0?Math.max(...W.map(bA=>bA[1])):0},AA=(Z.minX+Z.maxX)/2,nA=(Z.minY+Z.maxY)/2;let cA=-AA,tA=-nA;const oA=v.anchor_alignment||"center";oA.includes("left")?cA=-Z.minX:oA.includes("right")&&(cA=-Z.maxX),oA.includes("top")?tA=-Z.maxY:oA.includes("bottom")&&(tA=-Z.minY);const rA=[];let CA=v.ccw_rotation??0;if(v.layer==="bottom"&&(rA.push(kx(AA,nA),{a:-1,b:0,c:0,d:1,e:0,f:0},kx(-AA,-nA)),CA=-CA),CA){const bA=CA*Math.PI/180;rA.push(kx(AA,nA),a9A(bA),kx(-AA,-nA))}const dA=rA.length>0?r9A(...rA):void 0;J.forEach(bA=>{D.beginPath(),bA.forEach((kA,JA)=>{let gA={x:kA[0],y:kA[1]};dA&&(gA=o9A(dA,gA));const yA=gA.x+cA+v.anchor_position.x,EA=gA.y+tA+v.anchor_position.y,TA=x(yA),te=F(EA);JA===0?D.moveTo(TA,te):D.lineTo(TA,te)}),D.stroke()})});const k=new w_(f);return k.generateMipmaps=!0,k.minFilter=fu,k.magFilter=jB,k.anisotropy=16,k.needsUpdate=!0,k}function c9A(t){return t&&t.route_type==="wire"&&typeof t.layer=="string"&&typeof t.width=="number"}function oM({layer:t,circuitJson:A,boardData:e,traceColor:i,traceTextureResolution:n}){const o=mi(A).pcb_trace.list(),s=mi(A).pcb_via.list(),r=mi(A).pcb_plated_hole.list(),a=o.filter(Q=>Q.route.some(E=>c9A(E)&&E.layer===t));if(a.length===0)return null;const g=AF(e),I=document.createElement("canvas"),c=Math.floor(g.width*n),B=Math.floor(g.height*n);I.width=c,I.height=B;const l=I.getContext("2d");if(!l)return null;t==="bottom"&&(l.translate(0,B),l.scale(1,-1)),a.forEach(Q=>{let E=!0;l.beginPath(),l.strokeStyle=i,l.lineCap="round",l.lineJoin="round";let h=0;for(const u of Q.route){if(!c9A(u)||u.layer!==t){E||l.stroke(),E=!0;continue}const d=u.x,f=u.y;h=u.width*n,l.lineWidth=h;const w=(d-g.minX)*n,S=(g.maxY-f)*n;E?(l.moveTo(w,S),E=!1):l.lineTo(w,S)}E||l.stroke()}),l.globalCompositeOperation="destination-out",l.fillStyle="black",s.forEach(Q=>{const E=(Q.x-g.minX)*n,h=(g.maxY-Q.y)*n,u=Q.outer_diameter/2*n;l.beginPath(),l.arc(E,h,u,0,2*Math.PI,!1),l.fill()}),r.forEach(Q=>{if(Q.layers.includes(t)&&Q.shape==="circle"){const E=(Q.x-g.minX)*n,h=(g.maxY-Q.y)*n,u=Q.outer_diameter/2*n;l.beginPath(),l.arc(E,h,u,0,2*Math.PI,!1),l.fill()}}),l.globalCompositeOperation="source-over";const C=new w_(I);return C.generateMipmaps=!0,C.minFilter=fu,C.magFilter=jB,C.anisotropy=16,C.needsUpdate=!0,C}var oft=yr(glA());function _5(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 sft(t){return t.layer==="bottom"?t.is_mirrored!==!1:t.is_mirrored===!0}function rft(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])),n=Math.min(...A.map(s=>s[1])),o=Math.max(...A.map(s=>s[1]));return{minX:e,maxX:i,minY:n,maxY:o,width:i-e,height:o-n,centerX:(e+i)/2,centerY:(n+o)/2}}function aft(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 gft(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 Ift(t,A){const e=[];let i=t.ccw_rotation??0;if(sft(t)&&(e.push(kx(A.centerX,A.centerY),{a:-1,b:0,c:0,d:1,e:0,f:0},kx(-A.centerX,-A.centerY)),i=-i),i){const s=i*Math.PI/180;e.push(kx(A.centerX,A.centerY),a9A(s),kx(-A.centerX,-A.centerY))}return{matrix:e.length>0?r9A(...e):void 0,rotationDeg:i}}function B9A(t,A,e,i,n,o,s){A.forEach(r=>{t.beginPath(),r.forEach((a,g)=>{let I={x:a[0],y:a[1]};e&&(I=o9A(e,I));const c=I.x+i.x+n.x,B=I.y+i.y+n.y,l=o(c),C=s(B);g===0?t.moveTo(l,C):t.lineTo(l,C)}),t.stroke()})}function cft(t,A,e,i,n,o){t.save(),t.translate(A,e),t.rotate(-o),t.fillRect(-i/2,-n/2,i,n),t.restore()}function Bft(t,A,e,i,n,o,s,r,a,g){const I=typeof A.font_size=="number"?A.font_size:.2,c={left:_5(A.knockout_padding?.left,I*.5),right:_5(A.knockout_padding?.right,I*.5),top:_5(A.knockout_padding?.top,I*.3),bottom:_5(A.knockout_padding?.bottom,I*.3)},B=i.width+c.left+c.right,l=i.height+c.top+c.bottom,C=s(A.anchor_position.x),Q=r(A.anchor_position.y),E=B*a,h=l*a;t.fillStyle=g;const u=o*Math.PI/180;cft(t,C,Q,E,h,u);const d={x:-i.centerX,y:-i.centerY};t.globalCompositeOperation="destination-out",B9A(t,e,n,d,A.anchor_position,s,r),t.globalCompositeOperation="source-over"}function M5({layer:t,circuitJson:A,boardData:e,copperColor:i="rgb(230, 153, 51)",traceTextureResolution:n}){const s=A.filter(Q=>Q.type==="pcb_copper_text").filter(Q=>Q.layer===t);if(s.length===0)return null;const r=AF(e),a=document.createElement("canvas"),g=Math.floor(r.width*n),I=Math.floor(r.height*n);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)*n,l=Q=>(r.maxY-Q)*n;s.forEach(Q=>{const E=typeof Q.font_size=="number"?Q.font_size:.2,h=Math.max(.02,E*.08)*n;c.lineWidth=h,c.lineCap="round",c.lineJoin="round";const u=(0,oft.vectorText)({height:E*.45,input:Q.text}),d=aft(u),f=rft(d),{matrix:w,rotationDeg:S}=Ift(Q,f);if(Q.is_knockout)Bft(c,Q,d,f,w,S,B,l,n,i);else{const D=Q.anchor_alignment||"center",x=gft(f,D);B9A(c,d,w,x,Q.anchor_position,B,l)}});const C=new w_(a);return C.generateMipmaps=!0,C.minFilter=fu,C.magFilter=jB,C.anisotropy=16,C.needsUpdate=!0,C}function v5({layer:t,circuitJson:A,panelData:e,outlineColor:i="black",traceTextureResolution:n}){const o=mi(A).pcb_board.list().filter(l=>l.pcb_panel_id===e.pcb_board_id);if(o.length===0)return null;const s=document.createElement("canvas"),r=Math.floor(e.width*n),a=Math.floor(e.height*n);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*n;const I=l=>(l-e.center.x+e.width/2)*n,c=l=>(-(l-e.center.y)+e.height/2)*n;o.forEach(l=>{if(l.outline&&l.outline.length>=2)g.beginPath(),l.outline.forEach((C,Q)=>{const E=I(C.x),h=c(C.y);Q===0?g.moveTo(E,h):g.lineTo(E,h)}),g.closePath(),g.stroke();else{const C=l.width,Q=l.height,{x:E,y:h}=l.center,u=I(E-C/2),d=c(h+Q/2);g.strokeRect(u,d,C*n,Q*n)}});const B=new w_(s);return B.generateMipmaps=!0,B.minFilter=fu,B.magFilter=jB,B.anisotropy=16,B.needsUpdate=!0,B}function lft({circuitJson:t,pcbThickness:A,isFaux:e=!1}){const{rootObject:i}=wu(),{visibility:n}=iM(),o=j.useMemo(()=>{const r=t.filter(I=>I.type==="pcb_panel"),a=mi(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=j.useMemo(()=>{if(!o||!o.width||!o.height)return null;const r=VVA[o.material]??Mn.fr4SolderMaskGreen,a=`rgb(${Math.round(r[0]*255)}, ${Math.round(r[1]*255)}, ${Math.round(r[2]*255)})`,g="rgb(255,255,255)",I=Mn.fr4TracesWithMaskGreen,c=`rgb(${Math.round(I[0]*255)}, ${Math.round(I[1]*255)}, ${Math.round(I[2]*255)})`;return{topSoldermask:F5({layer:"top",circuitJson:t,boardData:o,soldermaskColor:a,traceTextureResolution:hc}),bottomSoldermask:F5({layer:"bottom",circuitJson:t,boardData:o,soldermaskColor:a,traceTextureResolution:hc}),topSilkscreen:N5({layer:"top",circuitJson:t,boardData:o,silkscreenColor:g,traceTextureResolution:hc}),bottomSilkscreen:N5({layer:"bottom",circuitJson:t,boardData:o,silkscreenColor:g,traceTextureResolution:hc}),topTraceWithMask:oM({layer:"top",circuitJson:t,boardData:o,traceColor:c,traceTextureResolution:hc}),bottomTraceWithMask:oM({layer:"bottom",circuitJson:t,boardData:o,traceColor:c,traceTextureResolution:hc}),topCopperText:M5({layer:"top",circuitJson:t,boardData:o,copperColor:`rgb(${Math.round(Mn.copper[0]*255)}, ${Math.round(Mn.copper[1]*255)}, ${Math.round(Mn.copper[2]*255)})`,traceTextureResolution:hc}),bottomCopperText:M5({layer:"bottom",circuitJson:t,boardData:o,copperColor:`rgb(${Math.round(Mn.copper[0]*255)}, ${Math.round(Mn.copper[1]*255)}, ${Math.round(Mn.copper[2]*255)})`,traceTextureResolution:hc}),topPanelOutlines:v5({layer:"top",circuitJson:t,panelData:o,traceTextureResolution:hc}),bottomPanelOutlines:v5({layer:"bottom",circuitJson:t,panelData:o,traceTextureResolution:hc})}},[t,o]);return j.useEffect(()=>{if(!i||!o||!s)return;const r=[],a=(I,c,B,l,C=!1,Q=!1)=>{if(!I)return null;const E=AF(o),h=new ym(E.width,E.height),u=new pd({map:I,transparent:!0,side:Ll,depthWrite:Q,polygonOffset:C,polygonOffsetFactor:C?-1:0,polygonOffsetUnits:C?-1:0,opacity:e?w5:1}),d=new Zn(h,u);return d.position.set(E.centerX,E.centerY,c),B&&d.rotation.set(Math.PI,0,0),d.name=l,d},g=.001;if(n.topMask){const I=a(s.topSoldermask,A/2+g,!1,"jscad-top-soldermask",!0);I&&(r.push(I),i.add(I))}if(n.bottomMask){const I=a(s.bottomSoldermask,-A/2-g,!0,"jscad-bottom-soldermask",!0);I&&(r.push(I),i.add(I))}if(n.topCopper&&n.topMask){const I=a(s.topTraceWithMask,A/2+gI.traces+.004,!1,"jscad-top-trace-with-mask");I&&(r.push(I),i.add(I))}if(n.bottomCopper&&n.bottomMask){const I=a(s.bottomTraceWithMask,-A/2-gI.traces-.005,!0,"jscad-bottom-trace-with-mask");I&&(r.push(I),i.add(I))}if(n.topSilkscreen){const I=a(s.topSilkscreen,A/2+g+.002,!1,"jscad-top-silkscreen");I&&(r.push(I),i.add(I))}if(n.bottomSilkscreen){const I=a(s.bottomSilkscreen,-A/2-g-.002,!0,"jscad-bottom-silkscreen");I&&(r.push(I),i.add(I))}if(n.topCopper){const I=a(s.topCopperText,A/2+gI.copper,!1,"jscad-top-copper-text");I&&(r.push(I),i.add(I))}if(n.bottomCopper){const I=a(s.bottomCopperText,-A/2-gI.copper,!0,"jscad-bottom-copper-text");I&&(r.push(I),i.add(I))}if(n.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 Op&&I.material.dispose()})}},[i,o,s,A,n]),null}function Cft(t){const A=mi(t).cad_component.list(),e=mi(t).pcb_smtpad.list(),i=mi(t).pcb_hole.list(),n=mi(t).pcb_plated_hole.list(),o=mi(t).pcb_via.list();if(A.length===0&&e.length===0&&i.length===0&&n.length===0&&o.length===0)return null;const s=[...i,...n,...o,...e],r=M1(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,l=Math.max(Math.abs(a),Math.abs(g))+B,C=Math.max(Math.abs(I),Math.abs(c))+B,Q=Math.max(2*l,10),E=Math.max(2*C,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 l9A(t){if(mi(t).pcb_board.list().length>0)return t;const e=Cft(t);if(!e)return t;const n=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+n}}}}return s}),e]}var Qft=j.forwardRef(({soup:t,circuitJson:A,children:e,autoRotateDisabled:i,clickToInteractEnabled:n,onUserInteraction:o,onCameraControllerReady:s},r)=>{const a=ZVA(e),g=j.useMemo(()=>l9A(t??A??a),[t,A,a]),I=Ppt(g),c=j.useMemo(()=>{if(!g)return[5,-5,5];try{const u=mi(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 w=5,S=Math.max(d,w),D=Math.max(f,w),x=Math.max(S,D);return[x*.4,-x*.7,x*.9]}catch(u){return console.error(u),[5,-5,5]}},[g]),B=j.useMemo(()=>{if(!g)return!1;try{const u=mi(g).pcb_board.list()[0];return!!u&&u.pcb_board_id==="faux-board"}catch{return!1}},[g]),l=j.useMemo(()=>{if(g)try{const u=mi(g).pcb_board.list()[0];return u?{width:u.width??0,height:u.height??0}:void 0}catch(u){console.error(u);return}},[g]),C=j.useMemo(()=>{if(g)try{const u=mi(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=Opt(g),{stls:E}=ypt(I),h=mi(g).cad_component.list();return O.jsxs(WVA,{ref:r,autoRotateDisabled:i,initialCameraPosition:c,clickToInteractEnabled:n,boardDimensions:l,boardCenter:C,onUserInteraction:o,onCameraControllerReady:s,children:[E.map(({stlData:u,color:d,layerType:f},w)=>O.jsx(jpt,{stlData:u,color:d,opacity:w===0?B?.8:.95:1,layerType:f},`board-${w}`)),O.jsx(lft,{circuitJson:g,pcbThickness:Q,isFaux:B}),h.map(u=>O.jsx(n9A,{fallback:({error:d})=>O.jsx(i9A,{cad_component:u,error:d}),children:O.jsx(TVA,{cad_component:u,circuitJson:g},u.cad_component_id)},u.cad_component_id))]})}),Eft=t=>{let A=0;for(let i=0;i<t.length;i++){const n=(i+1)%t.length;t[i]&&t[n]&&(A+=t[i][0]*t[n][1],A-=t[n][0]*t[i][1])}return A/2<=0};function hft(t,A,e,i,n){let o,s=null;if(e.outline&&e.outline.length>=3){let r=e.outline.map(g=>[g.x,g.y]);Eft(r)&&(r=r.reverse());const a=A.ofPolygons([r]);n.push(a),s=a,o=t.extrude(a,i,void 0,void 0,void 0,!0),n.push(o)}else e.outline&&e.outline.length>0&&console.warn("Board outline has fewer than 3 points, falling back to rectangular board."),o=t.cube([e.width,e.height,i],!0),n.push(o),o=o.translate([e.center.x,e.center.y,0]),n.push(o);return{boardOp:o,outlineCrossSection:s}}var uft=64;function uy({Manifold:t,width:A,height:e,thickness:i,borderRadius:n}){const o=hy(A,e,n);if(o<=0)return t.cube([A,e,i],!0);const s=[],r=A-2*o,a=e-2*o;return r>0&&s.push(t.cube([r,e,i],!0)),a>0&&s.push(t.cube([A,a,i],!0)),[[A/2-o,e/2-o],[-A/2+o,e/2-o],[-A/2+o,-e/2+o],[A/2-o,-e/2+o]].forEach(([I,c])=>{s.push(t.cylinder(i,o,o,uft,!0).translate([I,c,0]))}),t.union(s)}function dft({Manifold:t,pad:A,padBaseThickness:e}){if(A.shape==="rect"){const i=Qh(A);return uy({Manifold:t,width:A.width,height:A.height,thickness:e,borderRadius:i})}else if(A.shape==="rotated_rect"){const i=Qh(A);let n=uy({Manifold:t,width:A.width,height:A.height,thickness:e,borderRadius:i});const o=A.ccw_rotation??0;return o&&(n=n.rotate([0,0,o])),n}else if(A.shape==="circle"&&A.radius)return t.cylinder(e,A.radius,-1,32,!0);return null}var pft=t=>{let A=0;for(let i=0;i<t.length;i++){const n=(i+1)%t.length;t[i]&&t[n]&&(A+=t[i][0]*t[n][1],A-=t[n][0]*t[i][1])}return A/2<=0};function fft(t,A,e,i,n){const o=[],s=mi(e).pcb_cutout.list();for(const r of s){let a;const g=i*1.5;switch(r.shape){case"rect":{const B=Qh(r);if(typeof B=="number"&&B>0?a=uy({Manifold:t,width:r.width,height:r.height,thickness:g,borderRadius:B}):a=t.cube([r.width,r.height,g],!0),n.push(a),r.rotation){const l=a.rotate([0,0,r.rotation]);n.push(l),a=l}a=a.translate([r.center.x,r.center.y,0]),n.push(a);break}case"circle":a=t.cylinder(g,r.radius,-1,wC,!0),n.push(a),a=a.translate([r.center.x,r.center.y,0]),n.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]);pft(I)&&(I=I.reverse());const c=A.ofPolygons([I]);n.push(c),a=t.extrude(c,g,0,0,[1,1],!0),n.push(a);break;default:console.warn(`Unsupported cutout shape: ${r.shape} for cutout ${r.pcb_cutout_id}`);continue}a&&o.push(a)}return{cutoutOps:o}}function C9A({Manifold:t,x:A,y:e,diameter:i,thickness:n,segments:o=32}){return t.cylinder(n*1.2,i/2,i/2,o,!0).translate([A,e,0])}function Q9A({Manifold:t,x:A,y:e,holeDiameter:i,thickness:n,zOffset:o=.001,segments:s=32}){const r=i/2+o;return t.cylinder(n*1.2,r,r,s,!0).translate([A,e,0])}function yft(t){return t.hole_shape==="circle"&&typeof t.hole_diameter=="number"}function mft(t){return(t.shape==="pill"||t.hole_shape==="pill")&&typeof t.hole_width=="number"&&typeof t.hole_height=="number"}function wft(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 Dft(t,A,e,i){const n=[],o=mi(A).pcb_hole.list(),s=(r,a,g)=>{const I=uy({Manifold:t,width:r,height:a,thickness:g,borderRadius:Math.min(r,a)/2});return i.push(I),I};return o.forEach(r=>{if(yft(r)){const a=C9A({Manifold:t,x:r.x,y:r.y,diameter:r.hole_diameter,thickness:e,segments:wC});i.push(a),n.push(a)}else if(mft(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),n.push(B)}else if(wft(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 l=c.translate([r.x,r.y,0]);i.push(l),n.push(l)}}),{nonPlatedHoleBoardDrills:n}}function _w(t){const A=new dg;if(A.setAttribute("position",new Lo(t.vertProperties,3)),A.setIndex(new yiA(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],n=t.runIndex[e+1]-i;A.addGroup(i,n,0)}else A.addGroup(0,t.triVerts.length,0);return A}var QL=t=>{let A=0;for(let i=0;i<t.length;i++){const n=(i+1)%t.length;t[i]&&t[n]&&(A+=t[i][0]*t[n][1],A-=t[n][0]*t[i][1])}return A/2<=0},U5=(t,A,e)=>{const i=[];for(let n=0;n<e;n++){const o=2*Math.PI*n/e;i.push([t/2*Math.cos(o),A/2*Math.sin(o)])}return i},sM=new Ui(...Mn.copper),E9A=.05;function Sft(t,A,e,i,n,o){const s=[],r=mi(e).pcb_plated_hole.list(),a=[],g=[],I=(C,Q,E)=>{const h=uy({Manifold:t,width:C,height:Q,thickness:E,borderRadius:Math.min(C,Q)/2});return n.push(h),h},c=({padOutline:C,thickness:Q})=>{if(!Array.isArray(C)||C.length<3)return null;let E=C.map(d=>[d.x,d.y]);QL(E)&&(E=E.reverse());const h=A.ofPolygons([E]);n.push(h);const u=t.extrude(h,Q,0,0,[1,1],!0);return n.push(u),u},B=({ph:C,depth:Q,sizeDelta:E=0})=>{if(C.shape!=="hole_with_polygon_pad")return null;const u=C.pad_outline;if(!Array.isArray(u)||u.length<3)return null;const d=C.hole_shape||"circle",f=C.hole_offset_x||0,w=C.hole_offset_y||0;let S=null;if(d==="circle"){const D=Math.max((C.hole_diameter??0)+E,Vn),x=Math.max(D/2,Vn/2);S=t.cylinder(Q,x,x,wC,!0),n.push(S)}else{const D=C.hole_width??C.hole_diameter,x=C.hole_height??C.hole_diameter;if(!D||!x)return null;const F=Math.max(D+E,Vn),k=Math.max(x+E,Vn);if(d==="oval"){let v=U5(F,k,wC);QL(v)&&(v=v.reverse());const _=A.ofPolygons([v]);n.push(_),S=t.extrude(_,Q,0,0,[1,1],!0),n.push(S)}else(d==="pill"||d==="rotated_pill")&&(S=uy({Manifold:t,width:F,height:k,thickness:Q,borderRadius:Math.min(F,k)/2}),n.push(S))}if(!S)return null;if(f||w){const D=S.translate([f,w,0]);n.push(D),S=D}return S};r.forEach((C,Q)=>{if(C.shape==="circle"){const E=Q9A({Manifold:t,x:C.x,y:C.y,holeDiameter:C.hole_diameter*1.02,thickness:i,zOffset:Ey,segments:wC});n.push(E),s.push(E);const h=i+2*Ey,u=t.cylinder(h,C.outer_diameter/2,C.outer_diameter/2,wC,!0);n.push(u);const d=t.cylinder(h*1.05,C.hole_diameter/2,C.hole_diameter/2,wC,!0);n.push(d);const f=u.subtract(d);n.push(f);const w=f.translate([C.x,C.y,0]);n.push(w);let S=w;if(o){const x=t.intersection([w,o]);n.push(x),S=x}g.push(S);const D=_w(S.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:D,color:sM})}else if(C.shape==="pill"){const E=C.hole_width,h=C.hole_height,u=.4,d=C.outer_width??E+u,f=C.outer_height??h+u,w=E+2*Ey,S=h+2*Ey,D=i*1.2;let x=I(w,S,D);if(C.ccw_rotation){const Z=x.rotate([0,0,C.ccw_rotation]);n.push(Z),x=Z}const F=x.translate([C.x,C.y,0]);n.push(F),s.push(F);const k=i+2*Ey,v=I(d,f,k),_=I(E,h,k*1.05);let L=v.subtract(_);if(n.push(L),C.ccw_rotation){const Z=L.rotate([0,0,C.ccw_rotation]);n.push(Z),L=Z}const K=L.translate([C.x,C.y,0]);n.push(K);let J=K;if(o){const Z=t.intersection([K,o]);n.push(Z),J=Z}g.push(J);const W=_w(J.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:W,color:sM})}else if(C.shape==="pill_hole_with_rect_pad"){const E=C.hole_width,h=C.hole_height,u=C.hole_offset_x||0,d=C.hole_offset_y||0,f=C.rect_pad_width,w=C.rect_pad_height,S=Qh(C),D=m5,x=E+2*Ey,F=h+2*Ey,k=i*1.2,_=I(x,F,k).translate([u,d,0]).translate([C.x,C.y,0]);n.push(_),s.push(_);const L=uy({Manifold:t,width:f,height:w,thickness:i-2*D-2*gI.copper+.1,borderRadius:S});n.push(L);const K=uy({Manifold:t,width:f,height:w,thickness:D,borderRadius:S}).translate([0,0,i/2/2+gI.copper]),J=uy({Manifold:t,width:f,height:w,thickness:D,borderRadius:S}).translate([0,0,-i/2/2-gI.copper]);n.push(K,J);const W=I(E,h,i*1.02).translate([u,d,0]);n.push(W);const Z=t.union([L,K,J,W]);n.push(Z);const AA=I(Math.max(E-2*E9A,.01),Math.max(h-2*E9A,.01),i*1.2).translate([u,d,0]);n.push(AA);const nA=Z.subtract(AA);n.push(nA);const cA=nA.translate([C.x,C.y,0]);n.push(cA);let tA=cA;if(o){const rA=t.intersection([cA,o]);n.push(rA),tA=rA}g.push(tA);const oA=_w(tA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:oA,color:sM})}else if(C.shape==="hole_with_polygon_pad"){const E=C.pad_outline;if(!Array.isArray(E)||E.length<3)return;const h=B({ph:C,depth:i*1.2,sizeDelta:2*Vn});if(!h)return;const u=h.translate([C.x,C.y,0]);n.push(u),s.push(u);const d=m5,f=Math.max(i-2*d-2*gI.copper+.1,Vn),w=c({padOutline:E,thickness:f}),S=c({padOutline:E,thickness:d}),D=c({padOutline:E,thickness:d});if(!w||!S||!D)return;const x=S.translate([0,0,i/2/2+gI.copper]),F=D.translate([0,0,-i/2/2-gI.copper]);n.push(x,F);const k=B({ph:C,depth:i*1.02});if(!k)return;const v=B({ph:C,depth:i*1.2,sizeDelta:-2*Vn})||k,_=t.union([w,x,F,k]);n.push(_);const L=_.subtract(v);n.push(L);const K=L.translate([C.x,C.y,0]);n.push(K);let J=K;if(o){const Z=t.intersection([K,o]);n.push(Z),J=Z}g.push(J);const W=_w(J.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:W,color:sM})}else if(C.shape==="oval"){const E=C.hole_width,h=C.hole_height,u=C.outer_width??E+.4,d=C.outer_height??h+.4,f=E+2*Ey,w=h+2*Ey,S=i*1.2;let D=U5(f,w,wC);QL(D)&&(D=D.reverse());const x=A.ofPolygons([D]);n.push(x);let F=t.extrude(x,S,0,0,[1,1],!0);if(n.push(F),C.ccw_rotation){const oA=F.rotate([0,0,C.ccw_rotation]);n.push(oA),F=oA}const k=F.translate([C.x,C.y,0]);n.push(k),s.push(k);const v=i+2*Ey;let _=U5(u,d,wC);QL(_)&&(_=_.reverse());const L=A.ofPolygons([_]);n.push(L);let K=t.extrude(L,v,0,0,[1,1],!0);n.push(K);let J=U5(E,h,wC);QL(J)&&(J=J.reverse());const W=A.ofPolygons([J]);n.push(W);let Z=t.extrude(W,v*1.05,0,0,[1,1],!0);n.push(Z);let AA=K.subtract(Z);if(n.push(AA),C.ccw_rotation){const oA=AA.rotate([0,0,C.ccw_rotation]);n.push(oA),AA=oA}const nA=AA.translate([C.x,C.y,0]);n.push(nA);let cA=nA;if(o){const oA=t.intersection([nA,o]);n.push(oA),cA=oA}g.push(cA);const tA=_w(cA.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:tA,color:sM})}else if(C.shape==="circular_hole_with_rect_pad"){const E=C.hole_offset_x||0,h=C.hole_offset_y||0,u=C9A({Manifold:t,x:C.x+E,y:C.y+h,diameter:C.hole_diameter,thickness:i,segments:wC});n.push(u),s.push(u);const d=C.rect_pad_width??C.hole_diameter,f=C.rect_pad_height??C.hole_diameter,w=Qh(C),S=m5,D=C.hole_diameter/2,x=uy({Manifold:t,width:d,height:f,thickness:i-2*S-2*gI.copper+.1,borderRadius:w});n.push(x);const F=uy({Manifold:t,width:d,height:f,thickness:S,borderRadius:w}).translate([0,0,i/2/2+gI.copper]),k=uy({Manifold:t,width:d,height:f,thickness:S,borderRadius:w}).translate([0,0,-i/2/2-gI.copper]);n.push(F,k);const v=t.cylinder(i*1.02,D,D,wC,!0).translate([E,h,0]);n.push(v);const _=t.union([x,F,k,v]);n.push(_);const L=t.cylinder(i*1.2,Math.max(D-Vn,.01),Math.max(D-Vn,.01),wC,!0).translate([E,h,0]);n.push(L);const K=_.subtract(L);n.push(K);const J=K.translate([C.x,C.y,0]);n.push(J);let W=J;if(o){const AA=t.intersection([J,o]);n.push(AA),W=AA}g.push(W);const Z=_w(W.getMesh());a.push({key:`ph-${C.pcb_plated_hole_id||Q}`,geometry:Z,color:sM})}});let l;return g.length>0&&(l=t.union(g),n.push(l)),{platedHoleBoardDrills:s,platedHoleCopperGeoms:a,platedHoleSubtractOp:l}}var bft=new Ui(...Mn.copper);function xft(t,A,e,i,n,o){const s=[];return mi(A).pcb_smtpad.list().forEach((a,g)=>{const I=m5,c=a.layer==="bottom"?-e/2-gI.copper:e/2+gI.copper;let B=dft({Manifold:t,pad:a,padBaseThickness:I});if(B){i.push(B);const l=B.translate([a.x,a.y,c]);i.push(l);let C=l;if(n&&(C=l.subtract(n),i.push(C)),o){const E=t.intersection([C,o]);i.push(E),C=E}const Q=_w(C.getMesh());s.push({key:`smt_pad-${a.layer||"top"}-${a.pcb_smtpad_id||g}`,geometry:Q,color:bft})}}),{smtPadGeoms:s}}function kft({Manifold:t,x:A,y:e,outerDiameter:i,holeDiameter:n,thickness:o,zOffset:s=.001,segments:r=32}){const a=s,g=s;if(i<n)throw new Error(`Invalid via geometry: outerDiameter (${i}) must be >= holeDiameter (${n})`);const I=Math.min(i/2,n/2+g),c=t.cylinder(o,I,-1,r,!0),B=t.cylinder(a,i/2,-1,r,!0).translate([0,0,o/2]),l=t.cylinder(a,i/2,-1,r,!0).translate([0,0,-o/2]),C=t.union([c,B,l]),Q=o+a*2,E=t.cylinder(Q,n/2,-1,r,!0);return C.subtract(E).translate([A,e,0])}var Gft=new Ui(...Mn.copper);function Fft(t,A,e,i,n){const o=[],s=mi(A).pcb_via.list(),r=[];return s.forEach((a,g)=>{if(typeof a.hole_diameter=="number"){const I=Q9A({Manifold:t,x:a.x,y:a.y,holeDiameter:a.hole_diameter,thickness:e,zOffset:Ey,segments:wC});i.push(I),o.push(I)}if(typeof a.outer_diameter=="number"&&typeof a.hole_diameter=="number"){const I=kft({Manifold:t,x:a.x,y:a.y,outerDiameter:a.outer_diameter,holeDiameter:a.hole_diameter,thickness:e,zOffset:Ey,segments:wC});i.push(I);let c=I;if(n){const l=t.intersection([I,n]);i.push(l),c=l}const B=_w(c.getMesh());r.push({key:`via-${a.pcb_via_id||g}`,geometry:B,color:Gft})}}),{viaBoardDrills:o,viaCopperGeoms:r}}function h9A({ctx:t,points:A,canvasXFromPcb:e,canvasYFromPcb:i}){A.length<3||(t.beginPath(),A.forEach((n,o)=>{const s=e(n[0]),r=i(n[1]);o===0?t.moveTo(s,r):t.lineTo(s,r)}),t.closePath(),t.fill())}function Rft({ctx:t,pour:A,canvasXFromPcb:e,canvasYFromPcb:i}){const n=A.brep_shape;if(!n||!n.outer_ring)return;const o=G5(n.outer_ring,32);if(o.length>=3&&h9A({ctx:t,points:o,canvasXFromPcb:e,canvasYFromPcb:i}),n.inner_rings&&n.inner_rings.length>0){t.globalCompositeOperation="destination-out";for(const s of n.inner_rings){const r=G5(s,32);r.length>=3&&h9A({ctx:t,points:r,canvasXFromPcb:e,canvasYFromPcb:i})}t.globalCompositeOperation="source-over"}}function u9A({layer:t,circuitJson:A,boardData:e,traceTextureResolution:i=hc}){const o=A.filter(E=>E.type==="pcb_copper_pour").filter(E=>E.layer===t);if(o.length===0)return null;const s=AF(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,l=o.filter(E=>E.shape==="rect"||E.shape==="polygon"),C=o.filter(E=>E.shape==="brep");if(l.length>0){const E=new Wnt(I);E.setCameraBounds({minX:s.minX,maxX:s.maxX,minY:s.minY,maxY:s.maxY});const h=l.filter(w=>w.covered_with_solder_mask!==!1),u=l.filter(w=>w.covered_with_solder_mask===!1),d=`rgb(${Mn.fr4TracesWithMaskGreen.map(w=>w*255).join(",")})`,f=`rgb(${Mn.copper.map(w=>w*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 C){const u=E.covered_with_solder_mask!==!1?Mn.fr4TracesWithMaskGreen:Mn.copper,d=`rgb(${u[0]*255}, ${u[1]*255}, ${u[2]*255})`;I.fillStyle=d,Rft({ctx:I,pour:E,canvasXFromPcb:c,canvasYFromPcb:B})}const Q=new w_(r);return Q.generateMipmaps=!0,Q.minFilter=fu,Q.magFilter=jB,Q.anisotropy=16,Q.needsUpdate=!0,Q}function jp(t,A){const{texture:e,yOffset:i,isBottomLayer:n,textureType:o,usePolygonOffset:s=!1,renderOrder:r=0,isFaux:a=!1}=t;if(!e)return null;const g=AF(A),I=new ym(g.width,g.height),c=new pd({map:e,transparent:!0,side:Ll,depthWrite:o==="panel-outlines",polygonOffset:s,polygonOffsetFactor:s?-4:0,polygonOffsetUnits:s?-4:0,opacity:a?w5:1}),B=new Zn(I,c);return B.position.set(g.centerX,g.centerY,i),n&&B.rotation.set(Math.PI,0,0),B.name=`${n?"bottom":"top"}-${o}-texture-plane`,B.renderOrder=r,B}function Nft(t,A,e,i=!1){const n=[];if(!t||!A||e===null)return n;const o=jp({texture:t.topTrace,yOffset:e/2+gI.traces,isBottomLayer:!1,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);o&&n.push(o);const s=jp({texture:t.topTraceWithMask,yOffset:e/2+gI.traces,isBottomLayer:!1,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);s&&n.push(s);const r=jp({texture:t.topSilkscreen,yOffset:e/2+.003,isBottomLayer:!1,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);r&&n.push(r);const a=jp({texture:t.bottomTrace,yOffset:-e/2-gI.traces,isBottomLayer:!0,textureType:"trace",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);a&&n.push(a);const g=jp({texture:t.bottomTraceWithMask,yOffset:-e/2-gI.traces,isBottomLayer:!0,textureType:"trace-with-mask",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);g&&n.push(g);const I=jp({texture:t.bottomSilkscreen,yOffset:-e/2-.003,isBottomLayer:!0,textureType:"silkscreen",usePolygonOffset:!1,renderOrder:3,isFaux:i},A);I&&n.push(I);const c=jp({texture:t.topSoldermask,yOffset:e/2+.001,isBottomLayer:!1,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);c&&n.push(c);const B=jp({texture:t.bottomSoldermask,yOffset:-e/2-.001,isBottomLayer:!0,textureType:"soldermask",usePolygonOffset:!0,renderOrder:1,isFaux:i},A);B&&n.push(B);const l=jp({texture:t.topCopperText,yOffset:e/2+gI.copper,isBottomLayer:!1,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);l&&n.push(l);const C=jp({texture:t.bottomCopperText,yOffset:-e/2-gI.copper,isBottomLayer:!0,textureType:"copper-text",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);C&&n.push(C);const Q=jp({texture:t.topCopper,yOffset:e/2+gI.copper,isBottomLayer:!1,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);Q&&n.push(Q);const E=jp({texture:t.bottomCopper,yOffset:-e/2-gI.copper,isBottomLayer:!0,textureType:"copper",usePolygonOffset:!1,renderOrder:2,isFaux:i},A);E&&n.push(E);const h=jp({texture:t.topPanelOutlines,yOffset:e/2+.004,isBottomLayer:!1,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);h&&n.push(h);const u=jp({texture:t.bottomPanelOutlines,yOffset:-e/2-.004,isBottomLayer:!0,textureType:"panel-outlines",usePolygonOffset:!1,renderOrder:4,isFaux:i},A);return u&&n.push(u),n}var _ft=(t,A)=>{const[e,i]=j.useState(null),[n,o]=j.useState(null),[s,r]=j.useState(null),[a,g]=j.useState(null),[I,c]=j.useState(!0),B=j.useRef([]),l=j.useMemo(()=>{const Q=A.filter(u=>u.type==="pcb_panel"),E=mi(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]),C=j.useMemo(()=>{const Q=mi(A).pcb_board.list();return Q.length>0&&Q[0].pcb_board_id==="faux-board"},[A]);return j.useEffect(()=>{if(!t||!l){i(null),o(null),r(null),c(!1);return}if((l.width===0||!l.width)&&(l.height===0||!l.height)&&(!l.outline||l.outline.length<3)){i({platedHoles:[],smtPads:[],vias:[]}),o({}),r(l.thickness??0),c(!1);return}c(!0),g(null);const Q=t.Manifold,E=t.CrossSection,h=w=>{if(!(!w||typeof w.delete!="function"))try{w.delete()}catch(S){(!(S instanceof Error)||!S.message?.includes("Manifold instance already deleted"))&&console.warn("Failed to delete Manifold instance",S)}};B.current.forEach(h),B.current=[];let u=null;const d={},f={};try{const w=l.thickness||1.6;r(w);const{boardOp:S,outlineCrossSection:D}=hft(Q,E,l,w,B.current);let x=S;const k=w+2*1;let v=null;const _=.01;if(D){let TA=D;if(_>0){const ce=D.offset(_);B.current.push(ce),TA=ce}const te=Q.extrude(TA,k,void 0,void 0,void 0,!0);B.current.push(te),v=te}else{const TA=(l.width||0)+2*_,te=(l.height||0)+2*_,ce=Q.cube([TA,te,k],!0);B.current.push(ce);const mA=ce.translate([l.center.x,l.center.y,0]);B.current.push(mA),v=mA}const L=[];let K=null;const{nonPlatedHoleBoardDrills:J}=Dft(Q,A,w,B.current);L.push(...J);const{platedHoleBoardDrills:W,platedHoleCopperGeoms:Z,platedHoleSubtractOp:AA}=Sft(Q,E,A,w,B.current,v);L.push(...W),d.platedHoles=Z;const{viaBoardDrills:nA,viaCopperGeoms:cA}=Fft(Q,A,w,B.current,v);if(L.push(...nA),d.vias=cA,L.length>0){K=Q.union(L),B.current.push(K);const TA=AA?Q.union([K,AA]):K;B.current.push(TA);const te=x.subtract(TA);if(B.current.push(te),x=te,AA){const ce=AA.subtract(K);B.current.push(ce);const mA=ce.getMesh(),qA=_w(mA);d.platedHoles=[{key:"plated-holes-union",geometry:qA,color:new Ui(Mn.copper[0],Mn.copper[1],Mn.copper[2])}]}}const{cutoutOps:tA}=fft(Q,E,A,w,B.current);if(tA.length>0){const TA=Q.union(tA);B.current.push(TA);const te=x.subtract(TA);B.current.push(te),x=te}if(u=x,u){const TA=u.getMesh(),te=_w(TA),ce=$lA[l.material]??Mn.fr4Tan;d.board={geometry:te,color:new Ui(ce[0],ce[1],ce[2]),material:l.material,isFaux:C}}const{smtPadGeoms:oA}=xft(Q,A,w,B.current,K,v);d.smtPads=oA,i(d);const rA=Mn.fr4TracesWithoutMaskTan,CA=`rgb(${Math.round(rA[0]*255)}, ${Math.round(rA[1]*255)}, ${Math.round(rA[2]*255)})`;f.topTrace=oM({layer:"top",circuitJson:A,boardData:l,traceColor:CA,traceTextureResolution:hc}),f.bottomTrace=oM({layer:"bottom",circuitJson:A,boardData:l,traceColor:CA,traceTextureResolution:hc});const dA=Mn.fr4TracesWithMaskGreen,bA=`rgb(${Math.round(dA[0]*255)}, ${Math.round(dA[1]*255)}, ${Math.round(dA[2]*255)})`;f.topTraceWithMask=oM({layer:"top",circuitJson:A,boardData:l,traceColor:bA,traceTextureResolution:hc}),f.bottomTraceWithMask=oM({layer:"bottom",circuitJson:A,boardData:l,traceColor:bA,traceTextureResolution:hc});const kA="rgb(255,255,255)";f.topSilkscreen=N5({layer:"top",circuitJson:A,boardData:l,silkscreenColor:kA,traceTextureResolution:hc}),f.bottomSilkscreen=N5({layer:"bottom",circuitJson:A,boardData:l,silkscreenColor:kA,traceTextureResolution:hc});const JA=VVA[l.material]??Mn.fr4SolderMaskGreen,gA=`rgb(${Math.round(JA[0]*255)}, ${Math.round(JA[1]*255)}, ${Math.round(JA[2]*255)})`;f.topSoldermask=F5({layer:"top",circuitJson:A,boardData:l,soldermaskColor:gA,traceTextureResolution:hc}),f.bottomSoldermask=F5({layer:"bottom",circuitJson:A,boardData:l,soldermaskColor:gA,traceTextureResolution:hc});const yA=Mn.copper,EA=`rgb(${Math.round(yA[0]*255)}, ${Math.round(yA[1]*255)}, ${Math.round(yA[2]*255)})`;f.topCopperText=M5({layer:"top",circuitJson:A,boardData:l,copperColor:EA,traceTextureResolution:hc}),f.bottomCopperText=M5({layer:"bottom",circuitJson:A,boardData:l,copperColor:EA,traceTextureResolution:hc}),f.topPanelOutlines=v5({layer:"top",circuitJson:A,panelData:l,traceTextureResolution:hc}),f.bottomPanelOutlines=v5({layer:"bottom",circuitJson:A,panelData:l,traceTextureResolution:hc}),f.topCopper=u9A({layer:"top",circuitJson:A,boardData:l,traceTextureResolution:hc}),f.bottomCopper=u9A({layer:"bottom",circuitJson:A,boardData:l,traceTextureResolution:hc}),o(f)}catch(w){console.error("Error processing geometry with Manifold in hook:",w),g(w.message||"An unknown error occurred while processing geometry in hook."),i(null),o(null)}finally{c(!1)}return()=>{B.current.forEach(h),B.current=[]}},[t,A,l]),{geoms:e,textures:n,pcbThickness:s,error:a,isLoading:I,boardData:l,isFauxBoard:C}},Mft=Ll,vft=({material:t,color:A,side:e=Mft,isFaux:i=!1})=>t==="fr4"?new mm({color:A,side:e,metalness:0,roughness:.8,specularIntensity:.2,ior:1.45,sheen:0,clearcoat:0,transparent:i,opacity:i?w5:1,flatShading:!0}):new Ih({color:A,side:e,flatShading:!0,metalness:.1,roughness:.8,transparent:!0,opacity:i?w5:.9});function Uft(t){const A=[];if(!t)return A;if(t.board&&t.board.geometry){const i=new Zn(t.board.geometry,vft({material:t.board.material,color:t.board.color,side:Ll,isFaux:t.board.isFaux}));i.name="board-geom",A.push(i)}const e=i=>{i&&i.forEach(n=>{const o=new Zn(n.geometry,new Ih({color:n.color,side:Ll,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}));o.name=n.key,A.push(o)})};return e(t.platedHoles),e(t.smtPads),e(t.vias),A}var Lft=({geometryMeshes:t,textureMeshes:A})=>{const{rootObject:e}=wu(),{visibility:i}=iM();return j.useEffect(()=>{if(e)return t.forEach(n=>{let o=!0;n.name==="board-geom"?o=i.boardBody:n.name.includes("smt_pad")?n.name.includes("smt_pad-top")?o=i.topCopper:n.name.includes("smt_pad-bottom")?o=i.bottomCopper:o=i.topCopper||i.bottomCopper:(n.name.includes("plated_hole")||n.name.includes("via"))&&(o=i.topCopper||i.bottomCopper),o&&e.add(n)}),A.forEach(n=>{let o=!0;n.name.includes("top-trace-texture-plane")&&!n.name.includes("with-mask")?o=i.topCopper&&!i.topMask:n.name.includes("top-trace-with-mask")?o=i.topCopper&&i.topMask:n.name.includes("bottom-trace-texture-plane")&&!n.name.includes("with-mask")?o=i.bottomCopper&&!i.bottomMask:n.name.includes("bottom-trace-with-mask")?o=i.bottomCopper&&i.bottomMask:n.name.includes("top-silkscreen")?o=i.topSilkscreen:n.name.includes("bottom-silkscreen")?o=i.bottomSilkscreen:n.name.includes("top-soldermask")?o=i.topMask:n.name.includes("bottom-soldermask")?o=i.bottomMask:n.name.includes("top-copper-text")?o=i.topCopper:n.name.includes("bottom-copper-text")?o=i.bottomCopper:n.name.includes("top-copper")?o=i.topCopper:n.name.includes("bottom-copper")?o=i.bottomCopper:n.name.includes("panel-outlines")&&(o=i.boardBody),o&&e.add(n)}),()=>{t.forEach(n=>{n.parent===e&&e.remove(n)}),A.forEach(n=>{n.parent===e&&e.remove(n)})}},[e,t,A,i]),null},Hft="https://cdn.jsdelivr.net/npm/manifold-3d@3.2.1",Yft=({circuitJson:t,autoRotateDisabled:A,clickToInteractEnabled:e,onUserInteraction:i,children:n,onCameraControllerReady:o})=>{const s=ZVA(n),r=j.useMemo(()=>l9A(t??s),[t,s]),[a,g]=j.useState(null),[I,c]=j.useState(null);j.useEffect(()=>{if(window.ManifoldModule&&typeof window.ManifoldModule=="object"&&window.ManifoldModule.setup){g(window.ManifoldModule);return}const F=async J=>{try{const W=await J();W.setup(),window.ManifoldModule=W,g(W)}catch(W){console.error("Failed to initialize Manifold:",W),c(`Failed to initialize Manifold: ${W instanceof Error?W.message:"Unknown error"}`)}},k=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(k){window.ManifoldModule=k,F(window.ManifoldModule);return}const v="manifoldLoaded",_=()=>{const J=window.ManifoldModule??window.MANIFOLD??window.MANIFOLD_MODULE;if(J)window.ManifoldModule=J,F(window.ManifoldModule);else{const W="ManifoldModule not found on window after script load.";console.error(W),c(W)}};window.addEventListener(v,_,{once:!0});const L=document.createElement("script");L.type="module",L.innerHTML=`
5106
5106
  try {
5107
5107
  const { default: ManifoldModule } = await import('${Hft}/manifold.js');
5108
5108
  window.ManifoldModule = ManifoldModule;
@@ -5602,7 +5602,7 @@ test("${g} should solve problem correctly", () => {
5602
5602
  // Add more specific assertions based on expected output
5603
5603
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5604
5604
  })
5605
- `,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),l=document.createElement("a");l.href=B,l.download=`${g}.test.ts`,l.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return O.jsxs("div",{className:`relative ${A}`,ref:n,children:[O.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&O.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},ate=t=>t.activeSubSolver?[t,...ate(t.activeSubSolver)]:[t],zYt=({solver:t})=>{const A=ate(t);return O.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>O.jsxs("div",{className:"flex items-center",children:[i>0&&O.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),O.jsx(jYt,{solver:e})]},e.constructor.name))})},XYt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=j.useReducer(Q=>!Q,!1),r=j.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},I=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};j.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),j.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const l=t.getCurrentPhase!==void 0,C=l?t.getCurrentPhase():null;return O.jsxs("div",{className:"space-y-2 p-2 border-b",children:[O.jsx("div",{className:"flex items-center",children:O.jsx(zYt,{solver:t})}),O.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[O.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),O.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),O.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),O.jsx("button",{onClick:B,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),l&&O.jsx("button",{onClick:c,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),O.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",O.jsx("span",{className:"font-medium",children:C})]}),t.solved&&O.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&O.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&O.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},$Yt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},AJt=(t,A)=>{const i=t.pipelineDef[A].solverName,n=$Yt(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const B=t.pipelineDef[A+1],l=B?t.firstIterationOfPhase?.[B.solverName]:void 0;l!==void 0&&s!==null?a=l-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;n==="Completed"?I=1:n==="In Progress"&&o&&(I=o.progress??0);const c=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:o??null}},eJt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return O.jsx("span",{className:`font-medium ${A[t]}`,children:t})},tJt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:O.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),O.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},iJt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),nJt=({stats:t})=>{if(!t||Object.keys(t).length===0)return O.jsx("span",{children:"-"});const A=Object.entries(t),e=iJt(t);return O.jsxs("details",{className:"cursor-pointer",children:[O.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),O.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>O.jsxs("div",{children:[i,": ",String(n)]},i))})]})},QhA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(QhA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=QhA(i));return A},oJt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=QhA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},sJt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>AJt(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):oJt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return O.jsxs("div",{className:"border-t border-gray-200",children:[O.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:O.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),O.jsx("div",{className:"overflow-x-auto",children:O.jsxs("table",{className:"w-full text-sm",children:[O.jsx("thead",{children:O.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),O.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",O.jsx("sub",{children:"0"})]}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),O.jsx("tbody",{children:i.map(r=>O.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[O.jsx("td",{className:"px-4 py-2",children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),O.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),O.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(eJt,{status:r.status})}),O.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(tJt,{progress:r.progress})}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),O.jsx("td",{className:"px-4 py-2 text-gray-500",children:O.jsx(nJt,{stats:r.stats})}),O.jsx("td",{className:"px-4 py-2",children:r.solverInstance?O.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),O.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},rJt=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 aJt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of n){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of o)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,l=r-c,C=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return O.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${l} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>O.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>O.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),n.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),o.map((E,h)=>O.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var gJt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=j.useReducer(I=>I+1,0),s=j.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=j.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);j.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();o()}};return O.jsxs("div",{children:[O.jsx(XYt,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?O.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):O.jsx(rJt,{fallback:O.jsx(aJt,{graphics:s}),children:O.jsx(VYt,{graphics:s})}),a&&O.jsx(sJt,{solver:t,onStepUntilPhase:g})]})};const IJt=()=>{j.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)},[])},cJt=t=>t.toLowerCase().includes("pack")?oSt:t.toLowerCase().includes("rout")?ISt:qDt,BJt=({solverEvents:t=[]})=>{const[A,e]=j.useState(null);IJt();const i=j.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=j.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=j.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=ceA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(ceA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.length===0?O.jsx("div",{className:"rf-p-4",children:O.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:O.jsxs("div",{className:"rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),O.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):O.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[O.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[O.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return O.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=cJt(a.solverName);return O.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[O.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),O.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[O.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),O.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),O.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?O.jsx(py,{fallback:O.jsx("div",{className:"rf-p-4",children:O.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),O.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:O.jsx(gJt,{solver:s.instance})}):O.jsxs("div",{className:"rf-p-4",children:[O.jsxs("div",{className:"rf-mb-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),O.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&O.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:O.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),O.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[O.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:O.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),O.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:O.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):O.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:O.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},gte=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{j.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{C3.captureException(i)}catch{}}},[t,A]),j.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{C3.captureException(n,{error_type:i.type})}catch{}}},[e])},Ite="0.0.1467",lJt={version:Ite},$W=TvA()(KvA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),CJt=t=>{const[A,e]=j.useState([]),[i,n]=j.useState(null),[o,s]=j.useState(""),[r,a]=TM("eval-version-selection",null),g=$W(l=>l.setLastRunEvalVersion),I=$W(l=>l.lastRunEvalVersion);return j.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(l=>l.json()).then(l=>{if(Array.isArray(l?.versions)){let C=[...l.versions];l.tags?.latest&&(n(l.tags.latest),C=C.filter(Q=>Q!==l.tags.latest)),e(C)}}).catch(()=>{})},[t]),j.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:j.useMemo(()=>A.filter(l=>l.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:I,search:o,setSearch:s,selectVersion:l=>{a(l),s("")}}},QJt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=j.useState(""),[s,r]=j.useState("");if(!i)return null;const a=t.filter(c=>c.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),I=c=>{c.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return O.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:O.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[O.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),O.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:c=>r(c.target.value),onKeyDown:I}),O.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(c=>O.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===c?"bg-blue-50":""}`,onClick:()=>o(c),children:c},c)),g&&O.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),O.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},EJt=t=>{const A=j.useRef(null),e=Hc(i=>i.recentEvents);j.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function hJt(t){const A=uJt(t),e=j.forwardRef((i,n)=>{const{children:o,...s}=i,r=j.Children.toArray(o),a=r.find(pJt);if(a){const g=a.props.children,I=r.map(c=>c===a?j.Children.count(g)>1?j.Children.only(null):j.isValidElement(g)?g.props.children:null:c);return O.jsx(A,{...s,ref:n,children:j.isValidElement(g)?j.cloneElement(g,void 0,I):null})}return O.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function uJt(t){const A=j.forwardRef((e,i)=>{const{children:n,...o}=e;if(j.isValidElement(n)){const s=yJt(n),r=fJt(o,n.props);return n.type!==j.Fragment&&(r.ref=i?Jp(i,s):s),j.cloneElement(n,r)}return j.Children.count(n)>1?j.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var dJt=Symbol("radix.slottable");function pJt(t){return j.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===dJt}function fJt(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function yJt(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var AZ="Dialog",[cte,Bte]=rm(AZ),[mJt,Nm]=cte(AZ),lte=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=j.useRef(null),a=j.useRef(null),[g,I]=qb({prop:i,defaultProp:n??!1,onChange:o,caller:AZ});return O.jsx(mJt,{scope:A,triggerRef:r,contentRef:a,contentId:oh(),titleId:oh(),descriptionId:oh(),open:g,onOpenChange:I,onOpenToggle:j.useCallback(()=>I(c=>!c),[I]),modal:s,children:e})};lte.displayName=AZ;var Cte="DialogTrigger",Qte=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nm(Cte,e),o=Bc(A,n.triggerRef);return O.jsx(va.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":uhA(n.open),...i,ref:o,onClick:_n(t.onClick,n.onOpenToggle)})});Qte.displayName=Cte;var EhA="DialogPortal",[wJt,Ete]=cte(EhA,{forceMount:void 0}),hte=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Nm(EhA,A);return O.jsx(wJt,{scope:A,forceMount:e,children:j.Children.map(i,s=>O.jsx(Vf,{present:e||o.open,children:O.jsx(D8,{asChild:!0,container:n,children:s})}))})};hte.displayName=EhA;var eZ="DialogOverlay",ute=j.forwardRef((t,A)=>{const e=Ete(eZ,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Nm(eZ,t.__scopeDialog);return o.modal?O.jsx(Vf,{present:i||o.open,children:O.jsx(SJt,{...n,ref:A})}):null});ute.displayName=eZ;var DJt=hJt("DialogOverlay.RemoveScroll"),SJt=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nm(eZ,e);return O.jsx(N8,{as:DJt,allowPinchZoom:!0,shards:[n.contentRef],children:O.jsx(va.div,{"data-state":uhA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),xF="DialogContent",dte=j.forwardRef((t,A)=>{const e=Ete(xF,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Nm(xF,t.__scopeDialog);return O.jsx(Vf,{present:i||o.open,children:o.modal?O.jsx(bJt,{...n,ref:A}):O.jsx(xJt,{...n,ref:A})})});dte.displayName=xF;var bJt=j.forwardRef((t,A)=>{const e=Nm(xF,t.__scopeDialog),i=j.useRef(null),n=Bc(A,e.contentRef,i);return j.useEffect(()=>{const o=i.current;if(o)return EQA(o)},[]),O.jsx(pte,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:_n(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:_n(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:_n(t.onFocusOutside,o=>o.preventDefault())})}),xJt=j.forwardRef((t,A)=>{const e=Nm(xF,t.__scopeDialog),i=j.useRef(!1),n=j.useRef(!1);return O.jsx(pte,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),pte=j.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Nm(xF,e),a=j.useRef(null),g=Bc(A,a);return zCA(),O.jsxs(O.Fragment,{children:[O.jsx(B8,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:O.jsx(FL,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":uhA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),O.jsxs(O.Fragment,{children:[O.jsx(GJt,{titleId:r.titleId}),O.jsx(RJt,{contentRef:a,descriptionId:r.descriptionId})]})]})}),hhA="DialogTitle",fte=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nm(hhA,e);return O.jsx(va.h2,{id:n.titleId,...i,ref:A})});fte.displayName=hhA;var yte="DialogDescription",mte=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nm(yte,e);return O.jsx(va.p,{id:n.descriptionId,...i,ref:A})});mte.displayName=yte;var wte="DialogClose",Dte=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nm(wte,e);return O.jsx(va.button,{type:"button",...i,ref:A,onClick:_n(t.onClick,()=>n.onOpenChange(!1))})});Dte.displayName=wte;function uhA(t){return t?"open":"closed"}var Ste="DialogTitleWarning",[kJt,bte]=o3e(Ste,{contentName:xF,titleName:hhA,docsSlug:"dialog"}),GJt=({titleId:t})=>{const A=bte(Ste),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5605
+ `,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),l=document.createElement("a");l.href=B,l.download=`${g}.test.ts`,l.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return O.jsxs("div",{className:`relative ${A}`,ref:n,children:[O.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&O.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},ate=t=>t.activeSubSolver?[t,...ate(t.activeSubSolver)]:[t],zYt=({solver:t})=>{const A=ate(t);return O.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>O.jsxs("div",{className:"flex items-center",children:[i>0&&O.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),O.jsx(jYt,{solver:e})]},e.constructor.name))})},XYt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=j.useReducer(Q=>!Q,!1),r=j.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),n&&n(t))},I=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&t.solved&&n(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||o)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&n&&n(t)};j.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),j.useEffect(()=>{(t.solved||t.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,o]);const l=t.getCurrentPhase!==void 0,C=l?t.getCurrentPhase():null;return O.jsxs("div",{className:"space-y-2 p-2 border-b",children:[O.jsx("div",{className:"flex items-center",children:O.jsx(zYt,{solver:t})}),O.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[O.jsx("button",{onClick:a,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),O.jsx("button",{onClick:g,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),O.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),O.jsx("button",{onClick:B,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),l&&O.jsx("button",{onClick:c,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),O.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",O.jsx("span",{className:"font-medium",children:C})]}),t.solved&&O.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&O.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&O.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},$Yt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},AJt=(t,A)=>{const i=t.pipelineDef[A].solverName,n=$Yt(t,A),o=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(n==="Completed"){const B=t.pipelineDef[A+1],l=B?t.firstIterationOfPhase?.[B.solverName]:void 0;l!==void 0&&s!==null?a=l-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;n==="Completed"?I=1:n==="In Progress"&&o&&(I=o.progress??0);const c=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:o??null}},eJt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return O.jsx("span",{className:`font-medium ${A[t]}`,children:t})},tJt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:O.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),O.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},iJt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),nJt=({stats:t})=>{if(!t||Object.keys(t).length===0)return O.jsx("span",{children:"-"});const A=Object.entries(t),e=iJt(t);return O.jsxs("details",{className:"cursor-pointer",children:[O.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),O.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>O.jsxs("div",{children:[i,": ",String(n)]},i))})]})},QhA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(QhA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=QhA(i));return A},oJt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=QhA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},sJt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>AJt(t,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):oJt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return O.jsxs("div",{className:"border-t border-gray-200",children:[O.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:O.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),O.jsx("div",{className:"overflow-x-auto",children:O.jsxs("table",{className:"w-full text-sm",children:[O.jsx("thead",{children:O.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),O.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",O.jsx("sub",{children:"0"})]}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),O.jsx("tbody",{children:i.map(r=>O.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[O.jsx("td",{className:"px-4 py-2",children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),O.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),O.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(eJt,{status:r.status})}),O.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(tJt,{progress:r.progress})}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),O.jsx("td",{className:"px-4 py-2 text-gray-500",children:O.jsx(nJt,{stats:r.stats})}),O.jsx("td",{className:"px-4 py-2",children:r.solverInstance?O.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),O.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},rJt=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 aJt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],n=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of n){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of o)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,l=r-c,C=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return O.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${l} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>O.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>O.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),n.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),o.map((E,h)=>O.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var gJt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[n,o]=j.useReducer(I=>I+1,0),s=j.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,n]),r=j.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);j.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();o()}};return O.jsxs("div",{children:[O.jsx(XYt,{solver:t,triggerRender:o,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?O.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):O.jsx(rJt,{fallback:O.jsx(aJt,{graphics:s}),children:O.jsx(VYt,{graphics:s})}),a&&O.jsx(sJt,{solver:t,onStepUntilPhase:g})]})};const IJt=()=>{j.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)},[])},cJt=t=>t.toLowerCase().includes("pack")?oSt:t.toLowerCase().includes("rout")?ISt:qDt,BJt=({solverEvents:t=[]})=>{const[A,e]=j.useState(null);IJt();const i=j.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),n=j.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=j.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=ceA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(ceA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return t.length===0?O.jsx("div",{className:"rf-p-4",children:O.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:O.jsxs("div",{className:"rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),O.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):O.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[O.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[O.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return O.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=cJt(a.solverName);return O.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[O.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),O.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[O.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),O.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),O.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?O.jsx(py,{fallback:O.jsx("div",{className:"rf-p-4",children:O.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),O.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:O.jsx(gJt,{solver:s.instance})}):O.jsxs("div",{className:"rf-p-4",children:[O.jsxs("div",{className:"rf-mb-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),O.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&O.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:O.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),O.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[O.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:O.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),O.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:O.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):O.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:O.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},gte=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{j.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{C3.captureException(i)}catch{}}},[t,A]),j.useEffect(()=>{if(e&&e.length>0)for(const i of e){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{C3.captureException(n,{error_type:i.type})}catch{}}},[e])},Ite="0.0.1468",lJt={version:Ite},$W=TvA()(KvA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),CJt=t=>{const[A,e]=j.useState([]),[i,n]=j.useState(null),[o,s]=j.useState(""),[r,a]=TM("eval-version-selection",null),g=$W(l=>l.setLastRunEvalVersion),I=$W(l=>l.lastRunEvalVersion);return j.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(l=>l.json()).then(l=>{if(Array.isArray(l?.versions)){let C=[...l.versions];l.tags?.latest&&(n(l.tags.latest),C=C.filter(Q=>Q!==l.tags.latest)),e(C)}}).catch(()=>{})},[t]),j.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:j.useMemo(()=>A.filter(l=>l.includes(o)).slice(0,50),[A,o]),latestVersion:i,lastRunEvalVersion:I,search:o,setSearch:s,selectVersion:l=>{a(l),s("")}}},QJt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[n,o]=j.useState(""),[s,r]=j.useState("");if(!i)return null;const a=t.filter(c=>c.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),I=c=>{c.key==="Enter"&&(a.length===1?o(a[0]):g&&o(s))};return O.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:O.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[O.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),O.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:c=>r(c.target.value),onKeyDown:I}),O.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(c=>O.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${n===c?"bg-blue-50":""}`,onClick:()=>o(c),children:c},c)),g&&O.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${n===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),O.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>n&&A(n),disabled:!n,children:n===s?`Create "${n}"`:`Save to ${n}`})]})]})})},EJt=t=>{const A=j.useRef(null),e=Hc(i=>i.recentEvents);j.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function hJt(t){const A=uJt(t),e=j.forwardRef((i,n)=>{const{children:o,...s}=i,r=j.Children.toArray(o),a=r.find(pJt);if(a){const g=a.props.children,I=r.map(c=>c===a?j.Children.count(g)>1?j.Children.only(null):j.isValidElement(g)?g.props.children:null:c);return O.jsx(A,{...s,ref:n,children:j.isValidElement(g)?j.cloneElement(g,void 0,I):null})}return O.jsx(A,{...s,ref:n,children:o})});return e.displayName=`${t}.Slot`,e}function uJt(t){const A=j.forwardRef((e,i)=>{const{children:n,...o}=e;if(j.isValidElement(n)){const s=yJt(n),r=fJt(o,n.props);return n.type!==j.Fragment&&(r.ref=i?Jp(i,s):s),j.cloneElement(n,r)}return j.Children.count(n)>1?j.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var dJt=Symbol("radix.slottable");function pJt(t){return j.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===dJt}function fJt(t,A){const e={...A};for(const i in A){const n=t[i],o=A[i];/^on[A-Z]/.test(i)?n&&o?e[i]=(...r)=>{const a=o(...r);return n(...r),a}:n&&(e[i]=n):i==="style"?e[i]={...n,...o}:i==="className"&&(e[i]=[n,o].filter(Boolean).join(" "))}return{...t,...e}}function yJt(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var AZ="Dialog",[cte,Bte]=rm(AZ),[mJt,Nm]=cte(AZ),lte=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:n,onOpenChange:o,modal:s=!0}=t,r=j.useRef(null),a=j.useRef(null),[g,I]=qb({prop:i,defaultProp:n??!1,onChange:o,caller:AZ});return O.jsx(mJt,{scope:A,triggerRef:r,contentRef:a,contentId:oh(),titleId:oh(),descriptionId:oh(),open:g,onOpenChange:I,onOpenToggle:j.useCallback(()=>I(c=>!c),[I]),modal:s,children:e})};lte.displayName=AZ;var Cte="DialogTrigger",Qte=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nm(Cte,e),o=Bc(A,n.triggerRef);return O.jsx(va.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":uhA(n.open),...i,ref:o,onClick:_n(t.onClick,n.onOpenToggle)})});Qte.displayName=Cte;var EhA="DialogPortal",[wJt,Ete]=cte(EhA,{forceMount:void 0}),hte=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:n}=t,o=Nm(EhA,A);return O.jsx(wJt,{scope:A,forceMount:e,children:j.Children.map(i,s=>O.jsx(Vf,{present:e||o.open,children:O.jsx(D8,{asChild:!0,container:n,children:s})}))})};hte.displayName=EhA;var eZ="DialogOverlay",ute=j.forwardRef((t,A)=>{const e=Ete(eZ,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Nm(eZ,t.__scopeDialog);return o.modal?O.jsx(Vf,{present:i||o.open,children:O.jsx(SJt,{...n,ref:A})}):null});ute.displayName=eZ;var DJt=hJt("DialogOverlay.RemoveScroll"),SJt=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nm(eZ,e);return O.jsx(N8,{as:DJt,allowPinchZoom:!0,shards:[n.contentRef],children:O.jsx(va.div,{"data-state":uhA(n.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),xF="DialogContent",dte=j.forwardRef((t,A)=>{const e=Ete(xF,t.__scopeDialog),{forceMount:i=e.forceMount,...n}=t,o=Nm(xF,t.__scopeDialog);return O.jsx(Vf,{present:i||o.open,children:o.modal?O.jsx(bJt,{...n,ref:A}):O.jsx(xJt,{...n,ref:A})})});dte.displayName=xF;var bJt=j.forwardRef((t,A)=>{const e=Nm(xF,t.__scopeDialog),i=j.useRef(null),n=Bc(A,e.contentRef,i);return j.useEffect(()=>{const o=i.current;if(o)return EQA(o)},[]),O.jsx(pte,{...t,ref:n,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:_n(t.onCloseAutoFocus,o=>{o.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:_n(t.onPointerDownOutside,o=>{const s=o.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&o.preventDefault()}),onFocusOutside:_n(t.onFocusOutside,o=>o.preventDefault())})}),xJt=j.forwardRef((t,A)=>{const e=Nm(xF,t.__scopeDialog),i=j.useRef(!1),n=j.useRef(!1);return O.jsx(pte,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{t.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||e.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:o=>{t.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const s=o.target;e.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),pte=j.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...s}=t,r=Nm(xF,e),a=j.useRef(null),g=Bc(A,a);return zCA(),O.jsxs(O.Fragment,{children:[O.jsx(B8,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:O.jsx(FL,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":uhA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),O.jsxs(O.Fragment,{children:[O.jsx(GJt,{titleId:r.titleId}),O.jsx(RJt,{contentRef:a,descriptionId:r.descriptionId})]})]})}),hhA="DialogTitle",fte=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nm(hhA,e);return O.jsx(va.h2,{id:n.titleId,...i,ref:A})});fte.displayName=hhA;var yte="DialogDescription",mte=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nm(yte,e);return O.jsx(va.p,{id:n.descriptionId,...i,ref:A})});mte.displayName=yte;var wte="DialogClose",Dte=j.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,n=Nm(wte,e);return O.jsx(va.button,{type:"button",...i,ref:A,onClick:_n(t.onClick,()=>n.onOpenChange(!1))})});Dte.displayName=wte;function uhA(t){return t?"open":"closed"}var Ste="DialogTitleWarning",[kJt,bte]=o3e(Ste,{contentName:xF,titleName:hhA,docsSlug:"dialog"}),GJt=({titleId:t})=>{const A=bte(Ste),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5606
5606
 
5607
5607
  If you want to hide the \`${A.titleName}\`, you can wrap it with our VisuallyHidden component.
5608
5608