@tscircuit/runframe 0.0.2433 → 0.0.2434

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.
@@ -5467,7 +5467,7 @@ ${A.join(`
5467
5467
  ${_}polygon: ${h.polygon.vertices}
5468
5468
  `:A+=`
5469
5469
  `,h.children.length>0&&l.push(h.children)}return A}};e.exports=s}}),lSo=At({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,e){var n=sSo(),o=cSo(),i=class{constructor(r){this.polygonTree=new o,this.rootnode=new n(null),r&&this.addPolygons(r)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(r,s=!1){this.rootnode.clipTo(r,s)}allPolygons(){const r=[];return this.polygonTree.getPolygons(r),r}addPolygons(r){const s=new Array(r.length);for(let a=0;a<r.length;a++)s[a]=this.polygonTree.addChild(r[a]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};e.exports=i}}),owe=At({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,e){e.exports={Tree:lSo()}}}),gSo=At({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,e){var n=Hs(),o=nwe(),{Tree:i}=owe(),r=(s,a)=>{if(!o(s,a))return n.create();const A=new i(n.toPolygons(s)),c=new i(n.toPolygons(a));A.invert(),c.clipTo(A),c.invert(),A.clipTo(c),c.clipTo(A),A.addPolygons(c.allPolygons()),A.invert();const l=A.allPolygons();return n.create(l)};e.exports=r}}),Zwt=At({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,e){var n=fs(),o=xU(),i=gSo(),r=(...s)=>{s=n(s);let a=s.shift();return s.forEach(A=>{a=i(a,A)}),a=o(a),a};e.exports=r}}),uSo=At({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,e){var n=fs(),o=Hs(),i=wv(),r=ewe(),s=twe(),a=Zwt(),A=(...c)=>{c=n(c);const l=c.map(d=>s({z0:-1,z1:1},d)),g=a(l),u=i(g);return r(u,o.toPolygons(g))};e.exports=A}}),hSo=At({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,e){var n=fs(),o=EU(),i=Vs(),r=Hs(),s=uSo(),a=Zwt(),A=(...c)=>{if(c=n(c),c.length===0)throw new Error("wrong number of arguments");if(!o(c))throw new Error("only intersect of the types are supported");const l=c[0];return i.isA(l)?s(c):r.isA(l)?a(c):l};e.exports=A}}),iwe=At({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,e){var n=ja(),o=iwt(),i=r=>o(r,{skipTriangulation:!0}).map(A=>{const c=A.map(l=>r[l]);return n.create(c)});e.exports=i}}),e3t=At({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,e){var n=Hs(),o=nwe(),{Tree:i}=owe(),r=(a,A)=>{if(!o(a,A))return s(a,A);const c=new i(n.toPolygons(a)),l=new i(n.toPolygons(A));c.clipTo(l,!1),l.clipTo(c),l.invert(),l.clipTo(c),l.invert();const g=c.allPolygons().concat(l.allPolygons());return n.create(g)},s=(a,A)=>{let c=n.toPolygons(a);return c=c.concat(n.toPolygons(A)),n.create(c)};e.exports=r}}),rwe=At({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,e){var n=fs(),o=xU(),i=e3t(),r=(...s)=>{s=n(s);let a;for(a=1;a<s.length;a+=2)s.push(i(s[a-1],s[a]));let A=s[a-1];return A=o(A),A};e.exports=r}}),t3t=At({"node_modules/@jscad/modeling/src/operations/minkowski/minkowskiSum.js"(t,e){var n=fs(),o=Hs(),i=ja(),r=iwe(),s=rwe(),a=(...d)=>{if(d=n(d),d.length!==2)throw new Error("minkowskiSum requires exactly two geometries");const[h,_]=d;if(!o.isA(h)||!o.isA(_))throw new Error("minkowskiSum requires geom3 geometries");const m=o.isConvex(h),p=o.isConvex(_);if(m&&p)return g(h,_);if(!m&&p)return A(h,_);if(m&&!p)return A(_,h);throw new Error("minkowskiSum of two non-convex geometries is not yet supported")},A=(d,h)=>{const _=c(d);if(_.length===0)return o.create();const m=_.map(p=>g(p,h));return m.length===1?m[0]:s(m)},c=d=>{const h=o.toPolygons(d);if(h.length===0)return[];const _=[];for(let m=0;m<h.length;m++){const p=h[m],I=p.vertices;let f=0,C=0,y=0;for(let w=0;w<I.length;w++)f+=I[w][0],C+=I[w][1],y+=I[w][2];f/=I.length,C/=I.length,y/=I.length;const E=i.plane(p),B=E[0],Q=E[1],b=E[2],D=.1,R=[f-B*D,C-Q*D,y-b*D];for(let w=1;w<I.length-1;w++){const H=I[0],G=I[w],K=I[w+1],U=l(R,H,G,K);_.push(o.create(U))}}return _},l=(d,h,_,m)=>[i.create([d,_,h]),i.create([d,h,m]),i.create([h,_,m]),i.create([_,d,m])],g=(d,h)=>{const _=u(d),m=u(h);if(_.length===0||m.length===0)return o.create();const p=[];for(let f=0;f<_.length;f++){const C=_[f];for(let y=0;y<m.length;y++){const E=m[y];p.push([C[0]+E[0],C[1]+E[1],C[2]+E[2]])}}const I=r(p);return o.create(I)},u=d=>{const h=new Set,_=[],m=o.toPolygons(d);for(let p=0;p<m.length;p++){const I=m[p].vertices;for(let f=0;f<I.length;f++){const C=I[f],y=`${C[0]},${C[1]},${C[2]}`;h.has(y)||(h.add(y),_.push(C))}}return _};e.exports=a}}),dSo=At({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,e){var n=rr(),o=wv(),i=Hs(),r=c=>c.sort((l,g)=>l-g).filter((l,g,u)=>!g||l!==u[g-1]),s=(c,l,g)=>{const u=`${l}`,d=c.get(u);d===void 0?c.set(u,[g]):d.push(g)},a=(c,l)=>{const g=`${l}`;return c.get(g)},A=c=>{const l=o(c),g=i.toPolygons(c),u=g.length,d=new Map,h=n.create();g.forEach((f,C)=>{f.vertices.forEach(y=>{s(d,n.snap(h,y,l),C)})});const _=g.map(f=>{let C=[];return f.vertices.forEach(y=>{C=C.concat(a(d,n.snap(h,y,l)))}),{e:1,d:r(C)}});d.clear();let m=0;const p=_.length;for(let f=0;f<p;f++){const C=_[f];if(C.e>0){const y=new Array(u);y[f]=!0;do m=0,y.forEach((E,B)=>{const Q=_[B];if(Q.e>0){Q.e=-1;for(let b=0;b<Q.d.length;b++)y[Q.d[b]]=!0;m++}});while(m>0);C.indexes=y}}const I=[];for(let f=0;f<p;f++)if(_[f].indexes){const C=[];_[f].indexes.forEach((y,E)=>C.push(g[E])),I.push(i.create(C))}return I};e.exports=A}}),_So=At({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,e){var n=fs(),o=Hs(),i=dSo(),r=(...s)=>{if(s=n(s),s.length===0)throw new Error("wrong number of arguments");const a=s.map(A=>o.isA(A)?i(A):A);return a.length===1?a[0]:a};e.exports=r}}),mSo=At({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,e){var n=Hs(),o=nwe(),{Tree:i}=owe(),r=(s,a)=>{if(!o(s,a))return n.clone(s);const A=new i(n.toPolygons(s)),c=new i(n.toPolygons(a));A.invert(),A.clipTo(c),c.clipTo(A,!0),A.addPolygons(c.allPolygons()),A.invert();const l=A.allPolygons();return n.create(l)};e.exports=r}}),n3t=At({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,e){var n=fs(),o=xU(),i=mSo(),r=(...s)=>{s=n(s);let a=s.shift();return s.forEach(A=>{a=i(a,A)}),a=o(a),a};e.exports=r}}),pSo=At({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,e){var n=fs(),o=Hs(),i=wv(),r=ewe(),s=twe(),a=n3t(),A=(...c)=>{c=n(c);const l=c.map(d=>s({z0:-1,z1:1},d)),g=a(l),u=i(g);return r(u,o.toPolygons(g))};e.exports=A}}),ISo=At({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,e){var n=fs(),o=EU(),i=Vs(),r=Hs(),s=pSo(),a=n3t(),A=(...c)=>{if(c=n(c),c.length===0)throw new Error("wrong number of arguments");if(!o(c))throw new Error("only subtract of the types are supported");const l=c[0];return i.isA(l)?s(c):r.isA(l)?a(c):l};e.exports=A}}),o3t=At({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,e){var n=fs(),o=Hs(),i=wv(),r=ewe(),s=twe(),a=rwe(),A=(...c)=>{c=n(c);const l=c.map(d=>s({z0:-1,z1:1},d)),g=a(l),u=i(g);return r(u,o.toPolygons(g))};e.exports=A}}),swe=At({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,e){var n=fs(),o=EU(),i=Vs(),r=Hs(),s=o3t(),a=rwe(),A=(...c)=>{if(c=n(c),c.length===0)throw new Error("wrong number of arguments");if(!o(c))throw new Error("only unions of the same type are supported");const l=c[0];return i.isA(l)?s(c):r.isA(l)?a(c):l};e.exports=A}}),BU=At({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,e){e.exports={intersect:hSo(),minkowski:t3t(),scission:_So(),subtract:ISo(),union:swe()}}}),yie=At({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,e){var{EPS:n,TAU:o}=gA(),i=wwt(),r=WMe(),s=Ia(),a=Iie(),A=(c,l)=>{const g={delta:1,corners:"edge",closed:!1,segments:16};let{delta:u,corners:d,closed:h,segments:_}=Object.assign({},g,c);if(Math.abs(u)<n)return l;let m=c.closed?a(l):1;m===0&&(m=1);const p=m>0&&u>=0||m<0&&u<0;u=Math.abs(u);let I=null,f=[];const C=[],y=s.create(),E=l.length;for(let B=0;B<E;B++){const Q=(B+1)%E,b=l[B],D=l[Q];p?s.subtract(y,b,D):s.subtract(y,D,b),s.normal(y,y),s.normalize(y,y),s.scale(y,y,u);const R=s.add(s.create(),b,y),w=s.add(s.create(),D,y),H=[R,w];if(I!=null&&(h||!h&&Q!==0)){const G=i(I[0],I[1],H[0],H[1]);G?(f.pop(),H[0]=G):C.push({c:b,s0:I,s1:H})}I=[R,w],!(Q===0&&!h)&&(f.push(H[0]),f.push(H[1]))}if(h&&I!=null){const B=f[0],Q=f[1],b=i(I[0],I[1],B,Q);if(b)f[0]=b,f.pop();else{const D=l[0],R=[B,Q];C.push({c:D,s0:I,s1:R})}}if(d==="edge"){const B=new Map;f.forEach((D,R)=>B.set(D,R));const Q=r.create(),b=r.create();C.forEach(D=>{r.fromPoints(Q,D.s0[0],D.s0[1]),r.fromPoints(b,D.s1[0],D.s1[1]);const R=r.intersectPointOfLines(Q,b);if(Number.isFinite(R[0])&&Number.isFinite(R[1])){const w=D.s0[1],H=B.get(w);f[H]=R,f[(H+1)%f.length]=void 0}else{const w=D.s1[0],H=B.get(w);f[H]=void 0}}),f=f.filter(D=>D!==void 0)}if(d==="round"){let B=Math.floor(_/4);const Q=s.create();C.forEach(b=>{let D=s.angle(s.subtract(Q,b.s1[0],b.c));if(D-=s.angle(s.subtract(Q,b.s0[1],b.c)),p&&D<0&&(D=D+Math.PI,D<0&&(D=D+Math.PI)),!p&&D>0&&(D=D-Math.PI,D>0&&(D=D-Math.PI)),D!==0){B=Math.floor(_*(Math.abs(D)/o));const R=D/B,w=s.angle(s.subtract(Q,b.s0[1],b.c)),H=[];for(let G=1;G<B;G++){const K=w+R*G,U=s.fromAngleRadians(s.create(),K);s.scale(U,U,u),s.add(U,U,b.c),H.push(U)}if(H.length>0){const G=b.s0[1];let K=f.findIndex(U=>s.equals(G,U));K=(K+1)%f.length,f.splice(K,0,...H)}}else{const R=b.s1[0],w=f.findIndex(H=>s.equals(R,H));f.splice(w,1)}})}return f};e.exports=A}}),fSo=At({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,e){var n=Vs(),o=yie(),i=(r,s)=>{const a={delta:1,corners:"edge",segments:16},{delta:A,corners:c,segments:l}=Object.assign({},a,r);if(!(c==="edge"||c==="chamfer"||c==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const d=n.toOutlines(s).map(h=>(r={delta:A,corners:c,closed:!0,segments:l},o(r,h))).reduce((h,_)=>h.concat(n.toSides(n.fromPoints(_))),[]);return n.create(d)};e.exports=i}}),CSo=At({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,e){var n=Ig(),o=rr(),i=Hs(),r=ja(),s=(a,A)=>{o.dot(r.plane(A),a)>0&&(A=r.invert(A));const l=[A],g=r.transform(n.fromTranslation(n.create(),a),A),u=A.vertices.length;for(let d=0;d<u;d++){const h=d<u-1?d+1:0,_=r.create([A.vertices[d],g.vertices[d],g.vertices[h],A.vertices[h]]);l.push(_)}return l.push(r.invert(g)),i.create(l)};e.exports=s}}),ySo=At({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,e){var{EPS:n,TAU:o}=gA(),i=Ig(),r=rr(),s=Xwt(),a=Hs(),A=ja(),c=Ywt(),l=xU(),g=e3t(),u=CSo(),d=(p,I,f)=>{const C=I.toString();if(p.has(C))p.get(C)[1].push(f);else{const y=[I,[f]];p.set(C,y)}},h=(p,I,f)=>{const C=I[0].toString(),y=I[1].toString(),E=C<y?`${C},${y}`:`${y},${C}`;if(p.has(E))p.get(E)[1].push(f);else{const B=[I,[f]];p.set(E,B)}},_=(p,I)=>{p.findIndex(C=>C===I)<0&&p.push(I)},m=(p,I)=>{const f={delta:1,segments:12},{delta:C,segments:y}=Object.assign({},f,p);let E=a.create();const B=new Map,Q=new Map,b=r.create(),D=r.create();return a.toPolygons(I).forEach((w,H)=>{const G=r.scale(r.create(),A.plane(w),2*C),K=A.transform(i.fromTranslation(i.create(),r.scale(r.create(),G,-.5)),w),U=u(G,K);E=g(E,U);const q=w.vertices;for(let W=0;W<q.length;W++){d(B,q[W],A.plane(w));const ee=(W+1)%q.length,re=[q[W],q[ee]];h(Q,re,A.plane(w))}}),Q.forEach(w=>{const H=w[0],G=w[1],K=H[0],U=H[1],q=r.subtract(r.create(),U,K);r.normalize(q,q);const W=G[0],ee=r.cross(r.create(),W,q);let re=[];for(let Be=0;Be<y;Be++)_(re,Be*o/y);for(let Be=0,de=G.length;Be<de;Be++){const Ee=G[Be],pe=r.dot(ee,Ee),we=r.dot(W,Ee);let Ge=Math.atan2(pe,we);Ge<0&&(Ge+=o),_(re,Ge),Ge=Math.atan2(-pe,-we),Ge<0&&(Ge+=o),_(re,Ge)}re=re.sort(s);const X=re.length;let te,se;const le=[],ue=[],Ce=[];for(let Be=-1;Be<X;Be++){const de=re[Be<0?Be+X:Be],Ee=Math.sin(de),pe=Math.cos(de);r.scale(b,W,pe*C),r.scale(D,ee,Ee*C),r.add(b,b,D);const we=r.add(r.create(),K,b),Ge=r.add(r.create(),U,b);let Ve=!1;if(Be>=0&&r.distance(we,te)<n&&(Ve=!0),!Ve){if(Be>=0){le.push(we),ue.push(Ge);const Ie=[se,Ge,we,te],qe=A.create(Ie);Ce.push(qe)}te=we,se=Ge}}ue.reverse(),Ce.push(A.create(le)),Ce.push(A.create(ue));const ye=a.create(Ce);E=g(E,ye)}),B.forEach(w=>{const H=w[0],G=w[1],K=G[0];let U=null,q=0;for(let X=1;X<G.length;X++){const te=G[X],se=r.cross(b,K,te),le=r.length(se);le>.05&&le>q&&(q=le,U=te)}U||(U=r.orthogonal(b,K));const W=r.cross(b,K,U);r.normalize(W,W);const ee=r.cross(D,W,K),re=c({center:[H[0],H[1],H[2]],radius:C,segments:y,axes:[K,W,ee]});E=g(E,re)}),l(E)};e.exports=m}}),ESo=At({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,e){var n=Hs(),o=swe(),i=ySo(),r=(s,a)=>{const A={delta:1,corners:"round",segments:12},{delta:c,corners:l,segments:g}=Object.assign({},A,s);if(l!=="round")throw new Error('corners must be "round" for 3D geometries');if(n.toPolygons(a).length===0)throw new Error("the given geometry cannot be empty");s={delta:c,corners:l,segments:g};const d=i(s,a);return o(a,d)};e.exports=r}}),xSo=At({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,e){var n=Iie(),o=Ia(),i=Vs(),r=Yl(),s=yie(),a=l=>{let{external:g,internal:u}=l;n(g)<0?g=g.reverse():u=u.reverse();const d=r.fromPoints({closed:!0},g),h=r.fromPoints({closed:!0},u),_=i.toSides(i.fromPoints(r.toPoints(d))),m=i.toSides(i.fromPoints(r.toPoints(h)));return _.push(...m),i.create(_)},A=(l,g,u,d)=>{const{points:h,external:_,internal:m}=l,p=Math.floor(g/2),I=[],f=[];if(u==="round"&&p>0){const y=Math.PI/p,E=h[h.length-1],B=o.angle(o.subtract(o.create(),_[_.length-1],E)),Q=h[0],b=o.angle(o.subtract(o.create(),m[0],Q));for(let D=1;D<p;D++){let R=B+y*D,w=o.fromAngleRadians(o.create(),R);o.scale(w,w,d),o.add(w,w,E),I.push(w),R=b+y*D,w=o.fromAngleRadians(o.create(),R),o.scale(w,w,d),o.add(w,w,Q),f.push(w)}}const C=[];return C.push(..._,...I,...m.reverse(),...f),i.fromPoints(C)},c=(l,g)=>{l=Object.assign({},{delta:1,corners:"edge",segments:16},l);const{delta:d,corners:h,segments:_}=l;if(d<=0)throw new Error("the given delta must be positive for paths");if(!(h==="edge"||h==="chamfer"||h==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const m=g.isClosed,p=r.toPoints(g);if(p.length===0)throw new Error("the given geometry cannot be empty");const I={points:p,external:s({delta:d,corners:h,segments:_,closed:m},p),internal:s({delta:-d,corners:h,segments:_,closed:m},p)};return g.isClosed?a(I):A(I,_,h,d)};e.exports=c}}),awe=At({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,e){var n=fs(),o=Vs(),i=Hs(),r=Yl(),s=fSo(),a=ESo(),A=xSo(),c=(l,...g)=>{if(g=n(g),g.length===0)throw new Error("wrong number of arguments");const u=g.map(d=>r.isA(d)?A(l,d):o.isA(d)?s(l,d):i.isA(d)?a(l,d):d);return u.length===1?u[0]:u};e.exports=c}}),BSo=At({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,e){var n=Vs(),o=YMe(),i=yie(),r=(s,a)=>{const A={delta:1,corners:"edge",segments:0},{delta:c,corners:l,segments:g}=Object.assign({},A,s);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const u=n.toOutlines(a),h=u.map(_=>(s={delta:u.reduce((I,f)=>I+o.arePointsInside(_,o.create(f)),0)%2===0?c:-c,corners:l,closed:!0,segments:g},i(s,_))).reduce((_,m)=>_.concat(n.toSides(n.fromPoints(m))),[]);return n.create(h)};e.exports=r}}),QSo=At({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,e){var n=Yl(),o=yie(),i=(r,s)=>{const a={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:A,corners:c,closed:l,segments:g}=Object.assign({},a,r);if(!(c==="edge"||c==="chamfer"||c==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');r={delta:A,corners:c,closed:l,segments:g};const u=o(r,n.toPoints(s));return n.fromPoints({closed:l},u)};e.exports=i}}),SSo=At({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,e){var n=fs(),o=Vs(),i=Yl(),r=BSo(),s=QSo(),a=(A,...c)=>{if(c=n(c),c.length===0)throw new Error("wrong number of arguments");const l=c.map(g=>i.isA(g)?s(A,g):o.isA(g)?r(A,g):g);return l.length===1?l[0]:l};e.exports=a}}),i3t=At({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,e){e.exports={expand:awe(),offset:SSo()}}}),Eie=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,e){var n=Ig(),o=rr(),i=Vs(),r=kT(),s=Cie(),a=(A,c)=>{const l={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:g,twistAngle:u,twistSteps:d,repair:h}=Object.assign({},l,A);if(d<1)throw new Error("twistSteps must be 1 or more");u===0&&(d=1);const _=o.clone(g),m=i.toSides(c);if(m.length===0)throw new Error("the given geometry cannot be empty");const p=r.fromSides(m);_[2]<0&&r.reverse(p,p);const I=n.create(),f=(C,y,E)=>{const B=y/d*u,Q=o.scale(o.create(),_,y/d);return n.multiply(I,n.fromZRotation(I,B),n.fromTranslation(n.create(),Q)),r.transform(I,E)};return A={numberOfSlices:d+1,capStart:!0,capEnd:!0,repair:h,callback:f},s(A,p)};e.exports=a}}),bSo=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,e){var n=Vs(),o=Yl(),i=Eie(),r=(s,a)=>{if(!a.isClosed)throw new Error("extruded path must be closed");const A=o.toPoints(a),c=n.fromPoints(A);return i(s,c)};e.exports=r}}),DSo=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,e){var n=fs(),o=Vs(),i=Yl(),r=Eie(),s=bSo(),a=(A,...c)=>{const l={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:g,twistAngle:u,twistSteps:d,repair:h}=Object.assign({},l,A);if(c=n(c),c.length===0)throw new Error("wrong number of arguments");A={offset:[0,0,g],twistAngle:u,twistSteps:d,repair:h};const _=c.map(m=>i.isA(m)?s(A,m):o.isA(m)?r(A,m):m);return _.length===1?_[0]:_};e.exports=a}}),PSo=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,e){var n=Yl(),o=awe(),i=Eie(),r=(s,a)=>{const A={size:1,height:1},{size:c,height:l}=Object.assign({},A,s);if(s.delta=c,s.offset=[0,0,l],n.toPoints(a).length===0)throw new Error("the given geometry cannot be empty");const u=o(s,a);return i(s,u)};e.exports=r}}),vSo=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,e){var{area:n}=IU(),o=Vs(),i=Yl(),r=awe(),s=Eie(),a=(A,c)=>{const l={size:1,height:1},{size:g,height:u}=Object.assign({},l,A);A.delta=g,A.offset=[0,0,u];const d=o.toOutlines(c);if(d.length===0)throw new Error("the given geometry cannot be empty");const _=d.map(p=>(n(p)<0&&p.reverse(),r(A,i.fromPoints({closed:!0},p)))).reduce((p,I)=>p.concat(o.toSides(I)),[]),m=o.create(_);return s(A,m)};e.exports=a}}),MSo=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,e){var n=fs(),o=Vs(),i=Yl(),r=PSo(),s=vSo(),a=(A,...c)=>{const l={size:1,height:1},{size:g,height:u}=Object.assign({},l,A);if(c=n(c),c.length===0)throw new Error("wrong number of arguments");if(g<=0)throw new Error("size must be positive");if(u<=0)throw new Error("height must be positive");const d=c.map(h=>i.isA(h)?r(A,h):o.isA(h)?s(A,h):h);return d.length===1?d[0]:d};e.exports=a}}),wSo=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,e){var{TAU:n}=gA(),o=Ig(),i=Vs(),r=Cie(),s=kT(),a=(A,c)=>{const l={angle:n,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:g,startAngle:u,pitch:d,height:h,endOffset:_,segmentsPerRotation:m}=Object.assign({},l,A);if(h!=0&&(d=h/(g/n)),m<3)throw new Error("The number of segments per rotation needs to be at least 3.");const I=i.toSides(c);if(I.length===0)throw new Error("The given geometry cannot be empty");const f=I.filter(D=>D[0][0]>=0);let C=s.fromSides(I);f.length===0&&(C=s.reverse(C));const y=Math.round(m/n*Math.abs(g)),E=y>=2?y:2,B=o.create(),Q=o.create(),b=(D,R,w)=>{const H=u+g/E*R,G=_/E*R,K=(H-u)/n*d;return o.multiply(B,o.fromTranslation(o.create(),[G,0,K*Math.sign(g)]),o.fromXRotation(o.create(),-n/4*Math.sign(g))),o.multiply(Q,o.fromZRotation(o.create(),H),B),s.transform(Q,w)};return r({numberOfSlices:E+1,callback:b},C)};e.exports=a}}),NSo=At({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,e){var n=fs(),o=qMe(),i=YS(),r=Ig(),s=Vs(),a=Hs(),A=ja(),c=wv(),l=o3t(),g=(d,h)=>{const _=i.fromNormalAndPoint(i.create(),d.axis,d.origin);if(Number.isNaN(_[0])||Number.isNaN(_[1])||Number.isNaN(_[2])||Number.isNaN(_[3]))throw new Error("project: invalid axis or origin");const m=c(h),p=m*m*Math.sqrt(3)/4;if(m===0)return s.create();const I=a.toPolygons(h);let f=[];for(let y=0;y<I.length;y++){const E=I[y].vertices.map(b=>i.projectionOfPoint(_,b)),B=A.create(E),Q=A.plane(B);o(_,Q)&&(A.measureArea(B)<p||f.push(B))}if(!o(_,[0,0,1])){const y=r.fromVectorRotation(r.create(),_,[0,0,1]);f=f.map(E=>A.transform(y,E))}f=f.sort((y,E)=>A.measureArea(E)-A.measureArea(y));const C=f.map(y=>s.fromPoints(y.vertices));return l(C)},u=(d,...h)=>{const _={axis:[0,0,1],origin:[0,0,0]},{axis:m,origin:p}=Object.assign({},_,d);if(h=n(h),h.length===0)throw new Error("wrong number of arguments");d={axis:m,origin:p};const I=h.map(f=>a.isA(f)?g(d,f):f);return I.length===1?I[0]:I};e.exports=u}}),QU=At({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,e){e.exports={extrudeFromSlices:Cie(),extrudeLinear:DSo(),extrudeRectangular:MSo(),extrudeRotate:qwt(),extrudeHelical:wSo(),project:NSo(),slice:kT()}}}),Awe=At({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,e){var n=Ia(),o=s=>{let a=n.fromValues(1/0,1/0);s.forEach(l=>{(l[1]<a[1]||l[1]===a[1]&&l[0]<a[0])&&(a=l)});const A=[];s.forEach(l=>{const g=r(l[1]-a[1],l[0]-a[0]),u=n.squaredDistance(l,a);A.push({point:l,angle:g,distSq:u})}),A.sort((l,g)=>l.angle!==g.angle?l.angle-g.angle:l.distSq-g.distSq);const c=[];return A.forEach(l=>{let g=c.length;for(;g>1&&i(c[g-2],c[g-1],l.point)<=Number.EPSILON;)c.pop(),g=c.length;c.push(l.point)}),c},i=(s,a,A)=>(a[0]-s[0])*(A[1]-s[1])-(a[1]-s[1])*(A[0]-s[0]),r=(s,a)=>s===0&&a===0?-1/0:-a/s;e.exports=o}}),cwe=At({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,e){var n=Vs(),o=Hs(),i=Yl(),r=s=>{const a=new Set,A=[],c=l=>{const g=l.toString();a.has(g)||(A.push(l),a.add(g))};return s.forEach(l=>{n.isA(l)?n.toPoints(l).forEach(c):o.isA(l)?o.toPoints(l).forEach(g=>g.forEach(c)):i.isA(l)&&i.toPoints(l).forEach(c)}),A};e.exports=r}}),RSo=At({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,e){var n=fs(),o=Yl(),i=Awe(),r=cwe(),s=(...a)=>{a=n(a);const A=r(a),c=i(A);return o.fromPoints({closed:!0},c)};e.exports=s}}),TSo=At({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,e){var n=fs(),o=Vs(),i=Awe(),r=cwe(),s=(...a)=>{a=n(a);const A=r(a),c=i(A);return c.length<3?o.create():o.fromPoints(c)};e.exports=s}}),kSo=At({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,e){var n=fs(),o=Hs(),i=cwe(),r=iwe(),s=(...a)=>{a=n(a);const A=i(a);return A.length===0?o.create():o.create(r(A))};e.exports=s}}),r3t=At({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,e){var n=fs(),o=EU(),i=Vs(),r=Hs(),s=Yl(),a=RSo(),A=TSo(),c=kSo(),l=(...g)=>{if(g=n(g),g.length===0)throw new Error("wrong number of arguments");if(!o(g))throw new Error("only hulls of the same type are supported");const u=g[0];return s.isA(u)?a(g):i.isA(u)?A(g):r.isA(u)?c(g):u};e.exports=l}}),FSo=At({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,e){var n=fs(),o=swe(),i=r3t(),r=(...s)=>{if(s=n(s),s.length<2)throw new Error("wrong number of arguments");const a=[];for(let A=1;A<s.length;A++)a.push(i(s[A-1],s[A]));return o(a)};e.exports=r}}),LSo=At({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,e){e.exports={hull:r3t(),hullChain:FSo(),hullPoints2:Awe(),hullPoints3:iwe()}}}),HSo=At({"node_modules/@jscad/modeling/src/operations/minkowski/index.js"(t,e){e.exports={minkowskiSum:t3t()}}}),s3t=At({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,e){var n=rr(),o=ja(),i=(s,a)=>{const A=Math.abs(o.measureArea(a));return Number.isFinite(A)&&A>s},r=(s,a)=>{let A=a.map(l=>{const g=l.vertices.map(h=>n.snap(n.create(),h,s)),u=[];for(let h=0;h<g.length;h++){const _=(h+1)%g.length;n.equals(g[h],g[_])||u.push(g[h])}const d=o.create(u);return l.color&&(d.color=l.color),d});const c=s*s*Math.sqrt(3)/4;return A=A.filter(l=>i(c,l)),A};e.exports=r}}),GSo=At({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,e){var n=qMe(),o=rr(),i=ja(),r=p=>{const I=i.toPoints(p),f=[];for(let C=0;C<I.length;C++){const y=(C+1)%I.length,E={v1:I[C],v2:I[y]};f.push(E)}for(let C=0;C<f.length;C++){const y=(C+1)%I.length;f[C].next=f[y],f[y].prev=f[C]}return f},s=(p,I)=>{const f=`${I.v1}:${I.v2}`;p.set(f,I)},a=(p,I)=>{const f=`${I.v1}:${I.v2}`;p.delete(f)},A=(p,I)=>{const f=`${I.v2}:${I.v1}`;return p.get(f)},c=(p,I,f)=>{let C=p.prev.v1,y=p.prev.v2,E=I.next.v2;const B=u(C,y,E,f);C=I.prev.v1,y=I.prev.v2,E=p.next.v2;const Q=u(C,y,E,f);return[B,Q]},l=o.create(),g=o.create(),u=(p,I,f,C)=>{const y=o.subtract(l,I,p),E=o.subtract(g,f,I);return o.cross(y,y,E),o.dot(y,C)},d=p=>{let I;const f=[];for(;p.next;){const C=p.next;f.push(p.v1),p.v1=null,p.v2=null,p.next=null,p.prev=null,p=C}return f.length>0&&(I=i.create(f)),I},h=p=>{if(p.length<2)return p;const I=p[0].plane,f=p.slice(),C=new Map;for(;f.length>0;){const E=f.shift(),B=r(E);for(let Q=0;Q<B.length;Q++){const b=B[Q],D=A(C,b);if(D){const R=c(b,D,I);if(R[0]>=0&&R[1]>=0){const w=D.next,H=b.next;b.prev.next=D.next,b.next.prev=D.prev,D.prev.next=b.next,D.next.prev=b.prev,b.v1=null,b.v2=null,b.next=null,b.prev=null,a(C,D),D.v1=null,D.v2=null,D.next=null,D.prev=null;const G=(K,U,q)=>{const W={v1:q.v1,v2:U.v2,next:U.next,prev:q.prev};q.prev.next=W,U.next.prev=W,a(K,U),U.v1=null,U.v2=null,U.next=null,U.prev=null,a(K,q),q.v1=null,q.v2=null,q.next=null,q.prev=null};R[0]===0&&G(C,w,w.prev),R[1]===0&&G(C,H,H.prev)}}else b.next&&s(C,b)}}const y=[];return C.forEach(E=>{const B=d(E);B&&y.push(B)}),C.clear(),y},_=(p,I)=>Math.abs(p[3]-I[3])<15e-8?n(p,I):!1,m=(p,I)=>{const f=[];I.forEach(y=>{const E=f.find(B=>_(B[0],i.plane(y)));E?E[1].push(y):f.push([i.plane(y),[y]])});let C=[];return f.forEach(y=>{const E=y[1],B=h(E);C=C.concat(B)}),C};e.exports=m}}),OSo=At({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,e){var n=gA(),o=rr(),i=ja(),r=c=>`${c}`,s=(c,l,g,u,d,h)=>{const _=r(u),m=r(d),p=`${_}/${m}`,I=`${m}/${_}`;if(c.has(I))return a(c,l,g,d,u,null),null;const f={vertex0:u,vertex1:d,polygonindex:h};return c.has(p)?c.get(p).push(f):c.set(p,[f]),l.has(_)?l.get(_).push(p):l.set(_,[p]),g.has(m)?g.get(m).push(p):g.set(m,[p]),p},a=(c,l,g,u,d,h)=>{const _=r(u),m=r(d),p=`${_}/${m}`;let I=-1;const f=c.get(p);for(let C=0;C<f.length;C++){const y=f[C];let E=r(y.vertex0);if(E===_&&(E=r(y.vertex1),E===m&&!(h!==null&&y.polygonindex!==h))){I=C;break}}f.splice(I,1),f.length===0&&c.delete(p),I=l.get(_).indexOf(p),l.get(_).splice(I,1),l.get(_).length===0&&l.delete(_),I=g.get(m).indexOf(p),g.get(m).splice(I,1),g.get(m).length===0&&g.delete(m)},A=c=>{const l=new Map;for(let g=0;g<c.length;g++){const u=c[g],d=u.vertices.length;if(d>=3){let h=u.vertices[0],_=r(h);for(let m=0;m<d;m++){let p=m+1;p===d&&(p=0);const I=u.vertices[p],f=r(I),C=`${_}/${f}`,y=`${f}/${_}`;if(l.has(y)){const E=l.get(y);E.splice(-1,1),E.length===0&&l.delete(y)}else{const E={vertex0:h,vertex1:I,polygonindex:g};l.has(C)?l.get(C).push(E):l.set(C,[E])}h=I,_=f}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(l.size>0){const g=new Map,u=new Map,d=new Map;for(const[_,m]of l)d.set(_,!0),m.forEach(p=>{const I=r(p.vertex0),f=r(p.vertex1);g.has(I)?g.get(I).push(_):g.set(I,[_]),u.has(f)?u.get(f).push(_):u.set(f,[_])});const h=c.slice(0);for(;l.size!==0;){for(const m of l.keys())d.set(m,!0);let _=!1;for(;;){const m=Array.from(d.keys());if(m.length===0)break;const p=m[0];let I=!0;if(l.has(p)){const C=l.get(p)[0];for(let y=0;y<2;y++){const E=y===0?C.vertex0:C.vertex1,B=y===0?C.vertex1:C.vertex0,Q=r(E),b=r(B);let D=[];y===0?u.has(Q)&&(D=u.get(Q)):g.has(Q)&&(D=g.get(Q));for(let R=0;R<D.length;R++){const w=D[R],H=l.get(w)[0],G=y===0?H.vertex0:H.vertex1;if(y===0?H.vertex1:H.vertex0,r(G)===b){a(l,g,u,E,B,null),a(l,g,u,B,E,null),I=!1,y=2,_=!0;break}else{const U=E,q=B,W=G,ee=o.subtract(o.create(),W,U),re=o.dot(o.subtract(o.create(),q,U),ee)/o.dot(ee,ee);if(re>0&&re<1){const X=o.scale(o.create(),ee,re);if(o.add(X,X,U),o.squaredDistance(X,q)<n.EPS*n.EPS){const se=H.polygonindex,le=h[se],ue=r(H.vertex1);let Ce=-1;for(let pe=0;pe<le.vertices.length;pe++)if(r(le.vertices[pe])===ue){Ce=pe;break}const ye=le.vertices.slice(0);ye.splice(Ce,0,B);const Be=i.create(ye);h[se]=Be,a(l,g,u,H.vertex0,H.vertex1,se);const de=s(l,g,u,H.vertex0,B,se),Ee=s(l,g,u,B,H.vertex1,se);de!==null&&d.set(de,!0),Ee!==null&&d.set(Ee,!0),I=!1,y=2,_=!0;break}}}}}}I&&d.delete(p)}if(!_)break}c=h}return l.clear(),c};e.exports=A}}),KSo=At({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,e){var n=rr(),o=ja(),i=(s,a,A)=>{const c=a.vertices.length;if(c>3){if(c>4){const u=[0,0,0];a.vertices.forEach(d=>n.add(u,u,d)),n.snap(u,n.divide(u,u,[c,c,c]),s);for(let d=0;d<c;d++){const h=o.create([u,a.vertices[d],a.vertices[(d+1)%c]]);a.color&&(h.color=a.color),A.push(h)}return}const l=o.create([a.vertices[0],a.vertices[1],a.vertices[2]]),g=o.create([a.vertices[0],a.vertices[2],a.vertices[3]]);a.color&&(l.color=a.color,g.color=a.color),A.push(l,g);return}A.push(a)},r=(s,a)=>{const A=[];return a.forEach(c=>{i(s,c,A)}),A};e.exports=r}}),USo=At({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,e){var n=fs(),o=wv(),i=Vs(),r=Hs(),s=Yl(),a=s3t(),A=GSo(),c=OSo(),l=KSo(),g=(_,m)=>m,u=(_,m)=>m,d=(_,m)=>{const p={snap:!1,simplify:!1,triangulate:!1},{snap:I,simplify:f,triangulate:C}=Object.assign({},p,_),y=o(m);let E=r.toPolygons(m);I&&(E=a(y,E)),f&&(E=A(y,E)),C&&(E=c(E),E=l(y,E));const B=Object.assign({},m);return B.polygons=E,B},h=(_,...m)=>{if(m=n(m),m.length===0)throw new Error("wrong number of arguments");const p=m.map(I=>{if(s.isA(I))return g(_,I);if(i.isA(I))return u(_,I);if(r.isA(I))return d(_,I);throw new Error("invalid geometry")});return p.length===1?p[0]:p};e.exports=h}}),YSo=At({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,e){var n=fs(),o=Ia(),i=Vs(),r=Hs(),s=Yl(),a=wv(),A=s3t(),c=d=>{const h=a(d),m=s.toPoints(d).map(p=>o.snap(o.create(),p,h));return s.create(m)},l=d=>{const h=a(d);let m=i.toSides(d).map(p=>[o.snap(o.create(),p[0],h),o.snap(o.create(),p[1],h)]);return m=m.filter(p=>!o.equals(p[0],p[1])),i.create(m)},g=d=>{const h=a(d),_=r.toPolygons(d),m=A(h,_);return r.create(m)},u=(...d)=>{if(d=n(d),d.length===0)throw new Error("wrong number of arguments");const h=d.map(_=>s.isA(_)?c(_):i.isA(_)?l(_):r.isA(_)?g(_):_);return h.length===1?h[0]:h};e.exports=u}}),zSo=At({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,e){e.exports={generalize:USo(),snap:YSo(),retessellate:xU()}}}),VSo=At({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,e){var n=(o,i,r)=>{for(o=o.slice();o.length<r;)o.push(i);return o};e.exports=n}}),JSo=At({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,e){var n=fs(),o=VSo(),i=jMe(),{translate:r}=E6(),s=l=>{if(!Array.isArray(l.modes)||l.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(l.modes=o(l.modes,"none",3),l.modes.filter(g=>["center","max","min","none"].includes(g)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(l.relativeTo)||l.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(l.relativeTo=o(l.relativeTo,0,3),l.relativeTo.filter(g=>Number.isFinite(g)||g==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof l.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return l},a=(l,g,u)=>{for(let d=0;d<3;d++)l[d]==null&&(g[d]==="center"?l[d]=(u[0][d]+u[1][d])/2:g[d]==="max"?l[d]=u[1][d]:g[d]==="min"&&(l[d]=u[0][d]));return l},A=(l,g,u)=>{const d=i(l),h=[0,0,0];for(let _=0;_<3;_++)g[_]==="center"?h[_]=u[_]-(d[0][_]+d[1][_])/2:g[_]==="max"?h[_]=u[_]-d[1][_]:g[_]==="min"&&(h[_]=u[_]-d[0][_]);return r(h,l)},c=(l,...g)=>{l=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},l),l=s(l);let{modes:d,relativeTo:h,grouped:_}=l;if(g=n(g),g.length===0)throw new Error("align(): No geometries were provided to act upon");if(h.filter(m=>m==null).length){const m=i(g);h=a(h,d,m)}return _?g=A(g,d,h):g=g.map(m=>A(m,d,h)),g.length===1?g[0]:g};e.exports=c}}),xie=At({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,e){var n=fs(),o=Vs(),i=Hs(),r=Yl(),s=C6(),{translate:a}=E6(),A=(d,h)=>{const _={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:m,relativeTo:p}=Object.assign({},_,d),I=s(h),f=[0,0,0];return m[0]&&(f[0]=p[0]-(I[0][0]+(I[1][0]-I[0][0])/2)),m[1]&&(f[1]=p[1]-(I[0][1]+(I[1][1]-I[0][1])/2)),m[2]&&(f[2]=p[2]-(I[0][2]+(I[1][2]-I[0][2])/2)),a(f,h)},c=(d,...h)=>{const _={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:m,relativeTo:p}=Object.assign({},_,d);if(h=n(h),h.length===0)throw new Error("wrong number of arguments");if(p.length!==3)throw new Error("relativeTo must be an array of length 3");d={axes:m,relativeTo:p};const I=h.map(f=>r.isA(f)||o.isA(f)||i.isA(f)?A(d,f):f);return I.length===1?I[0]:I},l=(...d)=>c({axes:[!0,!1,!1]},d),g=(...d)=>c({axes:[!1,!0,!1]},d),u=(...d)=>c({axes:[!1,!1,!0]},d);e.exports={center:c,centerX:l,centerY:g,centerZ:u}}}),Bie=At({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,e){var n=fs(),o=Ig(),i=Vs(),r=Hs(),s=Yl(),a=(g,...u)=>{if(!Array.isArray(g))throw new Error("factors must be an array");if(u=n(u),u.length===0)throw new Error("wrong number of arguments");for(g=g.slice();g.length<3;)g.push(1);if(g[0]<=0||g[1]<=0||g[2]<=0)throw new Error("factors must be positive");const d=o.fromScaling(o.create(),g),h=u.map(_=>s.isA(_)?s.transform(d,_):i.isA(_)?i.transform(d,_):r.isA(_)?r.transform(d,_):_);return h.length===1?h[0]:h},A=(g,...u)=>a([g,1,1],u),c=(g,...u)=>a([1,g,1],u),l=(g,...u)=>a([1,1,g],u);e.exports={scale:a,scaleX:A,scaleY:c,scaleZ:l}}}),qSo=At({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,e){var n=fs(),o=Vs(),i=Hs(),r=Yl(),s=(a,...A)=>{if(A=n(A),A.length===0)throw new Error("wrong number of arguments");const c=A.map(l=>r.isA(l)?r.transform(a,l):o.isA(l)?o.transform(a,l):i.isA(l)?i.transform(a,l):l);return c.length===1?c[0]:c};e.exports=s}}),B6=At({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,e){e.exports={align:JSo(),center:xie().center,centerX:xie().centerX,centerY:xie().centerY,centerZ:xie().centerZ,mirror:CU().mirror,mirrorX:CU().mirrorX,mirrorY:CU().mirrorY,mirrorZ:CU().mirrorZ,rotate:yU().rotate,rotateX:yU().rotateX,rotateY:yU().rotateY,rotateZ:yU().rotateZ,scale:Bie().scale,scaleX:Bie().scaleX,scaleY:Bie().scaleY,scaleZ:Bie().scaleZ,transform:qSo(),translate:E6().translate,translateX:E6().translateX,translateY:E6().translateY,translateZ:E6().translateZ}}}),Qie=At({"node_modules/@jscad/modeling/src/index.js"(t,e){e.exports={colors:pie(),curves:KBo(),geometries:zMe(),maths:hQo(),measurements:yQo(),primitives:x6(),text:ZQo(),utils:$wt(),booleans:BU(),expansions:i3t(),extrusions:QU(),hulls:LSo(),minkowski:HSo(),modifiers:zSo(),transforms:B6()}}}),a3t=At({"node_modules/jscad-planner/dist/index.cjs"(t,e){var n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,s=(u,d)=>{for(var h in d)n(u,h,{get:d[h],enumerable:!0})},a=(u,d,h,_)=>{if(d&&typeof d=="object"||typeof d=="function")for(let m of i(d))!r.call(u,m)&&m!==h&&n(u,m,{get:()=>d[m],enumerable:!(_=o(d,m))||_.enumerable});return u},A=u=>a(n({},"__esModule",{value:!0}),u),c={};s(c,{executeJscadOperations:()=>g,jscadPlanner:()=>l}),e.exports=A(c);var l={booleans:{intersect:(...u)=>({type:"intersect",shapes:u}),subtract:(...u)=>({type:"subtract",shapes:u}),union:(...u)=>({type:"union",shapes:u})},hulls:{hull:(...u)=>({type:"hull",shapes:u.flat()}),hullChain:(...u)=>({type:"hullChain",shapes:u.flat()})},colors:{colorize:(u,d)=>({type:"colorize",color:u,shape:d})},primitives:{cube:u=>({type:"cube",...u}),sphere:u=>({type:"sphere",...u}),cylinder:u=>({type:"cylinder",...u}),polygon:u=>({type:"polygon",...u}),cuboid:u=>({type:"cuboid",...u}),roundedCuboid:u=>({type:"roundedCuboid",...u})},transforms:{rotate:(u,d)=>({type:"rotate",angles:u,shape:d}),scale:(u,d)=>({type:"scale",factors:u,shape:d}),translate:(u,d)=>({type:"translate",vector:u,shape:d})},extrusions:{extrudeLinear:(u,d)=>({type:"extrudeLinear",options:u,shape:d}),extrudeRotate:(u,d)=>({type:"extrudeRotate",options:u,shape:d})},maths:{vec2:{create:(u,d)=>[u,d],fromValues:(u,d)=>[u,d]},vec3:{create:(u,d,h)=>[u,d,h],fromValues:(u,d,h)=>[u,d,h]}},geometries:{geom2:{create:u=>({type:"createGeom2",points:u})},geom3:{create:u=>({type:"createGeom3",polygons:u})},path2:{create:u=>({type:"createPath2",points:u})}},measurements:{measureBoundingBox:u=>({type:"measureBoundingBox",shape:u}),measureArea:u=>({type:"measureArea",shape:u}),measureVolume:u=>({type:"measureVolume",shape:u})},utils:{degToRad:u=>u*Math.PI/180,radToDeg:u=>u*180/Math.PI}},g=(u,d)=>{if(Array.isArray(d)&&d.length===1)return g(u,d[0]);if(Array.isArray(d))throw new Error("executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually");const h=p=>g(u,p),{type:_,...m}=d;switch(_){case"intersect":return u.booleans.intersect(...d.shapes.map(h));case"subtract":return u.booleans.subtract(...d.shapes.map(h));case"union":return u.booleans.union(...d.shapes.map(h));case"hull":return u.hulls.hull(...d.shapes.map(h));case"hullChain":return u.hulls.hullChain(...d.shapes.map(h));case"colorize":return u.colors.colorize(d.color,h(d.shape));case"cube":return u.primitives.cube(m);case"sphere":return u.primitives.sphere(m);case"cylinder":return u.primitives.cylinder(m);case"polygon":return u.primitives.polygon(m);case"cuboid":return u.primitives.cuboid(m);case"roundedCuboid":return u.primitives.roundedCuboid(m);case"rotate":return u.transforms.rotate(d.angles,h(d.shape));case"scale":return u.transforms.scale(d.factors,h(d.shape));case"translate":return u.transforms.translate(d.vector,h(d.shape));case"extrudeLinear":return u.extrusions.extrudeLinear(d.options,h(d.shape));case"extrudeRotate":return u.extrusions.extrudeRotate(d.options,h(d.shape));case"createGeom2":return u.geometries.geom2.create(d.points);case"createGeom3":return u.geometries.geom3.create(d.polygons);case"createPath2":return u.geometries.path2.create(d.points);case"measureBoundingBox":return u.measurements.measureBoundingBox(h(d.shape));case"measureArea":return u.measurements.measureArea(h(d.shape));case"measureVolume":return u.measurements.measureVolume(h(d.shape));case"degToRad":return u.utils.degToRad(d.degrees);case"radToDeg":return u.utils.radToDeg(d.radians);default:throw d.type===void 0?new Error(`Operation type is undefined. This usually means the operation object is malformed or not properly initialized. Operation: ${JSON.stringify(d,null,2).slice(0,200)}...`):new Error(`Unsupported operation type: ${d.type}. Operation: ${JSON.stringify(d,null,2)}`)}}}}),WSo=At({"node_modules/ms/index.js"(t,e){var n=1e3,o=n*60,i=o*60,r=i*24,s=r*7,a=r*365.25;e.exports=function(u,d){d=d||{};var h=typeof u;if(h==="string"&&u.length>0)return A(u);if(h==="number"&&isFinite(u))return d.long?l(u):c(u);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(u))};function A(u){if(u=String(u),!(u.length>100)){var d=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);if(d){var h=parseFloat(d[1]),_=(d[2]||"ms").toLowerCase();switch(_){case"years":case"year":case"yrs":case"yr":case"y":return h*a;case"weeks":case"week":case"w":return h*s;case"days":case"day":case"d":return h*r;case"hours":case"hour":case"hrs":case"hr":case"h":return h*i;case"minutes":case"minute":case"mins":case"min":case"m":return h*o;case"seconds":case"second":case"secs":case"sec":case"s":return h*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return h;default:return}}}}function c(u){var d=Math.abs(u);return d>=r?Math.round(u/r)+"d":d>=i?Math.round(u/i)+"h":d>=o?Math.round(u/o)+"m":d>=n?Math.round(u/n)+"s":u+"ms"}function l(u){var d=Math.abs(u);return d>=r?g(u,d,r,"day"):d>=i?g(u,d,i,"hour"):d>=o?g(u,d,o,"minute"):d>=n?g(u,d,n,"second"):u+" ms"}function g(u,d,h,_){var m=d>=h*1.5;return Math.round(u/h)+" "+_+(m?"s":"")}}}),jSo=At({"node_modules/debug/src/common.js"(t,e){function n(o){r.debug=r,r.default=r,r.coerce=g,r.disable=c,r.enable=a,r.enabled=l,r.humanize=WSo(),r.destroy=u,Object.keys(o).forEach(d=>{r[d]=o[d]}),r.names=[],r.skips=[],r.formatters={};function i(d){let h=0;for(let _=0;_<d.length;_++)h=(h<<5)-h+d.charCodeAt(_),h|=0;return r.colors[Math.abs(h)%r.colors.length]}r.selectColor=i;function r(d){let h,_=null,m,p;function I(...f){if(!I.enabled)return;const C=I,y=Number(new Date),E=y-(h||y);C.diff=E,C.prev=h,C.curr=y,h=y,f[0]=r.coerce(f[0]),typeof f[0]!="string"&&f.unshift("%O");let B=0;f[0]=f[0].replace(/%([a-zA-Z%])/g,(b,D)=>{if(b==="%%")return"%";B++;const R=r.formatters[D];if(typeof R=="function"){const w=f[B];b=R.call(C,w),f.splice(B,1),B--}return b}),r.formatArgs.call(C,f),(C.log||r.log).apply(C,f)}return I.namespace=d,I.useColors=r.useColors(),I.color=r.selectColor(d),I.extend=s,I.destroy=r.destroy,Object.defineProperty(I,"enabled",{enumerable:!0,configurable:!1,get:()=>_!==null?_:(m!==r.namespaces&&(m=r.namespaces,p=r.enabled(d)),p),set:f=>{_=f}}),typeof r.init=="function"&&r.init(I),I}function s(d,h){const _=r(this.namespace+(typeof h>"u"?":":h)+d);return _.log=this.log,_}function a(d){r.save(d),r.namespaces=d,r.names=[],r.skips=[];const h=(typeof d=="string"?d:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const _ of h)_[0]==="-"?r.skips.push(_.slice(1)):r.names.push(_)}function A(d,h){let _=0,m=0,p=-1,I=0;for(;_<d.length;)if(m<h.length&&(h[m]===d[_]||h[m]==="*"))h[m]==="*"?(p=m,I=_,m++):(_++,m++);else if(p!==-1)m=p+1,I++,_=I;else return!1;for(;m<h.length&&h[m]==="*";)m++;return m===h.length}function c(){const d=[...r.names,...r.skips.map(h=>"-"+h)].join(",");return r.enable(""),d}function l(d){for(const h of r.skips)if(A(d,h))return!1;for(const h of r.names)if(A(d,h))return!0;return!1}function g(d){return d instanceof Error?d.stack||d.message:d}function u(){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 r.enable(r.load()),r}e.exports=n}}),XSo=At({"node_modules/debug/src/browser.js"(t,e){t.formatArgs=o,t.save=i,t.load=r,t.useColors=n,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 n(){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 o(A){if(A[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+A[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const c="color: "+this.color;A.splice(1,0,c,"color: inherit");let l=0,g=0;A[0].replace(/%[a-zA-Z%]/g,u=>{u!=="%%"&&(l++,u==="%c"&&(g=l))}),A.splice(g,0,c)}t.log=console.debug||console.log||(()=>{});function i(A){try{A?t.storage.setItem("debug",A):t.storage.removeItem("debug")}catch{}}function r(){let A;try{A=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!A&&typeof TMe<"u"&&"env"in TMe&&(A=TMe.env.DEBUG),A}function s(){try{return localStorage}catch{}}e.exports=jSo()(t);var{formatters:a}=e.exports;a.j=function(A){try{return JSON.stringify(A)}catch(c){return"[UnexpectedJSONParseError]: "+c.message}}}}),A3t={boardBody:!0,topCopper:!0,bottomCopper:!0,keepout:!0,adhesive:!1,solderPaste:!1,topSilkscreen:!0,bottomSilkscreen:!0,topMask:!0,bottomMask:!0,throughHoleModels:!0,smtModels:!0,translucentModels:!0,modelsNotInPosFile:!1,modelsMarkedDNP:!1,modelBoundingBoxes:!1,threedAxis:!1,pcbNotes:!1,backgroundStart:!0,backgroundEnd:!0},c3t=ne.createContext(void 0),$So=({children:t})=>{const[e,n]=ne.useState(A3t),o=ne.useCallback((s,a)=>{n(A=>({...A,[s]:a}))},[]),i=ne.useCallback(()=>{n(A3t)},[]),r=ne.useMemo(()=>({visibility:e,setLayerVisibility:o,resetToDefaults:i}),[e,o,i]);return j.jsx(c3t.Provider,{value:r,children:t})},Q6=()=>{const t=ne.useContext(c3t);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},lwe=1.2;function l3t(t){return ne.useMemo(()=>{if(!t)return lwe;try{return Fi(t).pcb_board.list()[0]?.thickness??lwe}catch{return lwe}},[t])}var g3t=ne.createContext(null),wI=()=>{const t=ne.useContext(g3t);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},SU=(t,e=[])=>{const{addFrameListener:n,removeFrameListener:o}=wI();Xr.useEffect(()=>(n(t),()=>o(t)),[n,o,...e])},bU={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},u3t=({children:t,position:e,style:n})=>{const{camera:o,renderer:i}=wI(),r=ne.useRef(document.createElement("div")),[s,a]=ne.useState(null);return ne.useEffect(()=>{const A=i?.domElement.parentNode;if(A)return A.style.position!=="relative"&&A.style.position!=="absolute"&&(A.style.position="relative"),A.appendChild(r.current),a(mRe.createPortal(t,r.current)),()=>{A.contains(r.current)&&A.removeChild(r.current)}},[i,t]),SU(()=>{if(!o||!r.current||!i)return;const A=new Dt(...e);A.project(o);const c=i.domElement.getBoundingClientRect(),l=Math.round((A.x+1)/2*c.width),g=Math.round((-A.y+1)/2*c.height);r.current.style.position="absolute",r.current.style.left=`${l}px`,r.current.style.top=`${g}px`,r.current.style.pointerEvents="none",r.current.style.zIndex=bU.htmlElements.toString(),n&&Object.assign(r.current.style,n)},[o,i,e,n]),s},h3t={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},iA=t=>{let e=typeof t=="number"?"mm":t.replace(/^[^a-zA-Z]+/g,"").toLowerCase();e||(e="mm");const n=typeof t=="number"?t:Number.parseFloat(t.split(e)[0]);if(e in h3t)return n*h3t[e];throw new Error(`Unsupported unit: ${e}`)},ph=iA,ZSo=Object.defineProperty,ebo=(t,e)=>{for(var n in e)ZSo(t,n,{get:e[n],enumerable:!0})},r5={};ebo(r5,{axial:()=>M4o,bga:()=>Nbo,breakoutheaders:()=>Y4o,cap:()=>Abo,dfn:()=>g4o,diode:()=>abo,dip:()=>obo,electrolytic:()=>GPo,hc49:()=>J4o,jst:()=>oPo,led:()=>cbo,lqfp:()=>K4o,m2host:()=>cvo,melf:()=>gDo,micromelf:()=>_Do,minimelf:()=>oDo,mlp:()=>Kbo,mountedpcbmodule:()=>gvo,ms012:()=>I4o,ms013:()=>C4o,msop:()=>hPo,pad:()=>q4o,pinrow:()=>h4o,platedhole:()=>ZPo,potentiometer:()=>FPo,pushbutton:()=>k4o,qfn:()=>Hbo,qfp:()=>Obo,quad:()=>LT,radial:()=>R4o,res:()=>vbo,sma:()=>fDo,smb:()=>bDo,smbf:()=>KPo,smc:()=>MDo,smf:()=>xDo,smtpad:()=>XPo,sod110:()=>rPo,sod123:()=>b4o,sod123f:()=>v5o,sod123fl:()=>R5o,sod123w:()=>l5o,sod128:()=>K5o,sod323:()=>d5o,sod323f:()=>S5o,sod323fl:()=>fPo,sod323w:()=>_Po,sod523:()=>e5o,sod723:()=>L5o,sod80:()=>s5o,sod882:()=>E5o,sod882d:()=>aDo,sod923:()=>I5o,soic:()=>Tbo,solderjumper:()=>DPo,son:()=>xPo,sop8:()=>i5o,sot:()=>tvo,sot223:()=>TDo,sot23:()=>i4o,sot23w:()=>YDo,sot25:()=>A4o,sot323:()=>JPo,sot343:()=>rvo,sot363:()=>Xbo,sot457:()=>MPo,sot563:()=>m4o,sot723:()=>E4o,sot886:()=>e4o,sot89:()=>$5o,sot963:()=>RPo,ssop:()=>zbo,stampboard:()=>L4o,stampreceiver:()=>O4o,to220:()=>w3t,to220f:()=>tDo,to92:()=>$4o,to92l:()=>_vo,to92s:()=>jDo,tqfp:()=>Gbo,tssop:()=>qbo,vson:()=>QPo,vssop:()=>lPo});var pi=(t,e,n)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:n,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:e},anchor_alignment:"center"}),hi=Ze({norefdes:Te().optional().describe("disable reference designator label"),invert:Te().optional().describe("hint to invert the orientation of the 3D model"),faceup:Te().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:Te().optional().describe("omit all silkscreen elements from the footprint")}),Js=(t,e,n,o,i)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:n,hole_diameter:iA(o),outer_diameter:iA(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),Sy=t=>{const{pn:e,x:n,y:o,holeDiameter:i,rectPadWidth:r,rectPadHeight:s,holeOffsetX:a=0,holeOffsetY:A=0,rectBorderRadius:c}=t;return{pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:n,y:o,hole_diameter:iA(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:iA(r),rect_pad_height:iA(s),...c!==void 0&&{rect_border_radius:c},pcb_port_id:"",layers:["top","bottom"],port_hints:[e.toString()],hole_offset_x:a,hole_offset_y:A}},Sie=Array.from({length:9},(t,e)=>Math.cos(e/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)})),ZC=t=>{if(t.length<2)throw new Error("Rect union outline requires at least two bounds");for(const c of t)if(c.minX>=c.maxX||c.minY>=c.maxY)throw new Error("Each rectangle bound must have min < max on both axes");for(let c=1;c<t.length;c++){const l=t[c-1],g=t[c];if(g.minX<l.minX||g.maxX>l.maxX||g.minY>l.minY||g.maxY<l.maxY)throw new Error("Bounds must be ordered outer-to-inner with tighter X and larger Y span")}const e=()=>{const c=[];let l=t.length-1;for(c.push({x:t[l].minX,y:t[l].maxY});l>0;){const g=t[l],u=t[l-1];c.push({x:g.minX,y:u.maxY}),c.push({x:u.minX,y:u.maxY}),l-=1}return c},n=()=>{const c=[];let l=t.length-1;for(c.push({x:t[l].maxX,y:t[l].maxY});l>0;){const g=t[l],u=t[l-1];c.push({x:g.maxX,y:u.maxY}),c.push({x:u.maxX,y:u.maxY}),l-=1}return c},o=()=>{const c=[];let l=t.length-1;for(c.push({x:t[l].maxX,y:t[l].minY});l>0;){const g=t[l],u=t[l-1];c.push({x:g.maxX,y:u.minY}),c.push({x:u.maxX,y:u.minY}),l-=1}return c},i=()=>{const c=[];let l=t.length-1;for(c.push({x:t[l].minX,y:t[l].minY});l>0;){const g=t[l],u=t[l-1];c.push({x:g.minX,y:u.minY}),c.push({x:u.minX,y:u.minY}),l-=1}return c},r=e(),s=n(),a=o(),A=i();return[...r.reverse(),...s,...a.reverse(),...A]};function Nv(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var bie=Nn([F(),Ue()]).transform(t=>Nv(t)),tbo=t=>hi.extend({fn:F(),num_pins:Ue().optional().default(6),wide:Te().optional(),narrow:Te().optional(),w:bie.optional(),p:bie.default(t.p??"2.54mm"),id:bie.optional(),od:bie.optional(),nosquareplating:Te().optional().default(!1).describe("do not use rectangular pad for pin 1")}).transform(e=>(!e.id&&!e.od?Math.abs(e.p-1.27)<.01?(e.id=Nv("0.55mm"),e.od=Nv("0.95mm")):(e.id=Nv("0.8mm"),e.od=Nv("1.6mm")):e.id?e.od||(e.od=e.id*(1.5/1)):e.id=e.od*(1/1.5),e.w||(e.wide?e.w=Nv("600mil"):e.narrow?e.w=Nv("300mil"):e.w=Nv(t.w??"300mil")),e)),nbo=tbo({}),d3t=(t,e,n,o,i)=>{const r=t/2,s=e<=r,a=r-1,A=o,c=A*a;return s?{x:-n/2,y:c/2-(e-1)*A}:{x:n/2,y:-c/2+(e-r-1)*A}},obo=t=>{const e=nbo.parse(t),n=[];for(let p=0;p<e.num_pins;p++){const{x:I,y:f}=d3t(e.num_pins,p+1,e.w,e.p??2.54,e.nosquareplating);if(p===0&&!e.nosquareplating){n.push(Sy({pn:p+1,x:I,y:f,holeDiameter:e.id??"0.8mm",rectPadWidth:e.od??"1mm",rectPadHeight:e.od??"1mm"}));continue}n.push(Js(p+1,I,f,e.id??"0.8mm",e.od??"1mm"))}const o=(e.num_pins/2-1)*e.p+e.od,r=e.w-e.od-1,s=(e.num_pins/2-1)*e.p+e.od+.4,a={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r/2,y:-s/2},{x:-r/2,y:s/2},...Sie.map(({x:p,y:I})=>({x:p*r/6,y:I*r/6+s/2})),{x:r/2,y:s/2},{x:r/2,y:-s/2},{x:-r/2,y:-s/2}],type:"pcb_silkscreen_path",stroke_width:.1},A=[];for(let p=0;p<e.num_pins;p++){const I=p<e.num_pins/2,f=.6,{y:C}=d3t(e.num_pins,p+1,e.w,e.p??2.54,e.nosquareplating),y=I?-e.w/2-e.od/2-f:e.w/2+e.od/2+f,E=C;A.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${p+1}`,layer:"top",pcb_component_id:`pin_${p+1}`,text:`{pin${p+1}}`,anchor_position:{x:y,y:E},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const c=pi(0,s/2+.5,.4),l=e.w+e.od,g=o,u=l/2+.25,d=u,h=g/2+.72,_=h,m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:ZC([{minX:-u,maxX:u,minY:-_,maxY:_},{minX:-d,maxX:d,minY:-h,maxY:h}]),layer:"top"};return{circuitJson:[...n,a,c,...A,m],parameters:e}},Oo=(t,e,n,o,i,r)=>({type:"pcb_smtpad",x:e,y:n,width:o,height:i,layer:"top",shape:"rect",...r!==void 0&&{corner_radius:r},pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(s=>s.toString()):[t.toString()]}),_3t=[{imperial:"01005",metric:"0402",p_mm_min:.5,pw_mm_min:.4,ph_mm_min:.3,w_mm_min:.58,h_mm_min:.21,courtyard_width_mm:1.2,courtyard_height_mm:.6},{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,courtyard_width_mm:5.9,courtyard_height_mm:3.9,nonpolarizedSilkscreen:{line_half_length_mm:1.386252,line_y_mm:1.71,stroke_width_mm:.12}},{imperial:"0201",metric:"0603",p_mm_min:.66,pw_mm_min:.46,ph_mm_min:.4,w_mm_min:.9,h_mm_min:.3,courtyard_width_mm:1.4,courtyard_height_mm:.7},{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,courtyard_width_mm:1.86,courtyard_height_mm:.94,nonpolarizedSilkscreen:{line_half_length_mm:.153641,line_y_mm:.38,stroke_width_mm:.12}},{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,courtyard_width_mm:2.96,courtyard_height_mm:1.46,nonpolarizedSilkscreen:{line_half_length_mm:.237258,line_y_mm:.5225,stroke_width_mm:.12}},{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,courtyard_width_mm:3.36,courtyard_height_mm:1.9,nonpolarizedSilkscreen:{line_half_length_mm:.227064,line_y_mm:.735,stroke_width_mm:.12}},{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,courtyard_width_mm:4.56,courtyard_height_mm:2.26,nonpolarizedSilkscreen:{line_half_length_mm:.727064,line_y_mm:.91,stroke_width_mm:.12}},{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,courtyard_width_mm:4.56,courtyard_height_mm:3.16,nonpolarizedSilkscreen:{line_half_length_mm:.723737,line_y_mm:1.355,stroke_width_mm:.12}},{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,courtyard_width_mm:6.36,courtyard_height_mm:3.16,nonpolarizedSilkscreen:{line_half_length_mm:1.527064,line_y_mm:1.36,stroke_width_mm:.12}},{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,courtyard_width_mm:7.66,courtyard_height_mm:3.86,nonpolarizedSilkscreen:{line_half_length_mm:2.177064,line_y_mm:1.71,stroke_width_mm:.12}}],ibo=Object.fromEntries(_3t.map(t=>[t.metric,t])),rbo=Object.fromEntries(_3t.map(t=>[t.imperial,t])),sbo=(t,e)=>({type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:t,height:e,layer:"top"});hi.extend({fn:F().optional(),string:F().optional(),tht:Te(),p:Ae.optional(),pw:Ae.optional(),ph:Ae.optional(),metric:it.optional(),imperial:it.optional(),w:Ae.optional(),h:Ae.optional(),nonpolarized:Te().optional(),textbottom:Te().optional(),roundedPads:Te().optional()});var Die=t=>{let{fn:e,tht:n,p:o,pw:i,ph:r,metric:s,imperial:a,w:A,h:c,nonpolarized:l,textbottom:g,roundedPads:u,string:d}=t;if(typeof A=="string"&&(A=ph(A)),typeof c=="string"&&(c=ph(c)),typeof o=="string"&&(o=ph(o)),typeof i=="string"&&(i=ph(i)),typeof r=="string"&&(r=ph(r)),c!==void 0&&A!==void 0&&c>A)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let h;if(s&&(h=ibo[s]),a&&(h=rbo[a]),h&&(A=h.w_mm_min,c=h.h_mm_min,o=h.p_mm_min,i=h.pw_mm_min,r=h.ph_mm_min),o===void 0||i===void 0||r===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");let _=[];const m=e==="res"&&(l===!0||typeof d!="string"||/^res(?:\d{4}|\d{5})(?:_|$)/i.test(d))?h?.nonpolarizedSilkscreen:void 0;if(m?.stroke_width_mm){const{line_half_length_mm:y=0,line_y_mm:E=0,stroke_width_mm:B}=m;_=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-y,y:E},{x:y,y:E}],stroke_width:B,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-y,y:-E},{x:y,y:-E}],stroke_width:B,pcb_silkscreen_path_id:""}]}else _=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/2,y:r/2+.4},{x:-o/2-i/2-.2,y:r/2+.4},{x:-o/2-i/2-.2,y:-r/2-.4},{x:o/2,y:-r/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""}];const p=g?-r/2-.9:r/2+.9,I=pi(0,p,.2),f=h?.courtyard_width_mm&&h.courtyard_height_mm?sbo(h.courtyard_width_mm,h.courtyard_height_mm):null,C=u?Math.min(.125,Math.min(i,r)/8):void 0;return n?[Js(1,-o/2,0,i,i*1/.8),Js(2,o/2,0,i,i*1/.8),..._,I,...f?[f]:[]]:[Oo(["1","left"],-o/2,0,i,r,C),Oo(["2","right"],o/2,0,i,r,C),..._,I,...f?[f]:[]]},abo=t=>({circuitJson:Die({...t,roundedPads:!0}),parameters:t}),Abo=t=>({circuitJson:Die(t),parameters:t}),cbo=t=>({circuitJson:Die(t).map(n=>n.type!=="pcb_silkscreen_path"?n:{...n,route:n.route.map(o=>({...o,x:-o.x}))}),parameters:t}),FT=t=>{const{padSpacing:e,padWidth:n,padHeight:o,padPitch:i,numRows:r,textbottom:s,courtyardOutline:a}=t,A=[],c=(r-1)*(i/2);for(let D=0;D<r;D++)A.push(c-D*i);const l=[];A.forEach((D,R)=>{l.push(Oo(R+1,-e/2,D,n,o))}),A.slice().reverse().forEach((D,R)=>{l.push(Oo(R+r+1,e/2,D,n,o))});const g=Math.max(...A)+o/2+.4,u=Math.min(...A)-o/2-.4,d=-e/2-n/2-.4,h=e/2+n/2+.4,_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h*.5,y:g},{x:d*.5,y:g}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h*.5,y:u},{x:d*.5,y:u}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},p=-e/2,I=Math.max(...A),f=.2,C=p-n/2-.1,y=I+o/2+.1,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:[{x:C,y},{x:C-f,y},{x:C,y:y+f},{x:C,y}],stroke_width:.1},B=s?u-.9:g+.9,Q=pi(0,B,.2),b=a?{type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:a}:null;return[...l,_,m,E,Q,...b?[b]:[]]},lbo=hi.extend({pw:Ae.default("0.5mm"),ph:Ae.default("0.4mm"),p:Ae.default("0.7mm"),textbottom:Te().optional(),convex:Te().optional(),concave:Te().optional()}),gbo=1,ubo=t=>{const e=lbo.parse(t);if(e.concave===!0)return[];const n=ph(e.pw),o=ph(e.ph),i=ph(e.p);return FT({padSpacing:gbo,padWidth:n,padHeight:o,padPitch:i,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1,y:.95},{x:-1,y:-.95},{x:1,y:-.95},{x:1,y:.95}]})},hbo=hi.extend({pw:Ae.default("0.5mm"),ph:Ae.default("0.32mm"),p:Ae.default("0.5mm"),textbottom:Te().optional(),convex:Te().optional(),concave:Te().optional()}),dbo=1,_bo=t=>{const e=hbo.parse(t),n=ph(e.pw),o=ph(e.ph),i=ph(e.p);return FT({padSpacing:dbo,padWidth:n,padHeight:o,padPitch:i,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1,y:1.25},{x:-1,y:-1.25},{x:1,y:-1.25},{x:1,y:1.25}]})},mbo=hi.extend({pw:Ae.default("0.9mm"),ph:Ae.default("0.4mm"),p:Ae.default("0.8mm"),textbottom:Te().optional(),convex:Te().optional(),concave:Te().optional()}),pbo=1.7,Ibo=t=>{const e=mbo.parse(t),n=ph(e.pw),o=ph(e.ph),i=ph(e.p);return FT({padSpacing:pbo,padWidth:n,padHeight:o,padPitch:i,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1.55,y:1.05},{x:-1.55,y:-1.05},{x:1.55,y:-1.05},{x:1.55,y:1.05}]})},fbo=hi.extend({pw:Ae.default("0.9mm"),ph:Ae.default("0.4mm"),p:Ae.default("0.8mm"),textbottom:Te().optional(),convex:Te().optional(),concave:Te().optional()}),Cbo=1.7,ybo=t=>{const e=fbo.parse(t),n=ph(e.pw),o=ph(e.ph),i=ph(e.p);return FT({padSpacing:Cbo,padWidth:n,padHeight:o,padPitch:i,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1.55,y:1.88},{x:-1.55,y:-1.87},{x:1.55,y:-1.87},{x:1.55,y:1.88}]})},Ebo=hi.extend({pw:Ae.default("0.7mm"),ph:Ae.default("0.64mm"),p:Ae.default("0.94mm"),textbottom:Te().optional(),convex:Te().optional(),concave:Te().optional()}),xbo=1.4,Bbo=t=>{const e=Ebo.parse(t),n=ph(e.pw),o=ph(e.ph),i=ph(e.p);return FT({padSpacing:xbo,padWidth:n,padHeight:o,padPitch:i,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1.3,y:1.05},{x:-1.3,y:-1.05},{x:1.3,y:-1.05},{x:1.3,y:1.05}]})},Qbo=hi.extend({pw:Ae.default("0.9mm"),ph:Ae.default("0.9mm"),p:Ae.default("1.34mm"),textbottom:Te().optional(),convex:Te().optional(),concave:Te().optional()}),Sbo=3,bbo=t=>{const e=Qbo.parse(t),n=ph(e.pw),o=ph(e.ph),i=ph(e.p);return FT({padSpacing:Sbo,padWidth:n,padHeight:o,padPitch:i,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-2.21,y:2.85},{x:-2.21,y:-2.85},{x:2.2,y:-2.85},{x:2.2,y:2.85}]})},Dbo=t=>{const e=t.array??t.x;if(typeof e=="number")return Number.isNaN(e)?void 0:e;if(typeof e=="string"){const n=Number.parseInt(e,10);return Number.isNaN(n)?void 0:n}if(typeof t.imperial=="string"){const o=t.imperial.match(/x(2|4)$/)?.[1];if(o)return Number.parseInt(o,10)}},Pbo=t=>t?(typeof t=="number"?`${t}`:t).split(/[_x]/)[0]:void 0,vbo=t=>{const e=Dbo(t),n=Pbo(t.imperial);return e===2&&n==="0402"?{circuitJson:ubo(t),parameters:t}:e===4&&n==="0402"?{circuitJson:_bo(t),parameters:t}:e===2&&n==="0603"?{circuitJson:Ibo(t),parameters:t}:e===4&&n==="0603"?{circuitJson:ybo(t),parameters:t}:e===2&&n==="0606"?{circuitJson:Bbo(t),parameters:t}:e===4&&n==="1206"?{circuitJson:bbo(t),parameters:t}:{circuitJson:Die(t),parameters:t}},m3t=(t,{x:e,y:n,radius:o})=>({type:"pcb_smtpad",x:e,y:n,radius:o,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(i=>i.toString()):[t.toString()]}),p3t="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Pie=F().transform(t=>{const[e,n]=t.split(/[x ]/);return{x:parseFloat(e??""),y:parseFloat(n??"")}}).pipe(Ze({x:Ue(),y:Ue()})),Mbo=F().or(Qt(Fg())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(e=>{const n=Number(e);return isNaN(n)?e:n}))).pipe(Qt(F().or(Ue()))),wbo=hi.extend({fn:F(),num_pins:Ue().optional().default(64),grid:Pie.optional(),p:it.default("0.8mm"),w:Ae.optional(),h:Ae.optional(),ball:Ae.optional().describe("ball diameter"),pad:Ae.optional().describe("pad width/height"),circularpads:Te().optional().describe("use circular pads"),tlorigin:Te().optional(),blorigin:Te().optional(),trorigin:Te().optional(),brorigin:Te().optional(),missing:Mbo.default([])}).transform(t=>{let e="tl";if(t.blorigin&&(e="bl"),t.trorigin&&(e="tr"),t.brorigin&&(e="br"),!t.grid){const o=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:o,y:o}}return t.missing&&(t.missing=t.missing.map(o=>{if(typeof o=="number")return o;if(o==="center")return"center";if(o==="topleft")return"topleft";const i=o.match(/([A-Z]+)(\d+)/);if(!i)return o;const r=p3t.indexOf(i[1]),s=Number.parseInt(i[2])-1;return r*t.grid.x+s+1})),{...t,origin:e}}),Nbo=t=>{const e=wbo.parse(t);let{num_pins:n,grid:o,p:i,w:r,h:s,ball:a,pad:A,missing:c}=e;a??=.75/1.27*i,A??=a*.8;const l=[],g=(c??[]).filter(W=>typeof W=="number"),u=o.x*o.y-n;if(c.length===0&&u>0&&(Math.sqrt(u)%1===0?c.push("center"):u===1&&c.push("topleft")),c?.includes("center")){const W=Math.floor(Math.sqrt(u)),ee=Math.floor((o.x-W)/2),re=Math.floor((o.y-W)/2);for(let X=re;X<re+W;X++)for(let te=ee;te<ee+W;te++)g.push(X*o.x+te+1)}c?.includes("topleft")&&g.push(1);const d=new Set(g);let h=0;for(let W=0;W<o.y;W++)for(let ee=0;ee<o.x;ee++){const re=(ee-(o.x-1)/2)*i,X=(W-(o.y-1)/2)*i;let te=ee,se=W;switch(e.origin){case"bl":te=ee,se=o.y-1-W;break;case"br":te=o.x-1-ee,se=o.y-1-W;break;case"tr":te=o.x-1-ee,se=W;break}let le=se*o.x+te+1;if(d.has(le)){h++;continue}le-=h;const ue=[le,`${p3t[se]}${te+1}`];l.push(e.circularpads?m3t(ue,{x:re,y:X,radius:A/2}):Oo(ue,re,X,A,A))}const _=pi(0,o.y*i/2,.2),m=i/6;let p;const I=o.x*i/2,f=o.y*i/2;switch(e.origin){case"bl":p=[{x:-I,y:-f},{x:-I,y:-f-m},{x:-I-m,y:-f},{x:-I,y:-f}];break;case"br":p=[{x:I,y:-f},{x:I,y:-f-m},{x:I+m,y:-f},{x:I,y:-f}];break;case"tr":p=[{x:I,y:f},{x:I,y:f+m},{x:I+m,y:f},{x:I,y:f}];break;default:p=[{x:-I,y:f},{x:-I,y:f+m},{x:-I-m,y:f},{x:-I,y:f}];break}const C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:p,stroke_width:.05},y=(o.x-1)*i+A,E=(o.y-1)*i+A,B=r??y,Q=s??E,b=Math.max(y/2,B/2),D=Math.max(E/2,Q/2),R=1.715,w=1.765,H=b+R,G=H,K=D+w,U=K,q={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:ZC([{minX:-H,maxX:H,minY:-U,maxY:U},{minX:-G,maxX:G,minY:-K,maxY:K}]),layer:"top"};return{circuitJson:[...l,_,C,q],parameters:e}},vie=(t,e,n,o,i)=>({type:"pcb_smtpad",x:e,y:n,width:o,height:i,radius:i/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(r=>r.toString()):[t.toString()]}),S6=t=>hi.extend({fn:F(),num_pins:Ue().optional().default(8),w:Ae.default(Ae.parse(t.w??"5.3mm")),p:Ae.default(Ae.parse(t.p??"1.27mm")),pw:Ae.default(Ae.parse(t.pw??"0.6mm")),pl:Ae.default(Ae.parse(t.pl??"1.0mm")),legsoutside:Te().optional().default(t.legsoutside??!1),pillpads:Te().optional().default(t.pillpads??!1),silkscreen_stroke_width:Ue().optional().default(.1)}).transform(e=>(!e.pw&&!e.pl?(e.pw=Ae.parse("0.6mm"),e.pl=Ae.parse("1.0mm")):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e)),Rbo=S6({}),gwe=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:e,pn:n,w:o,p:i,pl:r,legsoutside:s}=t,a=e/2,A=n<=a,c=a-1,l=i,g=l*c,u=s?r/2:-r/2;return A?{x:-o/2-u,y:g/2-(n-1)*l}:{x:o/2+u,y:-g/2+(n-a-1)*l}},Tbo=t=>{const e=Rbo.parse(t);return{circuitJson:DU(e),parameters:e}},DU=t=>{const e=[];let n=0,o=0;for(let m=0;m<t.num_pins;m++){const{x:p,y:I}=gwe({num_pins:t.num_pins,pn:m+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});n=Math.max(n,Math.abs(p)+t.pl/2),o=Math.max(o,Math.abs(I)+t.pw/2),t.pillpads?e.push(vie(m+1,p,I,t.pl,t.pw)):e.push(Oo(m+1,p,I,t.pl,t.pw))}const i=Math.min(1,t.p/2),r=t.w-(t.legsoutside?0:t.pl*2)-.2,s=(t.num_pins/2-1)*t.p+t.pw+i,a=pi(0,s/2+.4,s/12),A={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:-r/2,y:-s/2},{x:-r/2,y:s/2},...Sie.map(({x:m,y:p})=>({x:m*r/6,y:p*r/6+s/2})),{x:r/2,y:s/2},{x:r/2,y:-s/2},{x:-r/2,y:-s/2}]},c=t.w/2,l=s/2,g=Math.max(n,c)+.25,u=Math.min(o,l)+.25,d=Math.min(n,c)+.25,h=Math.max(o,l)+.25,_={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:ZC([{minX:-g,maxX:g,minY:-u,maxY:u},{minX:-d,maxX:d,minY:-h,maxY:h}])};return[...e,A,a,_]},I3t=Jt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),kbo=({num_pins:t,cw:e,ccw:n,startingpin:o})=>{const i=[],r=t/4;let s=1;const a={};for(const A of o??[])a[A]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=r:a.bottomside&&a.leftpin?s=r+1:a.bottomside&&a.rightpin?s=r*2:a.rightside&&a.bottompin?s=r*2+1:a.rightside&&a.toppin?s=r*3:a.topside&&a.rightpin?s=r*3+1:a.topside&&a.leftpin&&(s=r*4),i.push(-1);for(let A=0;A<t;A++)i[s]=A+1,n||!e?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return i},uwe=hi.extend({fn:F(),cc:Te().default(!0).optional(),ccw:Te().default(!0).optional(),startingpin:F().or(Qt(I3t)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(Qt(I3t)).optional(),num_pins:Ue().optional().default(64),w:Ae.optional(),h:Ae.optional(),p:Ae.default(Ae.parse("0.5mm")),pw:Ae.optional(),pl:Ae.optional(),thermalpad:Nn([be(!0),Pie]).optional(),legsoutside:Te().default(!1)}),hwe=t=>{t.w&&!t.h?t.h=t.w:!t.w&&t.h&&(t.w=t.h);const e=t.num_pins/4;if(!t.p&&!t.pw&&!t.pl&&t.w){const n=e+4;t.p=t.w/n}return!t.p&&t.w&&t.h&&t.pw&&t.pl&&(t.p=(t.w-t.pl*2)/(e-1)),!t.w&&!t.h&&t.p&&(t.w=t.p*(e+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},f3t=uwe.transform(hwe),Fbo=["left","bottom","right","top"],Lbo=t=>{const{pin_count:e,pn:n,w:o,h:i,p:r,pl:s,legsoutside:a}=t,A=e/4,c=Fbo[Math.floor((n-1)/A)],l=(n-1)%A,g=r*(A-1),u=r*(A-1),d=a?s/2:-s/2;switch(c){case"left":return{x:-o/2-d+.1,y:u/2-l*r,o:"vert"};case"bottom":return{x:-g/2+l*r,y:-i/2-d+.1,o:"horz"};case"right":return{x:o/2+d-.1,y:-u/2+l*r,o:"vert"};case"top":return{x:g/2-l*r,y:i/2+d-.1,o:"horz"};default:throw new Error("Invalid pin number")}},LT=t=>{const e=f3t.parse(t),n=[];let o=0,i=0;const r=kbo(e),s=e.num_pins/4;for(let f=0;f<e.num_pins;f++){const{x:C,y,o:E}=Lbo({pin_count:e.num_pins,pn:f+1,w:e.w,h:e.h,p:e.p??.5,pl:e.pl,legsoutside:e.legsoutside});let B=e.pw,Q=e.pl;E==="vert"&&([B,Q]=[Q,B]);const b=r[f+1];o=Math.max(o,Math.abs(C)+B/2),i=Math.max(i,Math.abs(y)+Q/2),n.push(Oo(b,C,y,B,Q))}if(e.thermalpad)if(typeof e.thermalpad=="boolean"){const f=e.p*(s-1)+e.pw,C=e.p*(s-1)+e.pw;o=Math.max(o,f/2),i=Math.max(i,C/2),n.push(Oo(["thermalpad"],0,0,f,C))}else o=Math.max(o,e.thermalpad.x/2),i=Math.max(i,e.thermalpad.y/2),n.push(Oo(["thermalpad"],0,0,e.thermalpad.x,e.thermalpad.y));const a=[];for(const[f,C,y]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const E=e.w/2*C,B=e.h/2*y;let Q="none",b=E,D=B;const R=e.pw*2;r[1]===1&&f==="top-left"?Q="in1":r[s*4]===1&&f==="top-left"||r[s*3+1]===1&&f==="top-right"?Q="in2":r[s*3]===1&&f==="top-right"||r[s]===1&&f==="bottom-left"?Q="in1":r[s+1]===1&&f==="bottom-left"?Q="in2":r[s*2]===1&&f==="bottom-right"?Q="in1":r[s*2+1]===1&&f==="bottom-right"&&(Q="in2");const w=Q==="in1"?1:-1;if(e.legsoutside){const H=Q==="in1"?e.pl/2:e.pw/2,G=Q==="in1"?e.pw/2:e.pl/2;b+=H*C*w,D-=G*y*w}(Q==="none"||e.legsoutside)&&a.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${f}`,route:[{x:E-R*C,y:B},{x:E,y:B},{x:E,y:B-R*y}],type:"pcb_silkscreen_path",stroke_width:.1}),(Q==="in1"||Q==="in2")&&!e.legsoutside&&a.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${f}_1`,route:[{x:E-R*C,y:B},{x:E-R*C/2,y:B}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${f}_2`,route:[{x:E,y:B-R*y/2},{x:E,y:B-R*y}],type:"pcb_silkscreen_path",stroke_width:.1}),(Q==="in1"||Q==="in2")&&a.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${f}_3`,route:[{x:b-.2*-C,y:D+.2*w},{x:b,y:D},{x:b+.2*w*-C,y:D+.2},{x:b-.2*-C,y:D+.2*w}],type:"pcb_silkscreen_path",stroke_width:.1})}const A=pi(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3),c=f=>Math.ceil(f/.05)*.05,l=(s-1)*e.p+e.pw,g=(s-1)*e.p+e.pw,u=l/2+.25,d=g/2+.25,h=e.w/2+.25,_=e.h/2+.25,m=Math.max(h,c(o+.25)),p=Math.max(_,c(i+.25)),I={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:ZC([{minX:-m,maxX:m,minY:-d,maxY:d},{minX:-h,maxX:h,minY:-_,maxY:_},{minX:-u,maxX:u,minY:-p,maxY:p}])};return{circuitJson:[...n,...a,A,I],parameters:e}};uwe.extend({}).transform(hwe);var Hbo=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),LT(t)),Gbo=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 LT(t)},Obo=t=>{t.legsoutside=!0;const e=f3t.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=e.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=e.pw;break}return LT(t)};uwe.extend({}).transform(hwe);var Kbo=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),LT(t)),Ubo=hi.extend({fn:F(),num_pins:Ue().optional().default(8),w:Ae.default(Ae.parse("3.9mm")),p:Ae.default(Ae.parse("1.27mm")),pw:Ae.optional(),pl:Ae.optional(),legsoutside:Te().optional().default(!1),silkscreen_stroke_width:Ue().optional().default(.1)}).transform(t=>(t.pw==null&&t.pl==null?(t.pw=Ae.parse("0.51mm"),t.pl=Ae.parse("1.1mm")):t.pw==null?t.pw=t.pl*(.51/1.1):t.pl==null&&(t.pl=t.pw*(1.1/.51)),t)),Ybo=t=>{const{num_pins:e,pn:n,w:o,p:i}=t,r=e/2,s=n<=r,a=r-1,A=i,c=A*a,l=o+Ae.parse("0.2mm"),g=(s?-1:1)*(l/2);return s?{x:g,y:c/2-(n-1)*A}:{x:g,y:-c/2+(n-r-1)*A}},zbo=t=>{const e=Ubo.parse(t),n=[];for(let m=0;m<e.num_pins;m++){const{x:p,y:I}=Ybo({num_pins:e.num_pins,pn:m+1,w:e.w,p:e.p,pl:e.pl,legsoutside:e.legsoutside});n.push(Oo(m+1,p,I,e.pl,e.pw))}const o=Math.min(1,e.p/2),i=e.w-(e.legsoutside?0:e.pl)-.2,r=(e.num_pins/2-1)*e.p+e.pw+o,s=pi(0,r/2+.4,r/12),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:e.silkscreen_stroke_width??.1,route:[{x:-i/2,y:-r/2},{x:-i/2,y:r/2},...Sie.map(({x:m,y:p})=>({x:m*i/6,y:p*i/6+r/2})),{x:i/2,y:r/2},{x:i/2,y:-r/2},{x:-i/2,y:-r/2}]},A=(e.num_pins/2-1)*e.p+e.pw,c=e.legsoutside?e.w/2+e.pl:(e.w+.2)/2+e.pl/2,l=A/2,g=c+.25,u=g,d=l+.445,h=d,_={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:ZC([{minX:-g,maxX:g,minY:-h,maxY:h},{minX:-u,maxX:u,minY:-d,maxY:d}]),layer:"top"};return{circuitJson:[...n,a,s,_],parameters:e}},Vbo=hi.extend({fn:F(),num_pins:Ue().optional().default(8),w:Ae.default(Ae.parse("3.0mm")),p:Ae.default(Ae.parse("0.5mm")),pw:Ae.default(Ae.parse("0.30mm")),pl:Ae.default(Ae.parse("1.45mm")),legsoutside:Te().optional().default(!0),silkscreen_stroke_width:Ue().optional().default(.1)}),Jbo=t=>{const{num_pins:e,pn:n,w:o,p:i,pl:r,legsoutside:s}=t,a=e/2,A=n<=a,c=a-1,l=i*c,g=s?r/2:-r/2;return A?{x:-o/2-g,y:l/2-(n-1)*i}:{x:o/2+g,y:-l/2+(n-a-1)*i}},qbo=t=>{const e={...t},n=e.p,o=typeof n=="string"||typeof n=="number"?Ae.parse(n):void 0,i=o!=null&&o<=Ae.parse("0.5mm"),r=Vbo.parse(e),s=[],a=i?r.w-Ae.parse("0.15mm"):r.w;for(let C=0;C<r.num_pins;C++){const{x:y,y:E}=Jbo({num_pins:r.num_pins,pn:C+1,w:a,p:r.p,pl:r.pl,legsoutside:r.legsoutside});s.push(Oo(C+1,y,E,r.pl,r.pw))}const A=Math.min(1,r.p/2),c=r.w-(r.legsoutside?0:r.pl*2)-.2,l=(r.num_pins/2-1)*r.p+r.pw+A,g=pi(0,l/2+.4,l/12),u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:r.silkscreen_stroke_width??.1,route:[{x:-c/2,y:-l/2},{x:-c/2,y:l/2},...Sie.map(({x:C,y})=>({x:C*c/6,y:y*c/6+l/2})),{x:c/2,y:l/2},{x:c/2,y:-l/2},{x:-c/2,y:-l/2}]},d=(r.num_pins/2-1)*r.p+r.pw,h=r.w/2+(r.legsoutside?r.pl:0),_=r.w/2+.25,m=h+.18,p=d/2+.25,I=p+.35,f={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:ZC([{minX:-m,maxX:m,minY:-p,maxY:p},{minX:-_,maxX:_,minY:-I,maxY:I}])};return{circuitJson:[...s,u,g,f],parameters:r}},Wbo=[{x:-1.45,y:.93},{x:-.73,y:.93},{x:-.73,y:1.1},{x:.73,y:1.1},{x:.73,y:.93},{x:1.45,y:.93},{x:1.45,y:-.93},{x:.73,y:-.93},{x:.73,y:-1.1},{x:-.73,y:-1.1},{x:-.73,y:-.93},{x:-1.45,y:-.93}],jbo=hi.extend({fn:F(),num_pins:be(6).default(6),w:F().default("3.1mm"),h:F().default("2.0mm"),p:F().default("0.65mm"),pl:F().default("1.03mm"),pw:F().default("0.35mm"),string:F().optional()}),Xbo=t=>{const e=jbo.parse({...t,fn:"sot363"}),n=Ae.parse(e.w),o=Ae.parse(e.h),i=Ae.parse(e.p),r=Ae.parse(e.pl),s=Ae.parse(e.pw),a=[];for(let h=0;h<6;h++){const{x:_,y:m}=C3t(h+1,n,i);a.push(Oo(h+1,_,m,r,s))}const A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/4,y:o/2+.1},{x:n/4,y:o/2+.1}],stroke_width:.05,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/4,y:-o/2-.1},{x:n/4,y:-o/2-.1}],stroke_width:.05,pcb_silkscreen_path_id:""},l=C3t(1,n,i),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-r/2-.3,y:l.y},{x:l.x-r/2-.45,y:l.y+.15},{x:l.x-r/2-.45,y:l.y-.15},{x:l.x-r/2-.3,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},u=pi(0,o/2+.4,.25),d={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:Wbo,layer:"top"};return{circuitJson:[...a,A,c,u,g,d],parameters:e}},C3t=(t,e,n,o)=>t<=3?{x:-.84,y:n-(t-1)*n}:{x:.84,y:-n+(t-4)*n},$bo=[{x:-.75,y:1},{x:-.75,y:-1},{x:.75,y:-1},{x:.75,y:1}],Zbo=hi.extend({fn:F(),num_pins:be(6).default(6),w:F().default("1.01mm"),h:F().default("1.45mm"),p:F().default("0.5mm"),pl:F().default("0.33mm"),pw:F().default("0.27mm"),string:F().optional()}),e4o=t=>{const e=Zbo.parse({...t,fn:"sot886"}),n=Ae.parse(e.w),o=Ae.parse(e.h),i=Ae.parse(e.p),r=Ae.parse(e.pl),s=Ae.parse(e.pw),a=[];for(let h=0;h<6;h++){const{x:_,y:m}=y3t(h+1,n,i,r);a.push(Oo(h+1,_,m,r,s))}const A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:o/2},{x:n/2,y:o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-o/2},{x:n/2,y:-o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=y3t(1,n,i,r),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-r/2-.3,y:l.y},{x:l.x-r/2-.45,y:l.y+.15},{x:l.x-r/2-.45,y:l.y-.15},{x:l.x-r/2-.3,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},u=pi(0,o/2+.4,.25),d={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:$bo,layer:"top"};return{circuitJson:[...a,A,c,u,g,d],parameters:e}},y3t=(t,e,n,o)=>{const i=e/2-o/2;return t<=3?{x:-i,y:n-(t-1)*n}:{x:i,y:-n+(t-4)*n}},t4o=[{x:-2.05,y:1.5},{x:-1.05,y:1.5},{x:-1.05,y:1.7},{x:1.05,y:1.7},{x:1.05,y:.55},{x:2.05,y:.55},{x:2.05,y:-.55},{x:1.05,y:-.55},{x:1.05,y:-1.7},{x:-1.05,y:-1.7},{x:-1.05,y:-1.5},{x:-2.05,y:-1.5},{x:-2.05,y:-.39},{x:-1.05,y:-.39},{x:-1.05,y:.39},{x:-2.05,y:.39}],n4o=[{x:-2.05,y:1.5},{x:-1.05,y:1.5},{x:-1.05,y:1.7},{x:1.05,y:1.7},{x:1.05,y:1.5},{x:2.05,y:1.5},{x:2.05,y:.39},{x:1.05,y:.39},{x:1.05,y:-.39},{x:2.05,y:-.39},{x:2.05,y:-1.5},{x:1.05,y:-1.5},{x:1.05,y:-1.7},{x:-1.05,y:-1.7},{x:-1.05,y:-1.5},{x:-2.05,y:-1.5}],E3t=hi.extend({fn:F(),num_pins:Ue().default(3),w:F().default("1.92mm"),h:F().default("2.74mm"),pl:F().default("1.325mm"),pw:F().default("0.6mm"),p:F().default("0.95mm"),string:F().optional()}),o4o=S6({p:"0.95mm",w:"1.6mm",legsoutside:!0}),i4o=t=>{const e=t.string?.match(/^sot23_(\d+)/),n=e?Number.parseInt(e[1],10):3;if(n===6||n===8){const i=o4o.parse({...t,num_pins:n});return{circuitJson:DU(i),parameters:i}}const o=E3t.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:s4o(o),parameters:o};if(o.num_pins===5)return{circuitJson:B3t(o),parameters:o};throw new Error("Invalid number of pins")},r4o=t=>{const{pn:e,p:n}=t;return e===1?{x:-1.1375,y:n}:e===2?{x:-1.1375,y:-n}:{x:1.1375,y:0}},s4o=t=>{const e=[];for(let i=0;i<t.num_pins;i++){const{x:r,y:s}=r4o({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)});e.push(Oo(i+1,r,s,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=pi(0,Number.parseInt(t.h),.3),o={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:t4o,layer:"top"};return[...e,n,o]},x3t=t=>{const{p:e,h:n,pn:o}=t;if(o===1)return{x:-1.1375,y:e};if(o===2)return{x:-1.1375,y:0};if(o===3)return{x:-1.1375,y:-e};if(o===4)return{x:1.1375,y:-e};if(o===5)return{x:1.1375,y:e};throw new Error("Invalid pin number")},B3t=t=>{const e=[];for(let u=1;u<=t.num_pins;u++){const{x:d,y:h}=x3t({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:u});e.push(Oo(u,d,h,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=(t.num_pins+1)/2*Number.parseFloat(t.p),o=Number.parseFloat(t.h),i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:o/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:o/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-o/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-o/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=pi(0,o+.3,.3),a=x3t({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const A=.3,c=.4,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+A/2,y:a.y},{x:a.x-A/2,y:a.y+c/2},{x:a.x-A/2,y:a.y-c/2},{x:a.x+A/2,y:a.y}],stroke_width:.05},g={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:n4o,layer:"top"};return[...e,s,i,r,l,g]},a4o=E3t.extend({}),A4o=t=>{const e=a4o.parse({...t,num_pins:5});return{circuitJson:B3t(e),parameters:e}},c4o=[{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}],l4o=S6({}),g4o=t=>{const e=l4o.parse(t),n=[];for(let m=0;m<e.num_pins;m++){const{x:p,y:I}=gwe({num_pins:e.num_pins,pn:m+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Oo(m+1,p,I,e.pl??"1mm",e.pw??"0.6mm"))}const o=Math.min(1,e.p/2),i=e.w+o,r=(e.num_pins/2-1)*e.p+e.pw+o,s=[];for(const m of c4o){const{dx:p,dy:I}=m;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:p*i/2-p*e.p,y:I*r/2},{x:p*i/2,y:I*r/2},{x:p*i/2,y:I*r/2-I*e.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const a=e.p/4,A=-i/2-a/2,c=r/2-e.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:A,y:c},{x:A-a,y:c+a},{x:A-a,y:c-a},{x:A,y:c}],stroke_width:.1});const l=pi(0,r/2+.4,r/12),g=m=>Math.ceil(m/.05)*.05,u=(e.num_pins/2-1)*e.p+e.pw,d=g(e.w/2+.25),h=g(u/2+.45),_={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:d*2,height:h*2,layer:"top"};return{circuitJson:[...n,l,...s,_],parameters:e}},b6=({fs:t,pn:e,anchor_x:n,anchor_y:o,textalign:i="center",orthogonal:r=!1,verticallyinverted:s=!1,layer:a="top"})=>{let A=0;r&&s?A=270:s?A=180:r?A=90:A=0;let c="center";return i==="left"&&(s?c="center_right":c="center_left"),i==="right"&&(s?c="center_left":c="center_right"),a==="bottom"&&(c==="center_left"?c="center_right":c==="center_right"&&(c="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${e}}`,layer:a,anchor_position:{x:n,y:o},anchor_alignment:c,ccw_rotation:A}};function Q3t({pinlabeltextalignleft:t,pinlabeltextalignright:e,pinlabelorthogonal:n}){let o="top";return n?o="left":o="top",t&&(n?o="bottom":o="right"),e&&(n?o="top":o="left"),o}var u4o=hi.extend({fn:F(),num_pins:Ue().optional().default(6),rows:Nn([F(),Ue()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:Ae.default("0.1in").describe("pitch"),id:Ae.default("1.0mm").describe("inner diameter"),od:Ae.default("1.5mm").describe("outer diameter"),male:Te().optional().describe("for male pin headers"),female:Te().optional().describe("for female pin headers"),smd:Te().optional().describe("surface mount device"),surfacemount:Te().optional().describe("surface mount device (verbose)"),rightangle:Te().optional().describe("right angle"),pw:Ae.optional().default("1.0mm").describe("pad width for SMD"),pl:Ae.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:Te().optional().default(!1),pinlabeltextaligncenter:Te().optional().default(!1),pinlabeltextalignright:Te().optional().default(!1),pinlabelverticallyinverted:Te().optional().default(!1),pinlabelorthogonal:Te().optional().default(!1),nosquareplating:Te().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Te().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Te().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Te().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const e=Q3t(t);return{...t,pinlabelAnchorSide:e,male:t.male??!t.female,female:t.female??!1,smd:t.smd??t.surfacemount??!1,rightangle:t.rightangle??!1}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:wn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),h4o=t=>{const e=u4o.parse(t),{p:n,id:o,od:i,rows:r,num_pins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:A,pinlabelorthogonal:c,pinlabeltextalignleft:l,pinlabeltextalignright:g,nopinlabels:u,doublesidedpinlabel:d,bottomsidepinlabel:h}=e;let _="center";l?_="left":g&&(_="right");const m=[],p=Math.ceil(s/r),I=(r-1)*n,f=I/2,C=-n,y=({xoff:re,yoff:X,od:te,anchorSide:se,smd:le,pw:ue,pl:Ce})=>{let ye=0,Be=0;if(le){const de=te/5;switch(se){case"right":ye=ue/2+de;break;case"top":Be=Ce/2+de;break;case"bottom":Be=-(Ce/2+de);break;case"left":ye=-(ue/2+de);break}}else{const de=te*.75;switch(se){case"right":ye=de;break;case"top":Be=de;break;case"bottom":Be=-de;break;case"left":ye=-de;break}}return{anchor_x:re+ye,anchor_y:X+Be}},E=(re,X,te)=>{e.smd?m.push(Oo(re,X,te,e.pw,e.pl)):re===1&&!e.nosquareplating?m.push(Sy({pn:re,x:X,y:te,holeDiameter:o,rectPadWidth:i,rectPadHeight:i})):m.push(Js(re,X,te,o,i));const{anchor_x:se,anchor_y:le}=y({xoff:X,yoff:te,od:i,anchorSide:a,smd:e.smd,pw:e.pw,pl:e.pl});u||(h?m.push(b6({fs:i/5,pn:re,anchor_x:se,anchor_y:le,textalign:_,orthogonal:c,verticallyinverted:A,layer:"bottom"})):m.push(b6({fs:i/5,pn:re,anchor_x:se,anchor_y:le,textalign:_,orthogonal:c,verticallyinverted:A,layer:"top"})),d&&m.push(b6({fs:i/5,pn:re,anchor_x:se,anchor_y:le,textalign:_,orthogonal:c,verticallyinverted:A,layer:"bottom"})))},B=new Set,Q=r>2&&p>2;if(r===1){const re=-((s-1)/2)*n;for(let X=0;X<s;X++){const te=X+1,se=re+X*n,le=`${se},0`;if(B.has(le))throw new Error(`Overlap at ${le}`);B.add(le),E(te,se,0)}}else if(Q){const re=-((p-1)/2)*n;let X=1;for(let te=0;te<r&&X<=s;te++)for(let se=0;se<p&&X<=s;se++){const le=re+se*n,ue=f+te*C,Ce=`${le},${ue}`;if(B.has(Ce))throw new Error(`Overlap at ${Ce}`);B.add(Ce),E(X++,le,ue)}}else{const re=-((p-1)/2)*n;let X=1,te=0,se=r-1,le=0,ue=p-1;for(;X<=s&&te<=se&&le<=ue;){for(let Ce=te;Ce<=se&&X<=s;Ce++){const ye=re+le*n,Be=f+Ce*C,de=`${ye},${Be}`;if(B.has(de))throw new Error(`Overlap at ${de}`);B.add(de),E(X++,ye,Be)}le++;for(let Ce=le;Ce<=ue&&X<=s;Ce++){const ye=re+Ce*n,Be=f+se*C,de=`${ye},${Be}`;if(B.has(de))throw new Error(`Overlap at ${de}`);B.add(de),E(X++,ye,Be)}if(se--,le<=ue){for(let Ce=se;Ce>=te&&X<=s;Ce--){const ye=re+ue*n,Be=f+Ce*C,de=`${ye},${Be}`;if(B.has(de))throw new Error(`Overlap at ${de}`);B.add(de),E(X++,ye,Be)}ue--}if(te<=se){for(let Ce=ue;Ce>=le&&X<=s;Ce--){const ye=re+Ce*n,Be=f+te*C,de=`${ye},${Be}`;if(B.has(de))throw new Error(`Overlap at ${de}`);B.add(de),E(X++,ye,Be)}te++}}if(X-1<s)throw new Error(`Missing pins: assigned ${X-1}, expected ${s}`)}const b=pi(0,I/2+n,.5),D=e.smd?e.pw/2:i/2,R=e.smd?e.pl/2:i/2,w=(p-1)*n,H=w/2+D,G=I/2+R,K=w/2+n/2,U=I/2+n/2,q=Math.max(H+.25,K+.5),W=Math.max(G+.25,U+.5),ee={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*q,height:2*W,layer:"top"};return{circuitJson:[...m,b,ee],parameters:e}},d4o=[{x:-1.2,y:.83},{x:-.75,y:.83},{x:-.75,y:.95},{x:.75,y:.95},{x:.75,y:.83},{x:1.2,y:.83},{x:1.2,y:-.83},{x:.75,y:-.83},{x:.75,y:-.95},{x:-.75,y:-.95},{x:-.75,y:-.83},{x:-1.2,y:-.83}],_4o=hi.extend({fn:F(),num_pins:be(6).default(6),w:F().default("2.1mm"),h:F().default("2.45mm"),p:F().default("0.5mm"),pl:F().default("0.675mm"),pw:F().default("0.35mm"),string:F().optional()}),m4o=t=>{const e=_4o.parse({...t,fn:"sot563"}),n=Ae.parse(e.w),o=Ae.parse(e.h),i=Ae.parse(e.p),r=Ae.parse(e.pl),s=Ae.parse(e.pw),a=[];for(let h=0;h<6;h++){const{x:_,y:m}=S3t(h+1,n,i,r);a.push(Oo(h+1,_,m,r,s))}const A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:o/2},{x:n/2,y:o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-o/2},{x:n/2,y:-o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=S3t(1,n,i,r),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-r/2-.3,y:l.y},{x:l.x-r/2-.45,y:l.y+.15},{x:l.x-r/2-.45,y:l.y-.15},{x:l.x-r/2-.3,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},u=pi(0,o/2+.4,.25),d={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:d4o,layer:"top"};return{circuitJson:[...a,A,c,u,g,d],parameters:e}},S3t=(t,e,n,o)=>{const i=e/2-o/2;return t<=3?{x:-i,y:n-(t-1)*n}:{x:i,y:-n+(t-4)*n}},p4o=S6({p:"1.27mm",w:"3.9mm",legsoutside:!0}),I4o=t=>{const e=p4o.parse({...t,num_pins:8});return{circuitJson:DU(e),parameters:e}},f4o=S6({p:"1.27mm",w:"7.5mm",legsoutside:!0}),C4o=t=>{const e=f4o.parse({...t,num_pins:16});return{circuitJson:DU(e),parameters:e}},y4o=hi.extend({fn:F(),num_pins:be(3).default(3),w:F().default("1.2mm"),h:F().default("1.2mm"),pw:F().default("0.40mm"),pl:F().default("0.45mm"),p:F().default("0.575mm")}),E4o=t=>{const e=y4o.parse(t),n=B4o(e),o=pi(0,Ae.parse(e.h),.2),i=1.8,r=1.8,s={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:[{x:-i/2,y:r/2},{x:i/2,y:r/2},{x:i/2,y:-r/2},{x:-i/2,y:-r/2}],layer:"top"};return{circuitJson:[...n,o,s],parameters:e}},x4o=t=>{const{pn:e,p:n}=t;return e===1?{x:n,y:0}:e===2?{x:-n,y:-.4}:{x:-n,y:.4}},B4o=t=>{const e=[];for(let n=0;n<3;n++){const{x:o,y:i}=x4o({num_pins:t.num_pins,pn:n+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Oo(n+1,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Uf=t=>{const e=t.p??t.pad_spacing;if(e===void 0||t.pl===void 0||t.pw===void 0)throw new Error("Diode fabrication note requires p or pad_spacing, pl, and pw");const n=Ae.parse(e),o=Ae.parse(t.pl),i=Ae.parse(t.pw);return Q4o({minX:-n/2-o/2,maxX:n/2+o/2,minY:-i/2,maxY:i/2})},Q4o=t=>{const e=[],n=t.maxX-t.minX,o=t.maxY-t.minY,i=(t.minX+t.maxX)/2,r=(t.minY+t.maxY)/2,s=o*.28,a=s*2,A=n*.2,l=Math.min(A,a*1.25),g=i-l/2,u=i+l/2,d=l*.18,h=g+d,_=u-d,m=Math.max(Math.min(n,o)*.035,.01),p=Math.max(Math.min(n,o)*.25,.1);return e.push({type:"pcb_fabrication_note_path",pcb_fabrication_note_path_id:"diode_fabrication_note_anode_leg",pcb_component_id:"",layer:"top",stroke_width:m,route:[{x:g,y:r},{x:h,y:r}]},{type:"pcb_fabrication_note_path",pcb_fabrication_note_path_id:"diode_fabrication_note_triangle",pcb_component_id:"",layer:"top",stroke_width:m,route:[{x:h,y:r+s},{x:_,y:r},{x:h,y:r-s},{x:h,y:r+s}]},{type:"pcb_fabrication_note_path",pcb_fabrication_note_path_id:"diode_fabrication_note_cathode",pcb_component_id:"",layer:"top",stroke_width:m,route:[{x:_,y:r+s},{x:_,y:r-s}]},{type:"pcb_fabrication_note_path",pcb_fabrication_note_path_id:"diode_fabrication_note_cathode_leg",pcb_component_id:"",layer:"top",stroke_width:m,route:[{x:_,y:r},{x:u,y:r}]},{type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:"diode_fabrication_note_positive",pcb_component_id:"",layer:"top",font:"tscircuit2024",font_size:p,text:"+",anchor_position:{x:t.minX+n*.125,y:r},anchor_alignment:"center"},{type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:"diode_fabrication_note_negative",pcb_component_id:"",layer:"top",font:"tscircuit2024",font_size:p,text:"-",anchor_position:{x:t.maxX-n*.125,y:r},anchor_alignment:"center"}),e},S4o=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("2.36mm"),h:F().default("1.22mm"),pl:F().default("0.9mm"),pw:F().default("1.2mm"),p:F().default("3.30mm")}),b4o=t=>{const e=S4o.parse(t),n=Ae.parse(e.h),o=pi(0,n/4+.4,.3),s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.7,height:2.3,layer:"top"};return{circuitJson:P4o(e).concat(...Uf(e),o,s),parameters:e}},D4o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},P4o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=D4o({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.1125))}return e},v4o=hi.extend({fn:F(),p:Ae.optional().default("2.54mm"),id:Ae.optional().default("0.7mm"),od:Ae.optional().default("1.4mm")}),M4o=t=>{const e=v4o.parse(t),{p:n,id:o,od:i}=e,r=[Js(1,-n/2,0,o,i),Js(2,n/2,0,o,i)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2+i+o/2,y:0},{x:n/2-i-o/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},a=pi(0,1.5,.5),A=-n/2,c=n/2,l=i/2,g=i/2,u=A-l-.35,d=c+l+.26,h=g+.35,_=u,m=d,p=h,I={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:ZC([{minX:u,maxX:d,minY:-p,maxY:p},{minX:_,maxX:m,minY:-h,maxY:h}]),layer:"top"};return{circuitJson:[...r,s,a,I],parameters:e}},w4o=(t,e,n,o,i,r=.1)=>{const s=[],a=[],A=Math.max(1,Math.ceil(Math.PI*n/r)),c=Math.PI/A;for(let l=0;l<=A;l++){const g=l*c,u=t+Math.cos(g)*n,d=e+Math.sin(g)*n;u<t-o&&d>=e-i/2&&d<=e+i/2||s.push({x:u,y:d})}for(let l=0;l<=A;l++){const g=Math.PI+l*c,u=t+Math.cos(g)*n,d=e+Math.sin(g)*n;u<t-o&&d>=e-i/2&&d<=e+i/2||a.push({x:u,y:d})}return{topArc:s,bottomArc:a}},N4o=hi.extend({fn:F(),p:Ae.optional().default("5mm"),id:Ae.optional().default("0.8mm"),od:Ae.optional().default("1.6mm"),ceramic:Te().optional(),electrolytic:Te().optional(),polarized:Te().optional()}),R4o=t=>{const e=N4o.parse(t),{p:n,id:o,od:i}=e;o===.8&&i===1.6&&(e.id=n===5?.8:n*.25,e.od=n===5?1.6:n*.5);const r=[Js(1,-n/2,0,e.id,e.od),Js(2,n/2,0,e.id,e.od)],s=n+.1,{topArc:a,bottomArc:A}=w4o(0,0,s,e.od/2,e.od),c=.02*n,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:c,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:A,stroke_width:c,pcb_silkscreen_path_id:""},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:s},{x:0,y:-s}],stroke_width:c,pcb_silkscreen_path_id:""},d=.1*n,h=-(n+d+.04*n),_=s-d-.08*n,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h-d,y:_},{x:h+d,y:_}],stroke_width:c,pcb_silkscreen_path_id:""},p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h,y:_-d},{x:h,y:_+d}],stroke_width:c,pcb_silkscreen_path_id:""},I=pi(0,s+.12*n,.1*n),f=[...r,l,g,u,I];(e.electrolytic===!0||e.polarized===!0)&&f.push(m,p);const y=n+.25,E={type:"pcb_courtyard_circle",pcb_courtyard_circle_id:"",pcb_component_id:"",center:{x:0,y:0},radius:y,layer:"top"};return f.push(E),{circuitJson:f,parameters:e}},D6=(t,e={})=>({type:"pcb_silkscreen_path",layer:e.layer||"top",pcb_component_id:e.pcb_component_id||"",pcb_silkscreen_path_id:e.pcb_silkscreen_path_id||"",route:t,stroke_width:e.stroke_width||.1}),T4o=hi.extend({fn:be("pushbutton"),w:Ae.default(4.5),h:Ae.default(6.5),id:Ae.default(1),od:Ae.default(1.2)}),k4o=t=>{const e=T4o.parse(t),n=e.w,o=e.h,i=e.id,r=[Js(1,-n/2,o/2,i,i*1.5),Js(2,-n/2,-o/2,i,i*1.5),Js(3,n/2,-o/2,i,i*1.5),Js(4,n/2,o/2,i,i*1.5)],s=[D6([{x:-n/2,y:-o/2},{x:-n/2,y:o/2}]),D6([{x:n/2,y:-o/2},{x:n/2,y:o/2}]),D6([{x:-n/2,y:0},{x:-n/5,y:0},{x:n/5*1/Math.sqrt(2),y:o/8}]),D6([{x:n/2,y:0},{x:n/5,y:0}])],a=pi(0,o/2+.4,.5),A=i*1.5/2,c=n,l=o,g=c/2+A,u=l/2+A,d=g+.5,h=u+.5,_={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*d,height:2*h,layer:"top"};return{circuitJson:[...r,...s,a,_],parameters:e}},b3t=hi.extend({fn:F(),w:Ae.default("22.58mm"),h:Ae.optional(),left:Ae.optional().default(20),right:Ae.optional().default(20),top:Ae.optional().default(2),bottom:Ae.optional().default(2),p:Ae.default(Ae.parse("2.54mm")),pw:Ae.default(Ae.parse("1.6mm")),pl:Ae.default(Ae.parse("2.4mm")),innerhole:Te().default(!1),innerholeedgedistance:Ae.default(Ae.parse("1.61mm")),silkscreenlabels:Te().default(!1),silkscreenlabelmargin:Ae.default(Ae.parse("0.1mm"))}),F4o=t=>{const e=b3t.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},Mie=(t,e,n)=>{let o=[];return n==="right"&&(o=[{x:t+1/2,y:e},{x:t-1/2,y:e+.6/2},{x:t-1/2,y:e-.6/2},{x:t+1/2,y:e}]),n==="left"&&(o=[{x:t-1/2,y:e},{x:t+1/2,y:e+.6/2},{x:t+1/2,y:e-.6/2},{x:t-1/2,y:e}]),n==="top"&&(o=[{x:t,y:e+1/2},{x:t-.6/2,y:e-1/2},{x:t+.6/2,y:e-1/2},{x:t,y:e+1/2}]),n==="bottom"&&(o=[{x:t,y:e-1/2},{x:t-.6/2,y:e+1/2},{x:t+.6/2,y:e+1/2},{x:t,y:e-1/2}]),o},L4o=t=>{const e=b3t.parse(t),n=e.h??F4o(e),o=[],i=[],r=[];let s=[];const a=1,A=a,c=e.left+e.right+(e.bottom??0)+(e.top??0),g=`pin${c}`.length*.7/2;if(e.right){const _=-((e.right-1)/2)*e.p;for(let m=0;m<e.right;m++){if(m===0&&!e.left&&!e.bottom&&!e.silkscreenlabels&&(s=Mie(e.w/2-e.pl*1.4,_+m*e.p,"right")),o.push(Oo(m+1+e.left+(e.bottom??0),e.w/2-e.pl/2,_+m*e.p,e.pl,e.pw)),e.silkscreenlabels){const p=m+1+e.left+(e.bottom??0),I=`pin${p}`;r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${p}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl-(g+e.silkscreenlabelmargin),y:_+m*e.p},text:I,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(i.push(Js(m+1+e.left+(e.bottom??0)+c,e.w/2,_+m*e.p,a,A)),i.push(Js(m+1+e.left+(e.bottom??0)+c*2,e.w/2-e.innerholeedgedistance,_+m*e.p,a,A)))}}if(e.left){const _=(e.left-1)/2*e.p;for(let m=0;m<e.left;m++){if(m===0&&!e.silkscreenlabels&&(s=Mie(-e.w/2+e.pl*1.4,_-m*e.p,"left")),o.push(Oo(m+1,-e.w/2+e.pl/2,_-m*e.p,e.pl,e.pw)),e.silkscreenlabels){const p=m+1,I=`pin${p}`;r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${p}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl+(g+e.silkscreenlabelmargin),y:_-m*e.p},text:I,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(i.push(Js(m+1+c,-e.w/2,_-m*e.p,a,A)),i.push(Js(m+1+c*2,-e.w/2+e.innerholeedgedistance,_-m*e.p,a,A)))}}if(e.top){const _=(e.top-1)/2*e.p;for(let m=0;m<e.top;m++){if(m===0&&!e.left&&!e.bottom&&!e.right&&!e.silkscreenlabels&&(s=Mie(_-m*e.p,n/2-e.pl*1.4,"top")),o.push(Oo(m+1+e.left+e.right+(e.bottom??0),_-m*e.p,n/2-e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const p=m+1+e.left+e.right+(e.bottom??0),I=`pin${p}`;r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${p}`,pcb_component_id:"1",layer:"top",anchor_position:{x:_-m*e.p,y:n/2-e.pl-(g+e.silkscreenlabelmargin)},text:I,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}e.innerhole&&(i.push(Js(m+1+e.left+e.right+(e.bottom??0)+c,_-m*e.p,n/2,a,A)),i.push(Js(m+1+e.left+e.right+(e.bottom??0)+c*2,_-m*e.p,n/2-e.innerholeedgedistance,a,A)))}}if(e.bottom){const _=-((e.bottom-1)/2)*e.p;for(let m=0;m<e.bottom;m++){if(m===0&&!e.left&&!e.silkscreenlabels&&(s=Mie(_+m*e.p,-n/2+e.pl*1.4,"bottom")),o.push(Oo(m+1+e.left,_+m*e.p,-n/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const p=m+1+e.left,I=`pin${p}`;r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${p}`,pcb_component_id:"1",layer:"top",anchor_position:{x:_+m*e.p,y:-n/2+e.pl+(g+e.silkscreenlabelmargin)},text:I,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}e.innerhole&&(i.push(Js(m+1+e.left+c,_+m*e.p,-n/2,a,A)),i.push(Js(m+1+e.left+c*2,_+m*e.p,-n/2+e.innerholeedgedistance,a,A)))}}const u={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},d={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2,y:n/2},{x:e.w/2,y:n/2},{x:e.w/2,y:-n/2},{x:-e.w/2,y:-n/2},{x:-e.w/2,y:n/2}],stroke_width:.1,layer:"top"},h=pi(0,n/1.8,n/25);return{circuitJson:[...o,...i,...r,d,...e.silkscreenlabels?[]:[u],h],parameters:e}},D3t=hi.extend({fn:F(),w:Ae.default("22.58mm"),h:Ae.optional(),left:Ae.optional().default(20),right:Ae.optional().default(20),top:Ae.optional().default(2),bottom:Ae.optional().default(2),p:Ae.default(Ae.parse("2.54mm")),pw:Ae.default(Ae.parse("1.6mm")),pl:Ae.default(Ae.parse("3.2mm")),innerhole:Te().default(!1),innerholeedgedistance:Ae.default(Ae.parse("1.61mm"))}),H4o=t=>{const e=D3t.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},G4o=(t,e,n,o=1,i=.6)=>{const r=o/2,s=i/2;return{left:[{x:t+r,y:e},{x:t-r,y:e+s},{x:t-r,y:e-s},{x:t+r,y:e}],right:[{x:t-r,y:e},{x:t+r,y:e+s},{x:t+r,y:e-s},{x:t-r,y:e}],top:[{x:t,y:e-r},{x:t-s,y:e+r},{x:t+s,y:e+r},{x:t,y:e-r}],bottom:[{x:t,y:e+r},{x:t-s,y:e-r},{x:t+s,y:e-r},{x:t,y:e+r}]}[n]},O4o=t=>{const e=D3t.parse(t),n=e.h??H4o(e),o=[],i=[],r=[],s=1,a=1.2,A=e.left+e.right+(e.bottom??0)+(e.top??0);let c=[],l=1;if(e.left){const h=(e.left-1)/2*e.p;for(let _=0;_<e.left;_++)_===0&&(c=G4o(-e.w/2-e.pl/2,h-_*e.p,"left")),o.push(Oo(l,-e.w/2+e.pl/2,h-_*e.p,e.pl,e.pw)),i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${l}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl/2-4.5,y:h-_*e.p},text:`pin${l}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),l++,e.innerhole&&r.push(Js(l+A,-e.w/2+e.innerholeedgedistance,h-_*e.p,s,a))}if(e.bottom){const h=(e.bottom-1)/2*e.p;for(let _=e.bottom-1;_>=0;_--)o.push(Oo(l,h-_*e.p,-n/2+e.pl/2,e.pw,e.pl)),i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${l}`,pcb_component_id:"1",layer:"top",anchor_position:{x:h-_*e.p,y:-n/2+e.pl/2-3.2},text:`pin${l}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),l++,e.innerhole&&r.push(Js(l+A,h-_*e.p,-n/2+e.innerholeedgedistance,s,a))}if(e.right){const h=-((e.right-1)/2)*e.p;for(let _=0;_<e.right;_++)o.push(Oo(l,e.w/2-e.pl/2,h+_*e.p,e.pl,e.pw)),i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${l}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl/2+3.7,y:h+_*e.p},text:`pin${l}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),l++,e.innerhole&&r.push(Js(l+A,e.w/2-e.innerholeedgedistance,h+_*e.p,s,a))}if(e.top){const h=-((e.top-1)/2)*e.p;for(let _=e.top-1;_>=0;_--)o.push(Oo(l,h+_*e.p,n/2-e.pl/2,e.pw,e.pl)),i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${l}`,pcb_component_id:"1",layer:"top",anchor_position:{x:h+_*e.p,y:n/2-e.pl/2+3.2},text:`pin${l}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),l++,e.innerhole&&r.push(Js(l+A,h+_*e.p,n/2-e.innerholeedgedistance,s,a))}const g={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:c,stroke_width:.1},u={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:n/2+e.pl/3}],stroke_width:.1,layer:"top"},d=pi(0,n/1.8,n/25);return{circuitJson:[...r,...o,...i,u,g,d],parameters:e}},K4o=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),LT(t)),P3t=hi.extend({fn:F(),w:Ae.default("10mm"),h:Ae.optional(),left:Ae.optional().default(20),right:Ae.optional().default(20),top:Ae.optional().default(0),bottom:Ae.optional().default(0),p:Ae.default(Ae.parse("2.54mm")),id:Ae.optional().default(Ae.parse("1mm")),od:Ae.optional().default(Ae.parse("1.5mm"))}),U4o=t=>{const e=P3t.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},wie=(t,e,n,o=1,i=.6)=>{const r=o/2,s=i/2;return{left:[{x:t+r,y:e},{x:t-r,y:e+s},{x:t-r,y:e-s},{x:t+r,y:e}],right:[{x:t-r,y:e},{x:t+r,y:e+s},{x:t+r,y:e-s},{x:t-r,y:e}],top:[{x:t,y:e-r},{x:t-s,y:e+r},{x:t+s,y:e+r},{x:t,y:e-r}],bottom:[{x:t,y:e+r},{x:t-s,y:e-r},{x:t+s,y:e-r},{x:t,y:e+r}]}[n]},Y4o=t=>{const e=P3t.parse(t),n=e.h??U4o(e),o=[],i=e.id,r=e.od;let s=[];if(e.right){const l=-((e.right-1)/2)*e.p;for(let g=0;g<e.right;g++)g===0&&!e.left&&!e.bottom&&(s=wie(e.w/2+r*1.4,l+g*e.p,"right")),o.push(Js(g+1+e.left+(e.bottom??0),e.w/2,l+g*e.p,i,r))}if(e.left){const l=-((e.left-1)/2)*e.p;for(let g=0;g<e.left;g++)g===e.left-1&&(s=wie(-e.w/2-r*1.4,l+g*e.p,"left")),o.push(Js(g+1,-e.w/2,l+g*e.p,i,r))}if(e.top){const l=-((e.top-1)/2)*e.p;for(let g=0;g<e.top;g++)g===e.top-1&&!e.left&&!e.bottom&&!e.right&&(s=wie(l+g*e.p,n/2+r*1.4,"top")),o.push(Js(g+1+e.right+(e.bottom??0)+e.left,l+g*e.p,n/2,i,r))}if(e.bottom){const l=-((e.bottom-1)/2)*e.p;for(let g=0;g<e.bottom;g++)g===0&&!e.left&&(s=wie(l+g*e.p,-n/2-r*1.4,"bottom")),o.push(Js(g+1+e.left,l+g*e.p,-n/2,i,r))}const a={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:-e.w/2-r,y:n/2+r},{x:e.w/2+r,y:n/2+r},{x:e.w/2+r,y:-n/2-r},{x:-e.w/2-r,y:-n/2-r},{x:-e.w/2-r,y:n/2+r}],stroke_width:.1,layer:"top"},c=pi(0,n/1.7,n/25);return{circuitJson:[...o,A,c,a],parameters:e}},z4o=t=>{const{centerX:e,centerY:n,straightHalfLength:o,radius:i,arcSegmentCount:r=9,orientation:s="horizontal"}=t;if(o<0)throw new Error("Capsule straightHalfLength must be non-negative");if(i<=0)throw new Error("Capsule radius must be positive");if(r<2)throw new Error("Capsule arcSegmentCount must be at least 2");if(s==="horizontal"){const g=e-o,u=e+o,d=Array.from({length:r+1},(_,m)=>{const p=Math.PI/2-m*Math.PI/r;return{x:u+Math.cos(p)*i,y:n+Math.sin(p)*i}}),h=Array.from({length:r+1},(_,m)=>{const p=-Math.PI/2+m*Math.PI/r;return{x:g-Math.cos(p)*i,y:n+Math.sin(p)*i}});return[{x:g,y:n+i},{x:u,y:n+i},...d.slice(1,-1),{x:u,y:n-i},{x:g,y:n-i},...h.slice(1,-1)]}const a=n-o,A=n+o,c=Array.from({length:r+1},(g,u)=>{const d=Math.PI-u*Math.PI/r;return{x:e+Math.cos(d)*i,y:A+Math.sin(d)*i}}),l=Array.from({length:r+1},(g,u)=>{const d=u*Math.PI/r;return{x:e+Math.cos(d)*i,y:a-Math.sin(d)*i}});return[{x:e-i,y:a},{x:e-i,y:A},...c.slice(1,-1),{x:e+i,y:A},{x:e+i,y:a},...l.slice(1,-1)]},v3t=(t,e,n,o)=>Array.from({length:25},(i,r)=>{const s=r/24*Math.PI-Math.PI/2;return{x:t+(o==="right"?1:-1)*Math.cos(s)*n,y:e+Math.sin(s)*n}}),V4o=hi.extend({fn:F(),p:Ae.optional().default("4.88mm"),id:Ae.optional().default("0.8mm"),od:Ae.optional().default("1.5mm"),w:Ae.optional().default("5.6mm"),h:Ae.optional().default("3.5mm")}),J4o=t=>{const e=V4o.parse(t),{p:n,id:o,od:i,w:r,h:s}=e,a=s/2,A=[Js(1,-n/2,0,o,i),Js(2,n/2,0,o,i)],c=v3t(-r/2,0,a,"left"),l=v3t(r/2,0,a,"right"),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...c,...c.slice(1).reverse(),{x:-r/2,y:-s/2},{x:r/2,y:-s/2},...l,{x:r/2,y:s/2},{x:-r/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},u=pi(0,n/4,.5),h=n/2+i/2,_=Math.max(s/2+.25,r/2+.03),m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:z4o({centerX:0,centerY:0,straightHalfLength:h,radius:_,arcSegmentCount:9}),layer:"top"};return{circuitJson:[...A,g,u,m],parameters:e}};hi.extend({w:Ae,h:Ae});var q4o=t=>{const{w:e,h:n}=t,o=iA(e),i=iA(n);return{circuitJson:[Oo(1,0,0,o,i),pi(0,i/2+.5,.2)],parameters:t}},Rv=(t,e,n,o,i,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:e,y:n,outer_width:iA(i),outer_height:iA(r),hole_width:iA(o),hole_height:iA(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),W4o=[{x:-2.73,y:3.71},{x:-2.73,y:-1.03},{x:2.73,y:-1.03},{x:2.73,y:3.71}],j4o=hi.extend({fn:F(),num_pins:Nn([be(3),be(2)]).default(3),p:F().default("1.27mm"),id:F().default("0.72mm"),od:F().default("0.95mm"),w:F().default("4.5mm"),h:F().default("4.5mm"),inline:Te().default(!1),string:F().optional()}),X4o=(t,e,n)=>Array.from({length:25},(o,i)=>{const r=i/24*Math.PI;return{x:t+Math.cos(r)*n,y:e+Math.sin(r)*n}}),$4o=t=>{const e=t.string?.match(/^to92_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=j4o.parse({...t,num_pins:n}),{p:i,id:r,od:s,w:a,h:A,inline:c}=o,l=Number.parseFloat(A)/2,g=Number.parseFloat(i),u=Number.parseFloat(r),d=Number.parseFloat(s),h=d,_=d*(1.5/1.05);let m=[];if(o.num_pins===3)c?m=[Sy({pn:1,x:-g,y:l-g,holeDiameter:u,rectPadWidth:d,rectPadHeight:_}),Rv(2,0,l-g,u,h,_),Rv(3,g,l-g,u,h,_)]:m=[Sy({pn:1,x:-g,y:l-g,holeDiameter:u,rectPadWidth:d,rectPadHeight:d}),Js(2,0,l,u,d),Js(3,g,l-g,u,d)];else if(o.num_pins===2)m=[Sy({pn:1,x:-g,y:l-g,holeDiameter:u,rectPadWidth:h,rectPadHeight:_}),Rv(2,g,l-g,u,h,_)];else throw new Error("Invalid number of pins for TO-92");const p=Number.parseFloat(a)/2,I=X4o(0,l,p),f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...I,{x:-p,y:0},{x:p,y:0},I[0]],stroke_width:.1,pcb_silkscreen_path_id:""},C=pi(0,l+1,.5),y={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:W4o,layer:"top"};return{circuitJson:[...m,f,C,y],parameters:o}},Z4o=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("2.15mm"),h:F().default("0.7mm"),pl:F().default("0.6mm"),pw:F().default("0.7mm"),p:F().default("1.4mm")}),e5o=t=>{const e=Z4o.parse(t),n=pi(0,Ae.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2+.2},{x:-Ae.parse(e.w)/2-.2,y:Ae.parse(e.h)/2+.2},{x:-Ae.parse(e.w)/2-.2,y:-Ae.parse(e.h)/2-.2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2.5,height:1.4,layer:"top"};return{circuitJson:n5o(e).concat(...Uf(e),o,n,s),parameters:e}},t5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},n5o=t=>{const e=[],n=Ae.parse(t.p),o=Ae.parse(t.pl),i=Ae.parse(t.pw),r=.075;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=t5o({pn:s,p:n});e.push(Oo(s,a,A,o,i,r))}return e},o5o=S6({w:"7.05mm",p:"1.27mm",pw:"0.65mm",pl:"1.975mm"}),i5o=t=>{const e=o5o.parse(t),n=[];for(let u=0;u<e.num_pins;u++){const{x:d,y:h}=gwe({num_pins:e.num_pins,pn:u+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Oo(u+1,d,h,e.pl??"1.5mm",e.pw??"0.6mm"))}const o=(e.num_pins/2-1)*e.p+e.pw,i=pi(0,o/2+1,o/12),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-e.w/3,y:o/2+.4},{x:e.w/3,y:o/2+.4}],stroke_width:.1},s=(e.num_pins/2-1)*e.p+e.pw,a=e.w/2-1.395,A=e.w/2+.255,c=s/2+.25,l=s/2+.5,g={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:ZC([{minX:-A,maxX:A,minY:-c,maxY:c},{minX:-a,maxX:a,minY:-l,maxY:l}])};return{circuitJson:[...n,i,r,g],parameters:e}},r5o=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("5.0mm"),h:F().default("2.30mm"),pl:F().default("1.25mm"),pw:F().default("2mm"),p:F().default("3.75mm")}),s5o=t=>{const e=r5o.parse(t),n=pi(0,Ae.parse(e.h)/2+1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2+.5,y:Ae.parse(e.h)/2+.5},{x:-Ae.parse(e.w)/2-.5,y:Ae.parse(e.h)/2+.5},{x:-Ae.parse(e.w)/2-.5,y:-Ae.parse(e.h)/2-.5},{x:Ae.parse(e.p)/2+.5,y:-Ae.parse(e.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:5.1,height:2.8,layer:"top"};return{circuitJson:A5o(e).concat(...Uf(e),o,n,s),parameters:e}},a5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},A5o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=a5o({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},c5o=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("4.4mm"),h:F().default("1.7mm"),pl:F().default("1.2mm"),pw:F().default("1.2mm"),p:F().default("2.8mm")}),l5o=t=>{const e=c5o.parse(t),n=pi(0,Ae.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.5,height:2.2,layer:"top"};return{circuitJson:u5o(e).concat(...Uf(e),o,n,s),parameters:e}},g5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},u5o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=g5o({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},h5o=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("3.30mm"),h:F().default("1.80mm"),pl:F().default("0.60mm"),pw:F().default("0.45mm"),p:F().default("2.1mm")}),d5o=t=>{const e=h5o.parse(t),n=pi(0,Ae.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.2,height:1.9,layer:"top"};return{circuitJson:m5o(e).concat(...Uf(e),o,n,s),parameters:e}},_5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},m5o=t=>{const e=[],n=Ae.parse(t.p),o=Ae.parse(t.pl),i=Ae.parse(t.pw),r=.05625;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=_5o({pn:s,p:n});e.push(Oo(s,a,A,o,i,r))}return e},p5o=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("1.4mm"),h:F().default("0.9mm"),pl:F().default("0.36mm"),pw:F().default("0.25mm"),p:F().default("0.85mm")}),I5o=t=>{const e=p5o.parse(t),n=Ae.parse(e.w),o=Ae.parse(e.h),i=Ae.parse(e.pl),r=Ae.parse(e.pw),s=Ae.parse(e.p),a=pi(0,o,.3),A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s/2+.15,y:o/2},{x:-n/2-.15,y:o/2},{x:-n/2-.15,y:-o/2},{x:s/2+.15,y:-o/2}],stroke_width:.1,pcb_silkscreen_path_id:""},c=s+i,l=r,g=n/2,u=o/2,d=c/2,h=l/2,_=Math.max(g,d),m=Math.max(u,h),p=Math.min(g,d),I=Math.min(u,h),f=_+.05,C=p-.055,y=m,E=I+.155,B={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:ZC([{minX:-f,maxX:f,minY:-E,maxY:E},{minX:-C,maxX:C,minY:-y,maxY:y}]),layer:"top"};return{circuitJson:C5o(e).concat(...Uf(e),A,a,B),parameters:e}},f5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},C5o=t=>{const e=[],n=Ae.parse(t.p),o=Ae.parse(t.pl),i=Ae.parse(t.pw),r=.03125;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=f5o({pn:s,p:n});e.push(Oo(s,a,A,o,i,r))}return e},y5o=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("1.3mm"),h:F().default("0.9mm"),pl:F().default("0.4mm"),pw:F().default("0.7mm"),p:F().default("0.7mm")}),E5o=t=>{const e=y5o.parse(t),n=pi(0,Ae.parse(e.h)+.1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2+.2,y:Ae.parse(e.h)/2+.2},{x:-Ae.parse(e.w)/2-.2,y:Ae.parse(e.h)/2+.2},{x:-Ae.parse(e.w)/2-.2,y:-Ae.parse(e.h)/2-.2},{x:Ae.parse(e.p)/2+.2,y:-Ae.parse(e.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:1.6,height:1.2,layer:"top"};return{circuitJson:B5o(e).concat(...Uf(e),o,n,s),parameters:e}},x5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},B5o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=x5o({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.025))}return e},Q5o=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("3.05mm"),h:F().default("1.4mm"),pl:F().default("0.5mm"),pw:F().default("0.5mm"),pad_spacing:F().default("2.2mm")}),S5o=t=>{const e=Q5o.parse(t),n=pi(0,Ae.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.pad_spacing)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.pad_spacing)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.2,height:1.9,layer:"top"};return{circuitJson:D5o(e).concat(...Uf(e),o,n,s),parameters:e}},b5o=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},D5o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=b5o({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.0625))}return e},P5o=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("4.4mm"),h:F().default("2.1mm"),pl:F().default("1.10mm"),pw:F().default("1.10mm"),p:F().default("2.8mm")}),v5o=t=>{const e=P5o.parse(t),n=pi(0,Ae.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.4,height:2.3,layer:"top"};return{circuitJson:w5o(e).concat(...Uf(e),o,n,s),parameters:e}},M5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},w5o=t=>{const e=[],n=Ae.parse(t.p),o=Ae.parse(t.pl),i=Ae.parse(t.pw),r=.125;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=M5o({pn:s,p:n});e.push(Oo(s,a,A,o,i,r))}return e},N5o=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("4.4mm"),h:F().default("2.1mm"),pl:F().default("0.91mm"),pw:F().default("1.22mm"),p:F().default("3.146mm")}),R5o=t=>{const e=N5o.parse(t),n=pi(0,Ae.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.9,height:2.7,layer:"top"};return{circuitJson:k5o(e).concat(...Uf(e),o,n,s),parameters:e}},T5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},k5o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=T5o({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},F5o=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("1.80mm"),h:F().default("1.00mm"),pl:F().default("0.66mm"),pw:F().default("0.5mm"),p:F().default("0.8mm")}),L5o=t=>{const e=F5o.parse(t),n=pi(0,Ae.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.1,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.1,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2.3,height:1.5,layer:"top"};return{circuitJson:G5o(e).concat(...Uf(e),o,n,s),parameters:e}},H5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},G5o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=H5o({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},O5o=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("6.2mm"),h:F().default("3.4mm"),pl:F().default("1.4mm"),pw:F().default("2.1mm"),p:F().default("4.4mm")}),K5o=t=>{const e=O5o.parse(t),n=pi(0,Ae.parse(e.h)/2+.4,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:6.3,height:3,layer:"top"};return{circuitJson:Y5o(e).concat(...Uf(e),o,n,s),parameters:e}},U5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Y5o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=U5o({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},M3t=(t,e)=>({type:"pcb_smtpad",points:e,layer:"top",shape:"polygon",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(n=>n.toString()):[t.toString()]}),z5o=[{x:-2.85,y:-2.5},{x:-2.85,y:2.5},{x:2.25,y:2.5},{x:2.25,y:-2.5}],V5o=[{x:-2.85,y:-2.5},{x:-2.85,y:2.5},{x:2.85,y:2.5},{x:2.85,y:-2.5}],J5o=[{x:.9,y:.5},{x:2.6,y:.5},{x:2.6,y:-.5},{x:.9,y:-.5},{x:.4,y:-1},{x:-.4,y:-1},{x:-.9,y:-.5},{x:-2.6,y:-.5},{x:-2.6,y:.5},{x:-.9,y:.5},{x:-.4,y:1},{x:.4,y:1}],q5o=[{x:2,y:-.8665},{x:-1.125,y:-.8665},{x:-1.125,y:-.45},{x:-2.6,y:-.45},{x:-2.6,y:.45},{x:-1.125,y:.45},{x:-1.125,y:.8665},{x:2,y:.8665}],W5o=hi.extend({fn:F(),num_pins:Nn([be(3),be(5)]).default(3),w:F().default("4.20mm"),h:F().default("4.80mm"),pl:F().default("1.3mm"),pw:F().default("0.9mm"),p:F().default("1.5mm"),string:F().optional()}),j5o=t=>{const e=Number.parseFloat(t.p),n=Number.parseFloat(t.pw),o=Number.parseFloat(t.w),i=Number.parseFloat(t.pl),r=-o/2+.15,s=o/2-1,a=Number.parseFloat(t.h)/2,A=[Oo(1,r,e,i,n),M3t(2,q5o),Oo(3,r,-e,i,n)],c=pi(0,a+.5,.3),l={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-s,y:a},{x:s,y:a},{x:s,y:a/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},g={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-s,y:-a},{x:s,y:-a},{x:s,y:-a/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},u={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:z5o,layer:"top"};return[...A,l,g,c,u]},X5o=t=>{const e=[Oo(1,-1.85,-1.5,1.5,.7),Oo(2,-1.85,1.5,1.5,.7),M3t(3,J5o),Oo(4,1.85,-1.5,1.5,.7),Oo(5,1.85,1.5,1.5,.7)],n=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.h)/2,i=pi(0,o+.5,.3),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n,y:o},{x:n,y:o}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n,y:-o},{x:n,y:-o}],type:"pcb_silkscreen_path",stroke_width:.1},a={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:V5o,layer:"top"};return[...e,r,s,i,a]},$5o=t=>{const e=t.string?.match(/^sot89_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=W5o.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:j5o(o),parameters:o};if(o.num_pins===5)return{circuitJson:X5o(o),parameters:o};throw new Error("Invalid number of pins for SOT89")},Z5o=hi.extend({fn:F(),p:Ae.optional().default("5.0mm"),id:Ae.optional().default("1.0mm"),od:Ae.optional().default("1.9mm"),w:Ae.optional().default("13mm"),h:Ae.optional().default("7mm"),num_pins:Ue().optional(),string:F().optional()}),w3t=t=>{const e=Z5o.parse(t),{id:n,od:o,w:i,h:r,string:s}=e,a=e.num_pins??Number.parseInt(s?.match(/^to220(?:_|-)(\d+)/i)?.[1]??"3"),A=-1,c=i/2,l=r/2,g=2.5,u=i*.4,d=Math.max(g,u/(a-1)),h=Array.from({length:a},(K,U)=>{const q=a%2===0?(U-a/2+.5)*d:(U-Math.floor(a/2))*d;return Js(U+1,q,A,n,o)}),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:-l},{x:c,y:-l},{x:c,y:l},{x:-c,y:l},{x:-c,y:-l}],stroke_width:.1,pcb_silkscreen_path_id:""},m=-l+2*r/3,p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:m},{x:c,y:m}],stroke_width:.1,pcb_silkscreen_path_id:""},I=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-i/6,y:m},{x:-i/6,y:l}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:i/6,y:m},{x:i/6,y:l}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=pi(0,r/2+.6,.5),C=Math.max(...h.map(K=>Math.abs(K.x)))+o/2,y=A+o/2,E=A-o/2,B=Math.max(C+.25,c-o*.59),Q=l-o*.63,b=E-(o/2+.01),D=-B,R=B,w=Math.min(b,E-.25),H=Math.max(Q,y+.25),G={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(D+R)/2,y:(w+H)/2},width:R-D,height:H-w,layer:"top"};return{circuitJson:[...h,_,p,...I,f,G],parameters:{...e,p:d}}},dwe=2.54,eDo=hi.extend({fn:F(),id:Ae.optional().default("1.2mm"),od:Ae.optional().default("1.905mm"),ph:Ae.optional().default("2mm"),w:Ae.optional().default("13mm"),h:Ae.optional().default("7mm"),num_pins:Ue().optional(),string:F().optional()}),tDo=t=>{const e=eDo.parse(t),n=e.num_pins??Number.parseInt(e.string?.match(/^to220f(?:_|-)(\d+)/i)?.[1]??"3"),o=w3t({...e,fn:"to220",string:e.string?.replace(/^to220f/i,"to220"),num_pins:n}),i=-1,r=Array.from({length:n},(a,A)=>{const c=n%2===0?(A-n/2+.5)*dwe:(A-Math.floor(n/2))*dwe;return A===0?Sy({pn:1,x:c,y:i,holeDiameter:e.id,rectPadWidth:e.od,rectPadHeight:e.ph}):Rv(A+1,c,i,iA(e.id),iA(e.od),iA(e.ph))}),s=o.circuitJson.filter(a=>a.type!=="pcb_plated_hole");return{circuitJson:[...r,...s],parameters:{...e,p:dwe,num_pins:n}}},nDo=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("5.40mm"),h:F().default("2.30mm"),pl:F().default("1.30mm"),pw:F().default("1.70mm"),p:F().default("3.5mm")}),oDo=t=>{const e=nDo.parse(t),n=pi(0,Ae.parse(e.h)/2+.4,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:5.3,height:2.2,layer:"top"};return{circuitJson:rDo(e).concat(o,n,s),parameters:e}},iDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},rDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=iDo({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},sDo=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("1.90mm"),h:F().default("1.33mm"),pl:F().default("0.5mm"),pw:F().default("0.7mm"),p:F().default("0.8mm")}),aDo=t=>{const e=sDo.parse(t),n=pi(0,Ae.parse(e.h)+.1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2+.1,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2+.1,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:1.8,height:1.2,layer:"top"};return{circuitJson:cDo(e).concat(...Uf(e),o,n,s),parameters:e}},ADo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},cDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=ADo({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.0625))}return e},lDo=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("7.0mm"),h:F().default("3.35mm"),pl:F().default("1.50mm"),pw:F().default("2.70mm"),p:F().default("4.8mm")}),gDo=t=>{const e=lDo.parse(t),n=pi(0,Ae.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:6.8,height:3.2,layer:"top"};return{circuitJson:hDo(e).concat(o,n,s),parameters:e}},uDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},hDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=uDo({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},dDo=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("3.0mm"),h:F().default("1.80mm"),pl:F().default("0.80mm"),pw:F().default("1.20mm"),p:F().default("1.6mm")}),_Do=t=>{const e=dDo.parse(t),n=pi(0,Ae.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.1,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.1,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2.9,height:1.7,layer:"top"};return{circuitJson:pDo(e).concat(o,n,s),parameters:e}},mDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},pDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=mDo({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.1))}return e},IDo=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("7.10mm"),h:F().default("3.40mm"),pl:F().default("2.50mm"),pw:F().default("1.80mm"),p:F().default("4.00mm")}),fDo=t=>{const e=IDo.parse(t),n=pi(0,Ae.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.5,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.5,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:7,height:3.5,layer:"top"};return{circuitJson:yDo(e).concat(o,n,s),parameters:e}},CDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},yDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=CDo({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},EDo=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("4.80mm"),h:F().default("2.10mm"),pl:F().default("1.30mm"),pw:F().default("1.40mm"),p:F().default("2.9mm")}),xDo=t=>{const e=EDo.parse(t),n=pi(0,Ae.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.7,height:2.3,layer:"top"};return{circuitJson:QDo(e).concat(o,n,s),parameters:e}},BDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},QDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=BDo({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},SDo=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("7.30mm"),h:F().default("4.40mm"),pl:F().default("2.50mm"),pw:F().default("2.30mm"),p:F().default("4.30mm")}),bDo=t=>{const e=SDo.parse(t),n=pi(0,Ae.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.1,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.1,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:7.3,height:4.5,layer:"top"};return{circuitJson:PDo(e).concat(o,n,s),parameters:e}},DDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},PDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=DDo({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},vDo=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("10.70mm"),h:F().default("6.60mm"),pl:F().default("2.50mm"),pw:F().default("3.30mm"),p:F().default("6.80mm")}),MDo=t=>{const e=vDo.parse(t),n=pi(0,3,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2-.8},{x:-Ae.parse(e.w)/2-.8,y:Ae.parse(e.h)/2-.8},{x:-Ae.parse(e.w)/2-.8,y:-Ae.parse(e.h)/2+.8},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:9.8,height:6.7,layer:"top"};return{circuitJson:NDo(e).concat(o,n,s),parameters:e}},wDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},NDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=wDo({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},RDo=hi.extend({fn:F(),num_pins:Ue().default(4),w:F().default("8.50mm"),h:F().default("6.90mm"),pl:F().default("2mm"),pw:F().default("1.5mm"),p:F().default("2.30mm"),string:F().optional()}),TDo=t=>{const e=t.string?.match(/^sot223_(\d+)/),n=e?Number.parseInt(e[1],10):4;if(n===8){const i=LDo.parse({...t,num_pins:n});return{circuitJson:DU(i),parameters:i}}const o=RDo.parse({...t,num_pins:n});if(o.num_pins===4)return{circuitJson:FDo(o),parameters:o};if(o.num_pins===5)return{circuitJson:GDo(o),parameters:o};if(o.num_pins===6)return{circuitJson:KDo(o),parameters:o};throw new Error("Invalid number of pins")},kDo=t=>{const{pn:e,w:n,p:o}=t;return e===1?{x:-n/2+1.1,y:o}:e===2?{x:-n/2+1.1,y:0}:e===3?{x:-n/2+1.1,y:-o}:{x:n/2-1.1,y:0}},FDo=t=>{const e=[];let n=0,o=0;for(let h=0;h<t.num_pins;h++){const{x:_,y:m}=kDo({num_pins:t.num_pins,pn:h+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),p=h===3?3.8:Number.parseFloat(t.pw),I=Number.parseFloat(t.pl);n=Math.max(n,Math.abs(_)+I/2),o=Math.max(o,Math.abs(m)+p/2),e.push(Oo(h+1,_,m,I,p))}const i=pi(0,0,.3),r=Number.parseFloat(t.w)/2-2.4,s=Number.parseFloat(t.h)/2,a={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r,y:s},{x:r,y:s},{x:r,y:s/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},A={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-r,y:-s},{x:r,y:-s},{x:r,y:-s/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},c=Number.parseFloat(t.w)/2,l=Number.parseFloat(t.h)/2,g=Math.max(n+.25,c+.15),u=Math.max(o+.25,l+.15),d={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*g,height:2*u,layer:"top"};return[...e,a,A,i,d]},LDo=S6({p:"0.90mm",w:"2.8mm",legsoutside:!0}),HDo=t=>{const{p:e,pn:n,w:o}=t;if(n===1)return{x:-o/2+1.2,y:e/2+e};if(n===2)return{x:-o/2+1.2,y:e/2};if(n===3)return{x:-o/2+1.2,y:-e/2};if(n===4)return{x:-o/2+1.2,y:-e/2-e};if(n===5)return{x:o/2-1,y:0};throw new Error("Invalid pin number")},GDo=t=>{const e=[];let n=0,o=0;for(let h=1;h<=t.num_pins;h++){const{x:_,y:m}=HDo({h:Number.parseFloat(t.h),p:1.5,pn:h,w:Number.parseFloat(t.w)});let p=Number.parseFloat(t.pw),I=Number.parseFloat(t.pl);h===5?(p=3.4,I=1.8):(p=1,I=2.2),n=Math.max(n,Math.abs(_)+I/2),o=Math.max(o,Math.abs(m)+p/2),e.push(Oo(h,_,m,I,p))}const i=Number.parseFloat(t.w)/2-2.4,r=Number.parseFloat(t.h)/2,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r},{x:i,y:r/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},a={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i,y:-r},{x:i,y:-r/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},A=pi(0,0,.3),c=Number.parseFloat(t.w)/2,l=Number.parseFloat(t.h)/2,g=Math.max(n+.25,c+.15),u=Math.max(o+.25,l+.15),d={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*g,height:2*u,layer:"top"};return[...e,s,a,A,d]},ODo=t=>{const{p:e,pn:n,w:o}=t;if(n===1)return{x:-o/2+1.2,y:2*e};if(n===2)return{x:-o/2+1.2,y:e};if(n===3)return{x:-o/2+1.2,y:0};if(n===4)return{x:-o/2+1.2,y:-e};if(n===5)return{x:-o/2+1.2,y:-2*e};if(n===6)return{x:o/2-1.175,y:0};throw new Error("Invalid pin number")},KDo=t=>{const e=[];let n=0,o=0;for(let h=1;h<=t.num_pins;h++){const{x:_,y:m}=ODo({h:Number.parseFloat(t.h),p:1.3,pn:h,w:8.7});let p=Number.parseFloat(t.pw),I=Number.parseFloat(t.pl);h===6?(p=3.4,I=2.15):(p=.6,I=2.2),n=Math.max(n,Math.abs(_)+I/2),o=Math.max(o,Math.abs(m)+p/2),e.push(Oo(h,_,m,I,p))}const i=Number.parseFloat(t.w)/2-2.4,r=Number.parseFloat(t.h)/2,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:r},{x:i,y:r},{x:i,y:r/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},a={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-r},{x:i,y:-r},{x:i,y:-r/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},A=pi(0,0,.3),c=Number.parseFloat(t.w)/2,l=Number.parseFloat(t.h)/2,g=Math.max(n+.25,c+.15),u=Math.max(o+.25,l+.15),d={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*g,height:2*u,layer:"top"};return[...e,s,a,A,d]},UDo=hi.extend({fn:F(),num_pins:Ue().default(3),w:F().default("3.40mm"),h:F().default("3.30mm"),pl:F().default("1mm"),pw:F().default("0.7mm"),p:F().default("1.2mm"),string:F().optional()}),YDo=t=>{const e=t.string?.match(/^sot23w_(\d+)/),n=e?Number.parseInt(e[1],3):3,o=UDo.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:VDo(o),parameters:o};throw new Error("Invalid number of pins")},zDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.95}:e===2?{x:-n,y:-.95}:{x:n,y:0}},VDo=t=>{const e=[];for(let p=0;p<t.num_pins;p++){const{x:I,y:f}=zDo({num_pins:t.num_pins,pn:p+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Oo(p+1,I,f,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=pi(0,Number.parseInt(t.h)/2+1,.3),o=Number.parseFloat(t.w)/2-1,i=Number.parseFloat(t.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o,y:i},{x:o+.3,y:i},{x:o+.3,y:i/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o,y:-i},{x:o+.3,y:-i},{x:o+.3,y:-i/2}],type:"pcb_silkscreen_path",stroke_width:.1},a=Number.parseFloat(t.p),A=Number.parseFloat(t.pl),c=Number.parseFloat(t.pw),l=Number.parseFloat(t.h),g=a+A/2,u=.95+c/2,d=l/2,h=g+.25,_=Math.max(u+.25,d+.09),m={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*h,height:2*_,layer:"top"};return[...e,r,s,n,m]},JDo=hi.extend({fn:F(),num_pins:Nn([be(3),be(2)]).default(3),p:F().default("1.27mm"),id:F().default("0.72mm"),od:F().default("0.95mm"),w:F().default("2.5mm"),h:F().default("4.2mm"),string:F().optional()}),qDo=t=>{const{p:e,id:n,od:o,w:i,h:r}=t,s=Number.parseFloat(r)/2,a=Number.parseFloat(e);return[Js(1,-a,s-a,n,o),Js(2,0,s-a,n,o),Js(3,a,s-a,n,o)]},WDo=t=>{const{p:e,id:n,od:o,h:i}=t,r=Number.parseFloat(i)/2,s=Number.parseFloat(e),a=Number.parseFloat(n),A=Number.parseFloat(o),c=A*(1.5/1.05);return[Sy({pn:1,x:-s,y:r-s,holeDiameter:a,rectPadWidth:A,rectPadHeight:c}),Rv(2,s,r-s,a,A,c)]},jDo=t=>{const e=t.string?.match(/^to92s_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=JDo.parse({...t,num_pins:n});let i=[];if(o.num_pins===3)i=qDo(o);else if(o.num_pins===2)i=WDo(o);else throw new Error("Invalid number of pins for TO-92");const r=Number.parseFloat(o.h)/2,s=Number.parseFloat(o.p),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-r,y:r-s},{x:-1.9,y:0},{x:1.9,y:0},{x:r,y:r-s},{x:1.5,y:Number.parseFloat(o.h)/2+.5},{x:-1.5,y:Number.parseFloat(o.h)/2+.5},{x:-r,y:r-s}],stroke_width:.1,pcb_silkscreen_path_id:""},A=pi(0,r+1,.5),c=Number.parseFloat(o.od),l=r-s,g=-s-c/2,u=s+c/2,d=l-c/2,h=l+c/2,_=-r,m=r,p=0,I=r+.5,f=Math.min(g,_)-.27,C=Math.max(u,m)+.13,y=Math.min(d,p)-.42,E=Math.max(h,I)+.08,B={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(f+C)/2,y:(y+E)/2},width:C-f,height:E-y,layer:"top"};return{circuitJson:[...i,a,A,B],parameters:o}},XDo=hi.extend({fn:F(),p:Ae.optional(),id:Ae.optional(),pw:Ae.optional(),pl:Ae.optional(),w:Ae.optional(),h:Ae.optional(),sh:Te().optional().describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Te().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),zh:Te().optional().describe("JST ZH (Through-hole) connector family. 1.5mm pitch wire-to-board."),string:F().optional()}),$Do=()=>({minX:Number.POSITIVE_INFINITY,maxX:Number.NEGATIVE_INFINITY,minY:Number.POSITIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY}),PU=({bounds:t,centerX:e,centerY:n,width:o,height:i})=>{const r=o/2,s=i/2;t.minX=Math.min(t.minX,e-r),t.maxX=Math.max(t.maxX,e+r),t.minY=Math.min(t.minY,n-s),t.maxY=Math.max(t.maxY,n+s)},ZDo={ph:{p:Ae.parse("2.2mm"),id:Ae.parse("0.70mm"),pw:Ae.parse("1.20mm"),pl:Ae.parse("1.20mm"),w:Ae.parse("6mm"),h:Ae.parse("5mm")},sh:{p:Ae.parse("1mm"),pw:Ae.parse("0.6mm"),pl:Ae.parse("1.55mm"),w:Ae.parse("5.8mm"),h:Ae.parse("7.8mm")},zh:{p:Ae.parse("1.5mm"),id:Ae.parse("0.73mm"),pw:Ae.parse("1.03mm"),pl:Ae.parse("1.73mm"),w:Ae.parse("3mm"),h:Ae.parse("3.5mm")}};function ePo(t){return t.sh?"sh":t.ph?"ph":t.zh?"zh":"ph"}function tPo({variant:t,numPins:e,p:n,id:o,pw:i,pl:r}){const s=[],a=$Do();let A=0;if(t==="ph"){const c=-((e-1)/2)*n;for(let l=0;l<e;l++){const g=c+l*n;s.push(Sy({pn:l+1,x:g,y:2,holeDiameter:o,rectPadWidth:i,rectPadHeight:r})),PU({bounds:a,centerX:g,centerY:2,width:i,height:r}),A=Math.max(A,r/2)}}else if(t==="zh"){const c=-((e-1)/2)*n;for(let l=0;l<e;l++){const g=c+l*n;l===0?s.push(Sy({pn:l+1,x:g,y:0,holeDiameter:o,rectPadWidth:i,rectPadHeight:r,rectBorderRadius:.12499977})):s.push(Rv(l+1,g,0,o,i,r)),PU({bounds:a,centerX:g,centerY:0,width:i,height:r}),A=Math.max(A,r/2)}}else{const c=-((e-1)/2)*n;for(let g=0;g<e;g++){const u=c+g*n;s.push(Oo(g+1,u,-1.325,i,r)),PU({bounds:a,centerX:u,centerY:-1.325,width:i,height:r}),A=Math.max(A,r/2)}const l=(e-1)/2*n+1.3;s.push(Oo(e+1,-l,1.22,1.2,1.8)),s.push(Oo(e+2,l,1.22,1.2,1.8)),PU({bounds:a,centerX:-l,centerY:1.22,width:1.2,height:1.8}),PU({bounds:a,centerX:l,centerY:1.22,width:1.2,height:1.8}),A=Math.max(A,.9)}return{pads:s,padBounds:a,maxPadHalfY:A}}function nPo({variant:t,w:e,h:n,numPins:o,p:i}){if(t==="ph")return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-3,y:3},{x:3,y:3},{x:3,y:-2},{x:-3,y:-2},{x:-3,y:3}],stroke_width:.1,pcb_silkscreen_path_id:""};if(t==="zh"&&o&&i){const r=(o-1)*i,s=-r/2-1.5,a=r/2+1.5,A=-n/2,c=n/2;return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:A},{x:a,y:A},{x:a,y:c},{x:s,y:c},{x:s,y:A}],stroke_width:.1,pcb_silkscreen_path_id:""}}else return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[],stroke_width:.1,pcb_silkscreen_path_id:""}}var oPo=t=>{const e=XDo.parse(t),n=ePo(e),o=ZDo[n],i=e.p??o.p,r=e.id??o.id,s=e.pw??o.pw,a=e.pl??o.pl,A=e.w??o.w,c=e.h??o.h;let l;const g=t.num_pins;typeof g=="number"&&(l=g);const u=typeof t.string=="string"?t.string:"",d=u.match(/(?:^|_)jst(\d+)(?:_|$)/),h=u.match(/(?:^|_)zh(\d+)(?:_|$)/);if(d&&d[1]){const re=Number.parseInt(d[1],10);Number.isNaN(re)||(l=re)}if(h&&h[1]){const re=Number.parseInt(h[1],10);Number.isNaN(re)||(l=re)}if(typeof l!="number")throw new Error(`JST requires an explicit pin count (e.g. jst6_sh or .jst(6))${e.string?`, from string "${e.string}"`:""}`);const _=tPo({variant:n,numPins:l,p:i,id:r,pw:s,pl:a}),{pads:m,padBounds:p,maxPadHalfY:I}=_,f=nPo({variant:n,w:A,h:c,numPins:l,p:i}),C=pi(0,c/2+1,.5),y=f.route.map(re=>re.x),E=f.route.map(re=>re.y),B=y.length>0&&E.length>0,Q=B?Math.min(p.minX,Math.min(...y)):p.minX,b=B?Math.max(p.maxX,Math.max(...y)):p.maxX,D=B?Math.min(p.minY,Math.min(...E)):p.minY,R=B?Math.max(p.maxY,Math.max(...E)):p.maxY,w=.5,H=.05,G=I+.085,K=Q-w,U=b+w,q=D-G,W=R+H,ee={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(K+U)/2,y:(q+W)/2},width:U-K,height:W-q,layer:"top"};return{circuitJson:[...m,f,C,ee],parameters:{...e,p:i,id:r,pw:s,pl:a,w:A,h:c,num_pins:l,sh:n==="sh",ph:n==="ph",zh:n==="zh"}}},iPo=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("3.30mm"),h:F().default("1.70mm"),pl:F().default("0.80mm"),pw:F().default("1mm"),p:F().default("1.90mm")}),rPo=t=>{const e=iPo.parse(t),n=pi(0,Ae.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.2,height:2,layer:"top"};return{circuitJson:aPo(e).concat(...Uf(e),o,n,s),parameters:e}},sPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},aPo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=sPo({pn:n,p:Number.parseFloat(t.p)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.1))}return e},APo=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"}}},cPo=hi.extend({fn:F(),num_pins:Nn([be(8),be(10)]).default(8),w:F().optional(),h:F().optional(),p:F().optional(),pl:F().optional(),pw:F().optional(),string:F().optional()}),lPo=t=>{const e=cPo.parse(t),n=APo(e.num_pins),o=Ae.parse(e.w||n.w),i=Ae.parse(e.h||n.h),r=Ae.parse(e.p||n.p),s=Ae.parse(e.pl||n.pl),a=Ae.parse(e.pw||n.pw),A=[],c=e.num_pins/2;for(let Q=0;Q<e.num_pins;Q++){const{x:b,y:D}=N3t(e.num_pins,Q+1,o,r),R=Q<c?Q+1:e.num_pins-(Q-c);A.push(Oo(R,b,D,s,a))}const l=o,g=i,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:g/2},{x:l/2,y:g/2}],stroke_width:.05,pcb_silkscreen_path_id:""},d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-g/2},{x:l/2,y:-g/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h=N3t(e.num_pins,1,l,r),_={x:h.x-.8,y:h.y},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:_.x-.4,y:_.y},{x:_.x-.7,y:_.y+.3},{x:_.x-.7,y:_.y-.3},{x:_.x-.4,y:_.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},p=pi(0,g/2+.5,.3),I=(e.num_pins/2-1)*r+a,f=o/2+.25,C=f+1.43,y=I/2+.255,E=i/2+.25,B={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:ZC([{minX:-C,maxX:C,minY:-y,maxY:y},{minX:-f,maxX:f,minY:-E,maxY:E}])};return{circuitJson:[...A,u,d,p,m,B],parameters:e}},N3t=(t,e,n,o)=>{const i=t/2,r=(e-1)%i,s=e<=i?-1:1,a=(i-1)/2-r;return{x:s*2.11,y:a*o}},gPo=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"}}},uPo=hi.extend({fn:F(),num_pins:Nn([be(8),be(10),be(12),be(16)]).default(8),w:F().optional(),h:F().optional(),p:F().optional(),pl:F().optional(),pw:F().optional(),string:F().optional()}),R3t=(t,e,n,o,i)=>{const r=t/2,s=(e-1)%r,a=e<=r?-1:1,A=(r-1)/2-s,c=Ae.parse("0.2mm");return{x:a*(n/2+i/2-c),y:A*o}},hPo=t=>{const e=uPo.parse(t),n=gPo(e.num_pins),o=Ae.parse(e.w||n.w),i=Ae.parse(e.h||n.h),r=Ae.parse(e.p||n.p),s=Ae.parse(e.pl||n.pl),a=Ae.parse(e.pw||n.pw),A=[];for(let B=0;B<e.num_pins;B++){const{x:Q,y:b}=R3t(e.num_pins,B+1,o,r,s);A.push(Oo(B+1,Q,b,s,a))}const c=o,l=i,g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:l/2},{x:c/2,y:l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:-l/2},{x:c/2,y:-l/2}],stroke_width:.05,pcb_silkscreen_path_id:""},d=R3t(e.num_pins,1,c,r,s),h={x:d.x-.8,y:d.y},_={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"},m=pi(0,l/2+.5,.3),p=(e.num_pins/2-1)*r+a,I=o/2+.25,f=I+1.43,C=p/2+.255,y=i/2+.25,E={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:ZC([{minX:-f,maxX:f,minY:-C,maxY:C},{minX:-I,maxX:I,minY:-y,maxY:y}])};return{circuitJson:[...A,g,u,m,_,E],parameters:e}},dPo=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("3.8mm"),h:F().default("1.65mm"),pl:F().default("1.2mm"),pw:F().default("1.2mm"),pad_spacing:F().default("2.6mm")}),_Po=t=>{const e=dPo.parse(t),n=pi(0,Ae.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.pad_spacing)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.pad_spacing)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.3,height:2.15,layer:"top"};return{circuitJson:pPo(e).concat(...Uf(e),o,n,s),parameters:e}},mPo=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},pPo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=mPo({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},IPo=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("3.20mm"),h:F().default("1.65mm"),pl:F().default("0.8mm"),pw:F().default("0.9mm"),pad_spacing:F().default("2.1mm")}),fPo=t=>{const e=IPo.parse(t),n=pi(0,Ae.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.pad_spacing)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.2,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.pad_spacing)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.7,height:2.15,layer:"top"};return{circuitJson:yPo(e).concat(...Uf(e),o,n,s),parameters:e}},CPo=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},yPo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=CPo({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Oo(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},EPo=hi.extend({fn:F(),num_pins:Nn([be(6),be(8)]).default(8),w:F().default("3mm"),h:F().default("3mm"),p:F().default("0.5mm"),pl:F().default("0.52mm"),pw:F().default("0.35mm"),epw:F().default("1.40mm"),eph:F().default("1.60mm"),string:F().optional(),ep:Te().default(!1)}),xPo=t=>{t.string&&t.string.includes("_ep")&&(t.ep=!0);const e=t.string?.match(/^son_(\d+)/),n=e?Number.parseInt(e[1],10):t.num_pins||8,o=EPo.parse({...t,num_pins:n}),i=Ae.parse(o.w),r=Ae.parse(o.h),s=Ae.parse(o.p),a=Ae.parse(o.pl),A=Ae.parse(o.pw),c=Ae.parse(o.epw),l=Ae.parse(o.eph),g=[];for(let w=0;w<o.num_pins;w++){const{x:H,y:G}=_we(o.num_pins,w+1,i,s);g.push(Oo(w+1,H,G,a,A))}o.ep&&g.push(Oo(o.num_pins+1,0,0,c,l));const u=i,d=r,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:d/2},{x:u/2,y:d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:-d/2},{x:u/2,y:-d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},m=_we(o.num_pins,1,u,s),p={x:m.x-.4,y:m.y},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:p.x-.4,y:p.y},{x:p.x-.7,y:p.y+.3},{x:p.x-.7,y:p.y-.3},{x:p.x-.4,y:p.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},f=pi(0,d/2+.5,.3),C=Math.abs(_we(o.num_pins,1,i,s).x),y=(o.num_pins/2-1)*s+A,E=C*2+a,B=i/2+.25,Q=E/2+.25,b=y/2+.25,D=r/2+.25,R={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:ZC([{minX:-Q,maxX:Q,minY:-b,maxY:b},{minX:-B,maxX:B,minY:-D,maxY:D}])};return{circuitJson:[...g,h,_,f,I,R],parameters:o}},_we=(t,e,n,o)=>{const i=t/2,r=(e-1)%i,s=e<=i?-1:1,a=(i-1)/2-r;return{x:s*Ae.parse("1.4mm"),y:a*o}},BPo=hi.extend({fn:F(),num_pins:Ue().optional().default(8),p:it.describe("pitch (distance between center of each pin)"),w:Ae.describe("width between vertical rows of pins"),grid:Pie.describe("width and height of the border of the footprint"),ep:Pie.default("0x0mm").describe("width and height of the central exposed thermal pad"),epx:Ae.default("0mm").describe("x offset of the center of the central exposed thermal pad"),pinw:Ae.describe("width of the pin pads"),pinh:Ae.describe("height of the pin pads")}),QPo=t=>{const e=BPo.parse(t),{num_pins:n,p:o,w:i,grid:r,ep:s,epx:a,pinw:A,pinh:c}=e;if(n%2!==0)throw new Error("invalid number of pins");const l=[];for(let B=0;B<n;B++){const{pinX:Q,pinY:b}=SPo({pinCount:n,pinIndex:B,width:i,pitch:o});l.push(Oo(B+1,Q,b,A,c))}s.x>0&&s.y>0&&l.push(Oo(e.num_pins+1,a,0,s.x,s.y));const g=bPo(r),u=pi(0,r.y/2+o,r.y/6),d=(n/2-1)*o+c,h=i+A,_=r.x/2+.25,m=h/2+.25,p=d/2+.25,I=d/2+.45+Math.max(0,.8-o),f=Math.min(r.y/2+.25,I),C=Math.max(0,.37-Math.max(0,m-_-.38)*1.4),y=Math.max(p,f-C),E={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:ZC([{minX:-m,maxX:m,minY:-y,maxY:y},{minX:-_,maxX:_,minY:-f,maxY:f}])};return{circuitJson:[...l,...g,u,E],parameters:e}},SPo=t=>{let e=0,n=0;const o=(t.pinCount/2-1)*t.pitch/2,i=t.pinCount/2;return t.pinIndex+1<=i?(e=t.pitch*t.pinIndex-o,n=0-t.width/2):(e=t.pitch*(t.pinCount-t.pinIndex-1)-o,n=t.width/2),{pinX:n,pinY:e}},bPo=t=>{const n=t.y/30;return[{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-t.x/2-.1,y:t.y/2+.1-n},{x:-t.x/2-.1,y:t.y/2+.1},{x:t.x/2+.1,y:t.y/2+.1},{x:t.x/2+.1,y:t.y/2+.1-n}],stroke_width:t.y/30},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-t.x/2-.1,y:-t.y/2-.1+n},{x:-t.x/2-.1,y:-t.y/2-.1},{x:t.x/2+.1,y:-t.y/2-.1},{x:t.x/2+.1,y:-t.y/2-.1+n}],stroke_width:t.y/30}]},DPo=t=>{const{num_pins:e,bridged:n,p:o=2.54,pw:i=1.5,ph:r=1.5}=t,s=Ae.parse(o),a=Ae.parse(i),A=Ae.parse(r),c=Math.min(A/4,.5),l=[];for(let D=0;D<e;D++)l.push(Oo(D+1,D*s,0,a,A));let g=[];if(n){const D=n.split("").map(Number);if(D.length>1)for(let R=0;R<D.length-1;R++){const w=D[R],H=D[R+1];if(typeof w=="number"&&typeof H=="number"&&!isNaN(w)&&!isNaN(H)){const G=(w-1)*s,K=(H-1)*s,U=Math.sign(K-G),q=G+U*(a/2),W=K-U*(a/2);g.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${w}}`,x:q,y:0,width:c,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${H}}`,x:W,y:0,width:c,layer:"top",route_type:"wire"}]})}}}const u=(e-1)*s+a+.7,d=A+1,h=(e-1)*s/2,_=0,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:h-u/2,y:_-d/2},{x:h+u/2,y:_-d/2},{x:h+u/2,y:_+d/2},{x:h-u/2,y:_+d/2},{x:h-u/2,y:_-d/2}],stroke_width:.15},I=_+d/2+.6,f=pi(h,I,.4),C=(e-1)*s,y=C/2+a/2,E=A/2,B=y+.5,Q=E+.5,b={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:C/2,y:0},width:2*B,height:2*Q,layer:"top"};return{circuitJson:[...l,...g,m,f,b],parameters:t}},T3t={fn:be("sot457"),num_pins:be(6).default(6),pillh:F().default("0.45mm"),pillw:F().default("1.45mm"),pl:F(),pw:F(),p:F(),wave:Te().optional(),reflow:Te().optional()},PPo=hi.extend({...T3t,h:F().default("2.5mm"),w:F().default("2.7mm"),pl:F().default("0.8mm"),pw:F().default("0.55mm"),p:F().default("0.95mm")}),vPo=hi.extend({...T3t,h:F().default("3mm"),w:F().default("4mm"),pillr:F().default("0.225mm"),pl:F().default("1.45mm"),pw:F().default("1.5mm"),p:F().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)})),s5=t=>Number.parseFloat(t.replace("mm","")),k3t=({pitch:t,width:e,pinNumber:n})=>{const r={1:{x:-e/2-.1,y:t},2:{x:-e/2-.1,y:0},3:{x:-e/2-.1,y:-t},4:{x:e/2+.1,y:-t},5:{x:e/2+.1,y:0},6:{x:e/2+.1,y:t}}[n];if(!r)throw new Error(`Invalid pin number: ${n}`);return r},F3t=t=>{const e=[],n=s5(t.p),o=s5(t.pl),i=s5(t.pw),r=s5(t.w),s=s5(t.h);if(t.wave){const _={1:({padWidth:m,padHeight:p})=>Oo(1,-n,n,p,m),2:({padWidth:m,padHeight:p})=>Oo(2,-n,-n,p,m),3:({padWidth:m,padHeight:p})=>vie(3,-n,0,s5(t.pillw),s5(t.pillh)),4:({padWidth:m,padHeight:p})=>vie(4,n,0,s5(t.pillw),s5(t.pillh)),5:({padWidth:m,padHeight:p})=>Oo(5,n,n,p,m),6:({padWidth:m,padHeight:p})=>Oo(6,n,-n,p,m)};for(let m=1;m<=t.num_pins;m++){const p=_[m];p&&e.push(p({padWidth:o,padHeight:i}))}}else for(let _=1;_<=t.num_pins;_++){const{x:m,y:p}=k3t({pitch:n,width:r,pinNumber:_});e.push(Oo(_,m,p,o,i))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r/3,y:s/2+n/1.3},{x:r/3,y:s/2+n/1.3}],stroke_width:.05},A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-r/3,y:-s/2-n/1.3},{x:r/3,y:-s/2-n/1.3}],stroke_width:.05},c=pi(0,s+.5,.3),l=k3t({pitch:n,width:r,pinNumber:1}),g=t.wave?1:.5,u=t.wave?.7:.3;l.x-=t.wave?i:i*1.7;const d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:l.x+g/2,y:l.y},{x:l.x-g/2,y:l.y+u/2},{x:l.x-g/2,y:l.y-u/2},{x:l.x+g/2,y:l.y}],stroke_width:.05};let h;if(t.wave){const _=2*n,m=2*n,p=_/2+i/2,I=m/2+o/2,f=p+.25,C=I+.25;h={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*f,height:2*C,layer:"top"}}else{const m=r/2+.1+o/2,p=n+i/2,I=r/2,f=s/2,C=m+.25,y=I+.08,E=p+.25,B=Math.max(f+.45,E);h={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:ZC([{minX:-C,maxX:C,minY:-E,maxY:E},{minX:-y,maxX:y,minY:-B,maxY:B}]),layer:"top"}}return[c,a,A,d,...e,h]},MPo=t=>{if(t.wave){const n=vPo.parse({...t,fn:"sot457"});return{circuitJson:F3t(n),parameters:n}}const e=PPo.parse(t);return{circuitJson:F3t(e),parameters:e}},wPo=[{x:-.8,y:.75},{x:.8,y:.75},{x:.8,y:-.75},{x:-.8,y:-.75}],NPo=hi.extend({fn:F(),num_pins:be(6).default(6),w:F().default("1.1mm"),h:F().default("1.45mm"),p:F().default("0.35mm"),pl:F().default("0.2mm"),pw:F().default("0.2mm"),string:F().optional()}),RPo=t=>{const e=NPo.parse({...t,fn:"sot963"}),n=Ae.parse(e.w),o=Ae.parse(e.h),i=Ae.parse(e.p),r=Ae.parse(e.pl),s=Ae.parse(e.pw),a=[];for(let h=0;h<6;h++){const{x:_,y:m}=L3t(h+1,n,i,r);a.push(Oo(h+1,_,m,r,s))}const A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:o/2},{x:n/2,y:o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-o/2},{x:n/2,y:-o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l=L3t(1,n,i,r),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:l.x-r/2-.3,y:l.y},{x:l.x-r/2-.45,y:l.y+.15},{x:l.x-r/2-.45,y:l.y-.15},{x:l.x-r/2-.3,y:l.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},u=pi(0,o/2+.4,.25),d={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:wPo,layer:"top"};return{circuitJson:[...a,A,c,u,g,d],parameters:e}},L3t=(t,e,n,o)=>{const i=e/2-o/2;return t<=3?{x:-i,y:n-(t-1)*n}:{x:i,y:-n+(t-4)*n}},TPo=hi.extend({fn:F(),num_pins:Nn([be(3),be(2)]).default(3),p:F().default("5mm"),id:F().default("1.25mm"),od:F().default("2.35mm"),ca:F().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:F().default("5.35mm"),h:F().default("4mm"),string:F().optional()}),kPo=t=>{const{p:e,id:n,od:o,h:i}=t,r=Number.parseFloat(i),s=Number.parseFloat(e);return[Js(1,0,s,n,o),Js(2,r,0,n,o),Js(3,0,-s,n,o)]},FPo=t=>{const e=t.string?.match(/^potentiometer_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=TPo.parse({...t,num_pins:n});let i=[];o.num_pins===3&&(i=kPo(o));const r=Number.parseFloat(o.ca)/2+.15,s=Number.parseFloat(o.w),a=Number.parseFloat(o.od)/2+.35,A={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:r-1.75},{x:0,y:r},{x:s,y:r},{x:s,y:a}],stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-a},{x:s,y:-r},{x:0,y:-r},{x:0,y:-r+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},l=Number.parseFloat(o.w)/2,g=pi(l,r+1,.5),u=Number.parseFloat(o.od)/2,d=Number.parseFloat(o.h),h=Number.parseFloat(o.ca)/2,_=-(u+.25),m=d+u+.25,p=h+.25,I={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(_+m)/2,y:0},width:m-_,height:2*p,layer:"top"};return{circuitJson:[...i,A,c,g,I],parameters:o}},LPo=hi.extend({fn:F(),p:Ae.optional().default("7.5mm"),id:Ae.optional().default("1mm"),od:Ae.optional().default("2mm"),d:Ae.optional().default("10.5mm")}),HPo=(t,e,n,o,i)=>{const r=[],s=[];for(let a=0;a<=50;a++){const A=a/50*Math.PI,c=t+Math.cos(A)*n,l=e+Math.sin(A)*n;c<t-o&&l>=e-i/2&&l<=e+i/2||r.push({x:c,y:l})}for(let a=0;a<=50;a++){const A=Math.PI+a/50*Math.PI,c=t+Math.cos(A)*n,l=e+Math.sin(A)*n;c<t-o&&l>=e-i/2&&l<=e+i/2||s.push({x:c,y:l})}return{topArc:r,bottomArc:s}},GPo=t=>{const e=LPo.parse(t),{p:n,id:o,od:i,d:r}=e,s=[Sy({pn:1,x:-n/2,y:0,holeDiameter:o,rectPadWidth:i,rectPadHeight:i}),Js(2,n/2,0,o,i)],{topArc:a,bottomArc:A}=HPo(0,0,r/2+.1,i/2,i),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:A,stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:r/2+.1},{x:0,y:-(r/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},u=-(r/2+.5),d=i/2+1.5,h=.5,_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:u-h,y:d},{x:u+h,y:d}],stroke_width:.1,pcb_silkscreen_path_id:""},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:u,y:d-h},{x:u,y:d+h}],stroke_width:.1,pcb_silkscreen_path_id:""},p=pi(0,r/2+1,.5),I=r/2,f=n/2+i/2,y=Math.max(I,f)+.25,E={type:"pcb_courtyard_circle",pcb_courtyard_circle_id:"",pcb_component_id:"",center:{x:0,y:0},radius:y,layer:"top"};return{circuitJson:[...s,c,l,g,_,m,p,E],parameters:e}},OPo=hi.extend({fn:F(),num_pins:be(2).default(2),w:F().default("6.5mm"),h:F().default("3mm"),pl:F().default("1.75mm"),pw:F().default("2.40mm"),p:F().default("4.75mm")}),KPo=t=>{const e=OPo.parse(t),n=pi(0,Ae.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:Ae.parse(e.p)/2,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.3,y:Ae.parse(e.h)/2},{x:-Ae.parse(e.w)/2-.3,y:-Ae.parse(e.h)/2},{x:Ae.parse(e.p)/2,y:-Ae.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:7,height:3.5,layer:"top"};return{circuitJson:YPo(e).concat(o,n,s),parameters:e}},UPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},YPo=t=>{const e=[],n=Ae.parse(t.p),o=Ae.parse(t.pl),i=Ae.parse(t.pw),r=.125;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=UPo({pn:s,p:n});e.push(Oo(s,a,A,o,i,r))}return e},zPo=[{x:-1.45,y:.98},{x:-.73,y:.98},{x:-.73,y:1.1},{x:.73,y:1.1},{x:.73,y:.33},{x:1.45,y:.33},{x:1.45,y:-.33},{x:.73,y:-.33},{x:.73,y:-1.1},{x:-.73,y:-1.1},{x:-.73,y:-.98},{x:-1.45,y:-.98},{x:-1.45,y:-.32},{x:-.73,y:-.32},{x:-.73,y:.32},{x:-1.45,y:.32}],VPo=hi.extend({fn:F(),num_pins:Ue().default(3),w:F().default("2.45mm"),h:F().default("2.40mm"),pl:F().default("0.92mm"),pw:F().default("0.45mm"),p:F().default("0.891mm"),string:F().optional()}),JPo=t=>{const e=t.string?.match(/^sot323_(\d+)/),n=e?Number.parseInt(e[1],3):3,o=VPo.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:WPo(o),parameters:o};throw new Error("Invalid number of pins")},qPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.65}:e===2?{x:-n,y:-.65}:{x:n,y:0}},WPo=t=>{const e=[];for(let A=0;A<t.num_pins;A++){const{x:c,y:l}=qPo({num_pins:t.num_pins,pn:A+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(Oo(A+1,c,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=pi(0,Number.parseInt(t.h)/2+1,.3),o=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),i=Number.parseFloat(t.h)/2,r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o,y:i+.3},{x:o,y:i+.3},{x:o,y:i/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o,y:-i-.3},{x:o,y:-i-.3},{x:o,y:-i/2}],type:"pcb_silkscreen_path",stroke_width:.1},a={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:zPo,layer:"top"};return[...e,r,s,n,a]},jPo=hi.extend({fn:F(),circle:Te().optional(),rect:Te().optional(),square:Te().optional(),pill:Te().optional(),d:Ae.optional(),pd:Ae.optional(),diameter:Ae.optional(),r:Ae.optional(),pr:Ae.optional(),radius:Ae.optional(),w:Ae.optional(),pw:Ae.optional(),width:Ae.optional(),h:Ae.optional(),ph:Ae.optional(),height:Ae.optional(),s:Ae.optional(),size:Ae.optional(),string:F().optional()}).transform(t=>{let e="rect";t.circle&&(e="circle"),t.square&&(e="square"),t.rect&&(e="rect"),t.pill&&(e="pill");let n,o,i;return e==="circle"?t.r!==void 0?n=iA(t.r):t.pr!==void 0?n=iA(t.pr):t.radius!==void 0?n=iA(t.radius):t.d!==void 0?n=iA(t.d)/2:t.pd!==void 0?n=iA(t.pd)/2:t.diameter!==void 0?n=iA(t.diameter)/2:n=iA("1mm")/2:(t.w!==void 0?o=iA(t.w):t.pw!==void 0?o=iA(t.pw):t.width!==void 0?o=iA(t.width):t.s!==void 0?o=iA(t.s):t.size!==void 0?o=iA(t.size):o=iA("1mm"),t.h!==void 0?i=iA(t.h):t.ph!==void 0?i=iA(t.ph):t.height!==void 0?i=iA(t.height):e==="square"||e==="rect"?i=o:i=iA("1mm")),{fn:t.fn,shape:e,radius:n,width:o,height:i}}),XPo=t=>{const e=jPo.parse(t),{shape:n,radius:o,width:i,height:r}=e;let s,a;return n==="circle"?(s=m3t(1,{x:0,y:0,radius:o}),a=o+.5):n==="pill"?(s=vie(1,0,0,i,r),a=Math.max(i,r)/2+.5):(s=Oo(1,0,0,i,r),a=r/2+.5),{circuitJson:[s,pi(0,a,.2)],parameters:e}},$Po=hi.extend({fn:F(),d:Ae.optional(),hd:Ae.optional(),r:Ae.optional(),hr:Ae.optional(),pd:Ae.optional(),pr:Ae.optional(),squarepad:Te().optional().default(!1)}).transform(t=>{let e;t.d!==void 0?e=iA(t.d):t.hd!==void 0?e=iA(t.hd):t.r!==void 0?e=iA(t.r)*2:t.hr!==void 0?e=iA(t.hr)*2:e=iA("1mm");let n;return t.pd!==void 0?n=iA(t.pd):t.pr!==void 0?n=iA(t.pr)*2:n=e*(1.5/1),{fn:t.fn,d:e,pd:n,squarepad:t.squarepad??!1}}),ZPo=t=>{const e=$Po.parse(t),{d:n,pd:o,squarepad:i}=e;return{circuitJson:[i?Sy({pn:1,x:0,y:0,holeDiameter:n,rectPadWidth:o,rectPadHeight:o}):Js(1,0,0,n,o),pi(0,o/2+.5,.2)],parameters:e}},evo=hi.extend({fn:F(),num_pins:be(6).default(6),h:F().default("1.3mm"),pl:F().default("1.325mm"),pw:F().default("0.6mm"),p:F().default("0.95mm")}),tvo=t=>{const e=evo.parse(t);return{circuitJson:nvo(e),parameters:e}},H3t=t=>{const{p:e,h:n,pn:o}=t;if(o===1)return{x:-n/2-.4875,y:e};if(o===2)return{x:-n/2-.4875,y:0};if(o===3)return{x:-n/2-.4875,y:-e};if(o===4)return{x:n/2+.4875,y:-e};if(o===5)return{x:n/2+.4875,y:0};if(o===6)return{x:n/2+.4875,y:e};throw new Error("Invalid pin number")},nvo=t=>{const e=[];for(let B=1;B<=t.num_pins;B++){const{x:Q,y:b}=H3t({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:B});e.push(Oo(B,Q,b,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=t.num_pins/2*Number.parseFloat(t.p),o=Number.parseFloat(t.h),i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:o/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:o/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-o/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-o/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=pi(0,o+.3,.3),a=H3t({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const A=.7,c=.3,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+A/2-.2,y:a.y},{x:a.x-A/2,y:a.y+c/2},{x:a.x-A/2,y:a.y-c/2},{x:a.x+A/2-.2,y:a.y}],stroke_width:.05},g=Number.parseFloat(t.h),u=Number.parseFloat(t.p),d=Number.parseFloat(t.pl),h=Number.parseFloat(t.pw),_=g/2+.4875,m=u*2+h,p=_+d/2,I=g/2+.4,f=p+.25,C=m/2+.25,y=C+.2,E={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:ZC([{minX:-f,maxX:f,minY:-C,maxY:C},{minX:-I,maxX:I,minY:-y,maxY:y}])};return[...e,s,i,r,l,E]},ovo=[{x:-1.703,y:.98},{x:-.983,y:.98},{x:-.983,y:1.1},{x:.477,y:1.1},{x:.477,y:.98},{x:1.197,y:.98},{x:1.197,y:-.98},{x:.477,y:-.98},{x:.477,y:-1.1},{x:-.983,y:-1.1},{x:-.983,y:-.98},{x:-1.703,y:-.98}],ivo=hi.extend({fn:F(),num_pins:Ue().default(4),w:F().default("3.2mm"),h:F().default("2.6mm"),pl:F().default("1.05mm"),pw:F().default("0.45mm"),p:F().default("0.55mm"),string:F().optional()}),rvo=t=>{const e=t.string?.match(/^sot343_(\d+)/),n=e?Number.parseInt(e[1],4):4,o=ivo.parse({...t,num_pins:n});if(o.num_pins===4)return{circuitJson:avo(o),parameters:o};throw new Error("Invalid number of pins")},svo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n*1.92,y:-.65}:e===2?{x:-n*1.92,y:.65}:e===3?{x:n,y:.65}:e===4?{x:n,y:-.65}:{x:0,y:0}},avo=t=>{const e=[],n=Number.parseFloat(t.w),o=Number.parseFloat(t.h),i=Number.parseFloat(t.pl),r=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let a=1/0,A=-1/0,c=1/0,l=-1/0;for(let C=0;C<t.num_pins;C++){const{x:y,y:E}=svo({num_pins:t.num_pins,pn:C+1,p:s});e.push(Oo(C+1,y,E,i,r)),y<a&&(a=y),y>A&&(A=y),E<c&&(c=E),E>l&&(l=E)}const g=(a+A)/2,u=l-c,d=o*.3,h=u/2+d;let _=n*.8;o<=2.6&&(_/=2);const m=pi(g,h+.5,.3),p={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:g-_/2,y:h},{x:g+_/2,y:h}],type:"pcb_silkscreen_path",stroke_width:.1},I={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_bottom",route:[{x:g-_/2,y:-h},{x:g+_/2,y:-h}],type:"pcb_silkscreen_path",stroke_width:.1},f={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:ovo,layer:"top"};return[...e,p,I,m,f]},Avo=hi.extend({fn:F()}),cvo=t=>{const e=Avo.parse(t),n=[],o=.5-.15,i=1.5,s=.5/2,a=75,A=-37/2;for(let B=0;B<a;B++){const Q=B+1;if(Q>=24&&Q<=31)continue;const b=A-B*s,D=Q%2===0,R=i+(D?.25:0),H=.5-R/2,G=Oo(Q,H,b,R,o);G.layer=D?"bottom":"top",n.push(G)}const c=46*.0254,l=137*.0254,g=261*.0254,u={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-l/2+i/2,y:A-g},width:l,height:c},d={x:-.5,y:A},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:d.x-.4,y:d.y},{x:d.x-.7,y:d.y+.3},{x:d.x-.7,y:d.y-.3},{x:d.x-.4,y:d.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let _=1/0,m=-1/0,p=1/0,I=-1/0;const f=(B,Q,b=0,D=0)=>{_=Math.min(_,B-b/2),m=Math.max(m,B+b/2),p=Math.min(p,Q-D/2),I=Math.max(I,Q+D/2)};for(const B of n){const Q=B;f(Q.x,Q.y,Q.width,Q.height)}f(u.center.x,u.center.y,u.width,u.height);for(const B of h.route)f(B.x,B.y);const C=(_+m)/2,y=(p+I)/2,E=B=>{typeof B.x=="number"&&(B.x-=C),typeof B.y=="number"&&(B.y-=y),B.center&&(B.center.x-=C,B.center.y-=y),Array.isArray(B.route)&&(B.route=B.route.map(Q=>({x:Q.x-C,y:Q.y-y})))};for(const B of n)E(B);return E(u),E(h),{circuitJson:[...n,u,h],parameters:e}},lvo=hi.extend({fn:F(),numPins:Ue().optional().default(0),rows:Nn([F(),Ue()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:Ae.default("2.54mm").describe("pitch"),id:Ae.default("1.0mm").describe("inner diameter"),od:Ae.default("1.5mm").describe("outer diameter"),male:Te().optional().describe("the module uses male headers"),nopin:Te().optional().default(!1).describe("omit pins rendering"),female:Te().optional().describe("the module uses female headers"),smd:Te().optional().describe("surface mount device"),pinlabeltextalignleft:Te().optional().default(!1),pinlabeltextaligncenter:Te().optional().default(!1),pinlabeltextalignright:Te().optional().default(!1),pinlabelverticallyinverted:Te().optional().default(!1),pinlabelorthogonal:Te().optional().default(!1),nopinlabels:Te().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Te().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Te().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top"),pinRowSide:Jt(["left","right","top","bottom"]).optional().default("left"),pinrowleft:Te().optional().default(!1),pinrowright:Te().optional().default(!1),pinrowtop:Te().optional().default(!1),pinrowbottom:Te().optional().default(!1),pinrowleftpins:Nn([F(),Ue()]).transform(t=>Number(t)).optional(),pinrowrightpins:Nn([F(),Ue()]).transform(t=>Number(t)).optional(),pinrowtoppins:Nn([F(),Ue()]).transform(t=>Number(t)).optional(),pinrowbottompins:Nn([F(),Ue()]).transform(t=>Number(t)).optional(),width:Ae.optional(),height:Ae.optional(),pinRowHoleEdgeToEdgeDist:Ae.default("2mm"),holes:Nn([F(),Qt(F())]).optional().transform(t=>!t||Array.isArray(t)?t:t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1).split(",").map(e=>e.trim()):[t]),holeXDist:Ae.optional(),holeYDist:Ae.optional(),holeInset:Ae.default("1mm"),pinrow:Nn([F(),Ue()]).optional(),usbposition:Jt(["left","right","top","bottom"]).optional().default("left"),usbleft:Te().optional().default(!1),usbtop:Te().optional().default(!1),usbright:Te().optional().default(!1),usbbottom:Te().optional().default(!1),usbtype:Jt(["micro","c"]).optional(),usbmicro:Te().optional().default(!1),usbc:Te().optional().default(!1),screen:Te().optional().default(!1).describe("add silkscreen outline for screen/display area"),screenwidth:Ae.optional(),screenheight:Ae.optional(),screencenteroffsetx:Ae.optional(),screencenteroffsety:Ae.optional()}).transform(t=>{const e=Q3t(t);let n=t.pinRowSide;t.pinrowleft&&(n="left"),t.pinrowright&&(n="right"),t.pinrowtop&&(n="top"),t.pinrowbottom&&(n="bottom");let o=t.usbposition;t.usbleft&&(o="left"),t.usbtop&&(o="top"),t.usbright&&(o="right"),t.usbbottom&&(o="bottom");let i=t.usbtype;t.usbmicro&&(i="micro"),t.usbc&&(i="c"),t.pinrow!==void 0&&(t.numPins=Number(t.pinrow));const r={left:t.pinrowleftpins,right:t.pinrowrightpins,top:t.pinrowtoppins,bottom:t.pinrowbottompins},s=Object.values(r).some(C=>C!==void 0&&C>0),a=(r.left??0)>0&&(r.right??0)>0,A=(r.top??0)>0&&(r.bottom??0)>0;s&&((r.left??0)>0?n="left":(r.right??0)>0?n="right":(r.top??0)>0?n="top":(r.bottom??0)>0&&(n="bottom"),t.numPins=(r.left??0)+(r.right??0)+(r.top??0)+(r.bottom??0));const c=Math.ceil(t.numPins/t.rows),l=Math.max(r.left??0,r.right??0),g=Math.max(r.top??0,r.bottom??0);let u,d;if(s){const C=a?t.p:0,y=A?t.p:0;u=(g>0?(g-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+C,d=(l>0?(l-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+y}else n==="left"||n==="right"?(u=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,d=(c-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist):(d=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,u=(c-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist);t.numPins===0&&(u=10,d=10);const h=t.width??u,_=t.height??d,m=t.screenwidth??h*.95,p=t.screenheight??_*.95,I=t.screencenteroffsetx??0,f=t.screencenteroffsety??0;return{...t,pinlabelAnchorSide:e,pinRowSide:n,usbposition:o,usbtype:i,male:t.male??!t.female,female:t.female??!1,width:h,height:_,screenwidth:m,screenheight:p,screencenteroffsetx:I,screencenteroffsety:f,pinrowleftpins:r.left,pinrowrightpins:r.right,pinrowtoppins:r.top,pinrowbottompins:r.bottom}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:wn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),gvo=t=>{const e=lvo.parse(t),{p:n,id:o,od:i,rows:r,numPins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:A,pinlabelorthogonal:c,pinlabeltextalignleft:l,pinlabeltextalignright:g,nopinlabels:u,doublesidedpinlabel:d,bottomsidepinlabel:h,pinRowSide:_,width:m,height:p,pinRowHoleEdgeToEdgeDist:I,holes:f,holeXDist:C,holeYDist:y,holeInset:E,pinrowleftpins:B,pinrowrightpins:Q,pinrowtoppins:b,pinrowbottompins:D,usbposition:R,usbtype:w,screen:H,screenwidth:G,screenheight:K,screencenteroffsetx:U,screencenteroffsety:q}=e;let W="center";l?W="left":g&&(W="right");const ee=[],re={left:B,right:Q,top:b,bottom:D},X=Object.values(re).some(le=>le!==void 0&&le>0),te=(le,ue,Ce,ye)=>{if(e.smd?ee.push(Oo(le,ue,Ce,e.od,e.od)):le===1?ee.push(Sy({pn:le,x:ue,y:Ce,holeDiameter:o,rectPadWidth:i,rectPadHeight:i})):ee.push(Js(le,ue,Ce,o,i)),!u){const Be=ue+(ye==="left"?-i:ye==="right"?i:0),de=Ce+(ye==="top"?i:ye==="bottom"?-i:0);h||ee.push(b6({fs:i/5,pn:le,anchor_x:Be,anchor_y:de,textalign:W,orthogonal:c,verticallyinverted:A,layer:"top"})),(d||h)&&ee.push(b6({fs:i/5,pn:le,anchor_x:Be,anchor_y:de,textalign:W,orthogonal:c,verticallyinverted:A,layer:"bottom"}))}};if(X){const le=n;let ue=1;const Ce=re.left??0,ye=re.right??0,Be=re.top??0,de=re.bottom??0,Ee=(pe,we)=>{if(!(we<=0))if(pe==="left"||pe==="right"){const Ge=pe==="left"?-m/2+I:m/2-I,Ve=(we-1)/2*le;for(let Ie=0;Ie<we;Ie++)te(ue,Ge,Ve-Ie*le,pe),ue++}else{const Ge=pe==="top"?p/2-I:-p/2+I,Ve=-((we-1)/2)*le;for(let Ie=0;Ie<we;Ie++)te(ue,Ve+Ie*le,Ge,pe),ue++}};Ee("left",Ce),Ee("right",ye),Ee("top",Be),Ee("bottom",de)}else{const le=n;let ue=0,Ce=0,ye=0,Be=0,de=0,Ee=0;const pe=Math.ceil(s/r);_==="left"||_==="right"?(ue=_==="left"?-m/2+I:m/2-I,Ce=(pe-1)/2*le,ye=0,Be=-le,de=_==="left"?le:-le,Ee=0):(ue=-(pe-1)/2*le,Ce=_==="top"?p/2-I:-p/2+I,ye=le,Be=0,de=0,Ee=_==="top"?-le:le);let we=1;for(let Ge=0;Ge<r&&we<=s;Ge++)for(let Ve=0;Ve<pe&&we<=s;Ve++){const Ie=ue+Ve*ye+Ge*de,qe=Ce+Ve*Be+Ge*Ee;if(e.smd?ee.push(Oo(we,Ie,qe,e.od,e.od)):we===1?ee.push(Sy({pn:we,x:Ie,y:qe,holeDiameter:o,rectPadWidth:i,rectPadHeight:i})):ee.push(Js(we,Ie,qe,o,i)),!u){const Me=Ie+(_==="left"?-i:_==="right"?i:0),Fe=qe+(_==="top"?i:_==="bottom"?-i:0);h||ee.push(b6({fs:i/5,pn:we,anchor_x:Me,anchor_y:Fe,textalign:W,orthogonal:c,verticallyinverted:A,layer:"top"})),(d||h)&&ee.push(b6({fs:i/5,pn:we,anchor_x:Me,anchor_y:Fe,textalign:W,orthogonal:c,verticallyinverted:A,layer:"bottom"}))}we++}}if(f)for(const le of f){let ue=0,Ce=0;le==="topleft"?(ue=-m/2+E,Ce=p/2-E):le==="topright"?(ue=m/2-E,Ce=p/2-E):le==="bottomleft"?(ue=-m/2+E,Ce=-p/2+E):le==="bottomright"?(ue=m/2-E,Ce=-p/2+E):le==="center"&&(ue=0,Ce=0),C!==void 0&&(ue+=C),y!==void 0&&(Ce+=y),ee.push(Js(s+f.indexOf(le)+1,ue,Ce,o,i))}if(!e.nosilkscreen){const le=[{x:-m/2,y:-p/2},{x:m/2,y:-p/2},{x:m/2,y:p/2},{x:-m/2,y:p/2},{x:-m/2,y:-p/2}];ee.push(D6(le,{stroke_width:.1,layer:"top"}))}const se=pi(0,p/2+1,.5);if(ee.push(se),R&&w){let le,ue;if(w==="c")le=8,ue=3;else if(w==="micro")le=6,ue=2;else return{circuitJson:ee,parameters:e};let Ce;if(R==="left")Ce=[{x:-m/2,y:-le/2},{x:-m/2+ue,y:-le/2},{x:-m/2+ue,y:le/2},{x:-m/2,y:le/2},{x:-m/2,y:-le/2}];else if(R==="right")Ce=[{x:m/2-ue,y:-le/2},{x:m/2,y:-le/2},{x:m/2,y:le/2},{x:m/2-ue,y:le/2},{x:m/2-ue,y:-le/2}];else if(R==="top")Ce=[{x:-le/2,y:p/2-ue},{x:le/2,y:p/2-ue},{x:le/2,y:p/2},{x:-le/2,y:p/2},{x:-le/2,y:p/2-ue}];else if(R==="bottom")Ce=[{x:-le/2,y:-p/2},{x:le/2,y:-p/2},{x:le/2,y:-p/2+ue},{x:-le/2,y:-p/2+ue},{x:-le/2,y:-p/2}];else return{circuitJson:ee,parameters:e};ee.push(D6(Ce,{stroke_width:.1,layer:"top"}))}if(H){const le=G/2,ue=K/2,Ce=U,ye=q,Be=[{x:-le+Ce,y:-ue+ye},{x:le+Ce,y:-ue+ye},{x:le+Ce,y:ue+ye},{x:-le+Ce,y:ue+ye},{x:-le+Ce,y:-ue+ye}];ee.push(D6(Be,{stroke_width:.05,layer:"top"}))}return{circuitJson:ee,parameters:e}},uvo=[{x:-1.45,y:2.75},{x:-1.45,y:-1.85},{x:4.05,y:-1.85},{x:4.05,y:2.75}],hvo=[{x:-1.55,y:2.75},{x:-1.55,y:-1.85},{x:3.95,y:-1.85},{x:3.95,y:2.75}],dvo=hi.extend({fn:F(),num_pins:Ue().default(3),inline:Te().default(!1),p:F().default("1.27mm"),id:F().default("0.75mm"),od:F().default("1.3mm"),w:F().default("4.8mm"),h:F().default("4.0mm")}),_vo=t=>{const e=dvo.parse(t),n=Number.parseFloat(e.p),o=Number.parseFloat(e.w),i=Number.parseFloat(e.h),r=e.inline?1.05:Number.parseFloat(e.od),s=e.inline?1.5:r,a=[Sy({pn:1,x:0,y:0,holeDiameter:e.id,rectPadWidth:r,rectPadHeight:s}),e.inline?Rv(2,n,0,Number.parseFloat(e.id),r,s):Js(2,n,n,e.id,r),e.inline?Rv(3,n*2,0,Number.parseFloat(e.id),r,s):Js(3,n*2,0,e.id,r)],A=o/2,c=e.inline?n-.09:n,l=.2,g=l+A-i,u=Array.from({length:32},(m,p)=>{const I=Math.PI*p/31;return{x:c+A*Math.cos(I),y:l+A*Math.sin(I)}}),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",stroke_width:.12,route:[...u,{x:c-A,y:g},{x:c+A,y:g},u[0]]},h=pi(c,l+A+1,.5),_={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:e.inline?hvo:uvo,layer:"top"};return{circuitJson:[...a,d,h,_],parameters:e}},mvo=(t,e)=>{const n=t.filter(o=>o.type==="pcb_silkscreen_text");if(n.length===0)return t;for(const o of n)e.norefdes&&(o.text="");return t},pvo=(t,e)=>e.nosilkscreen?t.filter(n=>n.type!=="pcb_silkscreen_path"&&n.type!=="pcb_silkscreen_text"):t,Ivo=(t,e)=>{if(!e)return t;const n=t.filter(l=>l.type==="pcb_smtpad"||l.type==="pcb_plated_hole");if(n.length===0)return t;let o=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;const a=(l,g,u=0,d=0)=>{const h=l-u/2,_=l+u/2,m=g-d/2,p=g+d/2;o=Math.min(o,h),i=Math.max(i,_),r=Math.min(r,m),s=Math.max(s,p)};for(const l of n)if(l.type==="pcb_smtpad"){const g=l.shape==="circle"?l.radius*2:l.width,u=l.shape==="circle"?l.radius*2:l.height;a(l.x,l.y,g,u)}else if(l.type==="pcb_plated_hole"){const g=l.outer_diameter??l.hole_diameter;a(l.x,l.y,g,g)}let A=0,c=0;switch(e){case"center":A=(o+i)/2,c=(r+s)/2;break;case"bottomleft":A=o,c=r;break;case"bottomcenter":case"centerbottom":A=(o+i)/2,c=r;break;case"topcenter":case"centertop":A=(o+i)/2,c=s;break;case"leftcenter":case"centerleft":A=o,c=(r+s)/2;break;case"rightcenter":case"centerright":A=i,c=(r+s)/2;break;case"pin1":{const l=n.find(g=>g.port_hints?.[0]==="1")||n[0];A=l.x,c=l.y;break}}if(A===0&&c===0)return t;for(const l of t){if(typeof l.x=="number"&&(l.x-=A),typeof l.y=="number"&&(l.y-=c),l.center&&typeof l.center.x=="number"&&(l.center.x-=A,l.center.y-=c),l.type==="pcb_silkscreen_path")for(const g of l.route)g.x-=A,g.y-=c;l.type==="pcb_silkscreen_text"&&l.anchor_position&&(l.anchor_position.x-=A,l.anchor_position.y-=c)}return t};function fvo(t){return t!=null}var Cvo=t=>t.trim().replace(/^pinheader(?=[\d_]|$)/i,"pinrow").replace(/^sot23-(\d+)(?=_|$)/i,"sot23_$1").replace(/^sot-223-(\d+)(?=_|$)/i,"sot223_$1").replace(/^to-220f-(\d+)(?=_|$)/i,"to220f_$1").replace(/^jst_(ph|sh|zh)_(\d+)(?=_|$)/i,"jst$2_$1"),yvo=t=>{let e=Nie();const n=Cvo(t),i=n.replace(/^((?:\d{4}|\d{5}))(?=$|_|x)/,"res$1").replace(/^zh(\d+)(?:$|_)/,"jst$1_zh").split(/_(?!metric)/).map(r=>{const s=r.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!s)return null;const[,a,A]=s;if(!a)return null;const c=a.toLowerCase();return A?.includes("?")?null:{fn:c,v:A}}).filter(fvo);for(const{fn:r,v:s}of i)e=e[r](s);return e.setString(n),e},Evo=()=>Object.keys(r5),Nie=()=>{const t=new Proxy({},{get:(e,n)=>{if(n==="soup"||n==="circuitJson"){if("fn"in e&&r5[e.fn])return()=>{const{circuitJson:o}=r5[e.fn](e),i=pvo(o,e),r=mvo(i,e);return Ivo(r,e.origin)};if(!r5[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>{throw new Error(`No function found for footprinter, make sure to specify .dip, .lr, .p, etc. Got "${n}"`)}}if(n==="json"){if(!r5[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>r5[e.fn](e).parameters}return n==="getFootprintNames"?()=>Object.keys(r5):n==="params"?()=>e:n==="setString"?o=>(e.string=o,t):o=>(Object.keys(e).length===0?`${n}${o}`in r5?(e[`${n}${o}`]=!0,e.fn=`${n}${o}`):(e[n]=!0,e.fn=n,n==="res"||n==="cap"||n==="led"||n==="diode"?o&&(typeof o=="string"&&o.includes("_metric")?e.metric=o.split("_metric")[0]:e.imperial=o):e.num_pins=Number.isNaN(Number.parseFloat(o))?void 0:Number.parseFloat(o)):!o&&["w","h","p"].includes(n)||(e[n]=o??!0),t)}});return t};Nie.string=yvo,Nie.getFootprintNames=Evo;var xvo=Nie,G3t=Symbol("Fragment");function mwe(t,e,...n){const o=n.length?n:e?.children!==void 0?[e.children]:[],i=[],r=(Array.isArray(o)?o:[o]).flat(1/0);for(const s of r)s==null||s===!1||(Array.isArray(s)?i.push(...s):i.push(s));return{type:t,props:(e&&e.children!==void 0?{...e,children:void 0}:e)||{},children:i}}var un=Symbol("Cuboid"),O3t=Symbol("Cube"),Xc=Symbol("Cylinder"),Rie=Symbol("Sphere"),vU=Symbol("RoundedCuboid"),Ai=Symbol("Translate"),qh=Symbol("Rotate"),R_=Symbol("Union"),Yf=Symbol("Subtract"),$c=Symbol("Hull"),Nr=Symbol("Colorize"),MU=Symbol("Polygon"),wU=Symbol("ExtrudeLinear"),by=Symbol("RoundedCylinder"),dr=G3t,We=(t,e,n)=>mwe(t,e),to=(t,e,n)=>mwe(t,e),Bvo=({hole:t,isPin1:e})=>{const n=e?"#00ff00":"#b87333";if(t.shape==="circle")return We(Nr,{color:n,children:We(Ai,{offset:[t.x,t.y,-.005],children:to(Yf,{children:[We(Xc,{radius:t.outer_diameter/2,height:.01}),We(Xc,{radius:t.hole_diameter/2,height:.01})]})})});if(t.shape==="circular_hole_with_rect_pad")return We(Nr,{color:n,children:We(Ai,{offset:[t.x,t.y,0],children:to(Yf,{children:[We(un,{size:[t.rect_pad_width,t.rect_pad_height,.01],center:[0,0,0]}),We(Xc,{radius:t.hole_diameter/2,height:.01})]})})});if(t.shape==="pill"){const o=t.outer_width,i=t.outer_height,r=Math.min(o,i)/2,s=o>i,a=t.hole_width??.8,A=t.hole_height??.8;return We(Nr,{color:n,children:We(Ai,{offset:[t.x,t.y,0],children:to(Yf,{children:[to($c,{children:[We(Xc,{radius:r,height:.01,center:[s?-(o/2-r):0,s?0:-(i/2-r),0]}),We(Xc,{radius:r,height:.01,center:[s?o/2-r:0,s?0:i/2-r,0]})]}),a===A?We(Xc,{radius:a/2,height:.01}):to($c,{children:[We(Xc,{radius:Math.min(a,A)/2,height:.01,center:[a>A?-(a/2-A/2):0,a>A?0:-(A/2-a/2),0]}),We(Xc,{radius:Math.min(a,A)/2,height:.01,center:[a>A?a/2-A/2:0,a>A?0:A/2-a/2,0]})]})]})})})}throw new Error("Shape not supported: "+t.shape)},Wh=({center:t,width:e,length:n,height:o,heightAboveSurface:i=.15,color:r="#555",taperRatio:s=.12,faceRatio:a=.75,straightHeightRatio:A=.5,includeNotch:c=!0,notchRadius:l,notchPosition:g,notchRotation:u=[0,0,0],notchLength:d=.5,notchWidth:h=.25,chamferSize:_=0})=>{const m=o*A,p=o-m,I=Math.min(e,n)*s,f=Math.max(e-I,e*a),C=Math.max(n-I,n*a),y=Math.min(e,n)*.12,E=l??y,B={x:0,y:n/2-E*.25,z:o},Q=g??B,b=to(R_,{children:[to($c,{children:[We(Ai,{z:.005,children:We(un,{size:[f,C,.01]})}),We(Ai,{z:m,children:We(un,{size:[e,n,.01]})})]}),to($c,{children:[We(Ai,{z:m,children:We(un,{size:[e,n,.01]})}),We(Ai,{z:m+p,children:We(un,{size:[f,C,.01]})})]})]}),D=(w,H)=>We(Ai,{offset:{x:w,y:H,z:0},children:We(qh,{rotation:[0,0,Math.PI/4],children:We(un,{size:[_*Math.SQRT2,_*Math.SQRT2,o*3]})})});let R=b;if(_>0){const w=e/2,H=n/2;R=to(Yf,{children:[b,D(w,H),D(-w,H),D(w,-H),D(-w,-H)]})}return We(Nr,{color:r,children:We(Ai,{offset:t,children:We(Ai,{offset:{x:0,y:0,z:i},children:c?to(Yf,{children:[R,We(Ai,{offset:Q,children:We(qh,{rotation:u,children:We(Xc,{radius:E,height:h})})})]}):R})})})},Qvo=t=>Array.from({length:t},(e,n)=>n);function pwe(t,e){if(t.length<2)throw new Error("Stroke must have at least two points");const n=Array.isArray(t[0])?t.map(([l,g])=>({x:l,y:g})):t,o=e/2,i=[],r=[];function s(l,g){const u=g.x-l.x,d=g.y-l.y,h=Math.sqrt(u*u+d*d);return{x:-d/h,y:u/h}}function a(l,g,u){const d={x:l.x+g.x*o*u,y:l.y+g.y*o*u};u>0?i.push(d):r.unshift(d)}const A=s(n[0],n[1]);a(n[0],A,1),a(n[0],A,-1);for(let l=1;l<n.length-1;l++){const g=n[l-1],u=n[l],d=n[l+1],h=s(g,u),_=s(u,d),m=h.x+_.x,p=h.y+_.y,I=Math.sqrt(m*m+p*p);if(I/2>2*o)a(u,h,1),a(u,_,1),a(u,h,-1),a(u,_,-1);else{const C=1/I;a(u,{x:m*C,y:p*C},1),a(u,{x:m*C,y:p*C},-1)}}const c=s(n[n.length-2],n[n.length-1]);return a(n[n.length-1],c,1),a(n[n.length-1],c,-1),[...i,...r]}var Svo=t=>{const e=Math.min(...t.map(a=>a.x)),n=Math.max(...t.map(a=>a.x)),o=Math.min(...t.map(a=>a.y)),s=5.47/(Math.max(...t.map(a=>a.y))-o);return t.map(a=>({x:(a.x-e-(n-e)/2)*s,y:(a.y-o)*s}))},bvo=Svo([{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}]),K3t=5.47,Tie=.5,Dvo=({x:t,y:e,z:n})=>{const o=t>0;return to(dr,{children:[We(Ai,{offset:{x:t+.25/2,y:e,z:n},children:We(qh,{rotation:["-90deg",0,"90deg"],children:We(wU,{height:.25,children:We(MU,{points:bvo.slice().reverse().map(i=>[i.x,i.y])})})})}),We(Ai,{offset:{x:t,y:e+(o?1:-1),z:n},children:We(qh,{rotation:["-90deg","90deg",o?"180deg":"0deg"],children:We(wU,{height:2,children:We(MU,{points:pwe([[0,0],[-1,0],[-1,-1]],.25).map(i=>[i.x,i.y])})})})})]})},Pvo=({numPins:t=8,pitch:e=2.54,bodyWidth:n=6.4,rowSpacing:o})=>{const i=Math.floor(t/2),r=o??(n>=7?n:n+1.22),s=n>=7?r-1.22:n;return to(dr,{children:[Qvo(t).map(a=>{const A=a%i,c=(Math.floor(a/i)-.5)*2;return We(Dvo,{x:c*r/2,y:A*e-(i-1)/2*e,z:K3t/2+Tie})}),We(Wh,{width:s,length:i*e+.5,height:K3t-Tie,heightAboveSurface:Tie,center:{x:0,y:0,z:Tie}})]})};function vvo(t,{height:e,padContactLength:n,curveLength:o,bodyDistance:i,steepness:r=10}){o||(o=i*.3);let s=i-n-o;s<0&&(o+=s,s=0);const a=n*.75,A=n+o+(i-n-o)*.25;if(t<=a)return 0;if(t>=A)return e;const c=(t-a)/(A-a);return e/(1+Math.exp(-r*(c-.5)))}var Gr=t=>{const{thickness:e,width:n,padContactLength:o,bodyDistance:i,height:r,rotation:s}=t,a=15,A=Array.from({length:a}).map((l,g)=>g/(a-1)*i).map(l=>[l,vvo(l,t)]),c=pwe(A,e);return We(Nr,{color:"#fff",children:We(Ai,{offset:{z:0,y:0,x:0,...t.position},children:We(qh,{rotation:["90deg",0,s??0],children:We(Ai,{offset:{x:0,y:0,z:-n/2},children:We(wU,{height:n,children:We(MU,{points:c.map(l=>[l.x,l.y])})})})})})})},Mvo=({pinCount:t,leadLength:e,leadWidth:n,pitch:o,bodyWidth:i})=>{const r=Math.ceil(t/2),s=r<=4,a=(r-1)*o/2,A=o*Math.max(r-1,0)+(s?1.5:1.15),c=i-(s?.66:.58),l=.15,g=.8,u=1.22,d=e*.5,h=d+Math.max(.22,Math.min(.4,e*.65)),_=i/2+e/2,m=h*.1,p=Math.min(Math.min(c,A)*.18,1),I=Math.min(Math.min(c,A)*.12,.45);return to(dr,{children:[Array.from({length:r}).map((f,C)=>We(Gr,{position:{x:-_,y:C*o-a,z:l/2},width:n,thickness:l,padContactLength:d,bodyDistance:h,curveLength:m,height:g})),Array.from({length:r}).map((f,C)=>We(Gr,{rotation:Math.PI,position:{x:_,y:C*o-a,z:l/2},width:n,thickness:l,padContactLength:d,bodyDistance:h,curveLength:m,height:g})),We(Wh,{center:{x:0,y:0,z:0},width:c,length:A,height:u,notchPosition:{x:-(c/2-p-.2),y:A/2-p-.2,z:u},notchRadius:I})]})},wvo=({pinCount:t,padContactLength:e=.4,leadWidth:n=.2,pitch:o=.65,bodyWidth:i=3})=>{const r=Math.ceil(t/2),s=(r-1)*o/2,a=.2;return to(dr,{children:[Array.from({length:r}).map((A,c)=>We(Gr,{position:{x:-i/2-e-.3,y:c*o-s,z:a/2},width:n,thickness:a,padContactLength:e,bodyDistance:e+.4,height:.6})),Array.from({length:r}).map((A,c)=>We(Gr,{rotation:Math.PI,position:{x:i/2+e+.3,y:c*o-s,z:a/2},width:n,thickness:a,padContactLength:e,bodyDistance:e+.4,height:.6})),We(Wh,{center:{x:0,y:0,z:a/2},width:i,length:i,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},Iwe=1,fwe=.5,HT=.5,NU=.2,Nvo=Iwe-NU*2,U3t=({color:t="#333"})=>to(dr,{children:[We(un,{size:[Nvo,fwe,HT],offset:[0,0,HT/2],color:t}),We(un,{size:[NU,HT,fwe],offset:[Iwe/2-NU/2,0,HT/2],color:"#ccc"}),We(un,{size:[NU,HT,fwe],offset:[-Iwe/2+NU/2,0,HT/2],color:"#ccc"})]}),Cwe=1.6,Rvo=Cwe-.3*2,kie=.3,ywe=.85,GT=.6,Y3t=({color:t="#333"})=>to(dr,{children:[We(un,{size:[Rvo,ywe,GT],offset:[0,0,GT/2],color:t}),We(un,{size:[kie,ywe,GT],offset:[Cwe/2-kie/2,0,GT/2],color:"#ccc"}),We(un,{size:[kie,ywe,GT],offset:[-Cwe/2+kie/2,0,GT/2],color:"#ccc"})]}),Ewe=2,xwe=1.25,OT=.55,RU=.5,Tvo=Ewe-RU*2,z3t=({color:t="#333"})=>to(dr,{children:[We(un,{size:[Tvo,xwe,OT],offset:[0,0,OT/2],color:t}),We(un,{size:[RU,xwe,OT],offset:[Ewe/2-RU/2,0,OT/2],color:"#ccc"}),We(un,{size:[RU,xwe,OT],offset:[-Ewe/2+RU/2,0,OT/2],color:"#ccc"})]}),kvo=({pinCount:t,pitch:e,leadWidth:n,padContactLength:o,bodyWidth:i})=>{const r=t/4;e||(e=Fvo(t,i)),o||(o=Lvo(t)),n||(n=Hvo(t,i)),i||(i=e*(r+4));const s=o,a=i,A=(r-1)*e/2,c=s*.5,l=a+2*c,g=l,u=.8,d=.15,h=c,_=c*.5,m=c*.18;return to(dr,{children:[Array.from({length:r}).map((p,I)=>We(Gr,{position:{x:-g/2,y:I*e-A,z:d/2},width:n,thickness:d,padContactLength:_,bodyDistance:h,curveLength:m,height:u})),Array.from({length:r}).map((p,I)=>We(Gr,{rotation:Math.PI,position:{x:g/2,y:I*e-A,z:d/2},width:n,thickness:d,padContactLength:_,bodyDistance:h,curveLength:m,height:u})),Array.from({length:r}).map((p,I)=>We(Gr,{rotation:Math.PI/2,position:{x:I*e-A,y:-l/2,z:d/2},width:n,thickness:d,padContactLength:_,bodyDistance:h,curveLength:m,height:u})),Array.from({length:r}).map((p,I)=>We(Gr,{rotation:-Math.PI/2,position:{x:I*e-A,y:l/2,z:d/2},width:n,thickness:d,padContactLength:_,bodyDistance:h,curveLength:m,height:u})),We(Wh,{center:{x:0,y:0,z:0},width:i,length:a,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(a/2-1.5),y:i/2-1.5,z:1.5},notchRadius:1.5/2})]})},Fvo=(t,e)=>{switch(t){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},Lvo=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}},Hvo=(t,e)=>{switch(t){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},V3t=({x:t,y:e,pinThickness:n,shortSidePinLength:o,longSidePinLength:i,bodyHeight:r,bodyLength:s=2.54,bodyWidth:a=2.54,flipZ:A,faceup:c,smd:l,rightangle:g})=>to(dr,{children:[We(Ai,{y:g?-3:0,children:We(un,{color:"#222",size:[s,a,r],center:[t,e,A(r/2)]})}),!c&&We(Nr,{color:"gold",children:l?We(Gr,{rotation:-Math.PI/2,position:{x:t,y:e+1,z:n/2},thickness:n,width:n,height:n,padContactLength:2,bodyDistance:3}):to($c,{children:[We(un,{color:"gold",size:[n,n,o*.9],center:[t,e,A(r*.9+r/2)]}),We(un,{color:"gold",size:[n/1.8,n/1.8,o],center:[t,e,A(r+r/2)]})]})}),We(Nr,{color:"gold",children:We(Ai,{y:g?-3.9:0,z:g?1:0,children:We(qh,{rotation:g?[-Math.PI/2,0,0]:[0,0,0],children:to($c,{children:[We(un,{color:"gold",size:[n,n,i*.9],center:[t,e,A(-i/2*.9)]}),We(un,{color:"gold",size:[n/1.8,n/1.8,i],center:[t,e,A(-i/2)]})]})})})})]}),Gvo=({numberOfPins:t,pitch:e=2.54,longSidePinLength:n=6,invert:o,faceup:i,rows:r=1,smd:s,rightangle:a})=>{const l=Math.ceil(t/r),g=2.54,u=3,d=-((l-1)/2)*e,h=!s&&!a?-2-1.6:0,_=m=>(o||i?-m+2:m)+h;return We(dr,{children:Array.from({length:t},(m,p)=>{const I=Math.floor(p/l),f=p%l,C=d+f*e,y=((r-1)/2-I)*g;return We(V3t,{x:C,y,pinThickness:.63,shortSidePinLength:u,longSidePinLength:n,bodyHeight:2,flipZ:_,faceup:i,smd:s,rightangle:a},p)})})},Ovo=t=>{const e=["left","bottom","right","top"],{pin_count:n,pn:o,w:i,h:r,p:s,pl:a}=t,A=n/4,c=e[Math.floor((o-1)/A)],l=(o-1)%A,g=s*(A-1),u=s*(A-1),d=-a/2;switch(c){case"left":return{x:-i/2-d,y:u/2-l*s,o:"vert"};case"bottom":return{x:-g/2+l*s,y:-r/2-d,o:"horz"};case"right":return{x:i/2+d,y:-u/2+l*s,o:"vert"};case"top":return{x:g/2-l*s,y:r/2+d,o:"horz"};default:throw new Error("Invalid pin number")}},Kvo=({num_pins:t,cw:e,ccw:n,startingpin:o})=>{const i=[],r=t/4;let s=1;const a={};for(const A of o??[])a[A]=!0;!a.leftside&&!a.topside&&!a.rightside&&!a.bottomside&&(a.leftside=!0),!a.bottompin&&!a.leftpin&&!a.rightpin&&!a.toppin&&(a.leftside?a.toppin=!0:a.topside?a.rightpin=!0:a.rightside?a.bottompin=!0:a.bottomside&&(a.leftpin=!0)),a.leftside&&a.toppin?s=1:a.leftside&&a.bottompin?s=r:a.bottomside&&a.leftpin?s=r+1:a.bottomside&&a.rightpin?s=r*2:a.rightside&&a.bottompin?s=r*2+1:a.rightside&&a.toppin?s=r*3:a.topside&&a.rightpin?s=r*3+1:a.topside&&a.leftpin&&(s=r*4),i.push(-1);for(let A=0;A<t;A++)i[s]=A+1,s++,s>t&&(s=1);return i},Uvo=({num_pins:t=16,bodyWidth:e=9,bodyLength:n=9,bodyThickness:o=.8,thermalPadSize:i,padWidth:r=.25,padLength:s=.25,pitch:a=.5,thermalPadThickness:A=.05})=>{const c=Kvo({num_pins:t,cw:!0,ccw:!0}),l=[];for(let g=0;g<t;g++){const{x:u,y:d,o:h}=Ovo({pin_count:t,pn:g+1,w:e,h:n,p:a,pl:s});let _=r,m=s;h==="vert"&&([_,m]=[m,_]);const p=c[g+1];l.push({pn:p,x:u,y:d,pw:_,pl:m})}return to(dr,{children:[We(Nr,{color:"grey",children:We(un,{center:[0,0,o/2],size:[e,n,o]})}),l.map((g,u)=>We(un,{center:[g.x,g.y,A/2],size:[g.pw,g.pl,A]})),i?.length!==void 0&&i?.width!==void 0&&We(un,{center:[0,0,A/2],size:[i.width,i.length,A]})]})},Yvo=Uvo,zvo=()=>{const A=1.1999999999999997;return to(dr,{children:[We(Gr,{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}),We(Gr,{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}),We(Gr,{position:{x:-2.8/2-A/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:A,height:.95}),We(Gr,{position:{x:-2.8/2-A/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:A,height:.95}),We(Gr,{position:{x:-2.8/2-A/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:A,height:.95}),We(Wh,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},Vvo=zvo,Jvo=({fullWidth:t=2.9,fullLength:e=2.8})=>{const l=(t-1.92)/2+.3;return to(dr,{children:[We(Gr,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:l,height:.45}),We(Gr,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:l,height:.45}),We(Gr,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:l,height:.45}),We(Wh,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},Bwe=.6,Qwe=.3,KT=.33,TU=.1,qvo=Bwe-TU*2,J3t=({color:t="#333"})=>to(dr,{children:[We(un,{size:[qvo,Qwe,KT],offset:[0,0,KT/2],color:t}),We(un,{size:[TU,Qwe,KT],offset:[Bwe/2-TU/2,0,KT/2],color:"#ccc"}),We(un,{size:[TU,Qwe,KT],offset:[-Bwe/2+TU/2,0,KT/2],color:"#ccc"})]}),Swe=.4,bwe=.2,UT=.13,kU=.07,Wvo=Swe-kU*2,q3t=({color:t="#333"})=>to(dr,{children:[We(un,{size:[Wvo,bwe,UT],offset:[0,0,UT/2],color:t}),We(un,{size:[kU,bwe,UT],offset:[Swe/2-kU/2,0,UT/2],color:"#ccc"}),We(un,{size:[kU,bwe,UT],offset:[-Swe/2+kU/2,0,UT/2],color:"#ccc"})]}),Dwe=3.2,Pwe=1.6,YT=.9,FU=.5,jvo=Dwe-FU*2,W3t=({color:t="#333"})=>to(dr,{children:[We(un,{size:[jvo,Pwe,YT],offset:[0,0,YT/2],color:t}),We(un,{size:[FU,Pwe,YT],offset:[Dwe/2-FU/2,0,YT/2],color:"#ccc"}),We(un,{size:[FU,Pwe,YT],offset:[-Dwe/2+FU/2,0,YT/2],color:"#ccc"})]}),vwe=3.2,Mwe=2.5,zT=1,LU=.6,Xvo=vwe-LU*2,j3t=({color:t="#333"})=>to(dr,{children:[We(un,{size:[Xvo,Mwe,zT],offset:[0,0,zT/2],color:t}),We(un,{size:[LU,Mwe,zT],offset:[vwe/2-LU/2,0,zT/2],color:"#ccc"}),We(un,{size:[LU,Mwe,zT],offset:[-vwe/2+LU/2,0,zT/2],color:"#ccc"})]}),wwe=5,Nwe=2.5,VT=1.4,HU=.6,$vo=wwe-HU*2,X3t=({color:t="#333"})=>to(dr,{children:[We(un,{size:[$vo,Nwe,VT],offset:[0,0,VT/2],color:t}),We(un,{size:[HU,Nwe,VT],offset:[wwe/2-HU/2,0,VT/2],color:"#ccc"}),We(un,{size:[HU,Nwe,VT],offset:[-wwe/2+HU/2,0,VT/2],color:"#ccc"})]}),Rwe=6.3,Twe=3.2,JT=1.8,GU=.8,Zvo=Rwe-GU*2,$3t=({color:t="#333"})=>to(dr,{children:[We(un,{size:[Zvo,Twe,JT],offset:[0,0,JT/2],color:t}),We(un,{size:[GU,Twe,JT],offset:[Rwe/2-GU/2,0,JT/2],color:"#ccc"}),We(un,{size:[GU,Twe,JT],offset:[-Rwe/2+GU/2,0,JT/2],color:"#ccc"})]}),Z3t=({x:t,y:e,z:n=0,pitch:o=2.54,legsLength:i=3,innerDiameter:r=.945,bodyHeight:s=5,bodyLength:a=o,bodyWidth:A=o,flipZ:c})=>{const l=r||.945,g=l/1.5,u=l,d=u*1.8,h=Math.min(s*.18,o*.24),_=s+.1,m=c(n+_/2),p=n+s-h,I=g*1.6;return to(dr,{children:[We(Nr,{color:"#1a1a1a",children:to(Yf,{children:[We(un,{color:"#000",size:[a,A,s],center:[t,e,c(n+s/2)]}),We(un,{size:[u,u,_],center:[t,e,m]}),to($c,{children:[We(un,{size:[u,u,.01],center:[t,e,c(p)]}),We(un,{size:[d,d,.01],center:[t,e,c(n+s)]})]})]})}),to(Nr,{color:"silver",children:[to($c,{children:[We(un,{color:"silver",size:[g,g,i*.9],center:[t,e,c(n+-i/2*.9)]}),We(un,{color:"silver",size:[g/1.8,g/1.8,i],center:[t,e,c(n+-i/2)]})]}),We(un,{color:"silver",size:[I,I,I*.5],center:[t,e,c(n+I/2*.5)]})]})]})},eMo=({numberOfPins:t,pitch:e=2.54,legsLength:n=3,innerDiameter:o=.945,rows:i=1,invert:r})=>{const a=Math.ceil(t/i),A=2.54,c=-((a-1)/2)*e,l=g=>r?-g+5:g;return We(dr,{children:Array.from({length:t},(g,u)=>{const d=Math.floor(u/a),h=u%a,_=c+h*e,m=((i-1)/2-d)*A;return We(Z3t,{x:_,y:m,pitch:e,legsLength:n,innerDiameter:o,flipZ:l},u)})})},tMo=({width:t,length:e,innerDiameter:n=1})=>{const o=t,i=e,r=t*.7,s=n/2.5;return to(dr,{children:[We(vU,{color:"#1a1a1f",center:[0,0,r/2],size:[i,i,r],roundRadius:.3}),We(vU,{color:"#f2f2f2",center:[0,0,r+r*.1/2.5],size:[i,i,r*.1],roundRadius:.14}),We(Xc,{color:"#1a1a1f",height:r*.8,radius:o/3,center:[0,0,r+r*.8/2]}),We(Xc,{color:"#1a1a1f",height:r*.2,radius:n/2,center:[i/3,i/3,r+r*.1/2]}),We(Xc,{color:"#1a1a1f",height:r*.2,radius:n/2,center:[-i/3,-i/3,r+r*.1/2]}),We(Xc,{color:"#1a1a1f",height:r*.2,radius:n/2,center:[-i/3,i/3,r+r*.1/2]}),We(Xc,{color:"#1a1a1f",height:r*.2,radius:n/2,center:[i/3,-i/3,r+r*.1/2]}),We(Fie,{thickness:n/3,width:s,horizontalLength:i*.8,verticalLength:r/2,position:{x:-o/2,y:-i/2,z:-r*1.2}}),We(Fie,{thickness:n/3,width:s,horizontalLength:i*.8,verticalLength:r/2,position:{x:-o/2,y:i/2,z:-r*1.2},rotation:Math.PI}),We(Fie,{thickness:n/3,width:s,horizontalLength:i*.8,verticalLength:r/2,position:{x:o/2,y:i/2,z:-r*1.2},rotation:Math.PI}),We(Fie,{thickness:n/3,width:s,horizontalLength:i*.8,verticalLength:r/2,position:{x:o/2+n/3.6,y:-i/2,z:-r*1.2}})]})},Fie=t=>{const{thickness:e,width:n,horizontalLength:o,verticalLength:i,rotation:r=0,position:s}=t,a=[[0,o],[-i/3,o/3],[-i/5,o/4],[0,0]],A=pwe(a,e);return We(Nr,{color:"#f2f2f2",children:We(Ai,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:We(qh,{rotation:[0,55,r],children:We(wU,{height:n,children:We(MU,{points:A.map(c=>[c.y,c.x])})})})})})},nMo=({pinCount:t,leadLength:e,leadWidth:n,pitch:o,bodyWidth:i})=>{const r=Math.ceil(t/2),s=(r-1)*o/2,a=.25,A=1,c=.8,l=e*0,g=o*(r-1)+n+.2,u=i*.55;return to(dr,{children:[Array.from({length:r}).map((d,h)=>We(Gr,{position:{x:-i/2-l,y:h*o-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:c})),Array.from({length:r}).map((d,h)=>We(Gr,{rotation:Math.PI,position:{x:i/2+l,y:h*o-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:c})),We(Wh,{center:{x:0,y:0,z:a/2},width:u,length:g,height:A})]})},oMo=({pinCount:t,pitch:e,leadWidth:n,leadLength:o,bodyWidth:i,bodyLength:r})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},a=isNaN(parseFloat(e))?s.pitch:parseFloat(e),A=isNaN(parseFloat(n))?s.leadWidth:parseFloat(n)*.8,c=isNaN(parseFloat(i))?2.6:parseFloat(i)*.8,l=isNaN(parseFloat(r))?2+Number(a)*1.4:parseFloat(r),g=t/2,u=(g-1)*a/2,d=.15,h=.8,_=4.5,m=(_-c)/2,p=m*.5;return to(dr,{children:[Array.from({length:g}).map((I,f)=>We(Gr,{position:{x:-_/2,y:u-f*a,z:d/2},width:A,thickness:d,padContactLength:p+.05,bodyDistance:m+.1,height:h})),Array.from({length:g}).map((I,f)=>We(Gr,{rotation:Math.PI,position:{x:_/2,y:u-f*a,z:d/2},width:A,thickness:d,padContactLength:p+.05,bodyDistance:m+.1,height:h})),We(Wh,{center:{x:0,y:0,z:d/2},width:c,length:l,height:1})]})},iMo=()=>to(dr,{children:[We(un,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),We(un,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),We(Nr,{color:"#222",children:to(R_,{children:[We(Ai,{z:.3/2,children:We(un,{size:[1.65,.8,.3]})}),to($c,{children:[We(Ai,{z:.3,children:We(un,{size:[1.65,.8,.01]})}),We(Ai,{z:.6,children:We(un,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),rMo=()=>to(dr,{children:[We(un,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),We(un,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),We(Nr,{color:"#222",children:We(Ai,{z:.47/2+.02,children:We(un,{size:[.98,.58,.47]})})}),We(un,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),We(un,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),We(un,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),We(un,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),sMo=()=>{const c=We(Nr,{color:"#1a1a1a",children:to(R_,{children:[to($c,{children:[We(Ai,{z:.13,children:We(un,{size:[4,3,.03]})}),We(Ai,{z:1.15,children:We(un,{size:[4.4,3.4,.01]})})]}),to($c,{children:[We(Ai,{z:1.15,children:We(un,{size:[4.4,3.4,.01]})}),We(Ai,{z:2.3,children:We(un,{size:[4,3,.01]})})]})]})}),l=({xDir:g})=>{const h=g*1.78,_=g*(3.4/2-.2/2+1),m=g*(3.4/2-.2/2),p=Math.abs(m-_),I=(_+m)/2;return We(Nr,{color:"#c0c0c0",children:to(R_,{children:[We(un,{size:[2.3*.8,1.45,.2],center:[h,0,.2/2]}),We(un,{size:[.2,1.45,1.14],center:[_,0,1.14/2+.2]}),We(un,{size:[p,1.45,.2],center:[I,0,.2/2+1.14]})]})})};return to(dr,{children:[We(l,{xDir:1}),We(l,{xDir:-1}),c]})},aMo=()=>{const c=We(Nr,{color:"#1a1a1a",children:to(R_,{children:[to($c,{children:[We(Ai,{z:.13,children:We(un,{size:[4,3,.03]})}),We(Ai,{z:1.15,children:We(un,{size:[4.4,3.4,.01]})})]}),to($c,{children:[We(Ai,{z:1.15,children:We(un,{size:[4.4,3.4,.01]})}),We(Ai,{z:2.3,children:We(un,{size:[4,3,.01]})})]})]})}),l=({xDir:g})=>{const h=g*1.78,_=g*(3.4/2-.2/2+1),m=g*(3.4/2-.2/2),p=Math.abs(m-_),I=(_+m)/2;return We(Nr,{color:"#c0c0c0",children:to(R_,{children:[We(un,{size:[2.3*.8,1.45,.2],center:[h,0,.2/2]}),We(un,{size:[.2,1.45,1.14],center:[_,0,1.14/2+.2]}),We(un,{size:[p,1.45,.2],center:[I,0,.2/2+1.14]})]})})};return to(dr,{children:[We(l,{xDir:1}),We(l,{xDir:-1}),c]})},AMo=()=>{const c=We(Nr,{color:"#1a1a1a",children:to(R_,{children:[to($c,{children:[We(Ai,{z:.21000000000000002,children:We(un,{size:[6.3999999999999995,5.6,.03]})}),We(Ai,{z:1.15,children:We(un,{size:[6.8,6,.01]})})]}),to($c,{children:[We(Ai,{z:1.15,children:We(un,{size:[6.8,6,.01]})}),We(Ai,{z:2.3,children:We(un,{size:[6.3999999999999995,5.6,.01]})})]})]})}),l=({xDir:g})=>{const h=g*3.08,_=g*(6/2-.2/2+1),m=g*(6/2-.2/2),p=Math.abs(m-_),I=(_+m)/2;return We(Nr,{color:"#c0c0c0",children:to(R_,{children:[We(un,{size:[2.3*.8,2.95,.2],center:[h,0,.2/2]}),We(un,{size:[.2,2.95,1.14],center:[_,0,1.14/2+.2]}),We(un,{size:[p,2.95,.2],center:[I,0,.2/2+1.14]})]})})};return to(dr,{children:[We(l,{xDir:1}),We(l,{xDir:-1}),c]})},cMo=()=>{const g=We(Nr,{color:"#222",children:to(R_,{children:[We(Ai,{z:.27,children:We(un,{size:[2.9,1.9,.54]})}),to($c,{children:[We(Ai,{z:.54,children:We(un,{size:[2.9,1.9,.01]})}),We(Ai,{z:1.08,children:We(un,{size:[2.6999999999999997,1.7,.01]})})]})]})});return to(dr,{children:[We(un,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),We(un,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),g]})},lMo=()=>to(dr,{children:[We(un,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),We(un,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),We(Nr,{color:"#222",children:to(R_,{children:[We(Ai,{z:.55/2,children:We(un,{size:[2.7,1.6,.55]})}),to($c,{children:[We(Ai,{z:.55,children:We(un,{size:[2.7,1.6,.01]})}),We(Ai,{z:1.1,children:We(un,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),gMo=()=>to(dr,{children:[We(un,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),We(un,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),We(Nr,{color:"#222",children:to(R_,{children:[We(Ai,{z:.2/2,children:We(un,{size:[2.75,1.8,.2]})}),to($c,{children:[We(Ai,{z:.2,children:We(un,{size:[2.75,1.8,.01]})}),We(Ai,{z:1,children:We(un,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),We(un,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),uMo=()=>to(dr,{children:[We(un,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),We(un,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),We(Nr,{color:"#222",children:to(R_,{children:[to($c,{children:[We(Ai,{z:.2,children:We(un,{size:[2.6-.1/2,1.7-.1/2,.01]})}),We(Ai,{z:.01,children:We(un,{size:[2.6-.1,1.7-.1,.01]})})]}),to($c,{children:[We(Ai,{z:.2,children:We(un,{size:[2.6,1.7,.01]})}),We(Ai,{z:1,children:We(un,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),We(un,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),hMo=()=>to(dr,{children:[We(un,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),We(un,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),We(Nr,{color:"#222",children:to(R_,{children:[to($c,{children:[We(Ai,{z:.2,children:We(un,{size:[3.8-.05/2,2.5-.05/2,.01]})}),We(Ai,{z:.01,children:We(un,{size:[3.8-.05,2.5-.05,.01]})})]}),to($c,{children:[We(Ai,{z:.2,children:We(un,{size:[3.8,2.5,.01]})}),We(Ai,{z:1,children:We(un,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),We(un,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),dMo=()=>to(dr,{children:[We(un,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),We(un,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),We(Nr,{color:"#222",children:to(R_,{children:[We(Ai,{z:.14/2,children:We(un,{size:[.8,.6,.14]})}),to($c,{children:[We(Ai,{z:.14,children:We(un,{size:[.8,.6,.01]})}),We(Ai,{z:.37,children:We(un,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),_Mo=()=>{const l=3.0999999999999996;return to(dr,{children:[We(Gr,{rotation:Math.PI,position:{x:6.6/2+l/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:l,height:.75}),We(Gr,{position:{x:-6.6/2-l/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:l,height:.75}),We(Gr,{position:{x:-6.6/2-l/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:l,height:.75}),We(Gr,{position:{x:-6.6/2-l/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:l,height:.75}),We(Wh,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},mMo=()=>to(dr,{children:[Array.from({length:16}).map((d,h)=>We(Gr,{position:{x:-10.5/2,y:h*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((d,h)=>We(Gr,{rotation:Math.PI,position:{x:10.5/2,y:h*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((d,h)=>We(Gr,{rotation:Math.PI/2,position:{x:h*.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((d,h)=>We(Gr,{rotation:-Math.PI/2,position:{x:h*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),We(Wh,{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})]}),pMo=mMo,IMo=()=>{const c=.7999999999999998;return to(dr,{children:[We(Gr,{rotation:Math.PI,position:{x:2.05/2+c/4,y:0,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:c,height:.65}),We(Gr,{position:{x:-2.05/2-c/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:c,height:.65}),We(Gr,{position:{x:-2.05/2-c/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:c,height:.65}),We(Wh,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},fMo=({pinCount:t,pitch:e,leadWidth:n,padContactLength:o,bodyWidth:i})=>{const r=t/4;if(r!==Math.floor(r))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);e||(e=.5),o||(o=.6),n||(n=.22),i||(i=e*(r+4));const s=i,a=(r-1)*e/2,A=s+3.3*o,c=A,l=.8,g=.2,u=(c-i)/2+.4;return to(dr,{children:[Array.from({length:r}).map((d,h)=>We(Gr,{position:{x:-c/2-.36,y:h*e-a,z:g/2},width:n,thickness:g,padContactLength:o,bodyDistance:u,height:l})),Array.from({length:r}).map((d,h)=>We(Gr,{rotation:Math.PI,position:{x:c/2+.36,y:h*e-a,z:g/2},width:n,thickness:g,padContactLength:o,bodyDistance:u,height:l})),Array.from({length:r}).map((d,h)=>We(Gr,{rotation:Math.PI/2,position:{x:h*e-a,y:-A/2-.36,z:g/2},width:n,thickness:g,padContactLength:o,bodyDistance:u,height:l})),Array.from({length:r}).map((d,h)=>We(Gr,{rotation:-Math.PI/2,position:{x:h*e-a,y:A/2+.36,z:g/2},width:n,thickness:g,padContactLength:o,bodyDistance:u,height:l})),We(Wh,{center:{x:0,y:0,z:0},width:i,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})]})},CMo=()=>{const o=.20900000000000002,i=.1,r=.3,s=.1,a=.2;return to(dr,{children:[We(Nr,{color:"#222",children:to(R_,{children:[We(un,{size:[.85,1.2,o],center:[0,0,o/2]}),to($c,{children:[We(Ai,{z:o,children:We(un,{size:[.85,1.2,.01]})}),We(Ai,{z:.38,children:We(un,{size:[.85-i,1.2-i,.01]})})]})]})}),We(un,{color:"#ccc",size:[r,.25,s],center:[.55,0,s/2]}),We(un,{color:"#ccc",size:[r,a,s],center:[-.55,.4,s/2]}),We(un,{color:"#ccc",size:[r,a,s],center:[-.55,-.4,s/2]})]})},yMo=({num_pins:t,bodyWidth:e=5.3,bodyLength:n=5.3,bodyThickness:o=1,thermalPadSize:i,padWidth:r=n/5.3*.6,padLength:s=n/5.3*1,pitch:a=.5,thermalPadThickness:A=.2})=>{const c=[],l=Math.floor(t/2),g=a*(l-1);for(let u=0;u<t;u++){const d=u<l?"left":"right",h=u%l,_=g/2-h*a,m=s,p=r,I=d==="left"?-e/2+m/2:e/2-m/2,f=u+1;c.push({pinNumber:f,x:I,y:_,padSizeX:m,padSizeY:p})}return to(dr,{children:[We(Wh,{center:{x:0,y:0,z:0},width:e,length:n,height:o,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(e/2-s),y:n/2-s,z:o}}),c.map((u,d)=>We(un,{center:[u.x,u.y,A/2],size:[u.padSizeX,u.padSizeY,A]})),i?.length!==void 0&&i?.width!==void 0&&We(un,{center:[0,0,A/2],size:[i.width,i.length,A]})]})},EMo=({bodyLength:t=10.2,bodyWidth:e=4.65,bodyHeight:n=13.46,leadSpacing:o=5,leadDiameter:i=.8,leadLength:r=12.7,color:s="#ddd",leadColor:a="#b87333"})=>{const A=t/2,c=e/2,l=A-c,g=o/2,u=.85;return to(dr,{children:[to(Nr,{color:s,children:[to($c,{children:[We(by,{height:n,roundRadius:.5,radius:c,center:[-l,0,n]}),We(by,{height:n,roundRadius:.5,radius:c,center:[l,0,n]})]}),to($c,{children:[We(by,{height:u,roundRadius:.1,radius:c+.85,center:[-l,0,n/2+u/2]}),We(by,{height:u,roundRadius:.1,radius:c+.85,center:[l,0,n/2+u/2]})]})]}),to(Nr,{color:a,children:[We(Xc,{height:r+n/2,radius:i/2,center:[-g+.06,0,-(r/2)+n/2]}),We(Xc,{height:r+n/2,radius:i/2,center:[g-.06,0,-(r/2)+n/2]})]})]})},xMo=({bodyLength:t=1.4,bodyDiameter:e=1.1,color:n="#3a3a3aff",contactColor:o="#c6c6c6",cathodeIdentification:i="#111"})=>to(dr,{children:[We(Nr,{color:n,children:to(qh,{rotation:[0,"90deg",0],children:[We(vU,{size:[e,e,t-.2],roundRadius:.2,center:[-e/2,0,.05]}),We(Xc,{height:.2/2,radius:e/2-.2,center:[-e/2,0,-t/2+.2/2]})]})}),We(Nr,{color:i,children:We(qh,{rotation:[0,"90deg",0],children:We(vU,{size:[e*1.01,e*1.01,t/3],roundRadius:.2,center:[-e/2,0,-t/4+.1]})})}),We(Nr,{color:o,children:We(qh,{rotation:[0,"90deg",0],children:We(by,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,-t/2]})})}),We(Nr,{color:o,children:We(qh,{rotation:[0,"90deg",0],children:We(by,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,t/2]})})})]}),BMo=({bodyLength:t=3.5,bodyDiameter:e=1.5,color:n="#3a3a3aff",contactColor:o="#c6c6c6"})=>to(dr,{children:[We(Nr,{color:n,children:We(qh,{rotation:[0,"90deg",0],children:We(by,{height:t,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),We(Nr,{color:o,children:We(qh,{rotation:[0,"90deg",0],children:We(by,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,-t/2]})})}),We(Nr,{color:o,children:We(qh,{rotation:[0,"90deg",0],children:We(by,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,t/2]})})})]}),QMo=({bodyLength:t=3.9,bodyDiameter:e=2.5,color:n="#3a3a3aff",contactColor:o="#c6c6c6"})=>to(dr,{children:[We(Nr,{color:n,children:We(qh,{rotation:[0,"90deg",0],children:We(by,{height:t,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),We(Nr,{color:o,children:We(qh,{rotation:[0,"90deg",0],children:We(by,{height:.55,radius:e/2,roundRadius:.2,center:[-e/2,0,-t/2]})})}),We(Nr,{color:o,children:We(qh,{rotation:[0,"90deg",0],children:We(by,{height:.55,radius:e/2,roundRadius:.2,center:[-e/2,0,t/2]})})})]}),SMo=({pinCount:t,padContactLength:e=.6,leadWidth:n=.41,pitch:o=1.27})=>{if(t%2!==0)throw new Error("MS012 pinCount must be even");const i=t/2,r=4.9,s=3.9,a=(i-1)*o/2,A=.2;return to(dr,{children:[Array.from({length:i}).map((c,l)=>We(Gr,{position:{x:-s/2-e-.3,y:l*o-a,z:A/2},width:n,thickness:A,padContactLength:e,bodyDistance:e+.4,height:.85})),Array.from({length:i}).map((c,l)=>We(Gr,{rotation:Math.PI,position:{x:s/2+e+.3,y:l*o-a,z:A/2},width:n,thickness:A,padContactLength:e,bodyDistance:e+.4,height:.85})),We(Wh,{center:{x:0,y:0,z:A/2},width:s,length:r,height:1.55,notchPosition:{x:-.95,y:r/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},bMo=({pinCount:t=16,padContactLength:e=.6,leadWidth:n=.41,pitch:o=1.27})=>{if(t!==16)throw new Error("MS013 only supports 16 pins");const i=t/2,r=7.5,s=10.3,a=(i-1)*o/2,A=.2;return to(dr,{children:[Array.from({length:i}).map((c,l)=>We(Gr,{position:{x:-r/2-e-.3,y:l*o-a,z:A/2},width:n,thickness:A,padContactLength:e,bodyDistance:e+.4,height:.85})),Array.from({length:i}).map((c,l)=>We(Gr,{rotation:Math.PI,position:{x:r/2+e+.3,y:l*o-a,z:A/2},width:n,thickness:A,padContactLength:e,bodyDistance:e+.4,height:.85})),We(Wh,{center:{x:0,y:0,z:A/2},width:r,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},DMo=()=>{const _=7.050000000000001,m=24.95+6.5/2;return We(Ai,{center:[0,0,1],children:to(dr,{children:[to(qh,{rotation:[0,55,-55],children:[to(Yf,{children:[We(un,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[m,0,1.3-2]}),We(Xc,{color:"black",center:[m,0,1.3-2],radius:3/2,height:1.3*1.2})]}),We(Nr,{color:"#222",children:We(Wh,{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})})]}),We(qh,{rotation:[0,55,55],children:Array.from({length:3}).map((p,I)=>{const f=_,C=(I-1)*2.7,y=-.5-.6;return to(Nr,{color:"gold",children:[to($c,{children:[We(Ai,{center:[15.05-4.5/2+.1,C,y],children:We(un,{size:[4.5,.81+1,.5]})}),We(Ai,{center:[15.05-4.5/2-1+.1,C,y],children:We(un,{size:[4.5,.81,.5]})})]}),We(Ai,{center:[f,C,y],children:We(un,{size:[16+.1,.81,.5]})})]},`prong-${I}`)})})]})})},PMo=()=>{const c=1.1999999999999997;return to(dr,{children:[We(Gr,{rotation:Math.PI,position:{x:2.8/2+c/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),We(Gr,{rotation:Math.PI,position:{x:2.8/2+c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),We(Gr,{rotation:Math.PI,position:{x:2.8/2+c/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),We(Gr,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),We(Gr,{position:{x:-2.8/2-c/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),We(Gr,{position:{x:-2.8/2-c/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),We(Wh,{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})]})},vMo=()=>to(dr,{children:[We(Wh,{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(c=>{const l=-.35+c*.35;return We(un,{center:[-.8/2+.19/2-.1,l,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(c=>{const l=-.35+c*.35;return We(un,{center:[.8/2-.19/2+.1,l,.12/2],size:[.19,.15,.12]})})]}),MMo=()=>{const s="#222",A=[.43,.4,1.32],c=[.43,.4,.25],l=[0,0,-.66],g=[0,0,-1.32],u=[0,1.28,-2.72],d=[0,1.28,-8.9],h=-7.5;return to(Ai,{center:[0,1,10.5],children:[We(Nr,{color:s,children:to(Yf,{children:[We(Ai,{center:[0,0,2.25],children:We(Xc,{radius:2.4,height:4.5})}),We(Ai,{center:[0,-1.8499999999999999,2.25],children:We(un,{size:[2.4*2,1.1,4.5+.2]})})]})}),We(Ai,{center:l,children:We(un,{size:A})}),to($c,{children:[We(Ai,{center:g,children:We(un,{size:c})}),We(Ai,{center:u,children:We(un,{size:c})})]}),We(Ai,{center:d,children:We(un,{size:[.43,.4,12.2]})}),We(Ai,{center:[1.3,0,h],children:We(un,{size:[.43,.4,15]})}),We(Ai,{center:[-1.3,0,h],children:We(un,{size:[.43,.4,15]})})]})},wMo=()=>to(dr,{children:[We(Gr,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),We(Gr,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),We(Gr,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),We(Gr,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),We(Gr,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),We(Gr,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),We(Wh,{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})]}),NMo=wMo,RMo=()=>to(dr,{children:[We(Wh,{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(a=>{const A=-.5+a*.5;return We(un,{center:[-1/2+.3/2,A,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(a=>{const A=-.5+a*.5;return We(un,{center:[1/2-.3/2,A,.05/2],size:[.3,.2,.05]})})]}),TMo=()=>to(dr,{children:[We(Gr,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),We(Gr,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),We(Nr,{color:"#222",children:We(Wh,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),We(un,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),kMo=()=>to(dr,{children:[We(un,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),We(un,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),We(Nr,{color:"#222",children:to(R_,{children:[We(Ai,{z:.175/2,children:We(un,{size:[1.7,1.25,.175]})}),to($c,{children:[We(Ai,{z:.175,children:We(un,{size:[1.7,1.25,.01]})}),We(Ai,{z:.725,children:We(un,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),We(un,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),FMo=()=>{const s=-1.0474999999999999,a=1.775/2+.4/2-.04;return to(dr,{children:[We(un,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),We(un,{color:"#ccc",size:[.4,.325,.13],center:[a,0,.13/2]}),We(Nr,{color:"#222",children:We(Wh,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),We(un,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},LMo=({pitch:t=10})=>to(dr,{children:[We(Xc,{height:4,radius:.5,center:[-t/2,0,.5]}),We(Rie,{radius:.5,center:[-t/2,0,2.5]}),We(Ai,{x:-2.5,y:0,z:2.5,children:to(qh,{rotation:[0,Math.PI/2,0],children:[We(Xc,{height:t,radius:.5,center:[0,0,2.5]}),We(Nr,{color:"#d2b48c",children:We(Xc,{height:5,radius:1.3,center:[0,0,2.5]})})]})}),We(Xc,{height:4,radius:.5,center:[t/2,0,.5]}),We(Rie,{radius:.5,center:[t/2,0,2.5]})]}),HMo=({bodyWidth:t=21,boardThickness:e=.5,leadWidth:n=1.6,leadLength:o=2.4,leadsPitch:i=2.54,leadsLeft:r,leadsRight:s,leadsTop:a,leadsBottom:A,innerHoles:c=!0,innerHoleEdgeDistance:l=1.61,innerHoleDiameter:g=1})=>{const u=t/2,d=e/2,h=e*1.05,_=g/2,m=Math.max(r||0,s||0,a||0,A||0)*i||51,p=[],I=[];if(s){const E=-((s-1)/2)*i;for(let B=0;B<s;B++){const Q=E+B*i;p.push({x:u-o/2,y:-Q,pl:o,pw:n}),c&&I.push({x:u,y:-Q},{x:u-l,y:-Q})}}if(r){const E=-((r-1)/2)*i;for(let B=0;B<r;B++){const Q=E+B*i;p.push({x:-u+o/2,y:-Q,pl:o,pw:n}),c&&I.push({x:-u,y:-Q},{x:-u+l,y:-Q})}}if(a){const E=-((a-1)/2)*i;for(let B=0;B<a;B++){const Q=E+B*i;p.push({x:-Q,y:m/2-o/2,pl:n,pw:o}),c&&I.push({x:-Q,y:m/2},{x:-Q,y:m/2-l})}}if(A){const E=-((A-1)/2)*i;for(let B=0;B<A;B++){const Q=E+B*i;p.push({x:-Q,y:-m/2+o/2,pl:n,pw:o}),c&&I.push({x:-Q,y:-m/2},{x:-Q,y:-m/2+l})}}const f=We(Nr,{color:"#051a0a",children:to(Yf,{children:[We(un,{center:[0,0,d],size:[t,m,e]}),p.map((E,B)=>We(un,{center:[E.x,E.y,d],size:[E.pl+.01,E.pw+.01,h]},B))]})}),C=c&&I.map((E,B)=>We(Xc,{color:"black",center:[E.x,E.y,d],radius:_,height:e*1.07})),y=p.map((E,B)=>We(un,{center:[E.x,E.y,d],size:[E.pl+.01,E.pw+.01,h]}));return to(dr,{children:[f,We(Nr,{color:"#FFD700",children:c?to(Yf,{children:[We(R_,{children:p.map((E,B)=>We(un,{center:[E.x,E.y,d],size:[E.pl+.01,E.pw+.01,h]},B))}),C]}):y})]})},GMo=({width:t=30,height:e=22,thickness:n=1,bezelInset:o=2,bezelDepth:i=1,screenColor:r="#001414",bezelColor:s="#0f1116",screenWidth:a,screenHeight:A,offset:c})=>{const l=t,g=e,u=Math.max(n,.4),d=Math.max(Math.min(i,u),.2),h=Math.max(u-d,0),_=Math.max(o,0),m=Math.max(a??l-_*2,2),p=Math.max(A??g-_*2,2),I=Math.min(Math.max(d*.6,.2),d),f=c?.x??0,C=c?.y??0,y=c?.z??0;return to(Ai,{offset:{x:f,y:C,z:y},children:[h>0&&We(Nr,{color:s,children:We(un,{size:[l,g,h],offset:[0,0,h/2]})}),We(Nr,{color:s,children:to(Yf,{children:[We(un,{size:[l,g,d],offset:[0,0,h+d/2]}),We(un,{size:[m,p,d+.02],offset:[0,0,h+d/2]})]})}),We(Nr,{color:r,children:We(un,{size:[m,p,I],offset:[0,0,h+I/2]})})]})},OMo=({numPins:t=5,rows:e=1,p:n=2.54,id:o=1,od:i=1.5,boardThickness:r=1.6,width:s,height:a,pinRowSide:A="left",holes:c=[],holeInset:l=1,pinRowHoleEdgeToEdgeDist:g=2,female:u,nopin:d,screen:h,screenWidth:_,screenHeight:m,screenCenterOffsetX:p,screenCenterOffsetY:I})=>{const f=h??!1,C=r/2,y=Math.ceil(t/e);let E,B;A==="left"||A==="right"?(E=(e-1)*n+2*g,B=(y-1)*n+2*g):(B=(e-1)*n+2*g,E=(y-1)*n+2*g),t===0&&(E=10,B=10);const Q=Number(s??E),b=Number(a??B),D=[];let R=0,w=0,H=0,G=0,K=0,U=0;A==="left"||A==="right"?(R=A==="left"?-Q/2+g:Q/2-g,w=-((y-1)/2)*n,H=0,G=n,K=A==="left"?n:-n,U=0):(R=-((y-1)/2)*n,w=A==="top"?b/2-g:-b/2+g,H=n,G=0,K=0,U=A==="top"?-n:n);let q=0;for(let de=0;de<e&&q<t;de++)for(let Ee=0;Ee<y&&q<t;Ee++){const pe=R+Ee*H+de*K,we=w+Ee*G+de*U;D.push({x:pe,y:we}),q++}const W=[];if(c)for(const de of c){let Ee=0,pe=0;de==="topleft"?(Ee=-Q/2+l,pe=b/2-l):de==="topright"?(Ee=Q/2-l,pe=b/2-l):de==="bottomleft"?(Ee=-Q/2+l,pe=-b/2+l):de==="bottomright"?(Ee=Q/2-l,pe=-b/2+l):de==="center"&&(Ee=0,pe=0),W.push({x:Ee,y:pe})}const ee=.63,re=2,X=6,te=3,se=d||u?0:re,le=se+r,ue=We(Nr,{color:"#008080",children:to(Yf,{children:[We(un,{center:[0,0,C+se],size:[Q,b,r]}),W.map((de,Ee)=>We(Xc,{center:[de.x,de.y,C+se],radius:i/2,height:r},`hole-${Ee}`)),D.map((de,Ee)=>We(Xc,{center:[de.x,de.y,C+se],radius:i/2,height:r},`pin-hole-${Ee}`))]})}),Ce=D.map((de,Ee)=>We(Nr,{color:"#FFD700",children:to(Yf,{children:[We(Xc,{center:[de.x,de.y,r/2+se],radius:i/2,height:r}),We(Xc,{center:[de.x,de.y,r/2+se],radius:o/2,height:r})]})})),ye=D.map((de,Ee)=>We(V3t,{x:de.x,y:de.y,pinThickness:ee,shortSidePinLength:te,longSidePinLength:X,bodyHeight:re,flipZ:pe=>pe})),Be=D.map((de,Ee)=>We(Z3t,{x:de.x,y:de.y,flipZ:pe=>-pe}));return to(dr,{children:[ue,Ce,!u&&!d&&ye,u&&Be,f&&We(GMo,{width:_??Q*.8,height:m??b*.6,offset:{x:p??0,y:I??0,z:le}})]})},KMo=()=>{const s=.8999999999999999,a=-s/2+.5/2-.15,A=s/2-.5/2+.15,c=.2,l=.5*.24;return to(dr,{children:[We(un,{color:"#ccc",size:[.5,.28,.12],center:[a,0,.12/2]}),We(un,{color:"#ccc",size:[.5,.28,.12],center:[A,0,.12/2]}),We(Nr,{color:"#222",children:to(R_,{children:[We(Ai,{z:l/2,children:We(un,{size:[s,.6,l]})}),to($c,{children:[We(Ai,{z:l,children:We(un,{size:[s,.6,.01]})}),We(Ai,{z:.5,children:We(un,{size:[s-c,.6-c,.01]})})]})]})}),We(un,{color:"#777",size:[1.4/6,.6-c,.02],center:[-s/4,0,.5]})]})},UMo=KMo,YMo=({numPins:t=7,showPins:e=!0,showFootprint:n=!0,bodyColor:o="#f5f5f5",pinColor:i="#635959"})=>{const c=3.5999999999999996,l=6,g=(t-1)*1.5+4,u=-((t-1)*1.5)/2;return to(dr,{children:[We(Ai,{offset:[0,0,6],children:We(qh,{angles:[Math.PI,0,0],children:We(Nr,{color:o,children:to(Yf,{children:[We(un,{size:[g,3.5,6],center:[0,0,6/2]}),We(un,{size:[g-.5*2,3.5-.5*2,c],center:[0,0,c/2]}),We(un,{size:[g,3.5/3,c],center:[0,0,c/6]}),We(un,{size:[g-.5*2,.5/2,c],center:[0,3.5/2-.5/4,c/2]}),We(un,{size:[g-.5*2,.5/2,c],center:[0,-3.5/2+.5/4,c/2]}),We(un,{size:[1,.5+2,1],center:[-g/4,3.5/2,6/2]}),We(un,{size:[1,.5+3,1],center:[g/4,3.5/2,6/2]}),We(un,{size:[1,.5+2,1],center:[-g/4,-3.5/2,6/2]}),We(un,{size:[1,.5+3,1],center:[g/4,-3.5/2,6/2]})]})})})}),e&&Array.from({length:t}).map((d,h)=>We(Nr,{color:i,children:We(Xc,{height:l,radius:.35,center:[u+h*1.5,0,2.5]})})),n&&Array.from({length:t}).map((d,h)=>{const _=h===0,m=_?{type:"pcb_plated_hole",pcb_plated_hole_id:`jstzh_${h}`,shape:"circular_hole_with_rect_pad",x:u+h*1.5,y:0,hole_diameter:.73,rect_pad_width:1.03,rect_pad_height:1.73,hole_shape:"circle",pad_shape:"rect",layers:["top","bottom"],port_hints:[`${h+1}`]}:{type:"pcb_plated_hole",pcb_plated_hole_id:`jstzh_${h}`,shape:"pill",x:u+h*1.5,y:0,hole_height:.73,hole_width:.73,outer_height:1.73,outer_width:1.03,layers:["top","bottom"],port_hints:[`${h+1}`]};return We(Bvo,{hole:m,isPin1:_})})]})},zMo=({footprint:t})=>{let e=t;if(t.startsWith("jstzh1_5mm")){const r=t.match(/jstzh1_5mm(\d+)?/);e=`zh${r&&r[1]?r[1]:"7"}`}const n=xvo.string(e).json();switch(n.fn){case"dip":return We(Pvo,{numPins:n.num_pins,pitch:n.p,bodyWidth:n.w});case"axial":return We(LMo,{pitch:n.p});case"tssop":return We(Mvo,{pinCount:n.num_pins,leadLength:n.pl,leadWidth:n.pw,pitch:n.p,bodyWidth:n.w});case"msop":return We(wvo,{pinCount:n.num_pins,padContactLength:n.pl,leadWidth:n.pw,pitch:n.p,bodyWidth:n.w});case"vssop":return We(oMo,{pinCount:n.num_pins,leadLength:n.pl,leadWidth:n.pw,pitch:n.p,bodyWidth:n.w,bodyLength:n.h});case"qfp":return We(kvo,{pinCount:n.num_pins,pitch:n.p,leadWidth:n.pw,padContactLength:n.pl,bodyWidth:n.w});case"tqfp":return We(pMo,{});case"lqfp":return We(fMo,{pinCount:n.num_pins});case"qfn":{const r=typeof n.thermalpad?.x=="number"&&typeof n.thermalpad?.y=="number";return We(Yvo,{num_pins:n.num_pins,bodyWidth:n.w,bodyLength:n.h,pitch:n.p,padLength:n.pl,padWidth:n.pw,thermalPadSize:r?{width:n.thermalpad.x,length:n.thermalpad.y}:void 0})}case"dfn":{const r=typeof n.thermalpad?.x=="number"&&typeof n.thermalpad?.y=="number";return We(yMo,{num_pins:n.num_pins,bodyWidth:n.w,bodyLength:n.h,pitch:n.p,padLength:n.pl,padWidth:n.pw,thermalPadSize:r?{width:n.thermalpad.x,length:n.thermalpad.y}:void 0})}case"pinrow":{const r=t.match(/_rows(\d+)/),s=r&&r[1]?parseInt(r[1],10):1;if(n.male)return We(Gvo,{numberOfPins:n.num_pins,pitch:n.p,invert:n.invert,faceup:n.faceup,rows:s,smd:n.smd||n.surface_mount,rightangle:n.rightangle});if(n.female)return We(eMo,{numberOfPins:n.num_pins,pitch:n.p,rows:s})}case"cap":switch(n.imperial){case"0402":return We(U3t,{color:"#856c4d"});case"0603":return We(Y3t,{color:"#856c4d"});case"0805":return We(z3t,{color:"#856c4d"});case"0201":return We(J3t,{color:"#856c4d"});case"01005":return We(q3t,{color:"#856c4d"});case"1206":return We(W3t,{color:"#856c4d"});case"1210":return We(j3t,{color:"#856c4d"});case"2010":return We(X3t,{color:"#856c4d"});case"2512":return We($3t,{color:"#856c4d"})}case"sot235":return We(Vvo,{});case"sot457":return We(PMo,{});case"sot223":return We(_Mo,{});case"sot23w":return We(Jvo,{});case"sot323":return We(IMo,{});case"sod323f":return We(kMo,{});case"sod323fl":return We(FMo,{});case"sot363":return We(NMo,{});case"sot886":return We(RMo,{});case"sot963":return We(vMo,{});case"pushbutton":return We(tMo,{width:n.w,length:n.h,innerDiameter:n.id});case"jst":if(n.zh)return We(YMo,{numPins:n.num_pins});break;case"soic":return We(nMo,{pinCount:n.num_pins,leadLength:n.pl,leadWidth:n.pw,pitch:n.p,bodyWidth:n.w});case"sod523":return We(iMo,{});case"sod723":return We(UMo,{});case"sod882":return We(rMo,{});case"sma":return We(sMo,{});case"smb":return We(aMo,{});case"smc":return We(AMo,{});case"smf":return We(cMo,{});case"sod123f":return We(lMo,{});case"sod123fl":return We(gMo,{});case"sod123w":return We(uMo,{});case"sod128":return We(hMo,{});case"sod323":return We(TMo,{});case"sod923":return We(dMo,{});case"hc49":return We(EMo,{});case"micromelf":return We(xMo,{});case"minimelf":return We(BMo,{});case"melf":return We(QMo,{});case"ms012":return We(SMo,{pinCount:n.num_pins,padContactLength:n.pl,leadWidth:n.pw,pitch:n.p});case"ms013":return We(bMo,{pinCount:n.num_pins,padContactLength:n.pl,leadWidth:n.pw,pitch:n.p});case"sot723":return We(CMo,{});case"to220":return We(DMo,{});case"to92":return We(MMo,{});case"stampboard":case"stampreceiver":return We(HMo,{bodyWidth:n.w,leadsLeft:n.left,leadsRight:n.right,leadsTop:n.top,leadsBottom:n.bottom,leadsPitch:n.p,leadWidth:n.pw,leadLength:n.pl,innerHoles:n.innerhole,innerHoleEdgeDistance:n.innerholeedgedistance});case"mountedpcbmodule":{const r=n.rows??1,s=n.pinRowSide??"left",a=n.holeInset,A=n.width,c=n.height,l=n.pinrow,g=n.pinRowHoleEdgeToEdgeDist,u=Array.isArray(n.holes)?n.holes:[];return We(OMo,{numPins:l,rows:r,p:n.p,id:n.id,od:n.od,width:A,height:c,pinRowSide:s,holes:u,holeInset:a,pinRowHoleEdgeToEdgeDist:g,nopin:n.nopin,female:n.female,screen:n.screen,screenWidth:n.screenwidth,screenHeight:n.screenheight,screenCenterOffsetX:n.screencenteroffsetx,screenCenterOffsetY:n.screencenteroffsety})}}const o=t.match(/_color\(([^)]+)\)/),i=o?o[1]:void 0;switch(n.imperial){case"0402":return We(U3t,{color:i});case"0603":return We(Y3t,{color:i});case"0805":return We(z3t,{color:i});case"0201":return We(J3t,{color:i});case"01005":return We(q3t,{color:i});case"1206":return We(W3t,{color:i});case"1210":return We(j3t,{color:i});case"2010":return We(X3t,{color:i});case"2512":return We($3t,{color:i})}return null},VMo=t=>t&&typeof t=="object"&&"type"in t,qT=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const e=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(t);if(e)return parseFloat(e[1])*Math.PI/180;const n=Number(t);if(!Number.isNaN(n))return n}return 0},JMo=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 zS(t,e,n){const{jscad:{primitives:o,booleans:i,hulls:r,geometries:s,extrusions:a,transforms:A}}=n;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(u=>zS(u,e,n));if(!VMo(t))return[];const{type:c,props:l,children:g}=t;if(c===G3t)return(g??[]).flatMap(u=>zS(u,e,n));if(c===Nr){const u=l?.color;return(g??[]).flatMap(d=>zS(d,u??e,n))}if(c===Ai){const u=JMo(l?.offset??l?.center??{x:l?.x,y:l?.y,z:l?.z});return(g??[]).flatMap(h=>zS(h,e,n)).map(({geom:h,color:_})=>({geom:A.translate(u,h),color:_??e}))}if(c===qh){const u=Array.isArray(l?.rotation)?[qT(l.rotation[0]),qT(l.rotation[1]),qT(l.rotation[2])]:[qT(l?.x??0),qT(l?.y??0),qT(l?.z??0)];return(g??[]).flatMap(h=>zS(h,e,n)).map(({geom:h,color:_})=>({geom:A.rotateZ(u[2],A.rotateY(u[1],A.rotateX(u[0],h))),color:_}))}if(c===R_||c===Yf||c===$c){const u=(g??[]).flatMap(h=>zS(h,e,n)).map(h=>h.geom);if(u.length===0)return[];let d;return c===R_?d=i.union(u):c===Yf?d=i.subtract(u[0],u.slice(1)):d=r.hull(u),[{geom:d,color:e}]}if(c===MU){const u=l?.points??[];return[{geom:s.geom2.fromPoints(u),color:e??l?.color}]}if(c===wU){const u=(g??[]).flatMap(m=>zS(m,e,n)).map(m=>m.geom);if(u.length===0)return[];const d=u.length>1?i.union(u):u[0],h=l?.height??l?.h??1;let _=a.extrudeLinear({height:h},d);if(_.polygons)for(const m of _.polygons)!m.plane||!m.vertices||m.vertices.length<3||m.vertices.reverse();return[{geom:_,color:e??l?.color}]}if(c===un||c===O3t||c===Xc||c===Rie||c===vU||c===by){let u;if(c===un){const d=l?.size??[1,1,1],h=l?.offset,_=l?.center??(h?[h[0],h[1],h[2]]:[0,0,0]);u=o.cuboid({size:d,center:_})}else if(c===O3t){const d=l?.size??1,h=l?.offset,_=l?.center??(h?[h[0],h[1],h[2]]:[0,0,0]);u=o.cube({size:d,center:_})}else if(c===Xc){const d=l?.height??1,h=l?.radius??1,_=l?.center??[0,0,0];u=o.cylinder({height:d,radius:h,center:_})}else if(c===Rie){const d=l?.radius??1,h=l?.center??[0,0,0];u=o.sphere({radius:d,center:h})}else if(c===by){const d=l?.height??1,h=l?.radius??1,_=l?.roundRadius??.1,m=l?.center??[0,0,0];u=o.roundedCylinder({height:d,radius:h,roundRadius:_,center:m})}else{const d=l?.size??[1,1,1],h=l?.roundRadius??.1,_=l?.center??[0,0,0];u=o.roundedCuboid({size:d,roundRadius:h,center:_})}return[{geom:u,color:e??l?.color}]}if(typeof c=="function"){const u=c(l??{});return zS(u,e,n)}return(g??[]).flatMap(u=>zS(u,e,n))}function qMo(t,e){return{geometries:zS(t,void 0,{jscad:e})}}function e6t(t){if(t.polygons){const e=[],n=[],o=[];let i=0;for(const s of t.polygons){for(const A of s.vertices)A.index=i,e.push(A[0],A[1],A[2]),t.color&&t.color.length>=3?o.push(t.color[0],t.color[1],t.color[2]):o.push(1,1,1),i++;const a=s.vertices[0].index;for(let A=2;A<s.vertices.length;A++){const c=s.vertices[A-1].index,l=s.vertices[A].index;n.push(a,c,l)}}const r=new qc;if(r.setAttribute("position",new Hg(new Float32Array(e),3)),r.setIndex(n),o.length>0&&r.setAttribute("color",new Hg(new Float32Array(o),3)),t.transforms){const s=new ws;s.fromArray(t.transforms),r.applyMatrix4(s)}return r.computeVertexNormals(),r}if(t.sides){const e=[],n=[];for(const i of t.sides)e.push(i[0][0],i[0][1],0),t.color&&t.color.length>=3?n.push(t.color[0],t.color[1],t.color[2]):n.push(1,1,1);const o=new qc;if(o.setAttribute("position",new Hg(new Float32Array(e),3)),n.length>0&&o.setAttribute("color",new Hg(new Float32Array(n),3)),t.transforms){const i=new ws;i.fromArray(t.transforms),o.applyMatrix4(i)}return o}return console.error("Invalid CSG object: neither polygons nor sides found"),new qc}function WMo(t,e){const n=mwe(zMo,{footprint:t});return qMo(n,e)}var jMo=jc(Qie()),t6t=ne.createContext(null),XMo=()=>{const t=ne.useContext(t6t);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},$Mo=({children:t})=>{const{camera:e,renderer:n}=wI(),[o,i]=ne.useState([]),r=ne.useMemo(()=>new oCn,[]),s=ne.useMemo(()=>new Io,[]),a=ne.useRef(o);a.current=o;const A=ne.useRef(null),c=ne.useCallback(h=>{i(_=>[..._,h])},[]),l=ne.useCallback(h=>{if(A.current){let _=!1,m=A.current.object;for(;m;){if(m===h){_=!0;break}m=m.parent}_&&(A.current.onUnhover(),A.current=null)}i(_=>_.filter(m=>m.object!==h))},[]),g=ne.useCallback(h=>{let _=h;for(;_;){const m=a.current.find(p=>p.object===_);if(m)return m;_=_.parent}},[]),u=ne.useCallback(h=>{if(!n.domElement)return;const _=n.domElement.getBoundingClientRect();s.x=(h.clientX-_.left)/_.width*2-1,s.y=-((h.clientY-_.top)/_.height)*2+1,r.setFromCamera(s,e);const m=a.current.map(I=>I.object);if(m.length===0){A.current&&(A.current.onUnhover(),A.current=null);return}const p=r.intersectObjects(m,!0);if(p.length>0){const I=p[0],f=g(I.object);if(f){const C={mousePosition:[I.point.x,I.point.y,I.point.z]};A.current!==f?(A.current?.onUnhover(),f.onHover(C),A.current=f):f.onHover(C)}else A.current&&(A.current.onUnhover(),A.current=null)}else A.current&&(A.current.onUnhover(),A.current=null)},[e,n,r,s,g]);ne.useEffect(()=>{const h=n.domElement;return h.addEventListener("mousemove",u),()=>{h.removeEventListener("mousemove",u)}},[n,u]);const d=ne.useMemo(()=>({addHoverable:c,removeHoverable:l}),[c,l]);return j.jsx(t6t.Provider,{value:d,children:t})},ZMo=({children:t,object:e,onHover:n,onUnhover:o,isHovered:i})=>{const{addHoverable:r,removeHoverable:s}=XMo();return ne.useEffect(()=>e?(r({object:e,onHover:n,onUnhover:o}),()=>{s(e)}):void 0,[e,n,o,r,s]),j.jsx(j.Fragment,{children:t})},OU=ZMo,OB=(t,{castShadow:e=!0,receiveShadow:n=!0}={})=>{t.traverse(o=>{o instanceof Ui&&(o.castShadow=e,o.receiveShadow=n)})},ewo=({positionOffset:t,footprint:e,rotationOffset:n,onHover:o,onUnhover:i,isHovered:r,scale:s,isTranslucent:a=!1})=>{const{rootObject:A}=wI(),c=ne.useMemo(()=>{if(!e)return null;const{geometries:l}=WMo(e,jMo),g=new Ah;for(const u of l.flat(1/0)){const d=u.geom;if(!d||!d.polygons&&!d.sides)continue;const h=new Ei(u.color);h.convertLinearToSRGB();const _={...d,color:[h.r,h.g,h.b]},m=e6t(_),p=new ug({vertexColors:!0,side:gm,transparent:a,opacity:a?.5:1,depthWrite:!a}),I=new Ui(m,p);I.renderOrder=a?2:1,OB(I,{castShadow:!a,receiveShadow:!0}),g.add(I)}return g},[e,a]);return ne.useEffect(()=>{if(!(!c||!A))return A.add(c),()=>{A.remove(c)}},[A,c]),ne.useEffect(()=>{c&&(t&&c.position.fromArray(t),n&&c.rotation.fromArray(n),s!==void 0&&c.scale.setScalar(s))},[c,t?.[0],t?.[1],t?.[2],n?.[0],n?.[1],n?.[2],s]),ne.useEffect(()=>{c&&c.traverse(l=>{l instanceof Ui&&l.material instanceof ug&&(r?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[r,c]),c?j.jsx(OU,{isHovered:r,onHover:o,onUnhover:i,object:c}):null},n6t=new WeakMap,two=()=>{const t=new hu;return t.name="fallback-environment-map",t.mapping=jW,t},nwo=t=>{if(!t)return null;const e=t,n=n6t.get(e);if(n)return n;let o;if(t instanceof Dj){const i=new pme(t);o=i.fromScene(bCn(),.04).texture,i.dispose()}else o=two();return n6t.set(e,o),o};function owo(t){const e=new sy;let n=!1;t.updateWorldMatrix(!0,!1);const o=t.parent?t.parent.matrixWorld.clone().invert():new ws;return t.traverse(i=>{if(i.updateWorldMatrix(!0,!1),i instanceof Ui&&i.geometry&&(i.geometry.boundingBox||i.geometry.computeBoundingBox(),i.geometry.boundingBox)){const r=o.clone().multiply(i.matrixWorld),s=i.geometry.boundingBox.clone();s.applyMatrix4(r),n?e.union(s):(e.copy(s),n=!0)}}),n?e:null}function iwo(t){const e=owo(t);return e?e.getSize(new Dt):new Dt}function rwo(t,e,n="contain_within_bounds"){if(!e)return[1,1,1];const o=iwo(t),i=[o.x>0?e[0]/o.x:1,o.y>0?e[1]/o.y:1,o.z>0?e[2]/o.z:1];if(n==="fill_bounds")return i;const r=Math.min(...i);return[r,r,r]}var kwe=({model:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:r,modelSize:s,modelFitMode:a="contain_within_bounds",scale:A})=>{const{rootObject:c}=wI(),l=ne.useMemo(()=>new Ah,[]),g=ne.useMemo(()=>new Ah,[]),u=ne.useMemo(()=>new Ah,[]),d=ne.useMemo(()=>new Ah,[]);return ne.useEffect(()=>(l.add(g),()=>{l.remove(g)}),[l,g]),ne.useEffect(()=>(g.add(u),()=>{g.remove(u)}),[g,u]),ne.useEffect(()=>(u.add(d),()=>{u.remove(d)}),[u,d]),ne.useEffect(()=>{for(;d.children.length>0;){const h=d.children[0];if(!h)break;d.remove(h)}t&&d.add(t)},[d,t]),ne.useEffect(()=>{if(!r){d.matrixAutoUpdate=!0,d.position.set(0,0,0),d.rotation.set(0,0,0),d.scale.set(1,1,1),d.updateMatrix();return}d.matrixAutoUpdate=!1,d.matrix.copy(r),d.matrixWorldNeedsUpdate=!0},[d,r]),ne.useEffect(()=>{if(c)return c.add(l),()=>{c.remove(l)}},[c,l]),ne.useEffect(()=>{if(e?l.position.fromArray(e):l.position.set(0,0,0),n?l.rotation.fromArray(n):l.rotation.set(0,0,0),u.position.fromArray(o),u.rotation.fromArray(i),u.scale.setScalar(A??1),!t){g.scale.set(1,1,1);return}g.scale.set(1,1,1),g.updateWorldMatrix(!0,!0);const h=rwo(u,s,a);g.scale.set(h[0],h[1],h[2])},[l,g,t,a,o,d,u,i,s,e,n,A]),{boardTransformGroup:l}},o6t=1.25;function i6t({gltfUrl:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:r,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:A,onUnhover:c,isHovered:l,scale:g,isTranslucent:u=!1}){const{renderer:d}=wI(),[h,_]=ne.useState(null),[m,p]=ne.useState(null),{boardTransformGroup:I}=kwe({model:h,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:g});if(ne.useEffect(()=>{if(!t)return;const f=new PCn;let C=!0;return f.load(t,y=>{if(!C)return;const E=y.scene;E.traverse(B=>{if(B instanceof Ui&&B.material){const Q=b=>{b.transparent=u,b.opacity=u?.5:1,b.depthWrite=!u,b.needsUpdate=!0};Array.isArray(B.material)?B.material.forEach(Q):Q(B.material),B.renderOrder=u?2:1}}),OB(E,{castShadow:!u,receiveShadow:!0}),_(E)},void 0,y=>{if(!C)return;console.error(`An error happened loading ${t}`,y);const E=y instanceof Error?y:new Error(`Failed to load glTF model from ${t}`);p(E)}),()=>{C=!1}},[t,u]),ne.useEffect(()=>{if(!h||!d)return;const f=nwo(d);if(!f)return;const C=[],y=E=>{E instanceof ug&&(C.push({material:E,envMap:E.envMap??null,envMapIntensity:E.envMapIntensity??1}),E.envMap=f,(typeof E.envMapIntensity!="number"||E.envMapIntensity<o6t)&&(E.envMapIntensity=o6t),E.needsUpdate=!0)};return h.traverse(E=>{if(!(E instanceof Ui))return;const B=E.material;Array.isArray(B)?B.forEach(y):B&&y(B)}),()=>{C.forEach(({material:E,envMap:B,envMapIntensity:Q})=>{E.envMap=B,E.envMapIntensity=Q,E.needsUpdate=!0})}},[h,d]),ne.useEffect(()=>{h&&h.traverse(f=>{if(!(f instanceof Ui))return;const C=Array.isArray(f.material)?f.material:[f.material];for(const y of C)y instanceof ug&&(l?(y.emissive.setHex(255),y.emissiveIntensity=.2):y.emissiveIntensity=0)})},[l,h]),m)throw m;return h?j.jsx(OU,{isHovered:l,onHover:A,onUnhover:c,object:I}):null}var swo=jc(a3t()),awo=jc(Qie()),Awo=({jscadPlan:t,positionOffset:e,rotationOffset:n,modelOffset:o=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:r,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:A,onUnhover:c,isHovered:l,scale:g,isTranslucent:u=!1})=>{const{threeGeom:d,material:h}=ne.useMemo(()=>{const p=(0,swo.executeJscadOperations)(awo.default,t);if(!p||!p.polygons&&!p.sides)return{threeGeom:null,material:null};const I=e6t(p),f=new ug({vertexColors:!0,side:gm,transparent:u,opacity:u?.5:1,depthWrite:!u});return{threeGeom:I,material:f}},[t,u]),_=ne.useMemo(()=>{if(!d)return null;const p=new Ui(d,h);return p.renderOrder=u?2:1,OB(p,{castShadow:!u,receiveShadow:!0}),p},[d,h,u]),{boardTransformGroup:m}=kwe({model:_,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:g});return ne.useEffect(()=>{if(h)if(l){const p=new Ei(h.color.getHex());h.emissive.copy(p),h.emissive.setRGB(0,0,1),h.emissiveIntensity=.2}else h.emissiveIntensity=0},[l,h]),d?j.jsx(OU,{isHovered:l,onHover:A,onUnhover:c,object:m}):null};function cwo(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(e,n,o)=>`${n} ${o.replace(/-/g,"_")}`)}async function lwo(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch "${t}": ${e.status} ${e.statusText}`);const n=await e.text();return new d1n().parse(cwo(n),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function gwo(t){const[e,n]=ne.useState(null);return ne.useEffect(()=>{if(!t)return;const o=t.replace(/&cachebust_origin=$/,""),i=window.TSCIRCUIT_OBJ_LOADER_CACHE;let r=!1;async function s(){try{if(o.endsWith(".wrl"))return await lwo(o);const A=await fetch(o);if(!A.ok)throw new Error(`Failed to fetch "${o}": ${A.status} ${A.statusText}`);const c=await A.text(),l=c.match(/newmtl[\s\S]*?endmtl/g),g=new x1n;if(l?.length){const u=l.join(`
5470
- `).replace(/d 0\./g,"d 1."),d=c.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),h=new g1n;h.setMaterialOptions({invertTrProperty:!0});const _=h.parse(u.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return g.setMaterials(_),g.parse(d)}return g.parse(c.replace(/^mtllib.*/gm,""))}catch(A){return A}}function a(){if(i.has(o)){const c=i.get(o);return c.result?Promise.resolve(c.result.clone()):c.promise.then(l=>l instanceof Error?l:l.clone())}const A=s().then(c=>(c instanceof Error||i.set(o,{...i.get(o),result:c}),c));return i.set(o,{promise:A,result:null}),A}return a().then(A=>{r||n(A)}).catch(A=>{console.error(A)}),()=>{r=!0}},[t]),e}function uwo({url:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:r,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:A,onUnhover:c,isHovered:l,scale:g,isTranslucent:u=!1}){const d=gwo(t),h=ne.useMemo(()=>{if(d&&!(d instanceof Error))return d.traverse(p=>{if(p instanceof Ui&&p.material){const I=f=>{f.transparent=u,f.opacity=u?.5:1,f.depthWrite=!u,f.needsUpdate=!0};Array.isArray(p.material)?p.material.forEach(I):I(p.material),p.renderOrder=u?2:1}}),OB(d,{castShadow:!u,receiveShadow:!0}),d;const m=new Ui(new Ay(.5,.5,.5),new ug({transparent:!0,color:"red",opacity:.25}));return OB(m,{castShadow:!1,receiveShadow:!0}),m},[d,u]),{boardTransformGroup:_}=kwe({model:h,position:Array.isArray(e)?e:e?[e.x,e.y,e.z]:void 0,rotation:Array.isArray(n)?n:n?[n.x,n.y,n.z]:void 0,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:g});if(d instanceof Error)throw d;return j.jsx(OU,{isHovered:l,onHover:A,onUnhover:c,object:_})}var hwo=new Ei(.82,.82,.82),r6t=t=>new ug({color:t?new Ei(t[0],t[1],t[2]):hwo});function dwo(t,e){const n=r6t(e.color),o=e.brep_faces??[];if(o.length===0)return[n];const i=o.length>1?[...o].sort((g,u)=>g.first-u.first):o,r=[n],s=new Map,a=e.index.array.length/3;let A=0,c=0;const l=g=>{if(!g)return 0;const u=g.join(","),d=s.get(u);if(d!==void 0)return d;const h=r.length;return r.push(r6t(g)),s.set(u,h),h};for(;A<a;){const g=i[c];let u=a,d=0;g&&(A<g.first?u=g.first:(u=g.last+1,d=l(g.color),c+=1)),u>A&&t.addGroup(A*3,(u-A)*3,d),A=u}return r}function _wo(t){const e=new Ah;for(const n of t){const o=n.attributes.position?.array??[],i=n.index?.array??[];if(!o.length||!i.length)continue;const r=new qc;r.setAttribute("position",new Yr(o,3));const s=n.attributes.normal?.array??[];s.length?r.setAttribute("normal",new Yr(s,3)):r.computeVertexNormals(),r.setIndex(i),r.clearGroups();const a=dwo(r,n),A=new Ui(r,a.length>1?a:a[0]);A.name=n.name,e.add(A)}return e}var Fwe,mwo="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function pwo(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 Iwo(){if(!Fwe){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");Fwe=pwo(t)({locateFile:n=>`${mwo}/${n}`})}return Fwe}async function fwo(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch STEP file: ${e.statusText}`);const n=await e.arrayBuffer(),i=(await Iwo()).ReadStepFile(new Uint8Array(n),null);if(!i.success||!i.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const r=_wo(i.meshes),s=new epe;return await new Promise((A,c)=>{s.parse(r,l=>{l instanceof ArrayBuffer?A(l):c(new Error("GLTFExporter did not return binary output"))},l=>{c(l)},{binary:!0})})}var s6t="step-glb-cache:v2:";function Cwo(t){const e=new Uint8Array(t),n=32768;let o="";for(let i=0;i<e.length;i+=n){const r=e.subarray(i,i+n);o+=String.fromCharCode(...r)}return btoa(o)}function ywo(t){const e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o+=1)n[o]=e.charCodeAt(o);return n.buffer}function Ewo(t){try{const e=localStorage.getItem(`${s6t}${t}`);return e?ywo(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function a6t(t,e){try{const n=Cwo(e);localStorage.setItem(`${s6t}${t}`,n)}catch(n){console.warn("Failed to write STEP GLB cache",n)}}function xwo(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var Bwo=({stepUrl:t,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:A,onHover:c,onUnhover:l,isHovered:g,isTranslucent:u})=>{const[d,h]=ne.useState(null);return ne.useEffect(()=>{let _=!0,m=null,p=!0;const I=xwo(),f=Ewo(t);if(f){const E={arrayBuffer:f,blobUrl:URL.createObjectURL(new Blob([f],{type:"model/gltf-binary"}))};return I.completed.set(t,E),m=E.blobUrl,p=!1,h(E.blobUrl),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)}}const C=I.completed.get(t);if(C)return m=C.blobUrl,p=!1,h(C.blobUrl),a6t(t,C.arrayBuffer),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)};let y=I.inProgress.get(t);return y||(y=fwo(t).then(E=>{const B={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return I.completed.set(t,B),I.inProgress.delete(t),B}).catch(E=>{throw I.inProgress.delete(t),E}),I.inProgress.set(t,y)),y.then(E=>{_&&(m=E.blobUrl,p=!1,h(E.blobUrl),a6t(t,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),_&&h(null)}),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)}},[t]),d?j.jsx(i6t,{gltfUrl:d,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:A,onHover:c,onUnhover:l,isHovered:g,isTranslucent:u}):null};function Lie(t,e){let{x:n,y:o,z:i}=t;if(e.axisMapping){const r={x:n,y:o,z:i};e.axisMapping.x&&(n=Lwe(r,e.axisMapping.x)),e.axisMapping.y&&(o=Lwe(r,e.axisMapping.y)),e.axisMapping.z&&(i=Lwe(r,e.axisMapping.z))}if(n*=e.flipX??1,o*=e.flipY??1,i*=e.flipZ??1,e.rotation){if(e.rotation.x){const r=e.rotation.x*Math.PI/180,s=Math.cos(r),a=Math.sin(r),A=o*s-i*a,c=o*a+i*s;o=A,i=c}if(e.rotation.y){const r=e.rotation.y*Math.PI/180,s=Math.cos(r),a=Math.sin(r),A=n*s+i*a,c=-n*a+i*s;n=A,i=c}if(e.rotation.z){const r=e.rotation.z*Math.PI/180,s=Math.cos(r),a=Math.sin(r),A=n*s-o*a,c=n*a+o*s;n=A,o=c}}return{x:n,y:o,z:i}}function Lwe(t,e){switch(e){case"x":return t.x;case"y":return t.y;case"z":return t.z;case"-x":return-t.x;case"-y":return-t.y;case"-z":return-t.z;default:return 0}}var Hwe={STEP_INVERTED:{axisMapping:{x:"-x",y:"z",z:"-y"}},Z_UP_TO_Y_UP_USB_FIX:{axisMapping:{x:"x",y:"-z",z:"y"},flipZ:-1},FOOTPRINTER_MODEL_TRANSFORM:{axisMapping:{x:"x",y:"-z",z:"y"},flipX:-1,rotation:{x:180,y:180}}};function Qwo(t,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return Hwe.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?Hwe.STEP_INVERTED:Hwe.Z_UP_TO_Y_UP_USB_FIX}}function KU(t,e){return Qwo(t,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function Hie(t){if(!t)return;const e=Lie({x:1,y:0,z:0},t),n=Lie({x:0,y:1,z:0},t),o=Lie({x:0,y:0,z:1},t);return new ws().makeBasis(new Dt(e.x,e.y,e.z),new Dt(n.x,n.y,n.z),new Dt(o.x,o.y,o.z))}function Tv(t){return t*Math.PI/180}function Swo(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,Tv(-90),0];case"x-":return[0,Tv(90),0];case"y+":return[Tv(90),0,0];case"y-":return[Tv(-90),0,0];case"z-":return[Tv(180),0,0];default:return[0,0,0]}}function bwo(t,e,n){if(!t.position)return;let o=t.position.z;return e==="bottom"&&t.position.z>=0&&(o=-(t.position.z+n)),[t.position.x,t.position.y,o]}function Dwo(t,e){return t.rotation?[Tv(t.rotation.x),Tv(t.rotation.y),Tv(t.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function Pwo(t,e){const n=new Dt(t.x,t.y,t.z),o=new LC(e[0],e[1],e[2],"XYZ");return n.applyEuler(o),[n.x,n.y,n.z]}function vwo(t,e,n){if(!t.model_origin_position)return[0,0,0];const o=e?Lie(t.model_origin_position,e):t.model_origin_position;return Pwo(o,n)}function Mwo(t,e){const n=bwo(t,e.layer,e.pcbThickness),o=Dwo(t,e.layer),i=KU(t,e.modelType),r=Swo(t.model_board_normal_direction??"z+"),s=vwo(t,i,r);return{position:n,rotation:o,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:r,scale:t.model_unit_to_mm_scale_factor??void 0,fitMode:t.model_object_fit??"contain_within_bounds",size:t.size?[t.size.x,t.size.y,t.size.z]:void 0}}var wwo=t=>t.model_glb_url||t.model_gltf_url?t.model_glb_url?"glb":"gltf":t.model_obj_url||t.model_wrl_url||t.model_stl_url?t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj":t.model_jscad?"jscad":t.footprinter_string?"footprinter":t.model_step_url?"step":"unknown",Nwo=t=>t==="step"?"glb":t,Rwo=(t,e)=>{if(t)return e?e(t):t},Two=(...t)=>t,Gwe=class extends Xr.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}},kwo=({error:t,onError:e})=>(ne.useEffect(()=>{e(t)},[t,e]),null),A6t=({cad_component:t,circuitJson:e,resolveStaticAsset:n})=>{const o=l3t(e),[i,r]=ne.useState(!1),{visibility:s}=Q6(),[a,A]=ne.useState(null),c=ne.useCallback(U=>{U?.mousePosition?(r(!0),A(U.mousePosition)):(r(!1),A(null))},[]),l=ne.useCallback(()=>{r(!1),A(null)},[]),g=ne.useMemo(()=>Fi(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),u=ne.useMemo(()=>e.filter(q=>q.type==="pcb_plated_hole"&&q.pcb_component_id===t.pcb_component_id).length>0,[e,t.pcb_component_id]),d=ne.useCallback(U=>Rwo(U,n),[n]),h=d(t.model_wrl_url??t.model_stl_url??t.model_obj_url),_=d(t.model_glb_url??t.model_gltf_url),m=d(t.model_step_url),[p,I]=ne.useState(0),[f,C]=ne.useState(null);ne.useEffect(()=>{I(0),C(null)},[t.cad_component_id,h,_,m]);const E=e.find(U=>U.type==="pcb_component"&&U.source_component_id===t.source_component_id)?.layer??"top",B=wwo(t),Q=Nwo(B),b=t.model_glb_url?"glb":"gltf",D=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",R=ne.useMemo(()=>Mwo(t,{layer:E,pcbThickness:o,modelType:Q}),[t,E,o,Q]),w=Two(...R.rotation),H=R.position,G=ne.useMemo(()=>{const U=[];return _&&U.push(j.jsx(i6t,{gltfUrl:_,position:H,rotation:w,modelOffset:R.modelPosition,modelRotation:R.modelRotation,sourceCoordinateTransform:Hie(KU(t,b)),scale:R.scale,modelSize:R.size,modelFitMode:R.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${_}`)),h&&U.push(j.jsx(uwo,{url:h,position:H,rotation:w,modelOffset:R.modelPosition,modelRotation:R.modelRotation,sourceCoordinateTransform:Hie(KU(t,D)),scale:R.scale,modelSize:R.size,modelFitMode:R.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${h}`)),m&&!t.model_jscad&&!t.footprinter_string&&U.push(j.jsx(Bwo,{stepUrl:m,position:H,rotation:w,modelOffset:R.modelPosition,modelRotation:R.modelRotation,sourceCoordinateTransform:Hie(KU(t,Q)),scale:R.scale,modelSize:R.size,modelFitMode:R.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${m}`)),U},[H,t.cad_component_id,t.footprinter_string,t.model_jscad,t.show_as_translucent_model,_,b,c,l,i,D,R.modelPosition,R.modelRotation,R.scale,R.fitMode,R.size,Q,w,m,h]);let K=null;if(G.length>0){if(p>=G.length){if(f)throw f;return null}K=j.jsx(Gwe,{fallback:({error:U})=>j.jsx(kwo,{error:U,onError:q=>{C(q),I(W=>Math.max(W,p+1))}}),children:G[p]},`${t.cad_component_id}-fallback-${p}`)}else t.model_jscad?K=j.jsx(Awo,{jscadPlan:t.model_jscad,positionOffset:H,rotationOffset:w,modelOffset:R.modelPosition,modelRotation:R.modelRotation,sourceCoordinateTransform:Hie(KU(t,"jscad")),scale:R.scale,modelSize:R.size,modelFitMode:R.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(K=j.jsx(ewo,{positionOffset:H,rotationOffset:w,footprint:t.footprinter_string,scale:R.scale,onHover:c,onUnhover:l,isHovered:i,isTranslucent:t.show_as_translucent_model}));if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(u&&!s.throughHoleModels||!u&&!s.smtModels)return null;return j.jsxs(j.Fragment,{children:[K,i&&a?j.jsx(u3t,{position:a,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]})},c6t={version:"0.0.587"},l6t="cadViewerLightingEnabled",Fwo=()=>typeof window>"u"?!0:window.localStorage.getItem(l6t)!=="false",g6t=ne.createContext(void 0),Lwo=({children:t})=>{const[e,n]=ne.useState(!1),[o,i]=ne.useState(!1),[r,s]=ne.useState(Fwo);ne.useEffect(()=>{window.localStorage.setItem(l6t,r?"true":"false")},[r]);const a=ne.useMemo(()=>({darkBackgroundEnabled:e,setDarkBackgroundEnabled:n,gridEnabled:o,setGridEnabled:i,lightingEnabled:r,setLightingEnabled:s}),[e,o,r]);return j.jsx(g6t.Provider,{value:a,children:t})},Owe=()=>{const t=ne.useContext(g6t);if(!t)throw new Error("useAppearance must be used within an AppearanceProvider");return t},u6t="cadViewerCameraStateSession",h6t=(t,e)=>{try{const n={position:t.position.toArray(),quaternion:t.quaternion.toArray(),up:t.up.toArray(),fov:t.fov??50,target:e.target.toArray()};sessionStorage.setItem(u6t,JSON.stringify(n))}catch(n){console.warn("Failed to save camera:",n)}},Kwe=(t,e)=>{try{const n=sessionStorage.getItem(u6t);if(!n)return!1;const o=JSON.parse(n);if(t.position.fromArray(o.position),t.quaternion.fromArray(o.quaternion),t.up.fromArray(o.up),"fov"in t){const i=t;i.fov=o.fov,i.updateProjectionMatrix?.()}return e.target.fromArray(o.target),e.update(),t.updateMatrixWorld(),!0}catch(n){return console.warn("Failed to restore camera:",n),!1}},d6t=ne.createContext(void 0),Hwo=({children:t,defaultTarget:e,initialCameraPosition:n,initialCameraType:o})=>{const i=ne.useRef(null),r=ne.useRef(null),[s,a]=ne.useState(null),[A,c]=ne.useState(o??"perspective"),[l,g]=ne.useState(n??null),[u,d]=ne.useState(new LC(0,0,0)),h=ne.useMemo(()=>{const[I,f,C]=n??[5,-5,5],y=Math.hypot(I-e.x,f-e.y,C-e.z);return y>0?y:5},[n,e]),_=ne.useCallback(I=>{const f=[e.x,e.y,e.z],C=r.current,y=i.current;let E=h;switch(C&&y&&(E=C.position.distanceTo(y.target)),I){case"Top Center Angled":{const B=E/Math.sqrt(2);return{position:[e.x,e.y-B,e.z+B],target:f,up:[0,0,1]}}case"Top Down":return{position:[e.x,e.y,e.z+E],target:f,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-E*.6,e.y-E*.6,e.z+E*.6],target:f,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+E*.6,e.y-E*.6,e.z+E*.6],target:f,up:[0,0,1]};case"Left Sideview":return{position:[e.x-E,e.y,e.z],target:f,up:[0,0,1]};case"Right Sideview":return{position:[e.x+E,e.y,e.z],target:f,up:[0,0,1]};case"Front":return{position:[e.x,e.y-E,e.z],target:f,up:[0,0,1]};default:return null}},[h,e,r,i]),m=ne.useCallback(I=>{i.current=I},[]),p=ne.useMemo(()=>({controlsRef:i,mainCameraRef:r,defaultTarget:e,baseDistance:h,controller:s,setController:a,getPresetConfig:_,handleControlsChange:m,cameraType:A,setCameraType:c,cameraPosition:l,setCameraPosition:g,cameraRotation:u,setCameraRotation:d,saveCameraToSession:h6t,loadCameraFromSession:Kwe}),[e,h,s,_,m,A,l,u]);return j.jsx(d6t.Provider,{value:p,children:t})},a5=()=>{const t=ne.useContext(d6t);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},Gwo=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,Owo=()=>{const{controlsRef:t,mainCameraRef:e,defaultTarget:n,setController:o,getPresetConfig:i}=a5(),r=ne.useRef(null),s=ne.useRef(new FC),a=ne.useRef(new Dt),A=ne.useRef(new Dt),c=ne.useRef(new FC),l=ne.useRef(new FC),g=ne.useRef(new _l),u=ne.useRef(new _l),d=ne.useCallback(({position:_,target:m,up:p,durationMs:I=600})=>{if(!e.current)return;const f=t.current?.target??n,C=new Dt(_[0],_[1],_[2]),y=m?new Dt(m[0],m[1],m[2]):n.clone(),E=new Dt(...p??[0,0,1]).normalize(),B=u.current;B.position.copy(C),B.up.copy(E),B.lookAt(y);const Q=B.quaternion.clone(),b=e.current.quaternion.clone(),D=e.current.position.clone(),R=f.clone(),w=g.current;w.up.set(0,0,1),w.position.copy(D),w.lookAt(R);const H=w.quaternion.clone();w.up.set(0,0,1),w.position.copy(C),w.lookAt(y);const G=w.quaternion.clone(),K=H.clone().invert().multiply(b).normalize(),U=G.clone().invert().multiply(Q).normalize();r.current={fromPosition:D,toPosition:C,fromTarget:R,toTarget:y,toQuaternion:Q,rollFrom:K,rollTo:U,startTime:performance.now(),duration:I}},[e,t,n]),h=ne.useCallback(_=>{if(_==="Custom")return;const m=i(_);m&&d(m)},[d,i]);return ne.useEffect(()=>e.current?(o({animateTo:d,animateToPreset:h}),()=>{o(null)}):void 0,[d,h,e,o]),SU(()=>{if(!e.current||!r.current)return;const{fromPosition:_,toPosition:m,fromTarget:p,toTarget:I,toQuaternion:f,rollFrom:C,rollTo:y,startTime:E,duration:B}=r.current,Q=performance.now()-E,b=B<=0?1:Math.min(Q/B,1),D=Gwo(b);e.current.position.lerpVectors(_,m,D);const R=a.current;R.copy(p).lerp(I,D);const w=g.current;w.up.set(0,0,1),w.position.copy(e.current.position),w.lookAt(R);const H=s.current;H.copy(w.quaternion);const G=c.current;G.copy(C);const K=l.current;K.copy(y),C.dot(y)<0&&(K.x*=-1,K.y*=-1,K.z*=-1,K.w*=-1),K.normalize(),G.slerp(K,D),e.current.quaternion.copy(H).multiply(G).normalize();const U=A.current;U.set(0,1,0).applyQuaternion(e.current.quaternion).normalize(),e.current.up.copy(U),t.current?.target.copy(R),e.current.updateMatrixWorld(),t.current?.update(),b>=1&&(e.current.position.copy(m),e.current.quaternion.copy(f),e.current.up.set(0,0,1),e.current.updateMatrixWorld(),t.current?.target.copy(I),t.current?.update(),r.current=null)}),null},Kwo=()=>{const{controlsRef:t}=a5(),e=ne.useRef(null),n=ne.useRef(!1),o=ne.useRef(null),i=ne.useCallback(s=>{e.current=s,!n.current&&t.current&&Kwe(s,t.current)&&(n.current=!0)},[t]),r=ne.useCallback(()=>{if(!(!e.current||!t.current)){if(!n.current&&Kwe(e.current,t.current)){n.current=!0;return}clearTimeout(o.current),o.current=setTimeout(()=>{e.current&&t.current&&h6t(e.current,t.current)},150)}},[t]);return{handleCameraCreated:i,handleControlsChange:r}};function Uwo(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var Ywo=t=>{t.outputColorSpace=B2,t.toneMapping=Nqe,t.toneMappingExposure=1,t.shadowMap.enabled=!0,t.shadowMap.type=Pqe},zwo=ne.forwardRef(({children:t,scene:e,camera:n,style:o,onCreated:i},r)=>{const{cameraType:s}=a5(),a=ne.useRef(null),[A,c]=ne.useState(null),l=ne.useRef([]),g=ne.useRef(void 0);g.current=i;const u=ne.useRef(null),d=ne.useCallback(p=>{l.current.push(p)},[]),h=ne.useCallback(p=>{l.current=l.current.filter(I=>I!==p)},[]),_=ne.useMemo(()=>new Sw,[]);e?.up&&_.up.set(e.up.x,e.up.y,e.up.z);const m=ne.useRef(new _l);return ne.useImperativeHandle(r,()=>m.current),ne.useEffect(()=>{if(!a.current)return;Uwo(a.current);const p=new Dj({antialias:!0,alpha:!0});Ywo(p),p.setSize(a.current.clientWidth,a.current.clientHeight),p.setPixelRatio(window.devicePixelRatio),a.current.appendChild(p.domElement);const I=a.current.clientWidth/a.current.clientHeight,f=s==="perspective"?new hm(75,I,.1,1e3):new l7(-10*I,10*I,10,-10,-1e3,1e3);u.current?(f.position.copy(u.current.position),f.quaternion.copy(u.current.quaternion),f.up.copy(u.current.up)):(n?.up&&f.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&f.position.set(n.position[0],n.position[1],n.position[2]),f.lookAt(0,0,0)),_.add(m.current),window.__TSCIRCUIT_THREE_OBJECT=m.current,c({scene:_,camera:f,renderer:p,rootObject:m.current,addFrameListener:d,removeFrameListener:h}),g.current?.({camera:f,renderer:p});let C;const y=new Jfn,E=()=>{const Q=y.getElapsedTime(),b=y.getDelta();l.current.forEach(D=>D(Q,b)),p.render(_,f),C=requestAnimationFrame(E)};E();const B=()=>{if(a.current){const Q=a.current.clientWidth/a.current.clientHeight;f instanceof hm?f.aspect=Q:f instanceof l7&&(f.left=-10*Q,f.right=10*Q,f.top=10,f.bottom=-10),f.updateProjectionMatrix(),p.setSize(a.current.clientWidth,a.current.clientHeight)}};return window.addEventListener("resize",B),()=>{u.current={position:f.position.clone(),quaternion:f.quaternion.clone(),up:f.up.clone()},window.removeEventListener("resize",B),cancelAnimationFrame(C),a.current&&p.domElement&&a.current.removeChild(p.domElement),p.dispose(),_.remove(m.current),window.__TSCIRCUIT_THREE_OBJECT===m.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[_,d,h,s]),j.jsx("div",{ref:a,style:{width:"100%",height:"100%",...o},children:A&&j.jsx(g3t.Provider,{value:A,children:j.jsx($Mo,{children:t})})})}),Vwo=`
5470
+ `).replace(/^d\s+0\./gm,"d 1."),d=c.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),h=new g1n;h.setMaterialOptions({invertTrProperty:!0});const _=h.parse(u,"embedded.mtl");return g.setMaterials(_),g.parse(d)}return g.parse(c.replace(/^mtllib.*/gm,""))}catch(A){return A}}function a(){if(i.has(o)){const c=i.get(o);return c.result?Promise.resolve(c.result.clone()):c.promise.then(l=>l instanceof Error?l:l.clone())}const A=s().then(c=>(c instanceof Error||i.set(o,{...i.get(o),result:c}),c));return i.set(o,{promise:A,result:null}),A}return a().then(A=>{r||n(A)}).catch(A=>{console.error(A)}),()=>{r=!0}},[t]),e}function uwo({url:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:r,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:A,onUnhover:c,isHovered:l,scale:g,isTranslucent:u=!1}){const d=gwo(t),h=ne.useMemo(()=>{if(d&&!(d instanceof Error))return d.traverse(p=>{if(p instanceof Ui&&p.material){const I=f=>{f.transparent=u,f.opacity=u?.5:1,f.depthWrite=!u,f.needsUpdate=!0};Array.isArray(p.material)?p.material.forEach(I):I(p.material),p.renderOrder=u?2:1}}),OB(d,{castShadow:!u,receiveShadow:!0}),d;const m=new Ui(new Ay(.5,.5,.5),new ug({transparent:!0,color:"red",opacity:.25}));return OB(m,{castShadow:!1,receiveShadow:!0}),m},[d,u]),{boardTransformGroup:_}=kwe({model:h,position:Array.isArray(e)?e:e?[e.x,e.y,e.z]:void 0,rotation:Array.isArray(n)?n:n?[n.x,n.y,n.z]:void 0,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:g});if(d instanceof Error)throw d;return j.jsx(OU,{isHovered:l,onHover:A,onUnhover:c,object:_})}var hwo=new Ei(.82,.82,.82),r6t=t=>new ug({color:t?new Ei(t[0],t[1],t[2]):hwo});function dwo(t,e){const n=r6t(e.color),o=e.brep_faces??[];if(o.length===0)return[n];const i=o.length>1?[...o].sort((g,u)=>g.first-u.first):o,r=[n],s=new Map,a=e.index.array.length/3;let A=0,c=0;const l=g=>{if(!g)return 0;const u=g.join(","),d=s.get(u);if(d!==void 0)return d;const h=r.length;return r.push(r6t(g)),s.set(u,h),h};for(;A<a;){const g=i[c];let u=a,d=0;g&&(A<g.first?u=g.first:(u=g.last+1,d=l(g.color),c+=1)),u>A&&t.addGroup(A*3,(u-A)*3,d),A=u}return r}function _wo(t){const e=new Ah;for(const n of t){const o=n.attributes.position?.array??[],i=n.index?.array??[];if(!o.length||!i.length)continue;const r=new qc;r.setAttribute("position",new Yr(o,3));const s=n.attributes.normal?.array??[];s.length?r.setAttribute("normal",new Yr(s,3)):r.computeVertexNormals(),r.setIndex(i),r.clearGroups();const a=dwo(r,n),A=new Ui(r,a.length>1?a:a[0]);A.name=n.name,e.add(A)}return e}var Fwe,mwo="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function pwo(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 Iwo(){if(!Fwe){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");Fwe=pwo(t)({locateFile:n=>`${mwo}/${n}`})}return Fwe}async function fwo(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch STEP file: ${e.statusText}`);const n=await e.arrayBuffer(),i=(await Iwo()).ReadStepFile(new Uint8Array(n),null);if(!i.success||!i.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const r=_wo(i.meshes),s=new epe;return await new Promise((A,c)=>{s.parse(r,l=>{l instanceof ArrayBuffer?A(l):c(new Error("GLTFExporter did not return binary output"))},l=>{c(l)},{binary:!0})})}var s6t="step-glb-cache:v2:";function Cwo(t){const e=new Uint8Array(t),n=32768;let o="";for(let i=0;i<e.length;i+=n){const r=e.subarray(i,i+n);o+=String.fromCharCode(...r)}return btoa(o)}function ywo(t){const e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o+=1)n[o]=e.charCodeAt(o);return n.buffer}function Ewo(t){try{const e=localStorage.getItem(`${s6t}${t}`);return e?ywo(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function a6t(t,e){try{const n=Cwo(e);localStorage.setItem(`${s6t}${t}`,n)}catch(n){console.warn("Failed to write STEP GLB cache",n)}}function xwo(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var Bwo=({stepUrl:t,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:A,onHover:c,onUnhover:l,isHovered:g,isTranslucent:u})=>{const[d,h]=ne.useState(null);return ne.useEffect(()=>{let _=!0,m=null,p=!0;const I=xwo(),f=Ewo(t);if(f){const E={arrayBuffer:f,blobUrl:URL.createObjectURL(new Blob([f],{type:"model/gltf-binary"}))};return I.completed.set(t,E),m=E.blobUrl,p=!1,h(E.blobUrl),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)}}const C=I.completed.get(t);if(C)return m=C.blobUrl,p=!1,h(C.blobUrl),a6t(t,C.arrayBuffer),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)};let y=I.inProgress.get(t);return y||(y=fwo(t).then(E=>{const B={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return I.completed.set(t,B),I.inProgress.delete(t),B}).catch(E=>{throw I.inProgress.delete(t),E}),I.inProgress.set(t,y)),y.then(E=>{_&&(m=E.blobUrl,p=!1,h(E.blobUrl),a6t(t,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),_&&h(null)}),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)}},[t]),d?j.jsx(i6t,{gltfUrl:d,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:A,onHover:c,onUnhover:l,isHovered:g,isTranslucent:u}):null};function Lie(t,e){let{x:n,y:o,z:i}=t;if(e.axisMapping){const r={x:n,y:o,z:i};e.axisMapping.x&&(n=Lwe(r,e.axisMapping.x)),e.axisMapping.y&&(o=Lwe(r,e.axisMapping.y)),e.axisMapping.z&&(i=Lwe(r,e.axisMapping.z))}if(n*=e.flipX??1,o*=e.flipY??1,i*=e.flipZ??1,e.rotation){if(e.rotation.x){const r=e.rotation.x*Math.PI/180,s=Math.cos(r),a=Math.sin(r),A=o*s-i*a,c=o*a+i*s;o=A,i=c}if(e.rotation.y){const r=e.rotation.y*Math.PI/180,s=Math.cos(r),a=Math.sin(r),A=n*s+i*a,c=-n*a+i*s;n=A,i=c}if(e.rotation.z){const r=e.rotation.z*Math.PI/180,s=Math.cos(r),a=Math.sin(r),A=n*s-o*a,c=n*a+o*s;n=A,o=c}}return{x:n,y:o,z:i}}function Lwe(t,e){switch(e){case"x":return t.x;case"y":return t.y;case"z":return t.z;case"-x":return-t.x;case"-y":return-t.y;case"-z":return-t.z;default:return 0}}var Hwe={STEP_INVERTED:{axisMapping:{x:"-x",y:"z",z:"-y"}},Z_UP_TO_Y_UP_USB_FIX:{axisMapping:{x:"x",y:"-z",z:"y"},flipZ:-1},FOOTPRINTER_MODEL_TRANSFORM:{axisMapping:{x:"x",y:"-z",z:"y"},flipX:-1,rotation:{x:180,y:180}}};function Qwo(t,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return Hwe.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?Hwe.STEP_INVERTED:Hwe.Z_UP_TO_Y_UP_USB_FIX}}function KU(t,e){return Qwo(t,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function Hie(t){if(!t)return;const e=Lie({x:1,y:0,z:0},t),n=Lie({x:0,y:1,z:0},t),o=Lie({x:0,y:0,z:1},t);return new ws().makeBasis(new Dt(e.x,e.y,e.z),new Dt(n.x,n.y,n.z),new Dt(o.x,o.y,o.z))}function Tv(t){return t*Math.PI/180}function Swo(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,Tv(-90),0];case"x-":return[0,Tv(90),0];case"y+":return[Tv(90),0,0];case"y-":return[Tv(-90),0,0];case"z-":return[Tv(180),0,0];default:return[0,0,0]}}function bwo(t,e,n){if(!t.position)return;let o=t.position.z;return e==="bottom"&&t.position.z>=0&&(o=-(t.position.z+n)),[t.position.x,t.position.y,o]}function Dwo(t,e){return t.rotation?[Tv(t.rotation.x),Tv(t.rotation.y),Tv(t.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function Pwo(t,e){const n=new Dt(t.x,t.y,t.z),o=new LC(e[0],e[1],e[2],"XYZ");return n.applyEuler(o),[n.x,n.y,n.z]}function vwo(t,e,n){if(!t.model_origin_position)return[0,0,0];const o=e?Lie(t.model_origin_position,e):t.model_origin_position;return Pwo(o,n)}function Mwo(t,e){const n=bwo(t,e.layer,e.pcbThickness),o=Dwo(t,e.layer),i=KU(t,e.modelType),r=Swo(t.model_board_normal_direction??"z+"),s=vwo(t,i,r);return{position:n,rotation:o,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:r,scale:t.model_unit_to_mm_scale_factor??void 0,fitMode:t.model_object_fit??"contain_within_bounds",size:t.size?[t.size.x,t.size.y,t.size.z]:void 0}}var wwo=t=>t.model_glb_url||t.model_gltf_url?t.model_glb_url?"glb":"gltf":t.model_obj_url||t.model_wrl_url||t.model_stl_url?t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj":t.model_jscad?"jscad":t.footprinter_string?"footprinter":t.model_step_url?"step":"unknown",Nwo=t=>t==="step"?"glb":t,Rwo=(t,e)=>{if(t)return e?e(t):t},Two=(...t)=>t,Gwe=class extends Xr.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}},kwo=({error:t,onError:e})=>(ne.useEffect(()=>{e(t)},[t,e]),null),A6t=({cad_component:t,circuitJson:e,resolveStaticAsset:n})=>{const o=l3t(e),[i,r]=ne.useState(!1),{visibility:s}=Q6(),[a,A]=ne.useState(null),c=ne.useCallback(U=>{U?.mousePosition?(r(!0),A(U.mousePosition)):(r(!1),A(null))},[]),l=ne.useCallback(()=>{r(!1),A(null)},[]),g=ne.useMemo(()=>Fi(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),u=ne.useMemo(()=>e.filter(q=>q.type==="pcb_plated_hole"&&q.pcb_component_id===t.pcb_component_id).length>0,[e,t.pcb_component_id]),d=ne.useCallback(U=>Rwo(U,n),[n]),h=d(t.model_wrl_url??t.model_stl_url??t.model_obj_url),_=d(t.model_glb_url??t.model_gltf_url),m=d(t.model_step_url),[p,I]=ne.useState(0),[f,C]=ne.useState(null);ne.useEffect(()=>{I(0),C(null)},[t.cad_component_id,h,_,m]);const E=e.find(U=>U.type==="pcb_component"&&U.source_component_id===t.source_component_id)?.layer??"top",B=wwo(t),Q=Nwo(B),b=t.model_glb_url?"glb":"gltf",D=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",R=ne.useMemo(()=>Mwo(t,{layer:E,pcbThickness:o,modelType:Q}),[t,E,o,Q]),w=Two(...R.rotation),H=R.position,G=ne.useMemo(()=>{const U=[];return _&&U.push(j.jsx(i6t,{gltfUrl:_,position:H,rotation:w,modelOffset:R.modelPosition,modelRotation:R.modelRotation,sourceCoordinateTransform:Hie(KU(t,b)),scale:R.scale,modelSize:R.size,modelFitMode:R.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${_}`)),h&&U.push(j.jsx(uwo,{url:h,position:H,rotation:w,modelOffset:R.modelPosition,modelRotation:R.modelRotation,sourceCoordinateTransform:Hie(KU(t,D)),scale:R.scale,modelSize:R.size,modelFitMode:R.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${h}`)),m&&!t.model_jscad&&!t.footprinter_string&&U.push(j.jsx(Bwo,{stepUrl:m,position:H,rotation:w,modelOffset:R.modelPosition,modelRotation:R.modelRotation,sourceCoordinateTransform:Hie(KU(t,Q)),scale:R.scale,modelSize:R.size,modelFitMode:R.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${m}`)),U},[H,t.cad_component_id,t.footprinter_string,t.model_jscad,t.show_as_translucent_model,_,b,c,l,i,D,R.modelPosition,R.modelRotation,R.scale,R.fitMode,R.size,Q,w,m,h]);let K=null;if(G.length>0){if(p>=G.length){if(f)throw f;return null}K=j.jsx(Gwe,{fallback:({error:U})=>j.jsx(kwo,{error:U,onError:q=>{C(q),I(W=>Math.max(W,p+1))}}),children:G[p]},`${t.cad_component_id}-fallback-${p}`)}else t.model_jscad?K=j.jsx(Awo,{jscadPlan:t.model_jscad,positionOffset:H,rotationOffset:w,modelOffset:R.modelPosition,modelRotation:R.modelRotation,sourceCoordinateTransform:Hie(KU(t,"jscad")),scale:R.scale,modelSize:R.size,modelFitMode:R.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(K=j.jsx(ewo,{positionOffset:H,rotationOffset:w,footprint:t.footprinter_string,scale:R.scale,onHover:c,onUnhover:l,isHovered:i,isTranslucent:t.show_as_translucent_model}));if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(u&&!s.throughHoleModels||!u&&!s.smtModels)return null;return j.jsxs(j.Fragment,{children:[K,i&&a?j.jsx(u3t,{position:a,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]})},c6t={version:"0.0.588"},l6t="cadViewerLightingEnabled",Fwo=()=>typeof window>"u"?!0:window.localStorage.getItem(l6t)!=="false",g6t=ne.createContext(void 0),Lwo=({children:t})=>{const[e,n]=ne.useState(!1),[o,i]=ne.useState(!1),[r,s]=ne.useState(Fwo);ne.useEffect(()=>{window.localStorage.setItem(l6t,r?"true":"false")},[r]);const a=ne.useMemo(()=>({darkBackgroundEnabled:e,setDarkBackgroundEnabled:n,gridEnabled:o,setGridEnabled:i,lightingEnabled:r,setLightingEnabled:s}),[e,o,r]);return j.jsx(g6t.Provider,{value:a,children:t})},Owe=()=>{const t=ne.useContext(g6t);if(!t)throw new Error("useAppearance must be used within an AppearanceProvider");return t},u6t="cadViewerCameraStateSession",h6t=(t,e)=>{try{const n={position:t.position.toArray(),quaternion:t.quaternion.toArray(),up:t.up.toArray(),fov:t.fov??50,target:e.target.toArray()};sessionStorage.setItem(u6t,JSON.stringify(n))}catch(n){console.warn("Failed to save camera:",n)}},Kwe=(t,e)=>{try{const n=sessionStorage.getItem(u6t);if(!n)return!1;const o=JSON.parse(n);if(t.position.fromArray(o.position),t.quaternion.fromArray(o.quaternion),t.up.fromArray(o.up),"fov"in t){const i=t;i.fov=o.fov,i.updateProjectionMatrix?.()}return e.target.fromArray(o.target),e.update(),t.updateMatrixWorld(),!0}catch(n){return console.warn("Failed to restore camera:",n),!1}},d6t=ne.createContext(void 0),Hwo=({children:t,defaultTarget:e,initialCameraPosition:n,initialCameraType:o})=>{const i=ne.useRef(null),r=ne.useRef(null),[s,a]=ne.useState(null),[A,c]=ne.useState(o??"perspective"),[l,g]=ne.useState(n??null),[u,d]=ne.useState(new LC(0,0,0)),h=ne.useMemo(()=>{const[I,f,C]=n??[5,-5,5],y=Math.hypot(I-e.x,f-e.y,C-e.z);return y>0?y:5},[n,e]),_=ne.useCallback(I=>{const f=[e.x,e.y,e.z],C=r.current,y=i.current;let E=h;switch(C&&y&&(E=C.position.distanceTo(y.target)),I){case"Top Center Angled":{const B=E/Math.sqrt(2);return{position:[e.x,e.y-B,e.z+B],target:f,up:[0,0,1]}}case"Top Down":return{position:[e.x,e.y,e.z+E],target:f,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-E*.6,e.y-E*.6,e.z+E*.6],target:f,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+E*.6,e.y-E*.6,e.z+E*.6],target:f,up:[0,0,1]};case"Left Sideview":return{position:[e.x-E,e.y,e.z],target:f,up:[0,0,1]};case"Right Sideview":return{position:[e.x+E,e.y,e.z],target:f,up:[0,0,1]};case"Front":return{position:[e.x,e.y-E,e.z],target:f,up:[0,0,1]};default:return null}},[h,e,r,i]),m=ne.useCallback(I=>{i.current=I},[]),p=ne.useMemo(()=>({controlsRef:i,mainCameraRef:r,defaultTarget:e,baseDistance:h,controller:s,setController:a,getPresetConfig:_,handleControlsChange:m,cameraType:A,setCameraType:c,cameraPosition:l,setCameraPosition:g,cameraRotation:u,setCameraRotation:d,saveCameraToSession:h6t,loadCameraFromSession:Kwe}),[e,h,s,_,m,A,l,u]);return j.jsx(d6t.Provider,{value:p,children:t})},a5=()=>{const t=ne.useContext(d6t);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},Gwo=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,Owo=()=>{const{controlsRef:t,mainCameraRef:e,defaultTarget:n,setController:o,getPresetConfig:i}=a5(),r=ne.useRef(null),s=ne.useRef(new FC),a=ne.useRef(new Dt),A=ne.useRef(new Dt),c=ne.useRef(new FC),l=ne.useRef(new FC),g=ne.useRef(new _l),u=ne.useRef(new _l),d=ne.useCallback(({position:_,target:m,up:p,durationMs:I=600})=>{if(!e.current)return;const f=t.current?.target??n,C=new Dt(_[0],_[1],_[2]),y=m?new Dt(m[0],m[1],m[2]):n.clone(),E=new Dt(...p??[0,0,1]).normalize(),B=u.current;B.position.copy(C),B.up.copy(E),B.lookAt(y);const Q=B.quaternion.clone(),b=e.current.quaternion.clone(),D=e.current.position.clone(),R=f.clone(),w=g.current;w.up.set(0,0,1),w.position.copy(D),w.lookAt(R);const H=w.quaternion.clone();w.up.set(0,0,1),w.position.copy(C),w.lookAt(y);const G=w.quaternion.clone(),K=H.clone().invert().multiply(b).normalize(),U=G.clone().invert().multiply(Q).normalize();r.current={fromPosition:D,toPosition:C,fromTarget:R,toTarget:y,toQuaternion:Q,rollFrom:K,rollTo:U,startTime:performance.now(),duration:I}},[e,t,n]),h=ne.useCallback(_=>{if(_==="Custom")return;const m=i(_);m&&d(m)},[d,i]);return ne.useEffect(()=>e.current?(o({animateTo:d,animateToPreset:h}),()=>{o(null)}):void 0,[d,h,e,o]),SU(()=>{if(!e.current||!r.current)return;const{fromPosition:_,toPosition:m,fromTarget:p,toTarget:I,toQuaternion:f,rollFrom:C,rollTo:y,startTime:E,duration:B}=r.current,Q=performance.now()-E,b=B<=0?1:Math.min(Q/B,1),D=Gwo(b);e.current.position.lerpVectors(_,m,D);const R=a.current;R.copy(p).lerp(I,D);const w=g.current;w.up.set(0,0,1),w.position.copy(e.current.position),w.lookAt(R);const H=s.current;H.copy(w.quaternion);const G=c.current;G.copy(C);const K=l.current;K.copy(y),C.dot(y)<0&&(K.x*=-1,K.y*=-1,K.z*=-1,K.w*=-1),K.normalize(),G.slerp(K,D),e.current.quaternion.copy(H).multiply(G).normalize();const U=A.current;U.set(0,1,0).applyQuaternion(e.current.quaternion).normalize(),e.current.up.copy(U),t.current?.target.copy(R),e.current.updateMatrixWorld(),t.current?.update(),b>=1&&(e.current.position.copy(m),e.current.quaternion.copy(f),e.current.up.set(0,0,1),e.current.updateMatrixWorld(),t.current?.target.copy(I),t.current?.update(),r.current=null)}),null},Kwo=()=>{const{controlsRef:t}=a5(),e=ne.useRef(null),n=ne.useRef(!1),o=ne.useRef(null),i=ne.useCallback(s=>{e.current=s,!n.current&&t.current&&Kwe(s,t.current)&&(n.current=!0)},[t]),r=ne.useCallback(()=>{if(!(!e.current||!t.current)){if(!n.current&&Kwe(e.current,t.current)){n.current=!0;return}clearTimeout(o.current),o.current=setTimeout(()=>{e.current&&t.current&&h6t(e.current,t.current)},150)}},[t]);return{handleCameraCreated:i,handleControlsChange:r}};function Uwo(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var Ywo=t=>{t.outputColorSpace=B2,t.toneMapping=Nqe,t.toneMappingExposure=1,t.shadowMap.enabled=!0,t.shadowMap.type=Pqe},zwo=ne.forwardRef(({children:t,scene:e,camera:n,style:o,onCreated:i},r)=>{const{cameraType:s}=a5(),a=ne.useRef(null),[A,c]=ne.useState(null),l=ne.useRef([]),g=ne.useRef(void 0);g.current=i;const u=ne.useRef(null),d=ne.useCallback(p=>{l.current.push(p)},[]),h=ne.useCallback(p=>{l.current=l.current.filter(I=>I!==p)},[]),_=ne.useMemo(()=>new Sw,[]);e?.up&&_.up.set(e.up.x,e.up.y,e.up.z);const m=ne.useRef(new _l);return ne.useImperativeHandle(r,()=>m.current),ne.useEffect(()=>{if(!a.current)return;Uwo(a.current);const p=new Dj({antialias:!0,alpha:!0});Ywo(p),p.setSize(a.current.clientWidth,a.current.clientHeight),p.setPixelRatio(window.devicePixelRatio),a.current.appendChild(p.domElement);const I=a.current.clientWidth/a.current.clientHeight,f=s==="perspective"?new hm(75,I,.1,1e3):new l7(-10*I,10*I,10,-10,-1e3,1e3);u.current?(f.position.copy(u.current.position),f.quaternion.copy(u.current.quaternion),f.up.copy(u.current.up)):(n?.up&&f.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&f.position.set(n.position[0],n.position[1],n.position[2]),f.lookAt(0,0,0)),_.add(m.current),window.__TSCIRCUIT_THREE_OBJECT=m.current,c({scene:_,camera:f,renderer:p,rootObject:m.current,addFrameListener:d,removeFrameListener:h}),g.current?.({camera:f,renderer:p});let C;const y=new Jfn,E=()=>{const Q=y.getElapsedTime(),b=y.getDelta();l.current.forEach(D=>D(Q,b)),p.render(_,f),C=requestAnimationFrame(E)};E();const B=()=>{if(a.current){const Q=a.current.clientWidth/a.current.clientHeight;f instanceof hm?f.aspect=Q:f instanceof l7&&(f.left=-10*Q,f.right=10*Q,f.top=10,f.bottom=-10),f.updateProjectionMatrix(),p.setSize(a.current.clientWidth,a.current.clientHeight)}};return window.addEventListener("resize",B),()=>{u.current={position:f.position.clone(),quaternion:f.quaternion.clone(),up:f.up.clone()},window.removeEventListener("resize",B),cancelAnimationFrame(C),a.current&&p.domElement&&a.current.removeChild(p.domElement),p.dispose(),_.remove(m.current),window.__TSCIRCUIT_THREE_OBJECT===m.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[_,d,h,s]),j.jsx("div",{ref:a,style:{width:"100%",height:"100%",...o},children:A&&j.jsx(g3t.Provider,{value:A,children:j.jsx($Mo,{children:t})})})}),Vwo=`
5471
5471
  varying vec3 worldPosition;
5472
5472
  void main() {
5473
5473
  worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
@@ -5793,7 +5793,7 @@ test("${c} should solve problem correctly", () => {
5793
5793
  // Add more specific assertions based on expected output
5794
5794
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5795
5795
  })
5796
- `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),d=document.createElement("a");d.href=u,d.download=`${c}.test.ts`,d.click(),URL.revokeObjectURL(u)}catch(A){alert(`Error generating test.ts for ${t.constructor.name}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return j.jsxs("div",{className:`relative ${e}`,ref:i,children:[j.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&j.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:[j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},YHt=t=>t.activeSubSolver?[t,...YHt(t.activeSubSolver)]:[t],Sqo=({solver:t})=>{const e=YHt(t);return j.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>j.jsxs("div",{className:"flex items-center",children:[o>0&&j.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),j.jsx(Qqo,{solver:n})]},n.constructor.name))})},bqo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=ne.useReducer(_=>!_,!1),a=ne.useRef(void 0),A=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const m=_.getCurrentPhase();for(;_.getCurrentPhase()===m&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const m=Number(_);if(!Number.isFinite(m)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<m&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};ne.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),ne.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const d=t.getCurrentPhase!==void 0,h=d?t.getCurrentPhase():null;return j.jsxs("div",{className:"space-y-2 p-2 border-b",children:[j.jsx("div",{className:"flex items-center",children:j.jsx(Sqo,{solver:t})}),j.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[j.jsx("button",{onClick:A,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),j.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),j.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),j.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,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"}),d&&j.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),j.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",j.jsx("span",{className:"font-medium",children:h})]}),t.solved&&j.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&j.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&j.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Dqo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Pqo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=Dqo(t,e),r=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let A=0;if(i==="Completed"){const u=t.pipelineDef[e+1],d=u?t.firstIterationOfPhase?.[u.solverName]:void 0;d!==void 0&&s!==null?A=d-s:s!==null&&(A=a-s)}else i==="In Progress"&&s!==null&&(A=a-s);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},vqo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return j.jsx("span",{className:`font-medium ${e[t]}`,children:t})},Mqo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:j.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),j.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},wqo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),Nqo=({stats:t})=>{if(!t||Object.keys(t).length===0)return j.jsx("span",{children:"-"});const e=Object.entries(t),n=wqo(t);return j.jsxs("details",{className:"cursor-pointer",children:[j.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),j.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>j.jsxs("div",{children:[o,": ",String(i)]},o))})]})},M9e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(M9e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=M9e(o));return e},Rqo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=M9e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},Tqo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,A)=>Pqo(t,A)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):Rqo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return j.jsxs("div",{className:"border-t border-gray-200",children:[j.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:j.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),j.jsx("div",{className:"overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),j.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",j.jsx("sub",{children:"0"})]}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),j.jsx("tbody",{children:o.map(a=>j.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[j.jsx("td",{className:"px-4 py-2",children:j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),j.jsx("button",{onClick:()=>i(a.name),disabled:a.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 ${a.name} completes`,children:j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})})}),j.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(vqo,{status:a.status})}),j.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(Mqo,{progress:a.progress})}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),j.jsx("td",{className:"px-4 py-2 text-gray-500",children:j.jsx(Nqo,{stats:a.stats})}),j.jsx("td",{className:"px-4 py-2",children:a.solverInstance?j.jsxs("button",{onClick:()=>r(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})}),j.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},kqo=class extends Xr.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 Fqo({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(m,p)=>{typeof m=="number"&&(m<s&&(s=m),m>A&&(A=m)),typeof p=="number"&&(p<a&&(a=p),p>c&&(c=p))};for(const m of e)l(m.x,m.y);for(const m of n){const p=m.points??[];for(const I of p)l(I.x,I.y)}for(const m of o){const p=m.x??0,I=m.y??0,f=m.width??0,C=m.height??0;l(p,I),l(p+f,I+C)}for(const m of i){const p=m.x??0,I=m.y??0,f=m.radius??1;l(p-f,I-f),l(p+f,I+f)}for(const m of r)l(m.x,m.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const g=10,u=s-g,d=a-g,h=Math.max(1,A-s+2*g),_=Math.max(1,c-a+2*g);return j.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${d} ${h} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,p)=>j.jsx("rect",{x:m.x??0,y:m.y??0,width:m.width??0,height:m.height??0,fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`rect-${p}`)),n.map((m,p)=>j.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${p}`)),i.map((m,p)=>j.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.fillColor??"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`circle-${p}`)),e.map((m,p)=>j.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.color??"black"},`point-${p}`)),r.map((m,p)=>j.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${p}`))]})}var Lqo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=ne.useReducer(l=>l+1,0),s=ne.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=ne.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);ne.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const A=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return j.jsxs("div",{children:[j.jsx(bqo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?j.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):j.jsx(kqo,{fallback:j.jsx(Fqo,{graphics:s}),children:j.jsx(Bqo,{graphics:s})}),A&&j.jsx(Tqo,{solver:t,onStepUntilPhase:c})]})};const Hqo=()=>{ne.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},Gqo=1e3,ub=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},Gqo)},zHt=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},hb="https://github.com/tscircuit/tscircuit-autorouter/issues/new",VHt="https://github.com/tscircuit/copper-pour-solver/issues/new",JHt="https://github.com/tscircuit/calculate-packing/issues/new",Oqo="https://github.com/tscircuit/matchpack/issues/new",qHt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",Kqo={PackSolver2:JHt,LayoutPipelineSolver:Oqo,AutoroutingPipelineSolver:hb,AssignableAutoroutingPipeline2:hb,AssignableAutoroutingPipeline3:hb,AutoroutingPipeline1_OriginalUnravel:hb,AutoroutingPipelineSolver3_HgPortPointPathing:hb,AutoroutingPipelineSolver4:hb,AutoroutingPipelineSolver5:hb,AutoroutingPipelineSolver7_MultiGraph:hb,AutoroutingPipelineSolver8:hb,CopperPourPipelineSolver:VHt,SchematicTracePipelineSolver:qHt},Uqo=t=>t.toLowerCase().includes("pack")?hTo:t.toLowerCase().includes("rout")?CTo:sTo,WHt=t=>{const e=Kqo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?hb:n.includes("schematic")&&n.includes("trace")?qHt:n.includes("copperpour")?VHt:n.includes("pack")?JHt:null},Yqo=t=>`${zHt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,jHt=t=>{ub(JSON.stringify(t.solverParams,null,2),{fileName:Yqo(t),mimeType:"application/json"})},zqo=({solverEvent:t})=>{const e=WHt(t.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[j.jsxs(Sc,{type:"button",variant:"outline",size:"sm",onClick:()=>jHt(t),children:[j.jsx(c6e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?j.jsx(Sc,{asChild:!0,variant:"outline",size:"sm",children:j.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[j.jsx(Pre,{className:"rf-w-4 rf-h-4"}),"Report"]})}):j.jsxs(Sc,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[j.jsx(Pre,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},Vqo=({solverEvent:t})=>{const e=WHt(t.solverName);return e?j.jsx(Sc,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:j.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:j.jsx(Pre,{className:"rf-w-4 rf-h-4"})})}):j.jsx(Sc,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:j.jsx(Pre,{className:"rf-w-4 rf-h-4"})})},Jqo=({solverEvents:t=[]})=>{const[e,n]=ne.useState(null);Hqo();const o=ne.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=ne.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=ne.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=RBe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(RBe).join(", ")}`,classFound:!1};try{const A=r.solverParams,c=A?.input!==void 0?A.input:A;return{instance:new a(c),error:null,classFound:!0}}catch(A){const c=A instanceof Error?A.message:String(A);return console.error("Failed to reconstruct solver:",A),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?j.jsx("div",{className:"rf-p-4",children:j.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:j.jsxs("div",{className:"rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),j.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."})]})})}):j.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[j.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:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const A=o.get(a),c=e===a;return j.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const l=Uqo(A.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[j.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),j.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[j.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),j.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),j.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?j.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[j.jsx(zqo,{solverEvent:r}),j.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:j.jsx(tb,{fallback:j.jsx("div",{className:"rf-p-4",children:j.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),j.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:j.jsx(Lqo,{solver:s.instance})})})]}):j.jsxs("div",{className:"rf-p-4",children:[j.jsxs("div",{className:"rf-mb-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),j.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&j.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:j.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),j.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[j.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[j.jsx(Vqo,{solverEvent:r}),j.jsx(Sc,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>jHt(r),children:j.jsx(c6e,{className:"rf-w-4 rf-h-4"})})]})]}),j.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:j.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):j.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:j.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},XHt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{ne.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{z8.captureException(o)}catch{}}},[t,e]),ne.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{z8.captureException(i,{error_type:o.type})}catch{}}},[n])},qqo=t=>{ne.useEffect(()=>{try{IWt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},$Ht="0.0.2432",Wqo={version:$Ht},w9e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},N9e=new Map,jse=t=>{const e=N9e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},jqo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=N9e.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return N9e.set(n.name,i),{type:"tracked",store:t,...i}},ZHt=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...A}=e;let c;try{c=(r??(w9e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(w9e?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=jqo(a,c,A);let u=!0;i.setState=(_,m,p)=>{const I=n(_,m);if(!u)return I;const f=p===void 0?{type:s||"anonymous"}:typeof p=="string"?{type:p}:p;return a===void 0?(l?.send(f,o()),I):(l?.send({...f,type:`${a}/${f.type}`},{...jse(A.name),[a]:i.getState()}),I)};const d=(..._)=>{const m=u;u=!1,n(..._),u=m},h=t(i.setState,o,i);if(g.type==="untracked"?l?.init(h):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([_,m])=>[_,_===g.store?h:m.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let _=!1;const m=i.dispatch;i.dispatch=(...p)=>{(w9e?"production":void 0)!=="production"&&p[0].type==="__setState"&&!_&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),_=!0),m(...p)}}return l.subscribe(_=>{var m;switch(_.type){case"ACTION":if(typeof _.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return R9e(_.payload,p=>{if(p.type==="__setState"){if(a===void 0){d(p.state);return}Object.keys(p.state).length!==1&&console.error(`
5796
+ `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),d=document.createElement("a");d.href=u,d.download=`${c}.test.ts`,d.click(),URL.revokeObjectURL(u)}catch(A){alert(`Error generating test.ts for ${t.constructor.name}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return j.jsxs("div",{className:`relative ${e}`,ref:i,children:[j.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&j.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:[j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},YHt=t=>t.activeSubSolver?[t,...YHt(t.activeSubSolver)]:[t],Sqo=({solver:t})=>{const e=YHt(t);return j.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>j.jsxs("div",{className:"flex items-center",children:[o>0&&j.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),j.jsx(Qqo,{solver:n})]},n.constructor.name))})},bqo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=ne.useReducer(_=>!_,!1),a=ne.useRef(void 0),A=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const m=_.getCurrentPhase();for(;_.getCurrentPhase()===m&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const m=Number(_);if(!Number.isFinite(m)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<m&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};ne.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),ne.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const d=t.getCurrentPhase!==void 0,h=d?t.getCurrentPhase():null;return j.jsxs("div",{className:"space-y-2 p-2 border-b",children:[j.jsx("div",{className:"flex items-center",children:j.jsx(Sqo,{solver:t})}),j.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[j.jsx("button",{onClick:A,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),j.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),j.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),j.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,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"}),d&&j.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),j.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",j.jsx("span",{className:"font-medium",children:h})]}),t.solved&&j.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&j.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&j.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Dqo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Pqo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=Dqo(t,e),r=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let A=0;if(i==="Completed"){const u=t.pipelineDef[e+1],d=u?t.firstIterationOfPhase?.[u.solverName]:void 0;d!==void 0&&s!==null?A=d-s:s!==null&&(A=a-s)}else i==="In Progress"&&s!==null&&(A=a-s);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},vqo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return j.jsx("span",{className:`font-medium ${e[t]}`,children:t})},Mqo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:j.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),j.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},wqo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),Nqo=({stats:t})=>{if(!t||Object.keys(t).length===0)return j.jsx("span",{children:"-"});const e=Object.entries(t),n=wqo(t);return j.jsxs("details",{className:"cursor-pointer",children:[j.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),j.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>j.jsxs("div",{children:[o,": ",String(i)]},o))})]})},M9e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(M9e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=M9e(o));return e},Rqo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=M9e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},Tqo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,A)=>Pqo(t,A)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):Rqo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return j.jsxs("div",{className:"border-t border-gray-200",children:[j.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:j.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),j.jsx("div",{className:"overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),j.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",j.jsx("sub",{children:"0"})]}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),j.jsx("tbody",{children:o.map(a=>j.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[j.jsx("td",{className:"px-4 py-2",children:j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),j.jsx("button",{onClick:()=>i(a.name),disabled:a.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 ${a.name} completes`,children:j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})})}),j.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(vqo,{status:a.status})}),j.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(Mqo,{progress:a.progress})}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),j.jsx("td",{className:"px-4 py-2 text-gray-500",children:j.jsx(Nqo,{stats:a.stats})}),j.jsx("td",{className:"px-4 py-2",children:a.solverInstance?j.jsxs("button",{onClick:()=>r(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})}),j.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},kqo=class extends Xr.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 Fqo({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(m,p)=>{typeof m=="number"&&(m<s&&(s=m),m>A&&(A=m)),typeof p=="number"&&(p<a&&(a=p),p>c&&(c=p))};for(const m of e)l(m.x,m.y);for(const m of n){const p=m.points??[];for(const I of p)l(I.x,I.y)}for(const m of o){const p=m.x??0,I=m.y??0,f=m.width??0,C=m.height??0;l(p,I),l(p+f,I+C)}for(const m of i){const p=m.x??0,I=m.y??0,f=m.radius??1;l(p-f,I-f),l(p+f,I+f)}for(const m of r)l(m.x,m.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const g=10,u=s-g,d=a-g,h=Math.max(1,A-s+2*g),_=Math.max(1,c-a+2*g);return j.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${d} ${h} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,p)=>j.jsx("rect",{x:m.x??0,y:m.y??0,width:m.width??0,height:m.height??0,fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`rect-${p}`)),n.map((m,p)=>j.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${p}`)),i.map((m,p)=>j.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.fillColor??"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`circle-${p}`)),e.map((m,p)=>j.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.color??"black"},`point-${p}`)),r.map((m,p)=>j.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${p}`))]})}var Lqo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=ne.useReducer(l=>l+1,0),s=ne.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=ne.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);ne.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const A=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return j.jsxs("div",{children:[j.jsx(bqo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?j.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):j.jsx(kqo,{fallback:j.jsx(Fqo,{graphics:s}),children:j.jsx(Bqo,{graphics:s})}),A&&j.jsx(Tqo,{solver:t,onStepUntilPhase:c})]})};const Hqo=()=>{ne.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},Gqo=1e3,ub=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},Gqo)},zHt=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},hb="https://github.com/tscircuit/tscircuit-autorouter/issues/new",VHt="https://github.com/tscircuit/copper-pour-solver/issues/new",JHt="https://github.com/tscircuit/calculate-packing/issues/new",Oqo="https://github.com/tscircuit/matchpack/issues/new",qHt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",Kqo={PackSolver2:JHt,LayoutPipelineSolver:Oqo,AutoroutingPipelineSolver:hb,AssignableAutoroutingPipeline2:hb,AssignableAutoroutingPipeline3:hb,AutoroutingPipeline1_OriginalUnravel:hb,AutoroutingPipelineSolver3_HgPortPointPathing:hb,AutoroutingPipelineSolver4:hb,AutoroutingPipelineSolver5:hb,AutoroutingPipelineSolver7_MultiGraph:hb,AutoroutingPipelineSolver8:hb,CopperPourPipelineSolver:VHt,SchematicTracePipelineSolver:qHt},Uqo=t=>t.toLowerCase().includes("pack")?hTo:t.toLowerCase().includes("rout")?CTo:sTo,WHt=t=>{const e=Kqo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?hb:n.includes("schematic")&&n.includes("trace")?qHt:n.includes("copperpour")?VHt:n.includes("pack")?JHt:null},Yqo=t=>`${zHt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,jHt=t=>{ub(JSON.stringify(t.solverParams,null,2),{fileName:Yqo(t),mimeType:"application/json"})},zqo=({solverEvent:t})=>{const e=WHt(t.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[j.jsxs(Sc,{type:"button",variant:"outline",size:"sm",onClick:()=>jHt(t),children:[j.jsx(c6e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?j.jsx(Sc,{asChild:!0,variant:"outline",size:"sm",children:j.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[j.jsx(Pre,{className:"rf-w-4 rf-h-4"}),"Report"]})}):j.jsxs(Sc,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[j.jsx(Pre,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},Vqo=({solverEvent:t})=>{const e=WHt(t.solverName);return e?j.jsx(Sc,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:j.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:j.jsx(Pre,{className:"rf-w-4 rf-h-4"})})}):j.jsx(Sc,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:j.jsx(Pre,{className:"rf-w-4 rf-h-4"})})},Jqo=({solverEvents:t=[]})=>{const[e,n]=ne.useState(null);Hqo();const o=ne.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=ne.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=ne.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=RBe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(RBe).join(", ")}`,classFound:!1};try{const A=r.solverParams,c=A?.input!==void 0?A.input:A;return{instance:new a(c),error:null,classFound:!0}}catch(A){const c=A instanceof Error?A.message:String(A);return console.error("Failed to reconstruct solver:",A),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?j.jsx("div",{className:"rf-p-4",children:j.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:j.jsxs("div",{className:"rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),j.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."})]})})}):j.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[j.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:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const A=o.get(a),c=e===a;return j.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const l=Uqo(A.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[j.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),j.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[j.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),j.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),j.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?j.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[j.jsx(zqo,{solverEvent:r}),j.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:j.jsx(tb,{fallback:j.jsx("div",{className:"rf-p-4",children:j.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),j.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:j.jsx(Lqo,{solver:s.instance})})})]}):j.jsxs("div",{className:"rf-p-4",children:[j.jsxs("div",{className:"rf-mb-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),j.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&j.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:j.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),j.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[j.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[j.jsx(Vqo,{solverEvent:r}),j.jsx(Sc,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>jHt(r),children:j.jsx(c6e,{className:"rf-w-4 rf-h-4"})})]})]}),j.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:j.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):j.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:j.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},XHt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{ne.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{z8.captureException(o)}catch{}}},[t,e]),ne.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{z8.captureException(i,{error_type:o.type})}catch{}}},[n])},qqo=t=>{ne.useEffect(()=>{try{IWt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},$Ht="0.0.2433",Wqo={version:$Ht},w9e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},N9e=new Map,jse=t=>{const e=N9e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},jqo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=N9e.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return N9e.set(n.name,i),{type:"tracked",store:t,...i}},ZHt=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...A}=e;let c;try{c=(r??(w9e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(w9e?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=jqo(a,c,A);let u=!0;i.setState=(_,m,p)=>{const I=n(_,m);if(!u)return I;const f=p===void 0?{type:s||"anonymous"}:typeof p=="string"?{type:p}:p;return a===void 0?(l?.send(f,o()),I):(l?.send({...f,type:`${a}/${f.type}`},{...jse(A.name),[a]:i.getState()}),I)};const d=(..._)=>{const m=u;u=!1,n(..._),u=m},h=t(i.setState,o,i);if(g.type==="untracked"?l?.init(h):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([_,m])=>[_,_===g.store?h:m.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let _=!1;const m=i.dispatch;i.dispatch=(...p)=>{(w9e?"production":void 0)!=="production"&&p[0].type==="__setState"&&!_&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),_=!0),m(...p)}}return l.subscribe(_=>{var m;switch(_.type){case"ACTION":if(typeof _.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return R9e(_.payload,p=>{if(p.type==="__setState"){if(a===void 0){d(p.state);return}Object.keys(p.state).length!==1&&console.error(`
5797
5797
  [zustand devtools middleware] Unsupported __setState action format.
5798
5798
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5799
5799
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }