@tscircuit/runframe 0.0.2465 → 0.0.2467

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: ${d.polygon.vertices}
5468
5468
  `:A+=`
5469
5469
  `,d.children.length>0&&l.push(d.children)}return A}};e.exports=s}}),KQo=At({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,e){var n=LQo(),o=OQo(),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}}),YMe=At({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,e){e.exports={Tree:KQo()}}}),UQo=At({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,e){var n=Ls(),o=UMe(),{Tree:i}=YMe(),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}}),Owt=At({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,e){var n=Is(),o=fU(),i=UQo(),r=(...s)=>{s=n(s);let a=s.shift();return s.forEach(A=>{a=i(a,A)}),a=o(a),a};e.exports=r}}),YQo=At({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,e){var n=Is(),o=Ls(),i=Bv(),r=OMe(),s=KMe(),a=Owt(),A=(...c)=>{c=n(c);const l=c.map(h=>s({z0:-1,z1:1},h)),g=a(l),u=i(g);return r(u,o.toPolygons(g))};e.exports=A}}),zQo=At({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,e){var n=Is(),o=IU(),i=Vs(),r=Ls(),s=YQo(),a=Owt(),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}}),zMe=At({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,e){var n=ja(),o=VMt(),i=r=>o(r,{skipTriangulation:!0}).map(A=>{const c=A.map(l=>r[l]);return n.create(c)});e.exports=i}}),Kwt=At({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,e){var n=Ls(),o=UMe(),{Tree:i}=YMe(),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}}),VMe=At({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,e){var n=Is(),o=fU(),i=Kwt(),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}}),Uwt=At({"node_modules/@jscad/modeling/src/operations/minkowski/minkowskiSum.js"(t,e){var n=Is(),o=Ls(),i=ja(),r=zMe(),s=VMe(),a=(...h)=>{if(h=n(h),h.length!==2)throw new Error("minkowskiSum requires exactly two geometries");const[d,_]=h;if(!o.isA(d)||!o.isA(_))throw new Error("minkowskiSum requires geom3 geometries");const m=o.isConvex(d),p=o.isConvex(_);if(m&&p)return g(d,_);if(!m&&p)return A(d,_);if(m&&!p)return A(_,d);throw new Error("minkowskiSum of two non-convex geometries is not yet supported")},A=(h,d)=>{const _=c(h);if(_.length===0)return o.create();const m=_.map(p=>g(p,d));return m.length===1?m[0]:s(m)},c=h=>{const d=o.toPolygons(h);if(d.length===0)return[];const _=[];for(let m=0;m<d.length;m++){const p=d[m],f=p.vertices;let I=0,C=0,y=0;for(let w=0;w<f.length;w++)I+=f[w][0],C+=f[w][1],y+=f[w][2];I/=f.length,C/=f.length,y/=f.length;const E=i.plane(p),B=E[0],Q=E[1],b=E[2],D=.1,R=[I-B*D,C-Q*D,y-b*D];for(let w=1;w<f.length-1;w++){const H=f[0],G=f[w],O=f[w+1],U=l(R,H,G,O);_.push(o.create(U))}}return _},l=(h,d,_,m)=>[i.create([h,_,d]),i.create([h,d,m]),i.create([d,_,m]),i.create([_,h,m])],g=(h,d)=>{const _=u(h),m=u(d);if(_.length===0||m.length===0)return o.create();const p=[];for(let I=0;I<_.length;I++){const C=_[I];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 f=r(p);return o.create(f)},u=h=>{const d=new Set,_=[],m=o.toPolygons(h);for(let p=0;p<m.length;p++){const f=m[p].vertices;for(let I=0;I<f.length;I++){const C=f[I],y=`${C[0]},${C[1]},${C[2]}`;d.has(y)||(d.add(y),_.push(C))}}return _};e.exports=a}}),VQo=At({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,e){var n=ar(),o=Bv(),i=Ls(),r=c=>c.sort((l,g)=>l-g).filter((l,g,u)=>!g||l!==u[g-1]),s=(c,l,g)=>{const u=`${l}`,h=c.get(u);h===void 0?c.set(u,[g]):h.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,h=new Map,d=n.create();g.forEach((I,C)=>{I.vertices.forEach(y=>{s(h,n.snap(d,y,l),C)})});const _=g.map(I=>{let C=[];return I.vertices.forEach(y=>{C=C.concat(a(h,n.snap(d,y,l)))}),{e:1,d:r(C)}});h.clear();let m=0;const p=_.length;for(let I=0;I<p;I++){const C=_[I];if(C.e>0){const y=new Array(u);y[I]=!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 f=[];for(let I=0;I<p;I++)if(_[I].indexes){const C=[];_[I].indexes.forEach((y,E)=>C.push(g[E])),f.push(i.create(C))}return f};e.exports=A}}),JQo=At({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,e){var n=Is(),o=Ls(),i=VQo(),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}}),qQo=At({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,e){var n=Ls(),o=UMe(),{Tree:i}=YMe(),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}}),Ywt=At({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,e){var n=Is(),o=fU(),i=qQo(),r=(...s)=>{s=n(s);let a=s.shift();return s.forEach(A=>{a=i(a,A)}),a=o(a),a};e.exports=r}}),WQo=At({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,e){var n=Is(),o=Ls(),i=Bv(),r=OMe(),s=KMe(),a=Ywt(),A=(...c)=>{c=n(c);const l=c.map(h=>s({z0:-1,z1:1},h)),g=a(l),u=i(g);return r(u,o.toPolygons(g))};e.exports=A}}),jQo=At({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,e){var n=Is(),o=IU(),i=Vs(),r=Ls(),s=WQo(),a=Ywt(),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}}),zwt=At({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,e){var n=Is(),o=Ls(),i=Bv(),r=OMe(),s=KMe(),a=VMe(),A=(...c)=>{c=n(c);const l=c.map(h=>s({z0:-1,z1:1},h)),g=a(l),u=i(g);return r(u,o.toPolygons(g))};e.exports=A}}),JMe=At({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,e){var n=Is(),o=IU(),i=Vs(),r=Ls(),s=zwt(),a=VMe(),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}}),CU=At({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,e){e.exports={intersect:zQo(),minkowski:Uwt(),scission:JQo(),subtract:jQo(),union:JMe()}}}),Aie=At({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,e){var{EPS:n,TAU:o}=uA(),i=Cwt(),r=kMe(),s=pa(),a=rie(),A=(c,l)=>{const g={delta:1,corners:"edge",closed:!1,segments:16};let{delta:u,corners:h,closed:d,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 f=null,I=[];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(f!=null&&(d||!d&&Q!==0)){const G=i(f[0],f[1],H[0],H[1]);G?(I.pop(),H[0]=G):C.push({c:b,s0:f,s1:H})}f=[R,w],!(Q===0&&!d)&&(I.push(H[0]),I.push(H[1]))}if(d&&f!=null){const B=I[0],Q=I[1],b=i(f[0],f[1],B,Q);if(b)I[0]=b,I.pop();else{const D=l[0],R=[B,Q];C.push({c:D,s0:f,s1:R})}}if(h==="edge"){const B=new Map;I.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);I[H]=R,I[(H+1)%I.length]=void 0}else{const w=D.s1[0],H=B.get(w);I[H]=void 0}}),I=I.filter(D=>D!==void 0)}if(h==="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 O=w+R*G,U=s.fromAngleRadians(s.create(),O);s.scale(U,U,u),s.add(U,U,b.c),H.push(U)}if(H.length>0){const G=b.s0[1];let O=I.findIndex(U=>s.equals(G,U));O=(O+1)%I.length,I.splice(O,0,...H)}}else{const R=b.s1[0],w=I.findIndex(H=>s.equals(R,H));I.splice(w,1)}})}return I};e.exports=A}}),XQo=At({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,e){var n=Vs(),o=Aie(),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 h=n.toOutlines(s).map(d=>(r={delta:A,corners:c,closed:!0,segments:l},o(r,d))).reduce((d,_)=>d.concat(n.toSides(n.fromPoints(_))),[]);return n.create(h)};e.exports=i}}),$Qo=At({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,e){var n=Cg(),o=ar(),i=Ls(),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 h=0;h<u;h++){const d=h<u-1?h+1:0,_=r.create([A.vertices[h],g.vertices[h],g.vertices[d],A.vertices[d]]);l.push(_)}return l.push(r.invert(g)),i.create(l)};e.exports=s}}),ZQo=At({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,e){var{EPS:n,TAU:o}=uA(),i=Cg(),r=ar(),s=Hwt(),a=Ls(),A=ja(),c=wwt(),l=fU(),g=Kwt(),u=$Qo(),h=(p,f,I)=>{const C=f.toString();if(p.has(C))p.get(C)[1].push(I);else{const y=[f,[I]];p.set(C,y)}},d=(p,f,I)=>{const C=f[0].toString(),y=f[1].toString(),E=C<y?`${C},${y}`:`${y},${C}`;if(p.has(E))p.get(E)[1].push(I);else{const B=[f,[I]];p.set(E,B)}},_=(p,f)=>{p.findIndex(C=>C===f)<0&&p.push(f)},m=(p,f)=>{const I={delta:1,segments:12},{delta:C,segments:y}=Object.assign({},I,p);let E=a.create();const B=new Map,Q=new Map,b=r.create(),D=r.create();return a.toPolygons(f).forEach((w,H)=>{const G=r.scale(r.create(),A.plane(w),2*C),O=A.transform(i.fromTranslation(i.create(),r.scale(r.create(),G,-.5)),w),U=u(G,O);E=g(E,U);const W=w.vertices;for(let j=0;j<W.length;j++){h(B,W[j],A.plane(w));const te=(j+1)%W.length,re=[W[j],W[te]];d(Q,re,A.plane(w))}}),Q.forEach(w=>{const H=w[0],G=w[1],O=H[0],U=H[1],W=r.subtract(r.create(),U,O);r.normalize(W,W);const j=G[0],te=r.cross(r.create(),j,W);let re=[];for(let Be=0;Be<y;Be++)_(re,Be*o/y);for(let Be=0,he=G.length;Be<he;Be++){const ye=G[Be],me=r.dot(te,ye),Pe=r.dot(j,ye);let Te=Math.atan2(me,Pe);Te<0&&(Te+=o),_(re,Te),Te=Math.atan2(-me,-Pe),Te<0&&(Te+=o),_(re,Te)}re=re.sort(s);const X=re.length;let ne,se;const Ae=[],ue=[],Ce=[];for(let Be=-1;Be<X;Be++){const he=re[Be<0?Be+X:Be],ye=Math.sin(he),me=Math.cos(he);r.scale(b,j,me*C),r.scale(D,te,ye*C),r.add(b,b,D);const Pe=r.add(r.create(),O,b),Te=r.add(r.create(),U,b);let Je=!1;if(Be>=0&&r.distance(Pe,ne)<n&&(Je=!0),!Je){if(Be>=0){Ae.push(Pe),ue.push(Te);const Ie=[se,Te,Pe,ne],We=A.create(Ie);Ce.push(We)}ne=Pe,se=Te}}ue.reverse(),Ce.push(A.create(Ae)),Ce.push(A.create(ue));const Ee=a.create(Ce);E=g(E,Ee)}),B.forEach(w=>{const H=w[0],G=w[1],O=G[0];let U=null,W=0;for(let X=1;X<G.length;X++){const ne=G[X],se=r.cross(b,O,ne),Ae=r.length(se);Ae>.05&&Ae>W&&(W=Ae,U=ne)}U||(U=r.orthogonal(b,O));const j=r.cross(b,O,U);r.normalize(j,j);const te=r.cross(D,j,O),re=c({center:[H[0],H[1],H[2]],radius:C,segments:y,axes:[O,j,te]});E=g(E,re)}),l(E)};e.exports=m}}),eSo=At({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,e){var n=Ls(),o=JMe(),i=ZQo(),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 h=i(s,a);return o(a,h)};e.exports=r}}),tSo=At({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,e){var n=rie(),o=pa(),i=Vs(),r=Jl(),s=Aie(),a=l=>{let{external:g,internal:u}=l;n(g)<0?g=g.reverse():u=u.reverse();const h=r.fromPoints({closed:!0},g),d=r.fromPoints({closed:!0},u),_=i.toSides(i.fromPoints(r.toPoints(h))),m=i.toSides(i.fromPoints(r.toPoints(d)));return _.push(...m),i.create(_)},A=(l,g,u,h)=>{const{points:d,external:_,internal:m}=l,p=Math.floor(g/2),f=[],I=[];if(u==="round"&&p>0){const y=Math.PI/p,E=d[d.length-1],B=o.angle(o.subtract(o.create(),_[_.length-1],E)),Q=d[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,h),o.add(w,w,E),f.push(w),R=b+y*D,w=o.fromAngleRadians(o.create(),R),o.scale(w,w,h),o.add(w,w,Q),I.push(w)}}const C=[];return C.push(..._,...f,...m.reverse(),...I),i.fromPoints(C)},c=(l,g)=>{l=Object.assign({},{delta:1,corners:"edge",segments:16},l);const{delta:h,corners:d,segments:_}=l;if(h<=0)throw new Error("the given delta must be positive for paths");if(!(d==="edge"||d==="chamfer"||d==="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 f={points:p,external:s({delta:h,corners:d,segments:_,closed:m},p),internal:s({delta:-h,corners:d,segments:_,closed:m},p)};return g.isClosed?a(f):A(f,_,d,h)};e.exports=c}}),qMe=At({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,e){var n=Is(),o=Vs(),i=Ls(),r=Jl(),s=XQo(),a=eSo(),A=tSo(),c=(l,...g)=>{if(g=n(g),g.length===0)throw new Error("wrong number of arguments");const u=g.map(h=>r.isA(h)?A(l,h):o.isA(h)?s(l,h):i.isA(h)?a(l,h):h);return u.length===1?u[0]:u};e.exports=c}}),nSo=At({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,e){var n=Vs(),o=MMe(),i=Aie(),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),d=u.map(_=>(s={delta:u.reduce((f,I)=>f+o.arePointsInside(_,o.create(I)),0)%2===0?c:-c,corners:l,closed:!0,segments:g},i(s,_))).reduce((_,m)=>_.concat(n.toSides(n.fromPoints(m))),[]);return n.create(d)};e.exports=r}}),oSo=At({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,e){var n=Jl(),o=Aie(),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}}),iSo=At({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,e){var n=Is(),o=Vs(),i=Jl(),r=nSo(),s=oSo(),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}}),Vwt=At({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,e){e.exports={expand:qMe(),offset:iSo()}}}),cie=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,e){var n=Cg(),o=ar(),i=Vs(),r=MT(),s=aie(),a=(A,c)=>{const l={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:g,twistAngle:u,twistSteps:h,repair:d}=Object.assign({},l,A);if(h<1)throw new Error("twistSteps must be 1 or more");u===0&&(h=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 f=n.create(),I=(C,y,E)=>{const B=y/h*u,Q=o.scale(o.create(),_,y/h);return n.multiply(f,n.fromZRotation(f,B),n.fromTranslation(n.create(),Q)),r.transform(f,E)};return A={numberOfSlices:h+1,capStart:!0,capEnd:!0,repair:d,callback:I},s(A,p)};e.exports=a}}),rSo=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,e){var n=Vs(),o=Jl(),i=cie(),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}}),sSo=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,e){var n=Is(),o=Vs(),i=Jl(),r=cie(),s=rSo(),a=(A,...c)=>{const l={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:g,twistAngle:u,twistSteps:h,repair:d}=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:h,repair:d};const _=c.map(m=>i.isA(m)?s(A,m):o.isA(m)?r(A,m):m);return _.length===1?_[0]:_};e.exports=a}}),aSo=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,e){var n=Jl(),o=qMe(),i=cie(),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}}),ASo=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,e){var{area:n}=hU(),o=Vs(),i=Jl(),r=qMe(),s=cie(),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 h=o.toOutlines(c);if(h.length===0)throw new Error("the given geometry cannot be empty");const _=h.map(p=>(n(p)<0&&p.reverse(),r(A,i.fromPoints({closed:!0},p)))).reduce((p,f)=>p.concat(o.toSides(f)),[]),m=o.create(_);return s(A,m)};e.exports=a}}),cSo=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,e){var n=Is(),o=Vs(),i=Jl(),r=aSo(),s=ASo(),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 h=c.map(d=>i.isA(d)?r(A,d):o.isA(d)?s(A,d):d);return h.length===1?h[0]:h};e.exports=a}}),lSo=At({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,e){var{TAU:n}=uA(),o=Cg(),i=Vs(),r=aie(),s=MT(),a=(A,c)=>{const l={angle:n,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:g,startAngle:u,pitch:h,height:d,endOffset:_,segmentsPerRotation:m}=Object.assign({},l,A);if(d!=0&&(h=d/(g/n)),m<3)throw new Error("The number of segments per rotation needs to be at least 3.");const f=i.toSides(c);if(f.length===0)throw new Error("The given geometry cannot be empty");const I=f.filter(D=>D[0][0]>=0);let C=s.fromSides(f);I.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,O=(H-u)/n*h;return o.multiply(B,o.fromTranslation(o.create(),[G,0,O*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}}),gSo=At({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,e){var n=Is(),o=TMe(),i=GS(),r=Cg(),s=Vs(),a=Ls(),A=ja(),c=Bv(),l=zwt(),g=(h,d)=>{const _=i.fromNormalAndPoint(i.create(),h.axis,h.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(d),p=m*m*Math.sqrt(3)/4;if(m===0)return s.create();const f=a.toPolygons(d);let I=[];for(let y=0;y<f.length;y++){const E=f[y].vertices.map(b=>i.projectionOfPoint(_,b)),B=A.create(E),Q=A.plane(B);o(_,Q)&&(A.measureArea(B)<p||I.push(B))}if(!o(_,[0,0,1])){const y=r.fromVectorRotation(r.create(),_,[0,0,1]);I=I.map(E=>A.transform(y,E))}I=I.sort((y,E)=>A.measureArea(E)-A.measureArea(y));const C=I.map(y=>s.fromPoints(y.vertices));return l(C)},u=(h,...d)=>{const _={axis:[0,0,1],origin:[0,0,0]},{axis:m,origin:p}=Object.assign({},_,h);if(d=n(d),d.length===0)throw new Error("wrong number of arguments");h={axis:m,origin:p};const f=d.map(I=>a.isA(I)?g(h,I):I);return f.length===1?f[0]:f};e.exports=u}}),yU=At({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,e){e.exports={extrudeFromSlices:aie(),extrudeLinear:sSo(),extrudeRectangular:cSo(),extrudeRotate:kwt(),extrudeHelical:lSo(),project:gSo(),slice:MT()}}}),WMe=At({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,e){var n=pa(),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}}),jMe=At({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,e){var n=Vs(),o=Ls(),i=Jl(),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}}),uSo=At({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,e){var n=Is(),o=Jl(),i=WMe(),r=jMe(),s=(...a)=>{a=n(a);const A=r(a),c=i(A);return o.fromPoints({closed:!0},c)};e.exports=s}}),dSo=At({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,e){var n=Is(),o=Vs(),i=WMe(),r=jMe(),s=(...a)=>{a=n(a);const A=r(a),c=i(A);return c.length<3?o.create():o.fromPoints(c)};e.exports=s}}),hSo=At({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,e){var n=Is(),o=Ls(),i=jMe(),r=zMe(),s=(...a)=>{a=n(a);const A=i(a);return A.length===0?o.create():o.create(r(A))};e.exports=s}}),Jwt=At({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,e){var n=Is(),o=IU(),i=Vs(),r=Ls(),s=Jl(),a=uSo(),A=dSo(),c=hSo(),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}}),_So=At({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,e){var n=Is(),o=JMe(),i=Jwt(),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}}),mSo=At({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,e){e.exports={hull:Jwt(),hullChain:_So(),hullPoints2:WMe(),hullPoints3:zMe()}}}),pSo=At({"node_modules/@jscad/modeling/src/operations/minkowski/index.js"(t,e){e.exports={minkowskiSum:Uwt()}}}),qwt=At({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,e){var n=ar(),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(d=>n.snap(n.create(),d,s)),u=[];for(let d=0;d<g.length;d++){const _=(d+1)%g.length;n.equals(g[d],g[_])||u.push(g[d])}const h=o.create(u);return l.color&&(h.color=l.color),h});const c=s*s*Math.sqrt(3)/4;return A=A.filter(l=>i(c,l)),A};e.exports=r}}),ISo=At({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,e){var n=TMe(),o=ar(),i=ja(),r=p=>{const f=i.toPoints(p),I=[];for(let C=0;C<f.length;C++){const y=(C+1)%f.length,E={v1:f[C],v2:f[y]};I.push(E)}for(let C=0;C<I.length;C++){const y=(C+1)%f.length;I[C].next=I[y],I[y].prev=I[C]}return I},s=(p,f)=>{const I=`${f.v1}:${f.v2}`;p.set(I,f)},a=(p,f)=>{const I=`${f.v1}:${f.v2}`;p.delete(I)},A=(p,f)=>{const I=`${f.v2}:${f.v1}`;return p.get(I)},c=(p,f,I)=>{let C=p.prev.v1,y=p.prev.v2,E=f.next.v2;const B=u(C,y,E,I);C=f.prev.v1,y=f.prev.v2,E=p.next.v2;const Q=u(C,y,E,I);return[B,Q]},l=o.create(),g=o.create(),u=(p,f,I,C)=>{const y=o.subtract(l,f,p),E=o.subtract(g,I,f);return o.cross(y,y,E),o.dot(y,C)},h=p=>{let f;const I=[];for(;p.next;){const C=p.next;I.push(p.v1),p.v1=null,p.v2=null,p.next=null,p.prev=null,p=C}return I.length>0&&(f=i.create(I)),f},d=p=>{if(p.length<2)return p;const f=p[0].plane,I=p.slice(),C=new Map;for(;I.length>0;){const E=I.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,f);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=(O,U,W)=>{const j={v1:W.v1,v2:U.v2,next:U.next,prev:W.prev};W.prev.next=j,U.next.prev=j,a(O,U),U.v1=null,U.v2=null,U.next=null,U.prev=null,a(O,W),W.v1=null,W.v2=null,W.next=null,W.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=h(E);B&&y.push(B)}),C.clear(),y},_=(p,f)=>Math.abs(p[3]-f[3])<15e-8?n(p,f):!1,m=(p,f)=>{const I=[];f.forEach(y=>{const E=I.find(B=>_(B[0],i.plane(y)));E?E[1].push(y):I.push([i.plane(y),[y]])});let C=[];return I.forEach(y=>{const E=y[1],B=d(E);C=C.concat(B)}),C};e.exports=m}}),fSo=At({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,e){var n=uA(),o=ar(),i=ja(),r=c=>`${c}`,s=(c,l,g,u,h,d)=>{const _=r(u),m=r(h),p=`${_}/${m}`,f=`${m}/${_}`;if(c.has(f))return a(c,l,g,h,u,null),null;const I={vertex0:u,vertex1:h,polygonindex:d};return c.has(p)?c.get(p).push(I):c.set(p,[I]),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,h,d)=>{const _=r(u),m=r(h),p=`${_}/${m}`;let f=-1;const I=c.get(p);for(let C=0;C<I.length;C++){const y=I[C];let E=r(y.vertex0);if(E===_&&(E=r(y.vertex1),E===m&&!(d!==null&&y.polygonindex!==d))){f=C;break}}I.splice(f,1),I.length===0&&c.delete(p),f=l.get(_).indexOf(p),l.get(_).splice(f,1),l.get(_).length===0&&l.delete(_),f=g.get(m).indexOf(p),g.get(m).splice(f,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],h=u.vertices.length;if(h>=3){let d=u.vertices[0],_=r(d);for(let m=0;m<h;m++){let p=m+1;p===h&&(p=0);const f=u.vertices[p],I=r(f),C=`${_}/${I}`,y=`${I}/${_}`;if(l.has(y)){const E=l.get(y);E.splice(-1,1),E.length===0&&l.delete(y)}else{const E={vertex0:d,vertex1:f,polygonindex:g};l.has(C)?l.get(C).push(E):l.set(C,[E])}d=f,_=I}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(l.size>0){const g=new Map,u=new Map,h=new Map;for(const[_,m]of l)h.set(_,!0),m.forEach(p=>{const f=r(p.vertex0),I=r(p.vertex1);g.has(f)?g.get(f).push(_):g.set(f,[_]),u.has(I)?u.get(I).push(_):u.set(I,[_])});const d=c.slice(0);for(;l.size!==0;){for(const m of l.keys())h.set(m,!0);let _=!1;for(;;){const m=Array.from(h.keys());if(m.length===0)break;const p=m[0];let f=!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),f=!1,y=2,_=!0;break}else{const U=E,W=B,j=G,te=o.subtract(o.create(),j,U),re=o.dot(o.subtract(o.create(),W,U),te)/o.dot(te,te);if(re>0&&re<1){const X=o.scale(o.create(),te,re);if(o.add(X,X,U),o.squaredDistance(X,W)<n.EPS*n.EPS){const se=H.polygonindex,Ae=d[se],ue=r(H.vertex1);let Ce=-1;for(let me=0;me<Ae.vertices.length;me++)if(r(Ae.vertices[me])===ue){Ce=me;break}const Ee=Ae.vertices.slice(0);Ee.splice(Ce,0,B);const Be=i.create(Ee);d[se]=Be,a(l,g,u,H.vertex0,H.vertex1,se);const he=s(l,g,u,H.vertex0,B,se),ye=s(l,g,u,B,H.vertex1,se);he!==null&&h.set(he,!0),ye!==null&&h.set(ye,!0),f=!1,y=2,_=!0;break}}}}}}f&&h.delete(p)}if(!_)break}c=d}return l.clear(),c};e.exports=A}}),CSo=At({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,e){var n=ar(),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(h=>n.add(u,u,h)),n.snap(u,n.divide(u,u,[c,c,c]),s);for(let h=0;h<c;h++){const d=o.create([u,a.vertices[h],a.vertices[(h+1)%c]]);a.color&&(d.color=a.color),A.push(d)}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}}),ySo=At({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,e){var n=Is(),o=Bv(),i=Vs(),r=Ls(),s=Jl(),a=qwt(),A=ISo(),c=fSo(),l=CSo(),g=(_,m)=>m,u=(_,m)=>m,h=(_,m)=>{const p={snap:!1,simplify:!1,triangulate:!1},{snap:f,simplify:I,triangulate:C}=Object.assign({},p,_),y=o(m);let E=r.toPolygons(m);f&&(E=a(y,E)),I&&(E=A(y,E)),C&&(E=c(E),E=l(y,E));const B=Object.assign({},m);return B.polygons=E,B},d=(_,...m)=>{if(m=n(m),m.length===0)throw new Error("wrong number of arguments");const p=m.map(f=>{if(s.isA(f))return g(_,f);if(i.isA(f))return u(_,f);if(r.isA(f))return h(_,f);throw new Error("invalid geometry")});return p.length===1?p[0]:p};e.exports=d}}),ESo=At({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,e){var n=Is(),o=pa(),i=Vs(),r=Ls(),s=Jl(),a=Bv(),A=qwt(),c=h=>{const d=a(h),m=s.toPoints(h).map(p=>o.snap(o.create(),p,d));return s.create(m)},l=h=>{const d=a(h);let m=i.toSides(h).map(p=>[o.snap(o.create(),p[0],d),o.snap(o.create(),p[1],d)]);return m=m.filter(p=>!o.equals(p[0],p[1])),i.create(m)},g=h=>{const d=a(h),_=r.toPolygons(h),m=A(d,_);return r.create(m)},u=(...h)=>{if(h=n(h),h.length===0)throw new Error("wrong number of arguments");const d=h.map(_=>s.isA(_)?c(_):i.isA(_)?l(_):r.isA(_)?g(_):_);return d.length===1?d[0]:d};e.exports=u}}),xSo=At({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,e){e.exports={generalize:ySo(),snap:ESo(),retessellate:fU()}}}),BSo=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}}),QSo=At({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,e){var n=Is(),o=BSo(),i=FMe(),{translate:r}=l6(),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 h=0;h<3;h++)l[h]==null&&(g[h]==="center"?l[h]=(u[0][h]+u[1][h])/2:g[h]==="max"?l[h]=u[1][h]:g[h]==="min"&&(l[h]=u[0][h]));return l},A=(l,g,u)=>{const h=i(l),d=[0,0,0];for(let _=0;_<3;_++)g[_]==="center"?d[_]=u[_]-(h[0][_]+h[1][_])/2:g[_]==="max"?d[_]=u[_]-h[1][_]:g[_]==="min"&&(d[_]=u[_]-h[0][_]);return r(d,l)},c=(l,...g)=>{l=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},l),l=s(l);let{modes:h,relativeTo:d,grouped:_}=l;if(g=n(g),g.length===0)throw new Error("align(): No geometries were provided to act upon");if(d.filter(m=>m==null).length){const m=i(g);d=a(d,h,m)}return _?g=A(g,h,d):g=g.map(m=>A(m,h,d)),g.length===1?g[0]:g};e.exports=c}}),lie=At({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,e){var n=Is(),o=Vs(),i=Ls(),r=Jl(),s=A6(),{translate:a}=l6(),A=(h,d)=>{const _={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:m,relativeTo:p}=Object.assign({},_,h),f=s(d),I=[0,0,0];return m[0]&&(I[0]=p[0]-(f[0][0]+(f[1][0]-f[0][0])/2)),m[1]&&(I[1]=p[1]-(f[0][1]+(f[1][1]-f[0][1])/2)),m[2]&&(I[2]=p[2]-(f[0][2]+(f[1][2]-f[0][2])/2)),a(I,d)},c=(h,...d)=>{const _={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:m,relativeTo:p}=Object.assign({},_,h);if(d=n(d),d.length===0)throw new Error("wrong number of arguments");if(p.length!==3)throw new Error("relativeTo must be an array of length 3");h={axes:m,relativeTo:p};const f=d.map(I=>r.isA(I)||o.isA(I)||i.isA(I)?A(h,I):I);return f.length===1?f[0]:f},l=(...h)=>c({axes:[!0,!1,!1]},h),g=(...h)=>c({axes:[!1,!0,!1]},h),u=(...h)=>c({axes:[!1,!1,!0]},h);e.exports={center:c,centerX:l,centerY:g,centerZ:u}}}),gie=At({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,e){var n=Is(),o=Cg(),i=Vs(),r=Ls(),s=Jl(),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 h=o.fromScaling(o.create(),g),d=u.map(_=>s.isA(_)?s.transform(h,_):i.isA(_)?i.transform(h,_):r.isA(_)?r.transform(h,_):_);return d.length===1?d[0]:d},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}}}),SSo=At({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,e){var n=Is(),o=Vs(),i=Ls(),r=Jl(),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}}),u6=At({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,e){e.exports={align:QSo(),center:lie().center,centerX:lie().centerX,centerY:lie().centerY,centerZ:lie().centerZ,mirror:mU().mirror,mirrorX:mU().mirrorX,mirrorY:mU().mirrorY,mirrorZ:mU().mirrorZ,rotate:pU().rotate,rotateX:pU().rotateX,rotateY:pU().rotateY,rotateZ:pU().rotateZ,scale:gie().scale,scaleX:gie().scaleX,scaleY:gie().scaleY,scaleZ:gie().scaleZ,transform:SSo(),translate:l6().translate,translateX:l6().translateX,translateY:l6().translateY,translateZ:l6().translateZ}}}),uie=At({"node_modules/@jscad/modeling/src/index.js"(t,e){e.exports={colors:iie(),curves:CBo(),geometries:wMe(),maths:zBo(),measurements:ZBo(),primitives:g6(),text:MQo(),utils:Gwt(),booleans:CU(),expansions:Vwt(),extrusions:yU(),hulls:mSo(),minkowski:pSo(),modifiers:xSo(),transforms:u6()}}}),Wwt=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,h)=>{for(var d in h)n(u,d,{get:h[d],enumerable:!0})},a=(u,h,d,_)=>{if(h&&typeof h=="object"||typeof h=="function")for(let m of i(h))!r.call(u,m)&&m!==d&&n(u,m,{get:()=>h[m],enumerable:!(_=o(h,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,h)=>({type:"colorize",color:u,shape:h})},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,h)=>({type:"rotate",angles:u,shape:h}),scale:(u,h)=>({type:"scale",factors:u,shape:h}),translate:(u,h)=>({type:"translate",vector:u,shape:h})},extrusions:{extrudeLinear:(u,h)=>({type:"extrudeLinear",options:u,shape:h}),extrudeRotate:(u,h)=>({type:"extrudeRotate",options:u,shape:h})},maths:{vec2:{create:(u,h)=>[u,h],fromValues:(u,h)=>[u,h]},vec3:{create:(u,h,d)=>[u,h,d],fromValues:(u,h,d)=>[u,h,d]}},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,h)=>{if(Array.isArray(h)&&h.length===1)return g(u,h[0]);if(Array.isArray(h))throw new Error("executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually");const d=p=>g(u,p),{type:_,...m}=h;switch(_){case"intersect":return u.booleans.intersect(...h.shapes.map(d));case"subtract":return u.booleans.subtract(...h.shapes.map(d));case"union":return u.booleans.union(...h.shapes.map(d));case"hull":return u.hulls.hull(...h.shapes.map(d));case"hullChain":return u.hulls.hullChain(...h.shapes.map(d));case"colorize":return u.colors.colorize(h.color,d(h.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(h.angles,d(h.shape));case"scale":return u.transforms.scale(h.factors,d(h.shape));case"translate":return u.transforms.translate(h.vector,d(h.shape));case"extrudeLinear":return u.extrusions.extrudeLinear(h.options,d(h.shape));case"extrudeRotate":return u.extrusions.extrudeRotate(h.options,d(h.shape));case"createGeom2":return u.geometries.geom2.create(h.points);case"createGeom3":return u.geometries.geom3.create(h.polygons);case"createPath2":return u.geometries.path2.create(h.points);case"measureBoundingBox":return u.measurements.measureBoundingBox(d(h.shape));case"measureArea":return u.measurements.measureArea(d(h.shape));case"measureVolume":return u.measurements.measureVolume(d(h.shape));case"degToRad":return u.utils.degToRad(h.degrees);case"radToDeg":return u.utils.radToDeg(h.radians);default:throw h.type===void 0?new Error(`Operation type is undefined. This usually means the operation object is malformed or not properly initialized. Operation: ${JSON.stringify(h,null,2).slice(0,200)}...`):new Error(`Unsupported operation type: ${h.type}. Operation: ${JSON.stringify(h,null,2)}`)}}}}),bSo=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,h){h=h||{};var d=typeof u;if(d==="string"&&u.length>0)return A(u);if(d==="number"&&isFinite(u))return h.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 h=/^(-?(?:\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(h){var d=parseFloat(h[1]),_=(h[2]||"ms").toLowerCase();switch(_){case"years":case"year":case"yrs":case"yr":case"y":return d*a;case"weeks":case"week":case"w":return d*s;case"days":case"day":case"d":return d*r;case"hours":case"hour":case"hrs":case"hr":case"h":return d*i;case"minutes":case"minute":case"mins":case"min":case"m":return d*o;case"seconds":case"second":case"secs":case"sec":case"s":return d*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:return}}}}function c(u){var h=Math.abs(u);return h>=r?Math.round(u/r)+"d":h>=i?Math.round(u/i)+"h":h>=o?Math.round(u/o)+"m":h>=n?Math.round(u/n)+"s":u+"ms"}function l(u){var h=Math.abs(u);return h>=r?g(u,h,r,"day"):h>=i?g(u,h,i,"hour"):h>=o?g(u,h,o,"minute"):h>=n?g(u,h,n,"second"):u+" ms"}function g(u,h,d,_){var m=h>=d*1.5;return Math.round(u/d)+" "+_+(m?"s":"")}}}),DSo=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=bSo(),r.destroy=u,Object.keys(o).forEach(h=>{r[h]=o[h]}),r.names=[],r.skips=[],r.formatters={};function i(h){let d=0;for(let _=0;_<h.length;_++)d=(d<<5)-d+h.charCodeAt(_),d|=0;return r.colors[Math.abs(d)%r.colors.length]}r.selectColor=i;function r(h){let d,_=null,m,p;function f(...I){if(!f.enabled)return;const C=f,y=Number(new Date),E=y-(d||y);C.diff=E,C.prev=d,C.curr=y,d=y,I[0]=r.coerce(I[0]),typeof I[0]!="string"&&I.unshift("%O");let B=0;I[0]=I[0].replace(/%([a-zA-Z%])/g,(b,D)=>{if(b==="%%")return"%";B++;const R=r.formatters[D];if(typeof R=="function"){const w=I[B];b=R.call(C,w),I.splice(B,1),B--}return b}),r.formatArgs.call(C,I),(C.log||r.log).apply(C,I)}return f.namespace=h,f.useColors=r.useColors(),f.color=r.selectColor(h),f.extend=s,f.destroy=r.destroy,Object.defineProperty(f,"enabled",{enumerable:!0,configurable:!1,get:()=>_!==null?_:(m!==r.namespaces&&(m=r.namespaces,p=r.enabled(h)),p),set:I=>{_=I}}),typeof r.init=="function"&&r.init(f),f}function s(h,d){const _=r(this.namespace+(typeof d>"u"?":":d)+h);return _.log=this.log,_}function a(h){r.save(h),r.namespaces=h,r.names=[],r.skips=[];const d=(typeof h=="string"?h:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const _ of d)_[0]==="-"?r.skips.push(_.slice(1)):r.names.push(_)}function A(h,d){let _=0,m=0,p=-1,f=0;for(;_<h.length;)if(m<d.length&&(d[m]===h[_]||d[m]==="*"))d[m]==="*"?(p=m,f=_,m++):(_++,m++);else if(p!==-1)m=p+1,f++,_=f;else return!1;for(;m<d.length&&d[m]==="*";)m++;return m===d.length}function c(){const h=[...r.names,...r.skips.map(d=>"-"+d)].join(",");return r.enable(""),h}function l(h){for(const d of r.skips)if(A(h,d))return!1;for(const d of r.names)if(A(h,d))return!0;return!1}function g(h){return h instanceof Error?h.stack||h.message:h}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}}),PSo=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 EMe<"u"&&"env"in EMe&&(A=EMe.env.DEBUG),A}function s(){try{return localStorage}catch{}}e.exports=DSo()(t);var{formatters:a}=e.exports;a.j=function(A){try{return JSON.stringify(A)}catch(c){return"[UnexpectedJSONParseError]: "+c.message}}}}),XMe=["translucent","opaque","hidden"],vSo=t=>XMe[(XMe.indexOf(t)+1)%XMe.length],jwt={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,enclosure:"translucent"},Xwt=Z.createContext(void 0),MSo=({children:t})=>{const[e,n]=Z.useState(jwt),o=Z.useCallback((s,a)=>{n(A=>({...A,[s]:a}))},[]),i=Z.useCallback(()=>{n(jwt)},[]),r=Z.useMemo(()=>({visibility:e,setLayerVisibility:o,resetToDefaults:i}),[e,o,i]);return q.jsx(Xwt.Provider,{value:r,children:t})},d6=()=>{const t=Z.useContext(Xwt);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},$Me=1.2;function $wt(t){return Z.useMemo(()=>{if(!t)return $Me;try{return Fi(t).pcb_board.list()[0]?.thickness??$Me}catch{return $Me}},[t])}var Zwt=Z.createContext(null),vI=()=>{const t=Z.useContext(Zwt);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},EU=(t,e=[])=>{const{addFrameListener:n,removeFrameListener:o}=vI();Xr.useEffect(()=>(n(t),()=>o(t)),[n,o,...e])},xU={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},e3t=({children:t,position:e,style:n})=>{const{camera:o,renderer:i}=vI(),r=Z.useRef(document.createElement("div")),[s,a]=Z.useState(null);return Z.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(sRe.createPortal(t,r.current)),()=>{A.contains(r.current)&&A.removeChild(r.current)}},[i,t]),EU(()=>{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=xU.htmlElements.toString(),n&&Object.assign(r.current.style,n)},[o,i,e,n]),s},t3t={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},Ha=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 t3t)return n*t3t[e];throw new Error(`Unsupported unit: ${e}`)},Cd=Ha,wSo=Object.defineProperty,NSo=(t,e)=>{for(var n in e)wSo(t,n,{get:e[n],enumerable:!0})},$4={};NSo($4,{axial:()=>l4o,bga:()=>ubo,breakoutheaders:()=>x4o,cap:()=>OSo,dfn:()=>Ybo,diode:()=>GSo,dip:()=>kSo,electrolytic:()=>fPo,hc49:()=>S4o,jst:()=>kDo,led:()=>KSo,lqfp:()=>y4o,m2host:()=>KPo,melf:()=>Y5o,micromelf:()=>q5o,minimelf:()=>k5o,mlp:()=>ybo,mountedpcbmodule:()=>YPo,ms012:()=>Xbo,ms013:()=>Zbo,msop:()=>VDo,pad:()=>b4o,pinrow:()=>Vbo,platedhole:()=>wPo,potentiometer:()=>mPo,pushbutton:()=>_4o,qfn:()=>Ibo,qfp:()=>Cbo,quad:()=>NT,radial:()=>d4o,res:()=>cbo,sma:()=>$5o,smb:()=>sDo,smbf:()=>yPo,smc:()=>lDo,smf:()=>nDo,smtpad:()=>vPo,sod110:()=>LDo,sod123:()=>s4o,sod123f:()=>c5o,sod123fl:()=>d5o,sod123w:()=>U4o,sod128:()=>y5o,sod323:()=>J4o,sod323f:()=>r5o,sod323fl:()=>$Do,sod323w:()=>qDo,sod523:()=>N4o,sod723:()=>p5o,sod80:()=>H4o,sod882:()=>t5o,sod882d:()=>G5o,sod923:()=>X4o,soic:()=>hbo,solderjumper:()=>aPo,son:()=>nPo,sop8:()=>F4o,sot:()=>RPo,sot223:()=>hDo,sot23:()=>Fbo,sot23w:()=>xDo,sot25:()=>Obo,sot323:()=>SPo,sot343:()=>LPo,sot363:()=>vbo,sot457:()=>lPo,sot563:()=>Wbo,sot723:()=>t4o,sot886:()=>Nbo,sot89:()=>M5o,sot963:()=>dPo,ssop:()=>Bbo,stampboard:()=>p4o,stampreceiver:()=>C4o,to220:()=>C3t,to220f:()=>R5o,to92:()=>M4o,to92l:()=>qPo,to92s:()=>PDo,tqfp:()=>fbo,tssop:()=>bbo,vson:()=>iPo,vssop:()=>UDo});var mi=(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"}),ui=Ze({norefdes:Fe().optional().describe("disable reference designator label"),invert:Fe().optional().describe("hint to invert the orientation of the 3D model"),faceup:Fe().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:Fe().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:Ha(o),outer_diameter:Ha(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),xy=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:Ha(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:Ha(r),rect_pad_height:Ha(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}},die=Array.from({length:9},(t,e)=>Math.cos(e/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)})),XC=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 Qv(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var hie=Rn([F(),Ue()]).transform(t=>Qv(t)),RSo=t=>ui.extend({fn:F(),num_pins:Ue().optional().default(6),wide:Fe().optional(),narrow:Fe().optional(),w:hie.optional(),p:hie.default(t.p??"2.54mm"),id:hie.optional(),od:hie.optional(),nosquareplating:Fe().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=Qv("0.55mm"),e.od=Qv("0.95mm")):(e.id=Qv("0.8mm"),e.od=Qv("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=Qv("600mil"):e.narrow?e.w=Qv("300mil"):e.w=Qv(t.w??"300mil")),e)),TSo=RSo({}),n3t=(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}},kSo=t=>{const e=TSo.parse(t),n=[];for(let p=0;p<e.num_pins;p++){const{x:f,y:I}=n3t(e.num_pins,p+1,e.w,e.p??2.54,e.nosquareplating);if(p===0&&!e.nosquareplating){n.push(xy({pn:p+1,x:f,y:I,holeDiameter:e.id??"0.8mm",rectPadWidth:e.od??"1mm",rectPadHeight:e.od??"1mm"}));continue}n.push(Js(p+1,f,I,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},...die.map(({x:p,y:f})=>({x:p*r/6,y:f*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 f=p<e.num_pins/2,I=.6,{y:C}=n3t(e.num_pins,p+1,e.w,e.p??2.54,e.nosquareplating),y=f?-e.w/2-e.od/2-I:e.w/2+e.od/2+I,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=mi(0,s/2+.5,.4),l=e.w+e.od,g=o,u=l/2+.25,h=u,d=g/2+.72,_=d,m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:XC([{minX:-u,maxX:u,minY:-_,maxY:_},{minX:-h,maxX:h,minY:-d,maxY:d}]),layer:"top"};return{circuitJson:[...n,a,c,...A,m],parameters:e}},Go=(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()]}),o3t=[{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}}],FSo=Object.fromEntries(o3t.map(t=>[t.metric,t])),LSo=Object.fromEntries(o3t.map(t=>[t.imperial,t])),HSo=(t,e)=>({type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:t,height:e,layer:"top"});ui.extend({fn:F().optional(),string:F().optional(),tht:Fe(),p:ce.optional(),pw:ce.optional(),ph:ce.optional(),metric:it.optional(),imperial:it.optional(),w:ce.optional(),h:ce.optional(),nonpolarized:Fe().optional(),textbottom:Fe().optional(),roundedPads:Fe().optional()});var _ie=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:h}=t;if(typeof A=="string"&&(A=Cd(A)),typeof c=="string"&&(c=Cd(c)),typeof o=="string"&&(o=Cd(o)),typeof i=="string"&&(i=Cd(i)),typeof r=="string"&&(r=Cd(r)),c!==void 0&&A!==void 0&&c>A)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let d;if(s&&(d=FSo[s]),a&&(d=LSo[a]),d&&(A=d.w_mm_min,c=d.h_mm_min,o=d.p_mm_min,i=d.pw_mm_min,r=d.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 h!="string"||/^res(?:\d{4}|\d{5})(?:_|$)/i.test(h))?d?.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,f=mi(0,p,.2),I=d?.courtyard_width_mm&&d.courtyard_height_mm?HSo(d.courtyard_width_mm,d.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),..._,f,...I?[I]:[]]:[Go(["1","left"],-o/2,0,i,r,C),Go(["2","right"],o/2,0,i,r,C),..._,f,...I?[I]:[]]},GSo=t=>({circuitJson:_ie({...t,roundedPads:!0}),parameters:t}),OSo=t=>({circuitJson:_ie(t),parameters:t}),KSo=t=>({circuitJson:_ie(t).map(n=>n.type!=="pcb_silkscreen_path"?n:{...n,route:n.route.map(o=>({...o,x:-o.x}))}),parameters:t}),wT=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(Go(R+1,-e/2,D,n,o))}),A.slice().reverse().forEach((D,R)=>{l.push(Go(R+r+1,e/2,D,n,o))});const g=Math.max(...A)+o/2+.4,u=Math.min(...A)-o/2-.4,h=-e/2-n/2-.4,d=e/2+n/2+.4,_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:d*.5,y:g},{x:h*.5,y:g}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:d*.5,y:u},{x:h*.5,y:u}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},p=-e/2,f=Math.max(...A),I=.2,C=p-n/2-.1,y=f+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-I,y},{x:C,y:y+I},{x:C,y}],stroke_width:.1},B=s?u-.9:g+.9,Q=mi(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]:[]]},USo=ui.extend({pw:ce.default("0.5mm"),ph:ce.default("0.4mm"),p:ce.default("0.7mm"),textbottom:Fe().optional(),convex:Fe().optional(),concave:Fe().optional()}),YSo=1,zSo=t=>{const e=USo.parse(t);if(e.concave===!0)return[];const n=Cd(e.pw),o=Cd(e.ph),i=Cd(e.p);return wT({padSpacing:YSo,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}]})},VSo=ui.extend({pw:ce.default("0.5mm"),ph:ce.default("0.32mm"),p:ce.default("0.5mm"),textbottom:Fe().optional(),convex:Fe().optional(),concave:Fe().optional()}),JSo=1,qSo=t=>{const e=VSo.parse(t),n=Cd(e.pw),o=Cd(e.ph),i=Cd(e.p);return wT({padSpacing:JSo,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}]})},WSo=ui.extend({pw:ce.default("0.9mm"),ph:ce.default("0.4mm"),p:ce.default("0.8mm"),textbottom:Fe().optional(),convex:Fe().optional(),concave:Fe().optional()}),jSo=1.7,XSo=t=>{const e=WSo.parse(t),n=Cd(e.pw),o=Cd(e.ph),i=Cd(e.p);return wT({padSpacing:jSo,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}]})},$So=ui.extend({pw:ce.default("0.9mm"),ph:ce.default("0.4mm"),p:ce.default("0.8mm"),textbottom:Fe().optional(),convex:Fe().optional(),concave:Fe().optional()}),ZSo=1.7,ebo=t=>{const e=$So.parse(t),n=Cd(e.pw),o=Cd(e.ph),i=Cd(e.p);return wT({padSpacing:ZSo,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}]})},tbo=ui.extend({pw:ce.default("0.7mm"),ph:ce.default("0.64mm"),p:ce.default("0.94mm"),textbottom:Fe().optional(),convex:Fe().optional(),concave:Fe().optional()}),nbo=1.4,obo=t=>{const e=tbo.parse(t),n=Cd(e.pw),o=Cd(e.ph),i=Cd(e.p);return wT({padSpacing:nbo,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}]})},ibo=ui.extend({pw:ce.default("0.9mm"),ph:ce.default("0.9mm"),p:ce.default("1.34mm"),textbottom:Fe().optional(),convex:Fe().optional(),concave:Fe().optional()}),rbo=3,sbo=t=>{const e=ibo.parse(t),n=Cd(e.pw),o=Cd(e.ph),i=Cd(e.p);return wT({padSpacing:rbo,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}]})},abo=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)}},Abo=t=>t?(typeof t=="number"?`${t}`:t).split(/[_x]/)[0]:void 0,cbo=t=>{const e=abo(t),n=Abo(t.imperial);return e===2&&n==="0402"?{circuitJson:zSo(t),parameters:t}:e===4&&n==="0402"?{circuitJson:qSo(t),parameters:t}:e===2&&n==="0603"?{circuitJson:XSo(t),parameters:t}:e===4&&n==="0603"?{circuitJson:ebo(t),parameters:t}:e===2&&n==="0606"?{circuitJson:obo(t),parameters:t}:e===4&&n==="1206"?{circuitJson:sbo(t),parameters:t}:{circuitJson:_ie(t),parameters:t}},i3t=(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()]}),r3t="ABCDEFGHIJKLMNOPQRSTUVWXYZ",mie=F().transform(t=>{const[e,n]=t.split(/[x ]/);return{x:parseFloat(e??""),y:parseFloat(n??"")}}).pipe(Ze({x:Ue(),y:Ue()})),lbo=F().or(Qt(Gg())).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()))),gbo=ui.extend({fn:F(),num_pins:Ue().optional().default(64),grid:mie.optional(),p:it.default("0.8mm"),w:ce.optional(),h:ce.optional(),ball:ce.optional().describe("ball diameter"),pad:ce.optional().describe("pad width/height"),circularpads:Fe().optional().describe("use circular pads"),tlorigin:Fe().optional(),blorigin:Fe().optional(),trorigin:Fe().optional(),brorigin:Fe().optional(),missing:lbo.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=r3t.indexOf(i[1]),s=Number.parseInt(i[2])-1;return r*t.grid.x+s+1})),{...t,origin:e}}),ubo=t=>{const e=gbo.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(j=>typeof j=="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 j=Math.floor(Math.sqrt(u)),te=Math.floor((o.x-j)/2),re=Math.floor((o.y-j)/2);for(let X=re;X<re+j;X++)for(let ne=te;ne<te+j;ne++)g.push(X*o.x+ne+1)}c?.includes("topleft")&&g.push(1);const h=new Set(g);let d=0;for(let j=0;j<o.y;j++)for(let te=0;te<o.x;te++){const re=(te-(o.x-1)/2)*i,X=(j-(o.y-1)/2)*i;let ne=te,se=j;switch(e.origin){case"bl":ne=te,se=o.y-1-j;break;case"br":ne=o.x-1-te,se=o.y-1-j;break;case"tr":ne=o.x-1-te,se=j;break}let Ae=se*o.x+ne+1;if(h.has(Ae)){d++;continue}Ae-=d;const ue=[Ae,`${r3t[se]}${ne+1}`];l.push(e.circularpads?i3t(ue,{x:re,y:X,radius:A/2}):Go(ue,re,X,A,A))}const _=mi(0,o.y*i/2,.2),m=i/6;let p;const f=o.x*i/2,I=o.y*i/2;switch(e.origin){case"bl":p=[{x:-f,y:-I},{x:-f,y:-I-m},{x:-f-m,y:-I},{x:-f,y:-I}];break;case"br":p=[{x:f,y:-I},{x:f,y:-I-m},{x:f+m,y:-I},{x:f,y:-I}];break;case"tr":p=[{x:f,y:I},{x:f,y:I+m},{x:f+m,y:I},{x:f,y:I}];break;default:p=[{x:-f,y:I},{x:-f,y:I+m},{x:-f-m,y:I},{x:-f,y:I}];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,O=D+w,U=O,W={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:XC([{minX:-H,maxX:H,minY:-U,maxY:U},{minX:-G,maxX:G,minY:-O,maxY:O}]),layer:"top"};return{circuitJson:[...l,_,C,W],parameters:e}},pie=(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()]}),h6=t=>ui.extend({fn:F(),num_pins:Ue().optional().default(8),w:ce.default(ce.parse(t.w??"5.3mm")),p:ce.default(ce.parse(t.p??"1.27mm")),pw:ce.default(ce.parse(t.pw??"0.6mm")),pl:ce.default(ce.parse(t.pl??"1.0mm")),legsoutside:Fe().optional().default(t.legsoutside??!1),pillpads:Fe().optional().default(t.pillpads??!1),silkscreen_stroke_width:Ue().optional().default(.1)}).transform(e=>(!e.pw&&!e.pl?(e.pw=ce.parse("0.6mm"),e.pl=ce.parse("1.0mm")):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e)),dbo=h6({}),ZMe=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}},hbo=t=>{const e=dbo.parse(t);return{circuitJson:BU(e),parameters:e}},BU=t=>{const e=[];let n=0,o=0;for(let m=0;m<t.num_pins;m++){const{x:p,y:f}=ZMe({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(f)+t.pw/2),t.pillpads?e.push(pie(m+1,p,f,t.pl,t.pw)):e.push(Go(m+1,p,f,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=mi(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},...die.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,h=Math.min(n,c)+.25,d=Math.max(o,l)+.25,_={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:XC([{minX:-g,maxX:g,minY:-u,maxY:u},{minX:-h,maxX:h,minY:-d,maxY:d}])};return[...e,A,a,_]},s3t=qt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),_bo=({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},ewe=ui.extend({fn:F(),cc:Fe().default(!0).optional(),ccw:Fe().default(!0).optional(),startingpin:F().or(Qt(s3t)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(Qt(s3t)).optional(),num_pins:Ue().optional().default(64),w:ce.optional(),h:ce.optional(),p:ce.default(ce.parse("0.5mm")),pw:ce.optional(),pl:ce.optional(),thermalpad:Rn([De(!0),mie]).optional(),legsoutside:Fe().default(!1)}),twe=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},a3t=ewe.transform(twe),mbo=["left","bottom","right","top"],pbo=t=>{const{pin_count:e,pn:n,w:o,h:i,p:r,pl:s,legsoutside:a}=t,A=e/4,c=mbo[Math.floor((n-1)/A)],l=(n-1)%A,g=r*(A-1),u=r*(A-1),h=a?s/2:-s/2;switch(c){case"left":return{x:-o/2-h+.1,y:u/2-l*r,o:"vert"};case"bottom":return{x:-g/2+l*r,y:-i/2-h+.1,o:"horz"};case"right":return{x:o/2+h-.1,y:-u/2+l*r,o:"vert"};case"top":return{x:g/2-l*r,y:i/2+h-.1,o:"horz"};default:throw new Error("Invalid pin number")}},NT=t=>{const e=a3t.parse(t),n=[];let o=0,i=0;const r=_bo(e),s=e.num_pins/4;for(let I=0;I<e.num_pins;I++){const{x:C,y,o:E}=pbo({pin_count:e.num_pins,pn:I+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[I+1];o=Math.max(o,Math.abs(C)+B/2),i=Math.max(i,Math.abs(y)+Q/2),n.push(Go(b,C,y,B,Q))}if(e.thermalpad)if(typeof e.thermalpad=="boolean"){const I=e.p*(s-1)+e.pw,C=e.p*(s-1)+e.pw;o=Math.max(o,I/2),i=Math.max(i,C/2),n.push(Go(["thermalpad"],0,0,I,C))}else o=Math.max(o,e.thermalpad.x/2),i=Math.max(i,e.thermalpad.y/2),n.push(Go(["thermalpad"],0,0,e.thermalpad.x,e.thermalpad.y));const a=[];for(const[I,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&&I==="top-left"?Q="in1":r[s*4]===1&&I==="top-left"||r[s*3+1]===1&&I==="top-right"?Q="in2":r[s*3]===1&&I==="top-right"||r[s]===1&&I==="bottom-left"?Q="in1":r[s+1]===1&&I==="bottom-left"?Q="in2":r[s*2]===1&&I==="bottom-right"?Q="in1":r[s*2+1]===1&&I==="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_${I}`,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_${I}_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_${I}_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_${I}_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=mi(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3),c=I=>Math.ceil(I/.05)*.05,l=(s-1)*e.p+e.pw,g=(s-1)*e.p+e.pw,u=l/2+.25,h=g/2+.25,d=e.w/2+.25,_=e.h/2+.25,m=Math.max(d,c(o+.25)),p=Math.max(_,c(i+.25)),f={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:XC([{minX:-m,maxX:m,minY:-h,maxY:h},{minX:-d,maxX:d,minY:-_,maxY:_},{minX:-u,maxX:u,minY:-p,maxY:p}])};return{circuitJson:[...n,...a,A,f],parameters:e}};ewe.extend({}).transform(twe);var Ibo=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),NT(t)),fbo=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 NT(t)},Cbo=t=>{t.legsoutside=!0;const e=a3t.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 NT(t)};ewe.extend({}).transform(twe);var ybo=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),NT(t)),Ebo=ui.extend({fn:F(),num_pins:Ue().optional().default(8),w:ce.default(ce.parse("3.9mm")),p:ce.default(ce.parse("1.27mm")),pw:ce.optional(),pl:ce.optional(),legsoutside:Fe().optional().default(!1),silkscreen_stroke_width:Ue().optional().default(.1)}).transform(t=>(t.pw==null&&t.pl==null?(t.pw=ce.parse("0.51mm"),t.pl=ce.parse("1.1mm")):t.pw==null?t.pw=t.pl*(.51/1.1):t.pl==null&&(t.pl=t.pw*(1.1/.51)),t)),xbo=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+ce.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}},Bbo=t=>{const e=Ebo.parse(t),n=[];for(let m=0;m<e.num_pins;m++){const{x:p,y:f}=xbo({num_pins:e.num_pins,pn:m+1,w:e.w,p:e.p,pl:e.pl,legsoutside:e.legsoutside});n.push(Go(m+1,p,f,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=mi(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},...die.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,h=l+.445,d=h,_={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:XC([{minX:-g,maxX:g,minY:-d,maxY:d},{minX:-u,maxX:u,minY:-h,maxY:h}]),layer:"top"};return{circuitJson:[...n,a,s,_],parameters:e}},Qbo=ui.extend({fn:F(),num_pins:Ue().optional().default(8),w:ce.default(ce.parse("3.0mm")),p:ce.default(ce.parse("0.5mm")),pw:ce.default(ce.parse("0.30mm")),pl:ce.default(ce.parse("1.45mm")),legsoutside:Fe().optional().default(!0),silkscreen_stroke_width:Ue().optional().default(.1)}),Sbo=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}},bbo=t=>{const e={...t},n=e.p,o=typeof n=="string"||typeof n=="number"?ce.parse(n):void 0,i=o!=null&&o<=ce.parse("0.5mm"),r=Qbo.parse(e),s=[],a=i?r.w-ce.parse("0.15mm"):r.w;for(let C=0;C<r.num_pins;C++){const{x:y,y:E}=Sbo({num_pins:r.num_pins,pn:C+1,w:a,p:r.p,pl:r.pl,legsoutside:r.legsoutside});s.push(Go(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=mi(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},...die.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}]},h=(r.num_pins/2-1)*r.p+r.pw,d=r.w/2+(r.legsoutside?r.pl:0),_=r.w/2+.25,m=d+.18,p=h/2+.25,f=p+.35,I={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:XC([{minX:-m,maxX:m,minY:-p,maxY:p},{minX:-_,maxX:_,minY:-f,maxY:f}])};return{circuitJson:[...s,u,g,I],parameters:r}},Dbo=[{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}],Pbo=ui.extend({fn:F(),num_pins:De(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()}),vbo=t=>{const e=Pbo.parse({...t,fn:"sot363"}),n=ce.parse(e.w),o=ce.parse(e.h),i=ce.parse(e.p),r=ce.parse(e.pl),s=ce.parse(e.pw),a=[];for(let d=0;d<6;d++){const{x:_,y:m}=A3t(d+1,n,i);a.push(Go(d+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=A3t(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=mi(0,o/2+.4,.25),h={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:Dbo,layer:"top"};return{circuitJson:[...a,A,c,u,g,h],parameters:e}},A3t=(t,e,n,o)=>t<=3?{x:-.84,y:n-(t-1)*n}:{x:.84,y:-n+(t-4)*n},Mbo=[{x:-.75,y:1},{x:-.75,y:-1},{x:.75,y:-1},{x:.75,y:1}],wbo=ui.extend({fn:F(),num_pins:De(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()}),Nbo=t=>{const e=wbo.parse({...t,fn:"sot886"}),n=ce.parse(e.w),o=ce.parse(e.h),i=ce.parse(e.p),r=ce.parse(e.pl),s=ce.parse(e.pw),a=[];for(let d=0;d<6;d++){const{x:_,y:m}=c3t(d+1,n,i,r);a.push(Go(d+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=c3t(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=mi(0,o/2+.4,.25),h={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:Mbo,layer:"top"};return{circuitJson:[...a,A,c,u,g,h],parameters:e}},c3t=(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}},Rbo=[{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}],Tbo=[{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}],l3t=ui.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()}),kbo=h6({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Fbo=t=>{const e=t.string?.match(/^sot23_(\d+)/),n=e?Number.parseInt(e[1],10):3;if(n===6||n===8){const i=kbo.parse({...t,num_pins:n});return{circuitJson:BU(i),parameters:i}}const o=l3t.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:Hbo(o),parameters:o};if(o.num_pins===5)return{circuitJson:u3t(o),parameters:o};throw new Error("Invalid number of pins")},Lbo=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}},Hbo=t=>{const e=[];for(let i=0;i<t.num_pins;i++){const{x:r,y:s}=Lbo({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(Go(i+1,r,s,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=mi(0,Number.parseInt(t.h),.3),o={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:Rbo,layer:"top"};return[...e,n,o]},g3t=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")},u3t=t=>{const e=[];for(let u=1;u<=t.num_pins;u++){const{x:h,y:d}=g3t({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:u});e.push(Go(u,h,d,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=mi(0,o+.3,.3),a=g3t({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:Tbo,layer:"top"};return[...e,s,i,r,l,g]},Gbo=l3t.extend({}),Obo=t=>{const e=Gbo.parse({...t,num_pins:5});return{circuitJson:u3t(e),parameters:e}},Kbo=[{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}],Ubo=h6({}),Ybo=t=>{const e=Ubo.parse(t),n=[];for(let m=0;m<e.num_pins;m++){const{x:p,y:f}=ZMe({num_pins:e.num_pins,pn:m+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Go(m+1,p,f,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 Kbo){const{dx:p,dy:f}=m;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:p*i/2-p*e.p,y:f*r/2},{x:p*i/2,y:f*r/2},{x:p*i/2,y:f*r/2-f*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=mi(0,r/2+.4,r/12),g=m=>Math.ceil(m/.05)*.05,u=(e.num_pins/2-1)*e.p+e.pw,h=g(e.w/2+.25),d=g(u/2+.45),_={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:h*2,height:d*2,layer:"top"};return{circuitJson:[...n,l,...s,_],parameters:e}},_6=({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 d3t({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 zbo=ui.extend({fn:F(),num_pins:Ue().optional().default(6),rows:Rn([F(),Ue()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:ce.default("0.1in").describe("pitch"),id:ce.default("1.0mm").describe("inner diameter"),od:ce.default("1.5mm").describe("outer diameter"),male:Fe().optional().describe("for male pin headers"),female:Fe().optional().describe("for female pin headers"),smd:Fe().optional().describe("surface mount device"),surfacemount:Fe().optional().describe("surface mount device (verbose)"),rightangle:Fe().optional().describe("right angle"),pw:ce.optional().default("1.0mm").describe("pad width for SMD"),pl:ce.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:Fe().optional().default(!1),pinlabeltextaligncenter:Fe().optional().default(!1),pinlabeltextalignright:Fe().optional().default(!1),pinlabelverticallyinverted:Fe().optional().default(!1),pinlabelorthogonal:Fe().optional().default(!1),nosquareplating:Fe().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Fe().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Fe().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Fe().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const e=d3t(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:Nn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),Vbo=t=>{const e=zbo.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:h,bottomsidepinlabel:d}=e;let _="center";l?_="left":g&&(_="right");const m=[],p=Math.ceil(s/r),f=(r-1)*n,I=f/2,C=-n,y=({xoff:re,yoff:X,od:ne,anchorSide:se,smd:Ae,pw:ue,pl:Ce})=>{let Ee=0,Be=0;if(Ae){const he=ne/5;switch(se){case"right":Ee=ue/2+he;break;case"top":Be=Ce/2+he;break;case"bottom":Be=-(Ce/2+he);break;case"left":Ee=-(ue/2+he);break}}else{const he=ne*.75;switch(se){case"right":Ee=he;break;case"top":Be=he;break;case"bottom":Be=-he;break;case"left":Ee=-he;break}}return{anchor_x:re+Ee,anchor_y:X+Be}},E=(re,X,ne)=>{e.smd?m.push(Go(re,X,ne,e.pw,e.pl)):re===1&&!e.nosquareplating?m.push(xy({pn:re,x:X,y:ne,holeDiameter:o,rectPadWidth:i,rectPadHeight:i})):m.push(Js(re,X,ne,o,i));const{anchor_x:se,anchor_y:Ae}=y({xoff:X,yoff:ne,od:i,anchorSide:a,smd:e.smd,pw:e.pw,pl:e.pl});u||(d?m.push(_6({fs:i/5,pn:re,anchor_x:se,anchor_y:Ae,textalign:_,orthogonal:c,verticallyinverted:A,layer:"bottom"})):m.push(_6({fs:i/5,pn:re,anchor_x:se,anchor_y:Ae,textalign:_,orthogonal:c,verticallyinverted:A,layer:"top"})),h&&m.push(_6({fs:i/5,pn:re,anchor_x:se,anchor_y:Ae,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 ne=X+1,se=re+X*n,Ae=`${se},0`;if(B.has(Ae))throw new Error(`Overlap at ${Ae}`);B.add(Ae),E(ne,se,0)}}else if(Q){const re=-((p-1)/2)*n;let X=1;for(let ne=0;ne<r&&X<=s;ne++)for(let se=0;se<p&&X<=s;se++){const Ae=re+se*n,ue=I+ne*C,Ce=`${Ae},${ue}`;if(B.has(Ce))throw new Error(`Overlap at ${Ce}`);B.add(Ce),E(X++,Ae,ue)}}else{const re=-((p-1)/2)*n;let X=1,ne=0,se=r-1,Ae=0,ue=p-1;for(;X<=s&&ne<=se&&Ae<=ue;){for(let Ce=ne;Ce<=se&&X<=s;Ce++){const Ee=re+Ae*n,Be=I+Ce*C,he=`${Ee},${Be}`;if(B.has(he))throw new Error(`Overlap at ${he}`);B.add(he),E(X++,Ee,Be)}Ae++;for(let Ce=Ae;Ce<=ue&&X<=s;Ce++){const Ee=re+Ce*n,Be=I+se*C,he=`${Ee},${Be}`;if(B.has(he))throw new Error(`Overlap at ${he}`);B.add(he),E(X++,Ee,Be)}if(se--,Ae<=ue){for(let Ce=se;Ce>=ne&&X<=s;Ce--){const Ee=re+ue*n,Be=I+Ce*C,he=`${Ee},${Be}`;if(B.has(he))throw new Error(`Overlap at ${he}`);B.add(he),E(X++,Ee,Be)}ue--}if(ne<=se){for(let Ce=ue;Ce>=Ae&&X<=s;Ce--){const Ee=re+Ce*n,Be=I+ne*C,he=`${Ee},${Be}`;if(B.has(he))throw new Error(`Overlap at ${he}`);B.add(he),E(X++,Ee,Be)}ne++}}if(X-1<s)throw new Error(`Missing pins: assigned ${X-1}, expected ${s}`)}const b=mi(0,f/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=f/2+R,O=w/2+n/2,U=f/2+n/2,W=Math.max(H+.25,O+.5),j=Math.max(G+.25,U+.5),te={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*W,height:2*j,layer:"top"};return{circuitJson:[...m,b,te],parameters:e}},Jbo=[{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}],qbo=ui.extend({fn:F(),num_pins:De(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()}),Wbo=t=>{const e=qbo.parse({...t,fn:"sot563"}),n=ce.parse(e.w),o=ce.parse(e.h),i=ce.parse(e.p),r=ce.parse(e.pl),s=ce.parse(e.pw),a=[];for(let d=0;d<6;d++){const{x:_,y:m}=h3t(d+1,n,i,r);a.push(Go(d+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=h3t(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=mi(0,o/2+.4,.25),h={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:Jbo,layer:"top"};return{circuitJson:[...a,A,c,u,g,h],parameters:e}},h3t=(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}},jbo=h6({p:"1.27mm",w:"3.9mm",legsoutside:!0}),Xbo=t=>{const e=jbo.parse({...t,num_pins:8});return{circuitJson:BU(e),parameters:e}},$bo=h6({p:"1.27mm",w:"7.5mm",legsoutside:!0}),Zbo=t=>{const e=$bo.parse({...t,num_pins:16});return{circuitJson:BU(e),parameters:e}},e4o=ui.extend({fn:F(),num_pins:De(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")}),t4o=t=>{const e=e4o.parse(t),n=o4o(e),o=mi(0,ce.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}},n4o=t=>{const{pn:e,p:n}=t;return e===1?{x:n,y:0}:e===2?{x:-n,y:-.4}:{x:-n,y:.4}},o4o=t=>{const e=[];for(let n=0;n<3;n++){const{x:o,y:i}=n4o({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(Go(n+1,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Kf=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=ce.parse(e),o=ce.parse(t.pl),i=ce.parse(t.pw);return i4o({minX:-n/2-o/2,maxX:n/2+o/2,minY:-i/2,maxY:i/2})},i4o=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,h=l*.18,d=g+h,_=u-h,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:d,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:d,y:r+s},{x:_,y:r},{x:d,y:r-s},{x:d,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},r4o=ui.extend({fn:F(),num_pins:De(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")}),s4o=t=>{const e=r4o.parse(t),n=ce.parse(e.h),o=mi(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:A4o(e).concat(...Kf(e),o,s),parameters:e}},a4o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},A4o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=a4o({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.1125))}return e},c4o=ui.extend({fn:F(),p:ce.optional().default("2.54mm"),id:ce.optional().default("0.7mm"),od:ce.optional().default("1.4mm")}),l4o=t=>{const e=c4o.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=mi(0,1.5,.5),A=-n/2,c=n/2,l=i/2,g=i/2,u=A-l-.35,h=c+l+.26,d=g+.35,_=u,m=h,p=d,f={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:XC([{minX:u,maxX:h,minY:-p,maxY:p},{minX:_,maxX:m,minY:-d,maxY:d}]),layer:"top"};return{circuitJson:[...r,s,a,f],parameters:e}},g4o=(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,h=e+Math.sin(g)*n;u<t-o&&h>=e-i/2&&h<=e+i/2||s.push({x:u,y:h})}for(let l=0;l<=A;l++){const g=Math.PI+l*c,u=t+Math.cos(g)*n,h=e+Math.sin(g)*n;u<t-o&&h>=e-i/2&&h<=e+i/2||a.push({x:u,y:h})}return{topArc:s,bottomArc:a}},u4o=ui.extend({fn:F(),p:ce.optional().default("5mm"),id:ce.optional().default("0.8mm"),od:ce.optional().default("1.6mm"),ceramic:Fe().optional(),electrolytic:Fe().optional(),polarized:Fe().optional()}),d4o=t=>{const e=u4o.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}=g4o(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:""},h=.1*n,d=-(n+h+.04*n),_=s-h-.08*n,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:d-h,y:_},{x:d+h,y:_}],stroke_width:c,pcb_silkscreen_path_id:""},p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:d,y:_-h},{x:d,y:_+h}],stroke_width:c,pcb_silkscreen_path_id:""},f=mi(0,s+.12*n,.1*n),I=[...r,l,g,u,f];(e.electrolytic===!0||e.polarized===!0)&&I.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 I.push(E),{circuitJson:I,parameters:e}},m6=(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}),h4o=ui.extend({fn:De("pushbutton"),w:ce.default(4.5),h:ce.default(6.5),id:ce.default(1),od:ce.default(1.2)}),_4o=t=>{const e=h4o.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=[m6([{x:-n/2,y:-o/2},{x:-n/2,y:o/2}]),m6([{x:n/2,y:-o/2},{x:n/2,y:o/2}]),m6([{x:-n/2,y:0},{x:-n/5,y:0},{x:n/5*1/Math.sqrt(2),y:o/8}]),m6([{x:n/2,y:0},{x:n/5,y:0}])],a=mi(0,o/2+.4,.5),A=i*1.5/2,c=n,l=o,g=c/2+A,u=l/2+A,h=g+.5,d=u+.5,_={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*h,height:2*d,layer:"top"};return{circuitJson:[...r,...s,a,_],parameters:e}},_3t=ui.extend({fn:F(),w:ce.default("22.58mm"),h:ce.optional(),left:ce.optional().default(20),right:ce.optional().default(20),top:ce.optional().default(2),bottom:ce.optional().default(2),p:ce.default(ce.parse("2.54mm")),pw:ce.default(ce.parse("1.6mm")),pl:ce.default(ce.parse("2.4mm")),innerhole:Fe().default(!1),innerholeedgedistance:ce.default(ce.parse("1.61mm")),silkscreenlabels:Fe().default(!1),silkscreenlabelmargin:ce.default(ce.parse("0.1mm"))}),m4o=t=>{const e=_3t.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},Iie=(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},p4o=t=>{const e=_3t.parse(t),n=e.h??m4o(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=Iie(e.w/2-e.pl*1.4,_+m*e.p,"right")),o.push(Go(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),f=`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:f,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=Iie(-e.w/2+e.pl*1.4,_-m*e.p,"left")),o.push(Go(m+1,-e.w/2+e.pl/2,_-m*e.p,e.pl,e.pw)),e.silkscreenlabels){const p=m+1,f=`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:f,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=Iie(_-m*e.p,n/2-e.pl*1.4,"top")),o.push(Go(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),f=`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:f,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=Iie(_+m*e.p,-n/2+e.pl*1.4,"bottom")),o.push(Go(m+1+e.left,_+m*e.p,-n/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const p=m+1+e.left,f=`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:f,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"},h={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"},d=mi(0,n/1.8,n/25);return{circuitJson:[...o,...i,...r,h,...e.silkscreenlabels?[]:[u],d],parameters:e}},m3t=ui.extend({fn:F(),w:ce.default("22.58mm"),h:ce.optional(),left:ce.optional().default(20),right:ce.optional().default(20),top:ce.optional().default(2),bottom:ce.optional().default(2),p:ce.default(ce.parse("2.54mm")),pw:ce.default(ce.parse("1.6mm")),pl:ce.default(ce.parse("3.2mm")),innerhole:Fe().default(!1),innerholeedgedistance:ce.default(ce.parse("1.61mm"))}),I4o=t=>{const e=m3t.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},f4o=(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]},C4o=t=>{const e=m3t.parse(t),n=e.h??I4o(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 d=(e.left-1)/2*e.p;for(let _=0;_<e.left;_++)_===0&&(c=f4o(-e.w/2-e.pl/2,d-_*e.p,"left")),o.push(Go(l,-e.w/2+e.pl/2,d-_*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:d-_*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,d-_*e.p,s,a))}if(e.bottom){const d=(e.bottom-1)/2*e.p;for(let _=e.bottom-1;_>=0;_--)o.push(Go(l,d-_*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:d-_*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,d-_*e.p,-n/2+e.innerholeedgedistance,s,a))}if(e.right){const d=-((e.right-1)/2)*e.p;for(let _=0;_<e.right;_++)o.push(Go(l,e.w/2-e.pl/2,d+_*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:d+_*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,d+_*e.p,s,a))}if(e.top){const d=-((e.top-1)/2)*e.p;for(let _=e.top-1;_>=0;_--)o.push(Go(l,d+_*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:d+_*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,d+_*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"},h=mi(0,n/1.8,n/25);return{circuitJson:[...r,...o,...i,u,g,h],parameters:e}},y4o=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),NT(t)),p3t=ui.extend({fn:F(),w:ce.default("10mm"),h:ce.optional(),left:ce.optional().default(20),right:ce.optional().default(20),top:ce.optional().default(0),bottom:ce.optional().default(0),p:ce.default(ce.parse("2.54mm")),id:ce.optional().default(ce.parse("1mm")),od:ce.optional().default(ce.parse("1.5mm"))}),E4o=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},fie=(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]},x4o=t=>{const e=p3t.parse(t),n=e.h??E4o(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=fie(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=fie(-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=fie(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=fie(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=mi(0,n/1.7,n/25);return{circuitJson:[...o,A,c,a],parameters:e}},B4o=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,h=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}}),d=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},...h.slice(1,-1),{x:u,y:n-i},{x:g,y:n-i},...d.slice(1,-1)]}const a=n-o,A=n+o,c=Array.from({length:r+1},(g,u)=>{const h=Math.PI-u*Math.PI/r;return{x:e+Math.cos(h)*i,y:A+Math.sin(h)*i}}),l=Array.from({length:r+1},(g,u)=>{const h=u*Math.PI/r;return{x:e+Math.cos(h)*i,y:a-Math.sin(h)*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)]},I3t=(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}}),Q4o=ui.extend({fn:F(),p:ce.optional().default("4.88mm"),id:ce.optional().default("0.8mm"),od:ce.optional().default("1.5mm"),w:ce.optional().default("5.6mm"),h:ce.optional().default("3.5mm")}),S4o=t=>{const e=Q4o.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=I3t(-r/2,0,a,"left"),l=I3t(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=mi(0,n/4,.5),d=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:B4o({centerX:0,centerY:0,straightHalfLength:d,radius:_,arcSegmentCount:9}),layer:"top"};return{circuitJson:[...A,g,u,m],parameters:e}};ui.extend({w:ce,h:ce});var b4o=t=>{const{w:e,h:n}=t,o=Ha(e),i=Ha(n);return{circuitJson:[Go(1,0,0,o,i),mi(0,i/2+.5,.2)],parameters:t}},Sv=(t,e,n,o,i,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:e,y:n,outer_width:Ha(i),outer_height:Ha(r),hole_width:Ha(o),hole_height:Ha(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),D4o=[{x:-2.73,y:3.71},{x:-2.73,y:-1.03},{x:2.73,y:-1.03},{x:2.73,y:3.71}],P4o=ui.extend({fn:F(),num_pins:Rn([De(3),De(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:Fe().default(!1),string:F().optional()}),v4o=(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}}),M4o=t=>{const e=t.string?.match(/^to92_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=P4o.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),h=Number.parseFloat(s),d=h,_=h*(1.5/1.05);let m=[];if(o.num_pins===3)c?m=[xy({pn:1,x:-g,y:l-g,holeDiameter:u,rectPadWidth:h,rectPadHeight:_}),Sv(2,0,l-g,u,d,_),Sv(3,g,l-g,u,d,_)]:m=[xy({pn:1,x:-g,y:l-g,holeDiameter:u,rectPadWidth:h,rectPadHeight:h}),Js(2,0,l,u,h),Js(3,g,l-g,u,h)];else if(o.num_pins===2)m=[xy({pn:1,x:-g,y:l-g,holeDiameter:u,rectPadWidth:d,rectPadHeight:_}),Sv(2,g,l-g,u,d,_)];else throw new Error("Invalid number of pins for TO-92");const p=Number.parseFloat(a)/2,f=v4o(0,l,p),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...f,{x:-p,y:0},{x:p,y:0},f[0]],stroke_width:.1,pcb_silkscreen_path_id:""},C=mi(0,l+1,.5),y={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:D4o,layer:"top"};return{circuitJson:[...m,I,C,y],parameters:o}},w4o=ui.extend({fn:F(),num_pins:De(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")}),N4o=t=>{const e=w4o.parse(t),n=mi(0,ce.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2+.2},{x:-ce.parse(e.w)/2-.2,y:ce.parse(e.h)/2+.2},{x:-ce.parse(e.w)/2-.2,y:-ce.parse(e.h)/2-.2},{x:ce.parse(e.p)/2,y:-ce.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:T4o(e).concat(...Kf(e),o,n,s),parameters:e}},R4o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},T4o=t=>{const e=[],n=ce.parse(t.p),o=ce.parse(t.pl),i=ce.parse(t.pw),r=.075;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=R4o({pn:s,p:n});e.push(Go(s,a,A,o,i,r))}return e},k4o=h6({w:"7.05mm",p:"1.27mm",pw:"0.65mm",pl:"1.975mm"}),F4o=t=>{const e=k4o.parse(t),n=[];for(let u=0;u<e.num_pins;u++){const{x:h,y:d}=ZMe({num_pins:e.num_pins,pn:u+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(Go(u+1,h,d,e.pl??"1.5mm",e.pw??"0.6mm"))}const o=(e.num_pins/2-1)*e.p+e.pw,i=mi(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:XC([{minX:-A,maxX:A,minY:-c,maxY:c},{minX:-a,maxX:a,minY:-l,maxY:l}])};return{circuitJson:[...n,i,r,g],parameters:e}},L4o=ui.extend({fn:F(),num_pins:De(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")}),H4o=t=>{const e=L4o.parse(t),n=mi(0,ce.parse(e.h)/2+1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2+.5,y:ce.parse(e.h)/2+.5},{x:-ce.parse(e.w)/2-.5,y:ce.parse(e.h)/2+.5},{x:-ce.parse(e.w)/2-.5,y:-ce.parse(e.h)/2-.5},{x:ce.parse(e.p)/2+.5,y:-ce.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:O4o(e).concat(...Kf(e),o,n,s),parameters:e}},G4o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},O4o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=G4o({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},K4o=ui.extend({fn:F(),num_pins:De(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")}),U4o=t=>{const e=K4o.parse(t),n=mi(0,ce.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:z4o(e).concat(...Kf(e),o,n,s),parameters:e}},Y4o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},z4o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=Y4o({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},V4o=ui.extend({fn:F(),num_pins:De(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")}),J4o=t=>{const e=V4o.parse(t),n=mi(0,ce.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:W4o(e).concat(...Kf(e),o,n,s),parameters:e}},q4o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},W4o=t=>{const e=[],n=ce.parse(t.p),o=ce.parse(t.pl),i=ce.parse(t.pw),r=.05625;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=q4o({pn:s,p:n});e.push(Go(s,a,A,o,i,r))}return e},j4o=ui.extend({fn:F(),num_pins:De(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")}),X4o=t=>{const e=j4o.parse(t),n=ce.parse(e.w),o=ce.parse(e.h),i=ce.parse(e.pl),r=ce.parse(e.pw),s=ce.parse(e.p),a=mi(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,h=c/2,d=l/2,_=Math.max(g,h),m=Math.max(u,d),p=Math.min(g,h),f=Math.min(u,d),I=_+.05,C=p-.055,y=m,E=f+.155,B={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:XC([{minX:-I,maxX:I,minY:-E,maxY:E},{minX:-C,maxX:C,minY:-y,maxY:y}]),layer:"top"};return{circuitJson:Z4o(e).concat(...Kf(e),A,a,B),parameters:e}},$4o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Z4o=t=>{const e=[],n=ce.parse(t.p),o=ce.parse(t.pl),i=ce.parse(t.pw),r=.03125;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=$4o({pn:s,p:n});e.push(Go(s,a,A,o,i,r))}return e},e5o=ui.extend({fn:F(),num_pins:De(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")}),t5o=t=>{const e=e5o.parse(t),n=mi(0,ce.parse(e.h)+.1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2+.2,y:ce.parse(e.h)/2+.2},{x:-ce.parse(e.w)/2-.2,y:ce.parse(e.h)/2+.2},{x:-ce.parse(e.w)/2-.2,y:-ce.parse(e.h)/2-.2},{x:ce.parse(e.p)/2+.2,y:-ce.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:o5o(e).concat(...Kf(e),o,n,s),parameters:e}},n5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},o5o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=n5o({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.025))}return e},i5o=ui.extend({fn:F(),num_pins:De(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")}),r5o=t=>{const e=i5o.parse(t),n=mi(0,ce.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.pad_spacing)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:-ce.parse(e.h)/2},{x:ce.parse(e.pad_spacing)/2,y:-ce.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:a5o(e).concat(...Kf(e),o,n,s),parameters:e}},s5o=t=>{const{pn:e,pad_spacing: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}=s5o({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.0625))}return e},A5o=ui.extend({fn:F(),num_pins:De(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")}),c5o=t=>{const e=A5o.parse(t),n=mi(0,ce.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:g5o(e).concat(...Kf(e),o,n,s),parameters:e}},l5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},g5o=t=>{const e=[],n=ce.parse(t.p),o=ce.parse(t.pl),i=ce.parse(t.pw),r=.125;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=l5o({pn:s,p:n});e.push(Go(s,a,A,o,i,r))}return e},u5o=ui.extend({fn:F(),num_pins:De(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")}),d5o=t=>{const e=u5o.parse(t),n=mi(0,ce.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:_5o(e).concat(...Kf(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}},_5o=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(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},m5o=ui.extend({fn:F(),num_pins:De(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")}),p5o=t=>{const e=m5o.parse(t),n=mi(0,ce.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.1,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.1,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:f5o(e).concat(...Kf(e),o,n,s),parameters:e}},I5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},f5o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=I5o({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},C5o=ui.extend({fn:F(),num_pins:De(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")}),y5o=t=>{const e=C5o.parse(t),n=mi(0,ce.parse(e.h)/2+.4,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:x5o(e).concat(...Kf(e),o,n,s),parameters:e}},E5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},x5o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=E5o({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},f3t=(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()]}),B5o=[{x:-2.85,y:-2.5},{x:-2.85,y:2.5},{x:2.25,y:2.5},{x:2.25,y:-2.5}],Q5o=[{x:-2.85,y:-2.5},{x:-2.85,y:2.5},{x:2.85,y:2.5},{x:2.85,y:-2.5}],S5o=[{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}],b5o=[{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}],D5o=ui.extend({fn:F(),num_pins:Rn([De(3),De(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()}),P5o=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=[Go(1,r,e,i,n),f3t(2,b5o),Go(3,r,-e,i,n)],c=mi(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:B5o,layer:"top"};return[...A,l,g,c,u]},v5o=t=>{const e=[Go(1,-1.85,-1.5,1.5,.7),Go(2,-1.85,1.5,1.5,.7),f3t(3,S5o),Go(4,1.85,-1.5,1.5,.7),Go(5,1.85,1.5,1.5,.7)],n=Number.parseFloat(t.w)/2-1,o=Number.parseFloat(t.h)/2,i=mi(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:Q5o,layer:"top"};return[...e,r,s,i,a]},M5o=t=>{const e=t.string?.match(/^sot89_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=D5o.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:P5o(o),parameters:o};if(o.num_pins===5)return{circuitJson:v5o(o),parameters:o};throw new Error("Invalid number of pins for SOT89")},w5o=ui.extend({fn:F(),p:ce.optional().default("5.0mm"),id:ce.optional().default("1.0mm"),od:ce.optional().default("1.9mm"),w:ce.optional().default("13mm"),h:ce.optional().default("7mm"),num_pins:Ue().optional(),string:F().optional()}),C3t=t=>{const e=w5o.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,h=Math.max(g,u/(a-1)),d=Array.from({length:a},(O,U)=>{const W=a%2===0?(U-a/2+.5)*h:(U-Math.floor(a/2))*h;return Js(U+1,W,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:""},f=[{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:""}],I=mi(0,r/2+.6,.5),C=Math.max(...d.map(O=>Math.abs(O.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:[...d,_,p,...f,I,G],parameters:{...e,p:h}}},nwe=2.54,N5o=ui.extend({fn:F(),id:ce.optional().default("1.2mm"),od:ce.optional().default("1.905mm"),ph:ce.optional().default("2mm"),w:ce.optional().default("13mm"),h:ce.optional().default("7mm"),num_pins:Ue().optional(),string:F().optional()}),R5o=t=>{const e=N5o.parse(t),n=e.num_pins??Number.parseInt(e.string?.match(/^to220f(?:_|-)(\d+)/i)?.[1]??"3"),o=C3t({...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)*nwe:(A-Math.floor(n/2))*nwe;return A===0?xy({pn:1,x:c,y:i,holeDiameter:e.id,rectPadWidth:e.od,rectPadHeight:e.ph}):Sv(A+1,c,i,Ha(e.id),Ha(e.od),Ha(e.ph))}),s=o.circuitJson.filter(a=>a.type!=="pcb_plated_hole");return{circuitJson:[...r,...s],parameters:{...e,p:nwe,num_pins:n}}},T5o=ui.extend({fn:F(),num_pins:De(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")}),k5o=t=>{const e=T5o.parse(t),n=mi(0,ce.parse(e.h)/2+.4,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:L5o(e).concat(o,n,s),parameters:e}},F5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},L5o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=F5o({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},H5o=ui.extend({fn:F(),num_pins:De(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")}),G5o=t=>{const e=H5o.parse(t),n=mi(0,ce.parse(e.h)+.1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2+.1,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2+.1,y:-ce.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:K5o(e).concat(...Kf(e),o,n,s),parameters:e}},O5o=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}=O5o({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.0625))}return e},U5o=ui.extend({fn:F(),num_pins:De(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")}),Y5o=t=>{const e=U5o.parse(t),n=mi(0,ce.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:V5o(e).concat(o,n,s),parameters:e}},z5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},V5o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=z5o({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},J5o=ui.extend({fn:F(),num_pins:De(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")}),q5o=t=>{const e=J5o.parse(t),n=mi(0,ce.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.1,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.1,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:j5o(e).concat(o,n,s),parameters:e}},W5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},j5o=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=W5o({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.1))}return e},X5o=ui.extend({fn:F(),num_pins:De(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")}),$5o=t=>{const e=X5o.parse(t),n=mi(0,ce.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.5,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.5,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:eDo(e).concat(o,n,s),parameters:e}},Z5o=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},eDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=Z5o({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},tDo=ui.extend({fn:F(),num_pins:De(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")}),nDo=t=>{const e=tDo.parse(t),n=mi(0,ce.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:iDo(e).concat(o,n,s),parameters:e}},oDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},iDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=oDo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},rDo=ui.extend({fn:F(),num_pins:De(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")}),sDo=t=>{const e=rDo.parse(t),n=mi(0,ce.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.1,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.1,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:ADo(e).concat(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}},ADo=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(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},cDo=ui.extend({fn:F(),num_pins:De(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")}),lDo=t=>{const e=cDo.parse(t),n=mi(0,3,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2-.8},{x:-ce.parse(e.w)/2-.8,y:ce.parse(e.h)/2-.8},{x:-ce.parse(e.w)/2-.8,y:-ce.parse(e.h)/2+.8},{x:ce.parse(e.p)/2,y:-ce.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:uDo(e).concat(o,n,s),parameters:e}},gDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},uDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=gDo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.125))}return e},dDo=ui.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()}),hDo=t=>{const e=t.string?.match(/^sot223_(\d+)/),n=e?Number.parseInt(e[1],10):4;if(n===8){const i=pDo.parse({...t,num_pins:n});return{circuitJson:BU(i),parameters:i}}const o=dDo.parse({...t,num_pins:n});if(o.num_pins===4)return{circuitJson:mDo(o),parameters:o};if(o.num_pins===5)return{circuitJson:fDo(o),parameters:o};if(o.num_pins===6)return{circuitJson:yDo(o),parameters:o};throw new Error("Invalid number of pins")},_Do=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}},mDo=t=>{const e=[];let n=0,o=0;for(let d=0;d<t.num_pins;d++){const{x:_,y:m}=_Do({num_pins:t.num_pins,pn:d+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),p=d===3?3.8:Number.parseFloat(t.pw),f=Number.parseFloat(t.pl);n=Math.max(n,Math.abs(_)+f/2),o=Math.max(o,Math.abs(m)+p/2),e.push(Go(d+1,_,m,f,p))}const i=mi(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),h={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,h]},pDo=h6({p:"0.90mm",w:"2.8mm",legsoutside:!0}),IDo=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")},fDo=t=>{const e=[];let n=0,o=0;for(let d=1;d<=t.num_pins;d++){const{x:_,y:m}=IDo({h:Number.parseFloat(t.h),p:1.5,pn:d,w:Number.parseFloat(t.w)});let p=Number.parseFloat(t.pw),f=Number.parseFloat(t.pl);d===5?(p=3.4,f=1.8):(p=1,f=2.2),n=Math.max(n,Math.abs(_)+f/2),o=Math.max(o,Math.abs(m)+p/2),e.push(Go(d,_,m,f,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=mi(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),h={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,h]},CDo=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")},yDo=t=>{const e=[];let n=0,o=0;for(let d=1;d<=t.num_pins;d++){const{x:_,y:m}=CDo({h:Number.parseFloat(t.h),p:1.3,pn:d,w:8.7});let p=Number.parseFloat(t.pw),f=Number.parseFloat(t.pl);d===6?(p=3.4,f=2.15):(p=.6,f=2.2),n=Math.max(n,Math.abs(_)+f/2),o=Math.max(o,Math.abs(m)+p/2),e.push(Go(d,_,m,f,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=mi(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),h={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,h]},EDo=ui.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()}),xDo=t=>{const e=t.string?.match(/^sot23w_(\d+)/),n=e?Number.parseInt(e[1],3):3,o=EDo.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:QDo(o),parameters:o};throw new Error("Invalid number of pins")},BDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.95}:e===2?{x:-n,y:-.95}:{x:n,y:0}},QDo=t=>{const e=[];for(let p=0;p<t.num_pins;p++){const{x:f,y:I}=BDo({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(Go(p+1,f,I,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=mi(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,h=l/2,d=g+.25,_=Math.max(u+.25,h+.09),m={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*d,height:2*_,layer:"top"};return[...e,r,s,n,m]},SDo=ui.extend({fn:F(),num_pins:Rn([De(3),De(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()}),bDo=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)]},DDo=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[xy({pn:1,x:-s,y:r-s,holeDiameter:a,rectPadWidth:A,rectPadHeight:c}),Sv(2,s,r-s,a,A,c)]},PDo=t=>{const e=t.string?.match(/^to92s_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=SDo.parse({...t,num_pins:n});let i=[];if(o.num_pins===3)i=bDo(o);else if(o.num_pins===2)i=DDo(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=mi(0,r+1,.5),c=Number.parseFloat(o.od),l=r-s,g=-s-c/2,u=s+c/2,h=l-c/2,d=l+c/2,_=-r,m=r,p=0,f=r+.5,I=Math.min(g,_)-.27,C=Math.max(u,m)+.13,y=Math.min(h,p)-.42,E=Math.max(d,f)+.08,B={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(I+C)/2,y:(y+E)/2},width:C-I,height:E-y,layer:"top"};return{circuitJson:[...i,a,A,B],parameters:o}},vDo=ui.extend({fn:F(),p:ce.optional(),id:ce.optional(),pw:ce.optional(),pl:ce.optional(),w:ce.optional(),h:ce.optional(),sh:Fe().optional().describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Fe().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),zh:Fe().optional().describe("JST ZH (Through-hole) connector family. 1.5mm pitch wire-to-board."),string:F().optional()}),MDo=()=>({minX:Number.POSITIVE_INFINITY,maxX:Number.NEGATIVE_INFINITY,minY:Number.POSITIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY}),QU=({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)},wDo={ph:{p:ce.parse("2.2mm"),id:ce.parse("0.70mm"),pw:ce.parse("1.20mm"),pl:ce.parse("1.20mm"),w:ce.parse("6mm"),h:ce.parse("5mm")},sh:{p:ce.parse("1mm"),pw:ce.parse("0.6mm"),pl:ce.parse("1.55mm"),w:ce.parse("5.8mm"),h:ce.parse("7.8mm")},zh:{p:ce.parse("1.5mm"),id:ce.parse("0.73mm"),pw:ce.parse("1.03mm"),pl:ce.parse("1.73mm"),w:ce.parse("3mm"),h:ce.parse("3.5mm")}};function NDo(t){return t.sh?"sh":t.ph?"ph":t.zh?"zh":"ph"}function RDo({variant:t,numPins:e,p:n,id:o,pw:i,pl:r}){const s=[],a=MDo();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(xy({pn:l+1,x:g,y:2,holeDiameter:o,rectPadWidth:i,rectPadHeight:r})),QU({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(xy({pn:l+1,x:g,y:0,holeDiameter:o,rectPadWidth:i,rectPadHeight:r,rectBorderRadius:.12499977})):s.push(Sv(l+1,g,0,o,i,r)),QU({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(Go(g+1,u,-1.325,i,r)),QU({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(Go(e+1,-l,1.22,1.2,1.8)),s.push(Go(e+2,l,1.22,1.2,1.8)),QU({bounds:a,centerX:-l,centerY:1.22,width:1.2,height:1.8}),QU({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 TDo({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 kDo=t=>{const e=vDo.parse(t),n=NDo(e),o=wDo[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:"",h=u.match(/(?:^|_)jst(\d+)(?:_|$)/),d=u.match(/(?:^|_)zh(\d+)(?:_|$)/);if(h&&h[1]){const re=Number.parseInt(h[1],10);Number.isNaN(re)||(l=re)}if(d&&d[1]){const re=Number.parseInt(d[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 _=RDo({variant:n,numPins:l,p:i,id:r,pw:s,pl:a}),{pads:m,padBounds:p,maxPadHalfY:f}=_,I=TDo({variant:n,w:A,h:c,numPins:l,p:i}),C=mi(0,c/2+1,.5),y=I.route.map(re=>re.x),E=I.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=f+.085,O=Q-w,U=b+w,W=D-G,j=R+H,te={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(O+U)/2,y:(W+j)/2},width:U-O,height:j-W,layer:"top"};return{circuitJson:[...m,I,C,te],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"}}},FDo=ui.extend({fn:F(),num_pins:De(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")}),LDo=t=>{const e=FDo.parse(t),n=mi(0,ce.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:GDo(e).concat(...Kf(e),o,n,s),parameters:e}},HDo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},GDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=HDo({pn:n,p:Number.parseFloat(t.p)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw),.1))}return e},ODo=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"}}},KDo=ui.extend({fn:F(),num_pins:Rn([De(8),De(10)]).default(8),w:F().optional(),h:F().optional(),p:F().optional(),pl:F().optional(),pw:F().optional(),string:F().optional()}),UDo=t=>{const e=KDo.parse(t),n=ODo(e.num_pins),o=ce.parse(e.w||n.w),i=ce.parse(e.h||n.h),r=ce.parse(e.p||n.p),s=ce.parse(e.pl||n.pl),a=ce.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}=y3t(e.num_pins,Q+1,o,r),R=Q<c?Q+1:e.num_pins-(Q-c);A.push(Go(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:""},h={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=y3t(e.num_pins,1,l,r),_={x:d.x-.8,y:d.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=mi(0,g/2+.5,.3),f=(e.num_pins/2-1)*r+a,I=o/2+.25,C=I+1.43,y=f/2+.255,E=i/2+.25,B={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:XC([{minX:-C,maxX:C,minY:-y,maxY:y},{minX:-I,maxX:I,minY:-E,maxY:E}])};return{circuitJson:[...A,u,h,p,m,B],parameters:e}},y3t=(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}},YDo=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"}}},zDo=ui.extend({fn:F(),num_pins:Rn([De(8),De(10),De(12),De(16)]).default(8),w:F().optional(),h:F().optional(),p:F().optional(),pl:F().optional(),pw:F().optional(),string:F().optional()}),E3t=(t,e,n,o,i)=>{const r=t/2,s=(e-1)%r,a=e<=r?-1:1,A=(r-1)/2-s,c=ce.parse("0.2mm");return{x:a*(n/2+i/2-c),y:A*o}},VDo=t=>{const e=zDo.parse(t),n=YDo(e.num_pins),o=ce.parse(e.w||n.w),i=ce.parse(e.h||n.h),r=ce.parse(e.p||n.p),s=ce.parse(e.pl||n.pl),a=ce.parse(e.pw||n.pw),A=[];for(let B=0;B<e.num_pins;B++){const{x:Q,y:b}=E3t(e.num_pins,B+1,o,r,s);A.push(Go(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:""},h=E3t(e.num_pins,1,c,r,s),d={x:h.x-.8,y:h.y},_={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"},m=mi(0,l/2+.5,.3),p=(e.num_pins/2-1)*r+a,f=o/2+.25,I=f+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:XC([{minX:-I,maxX:I,minY:-C,maxY:C},{minX:-f,maxX:f,minY:-y,maxY:y}])};return{circuitJson:[...A,g,u,m,_,E],parameters:e}},JDo=ui.extend({fn:F(),num_pins:De(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")}),qDo=t=>{const e=JDo.parse(t),n=mi(0,ce.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.pad_spacing)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:-ce.parse(e.h)/2},{x:ce.parse(e.pad_spacing)/2,y:-ce.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:jDo(e).concat(...Kf(e),o,n,s),parameters:e}},WDo=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},jDo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=WDo({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},XDo=ui.extend({fn:F(),num_pins:De(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")}),$Do=t=>{const e=XDo.parse(t),n=mi(0,ce.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.pad_spacing)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.2,y:-ce.parse(e.h)/2},{x:ce.parse(e.pad_spacing)/2,y:-ce.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:ePo(e).concat(...Kf(e),o,n,s),parameters:e}},ZDo=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},ePo=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:i}=ZDo({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(Go(n,o,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},tPo=ui.extend({fn:F(),num_pins:Rn([De(6),De(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:Fe().default(!1)}),nPo=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=tPo.parse({...t,num_pins:n}),i=ce.parse(o.w),r=ce.parse(o.h),s=ce.parse(o.p),a=ce.parse(o.pl),A=ce.parse(o.pw),c=ce.parse(o.epw),l=ce.parse(o.eph),g=[];for(let w=0;w<o.num_pins;w++){const{x:H,y:G}=owe(o.num_pins,w+1,i,s);g.push(Go(w+1,H,G,a,A))}o.ep&&g.push(Go(o.num_pins+1,0,0,c,l));const u=i,h=r,d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:h/2},{x:u/2,y:h/2}],stroke_width:.05,pcb_silkscreen_path_id:""},_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:-h/2},{x:u/2,y:-h/2}],stroke_width:.05,pcb_silkscreen_path_id:""},m=owe(o.num_pins,1,u,s),p={x:m.x-.4,y:m.y},f={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"},I=mi(0,h/2+.5,.3),C=Math.abs(owe(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:XC([{minX:-Q,maxX:Q,minY:-b,maxY:b},{minX:-B,maxX:B,minY:-D,maxY:D}])};return{circuitJson:[...g,d,_,I,f,R],parameters:o}},owe=(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*ce.parse("1.4mm"),y:a*o}},oPo=ui.extend({fn:F(),num_pins:Ue().optional().default(8),p:it.describe("pitch (distance between center of each pin)"),w:ce.describe("width between vertical rows of pins"),grid:mie.describe("width and height of the border of the footprint"),ep:mie.default("0x0mm").describe("width and height of the central exposed thermal pad"),epx:ce.default("0mm").describe("x offset of the center of the central exposed thermal pad"),pinw:ce.describe("width of the pin pads"),pinh:ce.describe("height of the pin pads")}),iPo=t=>{const e=oPo.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}=rPo({pinCount:n,pinIndex:B,width:i,pitch:o});l.push(Go(B+1,Q,b,A,c))}s.x>0&&s.y>0&&l.push(Go(e.num_pins+1,a,0,s.x,s.y));const g=sPo(r),u=mi(0,r.y/2+o,r.y/6),h=(n/2-1)*o+c,d=i+A,_=r.x/2+.25,m=d/2+.25,p=h/2+.25,f=h/2+.45+Math.max(0,.8-o),I=Math.min(r.y/2+.25,f),C=Math.max(0,.37-Math.max(0,m-_-.38)*1.4),y=Math.max(p,I-C),E={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:XC([{minX:-m,maxX:m,minY:-y,maxY:y},{minX:-_,maxX:_,minY:-I,maxY:I}])};return{circuitJson:[...l,...g,u,E],parameters:e}},rPo=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}},sPo=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}]},aPo=t=>{const{num_pins:e,bridged:n,p:o=2.54,pw:i=1.5,ph:r=1.5}=t,s=ce.parse(o),a=ce.parse(i),A=ce.parse(r),c=Math.min(A/4,.5),l=[];for(let D=0;D<e;D++)l.push(Go(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,O=(H-1)*s,U=Math.sign(O-G),W=G+U*(a/2),j=O-U*(a/2);g.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${w}}`,x:W,y:0,width:c,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${H}}`,x:j,y:0,width:c,layer:"top",route_type:"wire"}]})}}}const u=(e-1)*s+a+.7,h=A+1,d=(e-1)*s/2,_=0,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:d-u/2,y:_-h/2},{x:d+u/2,y:_-h/2},{x:d+u/2,y:_+h/2},{x:d-u/2,y:_+h/2},{x:d-u/2,y:_-h/2}],stroke_width:.15},f=_+h/2+.6,I=mi(d,f,.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,I,b],parameters:t}},x3t={fn:De("sot457"),num_pins:De(6).default(6),pillh:F().default("0.45mm"),pillw:F().default("1.45mm"),pl:F(),pw:F(),p:F(),wave:Fe().optional(),reflow:Fe().optional()},APo=ui.extend({...x3t,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")}),cPo=ui.extend({...x3t,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)})),Z4=t=>Number.parseFloat(t.replace("mm","")),B3t=({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},Q3t=t=>{const e=[],n=Z4(t.p),o=Z4(t.pl),i=Z4(t.pw),r=Z4(t.w),s=Z4(t.h);if(t.wave){const _={1:({padWidth:m,padHeight:p})=>Go(1,-n,n,p,m),2:({padWidth:m,padHeight:p})=>Go(2,-n,-n,p,m),3:({padWidth:m,padHeight:p})=>pie(3,-n,0,Z4(t.pillw),Z4(t.pillh)),4:({padWidth:m,padHeight:p})=>pie(4,n,0,Z4(t.pillw),Z4(t.pillh)),5:({padWidth:m,padHeight:p})=>Go(5,n,n,p,m),6:({padWidth:m,padHeight:p})=>Go(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}=B3t({pitch:n,width:r,pinNumber:_});e.push(Go(_,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=mi(0,s+.5,.3),l=B3t({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 h={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 d;if(t.wave){const _=2*n,m=2*n,p=_/2+i/2,f=m/2+o/2,I=p+.25,C=f+.25;d={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*I,height:2*C,layer:"top"}}else{const m=r/2+.1+o/2,p=n+i/2,f=r/2,I=s/2,C=m+.25,y=f+.08,E=p+.25,B=Math.max(I+.45,E);d={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:XC([{minX:-C,maxX:C,minY:-E,maxY:E},{minX:-y,maxX:y,minY:-B,maxY:B}]),layer:"top"}}return[c,a,A,h,...e,d]},lPo=t=>{if(t.wave){const n=cPo.parse({...t,fn:"sot457"});return{circuitJson:Q3t(n),parameters:n}}const e=APo.parse(t);return{circuitJson:Q3t(e),parameters:e}},gPo=[{x:-.8,y:.75},{x:.8,y:.75},{x:.8,y:-.75},{x:-.8,y:-.75}],uPo=ui.extend({fn:F(),num_pins:De(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()}),dPo=t=>{const e=uPo.parse({...t,fn:"sot963"}),n=ce.parse(e.w),o=ce.parse(e.h),i=ce.parse(e.p),r=ce.parse(e.pl),s=ce.parse(e.pw),a=[];for(let d=0;d<6;d++){const{x:_,y:m}=S3t(d+1,n,i,r);a.push(Go(d+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=mi(0,o/2+.4,.25),h={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:gPo,layer:"top"};return{circuitJson:[...a,A,c,u,g,h],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}},hPo=ui.extend({fn:F(),num_pins:Rn([De(3),De(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()}),_Po=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)]},mPo=t=>{const e=t.string?.match(/^potentiometer_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=hPo.parse({...t,num_pins:n});let i=[];o.num_pins===3&&(i=_Po(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=mi(l,r+1,.5),u=Number.parseFloat(o.od)/2,h=Number.parseFloat(o.h),d=Number.parseFloat(o.ca)/2,_=-(u+.25),m=h+u+.25,p=d+.25,f={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,f],parameters:o}},pPo=ui.extend({fn:F(),p:ce.optional().default("7.5mm"),id:ce.optional().default("1mm"),od:ce.optional().default("2mm"),d:ce.optional().default("10.5mm")}),IPo=(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}},fPo=t=>{const e=pPo.parse(t),{p:n,id:o,od:i,d:r}=e,s=[xy({pn:1,x:-n/2,y:0,holeDiameter:o,rectPadWidth:i,rectPadHeight:i}),Js(2,n/2,0,o,i)],{topArc:a,bottomArc:A}=IPo(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),h=i/2+1.5,d=.5,_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:u-d,y:h},{x:u+d,y:h}],stroke_width:.1,pcb_silkscreen_path_id:""},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:u,y:h-d},{x:u,y:h+d}],stroke_width:.1,pcb_silkscreen_path_id:""},p=mi(0,r/2+1,.5),f=r/2,I=n/2+i/2,y=Math.max(f,I)+.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}},CPo=ui.extend({fn:F(),num_pins:De(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")}),yPo=t=>{const e=CPo.parse(t),n=mi(0,ce.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.3,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.3,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2,y:-ce.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:xPo(e).concat(o,n,s),parameters:e}},EPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},xPo=t=>{const e=[],n=ce.parse(t.p),o=ce.parse(t.pl),i=ce.parse(t.pw),r=.125;for(let s=1;s<=t.num_pins;s++){const{x:a,y:A}=EPo({pn:s,p:n});e.push(Go(s,a,A,o,i,r))}return e},BPo=[{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}],QPo=ui.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()}),SPo=t=>{const e=t.string?.match(/^sot323_(\d+)/),n=e?Number.parseInt(e[1],3):3,o=QPo.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:DPo(o),parameters:o};throw new Error("Invalid number of pins")},bPo=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.65}:e===2?{x:-n,y:-.65}:{x:n,y:0}},DPo=t=>{const e=[];for(let A=0;A<t.num_pins;A++){const{x:c,y:l}=bPo({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(Go(A+1,c,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=mi(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:BPo,layer:"top"};return[...e,r,s,n,a]},PPo=ui.extend({fn:F(),circle:Fe().optional(),rect:Fe().optional(),square:Fe().optional(),pill:Fe().optional(),d:ce.optional(),pd:ce.optional(),diameter:ce.optional(),r:ce.optional(),pr:ce.optional(),radius:ce.optional(),w:ce.optional(),pw:ce.optional(),width:ce.optional(),h:ce.optional(),ph:ce.optional(),height:ce.optional(),s:ce.optional(),size:ce.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=Ha(t.r):t.pr!==void 0?n=Ha(t.pr):t.radius!==void 0?n=Ha(t.radius):t.d!==void 0?n=Ha(t.d)/2:t.pd!==void 0?n=Ha(t.pd)/2:t.diameter!==void 0?n=Ha(t.diameter)/2:n=Ha("1mm")/2:(t.w!==void 0?o=Ha(t.w):t.pw!==void 0?o=Ha(t.pw):t.width!==void 0?o=Ha(t.width):t.s!==void 0?o=Ha(t.s):t.size!==void 0?o=Ha(t.size):o=Ha("1mm"),t.h!==void 0?i=Ha(t.h):t.ph!==void 0?i=Ha(t.ph):t.height!==void 0?i=Ha(t.height):e==="square"||e==="rect"?i=o:i=Ha("1mm")),{fn:t.fn,shape:e,radius:n,width:o,height:i}}),vPo=t=>{const e=PPo.parse(t),{shape:n,radius:o,width:i,height:r}=e;let s,a;return n==="circle"?(s=i3t(1,{x:0,y:0,radius:o}),a=o+.5):n==="pill"?(s=pie(1,0,0,i,r),a=Math.max(i,r)/2+.5):(s=Go(1,0,0,i,r),a=r/2+.5),{circuitJson:[s,mi(0,a,.2)],parameters:e}},MPo=ui.extend({fn:F(),d:ce.optional(),hd:ce.optional(),r:ce.optional(),hr:ce.optional(),pd:ce.optional(),pr:ce.optional(),squarepad:Fe().optional().default(!1)}).transform(t=>{let e;t.d!==void 0?e=Ha(t.d):t.hd!==void 0?e=Ha(t.hd):t.r!==void 0?e=Ha(t.r)*2:t.hr!==void 0?e=Ha(t.hr)*2:e=Ha("1mm");let n;return t.pd!==void 0?n=Ha(t.pd):t.pr!==void 0?n=Ha(t.pr)*2:n=e*(1.5/1),{fn:t.fn,d:e,pd:n,squarepad:t.squarepad??!1}}),wPo=t=>{const e=MPo.parse(t),{d:n,pd:o,squarepad:i}=e;return{circuitJson:[i?xy({pn:1,x:0,y:0,holeDiameter:n,rectPadWidth:o,rectPadHeight:o}):Js(1,0,0,n,o),mi(0,o/2+.5,.2)],parameters:e}},NPo=ui.extend({fn:F(),num_pins:De(6).default(6),h:F().default("1.3mm"),pl:F().default("1.325mm"),pw:F().default("0.6mm"),p:F().default("0.95mm")}),RPo=t=>{const e=NPo.parse(t);return{circuitJson:TPo(e),parameters:e}},b3t=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")},TPo=t=>{const e=[];for(let B=1;B<=t.num_pins;B++){const{x:Q,y:b}=b3t({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:B});e.push(Go(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=mi(0,o+.3,.3),a=b3t({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),h=Number.parseFloat(t.pl),d=Number.parseFloat(t.pw),_=g/2+.4875,m=u*2+d,p=_+h/2,f=g/2+.4,I=p+.25,C=m/2+.25,y=C+.2,E={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:XC([{minX:-I,maxX:I,minY:-C,maxY:C},{minX:-f,maxX:f,minY:-y,maxY:y}])};return[...e,s,i,r,l,E]},kPo=[{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}],FPo=ui.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()}),LPo=t=>{const e=t.string?.match(/^sot343_(\d+)/),n=e?Number.parseInt(e[1],4):4,o=FPo.parse({...t,num_pins:n});if(o.num_pins===4)return{circuitJson:GPo(o),parameters:o};throw new Error("Invalid number of pins")},HPo=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}},GPo=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}=HPo({num_pins:t.num_pins,pn:C+1,p:s});e.push(Go(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,h=o*.3,d=u/2+h;let _=n*.8;o<=2.6&&(_/=2);const m=mi(g,d+.5,.3),p={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:g-_/2,y:d},{x:g+_/2,y:d}],type:"pcb_silkscreen_path",stroke_width:.1},f={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_bottom",route:[{x:g-_/2,y:-d},{x:g+_/2,y:-d}],type:"pcb_silkscreen_path",stroke_width:.1},I={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:kPo,layer:"top"};return[...e,p,f,m,I]},OPo=ui.extend({fn:F()}),KPo=t=>{const e=OPo.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=Go(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},h={x:-.5,y:A},d={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"};let _=1/0,m=-1/0,p=1/0,f=-1/0;const I=(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),f=Math.max(f,Q+D/2)};for(const B of n){const Q=B;I(Q.x,Q.y,Q.width,Q.height)}I(u.center.x,u.center.y,u.width,u.height);for(const B of d.route)I(B.x,B.y);const C=(_+m)/2,y=(p+f)/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(d),{circuitJson:[...n,u,d],parameters:e}},UPo=ui.extend({fn:F(),numPins:Ue().optional().default(0),rows:Rn([F(),Ue()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:ce.default("2.54mm").describe("pitch"),id:ce.default("1.0mm").describe("inner diameter"),od:ce.default("1.5mm").describe("outer diameter"),male:Fe().optional().describe("the module uses male headers"),nopin:Fe().optional().default(!1).describe("omit pins rendering"),female:Fe().optional().describe("the module uses female headers"),smd:Fe().optional().describe("surface mount device"),pinlabeltextalignleft:Fe().optional().default(!1),pinlabeltextaligncenter:Fe().optional().default(!1),pinlabeltextalignright:Fe().optional().default(!1),pinlabelverticallyinverted:Fe().optional().default(!1),pinlabelorthogonal:Fe().optional().default(!1),nopinlabels:Fe().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Fe().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Fe().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top"),pinRowSide:qt(["left","right","top","bottom"]).optional().default("left"),pinrowleft:Fe().optional().default(!1),pinrowright:Fe().optional().default(!1),pinrowtop:Fe().optional().default(!1),pinrowbottom:Fe().optional().default(!1),pinrowleftpins:Rn([F(),Ue()]).transform(t=>Number(t)).optional(),pinrowrightpins:Rn([F(),Ue()]).transform(t=>Number(t)).optional(),pinrowtoppins:Rn([F(),Ue()]).transform(t=>Number(t)).optional(),pinrowbottompins:Rn([F(),Ue()]).transform(t=>Number(t)).optional(),width:ce.optional(),height:ce.optional(),pinRowHoleEdgeToEdgeDist:ce.default("2mm"),holes:Rn([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:ce.optional(),holeYDist:ce.optional(),holeInset:ce.default("1mm"),pinrow:Rn([F(),Ue()]).optional(),usbposition:qt(["left","right","top","bottom"]).optional().default("left"),usbleft:Fe().optional().default(!1),usbtop:Fe().optional().default(!1),usbright:Fe().optional().default(!1),usbbottom:Fe().optional().default(!1),usbtype:qt(["micro","c"]).optional(),usbmicro:Fe().optional().default(!1),usbc:Fe().optional().default(!1),screen:Fe().optional().default(!1).describe("add silkscreen outline for screen/display area"),screenwidth:ce.optional(),screenheight:ce.optional(),screencenteroffsetx:ce.optional(),screencenteroffsety:ce.optional()}).transform(t=>{const e=d3t(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,h;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,h=(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,h=(c-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist):(h=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,u=(c-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist);t.numPins===0&&(u=10,h=10);const d=t.width??u,_=t.height??h,m=t.screenwidth??d*.95,p=t.screenheight??_*.95,f=t.screencenteroffsetx??0,I=t.screencenteroffsety??0;return{...t,pinlabelAnchorSide:e,pinRowSide:n,usbposition:o,usbtype:i,male:t.male??!t.female,female:t.female??!1,width:d,height:_,screenwidth:m,screenheight:p,screencenteroffsetx:f,screencenteroffsety:I,pinrowleftpins:r.left,pinrowrightpins:r.right,pinrowtoppins:r.top,pinrowbottompins:r.bottom}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:Nn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),YPo=t=>{const e=UPo.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:h,bottomsidepinlabel:d,pinRowSide:_,width:m,height:p,pinRowHoleEdgeToEdgeDist:f,holes:I,holeXDist:C,holeYDist:y,holeInset:E,pinrowleftpins:B,pinrowrightpins:Q,pinrowtoppins:b,pinrowbottompins:D,usbposition:R,usbtype:w,screen:H,screenwidth:G,screenheight:O,screencenteroffsetx:U,screencenteroffsety:W}=e;let j="center";l?j="left":g&&(j="right");const te=[],re={left:B,right:Q,top:b,bottom:D},X=Object.values(re).some(Ae=>Ae!==void 0&&Ae>0),ne=(Ae,ue,Ce,Ee)=>{if(e.smd?te.push(Go(Ae,ue,Ce,e.od,e.od)):Ae===1?te.push(xy({pn:Ae,x:ue,y:Ce,holeDiameter:o,rectPadWidth:i,rectPadHeight:i})):te.push(Js(Ae,ue,Ce,o,i)),!u){const Be=ue+(Ee==="left"?-i:Ee==="right"?i:0),he=Ce+(Ee==="top"?i:Ee==="bottom"?-i:0);d||te.push(_6({fs:i/5,pn:Ae,anchor_x:Be,anchor_y:he,textalign:j,orthogonal:c,verticallyinverted:A,layer:"top"})),(h||d)&&te.push(_6({fs:i/5,pn:Ae,anchor_x:Be,anchor_y:he,textalign:j,orthogonal:c,verticallyinverted:A,layer:"bottom"}))}};if(X){const Ae=n;let ue=1;const Ce=re.left??0,Ee=re.right??0,Be=re.top??0,he=re.bottom??0,ye=(me,Pe)=>{if(!(Pe<=0))if(me==="left"||me==="right"){const Te=me==="left"?-m/2+f:m/2-f,Je=(Pe-1)/2*Ae;for(let Ie=0;Ie<Pe;Ie++)ne(ue,Te,Je-Ie*Ae,me),ue++}else{const Te=me==="top"?p/2-f:-p/2+f,Je=-((Pe-1)/2)*Ae;for(let Ie=0;Ie<Pe;Ie++)ne(ue,Je+Ie*Ae,Te,me),ue++}};ye("left",Ce),ye("right",Ee),ye("top",Be),ye("bottom",he)}else{const Ae=n;let ue=0,Ce=0,Ee=0,Be=0,he=0,ye=0;const me=Math.ceil(s/r);_==="left"||_==="right"?(ue=_==="left"?-m/2+f:m/2-f,Ce=(me-1)/2*Ae,Ee=0,Be=-Ae,he=_==="left"?Ae:-Ae,ye=0):(ue=-(me-1)/2*Ae,Ce=_==="top"?p/2-f:-p/2+f,Ee=Ae,Be=0,he=0,ye=_==="top"?-Ae:Ae);let Pe=1;for(let Te=0;Te<r&&Pe<=s;Te++)for(let Je=0;Je<me&&Pe<=s;Je++){const Ie=ue+Je*Ee+Te*he,We=Ce+Je*Be+Te*ye;if(e.smd?te.push(Go(Pe,Ie,We,e.od,e.od)):Pe===1?te.push(xy({pn:Pe,x:Ie,y:We,holeDiameter:o,rectPadWidth:i,rectPadHeight:i})):te.push(Js(Pe,Ie,We,o,i)),!u){const we=Ie+(_==="left"?-i:_==="right"?i:0),ke=We+(_==="top"?i:_==="bottom"?-i:0);d||te.push(_6({fs:i/5,pn:Pe,anchor_x:we,anchor_y:ke,textalign:j,orthogonal:c,verticallyinverted:A,layer:"top"})),(h||d)&&te.push(_6({fs:i/5,pn:Pe,anchor_x:we,anchor_y:ke,textalign:j,orthogonal:c,verticallyinverted:A,layer:"bottom"}))}Pe++}}if(I)for(const Ae of I){let ue=0,Ce=0;Ae==="topleft"?(ue=-m/2+E,Ce=p/2-E):Ae==="topright"?(ue=m/2-E,Ce=p/2-E):Ae==="bottomleft"?(ue=-m/2+E,Ce=-p/2+E):Ae==="bottomright"?(ue=m/2-E,Ce=-p/2+E):Ae==="center"&&(ue=0,Ce=0),C!==void 0&&(ue+=C),y!==void 0&&(Ce+=y),te.push(Js(s+I.indexOf(Ae)+1,ue,Ce,o,i))}if(!e.nosilkscreen){const Ae=[{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}];te.push(m6(Ae,{stroke_width:.1,layer:"top"}))}const se=mi(0,p/2+1,.5);if(te.push(se),R&&w){let Ae,ue;if(w==="c")Ae=8,ue=3;else if(w==="micro")Ae=6,ue=2;else return{circuitJson:te,parameters:e};let Ce;if(R==="left")Ce=[{x:-m/2,y:-Ae/2},{x:-m/2+ue,y:-Ae/2},{x:-m/2+ue,y:Ae/2},{x:-m/2,y:Ae/2},{x:-m/2,y:-Ae/2}];else if(R==="right")Ce=[{x:m/2-ue,y:-Ae/2},{x:m/2,y:-Ae/2},{x:m/2,y:Ae/2},{x:m/2-ue,y:Ae/2},{x:m/2-ue,y:-Ae/2}];else if(R==="top")Ce=[{x:-Ae/2,y:p/2-ue},{x:Ae/2,y:p/2-ue},{x:Ae/2,y:p/2},{x:-Ae/2,y:p/2},{x:-Ae/2,y:p/2-ue}];else if(R==="bottom")Ce=[{x:-Ae/2,y:-p/2},{x:Ae/2,y:-p/2},{x:Ae/2,y:-p/2+ue},{x:-Ae/2,y:-p/2+ue},{x:-Ae/2,y:-p/2}];else return{circuitJson:te,parameters:e};te.push(m6(Ce,{stroke_width:.1,layer:"top"}))}if(H){const Ae=G/2,ue=O/2,Ce=U,Ee=W,Be=[{x:-Ae+Ce,y:-ue+Ee},{x:Ae+Ce,y:-ue+Ee},{x:Ae+Ce,y:ue+Ee},{x:-Ae+Ce,y:ue+Ee},{x:-Ae+Ce,y:-ue+Ee}];te.push(m6(Be,{stroke_width:.05,layer:"top"}))}return{circuitJson:te,parameters:e}},zPo=[{x:-1.45,y:2.75},{x:-1.45,y:-1.85},{x:4.05,y:-1.85},{x:4.05,y:2.75}],VPo=[{x:-1.55,y:2.75},{x:-1.55,y:-1.85},{x:3.95,y:-1.85},{x:3.95,y:2.75}],JPo=ui.extend({fn:F(),num_pins:Ue().default(3),inline:Fe().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")}),qPo=t=>{const e=JPo.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=[xy({pn:1,x:0,y:0,holeDiameter:e.id,rectPadWidth:r,rectPadHeight:s}),e.inline?Sv(2,n,0,Number.parseFloat(e.id),r,s):Js(2,n,n,e.id,r),e.inline?Sv(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 f=Math.PI*p/31;return{x:c+A*Math.cos(f),y:l+A*Math.sin(f)}}),h={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]]},d=mi(c,l+A+1,.5),_={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:e.inline?VPo:zPo,layer:"top"};return{circuitJson:[...a,h,d,_],parameters:e}},WPo=(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},jPo=(t,e)=>e.nosilkscreen?t.filter(n=>n.type!=="pcb_silkscreen_path"&&n.type!=="pcb_silkscreen_text"):t,XPo=(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,h=0)=>{const d=l-u/2,_=l+u/2,m=g-h/2,p=g+h/2;o=Math.min(o,d),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 $Po(t){return t!=null}var ZPo=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"),evo=t=>{let e=Cie();const n=ZPo(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($Po);for(const{fn:r,v:s}of i)e=e[r](s);return e.setString(n),e},tvo=()=>Object.keys($4),Cie=()=>{const t=new Proxy({},{get:(e,n)=>{if(n==="soup"||n==="circuitJson"){if("fn"in e&&$4[e.fn])return()=>{const{circuitJson:o}=$4[e.fn](e),i=jPo(o,e),r=WPo(i,e);return XPo(r,e.origin)};if(!$4[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(!$4[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>$4[e.fn](e).parameters}return n==="getFootprintNames"?()=>Object.keys($4):n==="params"?()=>e:n==="setString"?o=>(e.string=o,t):o=>(Object.keys(e).length===0?`${n}${o}`in $4?(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};Cie.string=evo,Cie.getFootprintNames=tvo;var nvo=Cie,D3t=Symbol("Fragment");function iwe(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 Jt=Symbol("Cuboid"),P3t=Symbol("Cube"),dA=Symbol("Cylinder"),yie=Symbol("Sphere"),MI=Symbol("RoundedCuboid"),jo=Symbol("Translate"),n0=Symbol("Rotate"),N_=Symbol("Union"),R_=Symbol("Subtract"),dc=Symbol("Hull"),or=Symbol("Colorize"),RT=Symbol("Polygon"),TT=Symbol("ExtrudeLinear"),By=Symbol("RoundedCylinder"),Gi=D3t,Ye=(t,e,n)=>iwe(t,e),wn=(t,e,n)=>iwe(t,e),ovo=({hole:t,isPin1:e})=>{const n=e?"#00ff00":"#b87333";if(t.shape==="circle")return Ye(or,{color:n,children:Ye(jo,{offset:[t.x,t.y,-.005],children:wn(R_,{children:[Ye(dA,{radius:t.outer_diameter/2,height:.01}),Ye(dA,{radius:t.hole_diameter/2,height:.01})]})})});if(t.shape==="circular_hole_with_rect_pad")return Ye(or,{color:n,children:Ye(jo,{offset:[t.x,t.y,0],children:wn(R_,{children:[Ye(Jt,{size:[t.rect_pad_width,t.rect_pad_height,.01],center:[0,0,0]}),Ye(dA,{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 Ye(or,{color:n,children:Ye(jo,{offset:[t.x,t.y,0],children:wn(R_,{children:[wn(dc,{children:[Ye(dA,{radius:r,height:.01,center:[s?-(o/2-r):0,s?0:-(i/2-r),0]}),Ye(dA,{radius:r,height:.01,center:[s?o/2-r:0,s?0:i/2-r,0]})]}),a===A?Ye(dA,{radius:a/2,height:.01}):wn(dc,{children:[Ye(dA,{radius:Math.min(a,A)/2,height:.01,center:[a>A?-(a/2-A/2):0,a>A?0:-(A/2-a/2),0]}),Ye(dA,{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)},o0=({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:h=.5,notchWidth:d=.25,chamferSize:_=0})=>{const m=o*A,p=o-m,f=Math.min(e,n)*s,I=Math.max(e-f,e*a),C=Math.max(n-f,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=wn(N_,{children:[wn(dc,{children:[Ye(jo,{z:.005,children:Ye(Jt,{size:[I,C,.01]})}),Ye(jo,{z:m,children:Ye(Jt,{size:[e,n,.01]})})]}),wn(dc,{children:[Ye(jo,{z:m,children:Ye(Jt,{size:[e,n,.01]})}),Ye(jo,{z:m+p,children:Ye(Jt,{size:[I,C,.01]})})]})]}),D=(w,H)=>Ye(jo,{offset:{x:w,y:H,z:0},children:Ye(n0,{rotation:[0,0,Math.PI/4],children:Ye(Jt,{size:[_*Math.SQRT2,_*Math.SQRT2,o*3]})})});let R=b;if(_>0){const w=e/2,H=n/2;R=wn(R_,{children:[b,D(w,H),D(-w,H),D(w,-H),D(-w,-H)]})}return Ye(or,{color:r,children:Ye(jo,{offset:t,children:Ye(jo,{offset:{x:0,y:0,z:i},children:c?wn(R_,{children:[R,Ye(jo,{offset:Q,children:Ye(n0,{rotation:u,children:Ye(dA,{radius:E,height:d})})})]}):R})})})},ivo=t=>Array.from({length:t},(e,n)=>n);function rwe(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,h=g.y-l.y,d=Math.sqrt(u*u+h*h);return{x:-h/d,y:u/d}}function a(l,g,u){const h={x:l.x+g.x*o*u,y:l.y+g.y*o*u};u>0?i.push(h):r.unshift(h)}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],h=n[l+1],d=s(g,u),_=s(u,h),m=d.x+_.x,p=d.y+_.y,f=Math.sqrt(m*m+p*p);if(f/2>2*o)a(u,d,1),a(u,_,1),a(u,d,-1),a(u,_,-1);else{const C=1/f;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 rvo=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}))},svo=rvo([{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}]),v3t=5.47,Eie=.5,avo=({x:t,y:e,z:n})=>{const o=t>0;return wn(Gi,{children:[Ye(jo,{offset:{x:t+.25/2,y:e,z:n},children:Ye(n0,{rotation:["-90deg",0,"90deg"],children:Ye(TT,{height:.25,children:Ye(RT,{points:svo.slice().reverse().map(i=>[i.x,i.y])})})})}),Ye(jo,{offset:{x:t,y:e+(o?1:-1),z:n},children:Ye(n0,{rotation:["-90deg","90deg",o?"180deg":"0deg"],children:Ye(TT,{height:2,children:Ye(RT,{points:rwe([[0,0],[-1,0],[-1,-1]],.25).map(i=>[i.x,i.y])})})})})]})},Avo=({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 wn(Gi,{children:[ivo(t).map(a=>{const A=a%i,c=(Math.floor(a/i)-.5)*2;return Ye(avo,{x:c*r/2,y:A*e-(i-1)/2*e,z:v3t/2+Eie})}),Ye(o0,{width:s,length:i*e+.5,height:v3t-Eie,heightAboveSurface:Eie,center:{x:0,y:0,z:Eie}})]})};function cvo(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 Tr=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,cvo(l,t)]),c=rwe(A,e);return Ye(or,{color:"#fff",children:Ye(jo,{offset:{z:0,y:0,x:0,...t.position},children:Ye(n0,{rotation:["90deg",0,s??0],children:Ye(jo,{offset:{x:0,y:0,z:-n/2},children:Ye(TT,{height:n,children:Ye(RT,{points:c.map(l=>[l.x,l.y])})})})})})})},lvo=({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,h=e*.5,d=h+Math.max(.22,Math.min(.4,e*.65)),_=i/2+e/2,m=d*.1,p=Math.min(Math.min(c,A)*.18,1),f=Math.min(Math.min(c,A)*.12,.45);return wn(Gi,{children:[Array.from({length:r}).map((I,C)=>Ye(Tr,{position:{x:-_,y:C*o-a,z:l/2},width:n,thickness:l,padContactLength:h,bodyDistance:d,curveLength:m,height:g})),Array.from({length:r}).map((I,C)=>Ye(Tr,{rotation:Math.PI,position:{x:_,y:C*o-a,z:l/2},width:n,thickness:l,padContactLength:h,bodyDistance:d,curveLength:m,height:g})),Ye(o0,{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:f})]})},gvo=({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 wn(Gi,{children:[Array.from({length:r}).map((A,c)=>Ye(Tr,{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)=>Ye(Tr,{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})),Ye(o0,{center:{x:0,y:0,z:a/2},width:i,length:i,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},swe=1,awe=.5,kT=.5,SU=.2,uvo=swe-SU*2,M3t=({color:t="#333"})=>wn(Gi,{children:[Ye(Jt,{size:[uvo,awe,kT],offset:[0,0,kT/2],color:t}),Ye(Jt,{size:[SU,kT,awe],offset:[swe/2-SU/2,0,kT/2],color:"#ccc"}),Ye(Jt,{size:[SU,kT,awe],offset:[-swe/2+SU/2,0,kT/2],color:"#ccc"})]}),Awe=1.6,dvo=Awe-.3*2,xie=.3,cwe=.85,FT=.6,w3t=({color:t="#333"})=>wn(Gi,{children:[Ye(Jt,{size:[dvo,cwe,FT],offset:[0,0,FT/2],color:t}),Ye(Jt,{size:[xie,cwe,FT],offset:[Awe/2-xie/2,0,FT/2],color:"#ccc"}),Ye(Jt,{size:[xie,cwe,FT],offset:[-Awe/2+xie/2,0,FT/2],color:"#ccc"})]}),lwe=2,gwe=1.25,LT=.55,bU=.5,hvo=lwe-bU*2,N3t=({color:t="#333"})=>wn(Gi,{children:[Ye(Jt,{size:[hvo,gwe,LT],offset:[0,0,LT/2],color:t}),Ye(Jt,{size:[bU,gwe,LT],offset:[lwe/2-bU/2,0,LT/2],color:"#ccc"}),Ye(Jt,{size:[bU,gwe,LT],offset:[-lwe/2+bU/2,0,LT/2],color:"#ccc"})]}),_vo=({pinCount:t,pitch:e,leadWidth:n,padContactLength:o,bodyWidth:i})=>{const r=t/4;e||(e=mvo(t,i)),o||(o=pvo(t)),n||(n=Ivo(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,h=.15,d=c,_=c*.5,m=c*.18;return wn(Gi,{children:[Array.from({length:r}).map((p,f)=>Ye(Tr,{position:{x:-g/2,y:f*e-A,z:h/2},width:n,thickness:h,padContactLength:_,bodyDistance:d,curveLength:m,height:u})),Array.from({length:r}).map((p,f)=>Ye(Tr,{rotation:Math.PI,position:{x:g/2,y:f*e-A,z:h/2},width:n,thickness:h,padContactLength:_,bodyDistance:d,curveLength:m,height:u})),Array.from({length:r}).map((p,f)=>Ye(Tr,{rotation:Math.PI/2,position:{x:f*e-A,y:-l/2,z:h/2},width:n,thickness:h,padContactLength:_,bodyDistance:d,curveLength:m,height:u})),Array.from({length:r}).map((p,f)=>Ye(Tr,{rotation:-Math.PI/2,position:{x:f*e-A,y:l/2,z:h/2},width:n,thickness:h,padContactLength:_,bodyDistance:d,curveLength:m,height:u})),Ye(o0,{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})]})},mvo=(t,e)=>{switch(t){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},pvo=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}},Ivo=(t,e)=>{switch(t){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},R3t=({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})=>wn(Gi,{children:[Ye(jo,{y:g?-3:0,children:Ye(Jt,{color:"#222",size:[s,a,r],center:[t,e,A(r/2)]})}),!c&&Ye(or,{color:"gold",children:l?Ye(Tr,{rotation:-Math.PI/2,position:{x:t,y:e+1,z:n/2},thickness:n,width:n,height:n,padContactLength:2,bodyDistance:3}):wn(dc,{children:[Ye(Jt,{color:"gold",size:[n,n,o*.9],center:[t,e,A(r*.9+r/2)]}),Ye(Jt,{color:"gold",size:[n/1.8,n/1.8,o],center:[t,e,A(r+r/2)]})]})}),Ye(or,{color:"gold",children:Ye(jo,{y:g?-3.9:0,z:g?1:0,children:Ye(n0,{rotation:g?[-Math.PI/2,0,0]:[0,0,0],children:wn(dc,{children:[Ye(Jt,{color:"gold",size:[n,n,i*.9],center:[t,e,A(-i/2*.9)]}),Ye(Jt,{color:"gold",size:[n/1.8,n/1.8,i],center:[t,e,A(-i/2)]})]})})})})]}),fvo=({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,h=-((l-1)/2)*e,d=!s&&!a?-2-1.6:0,_=m=>(o||i?-m+2:m)+d;return Ye(Gi,{children:Array.from({length:t},(m,p)=>{const f=Math.floor(p/l),I=p%l,C=h+I*e,y=((r-1)/2-f)*g;return Ye(R3t,{x:C,y,pinThickness:.63,shortSidePinLength:u,longSidePinLength:n,bodyHeight:2,flipZ:_,faceup:i,smd:s,rightangle:a},p)})})},Cvo=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),h=-a/2;switch(c){case"left":return{x:-i/2-h,y:u/2-l*s,o:"vert"};case"bottom":return{x:-g/2+l*s,y:-r/2-h,o:"horz"};case"right":return{x:i/2+h,y:-u/2+l*s,o:"vert"};case"top":return{x:g/2-l*s,y:r/2+h,o:"horz"};default:throw new Error("Invalid pin number")}},yvo=({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},Evo=({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=yvo({num_pins:t,cw:!0,ccw:!0}),l=[];for(let g=0;g<t;g++){const{x:u,y:h,o:d}=Cvo({pin_count:t,pn:g+1,w:e,h:n,p:a,pl:s});let _=r,m=s;d==="vert"&&([_,m]=[m,_]);const p=c[g+1];l.push({pn:p,x:u,y:h,pw:_,pl:m})}return wn(Gi,{children:[Ye(or,{color:"grey",children:Ye(Jt,{center:[0,0,o/2],size:[e,n,o]})}),l.map((g,u)=>Ye(Jt,{center:[g.x,g.y,A/2],size:[g.pw,g.pl,A]})),i?.length!==void 0&&i?.width!==void 0&&Ye(Jt,{center:[0,0,A/2],size:[i.width,i.length,A]})]})},xvo=Evo,Bvo=()=>{const A=1.1999999999999997;return wn(Gi,{children:[Ye(Tr,{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}),Ye(Tr,{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}),Ye(Tr,{position:{x:-2.8/2-A/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:A,height:.95}),Ye(Tr,{position:{x:-2.8/2-A/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:A,height:.95}),Ye(Tr,{position:{x:-2.8/2-A/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:A,height:.95}),Ye(o0,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},Qvo=Bvo,Svo=({fullWidth:t=2.9,fullLength:e=2.8})=>{const l=(t-1.92)/2+.3;return wn(Gi,{children:[Ye(Tr,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:l,height:.45}),Ye(Tr,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:l,height:.45}),Ye(Tr,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:l,height:.45}),Ye(o0,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},uwe=.6,dwe=.3,HT=.33,DU=.1,bvo=uwe-DU*2,T3t=({color:t="#333"})=>wn(Gi,{children:[Ye(Jt,{size:[bvo,dwe,HT],offset:[0,0,HT/2],color:t}),Ye(Jt,{size:[DU,dwe,HT],offset:[uwe/2-DU/2,0,HT/2],color:"#ccc"}),Ye(Jt,{size:[DU,dwe,HT],offset:[-uwe/2+DU/2,0,HT/2],color:"#ccc"})]}),hwe=.4,_we=.2,GT=.13,PU=.07,Dvo=hwe-PU*2,k3t=({color:t="#333"})=>wn(Gi,{children:[Ye(Jt,{size:[Dvo,_we,GT],offset:[0,0,GT/2],color:t}),Ye(Jt,{size:[PU,_we,GT],offset:[hwe/2-PU/2,0,GT/2],color:"#ccc"}),Ye(Jt,{size:[PU,_we,GT],offset:[-hwe/2+PU/2,0,GT/2],color:"#ccc"})]}),mwe=3.2,pwe=1.6,OT=.9,vU=.5,Pvo=mwe-vU*2,F3t=({color:t="#333"})=>wn(Gi,{children:[Ye(Jt,{size:[Pvo,pwe,OT],offset:[0,0,OT/2],color:t}),Ye(Jt,{size:[vU,pwe,OT],offset:[mwe/2-vU/2,0,OT/2],color:"#ccc"}),Ye(Jt,{size:[vU,pwe,OT],offset:[-mwe/2+vU/2,0,OT/2],color:"#ccc"})]}),Iwe=3.2,fwe=2.5,KT=1,MU=.6,vvo=Iwe-MU*2,L3t=({color:t="#333"})=>wn(Gi,{children:[Ye(Jt,{size:[vvo,fwe,KT],offset:[0,0,KT/2],color:t}),Ye(Jt,{size:[MU,fwe,KT],offset:[Iwe/2-MU/2,0,KT/2],color:"#ccc"}),Ye(Jt,{size:[MU,fwe,KT],offset:[-Iwe/2+MU/2,0,KT/2],color:"#ccc"})]}),Cwe=5,ywe=2.5,UT=1.4,wU=.6,Mvo=Cwe-wU*2,H3t=({color:t="#333"})=>wn(Gi,{children:[Ye(Jt,{size:[Mvo,ywe,UT],offset:[0,0,UT/2],color:t}),Ye(Jt,{size:[wU,ywe,UT],offset:[Cwe/2-wU/2,0,UT/2],color:"#ccc"}),Ye(Jt,{size:[wU,ywe,UT],offset:[-Cwe/2+wU/2,0,UT/2],color:"#ccc"})]}),Ewe=6.3,xwe=3.2,YT=1.8,NU=.8,wvo=Ewe-NU*2,G3t=({color:t="#333"})=>wn(Gi,{children:[Ye(Jt,{size:[wvo,xwe,YT],offset:[0,0,YT/2],color:t}),Ye(Jt,{size:[NU,xwe,YT],offset:[Ewe/2-NU/2,0,YT/2],color:"#ccc"}),Ye(Jt,{size:[NU,xwe,YT],offset:[-Ewe/2+NU/2,0,YT/2],color:"#ccc"})]}),O3t=({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,h=u*1.8,d=Math.min(s*.18,o*.24),_=s+.1,m=c(n+_/2),p=n+s-d,f=g*1.6;return wn(Gi,{children:[Ye(or,{color:"#1a1a1a",children:wn(R_,{children:[Ye(Jt,{color:"#000",size:[a,A,s],center:[t,e,c(n+s/2)]}),Ye(Jt,{size:[u,u,_],center:[t,e,m]}),wn(dc,{children:[Ye(Jt,{size:[u,u,.01],center:[t,e,c(p)]}),Ye(Jt,{size:[h,h,.01],center:[t,e,c(n+s)]})]})]})}),wn(or,{color:"silver",children:[wn(dc,{children:[Ye(Jt,{color:"silver",size:[g,g,i*.9],center:[t,e,c(n+-i/2*.9)]}),Ye(Jt,{color:"silver",size:[g/1.8,g/1.8,i],center:[t,e,c(n+-i/2)]})]}),Ye(Jt,{color:"silver",size:[f,f,f*.5],center:[t,e,c(n+f/2*.5)]})]})]})},Nvo=({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 Ye(Gi,{children:Array.from({length:t},(g,u)=>{const h=Math.floor(u/a),d=u%a,_=c+d*e,m=((i-1)/2-h)*A;return Ye(O3t,{x:_,y:m,pitch:e,legsLength:n,innerDiameter:o,flipZ:l},u)})})},Rvo=({width:t,length:e,innerDiameter:n=1})=>{const o=t,i=e,r=t*.7,s=n/2.5;return wn(Gi,{children:[Ye(MI,{color:"#1a1a1f",center:[0,0,r/2],size:[i,i,r],roundRadius:.3}),Ye(MI,{color:"#f2f2f2",center:[0,0,r+r*.1/2.5],size:[i,i,r*.1],roundRadius:.14}),Ye(dA,{color:"#1a1a1f",height:r*.8,radius:o/3,center:[0,0,r+r*.8/2]}),Ye(dA,{color:"#1a1a1f",height:r*.2,radius:n/2,center:[i/3,i/3,r+r*.1/2]}),Ye(dA,{color:"#1a1a1f",height:r*.2,radius:n/2,center:[-i/3,-i/3,r+r*.1/2]}),Ye(dA,{color:"#1a1a1f",height:r*.2,radius:n/2,center:[-i/3,i/3,r+r*.1/2]}),Ye(dA,{color:"#1a1a1f",height:r*.2,radius:n/2,center:[i/3,-i/3,r+r*.1/2]}),Ye(Bie,{thickness:n/3,width:s,horizontalLength:i*.8,verticalLength:r/2,position:{x:-o/2,y:-i/2,z:-r*1.2}}),Ye(Bie,{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}),Ye(Bie,{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}),Ye(Bie,{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}})]})},Bie=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=rwe(a,e);return Ye(or,{color:"#f2f2f2",children:Ye(jo,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Ye(n0,{rotation:[0,55,r],children:Ye(TT,{height:n,children:Ye(RT,{points:A.map(c=>[c.y,c.x])})})})})})},Tvo=({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 wn(Gi,{children:[Array.from({length:r}).map((h,d)=>Ye(Tr,{position:{x:-i/2-l,y:d*o-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:c})),Array.from({length:r}).map((h,d)=>Ye(Tr,{rotation:Math.PI,position:{x:i/2+l,y:d*o-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:c})),Ye(o0,{center:{x:0,y:0,z:a/2},width:u,length:g,height:A})]})},kvo=({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,h=.15,d=.8,_=4.5,m=(_-c)/2,p=m*.5;return wn(Gi,{children:[Array.from({length:g}).map((f,I)=>Ye(Tr,{position:{x:-_/2,y:u-I*a,z:h/2},width:A,thickness:h,padContactLength:p+.05,bodyDistance:m+.1,height:d})),Array.from({length:g}).map((f,I)=>Ye(Tr,{rotation:Math.PI,position:{x:_/2,y:u-I*a,z:h/2},width:A,thickness:h,padContactLength:p+.05,bodyDistance:m+.1,height:d})),Ye(o0,{center:{x:0,y:0,z:h/2},width:c,length:l,height:1})]})},Fvo=()=>wn(Gi,{children:[Ye(Jt,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),Ye(Jt,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),Ye(or,{color:"#222",children:wn(N_,{children:[Ye(jo,{z:.3/2,children:Ye(Jt,{size:[1.65,.8,.3]})}),wn(dc,{children:[Ye(jo,{z:.3,children:Ye(Jt,{size:[1.65,.8,.01]})}),Ye(jo,{z:.6,children:Ye(Jt,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),Lvo=()=>wn(Gi,{children:[Ye(Jt,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),Ye(Jt,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),Ye(or,{color:"#222",children:Ye(jo,{z:.47/2+.02,children:Ye(Jt,{size:[.98,.58,.47]})})}),Ye(Jt,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),Ye(Jt,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),Ye(Jt,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),Ye(Jt,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),Hvo=()=>{const c=Ye(or,{color:"#1a1a1a",children:wn(N_,{children:[wn(dc,{children:[Ye(jo,{z:.13,children:Ye(Jt,{size:[4,3,.03]})}),Ye(jo,{z:1.15,children:Ye(Jt,{size:[4.4,3.4,.01]})})]}),wn(dc,{children:[Ye(jo,{z:1.15,children:Ye(Jt,{size:[4.4,3.4,.01]})}),Ye(jo,{z:2.3,children:Ye(Jt,{size:[4,3,.01]})})]})]})}),l=({xDir:g})=>{const d=g*1.78,_=g*(3.4/2-.2/2+1),m=g*(3.4/2-.2/2),p=Math.abs(m-_),f=(_+m)/2;return Ye(or,{color:"#c0c0c0",children:wn(N_,{children:[Ye(Jt,{size:[2.3*.8,1.45,.2],center:[d,0,.2/2]}),Ye(Jt,{size:[.2,1.45,1.14],center:[_,0,1.14/2+.2]}),Ye(Jt,{size:[p,1.45,.2],center:[f,0,.2/2+1.14]})]})})};return wn(Gi,{children:[Ye(l,{xDir:1}),Ye(l,{xDir:-1}),c]})},Gvo=()=>{const c=Ye(or,{color:"#1a1a1a",children:wn(N_,{children:[wn(dc,{children:[Ye(jo,{z:.13,children:Ye(Jt,{size:[4,3,.03]})}),Ye(jo,{z:1.15,children:Ye(Jt,{size:[4.4,3.4,.01]})})]}),wn(dc,{children:[Ye(jo,{z:1.15,children:Ye(Jt,{size:[4.4,3.4,.01]})}),Ye(jo,{z:2.3,children:Ye(Jt,{size:[4,3,.01]})})]})]})}),l=({xDir:g})=>{const d=g*1.78,_=g*(3.4/2-.2/2+1),m=g*(3.4/2-.2/2),p=Math.abs(m-_),f=(_+m)/2;return Ye(or,{color:"#c0c0c0",children:wn(N_,{children:[Ye(Jt,{size:[2.3*.8,1.45,.2],center:[d,0,.2/2]}),Ye(Jt,{size:[.2,1.45,1.14],center:[_,0,1.14/2+.2]}),Ye(Jt,{size:[p,1.45,.2],center:[f,0,.2/2+1.14]})]})})};return wn(Gi,{children:[Ye(l,{xDir:1}),Ye(l,{xDir:-1}),c]})},Ovo=()=>{const c=Ye(or,{color:"#1a1a1a",children:wn(N_,{children:[wn(dc,{children:[Ye(jo,{z:.21000000000000002,children:Ye(Jt,{size:[6.3999999999999995,5.6,.03]})}),Ye(jo,{z:1.15,children:Ye(Jt,{size:[6.8,6,.01]})})]}),wn(dc,{children:[Ye(jo,{z:1.15,children:Ye(Jt,{size:[6.8,6,.01]})}),Ye(jo,{z:2.3,children:Ye(Jt,{size:[6.3999999999999995,5.6,.01]})})]})]})}),l=({xDir:g})=>{const d=g*3.08,_=g*(6/2-.2/2+1),m=g*(6/2-.2/2),p=Math.abs(m-_),f=(_+m)/2;return Ye(or,{color:"#c0c0c0",children:wn(N_,{children:[Ye(Jt,{size:[2.3*.8,2.95,.2],center:[d,0,.2/2]}),Ye(Jt,{size:[.2,2.95,1.14],center:[_,0,1.14/2+.2]}),Ye(Jt,{size:[p,2.95,.2],center:[f,0,.2/2+1.14]})]})})};return wn(Gi,{children:[Ye(l,{xDir:1}),Ye(l,{xDir:-1}),c]})},Kvo=()=>{const g=Ye(or,{color:"#222",children:wn(N_,{children:[Ye(jo,{z:.27,children:Ye(Jt,{size:[2.9,1.9,.54]})}),wn(dc,{children:[Ye(jo,{z:.54,children:Ye(Jt,{size:[2.9,1.9,.01]})}),Ye(jo,{z:1.08,children:Ye(Jt,{size:[2.6999999999999997,1.7,.01]})})]})]})});return wn(Gi,{children:[Ye(Jt,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),Ye(Jt,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),g]})},Uvo=()=>wn(Gi,{children:[Ye(Jt,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),Ye(Jt,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),Ye(or,{color:"#222",children:wn(N_,{children:[Ye(jo,{z:.55/2,children:Ye(Jt,{size:[2.7,1.6,.55]})}),wn(dc,{children:[Ye(jo,{z:.55,children:Ye(Jt,{size:[2.7,1.6,.01]})}),Ye(jo,{z:1.1,children:Ye(Jt,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),Yvo=()=>wn(Gi,{children:[Ye(Jt,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),Ye(Jt,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),Ye(or,{color:"#222",children:wn(N_,{children:[Ye(jo,{z:.2/2,children:Ye(Jt,{size:[2.75,1.8,.2]})}),wn(dc,{children:[Ye(jo,{z:.2,children:Ye(Jt,{size:[2.75,1.8,.01]})}),Ye(jo,{z:1,children:Ye(Jt,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),Ye(Jt,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),zvo=()=>wn(Gi,{children:[Ye(Jt,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),Ye(Jt,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),Ye(or,{color:"#222",children:wn(N_,{children:[wn(dc,{children:[Ye(jo,{z:.2,children:Ye(Jt,{size:[2.6-.1/2,1.7-.1/2,.01]})}),Ye(jo,{z:.01,children:Ye(Jt,{size:[2.6-.1,1.7-.1,.01]})})]}),wn(dc,{children:[Ye(jo,{z:.2,children:Ye(Jt,{size:[2.6,1.7,.01]})}),Ye(jo,{z:1,children:Ye(Jt,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),Ye(Jt,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),Vvo=({fullWidth:t=3.7,fullLength:e=1.55}={})=>{const n=t-1,o=e,i=1.175,r=.1,s=i-r,a=.55,A=.12,c=.35,l=(t-n)/2,g=.25,u=.2;return wn(Gi,{children:[Ye(Tr,{position:{x:-t/2,y:0,z:A/2},width:a,thickness:A,padContactLength:g,bodyDistance:l,curveLength:u,height:c}),Ye(Tr,{rotation:Math.PI,position:{x:t/2,y:0,z:A/2},width:a,thickness:A,padContactLength:g,bodyDistance:l,curveLength:u,height:c}),Ye(o0,{center:{x:0,y:0,z:0},width:n,length:o,height:s,heightAboveSurface:r,includeNotch:!1,color:"#222",taperRatio:.06,straightHeightRatio:.6}),Ye(Jt,{color:"#777",size:[.45,o-.15,.02],center:[-n/4,0,i]})]})},Jvo=()=>wn(Gi,{children:[Ye(Jt,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),Ye(Jt,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),Ye(or,{color:"#222",children:wn(N_,{children:[wn(dc,{children:[Ye(jo,{z:.2,children:Ye(Jt,{size:[3.8-.05/2,2.5-.05/2,.01]})}),Ye(jo,{z:.01,children:Ye(Jt,{size:[3.8-.05,2.5-.05,.01]})})]}),wn(dc,{children:[Ye(jo,{z:.2,children:Ye(Jt,{size:[3.8,2.5,.01]})}),Ye(jo,{z:1,children:Ye(Jt,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),Ye(Jt,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),qvo=()=>wn(Gi,{children:[Ye(Jt,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),Ye(Jt,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),Ye(or,{color:"#222",children:wn(N_,{children:[Ye(jo,{z:.14/2,children:Ye(Jt,{size:[.8,.6,.14]})}),wn(dc,{children:[Ye(jo,{z:.14,children:Ye(Jt,{size:[.8,.6,.01]})}),Ye(jo,{z:.37,children:Ye(Jt,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),Wvo=()=>{const l=3.0999999999999996;return wn(Gi,{children:[Ye(Tr,{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}),Ye(Tr,{position:{x:-6.6/2-l/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:l,height:.75}),Ye(Tr,{position:{x:-6.6/2-l/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:l,height:.75}),Ye(Tr,{position:{x:-6.6/2-l/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:l,height:.75}),Ye(o0,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},jvo=()=>wn(Gi,{children:[Array.from({length:16}).map((h,d)=>Ye(Tr,{position:{x:-10.5/2,y:d*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((h,d)=>Ye(Tr,{rotation:Math.PI,position:{x:10.5/2,y:d*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((h,d)=>Ye(Tr,{rotation:Math.PI/2,position:{x:d*.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((h,d)=>Ye(Tr,{rotation:-Math.PI/2,position:{x:d*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Ye(o0,{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})]}),Xvo=jvo,$vo=()=>{const c=.7999999999999998;return wn(Gi,{children:[Ye(Tr,{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}),Ye(Tr,{position:{x:-2.05/2-c/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:c,height:.65}),Ye(Tr,{position:{x:-2.05/2-c/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:c,height:.65}),Ye(o0,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},Zvo=({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 wn(Gi,{children:[Array.from({length:r}).map((h,d)=>Ye(Tr,{position:{x:-c/2-.36,y:d*e-a,z:g/2},width:n,thickness:g,padContactLength:o,bodyDistance:u,height:l})),Array.from({length:r}).map((h,d)=>Ye(Tr,{rotation:Math.PI,position:{x:c/2+.36,y:d*e-a,z:g/2},width:n,thickness:g,padContactLength:o,bodyDistance:u,height:l})),Array.from({length:r}).map((h,d)=>Ye(Tr,{rotation:Math.PI/2,position:{x:d*e-a,y:-A/2-.36,z:g/2},width:n,thickness:g,padContactLength:o,bodyDistance:u,height:l})),Array.from({length:r}).map((h,d)=>Ye(Tr,{rotation:-Math.PI/2,position:{x:d*e-a,y:A/2+.36,z:g/2},width:n,thickness:g,padContactLength:o,bodyDistance:u,height:l})),Ye(o0,{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})]})},eMo=()=>{const o=.20900000000000002,i=.1,r=.3,s=.1,a=.2;return wn(Gi,{children:[Ye(or,{color:"#222",children:wn(N_,{children:[Ye(Jt,{size:[.85,1.2,o],center:[0,0,o/2]}),wn(dc,{children:[Ye(jo,{z:o,children:Ye(Jt,{size:[.85,1.2,.01]})}),Ye(jo,{z:.38,children:Ye(Jt,{size:[.85-i,1.2-i,.01]})})]})]})}),Ye(Jt,{color:"#ccc",size:[r,.25,s],center:[.55,0,s/2]}),Ye(Jt,{color:"#ccc",size:[r,a,s],center:[-.55,.4,s/2]}),Ye(Jt,{color:"#ccc",size:[r,a,s],center:[-.55,-.4,s/2]})]})},tMo=({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 h=u<l?"left":"right",d=u%l,_=g/2-d*a,m=s,p=r,f=h==="left"?-e/2+m/2:e/2-m/2,I=u+1;c.push({pinNumber:I,x:f,y:_,padSizeX:m,padSizeY:p})}return wn(Gi,{children:[Ye(o0,{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,h)=>Ye(Jt,{center:[u.x,u.y,A/2],size:[u.padSizeX,u.padSizeY,A]})),i?.length!==void 0&&i?.width!==void 0&&Ye(Jt,{center:[0,0,A/2],size:[i.width,i.length,A]})]})},nMo=({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 wn(Gi,{children:[wn(or,{color:s,children:[wn(dc,{children:[Ye(By,{height:n,roundRadius:.5,radius:c,center:[-l,0,n]}),Ye(By,{height:n,roundRadius:.5,radius:c,center:[l,0,n]})]}),wn(dc,{children:[Ye(By,{height:u,roundRadius:.1,radius:c+.85,center:[-l,0,n/2+u/2]}),Ye(By,{height:u,roundRadius:.1,radius:c+.85,center:[l,0,n/2+u/2]})]})]}),wn(or,{color:a,children:[Ye(dA,{height:r+n/2,radius:i/2,center:[-g+.06,0,-(r/2)+n/2]}),Ye(dA,{height:r+n/2,radius:i/2,center:[g-.06,0,-(r/2)+n/2]})]})]})},oMo=({bodyLength:t=1.4,bodyDiameter:e=1.1,color:n="#3a3a3aff",contactColor:o="#c6c6c6",cathodeIdentification:i="#111"})=>wn(Gi,{children:[Ye(or,{color:n,children:wn(n0,{rotation:[0,"90deg",0],children:[Ye(MI,{size:[e,e,t-.2],roundRadius:.2,center:[-e/2,0,.05]}),Ye(dA,{height:.2/2,radius:e/2-.2,center:[-e/2,0,-t/2+.2/2]})]})}),Ye(or,{color:i,children:Ye(n0,{rotation:[0,"90deg",0],children:Ye(MI,{size:[e*1.01,e*1.01,t/3],roundRadius:.2,center:[-e/2,0,-t/4+.1]})})}),Ye(or,{color:o,children:Ye(n0,{rotation:[0,"90deg",0],children:Ye(By,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,-t/2]})})}),Ye(or,{color:o,children:Ye(n0,{rotation:[0,"90deg",0],children:Ye(By,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,t/2]})})})]}),iMo=({bodyLength:t=3.5,bodyDiameter:e=1.5,color:n="#3a3a3aff",contactColor:o="#c6c6c6"})=>wn(Gi,{children:[Ye(or,{color:n,children:Ye(n0,{rotation:[0,"90deg",0],children:Ye(By,{height:t,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),Ye(or,{color:o,children:Ye(n0,{rotation:[0,"90deg",0],children:Ye(By,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,-t/2]})})}),Ye(or,{color:o,children:Ye(n0,{rotation:[0,"90deg",0],children:Ye(By,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,t/2]})})})]}),rMo=({bodyLength:t=3.9,bodyDiameter:e=2.5,color:n="#3a3a3aff",contactColor:o="#c6c6c6"})=>wn(Gi,{children:[Ye(or,{color:n,children:Ye(n0,{rotation:[0,"90deg",0],children:Ye(By,{height:t,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),Ye(or,{color:o,children:Ye(n0,{rotation:[0,"90deg",0],children:Ye(By,{height:.55,radius:e/2,roundRadius:.2,center:[-e/2,0,-t/2]})})}),Ye(or,{color:o,children:Ye(n0,{rotation:[0,"90deg",0],children:Ye(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 wn(Gi,{children:[Array.from({length:i}).map((c,l)=>Ye(Tr,{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)=>Ye(Tr,{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})),Ye(o0,{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})]})},aMo=({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 wn(Gi,{children:[Array.from({length:i}).map((c,l)=>Ye(Tr,{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)=>Ye(Tr,{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})),Ye(o0,{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})]})},AMo=()=>{const _=7.050000000000001,m=24.95+6.5/2;return Ye(jo,{center:[0,0,1],children:wn(Gi,{children:[wn(n0,{rotation:[0,55,-55],children:[wn(R_,{children:[Ye(Jt,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[m,0,1.3-2]}),Ye(dA,{color:"black",center:[m,0,1.3-2],radius:3/2,height:1.3*1.2})]}),Ye(or,{color:"#222",children:Ye(o0,{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})})]}),Ye(n0,{rotation:[0,55,55],children:Array.from({length:3}).map((p,f)=>{const I=_,C=(f-1)*2.7,y=-.5-.6;return wn(or,{color:"gold",children:[wn(dc,{children:[Ye(jo,{center:[15.05-4.5/2+.1,C,y],children:Ye(Jt,{size:[4.5,.81+1,.5]})}),Ye(jo,{center:[15.05-4.5/2-1+.1,C,y],children:Ye(Jt,{size:[4.5,.81,.5]})})]}),Ye(jo,{center:[I,C,y],children:Ye(Jt,{size:[16+.1,.81,.5]})})]},`prong-${f}`)})})]})})},cMo=()=>{const c=1.1999999999999997;return wn(Gi,{children:[Ye(Tr,{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}),Ye(Tr,{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}),Ye(Tr,{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}),Ye(Tr,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ye(Tr,{position:{x:-2.8/2-c/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ye(Tr,{position:{x:-2.8/2-c/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ye(o0,{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})]})},lMo=()=>wn(Gi,{children:[Ye(o0,{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 Ye(Jt,{center:[-.8/2+.19/2-.1,l,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(c=>{const l=-.35+c*.35;return Ye(Jt,{center:[.8/2-.19/2+.1,l,.12/2],size:[.19,.15,.12]})})]}),gMo=()=>{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],h=[0,1.28,-8.9],d=-7.5;return wn(jo,{center:[0,1,10.5],children:[Ye(or,{color:s,children:wn(R_,{children:[Ye(jo,{center:[0,0,2.25],children:Ye(dA,{radius:2.4,height:4.5})}),Ye(jo,{center:[0,-1.8499999999999999,2.25],children:Ye(Jt,{size:[2.4*2,1.1,4.5+.2]})})]})}),Ye(jo,{center:l,children:Ye(Jt,{size:A})}),wn(dc,{children:[Ye(jo,{center:g,children:Ye(Jt,{size:c})}),Ye(jo,{center:u,children:Ye(Jt,{size:c})})]}),Ye(jo,{center:h,children:Ye(Jt,{size:[.43,.4,12.2]})}),Ye(jo,{center:[1.3,0,d],children:Ye(Jt,{size:[.43,.4,15]})}),Ye(jo,{center:[-1.3,0,d],children:Ye(Jt,{size:[.43,.4,15]})})]})},uMo=()=>wn(Gi,{children:[Ye(Tr,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ye(Tr,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ye(Tr,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ye(Tr,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ye(Tr,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ye(Tr,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ye(o0,{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})]}),dMo=uMo,hMo=()=>wn(Gi,{children:[Ye(o0,{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 Ye(Jt,{center:[-1/2+.3/2,A,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(a=>{const A=-.5+a*.5;return Ye(Jt,{center:[1/2-.3/2,A,.05/2],size:[.3,.2,.05]})})]}),_Mo=()=>wn(Gi,{children:[Ye(Tr,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ye(Tr,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ye(or,{color:"#222",children:Ye(o0,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),Ye(Jt,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),mMo=()=>wn(Gi,{children:[Ye(Jt,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),Ye(Jt,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),Ye(or,{color:"#222",children:wn(N_,{children:[Ye(jo,{z:.175/2,children:Ye(Jt,{size:[1.7,1.25,.175]})}),wn(dc,{children:[Ye(jo,{z:.175,children:Ye(Jt,{size:[1.7,1.25,.01]})}),Ye(jo,{z:.725,children:Ye(Jt,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),Ye(Jt,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),pMo=()=>{const s=-1.0474999999999999,a=1.775/2+.4/2-.04;return wn(Gi,{children:[Ye(Jt,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),Ye(Jt,{color:"#ccc",size:[.4,.325,.13],center:[a,0,.13/2]}),Ye(or,{color:"#222",children:Ye(o0,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),Ye(Jt,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},IMo=({pitch:t=10})=>wn(Gi,{children:[Ye(dA,{height:4,radius:.5,center:[-t/2,0,.5]}),Ye(yie,{radius:.5,center:[-t/2,0,2.5]}),Ye(jo,{x:-2.5,y:0,z:2.5,children:wn(n0,{rotation:[0,Math.PI/2,0],children:[Ye(dA,{height:t,radius:.5,center:[0,0,2.5]}),Ye(or,{color:"#d2b48c",children:Ye(dA,{height:5,radius:1.3,center:[0,0,2.5]})})]})}),Ye(dA,{height:4,radius:.5,center:[t/2,0,.5]}),Ye(yie,{radius:.5,center:[t/2,0,2.5]})]}),fMo=({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,h=e/2,d=e*1.05,_=g/2,m=Math.max(r||0,s||0,a||0,A||0)*i||51,p=[],f=[];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&&f.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&&f.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&&f.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&&f.push({x:-Q,y:-m/2},{x:-Q,y:-m/2+l})}}const I=Ye(or,{color:"#051a0a",children:wn(R_,{children:[Ye(Jt,{center:[0,0,h],size:[t,m,e]}),p.map((E,B)=>Ye(Jt,{center:[E.x,E.y,h],size:[E.pl+.01,E.pw+.01,d]},B))]})}),C=c&&f.map((E,B)=>Ye(dA,{color:"black",center:[E.x,E.y,h],radius:_,height:e*1.07})),y=p.map((E,B)=>Ye(Jt,{center:[E.x,E.y,h],size:[E.pl+.01,E.pw+.01,d]}));return wn(Gi,{children:[I,Ye(or,{color:"#FFD700",children:c?wn(R_,{children:[Ye(N_,{children:p.map((E,B)=>Ye(Jt,{center:[E.x,E.y,h],size:[E.pl+.01,E.pw+.01,d]},B))}),C]}):y})]})},CMo=({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),h=Math.max(Math.min(i,u),.2),d=Math.max(u-h,0),_=Math.max(o,0),m=Math.max(a??l-_*2,2),p=Math.max(A??g-_*2,2),f=Math.min(Math.max(h*.6,.2),h),I=c?.x??0,C=c?.y??0,y=c?.z??0;return wn(jo,{offset:{x:I,y:C,z:y},children:[d>0&&Ye(or,{color:s,children:Ye(Jt,{size:[l,g,d],offset:[0,0,d/2]})}),Ye(or,{color:s,children:wn(R_,{children:[Ye(Jt,{size:[l,g,h],offset:[0,0,d+h/2]}),Ye(Jt,{size:[m,p,h+.02],offset:[0,0,d+h/2]})]})}),Ye(or,{color:r,children:Ye(Jt,{size:[m,p,f],offset:[0,0,d+f/2]})})]})},yMo=({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:h,screen:d,screenWidth:_,screenHeight:m,screenCenterOffsetX:p,screenCenterOffsetY:f})=>{const I=d??!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,O=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,O=A==="left"?n:-n,U=0):(R=-((y-1)/2)*n,w=A==="top"?b/2-g:-b/2+g,H=n,G=0,O=0,U=A==="top"?-n:n);let W=0;for(let he=0;he<e&&W<t;he++)for(let ye=0;ye<y&&W<t;ye++){const me=R+ye*H+he*O,Pe=w+ye*G+he*U;D.push({x:me,y:Pe}),W++}const j=[];if(c)for(const he of c){let ye=0,me=0;he==="topleft"?(ye=-Q/2+l,me=b/2-l):he==="topright"?(ye=Q/2-l,me=b/2-l):he==="bottomleft"?(ye=-Q/2+l,me=-b/2+l):he==="bottomright"?(ye=Q/2-l,me=-b/2+l):he==="center"&&(ye=0,me=0),j.push({x:ye,y:me})}const te=.63,re=2,X=6,ne=3,se=h||u?0:re,Ae=se+r,ue=Ye(or,{color:"#008080",children:wn(R_,{children:[Ye(Jt,{center:[0,0,C+se],size:[Q,b,r]}),j.map((he,ye)=>Ye(dA,{center:[he.x,he.y,C+se],radius:i/2,height:r},`hole-${ye}`)),D.map((he,ye)=>Ye(dA,{center:[he.x,he.y,C+se],radius:i/2,height:r},`pin-hole-${ye}`))]})}),Ce=D.map((he,ye)=>Ye(or,{color:"#FFD700",children:wn(R_,{children:[Ye(dA,{center:[he.x,he.y,r/2+se],radius:i/2,height:r}),Ye(dA,{center:[he.x,he.y,r/2+se],radius:o/2,height:r})]})})),Ee=D.map((he,ye)=>Ye(R3t,{x:he.x,y:he.y,pinThickness:te,shortSidePinLength:ne,longSidePinLength:X,bodyHeight:re,flipZ:me=>me})),Be=D.map((he,ye)=>Ye(O3t,{x:he.x,y:he.y,flipZ:me=>-me}));return wn(Gi,{children:[ue,Ce,!u&&!h&&Ee,u&&Be,I&&Ye(CMo,{width:_??Q*.8,height:m??b*.6,offset:{x:p??0,y:f??0,z:Ae}})]})},EMo=()=>{const s=.8999999999999999,a=-s/2+.5/2-.15,A=s/2-.5/2+.15,c=.2,l=.5*.24;return wn(Gi,{children:[Ye(Jt,{color:"#ccc",size:[.5,.28,.12],center:[a,0,.12/2]}),Ye(Jt,{color:"#ccc",size:[.5,.28,.12],center:[A,0,.12/2]}),Ye(or,{color:"#222",children:wn(N_,{children:[Ye(jo,{z:l/2,children:Ye(Jt,{size:[s,.6,l]})}),wn(dc,{children:[Ye(jo,{z:l,children:Ye(Jt,{size:[s,.6,.01]})}),Ye(jo,{z:.5,children:Ye(Jt,{size:[s-c,.6-c,.01]})})]})]})}),Ye(Jt,{color:"#777",size:[1.4/6,.6-c,.02],center:[-s/4,0,.5]})]})},xMo=EMo,BMo=({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 wn(Gi,{children:[Ye(jo,{offset:[0,0,6],children:Ye(n0,{angles:[Math.PI,0,0],children:Ye(or,{color:o,children:wn(R_,{children:[Ye(Jt,{size:[g,3.5,6],center:[0,0,6/2]}),Ye(Jt,{size:[g-.5*2,3.5-.5*2,c],center:[0,0,c/2]}),Ye(Jt,{size:[g,3.5/3,c],center:[0,0,c/6]}),Ye(Jt,{size:[g-.5*2,.5/2,c],center:[0,3.5/2-.5/4,c/2]}),Ye(Jt,{size:[g-.5*2,.5/2,c],center:[0,-3.5/2+.5/4,c/2]}),Ye(Jt,{size:[1,.5+2,1],center:[-g/4,3.5/2,6/2]}),Ye(Jt,{size:[1,.5+3,1],center:[g/4,3.5/2,6/2]}),Ye(Jt,{size:[1,.5+2,1],center:[-g/4,-3.5/2,6/2]}),Ye(Jt,{size:[1,.5+3,1],center:[g/4,-3.5/2,6/2]})]})})})}),e&&Array.from({length:t}).map((h,d)=>Ye(or,{color:i,children:Ye(dA,{height:l,radius:.35,center:[u+d*1.5,0,2.5]})})),n&&Array.from({length:t}).map((h,d)=>{const _=d===0,m=_?{type:"pcb_plated_hole",pcb_plated_hole_id:`jstzh_${d}`,shape:"circular_hole_with_rect_pad",x:u+d*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:[`${d+1}`]}:{type:"pcb_plated_hole",pcb_plated_hole_id:`jstzh_${d}`,shape:"pill",x:u+d*1.5,y:0,hole_height:.73,hole_width:.73,outer_height:1.73,outer_width:1.03,layers:["top","bottom"],port_hints:[`${d+1}`]};return Ye(ovo,{hole:m,isPin1:_})})]})},QMo=([t,e],n,o,i,r)=>{const s=Math.sign(t),a=Math.sign(e),A=n/2,c=o/2,l=r?Math.min(.32,o*.36):0,g=Math.min(i,A,c),u=[[-A,-c],[A,-c],[A,c-g],[A-g,c],[-A,c]];l&&(u[0]=[-A+l,-c],u.push([-A,-c+l]));const h=u.map(([d,_])=>[t+d*s,e+_*a]);return s*a<0?h.reverse():h},Bwe=({width:t,length:e,radius:n,height:o,z:i})=>{const r=t/2-n,s=e/2-n;return[[-r,-s],[r,-s],[r,s],[-r,s]].map(([a,A],c)=>Ye(dA,{center:[a,A,i+o/2],height:o,radius:n}))},SMo=({horizontalPadPitch:t=2.2,verticalPadPitch:e=1.7,padWidth:n=1.4,padHeight:o=1.2,bodyHeight:i=.7})=>{const r=t+n*.7142857142857143,s=e+o*(2/3),a=Math.min(.01,i*.02),A=n*(5/7),c=o*.75,l=i*(5/7),g=l-a,u=i*(2/35),h=r*.95,d=s*.94,_=r*.905,m=s*.9,p=r*.83,f=s*.82,I=l+u,C=Math.min(.01,i*.015),y=Math.min(.12,s*.05),E=(r-A)/2,B=(s-c)/2,Q=[[-E,-B],[E,-B],[E,B],[-E,B]],b=Bwe({width:h,length:d,radius:Math.min(.13,d*.08),height:u,z:l}),D=[...Bwe({width:_,length:m,radius:Math.min(.14,m*.08),height:C,z:I}),...Bwe({width:p,length:f,radius:Math.min(.15,f*.09),height:C,z:i-C})];return wn(Gi,{children:[Q.map((R,w)=>Ye(or,{color:"#d6a258",children:Ye(TT,{height:a,children:Ye(RT,{points:QMo(R,A,c,y,w===0)})})})),Ye(o0,{center:{x:0,y:0,z:a},width:r,length:s,height:g-.005,heightAboveSurface:0,color:"#34343d",taperRatio:0,straightHeightRatio:1,includeNotch:!1,chamferSize:y}),Ye(or,{color:"#d2a057",children:Ye(dc,{children:b})}),Ye(or,{color:"#b9bec2",children:Ye(dc,{children:D})})]})},bMo="#303339",Qie="#1f2227",K3t="#eee8d8",U3t="#f8f3e7",Qwe="#b7bdc2",DMo="#d2d6d9",PMo="#767d82",vMo="#9ba1a5",MMo=({pinCount:t=12,pitch:e=.5,padWidth:n=.3,padLength:o=1.25,staggered:i=!1,reverse:r=!1,rowPitch:s=2.4,topPadLength:a=o,bottomPadLength:A=o,mountPadPitchX:c,mountPadOffsetY:l=2.575,mountTop:g=!1,mountPadWidth:u=2,mountPadLength:h=2.5})=>{const d=Math.max((t-1)*e,e),_=-d/2,m=c??d+(i?3.5:3.38),p=l===0?0:(g?1:-1)*l,f=Array.from({length:t},(Me,qe)=>{const $e=i&&qe%2===1!==r,at=i?$e?s/2:-s/2:0,lt=$e?a:A;return{index:qe,x:_+qe*e,y:at,length:lt}}),I=Math.max(...f.map(Me=>Me.y+Me.length/2)),C=Math.min(...f.map(Me=>Me.y-Me.length/2)),y=p-h/2,E=p+h/2,B=g?C:I,Q=g?Math.max(E,I)+.67:Math.min(y,C)-.67,b=g?-1:1,D=B-b*Math.max(o*.86,1.05),R=Q+b*.22,w=Math.abs(D-R),H=(D+R)/2,G=R-b*.01,O=Math.max(d+4.9,m+u*.76),U=Math.min(O-2.3,d+1.1),W=.3,j=1.42,te=2,re=Math.min(.92,w*.28),X=G+b*(re/2-.04),ne=1.6,se=1.1,Ae=Math.max(w-.78,1.5),ue=G+b*(Ae/2+.68),Ce=O-.72,Ee=.34,Be=te-Ee/2,he=G+b*Math.min(.68,w*.22),ye=1.48,me=Math.max(n*.82,.15),Pe=B,Te=Math.abs(Pe-D),Je=(Pe+D)/2,Ie=Math.max(re*.8,.5),We=G+b*(Ie/2+.08),we=m/2,ke=.75,ze=O/2-.04,Ne=O/2-.23,be=O/2-.32,Oe=.68;return wn(Gi,{children:[[-1,1].map(Me=>Ye(Jt,{color:Qwe,center:[Me*we,p,.07],size:[u,h,.14]})),f.map(Me=>Ye(Jt,{color:Qwe,center:[Me.x,Je,.065],size:[me,Te,.13]},`terminal:${Me.index}`)),Ye(MI,{color:Qie,center:[0,H,W/2],size:[O,w,W],roundRadius:.1}),Ye(or,{color:bMo,children:wn(R_,{children:[Ye(MI,{center:[0,H,W+j/2],size:[O-.2,w-.12,j],roundRadius:.14}),Ye(Jt,{center:[0,X,se],size:[U,re,ne]}),Ye(Jt,{center:[0,ue,te-Ee*.72],size:[Ce-.32,Ae-.16,Ee]})]})}),f.map(Me=>Ye(MI,{color:DMo,center:[Me.x,We,W+.82],size:[me*.82,Ie,.14],roundRadius:.035},`spring:${Me.index}`)),f.map(Me=>Ye(Jt,{color:Qwe,center:[Me.x,D-b*.03,W+.32],size:[me,.13,.62]},`terminal-rise:${Me.index}`)),Ye(Jt,{color:Qie,center:[0,G+b*.1,W+.71],size:[U+.18,.16,.8]}),Ye(MI,{color:K3t,center:[0,ue,Be],size:[Ce,Ae,Ee],roundRadius:.11}),Ye(Jt,{color:U3t,center:[0,ue-b*(Ae/2-.12),te-.035],size:[Ce-.36,.24,.07]}),[-1,1].map(Me=>Ye(MI,{color:K3t,center:[Me*be,he,ye],size:[Oe,.92,.72],roundRadius:.1})),[-1,1].map(Me=>Ye(jo,{x:Me*be,y:he,z:ye,children:Ye(n0,{rotation:[0,Math.PI/2,0],children:Ye(dA,{color:U3t,height:Oe+.12,radius:.24})})})),[-1,1].map(Me=>Ye(MI,{color:PMo,center:[Me*ze,p,ke/2],size:[.17,Math.min(h*.3,.7),ke],roundRadius:.04})),[-1,1].map(Me=>Ye(MI,{color:vMo,center:[Me*Ne,p,ke-.05],size:[.42,Math.min(h*.3,.7),.1],roundRadius:.035})),Ye(Jt,{color:Qie,center:[0,H,.025],size:[U+.7,w*.58,.05]}),Ye(Jt,{color:Qie,center:[0,D-b*.06,W+.82],size:[U+.4,.15,.92]})]})},wMo=({numberOfPins:t,pitch:e=2.54,pinThickness:n=.64,bodyWidth:o=2.5,bodyHeight:i=2.54,standoffHeight:r=1.27,matingPinLength:s=5.8,tailSpan:a=5.08})=>{const A=-((t-1)*e)/2,c=r+i,l=a/2,g=n*.35;return Ye(Gi,{children:Array.from({length:t},(u,h)=>{const d=A+h*e,_=h%2===0?1:-1,m=s-g,p=r-n/2;return wn(jo,{x:d,children:[Ye(Jt,{color:"#222",size:[e,o,i],center:[0,0,r+i/2]}),wn(or,{color:"#d4af37",children:[Ye(Jt,{size:[n,l,n],center:[0,_*(l/2),n/2]}),Ye(Jt,{size:[n,n,p],center:[0,0,n/2+p/2]}),Ye(Jt,{size:[n,n,m],center:[0,0,c+m/2]}),wn(dc,{children:[Ye(Jt,{size:[n,n,.01],center:[0,0,c+m]}),Ye(Jt,{size:[n*.65,n*.65,.01],center:[0,0,c+s]})]})]})]})})})},NMo=({padPitch:t,padHeight:e,color:n="#333"})=>{const o=t,i=e*.85,r=i,s=o*.2,a=o-s*2;return wn(Gi,{children:[Ye(Jt,{size:[a,i,r],offset:[0,0,r/2],color:n}),Ye(Jt,{size:[s,r,i],offset:[o/2-s/2,0,r/2],color:"#ccc"}),Ye(Jt,{size:[s,r,i],offset:[-o/2+s/2,0,r/2],color:"#ccc"})]})},RMo=({color:t="#ffff00",bodyColor:e="#ffffff",leadColor:n="#dedede"})=>{const m=[-1.7,0,1.7],p=[-1,1];return wn(Gi,{children:[m.flatMap(f=>p.map(I=>Ye(Jt,{color:n,size:[1.4,1,.2],center:[I*2,f,.2/2]}))),Ye(or,{color:e,children:wn(R_,{children:[Ye(o0,{width:5,length:5,height:1.3,heightAboveSurface:.2,center:{x:0,y:0,z:0},color:e,taperRatio:.036,straightHeightRatio:.01,includeNotch:!1}),Ye(dA,{radius:2,height:.25,center:[0,0,1.5-.25/2]}),Ye(jo,{offset:[-5/2,5/2,1.5-.3/2+.005],children:Ye(n0,{rotation:[0,0,Math.PI/4],children:Ye(Jt,{size:[.9,.9,.3+.01]})})})]})}),Ye(dA,{color:t,radius:2,height:.25,center:[0,0,1.55-.25/2]})]})},Y3t=t=>Array.from({length:t},(e,n)=>n),TMo=({bodyWidth:t=16.26,bodyDepth:e=15.88,bodyHeight:n=13.5,bodyCenterY:o=-.96,ledPins:i=!1,firstPinLeft:r=!1,firstPinTop:s=!1,signalPitch:a=1.02,signalRowPitch:A=1.78,signalHoleDiameter:c=.9144,shieldPinX:l=8.13,shieldPinY:g=.13,shieldHoleDiameter:u=1.8,locatorHoleX:h=6.35,locatorHoleY:d=-3.43,locatorHoleDiameter:_=3.25,ledPinX:m=4.57,ledPinPitch:p=2.29,ledPinY:f=5.7,openingDirection:I,shellColor:C="#b7bdc2",housingColor:y="#20242a",contactColor:E="#d6a928"})=>{const B=I??(o>0?1:-1),Q=o+B*e/2,b=Math.min(.38,t*.024),D=Math.max(t-2.5,t*.72),R=Math.min(n-2.4,9.6),w=1.3+R/2,H=Math.min(4.4,e*.34),G=Q-B*H/2,O=Q-B*(H+b*.7),U=Math.max(.22,Math.min(c*.36,.38)),W=Y3t(8).map(se=>{const Ae=(3.5-se)*a,ue=se%2===0?-A/2:A/2;return{x:r?-Ae:Ae,y:s?-ue:ue}}),j=[-m-p,-m,m,m+p],te=D/10,re=Q-B*Math.max(H*.48,1.2),X=w+R*.18,ne=Q+B*b*.2;return wn(Gi,{children:[wn(or,{color:C,children:[wn(R_,{children:[Ye(Jt,{center:[0,o,n/2],size:[t,e,n]}),Ye(Jt,{center:[0,G,w],size:[D,H+b*2,R]})]}),Ye(Jt,{center:[0,ne,.72],size:[D+.5,b*1.25,1.05]}),[-1,1].map(se=>Ye(Jt,{center:[se*l,g,.25],size:[Math.max(u*.46,.65),Math.max(u*.72,1.1),3.4]})),[-1,1].map(se=>Ye(Jt,{center:[se*t*.24,o-B*e*.08,n+.04],size:[t*.22,e*.42,.1]}))]}),wn(or,{color:y,children:[wn(R_,{children:[Ye(MI,{center:[0,G,w],size:[D-.2,H+b*.5,R-.2],roundRadius:.22}),Ye(Jt,{center:[0,G-B*b*.2,w-.05],size:[D-1.25,H+b,R-1.35]})]}),Ye(Jt,{center:[0,O,w],size:[D-1.15,b,R-1.25]}),Ye(MI,{center:[0,Q-B*H*.28,1.55],size:[D-2.6,H*.5,1.15],roundRadius:.16}),[-1,1].map(se=>Ye(dA,{center:[se*h,d,-.25],radius:Math.max(_*.41,.65),height:2.7}))]}),wn(or,{color:E,children:[W.map(({x:se,y:Ae},ue)=>Ye(dA,{center:[se,Ae,.15],radius:U,height:3.1})),Y3t(8).map(se=>Ye(jo,{offset:[(se-3.5)*te,re,X+(se%2===0?.03:-.03)],children:Ye(n0,{rotation:[B*.2,0,0],children:Ye(MI,{size:[Math.max(te*.28,.28),3.25,.16],roundRadius:.05})})})),i&&j.map((se,Ae)=>Ye(dA,{center:[se,f,.15],radius:U,height:3.1}))]}),i&&wn(Gi,{children:[Ye(MI,{color:"#73b744",center:[-t/2+2.05,Q+B*b*.35,n-2.05],size:[2.15,b*1.55,1.45],roundRadius:.18}),Ye(MI,{color:"#e0aa35",center:[t/2-2.05,Q+B*b*.35,n-2.05],size:[2.15,b*1.55,1.45],roundRadius:.18})]})]})},kMo=({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=nvo.string(e).json(),o=t.match(/_color\(([^)]+)\)/),i=o?o[1]:void 0;switch(n.fn){case"crystal":return Ye(SMo,{horizontalPadPitch:n.px,verticalPadPitch:n.py,padWidth:n.pw,padHeight:n.ph});case"dip":return Ye(Avo,{numPins:n.num_pins,pitch:n.p,bodyWidth:n.w});case"axial":return Ye(IMo,{pitch:n.p});case"tssop":return Ye(lvo,{pinCount:n.num_pins,leadLength:n.pl,leadWidth:n.pw,pitch:n.p,bodyWidth:n.w});case"msop":return Ye(gvo,{pinCount:n.num_pins,padContactLength:n.pl,leadWidth:n.pw,pitch:n.p,bodyWidth:n.w});case"vssop":return Ye(kvo,{pinCount:n.num_pins,leadLength:n.pl,leadWidth:n.pw,pitch:n.p,bodyWidth:n.w,bodyLength:n.h});case"qfp":return Ye(_vo,{pinCount:n.num_pins,pitch:n.p,leadWidth:n.pw,padContactLength:n.pl,bodyWidth:n.w});case"tqfp":return Ye(Xvo,{});case"lqfp":return Ye(Zvo,{pinCount:n.num_pins});case"qfn":{const r=typeof n.thermalpad?.x=="number"&&typeof n.thermalpad?.y=="number";return Ye(xvo,{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 Ye(tMo,{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 Ye(fvo,{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 Ye(Nvo,{numberOfPins:n.num_pins,pitch:n.p,rows:s})}case"smdpinheader":return Ye(wMo,{numberOfPins:n.num_pins,pitch:n.p,bodyWidth:n.bh});case"led5050":return Ye(RMo,{color:i});case"cap":{switch(n.imperial){case"0402":return Ye(M3t,{color:"#856c4d"});case"0603":return Ye(w3t,{color:"#856c4d"});case"0805":return Ye(N3t,{color:"#856c4d"});case"0201":return Ye(T3t,{color:"#856c4d"});case"01005":return Ye(k3t,{color:"#856c4d"});case"1206":return Ye(F3t,{color:"#856c4d"});case"1210":return Ye(L3t,{color:"#856c4d"});case"2010":return Ye(H3t,{color:"#856c4d"});case"2512":return Ye(G3t,{color:"#856c4d"})}break}case"sot235":return Ye(Qvo,{});case"sot457":return Ye(cMo,{});case"sot223":return Ye(Wvo,{});case"sot23w":return Ye(Svo,{});case"sot323":return Ye($vo,{});case"sod323f":return Ye(mMo,{});case"sod323fl":return Ye(pMo,{});case"sot363":return Ye(dMo,{});case"sot886":return Ye(hMo,{});case"sot963":return Ye(lMo,{});case"pushbutton":return Ye(Rvo,{width:n.w,length:n.h,innerDiameter:n.id});case"jst":if(n.zh)return Ye(BMo,{numPins:n.num_pins});break;case"fpc":return Ye(MMo,{pinCount:n.num_pins,pitch:n.p,padWidth:n.pw,padLength:n.pl,staggered:n.staggered,reverse:n.reverse,rowPitch:n.py,topPadLength:n.toppl,bottomPadLength:n.bottompl,mountPadPitchX:n.mpx,mountPadOffsetY:n.mpy,mountTop:n.mounttop,mountPadWidth:n.mpw,mountPadLength:n.mpl});case"rj45":return Ye(TMo,{bodyWidth:n.w,bodyDepth:n.h,bodyCenterY:n.bodyy,ledPins:n.ledpins||n.num_pins===14,firstPinLeft:n.firstpinleft,firstPinTop:n.firstpintop,signalPitch:n.p,signalRowPitch:n.py,signalHoleDiameter:n.id,shieldPinX:n.shieldx,shieldPinY:n.shieldy,shieldHoleDiameter:n.shieldid,locatorHoleX:n.holex,locatorHoleY:n.holey,locatorHoleDiameter:n.holed,ledPinX:n.ledx,ledPinPitch:n.ledp,ledPinY:n.ledy});case"soic":return Ye(Tvo,{pinCount:n.num_pins,leadLength:n.pl,leadWidth:n.pw,pitch:n.p,bodyWidth:n.w});case"sod523":return Ye(Fvo,{});case"sod723":return Ye(xMo,{});case"sod882":return Ye(Lvo,{});case"sma":return Ye(Hvo,{});case"smb":return Ye(Gvo,{});case"smc":return Ye(Ovo,{});case"smf":return Ye(Kvo,{});case"sod123":return Ye(Vvo,{});case"sod123f":return Ye(Uvo,{});case"sod123fl":return Ye(Yvo,{});case"sod123w":return Ye(zvo,{});case"sod128":return Ye(Jvo,{});case"sod323":return Ye(_Mo,{});case"sod923":return Ye(qvo,{});case"hc49":return Ye(nMo,{});case"micromelf":return Ye(oMo,{});case"minimelf":return Ye(iMo,{});case"melf":return Ye(rMo,{});case"ms012":return Ye(sMo,{pinCount:n.num_pins,padContactLength:n.pl,leadWidth:n.pw,pitch:n.p});case"ms013":return Ye(aMo,{pinCount:n.num_pins,padContactLength:n.pl,leadWidth:n.pw,pitch:n.p});case"sot723":return Ye(eMo,{});case"to220":return Ye(AMo,{});case"to92":return Ye(gMo,{});case"stampboard":case"stampreceiver":return Ye(fMo,{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 Ye(yMo,{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})}}switch(n.imperial){case"0402":return Ye(M3t,{color:i});case"0603":return Ye(w3t,{color:i});case"0805":return Ye(N3t,{color:i});case"0201":return Ye(T3t,{color:i});case"01005":return Ye(k3t,{color:i});case"1206":return Ye(F3t,{color:i});case"1210":return Ye(L3t,{color:i});case"2010":return Ye(H3t,{color:i});case"2512":return Ye(G3t,{color:i})}if((n.fn==="res"||n.fn==="cap")&&n.p!==void 0&&n.ph!==void 0){const r=Ha(n.p),s=Ha(n.ph);if(Number.isFinite(r)&&Number.isFinite(s))return Ye(NMo,{padPitch:r,padHeight:s,color:i??(n.fn==="cap"?"#856c4d":void 0)})}return null},FMo=t=>t&&typeof t=="object"&&"type"in t,zT=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},LMo=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 OS(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=>OS(u,e,n));if(!FMo(t))return[];const{type:c,props:l,children:g}=t;if(c===D3t)return(g??[]).flatMap(u=>OS(u,e,n));if(c===or){const u=l?.color;return(g??[]).flatMap(h=>OS(h,u??e,n))}if(c===jo){const u=LMo(l?.offset??l?.center??{x:l?.x,y:l?.y,z:l?.z});return(g??[]).flatMap(d=>OS(d,e,n)).map(({geom:d,color:_})=>({geom:A.translate(u,d),color:_??e}))}if(c===n0){const u=Array.isArray(l?.rotation)?[zT(l.rotation[0]),zT(l.rotation[1]),zT(l.rotation[2])]:[zT(l?.x??0),zT(l?.y??0),zT(l?.z??0)];return(g??[]).flatMap(d=>OS(d,e,n)).map(({geom:d,color:_})=>({geom:A.rotateZ(u[2],A.rotateY(u[1],A.rotateX(u[0],d))),color:_}))}if(c===N_||c===R_||c===dc){const u=(g??[]).flatMap(d=>OS(d,e,n)).map(d=>d.geom);if(u.length===0)return[];let h;return c===N_?h=i.union(u):c===R_?h=i.subtract(u[0],u.slice(1)):h=r.hull(u),[{geom:h,color:e}]}if(c===RT){const u=l?.points??[];return[{geom:s.geom2.fromPoints(u),color:e??l?.color}]}if(c===TT){const u=(g??[]).flatMap(m=>OS(m,e,n)).map(m=>m.geom);if(u.length===0)return[];const h=u.length>1?i.union(u):u[0],d=l?.height??l?.h??1;let _=a.extrudeLinear({height:d},h);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===Jt||c===P3t||c===dA||c===yie||c===MI||c===By){let u;if(c===Jt){const h=l?.size??[1,1,1],d=l?.offset,_=l?.center??(d?[d[0],d[1],d[2]]:[0,0,0]);u=o.cuboid({size:h,center:_})}else if(c===P3t){const h=l?.size??1,d=l?.offset,_=l?.center??(d?[d[0],d[1],d[2]]:[0,0,0]);u=o.cube({size:h,center:_})}else if(c===dA){const h=l?.height??1,d=l?.radius??1,_=l?.center??[0,0,0];u=o.cylinder({height:h,radius:d,center:_})}else if(c===yie){const h=l?.radius??1,d=l?.center??[0,0,0];u=o.sphere({radius:h,center:d})}else if(c===By){const h=l?.height??1,d=l?.radius??1,_=l?.roundRadius??.1,m=l?.center??[0,0,0];u=o.roundedCylinder({height:h,radius:d,roundRadius:_,center:m})}else{const h=l?.size??[1,1,1],d=l?.roundRadius??.1,_=l?.center??[0,0,0];u=o.roundedCuboid({size:h,roundRadius:d,center:_})}return[{geom:u,color:e??l?.color}]}if(typeof c=="function"){const u=c(l??{});return OS(u,e,n)}return(g??[]).flatMap(u=>OS(u,e,n))}function HMo(t,e){return{geometries:OS(t,void 0,{jscad:e})}}function z3t(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 Zc;if(r.setAttribute("position",new Kg(new Float32Array(e),3)),r.setIndex(n),o.length>0&&r.setAttribute("color",new Kg(new Float32Array(o),3)),t.transforms){const s=new Ms;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 Zc;if(o.setAttribute("position",new Kg(new Float32Array(e),3)),n.length>0&&o.setAttribute("color",new Kg(new Float32Array(n),3)),t.transforms){const i=new Ms;i.fromArray(t.transforms),o.applyMatrix4(i)}return o}return console.error("Invalid CSG object: neither polygons nor sides found"),new Zc}function GMo(t,e){const n=iwe(kMo,{footprint:t});return HMo(n,e)}var OMo=tl(uie()),V3t=Z.createContext(null),KMo=()=>{const t=Z.useContext(V3t);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},UMo=({children:t})=>{const{camera:e,renderer:n}=vI(),[o,i]=Z.useState([]),r=Z.useMemo(()=>new Tfn,[]),s=Z.useMemo(()=>new Io,[]),a=Z.useRef(o);a.current=o;const A=Z.useRef(null),c=Z.useCallback(d=>{i(_=>[..._,d])},[]),l=Z.useCallback(d=>{if(A.current){let _=!1,m=A.current.object;for(;m;){if(m===d){_=!0;break}m=m.parent}_&&(A.current.onUnhover(),A.current=null)}i(_=>_.filter(m=>m.object!==d))},[]),g=Z.useCallback(d=>{let _=d;for(;_;){const m=a.current.find(p=>p.object===_);if(m)return m;_=_.parent}},[]),u=Z.useCallback(d=>{if(!n.domElement)return;const _=n.domElement.getBoundingClientRect();s.x=(d.clientX-_.left)/_.width*2-1,s.y=-((d.clientY-_.top)/_.height)*2+1,r.setFromCamera(s,e);const m=a.current.map(f=>f.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 f=p[0],I=g(f.object);if(I){const C={mousePosition:[f.point.x,f.point.y,f.point.z]};A.current!==I?(A.current?.onUnhover(),I.onHover(C),A.current=I):I.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]);Z.useEffect(()=>{const d=n.domElement;return d.addEventListener("mousemove",u),()=>{d.removeEventListener("mousemove",u)}},[n,u]);const h=Z.useMemo(()=>({addHoverable:c,removeHoverable:l}),[c,l]);return q.jsx(V3t.Provider,{value:h,children:t})},YMo=({children:t,object:e,onHover:n,onUnhover:o,isHovered:i})=>{const{addHoverable:r,removeHoverable:s}=KMo();return Z.useEffect(()=>e?(r({object:e,onHover:n,onUnhover:o}),()=>{s(e)}):void 0,[e,n,o,r,s]),q.jsx(q.Fragment,{children:t})},RU=YMo,kB=(t,{castShadow:e=!0,receiveShadow:n=!0}={})=>{t.traverse(o=>{o instanceof Yi&&(o.castShadow=e,o.receiveShadow=n)})},zMo=({positionOffset:t,footprint:e,rotationOffset:n,onHover:o,onUnhover:i,isHovered:r,scale:s,isTranslucent:a=!1})=>{const{rootObject:A}=vI(),c=Z.useMemo(()=>{if(!e)return null;const{geometries:l}=GMo(e,OMo),g=new gd;for(const u of l.flat(1/0)){const h=u.geom;if(!h||!h.polygons&&!h.sides)continue;const d=new yi(u.color);d.convertLinearToSRGB();const _={...h,color:[d.r,d.g,d.b]},m=z3t(_),p=new hg({vertexColors:!0,side:lm,transparent:a,opacity:a?.5:1,depthWrite:!a}),f=new Yi(m,p);f.renderOrder=a?2:1,kB(f,{castShadow:!a,receiveShadow:!0}),g.add(f)}return g},[e,a]);return Z.useEffect(()=>{if(!(!c||!A))return A.add(c),()=>{A.remove(c)}},[A,c]),Z.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]),Z.useEffect(()=>{c&&c.traverse(l=>{l instanceof Yi&&l.material instanceof hg&&(r?(l.material.emissive.setHex(255),l.material.emissiveIntensity=.2):l.material.emissiveIntensity=0)})},[r,c]),c?q.jsx(RU,{isHovered:r,onHover:o,onUnhover:i,object:c}):null},J3t=new WeakMap,VMo=()=>{const t=new _u;return t.name="fallback-environment-map",t.mapping=LW,t},JMo=t=>{if(!t)return null;const e=t,n=J3t.get(e);if(n)return n;let o;if(t instanceof mj){const i=new ime(t);o=i.fromScene(rCn(),.04).texture,i.dispose()}else o=VMo();return J3t.set(e,o),o};function qMo(t){const e=new oy;let n=!1;t.updateWorldMatrix(!0,!1);const o=t.parent?t.parent.matrixWorld.clone().invert():new Ms;return t.traverse(i=>{if(i.updateWorldMatrix(!0,!1),i instanceof Yi&&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 WMo(t){const e=qMo(t);return e?e.getSize(new Dt):new Dt}function jMo(t,e,n="contain_within_bounds"){if(!e)return[1,1,1];const o=WMo(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 Swe=({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}=vI(),l=Z.useMemo(()=>new gd,[]),g=Z.useMemo(()=>new gd,[]),u=Z.useMemo(()=>new gd,[]),h=Z.useMemo(()=>new gd,[]);return Z.useEffect(()=>(l.add(g),()=>{l.remove(g)}),[l,g]),Z.useEffect(()=>(g.add(u),()=>{g.remove(u)}),[g,u]),Z.useEffect(()=>(u.add(h),()=>{u.remove(h)}),[u,h]),Z.useEffect(()=>{for(;h.children.length>0;){const d=h.children[0];if(!d)break;h.remove(d)}t&&h.add(t)},[h,t]),Z.useEffect(()=>{if(!r){h.matrixAutoUpdate=!0,h.position.set(0,0,0),h.rotation.set(0,0,0),h.scale.set(1,1,1),h.updateMatrix();return}h.matrixAutoUpdate=!1,h.matrix.copy(r),h.matrixWorldNeedsUpdate=!0},[h,r]),Z.useEffect(()=>{if(c)return c.add(l),()=>{c.remove(l)}},[c,l]),Z.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 d=jMo(u,s,a);g.scale.set(d[0],d[1],d[2])},[l,g,t,a,o,h,u,i,s,e,n,A]),{boardTransformGroup:l}},q3t=1.25;function W3t({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:h}=vI(),[d,_]=Z.useState(null),[m,p]=Z.useState(null),{boardTransformGroup:f}=Swe({model:d,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:g});if(Z.useEffect(()=>{if(!t)return;const I=new aCn;let C=!0;return I.load(t,y=>{if(!C)return;const E=y.scene;E.traverse(B=>{if(B instanceof Yi&&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}}),kB(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]),Z.useEffect(()=>{if(!d||!h)return;const I=JMo(h);if(!I)return;const C=[],y=E=>{E instanceof hg&&(C.push({material:E,envMap:E.envMap??null,envMapIntensity:E.envMapIntensity??1}),E.envMap=I,(typeof E.envMapIntensity!="number"||E.envMapIntensity<q3t)&&(E.envMapIntensity=q3t),E.needsUpdate=!0)};return d.traverse(E=>{if(!(E instanceof Yi))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})}},[d,h]),Z.useEffect(()=>{d&&d.traverse(I=>{if(!(I instanceof Yi))return;const C=Array.isArray(I.material)?I.material:[I.material];for(const y of C)y instanceof hg&&(l?(y.emissive.setHex(255),y.emissiveIntensity=.2):y.emissiveIntensity=0)})},[l,d]),m)throw m;return d?q.jsx(RU,{isHovered:l,onHover:A,onUnhover:c,object:f}):null}var XMo=tl(Wwt()),$Mo=tl(uie()),ZMo=({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:h,material:d}=Z.useMemo(()=>{const p=(0,XMo.executeJscadOperations)($Mo.default,t);if(!p||!p.polygons&&!p.sides)return{threeGeom:null,material:null};const f=z3t(p),I=new hg({vertexColors:!0,side:lm,transparent:u,opacity:u?.5:1,depthWrite:!u});return{threeGeom:f,material:I}},[t,u]),_=Z.useMemo(()=>{if(!h)return null;const p=new Yi(h,d);return p.renderOrder=u?2:1,kB(p,{castShadow:!u,receiveShadow:!0}),p},[h,d,u]),{boardTransformGroup:m}=Swe({model:_,position:e,rotation:n,modelOffset:o,modelRotation:i,sourceCoordinateTransform:r,modelSize:s,modelFitMode:a,scale:g});return Z.useEffect(()=>{if(d)if(l){const p=new yi(d.color.getHex());d.emissive.copy(p),d.emissive.setRGB(0,0,1),d.emissiveIntensity=.2}else d.emissiveIntensity=0},[l,d]),h?q.jsx(RU,{isHovered:l,onHover:A,onUnhover:c,object:m}):null};function ewo(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(e,n,o)=>`${n} ${o.replace(/-/g,"_")}`)}async function two(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 VCn().parse(ewo(n),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function nwo(t){const[e,n]=Z.useState(null);return Z.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 two(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 t1n;if(l?.length){const u=l.join(`
5470
- `).replace(/^d\s+0\./gm,"d 1."),h=c.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),d=new UCn;d.setMaterialOptions({invertTrProperty:!0});const _=d.parse(u,"embedded.mtl");return g.setMaterials(_),g.parse(h)}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 owo({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 h=nwo(t),d=Z.useMemo(()=>{if(h&&!(h instanceof Error))return h.traverse(p=>{if(p instanceof Yi&&p.material){const f=I=>{I.transparent=u,I.opacity=u?.5:1,I.depthWrite=!u,I.needsUpdate=!0};Array.isArray(p.material)?p.material.forEach(f):f(p.material),p.renderOrder=u?2:1}}),kB(h,{castShadow:!u,receiveShadow:!0}),h;const m=new Yi(new ry(.5,.5,.5),new hg({transparent:!0,color:"red",opacity:.25}));return kB(m,{castShadow:!1,receiveShadow:!0}),m},[h,u]),{boardTransformGroup:_}=Swe({model:d,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(h instanceof Error)throw h;return q.jsx(RU,{isHovered:l,onHover:A,onUnhover:c,object:_})}var iwo=new yi(.82,.82,.82),j3t=t=>new hg({color:t?new yi(t[0],t[1],t[2]):iwo});function rwo(t,e){const n=j3t(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(","),h=s.get(u);if(h!==void 0)return h;const d=r.length;return r.push(j3t(g)),s.set(u,d),d};for(;A<a;){const g=i[c];let u=a,h=0;g&&(A<g.first?u=g.first:(u=g.last+1,h=l(g.color),c+=1)),u>A&&t.addGroup(A*3,(u-A)*3,h),A=u}return r}function swo(t){const e=new gd;for(const n of t){const o=n.attributes.position?.array??[],i=n.index?.array??[];if(!o.length||!i.length)continue;const r=new Zc;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=rwo(r,n),A=new Yi(r,a.length>1?a:a[0]);A.name=n.name,e.add(A)}return e}var bwe,awo="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function Awo(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 cwo(){if(!bwe){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");bwe=Awo(t)({locateFile:n=>`${awo}/${n}`})}return bwe}async function lwo(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 cwo()).ReadStepFile(new Uint8Array(n),null);if(!i.success||!i.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const r=swo(i.meshes),s=new Ome;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 X3t="step-glb-cache:v2:";function gwo(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 uwo(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 dwo(t){try{const e=localStorage.getItem(`${X3t}${t}`);return e?uwo(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function $3t(t,e){try{const n=gwo(e);localStorage.setItem(`${X3t}${t}`,n)}catch(n){console.warn("Failed to write STEP GLB cache",n)}}function hwo(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var _wo=({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[h,d]=Z.useState(null);return Z.useEffect(()=>{let _=!0,m=null,p=!0;const f=hwo(),I=dwo(t);if(I){const E={arrayBuffer:I,blobUrl:URL.createObjectURL(new Blob([I],{type:"model/gltf-binary"}))};return f.completed.set(t,E),m=E.blobUrl,p=!1,d(E.blobUrl),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)}}const C=f.completed.get(t);if(C)return m=C.blobUrl,p=!1,d(C.blobUrl),$3t(t,C.arrayBuffer),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)};let y=f.inProgress.get(t);return y||(y=lwo(t).then(E=>{const B={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return f.completed.set(t,B),f.inProgress.delete(t),B}).catch(E=>{throw f.inProgress.delete(t),E}),f.inProgress.set(t,y)),y.then(E=>{_&&(m=E.blobUrl,p=!1,d(E.blobUrl),$3t(t,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),_&&d(null)}),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)}},[t]),h?q.jsx(W3t,{gltfUrl:h,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 Sie(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=Dwe(r,e.axisMapping.x)),e.axisMapping.y&&(o=Dwe(r,e.axisMapping.y)),e.axisMapping.z&&(i=Dwe(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 Dwe(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 Pwe={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 mwo(t,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return Pwe.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?Pwe.STEP_INVERTED:Pwe.Z_UP_TO_Y_UP_USB_FIX}}function TU(t,e){return mwo(t,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function bie(t){if(!t)return;const e=Sie({x:1,y:0,z:0},t),n=Sie({x:0,y:1,z:0},t),o=Sie({x:0,y:0,z:1},t);return new Ms().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 bv(t){return t*Math.PI/180}function pwo(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,bv(-90),0];case"x-":return[0,bv(90),0];case"y+":return[bv(90),0,0];case"y-":return[bv(-90),0,0];case"z-":return[bv(180),0,0];default:return[0,0,0]}}function Iwo(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 fwo(t,e){return t.rotation?[bv(t.rotation.x),bv(t.rotation.y),bv(t.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function Cwo(t,e){const n=new Dt(t.x,t.y,t.z),o=new TC(e[0],e[1],e[2],"XYZ");return n.applyEuler(o),[n.x,n.y,n.z]}function ywo(t,e,n){if(!t.model_origin_position)return[0,0,0];const o=e?Sie(t.model_origin_position,e):t.model_origin_position;return Cwo(o,n)}function Ewo(t,e){const n=Iwo(t,e.layer,e.pcbThickness),o=fwo(t,e.layer),i=TU(t,e.modelType),r=pwo(t.model_board_normal_direction??"z+"),s=ywo(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 xwo=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",Bwo=t=>t==="step"?"glb":t,Qwo=(t,e)=>{if(!t.model_jscad||t.model_origin_alignment!=="bottom_center_of_component")return!1;const n=e.find(o=>o.type==="pcb_component"&&o.pcb_component_id===t.pcb_component_id);return!!(n&&n.do_not_place&&n.is_allowed_to_be_off_board&&n.obstructs_within_bounds===!1)},Swo=(t,e)=>{if(t)return e?e(t):t},bwo=(...t)=>t,vwe=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}},Dwo=({error:t,onError:e})=>(Z.useEffect(()=>{e(t)},[t,e]),null),Z3t=({cad_component:t,circuitJson:e,resolveStaticAsset:n})=>{const o=$wt(e),[i,r]=Z.useState(!1),{visibility:s}=d6(),[a,A]=Z.useState(null),c=Z.useCallback(j=>{j?.mousePosition?(r(!0),A(j.mousePosition)):(r(!1),A(null))},[]),l=Z.useCallback(()=>{r(!1),A(null)},[]),g=Z.useMemo(()=>Fi(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),u=Z.useMemo(()=>e.filter(te=>te.type==="pcb_plated_hole"&&te.pcb_component_id===t.pcb_component_id).length>0,[e,t.pcb_component_id]),h=Z.useCallback(j=>Swo(j,n),[n]),d=h(t.model_wrl_url??t.model_stl_url??t.model_obj_url),_=h(t.model_glb_url??t.model_gltf_url),m=h(t.model_step_url),[p,f]=Z.useState(0),[I,C]=Z.useState(null);Z.useEffect(()=>{f(0),C(null)},[t.cad_component_id,d,_,m]);const E=e.find(j=>j.type==="pcb_component"&&j.source_component_id===t.source_component_id)?.layer??"top",B=Z.useMemo(()=>Qwo(t,e),[t,e]),Q=B?s.enclosure==="translucent":!!t.show_as_translucent_model,b=xwo(t),D=Bwo(b),R=t.model_glb_url?"glb":"gltf",w=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",H=Z.useMemo(()=>Ewo(t,{layer:E,pcbThickness:o,modelType:D}),[t,E,o,D]),G=bwo(...H.rotation),O=H.position,U=Z.useMemo(()=>{const j=[];return _&&j.push(q.jsx(W3t,{gltfUrl:_,position:O,rotation:G,modelOffset:H.modelPosition,modelRotation:H.modelRotation,sourceCoordinateTransform:bie(TU(t,R)),scale:H.scale,modelSize:H.size,modelFitMode:H.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},`${t.cad_component_id}-gltf-${_}`)),d&&j.push(q.jsx(owo,{url:d,position:O,rotation:G,modelOffset:H.modelPosition,modelRotation:H.modelRotation,sourceCoordinateTransform:bie(TU(t,w)),scale:H.scale,modelSize:H.size,modelFitMode:H.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},`${t.cad_component_id}-mixed-${d}`)),m&&!t.model_jscad&&!t.footprinter_string&&j.push(q.jsx(_wo,{stepUrl:m,position:O,rotation:G,modelOffset:H.modelPosition,modelRotation:H.modelRotation,sourceCoordinateTransform:bie(TU(t,D)),scale:H.scale,modelSize:H.size,modelFitMode:H.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},`${t.cad_component_id}-step-${m}`)),j},[O,t.cad_component_id,t.footprinter_string,t.model_jscad,Q,_,R,c,l,i,w,H.modelPosition,H.modelRotation,H.scale,H.fitMode,H.size,D,G,m,d]);let W=null;if(U.length>0){if(p>=U.length){if(I)throw I;return null}W=q.jsx(vwe,{fallback:({error:j})=>q.jsx(Dwo,{error:j,onError:te=>{C(te),f(re=>Math.max(re,p+1))}}),children:U[p]},`${t.cad_component_id}-fallback-${p}`)}else t.model_jscad?W=q.jsx(ZMo,{jscadPlan:t.model_jscad,positionOffset:O,rotationOffset:G,modelOffset:H.modelPosition,modelRotation:H.modelRotation,sourceCoordinateTransform:bie(TU(t,"jscad")),scale:H.scale,modelSize:H.size,modelFitMode:H.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},t.cad_component_id):t.footprinter_string&&(W=q.jsx(zMo,{positionOffset:O,rotationOffset:G,footprint:t.footprinter_string,scale:H.scale,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q}));if(B){if(s.enclosure==="hidden")return null}else if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(u&&!s.throughHoleModels||!u&&!s.smtModels)return null;return q.jsxs(q.Fragment,{children:[W,i&&a?q.jsx(e3t,{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]})},e6t={version:"0.0.591"},t6t="cadViewerLightingEnabled",Pwo=()=>typeof window>"u"?!0:window.localStorage.getItem(t6t)!=="false",n6t=Z.createContext(void 0),vwo=({children:t})=>{const[e,n]=Z.useState(!1),[o,i]=Z.useState(!1),[r,s]=Z.useState(Pwo);Z.useEffect(()=>{window.localStorage.setItem(t6t,r?"true":"false")},[r]);const a=Z.useMemo(()=>({darkBackgroundEnabled:e,setDarkBackgroundEnabled:n,gridEnabled:o,setGridEnabled:i,lightingEnabled:r,setLightingEnabled:s}),[e,o,r]);return q.jsx(n6t.Provider,{value:a,children:t})},Mwe=()=>{const t=Z.useContext(n6t);if(!t)throw new Error("useAppearance must be used within an AppearanceProvider");return t},o6t="cadViewerCameraStateSession",i6t=(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(o6t,JSON.stringify(n))}catch(n){console.warn("Failed to save camera:",n)}},wwe=(t,e)=>{try{const n=sessionStorage.getItem(o6t);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}},r6t=Z.createContext(void 0),Mwo=({children:t,defaultTarget:e,initialCameraPosition:n,initialCameraType:o})=>{const i=Z.useRef(null),r=Z.useRef(null),[s,a]=Z.useState(null),[A,c]=Z.useState(o??"perspective"),[l,g]=Z.useState(n??null),[u,h]=Z.useState(new TC(0,0,0)),d=Z.useMemo(()=>{const[f,I,C]=n??[5,-5,5],y=Math.hypot(f-e.x,I-e.y,C-e.z);return y>0?y:5},[n,e]),_=Z.useCallback(f=>{const I=[e.x,e.y,e.z],C=r.current,y=i.current;let E=d;switch(C&&y&&(E=C.position.distanceTo(y.target)),f){case"Top Center Angled":{const B=E/Math.sqrt(2);return{position:[e.x,e.y-B,e.z+B],target:I,up:[0,0,1]}}case"Top Down":return{position:[e.x,e.y,e.z+E],target:I,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-E*.6,e.y-E*.6,e.z+E*.6],target:I,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+E*.6,e.y-E*.6,e.z+E*.6],target:I,up:[0,0,1]};case"Left Sideview":return{position:[e.x-E,e.y,e.z],target:I,up:[0,0,1]};case"Right Sideview":return{position:[e.x+E,e.y,e.z],target:I,up:[0,0,1]};case"Front":return{position:[e.x,e.y-E,e.z],target:I,up:[0,0,1]};default:return null}},[d,e,r,i]),m=Z.useCallback(f=>{i.current=f},[]),p=Z.useMemo(()=>({controlsRef:i,mainCameraRef:r,defaultTarget:e,baseDistance:d,controller:s,setController:a,getPresetConfig:_,handleControlsChange:m,cameraType:A,setCameraType:c,cameraPosition:l,setCameraPosition:g,cameraRotation:u,setCameraRotation:h,saveCameraToSession:i6t,loadCameraFromSession:wwe}),[e,d,s,_,m,A,l,u]);return q.jsx(r6t.Provider,{value:p,children:t})},e5=()=>{const t=Z.useContext(r6t);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},wwo=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,Nwo=()=>{const{controlsRef:t,mainCameraRef:e,defaultTarget:n,setController:o,getPresetConfig:i}=e5(),r=Z.useRef(null),s=Z.useRef(new RC),a=Z.useRef(new Dt),A=Z.useRef(new Dt),c=Z.useRef(new RC),l=Z.useRef(new RC),g=Z.useRef(new Il),u=Z.useRef(new Il),h=Z.useCallback(({position:_,target:m,up:p,durationMs:f=600})=>{if(!e.current)return;const I=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=I.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(),O=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:O,rollTo:U,startTime:performance.now(),duration:f}},[e,t,n]),d=Z.useCallback(_=>{if(_==="Custom")return;const m=i(_);m&&h(m)},[h,i]);return Z.useEffect(()=>e.current?(o({animateTo:h,animateToPreset:d}),()=>{o(null)}):void 0,[h,d,e,o]),EU(()=>{if(!e.current||!r.current)return;const{fromPosition:_,toPosition:m,fromTarget:p,toTarget:f,toQuaternion:I,rollFrom:C,rollTo:y,startTime:E,duration:B}=r.current,Q=performance.now()-E,b=B<=0?1:Math.min(Q/B,1),D=wwo(b);e.current.position.lerpVectors(_,m,D);const R=a.current;R.copy(p).lerp(f,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 O=l.current;O.copy(y),C.dot(y)<0&&(O.x*=-1,O.y*=-1,O.z*=-1,O.w*=-1),O.normalize(),G.slerp(O,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(I),e.current.up.set(0,0,1),e.current.updateMatrixWorld(),t.current?.target.copy(f),t.current?.update(),r.current=null)}),null},Rwo=()=>{const{controlsRef:t}=e5(),e=Z.useRef(null),n=Z.useRef(!1),o=Z.useRef(null),i=Z.useCallback(s=>{e.current=s,!n.current&&t.current&&wwe(s,t.current)&&(n.current=!0)},[t]),r=Z.useCallback(()=>{if(!(!e.current||!t.current)){if(!n.current&&wwe(e.current,t.current)){n.current=!0;return}clearTimeout(o.current),o.current=setTimeout(()=>{e.current&&t.current&&i6t(e.current,t.current)},150)}},[t]);return{handleCameraCreated:i,handleControlsChange:r}};function Two(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var kwo=t=>{t.outputColorSpace=x2,t.toneMapping=yqe,t.toneMappingExposure=1,t.shadowMap.enabled=!0,t.shadowMap.type=pqe},Fwo=Z.forwardRef(({children:t,scene:e,camera:n,style:o,onCreated:i},r)=>{const{cameraType:s}=e5(),a=Z.useRef(null),[A,c]=Z.useState(null),l=Z.useRef([]),g=Z.useRef(void 0);g.current=i;const u=Z.useRef(null),h=Z.useCallback(p=>{l.current.push(p)},[]),d=Z.useCallback(p=>{l.current=l.current.filter(f=>f!==p)},[]),_=Z.useMemo(()=>new hw,[]);e?.up&&_.up.set(e.up.x,e.up.y,e.up.z);const m=Z.useRef(new Il);return Z.useImperativeHandle(r,()=>m.current),Z.useEffect(()=>{if(!a.current)return;Two(a.current);const p=new mj({antialias:!0,alpha:!0});kwo(p),p.setSize(a.current.clientWidth,a.current.clientHeight),p.setPixelRatio(window.devicePixelRatio),a.current.appendChild(p.domElement);const f=a.current.clientWidth/a.current.clientHeight,I=s==="perspective"?new um(75,f,.1,1e3):new r7(-10*f,10*f,10,-10,-1e3,1e3);u.current?(I.position.copy(u.current.position),I.quaternion.copy(u.current.quaternion),I.up.copy(u.current.up)):(n?.up&&I.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&I.position.set(n.position[0],n.position[1],n.position[2]),I.lookAt(0,0,0)),_.add(m.current),window.__TSCIRCUIT_THREE_OBJECT=m.current,c({scene:_,camera:I,renderer:p,rootObject:m.current,addFrameListener:h,removeFrameListener:d}),g.current?.({camera:I,renderer:p});let C;const y=new Qfn,E=()=>{const Q=y.getElapsedTime(),b=y.getDelta();l.current.forEach(D=>D(Q,b)),p.render(_,I),C=requestAnimationFrame(E)};E();const B=()=>{if(a.current){const Q=a.current.clientWidth/a.current.clientHeight;I instanceof um?I.aspect=Q:I instanceof r7&&(I.left=-10*Q,I.right=10*Q,I.top=10,I.bottom=-10),I.updateProjectionMatrix(),p.setSize(a.current.clientWidth,a.current.clientHeight)}};return window.addEventListener("resize",B),()=>{u.current={position:I.position.clone(),quaternion:I.quaternion.clone(),up:I.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)}},[_,h,d,s]),q.jsx("div",{ref:a,style:{width:"100%",height:"100%",...o},children:A&&q.jsx(Zwt.Provider,{value:A,children:q.jsx(UMo,{children:t})})})}),Lwo=`
5470
+ `).replace(/^d\s+0\./gm,"d 1."),h=c.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),d=new UCn;d.setMaterialOptions({invertTrProperty:!0});const _=d.parse(u,"embedded.mtl");return g.setMaterials(_),g.parse(h)}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 owo({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 h=nwo(t),d=Z.useMemo(()=>{if(h&&!(h instanceof Error))return h.traverse(p=>{if(p instanceof Yi&&p.material){const f=I=>{I.transparent=u,I.opacity=u?.5:1,I.depthWrite=!u,I.needsUpdate=!0};Array.isArray(p.material)?p.material.forEach(f):f(p.material),p.renderOrder=u?2:1}}),kB(h,{castShadow:!u,receiveShadow:!0}),h;const m=new Yi(new ry(.5,.5,.5),new hg({transparent:!0,color:"red",opacity:.25}));return kB(m,{castShadow:!1,receiveShadow:!0}),m},[h,u]),{boardTransformGroup:_}=Swe({model:d,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(h instanceof Error)throw h;return q.jsx(RU,{isHovered:l,onHover:A,onUnhover:c,object:_})}var iwo=new yi(.82,.82,.82),j3t=t=>new hg({color:t?new yi(t[0],t[1],t[2]):iwo});function rwo(t,e){const n=j3t(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(","),h=s.get(u);if(h!==void 0)return h;const d=r.length;return r.push(j3t(g)),s.set(u,d),d};for(;A<a;){const g=i[c];let u=a,h=0;g&&(A<g.first?u=g.first:(u=g.last+1,h=l(g.color),c+=1)),u>A&&t.addGroup(A*3,(u-A)*3,h),A=u}return r}function swo(t){const e=new gd;for(const n of t){const o=n.attributes.position?.array??[],i=n.index?.array??[];if(!o.length||!i.length)continue;const r=new Zc;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=rwo(r,n),A=new Yi(r,a.length>1?a:a[0]);A.name=n.name,e.add(A)}return e}var bwe,awo="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function Awo(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 cwo(){if(!bwe){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");bwe=Awo(t)({locateFile:n=>`${awo}/${n}`})}return bwe}async function lwo(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 cwo()).ReadStepFile(new Uint8Array(n),null);if(!i.success||!i.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const r=swo(i.meshes),s=new Ome;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 X3t="step-glb-cache:v2:";function gwo(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 uwo(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 dwo(t){try{const e=localStorage.getItem(`${X3t}${t}`);return e?uwo(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function $3t(t,e){try{const n=gwo(e);localStorage.setItem(`${X3t}${t}`,n)}catch(n){console.warn("Failed to write STEP GLB cache",n)}}function hwo(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var _wo=({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[h,d]=Z.useState(null);return Z.useEffect(()=>{let _=!0,m=null,p=!0;const f=hwo(),I=dwo(t);if(I){const E={arrayBuffer:I,blobUrl:URL.createObjectURL(new Blob([I],{type:"model/gltf-binary"}))};return f.completed.set(t,E),m=E.blobUrl,p=!1,d(E.blobUrl),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)}}const C=f.completed.get(t);if(C)return m=C.blobUrl,p=!1,d(C.blobUrl),$3t(t,C.arrayBuffer),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)};let y=f.inProgress.get(t);return y||(y=lwo(t).then(E=>{const B={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return f.completed.set(t,B),f.inProgress.delete(t),B}).catch(E=>{throw f.inProgress.delete(t),E}),f.inProgress.set(t,y)),y.then(E=>{_&&(m=E.blobUrl,p=!1,d(E.blobUrl),$3t(t,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),_&&d(null)}),()=>{_=!1,m&&p&&URL.revokeObjectURL(m)}},[t]),h?q.jsx(W3t,{gltfUrl:h,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 Sie(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=Dwe(r,e.axisMapping.x)),e.axisMapping.y&&(o=Dwe(r,e.axisMapping.y)),e.axisMapping.z&&(i=Dwe(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 Dwe(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 Pwe={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 mwo(t,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return Pwe.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?Pwe.STEP_INVERTED:Pwe.Z_UP_TO_Y_UP_USB_FIX}}function TU(t,e){return mwo(t,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function bie(t){if(!t)return;const e=Sie({x:1,y:0,z:0},t),n=Sie({x:0,y:1,z:0},t),o=Sie({x:0,y:0,z:1},t);return new Ms().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 bv(t){return t*Math.PI/180}function pwo(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,bv(-90),0];case"x-":return[0,bv(90),0];case"y+":return[bv(90),0,0];case"y-":return[bv(-90),0,0];case"z-":return[bv(180),0,0];default:return[0,0,0]}}function Iwo(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 fwo(t,e){return t.rotation?[bv(t.rotation.x),bv(t.rotation.y),bv(t.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function Cwo(t,e){const n=new Dt(t.x,t.y,t.z),o=new TC(e[0],e[1],e[2],"XYZ");return n.applyEuler(o),[n.x,n.y,n.z]}function ywo(t,e,n){if(!t.model_origin_position)return[0,0,0];const o=e?Sie(t.model_origin_position,e):t.model_origin_position;return Cwo(o,n)}function Ewo(t,e){const n=Iwo(t,e.layer,e.pcbThickness),o=fwo(t,e.layer),i=TU(t,e.modelType),r=pwo(t.model_board_normal_direction??"z+"),s=ywo(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 xwo=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",Bwo=t=>t==="step"?"glb":t,Qwo=(t,e)=>{if(!t.model_jscad||t.model_origin_alignment!=="bottom_center_of_component")return!1;const n=e.find(o=>o.type==="pcb_component"&&o.pcb_component_id===t.pcb_component_id);return!!(n&&n.do_not_place&&n.is_allowed_to_be_off_board&&n.obstructs_within_bounds===!1)},Swo=(t,e)=>{if(t)return e?e(t):t},bwo=(...t)=>t,vwe=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}},Dwo=({error:t,onError:e})=>(Z.useEffect(()=>{e(t)},[t,e]),null),Z3t=({cad_component:t,circuitJson:e,resolveStaticAsset:n})=>{const o=$wt(e),[i,r]=Z.useState(!1),{visibility:s}=d6(),[a,A]=Z.useState(null),c=Z.useCallback(j=>{j?.mousePosition?(r(!0),A(j.mousePosition)):(r(!1),A(null))},[]),l=Z.useCallback(()=>{r(!1),A(null)},[]),g=Z.useMemo(()=>Fi(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),u=Z.useMemo(()=>e.filter(te=>te.type==="pcb_plated_hole"&&te.pcb_component_id===t.pcb_component_id).length>0,[e,t.pcb_component_id]),h=Z.useCallback(j=>Swo(j,n),[n]),d=h(t.model_wrl_url??t.model_stl_url??t.model_obj_url),_=h(t.model_glb_url??t.model_gltf_url),m=h(t.model_step_url),[p,f]=Z.useState(0),[I,C]=Z.useState(null);Z.useEffect(()=>{f(0),C(null)},[t.cad_component_id,d,_,m]);const E=e.find(j=>j.type==="pcb_component"&&j.source_component_id===t.source_component_id)?.layer??"top",B=Z.useMemo(()=>Qwo(t,e),[t,e]),Q=B?s.enclosure==="translucent":!!t.show_as_translucent_model,b=xwo(t),D=Bwo(b),R=t.model_glb_url?"glb":"gltf",w=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",H=Z.useMemo(()=>Ewo(t,{layer:E,pcbThickness:o,modelType:D}),[t,E,o,D]),G=bwo(...H.rotation),O=H.position,U=Z.useMemo(()=>{const j=[];return _&&j.push(q.jsx(W3t,{gltfUrl:_,position:O,rotation:G,modelOffset:H.modelPosition,modelRotation:H.modelRotation,sourceCoordinateTransform:bie(TU(t,R)),scale:H.scale,modelSize:H.size,modelFitMode:H.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},`${t.cad_component_id}-gltf-${_}`)),d&&j.push(q.jsx(owo,{url:d,position:O,rotation:G,modelOffset:H.modelPosition,modelRotation:H.modelRotation,sourceCoordinateTransform:bie(TU(t,w)),scale:H.scale,modelSize:H.size,modelFitMode:H.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},`${t.cad_component_id}-mixed-${d}`)),m&&!t.model_jscad&&!t.footprinter_string&&j.push(q.jsx(_wo,{stepUrl:m,position:O,rotation:G,modelOffset:H.modelPosition,modelRotation:H.modelRotation,sourceCoordinateTransform:bie(TU(t,D)),scale:H.scale,modelSize:H.size,modelFitMode:H.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},`${t.cad_component_id}-step-${m}`)),j},[O,t.cad_component_id,t.footprinter_string,t.model_jscad,Q,_,R,c,l,i,w,H.modelPosition,H.modelRotation,H.scale,H.fitMode,H.size,D,G,m,d]);let W=null;if(U.length>0){if(p>=U.length){if(I)throw I;return null}W=q.jsx(vwe,{fallback:({error:j})=>q.jsx(Dwo,{error:j,onError:te=>{C(te),f(re=>Math.max(re,p+1))}}),children:U[p]},`${t.cad_component_id}-fallback-${p}`)}else t.model_jscad?W=q.jsx(ZMo,{jscadPlan:t.model_jscad,positionOffset:O,rotationOffset:G,modelOffset:H.modelPosition,modelRotation:H.modelRotation,sourceCoordinateTransform:bie(TU(t,"jscad")),scale:H.scale,modelSize:H.size,modelFitMode:H.fitMode,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q},t.cad_component_id):t.footprinter_string&&(W=q.jsx(zMo,{positionOffset:O,rotationOffset:G,footprint:t.footprinter_string,scale:H.scale,onHover:c,onUnhover:l,isHovered:i,isTranslucent:Q}));if(B){if(s.enclosure==="hidden")return null}else if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(u&&!s.throughHoleModels||!u&&!s.smtModels)return null;return q.jsxs(q.Fragment,{children:[W,i&&a?q.jsx(e3t,{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]})},e6t={version:"0.0.592"},t6t="cadViewerLightingEnabled",Pwo=()=>typeof window>"u"?!0:window.localStorage.getItem(t6t)!=="false",n6t=Z.createContext(void 0),vwo=({children:t})=>{const[e,n]=Z.useState(!1),[o,i]=Z.useState(!1),[r,s]=Z.useState(Pwo);Z.useEffect(()=>{window.localStorage.setItem(t6t,r?"true":"false")},[r]);const a=Z.useMemo(()=>({darkBackgroundEnabled:e,setDarkBackgroundEnabled:n,gridEnabled:o,setGridEnabled:i,lightingEnabled:r,setLightingEnabled:s}),[e,o,r]);return q.jsx(n6t.Provider,{value:a,children:t})},Mwe=()=>{const t=Z.useContext(n6t);if(!t)throw new Error("useAppearance must be used within an AppearanceProvider");return t},o6t="cadViewerCameraStateSession",i6t=(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(o6t,JSON.stringify(n))}catch(n){console.warn("Failed to save camera:",n)}},wwe=(t,e)=>{try{const n=sessionStorage.getItem(o6t);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}},r6t=Z.createContext(void 0),Mwo=({children:t,defaultTarget:e,initialCameraPosition:n,initialCameraType:o})=>{const i=Z.useRef(null),r=Z.useRef(null),[s,a]=Z.useState(null),[A,c]=Z.useState(o??"perspective"),[l,g]=Z.useState(n??null),[u,h]=Z.useState(new TC(0,0,0)),d=Z.useMemo(()=>{const[f,I,C]=n??[5,-5,5],y=Math.hypot(f-e.x,I-e.y,C-e.z);return y>0?y:5},[n,e]),_=Z.useCallback(f=>{const I=[e.x,e.y,e.z],C=r.current,y=i.current;let E=d;switch(C&&y&&(E=C.position.distanceTo(y.target)),f){case"Top Center Angled":{const B=E/Math.sqrt(2);return{position:[e.x,e.y-B,e.z+B],target:I,up:[0,0,1]}}case"Top Down":return{position:[e.x,e.y,e.z+E],target:I,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-E*.6,e.y-E*.6,e.z+E*.6],target:I,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+E*.6,e.y-E*.6,e.z+E*.6],target:I,up:[0,0,1]};case"Left Sideview":return{position:[e.x-E,e.y,e.z],target:I,up:[0,0,1]};case"Right Sideview":return{position:[e.x+E,e.y,e.z],target:I,up:[0,0,1]};case"Front":return{position:[e.x,e.y-E,e.z],target:I,up:[0,0,1]};default:return null}},[d,e,r,i]),m=Z.useCallback(f=>{i.current=f},[]),p=Z.useMemo(()=>({controlsRef:i,mainCameraRef:r,defaultTarget:e,baseDistance:d,controller:s,setController:a,getPresetConfig:_,handleControlsChange:m,cameraType:A,setCameraType:c,cameraPosition:l,setCameraPosition:g,cameraRotation:u,setCameraRotation:h,saveCameraToSession:i6t,loadCameraFromSession:wwe}),[e,d,s,_,m,A,l,u]);return q.jsx(r6t.Provider,{value:p,children:t})},e5=()=>{const t=Z.useContext(r6t);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},wwo=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,Nwo=()=>{const{controlsRef:t,mainCameraRef:e,defaultTarget:n,setController:o,getPresetConfig:i}=e5(),r=Z.useRef(null),s=Z.useRef(new RC),a=Z.useRef(new Dt),A=Z.useRef(new Dt),c=Z.useRef(new RC),l=Z.useRef(new RC),g=Z.useRef(new Il),u=Z.useRef(new Il),h=Z.useCallback(({position:_,target:m,up:p,durationMs:f=600})=>{if(!e.current)return;const I=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=I.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(),O=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:O,rollTo:U,startTime:performance.now(),duration:f}},[e,t,n]),d=Z.useCallback(_=>{if(_==="Custom")return;const m=i(_);m&&h(m)},[h,i]);return Z.useEffect(()=>e.current?(o({animateTo:h,animateToPreset:d}),()=>{o(null)}):void 0,[h,d,e,o]),EU(()=>{if(!e.current||!r.current)return;const{fromPosition:_,toPosition:m,fromTarget:p,toTarget:f,toQuaternion:I,rollFrom:C,rollTo:y,startTime:E,duration:B}=r.current,Q=performance.now()-E,b=B<=0?1:Math.min(Q/B,1),D=wwo(b);e.current.position.lerpVectors(_,m,D);const R=a.current;R.copy(p).lerp(f,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 O=l.current;O.copy(y),C.dot(y)<0&&(O.x*=-1,O.y*=-1,O.z*=-1,O.w*=-1),O.normalize(),G.slerp(O,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(I),e.current.up.set(0,0,1),e.current.updateMatrixWorld(),t.current?.target.copy(f),t.current?.update(),r.current=null)}),null},Rwo=()=>{const{controlsRef:t}=e5(),e=Z.useRef(null),n=Z.useRef(!1),o=Z.useRef(null),i=Z.useCallback(s=>{e.current=s,!n.current&&t.current&&wwe(s,t.current)&&(n.current=!0)},[t]),r=Z.useCallback(()=>{if(!(!e.current||!t.current)){if(!n.current&&wwe(e.current,t.current)){n.current=!0;return}clearTimeout(o.current),o.current=setTimeout(()=>{e.current&&t.current&&i6t(e.current,t.current)},150)}},[t]);return{handleCameraCreated:i,handleControlsChange:r}};function Two(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var kwo=t=>{t.outputColorSpace=x2,t.toneMapping=yqe,t.toneMappingExposure=1,t.shadowMap.enabled=!0,t.shadowMap.type=pqe},Fwo=Z.forwardRef(({children:t,scene:e,camera:n,style:o,onCreated:i},r)=>{const{cameraType:s}=e5(),a=Z.useRef(null),[A,c]=Z.useState(null),l=Z.useRef([]),g=Z.useRef(void 0);g.current=i;const u=Z.useRef(null),h=Z.useCallback(p=>{l.current.push(p)},[]),d=Z.useCallback(p=>{l.current=l.current.filter(f=>f!==p)},[]),_=Z.useMemo(()=>new hw,[]);e?.up&&_.up.set(e.up.x,e.up.y,e.up.z);const m=Z.useRef(new Il);return Z.useImperativeHandle(r,()=>m.current),Z.useEffect(()=>{if(!a.current)return;Two(a.current);const p=new mj({antialias:!0,alpha:!0});kwo(p),p.setSize(a.current.clientWidth,a.current.clientHeight),p.setPixelRatio(window.devicePixelRatio),a.current.appendChild(p.domElement);const f=a.current.clientWidth/a.current.clientHeight,I=s==="perspective"?new um(75,f,.1,1e3):new r7(-10*f,10*f,10,-10,-1e3,1e3);u.current?(I.position.copy(u.current.position),I.quaternion.copy(u.current.quaternion),I.up.copy(u.current.up)):(n?.up&&I.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&I.position.set(n.position[0],n.position[1],n.position[2]),I.lookAt(0,0,0)),_.add(m.current),window.__TSCIRCUIT_THREE_OBJECT=m.current,c({scene:_,camera:I,renderer:p,rootObject:m.current,addFrameListener:h,removeFrameListener:d}),g.current?.({camera:I,renderer:p});let C;const y=new Qfn,E=()=>{const Q=y.getElapsedTime(),b=y.getDelta();l.current.forEach(D=>D(Q,b)),p.render(_,I),C=requestAnimationFrame(E)};E();const B=()=>{if(a.current){const Q=a.current.clientWidth/a.current.clientHeight;I instanceof um?I.aspect=Q:I instanceof r7&&(I.left=-10*Q,I.right=10*Q,I.top=10,I.bottom=-10),I.updateProjectionMatrix(),p.setSize(a.current.clientWidth,a.current.clientHeight)}};return window.addEventListener("resize",B),()=>{u.current={position:I.position.clone(),quaternion:I.quaternion.clone(),up:I.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)}},[_,h,d,s]),q.jsx("div",{ref:a,style:{width:"100%",height:"100%",...o},children:A&&q.jsx(Zwt.Provider,{value:A,children:q.jsx(UMo,{children:t})})})}),Lwo=`
5471
5471
  varying vec3 worldPosition;
5472
5472
  void main() {
5473
5473
  worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
@@ -5791,7 +5791,7 @@ test("${c} should solve problem correctly", () => {
5791
5791
  // Add more specific assertions based on expected output
5792
5792
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5793
5793
  })
5794
- `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),h=document.createElement("a");h.href=u,h.download=`${c}.test.ts`,h.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 q.jsxs("div",{className:`relative ${e}`,ref:i,children:[q.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&&q.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:[q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},WLt=t=>t.activeSubSolver?[t,...WLt(t.activeSubSolver)]:[t],IVo=({solver:t})=>{const e=WLt(t);return q.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>q.jsxs("div",{className:"flex items-center",children:[o>0&&q.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),q.jsx(pVo,{solver:n})]},n.constructor.name))})},fVo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=Z.useReducer(_=>!_,!1),a=Z.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)};Z.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),Z.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const h=t.getCurrentPhase!==void 0,d=h?t.getCurrentPhase():null;return q.jsxs("div",{className:"space-y-2 p-2 border-b",children:[q.jsx("div",{className:"flex items-center",children:q.jsx(IVo,{solver:t})}),q.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[q.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"}),q.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"}),q.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"}),q.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"}),h&&q.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"}),q.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),d&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",q.jsx("span",{className:"font-medium",children:d})]}),t.solved&&q.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&q.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&q.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},CVo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},yVo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=CVo(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],h=u?t.firstIterationOfPhase?.[u.solverName]:void 0;h!==void 0&&s!==null?A=h-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}},EVo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return q.jsx("span",{className:`font-medium ${e[t]}`,children:t})},xVo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:q.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),q.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},BVo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),QVo=({stats:t})=>{if(!t||Object.keys(t).length===0)return q.jsx("span",{children:"-"});const e=Object.entries(t),n=BVo(t);return q.jsxs("details",{className:"cursor-pointer",children:[q.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),q.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>q.jsxs("div",{children:[o,": ",String(i)]},o))})]})},d9e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(d9e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=d9e(o));return e},SVo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=d9e(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)}`)}},bVo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,A)=>yVo(t,A)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):SVo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return q.jsxs("div",{className:"border-t border-gray-200",children:[q.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:q.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),q.jsx("div",{className:"overflow-x-auto",children:q.jsxs("table",{className:"w-full text-sm",children:[q.jsx("thead",{children:q.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),q.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",q.jsx("sub",{children:"0"})]}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),q.jsx("tbody",{children:o.map(a=>q.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[q.jsx("td",{className:"px-4 py-2",children:q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),q.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:q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})})}),q.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(EVo,{status:a.status})}),q.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(xVo,{progress:a.progress})}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),q.jsx("td",{className:"px-4 py-2 text-gray-500",children:q.jsx(QVo,{stats:a.stats})}),q.jsx("td",{className:"px-4 py-2",children:a.solverInstance?q.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:[q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})}),q.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},DVo=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 PVo({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 f of p)l(f.x,f.y)}for(const m of o){const p=m.x??0,f=m.y??0,I=m.width??0,C=m.height??0;l(p,f),l(p+I,f+C)}for(const m of i){const p=m.x??0,f=m.y??0,I=m.radius??1;l(p-I,f-I),l(p+I,f+I)}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,h=a-g,d=Math.max(1,A-s+2*g),_=Math.max(1,c-a+2*g);return q.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${h} ${d} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,p)=>q.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)=>q.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(f=>`${f.x??0},${f.y??0}`).join(" ")},`line-${p}`)),i.map((m,p)=>q.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)=>q.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)=>q.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${p}`))]})}var vVo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=Z.useReducer(l=>l+1,0),s=Z.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=Z.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);Z.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const 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 q.jsxs("div",{children:[q.jsx(fVo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?q.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):q.jsx(DVo,{fallback:q.jsx(PVo,{graphics:s}),children:q.jsx(mVo,{graphics:s})}),A&&q.jsx(bVo,{solver:t,onStepUntilPhase:c})]})};const MVo=()=>{Z.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)},[])},wVo=1e3,JB=(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)},wVo)},h9e=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"},sb="https://github.com/tscircuit/tscircuit-autorouter/issues/new",jLt="https://github.com/tscircuit/copper-pour-solver/issues/new",XLt="https://github.com/tscircuit/calculate-packing/issues/new",NVo="https://github.com/tscircuit/matchpack/issues/new",$Lt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",RVo={PackSolver2:XLt,LayoutPipelineSolver:NVo,AutoroutingPipelineSolver:sb,AssignableAutoroutingPipeline2:sb,AssignableAutoroutingPipeline3:sb,AutoroutingPipeline1_OriginalUnravel:sb,AutoroutingPipelineSolver3_HgPortPointPathing:sb,AutoroutingPipelineSolver4:sb,AutoroutingPipelineSolver5:sb,AutoroutingPipelineSolver7_MultiGraph:sb,AutoroutingPipelineSolver8:sb,CopperPourPipelineSolver:jLt,SchematicTracePipelineSolver:$Lt},TVo=t=>t.toLowerCase().includes("pack")?aTo:t.toLowerCase().includes("rout")?_To:ZRo,ZLt=t=>{const e=RVo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?sb:n.includes("schematic")&&n.includes("trace")?$Lt:n.includes("copperpour")?jLt:n.includes("pack")?XLt:null},kVo=t=>`${h9e(`${t.componentName}-${t.solverName}`)}-solver-input.json`,eHt=t=>{JB(JSON.stringify(t.solverParams,null,2),{fileName:kVo(t),mimeType:"application/json"})},FVo=({solverEvent:t})=>{const e=ZLt(t.solverName);return q.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:[q.jsxs(qA,{type:"button",variant:"outline",size:"sm",onClick:()=>eHt(t),children:[q.jsx(Cre,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?q.jsx(qA,{asChild:!0,variant:"outline",size:"sm",children:q.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[q.jsx(pre,{className:"rf-w-4 rf-h-4"}),"Report"]})}):q.jsxs(qA,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[q.jsx(pre,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},LVo=({solverEvent:t})=>{const e=ZLt(t.solverName);return e?q.jsx(qA,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:q.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:q.jsx(pre,{className:"rf-w-4 rf-h-4"})})}):q.jsx(qA,{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:q.jsx(pre,{className:"rf-w-4 rf-h-4"})})},HVo=({solverEvents:t=[]})=>{const[e,n]=Z.useState(null);MVo();const o=Z.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=Z.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=Z.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=yBe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(yBe).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?q.jsx("div",{className:"rf-p-4",children:q.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:q.jsxs("div",{className:"rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),q.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."})]})})}):q.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[q.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[q.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 q.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=TVo(A.solverName);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[q.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),q.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),q.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?q.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[q.jsx(FVo,{solverEvent:r}),q.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:q.jsx(XS,{fallback:q.jsx("div",{className:"rf-p-4",children:q.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),q.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:q.jsx(vVo,{solver:s.instance})})})]}):q.jsxs("div",{className:"rf-p-4",children:[q.jsxs("div",{className:"rf-mb-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),q.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&q.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:q.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),q.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[q.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:[q.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx(LVo,{solverEvent:r}),q.jsx(qA,{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:()=>eHt(r),children:q.jsx(Cre,{className:"rf-w-4 rf-h-4"})})]})]}),q.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:q.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)})})]})]}):q.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},tHt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Z.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{G8.captureException(o)}catch{}}},[t,e]),Z.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{G8.captureException(i,{error_type:o.type})}catch{}}},[n])},GVo=t=>{Z.useEffect(()=>{try{Jqt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},nHt="0.0.2464",OVo={version:nHt},_9e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},m9e=new Map,kse=t=>{const e=m9e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},KVo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=m9e.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return m9e.set(n.name,i),{type:"tracked",store:t,...i}},oHt=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...A}=e;let c;try{c=(r??(_9e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(_9e?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=KVo(a,c,A);let u=!0;i.setState=(_,m,p)=>{const f=n(_,m);if(!u)return f;const I=p===void 0?{type:s||"anonymous"}:typeof p=="string"?{type:p}:p;return a===void 0?(l?.send(I,o()),f):(l?.send({...I,type:`${a}/${I.type}`},{...kse(A.name),[a]:i.getState()}),f)};const h=(..._)=>{const m=u;u=!1,n(..._),u=m},d=t(i.setState,o,i);if(g.type==="untracked"?l?.init(d):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([_,m])=>[_,_===g.store?d:m.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let _=!1;const m=i.dispatch;i.dispatch=(...p)=>{(_9e?"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 p9e(_.payload,p=>{if(p.type==="__setState"){if(a===void 0){h(p.state);return}Object.keys(p.state).length!==1&&console.error(`
5794
+ `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),h=document.createElement("a");h.href=u,h.download=`${c}.test.ts`,h.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 q.jsxs("div",{className:`relative ${e}`,ref:i,children:[q.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&&q.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:[q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},WLt=t=>t.activeSubSolver?[t,...WLt(t.activeSubSolver)]:[t],IVo=({solver:t})=>{const e=WLt(t);return q.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>q.jsxs("div",{className:"flex items-center",children:[o>0&&q.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),q.jsx(pVo,{solver:n})]},n.constructor.name))})},fVo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=Z.useReducer(_=>!_,!1),a=Z.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)};Z.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),Z.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const h=t.getCurrentPhase!==void 0,d=h?t.getCurrentPhase():null;return q.jsxs("div",{className:"space-y-2 p-2 border-b",children:[q.jsx("div",{className:"flex items-center",children:q.jsx(IVo,{solver:t})}),q.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[q.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"}),q.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"}),q.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"}),q.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"}),h&&q.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"}),q.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),d&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",q.jsx("span",{className:"font-medium",children:d})]}),t.solved&&q.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&q.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&q.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},CVo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},yVo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=CVo(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],h=u?t.firstIterationOfPhase?.[u.solverName]:void 0;h!==void 0&&s!==null?A=h-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}},EVo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return q.jsx("span",{className:`font-medium ${e[t]}`,children:t})},xVo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:q.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),q.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},BVo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),QVo=({stats:t})=>{if(!t||Object.keys(t).length===0)return q.jsx("span",{children:"-"});const e=Object.entries(t),n=BVo(t);return q.jsxs("details",{className:"cursor-pointer",children:[q.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),q.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>q.jsxs("div",{children:[o,": ",String(i)]},o))})]})},d9e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(d9e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=d9e(o));return e},SVo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=d9e(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)}`)}},bVo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,A)=>yVo(t,A)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):SVo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return q.jsxs("div",{className:"border-t border-gray-200",children:[q.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:q.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),q.jsx("div",{className:"overflow-x-auto",children:q.jsxs("table",{className:"w-full text-sm",children:[q.jsx("thead",{children:q.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),q.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",q.jsx("sub",{children:"0"})]}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),q.jsx("tbody",{children:o.map(a=>q.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[q.jsx("td",{className:"px-4 py-2",children:q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),q.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:q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})})}),q.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(EVo,{status:a.status})}),q.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(xVo,{progress:a.progress})}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),q.jsx("td",{className:"px-4 py-2 text-gray-500",children:q.jsx(QVo,{stats:a.stats})}),q.jsx("td",{className:"px-4 py-2",children:a.solverInstance?q.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:[q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})}),q.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},DVo=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 PVo({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 f of p)l(f.x,f.y)}for(const m of o){const p=m.x??0,f=m.y??0,I=m.width??0,C=m.height??0;l(p,f),l(p+I,f+C)}for(const m of i){const p=m.x??0,f=m.y??0,I=m.radius??1;l(p-I,f-I),l(p+I,f+I)}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,h=a-g,d=Math.max(1,A-s+2*g),_=Math.max(1,c-a+2*g);return q.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${h} ${d} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,p)=>q.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)=>q.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(f=>`${f.x??0},${f.y??0}`).join(" ")},`line-${p}`)),i.map((m,p)=>q.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)=>q.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)=>q.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${p}`))]})}var vVo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=Z.useReducer(l=>l+1,0),s=Z.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=Z.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);Z.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const 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 q.jsxs("div",{children:[q.jsx(fVo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?q.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):q.jsx(DVo,{fallback:q.jsx(PVo,{graphics:s}),children:q.jsx(mVo,{graphics:s})}),A&&q.jsx(bVo,{solver:t,onStepUntilPhase:c})]})};const MVo=()=>{Z.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)},[])},wVo=1e3,JB=(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)},wVo)},h9e=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"},sb="https://github.com/tscircuit/tscircuit-autorouter/issues/new",jLt="https://github.com/tscircuit/copper-pour-solver/issues/new",XLt="https://github.com/tscircuit/calculate-packing/issues/new",NVo="https://github.com/tscircuit/matchpack/issues/new",$Lt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",RVo={PackSolver2:XLt,LayoutPipelineSolver:NVo,AutoroutingPipelineSolver:sb,AssignableAutoroutingPipeline2:sb,AssignableAutoroutingPipeline3:sb,AutoroutingPipeline1_OriginalUnravel:sb,AutoroutingPipelineSolver3_HgPortPointPathing:sb,AutoroutingPipelineSolver4:sb,AutoroutingPipelineSolver5:sb,AutoroutingPipelineSolver7_MultiGraph:sb,AutoroutingPipelineSolver8:sb,CopperPourPipelineSolver:jLt,SchematicTracePipelineSolver:$Lt},TVo=t=>t.toLowerCase().includes("pack")?aTo:t.toLowerCase().includes("rout")?_To:ZRo,ZLt=t=>{const e=RVo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?sb:n.includes("schematic")&&n.includes("trace")?$Lt:n.includes("copperpour")?jLt:n.includes("pack")?XLt:null},kVo=t=>`${h9e(`${t.componentName}-${t.solverName}`)}-solver-input.json`,eHt=t=>{JB(JSON.stringify(t.solverParams,null,2),{fileName:kVo(t),mimeType:"application/json"})},FVo=({solverEvent:t})=>{const e=ZLt(t.solverName);return q.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:[q.jsxs(qA,{type:"button",variant:"outline",size:"sm",onClick:()=>eHt(t),children:[q.jsx(Cre,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?q.jsx(qA,{asChild:!0,variant:"outline",size:"sm",children:q.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[q.jsx(pre,{className:"rf-w-4 rf-h-4"}),"Report"]})}):q.jsxs(qA,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[q.jsx(pre,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},LVo=({solverEvent:t})=>{const e=ZLt(t.solverName);return e?q.jsx(qA,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:q.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:q.jsx(pre,{className:"rf-w-4 rf-h-4"})})}):q.jsx(qA,{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:q.jsx(pre,{className:"rf-w-4 rf-h-4"})})},HVo=({solverEvents:t=[]})=>{const[e,n]=Z.useState(null);MVo();const o=Z.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=Z.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=Z.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=yBe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(yBe).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?q.jsx("div",{className:"rf-p-4",children:q.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:q.jsxs("div",{className:"rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),q.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."})]})})}):q.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[q.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[q.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 q.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=TVo(A.solverName);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[q.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),q.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),q.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?q.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[q.jsx(FVo,{solverEvent:r}),q.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:q.jsx(XS,{fallback:q.jsx("div",{className:"rf-p-4",children:q.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),q.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:q.jsx(vVo,{solver:s.instance})})})]}):q.jsxs("div",{className:"rf-p-4",children:[q.jsxs("div",{className:"rf-mb-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),q.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&q.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:q.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),q.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[q.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:[q.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx(LVo,{solverEvent:r}),q.jsx(qA,{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:()=>eHt(r),children:q.jsx(Cre,{className:"rf-w-4 rf-h-4"})})]})]}),q.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:q.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)})})]})]}):q.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},tHt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Z.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{G8.captureException(o)}catch{}}},[t,e]),Z.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{G8.captureException(i,{error_type:o.type})}catch{}}},[n])},GVo=t=>{Z.useEffect(()=>{try{Jqt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},nHt="0.0.2466",OVo={version:nHt},_9e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},m9e=new Map,kse=t=>{const e=m9e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},KVo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=m9e.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return m9e.set(n.name,i),{type:"tracked",store:t,...i}},oHt=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...A}=e;let c;try{c=(r??(_9e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(_9e?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=KVo(a,c,A);let u=!0;i.setState=(_,m,p)=>{const f=n(_,m);if(!u)return f;const I=p===void 0?{type:s||"anonymous"}:typeof p=="string"?{type:p}:p;return a===void 0?(l?.send(I,o()),f):(l?.send({...I,type:`${a}/${I.type}`},{...kse(A.name),[a]:i.getState()}),f)};const h=(..._)=>{const m=u;u=!1,n(..._),u=m},d=t(i.setState,o,i);if(g.type==="untracked"?l?.init(d):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([_,m])=>[_,_===g.store?d:m.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let _=!1;const m=i.dispatch;i.dispatch=(...p)=>{(_9e?"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 p9e(_.payload,p=>{if(p.type==="__setState"){if(a===void 0){h(p.state);return}Object.keys(p.state).length!==1&&console.error(`
5795
5795
  [zustand devtools middleware] Unsupported __setState action format.
5796
5796
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5797
5797
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }