@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.
@@ -5153,7 +5153,7 @@ ${c.join(`
5153
5153
  ${m}polygon: ${f.polygon.vertices}
5154
5154
  `:c+=`
5155
5155
  `,f.children.length>0&&u.push(f.children)}return c}};e.exports=s}}),d0n=tt({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(n,e){var t=a0n(),r=u0n(),i=class{constructor(o){this.polygonTree=new r,this.rootnode=new t(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}}),xpe=tt({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(n,e){e.exports={Tree:d0n()}}}),h0n=tt({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(n,e){var t=$o(),r=_pe(),{Tree:i}=xpe(),o=(s,a)=>{if(!r(s,a))return t.create();const c=new i(t.toPolygons(s)),l=new i(t.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 t.create(u)};e.exports=o}}),tGe=tt({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(n,e){var t=go(),r=dN(),i=h0n(),o=(...s)=>{s=t(s);let a=s.shift();return s.forEach(c=>{a=i(a,c)}),a=r(a),a};e.exports=o}}),p0n=tt({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(n,e){var t=go(),r=$o(),i=h9(),o=ype(),s=gpe(),a=tGe(),c=(...l)=>{l=t(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}}),f0n=tt({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(n,e){var t=go(),r=uN(),i=Uo(),o=$o(),s=p0n(),a=tGe(),c=(...l)=>{if(l=t(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}}),bpe=tt({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(n,e){var t=Ns(),r=sXe(),i=o=>r(o,{skipTriangulation:!0}).map(c=>{const l=c.map(u=>o[u]);return t.create(l)});e.exports=i}}),nGe=tt({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(n,e){var t=$o(),r=_pe(),{Tree:i}=xpe(),o=(a,c)=>{if(!r(a,c))return s(a,c);const l=new i(t.toPolygons(a)),u=new i(t.toPolygons(c));l.clipTo(u,!1),u.clipTo(l),u.invert(),u.clipTo(l),u.invert();const d=l.allPolygons().concat(u.allPolygons());return t.create(d)},s=(a,c)=>{let l=t.toPolygons(a);return l=l.concat(t.toPolygons(c)),t.create(l)};e.exports=o}}),vpe=tt({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(n,e){var t=go(),r=dN(),i=nGe(),o=(...s)=>{s=t(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}}),rGe=tt({"node_modules/@jscad/modeling/src/operations/minkowski/minkowskiSum.js"(n,e){var t=go(),r=$o(),i=Ns(),o=bpe(),s=vpe(),a=(...p)=>{if(p=t(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,M=0;for(let I=0;I<_.length;I++)b+=_[I][0],v+=_[I][1],M+=_[I][2];b/=_.length,v/=_.length,M/=_.length;const E=i.plane(g),A=E[0],P=E[1],N=E[2],C=.1,D=[b-A*C,v-P*C,M-N*C];for(let I=1;I<_.length-1;I++){const B=_[0],j=_[I],U=_[I+1],G=u(D,B,j,U);m.push(r.create(G))}}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 M=0;M<y.length;M++){const E=y[M];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],M=`${v[0]},${v[1]},${v[2]}`;f.has(M)||(f.add(M),m.push(v))}}return m};e.exports=a}}),m0n=tt({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(n,e){var t=gi(),r=h9(),i=$o(),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=t.create();d.forEach((b,v)=>{b.vertices.forEach(M=>{s(p,t.snap(f,M,u),v)})});const m=d.map(b=>{let v=[];return b.vertices.forEach(M=>{v=v.concat(a(p,t.snap(f,M,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 M=new Array(h);M[b]=!0;do y=0,M.forEach((E,A)=>{const P=m[A];if(P.e>0){P.e=-1;for(let N=0;N<P.d.length;N++)M[P.d[N]]=!0;y++}});while(y>0);v.indexes=M}}const _=[];for(let b=0;b<g;b++)if(m[b].indexes){const v=[];m[b].indexes.forEach((M,E)=>v.push(d[E])),_.push(i.create(v))}return _};e.exports=c}}),y0n=tt({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(n,e){var t=go(),r=$o(),i=m0n(),o=(...s)=>{if(s=t(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}}),g0n=tt({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(n,e){var t=$o(),r=_pe(),{Tree:i}=xpe(),o=(s,a)=>{if(!r(s,a))return t.clone(s);const c=new i(t.toPolygons(s)),l=new i(t.toPolygons(a));c.invert(),c.clipTo(l),l.clipTo(c,!0),c.addPolygons(l.allPolygons()),c.invert();const u=c.allPolygons();return t.create(u)};e.exports=o}}),iGe=tt({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(n,e){var t=go(),r=dN(),i=g0n(),o=(...s)=>{s=t(s);let a=s.shift();return s.forEach(c=>{a=i(a,c)}),a=r(a),a};e.exports=o}}),_0n=tt({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(n,e){var t=go(),r=$o(),i=h9(),o=ype(),s=gpe(),a=iGe(),c=(...l)=>{l=t(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}}),x0n=tt({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(n,e){var t=go(),r=uN(),i=Uo(),o=$o(),s=_0n(),a=iGe(),c=(...l)=>{if(l=t(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}}),oGe=tt({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(n,e){var t=go(),r=$o(),i=h9(),o=ype(),s=gpe(),a=vpe(),c=(...l)=>{l=t(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}}),wpe=tt({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(n,e){var t=go(),r=uN(),i=Uo(),o=$o(),s=oGe(),a=vpe(),c=(...l)=>{if(l=t(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}}),hN=tt({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(n,e){e.exports={intersect:f0n(),minkowski:rGe(),scission:y0n(),subtract:x0n(),union:wpe()}}}),IU=tt({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(n,e){var{EPS:t,TAU:r}=Ys(),i=IXe(),o=dpe(),s=cs(),a=NU(),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)<t)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=[],M=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(M,N,C):s.subtract(M,C,N),s.normal(M,M),s.normalize(M,M),s.scale(M,M,h);const D=s.add(s.create(),N,M),I=s.add(s.create(),C,M),B=[D,I];if(_!=null&&(f||!f&&P!==0)){const j=i(_[0],_[1],B[0],B[1]);j?(b.pop(),B[0]=j):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 j=1;j<A;j++){const U=I+D*j,G=s.fromAngleRadians(s.create(),U);s.scale(G,G,h),s.add(G,G,N.c),B.push(G)}if(B.length>0){const j=N.s0[1];let U=b.findIndex(G=>s.equals(j,G));U=(U+1)%b.length,b.splice(U,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}}),b0n=tt({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(n,e){var t=Uo(),r=IU(),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=t.toOutlines(s).map(f=>(o={delta:c,corners:l,closed:!0,segments:u},r(o,f))).reduce((f,m)=>f.concat(t.toSides(t.fromPoints(m))),[]);return t.create(p)};e.exports=i}}),v0n=tt({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(n,e){var t=Sl(),r=gi(),i=$o(),o=Ns(),s=(a,c)=>{r.dot(o.plane(c),a)>0&&(c=o.invert(c));const u=[c],d=o.transform(t.fromTranslation(t.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}}),w0n=tt({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(n,e){var{EPS:t,TAU:r}=Ys(),i=Sl(),o=gi(),s=JXe(),a=$o(),c=Ns(),l=XXe(),u=dN(),d=nGe(),h=v0n(),p=(g,_,b)=>{const v=_.toString();if(g.has(v))g.get(v)[1].push(b);else{const M=[_,[b]];g.set(v,M)}},f=(g,_,b)=>{const v=_[0].toString(),M=_[1].toString(),E=v<M?`${v},${M}`:`${M},${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:M}=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 j=o.scale(o.create(),c.plane(I),2*v),U=c.transform(i.fromTranslation(i.create(),o.scale(o.create(),j,-.5)),I),G=h(j,U);E=d(E,G);const K=I.vertices;for(let ee=0;ee<K.length;ee++){p(A,K[ee],c.plane(I));const re=(ee+1)%K.length,pe=[K[ee],K[re]];f(P,pe,c.plane(I))}}),P.forEach(I=>{const B=I[0],j=I[1],U=B[0],G=B[1],K=o.subtract(o.create(),G,U);o.normalize(K,K);const ee=j[0],re=o.cross(o.create(),ee,K);let pe=[];for(let $e=0;$e<M;$e++)m(pe,$e*r/M);for(let $e=0,me=j.length;$e<me;$e++){const Ee=j[$e],_e=o.dot(re,Ee),Fe=o.dot(ee,Ee);let Ve=Math.atan2(_e,Fe);Ve<0&&(Ve+=r),m(pe,Ve),Ve=Math.atan2(-_e,-Fe),Ve<0&&(Ve+=r),m(pe,Ve)}pe=pe.sort(s);const ie=pe.length;let se,le;const ae=[],ye=[],Te=[];for(let $e=-1;$e<ie;$e++){const me=pe[$e<0?$e+ie:$e],Ee=Math.sin(me),_e=Math.cos(me);o.scale(N,ee,_e*v),o.scale(C,re,Ee*v),o.add(N,N,C);const Fe=o.add(o.create(),U,N),Ve=o.add(o.create(),G,N);let it=!1;if($e>=0&&o.distance(Fe,se)<t&&(it=!0),!it){if($e>=0){ae.push(Fe),ye.push(Ve);const xe=[le,Ve,Fe,se],nt=c.create(xe);Te.push(nt)}se=Fe,le=Ve}}ye.reverse(),Te.push(c.create(ae)),Te.push(c.create(ye));const Me=a.create(Te);E=d(E,Me)}),A.forEach(I=>{const B=I[0],j=I[1],U=j[0];let G=null,K=0;for(let ie=1;ie<j.length;ie++){const se=j[ie],le=o.cross(N,U,se),ae=o.length(le);ae>.05&&ae>K&&(K=ae,G=se)}G||(G=o.orthogonal(N,U));const ee=o.cross(N,U,G);o.normalize(ee,ee);const re=o.cross(C,ee,U),pe=l({center:[B[0],B[1],B[2]],radius:v,segments:M,axes:[U,ee,re]});E=d(E,pe)}),u(E)};e.exports=y}}),S0n=tt({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(n,e){var t=$o(),r=wpe(),i=w0n(),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(t.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}}),E0n=tt({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(n,e){var t=NU(),r=cs(),i=Uo(),o=il(),s=IU(),a=u=>{let{external:d,internal:h}=u;t(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 M=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+M*C,I=r.fromAngleRadians(r.create(),D);r.scale(I,I,p),r.add(I,I,E),_.push(I),D=N+M*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}}),Spe=tt({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(n,e){var t=go(),r=Uo(),i=$o(),o=il(),s=b0n(),a=S0n(),c=E0n(),l=(u,...d)=>{if(d=t(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}}),M0n=tt({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(n,e){var t=Uo(),r=spe(),i=IU(),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=t.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(t.toSides(t.fromPoints(y))),[]);return t.create(f)};e.exports=o}}),T0n=tt({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(n,e){var t=il(),r=IU(),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,t.toPoints(s));return t.fromPoints({closed:u},h)};e.exports=i}}),C0n=tt({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(n,e){var t=go(),r=Uo(),i=il(),o=M0n(),s=T0n(),a=(c,...l)=>{if(l=t(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}}),sGe=tt({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(n,e){e.exports={expand:Spe(),offset:C0n()}}}),LU=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(n,e){var t=Sl(),r=gi(),i=Uo(),o=cT(),s=OU(),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 _=t.create(),b=(v,M,E)=>{const A=M/p*h,P=r.scale(r.create(),m,M/p);return t.multiply(_,t.fromZRotation(_,A),t.fromTranslation(t.create(),P)),o.transform(_,E)};return c={numberOfSlices:p+1,capStart:!0,capEnd:!0,repair:f,callback:b},s(c,g)};e.exports=a}}),P0n=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(n,e){var t=Uo(),r=il(),i=LU(),o=(s,a)=>{if(!a.isClosed)throw new Error("extruded path must be closed");const c=r.toPoints(a),l=t.fromPoints(c);return i(s,l)};e.exports=o}}),A0n=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(n,e){var t=go(),r=Uo(),i=il(),o=LU(),s=P0n(),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=t(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}}),R0n=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(n,e){var t=il(),r=Spe(),i=LU(),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],t.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}}),N0n=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(n,e){var{area:t}=sN(),r=Uo(),i=il(),o=Spe(),s=LU(),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=>(t(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}}),k0n=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(n,e){var t=go(),r=Uo(),i=il(),o=R0n(),s=N0n(),a=(c,...l)=>{const u={size:1,height:1},{size:d,height:h}=Object.assign({},u,c);if(l=t(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}}),O0n=tt({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(n,e){var{TAU:t}=Ys(),r=Sl(),i=Uo(),o=OU(),s=cT(),a=(c,l)=>{const u={angle:t,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/t)),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 M=Math.round(y/t*Math.abs(d)),E=M>=2?M:2,A=r.create(),P=r.create(),N=(C,D,I)=>{const B=h+d/E*D,j=m/E*D,U=(B-h)/t*p;return r.multiply(A,r.fromTranslation(r.create(),[j,0,U*Math.sign(d)]),r.fromXRotation(r.create(),-t/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}}),I0n=tt({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(n,e){var t=go(),r=upe(),i=d4(),o=Sl(),s=Uo(),a=$o(),c=Ns(),l=h9(),u=oGe(),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 M=0;M<_.length;M++){const E=_[M].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 M=o.fromVectorRotation(o.create(),m,[0,0,1]);b=b.map(E=>c.transform(M,E))}b=b.sort((M,E)=>c.measureArea(E)-c.measureArea(M));const v=b.map(M=>s.fromPoints(M.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=t(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}}),pN=tt({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(n,e){e.exports={extrudeFromSlices:OU(),extrudeLinear:A0n(),extrudeRectangular:k0n(),extrudeRotate:KXe(),extrudeHelical:O0n(),project:I0n(),slice:cT()}}}),Epe=tt({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(n,e){var t=cs(),r=s=>{let a=t.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=t.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}}),Mpe=tt({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(n,e){var t=Uo(),r=$o(),i=il(),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=>{t.isA(u)?t.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}}),L0n=tt({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(n,e){var t=go(),r=il(),i=Epe(),o=Mpe(),s=(...a)=>{a=t(a);const c=o(a),l=i(c);return r.fromPoints({closed:!0},l)};e.exports=s}}),D0n=tt({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(n,e){var t=go(),r=Uo(),i=Epe(),o=Mpe(),s=(...a)=>{a=t(a);const c=o(a),l=i(c);return l.length<3?r.create():r.fromPoints(l)};e.exports=s}}),z0n=tt({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(n,e){var t=go(),r=$o(),i=Mpe(),o=bpe(),s=(...a)=>{a=t(a);const c=i(a);return c.length===0?r.create():r.create(o(c))};e.exports=s}}),aGe=tt({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(n,e){var t=go(),r=uN(),i=Uo(),o=$o(),s=il(),a=L0n(),c=D0n(),l=z0n(),u=(...d)=>{if(d=t(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}}),$0n=tt({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(n,e){var t=go(),r=wpe(),i=aGe(),o=(...s)=>{if(s=t(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}}),F0n=tt({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(n,e){e.exports={hull:aGe(),hullChain:$0n(),hullPoints2:Epe(),hullPoints3:bpe()}}}),B0n=tt({"node_modules/@jscad/modeling/src/operations/minkowski/index.js"(n,e){e.exports={minkowskiSum:rGe()}}}),cGe=tt({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(n,e){var t=gi(),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=>t.snap(t.create(),f,s)),h=[];for(let f=0;f<d.length;f++){const m=(f+1)%d.length;t.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}}),j0n=tt({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(n,e){var t=upe(),r=gi(),i=Ns(),o=g=>{const _=i.toPoints(g),b=[];for(let v=0;v<_.length;v++){const M=(v+1)%_.length,E={v1:_[v],v2:_[M]};b.push(E)}for(let v=0;v<b.length;v++){const M=(v+1)%_.length;b[v].next=b[M],b[M].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,M=g.prev.v2,E=_.next.v2;const A=h(v,M,E,b);v=_.prev.v1,M=_.prev.v2,E=g.next.v2;const P=h(v,M,E,b);return[A,P]},u=r.create(),d=r.create(),h=(g,_,b,v)=>{const M=r.subtract(u,_,g),E=r.subtract(d,b,_);return r.cross(M,M,E),r.dot(M,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 j=(U,G,K)=>{const ee={v1:K.v1,v2:G.v2,next:G.next,prev:K.prev};K.prev.next=ee,G.next.prev=ee,a(U,G),G.v1=null,G.v2=null,G.next=null,G.prev=null,a(U,K),K.v1=null,K.v2=null,K.next=null,K.prev=null};D[0]===0&&j(v,I,I.prev),D[1]===0&&j(v,B,B.prev)}}else N.next&&s(v,N)}}const M=[];return v.forEach(E=>{const A=p(E);A&&M.push(A)}),v.clear(),M},m=(g,_)=>Math.abs(g[3]-_[3])<15e-8?t(g,_):!1,y=(g,_)=>{const b=[];_.forEach(M=>{const E=b.find(A=>m(A[0],i.plane(M)));E?E[1].push(M):b.push([i.plane(M),[M]])});let v=[];return b.forEach(M=>{const E=M[1],A=f(E);v=v.concat(A)}),v};e.exports=y}}),U0n=tt({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(n,e){var t=Ys(),r=gi(),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 M=b[v];let E=o(M.vertex0);if(E===m&&(E=o(M.vertex1),E===y&&!(f!==null&&M.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}`,M=`${b}/${m}`;if(u.has(M)){const E=u.get(M);E.splice(-1,1),E.length===0&&u.delete(M)}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 M=0;M<2;M++){const E=M===0?v.vertex0:v.vertex1,A=M===0?v.vertex1:v.vertex0,P=o(E),N=o(A);let C=[];M===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],j=M===0?B.vertex0:B.vertex1;if(M===0?B.vertex1:B.vertex0,o(j)===N){a(u,d,h,E,A,null),a(u,d,h,A,E,null),_=!1,M=2,m=!0;break}else{const G=E,K=A,ee=j,re=r.subtract(r.create(),ee,G),pe=r.dot(r.subtract(r.create(),K,G),re)/r.dot(re,re);if(pe>0&&pe<1){const ie=r.scale(r.create(),re,pe);if(r.add(ie,ie,G),r.squaredDistance(ie,K)<t.EPS*t.EPS){const le=B.polygonindex,ae=f[le],ye=o(B.vertex1);let Te=-1;for(let _e=0;_e<ae.vertices.length;_e++)if(o(ae.vertices[_e])===ye){Te=_e;break}const Me=ae.vertices.slice(0);Me.splice(Te,0,A);const $e=i.create(Me);f[le]=$e,a(u,d,h,B.vertex0,B.vertex1,le);const me=s(u,d,h,B.vertex0,A,le),Ee=s(u,d,h,A,B.vertex1,le);me!==null&&p.set(me,!0),Ee!==null&&p.set(Ee,!0),_=!1,M=2,m=!0;break}}}}}}_&&p.delete(g)}if(!m)break}l=f}return u.clear(),l};e.exports=c}}),H0n=tt({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(n,e){var t=gi(),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=>t.add(h,h,p)),t.snap(h,t.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}}),V0n=tt({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(n,e){var t=go(),r=h9(),i=Uo(),o=$o(),s=il(),a=cGe(),c=j0n(),l=U0n(),u=H0n(),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),M=r(y);let E=o.toPolygons(y);_&&(E=a(M,E)),b&&(E=c(M,E)),v&&(E=l(E),E=u(M,E));const A=Object.assign({},y);return A.polygons=E,A},f=(m,...y)=>{if(y=t(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}}),Y0n=tt({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(n,e){var t=go(),r=cs(),i=Uo(),o=$o(),s=il(),a=h9(),c=cGe(),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=t(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}}),X0n=tt({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(n,e){e.exports={generalize:V0n(),snap:Y0n(),retessellate:dN()}}}),G0n=tt({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(n,e){var t=(r,i,o)=>{for(r=r.slice();r.length<o;)r.push(i);return r};e.exports=t}}),q0n=tt({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(n,e){var t=go(),r=G0n(),i=hpe(),{translate:o}=q7(),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=t(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}}),DU=tt({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(n,e){var t=go(),r=Uo(),i=$o(),o=il(),s=X7(),{translate:a}=q7(),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=t(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}}}),zU=tt({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(n,e){var t=go(),r=Sl(),i=Uo(),o=$o(),s=il(),a=(d,...h)=>{if(!Array.isArray(d))throw new Error("factors must be an array");if(h=t(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}}}),W0n=tt({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(n,e){var t=go(),r=Uo(),i=$o(),o=il(),s=(a,...c)=>{if(c=t(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}}),K7=tt({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(n,e){e.exports={align:q0n(),center:DU().center,centerX:DU().centerX,centerY:DU().centerY,centerZ:DU().centerZ,mirror:cN().mirror,mirrorX:cN().mirrorX,mirrorY:cN().mirrorY,mirrorZ:cN().mirrorZ,rotate:lN().rotate,rotateX:lN().rotateX,rotateY:lN().rotateY,rotateZ:lN().rotateZ,scale:zU().scale,scaleX:zU().scaleX,scaleY:zU().scaleY,scaleZ:zU().scaleZ,transform:W0n(),translate:q7().translate,translateX:q7().translateX,translateY:q7().translateY,translateZ:q7().translateZ}}}),$U=tt({"node_modules/@jscad/modeling/src/index.js"(n,e){e.exports={colors:RU(),curves:Hdn(),geometries:ape(),maths:fhn(),measurements:whn(),primitives:W7(),text:e0n(),utils:eGe(),booleans:hN(),expansions:sGe(),extrusions:pN(),hulls:F0n(),minkowski:B0n(),modifiers:X0n(),transforms:K7()}}}),lGe=tt({"node_modules/jscad-planner/dist/index.cjs"(n,e){var t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(h,p)=>{for(var f in p)t(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&&t(h,y,{get:()=>p[y],enumerable:!(m=r(p,y))||m.enumerable});return h},c=h=>a(t({},"__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)}`)}}}}),K0n=tt({"node_modules/ms/index.js"(n,e){var t=1e3,r=t*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*t;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>=t?Math.round(h/t)+"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>=t?d(h,p,t,"second"):h+" ms"}function d(h,p,f,m){var y=p>=f*1.5;return Math.round(h/f)+" "+m+(y?"s":"")}}}),Z0n=tt({"node_modules/debug/src/common.js"(n,e){function t(r){o.debug=o,o.default=o,o.coerce=d,o.disable=l,o.enable=a,o.enabled=u,o.humanize=K0n(),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=_,M=Number(new Date),E=M-(f||M);v.diff=E,v.prev=f,v.curr=M,f=M,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=t}}),Q0n=tt({"node_modules/debug/src/browser.js"(n,e){n.formatArgs=r,n.save=i,n.load=o,n.useColors=t,n.storage=s(),n.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`."))}})(),n.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 t(){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)}n.log=console.debug||console.log||(()=>{});function i(c){try{c?n.storage.setItem("debug",c):n.storage.removeItem("debug")}catch{}}function o(){let c;try{c=n.storage.getItem("debug")||n.storage.getItem("DEBUG")}catch{}return!c&&typeof Z0e<"u"&&"env"in Z0e&&(c=Z0e.env.DEBUG),c}function s(){try{return localStorage}catch{}}e.exports=Z0n()(n);var{formatters:a}=e.exports;a.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}}),uGe={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},dGe=q.createContext(void 0),J0n=({children:n})=>{const[e,t]=q.useState(uGe),r=q.useCallback((s,a)=>{t(c=>({...c,[s]:a}))},[]),i=q.useCallback(()=>{t(uGe)},[]),o=q.useMemo(()=>({visibility:e,setLayerVisibility:r,resetToDefaults:i}),[e,r,i]);return X.jsx(dGe.Provider,{value:o,children:n})},Z7=()=>{const n=q.useContext(dGe);if(!n)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return n},Tpe=1.2;function hGe(n){return q.useMemo(()=>{if(!n)return Tpe;try{return pi(n).pcb_board.list()[0]?.thickness??Tpe}catch{return Tpe}},[n])}var pGe=q.createContext(null),Wy=()=>{const n=q.useContext(pGe);if(!n)throw new Error("useThree must be used within a ThreeProvider");return n},fN=(n,e=[])=>{const{addFrameListener:t,removeFrameListener:r}=Wy();ri.useEffect(()=>(t(n),()=>r(n)),[t,r,...e])},mN={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},fGe=({children:n,position:e,style:t})=>{const{camera:r,renderer:i}=Wy(),o=q.useRef(document.createElement("div")),[s,a]=q.useState(null);return q.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(dB.createPortal(n,o.current)),()=>{c.contains(o.current)&&c.removeChild(o.current)}},[i,n]),fN(()=>{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=mN.htmlElements.toString(),t&&Object.assign(o.current.style,t)},[r,i,e,t]),s},mGe={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},Bs=n=>{let e=typeof n=="number"?"mm":n.replace(/^[^a-zA-Z]+/g,"").toLowerCase();e||(e="mm");const t=typeof n=="number"?n:Number.parseFloat(n.split(e)[0]);if(e in mGe)return t*mGe[e];throw new Error(`Unsupported unit: ${e}`)},ih=Bs,epn=Object.defineProperty,tpn=(n,e)=>{for(var t in e)epn(n,t,{get:e[t],enumerable:!0})},Xb={};tpn(Xb,{axial:()=>Mfn,bga:()=>Opn,breakoutheaders:()=>$fn,cap:()=>cpn,dfn:()=>afn,diode:()=>apn,dip:()=>ipn,electrolytic:()=>Tyn,hc49:()=>Bfn,jst:()=>V1n,led:()=>lpn,lqfp:()=>Dfn,m2host:()=>Gyn,melf:()=>Jmn,micromelf:()=>r1n,minimelf:()=>Ymn,mlp:()=>Upn,mountedpcbmodule:()=>Wyn,ms012:()=>pfn,ms013:()=>mfn,msop:()=>eyn,pad:()=>jfn,pinrow:()=>lfn,platedhole:()=>$yn,potentiometer:()=>Syn,pushbutton:()=>Rfn,qfn:()=>Fpn,qfp:()=>jpn,quad:()=>uT,radial:()=>Pfn,res:()=>Rpn,sma:()=>a1n,smb:()=>m1n,smbf:()=>Pyn,smc:()=>x1n,smf:()=>d1n,smtpad:()=>Dyn,sod110:()=>X1n,sod123:()=>vfn,sod123f:()=>wmn,sod123fl:()=>Tmn,sod123w:()=>nmn,sod128:()=>Imn,sod323:()=>smn,sod323f:()=>_mn,sod323fl:()=>syn,sod323w:()=>nyn,sod523:()=>Xfn,sod723:()=>Rmn,sod80:()=>Qfn,sod882:()=>fmn,sod882d:()=>Wmn,sod923:()=>umn,soic:()=>Lpn,solderjumper:()=>myn,son:()=>uyn,sop8:()=>Kfn,sot:()=>Byn,sot223:()=>S1n,sot23:()=>efn,sot23w:()=>k1n,sot25:()=>ifn,sot323:()=>kyn,sot343:()=>Hyn,sot363:()=>Kpn,sot457:()=>_yn,sot563:()=>dfn,sot723:()=>gfn,sot886:()=>Qpn,sot89:()=>Bmn,sot963:()=>byn,ssop:()=>Ypn,stampboard:()=>kfn,stampreceiver:()=>Lfn,to220:()=>OGe,to220f:()=>Hmn,to92:()=>Vfn,to92l:()=>Zyn,to92s:()=>$1n,tqfp:()=>Bpn,tssop:()=>qpn,vson:()=>hyn,vssop:()=>Z1n});var Nr=(n,e,t)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:n,y:e},anchor_alignment:"center"}),Cr=Je({norefdes:Ie().optional().describe("disable reference designator label"),invert:Ie().optional().describe("hint to invert the orientation of the 3D model"),faceup:Ie().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:Ie().optional().describe("omit all silkscreen elements from the footprint")}),_o=(n,e,t,r,i)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:t,hole_diameter:Bs(r),outer_diameter:Bs(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[n.toString()]}),Yx=n=>{const{pn:e,x:t,y:r,holeDiameter:i,rectPadWidth:o,rectPadHeight:s,holeOffsetX:a=0,holeOffsetY:c=0,rectBorderRadius:l}=n;return{pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:t,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}},FU=Array.from({length:9},(n,e)=>Math.cos(e/8*Math.PI-Math.PI)).map(n=>({x:n,y:-Math.sqrt(1-n**2)}));function p9(n){return typeof n=="string"?n.trim().toLowerCase().endsWith("mil")?parseFloat(n)*.0254:parseFloat(n):Number(n)}var BU=kn([z(),He()]).transform(n=>p9(n)),npn=n=>Cr.extend({fn:z(),num_pins:He().optional().default(6),wide:Ie().optional(),narrow:Ie().optional(),w:BU.optional(),p:BU.default(n.p??"2.54mm"),id:BU.optional(),od:BU.optional(),nosquareplating:Ie().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=p9("0.55mm"),e.od=p9("0.95mm")):(e.id=p9("0.8mm"),e.od=p9("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=p9("600mil"):e.narrow?e.w=p9("300mil"):e.w=p9(n.w??"300mil")),e)),rpn=npn({}),yGe=(n,e,t,r,i)=>{const o=n/2,s=e<=o,a=o-1,c=r,l=c*a;return s?{x:-t/2,y:l/2-(e-1)*c}:{x:t/2,y:-l/2+(e-o-1)*c}},ipn=n=>{const e=rpn.parse(n),t=[];for(let l=0;l<e.num_pins;l++){const{x:u,y:d}=yGe(e.num_pins,l+1,e.w,e.p??2.54,e.nosquareplating);if(l===0&&!e.nosquareplating){t.push(Yx({pn:l+1,x:u,y:d,holeDiameter:e.id??"0.8mm",rectPadWidth:e.od??"1mm",rectPadHeight:e.od??"1mm"}));continue}t.push(_o(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},...FU.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}=yGe(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:[...t,s,c,...a],parameters:e}},ar=(n,e,t,r,i)=>({type:"pcb_smtpad",x:e,y:t,width:r,height:i,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(n)?n.map(o=>o.toString()):[n.toString()]}),gGe=[{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}],opn=Object.fromEntries(gGe.map(n=>[n.metric,n])),spn=Object.fromEntries(gGe.map(n=>[n.imperial,n]));Cr.extend({tht:Ie(),p:ue.optional(),pw:ue.optional(),ph:ue.optional(),metric:Qe.optional(),imperial:Qe.optional(),w:ue.optional(),h:ue.optional(),textbottom:Ie().optional()});var jU=n=>{let{tht:e,p:t,pw:r,ph:i,metric:o,imperial:s,w:a,h:c,textbottom:l}=n;if(typeof a=="string"&&(a=ih(a)),typeof c=="string"&&(c=ih(c)),typeof t=="string"&&(t=ih(t)),typeof r=="string"&&(r=ih(r)),typeof i=="string"&&(i=ih(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=opn[o]),s&&(u=spn[s]),u&&(a=u.w_mm_min,c=u.h_mm_min,t=u.p_mm_min,r=u.pw_mm_min,i=u.ph_mm_min),t===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:t/2,y:i/2+.4},{x:-t/2-r/2-.2,y:i/2+.4},{x:-t/2-r/2-.2,y:-i/2-.4},{x:t/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,-(t/2+r/2),...m)-f,_=Math.max((a??0)/2,t/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,M={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?[_o(1,-t/2,0,r,r*1/.8),_o(2,t/2,0,r,r*1/.8),d,p,M]:[ar(["1","left"],-t/2,0,r,i),ar(["2","right"],t/2,0,r,i),d,p,M]},apn=n=>({circuitJson:jU(n),parameters:n}),cpn=n=>({circuitJson:jU(n),parameters:n}),lpn=n=>({circuitJson:jU(n),parameters:n}),lT=n=>{const{padSpacing:e,padWidth:t,padHeight:r,padPitch:i,numRows:o,textbottom:s}=n,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,t,r))}),a.slice().reverse().forEach((P,N)=>{l.push(ar(N+o+1,e/2,P,t,r))});const u=Math.max(...a)+r/2+.4,d=Math.min(...a)-r/2-.4,h=-e/2-t/2-.4,p=e/2+t/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-t/2-.1,v=g+r/2+.1,M={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,M,A]},upn=Cr.extend({pw:ue.default("0.5mm"),ph:ue.default("0.4mm"),p:ue.default("0.7mm"),textbottom:Ie().optional(),convex:Ie().optional(),concave:Ie().optional()}),dpn=1,hpn=n=>{const e=upn.parse(n);if(e.concave===!0)return[];const t=ih(e.pw),r=ih(e.ph),i=ih(e.p);return lT({padSpacing:dpn,padWidth:t,padHeight:r,padPitch:i,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave})},ppn=Cr.extend({pw:ue.default("0.5mm"),ph:ue.default("0.32mm"),p:ue.default("0.5mm"),textbottom:Ie().optional(),convex:Ie().optional(),concave:Ie().optional()}),fpn=1,mpn=n=>{const e=ppn.parse(n),t=ih(e.pw),r=ih(e.ph),i=ih(e.p);return lT({padSpacing:fpn,padWidth:t,padHeight:r,padPitch:i,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave})},ypn=Cr.extend({pw:ue.default("0.9mm"),ph:ue.default("0.4mm"),p:ue.default("0.8mm"),textbottom:Ie().optional(),convex:Ie().optional(),concave:Ie().optional()}),gpn=1.7,_pn=n=>{const e=ypn.parse(n),t=ih(e.pw),r=ih(e.ph),i=ih(e.p);return lT({padSpacing:gpn,padWidth:t,padHeight:r,padPitch:i,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave})},xpn=Cr.extend({pw:ue.default("0.9mm"),ph:ue.default("0.4mm"),p:ue.default("0.8mm"),textbottom:Ie().optional(),convex:Ie().optional(),concave:Ie().optional()}),bpn=1.7,vpn=n=>{const e=xpn.parse(n),t=ih(e.pw),r=ih(e.ph),i=ih(e.p);return lT({padSpacing:bpn,padWidth:t,padHeight:r,padPitch:i,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave})},wpn=Cr.extend({pw:ue.default("0.7mm"),ph:ue.default("0.64mm"),p:ue.default("0.94mm"),textbottom:Ie().optional(),convex:Ie().optional(),concave:Ie().optional()}),Spn=1.4,Epn=n=>{const e=wpn.parse(n),t=ih(e.pw),r=ih(e.ph),i=ih(e.p);return lT({padSpacing:Spn,padWidth:t,padHeight:r,padPitch:i,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave})},Mpn=Cr.extend({pw:ue.default("0.9mm"),ph:ue.default("0.9mm"),p:ue.default("1.34mm"),textbottom:Ie().optional(),convex:Ie().optional(),concave:Ie().optional()}),Tpn=3,Cpn=n=>{const e=Mpn.parse(n),t=ih(e.pw),r=ih(e.ph),i=ih(e.p);return lT({padSpacing:Tpn,padWidth:t,padHeight:r,padPitch:i,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave})},Ppn=n=>{const e=n.array??n.x;if(typeof e=="number")return Number.isNaN(e)?void 0:e;if(typeof e=="string"){const t=Number.parseInt(e,10);return Number.isNaN(t)?void 0:t}if(typeof n.imperial=="string"){const r=n.imperial.match(/x(2|4)$/)?.[1];if(r)return Number.parseInt(r,10)}},Apn=n=>n?(typeof n=="number"?`${n}`:n).split(/[_x]/)[0]:void 0,Rpn=n=>{const e=Ppn(n),t=Apn(n.imperial);return e===2&&t==="0402"?{circuitJson:hpn(n),parameters:n}:e===4&&t==="0402"?{circuitJson:mpn(n),parameters:n}:e===2&&t==="0603"?{circuitJson:_pn(n),parameters:n}:e===4&&t==="0603"?{circuitJson:vpn(n),parameters:n}:e===2&&t==="0606"?{circuitJson:Epn(n),parameters:n}:e===4&&t==="1206"?{circuitJson:Cpn(n),parameters:n}:{circuitJson:jU(n),parameters:n}},_Ge=(n,{x:e,y:t,radius:r})=>({type:"pcb_smtpad",x:e,y:t,radius:r,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(n)?n.map(i=>i.toString()):[n.toString()]}),xGe="ABCDEFGHIJKLMNOPQRSTUVWXYZ",UU=z().transform(n=>{const[e,t]=n.split(/[x ]/);return{x:parseFloat(e??""),y:parseFloat(t??"")}}).pipe(Je({x:He(),y:He()})),Npn=z().or(bt(mu())).transform(n=>Array.isArray(n)?n:(n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1)),n.split(",").map(e=>{const t=Number(e);return isNaN(t)?e:t}))).pipe(bt(z().or(He()))),kpn=Cr.extend({fn:z(),num_pins:He().optional().default(64),grid:UU.optional(),p:Qe.default("0.8mm"),w:ue.optional(),h:ue.optional(),ball:ue.optional().describe("ball diameter"),pad:ue.optional().describe("pad width/height"),circularpads:Ie().optional().describe("use circular pads"),tlorigin:Ie().optional(),blorigin:Ie().optional(),trorigin:Ie().optional(),brorigin:Ie().optional(),missing:Npn.default([])}).transform(n=>{let e="tl";if(n.blorigin&&(e="bl"),n.trorigin&&(e="tr"),n.brorigin&&(e="br"),!n.grid){const r=Math.ceil(Math.sqrt(n.num_pins));n.grid={x:r,y:r}}return n.missing&&(n.missing=n.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=xGe.indexOf(i[1]),s=Number.parseInt(i[2])-1;return o*n.grid.x+s+1})),{...n,origin:e}}),Opn=n=>{const e=kpn.parse(n);let{num_pins:t,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(M=>typeof M=="number"),h=r.x*r.y-t;if(l.length===0&&h>0&&(Math.sqrt(h)%1===0?l.push("center"):h===1&&l.push("topleft")),l?.includes("center")){const M=Math.floor(Math.sqrt(h)),E=Math.floor((r.x-M)/2),A=Math.floor((r.y-M)/2);for(let P=A;P<A+M;P++)for(let N=E;N<E+M;N++)d.push(P*r.x+N+1)}l?.includes("topleft")&&d.push(1);const p=new Set(d);let f=0;for(let M=0;M<r.y;M++)for(let E=0;E<r.x;E++){const A=(E-(r.x-1)/2)*i,P=(M-(r.y-1)/2)*i;let N=E,C=M;switch(e.origin){case"bl":N=E,C=r.y-1-M;break;case"br":N=r.x-1-E,C=r.y-1-M;break;case"tr":N=r.x-1-E,C=M;break}let D=C*r.x+N+1;if(p.has(D)){f++;continue}D-=f;const I=[D,`${xGe[C]}${N+1}`];u.push(e.circularpads?_Ge(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}},HU=(n,e,t,r,i)=>({type:"pcb_smtpad",x:e,y:t,width:r,height:i,radius:i/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(n)?n.map(o=>o.toString()):[n.toString()]}),Q7=n=>Cr.extend({fn:z(),num_pins:He().optional().default(8),w:ue.default(ue.parse(n.w??"5.3mm")),p:ue.default(ue.parse(n.p??"1.27mm")),pw:ue.default(ue.parse(n.pw??"0.6mm")),pl:ue.default(ue.parse(n.pl??"1.0mm")),legsoutside:Ie().optional().default(n.legsoutside??!1),pillpads:Ie().optional().default(n.pillpads??!1),silkscreen_stroke_width:He().optional().default(.1)}).transform(e=>(!e.pw&&!e.pl?(e.pw=ue.parse("0.6mm"),e.pl=ue.parse("1.0mm")):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e)),Ipn=Q7({}),Cpe=n=>{n.widthincludeslegs!==void 0&&(n.legsoutside=!n.widthincludeslegs);const{num_pins:e,pn:t,w:r,p:i,pl:o,legsoutside:s}=n,a=e/2,c=t<=a,l=a-1,u=i,d=u*l,h=s?o/2:-o/2;return c?{x:-r/2-h,y:d/2-(t-1)*u}:{x:r/2+h,y:-d/2+(t-a-1)*u}},Lpn=n=>{const e=Ipn.parse(n);return{circuitJson:yN(e),parameters:e}},yN=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=Cpe({num_pins:n.num_pins,pn:a+1,w:n.w,p:n.p,pl:n.pl,legsoutside:n.legsoutside});n.pillpads?e.push(HU(a+1,c,l,n.pl,n.pw)):e.push(ar(a+1,c,l,n.pl,n.pw))}const t=Math.min(1,n.p/2),r=n.w-(n.legsoutside?0:n.pl*2)-.2,i=(n.num_pins/2-1)*n.p+n.pw+t,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:n.silkscreen_stroke_width??.1,route:[{x:-r/2,y:-i/2},{x:-r/2,y:i/2},...FU.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]},bGe=Gt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),Dpn=({num_pins:n,cw:e,ccw:t,startingpin:r})=>{const i=[],o=n/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<n;c++)i[s]=c+1,t||!e?(s++,s>n&&(s=1)):(s--,s<1&&(s=n));return i},Ppe=Cr.extend({fn:z(),cc:Ie().default(!0).optional(),ccw:Ie().default(!0).optional(),startingpin:z().or(bt(bGe)).transform(n=>typeof n=="string"?n.slice(1,-1).split(","):n).pipe(bt(bGe)).optional(),num_pins:He().optional().default(64),w:ue.optional(),h:ue.optional(),p:ue.default(ue.parse("0.5mm")),pw:ue.optional(),pl:ue.optional(),thermalpad:kn([Pe(!0),UU]).optional(),legsoutside:Ie().default(!1)}),Ape=n=>{n.w&&!n.h?n.h=n.w:!n.w&&n.h&&(n.w=n.h);const e=n.num_pins/4;if(!n.p&&!n.pw&&!n.pl&&n.w){const t=e+4;n.p=n.w/t}return!n.p&&n.w&&n.h&&n.pw&&n.pl&&(n.p=(n.w-n.pl*2)/(e-1)),!n.w&&!n.h&&n.p&&(n.w=n.p*(e+4),n.h=n.w),n.p&&!n.pw&&!n.pl?(n.pw=n.p/2,n.pl=n.p/2):n.pw?n.pl||(n.pl=n.pw*(1/.6)):n.pw=n.pl*(.6/1),n},vGe=Ppe.transform(Ape),zpn=["left","bottom","right","top"],$pn=n=>{const{pin_count:e,pn:t,w:r,h:i,p:o,pl:s,legsoutside:a}=n,c=e/4,l=zpn[Math.floor((t-1)/c)],u=(t-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")}},uT=n=>{const e=vGe.parse(n),t=[],r=Dpn(e),i=e.num_pins/4;for(let a=0;a<e.num_pins;a++){const{x:c,y:l,o:u}=$pn({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];t.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;t.push(ar(["thermalpad"],0,0,a,c))}else t.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:[...t,...o,s],parameters:e}};Ppe.extend({}).transform(Ape);var Fpn=n=>(n.legsoutside=!1,n.pl||(n.pl=.875),n.pw||(n.pw=.25),uT(n)),Bpn=n=>{if(n.legsoutside=!0,!n.p)switch(n.num_pins){case 32:n.p=.8;break;case 44:case 48:n.p=.5;break;case 64:case 80:case 100:n.p=.5;break;case 144:n.p=.5;break}if(!n.pl)switch(n.num_pins){case 32:case 44:case 48:case 64:case 80:case 100:n.pl=1.475;break;case 144:n.pl=1.6;break}if(!n.pw)switch(n.num_pins){case 32:n.pw=.55;break;case 44:case 48:case 64:case 80:case 100:n.pw=.3;break;case 144:n.pw=.25;break}return uT(n)},jpn=n=>{n.legsoutside=!0;const e=vGe.parse(n);if(!n.p)switch(n.num_pins){case 44:case 64:n.p=.8;break;case 52:n.w===14?n.p=1:n.p=.65;break;case 208:n.p=.5;break}if(!n.pl)switch(n.num_pins){case 44:case 52:case 64:n.pl=2.25;break;case 208:n.pl=1.65;break;default:n.pl=e.pl*4;break}if(!n.pw)switch(n.num_pins){case 44:case 64:n.pw=.5;break;case 52:n.w===14?n.pw=.45:n.pw=.55;break;case 208:n.pw=.3;break;default:n.pw=e.pw;break}return uT(n)};Ppe.extend({}).transform(Ape);var Upn=n=>(n.legsoutside=!1,n.thermalpad===void 0&&(n.thermalpad=!0),uT(n)),Hpn=Cr.extend({fn:z(),num_pins:He().optional().default(8),w:ue.default(ue.parse("3.9mm")),p:ue.default(ue.parse("1.27mm")),pw:ue.optional(),pl:ue.optional(),legsoutside:Ie().optional().default(!1),silkscreen_stroke_width:He().optional().default(.1)}).transform(n=>(n.pw==null&&n.pl==null?(n.pw=ue.parse("0.51mm"),n.pl=ue.parse("1.1mm")):n.pw==null?n.pw=n.pl*(.51/1.1):n.pl==null&&(n.pl=n.pw*(1.1/.51)),n)),Vpn=n=>{const{num_pins:e,pn:t,w:r,p:i}=n,o=e/2,s=t<=o,a=o-1,c=i,l=c*a,u=r+ue.parse("0.2mm"),d=(s?-1:1)*(u/2);return s?{x:d,y:l/2-(t-1)*c}:{x:d,y:-l/2+(t-o-1)*c}},Ypn=n=>{const e=Hpn.parse(n),t=[];for(let c=0;c<e.num_pins;c++){const{x:l,y:u}=Vpn({num_pins:e.num_pins,pn:c+1,w:e.w,p:e.p,pl:e.pl,legsoutside:e.legsoutside});t.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},...FU.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:[...t,a,s],parameters:e}},Xpn=Cr.extend({fn:z(),num_pins:He().optional().default(8),w:ue.default(ue.parse("3.0mm")),p:ue.default(ue.parse("0.5mm")),pw:ue.default(ue.parse("0.30mm")),pl:ue.default(ue.parse("1.45mm")),legsoutside:Ie().optional().default(!0),silkscreen_stroke_width:He().optional().default(.1)}),Gpn=n=>{const{num_pins:e,pn:t,w:r,p:i,pl:o,legsoutside:s}=n,a=e/2,c=t<=a,l=a-1,u=i*l,d=s?o/2:-o/2;return c?{x:-r/2-d,y:u/2-(t-1)*i}:{x:r/2+d,y:-u/2+(t-a-1)*i}},qpn=n=>{const e={...n},t=e.p,r=typeof t=="string"||typeof t=="number"?ue.parse(t):void 0,i=r!=null&&r<=ue.parse("0.5mm"),o=Xpn.parse(e),s=[],a=i?o.w-ue.parse("0.15mm"):o.w;for(let p=0;p<o.num_pins;p++){const{x:f,y:m}=Gpn({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},...FU.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}},Wpn=Cr.extend({fn:z(),num_pins:Pe(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()}),Kpn=n=>{const e=Wpn.parse({...n,fn:"sot363"}),t=ue.parse(e.w),r=ue.parse(e.h),i=ue.parse(e.p),o=ue.parse(e.pl),s=ue.parse(e.pw),a=[];for(let p=0;p<6;p++){const{x:f,y:m}=wGe(p+1,t,i);a.push(ar(p+1,f,m,o,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/4,y:r/2+.1},{x:t/4,y:r/2+.1}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/4,y:-r/2-.1},{x:t/4,y:-r/2-.1}],stroke_width:.05,pcb_silkscreen_path_id:""},u=wGe(1,t,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}},wGe=(n,e,t,r)=>n<=3?{x:-.84,y:t-(n-1)*t}:{x:.84,y:-t+(n-4)*t},Zpn=Cr.extend({fn:z(),num_pins:Pe(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()}),Qpn=n=>{const e=Zpn.parse({...n,fn:"sot886"}),t=ue.parse(e.w),r=ue.parse(e.h),i=ue.parse(e.p),o=ue.parse(e.pl),s=ue.parse(e.pw),a=[];for(let p=0;p<6;p++){const{x:f,y:m}=SGe(p+1,t,i,o);a.push(ar(p+1,f,m,o,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:r/2},{x:t/2,y:r/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:-r/2},{x:t/2,y:-r/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u=SGe(1,t,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}},SGe=(n,e,t,r)=>{const i=e/2-r/2;return n<=3?{x:-i,y:t-(n-1)*t}:{x:i,y:-t+(n-4)*t}},EGe=Cr.extend({fn:z(),num_pins:He().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()}),Jpn=Q7({p:"0.95mm",w:"1.6mm",legsoutside:!0}),efn=n=>{const e=n.string?.match(/^sot23_(\d+)/),t=e?Number.parseInt(e[1],10):3;if(t===6||t===8){const i=Jpn.parse({...n,num_pins:t});return{circuitJson:yN(i),parameters:i}}const r=EGe.parse({...n,num_pins:t});if(r.num_pins===3)return{circuitJson:nfn(r),parameters:r};if(r.num_pins===5)return{circuitJson:TGe(r),parameters:r};throw new Error("Invalid number of pins")},tfn=n=>{const{pn:e,p:t}=n;return e===1?{x:-1.155,y:t}:e===2?{x:-1.155,y:-t}:{x:1.15,y:0}},nfn=n=>{const e=[];for(let r=0;r<n.num_pins;r++){const{x:i,y:o}=tfn({num_pins:n.num_pins,pn:r+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl),p:Number.parseFloat(n.p)});e.push(ar(r+1,i,o,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=Nr(0,Number.parseInt(n.h),.3);return[...e,t]},MGe=n=>{const{p:e,h:t,pn:r}=n;if(r===1)return{x:-t/2-.5,y:e};if(r===2)return{x:-t/2-.5,y:0};if(r===3)return{x:-t/2-.5,y:-e};if(r===4)return{x:t/2+.5,y:-e};if(r===5)return{x:t/2+.5,y:e};throw new Error("Invalid pin number")},TGe=n=>{const e=[];for(let d=1;d<=n.num_pins;d++){const{x:h,y:p}=MGe({h:Number.parseFloat(n.h),p:Number.parseFloat(n.p),pn:d});e.push(ar(d,h,p,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=(n.num_pins+1)/2*Number.parseFloat(n.p),r=Number.parseFloat(n.h),i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t/3,y:r/2+Number.parseFloat(n.p)/1.3},{x:t/3,y:r/2+Number.parseFloat(n.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:-t/3,y:-r/2-Number.parseFloat(n.p)/1.3},{x:t/3,y:-r/2-Number.parseFloat(n.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Nr(0,r+.3,.3),a=MGe({h:Number.parseFloat(n.h),p:Number.parseFloat(n.p),pn:1});a.x=a.x-Number.parseFloat(n.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]},rfn=EGe.extend({}),ifn=n=>{const e=rfn.parse({...n,num_pins:5});return{circuitJson:TGe(e),parameters:e}},ofn=[{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}],sfn=Q7({}),afn=n=>{const e=sfn.parse(n),t=[];for(let d=0;d<e.num_pins;d++){const{x:h,y:p}=Cpe({num_pins:e.num_pins,pn:d+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});t.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 ofn){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:[...t,u,...s],parameters:e}},J7=({fs:n,pn:e,anchor_x:t,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:n,pcb_component_id:"pcb_component_1",text:`{PIN${e}}`,layer:a,anchor_position:{x:t,y:r},anchor_alignment:l,ccw_rotation:c}};function CGe({pinlabeltextalignleft:n,pinlabeltextalignright:e,pinlabelorthogonal:t}){let r="top";return t?r="left":r="top",n&&(t?r="bottom":r="right"),e&&(t?r="top":r="left"),r}var cfn=Cr.extend({fn:z(),num_pins:He().optional().default(6),rows:kn([z(),He()]).transform(n=>Number(n)).optional().default(1).describe("number of rows"),p:ue.default("0.1in").describe("pitch"),id:ue.default("1.0mm").describe("inner diameter"),od:ue.default("1.5mm").describe("outer diameter"),male:Ie().optional().describe("for male pin headers"),female:Ie().optional().describe("for female pin headers"),smd:Ie().optional().describe("surface mount device"),surfacemount:Ie().optional().describe("surface mount device (verbose)"),rightangle:Ie().optional().describe("right angle"),pw:ue.optional().default("1.0mm").describe("pad width for SMD"),pl:ue.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:Ie().optional().default(!1),pinlabeltextaligncenter:Ie().optional().default(!1),pinlabeltextalignright:Ie().optional().default(!1),pinlabelverticallyinverted:Ie().optional().default(!1),pinlabelorthogonal:Ie().optional().default(!1),nosquareplating:Ie().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Ie().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Ie().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Ie().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(n=>{const e=CGe(n);return{...n,pinlabelAnchorSide:e,male:n.male??!n.female,female:n.female??!1,smd:n.smd??n.surfacemount??!1,rightangle:n.rightangle??!1}}).superRefine((n,e)=>{n.male&&n.female&&e.addIssue({code:qn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),lfn=n=>{const e=cfn.parse(n),{p:t,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),_=-t,b=({xoff:P,yoff:N,od:C,anchorSide:D,smd:I,pw:B,pl:j})=>{let U=0,G=0;if(I){const K=C/5;switch(D){case"right":U=B/2+K;break;case"top":G=j/2+K;break;case"bottom":G=-(j/2+K);break;case"left":U=-(B/2+K);break}}else{const K=C*.75;switch(D){case"right":U=K;break;case"top":G=K;break;case"bottom":G=-K;break;case"left":U=-K;break}}return{anchor_x:P+U,anchor_y:N+G}},v=(P,N,C)=>{e.smd?y.push(ar(P,N,C,e.pw,e.pl)):P===1&&!e.nosquareplating?y.push(Yx({pn:P,x:N,y:C,holeDiameter:r,rectPadWidth:i,rectPadHeight:i})):y.push(_o(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"})))},M=new Set,E=o>2&&g>2;if(o===1){const P=-((s-1)/2)*t;for(let N=0;N<s;N++){const C=N+1,D=P+N*t,I=`${D},0`;if(M.has(I))throw new Error(`Overlap at ${I}`);M.add(I),v(C,D,0)}}else if(E){const P=-((g-1)/2)*t;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*t,B=C*_,j=`${I},${B}`;if(M.has(j))throw new Error(`Overlap at ${j}`);M.add(j),v(N++,I,B)}}else{const P=-((g-1)/2)*t;let N=1,C=0,D=o-1,I=0,B=g-1;for(;N<=s&&C<=D&&I<=B;){for(let j=C;j<=D&&N<=s;j++){const U=P+I*t,G=j*_,K=`${U},${G}`;if(M.has(K))throw new Error(`Overlap at ${K}`);M.add(K),v(N++,U,G)}I++;for(let j=I;j<=B&&N<=s;j++){const U=P+j*t,G=D*_,K=`${U},${G}`;if(M.has(K))throw new Error(`Overlap at ${K}`);M.add(K),v(N++,U,G)}if(D--,I<=B){for(let j=D;j>=C&&N<=s;j--){const U=P+B*t,G=j*_,K=`${U},${G}`;if(M.has(K))throw new Error(`Overlap at ${K}`);M.add(K),v(N++,U,G)}B--}if(C<=D){for(let j=B;j>=I&&N<=s;j--){const U=P+j*t,G=C*_,K=`${U},${G}`;if(M.has(K))throw new Error(`Overlap at ${K}`);M.add(K),v(N++,U,G)}C++}}if(N-1<s)throw new Error(`Missing pins: assigned ${N-1}, expected ${s}`)}const A=Nr(0,t,.5);return{circuitJson:[...y,A],parameters:e}},ufn=Cr.extend({fn:z(),num_pins:Pe(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()}),dfn=n=>{const e=ufn.parse({...n,fn:"sot563"}),t=ue.parse(e.w),r=ue.parse(e.h),i=ue.parse(e.p),o=ue.parse(e.pl),s=ue.parse(e.pw),a=[];for(let p=0;p<6;p++){const{x:f,y:m}=PGe(p+1,t,i,o);a.push(ar(p+1,f,m,o,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:r/2},{x:t/2,y:r/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:-r/2},{x:t/2,y:-r/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u=PGe(1,t,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}},PGe=(n,e,t,r)=>{const i=e/2-r/2;return n<=3?{x:-i,y:t-(n-1)*t}:{x:i,y:-t+(n-4)*t}},hfn=Q7({p:"1.27mm",w:"3.9mm",legsoutside:!0}),pfn=n=>{const e=hfn.parse({...n,num_pins:8});return{circuitJson:yN(e),parameters:e}},ffn=Q7({p:"1.27mm",w:"7.5mm",legsoutside:!0}),mfn=n=>{const e=ffn.parse({...n,num_pins:16});return{circuitJson:yN(e),parameters:e}},yfn=Cr.extend({fn:z(),num_pins:Pe(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")}),gfn=n=>{const e=yfn.parse(n),t=xfn(e),r=Nr(0,ue.parse(e.h),.2);return{circuitJson:[...t,r],parameters:e}},_fn=n=>{const{pn:e,p:t}=n;return e===1?{x:t,y:0}:e===2?{x:-t,y:-.4}:{x:-t,y:.4}},xfn=n=>{const e=[];for(let t=0;t<3;t++){const{x:r,y:i}=_fn({num_pins:n.num_pins,pn:t+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl),p:Number.parseFloat(n.p)});e.push(ar(t+1,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},bfn=Cr.extend({fn:z(),num_pins:Pe(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")}),vfn=n=>{const e=bfn.parse(n),t=Nr(0,ue.parse(e.h)/4+.4,.3);return{circuitJson:Sfn(e).concat(t),parameters:e}},wfn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Sfn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=wfn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Efn=Cr.extend({fn:z(),p:ue.optional().default("2.54mm"),id:ue.optional().default("0.7mm"),od:ue.optional().default("1.4mm")}),Mfn=n=>{const e=Efn.parse(n),{p:t,id:r,od:i}=e,o=[_o(1,-t/2,0,r,i),_o(2,t/2,0,r,i)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2+i+r/2,y:0},{x:t/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}},Tfn=(n,e,t,r,i,o=.1)=>{const s=[],a=[],c=Math.max(1,Math.ceil(Math.PI*t/o)),l=Math.PI/c;for(let u=0;u<=c;u++){const d=u*l,h=n+Math.cos(d)*t,p=e+Math.sin(d)*t;h<n-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=n+Math.cos(d)*t,p=e+Math.sin(d)*t;h<n-r&&p>=e-i/2&&p<=e+i/2||a.push({x:h,y:p})}return{topArc:s,bottomArc:a}},Cfn=Cr.extend({fn:z(),p:ue.optional().default("5mm"),id:ue.optional().default("0.8mm"),od:ue.optional().default("1.6mm"),ceramic:Ie().optional(),electrolytic:Ie().optional(),polarized:Ie().optional()}),Pfn=n=>{const e=Cfn.parse(n),{p:t,id:r,od:i}=e;r===.8&&i===1.6&&(e.id=t===5?.8:t*.25,e.od=t===5?1.6:t*.5);const o=[_o(1,-t/2,0,e.id,e.od),_o(2,t/2,0,e.id,e.od)],s=t+.1,{topArc:a,bottomArc:c}=Tfn(0,0,s,e.od/2,e.od),l=.02*t,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*t,f=-(t+p+.04*t),m=s-p-.08*t,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*t,.1*t),b=[...o,u,d,h,_];return(e.electrolytic===!0||e.polarized===!0)&&b.push(y,g),{circuitJson:b,parameters:e}},ew=(n,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:n,stroke_width:e.stroke_width||.1}),Afn=Cr.extend({fn:Pe("pushbutton"),w:ue.default(4.5),h:ue.default(6.5),id:ue.default(1),od:ue.default(1.2)}),Rfn=n=>{const e=Afn.parse(n),t=e.w,r=e.h,i=e.id,o=[_o(1,-t/2,r/2,i,i*1.5),_o(2,-t/2,-r/2,i,i*1.5),_o(3,t/2,-r/2,i,i*1.5),_o(4,t/2,r/2,i,i*1.5)],s=[ew([{x:-t/2,y:-r/2},{x:-t/2,y:r/2}]),ew([{x:t/2,y:-r/2},{x:t/2,y:r/2}]),ew([{x:-t/2,y:0},{x:-t/5,y:0},{x:t/5*1/Math.sqrt(2),y:r/8}]),ew([{x:t/2,y:0},{x:t/5,y:0}])],a=Nr(0,r/2+.4,.5);return{circuitJson:[...o,...s,a],parameters:e}},AGe=Cr.extend({fn:z(),w:ue.default("22.58mm"),h:ue.optional(),left:ue.optional().default(20),right:ue.optional().default(20),top:ue.optional().default(2),bottom:ue.optional().default(2),p:ue.default(ue.parse("2.54mm")),pw:ue.default(ue.parse("1.6mm")),pl:ue.default(ue.parse("2.4mm")),innerhole:Ie().default(!1),innerholeedgedistance:ue.default(ue.parse("1.61mm")),silkscreenlabels:Ie().default(!1),silkscreenlabelmargin:ue.default(ue.parse("0.1mm"))}),Nfn=n=>{const e=AGe.parse(n);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},VU=(n,e,t)=>{let r=[];return t==="right"&&(r=[{x:n+1/2,y:e},{x:n-1/2,y:e+.6/2},{x:n-1/2,y:e-.6/2},{x:n+1/2,y:e}]),t==="left"&&(r=[{x:n-1/2,y:e},{x:n+1/2,y:e+.6/2},{x:n+1/2,y:e-.6/2},{x:n-1/2,y:e}]),t==="top"&&(r=[{x:n,y:e+1/2},{x:n-.6/2,y:e-1/2},{x:n+.6/2,y:e-1/2},{x:n,y:e+1/2}]),t==="bottom"&&(r=[{x:n,y:e-1/2},{x:n-.6/2,y:e+1/2},{x:n+.6/2,y:e+1/2},{x:n,y:e-1/2}]),r},kfn=n=>{const e=AGe.parse(n),t=e.h??Nfn(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=VU(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(_o(y+1+e.left+(e.bottom??0)+l,e.w/2,m+y*e.p,a,c)),i.push(_o(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=VU(-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(_o(y+1+l,-e.w/2,m-y*e.p,a,c)),i.push(_o(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=VU(m-y*e.p,t/2-e.pl*1.4,"top")),r.push(ar(y+1+e.left+e.right+(e.bottom??0),m-y*e.p,t/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:t/2-e.pl-(d+e.silkscreenlabelmargin)},text:_,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}e.innerhole&&(i.push(_o(y+1+e.left+e.right+(e.bottom??0)+l,m-y*e.p,t/2,a,c)),i.push(_o(y+1+e.left+e.right+(e.bottom??0)+l*2,m-y*e.p,t/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=VU(m+y*e.p,-t/2+e.pl*1.4,"bottom")),r.push(ar(y+1+e.left,m+y*e.p,-t/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:-t/2+e.pl+(d+e.silkscreenlabelmargin)},text:_,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}e.innerhole&&(i.push(_o(y+1+e.left+l,m+y*e.p,-t/2,a,c)),i.push(_o(y+1+e.left+l*2,m+y*e.p,-t/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:t/2},{x:e.w/2,y:t/2},{x:e.w/2,y:-t/2},{x:-e.w/2,y:-t/2},{x:-e.w/2,y:t/2}],stroke_width:.1,layer:"top"},f=Nr(0,t/1.8,t/25);return{circuitJson:[...r,...i,...o,p,...e.silkscreenlabels?[]:[h],f],parameters:e}},RGe=Cr.extend({fn:z(),w:ue.default("22.58mm"),h:ue.optional(),left:ue.optional().default(20),right:ue.optional().default(20),top:ue.optional().default(2),bottom:ue.optional().default(2),p:ue.default(ue.parse("2.54mm")),pw:ue.default(ue.parse("1.6mm")),pl:ue.default(ue.parse("3.2mm")),innerhole:Ie().default(!1),innerholeedgedistance:ue.default(ue.parse("1.61mm"))}),Ofn=n=>{const e=RGe.parse(n);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},Ifn=(n,e,t,r=1,i=.6)=>{const o=r/2,s=i/2;return{left:[{x:n+o,y:e},{x:n-o,y:e+s},{x:n-o,y:e-s},{x:n+o,y:e}],right:[{x:n-o,y:e},{x:n+o,y:e+s},{x:n+o,y:e-s},{x:n-o,y:e}],top:[{x:n,y:e-o},{x:n-s,y:e+o},{x:n+s,y:e+o},{x:n,y:e-o}],bottom:[{x:n,y:e+o},{x:n-s,y:e-o},{x:n+s,y:e-o},{x:n,y:e+o}]}[t]},Lfn=n=>{const e=RGe.parse(n),t=e.h??Ofn(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=Ifn(-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(_o(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,-t/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:-t/2+e.pl/2-3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(_o(u+c,f-m*e.p,-t/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(_o(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,t/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:t/2-e.pl/2+3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&o.push(_o(u+c,f+m*e.p,t/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:t/2+e.pl/3},{x:e.w/2+e.pl/3,y:t/2+e.pl/3},{x:e.w/2+e.pl/3,y:-t/2-e.pl/3},{x:-e.w/2-e.pl/3,y:-t/2-e.pl/3},{x:-e.w/2-e.pl/3,y:t/2+e.pl/3}],stroke_width:.1,layer:"top"},p=Nr(0,t/1.8,t/25);return{circuitJson:[...o,...r,...i,h,d,p],parameters:e}},Dfn=n=>(n.legsoutside=!0,n.pl||(n.pl=1.5),n.pw||(n.pw=.3),uT(n)),NGe=Cr.extend({fn:z(),w:ue.default("10mm"),h:ue.optional(),left:ue.optional().default(20),right:ue.optional().default(20),top:ue.optional().default(0),bottom:ue.optional().default(0),p:ue.default(ue.parse("2.54mm")),id:ue.optional().default(ue.parse("1mm")),od:ue.optional().default(ue.parse("1.5mm"))}),zfn=n=>{const e=NGe.parse(n);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},YU=(n,e,t,r=1,i=.6)=>{const o=r/2,s=i/2;return{left:[{x:n+o,y:e},{x:n-o,y:e+s},{x:n-o,y:e-s},{x:n+o,y:e}],right:[{x:n-o,y:e},{x:n+o,y:e+s},{x:n+o,y:e-s},{x:n-o,y:e}],top:[{x:n,y:e-o},{x:n-s,y:e+o},{x:n+s,y:e+o},{x:n,y:e-o}],bottom:[{x:n,y:e+o},{x:n-s,y:e-o},{x:n+s,y:e-o},{x:n,y:e+o}]}[t]},$fn=n=>{const e=NGe.parse(n),t=e.h??zfn(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=YU(e.w/2+o*1.4,u+d*e.p,"right")),r.push(_o(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=YU(-e.w/2-o*1.4,u+d*e.p,"left")),r.push(_o(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=YU(u+d*e.p,t/2+o*1.4,"top")),r.push(_o(d+1+e.right+(e.bottom??0)+e.left,u+d*e.p,t/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=YU(u+d*e.p,-t/2-o*1.4,"bottom")),r.push(_o(d+1+e.left,u+d*e.p,-t/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:t/2+o},{x:e.w/2+o,y:t/2+o},{x:e.w/2+o,y:-t/2-o},{x:-e.w/2-o,y:-t/2-o},{x:-e.w/2-o,y:t/2+o}],stroke_width:.1,layer:"top"},l=Nr(0,t/1.7,t/25);return{circuitJson:[...r,c,l,a],parameters:e}},kGe=(n,e,t,r)=>Array.from({length:25},(i,o)=>{const s=o/24*Math.PI-Math.PI/2;return{x:n+(r==="right"?1:-1)*Math.cos(s)*t,y:e+Math.sin(s)*t}}),Ffn=Cr.extend({fn:z(),p:ue.optional().default("4.88mm"),id:ue.optional().default("0.8mm"),od:ue.optional().default("1.5mm"),w:ue.optional().default("5.6mm"),h:ue.optional().default("3.5mm")}),Bfn=n=>{const e=Ffn.parse(n),{p:t,id:r,od:i,w:o,h:s}=e,a=s/2,c=[_o(1,-t/2,0,r,i),_o(2,t/2,0,r,i)],l=kGe(-o/2,0,a,"left"),u=kGe(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,t/4,.5);return{circuitJson:[...c,d,h],parameters:e}};Cr.extend({w:ue,h:ue});var jfn=n=>{const{w:e,h:t}=n,r=Bs(e),i=Bs(t);return{circuitJson:[ar(1,0,0,r,i),Nr(0,i/2+.5,.2)],parameters:n}},tw=(n,e,t,r,i,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:e,y:t,outer_width:Bs(i),outer_height:Bs(o),hole_width:Bs(r),hole_height:Bs(r),pcb_port_id:"",layers:["top","bottom"],port_hints:[n.toString()],ccw_rotation:0}),Ufn=Cr.extend({fn:z(),num_pins:kn([Pe(3),Pe(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:Ie().default(!1),string:z().optional()}),Hfn=(n,e,t)=>Array.from({length:25},(r,i)=>{const o=i/24*Math.PI;return{x:n+Math.cos(o)*t,y:e+Math.sin(o)*t}}),Vfn=n=>{const e=n.string?.match(/^to92_(\d+)/),t=e?Number.parseInt(e[1],10):3,r=Ufn.parse({...n,num_pins:t}),{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=[Yx({pn:1,x:-d,y:u-d,holeDiameter:h,rectPadWidth:p,rectPadHeight:m}),tw(2,0,u-d,h,f,m),tw(3,d,u-d,h,f,m)]:y=[Yx({pn:1,x:-d,y:u-d,holeDiameter:h,rectPadWidth:p,rectPadHeight:p}),_o(2,0,u,h,p),_o(3,d,u-d,h,p)];else if(r.num_pins===2)y=[Yx({pn:1,x:-d,y:u-d,holeDiameter:h,rectPadWidth:f,rectPadHeight:m}),tw(2,d,u-d,h,f,m)];else throw new Error("Invalid number of pins for TO-92");const g=Number.parseFloat(a)/2,_=Hfn(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}},Yfn=Cr.extend({fn:z(),num_pins:Pe(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")}),Xfn=n=>{const e=Yfn.parse(n),t=Nr(0,ue.parse(e.h),.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:qfn(e).concat(r,t),parameters:e}},Gfn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},qfn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=Gfn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Wfn=Q7({w:"7.05mm",p:"1.27mm",pw:"0.65mm",pl:"1.975mm"}),Kfn=n=>{const e=Wfn.parse(n),t=[];for(let s=0;s<e.num_pins;s++){const{x:a,y:c}=Cpe({num_pins:e.num_pins,pn:s+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});t.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:[...t,i,o],parameters:e}},Zfn=Cr.extend({fn:z(),num_pins:Pe(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")}),Qfn=n=>{const e=Zfn.parse(n),t=Nr(0,ue.parse(e.h)/2+1,.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2+.5,y:ue.parse(e.h)/2+.5},{x:-ue.parse(e.w)/2-.5,y:ue.parse(e.h)/2+.5},{x:-ue.parse(e.w)/2-.5,y:-ue.parse(e.h)/2-.5},{x:ue.parse(e.p)/2+.5,y:-ue.parse(e.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:emn(e).concat(r,t),parameters:e}},Jfn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},emn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=Jfn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},tmn=Cr.extend({fn:z(),num_pins:Pe(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")}),nmn=n=>{const e=tmn.parse(n),t=Nr(0,ue.parse(e.h)-.5,.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:imn(e).concat(r,t),parameters:e}},rmn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},imn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=rmn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},omn=Cr.extend({fn:z(),num_pins:Pe(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")}),smn=n=>{const e=omn.parse(n),t=Nr(0,ue.parse(e.h)-.5,.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:cmn(e).concat(r,t),parameters:e}},amn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},cmn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=amn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},lmn=Cr.extend({fn:z(),num_pins:Pe(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")}),umn=n=>{const e=lmn.parse(n),t=Nr(0,ue.parse(e.h),.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2+.15,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.15,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.15,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2+.15,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:hmn(e).concat(r,t),parameters:e}},dmn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},hmn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=dmn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},pmn=Cr.extend({fn:z(),num_pins:Pe(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")}),fmn=n=>{const e=pmn.parse(n),t=Nr(0,ue.parse(e.h)+.1,.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2+.2,y:ue.parse(e.h)/2+.2},{x:-ue.parse(e.w)/2-.2,y:ue.parse(e.h)/2+.2},{x:-ue.parse(e.w)/2-.2,y:-ue.parse(e.h)/2-.2},{x:ue.parse(e.p)/2+.2,y:-ue.parse(e.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ymn(e).concat(r,t),parameters:e}},mmn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},ymn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=mmn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},gmn=Cr.extend({fn:z(),num_pins:Pe(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")}),_mn=n=>{const e=gmn.parse(n),t=Nr(0,ue.parse(e.h),.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.pad_spacing)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:-ue.parse(e.h)/2},{x:ue.parse(e.pad_spacing)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bmn(e).concat(r,t),parameters:e}},xmn=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},bmn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=xmn({pn:t,pad_spacing:Number.parseFloat(n.pad_spacing)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},vmn=Cr.extend({fn:z(),num_pins:Pe(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")}),wmn=n=>{const e=vmn.parse(n),t=Nr(0,ue.parse(e.h),.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Emn(e).concat(r,t),parameters:e}},Smn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Emn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=Smn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Mmn=Cr.extend({fn:z(),num_pins:Pe(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")}),Tmn=n=>{const e=Mmn.parse(n),t=Nr(0,ue.parse(e.h),.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Pmn(e).concat(r,t),parameters:e}},Cmn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Pmn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=Cmn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Amn=Cr.extend({fn:z(),num_pins:Pe(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")}),Rmn=n=>{const e=Amn.parse(n),t=Nr(0,ue.parse(e.h),.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.1,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.1,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:kmn(e).concat(r,t),parameters:e}},Nmn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},kmn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=Nmn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Omn=Cr.extend({fn:z(),num_pins:Pe(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")}),Imn=n=>{const e=Omn.parse(n),t=Nr(0,ue.parse(e.h)/2+.4,.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Dmn(e).concat(r,t),parameters:e}},Lmn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Dmn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=Lmn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},zmn=Cr.extend({fn:z(),num_pins:kn([Pe(3),Pe(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()}),$mn=n=>{const e=[],t=Number.parseFloat(n.p),r=Number.parseFloat(n.pw),i=Number.parseFloat(n.w),o=Number.parseFloat(n.pl),s=.175,a=(o-(o+s))/2;e.push(ar(1,-i/2+a,t,o,r),ar(2,-i/2,0,o+s,r),ar(3,-i/2+a,-t,o,r));const c=Nr(0,0,.3),l=Number.parseFloat(n.w)/2-1,u=Number.parseFloat(n.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]},Fmn=n=>{const e=[];Number.parseFloat(n.p),Number.parseFloat(n.pw),Number.parseFloat(n.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 t=Nr(0,Number.parseFloat(n.h)/2+.5,.3),r=Number.parseFloat(n.w)/2-1,i=Number.parseFloat(n.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,t]},Bmn=n=>{const e=n.string?.match(/^sot89_(\d+)/),t=e?Number.parseInt(e[1],10):3,r=zmn.parse({...n,num_pins:t});if(r.num_pins===3)return{circuitJson:$mn(r),parameters:r};if(r.num_pins===5)return{circuitJson:Fmn(r),parameters:r};throw new Error("Invalid number of pins for SOT89")},jmn=Cr.extend({fn:z(),p:ue.optional().default("5.0mm"),id:ue.optional().default("1.0mm"),od:ue.optional().default("1.9mm"),w:ue.optional().default("13mm"),h:ue.optional().default("7mm"),num_pins:He().optional(),string:z().optional()}),OGe=n=>{const e=jmn.parse(n),{id:t,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,M)=>{const E=a%2===0?(M-a/2+.5)*p:(M-Math.floor(a/2))*p;return _o(M+1,E,c,t,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}}},Rpe=2.54,Umn=Cr.extend({fn:z(),id:ue.optional().default("1.2mm"),od:ue.optional().default("1.905mm"),ph:ue.optional().default("2mm"),w:ue.optional().default("13mm"),h:ue.optional().default("7mm"),num_pins:He().optional(),string:z().optional()}),Hmn=n=>{const e=Umn.parse(n),t=e.num_pins??Number.parseInt(e.string?.match(/^to220f(?:_|-)(\d+)/i)?.[1]??"3"),r=OGe({...e,fn:"to220",string:e.string?.replace(/^to220f/i,"to220"),num_pins:t}),i=-1,o=Array.from({length:t},(a,c)=>{const l=t%2===0?(c-t/2+.5)*Rpe:(c-Math.floor(t/2))*Rpe;return c===0?Yx({pn:1,x:l,y:i,holeDiameter:e.id,rectPadWidth:e.od,rectPadHeight:e.ph}):tw(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:Rpe,num_pins:t}}},Vmn=Cr.extend({fn:z(),num_pins:Pe(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")}),Ymn=n=>{const e=Vmn.parse(n),t=Nr(0,ue.parse(e.h)/2+.4,.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Gmn(e).concat(r,t),parameters:e}},Xmn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Gmn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=Xmn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},qmn=Cr.extend({fn:z(),num_pins:Pe(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")}),Wmn=n=>{const e=qmn.parse(n),t=Nr(0,ue.parse(e.h)+.1,.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2+.1,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2+.1,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Zmn(e).concat(r,t),parameters:e}},Kmn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Zmn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=Kmn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Qmn=Cr.extend({fn:z(),num_pins:Pe(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")}),Jmn=n=>{const e=Qmn.parse(n),t=Nr(0,ue.parse(e.h),.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:t1n(e).concat(r,t),parameters:e}},e1n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},t1n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=e1n({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},n1n=Cr.extend({fn:z(),num_pins:Pe(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")}),r1n=n=>{const e=n1n.parse(n),t=Nr(0,ue.parse(e.h),.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.1,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.1,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:o1n(e).concat(r,t),parameters:e}},i1n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},o1n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=i1n({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},s1n=Cr.extend({fn:z(),num_pins:Pe(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")}),a1n=n=>{const e=s1n.parse(n),t=Nr(0,ue.parse(e.h)/2+.5,.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.5,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.5,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:l1n(e).concat(r,t),parameters:e}},c1n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},l1n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=c1n({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},u1n=Cr.extend({fn:z(),num_pins:Pe(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")}),d1n=n=>{const e=u1n.parse(n),t=Nr(0,ue.parse(e.h)-.5,.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:p1n(e).concat(r,t),parameters:e}},h1n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},p1n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=h1n({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},f1n=Cr.extend({fn:z(),num_pins:Pe(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")}),m1n=n=>{const e=f1n.parse(n),t=Nr(0,ue.parse(e.h)/2+.5,.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.1,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.1,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:g1n(e).concat(r,t),parameters:e}},y1n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},g1n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=y1n({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},_1n=Cr.extend({fn:z(),num_pins:Pe(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")}),x1n=n=>{const e=_1n.parse(n),t=Nr(0,3,.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2-.8},{x:-ue.parse(e.w)/2-.8,y:ue.parse(e.h)/2-.8},{x:-ue.parse(e.w)/2-.8,y:-ue.parse(e.h)/2+.8},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:v1n(e).concat(r,t),parameters:e}},b1n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},v1n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=b1n({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},w1n=Cr.extend({fn:z(),num_pins:He().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()}),S1n=n=>{const e=n.string?.match(/^sot223_(\d+)/),t=e?Number.parseInt(e[1],10):4;if(t===8){const i=T1n.parse({...n,num_pins:t});return{circuitJson:yN(i),parameters:i}}const r=w1n.parse({...n,num_pins:t});if(r.num_pins===4)return{circuitJson:M1n(r),parameters:r};if(r.num_pins===5)return{circuitJson:P1n(r),parameters:r};if(r.num_pins===6)return{circuitJson:R1n(r),parameters:r};throw new Error("Invalid number of pins")},E1n=n=>{const{pn:e,w:t,p:r}=n;return e===1?{x:-t/2+1.1,y:r}:e===2?{x:-t/2+1.1,y:0}:e===3?{x:-t/2+1.1,y:-r}:{x:t/2-1.1,y:0}},M1n=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=E1n({num_pins:n.num_pins,pn:a+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl),p:Number.parseFloat(n.p)}),u=a===3?3.8:Number.parseFloat(n.pw);e.push(ar(a+1,c,l,Number.parseFloat(n.pl),u))}const t=Nr(0,0,.3),r=Number.parseFloat(n.w)/2-2.4,i=Number.parseFloat(n.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,t]},T1n=Q7({p:"0.90mm",w:"2.8mm",legsoutside:!0}),C1n=n=>{const{p:e,pn:t,w:r}=n;if(t===1)return{x:-r/2+1.2,y:e/2+e};if(t===2)return{x:-r/2+1.2,y:e/2};if(t===3)return{x:-r/2+1.2,y:-e/2};if(t===4)return{x:-r/2+1.2,y:-e/2-e};if(t===5)return{x:r/2-1,y:0};throw new Error("Invalid pin number")},P1n=n=>{const e=[];for(let a=1;a<=n.num_pins;a++){const{x:c,y:l}=C1n({h:Number.parseFloat(n.h),p:1.5,pn:a,w:Number.parseFloat(n.w)});let u=Number.parseFloat(n.pw),d=Number.parseFloat(n.pl);a===5?(u=3.4,d=1.8):(u=1,d=2.2),e.push(ar(a,c,l,d,u))}const t=Number.parseFloat(n.w)/2-2.4,r=Number.parseFloat(n.h)/2,i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t,y:r},{x:t,y:r},{x:t,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:-t,y:-r},{x:t,y:-r},{x:t,y:-r/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Nr(0,0,.3);return[...e,i,o,s]},A1n=n=>{const{p:e,pn:t,w:r}=n;if(t===1)return{x:-r/2+1.2,y:2*e};if(t===2)return{x:-r/2+1.2,y:e};if(t===3)return{x:-r/2+1.2,y:0};if(t===4)return{x:-r/2+1.2,y:-e};if(t===5)return{x:-r/2+1.2,y:-2*e};if(t===6)return{x:r/2-1.175,y:0};throw new Error("Invalid pin number")},R1n=n=>{const e=[];for(let a=1;a<=n.num_pins;a++){const{x:c,y:l}=A1n({h:Number.parseFloat(n.h),p:1.3,pn:a,w:8.7});let u=Number.parseFloat(n.pw),d=Number.parseFloat(n.pl);a===6?(u=3.4,d=2.15):(u=.6,d=2.2),e.push(ar(a,c,l,d,u))}const t=Number.parseFloat(n.w)/2-2.4,r=Number.parseFloat(n.h)/2,i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t,y:r},{x:t,y:r},{x:t,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:-t,y:-r},{x:t,y:-r},{x:t,y:-r/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Nr(0,0,.3);return[...e,i,o,s]},N1n=Cr.extend({fn:z(),num_pins:He().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()}),k1n=n=>{const e=n.string?.match(/^sot23w_(\d+)/),t=e?Number.parseInt(e[1],3):3,r=N1n.parse({...n,num_pins:t});if(r.num_pins===3)return{circuitJson:I1n(r),parameters:r};throw new Error("Invalid number of pins")},O1n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t,y:.95}:e===2?{x:-t,y:-.95}:{x:t,y:0}},I1n=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=O1n({num_pins:n.num_pins,pn:a+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl),p:Number.parseFloat(n.p)});e.push(ar(a+1,c,l,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=Nr(0,Number.parseInt(n.h)/2+1,.3),r=Number.parseFloat(n.w)/2-1,i=Number.parseFloat(n.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,t]},L1n=Cr.extend({fn:z(),num_pins:kn([Pe(3),Pe(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()}),D1n=n=>{const{p:e,id:t,od:r,w:i,h:o}=n,s=Number.parseFloat(o)/2,a=Number.parseFloat(e);return[_o(1,-a,s-a,t,r),_o(2,0,s-a,t,r),_o(3,a,s-a,t,r)]},z1n=n=>{const{p:e,id:t,od:r,h:i}=n,o=Number.parseFloat(i)/2,s=Number.parseFloat(e);return[_o(1,-s,o-s,t,r),_o(2,s,o-s,t,r)]},$1n=n=>{const e=n.string?.match(/^to92s_(\d+)/),t=e?Number.parseInt(e[1],10):3,r=L1n.parse({...n,num_pins:t});let i=[];if(r.num_pins===3)i=D1n(r);else if(r.num_pins===2)i=z1n(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}},F1n=Cr.extend({fn:z(),p:ue.optional(),id:ue.optional(),pw:ue.optional(),pl:ue.optional(),w:ue.optional(),h:ue.optional(),sh:Ie().optional().describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Ie().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),zh:Ie().optional().describe("JST ZH (Through-hole) connector family. 1.5mm pitch wire-to-board."),string:z().optional()}),B1n={ph:{p:ue.parse("2.2mm"),id:ue.parse("0.70mm"),pw:ue.parse("1.20mm"),pl:ue.parse("1.20mm"),w:ue.parse("6mm"),h:ue.parse("5mm")},sh:{p:ue.parse("1mm"),pw:ue.parse("0.6mm"),pl:ue.parse("1.55mm"),w:ue.parse("5.8mm"),h:ue.parse("7.8mm")},zh:{p:ue.parse("1.5mm"),id:ue.parse("0.73mm"),pw:ue.parse("1.03mm"),pl:ue.parse("1.73mm"),w:ue.parse("3mm"),h:ue.parse("3.5mm")}};function j1n(n){return n.sh?"sh":n.ph?"ph":n.zh?"zh":"ph"}function U1n(n,e,t,r,i,o){const s=[];if(n==="ph"){const a=-((e-1)/2)*t;for(let c=0;c<e;c++){const l=a+c*t;s.push(Yx({pn:c+1,x:l,y:2,holeDiameter:r,rectPadWidth:i,rectPadHeight:o}))}}else if(n==="zh"){const a=-((e-1)/2)*t;for(let c=0;c<e;c++){const l=a+c*t;c===0?s.push(Yx({pn:c+1,x:l,y:0,holeDiameter:r,rectPadWidth:i,rectPadHeight:o,rectBorderRadius:.12499977})):s.push(tw(c+1,l,0,r,i,o))}}else{const a=-((e-1)/2)*t;for(let l=0;l<e;l++){const u=a+l*t;s.push(ar(l+1,u,-1.325,i,o))}const c=(e-1)/2*t+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 H1n(n,e,t,r,i){if(n==="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(n==="zh"&&r&&i){const o=(r-1)*i,s=-o/2-1.5,a=o/2+1.5,c=-t/2,l=t/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 V1n=n=>{const e=F1n.parse(n),t=j1n(e),r=B1n[t],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=n.num_pins;typeof d=="number"&&(u=d);const h=typeof n.string=="string"?n.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=U1n(t,u,i,o,s,a),y=H1n(t,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:t==="sh",ph:t==="ph",zh:t==="zh"}}},Y1n=Cr.extend({fn:z(),num_pins:Pe(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")}),X1n=n=>{const e=Y1n.parse(n),t=Nr(0,ue.parse(e.h)/2+.5,.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:q1n(e).concat(r,t),parameters:e}},G1n=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},q1n=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=G1n({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},W1n=n=>{switch(n){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"}}},K1n=Cr.extend({fn:z(),num_pins:kn([Pe(8),Pe(10)]).default(8),w:z().optional(),h:z().optional(),p:z().optional(),pl:z().optional(),pw:z().optional(),string:z().optional()}),Z1n=n=>{const e=K1n.parse(n),t=W1n(e.num_pins),r=ue.parse(e.w||t.w),i=ue.parse(e.h||t.h),o=ue.parse(e.p||t.p),s=ue.parse(e.pl||t.pl),a=ue.parse(e.pw||t.pw),c=[],l=e.num_pins/2;for(let _=0;_<e.num_pins;_++){const{x:b,y:v}=IGe(e.num_pins,_+1,r,o),M=_<l?_+1:e.num_pins-(_-l);c.push(ar(M,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=IGe(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}},IGe=(n,e,t,r)=>{const i=n/2,o=(e-1)%i,s=e<=i?-1:1,a=(i-1)/2-o;return{x:s*ue.parse(n===8?"1.8mm":"2.2mm"),y:a*r}},Q1n=n=>{switch(n){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"}}},J1n=Cr.extend({fn:z(),num_pins:kn([Pe(8),Pe(10),Pe(12),Pe(16)]).default(8),w:z().optional(),h:z().optional(),p:z().optional(),pl:z().optional(),pw:z().optional(),string:z().optional()}),LGe=(n,e,t,r)=>{const i=n/2,o=(e-1)%i,s=e<=i?-1:1,a=(i-1)/2-o;return{x:s*ue.parse("2mm"),y:a*r}},eyn=n=>{const e=J1n.parse(n),t=Q1n(e.num_pins),r=ue.parse(e.w||t.w),i=ue.parse(e.h||t.h),o=ue.parse(e.p||t.p),s=ue.parse(e.pl||t.pl),a=ue.parse(e.pw||t.pw),c=[];for(let g=0;g<e.num_pins;g++){const{x:_,y:b}=LGe(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=LGe(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}},tyn=Cr.extend({fn:z(),num_pins:Pe(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")}),nyn=n=>{const e=tyn.parse(n),t=Nr(0,ue.parse(e.h),.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.pad_spacing)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:-ue.parse(e.h)/2},{x:ue.parse(e.pad_spacing)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:iyn(e).concat(r,t),parameters:e}},ryn=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},iyn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=ryn({pn:t,pad_spacing:Number.parseFloat(n.pad_spacing)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},oyn=Cr.extend({fn:z(),num_pins:Pe(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")}),syn=n=>{const e=oyn.parse(n),t=Nr(0,ue.parse(e.h),.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.pad_spacing)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.2,y:-ue.parse(e.h)/2},{x:ue.parse(e.pad_spacing)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:cyn(e).concat(r,t),parameters:e}},ayn=n=>{const{pn:e,pad_spacing:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},cyn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=ayn({pn:t,pad_spacing:Number.parseFloat(n.pad_spacing)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},lyn=Cr.extend({fn:z(),num_pins:kn([Pe(6),Pe(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:Ie().default(!1)}),uyn=n=>{n.string&&n.string.includes("_ep")&&(n.ep=!0);const e=n.string?.match(/^son_(\d+)/),t=e?Number.parseInt(e[1],10):n.num_pins||8,r=lyn.parse({...n,num_pins:t}),i=ue.parse(r.w),o=ue.parse(r.h),s=ue.parse(r.p),a=ue.parse(r.pl),c=ue.parse(r.pw),l=ue.parse(r.epw),u=ue.parse(r.eph),d=[];for(let v=0;v<r.num_pins;v++){const{x:M,y:E}=DGe(r.num_pins,v+1,i,s);d.push(ar(v+1,M,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=DGe(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}},DGe=(n,e,t,r)=>{const i=n/2,o=(e-1)%i,s=e<=i?-1:1,a=(i-1)/2-o;return{x:s*ue.parse("1.4mm"),y:a*r}},dyn=Cr.extend({fn:z(),num_pins:He().optional().default(8),p:Qe.describe("pitch (distance between center of each pin)"),w:ue.describe("width between vertical rows of pins"),grid:UU.describe("width and height of the border of the footprint"),ep:UU.default("0x0mm").describe("width and height of the central exposed thermal pad"),epx:ue.default("0mm").describe("x offset of the center of the central exposed thermal pad"),pinw:ue.describe("width of the pin pads"),pinh:ue.describe("height of the pin pads")}),hyn=n=>{const e=dyn.parse(n),{num_pins:t,p:r,w:i,grid:o,ep:s,epx:a,pinw:c,pinh:l}=e;if(t%2!==0)throw new Error("invalid number of pins");const u=[];for(let p=0;p<t;p++){const{pinX:f,pinY:m}=pyn({pinCount:t,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=fyn(o),h=Nr(0,o.y/2+r,o.y/6);return{circuitJson:[...u,...d,h],parameters:e}},pyn=n=>{let e=0,t=0;const r=(n.pinCount/2-1)*n.pitch/2,i=n.pinCount/2;return n.pinIndex+1<=i?(e=n.pitch*n.pinIndex-r,t=0-n.width/2):(e=n.pitch*(n.pinCount-n.pinIndex-1)-r,t=n.width/2),{pinX:t,pinY:e}},fyn=n=>{const t=n.y/30;return[{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-n.x/2-.1,y:n.y/2+.1-t},{x:-n.x/2-.1,y:n.y/2+.1},{x:n.x/2+.1,y:n.y/2+.1},{x:n.x/2+.1,y:n.y/2+.1-t}],stroke_width:n.y/30},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-n.x/2-.1,y:-n.y/2-.1+t},{x:-n.x/2-.1,y:-n.y/2-.1},{x:n.x/2+.1,y:-n.y/2-.1},{x:n.x/2+.1,y:-n.y/2-.1+t}],stroke_width:n.y/30}]},myn=n=>{const{num_pins:e,bridged:t,p:r=2.54,pw:i=1.5,ph:o=1.5}=n,s=ue.parse(r),a=ue.parse(i),c=ue.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(t){const v=t.split("").map(Number);if(v.length>1)for(let M=0;M<v.length-1;M++){const E=v[M],A=v[M+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:n}},zGe={fn:Pe("sot457"),num_pins:Pe(6).default(6),pillh:z().default("0.45mm"),pillw:z().default("1.45mm"),pl:z(),pw:z(),p:z(),wave:Ie().optional(),reflow:Ie().optional()},yyn=Cr.extend({...zGe,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")}),gyn=Cr.extend({...zGe,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(n=>({...n,wave:n.wave??(n.reflow===void 0?!0:!n.reflow),reflow:n.reflow??(n.wave===void 0?!1:!n.wave)})),Gb=n=>Number.parseFloat(n.replace("mm","")),$Ge=({pitch:n,width:e,pinNumber:t})=>{const o={1:{x:-e/2-.1,y:n},2:{x:-e/2-.1,y:0},3:{x:-e/2-.1,y:-n},4:{x:e/2+.1,y:-n},5:{x:e/2+.1,y:0},6:{x:e/2+.1,y:n}}[t];if(!o)throw new Error(`Invalid pin number: ${t}`);return o},FGe=n=>{const e=[],t=Gb(n.p),r=Gb(n.pl),i=Gb(n.pw),o=Gb(n.w),s=Gb(n.h);if(n.wave){const f={1:({padWidth:m,padHeight:y})=>ar(1,-t,t,y,m),2:({padWidth:m,padHeight:y})=>ar(2,-t,-t,y,m),3:({padWidth:m,padHeight:y})=>HU(3,-t,0,Gb(n.pillw),Gb(n.pillh)),4:({padWidth:m,padHeight:y})=>HU(4,t,0,Gb(n.pillw),Gb(n.pillh)),5:({padWidth:m,padHeight:y})=>ar(5,t,t,y,m),6:({padWidth:m,padHeight:y})=>ar(6,t,-t,y,m)};for(let m=1;m<=n.num_pins;m++){const y=f[m];y&&e.push(y({padWidth:r,padHeight:i}))}}else for(let f=1;f<=n.num_pins;f++){const{x:m,y}=$Ge({pitch:t,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+t/1.3},{x:o/3,y:s/2+t/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-t/1.3},{x:o/3,y:-s/2-t/1.3}],stroke_width:.05},l=Nr(0,s+.5,.3),u=$Ge({pitch:t,width:o,pinNumber:1}),d=n.wave?1:.5,h=n.wave?.7:.3;u.x-=n.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]},_yn=n=>{if(n.wave){const t=gyn.parse({...n,fn:"sot457"});return{circuitJson:FGe(t),parameters:t}}const e=yyn.parse(n);return{circuitJson:FGe(e),parameters:e}},xyn=Cr.extend({fn:z(),num_pins:Pe(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()}),byn=n=>{const e=xyn.parse({...n,fn:"sot963"}),t=ue.parse(e.w),r=ue.parse(e.h),i=ue.parse(e.p),o=ue.parse(e.pl),s=ue.parse(e.pw),a=[];for(let p=0;p<6;p++){const{x:f,y:m}=BGe(p+1,t,i,o);a.push(ar(p+1,f,m,o,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:r/2},{x:t/2,y:r/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:-r/2},{x:t/2,y:-r/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u=BGe(1,t,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}},BGe=(n,e,t,r)=>{const i=e/2-r/2;return n<=3?{x:-i,y:t-(n-1)*t}:{x:i,y:-t+(n-4)*t}},vyn=Cr.extend({fn:z(),num_pins:kn([Pe(3),Pe(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()}),wyn=n=>{const{p:e,id:t,od:r,h:i,ca:o}=n,s=Number.parseFloat(i),a=Number.parseFloat(o);return[_o(1,0,a/4+.3,t,r),_o(2,s,0,t,r),_o(3,0,-a/4-.3,t,r)]},Syn=n=>{const e=n.string?.match(/^potentiometer_(\d+)/),t=e?Number.parseInt(e[1],10):3,r=vyn.parse({...n,num_pins:t});let i=[];r.num_pins===3&&(i=wyn(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}},Eyn=Cr.extend({fn:z(),p:ue.optional().default("7.5mm"),id:ue.optional().default("1mm"),od:ue.optional().default("2mm"),d:ue.optional().default("10.5mm")}),Myn=(n,e,t,r,i)=>{const o=[],s=[];for(let a=0;a<=50;a++){const c=a/50*Math.PI,l=n+Math.cos(c)*t,u=e+Math.sin(c)*t;l<n-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=n+Math.cos(c)*t,u=e+Math.sin(c)*t;l<n-r&&u>=e-i/2&&u<=e+i/2||s.push({x:l,y:u})}return{topArc:o,bottomArc:s}},Tyn=n=>{const e=Eyn.parse(n),{p:t,id:r,od:i,d:o}=e,s=[_o(1,-t/2,0,r,i),_o(2,t/2,0,r,i)],{topArc:a,bottomArc:c}=Myn(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}},Cyn=Cr.extend({fn:z(),num_pins:Pe(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")}),Pyn=n=>{const e=Cyn.parse(n),t=Nr(0,ue.parse(e.h)-.5,.3),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:ue.parse(e.p)/2,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.3,y:ue.parse(e.h)/2},{x:-ue.parse(e.w)/2-.3,y:-ue.parse(e.h)/2},{x:ue.parse(e.p)/2,y:-ue.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Ryn(e).concat(r,t),parameters:e}},Ayn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t/2,y:0}:{x:t/2,y:0}},Ryn=n=>{const e=[];for(let t=1;t<=n.num_pins;t++){const{x:r,y:i}=Ayn({pn:t,p:Number.parseFloat(n.p)});e.push(ar(t,r,i,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}return e},Nyn=Cr.extend({fn:z(),num_pins:He().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()}),kyn=n=>{const e=n.string?.match(/^sot323_(\d+)/),t=e?Number.parseInt(e[1],3):3,r=Nyn.parse({...n,num_pins:t});if(r.num_pins===3)return{circuitJson:Iyn(r),parameters:r};throw new Error("Invalid number of pins")},Oyn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t,y:.65}:e===2?{x:-t,y:-.65}:{x:t,y:0}},Iyn=n=>{const e=[];for(let a=0;a<n.num_pins;a++){const{x:c,y:l}=Oyn({num_pins:n.num_pins,pn:a+1,w:Number.parseFloat(n.w),h:Number.parseFloat(n.h),pl:Number.parseFloat(n.pl),p:Number.parseFloat(n.p)});e.push(ar(a+1,c,l,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=Nr(0,Number.parseInt(n.h)/2+1,.3),r=Number.parseFloat(n.w)/2-Number.parseFloat(n.pl),i=Number.parseFloat(n.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,t]},Lyn=Cr.extend({fn:z(),circle:Ie().optional(),rect:Ie().optional(),square:Ie().optional(),pill:Ie().optional(),d:ue.optional(),pd:ue.optional(),diameter:ue.optional(),r:ue.optional(),pr:ue.optional(),radius:ue.optional(),w:ue.optional(),pw:ue.optional(),width:ue.optional(),h:ue.optional(),ph:ue.optional(),height:ue.optional(),s:ue.optional(),size:ue.optional(),string:z().optional()}).transform(n=>{let e="rect";n.circle&&(e="circle"),n.square&&(e="square"),n.rect&&(e="rect"),n.pill&&(e="pill");let t,r,i;return e==="circle"?n.r!==void 0?t=Bs(n.r):n.pr!==void 0?t=Bs(n.pr):n.radius!==void 0?t=Bs(n.radius):n.d!==void 0?t=Bs(n.d)/2:n.pd!==void 0?t=Bs(n.pd)/2:n.diameter!==void 0?t=Bs(n.diameter)/2:t=Bs("1mm")/2:(n.w!==void 0?r=Bs(n.w):n.pw!==void 0?r=Bs(n.pw):n.width!==void 0?r=Bs(n.width):n.s!==void 0?r=Bs(n.s):n.size!==void 0?r=Bs(n.size):r=Bs("1mm"),n.h!==void 0?i=Bs(n.h):n.ph!==void 0?i=Bs(n.ph):n.height!==void 0?i=Bs(n.height):e==="square"||e==="rect"?i=r:i=Bs("1mm")),{fn:n.fn,shape:e,radius:t,width:r,height:i}}),Dyn=n=>{const e=Lyn.parse(n),{shape:t,radius:r,width:i,height:o}=e;let s,a;return t==="circle"?(s=_Ge(1,{x:0,y:0,radius:r}),a=r+.5):t==="pill"?(s=HU(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}},zyn=Cr.extend({fn:z(),d:ue.optional(),hd:ue.optional(),r:ue.optional(),hr:ue.optional(),pd:ue.optional(),pr:ue.optional(),squarepad:Ie().optional().default(!1)}).transform(n=>{let e;n.d!==void 0?e=Bs(n.d):n.hd!==void 0?e=Bs(n.hd):n.r!==void 0?e=Bs(n.r)*2:n.hr!==void 0?e=Bs(n.hr)*2:e=Bs("1mm");let t;return n.pd!==void 0?t=Bs(n.pd):n.pr!==void 0?t=Bs(n.pr)*2:t=e*(1.5/1),{fn:n.fn,d:e,pd:t,squarepad:n.squarepad??!1}}),$yn=n=>{const e=zyn.parse(n),{d:t,pd:r,squarepad:i}=e;return{circuitJson:[i?Yx({pn:1,x:0,y:0,holeDiameter:t,rectPadWidth:r,rectPadHeight:r}):_o(1,0,0,t,r),Nr(0,r/2+.5,.2)],parameters:e}},Fyn=Cr.extend({fn:z(),num_pins:Pe(6).default(6),h:z().default("1.6mm"),pl:z().default("1mm"),pw:z().default("0.7mm"),p:z().default("0.95mm")}),Byn=n=>{const e=Fyn.parse(n);return{circuitJson:jyn(e),parameters:e}},jGe=n=>{const{p:e,h:t,pn:r}=n;if(r===1)return{x:-t/2-.5,y:e};if(r===2)return{x:-t/2-.5,y:0};if(r===3)return{x:-t/2-.5,y:-e};if(r===4)return{x:t/2+.5,y:-e};if(r===5)return{x:t/2+.5,y:0};if(r===6)return{x:t/2+.5,y:e};throw new Error("Invalid pin number")},jyn=n=>{const e=[];for(let d=1;d<=n.num_pins;d++){const{x:h,y:p}=jGe({h:Number.parseFloat(n.h),p:Number.parseFloat(n.p),pn:d});e.push(ar(d,h,p,Number.parseFloat(n.pl),Number.parseFloat(n.pw)))}const t=n.num_pins/2*Number.parseFloat(n.p),r=Number.parseFloat(n.h),i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t/3,y:r/2+Number.parseFloat(n.p)/1.3},{x:t/3,y:r/2+Number.parseFloat(n.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:-t/3,y:-r/2-Number.parseFloat(n.p)/1.3},{x:t/3,y:-r/2-Number.parseFloat(n.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Nr(0,r+.3,.3),a=jGe({h:Number.parseFloat(n.h),p:Number.parseFloat(n.p),pn:1});a.x=a.x-Number.parseFloat(n.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]},Uyn=Cr.extend({fn:z(),num_pins:He().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()}),Hyn=n=>{const e=n.string?.match(/^sot343_(\d+)/),t=e?Number.parseInt(e[1],4):4,r=Uyn.parse({...n,num_pins:t});if(r.num_pins===4)return{circuitJson:Yyn(r),parameters:r};throw new Error("Invalid number of pins")},Vyn=n=>{const{pn:e,p:t}=n;return e===1?{x:-t*1.92,y:-.65}:e===2?{x:-t*1.92,y:.65}:e===3?{x:t,y:.65}:e===4?{x:t,y:-.65}:{x:0,y:0}},Yyn=n=>{const e=[],t=Number.parseFloat(n.w),r=Number.parseFloat(n.h),i=Number.parseFloat(n.pl),o=Number.parseFloat(n.pw),s=Number.parseFloat(n.p);let a=1/0,c=-1/0,l=1/0,u=-1/0;for(let b=0;b<n.num_pins;b++){const{x:v,y:M}=Vyn({num_pins:n.num_pins,pn:b+1,p:s});e.push(ar(b+1,v,M,i,o)),v<a&&(a=v),v>c&&(c=v),M<l&&(l=M),M>u&&(u=M)}const d=(a+c)/2,h=u-l,p=r*.3,f=h/2+p;let m=t*.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]},Xyn=Cr.extend({fn:z()}),Gyn=n=>{const e=Xyn.parse(n),t=[],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,j=ar(P,B,N,D,r);j.layer=C?"bottom":"top",t.push(j)}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 t){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,M=(g+_)/2,E=A=>{typeof A.x=="number"&&(A.x-=v),typeof A.y=="number"&&(A.y-=M),A.center&&(A.center.x-=v,A.center.y-=M),Array.isArray(A.route)&&(A.route=A.route.map(P=>({x:P.x-v,y:P.y-M})))};for(const A of t)E(A);return E(h),E(f),{circuitJson:[...t,h,f],parameters:e}},qyn=Cr.extend({fn:z(),numPins:He().optional().default(0),rows:kn([z(),He()]).transform(n=>Number(n)).optional().default(1).describe("number of rows"),p:ue.default("2.54mm").describe("pitch"),id:ue.default("1.0mm").describe("inner diameter"),od:ue.default("1.5mm").describe("outer diameter"),male:Ie().optional().describe("the module uses male headers"),nopin:Ie().optional().default(!1).describe("omit pins rendering"),female:Ie().optional().describe("the module uses female headers"),smd:Ie().optional().describe("surface mount device"),pinlabeltextalignleft:Ie().optional().default(!1),pinlabeltextaligncenter:Ie().optional().default(!1),pinlabeltextalignright:Ie().optional().default(!1),pinlabelverticallyinverted:Ie().optional().default(!1),pinlabelorthogonal:Ie().optional().default(!1),nopinlabels:Ie().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Ie().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Ie().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:Ie().optional().default(!1),pinrowright:Ie().optional().default(!1),pinrowtop:Ie().optional().default(!1),pinrowbottom:Ie().optional().default(!1),pinrowleftpins:kn([z(),He()]).transform(n=>Number(n)).optional(),pinrowrightpins:kn([z(),He()]).transform(n=>Number(n)).optional(),pinrowtoppins:kn([z(),He()]).transform(n=>Number(n)).optional(),pinrowbottompins:kn([z(),He()]).transform(n=>Number(n)).optional(),width:ue.optional(),height:ue.optional(),pinRowHoleEdgeToEdgeDist:ue.default("2mm"),holes:kn([z(),bt(z())]).optional().transform(n=>!n||Array.isArray(n)?n:n.startsWith("(")&&n.endsWith(")")?n.slice(1,-1).split(",").map(e=>e.trim()):[n]),holeXDist:ue.optional(),holeYDist:ue.optional(),holeInset:ue.default("1mm"),pinrow:kn([z(),He()]).optional(),usbposition:Gt(["left","right","top","bottom"]).optional().default("left"),usbleft:Ie().optional().default(!1),usbtop:Ie().optional().default(!1),usbright:Ie().optional().default(!1),usbbottom:Ie().optional().default(!1),usbtype:Gt(["micro","c"]).optional(),usbmicro:Ie().optional().default(!1),usbc:Ie().optional().default(!1),screen:Ie().optional().default(!1).describe("add silkscreen outline for screen/display area"),screenwidth:ue.optional(),screenheight:ue.optional(),screencenteroffsetx:ue.optional(),screencenteroffsety:ue.optional()}).transform(n=>{const e=CGe(n);let t=n.pinRowSide;n.pinrowleft&&(t="left"),n.pinrowright&&(t="right"),n.pinrowtop&&(t="top"),n.pinrowbottom&&(t="bottom");let r=n.usbposition;n.usbleft&&(r="left"),n.usbtop&&(r="top"),n.usbright&&(r="right"),n.usbbottom&&(r="bottom");let i=n.usbtype;n.usbmicro&&(i="micro"),n.usbc&&(i="c"),n.pinrow!==void 0&&(n.numPins=Number(n.pinrow));const o={left:n.pinrowleftpins,right:n.pinrowrightpins,top:n.pinrowtoppins,bottom:n.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?t="left":(o.right??0)>0?t="right":(o.top??0)>0?t="top":(o.bottom??0)>0&&(t="bottom"),n.numPins=(o.left??0)+(o.right??0)+(o.top??0)+(o.bottom??0));const l=Math.ceil(n.numPins/n.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?n.p:0,M=c?n.p:0;h=(d>0?(d-1)*n.p:0)+2*n.pinRowHoleEdgeToEdgeDist+v,p=(u>0?(u-1)*n.p:0)+2*n.pinRowHoleEdgeToEdgeDist+M}else t==="left"||t==="right"?(h=(n.rows-1)*n.p+2*n.pinRowHoleEdgeToEdgeDist,p=(l-1)*n.p+2*n.pinRowHoleEdgeToEdgeDist):(p=(n.rows-1)*n.p+2*n.pinRowHoleEdgeToEdgeDist,h=(l-1)*n.p+2*n.pinRowHoleEdgeToEdgeDist);n.numPins===0&&(h=10,p=10);const f=n.width??h,m=n.height??p,y=n.screenwidth??f*.95,g=n.screenheight??m*.95,_=n.screencenteroffsetx??0,b=n.screencenteroffsety??0;return{...n,pinlabelAnchorSide:e,pinRowSide:t,usbposition:r,usbtype:i,male:n.male??!n.female,female:n.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((n,e)=>{n.male&&n.female&&e.addIssue({code:qn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),Wyn=n=>{const e=qyn.parse(n),{p:t,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:M,holeInset:E,pinrowleftpins:A,pinrowrightpins:P,pinrowtoppins:N,pinrowbottompins:C,usbposition:D,usbtype:I,screen:B,screenwidth:j,screenheight:U,screencenteroffsetx:G,screencenteroffsety:K}=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(ae=>ae!==void 0&&ae>0),se=(ae,ye,Te,Me)=>{if(e.smd?re.push(ar(ae,ye,Te,e.od,e.od)):ae===1?re.push(Yx({pn:ae,x:ye,y:Te,holeDiameter:r,rectPadWidth:i,rectPadHeight:i})):re.push(_o(ae,ye,Te,r,i)),!h){const $e=ye+(Me==="left"?-i:Me==="right"?i:0),me=Te+(Me==="top"?i:Me==="bottom"?-i:0);f||re.push(J7({fs:i/5,pn:ae,anchor_x:$e,anchor_y:me,textalign:ee,orthogonal:l,verticallyinverted:c,layer:"top"})),(p||f)&&re.push(J7({fs:i/5,pn:ae,anchor_x:$e,anchor_y:me,textalign:ee,orthogonal:l,verticallyinverted:c,layer:"bottom"}))}};if(ie){const ae=t;let ye=1;const Te=pe.left??0,Me=pe.right??0,$e=pe.top??0,me=pe.bottom??0,Ee=(_e,Fe)=>{if(!(Fe<=0))if(_e==="left"||_e==="right"){const Ve=_e==="left"?-y/2+_:y/2-_,it=(Fe-1)/2*ae;for(let xe=0;xe<Fe;xe++)se(ye,Ve,it-xe*ae,_e),ye++}else{const Ve=_e==="top"?g/2-_:-g/2+_,it=-((Fe-1)/2)*ae;for(let xe=0;xe<Fe;xe++)se(ye,it+xe*ae,Ve,_e),ye++}};Ee("left",Te),Ee("right",Me),Ee("top",$e),Ee("bottom",me)}else{const ae=t;let ye=0,Te=0,Me=0,$e=0,me=0,Ee=0;const _e=Math.ceil(s/o);m==="left"||m==="right"?(ye=m==="left"?-y/2+_:y/2-_,Te=(_e-1)/2*ae,Me=0,$e=-ae,me=m==="left"?ae:-ae,Ee=0):(ye=-(_e-1)/2*ae,Te=m==="top"?g/2-_:-g/2+_,Me=ae,$e=0,me=0,Ee=m==="top"?-ae:ae);let Fe=1;for(let Ve=0;Ve<o&&Fe<=s;Ve++)for(let it=0;it<_e&&Fe<=s;it++){const xe=ye+it*Me+Ve*me,nt=Te+it*$e+Ve*Ee;if(e.smd?re.push(ar(Fe,xe,nt,e.od,e.od)):Fe===1?re.push(Yx({pn:Fe,x:xe,y:nt,holeDiameter:r,rectPadWidth:i,rectPadHeight:i})):re.push(_o(Fe,xe,nt,r,i)),!h){const Ue=xe+(m==="left"?-i:m==="right"?i:0),De=nt+(m==="top"?i:m==="bottom"?-i:0);f||re.push(J7({fs:i/5,pn:Fe,anchor_x:Ue,anchor_y:De,textalign:ee,orthogonal:l,verticallyinverted:c,layer:"top"})),(p||f)&&re.push(J7({fs:i/5,pn:Fe,anchor_x:Ue,anchor_y:De,textalign:ee,orthogonal:l,verticallyinverted:c,layer:"bottom"}))}Fe++}}if(b)for(const ae of b){let ye=0,Te=0;ae==="topleft"?(ye=-y/2+E,Te=g/2-E):ae==="topright"?(ye=y/2-E,Te=g/2-E):ae==="bottomleft"?(ye=-y/2+E,Te=-g/2+E):ae==="bottomright"?(ye=y/2-E,Te=-g/2+E):ae==="center"&&(ye=0,Te=0),v!==void 0&&(ye+=v),M!==void 0&&(Te+=M),re.push(_o(s+b.indexOf(ae)+1,ye,Te,r,i))}if(!e.nosilkscreen){const ae=[{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(ew(ae,{stroke_width:.1,layer:"top"}))}const le=Nr(0,g/2+1,.5);if(re.push(le),D&&I){let ae,ye;if(I==="c")ae=8,ye=3;else if(I==="micro")ae=6,ye=2;else return{circuitJson:re,parameters:e};let Te;if(D==="left")Te=[{x:-y/2,y:-ae/2},{x:-y/2+ye,y:-ae/2},{x:-y/2+ye,y:ae/2},{x:-y/2,y:ae/2},{x:-y/2,y:-ae/2}];else if(D==="right")Te=[{x:y/2-ye,y:-ae/2},{x:y/2,y:-ae/2},{x:y/2,y:ae/2},{x:y/2-ye,y:ae/2},{x:y/2-ye,y:-ae/2}];else if(D==="top")Te=[{x:-ae/2,y:g/2-ye},{x:ae/2,y:g/2-ye},{x:ae/2,y:g/2},{x:-ae/2,y:g/2},{x:-ae/2,y:g/2-ye}];else if(D==="bottom")Te=[{x:-ae/2,y:-g/2},{x:ae/2,y:-g/2},{x:ae/2,y:-g/2+ye},{x:-ae/2,y:-g/2+ye},{x:-ae/2,y:-g/2}];else return{circuitJson:re,parameters:e};re.push(ew(Te,{stroke_width:.1,layer:"top"}))}if(B){const ae=j/2,ye=U/2,Te=G,Me=K,$e=[{x:-ae+Te,y:-ye+Me},{x:ae+Te,y:-ye+Me},{x:ae+Te,y:ye+Me},{x:-ae+Te,y:ye+Me},{x:-ae+Te,y:-ye+Me}];re.push(ew($e,{stroke_width:.05,layer:"top"}))}return{circuitJson:re,parameters:e}},Kyn=Cr.extend({fn:z(),num_pins:He().default(3),inline:Ie().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")}),Zyn=n=>{const e=Kyn.parse(n),t=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=[Yx({pn:1,x:0,y:0,holeDiameter:e.id,rectPadWidth:o,rectPadHeight:s}),e.inline?tw(2,t,0,Number.parseFloat(e.id),o,s):_o(2,t,t,e.id,o),e.inline?tw(3,t*2,0,Number.parseFloat(e.id),o,s):_o(3,t*2,0,e.id,o)],c=r/2,l=e.inline?t-.09:t,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}},Qyn=(n,e)=>{const t=n.filter(r=>r.type==="pcb_silkscreen_text");if(t.length===0)return n;for(const r of t)e.norefdes&&(r.text="");return n},Jyn=(n,e)=>e.nosilkscreen?n.filter(t=>t.type!=="pcb_silkscreen_path"&&t.type!=="pcb_silkscreen_text"):n,egn=(n,e)=>{if(!e)return n;const t=n.filter(u=>u.type==="pcb_smtpad"||u.type==="pcb_plated_hole"||u.type==="pcb_thtpad");if(t.length===0)return n;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 t)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=t.find(d=>d.port_hints?.[0]==="1")||t[0];c=u.x,l=u.y;break}}if(c===0&&l===0)return n;for(const u of n){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 n};function tgn(n){return n!=null}var ngn=n=>n.trim().replace(/^sot-223-(\d+)(?=_|$)/i,"sot223_$1").replace(/^to-220f-(\d+)(?=_|$)/i,"to220f_$1"),rgn=n=>{let e=XU();const t=ngn(n),i=t.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(tgn);for(const{fn:o,v:s}of i)e=e[o](s);return e.setString(t),e},ign=()=>Object.keys(Xb),XU=()=>{const n=new Proxy({},{get:(e,t)=>{if(t==="soup"||t==="circuitJson"){if("fn"in e&&Xb[e.fn])return()=>{const{circuitJson:r}=Xb[e.fn](e),i=Jyn(r,e),o=Qyn(i,e);return egn(o,e.origin)};if(!Xb[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 "${t}"`)}}if(t==="json"){if(!Xb[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>Xb[e.fn](e).parameters}return t==="getFootprintNames"?()=>Object.keys(Xb):t==="params"?()=>e:t==="setString"?r=>(e.string=r,n):r=>(Object.keys(e).length===0?`${t}${r}`in Xb?(e[`${t}${r}`]=!0,e.fn=`${t}${r}`):(e[t]=!0,e.fn=t,t==="res"||t==="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(t)||(e[t]=r??!0),n)}});return n};XU.string=rgn,XU.getFootprintNames=ign;var ogn=XU,UGe=Symbol("Fragment");function Npe(n,e,...t){const r=t.length?t: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:n,props:(e&&e.children!==void 0?{...e,children:void 0}:e)||{},children:i}}var hn=Symbol("Cuboid"),HGe=Symbol("Cube"),oh=Symbol("Cylinder"),GU=Symbol("Sphere"),gN=Symbol("RoundedCuboid"),Br=Symbol("Translate"),m0=Symbol("Rotate"),Zp=Symbol("Union"),Xx=Symbol("Subtract"),Yl=Symbol("Hull"),uo=Symbol("Colorize"),_N=Symbol("Polygon"),xN=Symbol("ExtrudeLinear"),y_=Symbol("RoundedCylinder"),Ri=UGe,Xe=(n,e,t)=>Npe(n,e),Un=(n,e,t)=>Npe(n,e),kh=({center:n,width:e,length:t,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,t)*s,b=Math.max(e-_,e*a),v=Math.max(t-_,t*a),M=Math.min(e,t)*.12,E=u??M,A={x:0,y:t/2-E*.25,z:r},P=d??A,N=Un(Zp,{children:[Un(Yl,{children:[Xe(Br,{z:.005,children:Xe(hn,{size:[b,v,.01]})}),Xe(Br,{z:y,children:Xe(hn,{size:[e,t,.01]})})]}),Un(Yl,{children:[Xe(Br,{z:y,children:Xe(hn,{size:[e,t,.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(m0,{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=t/2;D=Un(Xx,{children:[N,C(I,B),C(-I,B),C(I,-B),C(-I,-B)]})}return Xe(uo,{color:o,children:Xe(Br,{offset:n,children:Xe(Br,{offset:{x:0,y:0,z:i},children:l?Un(Xx,{children:[D,Xe(Br,{offset:P,children:Xe(m0,{rotation:h,children:Xe(oh,{radius:E,height:f})})})]}):D})})})},sgn=n=>Array.from({length:n},(e,t)=>t);function kpe(n,e){if(n.length<2)throw new Error("Stroke must have at least two points");const t=Array.isArray(n[0])?n.map(([u,d])=>({x:u,y:d})):n,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(t[0],t[1]);a(t[0],c,1),a(t[0],c,-1);for(let u=1;u<t.length-1;u++){const d=t[u-1],h=t[u],p=t[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(t[t.length-2],t[t.length-1]);return a(t[t.length-1],l,1),a(t[t.length-1],l,-1),[...i,...o]}var agn=n=>{const e=Math.min(...n.map(a=>a.x)),t=Math.max(...n.map(a=>a.x)),r=Math.min(...n.map(a=>a.y)),s=5.47/(Math.max(...n.map(a=>a.y))-r);return n.map(a=>({x:(a.x-e-(t-e)/2)*s,y:(a.y-r)*s}))},cgn=agn([{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}]),VGe=5.47,qU=.5,lgn=({x:n,y:e,z:t})=>{const r=n>0;return Un(Ri,{children:[Xe(Br,{offset:{x:n+.25/2,y:e,z:t},children:Xe(m0,{rotation:["-90deg",0,"90deg"],children:Xe(xN,{height:.25,children:Xe(_N,{points:cgn.slice().reverse().map(i=>[i.x,i.y])})})})}),Xe(Br,{offset:{x:n,y:e+(r?1:-1),z:t},children:Xe(m0,{rotation:["-90deg","90deg",r?"180deg":"0deg"],children:Xe(xN,{height:2,children:Xe(_N,{points:kpe([[0,0],[-1,0],[-1,-1]],.25).map(i=>[i.x,i.y])})})})})]})},ugn=({numPins:n=8,pitch:e=2.54,bodyWidth:t=6.4,rowSpacing:r})=>{const i=Math.floor(n/2),o=r??(t>=7?t:t+1.22),s=t>=7?o-1.22:t;return Un(Ri,{children:[sgn(n).map(a=>{const c=a%i,l=(Math.floor(a/i)-.5)*2;return Xe(lgn,{x:l*o/2,y:c*e-(i-1)/2*e,z:VGe/2+qU})}),Xe(kh,{width:s,length:i*e+.5,height:VGe-qU,heightAboveSurface:qU,center:{x:0,y:0,z:qU}})]})};function dgn(n,{height:e,padContactLength:t,curveLength:r,bodyDistance:i,steepness:o=10}){r||(r=i*.3);let s=i-t-r;s<0&&(r+=s,s=0);const a=t*.75,c=t+r+(i-t-r)*.25;if(n<=a)return 0;if(n>=c)return e;const l=(n-a)/(c-a);return e/(1+Math.exp(-o*(l-.5)))}var Xi=n=>{const{thickness:e,width:t,padContactLength:r,bodyDistance:i,height:o,rotation:s}=n,a=15,c=Array.from({length:a}).map((u,d)=>d/(a-1)*i).map(u=>[u,dgn(u,n)]),l=kpe(c,e);return Xe(uo,{color:"#fff",children:Xe(Br,{offset:{z:0,y:0,x:0,...n.position},children:Xe(m0,{rotation:["90deg",0,s??0],children:Xe(Br,{offset:{x:0,y:0,z:-t/2},children:Xe(xN,{height:t,children:Xe(_N,{points:l.map(u=>[u.x,u.y])})})})})})})},hgn=({pinCount:n,leadLength:e,leadWidth:t,pitch:r,bodyWidth:i})=>{const o=Math.ceil(n/2),s=r*n/2+t/2,a=(o-1)*r/2,c=.25;return Un(Ri,{children:[Array.from({length:o}).map((l,u)=>Xe(Xi,{position:{x:-i/2-e,y:u*r-a,z:c/2},width:t,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Array.from({length:o}).map((l,u)=>Xe(Xi,{rotation:Math.PI,position:{x:i/2+e,y:u*r-a,z:c/2},width:t,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Xe(kh,{center:{x:0,y:0,z:c/2},width:i-t-1,length:s,height:1.5})]})},pgn=({pinCount:n,padContactLength:e=.4,leadWidth:t=.2,pitch:r=.65,bodyWidth:i=3})=>{const o=Math.ceil(n/2),s=(o-1)*r/2,a=.2;return Un(Ri,{children:[Array.from({length:o}).map((c,l)=>Xe(Xi,{position:{x:-i/2-e-.3,y:l*r-s,z:a/2},width:t,thickness:a,padContactLength:e,bodyDistance:e+.4,height:.6})),Array.from({length:o}).map((c,l)=>Xe(Xi,{rotation:Math.PI,position:{x:i/2+e+.3,y:l*r-s,z:a/2},width:t,thickness:a,padContactLength:e,bodyDistance:e+.4,height:.6})),Xe(kh,{center:{x:0,y:0,z:a/2},width:i,length:i,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},Ope=1,Ipe=.5,dT=.5,bN=.2,fgn=Ope-bN*2,YGe=({color:n="#333"})=>Un(Ri,{children:[Xe(hn,{size:[fgn,Ipe,dT],offset:[0,0,dT/2],color:n}),Xe(hn,{size:[bN,dT,Ipe],offset:[Ope/2-bN/2,0,dT/2],color:"#ccc"}),Xe(hn,{size:[bN,dT,Ipe],offset:[-Ope/2+bN/2,0,dT/2],color:"#ccc"})]}),Lpe=1.6,mgn=Lpe-.3*2,WU=.3,Dpe=.85,hT=.6,XGe=({color:n="#333"})=>Un(Ri,{children:[Xe(hn,{size:[mgn,Dpe,hT],offset:[0,0,hT/2],color:n}),Xe(hn,{size:[WU,Dpe,hT],offset:[Lpe/2-WU/2,0,hT/2],color:"#ccc"}),Xe(hn,{size:[WU,Dpe,hT],offset:[-Lpe/2+WU/2,0,hT/2],color:"#ccc"})]}),zpe=2,$pe=1.25,pT=.55,vN=.5,ygn=zpe-vN*2,GGe=({color:n="#333"})=>Un(Ri,{children:[Xe(hn,{size:[ygn,$pe,pT],offset:[0,0,pT/2],color:n}),Xe(hn,{size:[vN,$pe,pT],offset:[zpe/2-vN/2,0,pT/2],color:"#ccc"}),Xe(hn,{size:[vN,$pe,pT],offset:[-zpe/2+vN/2,0,pT/2],color:"#ccc"})]}),ggn=({pinCount:n,pitch:e,leadWidth:t,padContactLength:r,bodyWidth:i})=>{const o=n/4;e||(e=_gn(n,i)),r||(r=xgn(n)),t||(t=bgn(n,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(Ri,{children:[Array.from({length:o}).map((p,f)=>Xe(Xi,{position:{x:-l/2-.4,y:f*e-a,z:d/2},width:t,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Array.from({length:o}).map((p,f)=>Xe(Xi,{rotation:Math.PI,position:{x:l/2+.4,y:f*e-a,z:d/2},width:t,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Array.from({length:o}).map((p,f)=>Xe(Xi,{rotation:Math.PI/2,position:{x:f*e-a,y:-c/2-.4,z:d/2},width:t,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Array.from({length:o}).map((p,f)=>Xe(Xi,{rotation:-Math.PI/2,position:{x:f*e-a,y:c/2+.4,z:d/2},width:t,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Xe(kh,{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})]})},_gn=(n,e)=>{switch(n){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},xgn=n=>{switch(n){case 32:return .6;case 40:return .6;case 52:case 64:return .65;case 208:return 1.65;default:return .6}},bgn=(n,e)=>{switch(n){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},qGe=({x:n,y:e,pinThickness:t,shortSidePinLength:r,longSidePinLength:i,bodyHeight:o,bodyLength:s=2.54,bodyWidth:a=2.54,flipZ:c,faceup:l,smd:u,rightangle:d})=>Un(Ri,{children:[Xe(Br,{y:d?-3:0,children:Xe(hn,{color:"#222",size:[s,a,o],center:[n,e,c(o/2)]})}),!l&&Xe(uo,{color:"gold",children:u?Xe(Xi,{rotation:-Math.PI/2,position:{x:n,y:e+1,z:t/2},thickness:t,width:t,height:t,padContactLength:2,bodyDistance:3}):Un(Yl,{children:[Xe(hn,{color:"gold",size:[t,t,r*.9],center:[n,e,c(o*.9+o/2)]}),Xe(hn,{color:"gold",size:[t/1.8,t/1.8,r],center:[n,e,c(o+o/2)]})]})}),Xe(uo,{color:"gold",children:Xe(Br,{y:d?-3.9:0,z:d?1:0,children:Xe(m0,{rotation:d?[-Math.PI/2,0,0]:[0,0,0],children:Un(Yl,{children:[Xe(hn,{color:"gold",size:[t,t,i*.9],center:[n,e,c(-i/2*.9)]}),Xe(hn,{color:"gold",size:[t/1.8,t/1.8,i],center:[n,e,c(-i/2)]})]})})})})]}),vgn=({numberOfPins:n,pitch:e=2.54,longSidePinLength:t=6,invert:r,faceup:i,rows:o=1,smd:s,rightangle:a})=>{const u=Math.ceil(n/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(Ri,{children:Array.from({length:n},(y,g)=>{const _=Math.floor(g/u),b=g%u,v=p+b*e,M=-_*d;return Xe(qGe,{x:v,y:M,pinThickness:.63,shortSidePinLength:h,longSidePinLength:t,bodyHeight:2,flipZ:m,faceup:i,smd:s,rightangle:a},g)})})},wgn=n=>{const e=["left","bottom","right","top"],{pin_count:t,pn:r,w:i,h:o,p:s,pl:a}=n,c=t/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")}},Sgn=({num_pins:n,cw:e,ccw:t,startingpin:r})=>{const i=[],o=n/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<n;c++)i[s]=c+1,s++,s>n&&(s=1);return i},Egn=({num_pins:n=16,bodyWidth:e=9,bodyLength:t=9,bodyThickness:r=.8,thermalPadSize:i,padWidth:o=.25,padLength:s=.25,pitch:a=.5,thermalPadThickness:c=.05})=>{const l=Sgn({num_pins:n,cw:!0,ccw:!0}),u=[];for(let d=0;d<n;d++){const{x:h,y:p,o:f}=wgn({pin_count:n,pn:d+1,w:e,h:t,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(Ri,{children:[Xe(uo,{color:"grey",children:Xe(hn,{center:{x:0,y:0,z:r/2},size:[e,t,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]})]})},Mgn=Egn,Tgn=()=>{const c=1.1999999999999997;return Un(Ri,{children:[Xe(Xi,{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(Xi,{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(Xi,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Xe(Xi,{position:{x:-2.8/2-c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Xe(Xi,{position:{x:-2.8/2-c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Xe(kh,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},Cgn=Tgn,Pgn=({fullWidth:n=2.9,fullLength:e=2.8})=>{const u=(n-1.92)/2+.3;return Un(Ri,{children:[Xe(Xi,{rotation:Math.PI,position:{x:n/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:u,height:.45}),Xe(Xi,{position:{x:-n/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:u,height:.45}),Xe(Xi,{position:{x:-n/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:u,height:.45}),Xe(kh,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},Fpe=.6,Bpe=.3,fT=.33,wN=.1,Agn=Fpe-wN*2,WGe=({color:n="#333"})=>Un(Ri,{children:[Xe(hn,{size:[Agn,Bpe,fT],offset:[0,0,fT/2],color:n}),Xe(hn,{size:[wN,Bpe,fT],offset:[Fpe/2-wN/2,0,fT/2],color:"#ccc"}),Xe(hn,{size:[wN,Bpe,fT],offset:[-Fpe/2+wN/2,0,fT/2],color:"#ccc"})]}),jpe=.4,Upe=.2,mT=.13,SN=.07,Rgn=jpe-SN*2,KGe=({color:n="#333"})=>Un(Ri,{children:[Xe(hn,{size:[Rgn,Upe,mT],offset:[0,0,mT/2],color:n}),Xe(hn,{size:[SN,Upe,mT],offset:[jpe/2-SN/2,0,mT/2],color:"#ccc"}),Xe(hn,{size:[SN,Upe,mT],offset:[-jpe/2+SN/2,0,mT/2],color:"#ccc"})]}),Hpe=3.2,Vpe=1.6,yT=.9,EN=.5,Ngn=Hpe-EN*2,ZGe=({color:n="#333"})=>Un(Ri,{children:[Xe(hn,{size:[Ngn,Vpe,yT],offset:[0,0,yT/2],color:n}),Xe(hn,{size:[EN,Vpe,yT],offset:[Hpe/2-EN/2,0,yT/2],color:"#ccc"}),Xe(hn,{size:[EN,Vpe,yT],offset:[-Hpe/2+EN/2,0,yT/2],color:"#ccc"})]}),Ype=3.2,Xpe=2.5,gT=1,MN=.6,kgn=Ype-MN*2,QGe=({color:n="#333"})=>Un(Ri,{children:[Xe(hn,{size:[kgn,Xpe,gT],offset:[0,0,gT/2],color:n}),Xe(hn,{size:[MN,Xpe,gT],offset:[Ype/2-MN/2,0,gT/2],color:"#ccc"}),Xe(hn,{size:[MN,Xpe,gT],offset:[-Ype/2+MN/2,0,gT/2],color:"#ccc"})]}),Gpe=5,qpe=2.5,_T=1.4,TN=.6,Ogn=Gpe-TN*2,JGe=({color:n="#333"})=>Un(Ri,{children:[Xe(hn,{size:[Ogn,qpe,_T],offset:[0,0,_T/2],color:n}),Xe(hn,{size:[TN,qpe,_T],offset:[Gpe/2-TN/2,0,_T/2],color:"#ccc"}),Xe(hn,{size:[TN,qpe,_T],offset:[-Gpe/2+TN/2,0,_T/2],color:"#ccc"})]}),Wpe=6.3,Kpe=3.2,xT=1.8,CN=.8,Ign=Wpe-CN*2,eqe=({color:n="#333"})=>Un(Ri,{children:[Xe(hn,{size:[Ign,Kpe,xT],offset:[0,0,xT/2],color:n}),Xe(hn,{size:[CN,Kpe,xT],offset:[Wpe/2-CN/2,0,xT/2],color:"#ccc"}),Xe(hn,{size:[CN,Kpe,xT],offset:[-Wpe/2+CN/2,0,xT/2],color:"#ccc"})]}),tqe=({x:n,y:e,z:t=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(Ri,{children:[Xe(uo,{color:"#1a1a1a",children:Un(Xx,{children:[Xe(hn,{color:"#000",size:[a,c,s],center:[n,e,l(t+s/2)]}),o?Xe(oh,{height:s+.1,radius:o/2,center:[n,e,l(t+s/2)],color:"#222"}):Xe(hn,{size:[d,d,s],center:[n,e,l(t+s/2)]})]})}),Un(uo,{color:"silver",children:[Un(Yl,{children:[Xe(hn,{color:"silver",size:[u,u,i*.9],center:[n,e,l(t+-i/2*.9)]}),Xe(hn,{color:"silver",size:[u/1.8,u/1.8,i],center:[n,e,l(t+-i/2)]})]}),Xe(hn,{color:"silver",size:[d,d,d*.5],center:[n,e,l(t+d/2*.5)]})]})]})},Lgn=({numberOfPins:n,pitch:e=2.54,legsLength:t=3,innerDiameter:r=.945,rows:i=1,invert:o})=>{const a=Math.ceil(n/i),c=2.54,l=-((a-1)/2)*e,u=d=>o?-d+5:d;return Xe(Ri,{children:Array.from({length:n},(d,h)=>{const p=Math.floor(h/a),f=h%a,m=l+f*e,y=-p*c;return Xe(tqe,{x:m,y,pitch:e,legsLength:t,innerDiameter:r,flipZ:u},h)})})},Dgn=({width:n,length:e,innerDiameter:t=1})=>{const r=n,i=e,o=n*.7,s=t/2.5;return Un(Ri,{children:[Xe(gN,{color:"#1a1a1f",center:[0,0,o/2],size:[i,i,o],roundRadius:.3}),Xe(gN,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[i,i,o*.1],roundRadius:.14}),Xe(oh,{color:"#1a1a1f",height:o*.8,radius:r/3,center:[0,0,o+o*.8/2]}),Xe(oh,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[i/3,i/3,o+o*.1/2]}),Xe(oh,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-i/3,-i/3,o+o*.1/2]}),Xe(oh,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-i/3,i/3,o+o*.1/2]}),Xe(oh,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[i/3,-i/3,o+o*.1/2]}),Xe(KU,{thickness:t/3,width:s,horizontalLength:i*.8,verticalLength:o/2,position:{x:-r/2,y:-i/2,z:-o*1.2}}),Xe(KU,{thickness:t/3,width:s,horizontalLength:i*.8,verticalLength:o/2,position:{x:-r/2,y:i/2,z:-o*1.2},rotation:Math.PI}),Xe(KU,{thickness:t/3,width:s,horizontalLength:i*.8,verticalLength:o/2,position:{x:r/2,y:i/2,z:-o*1.2},rotation:Math.PI}),Xe(KU,{thickness:t/3,width:s,horizontalLength:i*.8,verticalLength:o/2,position:{x:r/2+t/3.6,y:-i/2,z:-o*1.2}})]})},KU=n=>{const{thickness:e,width:t,horizontalLength:r,verticalLength:i,rotation:o=0,position:s}=n,a=[[0,r],[-i/3,r/3],[-i/5,r/4],[0,0]],c=kpe(a,e);return Xe(uo,{color:"#f2f2f2",children:Xe(Br,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Xe(m0,{rotation:[0,55,o],children:Xe(xN,{height:t,children:Xe(_N,{points:c.map(l=>[l.y,l.x])})})})})})},zgn=({pinCount:n,leadLength:e,leadWidth:t,pitch:r,bodyWidth:i})=>{const o=Math.ceil(n/2),s=(o-1)*r/2,a=.25,c=1,l=.8,u=e*0,d=r*(o-1)+t+.2,h=i*.55;return Un(Ri,{children:[Array.from({length:o}).map((p,f)=>Xe(Xi,{position:{x:-i/2-u,y:f*r-s,z:a/2},width:t,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:l})),Array.from({length:o}).map((p,f)=>Xe(Xi,{rotation:Math.PI,position:{x:i/2+u,y:f*r-s,z:a/2},width:t,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:l})),Xe(kh,{center:{x:0,y:0,z:a/2},width:h,length:d,height:c})]})},$gn=({pinCount:n,pitch:e,leadWidth:t,leadLength:r,bodyWidth:i,bodyLength:o})=>{const s=n===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},a=isNaN(parseFloat(e))?s.pitch:parseFloat(e),c=isNaN(parseFloat(t))?s.leadWidth:parseFloat(t)*.8,l=isNaN(parseFloat(i))?2.6:parseFloat(i)*.8,u=isNaN(parseFloat(o))?2+Number(a)*1.4:parseFloat(o),d=n/2,h=(d-1)*a/2,p=.15,f=.8,m=4.5,y=(m-l)/2,g=y*.5;return Un(Ri,{children:[Array.from({length:d}).map((_,b)=>Xe(Xi,{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(Xi,{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(kh,{center:{x:0,y:0,z:p/2},width:l,length:u,height:1})]})},Fgn=()=>Un(Ri,{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(uo,{color:"#222",children:Un(Zp,{children:[Xe(Br,{z:.3/2,children:Xe(hn,{size:[1.65,.8,.3]})}),Un(Yl,{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]})})]})]})})]}),Bgn=()=>Un(Ri,{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(uo,{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]})]}),jgn=()=>{const l=Xe(uo,{color:"#1a1a1a",children:Un(Zp,{children:[Un(Yl,{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(Yl,{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(uo,{color:"#c0c0c0",children:Un(Zp,{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(Ri,{children:[Xe(u,{xDir:1}),Xe(u,{xDir:-1}),l]})},Ugn=()=>{const l=Xe(uo,{color:"#1a1a1a",children:Un(Zp,{children:[Un(Yl,{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(Yl,{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(uo,{color:"#c0c0c0",children:Un(Zp,{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(Ri,{children:[Xe(u,{xDir:1}),Xe(u,{xDir:-1}),l]})},Hgn=()=>{const l=Xe(uo,{color:"#1a1a1a",children:Un(Zp,{children:[Un(Yl,{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(Yl,{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(uo,{color:"#c0c0c0",children:Un(Zp,{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(Ri,{children:[Xe(u,{xDir:1}),Xe(u,{xDir:-1}),l]})},Vgn=()=>{const d=Xe(uo,{color:"#222",children:Un(Zp,{children:[Xe(Br,{z:.27,children:Xe(hn,{size:[2.9,1.9,.54]})}),Un(Yl,{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(Ri,{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]})},Ygn=()=>Un(Ri,{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(uo,{color:"#222",children:Un(Zp,{children:[Xe(Br,{z:.55/2,children:Xe(hn,{size:[2.7,1.6,.55]})}),Un(Yl,{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]})})]})]})})]}),Xgn=()=>Un(Ri,{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(uo,{color:"#222",children:Un(Zp,{children:[Xe(Br,{z:.2/2,children:Xe(hn,{size:[2.75,1.8,.2]})}),Un(Yl,{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]})]}),Ggn=()=>Un(Ri,{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(uo,{color:"#222",children:Un(Zp,{children:[Un(Yl,{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(Yl,{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]})]}),qgn=()=>Un(Ri,{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(uo,{color:"#222",children:Un(Zp,{children:[Un(Yl,{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(Yl,{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]})]}),Wgn=()=>Un(Ri,{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(uo,{color:"#222",children:Un(Zp,{children:[Xe(Br,{z:.14/2,children:Xe(hn,{size:[.8,.6,.14]})}),Un(Yl,{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]})})]})]})})]}),Kgn=()=>{const u=3.0999999999999996;return Un(Ri,{children:[Xe(Xi,{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(Xi,{position:{x:-6.6/2-u/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Xe(Xi,{position:{x:-6.6/2-u/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Xe(Xi,{position:{x:-6.6/2-u/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Xe(kh,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},Zgn=()=>Un(Ri,{children:[Array.from({length:16}).map((p,f)=>Xe(Xi,{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(Xi,{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(Xi,{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(Xi,{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(kh,{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})]}),Qgn=Zgn,Jgn=()=>{const l=.7999999999999998;return Un(Ri,{children:[Xe(Xi,{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(Xi,{position:{x:-2.05/2-l/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:l,height:.65}),Xe(Xi,{position:{x:-2.05/2-l/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:l,height:.65}),Xe(kh,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},e_n=({pinCount:n,pitch:e,leadWidth:t,padContactLength:r,bodyWidth:i})=>{const o=n/4;if(o!==Math.floor(o))throw new Error(`LQFP pinCount must be divisible by 4, got ${n}`);e||(e=.5),r||(r=.6),t||(t=.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(Ri,{children:[Array.from({length:o}).map((p,f)=>Xe(Xi,{position:{x:-l/2-.36,y:f*e-a,z:d/2},width:t,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Array.from({length:o}).map((p,f)=>Xe(Xi,{rotation:Math.PI,position:{x:l/2+.36,y:f*e-a,z:d/2},width:t,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Array.from({length:o}).map((p,f)=>Xe(Xi,{rotation:Math.PI/2,position:{x:f*e-a,y:-c/2-.36,z:d/2},width:t,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Array.from({length:o}).map((p,f)=>Xe(Xi,{rotation:-Math.PI/2,position:{x:f*e-a,y:c/2+.36,z:d/2},width:t,thickness:d,padContactLength:r,bodyDistance:h,height:u})),Xe(kh,{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})]})},t_n=()=>{const r=.20900000000000002,i=.1,o=.3,s=.1,a=.2;return Un(Ri,{children:[Xe(uo,{color:"#222",children:Un(Zp,{children:[Xe(hn,{size:[.85,1.2,r],center:[0,0,r/2]}),Un(Yl,{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]})]})},n_n=({num_pins:n,bodyWidth:e=5.3,bodyLength:t=5.3,bodyThickness:r=1,thermalPadSize:i,padWidth:o=t/5.3*.6,padLength:s=t/5.3*1,pitch:a=.5,thermalPadThickness:c=.2})=>{const l=[],u=Math.floor(n/2),d=a*(u-1);for(let h=0;h<n;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(Ri,{children:[Xe(kh,{center:{x:0,y:0,z:0},width:e,length:t,height:r,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(e/2-s),y:t/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]})]})},r_n=({bodyLength:n=10.2,bodyWidth:e=4.65,bodyHeight:t=13.46,leadSpacing:r=5,leadDiameter:i=.8,leadLength:o=12.7,color:s="#ddd",leadColor:a="#b87333"})=>{const c=n/2,l=e/2,u=c-l,d=r/2,h=.85;return Un(Ri,{children:[Un(uo,{color:s,children:[Un(Yl,{children:[Xe(y_,{height:t,roundRadius:.5,radius:l,center:[-u,0,t]}),Xe(y_,{height:t,roundRadius:.5,radius:l,center:[u,0,t]})]}),Un(Yl,{children:[Xe(y_,{height:h,roundRadius:.1,radius:l+.85,center:[-u,0,t/2+h/2]}),Xe(y_,{height:h,roundRadius:.1,radius:l+.85,center:[u,0,t/2+h/2]})]})]}),Un(uo,{color:a,children:[Xe(oh,{height:o+t/2,radius:i/2,center:[-d+.06,0,-(o/2)+t/2]}),Xe(oh,{height:o+t/2,radius:i/2,center:[d-.06,0,-(o/2)+t/2]})]})]})},i_n=({bodyLength:n=1.4,bodyDiameter:e=1.1,color:t="#3a3a3aff",contactColor:r="#c6c6c6",cathodeIdentification:i="#111"})=>Un(Ri,{children:[Xe(uo,{color:t,children:Un(m0,{rotation:[0,"90deg",0],children:[Xe(gN,{size:[e,e,n-.2],roundRadius:.2,center:[-e/2,0,.05]}),Xe(oh,{height:.2/2,radius:e/2-.2,center:[-e/2,0,-n/2+.2/2]})]})}),Xe(uo,{color:i,children:Xe(m0,{rotation:[0,"90deg",0],children:Xe(gN,{size:[e*1.01,e*1.01,n/3],roundRadius:.2,center:[-e/2,0,-n/4+.1]})})}),Xe(uo,{color:r,children:Xe(m0,{rotation:[0,"90deg",0],children:Xe(y_,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,-n/2]})})}),Xe(uo,{color:r,children:Xe(m0,{rotation:[0,"90deg",0],children:Xe(y_,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,n/2]})})})]}),o_n=({bodyLength:n=3.5,bodyDiameter:e=1.5,color:t="#3a3a3aff",contactColor:r="#c6c6c6"})=>Un(Ri,{children:[Xe(uo,{color:t,children:Xe(m0,{rotation:[0,"90deg",0],children:Xe(y_,{height:n,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),Xe(uo,{color:r,children:Xe(m0,{rotation:[0,"90deg",0],children:Xe(y_,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,-n/2]})})}),Xe(uo,{color:r,children:Xe(m0,{rotation:[0,"90deg",0],children:Xe(y_,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,n/2]})})})]}),s_n=({bodyLength:n=3.9,bodyDiameter:e=2.5,color:t="#3a3a3aff",contactColor:r="#c6c6c6"})=>Un(Ri,{children:[Xe(uo,{color:t,children:Xe(m0,{rotation:[0,"90deg",0],children:Xe(y_,{height:n,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),Xe(uo,{color:r,children:Xe(m0,{rotation:[0,"90deg",0],children:Xe(y_,{height:.55,radius:e/2,roundRadius:.2,center:[-e/2,0,-n/2]})})}),Xe(uo,{color:r,children:Xe(m0,{rotation:[0,"90deg",0],children:Xe(y_,{height:.55,radius:e/2,roundRadius:.2,center:[-e/2,0,n/2]})})})]}),a_n=({pinCount:n,padContactLength:e=.6,leadWidth:t=.41,pitch:r=1.27})=>{if(n%2!==0)throw new Error("MS012 pinCount must be even");const i=n/2,o=4.9,s=3.9,a=(i-1)*r/2,c=.2;return Un(Ri,{children:[Array.from({length:i}).map((l,u)=>Xe(Xi,{position:{x:-s/2-e-.3,y:u*r-a,z:c/2},width:t,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Array.from({length:i}).map((l,u)=>Xe(Xi,{rotation:Math.PI,position:{x:s/2+e+.3,y:u*r-a,z:c/2},width:t,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Xe(kh,{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})]})},c_n=({pinCount:n=16,padContactLength:e=.6,leadWidth:t=.41,pitch:r=1.27})=>{if(n!==16)throw new Error("MS013 only supports 16 pins");const i=n/2,o=7.5,s=10.3,a=(i-1)*r/2,c=.2;return Un(Ri,{children:[Array.from({length:i}).map((l,u)=>Xe(Xi,{position:{x:-o/2-e-.3,y:u*r-a,z:c/2},width:t,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Array.from({length:i}).map((l,u)=>Xe(Xi,{rotation:Math.PI,position:{x:o/2+e+.3,y:u*r-a,z:c/2},width:t,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Xe(kh,{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})]})},l_n=()=>{const m=7.050000000000001,y=24.95+6.5/2;return Xe(Br,{center:[0,0,1],children:Un(Ri,{children:[Un(m0,{rotation:[0,55,-55],children:[Un(Xx,{children:[Xe(hn,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[y,0,1.3-2]}),Xe(oh,{color:"black",center:[y,0,1.3-2],radius:3/2,height:1.3*1.2})]}),Xe(uo,{color:"#222",children:Xe(kh,{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(m0,{rotation:[0,55,55],children:Array.from({length:3}).map((g,_)=>{const b=m,v=(_-1)*2.7,M=-.5-.6;return Un(uo,{color:"gold",children:[Un(Yl,{children:[Xe(Br,{center:[15.05-4.5/2+.1,v,M],children:Xe(hn,{size:[4.5,.81+1,.5]})}),Xe(Br,{center:[15.05-4.5/2-1+.1,v,M],children:Xe(hn,{size:[4.5,.81,.5]})})]}),Xe(Br,{center:[b,v,M],children:Xe(hn,{size:[16+.1,.81,.5]})})]},`prong-${_}`)})})]})})},u_n=()=>{const l=1.1999999999999997;return Un(Ri,{children:[Xe(Xi,{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(Xi,{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(Xi,{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(Xi,{position:{x:-2.8/2-l/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Xe(Xi,{position:{x:-2.8/2-l/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Xe(Xi,{position:{x:-2.8/2-l/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Xe(kh,{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})]})},d_n=()=>Un(Ri,{children:[Xe(kh,{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]})})]}),h_n=()=>{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(uo,{color:s,children:Un(Xx,{children:[Xe(Br,{center:[0,0,2.25],children:Xe(oh,{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(Yl,{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]})})]})},p_n=()=>Un(Ri,{children:[Xe(Xi,{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(Xi,{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(Xi,{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(Xi,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Xe(Xi,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Xe(Xi,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Xe(kh,{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})]}),f_n=p_n,m_n=()=>Un(Ri,{children:[Xe(kh,{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]})})]}),y_n=()=>Un(Ri,{children:[Xe(Xi,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Xe(Xi,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Xe(uo,{color:"#222",children:Xe(kh,{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]})]}),g_n=()=>Un(Ri,{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(uo,{color:"#222",children:Un(Zp,{children:[Xe(Br,{z:.175/2,children:Xe(hn,{size:[1.7,1.25,.175]})}),Un(Yl,{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]})]}),__n=()=>{const s=-1.0474999999999999,a=1.775/2+.4/2-.04;return Un(Ri,{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(uo,{color:"#222",children:Xe(kh,{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]})]})},x_n=({pitch:n=10})=>Un(Ri,{children:[Xe(oh,{height:4,radius:.5,center:[-n/2,0,.5]}),Xe(GU,{radius:.5,center:[-n/2,0,2.5]}),Xe(Br,{x:-2.5,y:0,z:2.5,children:Un(m0,{rotation:[0,Math.PI/2,0],children:[Xe(oh,{height:n,radius:.5,center:[0,0,2.5]}),Xe(uo,{color:"#d2b48c",children:Xe(oh,{height:5,radius:1.3,center:[0,0,2.5]})})]})}),Xe(oh,{height:4,radius:.5,center:[n/2,0,.5]}),Xe(GU,{radius:.5,center:[n/2,0,2.5]})]}),b_n=({bodyWidth:n=21,boardThickness:e=.5,leadWidth:t=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=n/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:t}),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:t}),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:t,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:t,pw:r}),l&&_.push({x:-P,y:-y/2},{x:-P,y:-y/2+u})}}const b=Xe(uo,{color:"#008080",children:Un(Xx,{children:[Xe(hn,{center:[0,0,p],size:[n,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(oh,{color:"black",center:[E.x,E.y,p],radius:m,height:e*1.07})),M=g.map((E,A)=>Xe(hn,{center:[E.x,E.y,p],size:[E.pl+.01,E.pw+.01,f]}));return Un(Ri,{children:[b,Xe(uo,{color:"#FFD700",children:l?Un(Xx,{children:[Xe(Zp,{children:g.map((E,A)=>Xe(hn,{center:[E.x,E.y,p],size:[E.pl+.01,E.pw+.01,f]},A))}),v]}):M})]})},v_n=({width:n=30,height:e=22,thickness:t=1,bezelInset:r=2,bezelDepth:i=1,screenColor:o="#001414",bezelColor:s="#0f1116",screenWidth:a,screenHeight:c,offset:l})=>{const u=n,d=e,h=Math.max(t,.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,M=l?.z??0;return Un(Br,{offset:{x:b,y:v,z:M},children:[f>0&&Xe(uo,{color:s,children:Xe(hn,{size:[u,d,f],offset:[0,0,f/2]})}),Xe(uo,{color:s,children:Un(Xx,{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(uo,{color:o,children:Xe(hn,{size:[y,g,_],offset:[0,0,f+_/2]})})]})},w_n=({numPins:n=5,rows:e=1,p:t=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,M=Math.ceil(n/e);let E,A;c==="left"||c==="right"?(E=(e-1)*t+2*d,A=(M-1)*t+2*d):(A=(e-1)*t+2*d,E=(M-1)*t+2*d),n===0&&(E=10,A=10);const P=Number(s??E),N=Number(a??A),C=[];let D=0,I=0,B=0,j=0,U=0,G=0;c==="left"||c==="right"?(D=c==="left"?-P/2+d:P/2-d,I=-((M-1)/2)*t,B=0,j=t,U=c==="left"?t:-t,G=0):(D=-((M-1)/2)*t,I=c==="top"?N/2-d:-N/2+d,B=t,j=0,U=0,G=c==="top"?-t:t);let K=0;for(let me=0;me<e&&K<n;me++)for(let Ee=0;Ee<M&&K<n;Ee++){const _e=D+Ee*B+me*U,Fe=I+Ee*j+me*G;C.push({x:_e,y:Fe}),K++}const ee=[];if(l)for(const me of l){let Ee=0,_e=0;me==="topleft"?(Ee=-P/2+u,_e=N/2-u):me==="topright"?(Ee=P/2-u,_e=N/2-u):me==="bottomleft"?(Ee=-P/2+u,_e=-N/2+u):me==="bottomright"?(Ee=P/2-u,_e=-N/2+u):me==="center"&&(Ee=0,_e=0),ee.push({x:Ee,y:_e})}const re=.63,pe=2,ie=6,se=3,le=p||h?0:pe,ae=le+o,ye=Xe(uo,{color:"#008080",children:Un(Xx,{children:[Xe(hn,{center:[0,0,v+le],size:[P,N,o]}),ee.map((me,Ee)=>Xe(oh,{center:[me.x,me.y,v+le],radius:i/2,height:o},`hole-${Ee}`)),C.map((me,Ee)=>Xe(oh,{center:[me.x,me.y,v+le],radius:i/2,height:o},`pin-hole-${Ee}`))]})}),Te=C.map((me,Ee)=>Xe(uo,{color:"#FFD700",children:Un(Xx,{children:[Xe(oh,{center:[me.x,me.y,o/2+le],radius:i/2,height:o}),Xe(oh,{center:[me.x,me.y,o/2+le],radius:r/2,height:o})]})})),Me=C.map((me,Ee)=>Xe(qGe,{x:me.x,y:me.y,pinThickness:re,shortSidePinLength:se,longSidePinLength:ie,bodyHeight:pe,flipZ:_e=>_e})),$e=C.map((me,Ee)=>Xe(tqe,{x:me.x,y:me.y,flipZ:_e=>-_e}));return Un(Ri,{children:[ye,Te,!h&&!p&&Me,h&&$e,b&&Xe(v_n,{width:m??P*.8,height:y??N*.6,offset:{x:g??0,y:_??0,z:ae}})]})},S_n=({footprint:n})=>{const e=ogn.string(n).json();switch(e.fn){case"dip":return Xe(ugn,{numPins:e.num_pins,pitch:e.p,bodyWidth:e.w});case"axial":return Xe(x_n,{pitch:e.p});case"tssop":return Xe(hgn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"msop":return Xe(pgn,{pinCount:e.num_pins,padContactLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"vssop":return Xe($gn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w,bodyLength:e.h});case"qfp":return Xe(ggn,{pinCount:e.num_pins,pitch:e.p,leadWidth:e.pw,padContactLength:e.pl,bodyWidth:e.w});case"tqfp":return Xe(Qgn,{});case"lqfp":return Xe(e_n,{pinCount:e.num_pins});case"qfn":{const i=typeof e.thermalpad?.x=="number"&&typeof e.thermalpad?.y=="number";return Xe(Mgn,{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(n_n,{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=n.match(/_rows(\d+)/),o=i&&i[1]?parseInt(i[1],10):1;if(e.male)return Xe(vgn,{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(Lgn,{numberOfPins:e.num_pins,pitch:e.p,rows:o})}case"cap":switch(e.imperial){case"0402":return Xe(YGe,{color:"#856c4d"});case"0603":return Xe(XGe,{color:"#856c4d"});case"0805":return Xe(GGe,{color:"#856c4d"});case"0201":return Xe(WGe,{color:"#856c4d"});case"01005":return Xe(KGe,{color:"#856c4d"});case"1206":return Xe(ZGe,{color:"#856c4d"});case"1210":return Xe(QGe,{color:"#856c4d"});case"2010":return Xe(JGe,{color:"#856c4d"});case"2512":return Xe(eqe,{color:"#856c4d"})}case"sot235":return Xe(Cgn,{});case"sot457":return Xe(u_n,{});case"sot223":return Xe(Kgn,{});case"sot23w":return Xe(Pgn,{});case"sot323":return Xe(Jgn,{});case"sod323f":return Xe(g_n,{});case"sod323fl":return Xe(__n,{});case"sot363":return Xe(f_n,{});case"sot886":return Xe(m_n,{});case"sot963":return Xe(d_n,{});case"pushbutton":return Xe(Dgn,{width:e.w,length:e.h,innerDiameter:e.id});case"soic":return Xe(zgn,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"sod523":return Xe(Fgn,{});case"sod882":return Xe(Bgn,{});case"sma":return Xe(jgn,{});case"smb":return Xe(Ugn,{});case"smc":return Xe(Hgn,{});case"smf":return Xe(Vgn,{});case"sod123f":return Xe(Ygn,{});case"sod123fl":return Xe(Xgn,{});case"sod123w":return Xe(Ggn,{});case"sod128":return Xe(qgn,{});case"sod323":return Xe(y_n,{});case"sod923":return Xe(Wgn,{});case"hc49":return Xe(r_n,{});case"micromelf":return Xe(i_n,{});case"minimelf":return Xe(o_n,{});case"melf":return Xe(s_n,{});case"ms012":return Xe(a_n,{pinCount:e.num_pins,padContactLength:e.pl,leadWidth:e.pw,pitch:e.p});case"ms013":return Xe(c_n,{pinCount:e.num_pins,padContactLength:e.pl,leadWidth:e.pw,pitch:e.p});case"sot723":return Xe(t_n,{});case"to220":return Xe(l_n,{});case"to92":return Xe(h_n,{});case"stampboard":case"stampreceiver":return Xe(b_n,{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(w_n,{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 t=n.match(/_color\(([^)]+)\)/),r=t?t[1]:void 0;switch(e.imperial){case"0402":return Xe(YGe,{color:r});case"0603":return Xe(XGe,{color:r});case"0805":return Xe(GGe,{color:r});case"0201":return Xe(WGe,{color:r});case"01005":return Xe(KGe,{color:r});case"1206":return Xe(ZGe,{color:r});case"1210":return Xe(QGe,{color:r});case"2010":return Xe(JGe,{color:r});case"2512":return Xe(eqe,{color:r})}return null},E_n=n=>n&&typeof n=="object"&&"type"in n,bT=n=>{if(typeof n=="number")return n;if(typeof n=="string"){const e=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(n);if(e)return parseFloat(e[1])*Math.PI/180;const t=Number(n);if(!Number.isNaN(t))return t}return 0},M_n=n=>Array.isArray(n)?[Number(n[0])||0,Number(n[1])||0,Number(n[2])||0]:typeof n=="object"&&n?[Number(n.x)||0,Number(n.y)||0,Number(n.z)||0]:[0,0,0];function h4(n,e,t){const{jscad:{primitives:r,booleans:i,hulls:o,geometries:s,extrusions:a,transforms:c}}=t;if(n==null||n===!1)return[];if(Array.isArray(n))return n.flatMap(h=>h4(h,e,t));if(!E_n(n))return[];const{type:l,props:u,children:d}=n;if(l===UGe)return(d??[]).flatMap(h=>h4(h,e,t));if(l===uo){const h=u?.color;return(d??[]).flatMap(p=>h4(p,h??e,t))}if(l===Br){const h=M_n(u?.offset??u?.center??{x:u?.x,y:u?.y,z:u?.z});return(d??[]).flatMap(f=>h4(f,e,t)).map(({geom:f,color:m})=>({geom:c.translate(h,f),color:m??e}))}if(l===m0){const h=Array.isArray(u?.rotation)?[bT(u.rotation[0]),bT(u.rotation[1]),bT(u.rotation[2])]:[bT(u?.x??0),bT(u?.y??0),bT(u?.z??0)];return(d??[]).flatMap(f=>h4(f,e,t)).map(({geom:f,color:m})=>({geom:c.rotateZ(h[2],c.rotateY(h[1],c.rotateX(h[0],f))),color:m}))}if(l===Zp||l===Xx||l===Yl){const h=(d??[]).flatMap(f=>h4(f,e,t)).map(f=>f.geom);if(h.length===0)return[];let p;return l===Zp?p=i.union(h):l===Xx?p=i.subtract(h[0],h.slice(1)):p=o.hull(h),[{geom:p,color:e}]}if(l===_N){const h=u?.points??[];return[{geom:s.geom2.fromPoints(h),color:e??u?.color}]}if(l===xN){const h=(d??[]).flatMap(y=>h4(y,e,t)).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===HGe||l===oh||l===GU||l===gN||l===y_){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===HGe){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===oh){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===GU){const p=u?.radius??1,f=u?.center??[0,0,0];h=r.sphere({radius:p,center:f})}else if(l===y_){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 h4(h,e,t)}return(d??[]).flatMap(h=>h4(h,e,t))}function T_n(n,e){return{geometries:h4(n,void 0,{jscad:e})}}function nqe(n){if(n.polygons){const e=[],t=[],r=[];let i=0;for(const s of n.polygons){for(const c of s.vertices)c.index=i,e.push(c[0],c[1],c[2]),n.color&&n.color.length>=3?r.push(n.color[0],n.color[1],n.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;t.push(a,l,u)}}const o=new nl;if(o.setAttribute("position",new Vl(new Float32Array(e),3)),o.setIndex(t),r.length>0&&o.setAttribute("color",new Vl(new Float32Array(r),3)),n.transforms){const s=new Do;s.fromArray(n.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(n.sides){const e=[],t=[];for(const i of n.sides)e.push(i[0][0],i[0][1],0),n.color&&n.color.length>=3?t.push(n.color[0],n.color[1],n.color[2]):t.push(1,1,1);const r=new nl;if(r.setAttribute("position",new Vl(new Float32Array(e),3)),t.length>0&&r.setAttribute("color",new Vl(new Float32Array(t),3)),n.transforms){const i=new Do;i.fromArray(n.transforms),r.applyMatrix4(i)}return r}return console.error("Invalid CSG object: neither polygons nor sides found"),new nl}function C_n(n,e){const t=Npe(S_n,{footprint:n});return T_n(t,e)}var P_n=Sc($U()),rqe=q.createContext(null),A_n=()=>{const n=q.useContext(rqe);if(!n)throw new Error("useHover must be used within a HoverProvider");return n},R_n=({children:n})=>{const{camera:e,renderer:t}=Wy(),[r,i]=q.useState([]),o=q.useMemo(()=>new hJt,[]),s=q.useMemo(()=>new ui,[]),a=q.useRef(r);a.current=r;const c=q.useRef(null),l=q.useCallback(f=>{i(m=>[...m,f])},[]),u=q.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=q.useCallback(f=>{let m=f;for(;m;){const y=a.current.find(g=>g.object===m);if(y)return y;m=m.parent}},[]),h=q.useCallback(f=>{if(!t.domElement)return;const m=t.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,t,o,s,d]);q.useEffect(()=>{const f=t.domElement;return f.addEventListener("mousemove",h),()=>{f.removeEventListener("mousemove",h)}},[t,h]);const p=q.useMemo(()=>({addHoverable:l,removeHoverable:u}),[l,u]);return X.jsx(rqe.Provider,{value:p,children:n})},N_n=({children:n,object:e,onHover:t,onUnhover:r,isHovered:i})=>{const{addHoverable:o,removeHoverable:s}=A_n();return q.useEffect(()=>e?(o({object:e,onHover:t,onUnhover:r}),()=>{s(e)}):void 0,[e,t,r,o,s]),X.jsx(X.Fragment,{children:n})},PN=N_n,k_n=({positionOffset:n,footprint:e,rotationOffset:t,onHover:r,onUnhover:i,isHovered:o,scale:s,isTranslucent:a=!1})=>{const{rootObject:c}=Wy(),l=q.useMemo(()=>{if(!e)return null;const{geometries:u}=C_n(e,P_n),d=new Hf;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=nqe(m),g=new jm({vertexColors:!0,side:Yp,transparent:a,opacity:a?.5:1,depthWrite:!a}),_=new Wi(y,g);_.renderOrder=a?2:1,d.add(_)}return d},[e,a]);return q.useEffect(()=>{if(!(!l||!c))return c.add(l),()=>{c.remove(l)}},[c,l]),q.useEffect(()=>{l&&(n&&l.position.fromArray(n),t&&l.rotation.fromArray(t),s!==void 0&&l.scale.setScalar(s))},[l,n?.[0],n?.[1],n?.[2],t?.[0],t?.[1],t?.[2],s]),q.useEffect(()=>{l&&l.traverse(u=>{u instanceof Wi&&u.material instanceof jm&&(o?(u.material.emissive.setHex(255),u.material.emissiveIntensity=.2):u.material.emissiveIntensity=0)})},[o,l]),l?X.jsx(PN,{isHovered:o,onHover:r,onUnhover:i,object:l}):null},iqe=new WeakMap,O_n=()=>{const n=new bu;return n.name="fallback-environment-map",n.mapping=XB,n},I_n=n=>{if(!n)return null;const e=n,t=iqe.get(e);if(t)return t;let r;if(n instanceof Ej){const i=new Lie(n);r=i.fromScene(DJt(),.04).texture,i.dispose()}else r=O_n();return iqe.set(e,r),r};function L_n(n){const e=new Bx;let t=!1;n.updateWorldMatrix(!0,!1);const r=n.parent?n.parent.matrixWorld.clone().invert():new Do;return n.traverse(i=>{if(i.updateWorldMatrix(!0,!1),i instanceof Wi&&i.geometry&&(i.geometry.boundingBox||i.geometry.computeBoundingBox(),i.geometry.boundingBox)){const o=i.geometry.boundingBox.clone();o.applyMatrix4(i.matrixWorld),o.applyMatrix4(r),t?e.union(o):(e.copy(o),t=!0)}}),t?e:null}function D_n(n){const e=L_n(n);return e?e.getSize(new Mt):new Mt}function z_n(n,e,t="contain_within_bounds"){if(!e)return[1,1,1];const r=D_n(n),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(t==="fill_bounds")return i;const o=Math.min(...i);return[o,o,o]}var Zpe=({model:n,position:e,rotation:t,modelOffset:r=[0,0,0],modelRotation:i=[0,0,0],sourceCoordinateTransform:o,modelSize:s,modelFitMode:a="contain_within_bounds",scale:c})=>{const{rootObject:l}=Wy(),u=q.useMemo(()=>new Hf,[]),d=q.useMemo(()=>new Hf,[]),h=q.useMemo(()=>new Hf,[]),p=q.useMemo(()=>new Hf,[]);return q.useEffect(()=>(u.add(d),()=>{u.remove(d)}),[u,d]),q.useEffect(()=>(d.add(h),()=>{d.remove(h)}),[d,h]),q.useEffect(()=>(h.add(p),()=>{h.remove(p)}),[h,p]),q.useEffect(()=>{for(;p.children.length>0;){const f=p.children[0];if(!f)break;p.remove(f)}n&&p.add(n)},[p,n]),q.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]),q.useEffect(()=>{if(l)return l.add(u),()=>{l.remove(u)}},[l,u]),q.useEffect(()=>{if(e?u.position.fromArray(e):u.position.set(0,0,0),t?u.rotation.fromArray(t):u.rotation.set(0,0,0),h.position.fromArray(r),h.rotation.fromArray(i),h.scale.setScalar(c??1),!n){d.scale.set(1,1,1);return}d.scale.set(1,1,1),d.updateWorldMatrix(!0,!0);const f=z_n(h,s,a);d.scale.set(f[0],f[1],f[2])},[u,d,n,a,r,p,h,i,s,e,t,c]),{boardTransformGroup:u}},oqe=1.25;function sqe({gltfUrl:n,position:e,rotation:t,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}=Wy(),[f,m]=q.useState(null),[y,g]=q.useState(null),{boardTransformGroup:_}=Zpe({model:f,position:e,rotation:t,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:d});if(q.useEffect(()=>{if(!n)return;const b=new $Jt;let v=!0;return b.load(n,M=>{if(!v)return;const E=M.scene;E.traverse(A=>{if(A instanceof Wi&&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,M=>{if(!v)return;console.error(`An error happened loading ${n}`,M);const E=M instanceof Error?M:new Error(`Failed to load glTF model from ${n}`);g(E)}),()=>{v=!1}},[n,h]),q.useEffect(()=>{if(!f||!p)return;const b=I_n(p);if(!b)return;const v=[],M=E=>{E instanceof jm&&(v.push({material:E,envMap:E.envMap??null,envMapIntensity:E.envMapIntensity??1}),E.envMap=b,(typeof E.envMapIntensity!="number"||E.envMapIntensity<oqe)&&(E.envMapIntensity=oqe),E.needsUpdate=!0)};return f.traverse(E=>{if(!(E instanceof Wi))return;const A=E.material;Array.isArray(A)?A.forEach(M):A&&M(A)}),()=>{v.forEach(({material:E,envMap:A,envMapIntensity:P})=>{E.envMap=A,E.envMapIntensity=P,E.needsUpdate=!0})}},[f,p]),q.useEffect(()=>{f&&f.traverse(b=>{b instanceof Wi&&b.material instanceof jm&&(u?(b.material.emissive.setHex(255),b.material.emissiveIntensity=.2):b.material.emissiveIntensity=0)})},[u,f]),y)throw y;return f?X.jsx(PN,{isHovered:u,onHover:c,onUnhover:l,object:_}):null}var $_n=Sc(lGe()),F_n=Sc($U()),B_n=({jscadPlan:n,positionOffset:e,rotationOffset:t,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}=q.useMemo(()=>{const g=(0,$_n.executeJscadOperations)(F_n.default,n);if(!g||!g.polygons&&!g.sides)return{threeGeom:null,material:null};const _=nqe(g),b=new jm({vertexColors:!0,side:Yp,transparent:h,opacity:h?.5:1,depthWrite:!h});return{threeGeom:_,material:b}},[n,h]),m=q.useMemo(()=>{if(!p)return null;const g=new Wi(p,f);return g.renderOrder=h?2:1,g},[p,f,h]),{boardTransformGroup:y}=Zpe({model:m,position:e,rotation:t,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:d});return q.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?X.jsx(PN,{isHovered:u,onHover:c,onUnhover:l,object:y}):null};function j_n(n){return n.replace(/(DEF|USE)\s+([^\s]+)/g,(e,t,r)=>`${t} ${r.replace(/-/g,"_")}`)}async function U_n(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch "${n}": ${e.status} ${e.statusText}`);const t=await e.text();return new Sen().parse(j_n(t),n)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function H_n(n){const[e,t]=q.useState(null);return q.useEffect(()=>{if(!n)return;const r=n.replace(/&cachebust_origin=$/,""),i=window.TSCIRCUIT_OBJ_LOADER_CACHE;let o=!1;async function s(){try{if(r.endsWith(".wrl"))return await U_n(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 ken;if(u?.length){const h=u.join(`
5156
- `).replace(/d 0\./g,"d 1."),p=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),f=new ben;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||t(c)}).catch(c=>{console.error(c)}),()=>{o=!0}},[n]),e}function V_n({url:n,position:e,rotation:t,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=H_n(n),f=q.useMemo(()=>p&&!(p instanceof Error)?(p.traverse(y=>{if(y instanceof Wi&&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 Wi(new G5(.5,.5,.5),new jm({transparent:!0,color:"red",opacity:.25})),[p,h]),{boardTransformGroup:m}=Zpe({model:f,position:Array.isArray(e)?e:e?[e.x,e.y,e.z]:void 0,rotation:Array.isArray(t)?t:t?[t.x,t.y,t.z]:void 0,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:d});if(p instanceof Error)throw p;return X.jsx(PN,{isHovered:u,onHover:c,onUnhover:l,object:m})}var Qpe,Y_n="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function X_n(n){if(typeof n=="function")return n;if(n&&typeof n=="object"&&"default"in n&&typeof n.default=="function")return n.default;throw new Error("Unable to resolve occt-import-js factory export")}async function G_n(){if(!Qpe){const n=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");Qpe=X_n(n)({locateFile:t=>`${Y_n}/${t}`})}return Qpe}function q_n(n){const e=new Hf;for(const t of n){const r=t.attributes.position?.array??[],i=t.index?.array??[];if(!r.length||!i.length)continue;const o=new nl;o.setAttribute("position",new zo(r,3));const s=t.attributes.normal?.array??[];s.length?o.setAttribute("normal",new zo(s,3)):o.computeVertexNormals(),o.setIndex(i);const a=new jm({color:t.color?new Yr(t.color[0],t.color[1],t.color[2]):new Yr(.82,.82,.82)}),c=new Wi(o,a);c.name=t.name,e.add(c)}return e}async function W_n(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch STEP file: ${e.statusText}`);const t=await e.arrayBuffer(),i=(await G_n()).ReadStepFile(new Uint8Array(t),null);if(!i.success||!i.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=q_n(i.meshes),s=new hoe;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 aqe="step-glb-cache:";function K_n(n){const e=new Uint8Array(n),t=32768;let r="";for(let i=0;i<e.length;i+=t){const o=e.subarray(i,i+t);r+=String.fromCharCode(...o)}return btoa(r)}function Z_n(n){const e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)t[r]=e.charCodeAt(r);return t.buffer}function Q_n(n){try{const e=localStorage.getItem(`${aqe}${n}`);return e?Z_n(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function cqe(n,e){try{const t=K_n(e);localStorage.setItem(`${aqe}${n}`,t)}catch(t){console.warn("Failed to write STEP GLB cache",t)}}function J_n(){const n=globalThis;return n.stepUrlToGltfModelConversions||(n.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),n.stepUrlToGltfModelConversions}var e2n=({stepUrl:n,position:e,rotation:t,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:d,isTranslucent:h})=>{const[p,f]=q.useState(null);return q.useEffect(()=>{let m=!0,y=null,g=!0;const _=J_n(),b=Q_n(n);if(b){const E={arrayBuffer:b,blobUrl:URL.createObjectURL(new Blob([b],{type:"model/gltf-binary"}))};return _.completed.set(n,E),y=E.blobUrl,g=!1,f(E.blobUrl),()=>{m=!1,y&&g&&URL.revokeObjectURL(y)}}const v=_.completed.get(n);if(v)return y=v.blobUrl,g=!1,f(v.blobUrl),cqe(n,v.arrayBuffer),()=>{m=!1,y&&g&&URL.revokeObjectURL(y)};let M=_.inProgress.get(n);return M||(M=W_n(n).then(E=>{const A={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return _.completed.set(n,A),_.inProgress.delete(n),A}).catch(E=>{throw _.inProgress.delete(n),E}),_.inProgress.set(n,M)),M.then(E=>{m&&(y=E.blobUrl,g=!1,f(E.blobUrl),cqe(n,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),m&&f(null)}),()=>{m=!1,y&&g&&URL.revokeObjectURL(y)}},[n]),p?X.jsx(sqe,{gltfUrl:p,position:e,rotation:t,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:d,isTranslucent:h}):null};function ZU(n,e){let{x:t,y:r,z:i}=n;if(e.axisMapping){const o={x:t,y:r,z:i};e.axisMapping.x&&(t=Jpe(o,e.axisMapping.x)),e.axisMapping.y&&(r=Jpe(o,e.axisMapping.y)),e.axisMapping.z&&(i=Jpe(o,e.axisMapping.z))}if(t*=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=t*s+i*a,l=-t*a+i*s;t=c,i=l}if(e.rotation.z){const o=e.rotation.z*Math.PI/180,s=Math.cos(o),a=Math.sin(o),c=t*s-r*a,l=t*a+r*s;t=c,r=l}}return{x:t,y:r,z:i}}function Jpe(n,e){switch(e){case"x":return n.x;case"y":return n.y;case"z":return n.z;case"-x":return-n.x;case"-y":return-n.y;case"-z":return-n.z;default:return 0}}var efe={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 t2n(n,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return efe.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?efe.STEP_INVERTED:efe.Z_UP_TO_Y_UP_USB_FIX}}function AN(n,e){return t2n(n,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function QU(n){if(!n)return;const e=ZU({x:1,y:0,z:0},n),t=ZU({x:0,y:1,z:0},n),r=ZU({x:0,y:0,z:1},n);return new Do().makeBasis(new Mt(e.x,e.y,e.z),new Mt(t.x,t.y,t.z),new Mt(r.x,r.y,r.z))}function f9(n){return n*Math.PI/180}function n2n(n){if(n==="z+")return[0,0,0];switch(n){case"x+":return[0,f9(-90),0];case"x-":return[0,f9(90),0];case"y+":return[f9(90),0,0];case"y-":return[f9(-90),0,0];case"z-":return[f9(180),0,0];default:return[0,0,0]}}function r2n(n,e,t){if(!n.position)return;let r=n.position.z;return e==="bottom"&&n.position.z>=0&&(r=-(n.position.z+t)),[n.position.x,n.position.y,r]}function i2n(n,e){return n.rotation?[f9(n.rotation.x),f9(n.rotation.y),f9(n.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function o2n(n,e){const t=new Mt(n.x,n.y,n.z),r=new Vy(e[0],e[1],e[2],"XYZ");return t.applyEuler(r),[t.x,t.y,t.z]}function s2n(n,e,t){if(!n.model_origin_position)return[0,0,0];const r=e?ZU(n.model_origin_position,e):n.model_origin_position;return o2n(r,t)}function a2n(n,e){const t=r2n(n,e.layer,e.pcbThickness),r=i2n(n,e.layer),i=AN(n,e.modelType),o=n2n(n.model_board_normal_direction??"z+"),s=s2n(n,i,o);return{position:t,rotation:r,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:o,scale:n.model_unit_to_mm_scale_factor??void 0,fitMode:n.model_object_fit??"contain_within_bounds",size:n.size?[n.size.x,n.size.y,n.size.z]:void 0}}var c2n=n=>n.model_glb_url||n.model_gltf_url?n.model_glb_url?"glb":"gltf":n.model_obj_url||n.model_wrl_url||n.model_stl_url?n.model_wrl_url?"wrl":n.model_stl_url?"stl":"obj":n.model_jscad?"jscad":n.footprinter_string?"footprinter":n.model_step_url?"step":"unknown",l2n=n=>n==="step"?"glb":n,u2n=(n,e)=>{if(n)return e?e(n):n},d2n=(...n)=>n,tfe=class extends ri.Component{constructor(n){super(n),this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},h2n=({error:n,onError:e})=>(q.useEffect(()=>{e(n)},[n,e]),null),lqe=({cad_component:n,circuitJson:e,resolveStaticAsset:t})=>{const r=hGe(e),[i,o]=q.useState(!1),{visibility:s}=Z7(),[a,c]=q.useState(null),l=q.useCallback(G=>{G?.mousePosition?(o(!0),c(G.mousePosition)):(o(!1),c(null))},[]),u=q.useCallback(()=>{o(!1),c(null)},[]),d=q.useMemo(()=>pi(e).source_component.getUsing({source_component_id:n.source_component_id})?.name,[e,n.source_component_id]),h=q.useMemo(()=>e.filter(K=>K.type==="pcb_plated_hole"&&K.pcb_component_id===n.pcb_component_id).length>0,[e,n.pcb_component_id]),p=q.useCallback(G=>u2n(G,t),[t]),f=p(n.model_wrl_url??n.model_stl_url??n.model_obj_url),m=p(n.model_glb_url??n.model_gltf_url),y=p(n.model_step_url),[g,_]=q.useState(0),[b,v]=q.useState(null);q.useEffect(()=>{_(0),v(null)},[n.cad_component_id,f,m,y]);const E=e.find(G=>G.type==="pcb_component"&&G.source_component_id===n.source_component_id)?.layer??"top",A=c2n(n),P=l2n(A),N=n.model_glb_url?"glb":"gltf",C=n.model_wrl_url?"wrl":n.model_stl_url?"stl":"obj",D=q.useMemo(()=>a2n(n,{layer:E,pcbThickness:r,modelType:P}),[n,E,r,P]),I=d2n(...D.rotation),B=D.position,j=q.useMemo(()=>{const G=[];return m&&G.push(X.jsx(sqe,{gltfUrl:m,position:B,rotation:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:QU(AN(n,N)),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:n.show_as_translucent_model},`${n.cad_component_id}-gltf-${m}`)),f&&G.push(X.jsx(V_n,{url:f,position:B,rotation:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:QU(AN(n,C)),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:n.show_as_translucent_model},`${n.cad_component_id}-mixed-${f}`)),y&&!n.model_jscad&&!n.footprinter_string&&G.push(X.jsx(e2n,{stepUrl:y,position:B,rotation:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:QU(AN(n,P)),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:n.show_as_translucent_model},`${n.cad_component_id}-step-${y}`)),G},[B,n.cad_component_id,n.footprinter_string,n.model_jscad,n.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 U=null;if(j.length>0){if(g>=j.length){if(b)throw b;return null}U=X.jsx(tfe,{fallback:({error:G})=>X.jsx(h2n,{error:G,onError:K=>{v(K),_(ee=>Math.max(ee,g+1))}}),children:j[g]},`${n.cad_component_id}-fallback-${g}`)}else n.model_jscad?U=X.jsx(B_n,{jscadPlan:n.model_jscad,positionOffset:B,rotationOffset:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:QU(AN(n,"jscad")),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:n.show_as_translucent_model},n.cad_component_id):n.footprinter_string&&(U=X.jsx(k_n,{positionOffset:B,rotationOffset:I,footprint:n.footprinter_string,scale:D.scale,onHover:l,onUnhover:u,isHovered:i,isTranslucent:n.show_as_translucent_model}));if(n.show_as_translucent_model){if(!s.translucentModels)return null}else if(h&&!s.throughHoleModels||!h&&!s.smtModels)return null;return X.jsxs(X.Fragment,{children:[U,i&&a?X.jsx(fGe,{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]})},uqe={version:"0.0.548"};function p2n(n){n.querySelectorAll("canvas").forEach(e=>e.remove())}var f2n=n=>{n.outputColorSpace=F5,n.toneMapping=$ke,n.toneMappingExposure=1},dqe="cadViewerCameraStateSession",hqe=(n,e)=>{try{const t={position:n.position.toArray(),quaternion:n.quaternion.toArray(),up:n.up.toArray(),fov:n.fov??50,target:e.target.toArray()};sessionStorage.setItem(dqe,JSON.stringify(t))}catch(t){console.warn("Failed to save camera:",t)}},nfe=(n,e)=>{try{const t=sessionStorage.getItem(dqe);if(!t)return!1;const r=JSON.parse(t);if(n.position.fromArray(r.position),n.quaternion.fromArray(r.quaternion),n.up.fromArray(r.up),"fov"in n){const i=n;i.fov=r.fov,i.updateProjectionMatrix?.()}return e.target.fromArray(r.target),e.update(),n.updateMatrixWorld(),!0}catch(t){return console.warn("Failed to restore camera:",t),!1}},pqe=q.createContext(void 0),m2n=({children:n,defaultTarget:e,initialCameraPosition:t})=>{const r=q.useRef(null),i=q.useRef(null),[o,s]=q.useState(null),[a,c]=q.useState("perspective"),[l,u]=q.useState(t??null),[d,h]=q.useState(new Vy(0,0,0)),p=q.useMemo(()=>{const[g,_,b]=t??[5,-5,5],v=Math.hypot(g-e.x,_-e.y,b-e.z);return v>0?v:5},[t,e]),f=q.useCallback(g=>{const _=[e.x,e.y,e.z],b=i.current,v=r.current;let M=p;switch(b&&v&&(M=b.position.distanceTo(v.target)),g){case"Top Center Angled":{const E=M/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+M],target:_,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-M*.6,e.y-M*.6,e.z+M*.6],target:_,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+M*.6,e.y-M*.6,e.z+M*.6],target:_,up:[0,0,1]};case"Left Sideview":return{position:[e.x-M,e.y,e.z],target:_,up:[0,0,1]};case"Right Sideview":return{position:[e.x+M,e.y,e.z],target:_,up:[0,0,1]};case"Front":return{position:[e.x,e.y-M,e.z],target:_,up:[0,0,1]};default:return null}},[p,e,i,r]),m=q.useCallback(g=>{r.current=g},[]),y=q.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:hqe,loadCameraFromSession:nfe}),[e,p,o,f,m,a,l,d]);return X.jsx(pqe.Provider,{value:y,children:n})},m9=()=>{const n=q.useContext(pqe);if(!n)throw new Error("useCameraController must be used within a CameraControllerProvider");return n},y2n=q.forwardRef(({children:n,scene:e,camera:t,style:r,onCreated:i},o)=>{const{cameraType:s}=m9(),a=q.useRef(null),[c,l]=q.useState(null),u=q.useRef([]),d=q.useRef(void 0);d.current=i;const h=q.useRef(null),p=q.useCallback(g=>{u.current.push(g)},[]),f=q.useCallback(g=>{u.current=u.current.filter(_=>_!==g)},[]),m=q.useMemo(()=>new O7,[]);e?.up&&m.up.set(e.up.x,e.up.y,e.up.z);const y=q.useRef(new tl);return q.useImperativeHandle(o,()=>y.current),q.useEffect(()=>{if(!a.current)return;p2n(a.current);const g=new Ej({antialias:!0,alpha:!0});f2n(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 Uf(75,_,.1,1e3):new SR(-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)):(t?.up&&b.up.set(t.up[0],t.up[1],t.up[2]),t?.position&&b.position.set(t.position[0],t.position[1],t.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 M=new nJt,E=()=>{const P=M.getElapsedTime(),N=M.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 Uf?b.aspect=P:b instanceof SR&&(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]),X.jsx("div",{ref:a,style:{width:"100%",height:"100%",...r},children:c&&X.jsx(pGe.Provider,{value:c,children:X.jsx(R_n,{children:n})})})}),g2n=({autoRotate:n,autoRotateSpeed:e,onStart:t,panSpeed:r,rotateSpeed:i,zoomSpeed:o,enableDamping:s,dampingFactor:a,target:c,onControlsChange:l})=>{const{camera:u,renderer:d}=Wy(),h=q.useMemo(()=>!u||!d?null:new Ien(u,d.domElement),[u,d]);return q.useEffect(()=>(l?.(h??null),()=>l?.(null)),[h,l]),q.useEffect(()=>{if(!h)return;const p=()=>{l?.(h)};return h.addEventListener("change",p),()=>{h.removeEventListener("change",p)}},[h,l]),q.useEffect(()=>{h&&(h.autoRotate=n||!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:V6.ROTATE,MIDDLE:V6.PAN,RIGHT:null},c&&(h.target.set(c[0],c[1],c[2]),h.update()))},[h,n,e,r,i,o,s,a,c]),q.useEffect(()=>{if(!(!h||!t))return h.addEventListener("start",t),()=>{h.removeEventListener("start",t)}},[h,t]),q.useEffect(()=>{if(h)return()=>{h.dispose()}},[h]),fN(()=>{h?.update()},[h]),null},_2n=`
5156
+ `).replace(/d 0\./g,"d 1."),p=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),f=new ben;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||t(c)}).catch(c=>{console.error(c)}),()=>{o=!0}},[n]),e}function V_n({url:n,position:e,rotation:t,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=H_n(n),f=q.useMemo(()=>p&&!(p instanceof Error)?(p.traverse(y=>{if(y instanceof Wi&&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 Wi(new G5(.5,.5,.5),new jm({transparent:!0,color:"red",opacity:.25})),[p,h]),{boardTransformGroup:m}=Zpe({model:f,position:Array.isArray(e)?e:e?[e.x,e.y,e.z]:void 0,rotation:Array.isArray(t)?t:t?[t.x,t.y,t.z]:void 0,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:d});if(p instanceof Error)throw p;return X.jsx(PN,{isHovered:u,onHover:c,onUnhover:l,object:m})}var Qpe,Y_n="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function X_n(n){if(typeof n=="function")return n;if(n&&typeof n=="object"&&"default"in n&&typeof n.default=="function")return n.default;throw new Error("Unable to resolve occt-import-js factory export")}async function G_n(){if(!Qpe){const n=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");Qpe=X_n(n)({locateFile:t=>`${Y_n}/${t}`})}return Qpe}function q_n(n){const e=new Hf;for(const t of n){const r=t.attributes.position?.array??[],i=t.index?.array??[];if(!r.length||!i.length)continue;const o=new nl;o.setAttribute("position",new zo(r,3));const s=t.attributes.normal?.array??[];s.length?o.setAttribute("normal",new zo(s,3)):o.computeVertexNormals(),o.setIndex(i);const a=new jm({color:t.color?new Yr(t.color[0],t.color[1],t.color[2]):new Yr(.82,.82,.82)}),c=new Wi(o,a);c.name=t.name,e.add(c)}return e}async function W_n(n){const e=await fetch(n);if(!e.ok)throw new Error(`Failed to fetch STEP file: ${e.statusText}`);const t=await e.arrayBuffer(),i=(await G_n()).ReadStepFile(new Uint8Array(t),null);if(!i.success||!i.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=q_n(i.meshes),s=new hoe;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 aqe="step-glb-cache:";function K_n(n){const e=new Uint8Array(n),t=32768;let r="";for(let i=0;i<e.length;i+=t){const o=e.subarray(i,i+t);r+=String.fromCharCode(...o)}return btoa(r)}function Z_n(n){const e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)t[r]=e.charCodeAt(r);return t.buffer}function Q_n(n){try{const e=localStorage.getItem(`${aqe}${n}`);return e?Z_n(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function cqe(n,e){try{const t=K_n(e);localStorage.setItem(`${aqe}${n}`,t)}catch(t){console.warn("Failed to write STEP GLB cache",t)}}function J_n(){const n=globalThis;return n.stepUrlToGltfModelConversions||(n.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),n.stepUrlToGltfModelConversions}var e2n=({stepUrl:n,position:e,rotation:t,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:d,isTranslucent:h})=>{const[p,f]=q.useState(null);return q.useEffect(()=>{let m=!0,y=null,g=!0;const _=J_n(),b=Q_n(n);if(b){const E={arrayBuffer:b,blobUrl:URL.createObjectURL(new Blob([b],{type:"model/gltf-binary"}))};return _.completed.set(n,E),y=E.blobUrl,g=!1,f(E.blobUrl),()=>{m=!1,y&&g&&URL.revokeObjectURL(y)}}const v=_.completed.get(n);if(v)return y=v.blobUrl,g=!1,f(v.blobUrl),cqe(n,v.arrayBuffer),()=>{m=!1,y&&g&&URL.revokeObjectURL(y)};let M=_.inProgress.get(n);return M||(M=W_n(n).then(E=>{const A={arrayBuffer:E,blobUrl:URL.createObjectURL(new Blob([E],{type:"model/gltf-binary"}))};return _.completed.set(n,A),_.inProgress.delete(n),A}).catch(E=>{throw _.inProgress.delete(n),E}),_.inProgress.set(n,M)),M.then(E=>{m&&(y=E.blobUrl,g=!1,f(E.blobUrl),cqe(n,E.arrayBuffer))}).catch(E=>{console.error("Failed to convert STEP file to GLB",E),m&&f(null)}),()=>{m=!1,y&&g&&URL.revokeObjectURL(y)}},[n]),p?X.jsx(sqe,{gltfUrl:p,position:e,rotation:t,modelOffset:r,modelRotation:i,sourceCoordinateTransform:o,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:d,isTranslucent:h}):null};function ZU(n,e){let{x:t,y:r,z:i}=n;if(e.axisMapping){const o={x:t,y:r,z:i};e.axisMapping.x&&(t=Jpe(o,e.axisMapping.x)),e.axisMapping.y&&(r=Jpe(o,e.axisMapping.y)),e.axisMapping.z&&(i=Jpe(o,e.axisMapping.z))}if(t*=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=t*s+i*a,l=-t*a+i*s;t=c,i=l}if(e.rotation.z){const o=e.rotation.z*Math.PI/180,s=Math.cos(o),a=Math.sin(o),c=t*s-r*a,l=t*a+r*s;t=c,r=l}}return{x:t,y:r,z:i}}function Jpe(n,e){switch(e){case"x":return n.x;case"y":return n.y;case"z":return n.z;case"-x":return-n.x;case"-y":return-n.y;case"-z":return-n.z;default:return 0}}var efe={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 t2n(n,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return efe.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?efe.STEP_INVERTED:efe.Z_UP_TO_Y_UP_USB_FIX}}function AN(n,e){return t2n(n,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function QU(n){if(!n)return;const e=ZU({x:1,y:0,z:0},n),t=ZU({x:0,y:1,z:0},n),r=ZU({x:0,y:0,z:1},n);return new Do().makeBasis(new Mt(e.x,e.y,e.z),new Mt(t.x,t.y,t.z),new Mt(r.x,r.y,r.z))}function f9(n){return n*Math.PI/180}function n2n(n){if(n==="z+")return[0,0,0];switch(n){case"x+":return[0,f9(-90),0];case"x-":return[0,f9(90),0];case"y+":return[f9(90),0,0];case"y-":return[f9(-90),0,0];case"z-":return[f9(180),0,0];default:return[0,0,0]}}function r2n(n,e,t){if(!n.position)return;let r=n.position.z;return e==="bottom"&&n.position.z>=0&&(r=-(n.position.z+t)),[n.position.x,n.position.y,r]}function i2n(n,e){return n.rotation?[f9(n.rotation.x),f9(n.rotation.y),f9(n.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function o2n(n,e){const t=new Mt(n.x,n.y,n.z),r=new Vy(e[0],e[1],e[2],"XYZ");return t.applyEuler(r),[t.x,t.y,t.z]}function s2n(n,e,t){if(!n.model_origin_position)return[0,0,0];const r=e?ZU(n.model_origin_position,e):n.model_origin_position;return o2n(r,t)}function a2n(n,e){const t=r2n(n,e.layer,e.pcbThickness),r=i2n(n,e.layer),i=AN(n,e.modelType),o=n2n(n.model_board_normal_direction??"z+"),s=s2n(n,i,o);return{position:t,rotation:r,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:o,scale:n.model_unit_to_mm_scale_factor??void 0,fitMode:n.model_object_fit??"contain_within_bounds",size:n.size?[n.size.x,n.size.y,n.size.z]:void 0}}var c2n=n=>n.model_glb_url||n.model_gltf_url?n.model_glb_url?"glb":"gltf":n.model_obj_url||n.model_wrl_url||n.model_stl_url?n.model_wrl_url?"wrl":n.model_stl_url?"stl":"obj":n.model_jscad?"jscad":n.footprinter_string?"footprinter":n.model_step_url?"step":"unknown",l2n=n=>n==="step"?"glb":n,u2n=(n,e)=>{if(n)return e?e(n):n},d2n=(...n)=>n,tfe=class extends ri.Component{constructor(n){super(n),this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},h2n=({error:n,onError:e})=>(q.useEffect(()=>{e(n)},[n,e]),null),lqe=({cad_component:n,circuitJson:e,resolveStaticAsset:t})=>{const r=hGe(e),[i,o]=q.useState(!1),{visibility:s}=Z7(),[a,c]=q.useState(null),l=q.useCallback(G=>{G?.mousePosition?(o(!0),c(G.mousePosition)):(o(!1),c(null))},[]),u=q.useCallback(()=>{o(!1),c(null)},[]),d=q.useMemo(()=>pi(e).source_component.getUsing({source_component_id:n.source_component_id})?.name,[e,n.source_component_id]),h=q.useMemo(()=>e.filter(K=>K.type==="pcb_plated_hole"&&K.pcb_component_id===n.pcb_component_id).length>0,[e,n.pcb_component_id]),p=q.useCallback(G=>u2n(G,t),[t]),f=p(n.model_wrl_url??n.model_stl_url??n.model_obj_url),m=p(n.model_glb_url??n.model_gltf_url),y=p(n.model_step_url),[g,_]=q.useState(0),[b,v]=q.useState(null);q.useEffect(()=>{_(0),v(null)},[n.cad_component_id,f,m,y]);const E=e.find(G=>G.type==="pcb_component"&&G.source_component_id===n.source_component_id)?.layer??"top",A=c2n(n),P=l2n(A),N=n.model_glb_url?"glb":"gltf",C=n.model_wrl_url?"wrl":n.model_stl_url?"stl":"obj",D=q.useMemo(()=>a2n(n,{layer:E,pcbThickness:r,modelType:P}),[n,E,r,P]),I=d2n(...D.rotation),B=D.position,j=q.useMemo(()=>{const G=[];return m&&G.push(X.jsx(sqe,{gltfUrl:m,position:B,rotation:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:QU(AN(n,N)),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:n.show_as_translucent_model},`${n.cad_component_id}-gltf-${m}`)),f&&G.push(X.jsx(V_n,{url:f,position:B,rotation:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:QU(AN(n,C)),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:n.show_as_translucent_model},`${n.cad_component_id}-mixed-${f}`)),y&&!n.model_jscad&&!n.footprinter_string&&G.push(X.jsx(e2n,{stepUrl:y,position:B,rotation:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:QU(AN(n,P)),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:n.show_as_translucent_model},`${n.cad_component_id}-step-${y}`)),G},[B,n.cad_component_id,n.footprinter_string,n.model_jscad,n.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 U=null;if(j.length>0){if(g>=j.length){if(b)throw b;return null}U=X.jsx(tfe,{fallback:({error:G})=>X.jsx(h2n,{error:G,onError:K=>{v(K),_(ee=>Math.max(ee,g+1))}}),children:j[g]},`${n.cad_component_id}-fallback-${g}`)}else n.model_jscad?U=X.jsx(B_n,{jscadPlan:n.model_jscad,positionOffset:B,rotationOffset:I,modelOffset:D.modelPosition,modelRotation:D.modelRotation,sourceCoordinateTransform:QU(AN(n,"jscad")),scale:D.scale,modelSize:D.size,modelFitMode:D.fitMode,onHover:l,onUnhover:u,isHovered:i,isTranslucent:n.show_as_translucent_model},n.cad_component_id):n.footprinter_string&&(U=X.jsx(k_n,{positionOffset:B,rotationOffset:I,footprint:n.footprinter_string,scale:D.scale,onHover:l,onUnhover:u,isHovered:i,isTranslucent:n.show_as_translucent_model}));if(n.show_as_translucent_model){if(!s.translucentModels)return null}else if(h&&!s.throughHoleModels||!h&&!s.smtModels)return null;return X.jsxs(X.Fragment,{children:[U,i&&a?X.jsx(fGe,{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]})},uqe={version:"0.0.549"};function p2n(n){n.querySelectorAll("canvas").forEach(e=>e.remove())}var f2n=n=>{n.outputColorSpace=F5,n.toneMapping=$ke,n.toneMappingExposure=1},dqe="cadViewerCameraStateSession",hqe=(n,e)=>{try{const t={position:n.position.toArray(),quaternion:n.quaternion.toArray(),up:n.up.toArray(),fov:n.fov??50,target:e.target.toArray()};sessionStorage.setItem(dqe,JSON.stringify(t))}catch(t){console.warn("Failed to save camera:",t)}},nfe=(n,e)=>{try{const t=sessionStorage.getItem(dqe);if(!t)return!1;const r=JSON.parse(t);if(n.position.fromArray(r.position),n.quaternion.fromArray(r.quaternion),n.up.fromArray(r.up),"fov"in n){const i=n;i.fov=r.fov,i.updateProjectionMatrix?.()}return e.target.fromArray(r.target),e.update(),n.updateMatrixWorld(),!0}catch(t){return console.warn("Failed to restore camera:",t),!1}},pqe=q.createContext(void 0),m2n=({children:n,defaultTarget:e,initialCameraPosition:t})=>{const r=q.useRef(null),i=q.useRef(null),[o,s]=q.useState(null),[a,c]=q.useState("perspective"),[l,u]=q.useState(t??null),[d,h]=q.useState(new Vy(0,0,0)),p=q.useMemo(()=>{const[g,_,b]=t??[5,-5,5],v=Math.hypot(g-e.x,_-e.y,b-e.z);return v>0?v:5},[t,e]),f=q.useCallback(g=>{const _=[e.x,e.y,e.z],b=i.current,v=r.current;let M=p;switch(b&&v&&(M=b.position.distanceTo(v.target)),g){case"Top Center Angled":{const E=M/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+M],target:_,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-M*.6,e.y-M*.6,e.z+M*.6],target:_,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+M*.6,e.y-M*.6,e.z+M*.6],target:_,up:[0,0,1]};case"Left Sideview":return{position:[e.x-M,e.y,e.z],target:_,up:[0,0,1]};case"Right Sideview":return{position:[e.x+M,e.y,e.z],target:_,up:[0,0,1]};case"Front":return{position:[e.x,e.y-M,e.z],target:_,up:[0,0,1]};default:return null}},[p,e,i,r]),m=q.useCallback(g=>{r.current=g},[]),y=q.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:hqe,loadCameraFromSession:nfe}),[e,p,o,f,m,a,l,d]);return X.jsx(pqe.Provider,{value:y,children:n})},m9=()=>{const n=q.useContext(pqe);if(!n)throw new Error("useCameraController must be used within a CameraControllerProvider");return n},y2n=q.forwardRef(({children:n,scene:e,camera:t,style:r,onCreated:i},o)=>{const{cameraType:s}=m9(),a=q.useRef(null),[c,l]=q.useState(null),u=q.useRef([]),d=q.useRef(void 0);d.current=i;const h=q.useRef(null),p=q.useCallback(g=>{u.current.push(g)},[]),f=q.useCallback(g=>{u.current=u.current.filter(_=>_!==g)},[]),m=q.useMemo(()=>new O7,[]);e?.up&&m.up.set(e.up.x,e.up.y,e.up.z);const y=q.useRef(new tl);return q.useImperativeHandle(o,()=>y.current),q.useEffect(()=>{if(!a.current)return;p2n(a.current);const g=new Ej({antialias:!0,alpha:!0});f2n(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 Uf(75,_,.1,1e3):new SR(-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)):(t?.up&&b.up.set(t.up[0],t.up[1],t.up[2]),t?.position&&b.position.set(t.position[0],t.position[1],t.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 M=new nJt,E=()=>{const P=M.getElapsedTime(),N=M.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 Uf?b.aspect=P:b instanceof SR&&(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]),X.jsx("div",{ref:a,style:{width:"100%",height:"100%",...r},children:c&&X.jsx(pGe.Provider,{value:c,children:X.jsx(R_n,{children:n})})})}),g2n=({autoRotate:n,autoRotateSpeed:e,onStart:t,panSpeed:r,rotateSpeed:i,zoomSpeed:o,enableDamping:s,dampingFactor:a,target:c,onControlsChange:l})=>{const{camera:u,renderer:d}=Wy(),h=q.useMemo(()=>!u||!d?null:new Ien(u,d.domElement),[u,d]);return q.useEffect(()=>(l?.(h??null),()=>l?.(null)),[h,l]),q.useEffect(()=>{if(!h)return;const p=()=>{l?.(h)};return h.addEventListener("change",p),()=>{h.removeEventListener("change",p)}},[h,l]),q.useEffect(()=>{h&&(h.autoRotate=n||!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:V6.ROTATE,MIDDLE:V6.PAN,RIGHT:null},c&&(h.target.set(c[0],c[1],c[2]),h.update()))},[h,n,e,r,i,o,s,a,c]),q.useEffect(()=>{if(!(!h||!t))return h.addEventListener("start",t),()=>{h.removeEventListener("start",t)}},[h,t]),q.useEffect(()=>{if(h)return()=>{h.dispose()}},[h]),fN(()=>{h?.update()},[h]),null},_2n=`
5157
5157
  varying vec3 worldPosition;
5158
5158
  void main() {
5159
5159
  worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
@@ -5687,7 +5687,7 @@ test("${l} should solve problem correctly", () => {
5687
5687
  // Add more specific assertions based on expected output
5688
5688
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5689
5689
  })
5690
- `,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 ${n.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}r(!1)};return X.jsxs("div",{className:`relative ${e}`,ref:i,children:[X.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>r(!t),title:`Download options for ${n.constructor.name}`,children:n.constructor.name}),t&&X.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:[X.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),X.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),X.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Vst=n=>n.activeSubSolver?[n,...Vst(n.activeSubSolver)]:[n],rzn=({solver:n})=>{const e=Vst(n);return X.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((t,r)=>X.jsxs("div",{className:"flex items-center",children:[r>0&&X.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),X.jsx(nzn,{solver:t})]},t.constructor.name))})},izn=({solver:n,triggerRender:e,animationSpeed:t=25,onSolverStarted:r,onSolverCompleted:i})=>{const[o,s]=q.useReducer(m=>!m,!1),a=q.useRef(void 0),c=()=>{!n.solved&&!n.failed&&(n.step(),e())},l=()=>{!n.solved&&!n.failed&&(r&&r(n),n.solve(),e(),i&&i(n))},u=()=>{o?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(n.solved||n.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),i&&n.solved&&i(n);return}n.step(),e()},t))},d=()=>{const m=n;if(m.getCurrentPhase&&!n.solved&&!n.failed){const y=m.getCurrentPhase();for(;m.getCurrentPhase()===y&&!n.solved&&!n.failed;)n.step();e()}},h=()=>{if(n.solved||n.failed||o)return;const m=window.prompt("Step until which iteration?",`${n.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(;n.iterations<y&&!n.solved&&!n.failed;)n.step();e(),n.solved&&i&&i(n)};q.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),q.useEffect(()=>{(n.solved||n.failed)&&o&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[n.solved,n.failed,o]);const p=n.getCurrentPhase!==void 0,f=p?n.getCurrentPhase():null;return X.jsxs("div",{className:"space-y-2 p-2 border-b",children:[X.jsx("div",{className:"flex items-center",children:X.jsx(rzn,{solver:n})}),X.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[X.jsx("button",{onClick:c,disabled:n.solved||n.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"}),X.jsx("button",{onClick:l,disabled:n.solved||n.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"}),X.jsx("button",{onClick:u,disabled:n.solved||n.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"}),X.jsx("button",{onClick:h,disabled:n.solved||n.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&&X.jsx("button",{onClick:d,disabled:n.solved||n.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"}),X.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",n.iterations]}),n.timeToSolve!==void 0&&X.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(n.timeToSolve/1e3).toFixed(3),"s"]}),f&&X.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",X.jsx("span",{className:"font-medium",children:f})]}),n.solved&&X.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),n.failed&&X.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),n.error&&X.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",n.error]})]})},ozn=(n,e,t)=>{const r=n.currentPipelineStepIndex;return e<r?"Completed":e===r&&n.activeSubSolver?n.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},szn=(n,e)=>{const r=n.pipelineDef[e].solverName,i=ozn(n,e),o=n[r],s=n.firstIterationOfPhase?.[r]??null,a=n.iterations;let c=0;if(i==="Completed"){const h=n.pipelineDef[e+1],p=h?n.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=n.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}},azn=({status:n})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return X.jsx("span",{className:`font-medium ${e[n]}`,children:n})},czn=({progress:n})=>{if(n===0)return null;const e=Math.round(n*100);return X.jsxs("div",{className:"flex items-center gap-2",children:[X.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:X.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),X.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},lzn=n=>Object.entries(n).map(([e,t])=>`${e}: ${t}`).join(", "),uzn=({stats:n})=>{if(!n||Object.keys(n).length===0)return X.jsx("span",{children:"-"});const e=Object.entries(n),t=lzn(n);return X.jsxs("details",{className:"cursor-pointer",children:[X.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),X.jsx("div",{className:"mt-1 text-xs",children:e.map(([r,i])=>X.jsxs("div",{children:[r,": ",String(i)]},r))})]})},qye=n=>{if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(qye);const e={};for(const[t,r]of Object.entries(n))t.startsWith("_")||(e[t]=qye(r));return e},dzn=(n,e)=>{try{if(typeof n.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const t=qye(n.getConstructorParams()),r=new Blob([JSON.stringify(t,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(t){alert(`Error downloading input for ${e}: ${t instanceof Error?t.message:String(t)}`)}},hzn=({solver:n,onStepUntilPhase:e,onDownloadInput:t})=>{const r=n.pipelineDef.map((a,c)=>szn(n,c)),i=a=>{e?.(a)},o=a=>{a.solverInstance&&(t?t(a.solverInstance,a.name):dzn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return X.jsxs("div",{className:"border-t border-gray-200",children:[X.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:X.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),X.jsx("div",{className:"overflow-x-auto",children:X.jsxs("table",{className:"w-full text-sm",children:[X.jsx("thead",{children:X.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),X.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",X.jsx("sub",{children:"0"})]}),X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),X.jsx("tbody",{children:r.map(a=>X.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[X.jsx("td",{className:"px-4 py-2",children:X.jsxs("div",{className:"flex items-center gap-2",children:[X.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),X.jsx("button",{onClick:()=>i(a.name),disabled:a.status==="Completed"||n.solved||n.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:X.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:X.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"})})}),X.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),X.jsx("td",{className:"px-4 py-2",children:X.jsx(azn,{status:a.status})}),X.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),X.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),X.jsx("td",{className:"px-4 py-2",children:X.jsx(czn,{progress:a.progress})}),X.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),X.jsx("td",{className:"px-4 py-2 text-gray-500",children:X.jsx(uzn,{stats:a.stats})}),X.jsx("td",{className:"px-4 py-2",children:a.solverInstance?X.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:[X.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:X.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"})}),X.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},pzn=class extends ri.Component{constructor(n){super(n),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n){console.error("InteractiveGraphics render error:",n)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function fzn({graphics:n}){const e=n.points??[],t=n.lines??[],r=n.rects??[],i=n.circles??[],o=n.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 t){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 X.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)=>X.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}`)),t.map((y,g)=>X.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)=>X.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)=>X.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)=>X.jsx("text",{x:y.x??0,y:y.y??0,fontSize:y.fontSize??10,fill:y.color??"black",children:y.text??""},`text-${g}`))]})}var mzn=({solver:n,animationSpeed:e=25,onSolverStarted:t,onSolverCompleted:r})=>{const[i,o]=q.useReducer(u=>u+1,0),s=q.useMemo(()=>{try{return n.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[n,i]),a=q.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);q.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=n.pipelineDef!==void 0,l=u=>{const d=n;if(!n.solved&&!n.failed){for(;!n.solved&&!n.failed&&d.currentPipelineStepIndex<=d.pipelineDef.findIndex(h=>h.solverName===u);)n.step();o()}};return X.jsxs("div",{children:[X.jsx(izn,{solver:n,triggerRender:o,animationSpeed:e,onSolverStarted:t,onSolverCompleted:r}),a?X.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):X.jsx(pzn,{fallback:X.jsx(fzn,{graphics:s}),children:X.jsx(tzn,{graphics:s})}),c&&X.jsx(hzn,{solver:n,onStepUntilPhase:l})]})};const yzn=()=>{q.useEffect(()=>{const n="tailwind-cdn-script";if(document.getElementById(n)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const t=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),t)return;const r=document.createElement("script");r.id=n,r.src="https://cdn.tailwindcss.com",document.head.appendChild(r)},[])},gzn=n=>n.toLowerCase().includes("pack")?k6n:n.toLowerCase().includes("rout")?z6n:g6n,_zn=({solverEvents:n=[]})=>{const[e,t]=q.useState(null);yzn();const r=q.useMemo(()=>{const a=new Map;for(const c of n){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[n]),i=q.useMemo(()=>Array.from(r.keys()),[r]),o=e?r.get(e):null,s=q.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const a=pne[o.solverName];if(!a)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(pne).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 n.length===0?X.jsx("div",{className:"rf-p-4",children:X.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:X.jsxs("div",{className:"rf-p-4",children:[X.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),X.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."})]})})}):X.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[X.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[X.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 X.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:()=>t(a),children:(()=>{const u=gzn(c.solverName);return X.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[X.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),X.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[X.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),X.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),X.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?X.jsx(Wx,{fallback:X.jsx("div",{className:"rf-p-4",children:X.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[X.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),X.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:X.jsx(mzn,{solver:s.instance})}):X.jsxs("div",{className:"rf-p-4",children:[X.jsxs("div",{className:"rf-mb-4",children:[X.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),X.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&X.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:X.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),X.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[X.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:X.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),X.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:X.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)})})]})]}):X.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:X.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Yst=({errorMessage:n,errorStack:e,circuitJsonErrors:t})=>{q.useEffect(()=>{if(n){const r=new Error(n);e&&(r.stack=e);try{jB.captureException(r)}catch{}}},[n,e]),q.useEffect(()=>{if(t&&t.length>0)for(const r of t){const i=new Error(r.message||"Circuit JSON Error");r.stack&&(i.stack=r.stack);try{jB.captureException(i,{error_type:r.type})}catch{}}},[t])},Xst="0.0.1783",xzn={version:Xst},RY=PAe()(AAe(n=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{n({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),bzn=n=>{const[e,t]=q.useState([]),[r,i]=q.useState(null),[o,s]=q.useState(""),[a,c]=YE("eval-version-selection",null),l=RY(p=>p.setLastRunEvalVersion),u=RY(p=>p.lastRunEvalVersion);return q.useEffect(()=>{n&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(p=>p.json()).then(p=>{if(Array.isArray(p?.versions)){let f=[...p.versions];p.tags?.latest&&(i(p.tags.latest),f=f.filter(m=>m!==p.tags.latest)),t(f)}}).catch(()=>{})},[n]),q.useEffect(()=>{n&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):r&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,l(r)))},[n,a,r]),{versions:q.useMemo(()=>e.filter(p=>p.includes(o)).slice(0,50),[e,o]),latestVersion:r,lastRunEvalVersion:u,search:o,setSearch:s,selectVersion:p=>{c(p),s("")}}},vzn=({snippetNames:n,onSelect:e,onCancel:t,isOpen:r})=>{const[i,o]=q.useState(""),[s,a]=q.useState("");if(!r)return null;const c=n.filter(d=>d.toLowerCase().includes(s.toLowerCase())),l=s&&!n.includes(s),u=d=>{d.key==="Enter"&&(c.length===1?o(c[0]):l&&o(s))};return X.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:X.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[X.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),X.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:d=>a(d.target.value),onKeyDown:u}),X.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(d=>X.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===d?"bg-blue-50":""}`,onClick:()=>o(d),children:d},d)),l&&X.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),X.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[X.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:t,children:"Cancel"}),X.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},wzn=n=>{const e=q.useRef(null),t=qu(r=>r.recentEvents);q.useEffect(()=>{if(t.length===0)return;const r=t[0];r.event_id!==e.current&&(n(r),e.current=r.event_id)},[t,n])};function Szn(n){const e=Ezn(n),t=q.forwardRef((r,i)=>{const{children:o,...s}=r,a=q.Children.toArray(o),c=a.find(Tzn);if(c){const l=c.props.children,u=a.map(d=>d===c?q.Children.count(l)>1?q.Children.only(null):q.isValidElement(l)?l.props.children:null:d);return X.jsx(e,{...s,ref:i,children:q.isValidElement(l)?q.cloneElement(l,void 0,u):null})}return X.jsx(e,{...s,ref:i,children:o})});return t.displayName=`${n}.Slot`,t}function Ezn(n){const e=q.forwardRef((t,r)=>{const{children:i,...o}=t;if(q.isValidElement(i)){const s=Pzn(i),a=Czn(o,i.props);return i.type!==q.Fragment&&(a.ref=r?d_(r,s):s),q.cloneElement(i,a)}return q.Children.count(i)>1?q.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var Mzn=Symbol("radix.slottable");function Tzn(n){return q.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===Mzn}function Czn(n,e){const t={...e};for(const r in e){const i=n[r],o=e[r];/^on[A-Z]/.test(r)?i&&o?t[r]=(...a)=>{const c=o(...a);return i(...a),c}:i&&(t[r]=i):r==="style"?t[r]={...i,...o}:r==="className"&&(t[r]=[i,o].filter(Boolean).join(" "))}return{...n,...t}}function Pzn(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var NY="Dialog",[Gst,qst]=D5(NY),[Azn,c3]=Gst(NY),Wst=n=>{const{__scopeDialog:e,children:t,open:r,defaultOpen:i,onOpenChange:o,modal:s=!0}=n,a=q.useRef(null),c=q.useRef(null),[l,u]=O6({prop:r,defaultProp:i??!1,onChange:o,caller:NY});return X.jsx(Azn,{scope:e,triggerRef:a,contentRef:c,contentId:Dm(),titleId:Dm(),descriptionId:Dm(),open:l,onOpenChange:u,onOpenToggle:q.useCallback(()=>u(d=>!d),[u]),modal:s,children:t})};Wst.displayName=NY;var Kst="DialogTrigger",Zst=q.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=c3(Kst,t),o=Wu(e,i.triggerRef);return X.jsx(vc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Zye(i.open),...r,ref:o,onClick:zi(n.onClick,i.onOpenToggle)})});Zst.displayName=Kst;var Wye="DialogPortal",[Rzn,Qst]=Gst(Wye,{forceMount:void 0}),Jst=n=>{const{__scopeDialog:e,forceMount:t,children:r,container:i}=n,o=c3(Wye,e);return X.jsx(Rzn,{scope:e,forceMount:t,children:q.Children.map(r,s=>X.jsx(m2,{present:t||o.open,children:X.jsx(WH,{asChild:!0,container:i,children:s})}))})};Jst.displayName=Wye;var kY="DialogOverlay",eat=q.forwardRef((n,e)=>{const t=Qst(kY,n.__scopeDialog),{forceMount:r=t.forceMount,...i}=n,o=c3(kY,n.__scopeDialog);return o.modal?X.jsx(m2,{present:r||o.open,children:X.jsx(kzn,{...i,ref:e})}):null});eat.displayName=kY;var Nzn=Szn("DialogOverlay.RemoveScroll"),kzn=q.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=c3(kY,t);return X.jsx(rV,{as:Nzn,allowPinchZoom:!0,shards:[i.contentRef],children:X.jsx(vc.div,{"data-state":Zye(i.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Dw="DialogContent",tat=q.forwardRef((n,e)=>{const t=Qst(Dw,n.__scopeDialog),{forceMount:r=t.forceMount,...i}=n,o=c3(Dw,n.__scopeDialog);return X.jsx(m2,{present:r||o.open,children:o.modal?X.jsx(Ozn,{...i,ref:e}):X.jsx(Izn,{...i,ref:e})})});tat.displayName=Dw;var Ozn=q.forwardRef((n,e)=>{const t=c3(Dw,n.__scopeDialog),r=q.useRef(null),i=Wu(e,t.contentRef,r);return q.useEffect(()=>{const o=r.current;if(o)return bme(o)},[]),X.jsx(nat,{...n,ref:i,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:zi(n.onCloseAutoFocus,o=>{o.preventDefault(),t.triggerRef.current?.focus()}),onPointerDownOutside:zi(n.onPointerDownOutside,o=>{const s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:zi(n.onFocusOutside,o=>o.preventDefault())})}),Izn=q.forwardRef((n,e)=>{const t=c3(Dw,n.__scopeDialog),r=q.useRef(!1),i=q.useRef(!1);return X.jsx(nat,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{n.onCloseAutoFocus?.(o),o.defaultPrevented||(r.current||t.triggerRef.current?.focus(),o.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:o=>{n.onInteractOutside?.(o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=o.target;t.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})}),nat=q.forwardRef((n,e)=>{const{__scopeDialog:t,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...s}=n,a=c3(Dw,t),c=q.useRef(null),l=Wu(e,c);return tme(),X.jsxs(X.Fragment,{children:[X.jsx(DH,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:X.jsx(KN,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Zye(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),X.jsxs(X.Fragment,{children:[X.jsx(Dzn,{titleId:a.titleId}),X.jsx($zn,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Kye="DialogTitle",rat=q.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=c3(Kye,t);return X.jsx(vc.h2,{id:i.titleId,...r,ref:e})});rat.displayName=Kye;var iat="DialogDescription",oat=q.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=c3(iat,t);return X.jsx(vc.p,{id:i.descriptionId,...r,ref:e})});oat.displayName=iat;var sat="DialogClose",aat=q.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=c3(sat,t);return X.jsx(vc.button,{type:"button",...r,ref:e,onClick:zi(n.onClick,()=>i.onOpenChange(!1))})});aat.displayName=sat;function Zye(n){return n?"open":"closed"}var cat="DialogTitleWarning",[Lzn,lat]=OUt(cat,{contentName:Dw,titleName:Kye,docsSlug:"dialog"}),Dzn=({titleId:n})=>{const e=lat(cat),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
5690
+ `,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 ${n.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}r(!1)};return X.jsxs("div",{className:`relative ${e}`,ref:i,children:[X.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>r(!t),title:`Download options for ${n.constructor.name}`,children:n.constructor.name}),t&&X.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:[X.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),X.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),X.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Vst=n=>n.activeSubSolver?[n,...Vst(n.activeSubSolver)]:[n],rzn=({solver:n})=>{const e=Vst(n);return X.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((t,r)=>X.jsxs("div",{className:"flex items-center",children:[r>0&&X.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),X.jsx(nzn,{solver:t})]},t.constructor.name))})},izn=({solver:n,triggerRender:e,animationSpeed:t=25,onSolverStarted:r,onSolverCompleted:i})=>{const[o,s]=q.useReducer(m=>!m,!1),a=q.useRef(void 0),c=()=>{!n.solved&&!n.failed&&(n.step(),e())},l=()=>{!n.solved&&!n.failed&&(r&&r(n),n.solve(),e(),i&&i(n))},u=()=>{o?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(n.solved||n.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),i&&n.solved&&i(n);return}n.step(),e()},t))},d=()=>{const m=n;if(m.getCurrentPhase&&!n.solved&&!n.failed){const y=m.getCurrentPhase();for(;m.getCurrentPhase()===y&&!n.solved&&!n.failed;)n.step();e()}},h=()=>{if(n.solved||n.failed||o)return;const m=window.prompt("Step until which iteration?",`${n.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(;n.iterations<y&&!n.solved&&!n.failed;)n.step();e(),n.solved&&i&&i(n)};q.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),q.useEffect(()=>{(n.solved||n.failed)&&o&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[n.solved,n.failed,o]);const p=n.getCurrentPhase!==void 0,f=p?n.getCurrentPhase():null;return X.jsxs("div",{className:"space-y-2 p-2 border-b",children:[X.jsx("div",{className:"flex items-center",children:X.jsx(rzn,{solver:n})}),X.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[X.jsx("button",{onClick:c,disabled:n.solved||n.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"}),X.jsx("button",{onClick:l,disabled:n.solved||n.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"}),X.jsx("button",{onClick:u,disabled:n.solved||n.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"}),X.jsx("button",{onClick:h,disabled:n.solved||n.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&&X.jsx("button",{onClick:d,disabled:n.solved||n.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"}),X.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",n.iterations]}),n.timeToSolve!==void 0&&X.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(n.timeToSolve/1e3).toFixed(3),"s"]}),f&&X.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",X.jsx("span",{className:"font-medium",children:f})]}),n.solved&&X.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),n.failed&&X.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),n.error&&X.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",n.error]})]})},ozn=(n,e,t)=>{const r=n.currentPipelineStepIndex;return e<r?"Completed":e===r&&n.activeSubSolver?n.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},szn=(n,e)=>{const r=n.pipelineDef[e].solverName,i=ozn(n,e),o=n[r],s=n.firstIterationOfPhase?.[r]??null,a=n.iterations;let c=0;if(i==="Completed"){const h=n.pipelineDef[e+1],p=h?n.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=n.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}},azn=({status:n})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return X.jsx("span",{className:`font-medium ${e[n]}`,children:n})},czn=({progress:n})=>{if(n===0)return null;const e=Math.round(n*100);return X.jsxs("div",{className:"flex items-center gap-2",children:[X.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:X.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),X.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},lzn=n=>Object.entries(n).map(([e,t])=>`${e}: ${t}`).join(", "),uzn=({stats:n})=>{if(!n||Object.keys(n).length===0)return X.jsx("span",{children:"-"});const e=Object.entries(n),t=lzn(n);return X.jsxs("details",{className:"cursor-pointer",children:[X.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),X.jsx("div",{className:"mt-1 text-xs",children:e.map(([r,i])=>X.jsxs("div",{children:[r,": ",String(i)]},r))})]})},qye=n=>{if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(qye);const e={};for(const[t,r]of Object.entries(n))t.startsWith("_")||(e[t]=qye(r));return e},dzn=(n,e)=>{try{if(typeof n.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const t=qye(n.getConstructorParams()),r=new Blob([JSON.stringify(t,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(t){alert(`Error downloading input for ${e}: ${t instanceof Error?t.message:String(t)}`)}},hzn=({solver:n,onStepUntilPhase:e,onDownloadInput:t})=>{const r=n.pipelineDef.map((a,c)=>szn(n,c)),i=a=>{e?.(a)},o=a=>{a.solverInstance&&(t?t(a.solverInstance,a.name):dzn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return X.jsxs("div",{className:"border-t border-gray-200",children:[X.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:X.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),X.jsx("div",{className:"overflow-x-auto",children:X.jsxs("table",{className:"w-full text-sm",children:[X.jsx("thead",{children:X.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),X.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",X.jsx("sub",{children:"0"})]}),X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),X.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),X.jsx("tbody",{children:r.map(a=>X.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[X.jsx("td",{className:"px-4 py-2",children:X.jsxs("div",{className:"flex items-center gap-2",children:[X.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),X.jsx("button",{onClick:()=>i(a.name),disabled:a.status==="Completed"||n.solved||n.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:X.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:X.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"})})}),X.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),X.jsx("td",{className:"px-4 py-2",children:X.jsx(azn,{status:a.status})}),X.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),X.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),X.jsx("td",{className:"px-4 py-2",children:X.jsx(czn,{progress:a.progress})}),X.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),X.jsx("td",{className:"px-4 py-2 text-gray-500",children:X.jsx(uzn,{stats:a.stats})}),X.jsx("td",{className:"px-4 py-2",children:a.solverInstance?X.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:[X.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:X.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"})}),X.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},pzn=class extends ri.Component{constructor(n){super(n),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n){console.error("InteractiveGraphics render error:",n)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function fzn({graphics:n}){const e=n.points??[],t=n.lines??[],r=n.rects??[],i=n.circles??[],o=n.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 t){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 X.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)=>X.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}`)),t.map((y,g)=>X.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)=>X.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)=>X.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)=>X.jsx("text",{x:y.x??0,y:y.y??0,fontSize:y.fontSize??10,fill:y.color??"black",children:y.text??""},`text-${g}`))]})}var mzn=({solver:n,animationSpeed:e=25,onSolverStarted:t,onSolverCompleted:r})=>{const[i,o]=q.useReducer(u=>u+1,0),s=q.useMemo(()=>{try{return n.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[n,i]),a=q.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);q.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=n.pipelineDef!==void 0,l=u=>{const d=n;if(!n.solved&&!n.failed){for(;!n.solved&&!n.failed&&d.currentPipelineStepIndex<=d.pipelineDef.findIndex(h=>h.solverName===u);)n.step();o()}};return X.jsxs("div",{children:[X.jsx(izn,{solver:n,triggerRender:o,animationSpeed:e,onSolverStarted:t,onSolverCompleted:r}),a?X.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):X.jsx(pzn,{fallback:X.jsx(fzn,{graphics:s}),children:X.jsx(tzn,{graphics:s})}),c&&X.jsx(hzn,{solver:n,onStepUntilPhase:l})]})};const yzn=()=>{q.useEffect(()=>{const n="tailwind-cdn-script";if(document.getElementById(n)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const t=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),t)return;const r=document.createElement("script");r.id=n,r.src="https://cdn.tailwindcss.com",document.head.appendChild(r)},[])},gzn=n=>n.toLowerCase().includes("pack")?k6n:n.toLowerCase().includes("rout")?z6n:g6n,_zn=({solverEvents:n=[]})=>{const[e,t]=q.useState(null);yzn();const r=q.useMemo(()=>{const a=new Map;for(const c of n){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[n]),i=q.useMemo(()=>Array.from(r.keys()),[r]),o=e?r.get(e):null,s=q.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const a=pne[o.solverName];if(!a)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(pne).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 n.length===0?X.jsx("div",{className:"rf-p-4",children:X.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:X.jsxs("div",{className:"rf-p-4",children:[X.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),X.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."})]})})}):X.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[X.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[X.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 X.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:()=>t(a),children:(()=>{const u=gzn(c.solverName);return X.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[X.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),X.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[X.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),X.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),X.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?X.jsx(Wx,{fallback:X.jsx("div",{className:"rf-p-4",children:X.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[X.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),X.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:X.jsx(mzn,{solver:s.instance})}):X.jsxs("div",{className:"rf-p-4",children:[X.jsxs("div",{className:"rf-mb-4",children:[X.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),X.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&X.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:X.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),X.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[X.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:X.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),X.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:X.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)})})]})]}):X.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:X.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Yst=({errorMessage:n,errorStack:e,circuitJsonErrors:t})=>{q.useEffect(()=>{if(n){const r=new Error(n);e&&(r.stack=e);try{jB.captureException(r)}catch{}}},[n,e]),q.useEffect(()=>{if(t&&t.length>0)for(const r of t){const i=new Error(r.message||"Circuit JSON Error");r.stack&&(i.stack=r.stack);try{jB.captureException(i,{error_type:r.type})}catch{}}},[t])},Xst="0.0.1784",xzn={version:Xst},RY=PAe()(AAe(n=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{n({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),bzn=n=>{const[e,t]=q.useState([]),[r,i]=q.useState(null),[o,s]=q.useState(""),[a,c]=YE("eval-version-selection",null),l=RY(p=>p.setLastRunEvalVersion),u=RY(p=>p.lastRunEvalVersion);return q.useEffect(()=>{n&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(p=>p.json()).then(p=>{if(Array.isArray(p?.versions)){let f=[...p.versions];p.tags?.latest&&(i(p.tags.latest),f=f.filter(m=>m!==p.tags.latest)),t(f)}}).catch(()=>{})},[n]),q.useEffect(()=>{n&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):r&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,l(r)))},[n,a,r]),{versions:q.useMemo(()=>e.filter(p=>p.includes(o)).slice(0,50),[e,o]),latestVersion:r,lastRunEvalVersion:u,search:o,setSearch:s,selectVersion:p=>{c(p),s("")}}},vzn=({snippetNames:n,onSelect:e,onCancel:t,isOpen:r})=>{const[i,o]=q.useState(""),[s,a]=q.useState("");if(!r)return null;const c=n.filter(d=>d.toLowerCase().includes(s.toLowerCase())),l=s&&!n.includes(s),u=d=>{d.key==="Enter"&&(c.length===1?o(c[0]):l&&o(s))};return X.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:X.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[X.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),X.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:d=>a(d.target.value),onKeyDown:u}),X.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(d=>X.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===d?"bg-blue-50":""}`,onClick:()=>o(d),children:d},d)),l&&X.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),X.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[X.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:t,children:"Cancel"}),X.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},wzn=n=>{const e=q.useRef(null),t=qu(r=>r.recentEvents);q.useEffect(()=>{if(t.length===0)return;const r=t[0];r.event_id!==e.current&&(n(r),e.current=r.event_id)},[t,n])};function Szn(n){const e=Ezn(n),t=q.forwardRef((r,i)=>{const{children:o,...s}=r,a=q.Children.toArray(o),c=a.find(Tzn);if(c){const l=c.props.children,u=a.map(d=>d===c?q.Children.count(l)>1?q.Children.only(null):q.isValidElement(l)?l.props.children:null:d);return X.jsx(e,{...s,ref:i,children:q.isValidElement(l)?q.cloneElement(l,void 0,u):null})}return X.jsx(e,{...s,ref:i,children:o})});return t.displayName=`${n}.Slot`,t}function Ezn(n){const e=q.forwardRef((t,r)=>{const{children:i,...o}=t;if(q.isValidElement(i)){const s=Pzn(i),a=Czn(o,i.props);return i.type!==q.Fragment&&(a.ref=r?d_(r,s):s),q.cloneElement(i,a)}return q.Children.count(i)>1?q.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var Mzn=Symbol("radix.slottable");function Tzn(n){return q.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===Mzn}function Czn(n,e){const t={...e};for(const r in e){const i=n[r],o=e[r];/^on[A-Z]/.test(r)?i&&o?t[r]=(...a)=>{const c=o(...a);return i(...a),c}:i&&(t[r]=i):r==="style"?t[r]={...i,...o}:r==="className"&&(t[r]=[i,o].filter(Boolean).join(" "))}return{...n,...t}}function Pzn(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var NY="Dialog",[Gst,qst]=D5(NY),[Azn,c3]=Gst(NY),Wst=n=>{const{__scopeDialog:e,children:t,open:r,defaultOpen:i,onOpenChange:o,modal:s=!0}=n,a=q.useRef(null),c=q.useRef(null),[l,u]=O6({prop:r,defaultProp:i??!1,onChange:o,caller:NY});return X.jsx(Azn,{scope:e,triggerRef:a,contentRef:c,contentId:Dm(),titleId:Dm(),descriptionId:Dm(),open:l,onOpenChange:u,onOpenToggle:q.useCallback(()=>u(d=>!d),[u]),modal:s,children:t})};Wst.displayName=NY;var Kst="DialogTrigger",Zst=q.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=c3(Kst,t),o=Wu(e,i.triggerRef);return X.jsx(vc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Zye(i.open),...r,ref:o,onClick:zi(n.onClick,i.onOpenToggle)})});Zst.displayName=Kst;var Wye="DialogPortal",[Rzn,Qst]=Gst(Wye,{forceMount:void 0}),Jst=n=>{const{__scopeDialog:e,forceMount:t,children:r,container:i}=n,o=c3(Wye,e);return X.jsx(Rzn,{scope:e,forceMount:t,children:q.Children.map(r,s=>X.jsx(m2,{present:t||o.open,children:X.jsx(WH,{asChild:!0,container:i,children:s})}))})};Jst.displayName=Wye;var kY="DialogOverlay",eat=q.forwardRef((n,e)=>{const t=Qst(kY,n.__scopeDialog),{forceMount:r=t.forceMount,...i}=n,o=c3(kY,n.__scopeDialog);return o.modal?X.jsx(m2,{present:r||o.open,children:X.jsx(kzn,{...i,ref:e})}):null});eat.displayName=kY;var Nzn=Szn("DialogOverlay.RemoveScroll"),kzn=q.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=c3(kY,t);return X.jsx(rV,{as:Nzn,allowPinchZoom:!0,shards:[i.contentRef],children:X.jsx(vc.div,{"data-state":Zye(i.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Dw="DialogContent",tat=q.forwardRef((n,e)=>{const t=Qst(Dw,n.__scopeDialog),{forceMount:r=t.forceMount,...i}=n,o=c3(Dw,n.__scopeDialog);return X.jsx(m2,{present:r||o.open,children:o.modal?X.jsx(Ozn,{...i,ref:e}):X.jsx(Izn,{...i,ref:e})})});tat.displayName=Dw;var Ozn=q.forwardRef((n,e)=>{const t=c3(Dw,n.__scopeDialog),r=q.useRef(null),i=Wu(e,t.contentRef,r);return q.useEffect(()=>{const o=r.current;if(o)return bme(o)},[]),X.jsx(nat,{...n,ref:i,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:zi(n.onCloseAutoFocus,o=>{o.preventDefault(),t.triggerRef.current?.focus()}),onPointerDownOutside:zi(n.onPointerDownOutside,o=>{const s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:zi(n.onFocusOutside,o=>o.preventDefault())})}),Izn=q.forwardRef((n,e)=>{const t=c3(Dw,n.__scopeDialog),r=q.useRef(!1),i=q.useRef(!1);return X.jsx(nat,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{n.onCloseAutoFocus?.(o),o.defaultPrevented||(r.current||t.triggerRef.current?.focus(),o.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:o=>{n.onInteractOutside?.(o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=o.target;t.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})}),nat=q.forwardRef((n,e)=>{const{__scopeDialog:t,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...s}=n,a=c3(Dw,t),c=q.useRef(null),l=Wu(e,c);return tme(),X.jsxs(X.Fragment,{children:[X.jsx(DH,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:X.jsx(KN,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Zye(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),X.jsxs(X.Fragment,{children:[X.jsx(Dzn,{titleId:a.titleId}),X.jsx($zn,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Kye="DialogTitle",rat=q.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=c3(Kye,t);return X.jsx(vc.h2,{id:i.titleId,...r,ref:e})});rat.displayName=Kye;var iat="DialogDescription",oat=q.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=c3(iat,t);return X.jsx(vc.p,{id:i.descriptionId,...r,ref:e})});oat.displayName=iat;var sat="DialogClose",aat=q.forwardRef((n,e)=>{const{__scopeDialog:t,...r}=n,i=c3(sat,t);return X.jsx(vc.button,{type:"button",...r,ref:e,onClick:zi(n.onClick,()=>i.onOpenChange(!1))})});aat.displayName=sat;function Zye(n){return n?"open":"closed"}var cat="DialogTitleWarning",[Lzn,lat]=OUt(cat,{contentName:Dw,titleName:Kye,docsSlug:"dialog"}),Dzn=({titleId:n})=>{const e=lat(cat),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
5691
5691
 
5692
5692
  If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
5693
5693