@tscircuit/runframe 0.0.1784 → 0.0.1785
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.
|
@@ -5149,7 +5149,7 @@ ${c.join(`
|
|
|
5149
5149
|
${m}polygon: ${f.polygon.vertices}
|
|
5150
5150
|
`:c+=`
|
|
5151
5151
|
`,f.children.length>0&&u.push(f.children)}return c}};e.exports=s}}),iun=tt({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,e){var n=eun(),r=run(),i=class{constructor(o){this.polygonTree=new r,this.rootnode=new n(null),o&&this.addPolygons(o)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(o,s=!1){this.rootnode.clipTo(o,s)}allPolygons(){const o=[];return this.polygonTree.getPolygons(o),o}addPolygons(o){const s=new Array(o.length);for(let a=0;a<o.length;a++)s[a]=this.polygonTree.addChild(o[a]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};e.exports=i}}),l0e=tt({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,e){e.exports={Tree:iun()}}}),oun=tt({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,e){var n=zo(),r=c0e(),{Tree:i}=l0e(),o=(s,a)=>{if(!r(s,a))return n.create();const c=new i(n.toPolygons(s)),l=new i(n.toPolygons(a));c.invert(),l.clipTo(c),l.invert(),c.clipTo(l),l.clipTo(c),c.addPolygons(l.allPolygons()),c.invert();const u=c.allPolygons();return n.create(u)};e.exports=o}}),pYe=tt({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,e){var n=yo(),r=UR(),i=oun(),o=(...s)=>{s=n(s);let a=s.shift();return s.forEach(c=>{a=i(a,c)}),a=r(a),a};e.exports=o}}),sun=tt({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,e){var n=yo(),r=zo(),i=i9(),o=s0e(),s=a0e(),a=pYe(),c=(...l)=>{l=n(l);const u=l.map(p=>s({z0:-1,z1:1},p)),d=a(u),h=i(d);return o(h,r.toPolygons(d))};e.exports=c}}),aun=tt({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,e){var n=yo(),r=jR(),i=jo(),o=zo(),s=sun(),a=pYe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!r(l))throw new Error("only intersect of the types are supported");const u=l[0];return i.isA(u)?s(l):o.isA(u)?a(l):u};e.exports=c}}),u0e=tt({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,e){var n=Ns(),r=_Ve(),i=o=>r(o,{skipTriangulation:!0}).map(c=>{const l=c.map(u=>o[u]);return n.create(l)});e.exports=i}}),fYe=tt({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,e){var n=zo(),r=c0e(),{Tree:i}=l0e(),o=(a,c)=>{if(!r(a,c))return s(a,c);const l=new i(n.toPolygons(a)),u=new i(n.toPolygons(c));l.clipTo(u,!1),u.clipTo(l),u.invert(),u.clipTo(l),u.invert();const d=l.allPolygons().concat(u.allPolygons());return n.create(d)},s=(a,c)=>{let l=n.toPolygons(a);return l=l.concat(n.toPolygons(c)),n.create(l)};e.exports=o}}),d0e=tt({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,e){var n=yo(),r=UR(),i=fYe(),o=(...s)=>{s=n(s);let a;for(a=1;a<s.length;a+=2)s.push(i(s[a-1],s[a]));let c=s[a-1];return c=r(c),c};e.exports=o}}),mYe=tt({"node_modules/@jscad/modeling/src/operations/minkowski/minkowskiSum.js"(t,e){var n=yo(),r=zo(),i=Ns(),o=u0e(),s=d0e(),a=(...p)=>{if(p=n(p),p.length!==2)throw new Error("minkowskiSum requires exactly two geometries");const[f,m]=p;if(!r.isA(f)||!r.isA(m))throw new Error("minkowskiSum requires geom3 geometries");const y=r.isConvex(f),g=r.isConvex(m);if(y&&g)return d(f,m);if(!y&&g)return c(f,m);if(y&&!g)return c(m,f);throw new Error("minkowskiSum of two non-convex geometries is not yet supported")},c=(p,f)=>{const m=l(p);if(m.length===0)return r.create();const y=m.map(g=>d(g,f));return y.length===1?y[0]:s(y)},l=p=>{const f=r.toPolygons(p);if(f.length===0)return[];const m=[];for(let y=0;y<f.length;y++){const g=f[y],_=g.vertices;let b=0,v=0,T=0;for(let I=0;I<_.length;I++)b+=_[I][0],v+=_[I][1],T+=_[I][2];b/=_.length,v/=_.length,T/=_.length;const E=i.plane(g),A=E[0],P=E[1],N=E[2],C=.1,D=[b-A*C,v-P*C,T-N*C];for(let I=1;I<_.length-1;I++){const B=_[0],U=_[I],H=_[I+1],X=u(D,B,U,H);m.push(r.create(X))}}return m},u=(p,f,m,y)=>[i.create([p,m,f]),i.create([p,f,y]),i.create([f,m,y]),i.create([m,p,y])],d=(p,f)=>{const m=h(p),y=h(f);if(m.length===0||y.length===0)return r.create();const g=[];for(let b=0;b<m.length;b++){const v=m[b];for(let T=0;T<y.length;T++){const E=y[T];g.push([v[0]+E[0],v[1]+E[1],v[2]+E[2]])}}const _=o(g);return r.create(_)},h=p=>{const f=new Set,m=[],y=r.toPolygons(p);for(let g=0;g<y.length;g++){const _=y[g].vertices;for(let b=0;b<_.length;b++){const v=_[b],T=`${v[0]},${v[1]},${v[2]}`;f.has(T)||(f.add(T),m.push(v))}}return m};e.exports=a}}),cun=tt({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,e){var n=yi(),r=i9(),i=zo(),o=l=>l.sort((u,d)=>u-d).filter((u,d,h)=>!d||u!==h[d-1]),s=(l,u,d)=>{const h=`${u}`,p=l.get(h);p===void 0?l.set(h,[d]):p.push(d)},a=(l,u)=>{const d=`${u}`;return l.get(d)},c=l=>{const u=r(l),d=i.toPolygons(l),h=d.length,p=new Map,f=n.create();d.forEach((b,v)=>{b.vertices.forEach(T=>{s(p,n.snap(f,T,u),v)})});const m=d.map(b=>{let v=[];return b.vertices.forEach(T=>{v=v.concat(a(p,n.snap(f,T,u)))}),{e:1,d:o(v)}});p.clear();let y=0;const g=m.length;for(let b=0;b<g;b++){const v=m[b];if(v.e>0){const T=new Array(h);T[b]=!0;do y=0,T.forEach((E,A)=>{const P=m[A];if(P.e>0){P.e=-1;for(let N=0;N<P.d.length;N++)T[P.d[N]]=!0;y++}});while(y>0);v.indexes=T}}const _=[];for(let b=0;b<g;b++)if(m[b].indexes){const v=[];m[b].indexes.forEach((T,E)=>v.push(d[E])),_.push(i.create(v))}return _};e.exports=c}}),lun=tt({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,e){var n=yo(),r=zo(),i=cun(),o=(...s)=>{if(s=n(s),s.length===0)throw new Error("wrong number of arguments");const a=s.map(c=>r.isA(c)?i(c):c);return a.length===1?a[0]:a};e.exports=o}}),uun=tt({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,e){var n=zo(),r=c0e(),{Tree:i}=l0e(),o=(s,a)=>{if(!r(s,a))return n.clone(s);const c=new i(n.toPolygons(s)),l=new i(n.toPolygons(a));c.invert(),c.clipTo(l),l.clipTo(c,!0),c.addPolygons(l.allPolygons()),c.invert();const u=c.allPolygons();return n.create(u)};e.exports=o}}),yYe=tt({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,e){var n=yo(),r=UR(),i=uun(),o=(...s)=>{s=n(s);let a=s.shift();return s.forEach(c=>{a=i(a,c)}),a=r(a),a};e.exports=o}}),dun=tt({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,e){var n=yo(),r=zo(),i=i9(),o=s0e(),s=a0e(),a=yYe(),c=(...l)=>{l=n(l);const u=l.map(p=>s({z0:-1,z1:1},p)),d=a(u),h=i(d);return o(h,r.toPolygons(d))};e.exports=c}}),hun=tt({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,e){var n=yo(),r=jR(),i=jo(),o=zo(),s=dun(),a=yYe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!r(l))throw new Error("only subtract of the types are supported");const u=l[0];return i.isA(u)?s(l):o.isA(u)?a(l):u};e.exports=c}}),gYe=tt({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,e){var n=yo(),r=zo(),i=i9(),o=s0e(),s=a0e(),a=d0e(),c=(...l)=>{l=n(l);const u=l.map(p=>s({z0:-1,z1:1},p)),d=a(u),h=i(d);return o(h,r.toPolygons(d))};e.exports=c}}),h0e=tt({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,e){var n=yo(),r=jR(),i=jo(),o=zo(),s=gYe(),a=d0e(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!r(l))throw new Error("only unions of the same type are supported");const u=l[0];return i.isA(u)?s(l):o.isA(u)?a(l):u};e.exports=c}}),HR=tt({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,e){e.exports={intersect:aun(),minkowski:mYe(),scission:lun(),subtract:hun(),union:h0e()}}}),Kj=tt({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,e){var{EPS:n,TAU:r}=Ys(),i=XVe(),o=t0e(),s=as(),a=Gj(),c=(l,u)=>{const d={delta:1,corners:"edge",closed:!1,segments:16};let{delta:h,corners:p,closed:f,segments:m}=Object.assign({},d,l);if(Math.abs(h)<n)return u;let y=l.closed?a(u):1;y===0&&(y=1);const g=y>0&&h>=0||y<0&&h<0;h=Math.abs(h);let _=null,b=[];const v=[],T=s.create(),E=u.length;for(let A=0;A<E;A++){const P=(A+1)%E,N=u[A],C=u[P];g?s.subtract(T,N,C):s.subtract(T,C,N),s.normal(T,T),s.normalize(T,T),s.scale(T,T,h);const D=s.add(s.create(),N,T),I=s.add(s.create(),C,T),B=[D,I];if(_!=null&&(f||!f&&P!==0)){const U=i(_[0],_[1],B[0],B[1]);U?(b.pop(),B[0]=U):v.push({c:N,s0:_,s1:B})}_=[D,I],!(P===0&&!f)&&(b.push(B[0]),b.push(B[1]))}if(f&&_!=null){const A=b[0],P=b[1],N=i(_[0],_[1],A,P);if(N)b[0]=N,b.pop();else{const C=u[0],D=[A,P];v.push({c:C,s0:_,s1:D})}}if(p==="edge"){const A=new Map;b.forEach((C,D)=>A.set(C,D));const P=o.create(),N=o.create();v.forEach(C=>{o.fromPoints(P,C.s0[0],C.s0[1]),o.fromPoints(N,C.s1[0],C.s1[1]);const D=o.intersectPointOfLines(P,N);if(Number.isFinite(D[0])&&Number.isFinite(D[1])){const I=C.s0[1],B=A.get(I);b[B]=D,b[(B+1)%b.length]=void 0}else{const I=C.s1[0],B=A.get(I);b[B]=void 0}}),b=b.filter(C=>C!==void 0)}if(p==="round"){let A=Math.floor(m/4);const P=s.create();v.forEach(N=>{let C=s.angle(s.subtract(P,N.s1[0],N.c));if(C-=s.angle(s.subtract(P,N.s0[1],N.c)),g&&C<0&&(C=C+Math.PI,C<0&&(C=C+Math.PI)),!g&&C>0&&(C=C-Math.PI,C>0&&(C=C-Math.PI)),C!==0){A=Math.floor(m*(Math.abs(C)/r));const D=C/A,I=s.angle(s.subtract(P,N.s0[1],N.c)),B=[];for(let U=1;U<A;U++){const H=I+D*U,X=s.fromAngleRadians(s.create(),H);s.scale(X,X,h),s.add(X,X,N.c),B.push(X)}if(B.length>0){const U=N.s0[1];let H=b.findIndex(X=>s.equals(U,X));H=(H+1)%b.length,b.splice(H,0,...B)}}else{const D=N.s1[0],I=b.findIndex(B=>s.equals(D,B));b.splice(I,1)}})}return b};e.exports=c}}),pun=tt({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,e){var n=jo(),r=Kj(),i=(o,s)=>{const a={delta:1,corners:"edge",segments:16},{delta:c,corners:l,segments:u}=Object.assign({},a,o);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const p=n.toOutlines(s).map(f=>(o={delta:c,corners:l,closed:!0,segments:u},r(o,f))).reduce((f,m)=>f.concat(n.toSides(n.fromPoints(m))),[]);return n.create(p)};e.exports=i}}),fun=tt({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,e){var n=xl(),r=yi(),i=zo(),o=Ns(),s=(a,c)=>{r.dot(o.plane(c),a)>0&&(c=o.invert(c));const u=[c],d=o.transform(n.fromTranslation(n.create(),a),c),h=c.vertices.length;for(let p=0;p<h;p++){const f=p<h-1?p+1:0,m=o.create([c.vertices[p],d.vertices[p],d.vertices[f],c.vertices[f]]);u.push(m)}return u.push(o.invert(d)),i.create(u)};e.exports=s}}),mun=tt({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,e){var{EPS:n,TAU:r}=Ys(),i=xl(),o=yi(),s=dYe(),a=zo(),c=Ns(),l=iYe(),u=UR(),d=fYe(),h=fun(),p=(g,_,b)=>{const v=_.toString();if(g.has(v))g.get(v)[1].push(b);else{const T=[_,[b]];g.set(v,T)}},f=(g,_,b)=>{const v=_[0].toString(),T=_[1].toString(),E=v<T?`${v},${T}`:`${T},${v}`;if(g.has(E))g.get(E)[1].push(b);else{const A=[_,[b]];g.set(E,A)}},m=(g,_)=>{g.findIndex(v=>v===_)<0&&g.push(_)},y=(g,_)=>{const b={delta:1,segments:12},{delta:v,segments:T}=Object.assign({},b,g);let E=a.create();const A=new Map,P=new Map,N=o.create(),C=o.create();return a.toPolygons(_).forEach((I,B)=>{const U=o.scale(o.create(),c.plane(I),2*v),H=c.transform(i.fromTranslation(i.create(),o.scale(o.create(),U,-.5)),I),X=h(U,H);E=d(E,X);const W=I.vertices;for(let ee=0;ee<W.length;ee++){p(A,W[ee],c.plane(I));const re=(ee+1)%W.length,pe=[W[ee],W[re]];f(P,pe,c.plane(I))}}),P.forEach(I=>{const B=I[0],U=I[1],H=B[0],X=B[1],W=o.subtract(o.create(),X,H);o.normalize(W,W);const ee=U[0],re=o.cross(o.create(),ee,W);let pe=[];for(let Be=0;Be<T;Be++)m(pe,Be*r/T);for(let Be=0,_e=U.length;Be<_e;Be++){const Me=U[Be],ye=o.dot(re,Me),je=o.dot(ee,Me);let Ye=Math.atan2(ye,je);Ye<0&&(Ye+=r),m(pe,Ye),Ye=Math.atan2(-ye,-je),Ye<0&&(Ye+=r),m(pe,Ye)}pe=pe.sort(s);const ie=pe.length;let ae,de;const he=[],ve=[],Ae=[];for(let Be=-1;Be<ie;Be++){const _e=pe[Be<0?Be+ie:Be],Me=Math.sin(_e),ye=Math.cos(_e);o.scale(N,ee,ye*v),o.scale(C,re,Me*v),o.add(N,N,C);const je=o.add(o.create(),H,N),Ye=o.add(o.create(),X,N);let it=!1;if(Be>=0&&o.distance(je,ae)<n&&(it=!0),!it){if(Be>=0){he.push(je),ve.push(Ye);const be=[de,Ye,je,ae],rt=c.create(be);Ae.push(rt)}ae=je,de=Ye}}ve.reverse(),Ae.push(c.create(he)),Ae.push(c.create(ve));const Ce=a.create(Ae);E=d(E,Ce)}),A.forEach(I=>{const B=I[0],U=I[1],H=U[0];let X=null,W=0;for(let ie=1;ie<U.length;ie++){const ae=U[ie],de=o.cross(N,H,ae),he=o.length(de);he>.05&&he>W&&(W=he,X=ae)}X||(X=o.orthogonal(N,H));const ee=o.cross(N,H,X);o.normalize(ee,ee);const re=o.cross(C,ee,H),pe=l({center:[B[0],B[1],B[2]],radius:v,segments:T,axes:[H,ee,re]});E=d(E,pe)}),u(E)};e.exports=y}}),yun=tt({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,e){var n=zo(),r=h0e(),i=mun(),o=(s,a)=>{const c={delta:1,corners:"round",segments:12},{delta:l,corners:u,segments:d}=Object.assign({},c,s);if(u!=="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:l,corners:u,segments:d};const p=i(s,a);return r(a,p)};e.exports=o}}),gun=tt({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,e){var n=Gj(),r=as(),i=jo(),o=el(),s=Kj(),a=u=>{let{external:d,internal:h}=u;n(d)<0?d=d.reverse():h=h.reverse();const p=o.fromPoints({closed:!0},d),f=o.fromPoints({closed:!0},h),m=i.toSides(i.fromPoints(o.toPoints(p))),y=i.toSides(i.fromPoints(o.toPoints(f)));return m.push(...y),i.create(m)},c=(u,d,h,p)=>{const{points:f,external:m,internal:y}=u,g=Math.floor(d/2),_=[],b=[];if(h==="round"&&g>0){const T=Math.PI/g,E=f[f.length-1],A=r.angle(r.subtract(r.create(),m[m.length-1],E)),P=f[0],N=r.angle(r.subtract(r.create(),y[0],P));for(let C=1;C<g;C++){let D=A+T*C,I=r.fromAngleRadians(r.create(),D);r.scale(I,I,p),r.add(I,I,E),_.push(I),D=N+T*C,I=r.fromAngleRadians(r.create(),D),r.scale(I,I,p),r.add(I,I,P),b.push(I)}}const v=[];return v.push(...m,..._,...y.reverse(),...b),i.fromPoints(v)},l=(u,d)=>{u=Object.assign({},{delta:1,corners:"edge",segments:16},u);const{delta:p,corners:f,segments:m}=u;if(p<=0)throw new Error("the given delta must be positive for paths");if(!(f==="edge"||f==="chamfer"||f==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const y=d.isClosed,g=o.toPoints(d);if(g.length===0)throw new Error("the given geometry cannot be empty");const _={points:g,external:s({delta:p,corners:f,segments:m,closed:y},g),internal:s({delta:-p,corners:f,segments:m,closed:y},g)};return d.isClosed?a(_):c(_,m,f,p)};e.exports=l}}),p0e=tt({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,e){var n=yo(),r=jo(),i=zo(),o=el(),s=pun(),a=yun(),c=gun(),l=(u,...d)=>{if(d=n(d),d.length===0)throw new Error("wrong number of arguments");const h=d.map(p=>o.isA(p)?c(u,p):r.isA(p)?s(u,p):i.isA(p)?a(u,p):p);return h.length===1?h[0]:h};e.exports=l}}),_un=tt({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,e){var n=jo(),r=Khe(),i=Kj(),o=(s,a)=>{const c={delta:1,corners:"edge",segments:0},{delta:l,corners:u,segments:d}=Object.assign({},c,s);if(!(u==="edge"||u==="chamfer"||u==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const h=n.toOutlines(a),f=h.map(m=>(s={delta:h.reduce((_,b)=>_+r.arePointsInside(m,r.create(b)),0)%2===0?l:-l,corners:u,closed:!0,segments:d},i(s,m))).reduce((m,y)=>m.concat(n.toSides(n.fromPoints(y))),[]);return n.create(f)};e.exports=o}}),xun=tt({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,e){var n=el(),r=Kj(),i=(o,s)=>{const a={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:c,corners:l,closed:u,segments:d}=Object.assign({},a,o);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');o={delta:c,corners:l,closed:u,segments:d};const h=r(o,n.toPoints(s));return n.fromPoints({closed:u},h)};e.exports=i}}),bun=tt({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,e){var n=yo(),r=jo(),i=el(),o=_un(),s=xun(),a=(c,...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");const u=l.map(d=>i.isA(d)?s(c,d):r.isA(d)?o(c,d):d);return u.length===1?u[0]:u};e.exports=a}}),_Ye=tt({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,e){e.exports={expand:p0e(),offset:bun()}}}),Zj=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,e){var n=xl(),r=yi(),i=jo(),o=GM(),s=Wj(),a=(c,l)=>{const u={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:d,twistAngle:h,twistSteps:p,repair:f}=Object.assign({},u,c);if(p<1)throw new Error("twistSteps must be 1 or more");h===0&&(p=1);const m=r.clone(d),y=i.toSides(l);if(y.length===0)throw new Error("the given geometry cannot be empty");const g=o.fromSides(y);m[2]<0&&o.reverse(g,g);const _=n.create(),b=(v,T,E)=>{const A=T/p*h,P=r.scale(r.create(),m,T/p);return n.multiply(_,n.fromZRotation(_,A),n.fromTranslation(n.create(),P)),o.transform(_,E)};return c={numberOfSlices:p+1,capStart:!0,capEnd:!0,repair:f,callback:b},s(c,g)};e.exports=a}}),vun=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,e){var n=jo(),r=el(),i=Zj(),o=(s,a)=>{if(!a.isClosed)throw new Error("extruded path must be closed");const c=r.toPoints(a),l=n.fromPoints(c);return i(s,l)};e.exports=o}}),wun=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,e){var n=yo(),r=jo(),i=el(),o=Zj(),s=vun(),a=(c,...l)=>{const u={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:d,twistAngle:h,twistSteps:p,repair:f}=Object.assign({},u,c);if(l=n(l),l.length===0)throw new Error("wrong number of arguments");c={offset:[0,0,d],twistAngle:h,twistSteps:p,repair:f};const m=l.map(y=>i.isA(y)?s(c,y):r.isA(y)?o(c,y):y);return m.length===1?m[0]:m};e.exports=a}}),Sun=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,e){var n=el(),r=p0e(),i=Zj(),o=(s,a)=>{const c={size:1,height:1},{size:l,height:u}=Object.assign({},c,s);if(s.delta=l,s.offset=[0,0,u],n.toPoints(a).length===0)throw new Error("the given geometry cannot be empty");const h=r(s,a);return i(s,h)};e.exports=o}}),Eun=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,e){var{area:n}=zR(),r=jo(),i=el(),o=p0e(),s=Zj(),a=(c,l)=>{const u={size:1,height:1},{size:d,height:h}=Object.assign({},u,c);c.delta=d,c.offset=[0,0,h];const p=r.toOutlines(l);if(p.length===0)throw new Error("the given geometry cannot be empty");const m=p.map(g=>(n(g)<0&&g.reverse(),o(c,i.fromPoints({closed:!0},g)))).reduce((g,_)=>g.concat(r.toSides(_)),[]),y=r.create(m);return s(c,y)};e.exports=a}}),Mun=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,e){var n=yo(),r=jo(),i=el(),o=Sun(),s=Eun(),a=(c,...l)=>{const u={size:1,height:1},{size:d,height:h}=Object.assign({},u,c);if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(d<=0)throw new Error("size must be positive");if(h<=0)throw new Error("height must be positive");const p=l.map(f=>i.isA(f)?o(c,f):r.isA(f)?s(c,f):f);return p.length===1?p[0]:p};e.exports=a}}),Tun=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,e){var{TAU:n}=Ys(),r=xl(),i=jo(),o=Wj(),s=GM(),a=(c,l)=>{const u={angle:n,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:d,startAngle:h,pitch:p,height:f,endOffset:m,segmentsPerRotation:y}=Object.assign({},u,c);if(f!=0&&(p=f/(d/n)),y<3)throw new Error("The number of segments per rotation needs to be at least 3.");const _=i.toSides(l);if(_.length===0)throw new Error("The given geometry cannot be empty");const b=_.filter(C=>C[0][0]>=0);let v=s.fromSides(_);b.length===0&&(v=s.reverse(v));const T=Math.round(y/n*Math.abs(d)),E=T>=2?T:2,A=r.create(),P=r.create(),N=(C,D,I)=>{const B=h+d/E*D,U=m/E*D,H=(B-h)/n*p;return r.multiply(A,r.fromTranslation(r.create(),[U,0,H*Math.sign(d)]),r.fromXRotation(r.create(),-n/4*Math.sign(d))),r.multiply(P,r.fromZRotation(r.create(),B),A),s.transform(P,I)};return o({numberOfSlices:E+1,callback:N},v)};e.exports=a}}),Cun=tt({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,e){var n=yo(),r=e0e(),i=J3(),o=xl(),s=jo(),a=zo(),c=Ns(),l=i9(),u=gYe(),d=(p,f)=>{const m=i.fromNormalAndPoint(i.create(),p.axis,p.origin);if(Number.isNaN(m[0])||Number.isNaN(m[1])||Number.isNaN(m[2])||Number.isNaN(m[3]))throw new Error("project: invalid axis or origin");const y=l(f),g=y*y*Math.sqrt(3)/4;if(y===0)return s.create();const _=a.toPolygons(f);let b=[];for(let T=0;T<_.length;T++){const E=_[T].vertices.map(N=>i.projectionOfPoint(m,N)),A=c.create(E),P=c.plane(A);r(m,P)&&(c.measureArea(A)<g||b.push(A))}if(!r(m,[0,0,1])){const T=o.fromVectorRotation(o.create(),m,[0,0,1]);b=b.map(E=>c.transform(T,E))}b=b.sort((T,E)=>c.measureArea(E)-c.measureArea(T));const v=b.map(T=>s.fromPoints(T.vertices));return u(v)},h=(p,...f)=>{const m={axis:[0,0,1],origin:[0,0,0]},{axis:y,origin:g}=Object.assign({},m,p);if(f=n(f),f.length===0)throw new Error("wrong number of arguments");p={axis:y,origin:g};const _=f.map(b=>a.isA(b)?d(p,b):b);return _.length===1?_[0]:_};e.exports=h}}),VR=tt({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,e){e.exports={extrudeFromSlices:Wj(),extrudeLinear:wun(),extrudeRectangular:Mun(),extrudeRotate:cYe(),extrudeHelical:Tun(),project:Cun(),slice:GM()}}}),f0e=tt({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,e){var n=as(),r=s=>{let a=n.fromValues(1/0,1/0);s.forEach(u=>{(u[1]<a[1]||u[1]===a[1]&&u[0]<a[0])&&(a=u)});const c=[];s.forEach(u=>{const d=o(u[1]-a[1],u[0]-a[0]),h=n.squaredDistance(u,a);c.push({point:u,angle:d,distSq:h})}),c.sort((u,d)=>u.angle!==d.angle?u.angle-d.angle:u.distSq-d.distSq);const l=[];return c.forEach(u=>{let d=l.length;for(;d>1&&i(l[d-2],l[d-1],u.point)<=Number.EPSILON;)l.pop(),d=l.length;l.push(u.point)}),l},i=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),o=(s,a)=>s===0&&a===0?-1/0:-a/s;e.exports=r}}),m0e=tt({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,e){var n=jo(),r=zo(),i=el(),o=s=>{const a=new Set,c=[],l=u=>{const d=u.toString();a.has(d)||(c.push(u),a.add(d))};return s.forEach(u=>{n.isA(u)?n.toPoints(u).forEach(l):r.isA(u)?r.toPoints(u).forEach(d=>d.forEach(l)):i.isA(u)&&i.toPoints(u).forEach(l)}),c};e.exports=o}}),Pun=tt({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,e){var n=yo(),r=el(),i=f0e(),o=m0e(),s=(...a)=>{a=n(a);const c=o(a),l=i(c);return r.fromPoints({closed:!0},l)};e.exports=s}}),Aun=tt({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,e){var n=yo(),r=jo(),i=f0e(),o=m0e(),s=(...a)=>{a=n(a);const c=o(a),l=i(c);return l.length<3?r.create():r.fromPoints(l)};e.exports=s}}),Run=tt({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,e){var n=yo(),r=zo(),i=m0e(),o=u0e(),s=(...a)=>{a=n(a);const c=i(a);return c.length===0?r.create():r.create(o(c))};e.exports=s}}),xYe=tt({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,e){var n=yo(),r=jR(),i=jo(),o=zo(),s=el(),a=Pun(),c=Aun(),l=Run(),u=(...d)=>{if(d=n(d),d.length===0)throw new Error("wrong number of arguments");if(!r(d))throw new Error("only hulls of the same type are supported");const h=d[0];return s.isA(h)?a(d):i.isA(h)?c(d):o.isA(h)?l(d):h};e.exports=u}}),Nun=tt({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,e){var n=yo(),r=h0e(),i=xYe(),o=(...s)=>{if(s=n(s),s.length<2)throw new Error("wrong number of arguments");const a=[];for(let c=1;c<s.length;c++)a.push(i(s[c-1],s[c]));return r(a)};e.exports=o}}),kun=tt({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,e){e.exports={hull:xYe(),hullChain:Nun(),hullPoints2:f0e(),hullPoints3:u0e()}}}),Oun=tt({"node_modules/@jscad/modeling/src/operations/minkowski/index.js"(t,e){e.exports={minkowskiSum:mYe()}}}),bYe=tt({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,e){var n=yi(),r=Ns(),i=(s,a)=>{const c=Math.abs(r.measureArea(a));return Number.isFinite(c)&&c>s},o=(s,a)=>{let c=a.map(u=>{const d=u.vertices.map(f=>n.snap(n.create(),f,s)),h=[];for(let f=0;f<d.length;f++){const m=(f+1)%d.length;n.equals(d[f],d[m])||h.push(d[f])}const p=r.create(h);return u.color&&(p.color=u.color),p});const l=s*s*Math.sqrt(3)/4;return c=c.filter(u=>i(l,u)),c};e.exports=o}}),Iun=tt({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,e){var n=e0e(),r=yi(),i=Ns(),o=g=>{const _=i.toPoints(g),b=[];for(let v=0;v<_.length;v++){const T=(v+1)%_.length,E={v1:_[v],v2:_[T]};b.push(E)}for(let v=0;v<b.length;v++){const T=(v+1)%_.length;b[v].next=b[T],b[T].prev=b[v]}return b},s=(g,_)=>{const b=`${_.v1}:${_.v2}`;g.set(b,_)},a=(g,_)=>{const b=`${_.v1}:${_.v2}`;g.delete(b)},c=(g,_)=>{const b=`${_.v2}:${_.v1}`;return g.get(b)},l=(g,_,b)=>{let v=g.prev.v1,T=g.prev.v2,E=_.next.v2;const A=h(v,T,E,b);v=_.prev.v1,T=_.prev.v2,E=g.next.v2;const P=h(v,T,E,b);return[A,P]},u=r.create(),d=r.create(),h=(g,_,b,v)=>{const T=r.subtract(u,_,g),E=r.subtract(d,b,_);return r.cross(T,T,E),r.dot(T,v)},p=g=>{let _;const b=[];for(;g.next;){const v=g.next;b.push(g.v1),g.v1=null,g.v2=null,g.next=null,g.prev=null,g=v}return b.length>0&&(_=i.create(b)),_},f=g=>{if(g.length<2)return g;const _=g[0].plane,b=g.slice(),v=new Map;for(;b.length>0;){const E=b.shift(),A=o(E);for(let P=0;P<A.length;P++){const N=A[P],C=c(v,N);if(C){const D=l(N,C,_);if(D[0]>=0&&D[1]>=0){const I=C.next,B=N.next;N.prev.next=C.next,N.next.prev=C.prev,C.prev.next=N.next,C.next.prev=N.prev,N.v1=null,N.v2=null,N.next=null,N.prev=null,a(v,C),C.v1=null,C.v2=null,C.next=null,C.prev=null;const U=(H,X,W)=>{const ee={v1:W.v1,v2:X.v2,next:X.next,prev:W.prev};W.prev.next=ee,X.next.prev=ee,a(H,X),X.v1=null,X.v2=null,X.next=null,X.prev=null,a(H,W),W.v1=null,W.v2=null,W.next=null,W.prev=null};D[0]===0&&U(v,I,I.prev),D[1]===0&&U(v,B,B.prev)}}else N.next&&s(v,N)}}const T=[];return v.forEach(E=>{const A=p(E);A&&T.push(A)}),v.clear(),T},m=(g,_)=>Math.abs(g[3]-_[3])<15e-8?n(g,_):!1,y=(g,_)=>{const b=[];_.forEach(T=>{const E=b.find(A=>m(A[0],i.plane(T)));E?E[1].push(T):b.push([i.plane(T),[T]])});let v=[];return b.forEach(T=>{const E=T[1],A=f(E);v=v.concat(A)}),v};e.exports=y}}),Lun=tt({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,e){var n=Ys(),r=yi(),i=Ns(),o=l=>`${l}`,s=(l,u,d,h,p,f)=>{const m=o(h),y=o(p),g=`${m}/${y}`,_=`${y}/${m}`;if(l.has(_))return a(l,u,d,p,h,null),null;const b={vertex0:h,vertex1:p,polygonindex:f};return l.has(g)?l.get(g).push(b):l.set(g,[b]),u.has(m)?u.get(m).push(g):u.set(m,[g]),d.has(y)?d.get(y).push(g):d.set(y,[g]),g},a=(l,u,d,h,p,f)=>{const m=o(h),y=o(p),g=`${m}/${y}`;let _=-1;const b=l.get(g);for(let v=0;v<b.length;v++){const T=b[v];let E=o(T.vertex0);if(E===m&&(E=o(T.vertex1),E===y&&!(f!==null&&T.polygonindex!==f))){_=v;break}}b.splice(_,1),b.length===0&&l.delete(g),_=u.get(m).indexOf(g),u.get(m).splice(_,1),u.get(m).length===0&&u.delete(m),_=d.get(y).indexOf(g),d.get(y).splice(_,1),d.get(y).length===0&&d.delete(y)},c=l=>{const u=new Map;for(let d=0;d<l.length;d++){const h=l[d],p=h.vertices.length;if(p>=3){let f=h.vertices[0],m=o(f);for(let y=0;y<p;y++){let g=y+1;g===p&&(g=0);const _=h.vertices[g],b=o(_),v=`${m}/${b}`,T=`${b}/${m}`;if(u.has(T)){const E=u.get(T);E.splice(-1,1),E.length===0&&u.delete(T)}else{const E={vertex0:f,vertex1:_,polygonindex:d};u.has(v)?u.get(v).push(E):u.set(v,[E])}f=_,m=b}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(u.size>0){const d=new Map,h=new Map,p=new Map;for(const[m,y]of u)p.set(m,!0),y.forEach(g=>{const _=o(g.vertex0),b=o(g.vertex1);d.has(_)?d.get(_).push(m):d.set(_,[m]),h.has(b)?h.get(b).push(m):h.set(b,[m])});const f=l.slice(0);for(;u.size!==0;){for(const y of u.keys())p.set(y,!0);let m=!1;for(;;){const y=Array.from(p.keys());if(y.length===0)break;const g=y[0];let _=!0;if(u.has(g)){const v=u.get(g)[0];for(let T=0;T<2;T++){const E=T===0?v.vertex0:v.vertex1,A=T===0?v.vertex1:v.vertex0,P=o(E),N=o(A);let C=[];T===0?h.has(P)&&(C=h.get(P)):d.has(P)&&(C=d.get(P));for(let D=0;D<C.length;D++){const I=C[D],B=u.get(I)[0],U=T===0?B.vertex0:B.vertex1;if(T===0?B.vertex1:B.vertex0,o(U)===N){a(u,d,h,E,A,null),a(u,d,h,A,E,null),_=!1,T=2,m=!0;break}else{const X=E,W=A,ee=U,re=r.subtract(r.create(),ee,X),pe=r.dot(r.subtract(r.create(),W,X),re)/r.dot(re,re);if(pe>0&&pe<1){const ie=r.scale(r.create(),re,pe);if(r.add(ie,ie,X),r.squaredDistance(ie,W)<n.EPS*n.EPS){const de=B.polygonindex,he=f[de],ve=o(B.vertex1);let Ae=-1;for(let ye=0;ye<he.vertices.length;ye++)if(o(he.vertices[ye])===ve){Ae=ye;break}const Ce=he.vertices.slice(0);Ce.splice(Ae,0,A);const Be=i.create(Ce);f[de]=Be,a(u,d,h,B.vertex0,B.vertex1,de);const _e=s(u,d,h,B.vertex0,A,de),Me=s(u,d,h,A,B.vertex1,de);_e!==null&&p.set(_e,!0),Me!==null&&p.set(Me,!0),_=!1,T=2,m=!0;break}}}}}}_&&p.delete(g)}if(!m)break}l=f}return u.clear(),l};e.exports=c}}),Dun=tt({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,e){var n=yi(),r=Ns(),i=(s,a,c)=>{const l=a.vertices.length;if(l>3){if(l>4){const h=[0,0,0];a.vertices.forEach(p=>n.add(h,h,p)),n.snap(h,n.divide(h,h,[l,l,l]),s);for(let p=0;p<l;p++){const f=r.create([h,a.vertices[p],a.vertices[(p+1)%l]]);a.color&&(f.color=a.color),c.push(f)}return}const u=r.create([a.vertices[0],a.vertices[1],a.vertices[2]]),d=r.create([a.vertices[0],a.vertices[2],a.vertices[3]]);a.color&&(u.color=a.color,d.color=a.color),c.push(u,d);return}c.push(a)},o=(s,a)=>{const c=[];return a.forEach(l=>{i(s,l,c)}),c};e.exports=o}}),zun=tt({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,e){var n=yo(),r=i9(),i=jo(),o=zo(),s=el(),a=bYe(),c=Iun(),l=Lun(),u=Dun(),d=(m,y)=>y,h=(m,y)=>y,p=(m,y)=>{const g={snap:!1,simplify:!1,triangulate:!1},{snap:_,simplify:b,triangulate:v}=Object.assign({},g,m),T=r(y);let E=o.toPolygons(y);_&&(E=a(T,E)),b&&(E=c(T,E)),v&&(E=l(E),E=u(T,E));const A=Object.assign({},y);return A.polygons=E,A},f=(m,...y)=>{if(y=n(y),y.length===0)throw new Error("wrong number of arguments");const g=y.map(_=>{if(s.isA(_))return d(m,_);if(i.isA(_))return h(m,_);if(o.isA(_))return p(m,_);throw new Error("invalid geometry")});return g.length===1?g[0]:g};e.exports=f}}),$un=tt({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,e){var n=yo(),r=as(),i=jo(),o=zo(),s=el(),a=i9(),c=bYe(),l=p=>{const f=a(p),y=s.toPoints(p).map(g=>r.snap(r.create(),g,f));return s.create(y)},u=p=>{const f=a(p);let y=i.toSides(p).map(g=>[r.snap(r.create(),g[0],f),r.snap(r.create(),g[1],f)]);return y=y.filter(g=>!r.equals(g[0],g[1])),i.create(y)},d=p=>{const f=a(p),m=o.toPolygons(p),y=c(f,m);return o.create(y)},h=(...p)=>{if(p=n(p),p.length===0)throw new Error("wrong number of arguments");const f=p.map(m=>s.isA(m)?l(m):i.isA(m)?u(m):o.isA(m)?d(m):m);return f.length===1?f[0]:f};e.exports=h}}),Fun=tt({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,e){e.exports={generalize:zun(),snap:$un(),retessellate:UR()}}}),Bun=tt({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,e){var n=(r,i,o)=>{for(r=r.slice();r.length<o;)r.push(i);return r};e.exports=n}}),jun=tt({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,e){var n=yo(),r=Bun(),i=n0e(),{translate:o}=D7(),s=u=>{if(!Array.isArray(u.modes)||u.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(u.modes=r(u.modes,"none",3),u.modes.filter(d=>["center","max","min","none"].includes(d)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(u.relativeTo)||u.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(u.relativeTo=r(u.relativeTo,0,3),u.relativeTo.filter(d=>Number.isFinite(d)||d==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof u.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return u},a=(u,d,h)=>{for(let p=0;p<3;p++)u[p]==null&&(d[p]==="center"?u[p]=(h[0][p]+h[1][p])/2:d[p]==="max"?u[p]=h[1][p]:d[p]==="min"&&(u[p]=h[0][p]));return u},c=(u,d,h)=>{const p=i(u),f=[0,0,0];for(let m=0;m<3;m++)d[m]==="center"?f[m]=h[m]-(p[0][m]+p[1][m])/2:d[m]==="max"?f[m]=h[m]-p[1][m]:d[m]==="min"&&(f[m]=h[m]-p[0][m]);return o(f,u)},l=(u,...d)=>{u=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},u),u=s(u);let{modes:p,relativeTo:f,grouped:m}=u;if(d=n(d),d.length===0)throw new Error("align(): No geometries were provided to act upon");if(f.filter(y=>y==null).length){const y=i(d);f=a(f,p,y)}return m?d=c(d,p,f):d=d.map(y=>c(y,p,f)),d.length===1?d[0]:d};e.exports=l}}),Qj=tt({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,e){var n=yo(),r=jo(),i=zo(),o=el(),s=I7(),{translate:a}=D7(),c=(p,f)=>{const m={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:y,relativeTo:g}=Object.assign({},m,p),_=s(f),b=[0,0,0];return y[0]&&(b[0]=g[0]-(_[0][0]+(_[1][0]-_[0][0])/2)),y[1]&&(b[1]=g[1]-(_[0][1]+(_[1][1]-_[0][1])/2)),y[2]&&(b[2]=g[2]-(_[0][2]+(_[1][2]-_[0][2])/2)),a(b,f)},l=(p,...f)=>{const m={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:y,relativeTo:g}=Object.assign({},m,p);if(f=n(f),f.length===0)throw new Error("wrong number of arguments");if(g.length!==3)throw new Error("relativeTo must be an array of length 3");p={axes:y,relativeTo:g};const _=f.map(b=>o.isA(b)||r.isA(b)||i.isA(b)?c(p,b):b);return _.length===1?_[0]:_},u=(...p)=>l({axes:[!0,!1,!1]},p),d=(...p)=>l({axes:[!1,!0,!1]},p),h=(...p)=>l({axes:[!1,!1,!0]},p);e.exports={center:l,centerX:u,centerY:d,centerZ:h}}}),Jj=tt({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,e){var n=yo(),r=xl(),i=jo(),o=zo(),s=el(),a=(d,...h)=>{if(!Array.isArray(d))throw new Error("factors must be an array");if(h=n(h),h.length===0)throw new Error("wrong number of arguments");for(d=d.slice();d.length<3;)d.push(1);if(d[0]<=0||d[1]<=0||d[2]<=0)throw new Error("factors must be positive");const p=r.fromScaling(r.create(),d),f=h.map(m=>s.isA(m)?s.transform(p,m):i.isA(m)?i.transform(p,m):o.isA(m)?o.transform(p,m):m);return f.length===1?f[0]:f},c=(d,...h)=>a([d,1,1],h),l=(d,...h)=>a([1,d,1],h),u=(d,...h)=>a([1,1,d],h);e.exports={scale:a,scaleX:c,scaleY:l,scaleZ:u}}}),Uun=tt({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,e){var n=yo(),r=jo(),i=zo(),o=el(),s=(a,...c)=>{if(c=n(c),c.length===0)throw new Error("wrong number of arguments");const l=c.map(u=>o.isA(u)?o.transform(a,u):r.isA(u)?r.transform(a,u):i.isA(u)?i.transform(a,u):u);return l.length===1?l[0]:l};e.exports=s}}),$7=tt({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,e){e.exports={align:jun(),center:Qj().center,centerX:Qj().centerX,centerY:Qj().centerY,centerZ:Qj().centerZ,mirror:FR().mirror,mirrorX:FR().mirrorX,mirrorY:FR().mirrorY,mirrorZ:FR().mirrorZ,rotate:BR().rotate,rotateX:BR().rotateX,rotateY:BR().rotateY,rotateZ:BR().rotateZ,scale:Jj().scale,scaleX:Jj().scaleX,scaleY:Jj().scaleY,scaleZ:Jj().scaleZ,transform:Uun(),translate:D7().translate,translateX:D7().translateX,translateY:D7().translateY,translateZ:D7().translateZ}}}),eU=tt({"node_modules/@jscad/modeling/src/index.js"(t,e){e.exports={colors:Xj(),curves:Dcn(),geometries:Zhe(),maths:aln(),measurements:mln(),primitives:z7(),text:Gln(),utils:hYe(),booleans:HR(),expansions:_Ye(),extrusions:VR(),hulls:kun(),minkowski:Oun(),modifiers:Fun(),transforms:$7()}}}),vYe=tt({"node_modules/jscad-planner/dist/index.cjs"(t,e){var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(h,p)=>{for(var f in p)n(h,f,{get:p[f],enumerable:!0})},a=(h,p,f,m)=>{if(p&&typeof p=="object"||typeof p=="function")for(let y of i(p))!o.call(h,y)&&y!==f&&n(h,y,{get:()=>p[y],enumerable:!(m=r(p,y))||m.enumerable});return h},c=h=>a(n({},"__esModule",{value:!0}),h),l={};s(l,{executeJscadOperations:()=>d,jscadPlanner:()=>u}),e.exports=c(l);var u={booleans:{intersect:(...h)=>({type:"intersect",shapes:h}),subtract:(...h)=>({type:"subtract",shapes:h}),union:(...h)=>({type:"union",shapes:h})},hulls:{hull:(...h)=>({type:"hull",shapes:h.flat()}),hullChain:(...h)=>({type:"hullChain",shapes:h.flat()})},colors:{colorize:(h,p)=>({type:"colorize",color:h,shape:p})},primitives:{cube:h=>({type:"cube",...h}),sphere:h=>({type:"sphere",...h}),cylinder:h=>({type:"cylinder",...h}),polygon:h=>({type:"polygon",...h}),cuboid:h=>({type:"cuboid",...h}),roundedCuboid:h=>({type:"roundedCuboid",...h})},transforms:{rotate:(h,p)=>({type:"rotate",angles:h,shape:p}),scale:(h,p)=>({type:"scale",factors:h,shape:p}),translate:(h,p)=>({type:"translate",vector:h,shape:p})},extrusions:{extrudeLinear:(h,p)=>({type:"extrudeLinear",options:h,shape:p}),extrudeRotate:(h,p)=>({type:"extrudeRotate",options:h,shape:p})},maths:{vec2:{create:(h,p)=>[h,p],fromValues:(h,p)=>[h,p]},vec3:{create:(h,p,f)=>[h,p,f],fromValues:(h,p,f)=>[h,p,f]}},geometries:{geom2:{create:h=>({type:"createGeom2",points:h})},geom3:{create:h=>({type:"createGeom3",polygons:h})},path2:{create:h=>({type:"createPath2",points:h})}},measurements:{measureBoundingBox:h=>({type:"measureBoundingBox",shape:h}),measureArea:h=>({type:"measureArea",shape:h}),measureVolume:h=>({type:"measureVolume",shape:h})},utils:{degToRad:h=>h*Math.PI/180,radToDeg:h=>h*180/Math.PI}},d=(h,p)=>{if(Array.isArray(p)&&p.length===1)return d(h,p[0]);if(Array.isArray(p))throw new Error("executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually");const f=g=>d(h,g),{type:m,...y}=p;switch(m){case"intersect":return h.booleans.intersect(...p.shapes.map(f));case"subtract":return h.booleans.subtract(...p.shapes.map(f));case"union":return h.booleans.union(...p.shapes.map(f));case"hull":return h.hulls.hull(...p.shapes.map(f));case"hullChain":return h.hulls.hullChain(...p.shapes.map(f));case"colorize":return h.colors.colorize(p.color,f(p.shape));case"cube":return h.primitives.cube(y);case"sphere":return h.primitives.sphere(y);case"cylinder":return h.primitives.cylinder(y);case"polygon":return h.primitives.polygon(y);case"cuboid":return h.primitives.cuboid(y);case"roundedCuboid":return h.primitives.roundedCuboid(y);case"rotate":return h.transforms.rotate(p.angles,f(p.shape));case"scale":return h.transforms.scale(p.factors,f(p.shape));case"translate":return h.transforms.translate(p.vector,f(p.shape));case"extrudeLinear":return h.extrusions.extrudeLinear(p.options,f(p.shape));case"extrudeRotate":return h.extrusions.extrudeRotate(p.options,f(p.shape));case"createGeom2":return h.geometries.geom2.create(p.points);case"createGeom3":return h.geometries.geom3.create(p.polygons);case"createPath2":return h.geometries.path2.create(p.points);case"measureBoundingBox":return h.measurements.measureBoundingBox(f(p.shape));case"measureArea":return h.measurements.measureArea(f(p.shape));case"measureVolume":return h.measurements.measureVolume(f(p.shape));case"degToRad":return h.utils.degToRad(p.degrees);case"radToDeg":return h.utils.radToDeg(p.radians);default:throw p.type===void 0?new Error(`Operation type is undefined. This usually means the operation object is malformed or not properly initialized. Operation: ${JSON.stringify(p,null,2).slice(0,200)}...`):new Error(`Unsupported operation type: ${p.type}. Operation: ${JSON.stringify(p,null,2)}`)}}}}),Hun=tt({"node_modules/ms/index.js"(t,e){var n=1e3,r=n*60,i=r*60,o=i*24,s=o*7,a=o*365.25;e.exports=function(h,p){p=p||{};var f=typeof h;if(f==="string"&&h.length>0)return c(h);if(f==="number"&&isFinite(h))return p.long?u(h):l(h);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(h))};function c(h){if(h=String(h),!(h.length>100)){var p=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(h);if(p){var f=parseFloat(p[1]),m=(p[2]||"ms").toLowerCase();switch(m){case"years":case"year":case"yrs":case"yr":case"y":return f*a;case"weeks":case"week":case"w":return f*s;case"days":case"day":case"d":return f*o;case"hours":case"hour":case"hrs":case"hr":case"h":return f*i;case"minutes":case"minute":case"mins":case"min":case"m":return f*r;case"seconds":case"second":case"secs":case"sec":case"s":return f*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return}}}}function l(h){var p=Math.abs(h);return p>=o?Math.round(h/o)+"d":p>=i?Math.round(h/i)+"h":p>=r?Math.round(h/r)+"m":p>=n?Math.round(h/n)+"s":h+"ms"}function u(h){var p=Math.abs(h);return p>=o?d(h,p,o,"day"):p>=i?d(h,p,i,"hour"):p>=r?d(h,p,r,"minute"):p>=n?d(h,p,n,"second"):h+" ms"}function d(h,p,f,m){var y=p>=f*1.5;return Math.round(h/f)+" "+m+(y?"s":"")}}}),Vun=tt({"node_modules/debug/src/common.js"(t,e){function n(r){o.debug=o,o.default=o,o.coerce=d,o.disable=l,o.enable=a,o.enabled=u,o.humanize=Hun(),o.destroy=h,Object.keys(r).forEach(p=>{o[p]=r[p]}),o.names=[],o.skips=[],o.formatters={};function i(p){let f=0;for(let m=0;m<p.length;m++)f=(f<<5)-f+p.charCodeAt(m),f|=0;return o.colors[Math.abs(f)%o.colors.length]}o.selectColor=i;function o(p){let f,m=null,y,g;function _(...b){if(!_.enabled)return;const v=_,T=Number(new Date),E=T-(f||T);v.diff=E,v.prev=f,v.curr=T,f=T,b[0]=o.coerce(b[0]),typeof b[0]!="string"&&b.unshift("%O");let A=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(N,C)=>{if(N==="%%")return"%";A++;const D=o.formatters[C];if(typeof D=="function"){const I=b[A];N=D.call(v,I),b.splice(A,1),A--}return N}),o.formatArgs.call(v,b),(v.log||o.log).apply(v,b)}return _.namespace=p,_.useColors=o.useColors(),_.color=o.selectColor(p),_.extend=s,_.destroy=o.destroy,Object.defineProperty(_,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(y!==o.namespaces&&(y=o.namespaces,g=o.enabled(p)),g),set:b=>{m=b}}),typeof o.init=="function"&&o.init(_),_}function s(p,f){const m=o(this.namespace+(typeof f>"u"?":":f)+p);return m.log=this.log,m}function a(p){o.save(p),o.namespaces=p,o.names=[],o.skips=[];const f=(typeof p=="string"?p:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const m of f)m[0]==="-"?o.skips.push(m.slice(1)):o.names.push(m)}function c(p,f){let m=0,y=0,g=-1,_=0;for(;m<p.length;)if(y<f.length&&(f[y]===p[m]||f[y]==="*"))f[y]==="*"?(g=y,_=m,y++):(m++,y++);else if(g!==-1)y=g+1,_++,m=_;else return!1;for(;y<f.length&&f[y]==="*";)y++;return y===f.length}function l(){const p=[...o.names,...o.skips.map(f=>"-"+f)].join(",");return o.enable(""),p}function u(p){for(const f of o.skips)if(c(p,f))return!1;for(const f of o.names)if(c(p,f))return!0;return!1}function d(p){return p instanceof Error?p.stack||p.message:p}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}e.exports=n}}),Yun=tt({"node_modules/debug/src/browser.js"(t,e){t.formatArgs=r,t.save=i,t.load=o,t.useColors=n,t.storage=s(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!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 c;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&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let u=0,d=0;c[0].replace(/%[a-zA-Z%]/g,h=>{h!=="%%"&&(u++,h==="%c"&&(d=u))}),c.splice(d,0,l)}t.log=console.debug||console.log||(()=>{});function i(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function o(){let c;try{c=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!c&&typeof jhe<"u"&&"env"in jhe&&(c=jhe.env.DEBUG),c}function s(){try{return localStorage}catch{}}e.exports=Vun()(t);var{formatters:a}=e.exports;a.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}}),wYe={boardBody:!0,topCopper:!0,bottomCopper:!0,adhesive:!1,solderPaste:!1,topSilkscreen:!0,bottomSilkscreen:!0,topMask:!0,bottomMask:!0,throughHoleModels:!0,smtModels:!0,translucentModels:!0,modelsNotInPosFile:!1,modelsMarkedDNP:!1,modelBoundingBoxes:!1,threedAxis:!1,pcbNotes:!1,backgroundStart:!0,backgroundEnd:!0},SYe=J.createContext(void 0),Xun=({children:t})=>{const[e,n]=J.useState(wYe),r=J.useCallback((s,a)=>{n(c=>({...c,[s]:a}))},[]),i=J.useCallback(()=>{n(wYe)},[]),o=J.useMemo(()=>({visibility:e,setLayerVisibility:r,resetToDefaults:i}),[e,r,i]);return G.jsx(SYe.Provider,{value:o,children:t})},F7=()=>{const t=J.useContext(SYe);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},y0e=1.2;function EYe(t){return J.useMemo(()=>{if(!t)return y0e;try{return di(t).pcb_board.list()[0]?.thickness??y0e}catch{return y0e}},[t])}var MYe=J.createContext(null),Xy=()=>{const t=J.useContext(MYe);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},YR=(t,e=[])=>{const{addFrameListener:n,removeFrameListener:r}=Xy();ri.useEffect(()=>(n(t),()=>r(t)),[n,r,...e])},XR={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},TYe=({children:t,position:e,style:n})=>{const{camera:r,renderer:i}=Xy(),o=J.useRef(document.createElement("div")),[s,a]=J.useState(null);return J.useEffect(()=>{const c=i?.domElement.parentNode;if(c)return c.style.position!=="relative"&&c.style.position!=="absolute"&&(c.style.position="relative"),c.appendChild(o.current),a(LO.createPortal(t,o.current)),()=>{c.contains(o.current)&&c.removeChild(o.current)}},[i,t]),YR(()=>{if(!r||!o.current||!i)return;const c=new Mt(...e);c.project(r);const l=i.domElement.getBoundingClientRect(),u=Math.round((c.x+1)/2*l.width),d=Math.round((-c.y+1)/2*l.height);o.current.style.position="absolute",o.current.style.left=`${u}px`,o.current.style.top=`${d}px`,o.current.style.pointerEvents="none",o.current.style.zIndex=XR.htmlElements.toString(),n&&Object.assign(o.current.style,n)},[r,i,e,n]),s},CYe={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},Bs=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 CYe)return n*CYe[e];throw new Error(`Unsupported unit: ${e}`)},nh=Bs,Gun=Object.defineProperty,qun=(t,e)=>{for(var n in e)Gun(t,n,{get:e[n],enumerable:!0})},$b={};qun($b,{axial:()=>_hn,bga:()=>Tdn,breakoutheaders:()=>Nhn,cap:()=>tdn,dfn:()=>ehn,diode:()=>edn,dip:()=>Zun,electrolytic:()=>xfn,hc49:()=>Ohn,jst:()=>zpn,led:()=>ndn,lqfp:()=>Ahn,m2host:()=>Bfn,melf:()=>X0n,micromelf:()=>K0n,minimelf:()=>$0n,mlp:()=>Ldn,mountedpcbmodule:()=>Ufn,ms012:()=>shn,ms013:()=>chn,msop:()=>Gpn,pad:()=>Ihn,pinrow:()=>nhn,platedhole:()=>Nfn,potentiometer:()=>yfn,pushbutton:()=>Shn,qfn:()=>kdn,qfp:()=>Idn,quad:()=>WM,radial:()=>vhn,res:()=>Sdn,sma:()=>epn,smb:()=>cpn,smbf:()=>vfn,smc:()=>hpn,smf:()=>ipn,smtpad:()=>Afn,sod110:()=>Fpn,sod123:()=>fhn,sod123f:()=>m0n,sod123fl:()=>x0n,sod123w:()=>Whn,sod128:()=>C0n,sod323:()=>Jhn,sod323f:()=>d0n,sod323fl:()=>Jpn,sod323w:()=>Wpn,sod523:()=>Fhn,sod723:()=>S0n,sod80:()=>Yhn,sod882:()=>a0n,sod882d:()=>U0n,sod923:()=>r0n,soic:()=>Pdn,solderjumper:()=>cfn,son:()=>rfn,sop8:()=>Hhn,sot:()=>Ofn,sot223:()=>ypn,sot23:()=>Gdn,sot23w:()=>Mpn,sot25:()=>Zdn,sot323:()=>Mfn,sot343:()=>Dfn,sot363:()=>Hdn,sot457:()=>dfn,sot563:()=>ihn,sot723:()=>uhn,sot886:()=>Ydn,sot89:()=>O0n,sot963:()=>pfn,ssop:()=>$dn,stampboard:()=>Mhn,stampreceiver:()=>Phn,to220:()=>YYe,to220f:()=>D0n,to92:()=>zhn,to92l:()=>Vfn,to92s:()=>Npn,tqfp:()=>Odn,tssop:()=>jdn,vson:()=>ofn,vssop:()=>Vpn});var Nr=(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"}),Cr=Je({norefdes:Oe().optional().describe("disable reference designator label"),invert:Oe().optional().describe("hint to invert the orientation of the 3D model"),faceup:Oe().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:Oe().optional().describe("omit all silkscreen elements from the footprint")}),go=(t,e,n,r,i)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:n,hole_diameter:Bs(r),outer_diameter:Bs(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),Lx=t=>{const{pn:e,x:n,y:r,holeDiameter:i,rectPadWidth:o,rectPadHeight:s,holeOffsetX:a=0,holeOffsetY:c=0,rectBorderRadius:l}=t;return{pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:n,y:r,hole_diameter:Bs(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:Bs(o),rect_pad_height:Bs(s),...l!==void 0&&{rect_border_radius:l},pcb_port_id:"",layers:["top","bottom"],port_hints:[e.toString()],hole_offset_x:a,hole_offset_y:c}},tU=Array.from({length:9},(t,e)=>Math.cos(e/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)}));function o9(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var nU=kn([z(),Ue()]).transform(t=>o9(t)),Wun=t=>Cr.extend({fn:z(),num_pins:Ue().optional().default(6),wide:Oe().optional(),narrow:Oe().optional(),w:nU.optional(),p:nU.default(t.p??"2.54mm"),id:nU.optional(),od:nU.optional(),nosquareplating:Oe().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=o9("0.55mm"),e.od=o9("0.95mm")):(e.id=o9("0.8mm"),e.od=o9("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=o9("600mil"):e.narrow?e.w=o9("300mil"):e.w=o9(t.w??"300mil")),e)),Kun=Wun({}),PYe=(t,e,n,r,i)=>{const o=t/2,s=e<=o,a=o-1,c=r,l=c*a;return s?{x:-n/2,y:l/2-(e-1)*c}:{x:n/2,y:-l/2+(e-o-1)*c}},Zun=t=>{const e=Kun.parse(t),n=[];for(let l=0;l<e.num_pins;l++){const{x:u,y:d}=PYe(e.num_pins,l+1,e.w,e.p??2.54,e.nosquareplating);if(l===0&&!e.nosquareplating){n.push(Lx({pn:l+1,x:u,y:d,holeDiameter:e.id??"0.8mm",rectPadWidth:e.od??"1mm",rectPadHeight:e.od??"1mm"}));continue}n.push(go(l+1,u,d,e.id??"0.8mm",e.od??"1mm"))}(e.num_pins/2-1)*e.p+e.od;const i=e.w-e.od-1,o=(e.num_pins/2-1)*e.p+e.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i/2,y:-o/2},{x:-i/2,y:o/2},...tU.map(({x:l,y:u})=>({x:l*i/6,y:u*i/6+o/2})),{x:i/2,y:o/2},{x:i/2,y:-o/2},{x:-i/2,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1},a=[];for(let l=0;l<e.num_pins;l++){const u=l<e.num_pins/2,d=.6,{y:h}=PYe(e.num_pins,l+1,e.w,e.p??2.54,e.nosquareplating),p=u?-e.w/2-e.od/2-d:e.w/2+e.od/2+d,f=h;a.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${l+1}`,layer:"top",pcb_component_id:`pin_${l+1}`,text:`{pin${l+1}}`,anchor_position:{x:p,y:f},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const c=Nr(0,o/2+.5,.4);return{circuitJson:[...n,s,c,...a],parameters:e}},ar=(t,e,n,r,i)=>({type:"pcb_smtpad",x:e,y:n,width:r,height:i,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),AYe=[{imperial:"01005",metric:"0402",p_mm_min:.5,pw_mm_min:.4,ph_mm_min:.3,w_mm_min:.58,h_mm_min:.21},{imperial:"0504",metric:"1310",p_mm_min:1.1,pw_mm_min:.65,ph_mm_min:1.3,w_mm_min:.58,h_mm_min:.21},{imperial:"1812",metric:"4532",p_mm_min:4.275,pw_mm_min:1.125,ph_mm_min:3.4,w_mm_min:5.4,h_mm_min:3.4},{imperial:"0201",metric:"0603",p_mm_min:.66,pw_mm_min:.46,ph_mm_min:.4,w_mm_min:.9,h_mm_min:.3},{imperial:"0402",metric:"1005",p_mm_min:1.02,pw_mm_min:.54,ph_mm_min:.64,w_mm_min:1.56,h_mm_min:.64},{imperial:"0603",metric:"1608",p_mm_min:1.65,pw_mm_min:.8,ph_mm_min:.95,w_mm_min:2.45,h_mm_min:.95},{imperial:"0805",metric:"2012",p_mm_min:1.825,pw_mm_min:1.025,ph_mm_min:1.4,w_mm_min:2.8499999999999996,h_mm_min:1.4},{imperial:"1206",metric:"3216",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:1.75,w_mm_min:4.05,h_mm_min:1.75},{imperial:"1210",metric:"3225",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:2.65,w_mm_min:4.05,h_mm_min:2.65},{imperial:"2010",metric:"5025",p_mm_min:4.625,pw_mm_min:1.225,ph_mm_min:2.65,w_mm_min:5.85,h_mm_min:2.65},{imperial:"2512",metric:"6332",p_mm_min:5.925,pw_mm_min:1.225,ph_mm_min:3.35,w_mm_min:7.15,h_mm_min:3.35}],Qun=Object.fromEntries(AYe.map(t=>[t.metric,t])),Jun=Object.fromEntries(AYe.map(t=>[t.imperial,t]));Cr.extend({tht:Oe(),p:ce.optional(),pw:ce.optional(),ph:ce.optional(),metric:Qe.optional(),imperial:Qe.optional(),w:ce.optional(),h:ce.optional(),textbottom:Oe().optional()});var rU=t=>{let{tht:e,p:n,pw:r,ph:i,metric:o,imperial:s,w:a,h:c,textbottom:l}=t;if(typeof a=="string"&&(a=nh(a)),typeof c=="string"&&(c=nh(c)),typeof n=="string"&&(n=nh(n)),typeof r=="string"&&(r=nh(r)),typeof i=="string"&&(i=nh(i)),c!==void 0&&a!==void 0&&c>a)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let u;if(o&&(u=Qun[o]),s&&(u=Jun[s]),u&&(a=u.w_mm_min,c=u.h_mm_min,n=u.p_mm_min,r=u.pw_mm_min,i=u.ph_mm_min),n===void 0||r===void 0||i===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:n/2,y:i/2+.4},{x:-n/2-r/2-.2,y:i/2+.4},{x:-n/2-r/2-.2,y:-i/2-.4},{x:n/2,y:-i/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},h=l?-i/2-.9:i/2+.9,p=Nr(0,h,.2),f=.25,m=d.route.map(E=>E.x),y=d.route.map(E=>E.y),g=Math.min(-(a??0)/2,-(n/2+r/2),...m)-f,_=Math.max((a??0)/2,n/2+r/2,...m)+f,b=Math.min(-(c??0)/2,-i/2,...y)-f,v=Math.max((c??0)/2,i/2,...y)+f,T={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(g+_)/2,y:(b+v)/2},width:_-g,height:v-b,layer:"top"};return e?[go(1,-n/2,0,r,r*1/.8),go(2,n/2,0,r,r*1/.8),d,p,T]:[ar(["1","left"],-n/2,0,r,i),ar(["2","right"],n/2,0,r,i),d,p,T]},edn=t=>({circuitJson:rU(t),parameters:t}),tdn=t=>({circuitJson:rU(t),parameters:t}),ndn=t=>({circuitJson:rU(t),parameters:t}),qM=t=>{const{padSpacing:e,padWidth:n,padHeight:r,padPitch:i,numRows:o,textbottom:s}=t,a=[],c=(o-1)*(i/2);for(let P=0;P<o;P++)a.push(c-P*i);const l=[];a.forEach((P,N)=>{l.push(ar(N+1,-e/2,P,n,r))}),a.slice().reverse().forEach((P,N)=>{l.push(ar(N+o+1,e/2,P,n,r))});const u=Math.max(...a)+r/2+.4,d=Math.min(...a)-r/2-.4,h=-e/2-n/2-.4,p=e/2+n/2+.4,f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:p*.5,y:u},{x:h*.5,y:u}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:p*.5,y:d},{x:h*.5,y:d}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},y=-e/2,g=Math.max(...a),_=.2,b=y-n/2-.1,v=g+r/2+.1,T={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:[{x:b,y:v},{x:b-_,y:v},{x:b,y:v+_},{x:b,y:v}],stroke_width:.1},E=s?d-.9:u+.9,A=Nr(0,E,.2);return[...l,f,m,T,A]},rdn=Cr.extend({pw:ce.default("0.5mm"),ph:ce.default("0.4mm"),p:ce.default("0.7mm"),textbottom:Oe().optional(),convex:Oe().optional(),concave:Oe().optional()}),idn=1,odn=t=>{const e=rdn.parse(t);if(e.concave===!0)return[];const n=nh(e.pw),r=nh(e.ph),i=nh(e.p);return qM({padSpacing:idn,padWidth:n,padHeight:r,padPitch:i,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave})},sdn=Cr.extend({pw:ce.default("0.5mm"),ph:ce.default("0.32mm"),p:ce.default("0.5mm"),textbottom:Oe().optional(),convex:Oe().optional(),concave:Oe().optional()}),adn=1,cdn=t=>{const e=sdn.parse(t),n=nh(e.pw),r=nh(e.ph),i=nh(e.p);return qM({padSpacing:adn,padWidth:n,padHeight:r,padPitch:i,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave})},ldn=Cr.extend({pw:ce.default("0.9mm"),ph:ce.default("0.4mm"),p:ce.default("0.8mm"),textbottom:Oe().optional(),convex:Oe().optional(),concave:Oe().optional()}),udn=1.7,ddn=t=>{const e=ldn.parse(t),n=nh(e.pw),r=nh(e.ph),i=nh(e.p);return qM({padSpacing:udn,padWidth:n,padHeight:r,padPitch:i,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave})},hdn=Cr.extend({pw:ce.default("0.9mm"),ph:ce.default("0.4mm"),p:ce.default("0.8mm"),textbottom:Oe().optional(),convex:Oe().optional(),concave:Oe().optional()}),pdn=1.7,fdn=t=>{const e=hdn.parse(t),n=nh(e.pw),r=nh(e.ph),i=nh(e.p);return qM({padSpacing:pdn,padWidth:n,padHeight:r,padPitch:i,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave})},mdn=Cr.extend({pw:ce.default("0.7mm"),ph:ce.default("0.64mm"),p:ce.default("0.94mm"),textbottom:Oe().optional(),convex:Oe().optional(),concave:Oe().optional()}),ydn=1.4,gdn=t=>{const e=mdn.parse(t),n=nh(e.pw),r=nh(e.ph),i=nh(e.p);return qM({padSpacing:ydn,padWidth:n,padHeight:r,padPitch:i,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave})},_dn=Cr.extend({pw:ce.default("0.9mm"),ph:ce.default("0.9mm"),p:ce.default("1.34mm"),textbottom:Oe().optional(),convex:Oe().optional(),concave:Oe().optional()}),xdn=3,bdn=t=>{const e=_dn.parse(t),n=nh(e.pw),r=nh(e.ph),i=nh(e.p);return qM({padSpacing:xdn,padWidth:n,padHeight:r,padPitch:i,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave})},vdn=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 r=t.imperial.match(/x(2|4)$/)?.[1];if(r)return Number.parseInt(r,10)}},wdn=t=>t?(typeof t=="number"?`${t}`:t).split(/[_x]/)[0]:void 0,Sdn=t=>{const e=vdn(t),n=wdn(t.imperial);return e===2&&n==="0402"?{circuitJson:odn(t),parameters:t}:e===4&&n==="0402"?{circuitJson:cdn(t),parameters:t}:e===2&&n==="0603"?{circuitJson:ddn(t),parameters:t}:e===4&&n==="0603"?{circuitJson:fdn(t),parameters:t}:e===2&&n==="0606"?{circuitJson:gdn(t),parameters:t}:e===4&&n==="1206"?{circuitJson:bdn(t),parameters:t}:{circuitJson:rU(t),parameters:t}},RYe=(t,{x:e,y:n,radius:r})=>({type:"pcb_smtpad",x:e,y:n,radius:r,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(i=>i.toString()):[t.toString()]}),NYe="ABCDEFGHIJKLMNOPQRSTUVWXYZ",iU=z().transform(t=>{const[e,n]=t.split(/[x ]/);return{x:parseFloat(e??""),y:parseFloat(n??"")}}).pipe(Je({x:Ue(),y:Ue()})),Edn=z().or(bt(mu())).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(bt(z().or(Ue()))),Mdn=Cr.extend({fn:z(),num_pins:Ue().optional().default(64),grid:iU.optional(),p:Qe.default("0.8mm"),w:ce.optional(),h:ce.optional(),ball:ce.optional().describe("ball diameter"),pad:ce.optional().describe("pad width/height"),circularpads:Oe().optional().describe("use circular pads"),tlorigin:Oe().optional(),blorigin:Oe().optional(),trorigin:Oe().optional(),brorigin:Oe().optional(),missing:Edn.default([])}).transform(t=>{let e="tl";if(t.blorigin&&(e="bl"),t.trorigin&&(e="tr"),t.brorigin&&(e="br"),!t.grid){const r=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:r,y:r}}return t.missing&&(t.missing=t.missing.map(r=>{if(typeof r=="number")return r;if(r==="center")return"center";if(r==="topleft")return"topleft";const i=r.match(/([A-Z]+)(\d+)/);if(!i)return r;const o=NYe.indexOf(i[1]),s=Number.parseInt(i[2])-1;return o*t.grid.x+s+1})),{...t,origin:e}}),Tdn=t=>{const e=Mdn.parse(t);let{num_pins:n,grid:r,p:i,w:o,h:s,ball:a,pad:c,missing:l}=e;a??=.75/1.27*i,c??=a*.8;const u=[],d=(l??[]).filter(T=>typeof T=="number"),h=r.x*r.y-n;if(l.length===0&&h>0&&(Math.sqrt(h)%1===0?l.push("center"):h===1&&l.push("topleft")),l?.includes("center")){const T=Math.floor(Math.sqrt(h)),E=Math.floor((r.x-T)/2),A=Math.floor((r.y-T)/2);for(let P=A;P<A+T;P++)for(let N=E;N<E+T;N++)d.push(P*r.x+N+1)}l?.includes("topleft")&&d.push(1);const p=new Set(d);let f=0;for(let T=0;T<r.y;T++)for(let E=0;E<r.x;E++){const A=(E-(r.x-1)/2)*i,P=(T-(r.y-1)/2)*i;let N=E,C=T;switch(e.origin){case"bl":N=E,C=r.y-1-T;break;case"br":N=r.x-1-E,C=r.y-1-T;break;case"tr":N=r.x-1-E,C=T;break}let D=C*r.x+N+1;if(p.has(D)){f++;continue}D-=f;const I=[D,`${NYe[C]}${N+1}`];u.push(e.circularpads?RYe(I,{x:A,y:P,radius:c/2}):ar(I,A,P,c,c))}const m=Nr(0,r.y*i/2,.2),y=i/6;let g;const _=r.x*i/2,b=r.y*i/2;switch(e.origin){case"bl":g=[{x:-_,y:-b},{x:-_,y:-b-y},{x:-_-y,y:-b},{x:-_,y:-b}];break;case"br":g=[{x:_,y:-b},{x:_,y:-b-y},{x:_+y,y:-b},{x:_,y:-b}];break;case"tr":g=[{x:_,y:b},{x:_,y:b+y},{x:_+y,y:b},{x:_,y:b}];break;default:g=[{x:-_,y:b},{x:-_,y:b+y},{x:-_-y,y:b},{x:-_,y:b}];break}const v={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:g,stroke_width:.05};return{circuitJson:[...u,m,v],parameters:e}},oU=(t,e,n,r,i)=>({type:"pcb_smtpad",x:e,y:n,width:r,height:i,radius:i/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(o=>o.toString()):[t.toString()]}),B7=t=>Cr.extend({fn:z(),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:Oe().optional().default(t.legsoutside??!1),pillpads:Oe().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)),Cdn=B7({}),g0e=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:e,pn:n,w:r,p:i,pl:o,legsoutside:s}=t,a=e/2,c=n<=a,l=a-1,u=i,d=u*l,h=s?o/2:-o/2;return c?{x:-r/2-h,y:d/2-(n-1)*u}:{x:r/2+h,y:-d/2+(n-a-1)*u}},Pdn=t=>{const e=Cdn.parse(t);return{circuitJson:GR(e),parameters:e}},GR=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=g0e({num_pins:t.num_pins,pn:a+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?e.push(oU(a+1,c,l,t.pl,t.pw)):e.push(ar(a+1,c,l,t.pl,t.pw))}const n=Math.min(1,t.p/2),r=t.w-(t.legsoutside?0:t.pl*2)-.2,i=(t.num_pins/2-1)*t.p+t.pw+n,o=Nr(0,i/2+.4,i/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:t.silkscreen_stroke_width??.1,route:[{x:-r/2,y:-i/2},{x:-r/2,y:i/2},...tU.map(({x:a,y:c})=>({x:a*r/6,y:c*r/6+i/2})),{x:r/2,y:i/2},{x:r/2,y:-i/2},{x:-r/2,y:-i/2}]};return[...e,s,o]},kYe=Gt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),Adn=({num_pins:t,cw:e,ccw:n,startingpin:r})=>{const i=[],o=t/4;let s=1;const a={};for(const c of r??[])a[c]=!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=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),i.push(-1);for(let c=0;c<t;c++)i[s]=c+1,n||!e?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return i},_0e=Cr.extend({fn:z(),cc:Oe().default(!0).optional(),ccw:Oe().default(!0).optional(),startingpin:z().or(bt(kYe)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(bt(kYe)).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:kn([Te(!0),iU]).optional(),legsoutside:Oe().default(!1)}),x0e=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},OYe=_0e.transform(x0e),Rdn=["left","bottom","right","top"],Ndn=t=>{const{pin_count:e,pn:n,w:r,h:i,p:o,pl:s,legsoutside:a}=t,c=e/4,l=Rdn[Math.floor((n-1)/c)],u=(n-1)%c,d=o*(c-1),h=o*(c-1),p=a?s/2:-s/2;switch(l){case"left":return{x:-r/2-p+.1,y:h/2-u*o,o:"vert"};case"bottom":return{x:-d/2+u*o,y:-i/2-p+.1,o:"horz"};case"right":return{x:r/2+p-.1,y:-h/2+u*o,o:"vert"};case"top":return{x:d/2-u*o,y:i/2+p-.1,o:"horz"};default:throw new Error("Invalid pin number")}},WM=t=>{const e=OYe.parse(t),n=[],r=Adn(e),i=e.num_pins/4;for(let a=0;a<e.num_pins;a++){const{x:c,y:l,o:u}=Ndn({pin_count:e.num_pins,pn:a+1,w:e.w,h:e.h,p:e.p??.5,pl:e.pl,legsoutside:e.legsoutside});let d=e.pw,h=e.pl;u==="vert"&&([d,h]=[h,d]);const p=r[a+1];n.push(ar(p,c,l,d,h))}if(e.thermalpad)if(typeof e.thermalpad=="boolean"){const a=e.p*(i-1)+e.pw,c=e.p*(i-1)+e.pw;n.push(ar(["thermalpad"],0,0,a,c))}else n.push(ar(["thermalpad"],0,0,e.thermalpad.x,e.thermalpad.y));const o=[];for(const[a,c,l]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const u=e.w/2*c,d=e.h/2*l;let h="none",p=u,f=d;const m=e.pw*2;r[1]===1&&a==="top-left"?h="in1":r[i*4]===1&&a==="top-left"||r[i*3+1]===1&&a==="top-right"?h="in2":r[i*3]===1&&a==="top-right"||r[i]===1&&a==="bottom-left"?h="in1":r[i+1]===1&&a==="bottom-left"?h="in2":r[i*2]===1&&a==="bottom-right"?h="in1":r[i*2+1]===1&&a==="bottom-right"&&(h="in2");const y=h==="in1"?1:-1;if(e.legsoutside){const g=h==="in1"?e.pl/2:e.pw/2,_=h==="in1"?e.pw/2:e.pl/2;p+=g*c*y,f-=_*l*y}(h==="none"||e.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}`,route:[{x:u-m*c,y:d},{x:u,y:d},{x:u,y:d-m*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&!e.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_1`,route:[{x:u-m*c,y:d},{x:u-m*c/2,y:d}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_2`,route:[{x:u,y:d-m*l/2},{x:u,y:d-m*l}],type:"pcb_silkscreen_path",stroke_width:.1}),(h==="in1"||h==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${a}_3`,route:[{x:p-.2*-c,y:f+.2*y},{x:p,y:f},{x:p+.2*y*-c,y:f+.2},{x:p-.2*-c,y:f+.2*y}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Nr(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3);return{circuitJson:[...n,...o,s],parameters:e}};_0e.extend({}).transform(x0e);var kdn=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),WM(t)),Odn=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 WM(t)},Idn=t=>{t.legsoutside=!0;const e=OYe.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 WM(t)};_0e.extend({}).transform(x0e);var Ldn=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),WM(t)),Ddn=Cr.extend({fn:z(),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:Oe().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)),zdn=t=>{const{num_pins:e,pn:n,w:r,p:i}=t,o=e/2,s=n<=o,a=o-1,c=i,l=c*a,u=r+ce.parse("0.2mm"),d=(s?-1:1)*(u/2);return s?{x:d,y:l/2-(n-1)*c}:{x:d,y:-l/2+(n-o-1)*c}},$dn=t=>{const e=Ddn.parse(t),n=[];for(let c=0;c<e.num_pins;c++){const{x:l,y:u}=zdn({num_pins:e.num_pins,pn:c+1,w:e.w,p:e.p,pl:e.pl,legsoutside:e.legsoutside});n.push(ar(c+1,l,u,e.pl,e.pw))}const r=Math.min(1,e.p/2),i=e.w-(e.legsoutside?0:e.pl)-.2,o=(e.num_pins/2-1)*e.p+e.pw+r,s=Nr(0,o/2+.4,o/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:-o/2},{x:-i/2,y:o/2},...tU.map(({x:c,y:l})=>({x:c*i/6,y:l*i/6+o/2})),{x:i/2,y:o/2},{x:i/2,y:-o/2},{x:-i/2,y:-o/2}]};return{circuitJson:[...n,a,s],parameters:e}},Fdn=Cr.extend({fn:z(),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:Oe().optional().default(!0),silkscreen_stroke_width:Ue().optional().default(.1)}),Bdn=t=>{const{num_pins:e,pn:n,w:r,p:i,pl:o,legsoutside:s}=t,a=e/2,c=n<=a,l=a-1,u=i*l,d=s?o/2:-o/2;return c?{x:-r/2-d,y:u/2-(n-1)*i}:{x:r/2+d,y:-u/2+(n-a-1)*i}},jdn=t=>{const e={...t},n=e.p,r=typeof n=="string"||typeof n=="number"?ce.parse(n):void 0,i=r!=null&&r<=ce.parse("0.5mm"),o=Fdn.parse(e),s=[],a=i?o.w-ce.parse("0.15mm"):o.w;for(let p=0;p<o.num_pins;p++){const{x:f,y:m}=Bdn({num_pins:o.num_pins,pn:p+1,w:a,p:o.p,pl:o.pl,legsoutside:o.legsoutside});s.push(ar(p+1,f,m,o.pl,o.pw))}const c=Math.min(1,o.p/2),l=o.w-(o.legsoutside?0:o.pl*2)-.2,u=(o.num_pins/2-1)*o.p+o.pw+c,d=Nr(0,u/2+.4,u/12),h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:o.silkscreen_stroke_width??.1,route:[{x:-l/2,y:-u/2},{x:-l/2,y:u/2},...tU.map(({x:p,y:f})=>({x:p*l/6,y:f*l/6+u/2})),{x:l/2,y:u/2},{x:l/2,y:-u/2},{x:-l/2,y:-u/2}]};return{circuitJson:[...s,h,d],parameters:o}},Udn=Cr.extend({fn:z(),num_pins:Te(6).default(6),w:z().default("3.1mm"),h:z().default("2.0mm"),p:z().default("0.65mm"),pl:z().default("1.03mm"),pw:z().default("0.35mm"),string:z().optional()}),Hdn=t=>{const e=Udn.parse({...t,fn:"sot363"}),n=ce.parse(e.w),r=ce.parse(e.h),i=ce.parse(e.p),o=ce.parse(e.pl),s=ce.parse(e.pw),a=[];for(let p=0;p<6;p++){const{x:f,y:m}=IYe(p+1,n,i);a.push(ar(p+1,f,m,o,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/4,y:r/2+.1},{x:n/4,y:r/2+.1}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/4,y:-r/2-.1},{x:n/4,y:-r/2-.1}],stroke_width:.05,pcb_silkscreen_path_id:""},u=IYe(1,n,i),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:u.x-o/2-.3,y:u.y},{x:u.x-o/2-.45,y:u.y+.15},{x:u.x-o/2-.45,y:u.y-.15},{x:u.x-o/2-.3,y:u.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Nr(0,r/2+.4,.25);return{circuitJson:[...a,c,l,h,d],parameters:e}},IYe=(t,e,n,r)=>t<=3?{x:-.84,y:n-(t-1)*n}:{x:.84,y:-n+(t-4)*n},Vdn=Cr.extend({fn:z(),num_pins:Te(6).default(6),w:z().default("1.01mm"),h:z().default("1.45mm"),p:z().default("0.5mm"),pl:z().default("0.33mm"),pw:z().default("0.27mm"),string:z().optional()}),Ydn=t=>{const e=Vdn.parse({...t,fn:"sot886"}),n=ce.parse(e.w),r=ce.parse(e.h),i=ce.parse(e.p),o=ce.parse(e.pl),s=ce.parse(e.pw),a=[];for(let p=0;p<6;p++){const{x:f,y:m}=LYe(p+1,n,i,o);a.push(ar(p+1,f,m,o,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:r/2},{x:n/2,y:r/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-r/2},{x:n/2,y:-r/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u=LYe(1,n,i,o),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:u.x-o/2-.3,y:u.y},{x:u.x-o/2-.45,y:u.y+.15},{x:u.x-o/2-.45,y:u.y-.15},{x:u.x-o/2-.3,y:u.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Nr(0,r/2+.4,.25);return{circuitJson:[...a,c,l,h,d],parameters:e}},LYe=(t,e,n,r)=>{const i=e/2-r/2;return t<=3?{x:-i,y:n-(t-1)*n}:{x:i,y:-n+(t-4)*n}},DYe=Cr.extend({fn:z(),num_pins:Ue().default(3),w:z().default("1.92mm"),h:z().default("2.74mm"),pl:z().default("1.32mm"),pw:z().default("0.6mm"),p:z().default("0.95mm"),string:z().optional()}),Xdn=B7({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Gdn=t=>{const e=t.string?.match(/^sot23_(\d+)/),n=e?Number.parseInt(e[1],10):3;if(n===6||n===8){const i=Xdn.parse({...t,num_pins:n});return{circuitJson:GR(i),parameters:i}}const r=DYe.parse({...t,num_pins:n});if(r.num_pins===3)return{circuitJson:Wdn(r),parameters:r};if(r.num_pins===5)return{circuitJson:$Ye(r),parameters:r};throw new Error("Invalid number of pins")},qdn=t=>{const{pn:e,p:n}=t;return e===1?{x:-1.155,y:n}:e===2?{x:-1.155,y:-n}:{x:1.15,y:0}},Wdn=t=>{const e=[];for(let r=0;r<t.num_pins;r++){const{x:i,y:o}=qdn({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(ar(r+1,i,o,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=Nr(0,Number.parseInt(t.h),.3);return[...e,n]},zYe=t=>{const{p:e,h:n,pn:r}=t;if(r===1)return{x:-n/2-.5,y:e};if(r===2)return{x:-n/2-.5,y:0};if(r===3)return{x:-n/2-.5,y:-e};if(r===4)return{x:n/2+.5,y:-e};if(r===5)return{x:n/2+.5,y:e};throw new Error("Invalid pin number")},$Ye=t=>{const e=[];for(let d=1;d<=t.num_pins;d++){const{x:h,y:p}=zYe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:d});e.push(ar(d,h,p,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=(t.num_pins+1)/2*Number.parseFloat(t.p),r=Number.parseFloat(t.h),i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:r/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:r/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-r/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-r/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Nr(0,r+.3,.3),a=zYe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.3,l=.4,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,i,o,u]},Kdn=DYe.extend({}),Zdn=t=>{const e=Kdn.parse({...t,num_pins:5});return{circuitJson:$Ye(e),parameters:e}},Qdn=[{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}],Jdn=B7({}),ehn=t=>{const e=Jdn.parse(t),n=[];for(let d=0;d<e.num_pins;d++){const{x:h,y:p}=g0e({num_pins:e.num_pins,pn:d+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(ar(d+1,h,p,e.pl??"1mm",e.pw??"0.6mm"))}const r=Math.min(1,e.p/2),i=e.w+r,o=(e.num_pins/2-1)*e.p+e.pw+r,s=[];for(const d of Qdn){const{dx:h,dy:p}=d;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:h*i/2-h*e.p,y:p*o/2},{x:h*i/2,y:p*o/2},{x:h*i/2,y:p*o/2-p*e.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const a=e.p/4,c=-i/2-a/2,l=o/2-e.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:c,y:l},{x:c-a,y:l+a},{x:c-a,y:l-a},{x:c,y:l}],stroke_width:.1});const u=Nr(0,o/2+.4,o/12);return{circuitJson:[...n,u,...s],parameters:e}},j7=({fs:t,pn:e,anchor_x:n,anchor_y:r,textalign:i="center",orthogonal:o=!1,verticallyinverted:s=!1,layer:a="top"})=>{let c=0;o&&s?c=270:s?c=180:o?c=90:c=0;let l="center";return i==="left"&&(s?l="center_right":l="center_left"),i==="right"&&(s?l="center_left":l="center_right"),a==="bottom"&&(l==="center_left"?l="center_right":l==="center_right"&&(l="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:r},anchor_alignment:l,ccw_rotation:c}};function FYe({pinlabeltextalignleft:t,pinlabeltextalignright:e,pinlabelorthogonal:n}){let r="top";return n?r="left":r="top",t&&(n?r="bottom":r="right"),e&&(n?r="top":r="left"),r}var thn=Cr.extend({fn:z(),num_pins:Ue().optional().default(6),rows:kn([z(),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:Oe().optional().describe("for male pin headers"),female:Oe().optional().describe("for female pin headers"),smd:Oe().optional().describe("surface mount device"),surfacemount:Oe().optional().describe("surface mount device (verbose)"),rightangle:Oe().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:Oe().optional().default(!1),pinlabeltextaligncenter:Oe().optional().default(!1),pinlabeltextalignright:Oe().optional().default(!1),pinlabelverticallyinverted:Oe().optional().default(!1),pinlabelorthogonal:Oe().optional().default(!1),nosquareplating:Oe().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Oe().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Oe().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Oe().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const e=FYe(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:qn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),nhn=t=>{const e=thn.parse(t),{p:n,id:r,od:i,rows:o,num_pins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:c,pinlabelorthogonal:l,pinlabeltextalignleft:u,pinlabeltextalignright:d,nopinlabels:h,doublesidedpinlabel:p,bottomsidepinlabel:f}=e;let m="center";u?m="left":d&&(m="right");const y=[],g=Math.ceil(s/o),_=-n,b=({xoff:P,yoff:N,od:C,anchorSide:D,smd:I,pw:B,pl:U})=>{let H=0,X=0;if(I){const W=C/5;switch(D){case"right":H=B/2+W;break;case"top":X=U/2+W;break;case"bottom":X=-(U/2+W);break;case"left":H=-(B/2+W);break}}else{const W=C*.75;switch(D){case"right":H=W;break;case"top":X=W;break;case"bottom":X=-W;break;case"left":H=-W;break}}return{anchor_x:P+H,anchor_y:N+X}},v=(P,N,C)=>{e.smd?y.push(ar(P,N,C,e.pw,e.pl)):P===1&&!e.nosquareplating?y.push(Lx({pn:P,x:N,y:C,holeDiameter:r,rectPadWidth:i,rectPadHeight:i})):y.push(go(P,N,C,r,i));const{anchor_x:D,anchor_y:I}=b({xoff:N,yoff:C,od:i,anchorSide:a,smd:e.smd,pw:e.pw,pl:e.pl});h||(f?y.push(j7({fs:i/5,pn:P,anchor_x:D,anchor_y:I,textalign:m,orthogonal:l,verticallyinverted:c,layer:"bottom"})):y.push(j7({fs:i/5,pn:P,anchor_x:D,anchor_y:I,textalign:m,orthogonal:l,verticallyinverted:c,layer:"top"})),p&&y.push(j7({fs:i/5,pn:P,anchor_x:D,anchor_y:I,textalign:m,orthogonal:l,verticallyinverted:c,layer:"bottom"})))},T=new Set,E=o>2&&g>2;if(o===1){const P=-((s-1)/2)*n;for(let N=0;N<s;N++){const C=N+1,D=P+N*n,I=`${D},0`;if(T.has(I))throw new Error(`Overlap at ${I}`);T.add(I),v(C,D,0)}}else if(E){const P=-((g-1)/2)*n;let N=1;for(let C=0;C<o&&N<=s;C++)for(let D=0;D<g&&N<=s;D++){const I=P+D*n,B=C*_,U=`${I},${B}`;if(T.has(U))throw new Error(`Overlap at ${U}`);T.add(U),v(N++,I,B)}}else{const P=-((g-1)/2)*n;let N=1,C=0,D=o-1,I=0,B=g-1;for(;N<=s&&C<=D&&I<=B;){for(let U=C;U<=D&&N<=s;U++){const H=P+I*n,X=U*_,W=`${H},${X}`;if(T.has(W))throw new Error(`Overlap at ${W}`);T.add(W),v(N++,H,X)}I++;for(let U=I;U<=B&&N<=s;U++){const H=P+U*n,X=D*_,W=`${H},${X}`;if(T.has(W))throw new Error(`Overlap at ${W}`);T.add(W),v(N++,H,X)}if(D--,I<=B){for(let U=D;U>=C&&N<=s;U--){const H=P+B*n,X=U*_,W=`${H},${X}`;if(T.has(W))throw new Error(`Overlap at ${W}`);T.add(W),v(N++,H,X)}B--}if(C<=D){for(let U=B;U>=I&&N<=s;U--){const H=P+U*n,X=C*_,W=`${H},${X}`;if(T.has(W))throw new Error(`Overlap at ${W}`);T.add(W),v(N++,H,X)}C++}}if(N-1<s)throw new Error(`Missing pins: assigned ${N-1}, expected ${s}`)}const A=Nr(0,n,.5);return{circuitJson:[...y,A],parameters:e}},rhn=Cr.extend({fn:z(),num_pins:Te(6).default(6),w:z().default("2.1mm"),h:z().default("2.45mm"),p:z().default("0.5mm"),pl:z().default("0.675mm"),pw:z().default("0.35mm"),string:z().optional()}),ihn=t=>{const e=rhn.parse({...t,fn:"sot563"}),n=ce.parse(e.w),r=ce.parse(e.h),i=ce.parse(e.p),o=ce.parse(e.pl),s=ce.parse(e.pw),a=[];for(let p=0;p<6;p++){const{x:f,y:m}=BYe(p+1,n,i,o);a.push(ar(p+1,f,m,o,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:r/2},{x:n/2,y:r/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-r/2},{x:n/2,y:-r/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u=BYe(1,n,i,o),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:u.x-o/2-.3,y:u.y},{x:u.x-o/2-.45,y:u.y+.15},{x:u.x-o/2-.45,y:u.y-.15},{x:u.x-o/2-.3,y:u.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Nr(0,r/2+.4,.25);return{circuitJson:[...a,c,l,h,d],parameters:e}},BYe=(t,e,n,r)=>{const i=e/2-r/2;return t<=3?{x:-i,y:n-(t-1)*n}:{x:i,y:-n+(t-4)*n}},ohn=B7({p:"1.27mm",w:"3.9mm",legsoutside:!0}),shn=t=>{const e=ohn.parse({...t,num_pins:8});return{circuitJson:GR(e),parameters:e}},ahn=B7({p:"1.27mm",w:"7.5mm",legsoutside:!0}),chn=t=>{const e=ahn.parse({...t,num_pins:16});return{circuitJson:GR(e),parameters:e}},lhn=Cr.extend({fn:z(),num_pins:Te(3).default(3),w:z().default("1.2mm"),h:z().default("1.2mm"),pw:z().default("0.40mm"),pl:z().default("0.45mm"),p:z().default("0.575mm")}),uhn=t=>{const e=lhn.parse(t),n=hhn(e),r=Nr(0,ce.parse(e.h),.2);return{circuitJson:[...n,r],parameters:e}},dhn=t=>{const{pn:e,p:n}=t;return e===1?{x:n,y:0}:e===2?{x:-n,y:-.4}:{x:-n,y:.4}},hhn=t=>{const e=[];for(let n=0;n<3;n++){const{x:r,y:i}=dhn({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(ar(n+1,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},phn=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("2.36mm"),h:z().default("1.22mm"),pl:z().default("0.9mm"),pw:z().default("1.2mm"),p:z().default("3.30mm")}),fhn=t=>{const e=phn.parse(t),n=Nr(0,ce.parse(e.h)/4+.4,.3);return{circuitJson:yhn(e).concat(n),parameters:e}},mhn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},yhn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=mhn({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},ghn=Cr.extend({fn:z(),p:ce.optional().default("2.54mm"),id:ce.optional().default("0.7mm"),od:ce.optional().default("1.4mm")}),_hn=t=>{const e=ghn.parse(t),{p:n,id:r,od:i}=e,o=[go(1,-n/2,0,r,i),go(2,n/2,0,r,i)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2+i+r/2,y:0},{x:n/2-i-r/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Nr(0,1.5,.5);return{circuitJson:[...o,s,a],parameters:e}},xhn=(t,e,n,r,i,o=.1)=>{const s=[],a=[],c=Math.max(1,Math.ceil(Math.PI*n/o)),l=Math.PI/c;for(let u=0;u<=c;u++){const d=u*l,h=t+Math.cos(d)*n,p=e+Math.sin(d)*n;h<t-r&&p>=e-i/2&&p<=e+i/2||s.push({x:h,y:p})}for(let u=0;u<=c;u++){const d=Math.PI+u*l,h=t+Math.cos(d)*n,p=e+Math.sin(d)*n;h<t-r&&p>=e-i/2&&p<=e+i/2||a.push({x:h,y:p})}return{topArc:s,bottomArc:a}},bhn=Cr.extend({fn:z(),p:ce.optional().default("5mm"),id:ce.optional().default("0.8mm"),od:ce.optional().default("1.6mm"),ceramic:Oe().optional(),electrolytic:Oe().optional(),polarized:Oe().optional()}),vhn=t=>{const e=bhn.parse(t),{p:n,id:r,od:i}=e;r===.8&&i===1.6&&(e.id=n===5?.8:n*.25,e.od=n===5?1.6:n*.5);const o=[go(1,-n/2,0,e.id,e.od),go(2,n/2,0,e.id,e.od)],s=n+.1,{topArc:a,bottomArc:c}=xhn(0,0,s,e.od/2,e.od),l=.02*n,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:l,pcb_silkscreen_path_id:""},d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:c,stroke_width:l,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:s},{x:0,y:-s}],stroke_width:l,pcb_silkscreen_path_id:""},p=.1*n,f=-(n+p+.04*n),m=s-p-.08*n,y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:f-p,y:m},{x:f+p,y:m}],stroke_width:l,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:f,y:m-p},{x:f,y:m+p}],stroke_width:l,pcb_silkscreen_path_id:""},_=Nr(0,s+.12*n,.1*n),b=[...o,u,d,h,_];return(e.electrolytic===!0||e.polarized===!0)&&b.push(y,g),{circuitJson:b,parameters:e}},U7=(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}),whn=Cr.extend({fn:Te("pushbutton"),w:ce.default(4.5),h:ce.default(6.5),id:ce.default(1),od:ce.default(1.2)}),Shn=t=>{const e=whn.parse(t),n=e.w,r=e.h,i=e.id,o=[go(1,-n/2,r/2,i,i*1.5),go(2,-n/2,-r/2,i,i*1.5),go(3,n/2,-r/2,i,i*1.5),go(4,n/2,r/2,i,i*1.5)],s=[U7([{x:-n/2,y:-r/2},{x:-n/2,y:r/2}]),U7([{x:n/2,y:-r/2},{x:n/2,y:r/2}]),U7([{x:-n/2,y:0},{x:-n/5,y:0},{x:n/5*1/Math.sqrt(2),y:r/8}]),U7([{x:n/2,y:0},{x:n/5,y:0}])],a=Nr(0,r/2+.4,.5);return{circuitJson:[...o,...s,a],parameters:e}},jYe=Cr.extend({fn:z(),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:Oe().default(!1),innerholeedgedistance:ce.default(ce.parse("1.61mm")),silkscreenlabels:Oe().default(!1),silkscreenlabelmargin:ce.default(ce.parse("0.1mm"))}),Ehn=t=>{const e=jYe.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},sU=(t,e,n)=>{let r=[];return n==="right"&&(r=[{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"&&(r=[{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"&&(r=[{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"&&(r=[{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}]),r},Mhn=t=>{const e=jYe.parse(t),n=e.h??Ehn(e),r=[],i=[],o=[];let s=[];const a=1,c=a,l=e.left+e.right+(e.bottom??0)+(e.top??0),d=`pin${l}`.length*.7/2;if(e.right){const m=-((e.right-1)/2)*e.p;for(let y=0;y<e.right;y++){if(y===0&&!e.left&&!e.bottom&&!e.silkscreenlabels&&(s=sU(e.w/2-e.pl*1.4,m+y*e.p,"right")),r.push(ar(y+1+e.left+(e.bottom??0),e.w/2-e.pl/2,m+y*e.p,e.pl,e.pw)),e.silkscreenlabels){const g=y+1+e.left+(e.bottom??0),_=`pin${g}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${g}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl-(d+e.silkscreenlabelmargin),y:m+y*e.p},text:_,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(i.push(go(y+1+e.left+(e.bottom??0)+l,e.w/2,m+y*e.p,a,c)),i.push(go(y+1+e.left+(e.bottom??0)+l*2,e.w/2-e.innerholeedgedistance,m+y*e.p,a,c)))}}if(e.left){const m=(e.left-1)/2*e.p;for(let y=0;y<e.left;y++){if(y===0&&!e.silkscreenlabels&&(s=sU(-e.w/2+e.pl*1.4,m-y*e.p,"left")),r.push(ar(y+1,-e.w/2+e.pl/2,m-y*e.p,e.pl,e.pw)),e.silkscreenlabels){const g=y+1,_=`pin${g}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${g}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl+(d+e.silkscreenlabelmargin),y:m-y*e.p},text:_,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(i.push(go(y+1+l,-e.w/2,m-y*e.p,a,c)),i.push(go(y+1+l*2,-e.w/2+e.innerholeedgedistance,m-y*e.p,a,c)))}}if(e.top){const m=(e.top-1)/2*e.p;for(let y=0;y<e.top;y++){if(y===0&&!e.left&&!e.bottom&&!e.right&&!e.silkscreenlabels&&(s=sU(m-y*e.p,n/2-e.pl*1.4,"top")),r.push(ar(y+1+e.left+e.right+(e.bottom??0),m-y*e.p,n/2-e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const g=y+1+e.left+e.right+(e.bottom??0),_=`pin${g}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${g}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m-y*e.p,y:n/2-e.pl-(d+e.silkscreenlabelmargin)},text:_,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}e.innerhole&&(i.push(go(y+1+e.left+e.right+(e.bottom??0)+l,m-y*e.p,n/2,a,c)),i.push(go(y+1+e.left+e.right+(e.bottom??0)+l*2,m-y*e.p,n/2-e.innerholeedgedistance,a,c)))}}if(e.bottom){const m=-((e.bottom-1)/2)*e.p;for(let y=0;y<e.bottom;y++){if(y===0&&!e.left&&!e.silkscreenlabels&&(s=sU(m+y*e.p,-n/2+e.pl*1.4,"bottom")),r.push(ar(y+1+e.left,m+y*e.p,-n/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const g=y+1+e.left,_=`pin${g}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${g}`,pcb_component_id:"1",layer:"top",anchor_position:{x:m+y*e.p,y:-n/2+e.pl+(d+e.silkscreenlabelmargin)},text:_,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}e.innerhole&&(i.push(go(y+1+e.left+l,m+y*e.p,-n/2,a,c)),i.push(go(y+1+e.left+l*2,m+y*e.p,-n/2+e.innerholeedgedistance,a,c)))}}const h={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},p={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"},f=Nr(0,n/1.8,n/25);return{circuitJson:[...r,...i,...o,p,...e.silkscreenlabels?[]:[h],f],parameters:e}},UYe=Cr.extend({fn:z(),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:Oe().default(!1),innerholeedgedistance:ce.default(ce.parse("1.61mm"))}),Thn=t=>{const e=UYe.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},Chn=(t,e,n,r=1,i=.6)=>{const o=r/2,s=i/2;return{left:[{x:t+o,y:e},{x:t-o,y:e+s},{x:t-o,y:e-s},{x:t+o,y:e}],right:[{x:t-o,y:e},{x:t+o,y:e+s},{x:t+o,y:e-s},{x:t-o,y:e}],top:[{x:t,y:e-o},{x:t-s,y:e+o},{x:t+s,y:e+o},{x:t,y:e-o}],bottom:[{x:t,y:e+o},{x:t-s,y:e-o},{x:t+s,y:e-o},{x:t,y:e+o}]}[n]},Phn=t=>{const e=UYe.parse(t),n=e.h??Thn(e),r=[],i=[],o=[],s=1,a=1.2,c=e.left+e.right+(e.bottom??0)+(e.top??0);let l=[],u=1;if(e.left){const f=(e.left-1)/2*e.p;for(let m=0;m<e.left;m++)m===0&&(l=Chn(-e.w/2-e.pl/2,f-m*e.p,"left")),r.push(ar(u,-e.w/2+e.pl/2,f-m*e.p,e.pl,e.pw)),i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl/2-4.5,y:f-m*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(go(u+c,-e.w/2+e.innerholeedgedistance,f-m*e.p,s,a))}if(e.bottom){const f=(e.bottom-1)/2*e.p;for(let m=e.bottom-1;m>=0;m--)r.push(ar(u,f-m*e.p,-n/2+e.pl/2,e.pw,e.pl)),i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:f-m*e.p,y:-n/2+e.pl/2-3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(go(u+c,f-m*e.p,-n/2+e.innerholeedgedistance,s,a))}if(e.right){const f=-((e.right-1)/2)*e.p;for(let m=0;m<e.right;m++)r.push(ar(u,e.w/2-e.pl/2,f+m*e.p,e.pl,e.pw)),i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl/2+3.7,y:f+m*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(go(u+c,e.w/2-e.innerholeedgedistance,f+m*e.p,s,a))}if(e.top){const f=-((e.top-1)/2)*e.p;for(let m=e.top-1;m>=0;m--)r.push(ar(u,f+m*e.p,n/2-e.pl/2,e.pw,e.pl)),i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:f+m*e.p,y:n/2-e.pl/2+3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(go(u+c,f+m*e.p,n/2-e.innerholeedgedistance,s,a))}const d={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:l,stroke_width:.1},h={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"},p=Nr(0,n/1.8,n/25);return{circuitJson:[...o,...r,...i,h,d,p],parameters:e}},Ahn=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),WM(t)),HYe=Cr.extend({fn:z(),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"))}),Rhn=t=>{const e=HYe.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},aU=(t,e,n,r=1,i=.6)=>{const o=r/2,s=i/2;return{left:[{x:t+o,y:e},{x:t-o,y:e+s},{x:t-o,y:e-s},{x:t+o,y:e}],right:[{x:t-o,y:e},{x:t+o,y:e+s},{x:t+o,y:e-s},{x:t-o,y:e}],top:[{x:t,y:e-o},{x:t-s,y:e+o},{x:t+s,y:e+o},{x:t,y:e-o}],bottom:[{x:t,y:e+o},{x:t-s,y:e-o},{x:t+s,y:e-o},{x:t,y:e+o}]}[n]},Nhn=t=>{const e=HYe.parse(t),n=e.h??Rhn(e),r=[],i=e.id,o=e.od;let s=[];if(e.right){const u=-((e.right-1)/2)*e.p;for(let d=0;d<e.right;d++)d===0&&!e.left&&!e.bottom&&(s=aU(e.w/2+o*1.4,u+d*e.p,"right")),r.push(go(d+1+e.left+(e.bottom??0),e.w/2,u+d*e.p,i,o))}if(e.left){const u=-((e.left-1)/2)*e.p;for(let d=0;d<e.left;d++)d===e.left-1&&(s=aU(-e.w/2-o*1.4,u+d*e.p,"left")),r.push(go(d+1,-e.w/2,u+d*e.p,i,o))}if(e.top){const u=-((e.top-1)/2)*e.p;for(let d=0;d<e.top;d++)d===e.top-1&&!e.left&&!e.bottom&&!e.right&&(s=aU(u+d*e.p,n/2+o*1.4,"top")),r.push(go(d+1+e.right+(e.bottom??0)+e.left,u+d*e.p,n/2,i,o))}if(e.bottom){const u=-((e.bottom-1)/2)*e.p;for(let d=0;d<e.bottom;d++)d===0&&!e.left&&(s=aU(u+d*e.p,-n/2-o*1.4,"bottom")),r.push(go(d+1+e.left,u+d*e.p,-n/2,i,o))}const a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-o,y:n/2+o},{x:e.w/2+o,y:n/2+o},{x:e.w/2+o,y:-n/2-o},{x:-e.w/2-o,y:-n/2-o},{x:-e.w/2-o,y:n/2+o}],stroke_width:.1,layer:"top"},l=Nr(0,n/1.7,n/25);return{circuitJson:[...r,c,l,a],parameters:e}},VYe=(t,e,n,r)=>Array.from({length:25},(i,o)=>{const s=o/24*Math.PI-Math.PI/2;return{x:t+(r==="right"?1:-1)*Math.cos(s)*n,y:e+Math.sin(s)*n}}),khn=Cr.extend({fn:z(),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")}),Ohn=t=>{const e=khn.parse(t),{p:n,id:r,od:i,w:o,h:s}=e,a=s/2,c=[go(1,-n/2,0,r,i),go(2,n/2,0,r,i)],l=VYe(-o/2,0,a,"left"),u=VYe(o/2,0,a,"right"),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...l,...l.slice(1).reverse(),{x:-o/2,y:-s/2},{x:o/2,y:-s/2},...u,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Nr(0,n/4,.5);return{circuitJson:[...c,d,h],parameters:e}};Cr.extend({w:ce,h:ce});var Ihn=t=>{const{w:e,h:n}=t,r=Bs(e),i=Bs(n);return{circuitJson:[ar(1,0,0,r,i),Nr(0,i/2+.5,.2)],parameters:t}},H7=(t,e,n,r,i,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:e,y:n,outer_width:Bs(i),outer_height:Bs(o),hole_width:Bs(r),hole_height:Bs(r),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),Lhn=Cr.extend({fn:z(),num_pins:kn([Te(3),Te(2)]).default(3),p:z().default("1.27mm"),id:z().default("0.72mm"),od:z().default("0.95mm"),w:z().default("4.5mm"),h:z().default("4.5mm"),inline:Oe().default(!1),string:z().optional()}),Dhn=(t,e,n)=>Array.from({length:25},(r,i)=>{const o=i/24*Math.PI;return{x:t+Math.cos(o)*n,y:e+Math.sin(o)*n}}),zhn=t=>{const e=t.string?.match(/^to92_(\d+)/),n=e?Number.parseInt(e[1],10):3,r=Lhn.parse({...t,num_pins:n}),{p:i,id:o,od:s,w:a,h:c,inline:l}=r,u=Number.parseFloat(c)/2,d=Number.parseFloat(i),h=Number.parseFloat(o),p=Number.parseFloat(s),f=p,m=p*(1.5/1.05);let y=[];if(r.num_pins===3)l?y=[Lx({pn:1,x:-d,y:u-d,holeDiameter:h,rectPadWidth:p,rectPadHeight:m}),H7(2,0,u-d,h,f,m),H7(3,d,u-d,h,f,m)]:y=[Lx({pn:1,x:-d,y:u-d,holeDiameter:h,rectPadWidth:p,rectPadHeight:p}),go(2,0,u,h,p),go(3,d,u-d,h,p)];else if(r.num_pins===2)y=[Lx({pn:1,x:-d,y:u-d,holeDiameter:h,rectPadWidth:f,rectPadHeight:m}),H7(2,d,u-d,h,f,m)];else throw new Error("Invalid number of pins for TO-92");const g=Number.parseFloat(a)/2,_=Dhn(0,u,g),b={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[..._,{x:-g,y:0},{x:g,y:0},_[0]],stroke_width:.1,pcb_silkscreen_path_id:""},v=Nr(0,u+1,.5);return{circuitJson:[...y,b,v],parameters:r}},$hn=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("2.15mm"),h:z().default("1.20mm"),pl:z().default("0.5mm"),pw:z().default("0.6mm"),p:z().default("1.4mm")}),Fhn=t=>{const e=$hn.parse(t),n=Nr(0,ce.parse(e.h),.3),r={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:""};return{circuitJson:jhn(e).concat(r,n),parameters:e}},Bhn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},jhn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=Bhn({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Uhn=B7({w:"7.05mm",p:"1.27mm",pw:"0.65mm",pl:"1.975mm"}),Hhn=t=>{const e=Uhn.parse(t),n=[];for(let s=0;s<e.num_pins;s++){const{x:a,y:c}=g0e({num_pins:e.num_pins,pn:s+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(ar(s+1,a,c,e.pl??"1.5mm",e.pw??"0.6mm"))}const r=(e.num_pins/2-1)*e.p+e.pw,i=Nr(0,r/2+1,r/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-e.w/3,y:r/2+.4},{x:e.w/3,y:r/2+.4}],stroke_width:.1};return{circuitJson:[...n,i,o],parameters:e}},Vhn=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("5.0mm"),h:z().default("2.30mm"),pl:z().default("1.25mm"),pw:z().default("2mm"),p:z().default("3.75mm")}),Yhn=t=>{const e=Vhn.parse(t),n=Nr(0,ce.parse(e.h)/2+1,.3),r={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:""};return{circuitJson:Ghn(e).concat(r,n),parameters:e}},Xhn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Ghn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=Xhn({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},qhn=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("4.4mm"),h:z().default("2.1mm"),pl:z().default("1.2mm"),pw:z().default("1.2mm"),p:z().default("2.9mm")}),Whn=t=>{const e=qhn.parse(t),n=Nr(0,ce.parse(e.h)-.5,.3),r={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:""};return{circuitJson:Zhn(e).concat(r,n),parameters:e}},Khn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Zhn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=Khn({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Qhn=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("3.30mm"),h:z().default("1.80mm"),pl:z().default("0.60mm"),pw:z().default("0.45mm"),p:z().default("2.1mm")}),Jhn=t=>{const e=Qhn.parse(t),n=Nr(0,ce.parse(e.h)-.5,.3),r={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:""};return{circuitJson:t0n(e).concat(r,n),parameters:e}},e0n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},t0n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=e0n({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},n0n=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("1.4mm"),h:z().default("0.9mm"),pl:z().default("0.36mm"),pw:z().default("0.25mm"),p:z().default("0.85mm")}),r0n=t=>{const e=n0n.parse(t),n=Nr(0,ce.parse(e.h),.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ce.parse(e.p)/2+.15,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.15,y:ce.parse(e.h)/2},{x:-ce.parse(e.w)/2-.15,y:-ce.parse(e.h)/2},{x:ce.parse(e.p)/2+.15,y:-ce.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:o0n(e).concat(r,n),parameters:e}},i0n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},o0n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=i0n({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},s0n=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("1.3mm"),h:z().default("0.9mm"),pl:z().default("0.4mm"),pw:z().default("0.7mm"),p:z().default("0.7mm")}),a0n=t=>{const e=s0n.parse(t),n=Nr(0,ce.parse(e.h)+.1,.3),r={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:""};return{circuitJson:l0n(e).concat(r,n),parameters:e}},c0n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},l0n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=c0n({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},u0n=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("3,05mm"),h:z().default("1.65mm"),pl:z().default("0.6mm"),pw:z().default("0.6mm"),pad_spacing:z().default("2.2mm")}),d0n=t=>{const e=u0n.parse(t),n=Nr(0,ce.parse(e.h),.3),r={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:""};return{circuitJson:p0n(e).concat(r,n),parameters:e}},h0n=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},p0n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=h0n({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},f0n=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("4.4mm"),h:z().default("2.1mm"),pl:z().default("1.10mm"),pw:z().default("1.10mm"),p:z().default("2.8mm")}),m0n=t=>{const e=f0n.parse(t),n=Nr(0,ce.parse(e.h),.3),r={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:""};return{circuitJson:g0n(e).concat(r,n),parameters:e}},y0n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},g0n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=y0n({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},_0n=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("4.4mm"),h:z().default("2.1mm"),pl:z().default("0.91mm"),pw:z().default("1.22mm"),p:z().default("3.146mm")}),x0n=t=>{const e=_0n.parse(t),n=Nr(0,ce.parse(e.h),.3),r={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:""};return{circuitJson:v0n(e).concat(r,n),parameters:e}},b0n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},v0n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=b0n({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},w0n=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("1.80mm"),h:z().default("1.00mm"),pl:z().default("0.66mm"),pw:z().default("0.5mm"),p:z().default("0.8mm")}),S0n=t=>{const e=w0n.parse(t),n=Nr(0,ce.parse(e.h),.3),r={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:""};return{circuitJson:M0n(e).concat(r,n),parameters:e}},E0n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},M0n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=E0n({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},T0n=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("6.2mm"),h:z().default("3.4mm"),pl:z().default("1.4mm"),pw:z().default("2.1mm"),p:z().default("4.4mm")}),C0n=t=>{const e=T0n.parse(t),n=Nr(0,ce.parse(e.h)/2+.4,.3),r={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:""};return{circuitJson:A0n(e).concat(r,n),parameters:e}},P0n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},A0n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=P0n({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},R0n=Cr.extend({fn:z(),num_pins:kn([Te(3),Te(5)]).default(3),w:z().default("4.20mm"),h:z().default("4.80mm"),pl:z().default("1.3mm"),pw:z().default("0.9mm"),p:z().default("1.5mm"),string:z().optional()}),N0n=t=>{const e=[],n=Number.parseFloat(t.p),r=Number.parseFloat(t.pw),i=Number.parseFloat(t.w),o=Number.parseFloat(t.pl),s=.175,a=(o-(o+s))/2;e.push(ar(1,-i/2+a,n,o,r),ar(2,-i/2,0,o+s,r),ar(3,-i/2+a,-n,o,r));const c=Nr(0,0,.3),l=Number.parseFloat(t.w)/2-1,u=Number.parseFloat(t.h)/2,d={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-l,y:u},{x:l,y:u},{x:l,y:u/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},h={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-l,y:-u},{x:l,y:-u},{x:l,y:-u/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,d,h,c]},k0n=t=>{const e=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),e.push(ar(1,-1.85,-1.5,1.5,.7),ar(2,-1.85,1.5,1.5,.7),ar(3,0,0,.8,2),ar(4,1.85,-1.5,1.5,.7),ar(5,1.85,1.5,1.5,.7));const n=Nr(0,Number.parseFloat(t.h)/2+.5,.3),r=Number.parseFloat(t.w)/2-1,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r,y:i},{x:r,y:i}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-r,y:-i},{x:r,y:-i}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},O0n=t=>{const e=t.string?.match(/^sot89_(\d+)/),n=e?Number.parseInt(e[1],10):3,r=R0n.parse({...t,num_pins:n});if(r.num_pins===3)return{circuitJson:N0n(r),parameters:r};if(r.num_pins===5)return{circuitJson:k0n(r),parameters:r};throw new Error("Invalid number of pins for SOT89")},I0n=Cr.extend({fn:z(),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:z().optional()}),YYe=t=>{const e=I0n.parse(t),{id:n,od:r,w:i,h:o,string:s}=e,a=e.num_pins??Number.parseInt(s?.match(/^to220(?:_|-)(\d+)/i)?.[1]??"3"),c=-1,l=i/2,u=o/2,d=2.5,h=i*.4,p=Math.max(d,h/(a-1)),f=Array.from({length:a},(v,T)=>{const E=a%2===0?(T-a/2+.5)*p:(T-Math.floor(a/2))*p;return go(T+1,E,c,n,r)}),m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l,y:-u},{x:l,y:-u},{x:l,y:u},{x:-l,y:u},{x:-l,y:-u}],stroke_width:.1,pcb_silkscreen_path_id:""},y=-u+2*o/3,g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l,y},{x:l,y}],stroke_width:.1,pcb_silkscreen_path_id:""},_=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-i/6,y},{x:-i/6,y:u}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:i/6,y},{x:i/6,y:u}],stroke_width:.1,pcb_silkscreen_path_id:""}],b=Nr(0,o/2+.6,.5);return{circuitJson:[...f,m,g,..._,b],parameters:{...e,p}}},b0e=2.54,L0n=Cr.extend({fn:z(),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:z().optional()}),D0n=t=>{const e=L0n.parse(t),n=e.num_pins??Number.parseInt(e.string?.match(/^to220f(?:_|-)(\d+)/i)?.[1]??"3"),r=YYe({...e,fn:"to220",string:e.string?.replace(/^to220f/i,"to220"),num_pins:n}),i=-1,o=Array.from({length:n},(a,c)=>{const l=n%2===0?(c-n/2+.5)*b0e:(c-Math.floor(n/2))*b0e;return c===0?Lx({pn:1,x:l,y:i,holeDiameter:e.id,rectPadWidth:e.od,rectPadHeight:e.ph}):H7(c+1,l,i,Bs(e.id),Bs(e.od),Bs(e.ph))}),s=r.circuitJson.filter(a=>a.type!=="pcb_plated_hole");return{circuitJson:[...o,...s],parameters:{...e,p:b0e,num_pins:n}}},z0n=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("5.40mm"),h:z().default("2.30mm"),pl:z().default("1.30mm"),pw:z().default("1.70mm"),p:z().default("3.5mm")}),$0n=t=>{const e=z0n.parse(t),n=Nr(0,ce.parse(e.h)/2+.4,.3),r={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:""};return{circuitJson:B0n(e).concat(r,n),parameters:e}},F0n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},B0n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=F0n({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},j0n=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("1.90mm"),h:z().default("1.33mm"),pl:z().default("0.5mm"),pw:z().default("0.7mm"),p:z().default("0.8mm")}),U0n=t=>{const e=j0n.parse(t),n=Nr(0,ce.parse(e.h)+.1,.3),r={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:""};return{circuitJson:V0n(e).concat(r,n),parameters:e}},H0n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},V0n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=H0n({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Y0n=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("7.0mm"),h:z().default("3.35mm"),pl:z().default("1.50mm"),pw:z().default("2.70mm"),p:z().default("4.8mm")}),X0n=t=>{const e=Y0n.parse(t),n=Nr(0,ce.parse(e.h),.3),r={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:""};return{circuitJson:q0n(e).concat(r,n),parameters:e}},G0n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},q0n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=G0n({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},W0n=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("3.0mm"),h:z().default("1.80mm"),pl:z().default("0.80mm"),pw:z().default("1.20mm"),p:z().default("1.6mm")}),K0n=t=>{const e=W0n.parse(t),n=Nr(0,ce.parse(e.h),.3),r={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:""};return{circuitJson:Q0n(e).concat(r,n),parameters:e}},Z0n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Q0n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=Z0n({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},J0n=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("7.10mm"),h:z().default("3.40mm"),pl:z().default("2.45mm"),pw:z().default("1.80mm"),p:z().default("4.05mm")}),epn=t=>{const e=J0n.parse(t),n=Nr(0,ce.parse(e.h)/2+.5,.3),r={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:""};return{circuitJson:npn(e).concat(r,n),parameters:e}},tpn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},npn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=tpn({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},rpn=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("4.80mm"),h:z().default("2.10mm"),pl:z().default("1.30mm"),pw:z().default("1.40mm"),p:z().default("2.9mm")}),ipn=t=>{const e=rpn.parse(t),n=Nr(0,ce.parse(e.h)-.5,.3),r={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:""};return{circuitJson:spn(e).concat(r,n),parameters:e}},opn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},spn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=opn({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},apn=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("7.30mm"),h:z().default("4.40mm"),pl:z().default("2.50mm"),pw:z().default("2.30mm"),p:z().default("4.30mm")}),cpn=t=>{const e=apn.parse(t),n=Nr(0,ce.parse(e.h)/2+.5,.3),r={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:""};return{circuitJson:upn(e).concat(r,n),parameters:e}},lpn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},upn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=lpn({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},dpn=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("10.70mm"),h:z().default("6.60mm"),pl:z().default("3.30mm"),pw:z().default("2.50mm"),p:z().default("6.80mm")}),hpn=t=>{const e=dpn.parse(t),n=Nr(0,3,.3),r={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:""};return{circuitJson:fpn(e).concat(r,n),parameters:e}},ppn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},fpn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=ppn({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},mpn=Cr.extend({fn:z(),num_pins:Ue().default(4),w:z().default("8.50mm"),h:z().default("6.90mm"),pl:z().default("2mm"),pw:z().default("1.5mm"),p:z().default("2.30mm"),string:z().optional()}),ypn=t=>{const e=t.string?.match(/^sot223_(\d+)/),n=e?Number.parseInt(e[1],10):4;if(n===8){const i=xpn.parse({...t,num_pins:n});return{circuitJson:GR(i),parameters:i}}const r=mpn.parse({...t,num_pins:n});if(r.num_pins===4)return{circuitJson:_pn(r),parameters:r};if(r.num_pins===5)return{circuitJson:vpn(r),parameters:r};if(r.num_pins===6)return{circuitJson:Spn(r),parameters:r};throw new Error("Invalid number of pins")},gpn=t=>{const{pn:e,w:n,p:r}=t;return e===1?{x:-n/2+1.1,y:r}:e===2?{x:-n/2+1.1,y:0}:e===3?{x:-n/2+1.1,y:-r}:{x:n/2-1.1,y:0}},_pn=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=gpn({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)}),u=a===3?3.8:Number.parseFloat(t.pw);e.push(ar(a+1,c,l,Number.parseFloat(t.pl),u))}const n=Nr(0,0,.3),r=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r,y:i},{x:r,y:i},{x:r,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-r,y:-i},{x:r,y:-i},{x:r,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},xpn=B7({p:"0.90mm",w:"2.8mm",legsoutside:!0}),bpn=t=>{const{p:e,pn:n,w:r}=t;if(n===1)return{x:-r/2+1.2,y:e/2+e};if(n===2)return{x:-r/2+1.2,y:e/2};if(n===3)return{x:-r/2+1.2,y:-e/2};if(n===4)return{x:-r/2+1.2,y:-e/2-e};if(n===5)return{x:r/2-1,y:0};throw new Error("Invalid pin number")},vpn=t=>{const e=[];for(let a=1;a<=t.num_pins;a++){const{x:c,y:l}=bpn({h:Number.parseFloat(t.h),p:1.5,pn:a,w:Number.parseFloat(t.w)});let u=Number.parseFloat(t.pw),d=Number.parseFloat(t.pl);a===5?(u=3.4,d=1.8):(u=1,d=2.2),e.push(ar(a,c,l,d,u))}const n=Number.parseFloat(t.w)/2-2.4,r=Number.parseFloat(t.h)/2,i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n,y:r},{x:n,y:r},{x:n,y:r/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n,y:-r},{x:n,y:-r},{x:n,y:-r/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Nr(0,0,.3);return[...e,i,o,s]},wpn=t=>{const{p:e,pn:n,w:r}=t;if(n===1)return{x:-r/2+1.2,y:2*e};if(n===2)return{x:-r/2+1.2,y:e};if(n===3)return{x:-r/2+1.2,y:0};if(n===4)return{x:-r/2+1.2,y:-e};if(n===5)return{x:-r/2+1.2,y:-2*e};if(n===6)return{x:r/2-1.175,y:0};throw new Error("Invalid pin number")},Spn=t=>{const e=[];for(let a=1;a<=t.num_pins;a++){const{x:c,y:l}=wpn({h:Number.parseFloat(t.h),p:1.3,pn:a,w:8.7});let u=Number.parseFloat(t.pw),d=Number.parseFloat(t.pl);a===6?(u=3.4,d=2.15):(u=.6,d=2.2),e.push(ar(a,c,l,d,u))}const n=Number.parseFloat(t.w)/2-2.4,r=Number.parseFloat(t.h)/2,i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n,y:r},{x:n,y:r},{x:n,y:r/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n,y:-r},{x:n,y:-r},{x:n,y:-r/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Nr(0,0,.3);return[...e,i,o,s]},Epn=Cr.extend({fn:z(),num_pins:Ue().default(3),w:z().default("3.40mm"),h:z().default("3.30mm"),pl:z().default("1mm"),pw:z().default("0.7mm"),p:z().default("1.2mm"),string:z().optional()}),Mpn=t=>{const e=t.string?.match(/^sot23w_(\d+)/),n=e?Number.parseInt(e[1],3):3,r=Epn.parse({...t,num_pins:n});if(r.num_pins===3)return{circuitJson:Cpn(r),parameters:r};throw new Error("Invalid number of pins")},Tpn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.95}:e===2?{x:-n,y:-.95}:{x:n,y:0}},Cpn=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=Tpn({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(ar(a+1,c,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=Nr(0,Number.parseInt(t.h)/2+1,.3),r=Number.parseFloat(t.w)/2-1,i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r,y:i},{x:r+.3,y:i},{x:r+.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:-r,y:-i},{x:r+.3,y:-i},{x:r+.3,y:-i/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Ppn=Cr.extend({fn:z(),num_pins:kn([Te(3),Te(2)]).default(3),p:z().default("1.27mm"),id:z().default("0.72mm"),od:z().default("0.95mm"),w:z().default("2.5mm"),h:z().default("4.2mm"),string:z().optional()}),Apn=t=>{const{p:e,id:n,od:r,w:i,h:o}=t,s=Number.parseFloat(o)/2,a=Number.parseFloat(e);return[go(1,-a,s-a,n,r),go(2,0,s-a,n,r),go(3,a,s-a,n,r)]},Rpn=t=>{const{p:e,id:n,od:r,h:i}=t,o=Number.parseFloat(i)/2,s=Number.parseFloat(e);return[go(1,-s,o-s,n,r),go(2,s,o-s,n,r)]},Npn=t=>{const e=t.string?.match(/^to92s_(\d+)/),n=e?Number.parseInt(e[1],10):3,r=Ppn.parse({...t,num_pins:n});let i=[];if(r.num_pins===3)i=Apn(r);else if(r.num_pins===2)i=Rpn(r);else throw new Error("Invalid number of pins for TO-92");const o=Number.parseFloat(r.h)/2,s=Number.parseFloat(r.p),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o,y:o-s},{x:-1.9,y:0},{x:1.9,y:0},{x:o,y:o-s},{x:1.5,y:Number.parseFloat(r.h)/2+.5},{x:-1.5,y:Number.parseFloat(r.h)/2+.5},{x:-o,y:o-s}],stroke_width:.1,pcb_silkscreen_path_id:""},c=Nr(0,o+1,.5);return{circuitJson:[...i,a,c],parameters:r}},kpn=Cr.extend({fn:z(),p:ce.optional(),id:ce.optional(),pw:ce.optional(),pl:ce.optional(),w:ce.optional(),h:ce.optional(),sh:Oe().optional().describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Oe().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),zh:Oe().optional().describe("JST ZH (Through-hole) connector family. 1.5mm pitch wire-to-board."),string:z().optional()}),Opn={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 Ipn(t){return t.sh?"sh":t.ph?"ph":t.zh?"zh":"ph"}function Lpn(t,e,n,r,i,o){const s=[];if(t==="ph"){const a=-((e-1)/2)*n;for(let c=0;c<e;c++){const l=a+c*n;s.push(Lx({pn:c+1,x:l,y:2,holeDiameter:r,rectPadWidth:i,rectPadHeight:o}))}}else if(t==="zh"){const a=-((e-1)/2)*n;for(let c=0;c<e;c++){const l=a+c*n;c===0?s.push(Lx({pn:c+1,x:l,y:0,holeDiameter:r,rectPadWidth:i,rectPadHeight:o,rectBorderRadius:.12499977})):s.push(H7(c+1,l,0,r,i,o))}}else{const a=-((e-1)/2)*n;for(let l=0;l<e;l++){const u=a+l*n;s.push(ar(l+1,u,-1.325,i,o))}const c=(e-1)/2*n+1.3;s.push(ar(e+1,-c,1.22,1.2,1.8)),s.push(ar(e+2,c,1.22,1.2,1.8))}return s}function Dpn(t,e,n,r,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"&&r&&i){const o=(r-1)*i,s=-o/2-1.5,a=o/2+1.5,c=-n/2,l=n/2;return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:c},{x:a,y:c},{x:a,y:l},{x:s,y:l},{x:s,y:c}],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 zpn=t=>{const e=kpn.parse(t),n=Ipn(e),r=Opn[n],i=e.p??r.p,o=e.id??r.id,s=e.pw??r.pw,a=e.pl??r.pl,c=e.w??r.w,l=e.h??r.h;let u;const d=t.num_pins;typeof d=="number"&&(u=d);const h=typeof t.string=="string"?t.string:"",p=h.match(/(?:^|_)jst(\d+)(?:_|$)/),f=h.match(/(?:^|_)zh(\d+)(?:_|$)/);if(p&&p[1]){const _=Number.parseInt(p[1],10);Number.isNaN(_)||(u=_)}if(f&&f[1]){const _=Number.parseInt(f[1],10);Number.isNaN(_)||(u=_)}if(typeof u!="number")throw new Error(`JST requires an explicit pin count (e.g. jst6_sh or .jst(6))${e.string?`, from string "${e.string}"`:""}`);const m=Lpn(n,u,i,o,s,a),y=Dpn(n,c,l,u,i),g=Nr(0,l/2+1,.5);return{circuitJson:[...m,y,g],parameters:{...e,p:i,id:o,pw:s,pl:a,w:c,h:l,num_pins:u,sh:n==="sh",ph:n==="ph",zh:n==="zh"}}},$pn=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("3.30mm"),h:z().default("1.70mm"),pl:z().default("0.80mm"),pw:z().default("1mm"),p:z().default("1.90mm")}),Fpn=t=>{const e=$pn.parse(t),n=Nr(0,ce.parse(e.h)/2+.5,.3),r={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:""};return{circuitJson:jpn(e).concat(r,n),parameters:e}},Bpn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},jpn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=Bpn({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Upn=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"}}},Hpn=Cr.extend({fn:z(),num_pins:kn([Te(8),Te(10)]).default(8),w:z().optional(),h:z().optional(),p:z().optional(),pl:z().optional(),pw:z().optional(),string:z().optional()}),Vpn=t=>{const e=Hpn.parse(t),n=Upn(e.num_pins),r=ce.parse(e.w||n.w),i=ce.parse(e.h||n.h),o=ce.parse(e.p||n.p),s=ce.parse(e.pl||n.pl),a=ce.parse(e.pw||n.pw),c=[],l=e.num_pins/2;for(let _=0;_<e.num_pins;_++){const{x:b,y:v}=XYe(e.num_pins,_+1,r,o),T=_<l?_+1:e.num_pins-(_-l);c.push(ar(T,b,v,s,a))}const u=r,d=i,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:d/2},{x:u/2,y:d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:-d/2},{x:u/2,y:-d/2}],stroke_width:.05,pcb_silkscreen_path_id:""},f=XYe(e.num_pins,1,u,o),m={x:f.x-.8,y:f.y},y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:m.x-.4,y:m.y},{x:m.x-.7,y:m.y+.3},{x:m.x-.7,y:m.y-.3},{x:m.x-.4,y:m.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},g=Nr(0,d/2+.5,.3);return{circuitJson:[...c,h,p,g,y],parameters:e}},XYe=(t,e,n,r)=>{const i=t/2,o=(e-1)%i,s=e<=i?-1:1,a=(i-1)/2-o;return{x:s*ce.parse(t===8?"1.8mm":"2.2mm"),y:a*r}},Ypn=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"}}},Xpn=Cr.extend({fn:z(),num_pins:kn([Te(8),Te(10),Te(12),Te(16)]).default(8),w:z().optional(),h:z().optional(),p:z().optional(),pl:z().optional(),pw:z().optional(),string:z().optional()}),GYe=(t,e,n,r)=>{const i=t/2,o=(e-1)%i,s=e<=i?-1:1,a=(i-1)/2-o;return{x:s*ce.parse("2mm"),y:a*r}},Gpn=t=>{const e=Xpn.parse(t),n=Ypn(e.num_pins),r=ce.parse(e.w||n.w),i=ce.parse(e.h||n.h),o=ce.parse(e.p||n.p),s=ce.parse(e.pl||n.pl),a=ce.parse(e.pw||n.pw),c=[];for(let g=0;g<e.num_pins;g++){const{x:_,y:b}=GYe(e.num_pins,g+1,r,o);c.push(ar(g+1,_,b,s,a))}const l=r,u=i,d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:u/2},{x:l/2,y:u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-u/2},{x:l/2,y:-u/2}],stroke_width:.05,pcb_silkscreen_path_id:""},p=GYe(e.num_pins,1,l,o),f={x:p.x-.8,y:p.y},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:f.x-.4,y:f.y},{x:f.x-.7,y:f.y+.3},{x:f.x-.7,y:f.y-.3},{x:f.x-.4,y:f.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},y=Nr(0,u/2+.5,.3);return{circuitJson:[...c,d,h,y,m],parameters:e}},qpn=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("3.8mm"),h:z().default("1.65mm"),pl:z().default("1.2mm"),pw:z().default("1.2mm"),pad_spacing:z().default("2.6mm")}),Wpn=t=>{const e=qpn.parse(t),n=Nr(0,ce.parse(e.h),.3),r={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:""};return{circuitJson:Zpn(e).concat(r,n),parameters:e}},Kpn=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Zpn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=Kpn({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Qpn=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("3.20mm"),h:z().default("1.65mm"),pl:z().default("0.8mm"),pw:z().default("0.9mm"),pad_spacing:z().default("2.1mm")}),Jpn=t=>{const e=Qpn.parse(t),n=Nr(0,ce.parse(e.h),.3),r={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:""};return{circuitJson:tfn(e).concat(r,n),parameters:e}},efn=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},tfn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=efn({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},nfn=Cr.extend({fn:z(),num_pins:kn([Te(6),Te(8)]).default(8),w:z().default("3mm"),h:z().default("3mm"),p:z().default("0.5mm"),pl:z().default("0.52mm"),pw:z().default("0.35mm"),epw:z().default("1.40mm"),eph:z().default("1.60mm"),string:z().optional(),ep:Oe().default(!1)}),rfn=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,r=nfn.parse({...t,num_pins:n}),i=ce.parse(r.w),o=ce.parse(r.h),s=ce.parse(r.p),a=ce.parse(r.pl),c=ce.parse(r.pw),l=ce.parse(r.epw),u=ce.parse(r.eph),d=[];for(let v=0;v<r.num_pins;v++){const{x:T,y:E}=qYe(r.num_pins,v+1,i,s);d.push(ar(v+1,T,E,a,c))}r.ep&&d.push(ar(r.num_pins+1,0,0,l,u));const h=i,p=o,f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:p/2},{x:h/2,y:p/2}],stroke_width:.05,pcb_silkscreen_path_id:""},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-h/2,y:-p/2},{x:h/2,y:-p/2}],stroke_width:.05,pcb_silkscreen_path_id:""},y=qYe(r.num_pins,1,h,s),g={x:y.x-.4,y:y.y},_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:g.x-.4,y:g.y},{x:g.x-.7,y:g.y+.3},{x:g.x-.7,y:g.y-.3},{x:g.x-.4,y:g.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},b=Nr(0,p/2+.5,.3);return{circuitJson:[...d,f,m,b,_],parameters:r}},qYe=(t,e,n,r)=>{const i=t/2,o=(e-1)%i,s=e<=i?-1:1,a=(i-1)/2-o;return{x:s*ce.parse("1.4mm"),y:a*r}},ifn=Cr.extend({fn:z(),num_pins:Ue().optional().default(8),p:Qe.describe("pitch (distance between center of each pin)"),w:ce.describe("width between vertical rows of pins"),grid:iU.describe("width and height of the border of the footprint"),ep:iU.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")}),ofn=t=>{const e=ifn.parse(t),{num_pins:n,p:r,w:i,grid:o,ep:s,epx:a,pinw:c,pinh:l}=e;if(n%2!==0)throw new Error("invalid number of pins");const u=[];for(let p=0;p<n;p++){const{pinX:f,pinY:m}=sfn({pinCount:n,pinIndex:p,width:i,pitch:r});u.push(ar(p+1,f,m,c,l))}s.x>0&&s.y>0&&u.push(ar(e.num_pins+1,a,0,s.x,s.y));const d=afn(o),h=Nr(0,o.y/2+r,o.y/6);return{circuitJson:[...u,...d,h],parameters:e}},sfn=t=>{let e=0,n=0;const r=(t.pinCount/2-1)*t.pitch/2,i=t.pinCount/2;return t.pinIndex+1<=i?(e=t.pitch*t.pinIndex-r,n=0-t.width/2):(e=t.pitch*(t.pinCount-t.pinIndex-1)-r,n=t.width/2),{pinX:n,pinY:e}},afn=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}]},cfn=t=>{const{num_pins:e,bridged:n,p:r=2.54,pw:i=1.5,ph:o=1.5}=t,s=ce.parse(r),a=ce.parse(i),c=ce.parse(o),l=Math.min(c/4,.5),u=[];for(let v=0;v<e;v++)u.push(ar(v+1,v*s,0,a,c));let d=[];if(n){const v=n.split("").map(Number);if(v.length>1)for(let T=0;T<v.length-1;T++){const E=v[T],A=v[T+1];if(typeof E=="number"&&typeof A=="number"&&!isNaN(E)&&!isNaN(A)){const P=(E-1)*s,N=(A-1)*s,C=Math.sign(N-P),D=P+C*(a/2),I=N-C*(a/2);d.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${E}}`,x:D,y:0,width:l,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${A}}`,x:I,y:0,width:l,layer:"top",route_type:"wire"}]})}}}const h=(e-1)*s+a+.7,p=c+1,f=(e-1)*s/2,m=0,y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:f-h/2,y:m-p/2},{x:f+h/2,y:m-p/2},{x:f+h/2,y:m+p/2},{x:f-h/2,y:m+p/2},{x:f-h/2,y:m-p/2}],stroke_width:.15},_=m+p/2+.6,b=Nr(f,_,.4);return{circuitJson:[...u,...d,y,b],parameters:t}},WYe={fn:Te("sot457"),num_pins:Te(6).default(6),pillh:z().default("0.45mm"),pillw:z().default("1.45mm"),pl:z(),pw:z(),p:z(),wave:Oe().optional(),reflow:Oe().optional()},lfn=Cr.extend({...WYe,h:z().default("2.5mm"),w:z().default("2.7mm"),pl:z().default("0.8mm"),pw:z().default("0.55mm"),p:z().default("0.95mm")}),ufn=Cr.extend({...WYe,h:z().default("3mm"),w:z().default("4mm"),pillr:z().default("0.225mm"),pl:z().default("1.45mm"),pw:z().default("1.5mm"),p:z().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)})),Fb=t=>Number.parseFloat(t.replace("mm","")),KYe=({pitch:t,width:e,pinNumber:n})=>{const o={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(!o)throw new Error(`Invalid pin number: ${n}`);return o},ZYe=t=>{const e=[],n=Fb(t.p),r=Fb(t.pl),i=Fb(t.pw),o=Fb(t.w),s=Fb(t.h);if(t.wave){const f={1:({padWidth:m,padHeight:y})=>ar(1,-n,n,y,m),2:({padWidth:m,padHeight:y})=>ar(2,-n,-n,y,m),3:({padWidth:m,padHeight:y})=>oU(3,-n,0,Fb(t.pillw),Fb(t.pillh)),4:({padWidth:m,padHeight:y})=>oU(4,n,0,Fb(t.pillw),Fb(t.pillh)),5:({padWidth:m,padHeight:y})=>ar(5,n,n,y,m),6:({padWidth:m,padHeight:y})=>ar(6,n,-n,y,m)};for(let m=1;m<=t.num_pins;m++){const y=f[m];y&&e.push(y({padWidth:r,padHeight:i}))}}else for(let f=1;f<=t.num_pins;f++){const{x:m,y}=KYe({pitch:n,width:o,pinNumber:f});e.push(ar(f,m,y,r,i))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/3,y:s/2+n/1.3},{x:o/3,y:s/2+n/1.3}],stroke_width:.05},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o/3,y:-s/2-n/1.3},{x:o/3,y:-s/2-n/1.3}],stroke_width:.05},l=Nr(0,s+.5,.3),u=KYe({pitch:n,width:o,pinNumber:1}),d=t.wave?1:.5,h=t.wave?.7:.3;u.x-=t.wave?i:i*1.7;const p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:u.x+d/2,y:u.y},{x:u.x-d/2,y:u.y+h/2},{x:u.x-d/2,y:u.y-h/2},{x:u.x+d/2,y:u.y}],stroke_width:.05};return[l,a,c,p,...e]},dfn=t=>{if(t.wave){const n=ufn.parse({...t,fn:"sot457"});return{circuitJson:ZYe(n),parameters:n}}const e=lfn.parse(t);return{circuitJson:ZYe(e),parameters:e}},hfn=Cr.extend({fn:z(),num_pins:Te(6).default(6),w:z().default("1.1mm"),h:z().default("1.45mm"),p:z().default("0.35mm"),pl:z().default("0.2mm"),pw:z().default("0.2mm"),string:z().optional()}),pfn=t=>{const e=hfn.parse({...t,fn:"sot963"}),n=ce.parse(e.w),r=ce.parse(e.h),i=ce.parse(e.p),o=ce.parse(e.pl),s=ce.parse(e.pw),a=[];for(let p=0;p<6;p++){const{x:f,y:m}=QYe(p+1,n,i,o);a.push(ar(p+1,f,m,o,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:r/2},{x:n/2,y:r/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-r/2},{x:n/2,y:-r/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u=QYe(1,n,i,o),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:u.x-o/2-.3,y:u.y},{x:u.x-o/2-.45,y:u.y+.15},{x:u.x-o/2-.45,y:u.y-.15},{x:u.x-o/2-.3,y:u.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Nr(0,r/2+.4,.25);return{circuitJson:[...a,c,l,h,d],parameters:e}},QYe=(t,e,n,r)=>{const i=e/2-r/2;return t<=3?{x:-i,y:n-(t-1)*n}:{x:i,y:-n+(t-4)*n}},ffn=Cr.extend({fn:z(),num_pins:kn([Te(3),Te(2)]).default(3),p:z().default("3.8mm"),id:z().default("1.25mm"),od:z().default("2.35mm"),ca:z().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:z().default("5.35mm"),h:z().default("4mm"),string:z().optional()}),mfn=t=>{const{p:e,id:n,od:r,h:i,ca:o}=t,s=Number.parseFloat(i),a=Number.parseFloat(o);return[go(1,0,a/4+.3,n,r),go(2,s,0,n,r),go(3,0,-a/4-.3,n,r)]},yfn=t=>{const e=t.string?.match(/^potentiometer_(\d+)/),n=e?Number.parseInt(e[1],10):3,r=ffn.parse({...t,num_pins:n});let i=[];r.num_pins===3&&(i=mfn(r));const o=Number.parseFloat(r.ca)/2+.15,s=Number.parseFloat(r.w),a=Number.parseFloat(r.od)/2+.35,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o-1.75},{x:0,y:o},{x:s,y:o},{x:s,y:a}],stroke_width:.1,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-a},{x:s,y:-o},{x:0,y:-o},{x:0,y:-o+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},u=Number.parseFloat(r.w)/2,d=Nr(u,o+1,.5);return{circuitJson:[...i,c,l,d],parameters:r}},gfn=Cr.extend({fn:z(),p:ce.optional().default("7.5mm"),id:ce.optional().default("1mm"),od:ce.optional().default("2mm"),d:ce.optional().default("10.5mm")}),_fn=(t,e,n,r,i)=>{const o=[],s=[];for(let a=0;a<=50;a++){const c=a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-r&&u>=e-i/2&&u<=e+i/2||o.push({x:l,y:u})}for(let a=0;a<=50;a++){const c=Math.PI+a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-r&&u>=e-i/2&&u<=e+i/2||s.push({x:l,y:u})}return{topArc:o,bottomArc:s}},xfn=t=>{const e=gfn.parse(t),{p:n,id:r,od:i,d:o}=e,s=[go(1,-n/2,0,r,i),go(2,n/2,0,r,i)],{topArc:a,bottomArc:c}=_fn(0,0,o/2+.1,i/2,i),l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:c,stroke_width:.1,pcb_silkscreen_path_id:""},d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-(o/2+.5),p=i/2+1.5,f=.5,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h-f,y:p},{x:h+f,y:p}],stroke_width:.1,pcb_silkscreen_path_id:""},y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h,y:p-f},{x:h,y:p+f}],stroke_width:.1,pcb_silkscreen_path_id:""},g=Nr(0,o/2+1,.5);return{circuitJson:[...s,l,u,d,m,y,g],parameters:e}},bfn=Cr.extend({fn:z(),num_pins:Te(2).default(2),w:z().default("6.5mm"),h:z().default("3mm"),pl:z().default("1.75mm"),pw:z().default("2.40mm"),p:z().default("4.75mm")}),vfn=t=>{const e=bfn.parse(t),n=Nr(0,ce.parse(e.h)-.5,.3),r={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:""};return{circuitJson:Sfn(e).concat(r,n),parameters:e}},wfn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},Sfn=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:r,y:i}=wfn({pn:n,p:Number.parseFloat(t.p)});e.push(ar(n,r,i,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Efn=Cr.extend({fn:z(),num_pins:Ue().default(3),w:z().default("2.45mm"),h:z().default("2.40mm"),pl:z().default("0.92mm"),pw:z().default("0.45mm"),p:z().default("0.891mm"),string:z().optional()}),Mfn=t=>{const e=t.string?.match(/^sot323_(\d+)/),n=e?Number.parseInt(e[1],3):3,r=Efn.parse({...t,num_pins:n});if(r.num_pins===3)return{circuitJson:Cfn(r),parameters:r};throw new Error("Invalid number of pins")},Tfn=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.65}:e===2?{x:-n,y:-.65}:{x:n,y:0}},Cfn=t=>{const e=[];for(let a=0;a<t.num_pins;a++){const{x:c,y:l}=Tfn({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(ar(a+1,c,l,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=Nr(0,Number.parseInt(t.h)/2+1,.3),r=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),i=Number.parseFloat(t.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-r,y:i+.3},{x:r,y:i+.3},{x:r,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:-r,y:-i-.3},{x:r,y:-i-.3},{x:r,y:-i/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,o,s,n]},Pfn=Cr.extend({fn:z(),circle:Oe().optional(),rect:Oe().optional(),square:Oe().optional(),pill:Oe().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:z().optional()}).transform(t=>{let e="rect";t.circle&&(e="circle"),t.square&&(e="square"),t.rect&&(e="rect"),t.pill&&(e="pill");let n,r,i;return e==="circle"?t.r!==void 0?n=Bs(t.r):t.pr!==void 0?n=Bs(t.pr):t.radius!==void 0?n=Bs(t.radius):t.d!==void 0?n=Bs(t.d)/2:t.pd!==void 0?n=Bs(t.pd)/2:t.diameter!==void 0?n=Bs(t.diameter)/2:n=Bs("1mm")/2:(t.w!==void 0?r=Bs(t.w):t.pw!==void 0?r=Bs(t.pw):t.width!==void 0?r=Bs(t.width):t.s!==void 0?r=Bs(t.s):t.size!==void 0?r=Bs(t.size):r=Bs("1mm"),t.h!==void 0?i=Bs(t.h):t.ph!==void 0?i=Bs(t.ph):t.height!==void 0?i=Bs(t.height):e==="square"||e==="rect"?i=r:i=Bs("1mm")),{fn:t.fn,shape:e,radius:n,width:r,height:i}}),Afn=t=>{const e=Pfn.parse(t),{shape:n,radius:r,width:i,height:o}=e;let s,a;return n==="circle"?(s=RYe(1,{x:0,y:0,radius:r}),a=r+.5):n==="pill"?(s=oU(1,0,0,i,o),a=Math.max(i,o)/2+.5):(s=ar(1,0,0,i,o),a=o/2+.5),{circuitJson:[s,Nr(0,a,.2)],parameters:e}},Rfn=Cr.extend({fn:z(),d:ce.optional(),hd:ce.optional(),r:ce.optional(),hr:ce.optional(),pd:ce.optional(),pr:ce.optional(),squarepad:Oe().optional().default(!1)}).transform(t=>{let e;t.d!==void 0?e=Bs(t.d):t.hd!==void 0?e=Bs(t.hd):t.r!==void 0?e=Bs(t.r)*2:t.hr!==void 0?e=Bs(t.hr)*2:e=Bs("1mm");let n;return t.pd!==void 0?n=Bs(t.pd):t.pr!==void 0?n=Bs(t.pr)*2:n=e*(1.5/1),{fn:t.fn,d:e,pd:n,squarepad:t.squarepad??!1}}),Nfn=t=>{const e=Rfn.parse(t),{d:n,pd:r,squarepad:i}=e;return{circuitJson:[i?Lx({pn:1,x:0,y:0,holeDiameter:n,rectPadWidth:r,rectPadHeight:r}):go(1,0,0,n,r),Nr(0,r/2+.5,.2)],parameters:e}},kfn=Cr.extend({fn:z(),num_pins:Te(6).default(6),h:z().default("1.6mm"),pl:z().default("1mm"),pw:z().default("0.7mm"),p:z().default("0.95mm")}),Ofn=t=>{const e=kfn.parse(t);return{circuitJson:Ifn(e),parameters:e}},JYe=t=>{const{p:e,h:n,pn:r}=t;if(r===1)return{x:-n/2-.5,y:e};if(r===2)return{x:-n/2-.5,y:0};if(r===3)return{x:-n/2-.5,y:-e};if(r===4)return{x:n/2+.5,y:-e};if(r===5)return{x:n/2+.5,y:0};if(r===6)return{x:n/2+.5,y:e};throw new Error("Invalid pin number")},Ifn=t=>{const e=[];for(let d=1;d<=t.num_pins;d++){const{x:h,y:p}=JYe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:d});e.push(ar(d,h,p,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=t.num_pins/2*Number.parseFloat(t.p),r=Number.parseFloat(t.h),i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:r/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:r/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-r/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-r/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Nr(0,r+.3,.3),a=JYe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05};return[...e,s,i,o,u]},Lfn=Cr.extend({fn:z(),num_pins:Ue().default(4),w:z().default("3.2mm"),h:z().default("2.6mm"),pl:z().default("1.05mm"),pw:z().default("0.45mm"),p:z().default("0.55mm"),string:z().optional()}),Dfn=t=>{const e=t.string?.match(/^sot343_(\d+)/),n=e?Number.parseInt(e[1],4):4,r=Lfn.parse({...t,num_pins:n});if(r.num_pins===4)return{circuitJson:$fn(r),parameters:r};throw new Error("Invalid number of pins")},zfn=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}},$fn=t=>{const e=[],n=Number.parseFloat(t.w),r=Number.parseFloat(t.h),i=Number.parseFloat(t.pl),o=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let a=1/0,c=-1/0,l=1/0,u=-1/0;for(let b=0;b<t.num_pins;b++){const{x:v,y:T}=zfn({num_pins:t.num_pins,pn:b+1,p:s});e.push(ar(b+1,v,T,i,o)),v<a&&(a=v),v>c&&(c=v),T<l&&(l=T),T>u&&(u=T)}const d=(a+c)/2,h=u-l,p=r*.3,f=h/2+p;let m=n*.8;r<=2.6&&(m/=2);const y=Nr(d,f+.5,.3),g={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:d-m/2,y:f},{x:d+m/2,y:f}],type:"pcb_silkscreen_path",stroke_width:.1},_={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_bottom",route:[{x:d-m/2,y:-f},{x:d+m/2,y:-f}],type:"pcb_silkscreen_path",stroke_width:.1};return[...e,g,_,y]},Ffn=Cr.extend({fn:z()}),Bfn=t=>{const e=Ffn.parse(t),n=[],r=.5-.15,i=1.5,s=.5/2,a=75,c=-37/2;for(let A=0;A<a;A++){const P=A+1;if(P>=24&&P<=31)continue;const N=c-A*s,C=P%2===0,D=i+(C?.25:0),B=.5-D/2,U=ar(P,B,N,D,r);U.layer=C?"bottom":"top",n.push(U)}const l=46*.0254,u=137*.0254,d=261*.0254,h={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-u/2+i/2,y:c-d},width:u,height:l},p={x:-.5,y:c},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"};let m=1/0,y=-1/0,g=1/0,_=-1/0;const b=(A,P,N=0,C=0)=>{m=Math.min(m,A-N/2),y=Math.max(y,A+N/2),g=Math.min(g,P-C/2),_=Math.max(_,P+C/2)};for(const A of n){const P=A;b(P.x,P.y,P.width,P.height)}b(h.center.x,h.center.y,h.width,h.height);for(const A of f.route)b(A.x,A.y);const v=(m+y)/2,T=(g+_)/2,E=A=>{typeof A.x=="number"&&(A.x-=v),typeof A.y=="number"&&(A.y-=T),A.center&&(A.center.x-=v,A.center.y-=T),Array.isArray(A.route)&&(A.route=A.route.map(P=>({x:P.x-v,y:P.y-T})))};for(const A of n)E(A);return E(h),E(f),{circuitJson:[...n,h,f],parameters:e}},jfn=Cr.extend({fn:z(),numPins:Ue().optional().default(0),rows:kn([z(),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:Oe().optional().describe("the module uses male headers"),nopin:Oe().optional().default(!1).describe("omit pins rendering"),female:Oe().optional().describe("the module uses female headers"),smd:Oe().optional().describe("surface mount device"),pinlabeltextalignleft:Oe().optional().default(!1),pinlabeltextaligncenter:Oe().optional().default(!1),pinlabeltextalignright:Oe().optional().default(!1),pinlabelverticallyinverted:Oe().optional().default(!1),pinlabelorthogonal:Oe().optional().default(!1),nopinlabels:Oe().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Oe().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Oe().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top"),pinRowSide:Gt(["left","right","top","bottom"]).optional().default("left"),pinrowleft:Oe().optional().default(!1),pinrowright:Oe().optional().default(!1),pinrowtop:Oe().optional().default(!1),pinrowbottom:Oe().optional().default(!1),pinrowleftpins:kn([z(),Ue()]).transform(t=>Number(t)).optional(),pinrowrightpins:kn([z(),Ue()]).transform(t=>Number(t)).optional(),pinrowtoppins:kn([z(),Ue()]).transform(t=>Number(t)).optional(),pinrowbottompins:kn([z(),Ue()]).transform(t=>Number(t)).optional(),width:ce.optional(),height:ce.optional(),pinRowHoleEdgeToEdgeDist:ce.default("2mm"),holes:kn([z(),bt(z())]).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:kn([z(),Ue()]).optional(),usbposition:Gt(["left","right","top","bottom"]).optional().default("left"),usbleft:Oe().optional().default(!1),usbtop:Oe().optional().default(!1),usbright:Oe().optional().default(!1),usbbottom:Oe().optional().default(!1),usbtype:Gt(["micro","c"]).optional(),usbmicro:Oe().optional().default(!1),usbc:Oe().optional().default(!1),screen:Oe().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=FYe(t);let n=t.pinRowSide;t.pinrowleft&&(n="left"),t.pinrowright&&(n="right"),t.pinrowtop&&(n="top"),t.pinrowbottom&&(n="bottom");let r=t.usbposition;t.usbleft&&(r="left"),t.usbtop&&(r="top"),t.usbright&&(r="right"),t.usbbottom&&(r="bottom");let i=t.usbtype;t.usbmicro&&(i="micro"),t.usbc&&(i="c"),t.pinrow!==void 0&&(t.numPins=Number(t.pinrow));const o={left:t.pinrowleftpins,right:t.pinrowrightpins,top:t.pinrowtoppins,bottom:t.pinrowbottompins},s=Object.values(o).some(v=>v!==void 0&&v>0),a=(o.left??0)>0&&(o.right??0)>0,c=(o.top??0)>0&&(o.bottom??0)>0;s&&((o.left??0)>0?n="left":(o.right??0)>0?n="right":(o.top??0)>0?n="top":(o.bottom??0)>0&&(n="bottom"),t.numPins=(o.left??0)+(o.right??0)+(o.top??0)+(o.bottom??0));const l=Math.ceil(t.numPins/t.rows),u=Math.max(o.left??0,o.right??0),d=Math.max(o.top??0,o.bottom??0);let h,p;if(s){const v=a?t.p:0,T=c?t.p:0;h=(d>0?(d-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+v,p=(u>0?(u-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+T}else n==="left"||n==="right"?(h=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,p=(l-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist):(p=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,h=(l-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist);t.numPins===0&&(h=10,p=10);const f=t.width??h,m=t.height??p,y=t.screenwidth??f*.95,g=t.screenheight??m*.95,_=t.screencenteroffsetx??0,b=t.screencenteroffsety??0;return{...t,pinlabelAnchorSide:e,pinRowSide:n,usbposition:r,usbtype:i,male:t.male??!t.female,female:t.female??!1,width:f,height:m,screenwidth:y,screenheight:g,screencenteroffsetx:_,screencenteroffsety:b,pinrowleftpins:o.left,pinrowrightpins:o.right,pinrowtoppins:o.top,pinrowbottompins:o.bottom}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:qn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),Ufn=t=>{const e=jfn.parse(t),{p:n,id:r,od:i,rows:o,numPins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:c,pinlabelorthogonal:l,pinlabeltextalignleft:u,pinlabeltextalignright:d,nopinlabels:h,doublesidedpinlabel:p,bottomsidepinlabel:f,pinRowSide:m,width:y,height:g,pinRowHoleEdgeToEdgeDist:_,holes:b,holeXDist:v,holeYDist:T,holeInset:E,pinrowleftpins:A,pinrowrightpins:P,pinrowtoppins:N,pinrowbottompins:C,usbposition:D,usbtype:I,screen:B,screenwidth:U,screenheight:H,screencenteroffsetx:X,screencenteroffsety:W}=e;let ee="center";u?ee="left":d&&(ee="right");const re=[],pe={left:A,right:P,top:N,bottom:C},ie=Object.values(pe).some(he=>he!==void 0&&he>0),ae=(he,ve,Ae,Ce)=>{if(e.smd?re.push(ar(he,ve,Ae,e.od,e.od)):he===1?re.push(Lx({pn:he,x:ve,y:Ae,holeDiameter:r,rectPadWidth:i,rectPadHeight:i})):re.push(go(he,ve,Ae,r,i)),!h){const Be=ve+(Ce==="left"?-i:Ce==="right"?i:0),_e=Ae+(Ce==="top"?i:Ce==="bottom"?-i:0);f||re.push(j7({fs:i/5,pn:he,anchor_x:Be,anchor_y:_e,textalign:ee,orthogonal:l,verticallyinverted:c,layer:"top"})),(p||f)&&re.push(j7({fs:i/5,pn:he,anchor_x:Be,anchor_y:_e,textalign:ee,orthogonal:l,verticallyinverted:c,layer:"bottom"}))}};if(ie){const he=n;let ve=1;const Ae=pe.left??0,Ce=pe.right??0,Be=pe.top??0,_e=pe.bottom??0,Me=(ye,je)=>{if(!(je<=0))if(ye==="left"||ye==="right"){const Ye=ye==="left"?-y/2+_:y/2-_,it=(je-1)/2*he;for(let be=0;be<je;be++)ae(ve,Ye,it-be*he,ye),ve++}else{const Ye=ye==="top"?g/2-_:-g/2+_,it=-((je-1)/2)*he;for(let be=0;be<je;be++)ae(ve,it+be*he,Ye,ye),ve++}};Me("left",Ae),Me("right",Ce),Me("top",Be),Me("bottom",_e)}else{const he=n;let ve=0,Ae=0,Ce=0,Be=0,_e=0,Me=0;const ye=Math.ceil(s/o);m==="left"||m==="right"?(ve=m==="left"?-y/2+_:y/2-_,Ae=(ye-1)/2*he,Ce=0,Be=-he,_e=m==="left"?he:-he,Me=0):(ve=-(ye-1)/2*he,Ae=m==="top"?g/2-_:-g/2+_,Ce=he,Be=0,_e=0,Me=m==="top"?-he:he);let je=1;for(let Ye=0;Ye<o&&je<=s;Ye++)for(let it=0;it<ye&&je<=s;it++){const be=ve+it*Ce+Ye*_e,rt=Ae+it*Be+Ye*Me;if(e.smd?re.push(ar(je,be,rt,e.od,e.od)):je===1?re.push(Lx({pn:je,x:be,y:rt,holeDiameter:r,rectPadWidth:i,rectPadHeight:i})):re.push(go(je,be,rt,r,i)),!h){const He=be+(m==="left"?-i:m==="right"?i:0),De=rt+(m==="top"?i:m==="bottom"?-i:0);f||re.push(j7({fs:i/5,pn:je,anchor_x:He,anchor_y:De,textalign:ee,orthogonal:l,verticallyinverted:c,layer:"top"})),(p||f)&&re.push(j7({fs:i/5,pn:je,anchor_x:He,anchor_y:De,textalign:ee,orthogonal:l,verticallyinverted:c,layer:"bottom"}))}je++}}if(b)for(const he of b){let ve=0,Ae=0;he==="topleft"?(ve=-y/2+E,Ae=g/2-E):he==="topright"?(ve=y/2-E,Ae=g/2-E):he==="bottomleft"?(ve=-y/2+E,Ae=-g/2+E):he==="bottomright"?(ve=y/2-E,Ae=-g/2+E):he==="center"&&(ve=0,Ae=0),v!==void 0&&(ve+=v),T!==void 0&&(Ae+=T),re.push(go(s+b.indexOf(he)+1,ve,Ae,r,i))}if(!e.nosilkscreen){const he=[{x:-y/2,y:-g/2},{x:y/2,y:-g/2},{x:y/2,y:g/2},{x:-y/2,y:g/2},{x:-y/2,y:-g/2}];re.push(U7(he,{stroke_width:.1,layer:"top"}))}const de=Nr(0,g/2+1,.5);if(re.push(de),D&&I){let he,ve;if(I==="c")he=8,ve=3;else if(I==="micro")he=6,ve=2;else return{circuitJson:re,parameters:e};let Ae;if(D==="left")Ae=[{x:-y/2,y:-he/2},{x:-y/2+ve,y:-he/2},{x:-y/2+ve,y:he/2},{x:-y/2,y:he/2},{x:-y/2,y:-he/2}];else if(D==="right")Ae=[{x:y/2-ve,y:-he/2},{x:y/2,y:-he/2},{x:y/2,y:he/2},{x:y/2-ve,y:he/2},{x:y/2-ve,y:-he/2}];else if(D==="top")Ae=[{x:-he/2,y:g/2-ve},{x:he/2,y:g/2-ve},{x:he/2,y:g/2},{x:-he/2,y:g/2},{x:-he/2,y:g/2-ve}];else if(D==="bottom")Ae=[{x:-he/2,y:-g/2},{x:he/2,y:-g/2},{x:he/2,y:-g/2+ve},{x:-he/2,y:-g/2+ve},{x:-he/2,y:-g/2}];else return{circuitJson:re,parameters:e};re.push(U7(Ae,{stroke_width:.1,layer:"top"}))}if(B){const he=U/2,ve=H/2,Ae=X,Ce=W,Be=[{x:-he+Ae,y:-ve+Ce},{x:he+Ae,y:-ve+Ce},{x:he+Ae,y:ve+Ce},{x:-he+Ae,y:ve+Ce},{x:-he+Ae,y:-ve+Ce}];re.push(U7(Be,{stroke_width:.05,layer:"top"}))}return{circuitJson:re,parameters:e}},Hfn=Cr.extend({fn:z(),num_pins:Ue().default(3),inline:Oe().default(!1),p:z().default("1.27mm"),id:z().default("0.75mm"),od:z().default("1.3mm"),w:z().default("4.8mm"),h:z().default("4.0mm")}),Vfn=t=>{const e=Hfn.parse(t),n=Number.parseFloat(e.p),r=Number.parseFloat(e.w),i=Number.parseFloat(e.h),o=e.inline?1.05:Number.parseFloat(e.od),s=e.inline?1.5:o,a=[Lx({pn:1,x:0,y:0,holeDiameter:e.id,rectPadWidth:o,rectPadHeight:s}),e.inline?H7(2,n,0,Number.parseFloat(e.id),o,s):go(2,n,n,e.id,o),e.inline?H7(3,n*2,0,Number.parseFloat(e.id),o,s):go(3,n*2,0,e.id,o)],c=r/2,l=e.inline?n-.09:n,u=.2,d=u+c-i,h=Array.from({length:32},(m,y)=>{const g=Math.PI*y/31;return{x:l+c*Math.cos(g),y:u+c*Math.sin(g)}}),p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",stroke_width:.12,route:[...h,{x:l-c,y:d},{x:l+c,y:d},h[0]]},f=Nr(l,u+c+1,.5);return{circuitJson:[...a,p,f],parameters:e}},Yfn=(t,e)=>{const n=t.filter(r=>r.type==="pcb_silkscreen_text");if(n.length===0)return t;for(const r of n)e.norefdes&&(r.text="");return t},Xfn=(t,e)=>e.nosilkscreen?t.filter(n=>n.type!=="pcb_silkscreen_path"&&n.type!=="pcb_silkscreen_text"):t,Gfn=(t,e)=>{if(!e)return t;const n=t.filter(u=>u.type==="pcb_smtpad"||u.type==="pcb_plated_hole"||u.type==="pcb_thtpad");if(n.length===0)return t;let r=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;const a=(u,d,h=0,p=0)=>{const f=u-h/2,m=u+h/2,y=d-p/2,g=d+p/2;r=Math.min(r,f),i=Math.max(i,m),o=Math.min(o,y),s=Math.max(s,g)};for(const u of n)if(u.type==="pcb_smtpad"){const d=u.shape==="circle"?u.radius*2:u.width,h=u.shape==="circle"?u.radius*2:u.height;a(u.x,u.y,d,h)}else if(u.type==="pcb_plated_hole"){const d=u.outer_diameter??u.hole_diameter;a(u.x,u.y,d,d)}else if(u.type==="pcb_thtpad"){const d=u.diameter;a(u.x,u.y,d,d)}let c=0,l=0;switch(e){case"center":c=(r+i)/2,l=(o+s)/2;break;case"bottomleft":c=r,l=o;break;case"bottomcenter":case"centerbottom":c=(r+i)/2,l=o;break;case"topcenter":case"centertop":c=(r+i)/2,l=s;break;case"leftcenter":case"centerleft":c=r,l=(o+s)/2;break;case"rightcenter":case"centerright":c=i,l=(o+s)/2;break;case"pin1":{const u=n.find(d=>d.port_hints?.[0]==="1")||n[0];c=u.x,l=u.y;break}}if(c===0&&l===0)return t;for(const u of t){if(typeof u.x=="number"&&(u.x-=c),typeof u.y=="number"&&(u.y-=l),u.center&&typeof u.center.x=="number"&&(u.center.x-=c,u.center.y-=l),u.type==="pcb_silkscreen_path")for(const d of u.route)d.x-=c,d.y-=l;u.type==="pcb_silkscreen_text"&&u.anchor_position&&(u.anchor_position.x-=c,u.anchor_position.y-=l)}return t};function qfn(t){return t!=null}var Wfn=t=>t.trim().replace(/^sot-223-(\d+)(?=_|$)/i,"sot223_$1").replace(/^to-220f-(\d+)(?=_|$)/i,"to220f_$1"),Kfn=t=>{let e=cU();const n=Wfn(t),i=n.replace(/^((?:\d{4}|\d{5}))(?=$|_|x)/,"res$1").replace(/^zh(\d+)(?:$|_)/,"jst$1_zh").split(/_(?!metric)/).map(o=>{const s=o.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!s)return null;const[,a,c]=s;if(!a)return null;const l=a.toLowerCase();return c?.includes("?")?null:{fn:l,v:c}}).filter(qfn);for(const{fn:o,v:s}of i)e=e[o](s);return e.setString(n),e},Zfn=()=>Object.keys($b),cU=()=>{const t=new Proxy({},{get:(e,n)=>{if(n==="soup"||n==="circuitJson"){if("fn"in e&&$b[e.fn])return()=>{const{circuitJson:r}=$b[e.fn](e),i=Xfn(r,e),o=Yfn(i,e);return Gfn(o,e.origin)};if(!$b[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(!$b[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>$b[e.fn](e).parameters}return n==="getFootprintNames"?()=>Object.keys($b):n==="params"?()=>e:n==="setString"?r=>(e.string=r,t):r=>(Object.keys(e).length===0?`${n}${r}`in $b?(e[`${n}${r}`]=!0,e.fn=`${n}${r}`):(e[n]=!0,e.fn=n,n==="res"||n==="cap"?r&&(typeof r=="string"&&r.includes("_metric")?e.metric=r.split("_metric")[0]:e.imperial=r):e.num_pins=Number.isNaN(Number.parseFloat(r))?void 0:Number.parseFloat(r)):!r&&["w","h","p"].includes(n)||(e[n]=r??!0),t)}});return t};cU.string=Kfn,cU.getFootprintNames=Zfn;var Qfn=cU,eXe=Symbol("Fragment");function v0e(t,e,...n){const r=n.length?n:e?.children!==void 0?[e.children]:[],i=[],o=(Array.isArray(r)?r:[r]).flat(1/0);for(const s of o)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 hn=Symbol("Cuboid"),tXe=Symbol("Cube"),rh=Symbol("Cylinder"),lU=Symbol("Sphere"),qR=Symbol("RoundedCuboid"),Br=Symbol("Translate"),f0=Symbol("Rotate"),Kp=Symbol("Union"),Dx=Symbol("Subtract"),Hl=Symbol("Hull"),co=Symbol("Colorize"),WR=Symbol("Polygon"),KR=Symbol("ExtrudeLinear"),u_=Symbol("RoundedCylinder"),Ai=eXe,Xe=(t,e,n)=>v0e(t,e),Un=(t,e,n)=>v0e(t,e),Rh=({center:t,width:e,length:n,height:r,heightAboveSurface:i=.15,color:o="#555",taperRatio:s=.12,faceRatio:a=.75,straightHeightRatio:c=.5,includeNotch:l=!0,notchRadius:u,notchPosition:d,notchRotation:h=[0,0,0],notchLength:p=.5,notchWidth:f=.25,chamferSize:m=0})=>{const y=r*c,g=r-y,_=Math.min(e,n)*s,b=Math.max(e-_,e*a),v=Math.max(n-_,n*a),T=Math.min(e,n)*.12,E=u??T,A={x:0,y:n/2-E*.25,z:r},P=d??A,N=Un(Kp,{children:[Un(Hl,{children:[Xe(Br,{z:.005,children:Xe(hn,{size:[b,v,.01]})}),Xe(Br,{z:y,children:Xe(hn,{size:[e,n,.01]})})]}),Un(Hl,{children:[Xe(Br,{z:y,children:Xe(hn,{size:[e,n,.01]})}),Xe(Br,{z:y+g,children:Xe(hn,{size:[b,v,.01]})})]})]}),C=(I,B)=>Xe(Br,{offset:{x:I,y:B,z:0},children:Xe(f0,{rotation:[0,0,Math.PI/4],children:Xe(hn,{size:[m*Math.SQRT2,m*Math.SQRT2,r*3]})})});let D=N;if(m>0){const I=e/2,B=n/2;D=Un(Dx,{children:[N,C(I,B),C(-I,B),C(I,-B),C(-I,-B)]})}return Xe(co,{color:o,children:Xe(Br,{offset:t,children:Xe(Br,{offset:{x:0,y:0,z:i},children:l?Un(Dx,{children:[D,Xe(Br,{offset:P,children:Xe(f0,{rotation:h,children:Xe(rh,{radius:E,height:f})})})]}):D})})})},Jfn=t=>Array.from({length:t},(e,n)=>n);function w0e(t,e){if(t.length<2)throw new Error("Stroke must have at least two points");const n=Array.isArray(t[0])?t.map(([u,d])=>({x:u,y:d})):t,r=e/2,i=[],o=[];function s(u,d){const h=d.x-u.x,p=d.y-u.y,f=Math.sqrt(h*h+p*p);return{x:-p/f,y:h/f}}function a(u,d,h){const p={x:u.x+d.x*r*h,y:u.y+d.y*r*h};h>0?i.push(p):o.unshift(p)}const c=s(n[0],n[1]);a(n[0],c,1),a(n[0],c,-1);for(let u=1;u<n.length-1;u++){const d=n[u-1],h=n[u],p=n[u+1],f=s(d,h),m=s(h,p),y=f.x+m.x,g=f.y+m.y,_=Math.sqrt(y*y+g*g);if(_/2>2*r)a(h,f,1),a(h,m,1),a(h,f,-1),a(h,m,-1);else{const v=1/_;a(h,{x:y*v,y:g*v},1),a(h,{x:y*v,y:g*v},-1)}}const l=s(n[n.length-2],n[n.length-1]);return a(n[n.length-1],l,1),a(n[n.length-1],l,-1),[...i,...o]}var emn=t=>{const e=Math.min(...t.map(a=>a.x)),n=Math.max(...t.map(a=>a.x)),r=Math.min(...t.map(a=>a.y)),s=5.47/(Math.max(...t.map(a=>a.y))-r);return t.map(a=>({x:(a.x-e-(n-e)/2)*s,y:(a.y-r)*s}))},tmn=emn([{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}]),nXe=5.47,uU=.5,nmn=({x:t,y:e,z:n})=>{const r=t>0;return Un(Ai,{children:[Xe(Br,{offset:{x:t+.25/2,y:e,z:n},children:Xe(f0,{rotation:["-90deg",0,"90deg"],children:Xe(KR,{height:.25,children:Xe(WR,{points:tmn.slice().reverse().map(i=>[i.x,i.y])})})})}),Xe(Br,{offset:{x:t,y:e+(r?1:-1),z:n},children:Xe(f0,{rotation:["-90deg","90deg",r?"180deg":"0deg"],children:Xe(KR,{height:2,children:Xe(WR,{points:w0e([[0,0],[-1,0],[-1,-1]],.25).map(i=>[i.x,i.y])})})})})]})},rmn=({numPins:t=8,pitch:e=2.54,bodyWidth:n=6.4,rowSpacing:r})=>{const i=Math.floor(t/2),o=r??(n>=7?n:n+1.22),s=n>=7?o-1.22:n;return Un(Ai,{children:[Jfn(t).map(a=>{const c=a%i,l=(Math.floor(a/i)-.5)*2;return Xe(nmn,{x:l*o/2,y:c*e-(i-1)/2*e,z:nXe/2+uU})}),Xe(Rh,{width:s,length:i*e+.5,height:nXe-uU,heightAboveSurface:uU,center:{x:0,y:0,z:uU}})]})};function imn(t,{height:e,padContactLength:n,curveLength:r,bodyDistance:i,steepness:o=10}){r||(r=i*.3);let s=i-n-r;s<0&&(r+=s,s=0);const a=n*.75,c=n+r+(i-n-r)*.25;if(t<=a)return 0;if(t>=c)return e;const l=(t-a)/(c-a);return e/(1+Math.exp(-o*(l-.5)))}var Vi=t=>{const{thickness:e,width:n,padContactLength:r,bodyDistance:i,height:o,rotation:s}=t,a=15,c=Array.from({length:a}).map((u,d)=>d/(a-1)*i).map(u=>[u,imn(u,t)]),l=w0e(c,e);return Xe(co,{color:"#fff",children:Xe(Br,{offset:{z:0,y:0,x:0,...t.position},children:Xe(f0,{rotation:["90deg",0,s??0],children:Xe(Br,{offset:{x:0,y:0,z:-n/2},children:Xe(KR,{height:n,children:Xe(WR,{points:l.map(u=>[u.x,u.y])})})})})})})},omn=({pinCount:t,leadLength:e,leadWidth:n,pitch:r,bodyWidth:i})=>{const o=Math.ceil(t/2),s=r*t/2+n/2,a=(o-1)*r/2,c=.25;return Un(Ai,{children:[Array.from({length:o}).map((l,u)=>Xe(Vi,{position:{x:-i/2-e,y:u*r-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Array.from({length:o}).map((l,u)=>Xe(Vi,{rotation:Math.PI,position:{x:i/2+e,y:u*r-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Xe(Rh,{center:{x:0,y:0,z:c/2},width:i-n-1,length:s,height:1.5})]})},smn=({pinCount:t,padContactLength:e=.4,leadWidth:n=.2,pitch:r=.65,bodyWidth:i=3})=>{const o=Math.ceil(t/2),s=(o-1)*r/2,a=.2;return Un(Ai,{children:[Array.from({length:o}).map((c,l)=>Xe(Vi,{position:{x:-i/2-e-.3,y:l*r-s,z:a/2},width:n,thickness:a,padContactLength:e,bodyDistance:e+.4,height:.6})),Array.from({length:o}).map((c,l)=>Xe(Vi,{rotation:Math.PI,position:{x:i/2+e+.3,y:l*r-s,z:a/2},width:n,thickness:a,padContactLength:e,bodyDistance:e+.4,height:.6})),Xe(Rh,{center:{x:0,y:0,z:a/2},width:i,length:i,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},S0e=1,E0e=.5,KM=.5,ZR=.2,amn=S0e-ZR*2,rXe=({color:t="#333"})=>Un(Ai,{children:[Xe(hn,{size:[amn,E0e,KM],offset:[0,0,KM/2],color:t}),Xe(hn,{size:[ZR,KM,E0e],offset:[S0e/2-ZR/2,0,KM/2],color:"#ccc"}),Xe(hn,{size:[ZR,KM,E0e],offset:[-S0e/2+ZR/2,0,KM/2],color:"#ccc"})]}),M0e=1.6,cmn=M0e-.3*2,dU=.3,T0e=.85,ZM=.6,iXe=({color:t="#333"})=>Un(Ai,{children:[Xe(hn,{size:[cmn,T0e,ZM],offset:[0,0,ZM/2],color:t}),Xe(hn,{size:[dU,T0e,ZM],offset:[M0e/2-dU/2,0,ZM/2],color:"#ccc"}),Xe(hn,{size:[dU,T0e,ZM],offset:[-M0e/2+dU/2,0,ZM/2],color:"#ccc"})]}),C0e=2,P0e=1.25,QM=.55,QR=.5,lmn=C0e-QR*2,oXe=({color:t="#333"})=>Un(Ai,{children:[Xe(hn,{size:[lmn,P0e,QM],offset:[0,0,QM/2],color:t}),Xe(hn,{size:[QR,P0e,QM],offset:[C0e/2-QR/2,0,QM/2],color:"#ccc"}),Xe(hn,{size:[QR,P0e,QM],offset:[-C0e/2+QR/2,0,QM/2],color:"#ccc"})]}),umn=({pinCount:t,pitch:e,leadWidth:n,padContactLength:r,bodyWidth:i})=>{const o=t/4;e||(e=dmn(t,i)),r||(r=hmn(t)),n||(n=pmn(t,i)),i||(i=e*(o+4));const s=i,a=(o-1)*e/2,c=s+2*r,l=c,u=.8,d=.15,h=(l-i)/2+.5;return Un(Ai,{children:[Array.from({length:o}).map((p,f)=>Xe(Vi,{position:{x:-l/2-.4,y:f*e-a,z:d/2},width:n,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Array.from({length:o}).map((p,f)=>Xe(Vi,{rotation:Math.PI,position:{x:l/2+.4,y:f*e-a,z:d/2},width:n,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Array.from({length:o}).map((p,f)=>Xe(Vi,{rotation:Math.PI/2,position:{x:f*e-a,y:-c/2-.4,z:d/2},width:n,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Array.from({length:o}).map((p,f)=>Xe(Vi,{rotation:-Math.PI/2,position:{x:f*e-a,y:c/2+.4,z:d/2},width:n,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Xe(Rh,{center:{x:0,y:0,z:0},width:i,length:s,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:i/2-1.5,z:1.5},notchRadius:1.5/2})]})},dmn=(t,e)=>{switch(t){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},hmn=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}},pmn=(t,e)=>{switch(t){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},sXe=({x:t,y:e,pinThickness:n,shortSidePinLength:r,longSidePinLength:i,bodyHeight:o,bodyLength:s=2.54,bodyWidth:a=2.54,flipZ:c,faceup:l,smd:u,rightangle:d})=>Un(Ai,{children:[Xe(Br,{y:d?-3:0,children:Xe(hn,{color:"#222",size:[s,a,o],center:[t,e,c(o/2)]})}),!l&&Xe(co,{color:"gold",children:u?Xe(Vi,{rotation:-Math.PI/2,position:{x:t,y:e+1,z:n/2},thickness:n,width:n,height:n,padContactLength:2,bodyDistance:3}):Un(Hl,{children:[Xe(hn,{color:"gold",size:[n,n,r*.9],center:[t,e,c(o*.9+o/2)]}),Xe(hn,{color:"gold",size:[n/1.8,n/1.8,r],center:[t,e,c(o+o/2)]})]})}),Xe(co,{color:"gold",children:Xe(Br,{y:d?-3.9:0,z:d?1:0,children:Xe(f0,{rotation:d?[-Math.PI/2,0,0]:[0,0,0],children:Un(Hl,{children:[Xe(hn,{color:"gold",size:[n,n,i*.9],center:[t,e,c(-i/2*.9)]}),Xe(hn,{color:"gold",size:[n/1.8,n/1.8,i],center:[t,e,c(-i/2)]})]})})})})]}),fmn=({numberOfPins:t,pitch:e=2.54,longSidePinLength:n=6,invert:r,faceup:i,rows:o=1,smd:s,rightangle:a})=>{const u=Math.ceil(t/o),d=2.54,h=3,p=-((u-1)/2)*e,f=!s&&!a?-2-1.6:0,m=y=>(r||i?-y+2:y)+f;return Xe(Ai,{children:Array.from({length:t},(y,g)=>{const _=Math.floor(g/u),b=g%u,v=p+b*e,T=-_*d;return Xe(sXe,{x:v,y:T,pinThickness:.63,shortSidePinLength:h,longSidePinLength:n,bodyHeight:2,flipZ:m,faceup:i,smd:s,rightangle:a},g)})})},mmn=t=>{const e=["left","bottom","right","top"],{pin_count:n,pn:r,w:i,h:o,p:s,pl:a}=t,c=n/4,l=e[Math.floor((r-1)/c)],u=(r-1)%c,d=s*(c-1),h=s*(c-1),p=-a/2;switch(l){case"left":return{x:-i/2-p,y:h/2-u*s,o:"vert"};case"bottom":return{x:-d/2+u*s,y:-o/2-p,o:"horz"};case"right":return{x:i/2+p,y:-h/2+u*s,o:"vert"};case"top":return{x:d/2-u*s,y:o/2+p,o:"horz"};default:throw new Error("Invalid pin number")}},ymn=({num_pins:t,cw:e,ccw:n,startingpin:r})=>{const i=[],o=t/4;let s=1;const a={};for(const c of r??[])a[c]=!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=o:a.bottomside&&a.leftpin?s=o+1:a.bottomside&&a.rightpin?s=o*2:a.rightside&&a.bottompin?s=o*2+1:a.rightside&&a.toppin?s=o*3:a.topside&&a.rightpin?s=o*3+1:a.topside&&a.leftpin&&(s=o*4),i.push(-1);for(let c=0;c<t;c++)i[s]=c+1,s++,s>t&&(s=1);return i},gmn=({num_pins:t=16,bodyWidth:e=9,bodyLength:n=9,bodyThickness:r=.8,thermalPadSize:i,padWidth:o=.25,padLength:s=.25,pitch:a=.5,thermalPadThickness:c=.05})=>{const l=ymn({num_pins:t,cw:!0,ccw:!0}),u=[];for(let d=0;d<t;d++){const{x:h,y:p,o:f}=mmn({pin_count:t,pn:d+1,w:e,h:n,p:a,pl:s});let m=o,y=s;f==="vert"&&([m,y]=[y,m]);const g=l[d+1];u.push({pn:g,x:h,y:p,pw:m,pl:y})}return Un(Ai,{children:[Xe(co,{color:"grey",children:Xe(hn,{center:{x:0,y:0,z:r/2},size:[e,n,r]})}),u.map((d,h)=>Xe(hn,{center:{x:d.x,y:d.y,z:c/2},size:[d.pw,d.pl,c]})),i?.length!==void 0&&i?.width!==void 0&&Xe(hn,{center:{x:0,y:0,z:c/2},size:[i.width,i.length,c]})]})},_mn=gmn,xmn=()=>{const c=1.1999999999999997;return Un(Ai,{children:[Xe(Vi,{rotation:Math.PI,position:{x:2.8/2+c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Xe(Vi,{rotation:Math.PI,position:{x:2.8/2+c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Xe(Vi,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Xe(Vi,{position:{x:-2.8/2-c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Xe(Vi,{position:{x:-2.8/2-c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Xe(Rh,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},bmn=xmn,vmn=({fullWidth:t=2.9,fullLength:e=2.8})=>{const u=(t-1.92)/2+.3;return Un(Ai,{children:[Xe(Vi,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:u,height:.45}),Xe(Vi,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:u,height:.45}),Xe(Vi,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:u,height:.45}),Xe(Rh,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},A0e=.6,R0e=.3,JM=.33,JR=.1,wmn=A0e-JR*2,aXe=({color:t="#333"})=>Un(Ai,{children:[Xe(hn,{size:[wmn,R0e,JM],offset:[0,0,JM/2],color:t}),Xe(hn,{size:[JR,R0e,JM],offset:[A0e/2-JR/2,0,JM/2],color:"#ccc"}),Xe(hn,{size:[JR,R0e,JM],offset:[-A0e/2+JR/2,0,JM/2],color:"#ccc"})]}),N0e=.4,k0e=.2,eT=.13,eN=.07,Smn=N0e-eN*2,cXe=({color:t="#333"})=>Un(Ai,{children:[Xe(hn,{size:[Smn,k0e,eT],offset:[0,0,eT/2],color:t}),Xe(hn,{size:[eN,k0e,eT],offset:[N0e/2-eN/2,0,eT/2],color:"#ccc"}),Xe(hn,{size:[eN,k0e,eT],offset:[-N0e/2+eN/2,0,eT/2],color:"#ccc"})]}),O0e=3.2,I0e=1.6,tT=.9,tN=.5,Emn=O0e-tN*2,lXe=({color:t="#333"})=>Un(Ai,{children:[Xe(hn,{size:[Emn,I0e,tT],offset:[0,0,tT/2],color:t}),Xe(hn,{size:[tN,I0e,tT],offset:[O0e/2-tN/2,0,tT/2],color:"#ccc"}),Xe(hn,{size:[tN,I0e,tT],offset:[-O0e/2+tN/2,0,tT/2],color:"#ccc"})]}),L0e=3.2,D0e=2.5,nT=1,nN=.6,Mmn=L0e-nN*2,uXe=({color:t="#333"})=>Un(Ai,{children:[Xe(hn,{size:[Mmn,D0e,nT],offset:[0,0,nT/2],color:t}),Xe(hn,{size:[nN,D0e,nT],offset:[L0e/2-nN/2,0,nT/2],color:"#ccc"}),Xe(hn,{size:[nN,D0e,nT],offset:[-L0e/2+nN/2,0,nT/2],color:"#ccc"})]}),z0e=5,$0e=2.5,rT=1.4,rN=.6,Tmn=z0e-rN*2,dXe=({color:t="#333"})=>Un(Ai,{children:[Xe(hn,{size:[Tmn,$0e,rT],offset:[0,0,rT/2],color:t}),Xe(hn,{size:[rN,$0e,rT],offset:[z0e/2-rN/2,0,rT/2],color:"#ccc"}),Xe(hn,{size:[rN,$0e,rT],offset:[-z0e/2+rN/2,0,rT/2],color:"#ccc"})]}),F0e=6.3,B0e=3.2,iT=1.8,iN=.8,Cmn=F0e-iN*2,hXe=({color:t="#333"})=>Un(Ai,{children:[Xe(hn,{size:[Cmn,B0e,iT],offset:[0,0,iT/2],color:t}),Xe(hn,{size:[iN,B0e,iT],offset:[F0e/2-iN/2,0,iT/2],color:"#ccc"}),Xe(hn,{size:[iN,B0e,iT],offset:[-F0e/2+iN/2,0,iT/2],color:"#ccc"})]}),pXe=({x:t,y:e,z:n=0,pitch:r=2.54,legsLength:i=3,innerDiameter:o=.945,bodyHeight:s=5,bodyLength:a=r,bodyWidth:c=r,flipZ:l})=>{const u=o/1.5,d=u*1.6;return Un(Ai,{children:[Xe(co,{color:"#1a1a1a",children:Un(Dx,{children:[Xe(hn,{color:"#000",size:[a,c,s],center:[t,e,l(n+s/2)]}),o?Xe(rh,{height:s+.1,radius:o/2,center:[t,e,l(n+s/2)],color:"#222"}):Xe(hn,{size:[d,d,s],center:[t,e,l(n+s/2)]})]})}),Un(co,{color:"silver",children:[Un(Hl,{children:[Xe(hn,{color:"silver",size:[u,u,i*.9],center:[t,e,l(n+-i/2*.9)]}),Xe(hn,{color:"silver",size:[u/1.8,u/1.8,i],center:[t,e,l(n+-i/2)]})]}),Xe(hn,{color:"silver",size:[d,d,d*.5],center:[t,e,l(n+d/2*.5)]})]})]})},Pmn=({numberOfPins:t,pitch:e=2.54,legsLength:n=3,innerDiameter:r=.945,rows:i=1,invert:o})=>{const a=Math.ceil(t/i),c=2.54,l=-((a-1)/2)*e,u=d=>o?-d+5:d;return Xe(Ai,{children:Array.from({length:t},(d,h)=>{const p=Math.floor(h/a),f=h%a,m=l+f*e,y=-p*c;return Xe(pXe,{x:m,y,pitch:e,legsLength:n,innerDiameter:r,flipZ:u},h)})})},Amn=({width:t,length:e,innerDiameter:n=1})=>{const r=t,i=e,o=t*.7,s=n/2.5;return Un(Ai,{children:[Xe(qR,{color:"#1a1a1f",center:[0,0,o/2],size:[i,i,o],roundRadius:.3}),Xe(qR,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[i,i,o*.1],roundRadius:.14}),Xe(rh,{color:"#1a1a1f",height:o*.8,radius:r/3,center:[0,0,o+o*.8/2]}),Xe(rh,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[i/3,i/3,o+o*.1/2]}),Xe(rh,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[-i/3,-i/3,o+o*.1/2]}),Xe(rh,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[-i/3,i/3,o+o*.1/2]}),Xe(rh,{color:"#1a1a1f",height:o*.2,radius:n/2,center:[i/3,-i/3,o+o*.1/2]}),Xe(hU,{thickness:n/3,width:s,horizontalLength:i*.8,verticalLength:o/2,position:{x:-r/2,y:-i/2,z:-o*1.2}}),Xe(hU,{thickness:n/3,width:s,horizontalLength:i*.8,verticalLength:o/2,position:{x:-r/2,y:i/2,z:-o*1.2},rotation:Math.PI}),Xe(hU,{thickness:n/3,width:s,horizontalLength:i*.8,verticalLength:o/2,position:{x:r/2,y:i/2,z:-o*1.2},rotation:Math.PI}),Xe(hU,{thickness:n/3,width:s,horizontalLength:i*.8,verticalLength:o/2,position:{x:r/2+n/3.6,y:-i/2,z:-o*1.2}})]})},hU=t=>{const{thickness:e,width:n,horizontalLength:r,verticalLength:i,rotation:o=0,position:s}=t,a=[[0,r],[-i/3,r/3],[-i/5,r/4],[0,0]],c=w0e(a,e);return Xe(co,{color:"#f2f2f2",children:Xe(Br,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Xe(f0,{rotation:[0,55,o],children:Xe(KR,{height:n,children:Xe(WR,{points:c.map(l=>[l.y,l.x])})})})})})},Rmn=({pinCount:t,leadLength:e,leadWidth:n,pitch:r,bodyWidth:i})=>{const o=Math.ceil(t/2),s=(o-1)*r/2,a=.25,c=1,l=.8,u=e*0,d=r*(o-1)+n+.2,h=i*.55;return Un(Ai,{children:[Array.from({length:o}).map((p,f)=>Xe(Vi,{position:{x:-i/2-u,y:f*r-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:l})),Array.from({length:o}).map((p,f)=>Xe(Vi,{rotation:Math.PI,position:{x:i/2+u,y:f*r-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:l})),Xe(Rh,{center:{x:0,y:0,z:a/2},width:h,length:d,height:c})]})},Nmn=({pinCount:t,pitch:e,leadWidth:n,leadLength:r,bodyWidth:i,bodyLength:o})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},a=isNaN(parseFloat(e))?s.pitch:parseFloat(e),c=isNaN(parseFloat(n))?s.leadWidth:parseFloat(n)*.8,l=isNaN(parseFloat(i))?2.6:parseFloat(i)*.8,u=isNaN(parseFloat(o))?2+Number(a)*1.4:parseFloat(o),d=t/2,h=(d-1)*a/2,p=.15,f=.8,m=4.5,y=(m-l)/2,g=y*.5;return Un(Ai,{children:[Array.from({length:d}).map((_,b)=>Xe(Vi,{position:{x:-m/2,y:h-b*a,z:p/2},width:c,thickness:p,padContactLength:g+.05,bodyDistance:y+.1,height:f})),Array.from({length:d}).map((_,b)=>Xe(Vi,{rotation:Math.PI,position:{x:m/2,y:h-b*a,z:p/2},width:c,thickness:p,padContactLength:g+.05,bodyDistance:y+.1,height:f})),Xe(Rh,{center:{x:0,y:0,z:p/2},width:l,length:u,height:1})]})},kmn=()=>Un(Ai,{children:[Xe(hn,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),Xe(hn,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),Xe(co,{color:"#222",children:Un(Kp,{children:[Xe(Br,{z:.3/2,children:Xe(hn,{size:[1.65,.8,.3]})}),Un(Hl,{children:[Xe(Br,{z:.3,children:Xe(hn,{size:[1.65,.8,.01]})}),Xe(Br,{z:.6,children:Xe(hn,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),Omn=()=>Un(Ai,{children:[Xe(hn,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),Xe(hn,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),Xe(co,{color:"#222",children:Xe(Br,{z:.47/2+.02,children:Xe(hn,{size:[.98,.58,.47]})})}),Xe(hn,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),Xe(hn,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),Xe(hn,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),Xe(hn,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),Imn=()=>{const l=Xe(co,{color:"#1a1a1a",children:Un(Kp,{children:[Un(Hl,{children:[Xe(Br,{z:.13,children:Xe(hn,{size:[4,3,.03]})}),Xe(Br,{z:1.15,children:Xe(hn,{size:[4.4,3.4,.01]})})]}),Un(Hl,{children:[Xe(Br,{z:1.15,children:Xe(hn,{size:[4.4,3.4,.01]})}),Xe(Br,{z:2.3,children:Xe(hn,{size:[4,3,.01]})})]})]})}),u=({xDir:d})=>{const f=d*1.78,m=d*(3.4/2-.2/2+1),y=d*(3.4/2-.2/2),g=Math.abs(y-m),_=(m+y)/2;return Xe(co,{color:"#c0c0c0",children:Un(Kp,{children:[Xe(hn,{size:[2.3*.8,1.45,.2],center:[f,0,.2/2]}),Xe(hn,{size:[.2,1.45,1.14],center:[m,0,1.14/2+.2]}),Xe(hn,{size:[g,1.45,.2],center:[_,0,.2/2+1.14]})]})})};return Un(Ai,{children:[Xe(u,{xDir:1}),Xe(u,{xDir:-1}),l]})},Lmn=()=>{const l=Xe(co,{color:"#1a1a1a",children:Un(Kp,{children:[Un(Hl,{children:[Xe(Br,{z:.13,children:Xe(hn,{size:[4,3,.03]})}),Xe(Br,{z:1.15,children:Xe(hn,{size:[4.4,3.4,.01]})})]}),Un(Hl,{children:[Xe(Br,{z:1.15,children:Xe(hn,{size:[4.4,3.4,.01]})}),Xe(Br,{z:2.3,children:Xe(hn,{size:[4,3,.01]})})]})]})}),u=({xDir:d})=>{const f=d*1.78,m=d*(3.4/2-.2/2+1),y=d*(3.4/2-.2/2),g=Math.abs(y-m),_=(m+y)/2;return Xe(co,{color:"#c0c0c0",children:Un(Kp,{children:[Xe(hn,{size:[2.3*.8,1.45,.2],center:[f,0,.2/2]}),Xe(hn,{size:[.2,1.45,1.14],center:[m,0,1.14/2+.2]}),Xe(hn,{size:[g,1.45,.2],center:[_,0,.2/2+1.14]})]})})};return Un(Ai,{children:[Xe(u,{xDir:1}),Xe(u,{xDir:-1}),l]})},Dmn=()=>{const l=Xe(co,{color:"#1a1a1a",children:Un(Kp,{children:[Un(Hl,{children:[Xe(Br,{z:.21000000000000002,children:Xe(hn,{size:[6.3999999999999995,5.6,.03]})}),Xe(Br,{z:1.15,children:Xe(hn,{size:[6.8,6,.01]})})]}),Un(Hl,{children:[Xe(Br,{z:1.15,children:Xe(hn,{size:[6.8,6,.01]})}),Xe(Br,{z:2.3,children:Xe(hn,{size:[6.3999999999999995,5.6,.01]})})]})]})}),u=({xDir:d})=>{const f=d*3.08,m=d*(6/2-.2/2+1),y=d*(6/2-.2/2),g=Math.abs(y-m),_=(m+y)/2;return Xe(co,{color:"#c0c0c0",children:Un(Kp,{children:[Xe(hn,{size:[2.3*.8,2.95,.2],center:[f,0,.2/2]}),Xe(hn,{size:[.2,2.95,1.14],center:[m,0,1.14/2+.2]}),Xe(hn,{size:[g,2.95,.2],center:[_,0,.2/2+1.14]})]})})};return Un(Ai,{children:[Xe(u,{xDir:1}),Xe(u,{xDir:-1}),l]})},zmn=()=>{const d=Xe(co,{color:"#222",children:Un(Kp,{children:[Xe(Br,{z:.27,children:Xe(hn,{size:[2.9,1.9,.54]})}),Un(Hl,{children:[Xe(Br,{z:.54,children:Xe(hn,{size:[2.9,1.9,.01]})}),Xe(Br,{z:1.08,children:Xe(hn,{size:[2.6999999999999997,1.7,.01]})})]})]})});return Un(Ai,{children:[Xe(hn,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),Xe(hn,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),d]})},$mn=()=>Un(Ai,{children:[Xe(hn,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),Xe(hn,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),Xe(co,{color:"#222",children:Un(Kp,{children:[Xe(Br,{z:.55/2,children:Xe(hn,{size:[2.7,1.6,.55]})}),Un(Hl,{children:[Xe(Br,{z:.55,children:Xe(hn,{size:[2.7,1.6,.01]})}),Xe(Br,{z:1.1,children:Xe(hn,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),Fmn=()=>Un(Ai,{children:[Xe(hn,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),Xe(hn,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),Xe(co,{color:"#222",children:Un(Kp,{children:[Xe(Br,{z:.2/2,children:Xe(hn,{size:[2.75,1.8,.2]})}),Un(Hl,{children:[Xe(Br,{z:.2,children:Xe(hn,{size:[2.75,1.8,.01]})}),Xe(Br,{z:1,children:Xe(hn,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),Xe(hn,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),Bmn=()=>Un(Ai,{children:[Xe(hn,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),Xe(hn,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),Xe(co,{color:"#222",children:Un(Kp,{children:[Un(Hl,{children:[Xe(Br,{z:.2,children:Xe(hn,{size:[2.6-.1/2,1.7-.1/2,.01]})}),Xe(Br,{z:.01,children:Xe(hn,{size:[2.6-.1,1.7-.1,.01]})})]}),Un(Hl,{children:[Xe(Br,{z:.2,children:Xe(hn,{size:[2.6,1.7,.01]})}),Xe(Br,{z:1,children:Xe(hn,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),Xe(hn,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),jmn=()=>Un(Ai,{children:[Xe(hn,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),Xe(hn,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),Xe(co,{color:"#222",children:Un(Kp,{children:[Un(Hl,{children:[Xe(Br,{z:.2,children:Xe(hn,{size:[3.8-.05/2,2.5-.05/2,.01]})}),Xe(Br,{z:.01,children:Xe(hn,{size:[3.8-.05,2.5-.05,.01]})})]}),Un(Hl,{children:[Xe(Br,{z:.2,children:Xe(hn,{size:[3.8,2.5,.01]})}),Xe(Br,{z:1,children:Xe(hn,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),Xe(hn,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),Umn=()=>Un(Ai,{children:[Xe(hn,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),Xe(hn,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),Xe(co,{color:"#222",children:Un(Kp,{children:[Xe(Br,{z:.14/2,children:Xe(hn,{size:[.8,.6,.14]})}),Un(Hl,{children:[Xe(Br,{z:.14,children:Xe(hn,{size:[.8,.6,.01]})}),Xe(Br,{z:.37,children:Xe(hn,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),Hmn=()=>{const u=3.0999999999999996;return Un(Ai,{children:[Xe(Vi,{rotation:Math.PI,position:{x:6.6/2+u/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Xe(Vi,{position:{x:-6.6/2-u/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Xe(Vi,{position:{x:-6.6/2-u/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Xe(Vi,{position:{x:-6.6/2-u/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Xe(Rh,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},Vmn=()=>Un(Ai,{children:[Array.from({length:16}).map((p,f)=>Xe(Vi,{position:{x:-10.5/2,y:f*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((p,f)=>Xe(Vi,{rotation:Math.PI,position:{x:10.5/2,y:f*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((p,f)=>Xe(Vi,{rotation:Math.PI/2,position:{x:f*.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((p,f)=>Xe(Vi,{rotation:-Math.PI/2,position:{x:f*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Xe(Rh,{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})]}),Ymn=Vmn,Xmn=()=>{const l=.7999999999999998;return Un(Ai,{children:[Xe(Vi,{rotation:Math.PI,position:{x:2.05/2+l/4,y:0,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:l,height:.65}),Xe(Vi,{position:{x:-2.05/2-l/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:l,height:.65}),Xe(Vi,{position:{x:-2.05/2-l/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:l,height:.65}),Xe(Rh,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},Gmn=({pinCount:t,pitch:e,leadWidth:n,padContactLength:r,bodyWidth:i})=>{const o=t/4;if(o!==Math.floor(o))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);e||(e=.5),r||(r=.6),n||(n=.22),i||(i=e*(o+4));const s=i,a=(o-1)*e/2,c=s+3.3*r,l=c,u=.8,d=.2,h=(l-i)/2+.4;return Un(Ai,{children:[Array.from({length:o}).map((p,f)=>Xe(Vi,{position:{x:-l/2-.36,y:f*e-a,z:d/2},width:n,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Array.from({length:o}).map((p,f)=>Xe(Vi,{rotation:Math.PI,position:{x:l/2+.36,y:f*e-a,z:d/2},width:n,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Array.from({length:o}).map((p,f)=>Xe(Vi,{rotation:Math.PI/2,position:{x:f*e-a,y:-c/2-.36,z:d/2},width:n,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Array.from({length:o}).map((p,f)=>Xe(Vi,{rotation:-Math.PI/2,position:{x:f*e-a,y:c/2+.36,z:d/2},width:n,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Xe(Rh,{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})]})},qmn=()=>{const r=.20900000000000002,i=.1,o=.3,s=.1,a=.2;return Un(Ai,{children:[Xe(co,{color:"#222",children:Un(Kp,{children:[Xe(hn,{size:[.85,1.2,r],center:[0,0,r/2]}),Un(Hl,{children:[Xe(Br,{z:r,children:Xe(hn,{size:[.85,1.2,.01]})}),Xe(Br,{z:.38,children:Xe(hn,{size:[.85-i,1.2-i,.01]})})]})]})}),Xe(hn,{color:"#ccc",size:[o,.25,s],center:[.55,0,s/2]}),Xe(hn,{color:"#ccc",size:[o,a,s],center:[-.55,.4,s/2]}),Xe(hn,{color:"#ccc",size:[o,a,s],center:[-.55,-.4,s/2]})]})},Wmn=({num_pins:t,bodyWidth:e=5.3,bodyLength:n=5.3,bodyThickness:r=1,thermalPadSize:i,padWidth:o=n/5.3*.6,padLength:s=n/5.3*1,pitch:a=.5,thermalPadThickness:c=.2})=>{const l=[],u=Math.floor(t/2),d=a*(u-1);for(let h=0;h<t;h++){const p=h<u?"left":"right",f=h%u,m=d/2-f*a,y=s,g=o,_=p==="left"?-e/2+y/2:e/2-y/2,b=h+1;l.push({pinNumber:b,x:_,y:m,padSizeX:y,padSizeY:g})}return Un(Ai,{children:[Xe(Rh,{center:{x:0,y:0,z:0},width:e,length:n,height:r,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(e/2-s),y:n/2-s,z:r}}),l.map((h,p)=>Xe(hn,{center:[h.x,h.y,c/2],size:[h.padSizeX,h.padSizeY,c]})),i?.length!==void 0&&i?.width!==void 0&&Xe(hn,{center:[0,0,c/2],size:[i.width,i.length,c]})]})},Kmn=({bodyLength:t=10.2,bodyWidth:e=4.65,bodyHeight:n=13.46,leadSpacing:r=5,leadDiameter:i=.8,leadLength:o=12.7,color:s="#ddd",leadColor:a="#b87333"})=>{const c=t/2,l=e/2,u=c-l,d=r/2,h=.85;return Un(Ai,{children:[Un(co,{color:s,children:[Un(Hl,{children:[Xe(u_,{height:n,roundRadius:.5,radius:l,center:[-u,0,n]}),Xe(u_,{height:n,roundRadius:.5,radius:l,center:[u,0,n]})]}),Un(Hl,{children:[Xe(u_,{height:h,roundRadius:.1,radius:l+.85,center:[-u,0,n/2+h/2]}),Xe(u_,{height:h,roundRadius:.1,radius:l+.85,center:[u,0,n/2+h/2]})]})]}),Un(co,{color:a,children:[Xe(rh,{height:o+n/2,radius:i/2,center:[-d+.06,0,-(o/2)+n/2]}),Xe(rh,{height:o+n/2,radius:i/2,center:[d-.06,0,-(o/2)+n/2]})]})]})},Zmn=({bodyLength:t=1.4,bodyDiameter:e=1.1,color:n="#3a3a3aff",contactColor:r="#c6c6c6",cathodeIdentification:i="#111"})=>Un(Ai,{children:[Xe(co,{color:n,children:Un(f0,{rotation:[0,"90deg",0],children:[Xe(qR,{size:[e,e,t-.2],roundRadius:.2,center:[-e/2,0,.05]}),Xe(rh,{height:.2/2,radius:e/2-.2,center:[-e/2,0,-t/2+.2/2]})]})}),Xe(co,{color:i,children:Xe(f0,{rotation:[0,"90deg",0],children:Xe(qR,{size:[e*1.01,e*1.01,t/3],roundRadius:.2,center:[-e/2,0,-t/4+.1]})})}),Xe(co,{color:r,children:Xe(f0,{rotation:[0,"90deg",0],children:Xe(u_,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,-t/2]})})}),Xe(co,{color:r,children:Xe(f0,{rotation:[0,"90deg",0],children:Xe(u_,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,t/2]})})})]}),Qmn=({bodyLength:t=3.5,bodyDiameter:e=1.5,color:n="#3a3a3aff",contactColor:r="#c6c6c6"})=>Un(Ai,{children:[Xe(co,{color:n,children:Xe(f0,{rotation:[0,"90deg",0],children:Xe(u_,{height:t,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),Xe(co,{color:r,children:Xe(f0,{rotation:[0,"90deg",0],children:Xe(u_,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,-t/2]})})}),Xe(co,{color:r,children:Xe(f0,{rotation:[0,"90deg",0],children:Xe(u_,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,t/2]})})})]}),Jmn=({bodyLength:t=3.9,bodyDiameter:e=2.5,color:n="#3a3a3aff",contactColor:r="#c6c6c6"})=>Un(Ai,{children:[Xe(co,{color:n,children:Xe(f0,{rotation:[0,"90deg",0],children:Xe(u_,{height:t,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),Xe(co,{color:r,children:Xe(f0,{rotation:[0,"90deg",0],children:Xe(u_,{height:.55,radius:e/2,roundRadius:.2,center:[-e/2,0,-t/2]})})}),Xe(co,{color:r,children:Xe(f0,{rotation:[0,"90deg",0],children:Xe(u_,{height:.55,radius:e/2,roundRadius:.2,center:[-e/2,0,t/2]})})})]}),e1n=({pinCount:t,padContactLength:e=.6,leadWidth:n=.41,pitch:r=1.27})=>{if(t%2!==0)throw new Error("MS012 pinCount must be even");const i=t/2,o=4.9,s=3.9,a=(i-1)*r/2,c=.2;return Un(Ai,{children:[Array.from({length:i}).map((l,u)=>Xe(Vi,{position:{x:-s/2-e-.3,y:u*r-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Array.from({length:i}).map((l,u)=>Xe(Vi,{rotation:Math.PI,position:{x:s/2+e+.3,y:u*r-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Xe(Rh,{center:{x:0,y:0,z:c/2},width:s,length:o,height:1.55,notchPosition:{x:-.95,y:o/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},t1n=({pinCount:t=16,padContactLength:e=.6,leadWidth:n=.41,pitch:r=1.27})=>{if(t!==16)throw new Error("MS013 only supports 16 pins");const i=t/2,o=7.5,s=10.3,a=(i-1)*r/2,c=.2;return Un(Ai,{children:[Array.from({length:i}).map((l,u)=>Xe(Vi,{position:{x:-o/2-e-.3,y:u*r-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Array.from({length:i}).map((l,u)=>Xe(Vi,{rotation:Math.PI,position:{x:o/2+e+.3,y:u*r-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Xe(Rh,{center:{x:0,y:0,z:c/2},width:o,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},n1n=()=>{const m=7.050000000000001,y=24.95+6.5/2;return Xe(Br,{center:[0,0,1],children:Un(Ai,{children:[Un(f0,{rotation:[0,55,-55],children:[Un(Dx,{children:[Xe(hn,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[y,0,1.3-2]}),Xe(rh,{color:"black",center:[y,0,1.3-2],radius:3/2,height:1.3*1.2})]}),Xe(co,{color:"#222",children:Xe(Rh,{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})})]}),Xe(f0,{rotation:[0,55,55],children:Array.from({length:3}).map((g,_)=>{const b=m,v=(_-1)*2.7,T=-.5-.6;return Un(co,{color:"gold",children:[Un(Hl,{children:[Xe(Br,{center:[15.05-4.5/2+.1,v,T],children:Xe(hn,{size:[4.5,.81+1,.5]})}),Xe(Br,{center:[15.05-4.5/2-1+.1,v,T],children:Xe(hn,{size:[4.5,.81,.5]})})]}),Xe(Br,{center:[b,v,T],children:Xe(hn,{size:[16+.1,.81,.5]})})]},`prong-${_}`)})})]})})},r1n=()=>{const l=1.1999999999999997;return Un(Ai,{children:[Xe(Vi,{rotation:Math.PI,position:{x:2.8/2+l/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Xe(Vi,{rotation:Math.PI,position:{x:2.8/2+l/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Xe(Vi,{rotation:Math.PI,position:{x:2.8/2+l/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Xe(Vi,{position:{x:-2.8/2-l/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Xe(Vi,{position:{x:-2.8/2-l/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Xe(Vi,{position:{x:-2.8/2-l/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Xe(Rh,{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})]})},i1n=()=>Un(Ai,{children:[Xe(Rh,{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(l=>{const u=-.35+l*.35;return Xe(hn,{center:[-.8/2+.19/2-.1,u,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(l=>{const u=-.35+l*.35;return Xe(hn,{center:[.8/2-.19/2+.1,u,.12/2],size:[.19,.15,.12]})})]}),o1n=()=>{const s="#222",c=[.43,.4,1.32],l=[.43,.4,.25],u=[0,0,-.66],d=[0,0,-1.32],h=[0,1.28,-2.72],p=[0,1.28,-8.9],f=-7.5;return Un(Br,{center:[0,1,10.5],children:[Xe(co,{color:s,children:Un(Dx,{children:[Xe(Br,{center:[0,0,2.25],children:Xe(rh,{radius:2.4,height:4.5})}),Xe(Br,{center:[0,-1.8499999999999999,2.25],children:Xe(hn,{size:[2.4*2,1.1,4.5+.2]})})]})}),Xe(Br,{center:u,children:Xe(hn,{size:c})}),Un(Hl,{children:[Xe(Br,{center:d,children:Xe(hn,{size:l})}),Xe(Br,{center:h,children:Xe(hn,{size:l})})]}),Xe(Br,{center:p,children:Xe(hn,{size:[.43,.4,12.2]})}),Xe(Br,{center:[1.3,0,f],children:Xe(hn,{size:[.43,.4,15]})}),Xe(Br,{center:[-1.3,0,f],children:Xe(hn,{size:[.43,.4,15]})})]})},s1n=()=>Un(Ai,{children:[Xe(Vi,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Xe(Vi,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Xe(Vi,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Xe(Vi,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Xe(Vi,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Xe(Vi,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Xe(Rh,{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})]}),a1n=s1n,c1n=()=>Un(Ai,{children:[Xe(Rh,{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 c=-.5+a*.5;return Xe(hn,{center:[-1/2+.3/2,c,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(a=>{const c=-.5+a*.5;return Xe(hn,{center:[1/2-.3/2,c,.05/2],size:[.3,.2,.05]})})]}),l1n=()=>Un(Ai,{children:[Xe(Vi,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Xe(Vi,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Xe(co,{color:"#222",children:Xe(Rh,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),Xe(hn,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),u1n=()=>Un(Ai,{children:[Xe(hn,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),Xe(hn,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),Xe(co,{color:"#222",children:Un(Kp,{children:[Xe(Br,{z:.175/2,children:Xe(hn,{size:[1.7,1.25,.175]})}),Un(Hl,{children:[Xe(Br,{z:.175,children:Xe(hn,{size:[1.7,1.25,.01]})}),Xe(Br,{z:.725,children:Xe(hn,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),Xe(hn,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),d1n=()=>{const s=-1.0474999999999999,a=1.775/2+.4/2-.04;return Un(Ai,{children:[Xe(hn,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),Xe(hn,{color:"#ccc",size:[.4,.325,.13],center:[a,0,.13/2]}),Xe(co,{color:"#222",children:Xe(Rh,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),Xe(hn,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},h1n=({pitch:t=10})=>Un(Ai,{children:[Xe(rh,{height:4,radius:.5,center:[-t/2,0,.5]}),Xe(lU,{radius:.5,center:[-t/2,0,2.5]}),Xe(Br,{x:-2.5,y:0,z:2.5,children:Un(f0,{rotation:[0,Math.PI/2,0],children:[Xe(rh,{height:t,radius:.5,center:[0,0,2.5]}),Xe(co,{color:"#d2b48c",children:Xe(rh,{height:5,radius:1.3,center:[0,0,2.5]})})]})}),Xe(rh,{height:4,radius:.5,center:[t/2,0,.5]}),Xe(lU,{radius:.5,center:[t/2,0,2.5]})]}),p1n=({bodyWidth:t=21,boardThickness:e=.5,leadWidth:n=1.6,leadLength:r=2.4,leadsPitch:i=2.54,leadsLeft:o,leadsRight:s,leadsTop:a,leadsBottom:c,innerHoles:l=!0,innerHoleEdgeDistance:u=1.61,innerHoleDiameter:d=1})=>{const h=t/2,p=e/2,f=e*1.05,m=d/2,y=Math.max(o||0,s||0,a||0,c||0)*i||51,g=[],_=[];if(s){const E=-((s-1)/2)*i;for(let A=0;A<s;A++){const P=E+A*i;g.push({x:h-r/2,y:-P,pl:r,pw:n}),l&&_.push({x:h,y:-P},{x:h-u,y:-P})}}if(o){const E=-((o-1)/2)*i;for(let A=0;A<o;A++){const P=E+A*i;g.push({x:-h+r/2,y:-P,pl:r,pw:n}),l&&_.push({x:-h,y:-P},{x:-h+u,y:-P})}}if(a){const E=-((a-1)/2)*i;for(let A=0;A<a;A++){const P=E+A*i;g.push({x:-P,y:y/2-r/2,pl:n,pw:r}),l&&_.push({x:-P,y:y/2},{x:-P,y:y/2-u})}}if(c){const E=-((c-1)/2)*i;for(let A=0;A<c;A++){const P=E+A*i;g.push({x:-P,y:-y/2+r/2,pl:n,pw:r}),l&&_.push({x:-P,y:-y/2},{x:-P,y:-y/2+u})}}const b=Xe(co,{color:"#008080",children:Un(Dx,{children:[Xe(hn,{center:[0,0,p],size:[t,y,e]}),g.map((E,A)=>Xe(hn,{center:[E.x,E.y,p],size:[E.pl+.01,E.pw+.01,f]},A))]})}),v=l&&_.map((E,A)=>Xe(rh,{color:"black",center:[E.x,E.y,p],radius:m,height:e*1.07})),T=g.map((E,A)=>Xe(hn,{center:[E.x,E.y,p],size:[E.pl+.01,E.pw+.01,f]}));return Un(Ai,{children:[b,Xe(co,{color:"#FFD700",children:l?Un(Dx,{children:[Xe(Kp,{children:g.map((E,A)=>Xe(hn,{center:[E.x,E.y,p],size:[E.pl+.01,E.pw+.01,f]},A))}),v]}):T})]})},f1n=({width:t=30,height:e=22,thickness:n=1,bezelInset:r=2,bezelDepth:i=1,screenColor:o="#001414",bezelColor:s="#0f1116",screenWidth:a,screenHeight:c,offset:l})=>{const u=t,d=e,h=Math.max(n,.4),p=Math.max(Math.min(i,h),.2),f=Math.max(h-p,0),m=Math.max(r,0),y=Math.max(a??u-m*2,2),g=Math.max(c??d-m*2,2),_=Math.min(Math.max(p*.6,.2),p),b=l?.x??0,v=l?.y??0,T=l?.z??0;return Un(Br,{offset:{x:b,y:v,z:T},children:[f>0&&Xe(co,{color:s,children:Xe(hn,{size:[u,d,f],offset:[0,0,f/2]})}),Xe(co,{color:s,children:Un(Dx,{children:[Xe(hn,{size:[u,d,p],offset:[0,0,f+p/2]}),Xe(hn,{size:[y,g,p+.02],offset:[0,0,f+p/2]})]})}),Xe(co,{color:o,children:Xe(hn,{size:[y,g,_],offset:[0,0,f+_/2]})})]})},m1n=({numPins:t=5,rows:e=1,p:n=2.54,id:r=1,od:i=1.5,boardThickness:o=1.6,width:s,height:a,pinRowSide:c="left",holes:l=[],holeInset:u=1,pinRowHoleEdgeToEdgeDist:d=2,female:h,nopin:p,screen:f,screenWidth:m,screenHeight:y,screenCenterOffsetX:g,screenCenterOffsetY:_})=>{const b=f??!1,v=o/2,T=Math.ceil(t/e);let E,A;c==="left"||c==="right"?(E=(e-1)*n+2*d,A=(T-1)*n+2*d):(A=(e-1)*n+2*d,E=(T-1)*n+2*d),t===0&&(E=10,A=10);const P=Number(s??E),N=Number(a??A),C=[];let D=0,I=0,B=0,U=0,H=0,X=0;c==="left"||c==="right"?(D=c==="left"?-P/2+d:P/2-d,I=-((T-1)/2)*n,B=0,U=n,H=c==="left"?n:-n,X=0):(D=-((T-1)/2)*n,I=c==="top"?N/2-d:-N/2+d,B=n,U=0,H=0,X=c==="top"?-n:n);let W=0;for(let _e=0;_e<e&&W<t;_e++)for(let Me=0;Me<T&&W<t;Me++){const ye=D+Me*B+_e*H,je=I+Me*U+_e*X;C.push({x:ye,y:je}),W++}const ee=[];if(l)for(const _e of l){let Me=0,ye=0;_e==="topleft"?(Me=-P/2+u,ye=N/2-u):_e==="topright"?(Me=P/2-u,ye=N/2-u):_e==="bottomleft"?(Me=-P/2+u,ye=-N/2+u):_e==="bottomright"?(Me=P/2-u,ye=-N/2+u):_e==="center"&&(Me=0,ye=0),ee.push({x:Me,y:ye})}const re=.63,pe=2,ie=6,ae=3,de=p||h?0:pe,he=de+o,ve=Xe(co,{color:"#008080",children:Un(Dx,{children:[Xe(hn,{center:[0,0,v+de],size:[P,N,o]}),ee.map((_e,Me)=>Xe(rh,{center:[_e.x,_e.y,v+de],radius:i/2,height:o},`hole-${Me}`)),C.map((_e,Me)=>Xe(rh,{center:[_e.x,_e.y,v+de],radius:i/2,height:o},`pin-hole-${Me}`))]})}),Ae=C.map((_e,Me)=>Xe(co,{color:"#FFD700",children:Un(Dx,{children:[Xe(rh,{center:[_e.x,_e.y,o/2+de],radius:i/2,height:o}),Xe(rh,{center:[_e.x,_e.y,o/2+de],radius:r/2,height:o})]})})),Ce=C.map((_e,Me)=>Xe(sXe,{x:_e.x,y:_e.y,pinThickness:re,shortSidePinLength:ae,longSidePinLength:ie,bodyHeight:pe,flipZ:ye=>ye})),Be=C.map((_e,Me)=>Xe(pXe,{x:_e.x,y:_e.y,flipZ:ye=>-ye}));return Un(Ai,{children:[ve,Ae,!h&&!p&&Ce,h&&Be,b&&Xe(f1n,{width:m??P*.8,height:y??N*.6,offset:{x:g??0,y:_??0,z:he}})]})},y1n=({footprint:t})=>{const e=Qfn.string(t).json();switch(e.fn){case"dip":return Xe(rmn,{numPins:e.num_pins,pitch:e.p,bodyWidth:e.w});case"axial":return Xe(h1n,{pitch:e.p});case"tssop":return Xe(omn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"msop":return Xe(smn,{pinCount:e.num_pins,padContactLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"vssop":return Xe(Nmn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w,bodyLength:e.h});case"qfp":return Xe(umn,{pinCount:e.num_pins,pitch:e.p,leadWidth:e.pw,padContactLength:e.pl,bodyWidth:e.w});case"tqfp":return Xe(Ymn,{});case"lqfp":return Xe(Gmn,{pinCount:e.num_pins});case"qfn":{const i=typeof e.thermalpad?.x=="number"&&typeof e.thermalpad?.y=="number";return Xe(_mn,{num_pins:e.num_pins,bodyWidth:e.w,bodyLength:e.h,pitch:e.p,padLength:e.pl,padWidth:e.pw,thermalPadSize:i?{width:e.thermalpad.x,length:e.thermalpad.y}:void 0})}case"dfn":{const i=typeof e.thermalpad?.x=="number"&&typeof e.thermalpad?.y=="number";return Xe(Wmn,{num_pins:e.num_pins,bodyWidth:e.w,bodyLength:e.h,pitch:e.p,padLength:e.pl,padWidth:e.pw,thermalPadSize:i?{width:e.thermalpad.x,length:e.thermalpad.y}:void 0})}case"pinrow":{const i=t.match(/_rows(\d+)/),o=i&&i[1]?parseInt(i[1],10):1;if(e.male)return Xe(fmn,{numberOfPins:e.num_pins,pitch:e.p,invert:e.invert,faceup:e.faceup,rows:o,smd:e.smd||e.surface_mount,rightangle:e.rightangle});if(e.female)return Xe(Pmn,{numberOfPins:e.num_pins,pitch:e.p,rows:o})}case"cap":switch(e.imperial){case"0402":return Xe(rXe,{color:"#856c4d"});case"0603":return Xe(iXe,{color:"#856c4d"});case"0805":return Xe(oXe,{color:"#856c4d"});case"0201":return Xe(aXe,{color:"#856c4d"});case"01005":return Xe(cXe,{color:"#856c4d"});case"1206":return Xe(lXe,{color:"#856c4d"});case"1210":return Xe(uXe,{color:"#856c4d"});case"2010":return Xe(dXe,{color:"#856c4d"});case"2512":return Xe(hXe,{color:"#856c4d"})}case"sot235":return Xe(bmn,{});case"sot457":return Xe(r1n,{});case"sot223":return Xe(Hmn,{});case"sot23w":return Xe(vmn,{});case"sot323":return Xe(Xmn,{});case"sod323f":return Xe(u1n,{});case"sod323fl":return Xe(d1n,{});case"sot363":return Xe(a1n,{});case"sot886":return Xe(c1n,{});case"sot963":return Xe(i1n,{});case"pushbutton":return Xe(Amn,{width:e.w,length:e.h,innerDiameter:e.id});case"soic":return Xe(Rmn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"sod523":return Xe(kmn,{});case"sod882":return Xe(Omn,{});case"sma":return Xe(Imn,{});case"smb":return Xe(Lmn,{});case"smc":return Xe(Dmn,{});case"smf":return Xe(zmn,{});case"sod123f":return Xe($mn,{});case"sod123fl":return Xe(Fmn,{});case"sod123w":return Xe(Bmn,{});case"sod128":return Xe(jmn,{});case"sod323":return Xe(l1n,{});case"sod923":return Xe(Umn,{});case"hc49":return Xe(Kmn,{});case"micromelf":return Xe(Zmn,{});case"minimelf":return Xe(Qmn,{});case"melf":return Xe(Jmn,{});case"ms012":return Xe(e1n,{pinCount:e.num_pins,padContactLength:e.pl,leadWidth:e.pw,pitch:e.p});case"ms013":return Xe(t1n,{pinCount:e.num_pins,padContactLength:e.pl,leadWidth:e.pw,pitch:e.p});case"sot723":return Xe(qmn,{});case"to220":return Xe(n1n,{});case"to92":return Xe(o1n,{});case"stampboard":case"stampreceiver":return Xe(p1n,{bodyWidth:e.w,leadsLeft:e.left,leadsRight:e.right,leadsTop:e.top,leadsBottom:e.bottom,leadsPitch:e.p,leadWidth:e.pw,leadLength:e.pl,innerHoles:e.innerhole,innerHoleEdgeDistance:e.innerholeedgedistance});case"mountedpcbmodule":{const i=e.rows??1,o=e.pinRowSide??"left",s=e.holeInset,a=e.width,c=e.height,l=e.pinrow,u=e.pinRowHoleEdgeToEdgeDist,d=Array.isArray(e.holes)?e.holes:[];return Xe(m1n,{numPins:l,rows:i,p:e.p,id:e.id,od:e.od,width:a,height:c,pinRowSide:o,holes:d,holeInset:s,pinRowHoleEdgeToEdgeDist:u,nopin:e.nopin,female:e.female,screen:e.screen,screenWidth:e.screenwidth,screenHeight:e.screenheight,screenCenterOffsetX:e.screencenteroffsetx,screenCenterOffsetY:e.screencenteroffsety})}}const n=t.match(/_color\(([^)]+)\)/),r=n?n[1]:void 0;switch(e.imperial){case"0402":return Xe(rXe,{color:r});case"0603":return Xe(iXe,{color:r});case"0805":return Xe(oXe,{color:r});case"0201":return Xe(aXe,{color:r});case"01005":return Xe(cXe,{color:r});case"1206":return Xe(lXe,{color:r});case"1210":return Xe(uXe,{color:r});case"2010":return Xe(dXe,{color:r});case"2512":return Xe(hXe,{color:r})}return null},g1n=t=>t&&typeof t=="object"&&"type"in t,oT=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},_1n=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 e4(t,e,n){const{jscad:{primitives:r,booleans:i,hulls:o,geometries:s,extrusions:a,transforms:c}}=n;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(h=>e4(h,e,n));if(!g1n(t))return[];const{type:l,props:u,children:d}=t;if(l===eXe)return(d??[]).flatMap(h=>e4(h,e,n));if(l===co){const h=u?.color;return(d??[]).flatMap(p=>e4(p,h??e,n))}if(l===Br){const h=_1n(u?.offset??u?.center??{x:u?.x,y:u?.y,z:u?.z});return(d??[]).flatMap(f=>e4(f,e,n)).map(({geom:f,color:m})=>({geom:c.translate(h,f),color:m??e}))}if(l===f0){const h=Array.isArray(u?.rotation)?[oT(u.rotation[0]),oT(u.rotation[1]),oT(u.rotation[2])]:[oT(u?.x??0),oT(u?.y??0),oT(u?.z??0)];return(d??[]).flatMap(f=>e4(f,e,n)).map(({geom:f,color:m})=>({geom:c.rotateZ(h[2],c.rotateY(h[1],c.rotateX(h[0],f))),color:m}))}if(l===Kp||l===Dx||l===Hl){const h=(d??[]).flatMap(f=>e4(f,e,n)).map(f=>f.geom);if(h.length===0)return[];let p;return l===Kp?p=i.union(h):l===Dx?p=i.subtract(h[0],h.slice(1)):p=o.hull(h),[{geom:p,color:e}]}if(l===WR){const h=u?.points??[];return[{geom:s.geom2.fromPoints(h),color:e??u?.color}]}if(l===KR){const h=(d??[]).flatMap(y=>e4(y,e,n)).map(y=>y.geom);if(h.length===0)return[];const p=h.length>1?i.union(h):h[0],f=u?.height??u?.h??1;let m=a.extrudeLinear({height:f},p);if(m.polygons)for(const y of m.polygons)!y.plane||!y.vertices||y.vertices.length<3||y.vertices.reverse();return[{geom:m,color:e??u?.color}]}if(l===hn||l===tXe||l===rh||l===lU||l===qR||l===u_){let h;if(l===hn){const p=u?.size??[1,1,1],f=u?.offset,m=u?.center??(f?[f[0],f[1],f[2]]:[0,0,0]);h=r.cuboid({size:p,center:m})}else if(l===tXe){const p=u?.size??1,f=u?.offset,m=u?.center??(f?[f[0],f[1],f[2]]:[0,0,0]);h=r.cube({size:p,center:m})}else if(l===rh){const p=u?.height??1,f=u?.radius??1,m=u?.center??[0,0,0];h=r.cylinder({height:p,radius:f,center:m})}else if(l===lU){const p=u?.radius??1,f=u?.center??[0,0,0];h=r.sphere({radius:p,center:f})}else if(l===u_){const p=u?.height??1,f=u?.radius??1,m=u?.roundRadius??.1,y=u?.center??[0,0,0];h=r.roundedCylinder({height:p,radius:f,roundRadius:m,center:y})}else{const p=u?.size??[1,1,1],f=u?.roundRadius??.1,m=u?.center??[0,0,0];h=r.roundedCuboid({size:p,roundRadius:f,center:m})}return[{geom:h,color:e??u?.color}]}if(typeof l=="function"){const h=l(u??{});return e4(h,e,n)}return(d??[]).flatMap(h=>e4(h,e,n))}function x1n(t,e){return{geometries:e4(t,void 0,{jscad:e})}}function fXe(t){if(t.polygons){const e=[],n=[],r=[];let i=0;for(const s of t.polygons){for(const c of s.vertices)c.index=i,e.push(c[0],c[1],c[2]),t.color&&t.color.length>=3?r.push(t.color[0],t.color[1],t.color[2]):r.push(1,1,1),i++;const a=s.vertices[0].index;for(let c=2;c<s.vertices.length;c++){const l=s.vertices[c-1].index,u=s.vertices[c].index;n.push(a,l,u)}}const o=new Kc;if(o.setAttribute("position",new Bl(new Float32Array(e),3)),o.setIndex(n),r.length>0&&o.setAttribute("color",new Bl(new Float32Array(r),3)),t.transforms){const s=new Lo;s.fromArray(t.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}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 r=new Kc;if(r.setAttribute("position",new Bl(new Float32Array(e),3)),n.length>0&&r.setAttribute("color",new Bl(new Float32Array(n),3)),t.transforms){const i=new Lo;i.fromArray(t.transforms),r.applyMatrix4(i)}return r}return console.error("Invalid CSG object: neither polygons nor sides found"),new Kc}function b1n(t,e){const n=v0e(y1n,{footprint:t});return x1n(n,e)}var v1n=xc(eU()),mXe=J.createContext(null),w1n=()=>{const t=J.useContext(mXe);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},S1n=({children:t})=>{const{camera:e,renderer:n}=Xy(),[r,i]=J.useState([]),o=J.useMemo(()=>new u_t,[]),s=J.useMemo(()=>new fi,[]),a=J.useRef(r);a.current=r;const c=J.useRef(null),l=J.useCallback(f=>{i(m=>[...m,f])},[]),u=J.useCallback(f=>{if(c.current){let m=!1,y=c.current.object;for(;y;){if(y===f){m=!0;break}y=y.parent}m&&(c.current.onUnhover(),c.current=null)}i(m=>m.filter(y=>y.object!==f))},[]),d=J.useCallback(f=>{let m=f;for(;m;){const y=a.current.find(g=>g.object===m);if(y)return y;m=m.parent}},[]),h=J.useCallback(f=>{if(!n.domElement)return;const m=n.domElement.getBoundingClientRect();s.x=(f.clientX-m.left)/m.width*2-1,s.y=-((f.clientY-m.top)/m.height)*2+1,o.setFromCamera(s,e);const y=a.current.map(_=>_.object);if(y.length===0){c.current&&(c.current.onUnhover(),c.current=null);return}const g=o.intersectObjects(y,!0);if(g.length>0){const _=g[0],b=d(_.object);if(b){const v={mousePosition:[_.point.x,_.point.y,_.point.z]};c.current!==b?(c.current?.onUnhover(),b.onHover(v),c.current=b):b.onHover(v)}else c.current&&(c.current.onUnhover(),c.current=null)}else c.current&&(c.current.onUnhover(),c.current=null)},[e,n,o,s,d]);J.useEffect(()=>{const f=n.domElement;return f.addEventListener("mousemove",h),()=>{f.removeEventListener("mousemove",h)}},[n,h]);const p=J.useMemo(()=>({addHoverable:l,removeHoverable:u}),[l,u]);return G.jsx(mXe.Provider,{value:p,children:t})},E1n=({children:t,object:e,onHover:n,onUnhover:r,isHovered:i})=>{const{addHoverable:o,removeHoverable:s}=w1n();return J.useEffect(()=>e?(o({object:e,onHover:n,onUnhover:r}),()=>{s(e)}):void 0,[e,n,r,o,s]),G.jsx(G.Fragment,{children:t})},oN=E1n,M1n=({positionOffset:t,footprint:e,rotationOffset:n,onHover:r,onUnhover:i,isHovered:o,scale:s,isTranslucent:a=!1})=>{const{rootObject:c}=Xy(),l=J.useMemo(()=>{if(!e)return null;const{geometries:u}=b1n(e,v1n),d=new Lf;for(const h of u.flat(1/0)){const p=h.geom;if(!p||!p.polygons&&!p.sides)continue;const f=new Yr(h.color);f.convertLinearToSRGB();const m={...p,color:[f.r,f.g,f.b]},y=fXe(m),g=new Om({vertexColors:!0,side:Bp,transparent:a,opacity:a?.5:1,depthWrite:!a}),_=new Xi(y,g);_.renderOrder=a?2:1,d.add(_)}return d},[e,a]);return J.useEffect(()=>{if(!(!l||!c))return c.add(l),()=>{c.remove(l)}},[c,l]),J.useEffect(()=>{l&&(t&&l.position.fromArray(t),n&&l.rotation.fromArray(n),s!==void 0&&l.scale.setScalar(s))},[l,t?.[0],t?.[1],t?.[2],n?.[0],n?.[1],n?.[2],s]),J.useEffect(()=>{l&&l.traverse(u=>{u instanceof Xi&&u.material instanceof Om&&(o?(u.material.emissive.setHex(255),u.material.emissiveIntensity=.2):u.material.emissiveIntensity=0)})},[o,l]),l?G.jsx(oN,{isHovered:o,onHover:r,onUnhover:i,object:l}):null},yXe=new WeakMap,T1n=()=>{const t=new fu;return t.name="fallback-environment-map",t.mapping=fI,t},C1n=t=>{if(!t)return null;const e=t,n=yXe.get(e);if(n)return n;let r;if(t instanceof XI){const i=new uq(t);r=i.fromScene(fxt(),.04).texture,i.dispose()}else r=T1n();return yXe.set(e,r),r};function P1n(t){const e=new gx;let n=!1;t.updateWorldMatrix(!0,!1);const r=t.parent?t.parent.matrixWorld.clone().invert():new Lo;return t.traverse(i=>{if(i.updateWorldMatrix(!0,!1),i instanceof Xi&&i.geometry&&(i.geometry.boundingBox||i.geometry.computeBoundingBox(),i.geometry.boundingBox)){const o=i.geometry.boundingBox.clone();o.applyMatrix4(i.matrixWorld),o.applyMatrix4(r),n?e.union(o):(e.copy(o),n=!0)}}),n?e:null}function A1n(t){const e=P1n(t);return e?e.getSize(new Mt):new Mt}function R1n(t,e,n="contain_within_bounds"){if(!e)return[1,1,1];const r=A1n(t),i=[r.x>0?e[0]/r.x:1,r.y>0?e[1]/r.y:1,r.z>0?e[2]/r.z:1];if(n==="fill_bounds")return i;const o=Math.min(...i);return[o,o,o]}var j0e=({model:t,position:e,rotation:n,modelOffset:r=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:o,modelSize:s,modelFitMode:a="contain_within_bounds",scale:c})=>{const{rootObject:l}=Xy(),u=J.useMemo(()=>new Lf,[]),d=J.useMemo(()=>new Lf,[]),h=J.useMemo(()=>new Lf,[]),p=J.useMemo(()=>new Lf,[]);return J.useEffect(()=>(u.add(d),()=>{u.remove(d)}),[u,d]),J.useEffect(()=>(d.add(h),()=>{d.remove(h)}),[d,h]),J.useEffect(()=>(h.add(p),()=>{h.remove(p)}),[h,p]),J.useEffect(()=>{for(;p.children.length>0;){const f=p.children[0];if(!f)break;p.remove(f)}t&&p.add(t)},[p,t]),J.useEffect(()=>{if(!o){p.matrixAutoUpdate=!0,p.position.set(0,0,0),p.rotation.set(0,0,0),p.scale.set(1,1,1),p.updateMatrix();return}p.matrixAutoUpdate=!1,p.matrix.copy(o),p.matrixWorldNeedsUpdate=!0},[p,o]),J.useEffect(()=>{if(l)return l.add(u),()=>{l.remove(u)}},[l,u]),J.useEffect(()=>{if(e?u.position.fromArray(e):u.position.set(0,0,0),n?u.rotation.fromArray(n):u.rotation.set(0,0,0),h.position.fromArray(r),h.rotation.fromArray(i),h.scale.setScalar(c??1),!t){d.scale.set(1,1,1);return}d.scale.set(1,1,1),d.updateWorldMatrix(!0,!0);const f=R1n(h,s,a);d.scale.set(f[0],f[1],f[2])},[u,d,t,a,r,p,h,i,s,e,n,c]),{boardTransformGroup:u}},gXe=1.25;function _Xe({gltfUrl:t,position:e,rotation:n,modelOffset:r=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:o,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:c,onUnhover:l,isHovered:u,scale:d,isTranslucent:h=!1}){const{renderer:p}=Xy(),[f,m]=J.useState(null),[y,g]=J.useState(null),{boardTransformGroup:_}=j0e({model:f,position:e,rotation:n,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:d});if(J.useEffect(()=>{if(!t)return;const b=new yxt;let v=!0;return b.load(t,T=>{if(!v)return;const E=T.scene;E.traverse(A=>{if(A instanceof Xi&&A.material){const P=N=>{N.transparent=h,N.opacity=h?.5:1,N.depthWrite=!h,N.needsUpdate=!0};Array.isArray(A.material)?A.material.forEach(P):P(A.material),A.renderOrder=h?2:1}}),m(E)},void 0,T=>{if(!v)return;console.error(`An error happened loading ${t}`,T);const E=T instanceof Error?T:new Error(`Failed to load glTF model from ${t}`);g(E)}),()=>{v=!1}},[t,h]),J.useEffect(()=>{if(!f||!p)return;const b=C1n(p);if(!b)return;const v=[],T=E=>{E instanceof Om&&(v.push({material:E,envMap:E.envMap??null,envMapIntensity:E.envMapIntensity??1}),E.envMap=b,(typeof E.envMapIntensity!="number"||E.envMapIntensity<gXe)&&(E.envMapIntensity=gXe),E.needsUpdate=!0)};return f.traverse(E=>{if(!(E instanceof Xi))return;const A=E.material;Array.isArray(A)?A.forEach(T):A&&T(A)}),()=>{v.forEach(({material:E,envMap:A,envMapIntensity:P})=>{E.envMap=A,E.envMapIntensity=P,E.needsUpdate=!0})}},[f,p]),J.useEffect(()=>{f&&f.traverse(b=>{b instanceof Xi&&b.material instanceof Om&&(u?(b.material.emissive.setHex(255),b.material.emissiveIntensity=.2):b.material.emissiveIntensity=0)})},[u,f]),y)throw y;return f?G.jsx(oN,{isHovered:u,onHover:c,onUnhover:l,object:_}):null}var N1n=xc(vYe()),k1n=xc(eU()),O1n=({jscadPlan:t,positionOffset:e,rotationOffset:n,modelOffset:r=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:o,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:c,onUnhover:l,isHovered:u,scale:d,isTranslucent:h=!1})=>{const{threeGeom:p,material:f}=J.useMemo(()=>{const g=(0,N1n.executeJscadOperations)(k1n.default,t);if(!g||!g.polygons&&!g.sides)return{threeGeom:null,material:null};const _=fXe(g),b=new Om({vertexColors:!0,side:Bp,transparent:h,opacity:h?.5:1,depthWrite:!h});return{threeGeom:_,material:b}},[t,h]),m=J.useMemo(()=>{if(!p)return null;const g=new Xi(p,f);return g.renderOrder=h?2:1,g},[p,f,h]),{boardTransformGroup:y}=j0e({model:m,position:e,rotation:n,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:d});return J.useEffect(()=>{if(f)if(u){const g=new Yr(f.color.getHex());f.emissive.copy(g),f.emissive.setRGB(0,0,1),f.emissiveIntensity=.2}else f.emissiveIntensity=0},[u,f]),p?G.jsx(oN,{isHovered:u,onHover:c,onUnhover:l,object:y}):null};function I1n(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(e,n,r)=>`${n} ${r.replace(/-/g,"_")}`)}async function L1n(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 t5t().parse(I1n(n),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function D1n(t){const[e,n]=J.useState(null);return J.useEffect(()=>{if(!t)return;const r=t.replace(/&cachebust_origin=$/,""),i=window.TSCIRCUIT_OBJ_LOADER_CACHE;let o=!1;async function s(){try{if(r.endsWith(".wrl"))return await L1n(r);const c=await fetch(r);if(!c.ok)throw new Error(`Failed to fetch "${r}": ${c.status} ${c.statusText}`);const l=await c.text(),u=l.match(/newmtl[\s\S]*?endmtl/g),d=new u5t;if(u?.length){const h=u.join(`
|
|
5152
|
-
`).replace(/d 0\./g,"d 1."),p=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),f=new Qxt;f.setMaterialOptions({invertTrProperty:!0});const m=f.parse(h.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return d.setMaterials(m),d.parse(p)}return d.parse(l.replace(/^mtllib.*/gm,""))}catch(c){return c}}function a(){if(i.has(r)){const l=i.get(r);return l.result?Promise.resolve(l.result.clone()):l.promise.then(u=>u instanceof Error?u:u.clone())}const c=s().then(l=>(l instanceof Error||i.set(r,{...i.get(r),result:l}),l));return i.set(r,{promise:c,result:null}),c}return a().then(c=>{o||n(c)}).catch(c=>{console.error(c)}),()=>{o=!0}},[t]),e}function z1n({url:t,position:e,rotation:n,modelOffset:r=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:o,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:c,onUnhover:l,isHovered:u,scale:d,isTranslucent:h=!1}){const p=D1n(t),f=J.useMemo(()=>p&&!(p instanceof Error)?(p.traverse(y=>{if(y instanceof Xi&&y.material){const g=_=>{_.transparent=h,_.opacity=h?.5:1,_.depthWrite=!h,_.needsUpdate=!0};Array.isArray(y.material)?y.material.forEach(g):g(y.material),y.renderOrder=h?2:1}}),p):new Xi(new S5(.5,.5,.5),new Om({transparent:!0,color:"red",opacity:.25})),[p,h]),{boardTransformGroup:m}=j0e({model:f,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:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:d});if(p instanceof Error)throw p;return G.jsx(oN,{isHovered:u,onHover:c,onUnhover:l,object:m})}var U0e,$1n="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function F1n(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 B1n(){if(!U0e){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");U0e=F1n(t)({locateFile:n=>`${$1n}/${n}`})}return U0e}function j1n(t){const e=new Lf;for(const n of t){const r=n.attributes.position?.array??[],i=n.index?.array??[];if(!r.length||!i.length)continue;const o=new Kc;o.setAttribute("position",new Do(r,3));const s=n.attributes.normal?.array??[];s.length?o.setAttribute("normal",new Do(s,3)):o.computeVertexNormals(),o.setIndex(i);const a=new Om({color:n.color?new Yr(n.color[0],n.color[1],n.color[2]):new Yr(.82,.82,.82)}),c=new Xi(o,a);c.name=n.name,e.add(c)}return e}async function U1n(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 B1n()).ReadStepFile(new Uint8Array(n),null);if(!i.success||!i.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=j1n(i.meshes),s=new $W;return await new Promise((c,l)=>{s.parse(o,u=>{u instanceof ArrayBuffer?c(u):l(new Error("GLTFExporter did not return binary output"))},u=>{l(u)},{binary:!0})})}var xXe="step-glb-cache:";function H1n(t){const e=new Uint8Array(t),n=32768;let r="";for(let i=0;i<e.length;i+=n){const o=e.subarray(i,i+n);r+=String.fromCharCode(...o)}return btoa(r)}function V1n(t){const e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)n[r]=e.charCodeAt(r);return n.buffer}function Y1n(t){try{const e=localStorage.getItem(`${xXe}${t}`);return e?V1n(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function bXe(t,e){try{const n=H1n(e);localStorage.setItem(`${xXe}${t}`,n)}catch(n){console.warn("Failed to write STEP GLB cache",n)}}function X1n(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var G1n=({stepUrl:t,position:e,rotation:n,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:d,isTranslucent:h})=>{const[p,f]=J.useState(null);return J.useEffect(()=>{let m=!0,y=null,g=!0;const _=X1n(),b=Y1n(t);if(b){const E={arrayBuffer:b,blobUrl:URL.createObjectURL(new Blob([b],{type:"model/gltf-binary"}))};return _.completed.set(t,E),y=E.blobUrl,g=!1,f(E.blobUrl),()=>{m=!1,y&&g&&URL.revokeObjectURL(y)}}const v=_.completed.get(t);if(v)return y=v.blobUrl,g=!1,f(v.blobUrl),bXe(t,v.arrayBuffer),()=>{m=!1,y&&g&&URL.revokeObjectURL(y)};let T=_.inProgress.get(t);return T||(T=U1n(t).then(E=>{const A={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return _.completed.set(t,A),_.inProgress.delete(t),A}).catch(E=>{throw _.inProgress.delete(t),E}),_.inProgress.set(t,T)),T.then(E=>{m&&(y=E.blobUrl,g=!1,f(E.blobUrl),bXe(t,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),m&&f(null)}),()=>{m=!1,y&&g&&URL.revokeObjectURL(y)}},[t]),p?G.jsx(_Xe,{gltfUrl:p,position:e,rotation:n,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:d,isTranslucent:h}):null};function pU(t,e){let{x:n,y:r,z:i}=t;if(e.axisMapping){const o={x:n,y:r,z:i};e.axisMapping.x&&(n=H0e(o,e.axisMapping.x)),e.axisMapping.y&&(r=H0e(o,e.axisMapping.y)),e.axisMapping.z&&(i=H0e(o,e.axisMapping.z))}if(n*=e.flipX??1,r*=e.flipY??1,i*=e.flipZ??1,e.rotation){if(e.rotation.x){const o=e.rotation.x*Math.PI/180,s=Math.cos(o),a=Math.sin(o),c=r*s-i*a,l=r*a+i*s;r=c,i=l}if(e.rotation.y){const o=e.rotation.y*Math.PI/180,s=Math.cos(o),a=Math.sin(o),c=n*s+i*a,l=-n*a+i*s;n=c,i=l}if(e.rotation.z){const o=e.rotation.z*Math.PI/180,s=Math.cos(o),a=Math.sin(o),c=n*s-r*a,l=n*a+r*s;n=c,r=l}}return{x:n,y:r,z:i}}function H0e(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 V0e={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 q1n(t,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return V0e.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?V0e.STEP_INVERTED:V0e.Z_UP_TO_Y_UP_USB_FIX}}function sN(t,e){return q1n(t,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function fU(t){if(!t)return;const e=pU({x:1,y:0,z:0},t),n=pU({x:0,y:1,z:0},t),r=pU({x:0,y:0,z:1},t);return new Lo().makeBasis(new Mt(e.x,e.y,e.z),new Mt(n.x,n.y,n.z),new Mt(r.x,r.y,r.z))}function s9(t){return t*Math.PI/180}function W1n(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,s9(-90),0];case"x-":return[0,s9(90),0];case"y+":return[s9(90),0,0];case"y-":return[s9(-90),0,0];case"z-":return[s9(180),0,0];default:return[0,0,0]}}function K1n(t,e,n){if(!t.position)return;let r=t.position.z;return e==="bottom"&&t.position.z>=0&&(r=-(t.position.z+n)),[t.position.x,t.position.y,r]}function Z1n(t,e){return t.rotation?[s9(t.rotation.x),s9(t.rotation.y),s9(t.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function Q1n(t,e){const n=new Mt(t.x,t.y,t.z),r=new Ly(e[0],e[1],e[2],"XYZ");return n.applyEuler(r),[n.x,n.y,n.z]}function J1n(t,e,n){if(!t.model_origin_position)return[0,0,0];const r=e?pU(t.model_origin_position,e):t.model_origin_position;return Q1n(r,n)}function eyn(t,e){const n=K1n(t,e.layer,e.pcbThickness),r=Z1n(t,e.layer),i=sN(t,e.modelType),o=W1n(t.model_board_normal_direction??"z+"),s=J1n(t,i,o);return{position:n,rotation:r,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:o,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 tyn=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",nyn=t=>t==="step"?"glb":t,ryn=(t,e)=>{if(t)return e?e(t):t},iyn=(...t)=>t,Y0e=class extends ri.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}},oyn=({error:t,onError:e})=>(J.useEffect(()=>{e(t)},[t,e]),null),vXe=({cad_component:t,circuitJson:e,resolveStaticAsset:n})=>{const r=EYe(e),[i,o]=J.useState(!1),{visibility:s}=F7(),[a,c]=J.useState(null),l=J.useCallback(X=>{X?.mousePosition?(o(!0),c(X.mousePosition)):(o(!1),c(null))},[]),u=J.useCallback(()=>{o(!1),c(null)},[]),d=J.useMemo(()=>di(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),h=J.useMemo(()=>e.filter(W=>W.type==="pcb_plated_hole"&&W.pcb_component_id===t.pcb_component_id).length>0,[e,t.pcb_component_id]),p=J.useCallback(X=>ryn(X,n),[n]),f=p(t.model_wrl_url??t.model_stl_url??t.model_obj_url),m=p(t.model_glb_url??t.model_gltf_url),y=p(t.model_step_url),[g,_]=J.useState(0),[b,v]=J.useState(null);J.useEffect(()=>{_(0),v(null)},[t.cad_component_id,f,m,y]);const E=e.find(X=>X.type==="pcb_component"&&X.source_component_id===t.source_component_id)?.layer??"top",A=tyn(t),P=nyn(A),N=t.model_glb_url?"glb":"gltf",C=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",D=J.useMemo(()=>eyn(t,{layer:E,pcbThickness:r,modelType:P}),[t,E,r,P]),I=iyn(...D.rotation),B=D.position,U=J.useMemo(()=>{const X=[];return m&&X.push(G.jsx(_Xe,{gltfUrl:m,position:B,rotation:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:fU(sN(t,N)),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${m}`)),f&&X.push(G.jsx(z1n,{url:f,position:B,rotation:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:fU(sN(t,C)),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${f}`)),y&&!t.model_jscad&&!t.footprinter_string&&X.push(G.jsx(G1n,{stepUrl:y,position:B,rotation:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:fU(sN(t,P)),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${y}`)),X},[B,t.cad_component_id,t.footprinter_string,t.model_jscad,t.show_as_translucent_model,m,N,l,u,i,C,D.modelPosition,D.modelRotation,D.scale,D.fitMode,D.size,P,I,y,f]);let H=null;if(U.length>0){if(g>=U.length){if(b)throw b;return null}H=G.jsx(Y0e,{fallback:({error:X})=>G.jsx(oyn,{error:X,onError:W=>{v(W),_(ee=>Math.max(ee,g+1))}}),children:U[g]},`${t.cad_component_id}-fallback-${g}`)}else t.model_jscad?H=G.jsx(O1n,{jscadPlan:t.model_jscad,positionOffset:B,rotationOffset:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:fU(sN(t,"jscad")),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(H=G.jsx(M1n,{positionOffset:B,rotationOffset:I,footprint:t.footprinter_string,scale:D.scale,onHover:l,onUnhover:u,isHovered:i,isTranslucent:t.show_as_translucent_model}));if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(h&&!s.throughHoleModels||!h&&!s.smtModels)return null;return G.jsxs(G.Fragment,{children:[H,i&&a?G.jsx(TYe,{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:d??"<unknown>"}):null]})},wXe={version:"0.0.548"};function syn(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var ayn=t=>{t.outputColorSpace=m5,t.toneMapping=t5e,t.toneMappingExposure=1},SXe="cadViewerCameraStateSession",EXe=(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(SXe,JSON.stringify(n))}catch(n){console.warn("Failed to save camera:",n)}},X0e=(t,e)=>{try{const n=sessionStorage.getItem(SXe);if(!n)return!1;const r=JSON.parse(n);if(t.position.fromArray(r.position),t.quaternion.fromArray(r.quaternion),t.up.fromArray(r.up),"fov"in t){const i=t;i.fov=r.fov,i.updateProjectionMatrix?.()}return e.target.fromArray(r.target),e.update(),t.updateMatrixWorld(),!0}catch(n){return console.warn("Failed to restore camera:",n),!1}},MXe=J.createContext(void 0),cyn=({children:t,defaultTarget:e,initialCameraPosition:n})=>{const r=J.useRef(null),i=J.useRef(null),[o,s]=J.useState(null),[a,c]=J.useState("perspective"),[l,u]=J.useState(n??null),[d,h]=J.useState(new Ly(0,0,0)),p=J.useMemo(()=>{const[g,_,b]=n??[5,-5,5],v=Math.hypot(g-e.x,_-e.y,b-e.z);return v>0?v:5},[n,e]),f=J.useCallback(g=>{const _=[e.x,e.y,e.z],b=i.current,v=r.current;let T=p;switch(b&&v&&(T=b.position.distanceTo(v.target)),g){case"Top Center Angled":{const E=T/Math.sqrt(2);return{position:[e.x,e.y-E,e.z+E],target:_,up:[0,0,1]}}case"Top Down":return{position:[e.x,e.y,e.z+T],target:_,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-T*.6,e.y-T*.6,e.z+T*.6],target:_,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+T*.6,e.y-T*.6,e.z+T*.6],target:_,up:[0,0,1]};case"Left Sideview":return{position:[e.x-T,e.y,e.z],target:_,up:[0,0,1]};case"Right Sideview":return{position:[e.x+T,e.y,e.z],target:_,up:[0,0,1]};case"Front":return{position:[e.x,e.y-T,e.z],target:_,up:[0,0,1]};default:return null}},[p,e,i,r]),m=J.useCallback(g=>{r.current=g},[]),y=J.useMemo(()=>({controlsRef:r,mainCameraRef:i,defaultTarget:e,baseDistance:p,controller:o,setController:s,getPresetConfig:f,handleControlsChange:m,cameraType:a,setCameraType:c,cameraPosition:l,setCameraPosition:u,cameraRotation:d,setCameraRotation:h,saveCameraToSession:EXe,loadCameraFromSession:X0e}),[e,p,o,f,m,a,l,d]);return G.jsx(MXe.Provider,{value:y,children:t})},a9=()=>{const t=J.useContext(MXe);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},lyn=J.forwardRef(({children:t,scene:e,camera:n,style:r,onCreated:i},o)=>{const{cameraType:s}=a9(),a=J.useRef(null),[c,l]=J.useState(null),u=J.useRef([]),d=J.useRef(void 0);d.current=i;const h=J.useRef(null),p=J.useCallback(g=>{u.current.push(g)},[]),f=J.useCallback(g=>{u.current=u.current.filter(_=>_!==g)},[]),m=J.useMemo(()=>new D8,[]);e?.up&&m.up.set(e.up.x,e.up.y,e.up.z);const y=J.useRef(new Wc);return J.useImperativeHandle(o,()=>y.current),J.useEffect(()=>{if(!a.current)return;syn(a.current);const g=new XI({antialias:!0,alpha:!0});ayn(g),g.setSize(a.current.clientWidth,a.current.clientHeight),g.setPixelRatio(window.devicePixelRatio),a.current.appendChild(g.domElement);const _=a.current.clientWidth/a.current.clientHeight,b=s==="perspective"?new If(75,_,.1,1e3):new fP(-10*_,10*_,10,-10,-1e3,1e3);h.current?(b.position.copy(h.current.position),b.quaternion.copy(h.current.quaternion),b.up.copy(h.current.up)):(n?.up&&b.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&b.position.set(n.position[0],n.position[1],n.position[2]),b.lookAt(0,0,0)),m.add(y.current),window.__TSCIRCUIT_THREE_OBJECT=y.current,l({scene:m,camera:b,renderer:g,rootObject:y.current,addFrameListener:p,removeFrameListener:f}),d.current?.({camera:b,renderer:g});let v;const T=new e_t,E=()=>{const P=T.getElapsedTime(),N=T.getDelta();u.current.forEach(C=>C(P,N)),g.render(m,b),v=requestAnimationFrame(E)};E();const A=()=>{if(a.current){const P=a.current.clientWidth/a.current.clientHeight;b instanceof If?b.aspect=P:b instanceof fP&&(b.left=-10*P,b.right=10*P,b.top=10,b.bottom=-10),b.updateProjectionMatrix(),g.setSize(a.current.clientWidth,a.current.clientHeight)}};return window.addEventListener("resize",A),()=>{h.current={position:b.position.clone(),quaternion:b.quaternion.clone(),up:b.up.clone()},window.removeEventListener("resize",A),cancelAnimationFrame(v),a.current&&g.domElement&&a.current.removeChild(g.domElement),g.dispose(),m.remove(y.current),window.__TSCIRCUIT_THREE_OBJECT===y.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[m,p,f,s]),G.jsx("div",{ref:a,style:{width:"100%",height:"100%",...r},children:c&&G.jsx(MYe.Provider,{value:c,children:G.jsx(S1n,{children:t})})})}),uyn=({autoRotate:t,autoRotateSpeed:e,onStart:n,panSpeed:r,rotateSpeed:i,zoomSpeed:o,enableDamping:s,dampingFactor:a,target:c,onControlsChange:l})=>{const{camera:u,renderer:d}=Xy(),h=J.useMemo(()=>!u||!d?null:new h5t(u,d.domElement),[u,d]);return J.useEffect(()=>(l?.(h??null),()=>l?.(null)),[h,l]),J.useEffect(()=>{if(!h)return;const p=()=>{l?.(h)};return h.addEventListener("change",p),()=>{h.removeEventListener("change",p)}},[h,l]),J.useEffect(()=>{h&&(h.autoRotate=t||!1,h.autoRotateSpeed=e||1,r!==void 0&&(h.panSpeed=r),i!==void 0&&(h.rotateSpeed=i),o!==void 0&&(h.zoomSpeed=o),s!==void 0&&(h.enableDamping=s),a!==void 0&&(h.dampingFactor=a),h.zoomToCursor=!0,h.mouseButtons={LEFT:Bv.ROTATE,MIDDLE:Bv.PAN,RIGHT:null},c&&(h.target.set(c[0],c[1],c[2]),h.update()))},[h,t,e,r,i,o,s,a,c]),J.useEffect(()=>{if(!(!h||!n))return h.addEventListener("start",n),()=>{h.removeEventListener("start",n)}},[h,n]),J.useEffect(()=>{if(h)return()=>{h.dispose()}},[h]),YR(()=>{h?.update()},[h]),null},dyn=`
|
|
5152
|
+
`).replace(/d 0\./g,"d 1."),p=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),f=new Qxt;f.setMaterialOptions({invertTrProperty:!0});const m=f.parse(h.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return d.setMaterials(m),d.parse(p)}return d.parse(l.replace(/^mtllib.*/gm,""))}catch(c){return c}}function a(){if(i.has(r)){const l=i.get(r);return l.result?Promise.resolve(l.result.clone()):l.promise.then(u=>u instanceof Error?u:u.clone())}const c=s().then(l=>(l instanceof Error||i.set(r,{...i.get(r),result:l}),l));return i.set(r,{promise:c,result:null}),c}return a().then(c=>{o||n(c)}).catch(c=>{console.error(c)}),()=>{o=!0}},[t]),e}function z1n({url:t,position:e,rotation:n,modelOffset:r=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:o,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:c,onUnhover:l,isHovered:u,scale:d,isTranslucent:h=!1}){const p=D1n(t),f=J.useMemo(()=>p&&!(p instanceof Error)?(p.traverse(y=>{if(y instanceof Xi&&y.material){const g=_=>{_.transparent=h,_.opacity=h?.5:1,_.depthWrite=!h,_.needsUpdate=!0};Array.isArray(y.material)?y.material.forEach(g):g(y.material),y.renderOrder=h?2:1}}),p):new Xi(new S5(.5,.5,.5),new Om({transparent:!0,color:"red",opacity:.25})),[p,h]),{boardTransformGroup:m}=j0e({model:f,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:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:d});if(p instanceof Error)throw p;return G.jsx(oN,{isHovered:u,onHover:c,onUnhover:l,object:m})}var U0e,$1n="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function F1n(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 B1n(){if(!U0e){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");U0e=F1n(t)({locateFile:n=>`${$1n}/${n}`})}return U0e}function j1n(t){const e=new Lf;for(const n of t){const r=n.attributes.position?.array??[],i=n.index?.array??[];if(!r.length||!i.length)continue;const o=new Kc;o.setAttribute("position",new Do(r,3));const s=n.attributes.normal?.array??[];s.length?o.setAttribute("normal",new Do(s,3)):o.computeVertexNormals(),o.setIndex(i);const a=new Om({color:n.color?new Yr(n.color[0],n.color[1],n.color[2]):new Yr(.82,.82,.82)}),c=new Xi(o,a);c.name=n.name,e.add(c)}return e}async function U1n(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 B1n()).ReadStepFile(new Uint8Array(n),null);if(!i.success||!i.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=j1n(i.meshes),s=new $W;return await new Promise((c,l)=>{s.parse(o,u=>{u instanceof ArrayBuffer?c(u):l(new Error("GLTFExporter did not return binary output"))},u=>{l(u)},{binary:!0})})}var xXe="step-glb-cache:";function H1n(t){const e=new Uint8Array(t),n=32768;let r="";for(let i=0;i<e.length;i+=n){const o=e.subarray(i,i+n);r+=String.fromCharCode(...o)}return btoa(r)}function V1n(t){const e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)n[r]=e.charCodeAt(r);return n.buffer}function Y1n(t){try{const e=localStorage.getItem(`${xXe}${t}`);return e?V1n(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function bXe(t,e){try{const n=H1n(e);localStorage.setItem(`${xXe}${t}`,n)}catch(n){console.warn("Failed to write STEP GLB cache",n)}}function X1n(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var G1n=({stepUrl:t,position:e,rotation:n,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:d,isTranslucent:h})=>{const[p,f]=J.useState(null);return J.useEffect(()=>{let m=!0,y=null,g=!0;const _=X1n(),b=Y1n(t);if(b){const E={arrayBuffer:b,blobUrl:URL.createObjectURL(new Blob([b],{type:"model/gltf-binary"}))};return _.completed.set(t,E),y=E.blobUrl,g=!1,f(E.blobUrl),()=>{m=!1,y&&g&&URL.revokeObjectURL(y)}}const v=_.completed.get(t);if(v)return y=v.blobUrl,g=!1,f(v.blobUrl),bXe(t,v.arrayBuffer),()=>{m=!1,y&&g&&URL.revokeObjectURL(y)};let T=_.inProgress.get(t);return T||(T=U1n(t).then(E=>{const A={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return _.completed.set(t,A),_.inProgress.delete(t),A}).catch(E=>{throw _.inProgress.delete(t),E}),_.inProgress.set(t,T)),T.then(E=>{m&&(y=E.blobUrl,g=!1,f(E.blobUrl),bXe(t,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),m&&f(null)}),()=>{m=!1,y&&g&&URL.revokeObjectURL(y)}},[t]),p?G.jsx(_Xe,{gltfUrl:p,position:e,rotation:n,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:d,isTranslucent:h}):null};function pU(t,e){let{x:n,y:r,z:i}=t;if(e.axisMapping){const o={x:n,y:r,z:i};e.axisMapping.x&&(n=H0e(o,e.axisMapping.x)),e.axisMapping.y&&(r=H0e(o,e.axisMapping.y)),e.axisMapping.z&&(i=H0e(o,e.axisMapping.z))}if(n*=e.flipX??1,r*=e.flipY??1,i*=e.flipZ??1,e.rotation){if(e.rotation.x){const o=e.rotation.x*Math.PI/180,s=Math.cos(o),a=Math.sin(o),c=r*s-i*a,l=r*a+i*s;r=c,i=l}if(e.rotation.y){const o=e.rotation.y*Math.PI/180,s=Math.cos(o),a=Math.sin(o),c=n*s+i*a,l=-n*a+i*s;n=c,i=l}if(e.rotation.z){const o=e.rotation.z*Math.PI/180,s=Math.cos(o),a=Math.sin(o),c=n*s-r*a,l=n*a+r*s;n=c,r=l}}return{x:n,y:r,z:i}}function H0e(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 V0e={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 q1n(t,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return V0e.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?V0e.STEP_INVERTED:V0e.Z_UP_TO_Y_UP_USB_FIX}}function sN(t,e){return q1n(t,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function fU(t){if(!t)return;const e=pU({x:1,y:0,z:0},t),n=pU({x:0,y:1,z:0},t),r=pU({x:0,y:0,z:1},t);return new Lo().makeBasis(new Mt(e.x,e.y,e.z),new Mt(n.x,n.y,n.z),new Mt(r.x,r.y,r.z))}function s9(t){return t*Math.PI/180}function W1n(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,s9(-90),0];case"x-":return[0,s9(90),0];case"y+":return[s9(90),0,0];case"y-":return[s9(-90),0,0];case"z-":return[s9(180),0,0];default:return[0,0,0]}}function K1n(t,e,n){if(!t.position)return;let r=t.position.z;return e==="bottom"&&t.position.z>=0&&(r=-(t.position.z+n)),[t.position.x,t.position.y,r]}function Z1n(t,e){return t.rotation?[s9(t.rotation.x),s9(t.rotation.y),s9(t.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function Q1n(t,e){const n=new Mt(t.x,t.y,t.z),r=new Ly(e[0],e[1],e[2],"XYZ");return n.applyEuler(r),[n.x,n.y,n.z]}function J1n(t,e,n){if(!t.model_origin_position)return[0,0,0];const r=e?pU(t.model_origin_position,e):t.model_origin_position;return Q1n(r,n)}function eyn(t,e){const n=K1n(t,e.layer,e.pcbThickness),r=Z1n(t,e.layer),i=sN(t,e.modelType),o=W1n(t.model_board_normal_direction??"z+"),s=J1n(t,i,o);return{position:n,rotation:r,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:o,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 tyn=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",nyn=t=>t==="step"?"glb":t,ryn=(t,e)=>{if(t)return e?e(t):t},iyn=(...t)=>t,Y0e=class extends ri.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}},oyn=({error:t,onError:e})=>(J.useEffect(()=>{e(t)},[t,e]),null),vXe=({cad_component:t,circuitJson:e,resolveStaticAsset:n})=>{const r=EYe(e),[i,o]=J.useState(!1),{visibility:s}=F7(),[a,c]=J.useState(null),l=J.useCallback(X=>{X?.mousePosition?(o(!0),c(X.mousePosition)):(o(!1),c(null))},[]),u=J.useCallback(()=>{o(!1),c(null)},[]),d=J.useMemo(()=>di(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),h=J.useMemo(()=>e.filter(W=>W.type==="pcb_plated_hole"&&W.pcb_component_id===t.pcb_component_id).length>0,[e,t.pcb_component_id]),p=J.useCallback(X=>ryn(X,n),[n]),f=p(t.model_wrl_url??t.model_stl_url??t.model_obj_url),m=p(t.model_glb_url??t.model_gltf_url),y=p(t.model_step_url),[g,_]=J.useState(0),[b,v]=J.useState(null);J.useEffect(()=>{_(0),v(null)},[t.cad_component_id,f,m,y]);const E=e.find(X=>X.type==="pcb_component"&&X.source_component_id===t.source_component_id)?.layer??"top",A=tyn(t),P=nyn(A),N=t.model_glb_url?"glb":"gltf",C=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",D=J.useMemo(()=>eyn(t,{layer:E,pcbThickness:r,modelType:P}),[t,E,r,P]),I=iyn(...D.rotation),B=D.position,U=J.useMemo(()=>{const X=[];return m&&X.push(G.jsx(_Xe,{gltfUrl:m,position:B,rotation:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:fU(sN(t,N)),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${m}`)),f&&X.push(G.jsx(z1n,{url:f,position:B,rotation:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:fU(sN(t,C)),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${f}`)),y&&!t.model_jscad&&!t.footprinter_string&&X.push(G.jsx(G1n,{stepUrl:y,position:B,rotation:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:fU(sN(t,P)),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${y}`)),X},[B,t.cad_component_id,t.footprinter_string,t.model_jscad,t.show_as_translucent_model,m,N,l,u,i,C,D.modelPosition,D.modelRotation,D.scale,D.fitMode,D.size,P,I,y,f]);let H=null;if(U.length>0){if(g>=U.length){if(b)throw b;return null}H=G.jsx(Y0e,{fallback:({error:X})=>G.jsx(oyn,{error:X,onError:W=>{v(W),_(ee=>Math.max(ee,g+1))}}),children:U[g]},`${t.cad_component_id}-fallback-${g}`)}else t.model_jscad?H=G.jsx(O1n,{jscadPlan:t.model_jscad,positionOffset:B,rotationOffset:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:fU(sN(t,"jscad")),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(H=G.jsx(M1n,{positionOffset:B,rotationOffset:I,footprint:t.footprinter_string,scale:D.scale,onHover:l,onUnhover:u,isHovered:i,isTranslucent:t.show_as_translucent_model}));if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(h&&!s.throughHoleModels||!h&&!s.smtModels)return null;return G.jsxs(G.Fragment,{children:[H,i&&a?G.jsx(TYe,{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:d??"<unknown>"}):null]})},wXe={version:"0.0.549"};function syn(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var ayn=t=>{t.outputColorSpace=m5,t.toneMapping=t5e,t.toneMappingExposure=1},SXe="cadViewerCameraStateSession",EXe=(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(SXe,JSON.stringify(n))}catch(n){console.warn("Failed to save camera:",n)}},X0e=(t,e)=>{try{const n=sessionStorage.getItem(SXe);if(!n)return!1;const r=JSON.parse(n);if(t.position.fromArray(r.position),t.quaternion.fromArray(r.quaternion),t.up.fromArray(r.up),"fov"in t){const i=t;i.fov=r.fov,i.updateProjectionMatrix?.()}return e.target.fromArray(r.target),e.update(),t.updateMatrixWorld(),!0}catch(n){return console.warn("Failed to restore camera:",n),!1}},MXe=J.createContext(void 0),cyn=({children:t,defaultTarget:e,initialCameraPosition:n})=>{const r=J.useRef(null),i=J.useRef(null),[o,s]=J.useState(null),[a,c]=J.useState("perspective"),[l,u]=J.useState(n??null),[d,h]=J.useState(new Ly(0,0,0)),p=J.useMemo(()=>{const[g,_,b]=n??[5,-5,5],v=Math.hypot(g-e.x,_-e.y,b-e.z);return v>0?v:5},[n,e]),f=J.useCallback(g=>{const _=[e.x,e.y,e.z],b=i.current,v=r.current;let T=p;switch(b&&v&&(T=b.position.distanceTo(v.target)),g){case"Top Center Angled":{const E=T/Math.sqrt(2);return{position:[e.x,e.y-E,e.z+E],target:_,up:[0,0,1]}}case"Top Down":return{position:[e.x,e.y,e.z+T],target:_,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-T*.6,e.y-T*.6,e.z+T*.6],target:_,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+T*.6,e.y-T*.6,e.z+T*.6],target:_,up:[0,0,1]};case"Left Sideview":return{position:[e.x-T,e.y,e.z],target:_,up:[0,0,1]};case"Right Sideview":return{position:[e.x+T,e.y,e.z],target:_,up:[0,0,1]};case"Front":return{position:[e.x,e.y-T,e.z],target:_,up:[0,0,1]};default:return null}},[p,e,i,r]),m=J.useCallback(g=>{r.current=g},[]),y=J.useMemo(()=>({controlsRef:r,mainCameraRef:i,defaultTarget:e,baseDistance:p,controller:o,setController:s,getPresetConfig:f,handleControlsChange:m,cameraType:a,setCameraType:c,cameraPosition:l,setCameraPosition:u,cameraRotation:d,setCameraRotation:h,saveCameraToSession:EXe,loadCameraFromSession:X0e}),[e,p,o,f,m,a,l,d]);return G.jsx(MXe.Provider,{value:y,children:t})},a9=()=>{const t=J.useContext(MXe);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},lyn=J.forwardRef(({children:t,scene:e,camera:n,style:r,onCreated:i},o)=>{const{cameraType:s}=a9(),a=J.useRef(null),[c,l]=J.useState(null),u=J.useRef([]),d=J.useRef(void 0);d.current=i;const h=J.useRef(null),p=J.useCallback(g=>{u.current.push(g)},[]),f=J.useCallback(g=>{u.current=u.current.filter(_=>_!==g)},[]),m=J.useMemo(()=>new D8,[]);e?.up&&m.up.set(e.up.x,e.up.y,e.up.z);const y=J.useRef(new Wc);return J.useImperativeHandle(o,()=>y.current),J.useEffect(()=>{if(!a.current)return;syn(a.current);const g=new XI({antialias:!0,alpha:!0});ayn(g),g.setSize(a.current.clientWidth,a.current.clientHeight),g.setPixelRatio(window.devicePixelRatio),a.current.appendChild(g.domElement);const _=a.current.clientWidth/a.current.clientHeight,b=s==="perspective"?new If(75,_,.1,1e3):new fP(-10*_,10*_,10,-10,-1e3,1e3);h.current?(b.position.copy(h.current.position),b.quaternion.copy(h.current.quaternion),b.up.copy(h.current.up)):(n?.up&&b.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&b.position.set(n.position[0],n.position[1],n.position[2]),b.lookAt(0,0,0)),m.add(y.current),window.__TSCIRCUIT_THREE_OBJECT=y.current,l({scene:m,camera:b,renderer:g,rootObject:y.current,addFrameListener:p,removeFrameListener:f}),d.current?.({camera:b,renderer:g});let v;const T=new e_t,E=()=>{const P=T.getElapsedTime(),N=T.getDelta();u.current.forEach(C=>C(P,N)),g.render(m,b),v=requestAnimationFrame(E)};E();const A=()=>{if(a.current){const P=a.current.clientWidth/a.current.clientHeight;b instanceof If?b.aspect=P:b instanceof fP&&(b.left=-10*P,b.right=10*P,b.top=10,b.bottom=-10),b.updateProjectionMatrix(),g.setSize(a.current.clientWidth,a.current.clientHeight)}};return window.addEventListener("resize",A),()=>{h.current={position:b.position.clone(),quaternion:b.quaternion.clone(),up:b.up.clone()},window.removeEventListener("resize",A),cancelAnimationFrame(v),a.current&&g.domElement&&a.current.removeChild(g.domElement),g.dispose(),m.remove(y.current),window.__TSCIRCUIT_THREE_OBJECT===y.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[m,p,f,s]),G.jsx("div",{ref:a,style:{width:"100%",height:"100%",...r},children:c&&G.jsx(MYe.Provider,{value:c,children:G.jsx(S1n,{children:t})})})}),uyn=({autoRotate:t,autoRotateSpeed:e,onStart:n,panSpeed:r,rotateSpeed:i,zoomSpeed:o,enableDamping:s,dampingFactor:a,target:c,onControlsChange:l})=>{const{camera:u,renderer:d}=Xy(),h=J.useMemo(()=>!u||!d?null:new h5t(u,d.domElement),[u,d]);return J.useEffect(()=>(l?.(h??null),()=>l?.(null)),[h,l]),J.useEffect(()=>{if(!h)return;const p=()=>{l?.(h)};return h.addEventListener("change",p),()=>{h.removeEventListener("change",p)}},[h,l]),J.useEffect(()=>{h&&(h.autoRotate=t||!1,h.autoRotateSpeed=e||1,r!==void 0&&(h.panSpeed=r),i!==void 0&&(h.rotateSpeed=i),o!==void 0&&(h.zoomSpeed=o),s!==void 0&&(h.enableDamping=s),a!==void 0&&(h.dampingFactor=a),h.zoomToCursor=!0,h.mouseButtons={LEFT:Bv.ROTATE,MIDDLE:Bv.PAN,RIGHT:null},c&&(h.target.set(c[0],c[1],c[2]),h.update()))},[h,t,e,r,i,o,s,a,c]),J.useEffect(()=>{if(!(!h||!n))return h.addEventListener("start",n),()=>{h.removeEventListener("start",n)}},[h,n]),J.useEffect(()=>{if(h)return()=>{h.dispose()}},[h]),YR(()=>{h?.update()},[h]),null},dyn=`
|
|
5153
5153
|
varying vec3 worldPosition;
|
|
5154
5154
|
void main() {
|
|
5155
5155
|
worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
@@ -5683,7 +5683,7 @@ test("${l} should solve problem correctly", () => {
|
|
|
5683
5683
|
// Add more specific assertions based on expected output
|
|
5684
5684
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5685
5685
|
})
|
|
5686
|
-
`,d=new Blob([u],{type:"text/plain"}),h=URL.createObjectURL(d),p=document.createElement("a");p.href=h,p.download=`${l}.test.ts`,p.click(),URL.revokeObjectURL(h)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}r(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:i,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>r(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.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:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},vot=t=>t.activeSubSolver?[t,...vot(t.activeSubSolver)]:[t],rIn=({solver:t})=>{const e=vot(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,r)=>G.jsxs("div",{className:"flex items-center",children:[r>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(nIn,{solver:n})]},n.constructor.name))})},iIn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:r,onSolverCompleted:i})=>{const[o,s]=J.useReducer(m=>!m,!1),a=J.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(r&&r(t),t.solve(),e(),i&&i(t))},u=()=>{o?(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))},d=()=>{const m=t;if(m.getCurrentPhase&&!t.solved&&!t.failed){const y=m.getCurrentPhase();for(;m.getCurrentPhase()===y&&!t.solved&&!t.failed;)t.step();e()}},h=()=>{if(t.solved||t.failed||o)return;const m=window.prompt("Step until which iteration?",`${t.iterations}`);if(m===null)return;const y=Number(m);if(!Number.isFinite(y)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<y&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};J.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),J.useEffect(()=>{(t.solved||t.failed)&&o&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,o]);const p=t.getCurrentPhase!==void 0,f=p?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(rIn,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),G.jsx("button",{onClick:h,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),p&&G.jsx("button",{onClick:d,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),f&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:f})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},oIn=(t,e,n)=>{const r=t.currentPipelineStepIndex;return e<r?"Completed":e===r&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},sIn=(t,e)=>{const r=t.pipelineDef[e].solverName,i=oIn(t,e),o=t[r],s=t.firstIterationOfPhase?.[r]??null,a=t.iterations;let c=0;if(i==="Completed"){const h=t.pipelineDef[e+1],p=h?t.firstIterationOfPhase?.[h.solverName]:void 0;p!==void 0&&s!==null?c=p-s:s!==null&&(c=a-s)}else i==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[r]??0;let u=0;i==="Completed"?u=1:i==="In Progress"&&o&&(u=o.progress??0);const d=o?.stats??null;return{index:e,name:r,status:i,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:d&&Object.keys(d).length>0?d:null,solverInstance:o??null}},aIn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},cIn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},lIn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),uIn=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=lIn(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([r,i])=>G.jsxs("div",{children:[r,": ",String(i)]},r))})]})},j1e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(j1e);const e={};for(const[n,r]of Object.entries(t))n.startsWith("_")||(e[n]=j1e(r));return e},dIn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=j1e(t.getConstructorParams()),r=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=`${e}_input.json`,o.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},hIn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const r=t.pipelineDef.map((a,c)=>sIn(t,c)),i=a=>{e?.(a)},o=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):dIn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:r.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.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:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(aIn,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(cIn,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(uIn,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>o(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},pIn=class extends ri.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 fIn({graphics:t}){const e=t.points??[],n=t.lines??[],r=t.rects??[],i=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(y,g)=>{typeof y=="number"&&(y<s&&(s=y),y>c&&(c=y)),typeof g=="number"&&(g<a&&(a=g),g>l&&(l=g))};for(const y of e)u(y.x,y.y);for(const y of n){const g=y.points??[];for(const _ of g)u(_.x,_.y)}for(const y of r){const g=y.x??0,_=y.y??0,b=y.width??0,v=y.height??0;u(g,_),u(g+b,_+v)}for(const y of i){const g=y.x??0,_=y.y??0,b=y.radius??1;u(g-b,_-b),u(g+b,_+b)}for(const y of o)u(y.x,y.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const d=10,h=s-d,p=a-d,f=Math.max(1,c-s+2*d),m=Math.max(1,l-a+2*d);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${h} ${p} ${f} ${m}`,role:"img","aria-label":"Graphics fallback",children:[r.map((y,g)=>G.jsx("rect",{x:y.x??0,y:y.y??0,width:y.width??0,height:y.height??0,fill:"none",stroke:y.strokeColor??"black",strokeWidth:y.strokeWidth??1},`rect-${g}`)),n.map((y,g)=>G.jsx("polyline",{fill:"none",stroke:y.strokeColor??"black",strokeWidth:y.strokeWidth??1,points:(y.points??[]).map(_=>`${_.x??0},${_.y??0}`).join(" ")},`line-${g}`)),i.map((y,g)=>G.jsx("circle",{cx:y.x??0,cy:y.y??0,r:y.radius??1.5,fill:y.fillColor??"none",stroke:y.strokeColor??"black",strokeWidth:y.strokeWidth??1},`circle-${g}`)),e.map((y,g)=>G.jsx("circle",{cx:y.x??0,cy:y.y??0,r:y.radius??1.5,fill:y.color??"black"},`point-${g}`)),o.map((y,g)=>G.jsx("text",{x:y.x??0,y:y.y??0,fontSize:y.fontSize??10,fill:y.color??"black",children:y.text??""},`text-${g}`))]})}var mIn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:r})=>{const[i,o]=J.useReducer(u=>u+1,0),s=J.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=J.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);J.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const d=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&d.currentPipelineStepIndex<=d.pipelineDef.findIndex(h=>h.solverName===u);)t.step();o()}};return G.jsxs("div",{children:[G.jsx(iIn,{solver:t,triggerRender:o,animationSpeed:e,onSolverStarted:n,onSolverCompleted:r}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(pIn,{fallback:G.jsx(fIn,{graphics:s}),children:G.jsx(tIn,{graphics:s})}),c&&G.jsx(hIn,{solver:t,onStepUntilPhase:l})]})};const yIn=()=>{J.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 r=document.createElement("script");r.id=t,r.src="https://cdn.tailwindcss.com",document.head.appendChild(r)},[])},gIn=t=>t.toLowerCase().includes("pack")?x4n:t.toLowerCase().includes("rout")?M4n:u4n,_In=({solverEvents:t=[]})=>{const[e,n]=J.useState(null);yIn();const r=J.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),i=J.useMemo(()=>Array.from(r.keys()),[r]),o=e?r.get(e):null,s=J.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const a=fie[o.solverName];if(!a)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(fie).join(", ")}`,classFound:!1};try{const c=o.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[o]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.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."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.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 c=r.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=gIn(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?G.jsx(u4,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:G.jsx(mIn,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&G.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:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},wot=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{J.useEffect(()=>{if(t){const r=new Error(t);e&&(r.stack=e);try{lI.captureException(r)}catch{}}},[t,e]),J.useEffect(()=>{if(n&&n.length>0)for(const r of n){const i=new Error(r.message||"Circuit JSON Error");r.stack&&(i.stack=r.stack);try{lI.captureException(i,{error_type:r.type})}catch{}}},[n])},Sot="0.0.1783",xIn={version:Sot},U1e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},H1e=new Map,UV=t=>{const e=H1e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,r])=>[n,r.getState()])):{}},bIn=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const r=H1e.get(n.name);if(r)return{type:"tracked",store:t,...r};const i={connection:e.connect(n),stores:{}};return H1e.set(n.name,i),{type:"tracked",store:t,...i}},Eot=(t,e={})=>(n,r,i)=>{const{enabled:o,anonymousActionType:s,store:a,...c}=e;let l;try{l=(o??(U1e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(U1e?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,r,i);const{connection:u,...d}=bIn(a,l,c);let h=!0;i.setState=(m,y,g)=>{const _=n(m,y);if(!h)return _;const b=g===void 0?{type:s||"anonymous"}:typeof g=="string"?{type:g}:g;return a===void 0?(u?.send(b,r()),_):(u?.send({...b,type:`${a}/${b.type}`},{...UV(c.name),[a]:i.getState()}),_)};const p=(...m)=>{const y=h;h=!1,n(...m),h=y},f=t(i.setState,r,i);if(d.type==="untracked"?u?.init(f):(d.stores[d.store]=i,u?.init(Object.fromEntries(Object.entries(d.stores).map(([m,y])=>[m,m===d.store?f:y.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let m=!1;const y=i.dispatch;i.dispatch=(...g)=>{(U1e?"production":void 0)!=="production"&&g[0].type==="__setState"&&!m&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),m=!0),y(...g)}}return u.subscribe(m=>{var y;switch(m.type){case"ACTION":if(typeof m.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return V1e(m.payload,g=>{if(g.type==="__setState"){if(a===void 0){p(g.state);return}Object.keys(g.state).length!==1&&console.error(`
|
|
5686
|
+
`,d=new Blob([u],{type:"text/plain"}),h=URL.createObjectURL(d),p=document.createElement("a");p.href=h,p.download=`${l}.test.ts`,p.click(),URL.revokeObjectURL(h)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}r(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:i,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>r(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.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:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},vot=t=>t.activeSubSolver?[t,...vot(t.activeSubSolver)]:[t],rIn=({solver:t})=>{const e=vot(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,r)=>G.jsxs("div",{className:"flex items-center",children:[r>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(nIn,{solver:n})]},n.constructor.name))})},iIn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:r,onSolverCompleted:i})=>{const[o,s]=J.useReducer(m=>!m,!1),a=J.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(r&&r(t),t.solve(),e(),i&&i(t))},u=()=>{o?(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))},d=()=>{const m=t;if(m.getCurrentPhase&&!t.solved&&!t.failed){const y=m.getCurrentPhase();for(;m.getCurrentPhase()===y&&!t.solved&&!t.failed;)t.step();e()}},h=()=>{if(t.solved||t.failed||o)return;const m=window.prompt("Step until which iteration?",`${t.iterations}`);if(m===null)return;const y=Number(m);if(!Number.isFinite(y)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<y&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};J.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),J.useEffect(()=>{(t.solved||t.failed)&&o&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,o]);const p=t.getCurrentPhase!==void 0,f=p?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(rIn,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),G.jsx("button",{onClick:h,disabled:t.solved||t.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),p&&G.jsx("button",{onClick:d,disabled:t.solved||t.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),f&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:f})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},oIn=(t,e,n)=>{const r=t.currentPipelineStepIndex;return e<r?"Completed":e===r&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},sIn=(t,e)=>{const r=t.pipelineDef[e].solverName,i=oIn(t,e),o=t[r],s=t.firstIterationOfPhase?.[r]??null,a=t.iterations;let c=0;if(i==="Completed"){const h=t.pipelineDef[e+1],p=h?t.firstIterationOfPhase?.[h.solverName]:void 0;p!==void 0&&s!==null?c=p-s:s!==null&&(c=a-s)}else i==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[r]??0;let u=0;i==="Completed"?u=1:i==="In Progress"&&o&&(u=o.progress??0);const d=o?.stats??null;return{index:e,name:r,status:i,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:d&&Object.keys(d).length>0?d:null,solverInstance:o??null}},aIn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},cIn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},lIn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),uIn=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=lIn(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([r,i])=>G.jsxs("div",{children:[r,": ",String(i)]},r))})]})},j1e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(j1e);const e={};for(const[n,r]of Object.entries(t))n.startsWith("_")||(e[n]=j1e(r));return e},dIn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=j1e(t.getConstructorParams()),r=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=`${e}_input.json`,o.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},hIn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const r=t.pipelineDef.map((a,c)=>sIn(t,c)),i=a=>{e?.(a)},o=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):dIn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:r.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.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:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(aIn,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(cIn,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(uIn,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>o(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},pIn=class extends ri.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 fIn({graphics:t}){const e=t.points??[],n=t.lines??[],r=t.rects??[],i=t.circles??[],o=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(y,g)=>{typeof y=="number"&&(y<s&&(s=y),y>c&&(c=y)),typeof g=="number"&&(g<a&&(a=g),g>l&&(l=g))};for(const y of e)u(y.x,y.y);for(const y of n){const g=y.points??[];for(const _ of g)u(_.x,_.y)}for(const y of r){const g=y.x??0,_=y.y??0,b=y.width??0,v=y.height??0;u(g,_),u(g+b,_+v)}for(const y of i){const g=y.x??0,_=y.y??0,b=y.radius??1;u(g-b,_-b),u(g+b,_+b)}for(const y of o)u(y.x,y.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const d=10,h=s-d,p=a-d,f=Math.max(1,c-s+2*d),m=Math.max(1,l-a+2*d);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${h} ${p} ${f} ${m}`,role:"img","aria-label":"Graphics fallback",children:[r.map((y,g)=>G.jsx("rect",{x:y.x??0,y:y.y??0,width:y.width??0,height:y.height??0,fill:"none",stroke:y.strokeColor??"black",strokeWidth:y.strokeWidth??1},`rect-${g}`)),n.map((y,g)=>G.jsx("polyline",{fill:"none",stroke:y.strokeColor??"black",strokeWidth:y.strokeWidth??1,points:(y.points??[]).map(_=>`${_.x??0},${_.y??0}`).join(" ")},`line-${g}`)),i.map((y,g)=>G.jsx("circle",{cx:y.x??0,cy:y.y??0,r:y.radius??1.5,fill:y.fillColor??"none",stroke:y.strokeColor??"black",strokeWidth:y.strokeWidth??1},`circle-${g}`)),e.map((y,g)=>G.jsx("circle",{cx:y.x??0,cy:y.y??0,r:y.radius??1.5,fill:y.color??"black"},`point-${g}`)),o.map((y,g)=>G.jsx("text",{x:y.x??0,y:y.y??0,fontSize:y.fontSize??10,fill:y.color??"black",children:y.text??""},`text-${g}`))]})}var mIn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:r})=>{const[i,o]=J.useReducer(u=>u+1,0),s=J.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=J.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);J.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const d=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&d.currentPipelineStepIndex<=d.pipelineDef.findIndex(h=>h.solverName===u);)t.step();o()}};return G.jsxs("div",{children:[G.jsx(iIn,{solver:t,triggerRender:o,animationSpeed:e,onSolverStarted:n,onSolverCompleted:r}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(pIn,{fallback:G.jsx(fIn,{graphics:s}),children:G.jsx(tIn,{graphics:s})}),c&&G.jsx(hIn,{solver:t,onStepUntilPhase:l})]})};const yIn=()=>{J.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 r=document.createElement("script");r.id=t,r.src="https://cdn.tailwindcss.com",document.head.appendChild(r)},[])},gIn=t=>t.toLowerCase().includes("pack")?x4n:t.toLowerCase().includes("rout")?M4n:u4n,_In=({solverEvents:t=[]})=>{const[e,n]=J.useState(null);yIn();const r=J.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),i=J.useMemo(()=>Array.from(r.keys()),[r]),o=e?r.get(e):null,s=J.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const a=fie[o.solverName];if(!a)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(fie).join(", ")}`,classFound:!1};try{const c=o.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[o]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.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."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.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 c=r.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=gIn(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?G.jsx(u4,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:G.jsx(mIn,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&G.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:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},wot=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{J.useEffect(()=>{if(t){const r=new Error(t);e&&(r.stack=e);try{lI.captureException(r)}catch{}}},[t,e]),J.useEffect(()=>{if(n&&n.length>0)for(const r of n){const i=new Error(r.message||"Circuit JSON Error");r.stack&&(i.stack=r.stack);try{lI.captureException(i,{error_type:r.type})}catch{}}},[n])},Sot="0.0.1784",xIn={version:Sot},U1e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},H1e=new Map,UV=t=>{const e=H1e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,r])=>[n,r.getState()])):{}},bIn=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const r=H1e.get(n.name);if(r)return{type:"tracked",store:t,...r};const i={connection:e.connect(n),stores:{}};return H1e.set(n.name,i),{type:"tracked",store:t,...i}},Eot=(t,e={})=>(n,r,i)=>{const{enabled:o,anonymousActionType:s,store:a,...c}=e;let l;try{l=(o??(U1e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(U1e?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,r,i);const{connection:u,...d}=bIn(a,l,c);let h=!0;i.setState=(m,y,g)=>{const _=n(m,y);if(!h)return _;const b=g===void 0?{type:s||"anonymous"}:typeof g=="string"?{type:g}:g;return a===void 0?(u?.send(b,r()),_):(u?.send({...b,type:`${a}/${b.type}`},{...UV(c.name),[a]:i.getState()}),_)};const p=(...m)=>{const y=h;h=!1,n(...m),h=y},f=t(i.setState,r,i);if(d.type==="untracked"?u?.init(f):(d.stores[d.store]=i,u?.init(Object.fromEntries(Object.entries(d.stores).map(([m,y])=>[m,m===d.store?f:y.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let m=!1;const y=i.dispatch;i.dispatch=(...g)=>{(U1e?"production":void 0)!=="production"&&g[0].type==="__setState"&&!m&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),m=!0),y(...g)}}return u.subscribe(m=>{var y;switch(m.type){case"ACTION":if(typeof m.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return V1e(m.payload,g=>{if(g.type==="__setState"){if(a===void 0){p(g.state);return}Object.keys(g.state).length!==1&&console.error(`
|
|
5687
5687
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5688
5688
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5689
5689
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|