@tscircuit/runframe 0.0.1829 → 0.0.1831
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.
|
@@ -5146,7 +5146,7 @@ ${c.join(`
|
|
|
5146
5146
|
${p}polygon: ${h.polygon.vertices}
|
|
5147
5147
|
`:c+=`
|
|
5148
5148
|
`,h.children.length>0&&u.push(h.children)}return c}};e.exports=s}}),Jxn=it({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(t,e){var n=jxn(),o=qxn(),r=class{constructor(i){this.polygonTree=new o,this.rootnode=new n(null),i&&this.addPolygons(i)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(i,s=!1){this.rootnode.clipTo(i,s)}allPolygons(){const i=[];return this.polygonTree.getPolygons(i),i}addPolygons(i){const s=new Array(i.length);for(let a=0;a<i.length;a++)s[a]=this.polygonTree.addChild(i[a]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};e.exports=r}}),Fpe=it({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(t,e){e.exports={Tree:Jxn()}}}),Kxn=it({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(t,e){var n=$i(),o=Ope(),{Tree:r}=Fpe(),i=(s,a)=>{if(!o(s,a))return n.create();const c=new r(n.toPolygons(s)),l=new r(n.toPolygons(a));c.invert(),l.clipTo(c),l.invert(),c.clipTo(l),l.clipTo(c),c.addPolygons(l.allPolygons()),c.invert();const u=c.allPolygons();return n.create(u)};e.exports=i}}),TKe=it({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(t,e){var n=Pi(),o=Uk(),r=Kxn(),i=(...s)=>{s=n(s);let a=s.shift();return s.forEach(c=>{a=r(a,c)}),a=o(a),a};e.exports=i}}),Qxn=it({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(t,e){var n=Pi(),o=$i(),r=ZP(),i=Ipe(),s=Lpe(),a=TKe(),c=(...l)=>{l=n(l);const u=l.map(m=>s({z0:-1,z1:1},m)),_=a(u),d=r(_);return i(d,o.toPolygons(_))};e.exports=c}}),Zxn=it({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(t,e){var n=Pi(),o=Wk(),r=ji(),i=$i(),s=Qxn(),a=TKe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!o(l))throw new Error("only intersect of the types are supported");const u=l[0];return r.isA(u)?s(l):i.isA(u)?a(l):u};e.exports=c}}),Bpe=it({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(t,e){var n=Is(),o=RJe(),r=i=>o(i,{skipTriangulation:!0}).map(c=>{const l=c.map(u=>i[u]);return n.create(l)});e.exports=r}}),wKe=it({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(t,e){var n=$i(),o=Ope(),{Tree:r}=Fpe(),i=(a,c)=>{if(!o(a,c))return s(a,c);const l=new r(n.toPolygons(a)),u=new r(n.toPolygons(c));l.clipTo(u,!1),u.clipTo(l),u.invert(),u.clipTo(l),u.invert();const _=l.allPolygons().concat(u.allPolygons());return n.create(_)},s=(a,c)=>{let l=n.toPolygons(a);return l=l.concat(n.toPolygons(c)),n.create(l)};e.exports=i}}),zpe=it({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(t,e){var n=Pi(),o=Uk(),r=wKe(),i=(...s)=>{s=n(s);let a;for(a=1;a<s.length;a+=2)s.push(r(s[a-1],s[a]));let c=s[a-1];return c=o(c),c};e.exports=i}}),EKe=it({"node_modules/@jscad/modeling/src/operations/minkowski/minkowskiSum.js"(t,e){var n=Pi(),o=$i(),r=Is(),i=Bpe(),s=zpe(),a=(...m)=>{if(m=n(m),m.length!==2)throw new Error("minkowskiSum requires exactly two geometries");const[h,p]=m;if(!o.isA(h)||!o.isA(p))throw new Error("minkowskiSum requires geom3 geometries");const x=o.isConvex(h),f=o.isConvex(p);if(x&&f)return _(h,p);if(!x&&f)return c(h,p);if(x&&!f)return c(p,h);throw new Error("minkowskiSum of two non-convex geometries is not yet supported")},c=(m,h)=>{const p=l(m);if(p.length===0)return o.create();const x=p.map(f=>_(f,h));return x.length===1?x[0]:s(x)},l=m=>{const h=o.toPolygons(m);if(h.length===0)return[];const p=[];for(let x=0;x<h.length;x++){const f=h[x],g=f.vertices;let y=0,b=0,v=0;for(let H=0;H<g.length;H++)y+=g[H][0],b+=g[H][1],v+=g[H][2];y/=g.length,b/=g.length,v/=g.length;const S=r.plane(f),M=S[0],w=S[1],A=S[2],D=.1,I=[y-M*D,b-w*D,v-A*D];for(let H=1;H<g.length-1;H++){const B=g[0],z=g[H],V=g[H+1],j=u(I,B,z,V);p.push(o.create(j))}}return p},u=(m,h,p,x)=>[r.create([m,p,h]),r.create([m,h,x]),r.create([h,p,x]),r.create([p,m,x])],_=(m,h)=>{const p=d(m),x=d(h);if(p.length===0||x.length===0)return o.create();const f=[];for(let y=0;y<p.length;y++){const b=p[y];for(let v=0;v<x.length;v++){const S=x[v];f.push([b[0]+S[0],b[1]+S[1],b[2]+S[2]])}}const g=i(f);return o.create(g)},d=m=>{const h=new Set,p=[],x=o.toPolygons(m);for(let f=0;f<x.length;f++){const g=x[f].vertices;for(let y=0;y<g.length;y++){const b=g[y],v=`${b[0]},${b[1]},${b[2]}`;h.has(v)||(h.add(v),p.push(b))}}return p};e.exports=a}}),egn=it({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(t,e){var n=br(),o=ZP(),r=$i(),i=l=>l.sort((u,_)=>u-_).filter((u,_,d)=>!_||u!==d[_-1]),s=(l,u,_)=>{const d=`${u}`,m=l.get(d);m===void 0?l.set(d,[_]):m.push(_)},a=(l,u)=>{const _=`${u}`;return l.get(_)},c=l=>{const u=o(l),_=r.toPolygons(l),d=_.length,m=new Map,h=n.create();_.forEach((y,b)=>{y.vertices.forEach(v=>{s(m,n.snap(h,v,u),b)})});const p=_.map(y=>{let b=[];return y.vertices.forEach(v=>{b=b.concat(a(m,n.snap(h,v,u)))}),{e:1,d:i(b)}});m.clear();let x=0;const f=p.length;for(let y=0;y<f;y++){const b=p[y];if(b.e>0){const v=new Array(d);v[y]=!0;do x=0,v.forEach((S,M)=>{const w=p[M];if(w.e>0){w.e=-1;for(let A=0;A<w.d.length;A++)v[w.d[A]]=!0;x++}});while(x>0);b.indexes=v}}const g=[];for(let y=0;y<f;y++)if(p[y].indexes){const b=[];p[y].indexes.forEach((v,S)=>b.push(_[S])),g.push(r.create(b))}return g};e.exports=c}}),tgn=it({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(t,e){var n=Pi(),o=$i(),r=egn(),i=(...s)=>{if(s=n(s),s.length===0)throw new Error("wrong number of arguments");const a=s.map(c=>o.isA(c)?r(c):c);return a.length===1?a[0]:a};e.exports=i}}),ngn=it({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(t,e){var n=$i(),o=Ope(),{Tree:r}=Fpe(),i=(s,a)=>{if(!o(s,a))return n.clone(s);const c=new r(n.toPolygons(s)),l=new r(n.toPolygons(a));c.invert(),c.clipTo(l),l.clipTo(c,!0),c.addPolygons(l.allPolygons()),c.invert();const u=c.allPolygons();return n.create(u)};e.exports=i}}),DKe=it({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(t,e){var n=Pi(),o=Uk(),r=ngn(),i=(...s)=>{s=n(s);let a=s.shift();return s.forEach(c=>{a=r(a,c)}),a=o(a),a};e.exports=i}}),ogn=it({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(t,e){var n=Pi(),o=$i(),r=ZP(),i=Ipe(),s=Lpe(),a=DKe(),c=(...l)=>{l=n(l);const u=l.map(m=>s({z0:-1,z1:1},m)),_=a(u),d=r(_);return i(d,o.toPolygons(_))};e.exports=c}}),rgn=it({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(t,e){var n=Pi(),o=Wk(),r=ji(),i=$i(),s=ogn(),a=DKe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!o(l))throw new Error("only subtract of the types are supported");const u=l[0];return r.isA(u)?s(l):i.isA(u)?a(l):u};e.exports=c}}),AKe=it({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(t,e){var n=Pi(),o=$i(),r=ZP(),i=Ipe(),s=Lpe(),a=zpe(),c=(...l)=>{l=n(l);const u=l.map(m=>s({z0:-1,z1:1},m)),_=a(u),d=r(_);return i(d,o.toPolygons(_))};e.exports=c}}),Vpe=it({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(t,e){var n=Pi(),o=Wk(),r=ji(),i=$i(),s=AKe(),a=zpe(),c=(...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(!o(l))throw new Error("only unions of the same type are supported");const u=l[0];return r.isA(u)?s(l):i.isA(u)?a(l):u};e.exports=c}}),Xk=it({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(t,e){e.exports={intersect:Zxn(),minkowski:EKe(),scission:tgn(),subtract:rgn(),union:Vpe()}}}),OU=it({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(t,e){var{EPS:n,TAU:o}=Js(),r=iKe(),i=Ape(),s=ds(),a=HU(),c=(l,u)=>{const _={delta:1,corners:"edge",closed:!1,segments:16};let{delta:d,corners:m,closed:h,segments:p}=Object.assign({},_,l);if(Math.abs(d)<n)return u;let x=l.closed?a(u):1;x===0&&(x=1);const f=x>0&&d>=0||x<0&&d<0;d=Math.abs(d);let g=null,y=[];const b=[],v=s.create(),S=u.length;for(let M=0;M<S;M++){const w=(M+1)%S,A=u[M],D=u[w];f?s.subtract(v,A,D):s.subtract(v,D,A),s.normal(v,v),s.normalize(v,v),s.scale(v,v,d);const I=s.add(s.create(),A,v),H=s.add(s.create(),D,v),B=[I,H];if(g!=null&&(h||!h&&w!==0)){const z=r(g[0],g[1],B[0],B[1]);z?(y.pop(),B[0]=z):b.push({c:A,s0:g,s1:B})}g=[I,H],!(w===0&&!h)&&(y.push(B[0]),y.push(B[1]))}if(h&&g!=null){const M=y[0],w=y[1],A=r(g[0],g[1],M,w);if(A)y[0]=A,y.pop();else{const D=u[0],I=[M,w];b.push({c:D,s0:g,s1:I})}}if(m==="edge"){const M=new Map;y.forEach((D,I)=>M.set(D,I));const w=i.create(),A=i.create();b.forEach(D=>{i.fromPoints(w,D.s0[0],D.s0[1]),i.fromPoints(A,D.s1[0],D.s1[1]);const I=i.intersectPointOfLines(w,A);if(Number.isFinite(I[0])&&Number.isFinite(I[1])){const H=D.s0[1],B=M.get(H);y[B]=I,y[(B+1)%y.length]=void 0}else{const H=D.s1[0],B=M.get(H);y[B]=void 0}}),y=y.filter(D=>D!==void 0)}if(m==="round"){let M=Math.floor(p/4);const w=s.create();b.forEach(A=>{let D=s.angle(s.subtract(w,A.s1[0],A.c));if(D-=s.angle(s.subtract(w,A.s0[1],A.c)),f&&D<0&&(D=D+Math.PI,D<0&&(D=D+Math.PI)),!f&&D>0&&(D=D-Math.PI,D>0&&(D=D-Math.PI)),D!==0){M=Math.floor(p*(Math.abs(D)/o));const I=D/M,H=s.angle(s.subtract(w,A.s0[1],A.c)),B=[];for(let z=1;z<M;z++){const V=H+I*z,j=s.fromAngleRadians(s.create(),V);s.scale(j,j,d),s.add(j,j,A.c),B.push(j)}if(B.length>0){const z=A.s0[1];let V=y.findIndex(j=>s.equals(z,j));V=(V+1)%y.length,y.splice(V,0,...B)}}else{const I=A.s1[0],H=y.findIndex(B=>s.equals(I,B));y.splice(H,1)}})}return y};e.exports=c}}),ign=it({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(t,e){var n=ji(),o=OU(),r=(i,s)=>{const a={delta:1,corners:"edge",segments:16},{delta:c,corners:l,segments:u}=Object.assign({},a,i);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const m=n.toOutlines(s).map(h=>(i={delta:c,corners:l,closed:!0,segments:u},o(i,h))).reduce((h,p)=>h.concat(n.toSides(n.fromPoints(p))),[]);return n.create(m)};e.exports=r}}),sgn=it({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(t,e){var n=Cl(),o=br(),r=$i(),i=Is(),s=(a,c)=>{o.dot(i.plane(c),a)>0&&(c=i.invert(c));const u=[c],_=i.transform(n.fromTranslation(n.create(),a),c),d=c.vertices.length;for(let m=0;m<d;m++){const h=m<d-1?m+1:0,p=i.create([c.vertices[m],_.vertices[m],_.vertices[h],c.vertices[h]]);u.push(p)}return u.push(i.invert(_)),r.create(u)};e.exports=s}}),agn=it({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(t,e){var{EPS:n,TAU:o}=Js(),r=Cl(),i=br(),s=CKe(),a=$i(),c=Is(),l=xKe(),u=Uk(),_=wKe(),d=sgn(),m=(f,g,y)=>{const b=g.toString();if(f.has(b))f.get(b)[1].push(y);else{const v=[g,[y]];f.set(b,v)}},h=(f,g,y)=>{const b=g[0].toString(),v=g[1].toString(),S=b<v?`${b},${v}`:`${v},${b}`;if(f.has(S))f.get(S)[1].push(y);else{const M=[g,[y]];f.set(S,M)}},p=(f,g)=>{f.findIndex(b=>b===g)<0&&f.push(g)},x=(f,g)=>{const y={delta:1,segments:12},{delta:b,segments:v}=Object.assign({},y,f);let S=a.create();const M=new Map,w=new Map,A=i.create(),D=i.create();return a.toPolygons(g).forEach((H,B)=>{const z=i.scale(i.create(),c.plane(H),2*b),V=c.transform(r.fromTranslation(r.create(),i.scale(i.create(),z,-.5)),H),j=d(z,V);S=_(S,j);const q=H.vertices;for(let J=0;J<q.length;J++){m(M,q[J],c.plane(H));const ne=(J+1)%q.length,ae=[q[J],q[ne]];h(w,ae,c.plane(H))}}),w.forEach(H=>{const B=H[0],z=H[1],V=B[0],j=B[1],q=i.subtract(i.create(),j,V);i.normalize(q,q);const J=z[0],ne=i.cross(i.create(),J,q);let ae=[];for(let De=0;De<v;De++)p(ae,De*o/v);for(let De=0,ge=z.length;De<ge;De++){const Me=z[De],fe=i.dot(ne,Me),We=i.dot(J,Me);let je=Math.atan2(fe,We);je<0&&(je+=o),p(ae,je),je=Math.atan2(-fe,-We),je<0&&(je+=o),p(ae,je)}ae=ae.sort(s);const Z=ae.length;let oe,se;const le=[],pe=[],Se=[];for(let De=-1;De<Z;De++){const ge=ae[De<0?De+Z:De],Me=Math.sin(ge),fe=Math.cos(ge);i.scale(A,J,fe*b),i.scale(D,ne,Me*b),i.add(A,A,D);const We=i.add(i.create(),V,A),je=i.add(i.create(),j,A);let Ke=!1;if(De>=0&&i.distance(We,oe)<n&&(Ke=!0),!Ke){if(De>=0){le.push(We),pe.push(je);const me=[se,je,We,oe],qe=c.create(me);Se.push(qe)}oe=We,se=je}}pe.reverse(),Se.push(c.create(le)),Se.push(c.create(pe));const we=a.create(Se);S=_(S,we)}),M.forEach(H=>{const B=H[0],z=H[1],V=z[0];let j=null,q=0;for(let Z=1;Z<z.length;Z++){const oe=z[Z],se=i.cross(A,V,oe),le=i.length(se);le>.05&&le>q&&(q=le,j=oe)}j||(j=i.orthogonal(A,V));const J=i.cross(A,V,j);i.normalize(J,J);const ne=i.cross(D,J,V),ae=l({center:[B[0],B[1],B[2]],radius:b,segments:v,axes:[V,J,ne]});S=_(S,ae)}),u(S)};e.exports=x}}),cgn=it({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(t,e){var n=$i(),o=Vpe(),r=agn(),i=(s,a)=>{const c={delta:1,corners:"round",segments:12},{delta:l,corners:u,segments:_}=Object.assign({},c,s);if(u!=="round")throw new Error('corners must be "round" for 3D geometries');if(n.toPolygons(a).length===0)throw new Error("the given geometry cannot be empty");s={delta:l,corners:u,segments:_};const m=r(s,a);return o(a,m)};e.exports=i}}),lgn=it({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(t,e){var n=HU(),o=ds(),r=ji(),i=il(),s=OU(),a=u=>{let{external:_,internal:d}=u;n(_)<0?_=_.reverse():d=d.reverse();const m=i.fromPoints({closed:!0},_),h=i.fromPoints({closed:!0},d),p=r.toSides(r.fromPoints(i.toPoints(m))),x=r.toSides(r.fromPoints(i.toPoints(h)));return p.push(...x),r.create(p)},c=(u,_,d,m)=>{const{points:h,external:p,internal:x}=u,f=Math.floor(_/2),g=[],y=[];if(d==="round"&&f>0){const v=Math.PI/f,S=h[h.length-1],M=o.angle(o.subtract(o.create(),p[p.length-1],S)),w=h[0],A=o.angle(o.subtract(o.create(),x[0],w));for(let D=1;D<f;D++){let I=M+v*D,H=o.fromAngleRadians(o.create(),I);o.scale(H,H,m),o.add(H,H,S),g.push(H),I=A+v*D,H=o.fromAngleRadians(o.create(),I),o.scale(H,H,m),o.add(H,H,w),y.push(H)}}const b=[];return b.push(...p,...g,...x.reverse(),...y),r.fromPoints(b)},l=(u,_)=>{u=Object.assign({},{delta:1,corners:"edge",segments:16},u);const{delta:m,corners:h,segments:p}=u;if(m<=0)throw new Error("the given delta must be positive for paths");if(!(h==="edge"||h==="chamfer"||h==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const x=_.isClosed,f=i.toPoints(_);if(f.length===0)throw new Error("the given geometry cannot be empty");const g={points:f,external:s({delta:m,corners:h,segments:p,closed:x},f),internal:s({delta:-m,corners:h,segments:p,closed:x},f)};return _.isClosed?a(g):c(g,p,h,m)};e.exports=l}}),$pe=it({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(t,e){var n=Pi(),o=ji(),r=$i(),i=il(),s=ign(),a=cgn(),c=lgn(),l=(u,..._)=>{if(_=n(_),_.length===0)throw new Error("wrong number of arguments");const d=_.map(m=>i.isA(m)?c(u,m):o.isA(m)?s(u,m):r.isA(m)?a(u,m):m);return d.length===1?d[0]:d};e.exports=l}}),ugn=it({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(t,e){var n=ji(),o=Mpe(),r=OU(),i=(s,a)=>{const c={delta:1,corners:"edge",segments:0},{delta:l,corners:u,segments:_}=Object.assign({},c,s);if(!(u==="edge"||u==="chamfer"||u==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const d=n.toOutlines(a),h=d.map(p=>(s={delta:d.reduce((g,y)=>g+o.arePointsInside(p,o.create(y)),0)%2===0?l:-l,corners:u,closed:!0,segments:_},r(s,p))).reduce((p,x)=>p.concat(n.toSides(n.fromPoints(x))),[]);return n.create(h)};e.exports=i}}),_gn=it({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(t,e){var n=il(),o=OU(),r=(i,s)=>{const a={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:c,corners:l,closed:u,segments:_}=Object.assign({},a,i);if(!(l==="edge"||l==="chamfer"||l==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');i={delta:c,corners:l,closed:u,segments:_};const d=o(i,n.toPoints(s));return n.fromPoints({closed:u},d)};e.exports=r}}),dgn=it({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(t,e){var n=Pi(),o=ji(),r=il(),i=ugn(),s=_gn(),a=(c,...l)=>{if(l=n(l),l.length===0)throw new Error("wrong number of arguments");const u=l.map(_=>r.isA(_)?s(c,_):o.isA(_)?i(c,_):_);return u.length===1?u[0]:u};e.exports=a}}),RKe=it({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(t,e){e.exports={expand:$pe(),offset:dgn()}}}),FU=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(t,e){var n=Cl(),o=br(),r=ji(),i=Nw(),s=LU(),a=(c,l)=>{const u={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:_,twistAngle:d,twistSteps:m,repair:h}=Object.assign({},u,c);if(m<1)throw new Error("twistSteps must be 1 or more");d===0&&(m=1);const p=o.clone(_),x=r.toSides(l);if(x.length===0)throw new Error("the given geometry cannot be empty");const f=i.fromSides(x);p[2]<0&&i.reverse(f,f);const g=n.create(),y=(b,v,S)=>{const M=v/m*d,w=o.scale(o.create(),p,v/m);return n.multiply(g,n.fromZRotation(g,M),n.fromTranslation(n.create(),w)),i.transform(g,S)};return c={numberOfSlices:m+1,capStart:!0,capEnd:!0,repair:h,callback:y},s(c,f)};e.exports=a}}),hgn=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(t,e){var n=ji(),o=il(),r=FU(),i=(s,a)=>{if(!a.isClosed)throw new Error("extruded path must be closed");const c=o.toPoints(a),l=n.fromPoints(c);return r(s,l)};e.exports=i}}),mgn=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(t,e){var n=Pi(),o=ji(),r=il(),i=FU(),s=hgn(),a=(c,...l)=>{const u={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:_,twistAngle:d,twistSteps:m,repair:h}=Object.assign({},u,c);if(l=n(l),l.length===0)throw new Error("wrong number of arguments");c={offset:[0,0,_],twistAngle:d,twistSteps:m,repair:h};const p=l.map(x=>r.isA(x)?s(c,x):o.isA(x)?i(c,x):x);return p.length===1?p[0]:p};e.exports=a}}),pgn=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(t,e){var n=il(),o=$pe(),r=FU(),i=(s,a)=>{const c={size:1,height:1},{size:l,height:u}=Object.assign({},c,s);if(s.delta=l,s.offset=[0,0,u],n.toPoints(a).length===0)throw new Error("the given geometry cannot be empty");const d=o(s,a);return r(s,d)};e.exports=i}}),fgn=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(t,e){var{area:n}=Bk(),o=ji(),r=il(),i=$pe(),s=FU(),a=(c,l)=>{const u={size:1,height:1},{size:_,height:d}=Object.assign({},u,c);c.delta=_,c.offset=[0,0,d];const m=o.toOutlines(l);if(m.length===0)throw new Error("the given geometry cannot be empty");const p=m.map(f=>(n(f)<0&&f.reverse(),i(c,r.fromPoints({closed:!0},f)))).reduce((f,g)=>f.concat(o.toSides(g)),[]),x=o.create(p);return s(c,x)};e.exports=a}}),xgn=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(t,e){var n=Pi(),o=ji(),r=il(),i=pgn(),s=fgn(),a=(c,...l)=>{const u={size:1,height:1},{size:_,height:d}=Object.assign({},u,c);if(l=n(l),l.length===0)throw new Error("wrong number of arguments");if(_<=0)throw new Error("size must be positive");if(d<=0)throw new Error("height must be positive");const m=l.map(h=>r.isA(h)?i(c,h):o.isA(h)?s(c,h):h);return m.length===1?m[0]:m};e.exports=a}}),ggn=it({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(t,e){var{TAU:n}=Js(),o=Cl(),r=ji(),i=LU(),s=Nw(),a=(c,l)=>{const u={angle:n,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:_,startAngle:d,pitch:m,height:h,endOffset:p,segmentsPerRotation:x}=Object.assign({},u,c);if(h!=0&&(m=h/(_/n)),x<3)throw new Error("The number of segments per rotation needs to be at least 3.");const g=r.toSides(l);if(g.length===0)throw new Error("The given geometry cannot be empty");const y=g.filter(D=>D[0][0]>=0);let b=s.fromSides(g);y.length===0&&(b=s.reverse(b));const v=Math.round(x/n*Math.abs(_)),S=v>=2?v:2,M=o.create(),w=o.create(),A=(D,I,H)=>{const B=d+_/S*I,z=p/S*I,V=(B-d)/n*m;return o.multiply(M,o.fromTranslation(o.create(),[z,0,V*Math.sign(_)]),o.fromXRotation(o.create(),-n/4*Math.sign(_))),o.multiply(w,o.fromZRotation(o.create(),B),M),s.transform(w,H)};return i({numberOfSlices:S+1,callback:A},b)};e.exports=a}}),ygn=it({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(t,e){var n=Pi(),o=Dpe(),r=F6(),i=Cl(),s=ji(),a=$i(),c=Is(),l=ZP(),u=AKe(),_=(m,h)=>{const p=r.fromNormalAndPoint(r.create(),m.axis,m.origin);if(Number.isNaN(p[0])||Number.isNaN(p[1])||Number.isNaN(p[2])||Number.isNaN(p[3]))throw new Error("project: invalid axis or origin");const x=l(h),f=x*x*Math.sqrt(3)/4;if(x===0)return s.create();const g=a.toPolygons(h);let y=[];for(let v=0;v<g.length;v++){const S=g[v].vertices.map(A=>r.projectionOfPoint(p,A)),M=c.create(S),w=c.plane(M);o(p,w)&&(c.measureArea(M)<f||y.push(M))}if(!o(p,[0,0,1])){const v=i.fromVectorRotation(i.create(),p,[0,0,1]);y=y.map(S=>c.transform(v,S))}y=y.sort((v,S)=>c.measureArea(S)-c.measureArea(v));const b=y.map(v=>s.fromPoints(v.vertices));return u(b)},d=(m,...h)=>{const p={axis:[0,0,1],origin:[0,0,0]},{axis:x,origin:f}=Object.assign({},p,m);if(h=n(h),h.length===0)throw new Error("wrong number of arguments");m={axis:x,origin:f};const g=h.map(y=>a.isA(y)?_(m,y):y);return g.length===1?g[0]:g};e.exports=d}}),jk=it({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(t,e){e.exports={extrudeFromSlices:LU(),extrudeLinear:mgn(),extrudeRectangular:xgn(),extrudeRotate:PKe(),extrudeHelical:ggn(),project:ygn(),slice:Nw()}}}),Wpe=it({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(t,e){var n=ds(),o=s=>{let a=n.fromValues(1/0,1/0);s.forEach(u=>{(u[1]<a[1]||u[1]===a[1]&&u[0]<a[0])&&(a=u)});const c=[];s.forEach(u=>{const _=i(u[1]-a[1],u[0]-a[0]),d=n.squaredDistance(u,a);c.push({point:u,angle:_,distSq:d})}),c.sort((u,_)=>u.angle!==_.angle?u.angle-_.angle:u.distSq-_.distSq);const l=[];return c.forEach(u=>{let _=l.length;for(;_>1&&r(l[_-2],l[_-1],u.point)<=Number.EPSILON;)l.pop(),_=l.length;l.push(u.point)}),l},r=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),i=(s,a)=>s===0&&a===0?-1/0:-a/s;e.exports=o}}),Upe=it({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(t,e){var n=ji(),o=$i(),r=il(),i=s=>{const a=new Set,c=[],l=u=>{const _=u.toString();a.has(_)||(c.push(u),a.add(_))};return s.forEach(u=>{n.isA(u)?n.toPoints(u).forEach(l):o.isA(u)?o.toPoints(u).forEach(_=>_.forEach(l)):r.isA(u)&&r.toPoints(u).forEach(l)}),c};e.exports=i}}),bgn=it({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(t,e){var n=Pi(),o=il(),r=Wpe(),i=Upe(),s=(...a)=>{a=n(a);const c=i(a),l=r(c);return o.fromPoints({closed:!0},l)};e.exports=s}}),Pgn=it({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(t,e){var n=Pi(),o=ji(),r=Wpe(),i=Upe(),s=(...a)=>{a=n(a);const c=i(a),l=r(c);return l.length<3?o.create():o.fromPoints(l)};e.exports=s}}),vgn=it({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(t,e){var n=Pi(),o=$i(),r=Upe(),i=Bpe(),s=(...a)=>{a=n(a);const c=r(a);return c.length===0?o.create():o.create(i(c))};e.exports=s}}),kKe=it({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(t,e){var n=Pi(),o=Wk(),r=ji(),i=$i(),s=il(),a=bgn(),c=Pgn(),l=vgn(),u=(..._)=>{if(_=n(_),_.length===0)throw new Error("wrong number of arguments");if(!o(_))throw new Error("only hulls of the same type are supported");const d=_[0];return s.isA(d)?a(_):r.isA(d)?c(_):i.isA(d)?l(_):d};e.exports=u}}),Sgn=it({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(t,e){var n=Pi(),o=Vpe(),r=kKe(),i=(...s)=>{if(s=n(s),s.length<2)throw new Error("wrong number of arguments");const a=[];for(let c=1;c<s.length;c++)a.push(r(s[c-1],s[c]));return o(a)};e.exports=i}}),Cgn=it({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(t,e){e.exports={hull:kKe(),hullChain:Sgn(),hullPoints2:Wpe(),hullPoints3:Bpe()}}}),Mgn=it({"node_modules/@jscad/modeling/src/operations/minkowski/index.js"(t,e){e.exports={minkowskiSum:EKe()}}}),NKe=it({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(t,e){var n=br(),o=Is(),r=(s,a)=>{const c=Math.abs(o.measureArea(a));return Number.isFinite(c)&&c>s},i=(s,a)=>{let c=a.map(u=>{const _=u.vertices.map(h=>n.snap(n.create(),h,s)),d=[];for(let h=0;h<_.length;h++){const p=(h+1)%_.length;n.equals(_[h],_[p])||d.push(_[h])}const m=o.create(d);return u.color&&(m.color=u.color),m});const l=s*s*Math.sqrt(3)/4;return c=c.filter(u=>r(l,u)),c};e.exports=i}}),Tgn=it({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(t,e){var n=Dpe(),o=br(),r=Is(),i=f=>{const g=r.toPoints(f),y=[];for(let b=0;b<g.length;b++){const v=(b+1)%g.length,S={v1:g[b],v2:g[v]};y.push(S)}for(let b=0;b<y.length;b++){const v=(b+1)%g.length;y[b].next=y[v],y[v].prev=y[b]}return y},s=(f,g)=>{const y=`${g.v1}:${g.v2}`;f.set(y,g)},a=(f,g)=>{const y=`${g.v1}:${g.v2}`;f.delete(y)},c=(f,g)=>{const y=`${g.v2}:${g.v1}`;return f.get(y)},l=(f,g,y)=>{let b=f.prev.v1,v=f.prev.v2,S=g.next.v2;const M=d(b,v,S,y);b=g.prev.v1,v=g.prev.v2,S=f.next.v2;const w=d(b,v,S,y);return[M,w]},u=o.create(),_=o.create(),d=(f,g,y,b)=>{const v=o.subtract(u,g,f),S=o.subtract(_,y,g);return o.cross(v,v,S),o.dot(v,b)},m=f=>{let g;const y=[];for(;f.next;){const b=f.next;y.push(f.v1),f.v1=null,f.v2=null,f.next=null,f.prev=null,f=b}return y.length>0&&(g=r.create(y)),g},h=f=>{if(f.length<2)return f;const g=f[0].plane,y=f.slice(),b=new Map;for(;y.length>0;){const S=y.shift(),M=i(S);for(let w=0;w<M.length;w++){const A=M[w],D=c(b,A);if(D){const I=l(A,D,g);if(I[0]>=0&&I[1]>=0){const H=D.next,B=A.next;A.prev.next=D.next,A.next.prev=D.prev,D.prev.next=A.next,D.next.prev=A.prev,A.v1=null,A.v2=null,A.next=null,A.prev=null,a(b,D),D.v1=null,D.v2=null,D.next=null,D.prev=null;const z=(V,j,q)=>{const J={v1:q.v1,v2:j.v2,next:j.next,prev:q.prev};q.prev.next=J,j.next.prev=J,a(V,j),j.v1=null,j.v2=null,j.next=null,j.prev=null,a(V,q),q.v1=null,q.v2=null,q.next=null,q.prev=null};I[0]===0&&z(b,H,H.prev),I[1]===0&&z(b,B,B.prev)}}else A.next&&s(b,A)}}const v=[];return b.forEach(S=>{const M=m(S);M&&v.push(M)}),b.clear(),v},p=(f,g)=>Math.abs(f[3]-g[3])<15e-8?n(f,g):!1,x=(f,g)=>{const y=[];g.forEach(v=>{const S=y.find(M=>p(M[0],r.plane(v)));S?S[1].push(v):y.push([r.plane(v),[v]])});let b=[];return y.forEach(v=>{const S=v[1],M=h(S);b=b.concat(M)}),b};e.exports=x}}),wgn=it({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(t,e){var n=Js(),o=br(),r=Is(),i=l=>`${l}`,s=(l,u,_,d,m,h)=>{const p=i(d),x=i(m),f=`${p}/${x}`,g=`${x}/${p}`;if(l.has(g))return a(l,u,_,m,d,null),null;const y={vertex0:d,vertex1:m,polygonindex:h};return l.has(f)?l.get(f).push(y):l.set(f,[y]),u.has(p)?u.get(p).push(f):u.set(p,[f]),_.has(x)?_.get(x).push(f):_.set(x,[f]),f},a=(l,u,_,d,m,h)=>{const p=i(d),x=i(m),f=`${p}/${x}`;let g=-1;const y=l.get(f);for(let b=0;b<y.length;b++){const v=y[b];let S=i(v.vertex0);if(S===p&&(S=i(v.vertex1),S===x&&!(h!==null&&v.polygonindex!==h))){g=b;break}}y.splice(g,1),y.length===0&&l.delete(f),g=u.get(p).indexOf(f),u.get(p).splice(g,1),u.get(p).length===0&&u.delete(p),g=_.get(x).indexOf(f),_.get(x).splice(g,1),_.get(x).length===0&&_.delete(x)},c=l=>{const u=new Map;for(let _=0;_<l.length;_++){const d=l[_],m=d.vertices.length;if(m>=3){let h=d.vertices[0],p=i(h);for(let x=0;x<m;x++){let f=x+1;f===m&&(f=0);const g=d.vertices[f],y=i(g),b=`${p}/${y}`,v=`${y}/${p}`;if(u.has(v)){const S=u.get(v);S.splice(-1,1),S.length===0&&u.delete(v)}else{const S={vertex0:h,vertex1:g,polygonindex:_};u.has(b)?u.get(b).push(S):u.set(b,[S])}h=g,p=y}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(u.size>0){const _=new Map,d=new Map,m=new Map;for(const[p,x]of u)m.set(p,!0),x.forEach(f=>{const g=i(f.vertex0),y=i(f.vertex1);_.has(g)?_.get(g).push(p):_.set(g,[p]),d.has(y)?d.get(y).push(p):d.set(y,[p])});const h=l.slice(0);for(;u.size!==0;){for(const x of u.keys())m.set(x,!0);let p=!1;for(;;){const x=Array.from(m.keys());if(x.length===0)break;const f=x[0];let g=!0;if(u.has(f)){const b=u.get(f)[0];for(let v=0;v<2;v++){const S=v===0?b.vertex0:b.vertex1,M=v===0?b.vertex1:b.vertex0,w=i(S),A=i(M);let D=[];v===0?d.has(w)&&(D=d.get(w)):_.has(w)&&(D=_.get(w));for(let I=0;I<D.length;I++){const H=D[I],B=u.get(H)[0],z=v===0?B.vertex0:B.vertex1;if(v===0?B.vertex1:B.vertex0,i(z)===A){a(u,_,d,S,M,null),a(u,_,d,M,S,null),g=!1,v=2,p=!0;break}else{const j=S,q=M,J=z,ne=o.subtract(o.create(),J,j),ae=o.dot(o.subtract(o.create(),q,j),ne)/o.dot(ne,ne);if(ae>0&&ae<1){const Z=o.scale(o.create(),ne,ae);if(o.add(Z,Z,j),o.squaredDistance(Z,q)<n.EPS*n.EPS){const se=B.polygonindex,le=h[se],pe=i(B.vertex1);let Se=-1;for(let fe=0;fe<le.vertices.length;fe++)if(i(le.vertices[fe])===pe){Se=fe;break}const we=le.vertices.slice(0);we.splice(Se,0,M);const De=r.create(we);h[se]=De,a(u,_,d,B.vertex0,B.vertex1,se);const ge=s(u,_,d,B.vertex0,M,se),Me=s(u,_,d,M,B.vertex1,se);ge!==null&&m.set(ge,!0),Me!==null&&m.set(Me,!0),g=!1,v=2,p=!0;break}}}}}}g&&m.delete(f)}if(!p)break}l=h}return u.clear(),l};e.exports=c}}),Egn=it({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(t,e){var n=br(),o=Is(),r=(s,a,c)=>{const l=a.vertices.length;if(l>3){if(l>4){const d=[0,0,0];a.vertices.forEach(m=>n.add(d,d,m)),n.snap(d,n.divide(d,d,[l,l,l]),s);for(let m=0;m<l;m++){const h=o.create([d,a.vertices[m],a.vertices[(m+1)%l]]);a.color&&(h.color=a.color),c.push(h)}return}const u=o.create([a.vertices[0],a.vertices[1],a.vertices[2]]),_=o.create([a.vertices[0],a.vertices[2],a.vertices[3]]);a.color&&(u.color=a.color,_.color=a.color),c.push(u,_);return}c.push(a)},i=(s,a)=>{const c=[];return a.forEach(l=>{r(s,l,c)}),c};e.exports=i}}),Dgn=it({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(t,e){var n=Pi(),o=ZP(),r=ji(),i=$i(),s=il(),a=NKe(),c=Tgn(),l=wgn(),u=Egn(),_=(p,x)=>x,d=(p,x)=>x,m=(p,x)=>{const f={snap:!1,simplify:!1,triangulate:!1},{snap:g,simplify:y,triangulate:b}=Object.assign({},f,p),v=o(x);let S=i.toPolygons(x);g&&(S=a(v,S)),y&&(S=c(v,S)),b&&(S=l(S),S=u(v,S));const M=Object.assign({},x);return M.polygons=S,M},h=(p,...x)=>{if(x=n(x),x.length===0)throw new Error("wrong number of arguments");const f=x.map(g=>{if(s.isA(g))return _(p,g);if(r.isA(g))return d(p,g);if(i.isA(g))return m(p,g);throw new Error("invalid geometry")});return f.length===1?f[0]:f};e.exports=h}}),Agn=it({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(t,e){var n=Pi(),o=ds(),r=ji(),i=$i(),s=il(),a=ZP(),c=NKe(),l=m=>{const h=a(m),x=s.toPoints(m).map(f=>o.snap(o.create(),f,h));return s.create(x)},u=m=>{const h=a(m);let x=r.toSides(m).map(f=>[o.snap(o.create(),f[0],h),o.snap(o.create(),f[1],h)]);return x=x.filter(f=>!o.equals(f[0],f[1])),r.create(x)},_=m=>{const h=a(m),p=i.toPolygons(m),x=c(h,p);return i.create(x)},d=(...m)=>{if(m=n(m),m.length===0)throw new Error("wrong number of arguments");const h=m.map(p=>s.isA(p)?l(p):r.isA(p)?u(p):i.isA(p)?_(p):p);return h.length===1?h[0]:h};e.exports=d}}),Rgn=it({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(t,e){e.exports={generalize:Dgn(),snap:Agn(),retessellate:Uk()}}}),kgn=it({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(t,e){var n=(o,r,i)=>{for(o=o.slice();o.length<i;)o.push(r);return o};e.exports=n}}),Ngn=it({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(t,e){var n=Pi(),o=kgn(),r=Rpe(),{translate:i}=Z8(),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=o(u.modes,"none",3),u.modes.filter(_=>["center","max","min","none"].includes(_)).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=o(u.relativeTo,0,3),u.relativeTo.filter(_=>Number.isFinite(_)||_==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)=>{for(let m=0;m<3;m++)u[m]==null&&(_[m]==="center"?u[m]=(d[0][m]+d[1][m])/2:_[m]==="max"?u[m]=d[1][m]:_[m]==="min"&&(u[m]=d[0][m]));return u},c=(u,_,d)=>{const m=r(u),h=[0,0,0];for(let p=0;p<3;p++)_[p]==="center"?h[p]=d[p]-(m[0][p]+m[1][p])/2:_[p]==="max"?h[p]=d[p]-m[1][p]:_[p]==="min"&&(h[p]=d[p]-m[0][p]);return i(h,u)},l=(u,..._)=>{u=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},u),u=s(u);let{modes:m,relativeTo:h,grouped:p}=u;if(_=n(_),_.length===0)throw new Error("align(): No geometries were provided to act upon");if(h.filter(x=>x==null).length){const x=r(_);h=a(h,m,x)}return p?_=c(_,m,h):_=_.map(x=>c(x,m,h)),_.length===1?_[0]:_};e.exports=l}}),BU=it({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(t,e){var n=Pi(),o=ji(),r=$i(),i=il(),s=K8(),{translate:a}=Z8(),c=(m,h)=>{const p={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:x,relativeTo:f}=Object.assign({},p,m),g=s(h),y=[0,0,0];return x[0]&&(y[0]=f[0]-(g[0][0]+(g[1][0]-g[0][0])/2)),x[1]&&(y[1]=f[1]-(g[0][1]+(g[1][1]-g[0][1])/2)),x[2]&&(y[2]=f[2]-(g[0][2]+(g[1][2]-g[0][2])/2)),a(y,h)},l=(m,...h)=>{const p={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:x,relativeTo:f}=Object.assign({},p,m);if(h=n(h),h.length===0)throw new Error("wrong number of arguments");if(f.length!==3)throw new Error("relativeTo must be an array of length 3");m={axes:x,relativeTo:f};const g=h.map(y=>i.isA(y)||o.isA(y)||r.isA(y)?c(m,y):y);return g.length===1?g[0]:g},u=(...m)=>l({axes:[!0,!1,!1]},m),_=(...m)=>l({axes:[!1,!0,!1]},m),d=(...m)=>l({axes:[!1,!1,!0]},m);e.exports={center:l,centerX:u,centerY:_,centerZ:d}}}),zU=it({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(t,e){var n=Pi(),o=Cl(),r=ji(),i=$i(),s=il(),a=(_,...d)=>{if(!Array.isArray(_))throw new Error("factors must be an array");if(d=n(d),d.length===0)throw new Error("wrong number of arguments");for(_=_.slice();_.length<3;)_.push(1);if(_[0]<=0||_[1]<=0||_[2]<=0)throw new Error("factors must be positive");const m=o.fromScaling(o.create(),_),h=d.map(p=>s.isA(p)?s.transform(m,p):r.isA(p)?r.transform(m,p):i.isA(p)?i.transform(m,p):p);return h.length===1?h[0]:h},c=(_,...d)=>a([_,1,1],d),l=(_,...d)=>a([1,_,1],d),u=(_,...d)=>a([1,1,_],d);e.exports={scale:a,scaleX:c,scaleY:l,scaleZ:u}}}),Hgn=it({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(t,e){var n=Pi(),o=ji(),r=$i(),i=il(),s=(a,...c)=>{if(c=n(c),c.length===0)throw new Error("wrong number of arguments");const l=c.map(u=>i.isA(u)?i.transform(a,u):o.isA(u)?o.transform(a,u):r.isA(u)?r.transform(a,u):u);return l.length===1?l[0]:l};e.exports=s}}),tS=it({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(t,e){e.exports={align:Ngn(),center:BU().center,centerX:BU().centerX,centerY:BU().centerY,centerZ:BU().centerZ,mirror:Vk().mirror,mirrorX:Vk().mirrorX,mirrorY:Vk().mirrorY,mirrorZ:Vk().mirrorZ,rotate:$k().rotate,rotateX:$k().rotateX,rotateY:$k().rotateY,rotateZ:$k().rotateZ,scale:zU().scale,scaleX:zU().scaleX,scaleY:zU().scaleY,scaleZ:zU().scaleZ,transform:Hgn(),translate:Z8().translate,translateX:Z8().translateX,translateY:Z8().translateY,translateZ:Z8().translateZ}}}),VU=it({"node_modules/@jscad/modeling/src/index.js"(t,e){e.exports={colors:NU(),curves:E2n(),geometries:Tpe(),maths:Z2n(),measurements:axn(),primitives:eS(),text:Bxn(),utils:MKe(),booleans:Xk(),expansions:RKe(),extrusions:jk(),hulls:Cgn(),minkowski:Mgn(),modifiers:Rgn(),transforms:tS()}}}),HKe=it({"node_modules/jscad-planner/dist/index.cjs"(t,e){var n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s=(d,m)=>{for(var h in m)n(d,h,{get:m[h],enumerable:!0})},a=(d,m,h,p)=>{if(m&&typeof m=="object"||typeof m=="function")for(let x of r(m))!i.call(d,x)&&x!==h&&n(d,x,{get:()=>m[x],enumerable:!(p=o(m,x))||p.enumerable});return d},c=d=>a(n({},"__esModule",{value:!0}),d),l={};s(l,{executeJscadOperations:()=>_,jscadPlanner:()=>u}),e.exports=c(l);var u={booleans:{intersect:(...d)=>({type:"intersect",shapes:d}),subtract:(...d)=>({type:"subtract",shapes:d}),union:(...d)=>({type:"union",shapes:d})},hulls:{hull:(...d)=>({type:"hull",shapes:d.flat()}),hullChain:(...d)=>({type:"hullChain",shapes:d.flat()})},colors:{colorize:(d,m)=>({type:"colorize",color:d,shape:m})},primitives:{cube:d=>({type:"cube",...d}),sphere:d=>({type:"sphere",...d}),cylinder:d=>({type:"cylinder",...d}),polygon:d=>({type:"polygon",...d}),cuboid:d=>({type:"cuboid",...d}),roundedCuboid:d=>({type:"roundedCuboid",...d})},transforms:{rotate:(d,m)=>({type:"rotate",angles:d,shape:m}),scale:(d,m)=>({type:"scale",factors:d,shape:m}),translate:(d,m)=>({type:"translate",vector:d,shape:m})},extrusions:{extrudeLinear:(d,m)=>({type:"extrudeLinear",options:d,shape:m}),extrudeRotate:(d,m)=>({type:"extrudeRotate",options:d,shape:m})},maths:{vec2:{create:(d,m)=>[d,m],fromValues:(d,m)=>[d,m]},vec3:{create:(d,m,h)=>[d,m,h],fromValues:(d,m,h)=>[d,m,h]}},geometries:{geom2:{create:d=>({type:"createGeom2",points:d})},geom3:{create:d=>({type:"createGeom3",polygons:d})},path2:{create:d=>({type:"createPath2",points:d})}},measurements:{measureBoundingBox:d=>({type:"measureBoundingBox",shape:d}),measureArea:d=>({type:"measureArea",shape:d}),measureVolume:d=>({type:"measureVolume",shape:d})},utils:{degToRad:d=>d*Math.PI/180,radToDeg:d=>d*180/Math.PI}},_=(d,m)=>{if(Array.isArray(m)&&m.length===1)return _(d,m[0]);if(Array.isArray(m))throw new Error("executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually");const h=f=>_(d,f),{type:p,...x}=m;switch(p){case"intersect":return d.booleans.intersect(...m.shapes.map(h));case"subtract":return d.booleans.subtract(...m.shapes.map(h));case"union":return d.booleans.union(...m.shapes.map(h));case"hull":return d.hulls.hull(...m.shapes.map(h));case"hullChain":return d.hulls.hullChain(...m.shapes.map(h));case"colorize":return d.colors.colorize(m.color,h(m.shape));case"cube":return d.primitives.cube(x);case"sphere":return d.primitives.sphere(x);case"cylinder":return d.primitives.cylinder(x);case"polygon":return d.primitives.polygon(x);case"cuboid":return d.primitives.cuboid(x);case"roundedCuboid":return d.primitives.roundedCuboid(x);case"rotate":return d.transforms.rotate(m.angles,h(m.shape));case"scale":return d.transforms.scale(m.factors,h(m.shape));case"translate":return d.transforms.translate(m.vector,h(m.shape));case"extrudeLinear":return d.extrusions.extrudeLinear(m.options,h(m.shape));case"extrudeRotate":return d.extrusions.extrudeRotate(m.options,h(m.shape));case"createGeom2":return d.geometries.geom2.create(m.points);case"createGeom3":return d.geometries.geom3.create(m.polygons);case"createPath2":return d.geometries.path2.create(m.points);case"measureBoundingBox":return d.measurements.measureBoundingBox(h(m.shape));case"measureArea":return d.measurements.measureArea(h(m.shape));case"measureVolume":return d.measurements.measureVolume(h(m.shape));case"degToRad":return d.utils.degToRad(m.degrees);case"radToDeg":return d.utils.radToDeg(m.radians);default:throw m.type===void 0?new Error(`Operation type is undefined. This usually means the operation object is malformed or not properly initialized. Operation: ${JSON.stringify(m,null,2).slice(0,200)}...`):new Error(`Unsupported operation type: ${m.type}. Operation: ${JSON.stringify(m,null,2)}`)}}}}),Ign=it({"node_modules/ms/index.js"(t,e){var n=1e3,o=n*60,r=o*60,i=r*24,s=i*7,a=i*365.25;e.exports=function(d,m){m=m||{};var h=typeof d;if(h==="string"&&d.length>0)return c(d);if(h==="number"&&isFinite(d))return m.long?u(d):l(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))};function c(d){if(d=String(d),!(d.length>100)){var m=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(m){var h=parseFloat(m[1]),p=(m[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return h*a;case"weeks":case"week":case"w":return h*s;case"days":case"day":case"d":return h*i;case"hours":case"hour":case"hrs":case"hr":case"h":return h*r;case"minutes":case"minute":case"mins":case"min":case"m":return h*o;case"seconds":case"second":case"secs":case"sec":case"s":return h*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return h;default:return}}}}function l(d){var m=Math.abs(d);return m>=i?Math.round(d/i)+"d":m>=r?Math.round(d/r)+"h":m>=o?Math.round(d/o)+"m":m>=n?Math.round(d/n)+"s":d+"ms"}function u(d){var m=Math.abs(d);return m>=i?_(d,m,i,"day"):m>=r?_(d,m,r,"hour"):m>=o?_(d,m,o,"minute"):m>=n?_(d,m,n,"second"):d+" ms"}function _(d,m,h,p){var x=m>=h*1.5;return Math.round(d/h)+" "+p+(x?"s":"")}}}),Lgn=it({"node_modules/debug/src/common.js"(t,e){function n(o){i.debug=i,i.default=i,i.coerce=_,i.disable=l,i.enable=a,i.enabled=u,i.humanize=Ign(),i.destroy=d,Object.keys(o).forEach(m=>{i[m]=o[m]}),i.names=[],i.skips=[],i.formatters={};function r(m){let h=0;for(let p=0;p<m.length;p++)h=(h<<5)-h+m.charCodeAt(p),h|=0;return i.colors[Math.abs(h)%i.colors.length]}i.selectColor=r;function i(m){let h,p=null,x,f;function g(...y){if(!g.enabled)return;const b=g,v=Number(new Date),S=v-(h||v);b.diff=S,b.prev=h,b.curr=v,h=v,y[0]=i.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let M=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(A,D)=>{if(A==="%%")return"%";M++;const I=i.formatters[D];if(typeof I=="function"){const H=y[M];A=I.call(b,H),y.splice(M,1),M--}return A}),i.formatArgs.call(b,y),(b.log||i.log).apply(b,y)}return g.namespace=m,g.useColors=i.useColors(),g.color=i.selectColor(m),g.extend=s,g.destroy=i.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(x!==i.namespaces&&(x=i.namespaces,f=i.enabled(m)),f),set:y=>{p=y}}),typeof i.init=="function"&&i.init(g),g}function s(m,h){const p=i(this.namespace+(typeof h>"u"?":":h)+m);return p.log=this.log,p}function a(m){i.save(m),i.namespaces=m,i.names=[],i.skips=[];const h=(typeof m=="string"?m:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const p of h)p[0]==="-"?i.skips.push(p.slice(1)):i.names.push(p)}function c(m,h){let p=0,x=0,f=-1,g=0;for(;p<m.length;)if(x<h.length&&(h[x]===m[p]||h[x]==="*"))h[x]==="*"?(f=x,g=p,x++):(p++,x++);else if(f!==-1)x=f+1,g++,p=g;else return!1;for(;x<h.length&&h[x]==="*";)x++;return x===h.length}function l(){const m=[...i.names,...i.skips.map(h=>"-"+h)].join(",");return i.enable(""),m}function u(m){for(const h of i.skips)if(c(m,h))return!1;for(const h of i.names)if(c(m,h))return!0;return!1}function _(m){return m instanceof Error?m.stack||m.message:m}function d(){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 i.enable(i.load()),i}e.exports=n}}),Ogn=it({"node_modules/debug/src/browser.js"(t,e){t.formatArgs=o,t.save=r,t.load=i,t.useColors=n,t.storage=s(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let c;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function o(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,_=0;c[0].replace(/%[a-zA-Z%]/g,d=>{d!=="%%"&&(u++,d==="%c"&&(_=u))}),c.splice(_,0,l)}t.log=console.debug||console.log||(()=>{});function r(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function i(){let c;try{c=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!c&&typeof fpe<"u"&&"env"in fpe&&(c=fpe.env.DEBUG),c}function s(){try{return localStorage}catch{}}e.exports=Lgn()(t);var{formatters:a}=e.exports;a.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}}),IKe={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},LKe=te.createContext(void 0),Fgn=({children:t})=>{const[e,n]=te.useState(IKe),o=te.useCallback((s,a)=>{n(c=>({...c,[s]:a}))},[]),r=te.useCallback(()=>{n(IKe)},[]),i=te.useMemo(()=>({visibility:e,setLayerVisibility:o,resetToDefaults:r}),[e,o,r]);return G.jsx(LKe.Provider,{value:i,children:t})},nS=()=>{const t=te.useContext(LKe);if(!t)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return t},Xpe=1.2;function OKe(t){return te.useMemo(()=>{if(!t)return Xpe;try{return yr(t).pcb_board.list()[0]?.thickness??Xpe}catch{return Xpe}},[t])}var FKe=te.createContext(null),c2=()=>{const t=te.useContext(FKe);if(!t)throw new Error("useThree must be used within a ThreeProvider");return t},Gk=(t,e=[])=>{const{addFrameListener:n,removeFrameListener:o}=c2();ar.useEffect(()=>(n(t),()=>o(t)),[n,o,...e])},Yk={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},BKe=({children:t,position:e,style:n})=>{const{camera:o,renderer:r}=c2(),i=te.useRef(document.createElement("div")),[s,a]=te.useState(null);return te.useEffect(()=>{const c=r?.domElement.parentNode;if(c)return c.style.position!=="relative"&&c.style.position!=="absolute"&&(c.style.position="relative"),c.appendChild(i.current),a(XI.createPortal(t,i.current)),()=>{c.contains(i.current)&&c.removeChild(i.current)}},[r,t]),Gk(()=>{if(!o||!i.current||!r)return;const c=new wt(...e);c.project(o);const l=r.domElement.getBoundingClientRect(),u=Math.round((c.x+1)/2*l.width),_=Math.round((-c.y+1)/2*l.height);i.current.style.position="absolute",i.current.style.left=`${u}px`,i.current.style.top=`${_}px`,i.current.style.pointerEvents="none",i.current.style.zIndex=Yk.htmlElements.toString(),n&&Object.assign(i.current.style,n)},[o,r,e,n]),s},zKe={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},Xs=t=>{let e=typeof t=="number"?"mm":t.replace(/^[^a-zA-Z]+/g,"").toLowerCase();e||(e="mm");const n=typeof t=="number"?t:Number.parseFloat(t.split(e)[0]);if(e in zKe)return n*zKe[e];throw new Error(`Unsupported unit: ${e}`)},c_=Xs,Bgn=Object.defineProperty,zgn=(t,e)=>{for(var n in e)Bgn(t,n,{get:e[n],enumerable:!0})},D9={};zgn(D9,{axial:()=>f5n,bga:()=>yyn,breakoutheaders:()=>D5n,cap:()=>Ygn,dfn:()=>Kyn,diode:()=>Ggn,dip:()=>Wgn,electrolytic:()=>S3n,hc49:()=>k5n,jst:()=>z6n,led:()=>qgn,lqfp:()=>w5n,m2host:()=>j3n,melf:()=>Y4n,micromelf:()=>Q4n,minimelf:()=>z4n,mlp:()=>Eyn,mountedpcbmodule:()=>Y3n,ms012:()=>r5n,ms013:()=>s5n,msop:()=>J6n,pad:()=>N5n,pinrow:()=>Zyn,platedhole:()=>L3n,potentiometer:()=>b3n,pushbutton:()=>P5n,qfn:()=>Myn,qfp:()=>wyn,quad:()=>Iw,radial:()=>y5n,res:()=>fyn,sma:()=>n6n,smb:()=>u6n,smbf:()=>M3n,smc:()=>m6n,smf:()=>s6n,smtpad:()=>H3n,sod110:()=>$6n,sod123:()=>d5n,sod123f:()=>p4n,sod123fl:()=>y4n,sod123w:()=>q5n,sod128:()=>w4n,sod323:()=>Z5n,sod323f:()=>_4n,sod323fl:()=>n3n,sod323w:()=>Q6n,sod523:()=>B5n,sod723:()=>S4n,sod80:()=>X5n,sod882:()=>a4n,sod882d:()=>U4n,sod923:()=>o4n,soic:()=>Pyn,solderjumper:()=>_3n,son:()=>s3n,sop8:()=>W5n,sot:()=>F3n,sot223:()=>g6n,sot23:()=>Uyn,sot23w:()=>w6n,sot25:()=>Yyn,sot323:()=>A3n,sot343:()=>$3n,sot363:()=>Oyn,sot457:()=>m3n,sot563:()=>n5n,sot723:()=>c5n,sot886:()=>zyn,sot89:()=>I4n,sot963:()=>x3n,ssop:()=>Ryn,stampboard:()=>S5n,stampreceiver:()=>T5n,to220:()=>rQe,to220f:()=>F4n,to92:()=>O5n,to92l:()=>Q3n,to92s:()=>N6n,tqfp:()=>Tyn,tssop:()=>Hyn,vson:()=>c3n,vssop:()=>G6n});var Ho=(t,e,n)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:n,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:t,y:e},anchor_alignment:"center"}),Ro=rt({norefdes:Be().optional().describe("disable reference designator label"),invert:Be().optional().describe("hint to invert the orientation of the 3D model"),faceup:Be().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:Be().optional().describe("omit all silkscreen elements from the footprint")}),vi=(t,e,n,o,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:e,y:n,hole_diameter:Xs(o),outer_diameter:Xs(r),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()]}),_5=t=>{const{pn:e,x:n,y:o,holeDiameter:r,rectPadWidth:i,rectPadHeight:s,holeOffsetX:a=0,holeOffsetY:c=0,rectBorderRadius:l}=t;return{pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:n,y:o,hole_diameter:Xs(r),hole_shape:"circle",pad_shape:"rect",rect_pad_width:Xs(i),rect_pad_height:Xs(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}},$U=Array.from({length:9},(t,e)=>Math.cos(e/8*Math.PI-Math.PI)).map(t=>({x:t,y:-Math.sqrt(1-t**2)})),l2=t=>{if(t.length<2)throw new Error("Rect union outline requires at least two bounds");for(const l of t)if(l.minX>=l.maxX||l.minY>=l.maxY)throw new Error("Each rectangle bound must have min < max on both axes");for(let l=1;l<t.length;l++){const u=t[l-1],_=t[l];if(_.minX<u.minX||_.maxX>u.maxX||_.minY>u.minY||_.maxY<u.maxY)throw new Error("Bounds must be ordered outer-to-inner with tighter X and larger Y span")}const e=()=>{const l=[];let u=t.length-1;for(l.push({x:t[u].minX,y:t[u].maxY});u>0;){const _=t[u],d=t[u-1];l.push({x:_.minX,y:d.maxY}),l.push({x:d.minX,y:d.maxY}),u-=1}return l},n=()=>{const l=[];let u=t.length-1;for(l.push({x:t[u].maxX,y:t[u].maxY});u>0;){const _=t[u],d=t[u-1];l.push({x:_.maxX,y:d.maxY}),l.push({x:d.maxX,y:d.maxY}),u-=1}return l},o=()=>{const l=[];let u=t.length-1;for(l.push({x:t[u].maxX,y:t[u].minY});u>0;){const _=t[u],d=t[u-1];l.push({x:_.maxX,y:d.minY}),l.push({x:d.maxX,y:d.minY}),u-=1}return l},r=()=>{const l=[];let u=t.length-1;for(l.push({x:t[u].minX,y:t[u].minY});u>0;){const _=t[u],d=t[u-1];l.push({x:_.minX,y:d.minY}),l.push({x:d.minX,y:d.minY}),u-=1}return l},i=e(),s=n(),a=o(),c=r();return[...i.reverse(),...s,...a.reverse(),...c]};function ev(t){return typeof t=="string"?t.trim().toLowerCase().endsWith("mil")?parseFloat(t)*.0254:parseFloat(t):Number(t)}var WU=Nn([O(),Xe()]).transform(t=>ev(t)),Vgn=t=>Ro.extend({fn:O(),num_pins:Xe().optional().default(6),wide:Be().optional(),narrow:Be().optional(),w:WU.optional(),p:WU.default(t.p??"2.54mm"),id:WU.optional(),od:WU.optional(),nosquareplating:Be().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=ev("0.55mm"),e.od=ev("0.95mm")):(e.id=ev("0.8mm"),e.od=ev("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=ev("600mil"):e.narrow?e.w=ev("300mil"):e.w=ev(t.w??"300mil")),e)),$gn=Vgn({}),VKe=(t,e,n,o,r)=>{const i=t/2,s=e<=i,a=i-1,c=o,l=c*a;return s?{x:-n/2,y:l/2-(e-1)*c}:{x:n/2,y:-l/2+(e-i-1)*c}},Wgn=t=>{const e=$gn.parse(t),n=[];for(let f=0;f<e.num_pins;f++){const{x:g,y}=VKe(e.num_pins,f+1,e.w,e.p??2.54,e.nosquareplating);if(f===0&&!e.nosquareplating){n.push(_5({pn:f+1,x:g,y,holeDiameter:e.id??"0.8mm",rectPadWidth:e.od??"1mm",rectPadHeight:e.od??"1mm"}));continue}n.push(vi(f+1,g,y,e.id??"0.8mm",e.od??"1mm"))}const o=(e.num_pins/2-1)*e.p+e.od,i=e.w-e.od-1,s=(e.num_pins/2-1)*e.p+e.od+.4,a={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i/2,y:-s/2},{x:-i/2,y:s/2},...$U.map(({x:f,y:g})=>({x:f*i/6,y:g*i/6+s/2})),{x:i/2,y:s/2},{x:i/2,y:-s/2},{x:-i/2,y:-s/2}],type:"pcb_silkscreen_path",stroke_width:.1},c=[];for(let f=0;f<e.num_pins;f++){const g=f<e.num_pins/2,y=.6,{y:b}=VKe(e.num_pins,f+1,e.w,e.p??2.54,e.nosquareplating),v=g?-e.w/2-e.od/2-y:e.w/2+e.od/2+y,S=b;c.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${f+1}`,layer:"top",pcb_component_id:`pin_${f+1}`,text:`{pin${f+1}}`,anchor_position:{x:v,y:S},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const l=Ho(0,s/2+.5,.4),u=e.w+e.od,_=o,d=u/2+.25,m=d,h=_/2+.72,p=h,x={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:l2([{minX:-d,maxX:d,minY:-p,maxY:p},{minX:-m,maxX:m,minY:-h,maxY:h}]),layer:"top"};return{circuitJson:[...n,a,l,...c,x],parameters:e}},lo=(t,e,n,o,r)=>({type:"pcb_smtpad",x:e,y:n,width:o,height:r,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(i=>i.toString()):[t.toString()]}),$Ke=[{imperial:"01005",metric:"0402",p_mm_min:.5,pw_mm_min:.4,ph_mm_min:.3,w_mm_min:.58,h_mm_min:.21,courtyard_width_mm:1.2,courtyard_height_mm:.6},{imperial:"0504",metric:"1310",p_mm_min:1.1,pw_mm_min:.65,ph_mm_min:1.3,w_mm_min:.58,h_mm_min:.21},{imperial:"1812",metric:"4532",p_mm_min:4.275,pw_mm_min:1.125,ph_mm_min:3.4,w_mm_min:5.4,h_mm_min:3.4,courtyard_width_mm:5.9,courtyard_height_mm:3.9},{imperial:"0201",metric:"0603",p_mm_min:.66,pw_mm_min:.46,ph_mm_min:.4,w_mm_min:.9,h_mm_min:.3,courtyard_width_mm:1.4,courtyard_height_mm:.7},{imperial:"0402",metric:"1005",p_mm_min:1.02,pw_mm_min:.54,ph_mm_min:.64,w_mm_min:1.56,h_mm_min:.64,courtyard_width_mm:1.86,courtyard_height_mm:.94},{imperial:"0603",metric:"1608",p_mm_min:1.65,pw_mm_min:.8,ph_mm_min:.95,w_mm_min:2.45,h_mm_min:.95,courtyard_width_mm:2.96,courtyard_height_mm:1.46},{imperial:"0805",metric:"2012",p_mm_min:1.825,pw_mm_min:1.025,ph_mm_min:1.4,w_mm_min:2.8499999999999996,h_mm_min:1.4,courtyard_width_mm:3.36,courtyard_height_mm:1.9},{imperial:"1206",metric:"3216",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:1.75,w_mm_min:4.05,h_mm_min:1.75,courtyard_width_mm:4.56,courtyard_height_mm:2.26},{imperial:"1210",metric:"3225",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:2.65,w_mm_min:4.05,h_mm_min:2.65,courtyard_width_mm:4.56,courtyard_height_mm:3.16},{imperial:"2010",metric:"5025",p_mm_min:4.625,pw_mm_min:1.225,ph_mm_min:2.65,w_mm_min:5.85,h_mm_min:2.65,courtyard_width_mm:6.36,courtyard_height_mm:3.16},{imperial:"2512",metric:"6332",p_mm_min:5.925,pw_mm_min:1.225,ph_mm_min:3.35,w_mm_min:7.15,h_mm_min:3.35,courtyard_width_mm:7.66,courtyard_height_mm:3.86}],Ugn=Object.fromEntries($Ke.map(t=>[t.metric,t])),Xgn=Object.fromEntries($Ke.map(t=>[t.imperial,t])),jgn=(t,e)=>({type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:t,height:e,layer:"top"});Ro.extend({tht:Be(),p:_e.optional(),pw:_e.optional(),ph:_e.optional(),metric:nt.optional(),imperial:nt.optional(),w:_e.optional(),h:_e.optional(),textbottom:Be().optional()});var UU=t=>{let{tht:e,p:n,pw:o,ph:r,metric:i,imperial:s,w:a,h:c,textbottom:l}=t;if(typeof a=="string"&&(a=c_(a)),typeof c=="string"&&(c=c_(c)),typeof n=="string"&&(n=c_(n)),typeof o=="string"&&(o=c_(o)),typeof r=="string"&&(r=c_(r)),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(i&&(u=Ugn[i]),s&&(u=Xgn[s]),u&&(a=u.w_mm_min,c=u.h_mm_min,n=u.p_mm_min,o=u.pw_mm_min,r=u.ph_mm_min),n===void 0||o===void 0||r===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const _={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:n/2,y:r/2+.4},{x:-n/2-o/2-.2,y:r/2+.4},{x:-n/2-o/2-.2,y:-r/2-.4},{x:n/2,y:-r/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},d=l?-r/2-.9:r/2+.9,m=Ho(0,d,.2),h=u?.courtyard_width_mm&&u.courtyard_height_mm?jgn(u.courtyard_width_mm,u.courtyard_height_mm):null;return e?[vi(1,-n/2,0,o,o*1/.8),vi(2,n/2,0,o,o*1/.8),_,m,...h?[h]:[]]:[lo(["1","left"],-n/2,0,o,r),lo(["2","right"],n/2,0,o,r),_,m,...h?[h]:[]]},Ggn=t=>({circuitJson:UU(t),parameters:t}),Ygn=t=>({circuitJson:UU(t),parameters:t}),qgn=t=>({circuitJson:UU(t),parameters:t}),Hw=t=>{const{padSpacing:e,padWidth:n,padHeight:o,padPitch:r,numRows:i,textbottom:s,courtyardOutline:a}=t,c=[],l=(i-1)*(r/2);for(let D=0;D<i;D++)c.push(l-D*r);const u=[];c.forEach((D,I)=>{u.push(lo(I+1,-e/2,D,n,o))}),c.slice().reverse().forEach((D,I)=>{u.push(lo(I+i+1,e/2,D,n,o))});const _=Math.max(...c)+o/2+.4,d=Math.min(...c)-o/2-.4,m=-e/2-n/2-.4,h=e/2+n/2+.4,p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h*.5,y:_},{x:m*.5,y:_}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},x={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h*.5,y:d},{x:m*.5,y:d}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},f=-e/2,g=Math.max(...c),y=.2,b=f-n/2-.1,v=g+o/2+.1,S={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:[{x:b,y:v},{x:b-y,y:v},{x:b,y:v+y},{x:b,y:v}],stroke_width:.1},M=s?d-.9:_+.9,w=Ho(0,M,.2),A=a?{type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:a}:null;return[...u,p,x,S,w,...A?[A]:[]]},Jgn=Ro.extend({pw:_e.default("0.5mm"),ph:_e.default("0.4mm"),p:_e.default("0.7mm"),textbottom:Be().optional(),convex:Be().optional(),concave:Be().optional()}),Kgn=1,Qgn=t=>{const e=Jgn.parse(t);if(e.concave===!0)return[];const n=c_(e.pw),o=c_(e.ph),r=c_(e.p);return Hw({padSpacing:Kgn,padWidth:n,padHeight:o,padPitch:r,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1,y:.95},{x:-1,y:-.95},{x:1,y:-.95},{x:1,y:.95}]})},Zgn=Ro.extend({pw:_e.default("0.5mm"),ph:_e.default("0.32mm"),p:_e.default("0.5mm"),textbottom:Be().optional(),convex:Be().optional(),concave:Be().optional()}),eyn=1,tyn=t=>{const e=Zgn.parse(t),n=c_(e.pw),o=c_(e.ph),r=c_(e.p);return Hw({padSpacing:eyn,padWidth:n,padHeight:o,padPitch:r,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1,y:1.25},{x:-1,y:-1.25},{x:1,y:-1.25},{x:1,y:1.25}]})},nyn=Ro.extend({pw:_e.default("0.9mm"),ph:_e.default("0.4mm"),p:_e.default("0.8mm"),textbottom:Be().optional(),convex:Be().optional(),concave:Be().optional()}),oyn=1.7,ryn=t=>{const e=nyn.parse(t),n=c_(e.pw),o=c_(e.ph),r=c_(e.p);return Hw({padSpacing:oyn,padWidth:n,padHeight:o,padPitch:r,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1.55,y:1.05},{x:-1.55,y:-1.05},{x:1.55,y:-1.05},{x:1.55,y:1.05}]})},iyn=Ro.extend({pw:_e.default("0.9mm"),ph:_e.default("0.4mm"),p:_e.default("0.8mm"),textbottom:Be().optional(),convex:Be().optional(),concave:Be().optional()}),syn=1.7,ayn=t=>{const e=iyn.parse(t),n=c_(e.pw),o=c_(e.ph),r=c_(e.p);return Hw({padSpacing:syn,padWidth:n,padHeight:o,padPitch:r,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1.55,y:1.88},{x:-1.55,y:-1.87},{x:1.55,y:-1.87},{x:1.55,y:1.88}]})},cyn=Ro.extend({pw:_e.default("0.7mm"),ph:_e.default("0.64mm"),p:_e.default("0.94mm"),textbottom:Be().optional(),convex:Be().optional(),concave:Be().optional()}),lyn=1.4,uyn=t=>{const e=cyn.parse(t),n=c_(e.pw),o=c_(e.ph),r=c_(e.p);return Hw({padSpacing:lyn,padWidth:n,padHeight:o,padPitch:r,numRows:2,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-1.3,y:1.05},{x:-1.3,y:-1.05},{x:1.3,y:-1.05},{x:1.3,y:1.05}]})},_yn=Ro.extend({pw:_e.default("0.9mm"),ph:_e.default("0.9mm"),p:_e.default("1.34mm"),textbottom:Be().optional(),convex:Be().optional(),concave:Be().optional()}),dyn=3,hyn=t=>{const e=_yn.parse(t),n=c_(e.pw),o=c_(e.ph),r=c_(e.p);return Hw({padSpacing:dyn,padWidth:n,padHeight:o,padPitch:r,numRows:4,textbottom:e.textbottom,convex:e.convex,concave:e.concave,courtyardOutline:[{x:-2.21,y:2.85},{x:-2.21,y:-2.85},{x:2.2,y:-2.85},{x:2.2,y:2.85}]})},myn=t=>{const e=t.array??t.x;if(typeof e=="number")return Number.isNaN(e)?void 0:e;if(typeof e=="string"){const n=Number.parseInt(e,10);return Number.isNaN(n)?void 0:n}if(typeof t.imperial=="string"){const o=t.imperial.match(/x(2|4)$/)?.[1];if(o)return Number.parseInt(o,10)}},pyn=t=>t?(typeof t=="number"?`${t}`:t).split(/[_x]/)[0]:void 0,fyn=t=>{const e=myn(t),n=pyn(t.imperial);return e===2&&n==="0402"?{circuitJson:Qgn(t),parameters:t}:e===4&&n==="0402"?{circuitJson:tyn(t),parameters:t}:e===2&&n==="0603"?{circuitJson:ryn(t),parameters:t}:e===4&&n==="0603"?{circuitJson:ayn(t),parameters:t}:e===2&&n==="0606"?{circuitJson:uyn(t),parameters:t}:e===4&&n==="1206"?{circuitJson:hyn(t),parameters:t}:{circuitJson:UU(t),parameters:t}},WKe=(t,{x:e,y:n,radius:o})=>({type:"pcb_smtpad",x:e,y:n,radius:o,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(r=>r.toString()):[t.toString()]}),UKe="ABCDEFGHIJKLMNOPQRSTUVWXYZ",XU=O().transform(t=>{const[e,n]=t.split(/[x ]/);return{x:parseFloat(e??""),y:parseFloat(n??"")}}).pipe(rt({x:Xe(),y:Xe()})),xyn=O().or(Pt(b0())).transform(t=>Array.isArray(t)?t:(t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1)),t.split(",").map(e=>{const n=Number(e);return isNaN(n)?e:n}))).pipe(Pt(O().or(Xe()))),gyn=Ro.extend({fn:O(),num_pins:Xe().optional().default(64),grid:XU.optional(),p:nt.default("0.8mm"),w:_e.optional(),h:_e.optional(),ball:_e.optional().describe("ball diameter"),pad:_e.optional().describe("pad width/height"),circularpads:Be().optional().describe("use circular pads"),tlorigin:Be().optional(),blorigin:Be().optional(),trorigin:Be().optional(),brorigin:Be().optional(),missing:xyn.default([])}).transform(t=>{let e="tl";if(t.blorigin&&(e="bl"),t.trorigin&&(e="tr"),t.brorigin&&(e="br"),!t.grid){const o=Math.ceil(Math.sqrt(t.num_pins));t.grid={x:o,y:o}}return t.missing&&(t.missing=t.missing.map(o=>{if(typeof o=="number")return o;if(o==="center")return"center";if(o==="topleft")return"topleft";const r=o.match(/([A-Z]+)(\d+)/);if(!r)return o;const i=UKe.indexOf(r[1]),s=Number.parseInt(r[2])-1;return i*t.grid.x+s+1})),{...t,origin:e}}),yyn=t=>{const e=gyn.parse(t);let{num_pins:n,grid:o,p:r,w:i,h:s,ball:a,pad:c,missing:l}=e;a??=.75/1.27*r,c??=a*.8;const u=[],_=(l??[]).filter(J=>typeof J=="number"),d=o.x*o.y-n;if(l.length===0&&d>0&&(Math.sqrt(d)%1===0?l.push("center"):d===1&&l.push("topleft")),l?.includes("center")){const J=Math.floor(Math.sqrt(d)),ne=Math.floor((o.x-J)/2),ae=Math.floor((o.y-J)/2);for(let Z=ae;Z<ae+J;Z++)for(let oe=ne;oe<ne+J;oe++)_.push(Z*o.x+oe+1)}l?.includes("topleft")&&_.push(1);const m=new Set(_);let h=0;for(let J=0;J<o.y;J++)for(let ne=0;ne<o.x;ne++){const ae=(ne-(o.x-1)/2)*r,Z=(J-(o.y-1)/2)*r;let oe=ne,se=J;switch(e.origin){case"bl":oe=ne,se=o.y-1-J;break;case"br":oe=o.x-1-ne,se=o.y-1-J;break;case"tr":oe=o.x-1-ne,se=J;break}let le=se*o.x+oe+1;if(m.has(le)){h++;continue}le-=h;const pe=[le,`${UKe[se]}${oe+1}`];u.push(e.circularpads?WKe(pe,{x:ae,y:Z,radius:c/2}):lo(pe,ae,Z,c,c))}const p=Ho(0,o.y*r/2,.2),x=r/6;let f;const g=o.x*r/2,y=o.y*r/2;switch(e.origin){case"bl":f=[{x:-g,y:-y},{x:-g,y:-y-x},{x:-g-x,y:-y},{x:-g,y:-y}];break;case"br":f=[{x:g,y:-y},{x:g,y:-y-x},{x:g+x,y:-y},{x:g,y:-y}];break;case"tr":f=[{x:g,y},{x:g,y:y+x},{x:g+x,y},{x:g,y}];break;default:f=[{x:-g,y},{x:-g,y:y+x},{x:-g-x,y},{x:-g,y}];break}const b={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:f,stroke_width:.05},v=(o.x-1)*r+c,S=(o.y-1)*r+c,M=i??v,w=s??S,A=Math.max(v/2,M/2),D=Math.max(S/2,w/2),I=1.715,H=1.765,B=A+I,z=B,V=D+H,j=V,q={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:l2([{minX:-B,maxX:B,minY:-j,maxY:j},{minX:-z,maxX:z,minY:-V,maxY:V}]),layer:"top"};return{circuitJson:[...u,p,b,q],parameters:e}},jU=(t,e,n,o,r)=>({type:"pcb_smtpad",x:e,y:n,width:o,height:r,radius:r/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(t)?t.map(i=>i.toString()):[t.toString()]}),oS=t=>Ro.extend({fn:O(),num_pins:Xe().optional().default(8),w:_e.default(_e.parse(t.w??"5.3mm")),p:_e.default(_e.parse(t.p??"1.27mm")),pw:_e.default(_e.parse(t.pw??"0.6mm")),pl:_e.default(_e.parse(t.pl??"1.0mm")),legsoutside:Be().optional().default(t.legsoutside??!1),pillpads:Be().optional().default(t.pillpads??!1),silkscreen_stroke_width:Xe().optional().default(.1)}).transform(e=>(!e.pw&&!e.pl?(e.pw=_e.parse("0.6mm"),e.pl=_e.parse("1.0mm")):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e)),byn=oS({}),jpe=t=>{t.widthincludeslegs!==void 0&&(t.legsoutside=!t.widthincludeslegs);const{num_pins:e,pn:n,w:o,p:r,pl:i,legsoutside:s}=t,a=e/2,c=n<=a,l=a-1,u=r,_=u*l,d=s?i/2:-i/2;return c?{x:-o/2-d,y:_/2-(n-1)*u}:{x:o/2+d,y:-_/2+(n-a-1)*u}},Pyn=t=>{const e=byn.parse(t);return{circuitJson:qk(e),parameters:e}},qk=t=>{const e=[];for(let m=0;m<t.num_pins;m++){const{x:h,y:p}=jpe({num_pins:t.num_pins,pn:m+1,w:t.w,p:t.p,pl:t.pl,legsoutside:t.legsoutside});t.pillpads?e.push(jU(m+1,h,p,t.pl,t.pw)):e.push(lo(m+1,h,p,t.pl,t.pw))}const n=Math.min(1,t.p/2),o=t.w-(t.legsoutside?0:t.pl*2)-.2,r=(t.num_pins/2-1)*t.p+t.pw+n,i=Ho(0,r/2+.4,r/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:t.silkscreen_stroke_width??.1,route:[{x:-o/2,y:-r/2},{x:-o/2,y:r/2},...$U.map(({x:m,y:h})=>({x:m*o/6,y:h*o/6+r/2})),{x:o/2,y:r/2},{x:o/2,y:-r/2},{x:-o/2,y:-r/2}]},a=(t.num_pins/2-1)*t.p+t.pw,c=t.w/2+.25,l=c+1.93,u=a/2+.275,_=a/2+.635,d={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:l2([{minX:-l,maxX:l,minY:-u,maxY:u},{minX:-c,maxX:c,minY:-_,maxY:_}])};return[...e,s,i,d]},XKe=Kt(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),vyn=({num_pins:t,cw:e,ccw:n,startingpin:o})=>{const r=[],i=t/4;let s=1;const a={};for(const c of o??[])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=i:a.bottomside&&a.leftpin?s=i+1:a.bottomside&&a.rightpin?s=i*2:a.rightside&&a.bottompin?s=i*2+1:a.rightside&&a.toppin?s=i*3:a.topside&&a.rightpin?s=i*3+1:a.topside&&a.leftpin&&(s=i*4),r.push(-1);for(let c=0;c<t;c++)r[s]=c+1,n||!e?(s++,s>t&&(s=1)):(s--,s<1&&(s=t));return r},Gpe=Ro.extend({fn:O(),cc:Be().default(!0).optional(),ccw:Be().default(!0).optional(),startingpin:O().or(Pt(XKe)).transform(t=>typeof t=="string"?t.slice(1,-1).split(","):t).pipe(Pt(XKe)).optional(),num_pins:Xe().optional().default(64),w:_e.optional(),h:_e.optional(),p:_e.default(_e.parse("0.5mm")),pw:_e.optional(),pl:_e.optional(),thermalpad:Nn([Re(!0),XU]).optional(),legsoutside:Be().default(!1)}),Ype=t=>{t.w&&!t.h?t.h=t.w:!t.w&&t.h&&(t.w=t.h);const e=t.num_pins/4;if(!t.p&&!t.pw&&!t.pl&&t.w){const n=e+4;t.p=t.w/n}return!t.p&&t.w&&t.h&&t.pw&&t.pl&&(t.p=(t.w-t.pl*2)/(e-1)),!t.w&&!t.h&&t.p&&(t.w=t.p*(e+4),t.h=t.w),t.p&&!t.pw&&!t.pl?(t.pw=t.p/2,t.pl=t.p/2):t.pw?t.pl||(t.pl=t.pw*(1/.6)):t.pw=t.pl*(.6/1),t},jKe=Gpe.transform(Ype),Syn=["left","bottom","right","top"],Cyn=t=>{const{pin_count:e,pn:n,w:o,h:r,p:i,pl:s,legsoutside:a}=t,c=e/4,l=Syn[Math.floor((n-1)/c)],u=(n-1)%c,_=i*(c-1),d=i*(c-1),m=a?s/2:-s/2;switch(l){case"left":return{x:-o/2-m+.1,y:d/2-u*i,o:"vert"};case"bottom":return{x:-_/2+u*i,y:-r/2-m+.1,o:"horz"};case"right":return{x:o/2+m-.1,y:-d/2+u*i,o:"vert"};case"top":return{x:_/2-u*i,y:r/2+m-.1,o:"horz"};default:throw new Error("Invalid pin number")}},Iw=t=>{const e=jKe.parse(t),n=[];let o=0,r=0;const i=vyn(e),s=e.num_pins/4;for(let y=0;y<e.num_pins;y++){const{x:b,y:v,o:S}=Cyn({pin_count:e.num_pins,pn:y+1,w:e.w,h:e.h,p:e.p??.5,pl:e.pl,legsoutside:e.legsoutside});let M=e.pw,w=e.pl;S==="vert"&&([M,w]=[w,M]);const A=i[y+1];o=Math.max(o,Math.abs(b)+M/2),r=Math.max(r,Math.abs(v)+w/2),n.push(lo(A,b,v,M,w))}if(e.thermalpad)if(typeof e.thermalpad=="boolean"){const y=e.p*(s-1)+e.pw,b=e.p*(s-1)+e.pw;o=Math.max(o,y/2),r=Math.max(r,b/2),n.push(lo(["thermalpad"],0,0,y,b))}else o=Math.max(o,e.thermalpad.x/2),r=Math.max(r,e.thermalpad.y/2),n.push(lo(["thermalpad"],0,0,e.thermalpad.x,e.thermalpad.y));const a=[];for(const[y,b,v]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const S=e.w/2*b,M=e.h/2*v;let w="none",A=S,D=M;const I=e.pw*2;i[1]===1&&y==="top-left"?w="in1":i[s*4]===1&&y==="top-left"||i[s*3+1]===1&&y==="top-right"?w="in2":i[s*3]===1&&y==="top-right"||i[s]===1&&y==="bottom-left"?w="in1":i[s+1]===1&&y==="bottom-left"?w="in2":i[s*2]===1&&y==="bottom-right"?w="in1":i[s*2+1]===1&&y==="bottom-right"&&(w="in2");const H=w==="in1"?1:-1;if(e.legsoutside){const B=w==="in1"?e.pl/2:e.pw/2,z=w==="in1"?e.pw/2:e.pl/2;A+=B*b*H,D-=z*v*H}(w==="none"||e.legsoutside)&&a.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${y}`,route:[{x:S-I*b,y:M},{x:S,y:M},{x:S,y:M-I*v}],type:"pcb_silkscreen_path",stroke_width:.1}),(w==="in1"||w==="in2")&&!e.legsoutside&&a.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${y}_1`,route:[{x:S-I*b,y:M},{x:S-I*b/2,y:M}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${y}_2`,route:[{x:S,y:M-I*v/2},{x:S,y:M-I*v}],type:"pcb_silkscreen_path",stroke_width:.1}),(w==="in1"||w==="in2")&&a.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${y}_3`,route:[{x:A-.2*-b,y:D+.2*H},{x:A,y:D},{x:A+.2*H*-b,y:D+.2},{x:A-.2*-b,y:D+.2*H}],type:"pcb_silkscreen_path",stroke_width:.1})}const c=Ho(0,e.h/2+(e.legsoutside?e.pl*1.2:.5),.3),l=y=>Math.ceil(y/.05)*.05,u=(s-1)*e.p+e.pw,_=(s-1)*e.p+e.pw,d=u/2+.25,m=_/2+.25,h=e.w/2+.25,p=e.h/2+.25,x=Math.max(h,l(o+.25)),f=Math.max(p,l(r+.25)),g={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:l2([{minX:-x,maxX:x,minY:-m,maxY:m},{minX:-h,maxX:h,minY:-p,maxY:p},{minX:-d,maxX:d,minY:-f,maxY:f}])};return{circuitJson:[...n,...a,c,g],parameters:e}};Gpe.extend({}).transform(Ype);var Myn=t=>(t.legsoutside=!1,t.pl||(t.pl=.875),t.pw||(t.pw=.25),Iw(t)),Tyn=t=>{if(t.legsoutside=!0,!t.p)switch(t.num_pins){case 32:t.p=.8;break;case 44:case 48:t.p=.5;break;case 64:case 80:case 100:t.p=.5;break;case 144:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 32:case 44:case 48:case 64:case 80:case 100:t.pl=1.475;break;case 144:t.pl=1.6;break}if(!t.pw)switch(t.num_pins){case 32:t.pw=.55;break;case 44:case 48:case 64:case 80:case 100:t.pw=.3;break;case 144:t.pw=.25;break}return Iw(t)},wyn=t=>{t.legsoutside=!0;const e=jKe.parse(t);if(!t.p)switch(t.num_pins){case 44:case 64:t.p=.8;break;case 52:t.w===14?t.p=1:t.p=.65;break;case 208:t.p=.5;break}if(!t.pl)switch(t.num_pins){case 44:case 52:case 64:t.pl=2.25;break;case 208:t.pl=1.65;break;default:t.pl=e.pl*4;break}if(!t.pw)switch(t.num_pins){case 44:case 64:t.pw=.5;break;case 52:t.w===14?t.pw=.45:t.pw=.55;break;case 208:t.pw=.3;break;default:t.pw=e.pw;break}return Iw(t)};Gpe.extend({}).transform(Ype);var Eyn=t=>(t.legsoutside=!1,t.thermalpad===void 0&&(t.thermalpad=!0),Iw(t)),Dyn=Ro.extend({fn:O(),num_pins:Xe().optional().default(8),w:_e.default(_e.parse("3.9mm")),p:_e.default(_e.parse("1.27mm")),pw:_e.optional(),pl:_e.optional(),legsoutside:Be().optional().default(!1),silkscreen_stroke_width:Xe().optional().default(.1)}).transform(t=>(t.pw==null&&t.pl==null?(t.pw=_e.parse("0.51mm"),t.pl=_e.parse("1.1mm")):t.pw==null?t.pw=t.pl*(.51/1.1):t.pl==null&&(t.pl=t.pw*(1.1/.51)),t)),Ayn=t=>{const{num_pins:e,pn:n,w:o,p:r}=t,i=e/2,s=n<=i,a=i-1,c=r,l=c*a,u=o+_e.parse("0.2mm"),_=(s?-1:1)*(u/2);return s?{x:_,y:l/2-(n-1)*c}:{x:_,y:-l/2+(n-i-1)*c}},Ryn=t=>{const e=Dyn.parse(t),n=[];for(let x=0;x<e.num_pins;x++){const{x:f,y:g}=Ayn({num_pins:e.num_pins,pn:x+1,w:e.w,p:e.p,pl:e.pl,legsoutside:e.legsoutside});n.push(lo(x+1,f,g,e.pl,e.pw))}const o=Math.min(1,e.p/2),r=e.w-(e.legsoutside?0:e.pl)-.2,i=(e.num_pins/2-1)*e.p+e.pw+o,s=Ho(0,i/2+.4,i/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:-r/2,y:-i/2},{x:-r/2,y:i/2},...$U.map(({x,y:f})=>({x:x*r/6,y:f*r/6+i/2})),{x:r/2,y:i/2},{x:r/2,y:-i/2},{x:-r/2,y:-i/2}]},c=(e.num_pins/2-1)*e.p+e.pw,l=e.legsoutside?e.w/2+e.pl:(e.w+.2)/2+e.pl/2,u=c/2,_=l+.25,d=_,m=u+.445,h=m,p={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:l2([{minX:-_,maxX:_,minY:-h,maxY:h},{minX:-d,maxX:d,minY:-m,maxY:m}]),layer:"top"};return{circuitJson:[...n,a,s,p],parameters:e}},kyn=Ro.extend({fn:O(),num_pins:Xe().optional().default(8),w:_e.default(_e.parse("3.0mm")),p:_e.default(_e.parse("0.5mm")),pw:_e.default(_e.parse("0.30mm")),pl:_e.default(_e.parse("1.45mm")),legsoutside:Be().optional().default(!0),silkscreen_stroke_width:Xe().optional().default(.1)}),Nyn=t=>{const{num_pins:e,pn:n,w:o,p:r,pl:i,legsoutside:s}=t,a=e/2,c=n<=a,l=a-1,u=r*l,_=s?i/2:-i/2;return c?{x:-o/2-_,y:u/2-(n-1)*r}:{x:o/2+_,y:-u/2+(n-a-1)*r}},Hyn=t=>{const e={...t},n=e.p,o=typeof n=="string"||typeof n=="number"?_e.parse(n):void 0,r=o!=null&&o<=_e.parse("0.5mm"),i=kyn.parse(e),s=[],a=r?i.w-_e.parse("0.15mm"):i.w;for(let b=0;b<i.num_pins;b++){const{x:v,y:S}=Nyn({num_pins:i.num_pins,pn:b+1,w:a,p:i.p,pl:i.pl,legsoutside:i.legsoutside});s.push(lo(b+1,v,S,i.pl,i.pw))}const c=Math.min(1,i.p/2),l=i.w-(i.legsoutside?0:i.pl*2)-.2,u=(i.num_pins/2-1)*i.p+i.pw+c,_=Ho(0,u/2+.4,u/12),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:i.silkscreen_stroke_width??.1,route:[{x:-l/2,y:-u/2},{x:-l/2,y:u/2},...$U.map(({x:b,y:v})=>({x:b*l/6,y:v*l/6+u/2})),{x:l/2,y:u/2},{x:l/2,y:-u/2},{x:-l/2,y:-u/2}]},m=(i.num_pins/2-1)*i.p+i.pw,h=i.w/2+(i.legsoutside?i.pl:0),p=i.w/2+.25,x=h+.18,f=m/2+.25,g=f+.35,y={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:l2([{minX:-x,maxX:x,minY:-f,maxY:f},{minX:-p,maxX:p,minY:-g,maxY:g}])};return{circuitJson:[...s,d,_,y],parameters:i}},Iyn=[{x:-1.45,y:.93},{x:-.73,y:.93},{x:-.73,y:1.1},{x:.73,y:1.1},{x:.73,y:.93},{x:1.45,y:.93},{x:1.45,y:-.93},{x:.73,y:-.93},{x:.73,y:-1.1},{x:-.73,y:-1.1},{x:-.73,y:-.93},{x:-1.45,y:-.93}],Lyn=Ro.extend({fn:O(),num_pins:Re(6).default(6),w:O().default("3.1mm"),h:O().default("2.0mm"),p:O().default("0.65mm"),pl:O().default("1.03mm"),pw:O().default("0.35mm"),string:O().optional()}),Oyn=t=>{const e=Lyn.parse({...t,fn:"sot363"}),n=_e.parse(e.w),o=_e.parse(e.h),r=_e.parse(e.p),i=_e.parse(e.pl),s=_e.parse(e.pw),a=[];for(let h=0;h<6;h++){const{x:p,y:x}=GKe(h+1,n,r);a.push(lo(h+1,p,x,i,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/4,y:o/2+.1},{x:n/4,y:o/2+.1}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/4,y:-o/2-.1},{x:n/4,y:-o/2-.1}],stroke_width:.05,pcb_silkscreen_path_id:""},u=GKe(1,n,r),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:u.x-i/2-.3,y:u.y},{x:u.x-i/2-.45,y:u.y+.15},{x:u.x-i/2-.45,y:u.y-.15},{x:u.x-i/2-.3,y:u.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Ho(0,o/2+.4,.25),m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:Iyn,layer:"top"};return{circuitJson:[...a,c,l,d,_,m],parameters:e}},GKe=(t,e,n,o)=>t<=3?{x:-.84,y:n-(t-1)*n}:{x:.84,y:-n+(t-4)*n},Fyn=[{x:-.75,y:1},{x:-.75,y:-1},{x:.75,y:-1},{x:.75,y:1}],Byn=Ro.extend({fn:O(),num_pins:Re(6).default(6),w:O().default("1.01mm"),h:O().default("1.45mm"),p:O().default("0.5mm"),pl:O().default("0.33mm"),pw:O().default("0.27mm"),string:O().optional()}),zyn=t=>{const e=Byn.parse({...t,fn:"sot886"}),n=_e.parse(e.w),o=_e.parse(e.h),r=_e.parse(e.p),i=_e.parse(e.pl),s=_e.parse(e.pw),a=[];for(let h=0;h<6;h++){const{x:p,y:x}=YKe(h+1,n,r,i);a.push(lo(h+1,p,x,i,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:o/2},{x:n/2,y:o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-o/2},{x:n/2,y:-o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u=YKe(1,n,r,i),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:u.x-i/2-.3,y:u.y},{x:u.x-i/2-.45,y:u.y+.15},{x:u.x-i/2-.45,y:u.y-.15},{x:u.x-i/2-.3,y:u.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Ho(0,o/2+.4,.25),m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:Fyn,layer:"top"};return{circuitJson:[...a,c,l,d,_,m],parameters:e}},YKe=(t,e,n,o)=>{const r=e/2-o/2;return t<=3?{x:-r,y:n-(t-1)*n}:{x:r,y:-n+(t-4)*n}},Vyn=[{x:-2.05,y:1.5},{x:-1.05,y:1.5},{x:-1.05,y:1.7},{x:1.05,y:1.7},{x:1.05,y:.55},{x:2.05,y:.55},{x:2.05,y:-.55},{x:1.05,y:-.55},{x:1.05,y:-1.7},{x:-1.05,y:-1.7},{x:-1.05,y:-1.5},{x:-2.05,y:-1.5},{x:-2.05,y:-.39},{x:-1.05,y:-.39},{x:-1.05,y:.39},{x:-2.05,y:.39}],$yn=[{x:-2.05,y:1.5},{x:-1.05,y:1.5},{x:-1.05,y:1.7},{x:1.05,y:1.7},{x:1.05,y:1.5},{x:2.05,y:1.5},{x:2.05,y:.39},{x:1.05,y:.39},{x:1.05,y:-.39},{x:2.05,y:-.39},{x:2.05,y:-1.5},{x:1.05,y:-1.5},{x:1.05,y:-1.7},{x:-1.05,y:-1.7},{x:-1.05,y:-1.5},{x:-2.05,y:-1.5}],qKe=Ro.extend({fn:O(),num_pins:Xe().default(3),w:O().default("1.92mm"),h:O().default("2.74mm"),pl:O().default("1.325mm"),pw:O().default("0.6mm"),p:O().default("0.95mm"),string:O().optional()}),Wyn=oS({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Uyn=t=>{const e=t.string?.match(/^sot23_(\d+)/),n=e?Number.parseInt(e[1],10):3;if(n===6||n===8){const r=Wyn.parse({...t,num_pins:n});return{circuitJson:qk(r),parameters:r}}const o=qKe.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:jyn(o),parameters:o};if(o.num_pins===5)return{circuitJson:KKe(o),parameters:o};throw new Error("Invalid number of pins")},Xyn=t=>{const{pn:e,p:n}=t;return e===1?{x:-1.1375,y:n}:e===2?{x:-1.1375,y:-n}:{x:1.1375,y:0}},jyn=t=>{const e=[];for(let r=0;r<t.num_pins;r++){const{x:i,y:s}=Xyn({num_pins:t.num_pins,pn:r+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(lo(r+1,i,s,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=Ho(0,Number.parseInt(t.h),.3),o={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:Vyn,layer:"top"};return[...e,n,o]},JKe=t=>{const{p:e,h:n,pn:o}=t;if(o===1)return{x:-1.1375,y:e};if(o===2)return{x:-1.1375,y:0};if(o===3)return{x:-1.1375,y:-e};if(o===4)return{x:1.1375,y:-e};if(o===5)return{x:1.1375,y:e};throw new Error("Invalid pin number")},KKe=t=>{const e=[];for(let d=1;d<=t.num_pins;d++){const{x:m,y:h}=JKe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:d});e.push(lo(d,m,h,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=(t.num_pins+1)/2*Number.parseFloat(t.p),o=Number.parseFloat(t.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:o/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:o/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-o/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-o/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Ho(0,o+.3,.3),a=JKe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.3,l=.4,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05},_={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:$yn,layer:"top"};return[...e,s,r,i,u,_]},Gyn=qKe.extend({}),Yyn=t=>{const e=Gyn.parse({...t,num_pins:5});return{circuitJson:KKe(e),parameters:e}},qyn=[{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}],Jyn=oS({}),Kyn=t=>{const e=Jyn.parse(t),n=[];for(let x=0;x<e.num_pins;x++){const{x:f,y:g}=jpe({num_pins:e.num_pins,pn:x+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(lo(x+1,f,g,e.pl??"1mm",e.pw??"0.6mm"))}const o=Math.min(1,e.p/2),r=e.w+o,i=(e.num_pins/2-1)*e.p+e.pw+o,s=[];for(const x of qyn){const{dx:f,dy:g}=x;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:f*r/2-f*e.p,y:g*i/2},{x:f*r/2,y:g*i/2},{x:f*r/2,y:g*i/2-g*e.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const a=e.p/4,c=-r/2-a/2,l=i/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=Ho(0,i/2+.4,i/12),_=x=>Math.ceil(x/.05)*.05,d=(e.num_pins/2-1)*e.p+e.pw,m=_(e.w/2+.25),h=_(d/2+.45),p={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:m*2,height:h*2,layer:"top"};return{circuitJson:[...n,u,...s,p],parameters:e}},rS=({fs:t,pn:e,anchor_x:n,anchor_y:o,textalign:r="center",orthogonal:i=!1,verticallyinverted:s=!1,layer:a="top"})=>{let c=0;i&&s?c=270:s?c=180:i?c=90:c=0;let l="center";return r==="left"&&(s?l="center_right":l="center_left"),r==="right"&&(s?l="center_left":l="center_right"),a==="bottom"&&(l==="center_left"?l="center_right":l==="center_right"&&(l="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:`{PIN${e}}`,layer:a,anchor_position:{x:n,y:o},anchor_alignment:l,ccw_rotation:c}};function QKe({pinlabeltextalignleft:t,pinlabeltextalignright:e,pinlabelorthogonal:n}){let o="top";return n?o="left":o="top",t&&(n?o="bottom":o="right"),e&&(n?o="top":o="left"),o}var Qyn=Ro.extend({fn:O(),num_pins:Xe().optional().default(6),rows:Nn([O(),Xe()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:_e.default("0.1in").describe("pitch"),id:_e.default("1.0mm").describe("inner diameter"),od:_e.default("1.5mm").describe("outer diameter"),male:Be().optional().describe("for male pin headers"),female:Be().optional().describe("for female pin headers"),smd:Be().optional().describe("surface mount device"),surfacemount:Be().optional().describe("surface mount device (verbose)"),rightangle:Be().optional().describe("right angle"),pw:_e.optional().default("1.0mm").describe("pad width for SMD"),pl:_e.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:Be().optional().default(!1),pinlabeltextaligncenter:Be().optional().default(!1),pinlabeltextalignright:Be().optional().default(!1),pinlabelverticallyinverted:Be().optional().default(!1),pinlabelorthogonal:Be().optional().default(!1),nosquareplating:Be().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:Be().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Be().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Be().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(t=>{const e=QKe(t);return{...t,pinlabelAnchorSide:e,male:t.male??!t.female,female:t.female??!1,smd:t.smd??t.surfacemount??!1,rightangle:t.rightangle??!1}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:Jn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),Zyn=t=>{const e=Qyn.parse(t),{p:n,id:o,od:r,rows:i,num_pins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:c,pinlabelorthogonal:l,pinlabeltextalignleft:u,pinlabeltextalignright:_,nopinlabels:d,doublesidedpinlabel:m,bottomsidepinlabel:h}=e;let p="center";u?p="left":_&&(p="right");const x=[],f=Math.ceil(s/i),g=-n,y=({xoff:ne,yoff:ae,od:Z,anchorSide:oe,smd:se,pw:le,pl:pe})=>{let Se=0,we=0;if(se){const De=Z/5;switch(oe){case"right":Se=le/2+De;break;case"top":we=pe/2+De;break;case"bottom":we=-(pe/2+De);break;case"left":Se=-(le/2+De);break}}else{const De=Z*.75;switch(oe){case"right":Se=De;break;case"top":we=De;break;case"bottom":we=-De;break;case"left":Se=-De;break}}return{anchor_x:ne+Se,anchor_y:ae+we}},b=(ne,ae,Z)=>{e.smd?x.push(lo(ne,ae,Z,e.pw,e.pl)):ne===1&&!e.nosquareplating?x.push(_5({pn:ne,x:ae,y:Z,holeDiameter:o,rectPadWidth:r,rectPadHeight:r})):x.push(vi(ne,ae,Z,o,r));const{anchor_x:oe,anchor_y:se}=y({xoff:ae,yoff:Z,od:r,anchorSide:a,smd:e.smd,pw:e.pw,pl:e.pl});d||(h?x.push(rS({fs:r/5,pn:ne,anchor_x:oe,anchor_y:se,textalign:p,orthogonal:l,verticallyinverted:c,layer:"bottom"})):x.push(rS({fs:r/5,pn:ne,anchor_x:oe,anchor_y:se,textalign:p,orthogonal:l,verticallyinverted:c,layer:"top"})),m&&x.push(rS({fs:r/5,pn:ne,anchor_x:oe,anchor_y:se,textalign:p,orthogonal:l,verticallyinverted:c,layer:"bottom"})))},v=new Set,S=i>2&&f>2;if(i===1){const ne=-((s-1)/2)*n;for(let ae=0;ae<s;ae++){const Z=ae+1,oe=ne+ae*n,se=`${oe},0`;if(v.has(se))throw new Error(`Overlap at ${se}`);v.add(se),b(Z,oe,0)}}else if(S){const ne=-((f-1)/2)*n;let ae=1;for(let Z=0;Z<i&&ae<=s;Z++)for(let oe=0;oe<f&&ae<=s;oe++){const se=ne+oe*n,le=Z*g,pe=`${se},${le}`;if(v.has(pe))throw new Error(`Overlap at ${pe}`);v.add(pe),b(ae++,se,le)}}else{const ne=-((f-1)/2)*n;let ae=1,Z=0,oe=i-1,se=0,le=f-1;for(;ae<=s&&Z<=oe&&se<=le;){for(let pe=Z;pe<=oe&&ae<=s;pe++){const Se=ne+se*n,we=pe*g,De=`${Se},${we}`;if(v.has(De))throw new Error(`Overlap at ${De}`);v.add(De),b(ae++,Se,we)}se++;for(let pe=se;pe<=le&&ae<=s;pe++){const Se=ne+pe*n,we=oe*g,De=`${Se},${we}`;if(v.has(De))throw new Error(`Overlap at ${De}`);v.add(De),b(ae++,Se,we)}if(oe--,se<=le){for(let pe=oe;pe>=Z&&ae<=s;pe--){const Se=ne+le*n,we=pe*g,De=`${Se},${we}`;if(v.has(De))throw new Error(`Overlap at ${De}`);v.add(De),b(ae++,Se,we)}le--}if(Z<=oe){for(let pe=le;pe>=se&&ae<=s;pe--){const Se=ne+pe*n,we=Z*g,De=`${Se},${we}`;if(v.has(De))throw new Error(`Overlap at ${De}`);v.add(De),b(ae++,Se,we)}Z++}}if(ae-1<s)throw new Error(`Missing pins: assigned ${ae-1}, expected ${s}`)}const M=Ho(0,n,.5),w=e.smd?e.pw/2:r/2,A=e.smd?e.pl/2:r/2,D=(f-1)*n,I=(i-1)*n,H=D/2+w,B=I/2+A,z=D/2+n/2,V=I/2+n/2,j=Math.max(H+.25,z+.5),q=Math.max(B+.25,V+.5),J={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:-((i-1)*n)/2},width:2*j,height:2*q,layer:"top"};return{circuitJson:[...x,M,J],parameters:e}},e5n=[{x:-1.2,y:.83},{x:-.75,y:.83},{x:-.75,y:.95},{x:.75,y:.95},{x:.75,y:.83},{x:1.2,y:.83},{x:1.2,y:-.83},{x:.75,y:-.83},{x:.75,y:-.95},{x:-.75,y:-.95},{x:-.75,y:-.83},{x:-1.2,y:-.83}],t5n=Ro.extend({fn:O(),num_pins:Re(6).default(6),w:O().default("2.1mm"),h:O().default("2.45mm"),p:O().default("0.5mm"),pl:O().default("0.675mm"),pw:O().default("0.35mm"),string:O().optional()}),n5n=t=>{const e=t5n.parse({...t,fn:"sot563"}),n=_e.parse(e.w),o=_e.parse(e.h),r=_e.parse(e.p),i=_e.parse(e.pl),s=_e.parse(e.pw),a=[];for(let h=0;h<6;h++){const{x:p,y:x}=ZKe(h+1,n,r,i);a.push(lo(h+1,p,x,i,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:o/2},{x:n/2,y:o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-o/2},{x:n/2,y:-o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u=ZKe(1,n,r,i),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:u.x-i/2-.3,y:u.y},{x:u.x-i/2-.45,y:u.y+.15},{x:u.x-i/2-.45,y:u.y-.15},{x:u.x-i/2-.3,y:u.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Ho(0,o/2+.4,.25),m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:e5n,layer:"top"};return{circuitJson:[...a,c,l,d,_,m],parameters:e}},ZKe=(t,e,n,o)=>{const r=e/2-o/2;return t<=3?{x:-r,y:n-(t-1)*n}:{x:r,y:-n+(t-4)*n}},o5n=oS({p:"1.27mm",w:"3.9mm",legsoutside:!0}),r5n=t=>{const e=o5n.parse({...t,num_pins:8});return{circuitJson:qk(e),parameters:e}},i5n=oS({p:"1.27mm",w:"7.5mm",legsoutside:!0}),s5n=t=>{const e=i5n.parse({...t,num_pins:16});return{circuitJson:qk(e),parameters:e}},a5n=Ro.extend({fn:O(),num_pins:Re(3).default(3),w:O().default("1.2mm"),h:O().default("1.2mm"),pw:O().default("0.40mm"),pl:O().default("0.45mm"),p:O().default("0.575mm")}),c5n=t=>{const e=a5n.parse(t),n=u5n(e),o=Ho(0,_e.parse(e.h),.2),r=1.8,i=1.8,s={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:[{x:-r/2,y:i/2},{x:r/2,y:i/2},{x:r/2,y:-i/2},{x:-r/2,y:-i/2}],layer:"top"};return{circuitJson:[...n,o,s],parameters:e}},l5n=t=>{const{pn:e,p:n}=t;return e===1?{x:n,y:0}:e===2?{x:-n,y:-.4}:{x:-n,y:.4}},u5n=t=>{const e=[];for(let n=0;n<3;n++){const{x:o,y:r}=l5n({num_pins:t.num_pins,pn:n+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(lo(n+1,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},_5n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("2.36mm"),h:O().default("1.22mm"),pl:O().default("0.9mm"),pw:O().default("1.2mm"),p:O().default("3.30mm")}),d5n=t=>{const e=_5n.parse(t),n=Ho(0,_e.parse(e.h)/4+.4,.3),i={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.7,height:2.3,layer:"top"};return{circuitJson:m5n(e).concat(n,i),parameters:e}},h5n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},m5n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=h5n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},p5n=Ro.extend({fn:O(),p:_e.optional().default("2.54mm"),id:_e.optional().default("0.7mm"),od:_e.optional().default("1.4mm")}),f5n=t=>{const e=p5n.parse(t),{p:n,id:o,od:r}=e,i=[vi(1,-n/2,0,o,r),vi(2,n/2,0,o,r)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2+r+o/2,y:0},{x:n/2-r-o/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Ho(0,1.5,.5),c=-n/2,l=n/2,u=r/2,_=r/2,d=c-u-.35,m=l+u+.26,h=_+.35,p=d,x=m,f=h,g={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:l2([{minX:d,maxX:m,minY:-f,maxY:f},{minX:p,maxX:x,minY:-h,maxY:h}]),layer:"top"};return{circuitJson:[...i,s,a,g],parameters:e}},x5n=(t,e,n,o,r,i=.1)=>{const s=[],a=[],c=Math.max(1,Math.ceil(Math.PI*n/i)),l=Math.PI/c;for(let u=0;u<=c;u++){const _=u*l,d=t+Math.cos(_)*n,m=e+Math.sin(_)*n;d<t-o&&m>=e-r/2&&m<=e+r/2||s.push({x:d,y:m})}for(let u=0;u<=c;u++){const _=Math.PI+u*l,d=t+Math.cos(_)*n,m=e+Math.sin(_)*n;d<t-o&&m>=e-r/2&&m<=e+r/2||a.push({x:d,y:m})}return{topArc:s,bottomArc:a}},g5n=Ro.extend({fn:O(),p:_e.optional().default("5mm"),id:_e.optional().default("0.8mm"),od:_e.optional().default("1.6mm"),ceramic:Be().optional(),electrolytic:Be().optional(),polarized:Be().optional()}),y5n=t=>{const e=g5n.parse(t),{p:n,id:o,od:r}=e;o===.8&&r===1.6&&(e.id=n===5?.8:n*.25,e.od=n===5?1.6:n*.5);const i=[vi(1,-n/2,0,e.id,e.od),vi(2,n/2,0,e.id,e.od)],s=n+.1,{topArc:a,bottomArc:c}=x5n(0,0,s,e.od/2,e.od),l=.02*n,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:l,pcb_silkscreen_path_id:""},_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:c,stroke_width:l,pcb_silkscreen_path_id:""},d={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:""},m=.1*n,h=-(n+m+.04*n),p=s-m-.08*n,x={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h-m,y:p},{x:h+m,y:p}],stroke_width:l,pcb_silkscreen_path_id:""},f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:h,y:p-m},{x:h,y:p+m}],stroke_width:l,pcb_silkscreen_path_id:""},g=Ho(0,s+.12*n,.1*n),y=[...i,u,_,d,g];(e.electrolytic===!0||e.polarized===!0)&&y.push(x,f);const v=n+.25,S={type:"pcb_courtyard_circle",pcb_courtyard_circle_id:"",pcb_component_id:"",center:{x:0,y:0},radius:v,layer:"top"};return y.push(S),{circuitJson:y,parameters:e}},iS=(t,e={})=>({type:"pcb_silkscreen_path",layer:e.layer||"top",pcb_component_id:e.pcb_component_id||"",pcb_silkscreen_path_id:e.pcb_silkscreen_path_id||"",route:t,stroke_width:e.stroke_width||.1}),b5n=Ro.extend({fn:Re("pushbutton"),w:_e.default(4.5),h:_e.default(6.5),id:_e.default(1),od:_e.default(1.2)}),P5n=t=>{const e=b5n.parse(t),n=e.w,o=e.h,r=e.id,i=[vi(1,-n/2,o/2,r,r*1.5),vi(2,-n/2,-o/2,r,r*1.5),vi(3,n/2,-o/2,r,r*1.5),vi(4,n/2,o/2,r,r*1.5)],s=[iS([{x:-n/2,y:-o/2},{x:-n/2,y:o/2}]),iS([{x:n/2,y:-o/2},{x:n/2,y:o/2}]),iS([{x:-n/2,y:0},{x:-n/5,y:0},{x:n/5*1/Math.sqrt(2),y:o/8}]),iS([{x:n/2,y:0},{x:n/5,y:0}])],a=Ho(0,o/2+.4,.5),c=r*1.5/2,l=n,u=o,_=l/2+c,d=u/2+c,m=_+.5,h=d+.5,p={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*m,height:2*h,layer:"top"};return{circuitJson:[...i,...s,a,p],parameters:e}},eQe=Ro.extend({fn:O(),w:_e.default("22.58mm"),h:_e.optional(),left:_e.optional().default(20),right:_e.optional().default(20),top:_e.optional().default(2),bottom:_e.optional().default(2),p:_e.default(_e.parse("2.54mm")),pw:_e.default(_e.parse("1.6mm")),pl:_e.default(_e.parse("2.4mm")),innerhole:Be().default(!1),innerholeedgedistance:_e.default(_e.parse("1.61mm")),silkscreenlabels:Be().default(!1),silkscreenlabelmargin:_e.default(_e.parse("0.1mm"))}),v5n=t=>{const e=eQe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},GU=(t,e,n)=>{let o=[];return n==="right"&&(o=[{x:t+1/2,y:e},{x:t-1/2,y:e+.6/2},{x:t-1/2,y:e-.6/2},{x:t+1/2,y:e}]),n==="left"&&(o=[{x:t-1/2,y:e},{x:t+1/2,y:e+.6/2},{x:t+1/2,y:e-.6/2},{x:t-1/2,y:e}]),n==="top"&&(o=[{x:t,y:e+1/2},{x:t-.6/2,y:e-1/2},{x:t+.6/2,y:e-1/2},{x:t,y:e+1/2}]),n==="bottom"&&(o=[{x:t,y:e-1/2},{x:t-.6/2,y:e+1/2},{x:t+.6/2,y:e+1/2},{x:t,y:e-1/2}]),o},S5n=t=>{const e=eQe.parse(t),n=e.h??v5n(e),o=[],r=[],i=[];let s=[];const a=1,c=a,l=e.left+e.right+(e.bottom??0)+(e.top??0),_=`pin${l}`.length*.7/2;if(e.right){const p=-((e.right-1)/2)*e.p;for(let x=0;x<e.right;x++){if(x===0&&!e.left&&!e.bottom&&!e.silkscreenlabels&&(s=GU(e.w/2-e.pl*1.4,p+x*e.p,"right")),o.push(lo(x+1+e.left+(e.bottom??0),e.w/2-e.pl/2,p+x*e.p,e.pl,e.pw)),e.silkscreenlabels){const f=x+1+e.left+(e.bottom??0),g=`pin${f}`;i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${f}`,pcb_component_id:"1",layer:"top",anchor_position:{x:e.w/2-e.pl-(_+e.silkscreenlabelmargin),y:p+x*e.p},text:g,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(vi(x+1+e.left+(e.bottom??0)+l,e.w/2,p+x*e.p,a,c)),r.push(vi(x+1+e.left+(e.bottom??0)+l*2,e.w/2-e.innerholeedgedistance,p+x*e.p,a,c)))}}if(e.left){const p=(e.left-1)/2*e.p;for(let x=0;x<e.left;x++){if(x===0&&!e.silkscreenlabels&&(s=GU(-e.w/2+e.pl*1.4,p-x*e.p,"left")),o.push(lo(x+1,-e.w/2+e.pl/2,p-x*e.p,e.pl,e.pw)),e.silkscreenlabels){const f=x+1,g=`pin${f}`;i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${f}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-e.w/2+e.pl+(_+e.silkscreenlabelmargin),y:p-x*e.p},text:g,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}e.innerhole&&(r.push(vi(x+1+l,-e.w/2,p-x*e.p,a,c)),r.push(vi(x+1+l*2,-e.w/2+e.innerholeedgedistance,p-x*e.p,a,c)))}}if(e.top){const p=(e.top-1)/2*e.p;for(let x=0;x<e.top;x++){if(x===0&&!e.left&&!e.bottom&&!e.right&&!e.silkscreenlabels&&(s=GU(p-x*e.p,n/2-e.pl*1.4,"top")),o.push(lo(x+1+e.left+e.right+(e.bottom??0),p-x*e.p,n/2-e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const f=x+1+e.left+e.right+(e.bottom??0),g=`pin${f}`;i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${f}`,pcb_component_id:"1",layer:"top",anchor_position:{x:p-x*e.p,y:n/2-e.pl-(_+e.silkscreenlabelmargin)},text:g,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}e.innerhole&&(r.push(vi(x+1+e.left+e.right+(e.bottom??0)+l,p-x*e.p,n/2,a,c)),r.push(vi(x+1+e.left+e.right+(e.bottom??0)+l*2,p-x*e.p,n/2-e.innerholeedgedistance,a,c)))}}if(e.bottom){const p=-((e.bottom-1)/2)*e.p;for(let x=0;x<e.bottom;x++){if(x===0&&!e.left&&!e.silkscreenlabels&&(s=GU(p+x*e.p,-n/2+e.pl*1.4,"bottom")),o.push(lo(x+1+e.left,p+x*e.p,-n/2+e.pl/2,e.pw,e.pl)),e.silkscreenlabels){const f=x+1+e.left,g=`pin${f}`;i.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${f}`,pcb_component_id:"1",layer:"top",anchor_position:{x:p+x*e.p,y:-n/2+e.pl+(_+e.silkscreenlabelmargin)},text:g,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}e.innerhole&&(r.push(vi(x+1+e.left+l,p+x*e.p,-n/2,a,c)),r.push(vi(x+1+e.left+l*2,p+x*e.p,-n/2+e.innerholeedgedistance,a,c)))}}const d={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},m={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2,y:n/2},{x:e.w/2,y:n/2},{x:e.w/2,y:-n/2},{x:-e.w/2,y:-n/2},{x:-e.w/2,y:n/2}],stroke_width:.1,layer:"top"},h=Ho(0,n/1.8,n/25);return{circuitJson:[...o,...r,...i,m,...e.silkscreenlabels?[]:[d],h],parameters:e}},tQe=Ro.extend({fn:O(),w:_e.default("22.58mm"),h:_e.optional(),left:_e.optional().default(20),right:_e.optional().default(20),top:_e.optional().default(2),bottom:_e.optional().default(2),p:_e.default(_e.parse("2.54mm")),pw:_e.default(_e.parse("1.6mm")),pl:_e.default(_e.parse("3.2mm")),innerhole:Be().default(!1),innerholeedgedistance:_e.default(_e.parse("1.61mm"))}),C5n=t=>{const e=tQe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},M5n=(t,e,n,o=1,r=.6)=>{const i=o/2,s=r/2;return{left:[{x:t+i,y:e},{x:t-i,y:e+s},{x:t-i,y:e-s},{x:t+i,y:e}],right:[{x:t-i,y:e},{x:t+i,y:e+s},{x:t+i,y:e-s},{x:t-i,y:e}],top:[{x:t,y:e-i},{x:t-s,y:e+i},{x:t+s,y:e+i},{x:t,y:e-i}],bottom:[{x:t,y:e+i},{x:t-s,y:e-i},{x:t+s,y:e-i},{x:t,y:e+i}]}[n]},T5n=t=>{const e=tQe.parse(t),n=e.h??C5n(e),o=[],r=[],i=[],s=1,a=1.2,c=e.left+e.right+(e.bottom??0)+(e.top??0);let l=[],u=1;if(e.left){const h=(e.left-1)/2*e.p;for(let p=0;p<e.left;p++)p===0&&(l=M5n(-e.w/2-e.pl/2,h-p*e.p,"left")),o.push(lo(u,-e.w/2+e.pl/2,h-p*e.p,e.pl,e.pw)),r.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:h-p*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&i.push(vi(u+c,-e.w/2+e.innerholeedgedistance,h-p*e.p,s,a))}if(e.bottom){const h=(e.bottom-1)/2*e.p;for(let p=e.bottom-1;p>=0;p--)o.push(lo(u,h-p*e.p,-n/2+e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:h-p*e.p,y:-n/2+e.pl/2-3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&i.push(vi(u+c,h-p*e.p,-n/2+e.innerholeedgedistance,s,a))}if(e.right){const h=-((e.right-1)/2)*e.p;for(let p=0;p<e.right;p++)o.push(lo(u,e.w/2-e.pl/2,h+p*e.p,e.pl,e.pw)),r.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:h+p*e.p},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&i.push(vi(u+c,e.w/2-e.innerholeedgedistance,h+p*e.p,s,a))}if(e.top){const h=-((e.top-1)/2)*e.p;for(let p=e.top-1;p>=0;p--)o.push(lo(u,h+p*e.p,n/2-e.pl/2,e.pw,e.pl)),r.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${u}`,pcb_component_id:"1",layer:"top",anchor_position:{x:h+p*e.p,y:n/2-e.pl/2+3.2},text:`pin${u}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),u++,e.innerhole&&i.push(vi(u+c,h+p*e.p,n/2-e.innerholeedgedistance,s,a))}const _={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:l,stroke_width:.1},d={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-e.w/2-e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:n/2+e.pl/3},{x:e.w/2+e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:-n/2-e.pl/3},{x:-e.w/2-e.pl/3,y:n/2+e.pl/3}],stroke_width:.1,layer:"top"},m=Ho(0,n/1.8,n/25);return{circuitJson:[...i,...o,...r,d,_,m],parameters:e}},w5n=t=>(t.legsoutside=!0,t.pl||(t.pl=1.5),t.pw||(t.pw=.3),Iw(t)),nQe=Ro.extend({fn:O(),w:_e.default("10mm"),h:_e.optional(),left:_e.optional().default(20),right:_e.optional().default(20),top:_e.optional().default(0),bottom:_e.optional().default(0),p:_e.default(_e.parse("2.54mm")),id:_e.optional().default(_e.parse("1mm")),od:_e.optional().default(_e.parse("1.5mm"))}),E5n=t=>{const e=nQe.parse(t);return e.left&&e.right?Math.max(e.left,e.right)*e.p:e.left?e.left*e.p:e.right?e.right*e.p:51},YU=(t,e,n,o=1,r=.6)=>{const i=o/2,s=r/2;return{left:[{x:t+i,y:e},{x:t-i,y:e+s},{x:t-i,y:e-s},{x:t+i,y:e}],right:[{x:t-i,y:e},{x:t+i,y:e+s},{x:t+i,y:e-s},{x:t-i,y:e}],top:[{x:t,y:e-i},{x:t-s,y:e+i},{x:t+s,y:e+i},{x:t,y:e-i}],bottom:[{x:t,y:e+i},{x:t-s,y:e-i},{x:t+s,y:e-i},{x:t,y:e+i}]}[n]},D5n=t=>{const e=nQe.parse(t),n=e.h??E5n(e),o=[],r=e.id,i=e.od;let s=[];if(e.right){const u=-((e.right-1)/2)*e.p;for(let _=0;_<e.right;_++)_===0&&!e.left&&!e.bottom&&(s=YU(e.w/2+i*1.4,u+_*e.p,"right")),o.push(vi(_+1+e.left+(e.bottom??0),e.w/2,u+_*e.p,r,i))}if(e.left){const u=-((e.left-1)/2)*e.p;for(let _=0;_<e.left;_++)_===e.left-1&&(s=YU(-e.w/2-i*1.4,u+_*e.p,"left")),o.push(vi(_+1,-e.w/2,u+_*e.p,r,i))}if(e.top){const u=-((e.top-1)/2)*e.p;for(let _=0;_<e.top;_++)_===e.top-1&&!e.left&&!e.bottom&&!e.right&&(s=YU(u+_*e.p,n/2+i*1.4,"top")),o.push(vi(_+1+e.right+(e.bottom??0)+e.left,u+_*e.p,n/2,r,i))}if(e.bottom){const u=-((e.bottom-1)/2)*e.p;for(let _=0;_<e.bottom;_++)_===0&&!e.left&&(s=YU(u+_*e.p,-n/2-i*1.4,"bottom")),o.push(vi(_+1+e.left,u+_*e.p,-n/2,r,i))}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-i,y:n/2+i},{x:e.w/2+i,y:n/2+i},{x:e.w/2+i,y:-n/2-i},{x:-e.w/2-i,y:-n/2-i},{x:-e.w/2-i,y:n/2+i}],stroke_width:.1,layer:"top"},l=Ho(0,n/1.7,n/25);return{circuitJson:[...o,c,l,a],parameters:e}},A5n=t=>{const{centerX:e,centerY:n,straightHalfLength:o,radius:r,arcSegmentCount:i=9,orientation:s="horizontal"}=t;if(o<0)throw new Error("Capsule straightHalfLength must be non-negative");if(r<=0)throw new Error("Capsule radius must be positive");if(i<2)throw new Error("Capsule arcSegmentCount must be at least 2");if(s==="horizontal"){const _=e-o,d=e+o,m=Array.from({length:i+1},(p,x)=>{const f=Math.PI/2-x*Math.PI/i;return{x:d+Math.cos(f)*r,y:n+Math.sin(f)*r}}),h=Array.from({length:i+1},(p,x)=>{const f=-Math.PI/2+x*Math.PI/i;return{x:_-Math.cos(f)*r,y:n+Math.sin(f)*r}});return[{x:_,y:n+r},{x:d,y:n+r},...m.slice(1,-1),{x:d,y:n-r},{x:_,y:n-r},...h.slice(1,-1)]}const a=n-o,c=n+o,l=Array.from({length:i+1},(_,d)=>{const m=Math.PI-d*Math.PI/i;return{x:e+Math.cos(m)*r,y:c+Math.sin(m)*r}}),u=Array.from({length:i+1},(_,d)=>{const m=d*Math.PI/i;return{x:e+Math.cos(m)*r,y:a-Math.sin(m)*r}});return[{x:e-r,y:a},{x:e-r,y:c},...l.slice(1,-1),{x:e+r,y:c},{x:e+r,y:a},...u.slice(1,-1)]},oQe=(t,e,n,o)=>Array.from({length:25},(r,i)=>{const s=i/24*Math.PI-Math.PI/2;return{x:t+(o==="right"?1:-1)*Math.cos(s)*n,y:e+Math.sin(s)*n}}),R5n=Ro.extend({fn:O(),p:_e.optional().default("4.88mm"),id:_e.optional().default("0.8mm"),od:_e.optional().default("1.5mm"),w:_e.optional().default("5.6mm"),h:_e.optional().default("3.5mm")}),k5n=t=>{const e=R5n.parse(t),{p:n,id:o,od:r,w:i,h:s}=e,a=s/2,c=[vi(1,-n/2,0,o,r),vi(2,n/2,0,o,r)],l=oQe(-i/2,0,a,"left"),u=oQe(i/2,0,a,"right"),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...l,...l.slice(1).reverse(),{x:-i/2,y:-s/2},{x:i/2,y:-s/2},...u,{x:i/2,y:s/2},{x:-i/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},d=Ho(0,n/4,.5),h=n/2+r/2,p=Math.max(s/2+.25,i/2+.03),x={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:A5n({centerX:0,centerY:0,straightHalfLength:h,radius:p,arcSegmentCount:9}),layer:"top"};return{circuitJson:[...c,_,d,x],parameters:e}};Ro.extend({w:_e,h:_e});var N5n=t=>{const{w:e,h:n}=t,o=Xs(e),r=Xs(n);return{circuitJson:[lo(1,0,0,o,r),Ho(0,r/2+.5,.2)],parameters:t}},sS=(t,e,n,o,r,i)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:e,y:n,outer_width:Xs(r),outer_height:Xs(i),hole_width:Xs(o),hole_height:Xs(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[t.toString()],ccw_rotation:0}),H5n=[{x:-2.73,y:3.71},{x:-2.73,y:-1.03},{x:2.73,y:-1.03},{x:2.73,y:3.71}],I5n=Ro.extend({fn:O(),num_pins:Nn([Re(3),Re(2)]).default(3),p:O().default("1.27mm"),id:O().default("0.72mm"),od:O().default("0.95mm"),w:O().default("4.5mm"),h:O().default("4.5mm"),inline:Be().default(!1),string:O().optional()}),L5n=(t,e,n)=>Array.from({length:25},(o,r)=>{const i=r/24*Math.PI;return{x:t+Math.cos(i)*n,y:e+Math.sin(i)*n}}),O5n=t=>{const e=t.string?.match(/^to92_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=I5n.parse({...t,num_pins:n}),{p:r,id:i,od:s,w:a,h:c,inline:l}=o,u=Number.parseFloat(c)/2,_=Number.parseFloat(r),d=Number.parseFloat(i),m=Number.parseFloat(s),h=m,p=m*(1.5/1.05);let x=[];if(o.num_pins===3)l?x=[_5({pn:1,x:-_,y:u-_,holeDiameter:d,rectPadWidth:m,rectPadHeight:p}),sS(2,0,u-_,d,h,p),sS(3,_,u-_,d,h,p)]:x=[_5({pn:1,x:-_,y:u-_,holeDiameter:d,rectPadWidth:m,rectPadHeight:m}),vi(2,0,u,d,m),vi(3,_,u-_,d,m)];else if(o.num_pins===2)x=[_5({pn:1,x:-_,y:u-_,holeDiameter:d,rectPadWidth:h,rectPadHeight:p}),sS(2,_,u-_,d,h,p)];else throw new Error("Invalid number of pins for TO-92");const f=Number.parseFloat(a)/2,g=L5n(0,u,f),y={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...g,{x:-f,y:0},{x:f,y:0},g[0]],stroke_width:.1,pcb_silkscreen_path_id:""},b=Ho(0,u+1,.5),v={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:H5n,layer:"top"};return{circuitJson:[...x,y,b,v],parameters:o}},F5n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("2.15mm"),h:O().default("1.20mm"),pl:O().default("0.5mm"),pw:O().default("0.6mm"),p:O().default("1.4mm")}),B5n=t=>{const e=F5n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2.5,height:1.4,layer:"top"};return{circuitJson:V5n(e).concat(o,n,s),parameters:e}},z5n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},V5n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=z5n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},$5n=oS({w:"7.05mm",p:"1.27mm",pw:"0.65mm",pl:"1.975mm"}),W5n=t=>{const e=$5n.parse(t),n=[];for(let d=0;d<e.num_pins;d++){const{x:m,y:h}=jpe({num_pins:e.num_pins,pn:d+1,w:e.w,p:e.p??1.27,pl:e.pl,widthincludeslegs:!0});n.push(lo(d+1,m,h,e.pl??"1.5mm",e.pw??"0.6mm"))}const o=(e.num_pins/2-1)*e.p+e.pw,r=Ho(0,o/2+1,o/12),i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-e.w/3,y:o/2+.4},{x:e.w/3,y:o/2+.4}],stroke_width:.1},s=(e.num_pins/2-1)*e.p+e.pw,a=e.w/2-1.395,c=e.w/2+.255,l=s/2+.25,u=s/2+.5,_={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:l2([{minX:-c,maxX:c,minY:-l,maxY:l},{minX:-a,maxX:a,minY:-u,maxY:u}])};return{circuitJson:[...n,r,i,_],parameters:e}},U5n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("5.0mm"),h:O().default("2.30mm"),pl:O().default("1.25mm"),pw:O().default("2mm"),p:O().default("3.75mm")}),X5n=t=>{const e=U5n.parse(t),n=Ho(0,_e.parse(e.h)/2+1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2+.5,y:_e.parse(e.h)/2+.5},{x:-_e.parse(e.w)/2-.5,y:_e.parse(e.h)/2+.5},{x:-_e.parse(e.w)/2-.5,y:-_e.parse(e.h)/2-.5},{x:_e.parse(e.p)/2+.5,y:-_e.parse(e.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:5.1,height:2.8,layer:"top"};return{circuitJson:G5n(e).concat(o,n,s),parameters:e}},j5n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},G5n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=j5n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Y5n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("4.4mm"),h:O().default("2.1mm"),pl:O().default("1.2mm"),pw:O().default("1.2mm"),p:O().default("2.9mm")}),q5n=t=>{const e=Y5n.parse(t),n=Ho(0,_e.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.5,height:2.2,layer:"top"};return{circuitJson:K5n(e).concat(o,n,s),parameters:e}},J5n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},K5n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=J5n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},Q5n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("3.30mm"),h:O().default("1.80mm"),pl:O().default("0.60mm"),pw:O().default("0.45mm"),p:O().default("2.1mm")}),Z5n=t=>{const e=Q5n.parse(t),n=Ho(0,_e.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.2,height:1.9,layer:"top"};return{circuitJson:t4n(e).concat(o,n,s),parameters:e}},e4n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},t4n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=e4n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},n4n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("1.4mm"),h:O().default("0.9mm"),pl:O().default("0.36mm"),pw:O().default("0.25mm"),p:O().default("0.85mm")}),o4n=t=>{const e=n4n.parse(t),n=_e.parse(e.w),o=_e.parse(e.h),r=_e.parse(e.pl),i=_e.parse(e.pw),s=_e.parse(e.p),a=Ho(0,o,.3),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s/2+.15,y:o/2},{x:-n/2-.15,y:o/2},{x:-n/2-.15,y:-o/2},{x:s/2+.15,y:-o/2}],stroke_width:.1,pcb_silkscreen_path_id:""},l=s+r,u=i,_=n/2,d=o/2,m=l/2,h=u/2,p=Math.max(_,m),x=Math.max(d,h),f=Math.min(_,m),g=Math.min(d,h),y=p+.05,b=f-.055,v=x,S=g+.155,M={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:l2([{minX:-y,maxX:y,minY:-S,maxY:S},{minX:-b,maxX:b,minY:-v,maxY:v}]),layer:"top"};return{circuitJson:i4n(e).concat(c,a,M),parameters:e}},r4n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},i4n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=r4n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},s4n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("1.3mm"),h:O().default("0.9mm"),pl:O().default("0.4mm"),pw:O().default("0.7mm"),p:O().default("0.7mm")}),a4n=t=>{const e=s4n.parse(t),n=Ho(0,_e.parse(e.h)+.1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2+.2,y:_e.parse(e.h)/2+.2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2+.2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2-.2},{x:_e.parse(e.p)/2+.2,y:-_e.parse(e.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:1.6,height:1.2,layer:"top"};return{circuitJson:l4n(e).concat(o,n,s),parameters:e}},c4n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},l4n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=c4n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},u4n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("3.05mm"),h:O().default("1.65mm"),pl:O().default("0.6mm"),pw:O().default("0.6mm"),pad_spacing:O().default("2.2mm")}),_4n=t=>{const e=u4n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.pad_spacing)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.pad_spacing)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.2,height:1.9,layer:"top"};return{circuitJson:h4n(e).concat(o,n,s),parameters:e}},d4n=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},h4n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=d4n({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},m4n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("4.4mm"),h:O().default("2.1mm"),pl:O().default("1.10mm"),pw:O().default("1.10mm"),p:O().default("2.8mm")}),p4n=t=>{const e=m4n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.4,height:2.3,layer:"top"};return{circuitJson:x4n(e).concat(o,n,s),parameters:e}},f4n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},x4n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=f4n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},g4n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("4.4mm"),h:O().default("2.1mm"),pl:O().default("0.91mm"),pw:O().default("1.22mm"),p:O().default("3.146mm")}),y4n=t=>{const e=g4n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.9,height:2.7,layer:"top"};return{circuitJson:P4n(e).concat(o,n,s),parameters:e}},b4n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},P4n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=b4n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},v4n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("1.80mm"),h:O().default("1.00mm"),pl:O().default("0.66mm"),pw:O().default("0.5mm"),p:O().default("0.8mm")}),S4n=t=>{const e=v4n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.1,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.1,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2.3,height:1.5,layer:"top"};return{circuitJson:M4n(e).concat(o,n,s),parameters:e}},C4n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},M4n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=C4n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},T4n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("6.2mm"),h:O().default("3.4mm"),pl:O().default("1.4mm"),pw:O().default("2.1mm"),p:O().default("4.4mm")}),w4n=t=>{const e=T4n.parse(t),n=Ho(0,_e.parse(e.h)/2+.4,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:6.3,height:3,layer:"top"};return{circuitJson:D4n(e).concat(o,n,s),parameters:e}},E4n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},D4n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=E4n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},A4n=[{x:-3.0875,y:-2.5},{x:-3.0875,y:2.5},{x:2.0125,y:2.5},{x:2.0125,y:-2.5}],R4n=[{x:-2.85,y:-2.5},{x:-2.85,y:2.5},{x:2.85,y:2.5},{x:2.85,y:-2.5}],k4n=Ro.extend({fn:O(),num_pins:Nn([Re(3),Re(5)]).default(3),w:O().default("4.20mm"),h:O().default("4.80mm"),pl:O().default("1.3mm"),pw:O().default("0.9mm"),p:O().default("1.5mm"),string:O().optional()}),N4n=t=>{const e=[],n=Number.parseFloat(t.p),o=Number.parseFloat(t.pw),r=Number.parseFloat(t.w),i=Number.parseFloat(t.pl),s=.175,a=(i-(i+s))/2;e.push(lo(1,-r/2+a,n,i,o),lo(2,-r/2,0,i+s,o),lo(3,-r/2+a,-n,i,o));const c=Ho(0,0,.3),l=Number.parseFloat(t.w)/2-1,u=Number.parseFloat(t.h)/2,_={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},d={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},m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:A4n,layer:"top"};return[...e,_,d,c,m]},H4n=t=>{const e=[];Number.parseFloat(t.p),Number.parseFloat(t.pw),Number.parseFloat(t.w),e.push(lo(1,-1.85,-1.5,1.5,.7),lo(2,-1.85,1.5,1.5,.7),lo(3,0,0,.8,2),lo(4,1.85,-1.5,1.5,.7),lo(5,1.85,1.5,1.5,.7));const n=Ho(0,Number.parseFloat(t.h)/2+.5,.3),o=Number.parseFloat(t.w)/2-1,r=Number.parseFloat(t.h)/2,i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o,y:r},{x:o,y:r}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o,y:-r},{x:o,y:-r}],type:"pcb_silkscreen_path",stroke_width:.1},a={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:R4n,layer:"top"};return[...e,i,s,n,a]},I4n=t=>{const e=t.string?.match(/^sot89_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=k4n.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:N4n(o),parameters:o};if(o.num_pins===5)return{circuitJson:H4n(o),parameters:o};throw new Error("Invalid number of pins for SOT89")},L4n=Ro.extend({fn:O(),p:_e.optional().default("5.0mm"),id:_e.optional().default("1.0mm"),od:_e.optional().default("1.9mm"),w:_e.optional().default("13mm"),h:_e.optional().default("7mm"),num_pins:Xe().optional(),string:O().optional()}),rQe=t=>{const e=L4n.parse(t),{id:n,od:o,w:r,h:i,string:s}=e,a=e.num_pins??Number.parseInt(s?.match(/^to220(?:_|-)(\d+)/i)?.[1]??"3"),c=-1,l=r/2,u=i/2,_=2.5,d=r*.4,m=Math.max(_,d/(a-1)),h=Array.from({length:a},(V,j)=>{const q=a%2===0?(j-a/2+.5)*m:(j-Math.floor(a/2))*m;return vi(j+1,q,c,n,o)}),p={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:""},x=-u+2*i/3,f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l,y:x},{x:l,y:x}],stroke_width:.1,pcb_silkscreen_path_id:""},g=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-r/6,y:x},{x:-r/6,y:u}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:r/6,y:x},{x:r/6,y:u}],stroke_width:.1,pcb_silkscreen_path_id:""}],y=Ho(0,i/2+.6,.5),b=Math.max(...h.map(V=>Math.abs(V.x)))+o/2,v=c+o/2,S=c-o/2,M=Math.max(b+.25,l-o*.59),w=u-o*.63,A=S-(o/2+.01),D=-M,I=M,H=Math.min(A,S-.25),B=Math.max(w,v+.25),z={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(D+I)/2,y:(H+B)/2},width:I-D,height:B-H,layer:"top"};return{circuitJson:[...h,p,f,...g,y,z],parameters:{...e,p:m}}},qpe=2.54,O4n=Ro.extend({fn:O(),id:_e.optional().default("1.2mm"),od:_e.optional().default("1.905mm"),ph:_e.optional().default("2mm"),w:_e.optional().default("13mm"),h:_e.optional().default("7mm"),num_pins:Xe().optional(),string:O().optional()}),F4n=t=>{const e=O4n.parse(t),n=e.num_pins??Number.parseInt(e.string?.match(/^to220f(?:_|-)(\d+)/i)?.[1]??"3"),o=rQe({...e,fn:"to220",string:e.string?.replace(/^to220f/i,"to220"),num_pins:n}),r=-1,i=Array.from({length:n},(a,c)=>{const l=n%2===0?(c-n/2+.5)*qpe:(c-Math.floor(n/2))*qpe;return c===0?_5({pn:1,x:l,y:r,holeDiameter:e.id,rectPadWidth:e.od,rectPadHeight:e.ph}):sS(c+1,l,r,Xs(e.id),Xs(e.od),Xs(e.ph))}),s=o.circuitJson.filter(a=>a.type!=="pcb_plated_hole");return{circuitJson:[...i,...s],parameters:{...e,p:qpe,num_pins:n}}},B4n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("5.40mm"),h:O().default("2.30mm"),pl:O().default("1.30mm"),pw:O().default("1.70mm"),p:O().default("3.5mm")}),z4n=t=>{const e=B4n.parse(t),n=Ho(0,_e.parse(e.h)/2+.4,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:5.3,height:2.2,layer:"top"};return{circuitJson:$4n(e).concat(o,n,s),parameters:e}},V4n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},$4n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=V4n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},W4n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("1.90mm"),h:O().default("1.33mm"),pl:O().default("0.5mm"),pw:O().default("0.7mm"),p:O().default("0.8mm")}),U4n=t=>{const e=W4n.parse(t),n=Ho(0,_e.parse(e.h)+.1,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2+.1,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2+.1,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:1.8,height:1.2,layer:"top"};return{circuitJson:j4n(e).concat(o,n,s),parameters:e}},X4n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},j4n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=X4n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},G4n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("7.0mm"),h:O().default("3.35mm"),pl:O().default("1.50mm"),pw:O().default("2.70mm"),p:O().default("4.8mm")}),Y4n=t=>{const e=G4n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:6.8,height:3.2,layer:"top"};return{circuitJson:J4n(e).concat(o,n,s),parameters:e}},q4n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},J4n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=q4n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},K4n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("3.0mm"),h:O().default("1.80mm"),pl:O().default("0.80mm"),pw:O().default("1.20mm"),p:O().default("1.6mm")}),Q4n=t=>{const e=K4n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.1,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.1,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2.9,height:1.7,layer:"top"};return{circuitJson:e6n(e).concat(o,n,s),parameters:e}},Z4n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},e6n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=Z4n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},t6n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("7.10mm"),h:O().default("3.40mm"),pl:O().default("2.50mm"),pw:O().default("1.80mm"),p:O().default("4.00mm")}),n6n=t=>{const e=t6n.parse(t),n=Ho(0,_e.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.5,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.5,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:7,height:3.5,layer:"top"};return{circuitJson:r6n(e).concat(o,n,s),parameters:e}},o6n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},r6n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=o6n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},i6n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("4.80mm"),h:O().default("2.10mm"),pl:O().default("1.30mm"),pw:O().default("1.40mm"),p:O().default("2.9mm")}),s6n=t=>{const e=i6n.parse(t),n=Ho(0,_e.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.7,height:2.3,layer:"top"};return{circuitJson:c6n(e).concat(o,n,s),parameters:e}},a6n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},c6n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=a6n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},l6n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("7.30mm"),h:O().default("4.40mm"),pl:O().default("2.50mm"),pw:O().default("2.30mm"),p:O().default("4.30mm")}),u6n=t=>{const e=l6n.parse(t),n=Ho(0,_e.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.1,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.1,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:7.3,height:4.5,layer:"top"};return{circuitJson:d6n(e).concat(o,n,s),parameters:e}},_6n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},d6n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=_6n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},h6n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("10.70mm"),h:O().default("6.60mm"),pl:O().default("2.50mm"),pw:O().default("3.30mm"),p:O().default("6.80mm")}),m6n=t=>{const e=h6n.parse(t),n=Ho(0,3,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2-.8},{x:-_e.parse(e.w)/2-.8,y:_e.parse(e.h)/2-.8},{x:-_e.parse(e.w)/2-.8,y:-_e.parse(e.h)/2+.8},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:9.8,height:6.7,layer:"top"};return{circuitJson:f6n(e).concat(o,n,s),parameters:e}},p6n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},f6n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=p6n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},x6n=Ro.extend({fn:O(),num_pins:Xe().default(4),w:O().default("8.50mm"),h:O().default("6.90mm"),pl:O().default("2mm"),pw:O().default("1.5mm"),p:O().default("2.30mm"),string:O().optional()}),g6n=t=>{const e=t.string?.match(/^sot223_(\d+)/),n=e?Number.parseInt(e[1],10):4;if(n===8){const r=P6n.parse({...t,num_pins:n});return{circuitJson:qk(r),parameters:r}}const o=x6n.parse({...t,num_pins:n});if(o.num_pins===4)return{circuitJson:b6n(o),parameters:o};if(o.num_pins===5)return{circuitJson:S6n(o),parameters:o};if(o.num_pins===6)return{circuitJson:M6n(o),parameters:o};throw new Error("Invalid number of pins")},y6n=t=>{const{pn:e,w:n,p:o}=t;return e===1?{x:-n/2+1.1,y:o}:e===2?{x:-n/2+1.1,y:0}:e===3?{x:-n/2+1.1,y:-o}:{x:n/2-1.1,y:0}},b6n=t=>{const e=[];let n=0,o=0;for(let h=0;h<t.num_pins;h++){const{x:p,y:x}=y6n({num_pins:t.num_pins,pn:h+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)}),f=h===3?3.8:Number.parseFloat(t.pw),g=Number.parseFloat(t.pl);n=Math.max(n,Math.abs(p)+g/2),o=Math.max(o,Math.abs(x)+f/2),e.push(lo(h+1,p,x,g,f))}const r=Ho(0,0,.3),i=Number.parseFloat(t.w)/2-2.4,s=Number.parseFloat(t.h)/2,a={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:s},{x:i,y:s},{x:i,y:s/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},c={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-s},{x:i,y:-s},{x:i,y:-s/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},l=Number.parseFloat(t.w)/2,u=Number.parseFloat(t.h)/2,_=Math.max(n+.25,l+.15),d=Math.max(o+.25,u+.15),m={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*_,height:2*d,layer:"top"};return[...e,a,c,r,m]},P6n=oS({p:"0.90mm",w:"2.8mm",legsoutside:!0}),v6n=t=>{const{p:e,pn:n,w:o}=t;if(n===1)return{x:-o/2+1.2,y:e/2+e};if(n===2)return{x:-o/2+1.2,y:e/2};if(n===3)return{x:-o/2+1.2,y:-e/2};if(n===4)return{x:-o/2+1.2,y:-e/2-e};if(n===5)return{x:o/2-1,y:0};throw new Error("Invalid pin number")},S6n=t=>{const e=[];let n=0,o=0;for(let h=1;h<=t.num_pins;h++){const{x:p,y:x}=v6n({h:Number.parseFloat(t.h),p:1.5,pn:h,w:Number.parseFloat(t.w)});let f=Number.parseFloat(t.pw),g=Number.parseFloat(t.pl);h===5?(f=3.4,g=1.8):(f=1,g=2.2),n=Math.max(n,Math.abs(p)+g/2),o=Math.max(o,Math.abs(x)+f/2),e.push(lo(h,p,x,g,f))}const r=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,s={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},a={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},c=Ho(0,0,.3),l=Number.parseFloat(t.w)/2,u=Number.parseFloat(t.h)/2,_=Math.max(n+.25,l+.15),d=Math.max(o+.25,u+.15),m={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*_,height:2*d,layer:"top"};return[...e,s,a,c,m]},C6n=t=>{const{p:e,pn:n,w:o}=t;if(n===1)return{x:-o/2+1.2,y:2*e};if(n===2)return{x:-o/2+1.2,y:e};if(n===3)return{x:-o/2+1.2,y:0};if(n===4)return{x:-o/2+1.2,y:-e};if(n===5)return{x:-o/2+1.2,y:-2*e};if(n===6)return{x:o/2-1.175,y:0};throw new Error("Invalid pin number")},M6n=t=>{const e=[];let n=0,o=0;for(let h=1;h<=t.num_pins;h++){const{x:p,y:x}=C6n({h:Number.parseFloat(t.h),p:1.3,pn:h,w:8.7});let f=Number.parseFloat(t.pw),g=Number.parseFloat(t.pl);h===6?(f=3.4,g=2.15):(f=.6,g=2.2),n=Math.max(n,Math.abs(p)+g/2),o=Math.max(o,Math.abs(x)+f/2),e.push(lo(h,p,x,g,f))}const r=Number.parseFloat(t.w)/2-2.4,i=Number.parseFloat(t.h)/2,s={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},a={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},c=Ho(0,0,.3),l=Number.parseFloat(t.w)/2,u=Number.parseFloat(t.h)/2,_=Math.max(n+.25,l+.15),d=Math.max(o+.25,u+.15),m={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*_,height:2*d,layer:"top"};return[...e,s,a,c,m]},T6n=Ro.extend({fn:O(),num_pins:Xe().default(3),w:O().default("3.40mm"),h:O().default("3.30mm"),pl:O().default("1mm"),pw:O().default("0.7mm"),p:O().default("1.2mm"),string:O().optional()}),w6n=t=>{const e=t.string?.match(/^sot23w_(\d+)/),n=e?Number.parseInt(e[1],3):3,o=T6n.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:D6n(o),parameters:o};throw new Error("Invalid number of pins")},E6n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.95}:e===2?{x:-n,y:-.95}:{x:n,y:0}},D6n=t=>{const e=[];for(let f=0;f<t.num_pins;f++){const{x:g,y}=E6n({num_pins:t.num_pins,pn:f+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(lo(f+1,g,y,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=Ho(0,Number.parseInt(t.h)/2+1,.3),o=Number.parseFloat(t.w)/2-1,r=Number.parseFloat(t.h)/2,i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o,y:r},{x:o+.3,y:r},{x:o+.3,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o,y:-r},{x:o+.3,y:-r},{x:o+.3,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1},a=Number.parseFloat(t.p),c=Number.parseFloat(t.pl),l=Number.parseFloat(t.pw),u=Number.parseFloat(t.h),_=a+c/2,d=.95+l/2,m=u/2,h=_+.25,p=Math.max(d+.25,m+.09),x={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*h,height:2*p,layer:"top"};return[...e,i,s,n,x]},A6n=Ro.extend({fn:O(),num_pins:Nn([Re(3),Re(2)]).default(3),p:O().default("1.27mm"),id:O().default("0.72mm"),od:O().default("0.95mm"),w:O().default("2.5mm"),h:O().default("4.2mm"),string:O().optional()}),R6n=t=>{const{p:e,id:n,od:o,w:r,h:i}=t,s=Number.parseFloat(i)/2,a=Number.parseFloat(e);return[vi(1,-a,s-a,n,o),vi(2,0,s-a,n,o),vi(3,a,s-a,n,o)]},k6n=t=>{const{p:e,id:n,od:o,h:r}=t,i=Number.parseFloat(r)/2,s=Number.parseFloat(e);return[vi(1,-s,i-s,n,o),vi(2,s,i-s,n,o)]},N6n=t=>{const e=t.string?.match(/^to92s_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=A6n.parse({...t,num_pins:n});let r=[];if(o.num_pins===3)r=R6n(o);else if(o.num_pins===2)r=k6n(o);else throw new Error("Invalid number of pins for TO-92");const i=Number.parseFloat(o.h)/2,s=Number.parseFloat(o.p),a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-i,y:i-s},{x:-1.9,y:0},{x:1.9,y:0},{x:i,y:i-s},{x:1.5,y:Number.parseFloat(o.h)/2+.5},{x:-1.5,y:Number.parseFloat(o.h)/2+.5},{x:-i,y:i-s}],stroke_width:.1,pcb_silkscreen_path_id:""},c=Ho(0,i+1,.5),l=Number.parseFloat(o.od),u=i-s,_=-s-l/2,d=s+l/2,m=u-l/2,h=u+l/2,p=-i,x=i,f=0,g=i+.5,y=Math.min(_,p)-.27,b=Math.max(d,x)+.13,v=Math.min(m,f)-.42,S=Math.max(h,g)+.08,M={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(y+b)/2,y:(v+S)/2},width:b-y,height:S-v,layer:"top"};return{circuitJson:[...r,a,c,M],parameters:o}},H6n=Ro.extend({fn:O(),p:_e.optional(),id:_e.optional(),pw:_e.optional(),pl:_e.optional(),w:_e.optional(),h:_e.optional(),sh:Be().optional().describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:Be().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),zh:Be().optional().describe("JST ZH (Through-hole) connector family. 1.5mm pitch wire-to-board."),string:O().optional()}),I6n=()=>({minX:Number.POSITIVE_INFINITY,maxX:Number.NEGATIVE_INFINITY,minY:Number.POSITIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY}),Jk=({bounds:t,centerX:e,centerY:n,width:o,height:r})=>{const i=o/2,s=r/2;t.minX=Math.min(t.minX,e-i),t.maxX=Math.max(t.maxX,e+i),t.minY=Math.min(t.minY,n-s),t.maxY=Math.max(t.maxY,n+s)},L6n={ph:{p:_e.parse("2.2mm"),id:_e.parse("0.70mm"),pw:_e.parse("1.20mm"),pl:_e.parse("1.20mm"),w:_e.parse("6mm"),h:_e.parse("5mm")},sh:{p:_e.parse("1mm"),pw:_e.parse("0.6mm"),pl:_e.parse("1.55mm"),w:_e.parse("5.8mm"),h:_e.parse("7.8mm")},zh:{p:_e.parse("1.5mm"),id:_e.parse("0.73mm"),pw:_e.parse("1.03mm"),pl:_e.parse("1.73mm"),w:_e.parse("3mm"),h:_e.parse("3.5mm")}};function O6n(t){return t.sh?"sh":t.ph?"ph":t.zh?"zh":"ph"}function F6n({variant:t,numPins:e,p:n,id:o,pw:r,pl:i}){const s=[],a=I6n();let c=0;if(t==="ph"){const l=-((e-1)/2)*n;for(let u=0;u<e;u++){const _=l+u*n;s.push(_5({pn:u+1,x:_,y:2,holeDiameter:o,rectPadWidth:r,rectPadHeight:i})),Jk({bounds:a,centerX:_,centerY:2,width:r,height:i}),c=Math.max(c,i/2)}}else if(t==="zh"){const l=-((e-1)/2)*n;for(let u=0;u<e;u++){const _=l+u*n;u===0?s.push(_5({pn:u+1,x:_,y:0,holeDiameter:o,rectPadWidth:r,rectPadHeight:i,rectBorderRadius:.12499977})):s.push(sS(u+1,_,0,o,r,i)),Jk({bounds:a,centerX:_,centerY:0,width:r,height:i}),c=Math.max(c,i/2)}}else{const l=-((e-1)/2)*n;for(let _=0;_<e;_++){const d=l+_*n;s.push(lo(_+1,d,-1.325,r,i)),Jk({bounds:a,centerX:d,centerY:-1.325,width:r,height:i}),c=Math.max(c,i/2)}const u=(e-1)/2*n+1.3;s.push(lo(e+1,-u,1.22,1.2,1.8)),s.push(lo(e+2,u,1.22,1.2,1.8)),Jk({bounds:a,centerX:-u,centerY:1.22,width:1.2,height:1.8}),Jk({bounds:a,centerX:u,centerY:1.22,width:1.2,height:1.8}),c=Math.max(c,.9)}return{pads:s,padBounds:a,maxPadHalfY:c}}function B6n({variant:t,w:e,h:n,numPins:o,p:r}){if(t==="ph")return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-3,y:3},{x:3,y:3},{x:3,y:-2},{x:-3,y:-2},{x:-3,y:3}],stroke_width:.1,pcb_silkscreen_path_id:""};if(t==="zh"&&o&&r){const i=(o-1)*r,s=-i/2-1.5,a=i/2+1.5,c=-n/2,l=n/2;return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:c},{x:a,y:c},{x:a,y:l},{x:s,y:l},{x:s,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""}}else return{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[],stroke_width:.1,pcb_silkscreen_path_id:""}}var z6n=t=>{const e=H6n.parse(t),n=O6n(e),o=L6n[n],r=e.p??o.p,i=e.id??o.id,s=e.pw??o.pw,a=e.pl??o.pl,c=e.w??o.w,l=e.h??o.h;let u;const _=t.num_pins;typeof _=="number"&&(u=_);const d=typeof t.string=="string"?t.string:"",m=d.match(/(?:^|_)jst(\d+)(?:_|$)/),h=d.match(/(?:^|_)zh(\d+)(?:_|$)/);if(m&&m[1]){const ae=Number.parseInt(m[1],10);Number.isNaN(ae)||(u=ae)}if(h&&h[1]){const ae=Number.parseInt(h[1],10);Number.isNaN(ae)||(u=ae)}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 p=F6n({variant:n,numPins:u,p:r,id:i,pw:s,pl:a}),{pads:x,padBounds:f,maxPadHalfY:g}=p,y=B6n({variant:n,w:c,h:l,numPins:u,p:r}),b=Ho(0,l/2+1,.5),v=y.route.map(ae=>ae.x),S=y.route.map(ae=>ae.y),M=v.length>0&&S.length>0,w=M?Math.min(f.minX,Math.min(...v)):f.minX,A=M?Math.max(f.maxX,Math.max(...v)):f.maxX,D=M?Math.min(f.minY,Math.min(...S)):f.minY,I=M?Math.max(f.maxY,Math.max(...S)):f.maxY,H=.5,B=.05,z=g+.085,V=w-H,j=A+H,q=D-z,J=I+B,ne={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(V+j)/2,y:(q+J)/2},width:j-V,height:J-q,layer:"top"};return{circuitJson:[...x,y,b,ne],parameters:{...e,p:r,id:i,pw:s,pl:a,w:c,h:l,num_pins:u,sh:n==="sh",ph:n==="ph",zh:n==="zh"}}},V6n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("3.30mm"),h:O().default("1.70mm"),pl:O().default("0.80mm"),pw:O().default("1mm"),p:O().default("1.90mm")}),$6n=t=>{const e=V6n.parse(t),n=Ho(0,_e.parse(e.h)/2+.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.2,height:2,layer:"top"};return{circuitJson:U6n(e).concat(o,n,s),parameters:e}},W6n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},U6n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=W6n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},X6n=t=>{switch(t){case 8:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"};case 10:return{w:"3.10mm",h:"3.33mm",p:"0.5mm",pl:"1.45mm",pw:"0.3mm"};default:return{w:"3.06mm",h:"3.14mm",p:"0.65mm",pl:"1.6mm",pw:"0.5mm"}}},j6n=Ro.extend({fn:O(),num_pins:Nn([Re(8),Re(10)]).default(8),w:O().optional(),h:O().optional(),p:O().optional(),pl:O().optional(),pw:O().optional(),string:O().optional()}),G6n=t=>{const e=j6n.parse(t),n=X6n(e.num_pins),o=_e.parse(e.w||n.w),r=_e.parse(e.h||n.h),i=_e.parse(e.p||n.p),s=_e.parse(e.pl||n.pl),a=_e.parse(e.pw||n.pw),c=[],l=e.num_pins/2;for(let w=0;w<e.num_pins;w++){const{x:A,y:D}=iQe(e.num_pins,w+1,o,i),I=w<l?w+1:e.num_pins-(w-l);c.push(lo(I,A,D,s,a))}const u=o,_=r,d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:_/2},{x:u/2,y:_/2}],stroke_width:.05,pcb_silkscreen_path_id:""},m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-u/2,y:-_/2},{x:u/2,y:-_/2}],stroke_width:.05,pcb_silkscreen_path_id:""},h=iQe(e.num_pins,1,u,i),p={x:h.x-.8,y:h.y},x={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:p.x-.4,y:p.y},{x:p.x-.7,y:p.y+.3},{x:p.x-.7,y:p.y-.3},{x:p.x-.4,y:p.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},f=Ho(0,_/2+.5,.3),g=(e.num_pins/2-1)*i+a,y=o/2+.25,b=y+1.43,v=g/2+.255,S=r/2+.25,M={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:l2([{minX:-b,maxX:b,minY:-v,maxY:v},{minX:-y,maxX:y,minY:-S,maxY:S}])};return{circuitJson:[...c,d,m,f,x,M],parameters:e}},iQe=(t,e,n,o)=>{const r=t/2,i=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-i;return{x:s*2.11,y:a*o}},Y6n=t=>{switch(t){case 10:return{w:"3.10mm",h:"3.32mm",p:"0.5mm",pl:"1.63mm",pw:"0.33mm"};case 12:return{w:"3mm",h:"4mm",p:"0.65mm",pl:"0.88mm",pw:"0.4mm"};case 16:return{w:"3.10mm",h:"4mm",p:"0.5mm",pl:"0.88mm",pw:"0.3mm"};default:return{w:"3.10mm",h:"3.32mm",p:"0.65mm",pl:"1.63mm",pw:"0.4mm"}}},q6n=Ro.extend({fn:O(),num_pins:Nn([Re(8),Re(10),Re(12),Re(16)]).default(8),w:O().optional(),h:O().optional(),p:O().optional(),pl:O().optional(),pw:O().optional(),string:O().optional()}),sQe=(t,e,n,o)=>{const r=t/2,i=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-i;return{x:s*_e.parse("2mm"),y:a*o}},J6n=t=>{const e=q6n.parse(t),n=Y6n(e.num_pins),o=_e.parse(e.w||n.w),r=_e.parse(e.h||n.h),i=_e.parse(e.p||n.p),s=_e.parse(e.pl||n.pl),a=_e.parse(e.pw||n.pw),c=[];for(let M=0;M<e.num_pins;M++){const{x:w,y:A}=sQe(e.num_pins,M+1,o,i);c.push(lo(M+1,w,A,s,a))}const l=o,u=r,_={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:""},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:""},m=sQe(e.num_pins,1,l,i),h={x:m.x-.8,y:m.y},p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:h.x-.4,y:h.y},{x:h.x-.7,y:h.y+.3},{x:h.x-.7,y:h.y-.3},{x:h.x-.4,y:h.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},x=Ho(0,u/2+.5,.3),f=(e.num_pins/2-1)*i+a,g=o/2+.25,y=g+1.43,b=f/2+.255,v=r/2+.25,S={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:l2([{minX:-y,maxX:y,minY:-b,maxY:b},{minX:-g,maxX:g,minY:-v,maxY:v}])};return{circuitJson:[...c,_,d,x,p,S],parameters:e}},K6n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("3.8mm"),h:O().default("1.65mm"),pl:O().default("1.2mm"),pw:O().default("1.2mm"),pad_spacing:O().default("2.6mm")}),Q6n=t=>{const e=K6n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.pad_spacing)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.pad_spacing)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:4.3,height:2.15,layer:"top"};return{circuitJson:e3n(e).concat(o,n,s),parameters:e}},Z6n=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},e3n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=Z6n({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},t3n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("3.20mm"),h:O().default("1.65mm"),pl:O().default("0.8mm"),pw:O().default("0.9mm"),pad_spacing:O().default("2.1mm")}),n3n=t=>{const e=t3n.parse(t),n=Ho(0,_e.parse(e.h),.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.pad_spacing)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.2,y:-_e.parse(e.h)/2},{x:_e.parse(e.pad_spacing)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:3.7,height:2.15,layer:"top"};return{circuitJson:r3n(e).concat(o,n,s),parameters:e}},o3n=t=>{const{pn:e,pad_spacing:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},r3n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=o3n({pn:n,pad_spacing:Number.parseFloat(t.pad_spacing)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},i3n=Ro.extend({fn:O(),num_pins:Nn([Re(6),Re(8)]).default(8),w:O().default("3mm"),h:O().default("3mm"),p:O().default("0.5mm"),pl:O().default("0.52mm"),pw:O().default("0.35mm"),epw:O().default("1.40mm"),eph:O().default("1.60mm"),string:O().optional(),ep:Be().default(!1)}),s3n=t=>{t.string&&t.string.includes("_ep")&&(t.ep=!0);const e=t.string?.match(/^son_(\d+)/),n=e?Number.parseInt(e[1],10):t.num_pins||8,o=i3n.parse({...t,num_pins:n}),r=_e.parse(o.w),i=_e.parse(o.h),s=_e.parse(o.p),a=_e.parse(o.pl),c=_e.parse(o.pw),l=_e.parse(o.epw),u=_e.parse(o.eph),_=[];for(let H=0;H<o.num_pins;H++){const{x:B,y:z}=Jpe(o.num_pins,H+1,r,s);_.push(lo(H+1,B,z,a,c))}o.ep&&_.push(lo(o.num_pins+1,0,0,l,u));const d=r,m=i,h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-d/2,y:m/2},{x:d/2,y:m/2}],stroke_width:.05,pcb_silkscreen_path_id:""},p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-d/2,y:-m/2},{x:d/2,y:-m/2}],stroke_width:.05,pcb_silkscreen_path_id:""},x=Jpe(o.num_pins,1,d,s),f={x:x.x-.4,y:x.y},g={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=Ho(0,m/2+.5,.3),b=Math.abs(Jpe(o.num_pins,1,r,s).x),v=(o.num_pins/2-1)*s+c,S=b*2+a,M=r/2+.25,w=S/2+.25,A=v/2+.25,D=i/2+.25,I={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:l2([{minX:-w,maxX:w,minY:-A,maxY:A},{minX:-M,maxX:M,minY:-D,maxY:D}])};return{circuitJson:[..._,h,p,y,g,I],parameters:o}},Jpe=(t,e,n,o)=>{const r=t/2,i=(e-1)%r,s=e<=r?-1:1,a=(r-1)/2-i;return{x:s*_e.parse("1.4mm"),y:a*o}},a3n=Ro.extend({fn:O(),num_pins:Xe().optional().default(8),p:nt.describe("pitch (distance between center of each pin)"),w:_e.describe("width between vertical rows of pins"),grid:XU.describe("width and height of the border of the footprint"),ep:XU.default("0x0mm").describe("width and height of the central exposed thermal pad"),epx:_e.default("0mm").describe("x offset of the center of the central exposed thermal pad"),pinw:_e.describe("width of the pin pads"),pinh:_e.describe("height of the pin pads")}),c3n=t=>{const e=a3n.parse(t),{num_pins:n,p:o,w:r,grid:i,ep:s,epx:a,pinw:c,pinh:l}=e;if(n%2!==0)throw new Error("invalid number of pins");const u=[];for(let M=0;M<n;M++){const{pinX:w,pinY:A}=l3n({pinCount:n,pinIndex:M,width:r,pitch:o});u.push(lo(M+1,w,A,c,l))}s.x>0&&s.y>0&&u.push(lo(e.num_pins+1,a,0,s.x,s.y));const _=u3n(i),d=Ho(0,i.y/2+o,i.y/6),m=(n/2-1)*o+l,h=r+c,p=i.x/2+.25,x=h/2+.25,f=m/2+.25,g=m/2+.45+Math.max(0,.8-o),y=Math.min(i.y/2+.25,g),b=Math.max(0,.37-Math.max(0,x-p-.38)*1.4),v=Math.max(f,y-b),S={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:l2([{minX:-x,maxX:x,minY:-v,maxY:v},{minX:-p,maxX:p,minY:-y,maxY:y}])};return{circuitJson:[...u,..._,d,S],parameters:e}},l3n=t=>{let e=0,n=0;const o=(t.pinCount/2-1)*t.pitch/2,r=t.pinCount/2;return t.pinIndex+1<=r?(e=t.pitch*t.pinIndex-o,n=0-t.width/2):(e=t.pitch*(t.pinCount-t.pinIndex-1)-o,n=t.width/2),{pinX:n,pinY:e}},u3n=t=>{const n=t.y/30;return[{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-t.x/2-.1,y:t.y/2+.1-n},{x:-t.x/2-.1,y:t.y/2+.1},{x:t.x/2+.1,y:t.y/2+.1},{x:t.x/2+.1,y:t.y/2+.1-n}],stroke_width:t.y/30},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-t.x/2-.1,y:-t.y/2-.1+n},{x:-t.x/2-.1,y:-t.y/2-.1},{x:t.x/2+.1,y:-t.y/2-.1},{x:t.x/2+.1,y:-t.y/2-.1+n}],stroke_width:t.y/30}]},_3n=t=>{const{num_pins:e,bridged:n,p:o=2.54,pw:r=1.5,ph:i=1.5}=t,s=_e.parse(o),a=_e.parse(r),c=_e.parse(i),l=Math.min(c/4,.5),u=[];for(let D=0;D<e;D++)u.push(lo(D+1,D*s,0,a,c));let _=[];if(n){const D=n.split("").map(Number);if(D.length>1)for(let I=0;I<D.length-1;I++){const H=D[I],B=D[I+1];if(typeof H=="number"&&typeof B=="number"&&!isNaN(H)&&!isNaN(B)){const z=(H-1)*s,V=(B-1)*s,j=Math.sign(V-z),q=z+j*(a/2),J=V-j*(a/2);_.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${H}}`,x:q,y:0,width:l,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${B}}`,x:J,y:0,width:l,layer:"top",route_type:"wire"}]})}}}const d=(e-1)*s+a+.7,m=c+1,h=(e-1)*s/2,p=0,x={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:h-d/2,y:p-m/2},{x:h+d/2,y:p-m/2},{x:h+d/2,y:p+m/2},{x:h-d/2,y:p+m/2},{x:h-d/2,y:p-m/2}],stroke_width:.15},g=p+m/2+.6,y=Ho(h,g,.4),b=(e-1)*s,v=b/2+a/2,S=c/2,M=v+.5,w=S+.5,A={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:b/2,y:0},width:2*M,height:2*w,layer:"top"};return{circuitJson:[...u,..._,x,y,A],parameters:t}},aQe={fn:Re("sot457"),num_pins:Re(6).default(6),pillh:O().default("0.45mm"),pillw:O().default("1.45mm"),pl:O(),pw:O(),p:O(),wave:Be().optional(),reflow:Be().optional()},d3n=Ro.extend({...aQe,h:O().default("2.5mm"),w:O().default("2.7mm"),pl:O().default("0.8mm"),pw:O().default("0.55mm"),p:O().default("0.95mm")}),h3n=Ro.extend({...aQe,h:O().default("3mm"),w:O().default("4mm"),pillr:O().default("0.225mm"),pl:O().default("1.45mm"),pw:O().default("1.5mm"),p:O().default("1.475mm")}).transform(t=>({...t,wave:t.wave??(t.reflow===void 0?!0:!t.reflow),reflow:t.reflow??(t.wave===void 0?!1:!t.wave)})),A9=t=>Number.parseFloat(t.replace("mm","")),cQe=({pitch:t,width:e,pinNumber:n})=>{const i={1:{x:-e/2-.1,y:t},2:{x:-e/2-.1,y:0},3:{x:-e/2-.1,y:-t},4:{x:e/2+.1,y:-t},5:{x:e/2+.1,y:0},6:{x:e/2+.1,y:t}}[n];if(!i)throw new Error(`Invalid pin number: ${n}`);return i},lQe=t=>{const e=[],n=A9(t.p),o=A9(t.pl),r=A9(t.pw),i=A9(t.w),s=A9(t.h);if(t.wave){const p={1:({padWidth:x,padHeight:f})=>lo(1,-n,n,f,x),2:({padWidth:x,padHeight:f})=>lo(2,-n,-n,f,x),3:({padWidth:x,padHeight:f})=>jU(3,-n,0,A9(t.pillw),A9(t.pillh)),4:({padWidth:x,padHeight:f})=>jU(4,n,0,A9(t.pillw),A9(t.pillh)),5:({padWidth:x,padHeight:f})=>lo(5,n,n,f,x),6:({padWidth:x,padHeight:f})=>lo(6,n,-n,f,x)};for(let x=1;x<=t.num_pins;x++){const f=p[x];f&&e.push(f({padWidth:o,padHeight:r}))}}else for(let p=1;p<=t.num_pins;p++){const{x,y:f}=cQe({pitch:n,width:i,pinNumber:p});e.push(lo(p,x,f,o,r))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i/3,y:s/2+n/1.3},{x:i/3,y:s/2+n/1.3}],stroke_width:.05},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i/3,y:-s/2-n/1.3},{x:i/3,y:-s/2-n/1.3}],stroke_width:.05},l=Ho(0,s+.5,.3),u=cQe({pitch:n,width:i,pinNumber:1}),_=t.wave?1:.5,d=t.wave?.7:.3;u.x-=t.wave?r:r*1.7;const m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:u.x+_/2,y:u.y},{x:u.x-_/2,y:u.y+d/2},{x:u.x-_/2,y:u.y-d/2},{x:u.x+_/2,y:u.y}],stroke_width:.05};let h;if(t.wave){const p=2*n,x=2*n,f=p/2+r/2,g=x/2+o/2,y=f+.25,b=g+.25;h={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:2*y,height:2*b,layer:"top"}}else{const x=i/2+.1+o/2,f=n+r/2,g=i/2,y=s/2,b=x+.25,v=g+.08,S=f+.25,M=Math.max(y+.45,S);h={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:l2([{minX:-b,maxX:b,minY:-S,maxY:S},{minX:-v,maxX:v,minY:-M,maxY:M}]),layer:"top"}}return[l,a,c,m,...e,h]},m3n=t=>{if(t.wave){const n=h3n.parse({...t,fn:"sot457"});return{circuitJson:lQe(n),parameters:n}}const e=d3n.parse(t);return{circuitJson:lQe(e),parameters:e}},p3n=[{x:-.8,y:.75},{x:.8,y:.75},{x:.8,y:-.75},{x:-.8,y:-.75}],f3n=Ro.extend({fn:O(),num_pins:Re(6).default(6),w:O().default("1.1mm"),h:O().default("1.45mm"),p:O().default("0.35mm"),pl:O().default("0.2mm"),pw:O().default("0.2mm"),string:O().optional()}),x3n=t=>{const e=f3n.parse({...t,fn:"sot963"}),n=_e.parse(e.w),o=_e.parse(e.h),r=_e.parse(e.p),i=_e.parse(e.pl),s=_e.parse(e.pw),a=[];for(let h=0;h<6;h++){const{x:p,y:x}=uQe(h+1,n,r,i);a.push(lo(h+1,p,x,i,s))}const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:o/2},{x:n/2,y:o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-n/2,y:-o/2},{x:n/2,y:-o/2}],stroke_width:.05,pcb_silkscreen_path_id:""},u=uQe(1,n,r,i),_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:u.x-i/2-.3,y:u.y},{x:u.x-i/2-.45,y:u.y+.15},{x:u.x-i/2-.45,y:u.y-.15},{x:u.x-i/2-.3,y:u.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},d=Ho(0,o/2+.4,.25),m={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:p3n,layer:"top"};return{circuitJson:[...a,c,l,d,_,m],parameters:e}},uQe=(t,e,n,o)=>{const r=e/2-o/2;return t<=3?{x:-r,y:n-(t-1)*n}:{x:r,y:-n+(t-4)*n}},g3n=Ro.extend({fn:O(),num_pins:Nn([Re(3),Re(2)]).default(3),p:O().default("3.8mm"),id:O().default("1.25mm"),od:O().default("2.35mm"),ca:O().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:O().default("5.35mm"),h:O().default("4mm"),string:O().optional()}),y3n=t=>{const{p:e,id:n,od:o,h:r,ca:i}=t,s=Number.parseFloat(r),a=Number.parseFloat(i);return[vi(1,0,a/4+.3,n,o),vi(2,s,0,n,o),vi(3,0,-a/4-.3,n,o)]},b3n=t=>{const e=t.string?.match(/^potentiometer_(\d+)/),n=e?Number.parseInt(e[1],10):3,o=g3n.parse({...t,num_pins:n});let r=[];o.num_pins===3&&(r=y3n(o));const i=Number.parseFloat(o.ca)/2+.15,s=Number.parseFloat(o.w),a=Number.parseFloat(o.od)/2+.35,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:i-1.75},{x:0,y:i},{x:s,y:i},{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:-i},{x:0,y:-i},{x:0,y:-i+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},u=Number.parseFloat(o.w)/2,_=Ho(u,i+1,.5),d=Number.parseFloat(o.od)/2,m=Number.parseFloat(o.h),h=Number.parseFloat(o.ca)/2,p=-(d+.25),x=m+d+.25,f=h+.25,g={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:(p+x)/2,y:0},width:x-p,height:2*f,layer:"top"};return{circuitJson:[...r,c,l,_,g],parameters:o}},P3n=Ro.extend({fn:O(),p:_e.optional().default("7.5mm"),id:_e.optional().default("1mm"),od:_e.optional().default("2mm"),d:_e.optional().default("10.5mm")}),v3n=(t,e,n,o,r)=>{const i=[],s=[];for(let a=0;a<=50;a++){const c=a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-o&&u>=e-r/2&&u<=e+r/2||i.push({x:l,y:u})}for(let a=0;a<=50;a++){const c=Math.PI+a/50*Math.PI,l=t+Math.cos(c)*n,u=e+Math.sin(c)*n;l<t-o&&u>=e-r/2&&u<=e+r/2||s.push({x:l,y:u})}return{topArc:i,bottomArc:s}},S3n=t=>{const e=P3n.parse(t),{p:n,id:o,od:r,d:i}=e,s=[vi(1,-n/2,0,o,r),vi(2,n/2,0,o,r)],{topArc:a,bottomArc:c}=v3n(0,0,i/2+.1,r/2,r),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:""},_={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:i/2+.1},{x:0,y:-(i/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},d=-(i/2+.5),m=r/2+1.5,h=.5,p={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:d-h,y:m},{x:d+h,y:m}],stroke_width:.1,pcb_silkscreen_path_id:""},x={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:d,y:m-h},{x:d,y:m+h}],stroke_width:.1,pcb_silkscreen_path_id:""},f=Ho(0,i/2+1,.5),g=i/2,y=n/2+r/2,v=Math.max(g,y)+.25,S={type:"pcb_courtyard_circle",pcb_courtyard_circle_id:"",pcb_component_id:"",center:{x:0,y:0},radius:v,layer:"top"};return{circuitJson:[...s,l,u,_,p,x,f,S],parameters:e}},C3n=Ro.extend({fn:O(),num_pins:Re(2).default(2),w:O().default("6.5mm"),h:O().default("3mm"),pl:O().default("1.75mm"),pw:O().default("2.40mm"),p:O().default("4.75mm")}),M3n=t=>{const e=C3n.parse(t),n=Ho(0,_e.parse(e.h)-.5,.3),o={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:_e.parse(e.p)/2,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.3,y:_e.parse(e.h)/2},{x:-_e.parse(e.w)/2-.3,y:-_e.parse(e.h)/2},{x:_e.parse(e.p)/2,y:-_e.parse(e.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""},s={type:"pcb_courtyard_rect",pcb_courtyard_rect_id:"",pcb_component_id:"",center:{x:0,y:0},width:7,height:3.5,layer:"top"};return{circuitJson:w3n(e).concat(o,n,s),parameters:e}},T3n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n/2,y:0}:{x:n/2,y:0}},w3n=t=>{const e=[];for(let n=1;n<=t.num_pins;n++){const{x:o,y:r}=T3n({pn:n,p:Number.parseFloat(t.p)});e.push(lo(n,o,r,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}return e},E3n=[{x:-1.45,y:.98},{x:-.73,y:.98},{x:-.73,y:1.1},{x:.73,y:1.1},{x:.73,y:.33},{x:1.45,y:.33},{x:1.45,y:-.33},{x:.73,y:-.33},{x:.73,y:-1.1},{x:-.73,y:-1.1},{x:-.73,y:-.98},{x:-1.45,y:-.98},{x:-1.45,y:-.32},{x:-.73,y:-.32},{x:-.73,y:.32},{x:-1.45,y:.32}],D3n=Ro.extend({fn:O(),num_pins:Xe().default(3),w:O().default("2.45mm"),h:O().default("2.40mm"),pl:O().default("0.92mm"),pw:O().default("0.45mm"),p:O().default("0.891mm"),string:O().optional()}),A3n=t=>{const e=t.string?.match(/^sot323_(\d+)/),n=e?Number.parseInt(e[1],3):3,o=D3n.parse({...t,num_pins:n});if(o.num_pins===3)return{circuitJson:k3n(o),parameters:o};throw new Error("Invalid number of pins")},R3n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n,y:.65}:e===2?{x:-n,y:-.65}:{x:n,y:0}},k3n=t=>{const e=[];for(let c=0;c<t.num_pins;c++){const{x:l,y:u}=R3n({num_pins:t.num_pins,pn:c+1,w:Number.parseFloat(t.w),h:Number.parseFloat(t.h),pl:Number.parseFloat(t.pl),p:Number.parseFloat(t.p)});e.push(lo(c+1,l,u,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=Ho(0,Number.parseInt(t.h)/2+1,.3),o=Number.parseFloat(t.w)/2-Number.parseFloat(t.pl),r=Number.parseFloat(t.h)/2,i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o,y:r+.3},{x:o,y:r+.3},{x:o,y:r/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o,y:-r-.3},{x:o,y:-r-.3},{x:o,y:-r/2}],type:"pcb_silkscreen_path",stroke_width:.1},a={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:E3n,layer:"top"};return[...e,i,s,n,a]},N3n=Ro.extend({fn:O(),circle:Be().optional(),rect:Be().optional(),square:Be().optional(),pill:Be().optional(),d:_e.optional(),pd:_e.optional(),diameter:_e.optional(),r:_e.optional(),pr:_e.optional(),radius:_e.optional(),w:_e.optional(),pw:_e.optional(),width:_e.optional(),h:_e.optional(),ph:_e.optional(),height:_e.optional(),s:_e.optional(),size:_e.optional(),string:O().optional()}).transform(t=>{let e="rect";t.circle&&(e="circle"),t.square&&(e="square"),t.rect&&(e="rect"),t.pill&&(e="pill");let n,o,r;return e==="circle"?t.r!==void 0?n=Xs(t.r):t.pr!==void 0?n=Xs(t.pr):t.radius!==void 0?n=Xs(t.radius):t.d!==void 0?n=Xs(t.d)/2:t.pd!==void 0?n=Xs(t.pd)/2:t.diameter!==void 0?n=Xs(t.diameter)/2:n=Xs("1mm")/2:(t.w!==void 0?o=Xs(t.w):t.pw!==void 0?o=Xs(t.pw):t.width!==void 0?o=Xs(t.width):t.s!==void 0?o=Xs(t.s):t.size!==void 0?o=Xs(t.size):o=Xs("1mm"),t.h!==void 0?r=Xs(t.h):t.ph!==void 0?r=Xs(t.ph):t.height!==void 0?r=Xs(t.height):e==="square"||e==="rect"?r=o:r=Xs("1mm")),{fn:t.fn,shape:e,radius:n,width:o,height:r}}),H3n=t=>{const e=N3n.parse(t),{shape:n,radius:o,width:r,height:i}=e;let s,a;return n==="circle"?(s=WKe(1,{x:0,y:0,radius:o}),a=o+.5):n==="pill"?(s=jU(1,0,0,r,i),a=Math.max(r,i)/2+.5):(s=lo(1,0,0,r,i),a=i/2+.5),{circuitJson:[s,Ho(0,a,.2)],parameters:e}},I3n=Ro.extend({fn:O(),d:_e.optional(),hd:_e.optional(),r:_e.optional(),hr:_e.optional(),pd:_e.optional(),pr:_e.optional(),squarepad:Be().optional().default(!1)}).transform(t=>{let e;t.d!==void 0?e=Xs(t.d):t.hd!==void 0?e=Xs(t.hd):t.r!==void 0?e=Xs(t.r)*2:t.hr!==void 0?e=Xs(t.hr)*2:e=Xs("1mm");let n;return t.pd!==void 0?n=Xs(t.pd):t.pr!==void 0?n=Xs(t.pr)*2:n=e*(1.5/1),{fn:t.fn,d:e,pd:n,squarepad:t.squarepad??!1}}),L3n=t=>{const e=I3n.parse(t),{d:n,pd:o,squarepad:r}=e;return{circuitJson:[r?_5({pn:1,x:0,y:0,holeDiameter:n,rectPadWidth:o,rectPadHeight:o}):vi(1,0,0,n,o),Ho(0,o/2+.5,.2)],parameters:e}},O3n=Ro.extend({fn:O(),num_pins:Re(6).default(6),h:O().default("1.6mm"),pl:O().default("1mm"),pw:O().default("0.7mm"),p:O().default("0.95mm")}),F3n=t=>{const e=O3n.parse(t);return{circuitJson:B3n(e),parameters:e}},_Qe=t=>{const{p:e,h:n,pn:o}=t;if(o===1)return{x:-n/2-.5,y:e};if(o===2)return{x:-n/2-.5,y:0};if(o===3)return{x:-n/2-.5,y:-e};if(o===4)return{x:n/2+.5,y:-e};if(o===5)return{x:n/2+.5,y:0};if(o===6)return{x:n/2+.5,y:e};throw new Error("Invalid pin number")},B3n=t=>{const e=[];for(let M=1;M<=t.num_pins;M++){const{x:w,y:A}=_Qe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:M});e.push(lo(M,w,A,Number.parseFloat(t.pl),Number.parseFloat(t.pw)))}const n=t.num_pins/2*Number.parseFloat(t.p),o=Number.parseFloat(t.h),r={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/3,y:o/2+Number.parseFloat(t.p)/1.3},{x:n/3,y:o/2+Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},i={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-n/3,y:-o/2-Number.parseFloat(t.p)/1.3},{x:n/3,y:-o/2-Number.parseFloat(t.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Ho(0,o+.3,.3),a=_Qe({h:Number.parseFloat(t.h),p:Number.parseFloat(t.p),pn:1});a.x=a.x-Number.parseFloat(t.pw)*1.5;const c=.7,l=.3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:a.x+c/2,y:a.y},{x:a.x-c/2,y:a.y+l/2},{x:a.x-c/2,y:a.y-l/2},{x:a.x+c/2,y:a.y}],stroke_width:.05},_=Number.parseFloat(t.h),d=Number.parseFloat(t.p),m=Number.parseFloat(t.pl),h=Number.parseFloat(t.pw),p=_/2+.5,x=d*2+h,f=p+m/2,g=_/2+.25,y=f+.25,b=x/2+.2,v=b+.2,S={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",layer:"top",outline:l2([{minX:-y,maxX:y,minY:-b,maxY:b},{minX:-g,maxX:g,minY:-v,maxY:v}])};return[...e,s,r,i,u,S]},z3n=[{x:-1.703,y:.98},{x:-.983,y:.98},{x:-.983,y:1.1},{x:.477,y:1.1},{x:.477,y:.98},{x:1.197,y:.98},{x:1.197,y:-.98},{x:.477,y:-.98},{x:.477,y:-1.1},{x:-.983,y:-1.1},{x:-.983,y:-.98},{x:-1.703,y:-.98}],V3n=Ro.extend({fn:O(),num_pins:Xe().default(4),w:O().default("3.2mm"),h:O().default("2.6mm"),pl:O().default("1.05mm"),pw:O().default("0.45mm"),p:O().default("0.55mm"),string:O().optional()}),$3n=t=>{const e=t.string?.match(/^sot343_(\d+)/),n=e?Number.parseInt(e[1],4):4,o=V3n.parse({...t,num_pins:n});if(o.num_pins===4)return{circuitJson:U3n(o),parameters:o};throw new Error("Invalid number of pins")},W3n=t=>{const{pn:e,p:n}=t;return e===1?{x:-n*1.92,y:-.65}:e===2?{x:-n*1.92,y:.65}:e===3?{x:n,y:.65}:e===4?{x:n,y:-.65}:{x:0,y:0}},U3n=t=>{const e=[],n=Number.parseFloat(t.w),o=Number.parseFloat(t.h),r=Number.parseFloat(t.pl),i=Number.parseFloat(t.pw),s=Number.parseFloat(t.p);let a=1/0,c=-1/0,l=1/0,u=-1/0;for(let b=0;b<t.num_pins;b++){const{x:v,y:S}=W3n({num_pins:t.num_pins,pn:b+1,p:s});e.push(lo(b+1,v,S,r,i)),v<a&&(a=v),v>c&&(c=v),S<l&&(l=S),S>u&&(u=S)}const _=(a+c)/2,d=u-l,m=o*.3,h=d/2+m;let p=n*.8;o<=2.6&&(p/=2);const x=Ho(_,h+.5,.3),f={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:_-p/2,y:h},{x:_+p/2,y:h}],type:"pcb_silkscreen_path",stroke_width:.1},g={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_bottom",route:[{x:_-p/2,y:-h},{x:_+p/2,y:-h}],type:"pcb_silkscreen_path",stroke_width:.1},y={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:z3n,layer:"top"};return[...e,f,g,x,y]},X3n=Ro.extend({fn:O()}),j3n=t=>{const e=X3n.parse(t),n=[],o=.5-.15,r=1.5,s=.5/2,a=75,c=-37/2;for(let M=0;M<a;M++){const w=M+1;if(w>=24&&w<=31)continue;const A=c-M*s,D=w%2===0,I=r+(D?.25:0),B=.5-I/2,z=lo(w,B,A,I,o);z.layer=D?"bottom":"top",n.push(z)}const l=46*.0254,u=137*.0254,_=261*.0254,d={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-u/2+r/2,y:c-_},width:u,height:l},m={x:-.5,y:c},h={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"};let p=1/0,x=-1/0,f=1/0,g=-1/0;const y=(M,w,A=0,D=0)=>{p=Math.min(p,M-A/2),x=Math.max(x,M+A/2),f=Math.min(f,w-D/2),g=Math.max(g,w+D/2)};for(const M of n){const w=M;y(w.x,w.y,w.width,w.height)}y(d.center.x,d.center.y,d.width,d.height);for(const M of h.route)y(M.x,M.y);const b=(p+x)/2,v=(f+g)/2,S=M=>{typeof M.x=="number"&&(M.x-=b),typeof M.y=="number"&&(M.y-=v),M.center&&(M.center.x-=b,M.center.y-=v),Array.isArray(M.route)&&(M.route=M.route.map(w=>({x:w.x-b,y:w.y-v})))};for(const M of n)S(M);return S(d),S(h),{circuitJson:[...n,d,h],parameters:e}},G3n=Ro.extend({fn:O(),numPins:Xe().optional().default(0),rows:Nn([O(),Xe()]).transform(t=>Number(t)).optional().default(1).describe("number of rows"),p:_e.default("2.54mm").describe("pitch"),id:_e.default("1.0mm").describe("inner diameter"),od:_e.default("1.5mm").describe("outer diameter"),male:Be().optional().describe("the module uses male headers"),nopin:Be().optional().default(!1).describe("omit pins rendering"),female:Be().optional().describe("the module uses female headers"),smd:Be().optional().describe("surface mount device"),pinlabeltextalignleft:Be().optional().default(!1),pinlabeltextaligncenter:Be().optional().default(!1),pinlabeltextalignright:Be().optional().default(!1),pinlabelverticallyinverted:Be().optional().default(!1),pinlabelorthogonal:Be().optional().default(!1),nopinlabels:Be().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:Be().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:Be().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top"),pinRowSide:Kt(["left","right","top","bottom"]).optional().default("left"),pinrowleft:Be().optional().default(!1),pinrowright:Be().optional().default(!1),pinrowtop:Be().optional().default(!1),pinrowbottom:Be().optional().default(!1),pinrowleftpins:Nn([O(),Xe()]).transform(t=>Number(t)).optional(),pinrowrightpins:Nn([O(),Xe()]).transform(t=>Number(t)).optional(),pinrowtoppins:Nn([O(),Xe()]).transform(t=>Number(t)).optional(),pinrowbottompins:Nn([O(),Xe()]).transform(t=>Number(t)).optional(),width:_e.optional(),height:_e.optional(),pinRowHoleEdgeToEdgeDist:_e.default("2mm"),holes:Nn([O(),Pt(O())]).optional().transform(t=>!t||Array.isArray(t)?t:t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1).split(",").map(e=>e.trim()):[t]),holeXDist:_e.optional(),holeYDist:_e.optional(),holeInset:_e.default("1mm"),pinrow:Nn([O(),Xe()]).optional(),usbposition:Kt(["left","right","top","bottom"]).optional().default("left"),usbleft:Be().optional().default(!1),usbtop:Be().optional().default(!1),usbright:Be().optional().default(!1),usbbottom:Be().optional().default(!1),usbtype:Kt(["micro","c"]).optional(),usbmicro:Be().optional().default(!1),usbc:Be().optional().default(!1),screen:Be().optional().default(!1).describe("add silkscreen outline for screen/display area"),screenwidth:_e.optional(),screenheight:_e.optional(),screencenteroffsetx:_e.optional(),screencenteroffsety:_e.optional()}).transform(t=>{const e=QKe(t);let n=t.pinRowSide;t.pinrowleft&&(n="left"),t.pinrowright&&(n="right"),t.pinrowtop&&(n="top"),t.pinrowbottom&&(n="bottom");let o=t.usbposition;t.usbleft&&(o="left"),t.usbtop&&(o="top"),t.usbright&&(o="right"),t.usbbottom&&(o="bottom");let r=t.usbtype;t.usbmicro&&(r="micro"),t.usbc&&(r="c"),t.pinrow!==void 0&&(t.numPins=Number(t.pinrow));const i={left:t.pinrowleftpins,right:t.pinrowrightpins,top:t.pinrowtoppins,bottom:t.pinrowbottompins},s=Object.values(i).some(b=>b!==void 0&&b>0),a=(i.left??0)>0&&(i.right??0)>0,c=(i.top??0)>0&&(i.bottom??0)>0;s&&((i.left??0)>0?n="left":(i.right??0)>0?n="right":(i.top??0)>0?n="top":(i.bottom??0)>0&&(n="bottom"),t.numPins=(i.left??0)+(i.right??0)+(i.top??0)+(i.bottom??0));const l=Math.ceil(t.numPins/t.rows),u=Math.max(i.left??0,i.right??0),_=Math.max(i.top??0,i.bottom??0);let d,m;if(s){const b=a?t.p:0,v=c?t.p:0;d=(_>0?(_-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+b,m=(u>0?(u-1)*t.p:0)+2*t.pinRowHoleEdgeToEdgeDist+v}else n==="left"||n==="right"?(d=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,m=(l-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist):(m=(t.rows-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist,d=(l-1)*t.p+2*t.pinRowHoleEdgeToEdgeDist);t.numPins===0&&(d=10,m=10);const h=t.width??d,p=t.height??m,x=t.screenwidth??h*.95,f=t.screenheight??p*.95,g=t.screencenteroffsetx??0,y=t.screencenteroffsety??0;return{...t,pinlabelAnchorSide:e,pinRowSide:n,usbposition:o,usbtype:r,male:t.male??!t.female,female:t.female??!1,width:h,height:p,screenwidth:x,screenheight:f,screencenteroffsetx:g,screencenteroffsety:y,pinrowleftpins:i.left,pinrowrightpins:i.right,pinrowtoppins:i.top,pinrowbottompins:i.bottom}}).superRefine((t,e)=>{t.male&&t.female&&e.addIssue({code:Jn.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),Y3n=t=>{const e=G3n.parse(t),{p:n,id:o,od:r,rows:i,numPins:s,pinlabelAnchorSide:a,pinlabelverticallyinverted:c,pinlabelorthogonal:l,pinlabeltextalignleft:u,pinlabeltextalignright:_,nopinlabels:d,doublesidedpinlabel:m,bottomsidepinlabel:h,pinRowSide:p,width:x,height:f,pinRowHoleEdgeToEdgeDist:g,holes:y,holeXDist:b,holeYDist:v,holeInset:S,pinrowleftpins:M,pinrowrightpins:w,pinrowtoppins:A,pinrowbottompins:D,usbposition:I,usbtype:H,screen:B,screenwidth:z,screenheight:V,screencenteroffsetx:j,screencenteroffsety:q}=e;let J="center";u?J="left":_&&(J="right");const ne=[],ae={left:M,right:w,top:A,bottom:D},Z=Object.values(ae).some(le=>le!==void 0&&le>0),oe=(le,pe,Se,we)=>{if(e.smd?ne.push(lo(le,pe,Se,e.od,e.od)):le===1?ne.push(_5({pn:le,x:pe,y:Se,holeDiameter:o,rectPadWidth:r,rectPadHeight:r})):ne.push(vi(le,pe,Se,o,r)),!d){const De=pe+(we==="left"?-r:we==="right"?r:0),ge=Se+(we==="top"?r:we==="bottom"?-r:0);h||ne.push(rS({fs:r/5,pn:le,anchor_x:De,anchor_y:ge,textalign:J,orthogonal:l,verticallyinverted:c,layer:"top"})),(m||h)&&ne.push(rS({fs:r/5,pn:le,anchor_x:De,anchor_y:ge,textalign:J,orthogonal:l,verticallyinverted:c,layer:"bottom"}))}};if(Z){const le=n;let pe=1;const Se=ae.left??0,we=ae.right??0,De=ae.top??0,ge=ae.bottom??0,Me=(fe,We)=>{if(!(We<=0))if(fe==="left"||fe==="right"){const je=fe==="left"?-x/2+g:x/2-g,Ke=(We-1)/2*le;for(let me=0;me<We;me++)oe(pe,je,Ke-me*le,fe),pe++}else{const je=fe==="top"?f/2-g:-f/2+g,Ke=-((We-1)/2)*le;for(let me=0;me<We;me++)oe(pe,Ke+me*le,je,fe),pe++}};Me("left",Se),Me("right",we),Me("top",De),Me("bottom",ge)}else{const le=n;let pe=0,Se=0,we=0,De=0,ge=0,Me=0;const fe=Math.ceil(s/i);p==="left"||p==="right"?(pe=p==="left"?-x/2+g:x/2-g,Se=(fe-1)/2*le,we=0,De=-le,ge=p==="left"?le:-le,Me=0):(pe=-(fe-1)/2*le,Se=p==="top"?f/2-g:-f/2+g,we=le,De=0,ge=0,Me=p==="top"?-le:le);let We=1;for(let je=0;je<i&&We<=s;je++)for(let Ke=0;Ke<fe&&We<=s;Ke++){const me=pe+Ke*we+je*ge,qe=Se+Ke*De+je*Me;if(e.smd?ne.push(lo(We,me,qe,e.od,e.od)):We===1?ne.push(_5({pn:We,x:me,y:qe,holeDiameter:o,rectPadWidth:r,rectPadHeight:r})):ne.push(vi(We,me,qe,o,r)),!d){const Fe=me+(p==="left"?-r:p==="right"?r:0),Ne=qe+(p==="top"?r:p==="bottom"?-r:0);h||ne.push(rS({fs:r/5,pn:We,anchor_x:Fe,anchor_y:Ne,textalign:J,orthogonal:l,verticallyinverted:c,layer:"top"})),(m||h)&&ne.push(rS({fs:r/5,pn:We,anchor_x:Fe,anchor_y:Ne,textalign:J,orthogonal:l,verticallyinverted:c,layer:"bottom"}))}We++}}if(y)for(const le of y){let pe=0,Se=0;le==="topleft"?(pe=-x/2+S,Se=f/2-S):le==="topright"?(pe=x/2-S,Se=f/2-S):le==="bottomleft"?(pe=-x/2+S,Se=-f/2+S):le==="bottomright"?(pe=x/2-S,Se=-f/2+S):le==="center"&&(pe=0,Se=0),b!==void 0&&(pe+=b),v!==void 0&&(Se+=v),ne.push(vi(s+y.indexOf(le)+1,pe,Se,o,r))}if(!e.nosilkscreen){const le=[{x:-x/2,y:-f/2},{x:x/2,y:-f/2},{x:x/2,y:f/2},{x:-x/2,y:f/2},{x:-x/2,y:-f/2}];ne.push(iS(le,{stroke_width:.1,layer:"top"}))}const se=Ho(0,f/2+1,.5);if(ne.push(se),I&&H){let le,pe;if(H==="c")le=8,pe=3;else if(H==="micro")le=6,pe=2;else return{circuitJson:ne,parameters:e};let Se;if(I==="left")Se=[{x:-x/2,y:-le/2},{x:-x/2+pe,y:-le/2},{x:-x/2+pe,y:le/2},{x:-x/2,y:le/2},{x:-x/2,y:-le/2}];else if(I==="right")Se=[{x:x/2-pe,y:-le/2},{x:x/2,y:-le/2},{x:x/2,y:le/2},{x:x/2-pe,y:le/2},{x:x/2-pe,y:-le/2}];else if(I==="top")Se=[{x:-le/2,y:f/2-pe},{x:le/2,y:f/2-pe},{x:le/2,y:f/2},{x:-le/2,y:f/2},{x:-le/2,y:f/2-pe}];else if(I==="bottom")Se=[{x:-le/2,y:-f/2},{x:le/2,y:-f/2},{x:le/2,y:-f/2+pe},{x:-le/2,y:-f/2+pe},{x:-le/2,y:-f/2}];else return{circuitJson:ne,parameters:e};ne.push(iS(Se,{stroke_width:.1,layer:"top"}))}if(B){const le=z/2,pe=V/2,Se=j,we=q,De=[{x:-le+Se,y:-pe+we},{x:le+Se,y:-pe+we},{x:le+Se,y:pe+we},{x:-le+Se,y:pe+we},{x:-le+Se,y:-pe+we}];ne.push(iS(De,{stroke_width:.05,layer:"top"}))}return{circuitJson:ne,parameters:e}},q3n=[{x:-1.45,y:2.75},{x:-1.45,y:-1.85},{x:4.05,y:-1.85},{x:4.05,y:2.75}],J3n=[{x:-1.55,y:2.75},{x:-1.55,y:-1.85},{x:3.95,y:-1.85},{x:3.95,y:2.75}],K3n=Ro.extend({fn:O(),num_pins:Xe().default(3),inline:Be().default(!1),p:O().default("1.27mm"),id:O().default("0.75mm"),od:O().default("1.3mm"),w:O().default("4.8mm"),h:O().default("4.0mm")}),Q3n=t=>{const e=K3n.parse(t),n=Number.parseFloat(e.p),o=Number.parseFloat(e.w),r=Number.parseFloat(e.h),i=e.inline?1.05:Number.parseFloat(e.od),s=e.inline?1.5:i,a=[_5({pn:1,x:0,y:0,holeDiameter:e.id,rectPadWidth:i,rectPadHeight:s}),e.inline?sS(2,n,0,Number.parseFloat(e.id),i,s):vi(2,n,n,e.id,i),e.inline?sS(3,n*2,0,Number.parseFloat(e.id),i,s):vi(3,n*2,0,e.id,i)],c=o/2,l=e.inline?n-.09:n,u=.2,_=u+c-r,d=Array.from({length:32},(x,f)=>{const g=Math.PI*f/31;return{x:l+c*Math.cos(g),y:u+c*Math.sin(g)}}),m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",stroke_width:.12,route:[...d,{x:l-c,y:_},{x:l+c,y:_},d[0]]},h=Ho(l,u+c+1,.5),p={type:"pcb_courtyard_outline",pcb_courtyard_outline_id:"",pcb_component_id:"",outline:e.inline?J3n:q3n,layer:"top"};return{circuitJson:[...a,m,h,p],parameters:e}},Z3n=(t,e)=>{const n=t.filter(o=>o.type==="pcb_silkscreen_text");if(n.length===0)return t;for(const o of n)e.norefdes&&(o.text="");return t},e9n=(t,e)=>e.nosilkscreen?t.filter(n=>n.type!=="pcb_silkscreen_path"&&n.type!=="pcb_silkscreen_text"):t,t9n=(t,e)=>{if(!e)return t;const n=t.filter(u=>u.type==="pcb_smtpad"||u.type==="pcb_plated_hole");if(n.length===0)return t;let o=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;const a=(u,_,d=0,m=0)=>{const h=u-d/2,p=u+d/2,x=_-m/2,f=_+m/2;o=Math.min(o,h),r=Math.max(r,p),i=Math.min(i,x),s=Math.max(s,f)};for(const u of n)if(u.type==="pcb_smtpad"){const _=u.shape==="circle"?u.radius*2:u.width,d=u.shape==="circle"?u.radius*2:u.height;a(u.x,u.y,_,d)}else if(u.type==="pcb_plated_hole"){const _=u.outer_diameter??u.hole_diameter;a(u.x,u.y,_,_)}let c=0,l=0;switch(e){case"center":c=(o+r)/2,l=(i+s)/2;break;case"bottomleft":c=o,l=i;break;case"bottomcenter":case"centerbottom":c=(o+r)/2,l=i;break;case"topcenter":case"centertop":c=(o+r)/2,l=s;break;case"leftcenter":case"centerleft":c=o,l=(i+s)/2;break;case"rightcenter":case"centerright":c=r,l=(i+s)/2;break;case"pin1":{const u=n.find(_=>_.port_hints?.[0]==="1")||n[0];c=u.x,l=u.y;break}}if(c===0&&l===0)return t;for(const u of t){if(typeof u.x=="number"&&(u.x-=c),typeof u.y=="number"&&(u.y-=l),u.center&&typeof u.center.x=="number"&&(u.center.x-=c,u.center.y-=l),u.type==="pcb_silkscreen_path")for(const _ of u.route)_.x-=c,_.y-=l;u.type==="pcb_silkscreen_text"&&u.anchor_position&&(u.anchor_position.x-=c,u.anchor_position.y-=l)}return t};function n9n(t){return t!=null}var o9n=t=>t.trim().replace(/^sot23-(\d+)(?=_|$)/i,"sot23_$1").replace(/^sot-223-(\d+)(?=_|$)/i,"sot223_$1").replace(/^to-220f-(\d+)(?=_|$)/i,"to220f_$1").replace(/^jst_(ph|sh|zh)_(\d+)(?=_|$)/i,"jst$2_$1"),r9n=t=>{let e=qU();const n=o9n(t),r=n.replace(/^((?:\d{4}|\d{5}))(?=$|_|x)/,"res$1").replace(/^zh(\d+)(?:$|_)/,"jst$1_zh").split(/_(?!metric)/).map(i=>{const s=i.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(n9n);for(const{fn:i,v:s}of r)e=e[i](s);return e.setString(n),e},i9n=()=>Object.keys(D9),qU=()=>{const t=new Proxy({},{get:(e,n)=>{if(n==="soup"||n==="circuitJson"){if("fn"in e&&D9[e.fn])return()=>{const{circuitJson:o}=D9[e.fn](e),r=e9n(o,e),i=Z3n(r,e);return t9n(i,e.origin)};if(!D9[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>{throw new Error(`No function found for footprinter, make sure to specify .dip, .lr, .p, etc. Got "${n}"`)}}if(n==="json"){if(!D9[e.fn])throw new Error(`Invalid footprint function, got "${e.fn}"${e.string?`, from string "${e.string}"`:""}`);return()=>D9[e.fn](e).parameters}return n==="getFootprintNames"?()=>Object.keys(D9):n==="params"?()=>e:n==="setString"?o=>(e.string=o,t):o=>(Object.keys(e).length===0?`${n}${o}`in D9?(e[`${n}${o}`]=!0,e.fn=`${n}${o}`):(e[n]=!0,e.fn=n,n==="res"||n==="cap"?o&&(typeof o=="string"&&o.includes("_metric")?e.metric=o.split("_metric")[0]:e.imperial=o):e.num_pins=Number.isNaN(Number.parseFloat(o))?void 0:Number.parseFloat(o)):!o&&["w","h","p"].includes(n)||(e[n]=o??!0),t)}});return t};qU.string=r9n,qU.getFootprintNames=i9n;var s9n=qU,dQe=Symbol("Fragment");function Kpe(t,e,...n){const o=n.length?n:e?.children!==void 0?[e.children]:[],r=[],i=(Array.isArray(o)?o:[o]).flat(1/0);for(const s of i)s==null||s===!1||(Array.isArray(s)?r.push(...s):r.push(s));return{type:t,props:(e&&e.children!==void 0?{...e,children:void 0}:e)||{},children:r}}var hn=Symbol("Cuboid"),hQe=Symbol("Cube"),l_=Symbol("Cylinder"),JU=Symbol("Sphere"),Kk=Symbol("RoundedCuboid"),Uo=Symbol("Translate"),Sd=Symbol("Rotate"),cm=Symbol("Union"),d5=Symbol("Subtract"),ql=Symbol("Hull"),mi=Symbol("Colorize"),Qk=Symbol("Polygon"),Zk=Symbol("ExtrudeLinear"),Ax=Symbol("RoundedCylinder"),Nr=dQe,Ge=(t,e,n)=>Kpe(t,e),Un=(t,e,n)=>Kpe(t,e),F_=({center:t,width:e,length:n,height:o,heightAboveSurface:r=.15,color:i="#555",taperRatio:s=.12,faceRatio:a=.75,straightHeightRatio:c=.5,includeNotch:l=!0,notchRadius:u,notchPosition:_,notchRotation:d=[0,0,0],notchLength:m=.5,notchWidth:h=.25,chamferSize:p=0})=>{const x=o*c,f=o-x,g=Math.min(e,n)*s,y=Math.max(e-g,e*a),b=Math.max(n-g,n*a),v=Math.min(e,n)*.12,S=u??v,M={x:0,y:n/2-S*.25,z:o},w=_??M,A=Un(cm,{children:[Un(ql,{children:[Ge(Uo,{z:.005,children:Ge(hn,{size:[y,b,.01]})}),Ge(Uo,{z:x,children:Ge(hn,{size:[e,n,.01]})})]}),Un(ql,{children:[Ge(Uo,{z:x,children:Ge(hn,{size:[e,n,.01]})}),Ge(Uo,{z:x+f,children:Ge(hn,{size:[y,b,.01]})})]})]}),D=(H,B)=>Ge(Uo,{offset:{x:H,y:B,z:0},children:Ge(Sd,{rotation:[0,0,Math.PI/4],children:Ge(hn,{size:[p*Math.SQRT2,p*Math.SQRT2,o*3]})})});let I=A;if(p>0){const H=e/2,B=n/2;I=Un(d5,{children:[A,D(H,B),D(-H,B),D(H,-B),D(-H,-B)]})}return Ge(mi,{color:i,children:Ge(Uo,{offset:t,children:Ge(Uo,{offset:{x:0,y:0,z:r},children:l?Un(d5,{children:[I,Ge(Uo,{offset:w,children:Ge(Sd,{rotation:d,children:Ge(l_,{radius:S,height:h})})})]}):I})})})},a9n=t=>Array.from({length:t},(e,n)=>n);function Qpe(t,e){if(t.length<2)throw new Error("Stroke must have at least two points");const n=Array.isArray(t[0])?t.map(([u,_])=>({x:u,y:_})):t,o=e/2,r=[],i=[];function s(u,_){const d=_.x-u.x,m=_.y-u.y,h=Math.sqrt(d*d+m*m);return{x:-m/h,y:d/h}}function a(u,_,d){const m={x:u.x+_.x*o*d,y:u.y+_.y*o*d};d>0?r.push(m):i.unshift(m)}const c=s(n[0],n[1]);a(n[0],c,1),a(n[0],c,-1);for(let u=1;u<n.length-1;u++){const _=n[u-1],d=n[u],m=n[u+1],h=s(_,d),p=s(d,m),x=h.x+p.x,f=h.y+p.y,g=Math.sqrt(x*x+f*f);if(g/2>2*o)a(d,h,1),a(d,p,1),a(d,h,-1),a(d,p,-1);else{const b=1/g;a(d,{x:x*b,y:f*b},1),a(d,{x:x*b,y:f*b},-1)}}const l=s(n[n.length-2],n[n.length-1]);return a(n[n.length-1],l,1),a(n[n.length-1],l,-1),[...r,...i]}var c9n=t=>{const e=Math.min(...t.map(a=>a.x)),n=Math.max(...t.map(a=>a.x)),o=Math.min(...t.map(a=>a.y)),s=5.47/(Math.max(...t.map(a=>a.y))-o);return t.map(a=>({x:(a.x-e-(n-e)/2)*s,y:(a.y-o)*s}))},l9n=c9n([{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}]),mQe=5.47,KU=.5,u9n=({x:t,y:e,z:n})=>{const o=t>0;return Un(Nr,{children:[Ge(Uo,{offset:{x:t+.25/2,y:e,z:n},children:Ge(Sd,{rotation:["-90deg",0,"90deg"],children:Ge(Zk,{height:.25,children:Ge(Qk,{points:l9n.slice().reverse().map(r=>[r.x,r.y])})})})}),Ge(Uo,{offset:{x:t,y:e+(o?1:-1),z:n},children:Ge(Sd,{rotation:["-90deg","90deg",o?"180deg":"0deg"],children:Ge(Zk,{height:2,children:Ge(Qk,{points:Qpe([[0,0],[-1,0],[-1,-1]],.25).map(r=>[r.x,r.y])})})})})]})},_9n=({numPins:t=8,pitch:e=2.54,bodyWidth:n=6.4,rowSpacing:o})=>{const r=Math.floor(t/2),i=o??(n>=7?n:n+1.22),s=n>=7?i-1.22:n;return Un(Nr,{children:[a9n(t).map(a=>{const c=a%r,l=(Math.floor(a/r)-.5)*2;return Ge(u9n,{x:l*i/2,y:c*e-(r-1)/2*e,z:mQe/2+KU})}),Ge(F_,{width:s,length:r*e+.5,height:mQe-KU,heightAboveSurface:KU,center:{x:0,y:0,z:KU}})]})};function d9n(t,{height:e,padContactLength:n,curveLength:o,bodyDistance:r,steepness:i=10}){o||(o=r*.3);let s=r-n-o;s<0&&(o+=s,s=0);const a=n*.75,c=n+o+(r-n-o)*.25;if(t<=a)return 0;if(t>=c)return e;const l=(t-a)/(c-a);return e/(1+Math.exp(-i*(l-.5)))}var qr=t=>{const{thickness:e,width:n,padContactLength:o,bodyDistance:r,height:i,rotation:s}=t,a=15,c=Array.from({length:a}).map((u,_)=>_/(a-1)*r).map(u=>[u,d9n(u,t)]),l=Qpe(c,e);return Ge(mi,{color:"#fff",children:Ge(Uo,{offset:{z:0,y:0,x:0,...t.position},children:Ge(Sd,{rotation:["90deg",0,s??0],children:Ge(Uo,{offset:{x:0,y:0,z:-n/2},children:Ge(Zk,{height:n,children:Ge(Qk,{points:l.map(u=>[u.x,u.y])})})})})})})},h9n=({pinCount:t,leadLength:e,leadWidth:n,pitch:o,bodyWidth:r})=>{const i=Math.ceil(t/2),s=o*t/2+n/2,a=(i-1)*o/2,c=.25;return Un(Nr,{children:[Array.from({length:i}).map((l,u)=>Ge(qr,{position:{x:-r/2-e,y:u*o-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Array.from({length:i}).map((l,u)=>Ge(qr,{rotation:Math.PI,position:{x:r/2+e,y:u*o-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+1,height:.8})),Ge(F_,{center:{x:0,y:0,z:c/2},width:r-n-1,length:s,height:1.5})]})},m9n=({pinCount:t,padContactLength:e=.4,leadWidth:n=.2,pitch:o=.65,bodyWidth:r=3})=>{const i=Math.ceil(t/2),s=(i-1)*o/2,a=.2;return Un(Nr,{children:[Array.from({length:i}).map((c,l)=>Ge(qr,{position:{x:-r/2-e-.3,y:l*o-s,z:a/2},width:n,thickness:a,padContactLength:e,bodyDistance:e+.4,height:.6})),Array.from({length:i}).map((c,l)=>Ge(qr,{rotation:Math.PI,position:{x:r/2+e+.3,y:l*o-s,z:a/2},width:n,thickness:a,padContactLength:e,bodyDistance:e+.4,height:.6})),Ge(F_,{center:{x:0,y:0,z:a/2},width:r,length:r,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},Zpe=1,efe=.5,Lw=.5,eN=.2,p9n=Zpe-eN*2,pQe=({color:t="#333"})=>Un(Nr,{children:[Ge(hn,{size:[p9n,efe,Lw],offset:[0,0,Lw/2],color:t}),Ge(hn,{size:[eN,Lw,efe],offset:[Zpe/2-eN/2,0,Lw/2],color:"#ccc"}),Ge(hn,{size:[eN,Lw,efe],offset:[-Zpe/2+eN/2,0,Lw/2],color:"#ccc"})]}),tfe=1.6,f9n=tfe-.3*2,QU=.3,nfe=.85,Ow=.6,fQe=({color:t="#333"})=>Un(Nr,{children:[Ge(hn,{size:[f9n,nfe,Ow],offset:[0,0,Ow/2],color:t}),Ge(hn,{size:[QU,nfe,Ow],offset:[tfe/2-QU/2,0,Ow/2],color:"#ccc"}),Ge(hn,{size:[QU,nfe,Ow],offset:[-tfe/2+QU/2,0,Ow/2],color:"#ccc"})]}),ofe=2,rfe=1.25,Fw=.55,tN=.5,x9n=ofe-tN*2,xQe=({color:t="#333"})=>Un(Nr,{children:[Ge(hn,{size:[x9n,rfe,Fw],offset:[0,0,Fw/2],color:t}),Ge(hn,{size:[tN,rfe,Fw],offset:[ofe/2-tN/2,0,Fw/2],color:"#ccc"}),Ge(hn,{size:[tN,rfe,Fw],offset:[-ofe/2+tN/2,0,Fw/2],color:"#ccc"})]}),g9n=({pinCount:t,pitch:e,leadWidth:n,padContactLength:o,bodyWidth:r})=>{const i=t/4;e||(e=y9n(t,r)),o||(o=b9n(t)),n||(n=P9n(t,r)),r||(r=e*(i+4));const s=r,a=(i-1)*e/2,c=s+2*o,l=c,u=.8,_=.15,d=(l-r)/2+.5;return Un(Nr,{children:[Array.from({length:i}).map((m,h)=>Ge(qr,{position:{x:-l/2-.4,y:h*e-a,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Array.from({length:i}).map((m,h)=>Ge(qr,{rotation:Math.PI,position:{x:l/2+.4,y:h*e-a,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Array.from({length:i}).map((m,h)=>Ge(qr,{rotation:Math.PI/2,position:{x:h*e-a,y:-c/2-.4,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Array.from({length:i}).map((m,h)=>Ge(qr,{rotation:-Math.PI/2,position:{x:h*e-a,y:c/2+.4,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Ge(F_,{center:{x:0,y:0,z:0},width:r,length:s,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:r/2-1.5,z:1.5},notchRadius:1.5/2})]})},y9n=(t,e)=>{switch(t){case 44:case 64:return .8;case 52:return e===14?1:.65;case 208:return .5;default:return .5}},b9n=t=>{switch(t){case 32:return .6;case 40:return .6;case 52:case 64:return .65;case 208:return 1.65;default:return .6}},P9n=(t,e)=>{switch(t){case 44:case 64:return .5;case 52:return e===14?.45:.55;case 208:return .3;default:return .25}},gQe=({x:t,y:e,pinThickness:n,shortSidePinLength:o,longSidePinLength:r,bodyHeight:i,bodyLength:s=2.54,bodyWidth:a=2.54,flipZ:c,faceup:l,smd:u,rightangle:_})=>Un(Nr,{children:[Ge(Uo,{y:_?-3:0,children:Ge(hn,{color:"#222",size:[s,a,i],center:[t,e,c(i/2)]})}),!l&&Ge(mi,{color:"gold",children:u?Ge(qr,{rotation:-Math.PI/2,position:{x:t,y:e+1,z:n/2},thickness:n,width:n,height:n,padContactLength:2,bodyDistance:3}):Un(ql,{children:[Ge(hn,{color:"gold",size:[n,n,o*.9],center:[t,e,c(i*.9+i/2)]}),Ge(hn,{color:"gold",size:[n/1.8,n/1.8,o],center:[t,e,c(i+i/2)]})]})}),Ge(mi,{color:"gold",children:Ge(Uo,{y:_?-3.9:0,z:_?1:0,children:Ge(Sd,{rotation:_?[-Math.PI/2,0,0]:[0,0,0],children:Un(ql,{children:[Ge(hn,{color:"gold",size:[n,n,r*.9],center:[t,e,c(-r/2*.9)]}),Ge(hn,{color:"gold",size:[n/1.8,n/1.8,r],center:[t,e,c(-r/2)]})]})})})})]}),v9n=({numberOfPins:t,pitch:e=2.54,longSidePinLength:n=6,invert:o,faceup:r,rows:i=1,smd:s,rightangle:a})=>{const u=Math.ceil(t/i),_=2.54,d=3,m=-((u-1)/2)*e,h=!s&&!a?-2-1.6:0,p=x=>(o||r?-x+2:x)+h;return Ge(Nr,{children:Array.from({length:t},(x,f)=>{const g=Math.floor(f/u),y=f%u,b=m+y*e,v=-g*_;return Ge(gQe,{x:b,y:v,pinThickness:.63,shortSidePinLength:d,longSidePinLength:n,bodyHeight:2,flipZ:p,faceup:r,smd:s,rightangle:a},f)})})},S9n=t=>{const e=["left","bottom","right","top"],{pin_count:n,pn:o,w:r,h:i,p:s,pl:a}=t,c=n/4,l=e[Math.floor((o-1)/c)],u=(o-1)%c,_=s*(c-1),d=s*(c-1),m=-a/2;switch(l){case"left":return{x:-r/2-m,y:d/2-u*s,o:"vert"};case"bottom":return{x:-_/2+u*s,y:-i/2-m,o:"horz"};case"right":return{x:r/2+m,y:-d/2+u*s,o:"vert"};case"top":return{x:_/2-u*s,y:i/2+m,o:"horz"};default:throw new Error("Invalid pin number")}},C9n=({num_pins:t,cw:e,ccw:n,startingpin:o})=>{const r=[],i=t/4;let s=1;const a={};for(const c of o??[])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=i:a.bottomside&&a.leftpin?s=i+1:a.bottomside&&a.rightpin?s=i*2:a.rightside&&a.bottompin?s=i*2+1:a.rightside&&a.toppin?s=i*3:a.topside&&a.rightpin?s=i*3+1:a.topside&&a.leftpin&&(s=i*4),r.push(-1);for(let c=0;c<t;c++)r[s]=c+1,s++,s>t&&(s=1);return r},M9n=({num_pins:t=16,bodyWidth:e=9,bodyLength:n=9,bodyThickness:o=.8,thermalPadSize:r,padWidth:i=.25,padLength:s=.25,pitch:a=.5,thermalPadThickness:c=.05})=>{const l=C9n({num_pins:t,cw:!0,ccw:!0}),u=[];for(let _=0;_<t;_++){const{x:d,y:m,o:h}=S9n({pin_count:t,pn:_+1,w:e,h:n,p:a,pl:s});let p=i,x=s;h==="vert"&&([p,x]=[x,p]);const f=l[_+1];u.push({pn:f,x:d,y:m,pw:p,pl:x})}return Un(Nr,{children:[Ge(mi,{color:"grey",children:Ge(hn,{center:{x:0,y:0,z:o/2},size:[e,n,o]})}),u.map((_,d)=>Ge(hn,{center:{x:_.x,y:_.y,z:c/2},size:[_.pw,_.pl,c]})),r?.length!==void 0&&r?.width!==void 0&&Ge(hn,{center:{x:0,y:0,z:c/2},size:[r.width,r.length,c]})]})},T9n=M9n,w9n=()=>{const c=1.1999999999999997;return Un(Nr,{children:[Ge(qr,{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}),Ge(qr,{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}),Ge(qr,{position:{x:-2.8/2-c/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ge(qr,{position:{x:-2.8/2-c/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ge(qr,{position:{x:-2.8/2-c/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:c,height:.95}),Ge(F_,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},E9n=w9n,D9n=({fullWidth:t=2.9,fullLength:e=2.8})=>{const u=(t-1.92)/2+.3;return Un(Nr,{children:[Ge(qr,{rotation:Math.PI,position:{x:t/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:u,height:.45}),Ge(qr,{position:{x:-t/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:u,height:.45}),Ge(qr,{position:{x:-t/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:u,height:.45}),Ge(F_,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},ife=.6,sfe=.3,Bw=.33,nN=.1,A9n=ife-nN*2,yQe=({color:t="#333"})=>Un(Nr,{children:[Ge(hn,{size:[A9n,sfe,Bw],offset:[0,0,Bw/2],color:t}),Ge(hn,{size:[nN,sfe,Bw],offset:[ife/2-nN/2,0,Bw/2],color:"#ccc"}),Ge(hn,{size:[nN,sfe,Bw],offset:[-ife/2+nN/2,0,Bw/2],color:"#ccc"})]}),afe=.4,cfe=.2,zw=.13,oN=.07,R9n=afe-oN*2,bQe=({color:t="#333"})=>Un(Nr,{children:[Ge(hn,{size:[R9n,cfe,zw],offset:[0,0,zw/2],color:t}),Ge(hn,{size:[oN,cfe,zw],offset:[afe/2-oN/2,0,zw/2],color:"#ccc"}),Ge(hn,{size:[oN,cfe,zw],offset:[-afe/2+oN/2,0,zw/2],color:"#ccc"})]}),lfe=3.2,ufe=1.6,Vw=.9,rN=.5,k9n=lfe-rN*2,PQe=({color:t="#333"})=>Un(Nr,{children:[Ge(hn,{size:[k9n,ufe,Vw],offset:[0,0,Vw/2],color:t}),Ge(hn,{size:[rN,ufe,Vw],offset:[lfe/2-rN/2,0,Vw/2],color:"#ccc"}),Ge(hn,{size:[rN,ufe,Vw],offset:[-lfe/2+rN/2,0,Vw/2],color:"#ccc"})]}),_fe=3.2,dfe=2.5,$w=1,iN=.6,N9n=_fe-iN*2,vQe=({color:t="#333"})=>Un(Nr,{children:[Ge(hn,{size:[N9n,dfe,$w],offset:[0,0,$w/2],color:t}),Ge(hn,{size:[iN,dfe,$w],offset:[_fe/2-iN/2,0,$w/2],color:"#ccc"}),Ge(hn,{size:[iN,dfe,$w],offset:[-_fe/2+iN/2,0,$w/2],color:"#ccc"})]}),hfe=5,mfe=2.5,Ww=1.4,sN=.6,H9n=hfe-sN*2,SQe=({color:t="#333"})=>Un(Nr,{children:[Ge(hn,{size:[H9n,mfe,Ww],offset:[0,0,Ww/2],color:t}),Ge(hn,{size:[sN,mfe,Ww],offset:[hfe/2-sN/2,0,Ww/2],color:"#ccc"}),Ge(hn,{size:[sN,mfe,Ww],offset:[-hfe/2+sN/2,0,Ww/2],color:"#ccc"})]}),pfe=6.3,ffe=3.2,Uw=1.8,aN=.8,I9n=pfe-aN*2,CQe=({color:t="#333"})=>Un(Nr,{children:[Ge(hn,{size:[I9n,ffe,Uw],offset:[0,0,Uw/2],color:t}),Ge(hn,{size:[aN,ffe,Uw],offset:[pfe/2-aN/2,0,Uw/2],color:"#ccc"}),Ge(hn,{size:[aN,ffe,Uw],offset:[-pfe/2+aN/2,0,Uw/2],color:"#ccc"})]}),MQe=({x:t,y:e,z:n=0,pitch:o=2.54,legsLength:r=3,innerDiameter:i=.945,bodyHeight:s=5,bodyLength:a=o,bodyWidth:c=o,flipZ:l})=>{const u=i/1.5,_=u*1.6;return Un(Nr,{children:[Ge(mi,{color:"#1a1a1a",children:Un(d5,{children:[Ge(hn,{color:"#000",size:[a,c,s],center:[t,e,l(n+s/2)]}),i?Ge(l_,{height:s+.1,radius:i/2,center:[t,e,l(n+s/2)],color:"#222"}):Ge(hn,{size:[_,_,s],center:[t,e,l(n+s/2)]})]})}),Un(mi,{color:"silver",children:[Un(ql,{children:[Ge(hn,{color:"silver",size:[u,u,r*.9],center:[t,e,l(n+-r/2*.9)]}),Ge(hn,{color:"silver",size:[u/1.8,u/1.8,r],center:[t,e,l(n+-r/2)]})]}),Ge(hn,{color:"silver",size:[_,_,_*.5],center:[t,e,l(n+_/2*.5)]})]})]})},L9n=({numberOfPins:t,pitch:e=2.54,legsLength:n=3,innerDiameter:o=.945,rows:r=1,invert:i})=>{const a=Math.ceil(t/r),c=2.54,l=-((a-1)/2)*e,u=_=>i?-_+5:_;return Ge(Nr,{children:Array.from({length:t},(_,d)=>{const m=Math.floor(d/a),h=d%a,p=l+h*e,x=-m*c;return Ge(MQe,{x:p,y:x,pitch:e,legsLength:n,innerDiameter:o,flipZ:u},d)})})},O9n=({width:t,length:e,innerDiameter:n=1})=>{const o=t,r=e,i=t*.7,s=n/2.5;return Un(Nr,{children:[Ge(Kk,{color:"#1a1a1f",center:[0,0,i/2],size:[r,r,i],roundRadius:.3}),Ge(Kk,{color:"#f2f2f2",center:[0,0,i+i*.1/2.5],size:[r,r,i*.1],roundRadius:.14}),Ge(l_,{color:"#1a1a1f",height:i*.8,radius:o/3,center:[0,0,i+i*.8/2]}),Ge(l_,{color:"#1a1a1f",height:i*.2,radius:n/2,center:[r/3,r/3,i+i*.1/2]}),Ge(l_,{color:"#1a1a1f",height:i*.2,radius:n/2,center:[-r/3,-r/3,i+i*.1/2]}),Ge(l_,{color:"#1a1a1f",height:i*.2,radius:n/2,center:[-r/3,r/3,i+i*.1/2]}),Ge(l_,{color:"#1a1a1f",height:i*.2,radius:n/2,center:[r/3,-r/3,i+i*.1/2]}),Ge(ZU,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:i/2,position:{x:-o/2,y:-r/2,z:-i*1.2}}),Ge(ZU,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:i/2,position:{x:-o/2,y:r/2,z:-i*1.2},rotation:Math.PI}),Ge(ZU,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:i/2,position:{x:o/2,y:r/2,z:-i*1.2},rotation:Math.PI}),Ge(ZU,{thickness:n/3,width:s,horizontalLength:r*.8,verticalLength:i/2,position:{x:o/2+n/3.6,y:-r/2,z:-i*1.2}})]})},ZU=t=>{const{thickness:e,width:n,horizontalLength:o,verticalLength:r,rotation:i=0,position:s}=t,a=[[0,o],[-r/3,o/3],[-r/5,o/4],[0,0]],c=Qpe(a,e);return Ge(mi,{color:"#f2f2f2",children:Ge(Uo,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:Ge(Sd,{rotation:[0,55,i],children:Ge(Zk,{height:n,children:Ge(Qk,{points:c.map(l=>[l.y,l.x])})})})})})},F9n=({pinCount:t,leadLength:e,leadWidth:n,pitch:o,bodyWidth:r})=>{const i=Math.ceil(t/2),s=(i-1)*o/2,a=.25,c=1,l=.8,u=e*0,_=o*(i-1)+n+.2,d=r*.55;return Un(Nr,{children:[Array.from({length:i}).map((m,h)=>Ge(qr,{position:{x:-r/2-u,y:h*o-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:l})),Array.from({length:i}).map((m,h)=>Ge(qr,{rotation:Math.PI,position:{x:r/2+u,y:h*o-s,z:a/2},width:n,thickness:a,padContactLength:e/2,bodyDistance:e+.3,height:l})),Ge(F_,{center:{x:0,y:0,z:a/2},width:d,length:_,height:c})]})},B9n=({pinCount:t,pitch:e,leadWidth:n,leadLength:o,bodyWidth:r,bodyLength:i})=>{const s=t===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},a=isNaN(parseFloat(e))?s.pitch:parseFloat(e),c=isNaN(parseFloat(n))?s.leadWidth:parseFloat(n)*.8,l=isNaN(parseFloat(r))?2.6:parseFloat(r)*.8,u=isNaN(parseFloat(i))?2+Number(a)*1.4:parseFloat(i),_=t/2,d=(_-1)*a/2,m=.15,h=.8,p=4.5,x=(p-l)/2,f=x*.5;return Un(Nr,{children:[Array.from({length:_}).map((g,y)=>Ge(qr,{position:{x:-p/2,y:d-y*a,z:m/2},width:c,thickness:m,padContactLength:f+.05,bodyDistance:x+.1,height:h})),Array.from({length:_}).map((g,y)=>Ge(qr,{rotation:Math.PI,position:{x:p/2,y:d-y*a,z:m/2},width:c,thickness:m,padContactLength:f+.05,bodyDistance:x+.1,height:h})),Ge(F_,{center:{x:0,y:0,z:m/2},width:l,length:u,height:1})]})},z9n=()=>Un(Nr,{children:[Ge(hn,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),Ge(hn,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),Ge(mi,{color:"#222",children:Un(cm,{children:[Ge(Uo,{z:.3/2,children:Ge(hn,{size:[1.65,.8,.3]})}),Un(ql,{children:[Ge(Uo,{z:.3,children:Ge(hn,{size:[1.65,.8,.01]})}),Ge(Uo,{z:.6,children:Ge(hn,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),V9n=()=>Un(Nr,{children:[Ge(hn,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),Ge(hn,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),Ge(mi,{color:"#222",children:Ge(Uo,{z:.47/2+.02,children:Ge(hn,{size:[.98,.58,.47]})})}),Ge(hn,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),Ge(hn,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),Ge(hn,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),Ge(hn,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),$9n=()=>{const l=Ge(mi,{color:"#1a1a1a",children:Un(cm,{children:[Un(ql,{children:[Ge(Uo,{z:.13,children:Ge(hn,{size:[4,3,.03]})}),Ge(Uo,{z:1.15,children:Ge(hn,{size:[4.4,3.4,.01]})})]}),Un(ql,{children:[Ge(Uo,{z:1.15,children:Ge(hn,{size:[4.4,3.4,.01]})}),Ge(Uo,{z:2.3,children:Ge(hn,{size:[4,3,.01]})})]})]})}),u=({xDir:_})=>{const h=_*1.78,p=_*(3.4/2-.2/2+1),x=_*(3.4/2-.2/2),f=Math.abs(x-p),g=(p+x)/2;return Ge(mi,{color:"#c0c0c0",children:Un(cm,{children:[Ge(hn,{size:[2.3*.8,1.45,.2],center:[h,0,.2/2]}),Ge(hn,{size:[.2,1.45,1.14],center:[p,0,1.14/2+.2]}),Ge(hn,{size:[f,1.45,.2],center:[g,0,.2/2+1.14]})]})})};return Un(Nr,{children:[Ge(u,{xDir:1}),Ge(u,{xDir:-1}),l]})},W9n=()=>{const l=Ge(mi,{color:"#1a1a1a",children:Un(cm,{children:[Un(ql,{children:[Ge(Uo,{z:.13,children:Ge(hn,{size:[4,3,.03]})}),Ge(Uo,{z:1.15,children:Ge(hn,{size:[4.4,3.4,.01]})})]}),Un(ql,{children:[Ge(Uo,{z:1.15,children:Ge(hn,{size:[4.4,3.4,.01]})}),Ge(Uo,{z:2.3,children:Ge(hn,{size:[4,3,.01]})})]})]})}),u=({xDir:_})=>{const h=_*1.78,p=_*(3.4/2-.2/2+1),x=_*(3.4/2-.2/2),f=Math.abs(x-p),g=(p+x)/2;return Ge(mi,{color:"#c0c0c0",children:Un(cm,{children:[Ge(hn,{size:[2.3*.8,1.45,.2],center:[h,0,.2/2]}),Ge(hn,{size:[.2,1.45,1.14],center:[p,0,1.14/2+.2]}),Ge(hn,{size:[f,1.45,.2],center:[g,0,.2/2+1.14]})]})})};return Un(Nr,{children:[Ge(u,{xDir:1}),Ge(u,{xDir:-1}),l]})},U9n=()=>{const l=Ge(mi,{color:"#1a1a1a",children:Un(cm,{children:[Un(ql,{children:[Ge(Uo,{z:.21000000000000002,children:Ge(hn,{size:[6.3999999999999995,5.6,.03]})}),Ge(Uo,{z:1.15,children:Ge(hn,{size:[6.8,6,.01]})})]}),Un(ql,{children:[Ge(Uo,{z:1.15,children:Ge(hn,{size:[6.8,6,.01]})}),Ge(Uo,{z:2.3,children:Ge(hn,{size:[6.3999999999999995,5.6,.01]})})]})]})}),u=({xDir:_})=>{const h=_*3.08,p=_*(6/2-.2/2+1),x=_*(6/2-.2/2),f=Math.abs(x-p),g=(p+x)/2;return Ge(mi,{color:"#c0c0c0",children:Un(cm,{children:[Ge(hn,{size:[2.3*.8,2.95,.2],center:[h,0,.2/2]}),Ge(hn,{size:[.2,2.95,1.14],center:[p,0,1.14/2+.2]}),Ge(hn,{size:[f,2.95,.2],center:[g,0,.2/2+1.14]})]})})};return Un(Nr,{children:[Ge(u,{xDir:1}),Ge(u,{xDir:-1}),l]})},X9n=()=>{const _=Ge(mi,{color:"#222",children:Un(cm,{children:[Ge(Uo,{z:.27,children:Ge(hn,{size:[2.9,1.9,.54]})}),Un(ql,{children:[Ge(Uo,{z:.54,children:Ge(hn,{size:[2.9,1.9,.01]})}),Ge(Uo,{z:1.08,children:Ge(hn,{size:[2.6999999999999997,1.7,.01]})})]})]})});return Un(Nr,{children:[Ge(hn,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),Ge(hn,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),_]})},j9n=()=>Un(Nr,{children:[Ge(hn,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),Ge(hn,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),Ge(mi,{color:"#222",children:Un(cm,{children:[Ge(Uo,{z:.55/2,children:Ge(hn,{size:[2.7,1.6,.55]})}),Un(ql,{children:[Ge(Uo,{z:.55,children:Ge(hn,{size:[2.7,1.6,.01]})}),Ge(Uo,{z:1.1,children:Ge(hn,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),G9n=()=>Un(Nr,{children:[Ge(hn,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),Ge(hn,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),Ge(mi,{color:"#222",children:Un(cm,{children:[Ge(Uo,{z:.2/2,children:Ge(hn,{size:[2.75,1.8,.2]})}),Un(ql,{children:[Ge(Uo,{z:.2,children:Ge(hn,{size:[2.75,1.8,.01]})}),Ge(Uo,{z:1,children:Ge(hn,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),Ge(hn,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),Y9n=()=>Un(Nr,{children:[Ge(hn,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),Ge(hn,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),Ge(mi,{color:"#222",children:Un(cm,{children:[Un(ql,{children:[Ge(Uo,{z:.2,children:Ge(hn,{size:[2.6-.1/2,1.7-.1/2,.01]})}),Ge(Uo,{z:.01,children:Ge(hn,{size:[2.6-.1,1.7-.1,.01]})})]}),Un(ql,{children:[Ge(Uo,{z:.2,children:Ge(hn,{size:[2.6,1.7,.01]})}),Ge(Uo,{z:1,children:Ge(hn,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),Ge(hn,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),q9n=()=>Un(Nr,{children:[Ge(hn,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),Ge(hn,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),Ge(mi,{color:"#222",children:Un(cm,{children:[Un(ql,{children:[Ge(Uo,{z:.2,children:Ge(hn,{size:[3.8-.05/2,2.5-.05/2,.01]})}),Ge(Uo,{z:.01,children:Ge(hn,{size:[3.8-.05,2.5-.05,.01]})})]}),Un(ql,{children:[Ge(Uo,{z:.2,children:Ge(hn,{size:[3.8,2.5,.01]})}),Ge(Uo,{z:1,children:Ge(hn,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),Ge(hn,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),J9n=()=>Un(Nr,{children:[Ge(hn,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),Ge(hn,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),Ge(mi,{color:"#222",children:Un(cm,{children:[Ge(Uo,{z:.14/2,children:Ge(hn,{size:[.8,.6,.14]})}),Un(ql,{children:[Ge(Uo,{z:.14,children:Ge(hn,{size:[.8,.6,.01]})}),Ge(Uo,{z:.37,children:Ge(hn,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),K9n=()=>{const u=3.0999999999999996;return Un(Nr,{children:[Ge(qr,{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}),Ge(qr,{position:{x:-6.6/2-u/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Ge(qr,{position:{x:-6.6/2-u/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Ge(qr,{position:{x:-6.6/2-u/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:u,height:.75}),Ge(F_,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},Q9n=()=>Un(Nr,{children:[Array.from({length:16}).map((m,h)=>Ge(qr,{position:{x:-10.5/2,y:h*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((m,h)=>Ge(qr,{rotation:Math.PI,position:{x:10.5/2,y:h*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((m,h)=>Ge(qr,{rotation:Math.PI/2,position:{x:h*.5-3.75,y:-10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((m,h)=>Ge(qr,{rotation:-Math.PI/2,position:{x:h*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Ge(F_,{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})]}),Z9n=Q9n,ebn=()=>{const l=.7999999999999998;return Un(Nr,{children:[Ge(qr,{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}),Ge(qr,{position:{x:-2.05/2-l/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:l,height:.65}),Ge(qr,{position:{x:-2.05/2-l/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:l,height:.65}),Ge(F_,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},tbn=({pinCount:t,pitch:e,leadWidth:n,padContactLength:o,bodyWidth:r})=>{const i=t/4;if(i!==Math.floor(i))throw new Error(`LQFP pinCount must be divisible by 4, got ${t}`);e||(e=.5),o||(o=.6),n||(n=.22),r||(r=e*(i+4));const s=r,a=(i-1)*e/2,c=s+3.3*o,l=c,u=.8,_=.2,d=(l-r)/2+.4;return Un(Nr,{children:[Array.from({length:i}).map((m,h)=>Ge(qr,{position:{x:-l/2-.36,y:h*e-a,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Array.from({length:i}).map((m,h)=>Ge(qr,{rotation:Math.PI,position:{x:l/2+.36,y:h*e-a,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Array.from({length:i}).map((m,h)=>Ge(qr,{rotation:Math.PI/2,position:{x:h*e-a,y:-c/2-.36,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Array.from({length:i}).map((m,h)=>Ge(qr,{rotation:-Math.PI/2,position:{x:h*e-a,y:c/2+.36,z:_/2},width:n,thickness:_,padContactLength:o,bodyDistance:d,height:u})),Ge(F_,{center:{x:0,y:0,z:0},width:r,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})]})},nbn=()=>{const o=.20900000000000002,r=.1,i=.3,s=.1,a=.2;return Un(Nr,{children:[Ge(mi,{color:"#222",children:Un(cm,{children:[Ge(hn,{size:[.85,1.2,o],center:[0,0,o/2]}),Un(ql,{children:[Ge(Uo,{z:o,children:Ge(hn,{size:[.85,1.2,.01]})}),Ge(Uo,{z:.38,children:Ge(hn,{size:[.85-r,1.2-r,.01]})})]})]})}),Ge(hn,{color:"#ccc",size:[i,.25,s],center:[.55,0,s/2]}),Ge(hn,{color:"#ccc",size:[i,a,s],center:[-.55,.4,s/2]}),Ge(hn,{color:"#ccc",size:[i,a,s],center:[-.55,-.4,s/2]})]})},obn=({num_pins:t,bodyWidth:e=5.3,bodyLength:n=5.3,bodyThickness:o=1,thermalPadSize:r,padWidth:i=n/5.3*.6,padLength:s=n/5.3*1,pitch:a=.5,thermalPadThickness:c=.2})=>{const l=[],u=Math.floor(t/2),_=a*(u-1);for(let d=0;d<t;d++){const m=d<u?"left":"right",h=d%u,p=_/2-h*a,x=s,f=i,g=m==="left"?-e/2+x/2:e/2-x/2,y=d+1;l.push({pinNumber:y,x:g,y:p,padSizeX:x,padSizeY:f})}return Un(Nr,{children:[Ge(F_,{center:{x:0,y:0,z:0},width:e,length:n,height:o,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(e/2-s),y:n/2-s,z:o}}),l.map((d,m)=>Ge(hn,{center:[d.x,d.y,c/2],size:[d.padSizeX,d.padSizeY,c]})),r?.length!==void 0&&r?.width!==void 0&&Ge(hn,{center:[0,0,c/2],size:[r.width,r.length,c]})]})},rbn=({bodyLength:t=10.2,bodyWidth:e=4.65,bodyHeight:n=13.46,leadSpacing:o=5,leadDiameter:r=.8,leadLength:i=12.7,color:s="#ddd",leadColor:a="#b87333"})=>{const c=t/2,l=e/2,u=c-l,_=o/2,d=.85;return Un(Nr,{children:[Un(mi,{color:s,children:[Un(ql,{children:[Ge(Ax,{height:n,roundRadius:.5,radius:l,center:[-u,0,n]}),Ge(Ax,{height:n,roundRadius:.5,radius:l,center:[u,0,n]})]}),Un(ql,{children:[Ge(Ax,{height:d,roundRadius:.1,radius:l+.85,center:[-u,0,n/2+d/2]}),Ge(Ax,{height:d,roundRadius:.1,radius:l+.85,center:[u,0,n/2+d/2]})]})]}),Un(mi,{color:a,children:[Ge(l_,{height:i+n/2,radius:r/2,center:[-_+.06,0,-(i/2)+n/2]}),Ge(l_,{height:i+n/2,radius:r/2,center:[_-.06,0,-(i/2)+n/2]})]})]})},ibn=({bodyLength:t=1.4,bodyDiameter:e=1.1,color:n="#3a3a3aff",contactColor:o="#c6c6c6",cathodeIdentification:r="#111"})=>Un(Nr,{children:[Ge(mi,{color:n,children:Un(Sd,{rotation:[0,"90deg",0],children:[Ge(Kk,{size:[e,e,t-.2],roundRadius:.2,center:[-e/2,0,.05]}),Ge(l_,{height:.2/2,radius:e/2-.2,center:[-e/2,0,-t/2+.2/2]})]})}),Ge(mi,{color:r,children:Ge(Sd,{rotation:[0,"90deg",0],children:Ge(Kk,{size:[e*1.01,e*1.01,t/3],roundRadius:.2,center:[-e/2,0,-t/4+.1]})})}),Ge(mi,{color:o,children:Ge(Sd,{rotation:[0,"90deg",0],children:Ge(Ax,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,-t/2]})})}),Ge(mi,{color:o,children:Ge(Sd,{rotation:[0,"90deg",0],children:Ge(Ax,{height:.2,radius:e/2,roundRadius:.2/3,center:[-e/2,0,t/2]})})})]}),sbn=({bodyLength:t=3.5,bodyDiameter:e=1.5,color:n="#3a3a3aff",contactColor:o="#c6c6c6"})=>Un(Nr,{children:[Ge(mi,{color:n,children:Ge(Sd,{rotation:[0,"90deg",0],children:Ge(Ax,{height:t,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),Ge(mi,{color:o,children:Ge(Sd,{rotation:[0,"90deg",0],children:Ge(Ax,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,-t/2]})})}),Ge(mi,{color:o,children:Ge(Sd,{rotation:[0,"90deg",0],children:Ge(Ax,{height:.5,radius:e/2,roundRadius:.2,center:[-e/2,0,t/2]})})})]}),abn=({bodyLength:t=3.9,bodyDiameter:e=2.5,color:n="#3a3a3aff",contactColor:o="#c6c6c6"})=>Un(Nr,{children:[Ge(mi,{color:n,children:Ge(Sd,{rotation:[0,"90deg",0],children:Ge(Ax,{height:t,radius:e/2,roundRadius:.3,center:[-e/2,0,0]})})}),Ge(mi,{color:o,children:Ge(Sd,{rotation:[0,"90deg",0],children:Ge(Ax,{height:.55,radius:e/2,roundRadius:.2,center:[-e/2,0,-t/2]})})}),Ge(mi,{color:o,children:Ge(Sd,{rotation:[0,"90deg",0],children:Ge(Ax,{height:.55,radius:e/2,roundRadius:.2,center:[-e/2,0,t/2]})})})]}),cbn=({pinCount:t,padContactLength:e=.6,leadWidth:n=.41,pitch:o=1.27})=>{if(t%2!==0)throw new Error("MS012 pinCount must be even");const r=t/2,i=4.9,s=3.9,a=(r-1)*o/2,c=.2;return Un(Nr,{children:[Array.from({length:r}).map((l,u)=>Ge(qr,{position:{x:-s/2-e-.3,y:u*o-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Array.from({length:r}).map((l,u)=>Ge(qr,{rotation:Math.PI,position:{x:s/2+e+.3,y:u*o-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Ge(F_,{center:{x:0,y:0,z:c/2},width:s,length:i,height:1.55,notchPosition:{x:-.95,y:i/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},lbn=({pinCount:t=16,padContactLength:e=.6,leadWidth:n=.41,pitch:o=1.27})=>{if(t!==16)throw new Error("MS013 only supports 16 pins");const r=t/2,i=7.5,s=10.3,a=(r-1)*o/2,c=.2;return Un(Nr,{children:[Array.from({length:r}).map((l,u)=>Ge(qr,{position:{x:-i/2-e-.3,y:u*o-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Array.from({length:r}).map((l,u)=>Ge(qr,{rotation:Math.PI,position:{x:i/2+e+.3,y:u*o-a,z:c/2},width:n,thickness:c,padContactLength:e,bodyDistance:e+.4,height:.85})),Ge(F_,{center:{x:0,y:0,z:c/2},width:i,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},ubn=()=>{const p=7.050000000000001,x=24.95+6.5/2;return Ge(Uo,{center:[0,0,1],children:Un(Nr,{children:[Un(Sd,{rotation:[0,55,-55],children:[Un(d5,{children:[Ge(hn,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[x,0,1.3-2]}),Ge(l_,{color:"black",center:[x,0,1.3-2],radius:3/2,height:1.3*1.2})]}),Ge(mi,{color:"#222",children:Ge(F_,{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})})]}),Ge(Sd,{rotation:[0,55,55],children:Array.from({length:3}).map((f,g)=>{const y=p,b=(g-1)*2.7,v=-.5-.6;return Un(mi,{color:"gold",children:[Un(ql,{children:[Ge(Uo,{center:[15.05-4.5/2+.1,b,v],children:Ge(hn,{size:[4.5,.81+1,.5]})}),Ge(Uo,{center:[15.05-4.5/2-1+.1,b,v],children:Ge(hn,{size:[4.5,.81,.5]})})]}),Ge(Uo,{center:[y,b,v],children:Ge(hn,{size:[16+.1,.81,.5]})})]},`prong-${g}`)})})]})})},_bn=()=>{const l=1.1999999999999997;return Un(Nr,{children:[Ge(qr,{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}),Ge(qr,{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}),Ge(qr,{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}),Ge(qr,{position:{x:-2.8/2-l/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Ge(qr,{position:{x:-2.8/2-l/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Ge(qr,{position:{x:-2.8/2-l/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:l,height:.95}),Ge(F_,{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})]})},dbn=()=>Un(Nr,{children:[Ge(F_,{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 Ge(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 Ge(hn,{center:[.8/2-.19/2+.1,u,.12/2],size:[.19,.15,.12]})})]}),hbn=()=>{const s="#222",c=[.43,.4,1.32],l=[.43,.4,.25],u=[0,0,-.66],_=[0,0,-1.32],d=[0,1.28,-2.72],m=[0,1.28,-8.9],h=-7.5;return Un(Uo,{center:[0,1,10.5],children:[Ge(mi,{color:s,children:Un(d5,{children:[Ge(Uo,{center:[0,0,2.25],children:Ge(l_,{radius:2.4,height:4.5})}),Ge(Uo,{center:[0,-1.8499999999999999,2.25],children:Ge(hn,{size:[2.4*2,1.1,4.5+.2]})})]})}),Ge(Uo,{center:u,children:Ge(hn,{size:c})}),Un(ql,{children:[Ge(Uo,{center:_,children:Ge(hn,{size:l})}),Ge(Uo,{center:d,children:Ge(hn,{size:l})})]}),Ge(Uo,{center:m,children:Ge(hn,{size:[.43,.4,12.2]})}),Ge(Uo,{center:[1.3,0,h],children:Ge(hn,{size:[.43,.4,15]})}),Ge(Uo,{center:[-1.3,0,h],children:Ge(hn,{size:[.43,.4,15]})})]})},mbn=()=>Un(Nr,{children:[Ge(qr,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ge(qr,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ge(qr,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ge(qr,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ge(qr,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ge(qr,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),Ge(F_,{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})]}),pbn=mbn,fbn=()=>Un(Nr,{children:[Ge(F_,{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 Ge(hn,{center:[-1/2+.3/2,c,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(a=>{const c=-.5+a*.5;return Ge(hn,{center:[1/2-.3/2,c,.05/2],size:[.3,.2,.05]})})]}),xbn=()=>Un(Nr,{children:[Ge(qr,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ge(qr,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),Ge(mi,{color:"#222",children:Ge(F_,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),Ge(hn,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),gbn=()=>Un(Nr,{children:[Ge(hn,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),Ge(hn,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),Ge(mi,{color:"#222",children:Un(cm,{children:[Ge(Uo,{z:.175/2,children:Ge(hn,{size:[1.7,1.25,.175]})}),Un(ql,{children:[Ge(Uo,{z:.175,children:Ge(hn,{size:[1.7,1.25,.01]})}),Ge(Uo,{z:.725,children:Ge(hn,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),Ge(hn,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),ybn=()=>{const s=-1.0474999999999999,a=1.775/2+.4/2-.04;return Un(Nr,{children:[Ge(hn,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),Ge(hn,{color:"#ccc",size:[.4,.325,.13],center:[a,0,.13/2]}),Ge(mi,{color:"#222",children:Ge(F_,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),Ge(hn,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},bbn=({pitch:t=10})=>Un(Nr,{children:[Ge(l_,{height:4,radius:.5,center:[-t/2,0,.5]}),Ge(JU,{radius:.5,center:[-t/2,0,2.5]}),Ge(Uo,{x:-2.5,y:0,z:2.5,children:Un(Sd,{rotation:[0,Math.PI/2,0],children:[Ge(l_,{height:t,radius:.5,center:[0,0,2.5]}),Ge(mi,{color:"#d2b48c",children:Ge(l_,{height:5,radius:1.3,center:[0,0,2.5]})})]})}),Ge(l_,{height:4,radius:.5,center:[t/2,0,.5]}),Ge(JU,{radius:.5,center:[t/2,0,2.5]})]}),Pbn=({bodyWidth:t=21,boardThickness:e=.5,leadWidth:n=1.6,leadLength:o=2.4,leadsPitch:r=2.54,leadsLeft:i,leadsRight:s,leadsTop:a,leadsBottom:c,innerHoles:l=!0,innerHoleEdgeDistance:u=1.61,innerHoleDiameter:_=1})=>{const d=t/2,m=e/2,h=e*1.05,p=_/2,x=Math.max(i||0,s||0,a||0,c||0)*r||51,f=[],g=[];if(s){const S=-((s-1)/2)*r;for(let M=0;M<s;M++){const w=S+M*r;f.push({x:d-o/2,y:-w,pl:o,pw:n}),l&&g.push({x:d,y:-w},{x:d-u,y:-w})}}if(i){const S=-((i-1)/2)*r;for(let M=0;M<i;M++){const w=S+M*r;f.push({x:-d+o/2,y:-w,pl:o,pw:n}),l&&g.push({x:-d,y:-w},{x:-d+u,y:-w})}}if(a){const S=-((a-1)/2)*r;for(let M=0;M<a;M++){const w=S+M*r;f.push({x:-w,y:x/2-o/2,pl:n,pw:o}),l&&g.push({x:-w,y:x/2},{x:-w,y:x/2-u})}}if(c){const S=-((c-1)/2)*r;for(let M=0;M<c;M++){const w=S+M*r;f.push({x:-w,y:-x/2+o/2,pl:n,pw:o}),l&&g.push({x:-w,y:-x/2},{x:-w,y:-x/2+u})}}const y=Ge(mi,{color:"#008080",children:Un(d5,{children:[Ge(hn,{center:[0,0,m],size:[t,x,e]}),f.map((S,M)=>Ge(hn,{center:[S.x,S.y,m],size:[S.pl+.01,S.pw+.01,h]},M))]})}),b=l&&g.map((S,M)=>Ge(l_,{color:"black",center:[S.x,S.y,m],radius:p,height:e*1.07})),v=f.map((S,M)=>Ge(hn,{center:[S.x,S.y,m],size:[S.pl+.01,S.pw+.01,h]}));return Un(Nr,{children:[y,Ge(mi,{color:"#FFD700",children:l?Un(d5,{children:[Ge(cm,{children:f.map((S,M)=>Ge(hn,{center:[S.x,S.y,m],size:[S.pl+.01,S.pw+.01,h]},M))}),b]}):v})]})},vbn=({width:t=30,height:e=22,thickness:n=1,bezelInset:o=2,bezelDepth:r=1,screenColor:i="#001414",bezelColor:s="#0f1116",screenWidth:a,screenHeight:c,offset:l})=>{const u=t,_=e,d=Math.max(n,.4),m=Math.max(Math.min(r,d),.2),h=Math.max(d-m,0),p=Math.max(o,0),x=Math.max(a??u-p*2,2),f=Math.max(c??_-p*2,2),g=Math.min(Math.max(m*.6,.2),m),y=l?.x??0,b=l?.y??0,v=l?.z??0;return Un(Uo,{offset:{x:y,y:b,z:v},children:[h>0&&Ge(mi,{color:s,children:Ge(hn,{size:[u,_,h],offset:[0,0,h/2]})}),Ge(mi,{color:s,children:Un(d5,{children:[Ge(hn,{size:[u,_,m],offset:[0,0,h+m/2]}),Ge(hn,{size:[x,f,m+.02],offset:[0,0,h+m/2]})]})}),Ge(mi,{color:i,children:Ge(hn,{size:[x,f,g],offset:[0,0,h+g/2]})})]})},Sbn=({numPins:t=5,rows:e=1,p:n=2.54,id:o=1,od:r=1.5,boardThickness:i=1.6,width:s,height:a,pinRowSide:c="left",holes:l=[],holeInset:u=1,pinRowHoleEdgeToEdgeDist:_=2,female:d,nopin:m,screen:h,screenWidth:p,screenHeight:x,screenCenterOffsetX:f,screenCenterOffsetY:g})=>{const y=h??!1,b=i/2,v=Math.ceil(t/e);let S,M;c==="left"||c==="right"?(S=(e-1)*n+2*_,M=(v-1)*n+2*_):(M=(e-1)*n+2*_,S=(v-1)*n+2*_),t===0&&(S=10,M=10);const w=Number(s??S),A=Number(a??M),D=[];let I=0,H=0,B=0,z=0,V=0,j=0;c==="left"||c==="right"?(I=c==="left"?-w/2+_:w/2-_,H=-((v-1)/2)*n,B=0,z=n,V=c==="left"?n:-n,j=0):(I=-((v-1)/2)*n,H=c==="top"?A/2-_:-A/2+_,B=n,z=0,V=0,j=c==="top"?-n:n);let q=0;for(let ge=0;ge<e&&q<t;ge++)for(let Me=0;Me<v&&q<t;Me++){const fe=I+Me*B+ge*V,We=H+Me*z+ge*j;D.push({x:fe,y:We}),q++}const J=[];if(l)for(const ge of l){let Me=0,fe=0;ge==="topleft"?(Me=-w/2+u,fe=A/2-u):ge==="topright"?(Me=w/2-u,fe=A/2-u):ge==="bottomleft"?(Me=-w/2+u,fe=-A/2+u):ge==="bottomright"?(Me=w/2-u,fe=-A/2+u):ge==="center"&&(Me=0,fe=0),J.push({x:Me,y:fe})}const ne=.63,ae=2,Z=6,oe=3,se=m||d?0:ae,le=se+i,pe=Ge(mi,{color:"#008080",children:Un(d5,{children:[Ge(hn,{center:[0,0,b+se],size:[w,A,i]}),J.map((ge,Me)=>Ge(l_,{center:[ge.x,ge.y,b+se],radius:r/2,height:i},`hole-${Me}`)),D.map((ge,Me)=>Ge(l_,{center:[ge.x,ge.y,b+se],radius:r/2,height:i},`pin-hole-${Me}`))]})}),Se=D.map((ge,Me)=>Ge(mi,{color:"#FFD700",children:Un(d5,{children:[Ge(l_,{center:[ge.x,ge.y,i/2+se],radius:r/2,height:i}),Ge(l_,{center:[ge.x,ge.y,i/2+se],radius:o/2,height:i})]})})),we=D.map((ge,Me)=>Ge(gQe,{x:ge.x,y:ge.y,pinThickness:ne,shortSidePinLength:oe,longSidePinLength:Z,bodyHeight:ae,flipZ:fe=>fe})),De=D.map((ge,Me)=>Ge(MQe,{x:ge.x,y:ge.y,flipZ:fe=>-fe}));return Un(Nr,{children:[pe,Se,!d&&!m&&we,d&&De,y&&Ge(vbn,{width:p??w*.8,height:x??A*.6,offset:{x:f??0,y:g??0,z:le}})]})},Cbn=({footprint:t})=>{const e=s9n.string(t).json();switch(e.fn){case"dip":return Ge(_9n,{numPins:e.num_pins,pitch:e.p,bodyWidth:e.w});case"axial":return Ge(bbn,{pitch:e.p});case"tssop":return Ge(h9n,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"msop":return Ge(m9n,{pinCount:e.num_pins,padContactLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"vssop":return Ge(B9n,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w,bodyLength:e.h});case"qfp":return Ge(g9n,{pinCount:e.num_pins,pitch:e.p,leadWidth:e.pw,padContactLength:e.pl,bodyWidth:e.w});case"tqfp":return Ge(Z9n,{});case"lqfp":return Ge(tbn,{pinCount:e.num_pins});case"qfn":{const r=typeof e.thermalpad?.x=="number"&&typeof e.thermalpad?.y=="number";return Ge(T9n,{num_pins:e.num_pins,bodyWidth:e.w,bodyLength:e.h,pitch:e.p,padLength:e.pl,padWidth:e.pw,thermalPadSize:r?{width:e.thermalpad.x,length:e.thermalpad.y}:void 0})}case"dfn":{const r=typeof e.thermalpad?.x=="number"&&typeof e.thermalpad?.y=="number";return Ge(obn,{num_pins:e.num_pins,bodyWidth:e.w,bodyLength:e.h,pitch:e.p,padLength:e.pl,padWidth:e.pw,thermalPadSize:r?{width:e.thermalpad.x,length:e.thermalpad.y}:void 0})}case"pinrow":{const r=t.match(/_rows(\d+)/),i=r&&r[1]?parseInt(r[1],10):1;if(e.male)return Ge(v9n,{numberOfPins:e.num_pins,pitch:e.p,invert:e.invert,faceup:e.faceup,rows:i,smd:e.smd||e.surface_mount,rightangle:e.rightangle});if(e.female)return Ge(L9n,{numberOfPins:e.num_pins,pitch:e.p,rows:i})}case"cap":switch(e.imperial){case"0402":return Ge(pQe,{color:"#856c4d"});case"0603":return Ge(fQe,{color:"#856c4d"});case"0805":return Ge(xQe,{color:"#856c4d"});case"0201":return Ge(yQe,{color:"#856c4d"});case"01005":return Ge(bQe,{color:"#856c4d"});case"1206":return Ge(PQe,{color:"#856c4d"});case"1210":return Ge(vQe,{color:"#856c4d"});case"2010":return Ge(SQe,{color:"#856c4d"});case"2512":return Ge(CQe,{color:"#856c4d"})}case"sot235":return Ge(E9n,{});case"sot457":return Ge(_bn,{});case"sot223":return Ge(K9n,{});case"sot23w":return Ge(D9n,{});case"sot323":return Ge(ebn,{});case"sod323f":return Ge(gbn,{});case"sod323fl":return Ge(ybn,{});case"sot363":return Ge(pbn,{});case"sot886":return Ge(fbn,{});case"sot963":return Ge(dbn,{});case"pushbutton":return Ge(O9n,{width:e.w,length:e.h,innerDiameter:e.id});case"soic":return Ge(F9n,{pinCount:e.num_pins,leadLength:e.pl,leadWidth:e.pw,pitch:e.p,bodyWidth:e.w});case"sod523":return Ge(z9n,{});case"sod882":return Ge(V9n,{});case"sma":return Ge($9n,{});case"smb":return Ge(W9n,{});case"smc":return Ge(U9n,{});case"smf":return Ge(X9n,{});case"sod123f":return Ge(j9n,{});case"sod123fl":return Ge(G9n,{});case"sod123w":return Ge(Y9n,{});case"sod128":return Ge(q9n,{});case"sod323":return Ge(xbn,{});case"sod923":return Ge(J9n,{});case"hc49":return Ge(rbn,{});case"micromelf":return Ge(ibn,{});case"minimelf":return Ge(sbn,{});case"melf":return Ge(abn,{});case"ms012":return Ge(cbn,{pinCount:e.num_pins,padContactLength:e.pl,leadWidth:e.pw,pitch:e.p});case"ms013":return Ge(lbn,{pinCount:e.num_pins,padContactLength:e.pl,leadWidth:e.pw,pitch:e.p});case"sot723":return Ge(nbn,{});case"to220":return Ge(ubn,{});case"to92":return Ge(hbn,{});case"stampboard":case"stampreceiver":return Ge(Pbn,{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 r=e.rows??1,i=e.pinRowSide??"left",s=e.holeInset,a=e.width,c=e.height,l=e.pinrow,u=e.pinRowHoleEdgeToEdgeDist,_=Array.isArray(e.holes)?e.holes:[];return Ge(Sbn,{numPins:l,rows:r,p:e.p,id:e.id,od:e.od,width:a,height:c,pinRowSide:i,holes:_,holeInset:s,pinRowHoleEdgeToEdgeDist:u,nopin:e.nopin,female:e.female,screen:e.screen,screenWidth:e.screenwidth,screenHeight:e.screenheight,screenCenterOffsetX:e.screencenteroffsetx,screenCenterOffsetY:e.screencenteroffsety})}}const n=t.match(/_color\(([^)]+)\)/),o=n?n[1]:void 0;switch(e.imperial){case"0402":return Ge(pQe,{color:o});case"0603":return Ge(fQe,{color:o});case"0805":return Ge(xQe,{color:o});case"0201":return Ge(yQe,{color:o});case"01005":return Ge(bQe,{color:o});case"1206":return Ge(PQe,{color:o});case"1210":return Ge(vQe,{color:o});case"2010":return Ge(SQe,{color:o});case"2512":return Ge(CQe,{color:o})}return null},Mbn=t=>t&&typeof t=="object"&&"type"in t,Xw=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const e=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(t);if(e)return parseFloat(e[1])*Math.PI/180;const n=Number(t);if(!Number.isNaN(n))return n}return 0},Tbn=t=>Array.isArray(t)?[Number(t[0])||0,Number(t[1])||0,Number(t[2])||0]:typeof t=="object"&&t?[Number(t.x)||0,Number(t.y)||0,Number(t.z)||0]:[0,0,0];function B6(t,e,n){const{jscad:{primitives:o,booleans:r,hulls:i,geometries:s,extrusions:a,transforms:c}}=n;if(t==null||t===!1)return[];if(Array.isArray(t))return t.flatMap(d=>B6(d,e,n));if(!Mbn(t))return[];const{type:l,props:u,children:_}=t;if(l===dQe)return(_??[]).flatMap(d=>B6(d,e,n));if(l===mi){const d=u?.color;return(_??[]).flatMap(m=>B6(m,d??e,n))}if(l===Uo){const d=Tbn(u?.offset??u?.center??{x:u?.x,y:u?.y,z:u?.z});return(_??[]).flatMap(h=>B6(h,e,n)).map(({geom:h,color:p})=>({geom:c.translate(d,h),color:p??e}))}if(l===Sd){const d=Array.isArray(u?.rotation)?[Xw(u.rotation[0]),Xw(u.rotation[1]),Xw(u.rotation[2])]:[Xw(u?.x??0),Xw(u?.y??0),Xw(u?.z??0)];return(_??[]).flatMap(h=>B6(h,e,n)).map(({geom:h,color:p})=>({geom:c.rotateZ(d[2],c.rotateY(d[1],c.rotateX(d[0],h))),color:p}))}if(l===cm||l===d5||l===ql){const d=(_??[]).flatMap(h=>B6(h,e,n)).map(h=>h.geom);if(d.length===0)return[];let m;return l===cm?m=r.union(d):l===d5?m=r.subtract(d[0],d.slice(1)):m=i.hull(d),[{geom:m,color:e}]}if(l===Qk){const d=u?.points??[];return[{geom:s.geom2.fromPoints(d),color:e??u?.color}]}if(l===Zk){const d=(_??[]).flatMap(x=>B6(x,e,n)).map(x=>x.geom);if(d.length===0)return[];const m=d.length>1?r.union(d):d[0],h=u?.height??u?.h??1;let p=a.extrudeLinear({height:h},m);if(p.polygons)for(const x of p.polygons)!x.plane||!x.vertices||x.vertices.length<3||x.vertices.reverse();return[{geom:p,color:e??u?.color}]}if(l===hn||l===hQe||l===l_||l===JU||l===Kk||l===Ax){let d;if(l===hn){const m=u?.size??[1,1,1],h=u?.offset,p=u?.center??(h?[h[0],h[1],h[2]]:[0,0,0]);d=o.cuboid({size:m,center:p})}else if(l===hQe){const m=u?.size??1,h=u?.offset,p=u?.center??(h?[h[0],h[1],h[2]]:[0,0,0]);d=o.cube({size:m,center:p})}else if(l===l_){const m=u?.height??1,h=u?.radius??1,p=u?.center??[0,0,0];d=o.cylinder({height:m,radius:h,center:p})}else if(l===JU){const m=u?.radius??1,h=u?.center??[0,0,0];d=o.sphere({radius:m,center:h})}else if(l===Ax){const m=u?.height??1,h=u?.radius??1,p=u?.roundRadius??.1,x=u?.center??[0,0,0];d=o.roundedCylinder({height:m,radius:h,roundRadius:p,center:x})}else{const m=u?.size??[1,1,1],h=u?.roundRadius??.1,p=u?.center??[0,0,0];d=o.roundedCuboid({size:m,roundRadius:h,center:p})}return[{geom:d,color:e??u?.color}]}if(typeof l=="function"){const d=l(u??{});return B6(d,e,n)}return(_??[]).flatMap(d=>B6(d,e,n))}function wbn(t,e){return{geometries:B6(t,void 0,{jscad:e})}}function TQe(t){if(t.polygons){const e=[],n=[],o=[];let r=0;for(const s of t.polygons){for(const c of s.vertices)c.index=r,e.push(c[0],c[1],c[2]),t.color&&t.color.length>=3?o.push(t.color[0],t.color[1],t.color[2]):o.push(1,1,1),r++;const a=s.vertices[0].index;for(let c=2;c<s.vertices.length;c++){const l=s.vertices[c-1].index,u=s.vertices[c].index;n.push(a,l,u)}}const i=new el;if(i.setAttribute("position",new Xl(new Float32Array(e),3)),i.setIndex(n),o.length>0&&i.setAttribute("color",new Xl(new Float32Array(o),3)),t.transforms){const s=new zi;s.fromArray(t.transforms),i.applyMatrix4(s)}return i.computeVertexNormals(),i}if(t.sides){const e=[],n=[];for(const r of t.sides)e.push(r[0][0],r[0][1],0),t.color&&t.color.length>=3?n.push(t.color[0],t.color[1],t.color[2]):n.push(1,1,1);const o=new el;if(o.setAttribute("position",new Xl(new Float32Array(e),3)),n.length>0&&o.setAttribute("color",new Xl(new Float32Array(n),3)),t.transforms){const r=new zi;r.fromArray(t.transforms),o.applyMatrix4(r)}return o}return console.error("Invalid CSG object: neither polygons nor sides found"),new el}function Ebn(t,e){const n=Kpe(Cbn,{footprint:t});return wbn(n,e)}var Dbn=vc(VU()),wQe=te.createContext(null),Abn=()=>{const t=te.useContext(wQe);if(!t)throw new Error("useHover must be used within a HoverProvider");return t},Rbn=({children:t})=>{const{camera:e,renderer:n}=c2(),[o,r]=te.useState([]),i=te.useMemo(()=>new e9t,[]),s=te.useMemo(()=>new gr,[]),a=te.useRef(o);a.current=o;const c=te.useRef(null),l=te.useCallback(h=>{r(p=>[...p,h])},[]),u=te.useCallback(h=>{if(c.current){let p=!1,x=c.current.object;for(;x;){if(x===h){p=!0;break}x=x.parent}p&&(c.current.onUnhover(),c.current=null)}r(p=>p.filter(x=>x.object!==h))},[]),_=te.useCallback(h=>{let p=h;for(;p;){const x=a.current.find(f=>f.object===p);if(x)return x;p=p.parent}},[]),d=te.useCallback(h=>{if(!n.domElement)return;const p=n.domElement.getBoundingClientRect();s.x=(h.clientX-p.left)/p.width*2-1,s.y=-((h.clientY-p.top)/p.height)*2+1,i.setFromCamera(s,e);const x=a.current.map(g=>g.object);if(x.length===0){c.current&&(c.current.onUnhover(),c.current=null);return}const f=i.intersectObjects(x,!0);if(f.length>0){const g=f[0],y=_(g.object);if(y){const b={mousePosition:[g.point.x,g.point.y,g.point.z]};c.current!==y?(c.current?.onUnhover(),y.onHover(b),c.current=y):y.onHover(b)}else c.current&&(c.current.onUnhover(),c.current=null)}else c.current&&(c.current.onUnhover(),c.current=null)},[e,n,i,s,_]);te.useEffect(()=>{const h=n.domElement;return h.addEventListener("mousemove",d),()=>{h.removeEventListener("mousemove",d)}},[n,d]);const m=te.useMemo(()=>({addHoverable:l,removeHoverable:u}),[l,u]);return G.jsx(wQe.Provider,{value:m,children:t})},kbn=({children:t,object:e,onHover:n,onUnhover:o,isHovered:r})=>{const{addHoverable:i,removeHoverable:s}=Abn();return te.useEffect(()=>e?(i({object:e,onHover:n,onUnhover:o}),()=>{s(e)}):void 0,[e,n,o,i,s]),G.jsx(G.Fragment,{children:t})},cN=kbn,Nbn=({positionOffset:t,footprint:e,rotationOffset:n,onHover:o,onUnhover:r,isHovered:i,scale:s,isTranslucent:a=!1})=>{const{rootObject:c}=c2(),l=te.useMemo(()=>{if(!e)return null;const{geometries:u}=Ebn(e,Dbn),_=new Gm;for(const d of u.flat(1/0)){const m=d.geom;if(!m||!m.polygons&&!m.sides)continue;const h=new Yo(d.color);h.convertLinearToSRGB();const p={...m,color:[h.r,h.g,h.b]},x=TQe(p),f=new Yp({vertexColors:!0,side:Qh,transparent:a,opacity:a?.5:1,depthWrite:!a}),g=new Kr(x,f);g.renderOrder=a?2:1,_.add(g)}return _},[e,a]);return te.useEffect(()=>{if(!(!l||!c))return c.add(l),()=>{c.remove(l)}},[c,l]),te.useEffect(()=>{l&&(t&&l.position.fromArray(t),n&&l.rotation.fromArray(n),s!==void 0&&l.scale.setScalar(s))},[l,t?.[0],t?.[1],t?.[2],n?.[0],n?.[1],n?.[2],s]),te.useEffect(()=>{l&&l.traverse(u=>{u instanceof Kr&&u.material instanceof Yp&&(i?(u.material.emissive.setHex(255),u.material.emissiveIntensity=.2):u.material.emissiveIntensity=0)})},[i,l]),l?G.jsx(cN,{isHovered:i,onHover:o,onUnhover:r,object:l}):null},EQe=new WeakMap,Hbn=()=>{const t=new y0;return t.name="fallback-environment-map",t.mapping=CL,t},Ibn=t=>{if(!t)return null;const e=t,n=EQe.get(e);if(n)return n;let o;if(t instanceof nO){const r=new nK(t);o=r.fromScene(sPt(),.04).texture,r.dispose()}else o=Hbn();return EQe.set(e,o),o};function Lbn(t){const e=new $y;let n=!1;t.updateWorldMatrix(!0,!1);const o=t.parent?t.parent.matrixWorld.clone().invert():new zi;return t.traverse(r=>{if(r.updateWorldMatrix(!0,!1),r instanceof Kr&&r.geometry&&(r.geometry.boundingBox||r.geometry.computeBoundingBox(),r.geometry.boundingBox)){const i=r.geometry.boundingBox.clone();i.applyMatrix4(r.matrixWorld),i.applyMatrix4(o),n?e.union(i):(e.copy(i),n=!0)}}),n?e:null}function Obn(t){const e=Lbn(t);return e?e.getSize(new wt):new wt}function Fbn(t,e,n="contain_within_bounds"){if(!e)return[1,1,1];const o=Obn(t),r=[o.x>0?e[0]/o.x:1,o.y>0?e[1]/o.y:1,o.z>0?e[2]/o.z:1];if(n==="fill_bounds")return r;const i=Math.min(...r);return[i,i,i]}var xfe=({model:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:r=[0,0,0],sourceCoordinateTransform:i,modelSize:s,modelFitMode:a="contain_within_bounds",scale:c})=>{const{rootObject:l}=c2(),u=te.useMemo(()=>new Gm,[]),_=te.useMemo(()=>new Gm,[]),d=te.useMemo(()=>new Gm,[]),m=te.useMemo(()=>new Gm,[]);return te.useEffect(()=>(u.add(_),()=>{u.remove(_)}),[u,_]),te.useEffect(()=>(_.add(d),()=>{_.remove(d)}),[_,d]),te.useEffect(()=>(d.add(m),()=>{d.remove(m)}),[d,m]),te.useEffect(()=>{for(;m.children.length>0;){const h=m.children[0];if(!h)break;m.remove(h)}t&&m.add(t)},[m,t]),te.useEffect(()=>{if(!i){m.matrixAutoUpdate=!0,m.position.set(0,0,0),m.rotation.set(0,0,0),m.scale.set(1,1,1),m.updateMatrix();return}m.matrixAutoUpdate=!1,m.matrix.copy(i),m.matrixWorldNeedsUpdate=!0},[m,i]),te.useEffect(()=>{if(l)return l.add(u),()=>{l.remove(u)}},[l,u]),te.useEffect(()=>{if(e?u.position.fromArray(e):u.position.set(0,0,0),n?u.rotation.fromArray(n):u.rotation.set(0,0,0),d.position.fromArray(o),d.rotation.fromArray(r),d.scale.setScalar(c??1),!t){_.scale.set(1,1,1);return}_.scale.set(1,1,1),_.updateWorldMatrix(!0,!0);const h=Fbn(d,s,a);_.scale.set(h[0],h[1],h[2])},[u,_,t,a,o,m,d,r,s,e,n,c]),{boardTransformGroup:u}},DQe=1.25;function AQe({gltfUrl:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:r=[0,0,0],sourceCoordinateTransform:i,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:c,onUnhover:l,isHovered:u,scale:_,isTranslucent:d=!1}){const{renderer:m}=c2(),[h,p]=te.useState(null),[x,f]=te.useState(null),{boardTransformGroup:g}=xfe({model:h,position:e,rotation:n,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:_});if(te.useEffect(()=>{if(!t)return;const y=new cPt;let b=!0;return y.load(t,v=>{if(!b)return;const S=v.scene;S.traverse(M=>{if(M instanceof Kr&&M.material){const w=A=>{A.transparent=d,A.opacity=d?.5:1,A.depthWrite=!d,A.needsUpdate=!0};Array.isArray(M.material)?M.material.forEach(w):w(M.material),M.renderOrder=d?2:1}}),p(S)},void 0,v=>{if(!b)return;console.error(`An error happened loading ${t}`,v);const S=v instanceof Error?v:new Error(`Failed to load glTF model from ${t}`);f(S)}),()=>{b=!1}},[t,d]),te.useEffect(()=>{if(!h||!m)return;const y=Ibn(m);if(!y)return;const b=[],v=S=>{S instanceof Yp&&(b.push({material:S,envMap:S.envMap??null,envMapIntensity:S.envMapIntensity??1}),S.envMap=y,(typeof S.envMapIntensity!="number"||S.envMapIntensity<DQe)&&(S.envMapIntensity=DQe),S.needsUpdate=!0)};return h.traverse(S=>{if(!(S instanceof Kr))return;const M=S.material;Array.isArray(M)?M.forEach(v):M&&v(M)}),()=>{b.forEach(({material:S,envMap:M,envMapIntensity:w})=>{S.envMap=M,S.envMapIntensity=w,S.needsUpdate=!0})}},[h,m]),te.useEffect(()=>{h&&h.traverse(y=>{y instanceof Kr&&y.material instanceof Yp&&(u?(y.material.emissive.setHex(255),y.material.emissiveIntensity=.2):y.material.emissiveIntensity=0)})},[u,h]),x)throw x;return h?G.jsx(cN,{isHovered:u,onHover:c,onUnhover:l,object:g}):null}var Bbn=vc(HKe()),zbn=vc(VU()),Vbn=({jscadPlan:t,positionOffset:e,rotationOffset:n,modelOffset:o=[0,0,0],modelRotation:r=[0,0,0],sourceCoordinateTransform:i,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:c,onUnhover:l,isHovered:u,scale:_,isTranslucent:d=!1})=>{const{threeGeom:m,material:h}=te.useMemo(()=>{const f=(0,Bbn.executeJscadOperations)(zbn.default,t);if(!f||!f.polygons&&!f.sides)return{threeGeom:null,material:null};const g=TQe(f),y=new Yp({vertexColors:!0,side:Qh,transparent:d,opacity:d?.5:1,depthWrite:!d});return{threeGeom:g,material:y}},[t,d]),p=te.useMemo(()=>{if(!m)return null;const f=new Kr(m,h);return f.renderOrder=d?2:1,f},[m,h,d]),{boardTransformGroup:x}=xfe({model:p,position:e,rotation:n,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:_});return te.useEffect(()=>{if(h)if(u){const f=new Yo(h.color.getHex());h.emissive.copy(f),h.emissive.setRGB(0,0,1),h.emissiveIntensity=.2}else h.emissiveIntensity=0},[u,h]),m?G.jsx(cN,{isHovered:u,onHover:c,onUnhover:l,object:x}):null};function $bn(t){return t.replace(/(DEF|USE)\s+([^\s]+)/g,(e,n,o)=>`${n} ${o.replace(/-/g,"_")}`)}async function Wbn(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch "${t}": ${e.status} ${e.statusText}`);const n=await e.text();return new GPt().parse($bn(n),t)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function Ubn(t){const[e,n]=te.useState(null);return te.useEffect(()=>{if(!t)return;const o=t.replace(/&cachebust_origin=$/,""),r=window.TSCIRCUIT_OBJ_LOADER_CACHE;let i=!1;async function s(){try{if(o.endsWith(".wrl"))return await Wbn(o);const c=await fetch(o);if(!c.ok)throw new Error(`Failed to fetch "${o}": ${c.status} ${c.statusText}`);const l=await c.text(),u=l.match(/newmtl[\s\S]*?endmtl/g),_=new nvt;if(u?.length){const d=u.join(`
|
|
5149
|
-
`).replace(/d 0\./g,"d 1."),m=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),h=new UPt;h.setMaterialOptions({invertTrProperty:!0});const p=h.parse(d.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return _.setMaterials(p),_.parse(m)}return _.parse(l.replace(/^mtllib.*/gm,""))}catch(c){return c}}function a(){if(r.has(o)){const l=r.get(o);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||r.set(o,{...r.get(o),result:l}),l));return r.set(o,{promise:c,result:null}),c}return a().then(c=>{i||n(c)}).catch(c=>{console.error(c)}),()=>{i=!0}},[t]),e}function Xbn({url:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:r=[0,0,0],sourceCoordinateTransform:i,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:c,onUnhover:l,isHovered:u,scale:_,isTranslucent:d=!1}){const m=Ubn(t),h=te.useMemo(()=>m&&!(m instanceof Error)?(m.traverse(x=>{if(x instanceof Kr&&x.material){const f=g=>{g.transparent=d,g.opacity=d?.5:1,g.depthWrite=!d,g.needsUpdate=!0};Array.isArray(x.material)?x.material.forEach(f):f(x.material),x.renderOrder=d?2:1}}),m):new Kr(new t4(.5,.5,.5),new Yp({transparent:!0,color:"red",opacity:.25})),[m,d]),{boardTransformGroup:p}=xfe({model:h,position:Array.isArray(e)?e:e?[e.x,e.y,e.z]:void 0,rotation:Array.isArray(n)?n:n?[n.x,n.y,n.z]:void 0,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:_});if(m instanceof Error)throw m;return G.jsx(cN,{isHovered:u,onHover:c,onUnhover:l,object:p})}var gfe,jbn="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function Gbn(t){if(typeof t=="function")return t;if(t&&typeof t=="object"&&"default"in t&&typeof t.default=="function")return t.default;throw new Error("Unable to resolve occt-import-js factory export")}async function Ybn(){if(!gfe){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");gfe=Gbn(t)({locateFile:n=>`${jbn}/${n}`})}return gfe}function qbn(t){const e=new Gm;for(const n of t){const o=n.attributes.position?.array??[],r=n.index?.array??[];if(!o.length||!r.length)continue;const i=new el;i.setAttribute("position",new Vi(o,3));const s=n.attributes.normal?.array??[];s.length?i.setAttribute("normal",new Vi(s,3)):i.computeVertexNormals(),i.setIndex(r);const a=new Yp({color:n.color?new Yo(n.color[0],n.color[1],n.color[2]):new Yo(.82,.82,.82)}),c=new Kr(i,a);c.name=n.name,e.add(c)}return e}async function Jbn(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch STEP file: ${e.statusText}`);const n=await e.arrayBuffer(),r=(await Ybn()).ReadStepFile(new Uint8Array(n),null);if(!r.success||!r.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const i=qbn(r.meshes),s=new AQ;return await new Promise((c,l)=>{s.parse(i,u=>{u instanceof ArrayBuffer?c(u):l(new Error("GLTFExporter did not return binary output"))},u=>{l(u)},{binary:!0})})}var RQe="step-glb-cache:";function Kbn(t){const e=new Uint8Array(t),n=32768;let o="";for(let r=0;r<e.length;r+=n){const i=e.subarray(r,r+n);o+=String.fromCharCode(...i)}return btoa(o)}function Qbn(t){const e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o+=1)n[o]=e.charCodeAt(o);return n.buffer}function Zbn(t){try{const e=localStorage.getItem(`${RQe}${t}`);return e?Qbn(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function kQe(t,e){try{const n=Kbn(e);localStorage.setItem(`${RQe}${t}`,n)}catch(n){console.warn("Failed to write STEP GLB cache",n)}}function ePn(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var tPn=({stepUrl:t,position:e,rotation:n,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:_,isTranslucent:d})=>{const[m,h]=te.useState(null);return te.useEffect(()=>{let p=!0,x=null,f=!0;const g=ePn(),y=Zbn(t);if(y){const S={arrayBuffer:y,blobUrl:URL.createObjectURL(new Blob([y],{type:"model/gltf-binary"}))};return g.completed.set(t,S),x=S.blobUrl,f=!1,h(S.blobUrl),()=>{p=!1,x&&f&&URL.revokeObjectURL(x)}}const b=g.completed.get(t);if(b)return x=b.blobUrl,f=!1,h(b.blobUrl),kQe(t,b.arrayBuffer),()=>{p=!1,x&&f&&URL.revokeObjectURL(x)};let v=g.inProgress.get(t);return v||(v=Jbn(t).then(S=>{const M={arrayBuffer:S,blobUrl:URL.createObjectURL(new Blob([S],{type:"model/gltf-binary"}))};return g.completed.set(t,M),g.inProgress.delete(t),M}).catch(S=>{throw g.inProgress.delete(t),S}),g.inProgress.set(t,v)),v.then(S=>{p&&(x=S.blobUrl,f=!1,h(S.blobUrl),kQe(t,S.arrayBuffer))}).catch(S=>{console.error("Failed to convert STEP file to GLB",S),p&&h(null)}),()=>{p=!1,x&&f&&URL.revokeObjectURL(x)}},[t]),m?G.jsx(AQe,{gltfUrl:m,position:e,rotation:n,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:_,isTranslucent:d}):null};function eX(t,e){let{x:n,y:o,z:r}=t;if(e.axisMapping){const i={x:n,y:o,z:r};e.axisMapping.x&&(n=yfe(i,e.axisMapping.x)),e.axisMapping.y&&(o=yfe(i,e.axisMapping.y)),e.axisMapping.z&&(r=yfe(i,e.axisMapping.z))}if(n*=e.flipX??1,o*=e.flipY??1,r*=e.flipZ??1,e.rotation){if(e.rotation.x){const i=e.rotation.x*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=o*s-r*a,l=o*a+r*s;o=c,r=l}if(e.rotation.y){const i=e.rotation.y*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=n*s+r*a,l=-n*a+r*s;n=c,r=l}if(e.rotation.z){const i=e.rotation.z*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=n*s-o*a,l=n*a+o*s;n=c,o=l}}return{x:n,y:o,z:r}}function yfe(t,e){switch(e){case"x":return t.x;case"y":return t.y;case"z":return t.z;case"-x":return-t.x;case"-y":return-t.y;case"-z":return-t.z;default:return 0}}var bfe={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 nPn(t,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return bfe.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?bfe.STEP_INVERTED:bfe.Z_UP_TO_Y_UP_USB_FIX}}function lN(t,e){return nPn(t,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function tX(t){if(!t)return;const e=eX({x:1,y:0,z:0},t),n=eX({x:0,y:1,z:0},t),o=eX({x:0,y:0,z:1},t);return new zi().makeBasis(new wt(e.x,e.y,e.z),new wt(n.x,n.y,n.z),new wt(o.x,o.y,o.z))}function tv(t){return t*Math.PI/180}function oPn(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,tv(-90),0];case"x-":return[0,tv(90),0];case"y+":return[tv(90),0,0];case"y-":return[tv(-90),0,0];case"z-":return[tv(180),0,0];default:return[0,0,0]}}function rPn(t,e,n){if(!t.position)return;let o=t.position.z;return e==="bottom"&&t.position.z>=0&&(o=-(t.position.z+n)),[t.position.x,t.position.y,o]}function iPn(t,e){return t.rotation?[tv(t.rotation.x),tv(t.rotation.y),tv(t.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function sPn(t,e){const n=new wt(t.x,t.y,t.z),o=new Z1(e[0],e[1],e[2],"XYZ");return n.applyEuler(o),[n.x,n.y,n.z]}function aPn(t,e,n){if(!t.model_origin_position)return[0,0,0];const o=e?eX(t.model_origin_position,e):t.model_origin_position;return sPn(o,n)}function cPn(t,e){const n=rPn(t,e.layer,e.pcbThickness),o=iPn(t,e.layer),r=lN(t,e.modelType),i=oPn(t.model_board_normal_direction??"z+"),s=aPn(t,r,i);return{position:n,rotation:o,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:i,scale:t.model_unit_to_mm_scale_factor??void 0,fitMode:t.model_object_fit??"contain_within_bounds",size:t.size?[t.size.x,t.size.y,t.size.z]:void 0}}var lPn=t=>t.model_glb_url||t.model_gltf_url?t.model_glb_url?"glb":"gltf":t.model_obj_url||t.model_wrl_url||t.model_stl_url?t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj":t.model_jscad?"jscad":t.footprinter_string?"footprinter":t.model_step_url?"step":"unknown",uPn=t=>t==="step"?"glb":t,_Pn=(t,e)=>{if(t)return e?e(t):t},dPn=(...t)=>t,Pfe=class extends ar.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},hPn=({error:t,onError:e})=>(te.useEffect(()=>{e(t)},[t,e]),null),NQe=({cad_component:t,circuitJson:e,resolveStaticAsset:n})=>{const o=OKe(e),[r,i]=te.useState(!1),{visibility:s}=nS(),[a,c]=te.useState(null),l=te.useCallback(j=>{j?.mousePosition?(i(!0),c(j.mousePosition)):(i(!1),c(null))},[]),u=te.useCallback(()=>{i(!1),c(null)},[]),_=te.useMemo(()=>yr(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),d=te.useMemo(()=>e.filter(q=>q.type==="pcb_plated_hole"&&q.pcb_component_id===t.pcb_component_id).length>0,[e,t.pcb_component_id]),m=te.useCallback(j=>_Pn(j,n),[n]),h=m(t.model_wrl_url??t.model_stl_url??t.model_obj_url),p=m(t.model_glb_url??t.model_gltf_url),x=m(t.model_step_url),[f,g]=te.useState(0),[y,b]=te.useState(null);te.useEffect(()=>{g(0),b(null)},[t.cad_component_id,h,p,x]);const S=e.find(j=>j.type==="pcb_component"&&j.source_component_id===t.source_component_id)?.layer??"top",M=lPn(t),w=uPn(M),A=t.model_glb_url?"glb":"gltf",D=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",I=te.useMemo(()=>cPn(t,{layer:S,pcbThickness:o,modelType:w}),[t,S,o,w]),H=dPn(...I.rotation),B=I.position,z=te.useMemo(()=>{const j=[];return p&&j.push(G.jsx(AQe,{gltfUrl:p,position:B,rotation:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:tX(lN(t,A)),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${p}`)),h&&j.push(G.jsx(Xbn,{url:h,position:B,rotation:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:tX(lN(t,D)),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${h}`)),x&&!t.model_jscad&&!t.footprinter_string&&j.push(G.jsx(tPn,{stepUrl:x,position:B,rotation:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:tX(lN(t,w)),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${x}`)),j},[B,t.cad_component_id,t.footprinter_string,t.model_jscad,t.show_as_translucent_model,p,A,l,u,r,D,I.modelPosition,I.modelRotation,I.scale,I.fitMode,I.size,w,H,x,h]);let V=null;if(z.length>0){if(f>=z.length){if(y)throw y;return null}V=G.jsx(Pfe,{fallback:({error:j})=>G.jsx(hPn,{error:j,onError:q=>{b(q),g(J=>Math.max(J,f+1))}}),children:z[f]},`${t.cad_component_id}-fallback-${f}`)}else t.model_jscad?V=G.jsx(Vbn,{jscadPlan:t.model_jscad,positionOffset:B,rotationOffset:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:tX(lN(t,"jscad")),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(V=G.jsx(Nbn,{positionOffset:B,rotationOffset:H,footprint:t.footprinter_string,scale:I.scale,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model}));if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(d&&!s.throughHoleModels||!d&&!s.smtModels)return null;return G.jsxs(G.Fragment,{children:[V,r&&a?G.jsx(BKe,{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:_??"<unknown>"}):null]})},HQe={version:"0.0.552"};function mPn(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var pPn=t=>{t.outputColorSpace=G5,t.toneMapping=O3e,t.toneMappingExposure=1},IQe="cadViewerCameraStateSession",LQe=(t,e)=>{try{const n={position:t.position.toArray(),quaternion:t.quaternion.toArray(),up:t.up.toArray(),fov:t.fov??50,target:e.target.toArray()};sessionStorage.setItem(IQe,JSON.stringify(n))}catch(n){console.warn("Failed to save camera:",n)}},vfe=(t,e)=>{try{const n=sessionStorage.getItem(IQe);if(!n)return!1;const o=JSON.parse(n);if(t.position.fromArray(o.position),t.quaternion.fromArray(o.quaternion),t.up.fromArray(o.up),"fov"in t){const r=t;r.fov=o.fov,r.updateProjectionMatrix?.()}return e.target.fromArray(o.target),e.update(),t.updateMatrixWorld(),!0}catch(n){return console.warn("Failed to restore camera:",n),!1}},OQe=te.createContext(void 0),fPn=({children:t,defaultTarget:e,initialCameraPosition:n})=>{const o=te.useRef(null),r=te.useRef(null),[i,s]=te.useState(null),[a,c]=te.useState("perspective"),[l,u]=te.useState(n??null),[_,d]=te.useState(new Z1(0,0,0)),m=te.useMemo(()=>{const[f,g,y]=n??[5,-5,5],b=Math.hypot(f-e.x,g-e.y,y-e.z);return b>0?b:5},[n,e]),h=te.useCallback(f=>{const g=[e.x,e.y,e.z],y=r.current,b=o.current;let v=m;switch(y&&b&&(v=y.position.distanceTo(b.target)),f){case"Top Center Angled":{const S=v/Math.sqrt(2);return{position:[e.x,e.y-S,e.z+S],target:g,up:[0,0,1]}}case"Top Down":return{position:[e.x,e.y,e.z+v],target:g,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-v*.6,e.y-v*.6,e.z+v*.6],target:g,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+v*.6,e.y-v*.6,e.z+v*.6],target:g,up:[0,0,1]};case"Left Sideview":return{position:[e.x-v,e.y,e.z],target:g,up:[0,0,1]};case"Right Sideview":return{position:[e.x+v,e.y,e.z],target:g,up:[0,0,1]};case"Front":return{position:[e.x,e.y-v,e.z],target:g,up:[0,0,1]};default:return null}},[m,e,r,o]),p=te.useCallback(f=>{o.current=f},[]),x=te.useMemo(()=>({controlsRef:o,mainCameraRef:r,defaultTarget:e,baseDistance:m,controller:i,setController:s,getPresetConfig:h,handleControlsChange:p,cameraType:a,setCameraType:c,cameraPosition:l,setCameraPosition:u,cameraRotation:_,setCameraRotation:d,saveCameraToSession:LQe,loadCameraFromSession:vfe}),[e,m,i,h,p,a,l,_]);return G.jsx(OQe.Provider,{value:x,children:t})},nv=()=>{const t=te.useContext(OQe);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},xPn=te.forwardRef(({children:t,scene:e,camera:n,style:o,onCreated:r},i)=>{const{cameraType:s}=nv(),a=te.useRef(null),[c,l]=te.useState(null),u=te.useRef([]),_=te.useRef(void 0);_.current=r;const d=te.useRef(null),m=te.useCallback(f=>{u.current.push(f)},[]),h=te.useCallback(f=>{u.current=u.current.filter(g=>g!==f)},[]),p=te.useMemo(()=>new L7,[]);e?.up&&p.up.set(e.up.x,e.up.y,e.up.z);const x=te.useRef(new Zc);return te.useImperativeHandle(i,()=>x.current),te.useEffect(()=>{if(!a.current)return;mPn(a.current);const f=new nO({antialias:!0,alpha:!0});pPn(f),f.setSize(a.current.clientWidth,a.current.clientHeight),f.setPixelRatio(window.devicePixelRatio),a.current.appendChild(f.domElement);const g=a.current.clientWidth/a.current.clientHeight,y=s==="perspective"?new jm(75,g,.1,1e3):new iA(-10*g,10*g,10,-10,-1e3,1e3);d.current?(y.position.copy(d.current.position),y.quaternion.copy(d.current.quaternion),y.up.copy(d.current.up)):(n?.up&&y.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&y.position.set(n.position[0],n.position[1],n.position[2]),y.lookAt(0,0,0)),p.add(x.current),window.__TSCIRCUIT_THREE_OBJECT=x.current,l({scene:p,camera:y,renderer:f,rootObject:x.current,addFrameListener:m,removeFrameListener:h}),_.current?.({camera:y,renderer:f});let b;const v=new U3t,S=()=>{const w=v.getElapsedTime(),A=v.getDelta();u.current.forEach(D=>D(w,A)),f.render(p,y),b=requestAnimationFrame(S)};S();const M=()=>{if(a.current){const w=a.current.clientWidth/a.current.clientHeight;y instanceof jm?y.aspect=w:y instanceof iA&&(y.left=-10*w,y.right=10*w,y.top=10,y.bottom=-10),y.updateProjectionMatrix(),f.setSize(a.current.clientWidth,a.current.clientHeight)}};return window.addEventListener("resize",M),()=>{d.current={position:y.position.clone(),quaternion:y.quaternion.clone(),up:y.up.clone()},window.removeEventListener("resize",M),cancelAnimationFrame(b),a.current&&f.domElement&&a.current.removeChild(f.domElement),f.dispose(),p.remove(x.current),window.__TSCIRCUIT_THREE_OBJECT===x.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[p,m,h,s]),G.jsx("div",{ref:a,style:{width:"100%",height:"100%",...o},children:c&&G.jsx(FKe.Provider,{value:c,children:G.jsx(Rbn,{children:t})})})}),gPn=({autoRotate:t,autoRotateSpeed:e,onStart:n,panSpeed:o,rotateSpeed:r,zoomSpeed:i,enableDamping:s,dampingFactor:a,target:c,onControlsChange:l})=>{const{camera:u,renderer:_}=c2(),d=te.useMemo(()=>!u||!_?null:new rvt(u,_.domElement),[u,_]);return te.useEffect(()=>(l?.(d??null),()=>l?.(null)),[d,l]),te.useEffect(()=>{if(!d)return;const m=()=>{l?.(d)};return d.addEventListener("change",m),()=>{d.removeEventListener("change",m)}},[d,l]),te.useEffect(()=>{d&&(d.autoRotate=t||!1,d.autoRotateSpeed=e||1,o!==void 0&&(d.panSpeed=o),r!==void 0&&(d.rotateSpeed=r),i!==void 0&&(d.zoomSpeed=i),s!==void 0&&(d.enableDamping=s),a!==void 0&&(d.dampingFactor=a),d.zoomToCursor=!0,d.mouseButtons={LEFT:Rb.ROTATE,MIDDLE:Rb.PAN,RIGHT:null},c&&(d.target.set(c[0],c[1],c[2]),d.update()))},[d,t,e,o,r,i,s,a,c]),te.useEffect(()=>{if(!(!d||!n))return d.addEventListener("start",n),()=>{d.removeEventListener("start",n)}},[d,n]),te.useEffect(()=>{if(d)return()=>{d.dispose()}},[d]),Gk(()=>{d?.update()},[d]),null},yPn=`
|
|
5149
|
+
`).replace(/d 0\./g,"d 1."),m=l.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),h=new UPt;h.setMaterialOptions({invertTrProperty:!0});const p=h.parse(d.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return _.setMaterials(p),_.parse(m)}return _.parse(l.replace(/^mtllib.*/gm,""))}catch(c){return c}}function a(){if(r.has(o)){const l=r.get(o);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||r.set(o,{...r.get(o),result:l}),l));return r.set(o,{promise:c,result:null}),c}return a().then(c=>{i||n(c)}).catch(c=>{console.error(c)}),()=>{i=!0}},[t]),e}function Xbn({url:t,position:e,rotation:n,modelOffset:o=[0,0,0],modelRotation:r=[0,0,0],sourceCoordinateTransform:i,modelSize:s,modelFitMode:a="contain_within_bounds",onHover:c,onUnhover:l,isHovered:u,scale:_,isTranslucent:d=!1}){const m=Ubn(t),h=te.useMemo(()=>m&&!(m instanceof Error)?(m.traverse(x=>{if(x instanceof Kr&&x.material){const f=g=>{g.transparent=d,g.opacity=d?.5:1,g.depthWrite=!d,g.needsUpdate=!0};Array.isArray(x.material)?x.material.forEach(f):f(x.material),x.renderOrder=d?2:1}}),m):new Kr(new t4(.5,.5,.5),new Yp({transparent:!0,color:"red",opacity:.25})),[m,d]),{boardTransformGroup:p}=xfe({model:h,position:Array.isArray(e)?e:e?[e.x,e.y,e.z]:void 0,rotation:Array.isArray(n)?n:n?[n.x,n.y,n.z]:void 0,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:_});if(m instanceof Error)throw m;return G.jsx(cN,{isHovered:u,onHover:c,onUnhover:l,object:p})}var gfe,jbn="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function Gbn(t){if(typeof t=="function")return t;if(t&&typeof t=="object"&&"default"in t&&typeof t.default=="function")return t.default;throw new Error("Unable to resolve occt-import-js factory export")}async function Ybn(){if(!gfe){const t=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");gfe=Gbn(t)({locateFile:n=>`${jbn}/${n}`})}return gfe}function qbn(t){const e=new Gm;for(const n of t){const o=n.attributes.position?.array??[],r=n.index?.array??[];if(!o.length||!r.length)continue;const i=new el;i.setAttribute("position",new Vi(o,3));const s=n.attributes.normal?.array??[];s.length?i.setAttribute("normal",new Vi(s,3)):i.computeVertexNormals(),i.setIndex(r);const a=new Yp({color:n.color?new Yo(n.color[0],n.color[1],n.color[2]):new Yo(.82,.82,.82)}),c=new Kr(i,a);c.name=n.name,e.add(c)}return e}async function Jbn(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch STEP file: ${e.statusText}`);const n=await e.arrayBuffer(),r=(await Ybn()).ReadStepFile(new Uint8Array(n),null);if(!r.success||!r.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const i=qbn(r.meshes),s=new AQ;return await new Promise((c,l)=>{s.parse(i,u=>{u instanceof ArrayBuffer?c(u):l(new Error("GLTFExporter did not return binary output"))},u=>{l(u)},{binary:!0})})}var RQe="step-glb-cache:";function Kbn(t){const e=new Uint8Array(t),n=32768;let o="";for(let r=0;r<e.length;r+=n){const i=e.subarray(r,r+n);o+=String.fromCharCode(...i)}return btoa(o)}function Qbn(t){const e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o+=1)n[o]=e.charCodeAt(o);return n.buffer}function Zbn(t){try{const e=localStorage.getItem(`${RQe}${t}`);return e?Qbn(e):null}catch(e){return console.warn("Failed to read STEP GLB cache",e),null}}function kQe(t,e){try{const n=Kbn(e);localStorage.setItem(`${RQe}${t}`,n)}catch(n){console.warn("Failed to write STEP GLB cache",n)}}function ePn(){const t=globalThis;return t.stepUrlToGltfModelConversions||(t.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),t.stepUrlToGltfModelConversions}var tPn=({stepUrl:t,position:e,rotation:n,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:_,isTranslucent:d})=>{const[m,h]=te.useState(null);return te.useEffect(()=>{let p=!0,x=null,f=!0;const g=ePn(),y=Zbn(t);if(y){const S={arrayBuffer:y,blobUrl:URL.createObjectURL(new Blob([y],{type:"model/gltf-binary"}))};return g.completed.set(t,S),x=S.blobUrl,f=!1,h(S.blobUrl),()=>{p=!1,x&&f&&URL.revokeObjectURL(x)}}const b=g.completed.get(t);if(b)return x=b.blobUrl,f=!1,h(b.blobUrl),kQe(t,b.arrayBuffer),()=>{p=!1,x&&f&&URL.revokeObjectURL(x)};let v=g.inProgress.get(t);return v||(v=Jbn(t).then(S=>{const M={arrayBuffer:S,blobUrl:URL.createObjectURL(new Blob([S],{type:"model/gltf-binary"}))};return g.completed.set(t,M),g.inProgress.delete(t),M}).catch(S=>{throw g.inProgress.delete(t),S}),g.inProgress.set(t,v)),v.then(S=>{p&&(x=S.blobUrl,f=!1,h(S.blobUrl),kQe(t,S.arrayBuffer))}).catch(S=>{console.error("Failed to convert STEP file to GLB",S),p&&h(null)}),()=>{p=!1,x&&f&&URL.revokeObjectURL(x)}},[t]),m?G.jsx(AQe,{gltfUrl:m,position:e,rotation:n,modelOffset:o,modelRotation:r,sourceCoordinateTransform:i,modelSize:s,modelFitMode:a,scale:c,onHover:l,onUnhover:u,isHovered:_,isTranslucent:d}):null};function eX(t,e){let{x:n,y:o,z:r}=t;if(e.axisMapping){const i={x:n,y:o,z:r};e.axisMapping.x&&(n=yfe(i,e.axisMapping.x)),e.axisMapping.y&&(o=yfe(i,e.axisMapping.y)),e.axisMapping.z&&(r=yfe(i,e.axisMapping.z))}if(n*=e.flipX??1,o*=e.flipY??1,r*=e.flipZ??1,e.rotation){if(e.rotation.x){const i=e.rotation.x*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=o*s-r*a,l=o*a+r*s;o=c,r=l}if(e.rotation.y){const i=e.rotation.y*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=n*s+r*a,l=-n*a+r*s;n=c,r=l}if(e.rotation.z){const i=e.rotation.z*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=n*s-o*a,l=n*a+o*s;n=c,o=l}}return{x:n,y:o,z:r}}function yfe(t,e){switch(e){case"x":return t.x;case"y":return t.y;case"z":return t.z;case"-x":return-t.x;case"-y":return-t.y;case"-z":return-t.z;default:return 0}}var bfe={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 nPn(t,e){if(e.coordinateTransform)return e.coordinateTransform;if(!e.usingGlbCoordinates){if(e.hasFootprinterModel)return bfe.FOOTPRINTER_MODEL_TRANSFORM;if(!e.usingObjFormat)return e.usingStepFormat?bfe.STEP_INVERTED:bfe.Z_UP_TO_Y_UP_USB_FIX}}function lN(t,e){return nPn(t,{usingGlbCoordinates:e==="gltf"||e==="glb"||e==="jscad",usingObjFormat:e==="obj"||e==="wrl",usingStepFormat:e==="step",hasFootprinterModel:e==="footprinter"})}function tX(t){if(!t)return;const e=eX({x:1,y:0,z:0},t),n=eX({x:0,y:1,z:0},t),o=eX({x:0,y:0,z:1},t);return new zi().makeBasis(new wt(e.x,e.y,e.z),new wt(n.x,n.y,n.z),new wt(o.x,o.y,o.z))}function tv(t){return t*Math.PI/180}function oPn(t){if(t==="z+")return[0,0,0];switch(t){case"x+":return[0,tv(-90),0];case"x-":return[0,tv(90),0];case"y+":return[tv(90),0,0];case"y-":return[tv(-90),0,0];case"z-":return[tv(180),0,0];default:return[0,0,0]}}function rPn(t,e,n){if(!t.position)return;let o=t.position.z;return e==="bottom"&&t.position.z>=0&&(o=-(t.position.z+n)),[t.position.x,t.position.y,o]}function iPn(t,e){return t.rotation?[tv(t.rotation.x),tv(t.rotation.y),tv(t.rotation.z)]:e==="bottom"?[Math.PI,0,0]:[0,0,0]}function sPn(t,e){const n=new wt(t.x,t.y,t.z),o=new Z1(e[0],e[1],e[2],"XYZ");return n.applyEuler(o),[n.x,n.y,n.z]}function aPn(t,e,n){if(!t.model_origin_position)return[0,0,0];const o=e?eX(t.model_origin_position,e):t.model_origin_position;return sPn(o,n)}function cPn(t,e){const n=rPn(t,e.layer,e.pcbThickness),o=iPn(t,e.layer),r=lN(t,e.modelType),i=oPn(t.model_board_normal_direction??"z+"),s=aPn(t,r,i);return{position:n,rotation:o,modelPosition:[-s[0],-s[1],-s[2]],modelRotation:i,scale:t.model_unit_to_mm_scale_factor??void 0,fitMode:t.model_object_fit??"contain_within_bounds",size:t.size?[t.size.x,t.size.y,t.size.z]:void 0}}var lPn=t=>t.model_glb_url||t.model_gltf_url?t.model_glb_url?"glb":"gltf":t.model_obj_url||t.model_wrl_url||t.model_stl_url?t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj":t.model_jscad?"jscad":t.footprinter_string?"footprinter":t.model_step_url?"step":"unknown",uPn=t=>t==="step"?"glb":t,_Pn=(t,e)=>{if(t)return e?e(t):t},dPn=(...t)=>t,Pfe=class extends ar.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},hPn=({error:t,onError:e})=>(te.useEffect(()=>{e(t)},[t,e]),null),NQe=({cad_component:t,circuitJson:e,resolveStaticAsset:n})=>{const o=OKe(e),[r,i]=te.useState(!1),{visibility:s}=nS(),[a,c]=te.useState(null),l=te.useCallback(j=>{j?.mousePosition?(i(!0),c(j.mousePosition)):(i(!1),c(null))},[]),u=te.useCallback(()=>{i(!1),c(null)},[]),_=te.useMemo(()=>yr(e).source_component.getUsing({source_component_id:t.source_component_id})?.name,[e,t.source_component_id]),d=te.useMemo(()=>e.filter(q=>q.type==="pcb_plated_hole"&&q.pcb_component_id===t.pcb_component_id).length>0,[e,t.pcb_component_id]),m=te.useCallback(j=>_Pn(j,n),[n]),h=m(t.model_wrl_url??t.model_stl_url??t.model_obj_url),p=m(t.model_glb_url??t.model_gltf_url),x=m(t.model_step_url),[f,g]=te.useState(0),[y,b]=te.useState(null);te.useEffect(()=>{g(0),b(null)},[t.cad_component_id,h,p,x]);const S=e.find(j=>j.type==="pcb_component"&&j.source_component_id===t.source_component_id)?.layer??"top",M=lPn(t),w=uPn(M),A=t.model_glb_url?"glb":"gltf",D=t.model_wrl_url?"wrl":t.model_stl_url?"stl":"obj",I=te.useMemo(()=>cPn(t,{layer:S,pcbThickness:o,modelType:w}),[t,S,o,w]),H=dPn(...I.rotation),B=I.position,z=te.useMemo(()=>{const j=[];return p&&j.push(G.jsx(AQe,{gltfUrl:p,position:B,rotation:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:tX(lN(t,A)),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-gltf-${p}`)),h&&j.push(G.jsx(Xbn,{url:h,position:B,rotation:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:tX(lN(t,D)),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-mixed-${h}`)),x&&!t.model_jscad&&!t.footprinter_string&&j.push(G.jsx(tPn,{stepUrl:x,position:B,rotation:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:tX(lN(t,w)),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},`${t.cad_component_id}-step-${x}`)),j},[B,t.cad_component_id,t.footprinter_string,t.model_jscad,t.show_as_translucent_model,p,A,l,u,r,D,I.modelPosition,I.modelRotation,I.scale,I.fitMode,I.size,w,H,x,h]);let V=null;if(z.length>0){if(f>=z.length){if(y)throw y;return null}V=G.jsx(Pfe,{fallback:({error:j})=>G.jsx(hPn,{error:j,onError:q=>{b(q),g(J=>Math.max(J,f+1))}}),children:z[f]},`${t.cad_component_id}-fallback-${f}`)}else t.model_jscad?V=G.jsx(Vbn,{jscadPlan:t.model_jscad,positionOffset:B,rotationOffset:H,modelOffset:I.modelPosition,modelRotation:I.modelRotation,sourceCoordinateTransform:tX(lN(t,"jscad")),scale:I.scale,modelSize:I.size,modelFitMode:I.fitMode,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model},t.cad_component_id):t.footprinter_string&&(V=G.jsx(Nbn,{positionOffset:B,rotationOffset:H,footprint:t.footprinter_string,scale:I.scale,onHover:l,onUnhover:u,isHovered:r,isTranslucent:t.show_as_translucent_model}));if(t.show_as_translucent_model){if(!s.translucentModels)return null}else if(d&&!s.throughHoleModels||!d&&!s.smtModels)return null;return G.jsxs(G.Fragment,{children:[V,r&&a?G.jsx(BKe,{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:_??"<unknown>"}):null]})},HQe={version:"0.0.553"};function mPn(t){t.querySelectorAll("canvas").forEach(e=>e.remove())}var pPn=t=>{t.outputColorSpace=G5,t.toneMapping=O3e,t.toneMappingExposure=1},IQe="cadViewerCameraStateSession",LQe=(t,e)=>{try{const n={position:t.position.toArray(),quaternion:t.quaternion.toArray(),up:t.up.toArray(),fov:t.fov??50,target:e.target.toArray()};sessionStorage.setItem(IQe,JSON.stringify(n))}catch(n){console.warn("Failed to save camera:",n)}},vfe=(t,e)=>{try{const n=sessionStorage.getItem(IQe);if(!n)return!1;const o=JSON.parse(n);if(t.position.fromArray(o.position),t.quaternion.fromArray(o.quaternion),t.up.fromArray(o.up),"fov"in t){const r=t;r.fov=o.fov,r.updateProjectionMatrix?.()}return e.target.fromArray(o.target),e.update(),t.updateMatrixWorld(),!0}catch(n){return console.warn("Failed to restore camera:",n),!1}},OQe=te.createContext(void 0),fPn=({children:t,defaultTarget:e,initialCameraPosition:n})=>{const o=te.useRef(null),r=te.useRef(null),[i,s]=te.useState(null),[a,c]=te.useState("perspective"),[l,u]=te.useState(n??null),[_,d]=te.useState(new Z1(0,0,0)),m=te.useMemo(()=>{const[f,g,y]=n??[5,-5,5],b=Math.hypot(f-e.x,g-e.y,y-e.z);return b>0?b:5},[n,e]),h=te.useCallback(f=>{const g=[e.x,e.y,e.z],y=r.current,b=o.current;let v=m;switch(y&&b&&(v=y.position.distanceTo(b.target)),f){case"Top Center Angled":{const S=v/Math.sqrt(2);return{position:[e.x,e.y-S,e.z+S],target:g,up:[0,0,1]}}case"Top Down":return{position:[e.x,e.y,e.z+v],target:g,up:[0,0,1]};case"Top Left Corner":return{position:[e.x-v*.6,e.y-v*.6,e.z+v*.6],target:g,up:[0,0,1]};case"Top Right Corner":return{position:[e.x+v*.6,e.y-v*.6,e.z+v*.6],target:g,up:[0,0,1]};case"Left Sideview":return{position:[e.x-v,e.y,e.z],target:g,up:[0,0,1]};case"Right Sideview":return{position:[e.x+v,e.y,e.z],target:g,up:[0,0,1]};case"Front":return{position:[e.x,e.y-v,e.z],target:g,up:[0,0,1]};default:return null}},[m,e,r,o]),p=te.useCallback(f=>{o.current=f},[]),x=te.useMemo(()=>({controlsRef:o,mainCameraRef:r,defaultTarget:e,baseDistance:m,controller:i,setController:s,getPresetConfig:h,handleControlsChange:p,cameraType:a,setCameraType:c,cameraPosition:l,setCameraPosition:u,cameraRotation:_,setCameraRotation:d,saveCameraToSession:LQe,loadCameraFromSession:vfe}),[e,m,i,h,p,a,l,_]);return G.jsx(OQe.Provider,{value:x,children:t})},nv=()=>{const t=te.useContext(OQe);if(!t)throw new Error("useCameraController must be used within a CameraControllerProvider");return t},xPn=te.forwardRef(({children:t,scene:e,camera:n,style:o,onCreated:r},i)=>{const{cameraType:s}=nv(),a=te.useRef(null),[c,l]=te.useState(null),u=te.useRef([]),_=te.useRef(void 0);_.current=r;const d=te.useRef(null),m=te.useCallback(f=>{u.current.push(f)},[]),h=te.useCallback(f=>{u.current=u.current.filter(g=>g!==f)},[]),p=te.useMemo(()=>new L7,[]);e?.up&&p.up.set(e.up.x,e.up.y,e.up.z);const x=te.useRef(new Zc);return te.useImperativeHandle(i,()=>x.current),te.useEffect(()=>{if(!a.current)return;mPn(a.current);const f=new nO({antialias:!0,alpha:!0});pPn(f),f.setSize(a.current.clientWidth,a.current.clientHeight),f.setPixelRatio(window.devicePixelRatio),a.current.appendChild(f.domElement);const g=a.current.clientWidth/a.current.clientHeight,y=s==="perspective"?new jm(75,g,.1,1e3):new iA(-10*g,10*g,10,-10,-1e3,1e3);d.current?(y.position.copy(d.current.position),y.quaternion.copy(d.current.quaternion),y.up.copy(d.current.up)):(n?.up&&y.up.set(n.up[0],n.up[1],n.up[2]),n?.position&&y.position.set(n.position[0],n.position[1],n.position[2]),y.lookAt(0,0,0)),p.add(x.current),window.__TSCIRCUIT_THREE_OBJECT=x.current,l({scene:p,camera:y,renderer:f,rootObject:x.current,addFrameListener:m,removeFrameListener:h}),_.current?.({camera:y,renderer:f});let b;const v=new U3t,S=()=>{const w=v.getElapsedTime(),A=v.getDelta();u.current.forEach(D=>D(w,A)),f.render(p,y),b=requestAnimationFrame(S)};S();const M=()=>{if(a.current){const w=a.current.clientWidth/a.current.clientHeight;y instanceof jm?y.aspect=w:y instanceof iA&&(y.left=-10*w,y.right=10*w,y.top=10,y.bottom=-10),y.updateProjectionMatrix(),f.setSize(a.current.clientWidth,a.current.clientHeight)}};return window.addEventListener("resize",M),()=>{d.current={position:y.position.clone(),quaternion:y.quaternion.clone(),up:y.up.clone()},window.removeEventListener("resize",M),cancelAnimationFrame(b),a.current&&f.domElement&&a.current.removeChild(f.domElement),f.dispose(),p.remove(x.current),window.__TSCIRCUIT_THREE_OBJECT===x.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[p,m,h,s]),G.jsx("div",{ref:a,style:{width:"100%",height:"100%",...o},children:c&&G.jsx(FKe.Provider,{value:c,children:G.jsx(Rbn,{children:t})})})}),gPn=({autoRotate:t,autoRotateSpeed:e,onStart:n,panSpeed:o,rotateSpeed:r,zoomSpeed:i,enableDamping:s,dampingFactor:a,target:c,onControlsChange:l})=>{const{camera:u,renderer:_}=c2(),d=te.useMemo(()=>!u||!_?null:new rvt(u,_.domElement),[u,_]);return te.useEffect(()=>(l?.(d??null),()=>l?.(null)),[d,l]),te.useEffect(()=>{if(!d)return;const m=()=>{l?.(d)};return d.addEventListener("change",m),()=>{d.removeEventListener("change",m)}},[d,l]),te.useEffect(()=>{d&&(d.autoRotate=t||!1,d.autoRotateSpeed=e||1,o!==void 0&&(d.panSpeed=o),r!==void 0&&(d.rotateSpeed=r),i!==void 0&&(d.zoomSpeed=i),s!==void 0&&(d.enableDamping=s),a!==void 0&&(d.dampingFactor=a),d.zoomToCursor=!0,d.mouseButtons={LEFT:Rb.ROTATE,MIDDLE:Rb.PAN,RIGHT:null},c&&(d.target.set(c[0],c[1],c[2]),d.update()))},[d,t,e,o,r,i,s,a,c]),te.useEffect(()=>{if(!(!d||!n))return d.addEventListener("start",n),()=>{d.removeEventListener("start",n)}},[d,n]),te.useEffect(()=>{if(d)return()=>{d.dispose()}},[d]),Gk(()=>{d?.update()},[d]),null},yPn=`
|
|
5150
5150
|
varying vec3 worldPosition;
|
|
5151
5151
|
void main() {
|
|
5152
5152
|
worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
@@ -5682,7 +5682,7 @@ test("${l} should solve problem correctly", () => {
|
|
|
5682
5682
|
// Add more specific assertions based on expected output
|
|
5683
5683
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5684
5684
|
})
|
|
5685
|
-
`,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},s_t=t=>t.activeSubSolver?[t,...s_t(t.activeSubSolver)]:[t],_Gn=({solver:t})=>{const e=s_t(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(uGn,{solver:n})]},n.constructor.name))})},dGn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=te.useReducer(p=>!p,!1),a=te.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};te.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(_Gn,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,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"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},hGn=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},mGn=(t,e)=>{const o=t.pipelineDef[e].solverName,r=hGn(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},pGn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},fGn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},xGn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),gGn=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=xGn(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},vge=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(vge);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=vge(o));return e},yGn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=vge(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},bGn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>mGn(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):yGn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(pGn,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(fGn,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(gGn,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},PGn=class extends ar.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function vGn({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var SGn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=te.useReducer(u=>u+1,0),s=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=te.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(dGn,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(PGn,{fallback:G.jsx(vGn,{graphics:s}),children:G.jsx(lGn,{graphics:s})}),c&&G.jsx(bGn,{solver:t,onStepUntilPhase:l})]})};const CGn=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},MGn=t=>t.toLowerCase().includes("pack")?wTn:t.toLowerCase().includes("rout")?NTn:gTn,TGn=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);CGn();const o=te.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=te.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=te.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=Wae[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Wae).join(", ")}`,classFound:!1};try{const c=i.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}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=MGn(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(q6,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(SGn,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},a_t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{yL.captureException(o)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{yL.captureException(r,{error_type:o.type})}catch{}}},[n])},c_t="0.0.1828",wGn={version:c_t},Sge={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Cge=new Map,NG=t=>{const e=Cge.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},EGn=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=Cge.get(n.name);if(o)return{type:"tracked",store:t,...o};const r={connection:e.connect(n),stores:{}};return Cge.set(n.name,r),{type:"tracked",store:t,...r}},l_t=(t,e={})=>(n,o,r)=>{const{enabled:i,anonymousActionType:s,store:a,...c}=e;let l;try{l=(i??(Sge?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(Sge?"production":void 0)!=="production"&&i&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,r);const{connection:u,..._}=EGn(a,l,c);let d=!0;r.setState=(p,x,f)=>{const g=n(p,x);if(!d)return g;const y=f===void 0?{type:s||"anonymous"}:typeof f=="string"?{type:f}:f;return a===void 0?(u?.send(y,o()),g):(u?.send({...y,type:`${a}/${y.type}`},{...NG(c.name),[a]:r.getState()}),g)};const m=(...p)=>{const x=d;d=!1,n(...p),d=x},h=t(r.setState,o,r);if(_.type==="untracked"?u?.init(h):(_.stores[_.store]=r,u?.init(Object.fromEntries(Object.entries(_.stores).map(([p,x])=>[p,p===_.store?h:x.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let p=!1;const x=r.dispatch;r.dispatch=(...f)=>{(Sge?"production":void 0)!=="production"&&f[0].type==="__setState"&&!p&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),p=!0),x(...f)}}return u.subscribe(p=>{var x;switch(p.type){case"ACTION":if(typeof p.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Mge(p.payload,f=>{if(f.type==="__setState"){if(a===void 0){m(f.state);return}Object.keys(f.state).length!==1&&console.error(`
|
|
5685
|
+
`,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},s_t=t=>t.activeSubSolver?[t,...s_t(t.activeSubSolver)]:[t],_Gn=({solver:t})=>{const e=s_t(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(uGn,{solver:n})]},n.constructor.name))})},dGn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=te.useReducer(p=>!p,!1),a=te.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};te.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(_Gn,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,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"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},hGn=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},mGn=(t,e)=>{const o=t.pipelineDef[e].solverName,r=hGn(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},pGn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},fGn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},xGn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),gGn=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=xGn(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},vge=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(vge);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=vge(o));return e},yGn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=vge(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},bGn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>mGn(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):yGn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(pGn,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(fGn,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(gGn,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},PGn=class extends ar.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function vGn({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var SGn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=te.useReducer(u=>u+1,0),s=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=te.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(dGn,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(PGn,{fallback:G.jsx(vGn,{graphics:s}),children:G.jsx(lGn,{graphics:s})}),c&&G.jsx(bGn,{solver:t,onStepUntilPhase:l})]})};const CGn=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},MGn=t=>t.toLowerCase().includes("pack")?wTn:t.toLowerCase().includes("rout")?NTn:gTn,TGn=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);CGn();const o=te.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=te.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=te.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=Wae[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Wae).join(", ")}`,classFound:!1};try{const c=i.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}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=MGn(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(q6,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(SGn,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},a_t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{yL.captureException(o)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{yL.captureException(r,{error_type:o.type})}catch{}}},[n])},c_t="0.0.1830",wGn={version:c_t},Sge={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Cge=new Map,NG=t=>{const e=Cge.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},EGn=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=Cge.get(n.name);if(o)return{type:"tracked",store:t,...o};const r={connection:e.connect(n),stores:{}};return Cge.set(n.name,r),{type:"tracked",store:t,...r}},l_t=(t,e={})=>(n,o,r)=>{const{enabled:i,anonymousActionType:s,store:a,...c}=e;let l;try{l=(i??(Sge?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(Sge?"production":void 0)!=="production"&&i&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,r);const{connection:u,..._}=EGn(a,l,c);let d=!0;r.setState=(p,x,f)=>{const g=n(p,x);if(!d)return g;const y=f===void 0?{type:s||"anonymous"}:typeof f=="string"?{type:f}:f;return a===void 0?(u?.send(y,o()),g):(u?.send({...y,type:`${a}/${y.type}`},{...NG(c.name),[a]:r.getState()}),g)};const m=(...p)=>{const x=d;d=!1,n(...p),d=x},h=t(r.setState,o,r);if(_.type==="untracked"?u?.init(h):(_.stores[_.store]=r,u?.init(Object.fromEntries(Object.entries(_.stores).map(([p,x])=>[p,p===_.store?h:x.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let p=!1;const x=r.dispatch;r.dispatch=(...f)=>{(Sge?"production":void 0)!=="production"&&f[0].type==="__setState"&&!p&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),p=!0),x(...f)}}return u.subscribe(p=>{var x;switch(p.type){case"ACTION":if(typeof p.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Mge(p.payload,f=>{if(f.type==="__setState"){if(a===void 0){m(f.state);return}Object.keys(f.state).length!==1&&console.error(`
|
|
5686
5686
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5687
5687
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5688
5688
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|