@tscircuit/runframe 0.0.1590 → 0.0.1591
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.
|
@@ -5131,7 +5131,7 @@ ${a.join(`
|
|
|
5131
5131
|
${E}polygon: ${C.polygon.vertices}
|
|
5132
5132
|
`:a+=`
|
|
5133
5133
|
`,C.children.length>0&&I.push(C.children)}return a}};A.exports=s}}),jhe=st({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(e,A){var t=Ohe(),i=Vhe(),n=class{constructor(o){this.polygonTree=new i,this.rootnode=new t(null),o&&this.addPolygons(o)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(o,s=!1){this.rootnode.clipTo(o,s)}allPolygons(){const o=[];return this.polygonTree.getPolygons(o),o}addPolygons(o){const s=new Array(o.length);for(let r=0;r<o.length;r++)s[r]=this.polygonTree.addChild(o[r]);this.rootnode.addPolygonTreeNodes(s)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}};A.exports=n}}),zQA=st({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(e,A){A.exports={Tree:jhe()}}}),zhe=st({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(e,A){var t=jo(),i=jQA(),{Tree:n}=zQA(),o=(s,r)=>{if(!i(s,r))return t.create();const a=new n(t.toPolygons(s)),g=new n(t.toPolygons(r));a.invert(),g.clipTo(a),g.invert(),a.clipTo(g),g.clipTo(a),a.addPolygons(g.allPolygons()),a.invert();const I=a.allPolygons();return t.create(I)};A.exports=o}}),ezA=st({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(e,A){var t=No(),i=AH(),n=zhe(),o=(...s)=>{s=t(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),Xhe=st({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(e,A){var t=No(),i=jo(),n=C_(),o=ZQA(),s=VQA(),r=ezA(),a=(...g)=>{g=t(g);const I=g.map(B=>s({z0:-1,z1:1},B)),c=r(I),l=n(c);return o(l,i.toPolygons(c))};A.exports=a}}),$he=st({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(e,A){var t=No(),i=$U(),n=Vo(),o=jo(),s=Xhe(),r=ezA(),a=(...g)=>{if(g=t(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only intersect of the types are supported");const I=g[0];return n.isA(I)?s(g):o.isA(I)?r(g):I};A.exports=a}}),Aue=st({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(e,A){var t=mn(),i=C_(),n=jo(),o=g=>g.sort((I,c)=>I-c).filter((I,c,l)=>!c||I!==l[c-1]),s=(g,I,c)=>{const l=`${I}`,B=g.get(l);B===void 0?g.set(l,[c]):B.push(c)},r=(g,I)=>{const c=`${I}`;return g.get(c)},a=g=>{const I=i(g),c=n.toPolygons(g),l=c.length,B=new Map,C=t.create();c.forEach((d,f)=>{d.vertices.forEach(m=>{s(B,t.snap(C,m,I),f)})});const E=c.map(d=>{let f=[];return d.vertices.forEach(m=>{f=f.concat(r(B,t.snap(C,m,I)))}),{e:1,d:o(f)}});B.clear();let Q=0;const h=E.length;for(let d=0;d<h;d++){const f=E[d];if(f.e>0){const m=new Array(l);m[d]=!0;do Q=0,m.forEach((w,D)=>{const b=E[D];if(b.e>0){b.e=-1;for(let k=0;k<b.d.length;k++)m[b.d[k]]=!0;Q++}});while(Q>0);f.indexes=m}}const u=[];for(let d=0;d<h;d++)if(E[d].indexes){const f=[];E[d].indexes.forEach((m,w)=>f.push(c[w])),u.push(n.create(f))}return u};A.exports=a}}),tue=st({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(e,A){var t=No(),i=jo(),n=Aue(),o=(...s)=>{if(s=t(s),s.length===0)throw new Error("wrong number of arguments");const r=s.map(a=>i.isA(a)?n(a):a);return r.length===1?r[0]:r};A.exports=o}}),eue=st({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(e,A){var t=jo(),i=jQA(),{Tree:n}=zQA(),o=(s,r)=>{if(!i(s,r))return t.clone(s);const a=new n(t.toPolygons(s)),g=new n(t.toPolygons(r));a.invert(),a.clipTo(g),g.clipTo(a,!0),a.addPolygons(g.allPolygons()),a.invert();const I=a.allPolygons();return t.create(I)};A.exports=o}}),izA=st({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(e,A){var t=No(),i=AH(),n=eue(),o=(...s)=>{s=t(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),iue=st({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(e,A){var t=No(),i=jo(),n=C_(),o=ZQA(),s=VQA(),r=izA(),a=(...g)=>{g=t(g);const I=g.map(B=>s({z0:-1,z1:1},B)),c=r(I),l=n(c);return o(l,i.toPolygons(c))};A.exports=a}}),nue=st({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(e,A){var t=No(),i=$U(),n=Vo(),o=jo(),s=iue(),r=izA(),a=(...g)=>{if(g=t(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only subtract of the types are supported");const I=g[0];return n.isA(I)?s(g):o.isA(I)?r(g):I};A.exports=a}}),nzA=st({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(e,A){var t=jo(),i=jQA(),{Tree:n}=zQA(),o=(r,a)=>{if(!i(r,a))return s(r,a);const g=new n(t.toPolygons(r)),I=new n(t.toPolygons(a));g.clipTo(I,!1),I.clipTo(g),I.invert(),I.clipTo(g),I.invert();const c=g.allPolygons().concat(I.allPolygons());return t.create(c)},s=(r,a)=>{let g=t.toPolygons(r);return g=g.concat(t.toPolygons(a)),t.create(g)};A.exports=o}}),ozA=st({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(e,A){var t=No(),i=AH(),n=nzA(),o=(...s)=>{s=t(s);let r;for(r=1;r<s.length;r+=2)s.push(n(s[r-1],s[r]));let a=s[r-1];return a=i(a),a};A.exports=o}}),szA=st({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(e,A){var t=No(),i=jo(),n=C_(),o=ZQA(),s=VQA(),r=ozA(),a=(...g)=>{g=t(g);const I=g.map(B=>s({z0:-1,z1:1},B)),c=r(I),l=n(c);return o(l,i.toPolygons(c))};A.exports=a}}),XQA=st({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(e,A){var t=No(),i=$U(),n=Vo(),o=jo(),s=szA(),r=ozA(),a=(...g)=>{if(g=t(g),g.length===0)throw new Error("wrong number of arguments");if(!i(g))throw new Error("only unions of the same type are supported");const I=g[0];return n.isA(I)?s(g):o.isA(I)?r(g):I};A.exports=a}}),PN=st({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(e,A){A.exports={intersect:$he(),scission:tue(),subtract:nue(),union:XQA()}}}),V8=st({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(e,A){var{EPS:t,TAU:i}=fr(),n=NjA(),o=TQA(),s=ps(),r=O8(),a=(g,I)=>{const c={delta:1,corners:"edge",closed:!1,segments:16};let{delta:l,corners:B,closed:C,segments:E}=Object.assign({},c,g);if(Math.abs(l)<t)return I;let Q=g.closed?r(I):1;Q===0&&(Q=1);const h=Q>0&&l>=0||Q<0&&l<0;l=Math.abs(l);let u=null,d=[];const f=[],m=s.create(),w=I.length;for(let D=0;D<w;D++){const b=(D+1)%w,k=I[D],x=I[b];h?s.subtract(m,k,x):s.subtract(m,x,k),s.normal(m,m),s.normalize(m,m),s.scale(m,m,l);const N=s.add(s.create(),k,m),R=s.add(s.create(),x,m),U=[N,R];if(u!=null&&(C||!C&&b!==0)){const Y=n(u[0],u[1],U[0],U[1]);Y?(d.pop(),U[0]=Y):f.push({c:k,s0:u,s1:U})}u=[N,R],!(b===0&&!C)&&(d.push(U[0]),d.push(U[1]))}if(C&&u!=null){const D=d[0],b=d[1],k=n(u[0],u[1],D,b);if(k)d[0]=k,d.pop();else{const x=I[0],N=[D,b];f.push({c:x,s0:u,s1:N})}}if(B==="edge"){const D=new Map;d.forEach((x,N)=>D.set(x,N));const b=o.create(),k=o.create();f.forEach(x=>{o.fromPoints(b,x.s0[0],x.s0[1]),o.fromPoints(k,x.s1[0],x.s1[1]);const N=o.intersectPointOfLines(b,k);if(Number.isFinite(N[0])&&Number.isFinite(N[1])){const R=x.s0[1],U=D.get(R);d[U]=N,d[(U+1)%d.length]=void 0}else{const R=x.s1[0],U=D.get(R);d[U]=void 0}}),d=d.filter(x=>x!==void 0)}if(B==="round"){let D=Math.floor(E/4);const b=s.create();f.forEach(k=>{let x=s.angle(s.subtract(b,k.s1[0],k.c));if(x-=s.angle(s.subtract(b,k.s0[1],k.c)),h&&x<0&&(x=x+Math.PI,x<0&&(x=x+Math.PI)),!h&&x>0&&(x=x-Math.PI,x>0&&(x=x-Math.PI)),x!==0){D=Math.floor(E*(Math.abs(x)/i));const N=x/D,R=s.angle(s.subtract(b,k.s0[1],k.c)),U=[];for(let Y=1;Y<D;Y++){const H=R+N*Y,O=s.fromAngleRadians(s.create(),H);s.scale(O,O,l),s.add(O,O,k.c),U.push(O)}if(U.length>0){const Y=k.s0[1];let H=d.findIndex(O=>s.equals(Y,O));H=(H+1)%d.length,d.splice(H,0,...U)}}else{const N=k.s1[0],R=d.findIndex(U=>s.equals(N,U));d.splice(R,1)}})}return d};A.exports=a}}),oue=st({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(e,A){var t=Vo(),i=V8(),n=(o,s)=>{const r={delta:1,corners:"edge",segments:16},{delta:a,corners:g,segments:I}=Object.assign({},r,o);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const B=t.toOutlines(s).map(C=>(o={delta:a,corners:g,closed:!0,segments:I},i(o,C))).reduce((C,E)=>C.concat(t.toSides(t.fromPoints(E))),[]);return t.create(B)};A.exports=n}}),sue=st({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(e,A){var t=Og(),i=mn(),n=jo(),o=or(),s=(r,a)=>{i.dot(o.plane(a),r)>0&&(a=o.invert(a));const I=[a],c=o.transform(t.fromTranslation(t.create(),r),a),l=a.vertices.length;for(let B=0;B<l;B++){const C=B<l-1?B+1:0,E=o.create([a.vertices[B],c.vertices[B],c.vertices[C],a.vertices[C]]);I.push(E)}return I.push(o.invert(c)),n.create(I)};A.exports=s}}),rue=st({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(e,A){var{EPS:t,TAU:i}=fr(),n=Og(),o=mn(),s=AzA(),r=jo(),a=or(),g=WjA(),I=AH(),c=nzA(),l=sue(),B=(h,u,d)=>{const f=u.toString();if(h.has(f))h.get(f)[1].push(d);else{const m=[u,[d]];h.set(f,m)}},C=(h,u,d)=>{const f=u[0].toString(),m=u[1].toString(),w=f<m?`${f},${m}`:`${m},${f}`;if(h.has(w))h.get(w)[1].push(d);else{const D=[u,[d]];h.set(w,D)}},E=(h,u)=>{h.findIndex(f=>f===u)<0&&h.push(u)},Q=(h,u)=>{const d={delta:1,segments:12},{delta:f,segments:m}=Object.assign({},d,h);let w=r.create();const D=new Map,b=new Map,k=o.create(),x=o.create();return r.toPolygons(u).forEach((R,U)=>{const Y=o.scale(o.create(),a.plane(R),2*f),H=a.transform(n.fromTranslation(n.create(),o.scale(o.create(),Y,-.5)),R),O=l(Y,H);w=c(w,O);const W=R.vertices;for(let $=0;$<W.length;$++){B(D,W[$],a.plane(R));const iA=($+1)%W.length,rA=[W[$],W[iA]];C(b,rA,a.plane(R))}}),b.forEach(R=>{const U=R[0],Y=R[1],H=U[0],O=U[1],W=o.subtract(o.create(),O,H);o.normalize(W,W);const $=Y[0],iA=o.cross(o.create(),$,W);let rA=[];for(let KA=0;KA<m;KA++)E(rA,KA*i/m);for(let KA=0,hA=Y.length;KA<hA;KA++){const GA=Y[KA],dA=o.dot(iA,GA),PA=o.dot($,GA);let JA=Math.atan2(dA,PA);JA<0&&(JA+=i),E(rA,JA),JA=Math.atan2(-dA,-PA),JA<0&&(JA+=i),E(rA,JA)}rA=rA.sort(s);const tA=rA.length;let oA,aA;const QA=[],SA=[],FA=[];for(let KA=-1;KA<tA;KA++){const hA=rA[KA<0?KA+tA:KA],GA=Math.sin(hA),dA=Math.cos(hA);o.scale(k,$,dA*f),o.scale(x,iA,GA*f),o.add(k,k,x);const PA=o.add(o.create(),H,k),JA=o.add(o.create(),O,k);let it=!1;if(KA>=0&&o.distance(PA,oA)<t&&(it=!0),!it){if(KA>=0){QA.push(PA),SA.push(JA);const fA=[aA,JA,PA,oA],tt=a.create(fA);FA.push(tt)}oA=PA,aA=JA}}SA.reverse(),FA.push(a.create(QA)),FA.push(a.create(SA));const MA=r.create(FA);w=c(w,MA)}),D.forEach(R=>{const U=R[0],Y=R[1],H=Y[0];let O=null,W=0;for(let tA=1;tA<Y.length;tA++){const oA=Y[tA],aA=o.cross(k,H,oA),QA=o.length(aA);QA>.05&&QA>W&&(W=QA,O=oA)}O||(O=o.orthogonal(k,H));const $=o.cross(k,H,O);o.normalize($,$);const iA=o.cross(x,$,H),rA=g({center:[U[0],U[1],U[2]],radius:f,segments:m,axes:[H,$,iA]});w=c(w,rA)}),I(w)};A.exports=Q}}),aue=st({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(e,A){var t=jo(),i=XQA(),n=rue(),o=(s,r)=>{const a={delta:1,corners:"round",segments:12},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(I!=="round")throw new Error('corners must be "round" for 3D geometries');if(t.toPolygons(r).length===0)throw new Error("the given geometry cannot be empty");s={delta:g,corners:I,segments:c};const B=n(s,r);return i(r,B)};A.exports=o}}),gue=st({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(e,A){var t=O8(),i=ps(),n=Vo(),o=Dg(),s=V8(),r=I=>{let{external:c,internal:l}=I;t(c)<0?c=c.reverse():l=l.reverse();const B=o.fromPoints({closed:!0},c),C=o.fromPoints({closed:!0},l),E=n.toSides(n.fromPoints(o.toPoints(B))),Q=n.toSides(n.fromPoints(o.toPoints(C)));return E.push(...Q),n.create(E)},a=(I,c,l,B)=>{const{points:C,external:E,internal:Q}=I,h=Math.floor(c/2),u=[],d=[];if(l==="round"&&h>0){const m=Math.PI/h,w=C[C.length-1],D=i.angle(i.subtract(i.create(),E[E.length-1],w)),b=C[0],k=i.angle(i.subtract(i.create(),Q[0],b));for(let x=1;x<h;x++){let N=D+m*x,R=i.fromAngleRadians(i.create(),N);i.scale(R,R,B),i.add(R,R,w),u.push(R),N=k+m*x,R=i.fromAngleRadians(i.create(),N),i.scale(R,R,B),i.add(R,R,b),d.push(R)}}const f=[];return f.push(...E,...u,...Q.reverse(),...d),n.fromPoints(f)},g=(I,c)=>{I=Object.assign({},{delta:1,corners:"edge",segments:16},I);const{delta:B,corners:C,segments:E}=I;if(B<=0)throw new Error("the given delta must be positive for paths");if(!(C==="edge"||C==="chamfer"||C==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const Q=c.isClosed,h=o.toPoints(c);if(h.length===0)throw new Error("the given geometry cannot be empty");const u={points:h,external:s({delta:B,corners:C,segments:E,closed:Q},h),internal:s({delta:-B,corners:C,segments:E,closed:Q},h)};return c.isClosed?r(u):a(u,E,C,B)};A.exports=g}}),$QA=st({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(e,A){var t=No(),i=Vo(),n=jo(),o=Dg(),s=oue(),r=aue(),a=gue(),g=(I,...c)=>{if(c=t(c),c.length===0)throw new Error("wrong number of arguments");const l=c.map(B=>o.isA(B)?a(I,B):i.isA(B)?s(I,B):n.isA(B)?r(I,B):B);return l.length===1?l[0]:l};A.exports=g}}),Iue=st({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(e,A){var t=Vo(),i=LQA(),n=V8(),o=(s,r)=>{const a={delta:1,corners:"edge",segments:0},{delta:g,corners:I,segments:c}=Object.assign({},a,s);if(!(I==="edge"||I==="chamfer"||I==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const l=t.toOutlines(r),C=l.map(E=>(s={delta:l.reduce((u,d)=>u+i.arePointsInside(E,i.create(d)),0)%2===0?g:-g,corners:I,closed:!0,segments:c},n(s,E))).reduce((E,Q)=>E.concat(t.toSides(t.fromPoints(Q))),[]);return t.create(C)};A.exports=o}}),cue=st({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(e,A){var t=Dg(),i=V8(),n=(o,s)=>{const r={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:a,corners:g,closed:I,segments:c}=Object.assign({},r,o);if(!(g==="edge"||g==="chamfer"||g==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');o={delta:a,corners:g,closed:I,segments:c};const l=i(o,t.toPoints(s));return t.fromPoints({closed:I},l)};A.exports=n}}),lue=st({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(e,A){var t=No(),i=Vo(),n=Dg(),o=Iue(),s=cue(),r=(a,...g)=>{if(g=t(g),g.length===0)throw new Error("wrong number of arguments");const I=g.map(c=>n.isA(c)?s(a,c):i.isA(c)?o(a,c):c);return I.length===1?I[0]:I};A.exports=r}}),rzA=st({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(e,A){A.exports={expand:$QA(),offset:lue()}}}),j8=st({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(e,A){var t=Og(),i=mn(),n=Vo(),o=KN(),s=Z8(),r=(a,g)=>{const I={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:c,twistAngle:l,twistSteps:B,repair:C}=Object.assign({},I,a);if(B<1)throw new Error("twistSteps must be 1 or more");l===0&&(B=1);const E=i.clone(c),Q=n.toSides(g);if(Q.length===0)throw new Error("the given geometry cannot be empty");const h=o.fromSides(Q);E[2]<0&&o.reverse(h,h);const u=t.create(),d=(f,m,w)=>{const D=m/B*l,b=i.scale(i.create(),E,m/B);return t.multiply(u,t.fromZRotation(u,D),t.fromTranslation(t.create(),b)),o.transform(u,w)};return a={numberOfSlices:B+1,capStart:!0,capEnd:!0,repair:C,callback:d},s(a,h)};A.exports=r}}),Bue=st({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(e,A){var t=Vo(),i=Dg(),n=j8(),o=(s,r)=>{if(!r.isClosed)throw new Error("extruded path must be closed");const a=i.toPoints(r),g=t.fromPoints(a);return n(s,g)};A.exports=o}}),Cue=st({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(e,A){var t=No(),i=Vo(),n=Dg(),o=j8(),s=Bue(),r=(a,...g)=>{const I={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:c,twistAngle:l,twistSteps:B,repair:C}=Object.assign({},I,a);if(g=t(g),g.length===0)throw new Error("wrong number of arguments");a={offset:[0,0,c],twistAngle:l,twistSteps:B,repair:C};const E=g.map(Q=>n.isA(Q)?s(a,Q):i.isA(Q)?o(a,Q):Q);return E.length===1?E[0]:E};A.exports=r}}),Que=st({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(e,A){var t=Dg(),i=$QA(),n=j8(),o=(s,r)=>{const a={size:1,height:1},{size:g,height:I}=Object.assign({},a,s);if(s.delta=g,s.offset=[0,0,I],t.toPoints(r).length===0)throw new Error("the given geometry cannot be empty");const l=i(s,r);return n(s,l)};A.exports=o}}),Eue=st({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(e,A){var{area:t}=VU(),i=Vo(),n=Dg(),o=$QA(),s=j8(),r=(a,g)=>{const I={size:1,height:1},{size:c,height:l}=Object.assign({},I,a);a.delta=c,a.offset=[0,0,l];const B=i.toOutlines(g);if(B.length===0)throw new Error("the given geometry cannot be empty");const E=B.map(h=>(t(h)<0&&h.reverse(),o(a,n.fromPoints({closed:!0},h)))).reduce((h,u)=>h.concat(i.toSides(u)),[]),Q=i.create(E);return s(a,Q)};A.exports=r}}),hue=st({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(e,A){var t=No(),i=Vo(),n=Dg(),o=Que(),s=Eue(),r=(a,...g)=>{const I={size:1,height:1},{size:c,height:l}=Object.assign({},I,a);if(g=t(g),g.length===0)throw new Error("wrong number of arguments");if(c<=0)throw new Error("size must be positive");if(l<=0)throw new Error("height must be positive");const B=g.map(C=>n.isA(C)?o(a,C):i.isA(C)?s(a,C):C);return B.length===1?B[0]:B};A.exports=r}}),uue=st({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(e,A){var{TAU:t}=fr(),i=Og(),n=Vo(),o=Z8(),s=KN(),r=(a,g)=>{const I={angle:t,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:c,startAngle:l,pitch:B,height:C,endOffset:E,segmentsPerRotation:Q}=Object.assign({},I,a);if(C!=0&&(B=C/(c/t)),Q<3)throw new Error("The number of segments per rotation needs to be at least 3.");const u=n.toSides(g);if(u.length===0)throw new Error("The given geometry cannot be empty");const d=u.filter(x=>x[0][0]>=0);let f=s.fromSides(u);d.length===0&&(f=s.reverse(f));const m=Math.round(Q/t*Math.abs(c)),w=m>=2?m:2,D=i.create(),b=i.create(),k=(x,N,R)=>{const U=l+c/w*N,Y=E/w*N,H=(U-l)/t*B;return i.multiply(D,i.fromTranslation(i.create(),[Y,0,H*Math.sign(c)]),i.fromXRotation(i.create(),-t/4*Math.sign(c))),i.multiply(b,i.fromZRotation(i.create(),U),D),s.transform(b,R)};return o({numberOfSlices:w+1,callback:k},f)};A.exports=r}}),due=st({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(e,A){var t=No(),i=JQA(),n=aD(),o=Og(),s=Vo(),r=jo(),a=or(),g=C_(),I=szA(),c=(B,C)=>{const E=n.fromNormalAndPoint(n.create(),B.axis,B.origin);if(Number.isNaN(E[0])||Number.isNaN(E[1])||Number.isNaN(E[2])||Number.isNaN(E[3]))throw new Error("project: invalid axis or origin");const Q=g(C),h=Q*Q*Math.sqrt(3)/4;if(Q===0)return s.create();const u=r.toPolygons(C);let d=[];for(let m=0;m<u.length;m++){const w=u[m].vertices.map(k=>n.projectionOfPoint(E,k)),D=a.create(w),b=a.plane(D);i(E,b)&&(a.measureArea(D)<h||d.push(D))}if(!i(E,[0,0,1])){const m=o.fromVectorRotation(o.create(),E,[0,0,1]);d=d.map(w=>a.transform(m,w))}d=d.sort((m,w)=>a.measureArea(w)-a.measureArea(m));const f=d.map(m=>s.fromPoints(m.vertices));return I(f)},l=(B,...C)=>{const E={axis:[0,0,1],origin:[0,0,0]},{axis:Q,origin:h}=Object.assign({},E,B);if(C=t(C),C.length===0)throw new Error("wrong number of arguments");B={axis:Q,origin:h};const u=C.map(d=>r.isA(d)?c(B,d):d);return u.length===1?u[0]:u};A.exports=l}}),tH=st({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(e,A){A.exports={extrudeFromSlices:Z8(),extrudeLinear:Cue(),extrudeRectangular:hue(),extrudeRotate:zjA(),extrudeHelical:uue(),project:due(),slice:KN()}}}),AEA=st({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(e,A){var t=ps(),i=s=>{let r=t.fromValues(1/0,1/0);s.forEach(I=>{(I[1]<r[1]||I[1]===r[1]&&I[0]<r[0])&&(r=I)});const a=[];s.forEach(I=>{const c=o(I[1]-r[1],I[0]-r[0]),l=t.squaredDistance(I,r);a.push({point:I,angle:c,distSq:l})}),a.sort((I,c)=>I.angle!==c.angle?I.angle-c.angle:I.distSq-c.distSq);const g=[];return a.forEach(I=>{let c=g.length;for(;c>1&&n(g[c-2],g[c-1],I.point)<=Number.EPSILON;)g.pop(),c=g.length;g.push(I.point)}),g},n=(s,r,a)=>(r[0]-s[0])*(a[1]-s[1])-(r[1]-s[1])*(a[0]-s[0]),o=(s,r)=>s===0&&r===0?-1/0:-r/s;A.exports=i}}),tEA=st({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(e,A){var t=Vo(),i=jo(),n=Dg(),o=s=>{const r=new Set,a=[],g=I=>{const c=I.toString();r.has(c)||(a.push(I),r.add(c))};return s.forEach(I=>{t.isA(I)?t.toPoints(I).forEach(g):i.isA(I)?i.toPoints(I).forEach(c=>c.forEach(g)):n.isA(I)&&n.toPoints(I).forEach(g)}),a};A.exports=o}}),pue=st({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(e,A){var t=No(),i=Dg(),n=AEA(),o=tEA(),s=(...r)=>{r=t(r);const a=o(r),g=n(a);return i.fromPoints({closed:!0},g)};A.exports=s}}),fue=st({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(e,A){var t=No(),i=Vo(),n=AEA(),o=tEA(),s=(...r)=>{r=t(r);const a=o(r),g=n(a);return g.length<3?i.create():i.fromPoints(g)};A.exports=s}}),azA=st({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(e,A){var t=or(),i=sjA(),n=o=>i(o,{skipTriangulation:!0}).map(a=>{const g=a.map(I=>o[I]);return t.create(g)});A.exports=n}}),yue=st({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(e,A){var t=No(),i=jo(),n=tEA(),o=azA(),s=(...r)=>{r=t(r);const a=n(r);return a.length===0?i.create():i.create(o(a))};A.exports=s}}),gzA=st({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(e,A){var t=No(),i=$U(),n=Vo(),o=jo(),s=Dg(),r=pue(),a=fue(),g=yue(),I=(...c)=>{if(c=t(c),c.length===0)throw new Error("wrong number of arguments");if(!i(c))throw new Error("only hulls of the same type are supported");const l=c[0];return s.isA(l)?r(c):n.isA(l)?a(c):o.isA(l)?g(c):l};A.exports=I}}),mue=st({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(e,A){var t=No(),i=XQA(),n=gzA(),o=(...s)=>{if(s=t(s),s.length<2)throw new Error("wrong number of arguments");const r=[];for(let a=1;a<s.length;a++)r.push(n(s[a-1],s[a]));return i(r)};A.exports=o}}),wue=st({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(e,A){A.exports={hull:gzA(),hullChain:mue(),hullPoints2:AEA(),hullPoints3:azA()}}}),IzA=st({"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(e,A){var t=mn(),i=or(),n=(s,r)=>{const a=Math.abs(i.measureArea(r));return Number.isFinite(a)&&a>s},o=(s,r)=>{let a=r.map(I=>{const c=I.vertices.map(C=>t.snap(t.create(),C,s)),l=[];for(let C=0;C<c.length;C++){const E=(C+1)%c.length;t.equals(c[C],c[E])||l.push(c[C])}const B=i.create(l);return I.color&&(B.color=I.color),B});const g=s*s*Math.sqrt(3)/4;return a=a.filter(I=>n(g,I)),a};A.exports=o}}),Due=st({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(e,A){var t=JQA(),i=mn(),n=or(),o=h=>{const u=n.toPoints(h),d=[];for(let f=0;f<u.length;f++){const m=(f+1)%u.length,w={v1:u[f],v2:u[m]};d.push(w)}for(let f=0;f<d.length;f++){const m=(f+1)%u.length;d[f].next=d[m],d[m].prev=d[f]}return d},s=(h,u)=>{const d=`${u.v1}:${u.v2}`;h.set(d,u)},r=(h,u)=>{const d=`${u.v1}:${u.v2}`;h.delete(d)},a=(h,u)=>{const d=`${u.v2}:${u.v1}`;return h.get(d)},g=(h,u,d)=>{let f=h.prev.v1,m=h.prev.v2,w=u.next.v2;const D=l(f,m,w,d);f=u.prev.v1,m=u.prev.v2,w=h.next.v2;const b=l(f,m,w,d);return[D,b]},I=i.create(),c=i.create(),l=(h,u,d,f)=>{const m=i.subtract(I,u,h),w=i.subtract(c,d,u);return i.cross(m,m,w),i.dot(m,f)},B=h=>{let u;const d=[];for(;h.next;){const f=h.next;d.push(h.v1),h.v1=null,h.v2=null,h.next=null,h.prev=null,h=f}return d.length>0&&(u=n.create(d)),u},C=h=>{if(h.length<2)return h;const u=h[0].plane,d=h.slice(),f=new Map;for(;d.length>0;){const w=d.shift(),D=o(w);for(let b=0;b<D.length;b++){const k=D[b],x=a(f,k);if(x){const N=g(k,x,u);if(N[0]>=0&&N[1]>=0){const R=x.next,U=k.next;k.prev.next=x.next,k.next.prev=x.prev,x.prev.next=k.next,x.next.prev=k.prev,k.v1=null,k.v2=null,k.next=null,k.prev=null,r(f,x),x.v1=null,x.v2=null,x.next=null,x.prev=null;const Y=(H,O,W)=>{const $={v1:W.v1,v2:O.v2,next:O.next,prev:W.prev};W.prev.next=$,O.next.prev=$,r(H,O),O.v1=null,O.v2=null,O.next=null,O.prev=null,r(H,W),W.v1=null,W.v2=null,W.next=null,W.prev=null};N[0]===0&&Y(f,R,R.prev),N[1]===0&&Y(f,U,U.prev)}}else k.next&&s(f,k)}}const m=[];return f.forEach(w=>{const D=B(w);D&&m.push(D)}),f.clear(),m},E=(h,u)=>Math.abs(h[3]-u[3])<15e-8?t(h,u):!1,Q=(h,u)=>{const d=[];u.forEach(m=>{const w=d.find(D=>E(D[0],n.plane(m)));w?w[1].push(m):d.push([n.plane(m),[m]])});let f=[];return d.forEach(m=>{const w=m[1],D=C(w);f=f.concat(D)}),f};A.exports=Q}}),Sue=st({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(e,A){var t=fr(),i=mn(),n=or(),o=g=>`${g}`,s=(g,I,c,l,B,C)=>{const E=o(l),Q=o(B),h=`${E}/${Q}`,u=`${Q}/${E}`;if(g.has(u))return r(g,I,c,B,l,null),null;const d={vertex0:l,vertex1:B,polygonindex:C};return g.has(h)?g.get(h).push(d):g.set(h,[d]),I.has(E)?I.get(E).push(h):I.set(E,[h]),c.has(Q)?c.get(Q).push(h):c.set(Q,[h]),h},r=(g,I,c,l,B,C)=>{const E=o(l),Q=o(B),h=`${E}/${Q}`;let u=-1;const d=g.get(h);for(let f=0;f<d.length;f++){const m=d[f];let w=o(m.vertex0);if(w===E&&(w=o(m.vertex1),w===Q&&!(C!==null&&m.polygonindex!==C))){u=f;break}}d.splice(u,1),d.length===0&&g.delete(h),u=I.get(E).indexOf(h),I.get(E).splice(u,1),I.get(E).length===0&&I.delete(E),u=c.get(Q).indexOf(h),c.get(Q).splice(u,1),c.get(Q).length===0&&c.delete(Q)},a=g=>{const I=new Map;for(let c=0;c<g.length;c++){const l=g[c],B=l.vertices.length;if(B>=3){let C=l.vertices[0],E=o(C);for(let Q=0;Q<B;Q++){let h=Q+1;h===B&&(h=0);const u=l.vertices[h],d=o(u),f=`${E}/${d}`,m=`${d}/${E}`;if(I.has(m)){const w=I.get(m);w.splice(-1,1),w.length===0&&I.delete(m)}else{const w={vertex0:C,vertex1:u,polygonindex:c};I.has(f)?I.get(f).push(w):I.set(f,[w])}C=u,E=d}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(I.size>0){const c=new Map,l=new Map,B=new Map;for(const[E,Q]of I)B.set(E,!0),Q.forEach(h=>{const u=o(h.vertex0),d=o(h.vertex1);c.has(u)?c.get(u).push(E):c.set(u,[E]),l.has(d)?l.get(d).push(E):l.set(d,[E])});const C=g.slice(0);for(;I.size!==0;){for(const Q of I.keys())B.set(Q,!0);let E=!1;for(;;){const Q=Array.from(B.keys());if(Q.length===0)break;const h=Q[0];let u=!0;if(I.has(h)){const f=I.get(h)[0];for(let m=0;m<2;m++){const w=m===0?f.vertex0:f.vertex1,D=m===0?f.vertex1:f.vertex0,b=o(w),k=o(D);let x=[];m===0?l.has(b)&&(x=l.get(b)):c.has(b)&&(x=c.get(b));for(let N=0;N<x.length;N++){const R=x[N],U=I.get(R)[0],Y=m===0?U.vertex0:U.vertex1;if(m===0?U.vertex1:U.vertex0,o(Y)===k){r(I,c,l,w,D,null),r(I,c,l,D,w,null),u=!1,m=2,E=!0;break}else{const O=w,W=D,$=Y,iA=i.subtract(i.create(),$,O),rA=i.dot(i.subtract(i.create(),W,O),iA)/i.dot(iA,iA);if(rA>0&&rA<1){const tA=i.scale(i.create(),iA,rA);if(i.add(tA,tA,O),i.squaredDistance(tA,W)<t.EPS*t.EPS){const aA=U.polygonindex,QA=C[aA],SA=o(U.vertex1);let FA=-1;for(let dA=0;dA<QA.vertices.length;dA++)if(o(QA.vertices[dA])===SA){FA=dA;break}const MA=QA.vertices.slice(0);MA.splice(FA,0,D);const KA=n.create(MA);C[aA]=KA,r(I,c,l,U.vertex0,U.vertex1,aA);const hA=s(I,c,l,U.vertex0,D,aA),GA=s(I,c,l,D,U.vertex1,aA);hA!==null&&B.set(hA,!0),GA!==null&&B.set(GA,!0),u=!1,m=2,E=!0;break}}}}}}u&&B.delete(h)}if(!E)break}g=C}return I.clear(),g};A.exports=a}}),bue=st({"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(e,A){var t=mn(),i=or(),n=(s,r,a)=>{const g=r.vertices.length;if(g>3){if(g>4){const l=[0,0,0];r.vertices.forEach(B=>t.add(l,l,B)),t.snap(l,t.divide(l,l,[g,g,g]),s);for(let B=0;B<g;B++){const C=i.create([l,r.vertices[B],r.vertices[(B+1)%g]]);r.color&&(C.color=r.color),a.push(C)}return}const I=i.create([r.vertices[0],r.vertices[1],r.vertices[2]]),c=i.create([r.vertices[0],r.vertices[2],r.vertices[3]]);r.color&&(I.color=r.color,c.color=r.color),a.push(I,c);return}a.push(r)},o=(s,r)=>{const a=[];return r.forEach(g=>{n(s,g,a)}),a};A.exports=o}}),xue=st({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(e,A){var t=No(),i=C_(),n=Vo(),o=jo(),s=Dg(),r=IzA(),a=Due(),g=Sue(),I=bue(),c=(E,Q)=>Q,l=(E,Q)=>Q,B=(E,Q)=>{const h={snap:!1,simplify:!1,triangulate:!1},{snap:u,simplify:d,triangulate:f}=Object.assign({},h,E),m=i(Q);let w=o.toPolygons(Q);u&&(w=r(m,w)),d&&(w=a(m,w)),f&&(w=g(w),w=I(m,w));const D=Object.assign({},Q);return D.polygons=w,D},C=(E,...Q)=>{if(Q=t(Q),Q.length===0)throw new Error("wrong number of arguments");const h=Q.map(u=>{if(s.isA(u))return c(E,u);if(n.isA(u))return l(E,u);if(o.isA(u))return B(E,u);throw new Error("invalid geometry")});return h.length===1?h[0]:h};A.exports=C}}),_ue=st({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(e,A){var t=No(),i=ps(),n=Vo(),o=jo(),s=Dg(),r=C_(),a=IzA(),g=B=>{const C=r(B),Q=s.toPoints(B).map(h=>i.snap(i.create(),h,C));return s.create(Q)},I=B=>{const C=r(B);let Q=n.toSides(B).map(h=>[i.snap(i.create(),h[0],C),i.snap(i.create(),h[1],C)]);return Q=Q.filter(h=>!i.equals(h[0],h[1])),n.create(Q)},c=B=>{const C=r(B),E=o.toPolygons(B),Q=a(C,E);return o.create(Q)},l=(...B)=>{if(B=t(B),B.length===0)throw new Error("wrong number of arguments");const C=B.map(E=>s.isA(E)?g(E):n.isA(E)?I(E):o.isA(E)?c(E):E);return C.length===1?C[0]:C};A.exports=l}}),kue=st({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(e,A){A.exports={generalize:xue(),snap:_ue(),retessellate:AH()}}}),Gue=st({"node_modules/@jscad/modeling/src/utils/padArrayToLength.js"(e,A){var t=(i,n,o)=>{for(i=i.slice();i.length<o;)i.push(n);return i};A.exports=t}}),Fue=st({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(e,A){var t=No(),i=Gue(),n=KQA(),{translate:o}=OG(),s=I=>{if(!Array.isArray(I.modes)||I.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(I.modes=i(I.modes,"none",3),I.modes.filter(c=>["center","max","min","none"].includes(c)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(I.relativeTo)||I.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(I.relativeTo=i(I.relativeTo,0,3),I.relativeTo.filter(c=>Number.isFinite(c)||c==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof I.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return I},r=(I,c,l)=>{for(let B=0;B<3;B++)I[B]==null&&(c[B]==="center"?I[B]=(l[0][B]+l[1][B])/2:c[B]==="max"?I[B]=l[1][B]:c[B]==="min"&&(I[B]=l[0][B]));return I},a=(I,c,l)=>{const B=n(I),C=[0,0,0];for(let E=0;E<3;E++)c[E]==="center"?C[E]=l[E]-(B[0][E]+B[1][E])/2:c[E]==="max"?C[E]=l[E]-B[1][E]:c[E]==="min"&&(C[E]=l[E]-B[0][E]);return o(C,I)},g=(I,...c)=>{I=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},I),I=s(I);let{modes:B,relativeTo:C,grouped:E}=I;if(c=t(c),c.length===0)throw new Error("align(): No geometries were provided to act upon");if(C.filter(Q=>Q==null).length){const Q=n(c);C=r(C,B,Q)}return E?c=a(c,B,C):c=c.map(Q=>a(Q,B,C)),c.length===1?c[0]:c};A.exports=g}}),z8=st({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(e,A){var t=No(),i=Vo(),n=jo(),o=Dg(),s=PG(),{translate:r}=OG(),a=(B,C)=>{const E={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:Q,relativeTo:h}=Object.assign({},E,B),u=s(C),d=[0,0,0];return Q[0]&&(d[0]=h[0]-(u[0][0]+(u[1][0]-u[0][0])/2)),Q[1]&&(d[1]=h[1]-(u[0][1]+(u[1][1]-u[0][1])/2)),Q[2]&&(d[2]=h[2]-(u[0][2]+(u[1][2]-u[0][2])/2)),r(d,C)},g=(B,...C)=>{const E={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:Q,relativeTo:h}=Object.assign({},E,B);if(C=t(C),C.length===0)throw new Error("wrong number of arguments");if(h.length!==3)throw new Error("relativeTo must be an array of length 3");B={axes:Q,relativeTo:h};const u=C.map(d=>o.isA(d)||i.isA(d)||n.isA(d)?a(B,d):d);return u.length===1?u[0]:u},I=(...B)=>g({axes:[!0,!1,!1]},B),c=(...B)=>g({axes:[!1,!0,!1]},B),l=(...B)=>g({axes:[!1,!1,!0]},B);A.exports={center:g,centerX:I,centerY:c,centerZ:l}}}),X8=st({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(e,A){var t=No(),i=Og(),n=Vo(),o=jo(),s=Dg(),r=(c,...l)=>{if(!Array.isArray(c))throw new Error("factors must be an array");if(l=t(l),l.length===0)throw new Error("wrong number of arguments");for(c=c.slice();c.length<3;)c.push(1);if(c[0]<=0||c[1]<=0||c[2]<=0)throw new Error("factors must be positive");const B=i.fromScaling(i.create(),c),C=l.map(E=>s.isA(E)?s.transform(B,E):n.isA(E)?n.transform(B,E):o.isA(E)?o.transform(B,E):E);return C.length===1?C[0]:C},a=(c,...l)=>r([c,1,1],l),g=(c,...l)=>r([1,c,1],l),I=(c,...l)=>r([1,1,c],l);A.exports={scale:r,scaleX:a,scaleY:g,scaleZ:I}}}),Mue=st({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(e,A){var t=No(),i=Vo(),n=jo(),o=Dg(),s=(r,...a)=>{if(a=t(a),a.length===0)throw new Error("wrong number of arguments");const g=a.map(I=>o.isA(I)?o.transform(r,I):i.isA(I)?i.transform(r,I):n.isA(I)?n.transform(r,I):I);return g.length===1?g[0]:g};A.exports=s}}),WG=st({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(e,A){A.exports={align:Fue(),center:z8().center,centerX:z8().centerX,centerY:z8().centerY,centerZ:z8().centerZ,mirror:zU().mirror,mirrorX:zU().mirrorX,mirrorY:zU().mirrorY,mirrorZ:zU().mirrorZ,rotate:XU().rotate,rotateX:XU().rotateX,rotateY:XU().rotateY,rotateZ:XU().rotateZ,scale:X8().scale,scaleX:X8().scaleX,scaleY:X8().scaleY,scaleZ:X8().scaleZ,transform:Mue(),translate:OG().translate,translateX:OG().translateX,translateY:OG().translateY,translateZ:OG().translateZ}}}),$8=st({"node_modules/@jscad/modeling/src/index.js"(e,A){A.exports={colors:q8(),curves:_Ee(),geometries:UQA(),maths:Ahe(),measurements:ahe(),primitives:Q_(),text:WQA(),utils:tzA(),booleans:PN(),expansions:rzA(),extrusions:tH(),hulls:wue(),modifiers:kue(),transforms:WG()}}}),czA=st({"node_modules/jscad-planner/dist/index.cjs"(e,A){var t=Object.defineProperty,i=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(l,B)=>{for(var C in B)t(l,C,{get:B[C],enumerable:!0})},r=(l,B,C,E)=>{if(B&&typeof B=="object"||typeof B=="function")for(let Q of n(B))!o.call(l,Q)&&Q!==C&&t(l,Q,{get:()=>B[Q],enumerable:!(E=i(B,Q))||E.enumerable});return l},a=l=>r(t({},"__esModule",{value:!0}),l),g={};s(g,{executeJscadOperations:()=>c,jscadPlanner:()=>I}),A.exports=a(g);var I={booleans:{intersect:(...l)=>({type:"intersect",shapes:l}),subtract:(...l)=>({type:"subtract",shapes:l}),union:(...l)=>({type:"union",shapes:l})},hulls:{hull:(...l)=>({type:"hull",shapes:l.flat()}),hullChain:(...l)=>({type:"hullChain",shapes:l.flat()})},colors:{colorize:(l,B)=>({type:"colorize",color:l,shape:B})},primitives:{cube:l=>({type:"cube",...l}),sphere:l=>({type:"sphere",...l}),cylinder:l=>({type:"cylinder",...l}),polygon:l=>({type:"polygon",...l}),cuboid:l=>({type:"cuboid",...l}),roundedCuboid:l=>({type:"roundedCuboid",...l})},transforms:{rotate:(l,B)=>({type:"rotate",angles:l,shape:B}),scale:(l,B)=>({type:"scale",factors:l,shape:B}),translate:(l,B)=>({type:"translate",vector:l,shape:B})},extrusions:{extrudeLinear:(l,B)=>({type:"extrudeLinear",options:l,shape:B}),extrudeRotate:(l,B)=>({type:"extrudeRotate",options:l,shape:B})},maths:{vec2:{create:(l,B)=>[l,B],fromValues:(l,B)=>[l,B]},vec3:{create:(l,B,C)=>[l,B,C],fromValues:(l,B,C)=>[l,B,C]}},geometries:{geom2:{create:l=>({type:"createGeom2",points:l})},geom3:{create:l=>({type:"createGeom3",polygons:l})},path2:{create:l=>({type:"createPath2",points:l})}},measurements:{measureBoundingBox:l=>({type:"measureBoundingBox",shape:l}),measureArea:l=>({type:"measureArea",shape:l}),measureVolume:l=>({type:"measureVolume",shape:l})},utils:{degToRad:l=>l*Math.PI/180,radToDeg:l=>l*180/Math.PI}},c=(l,B)=>{if(Array.isArray(B)&&B.length===1)return c(l,B[0]);if(Array.isArray(B))throw new Error("executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually");const C=h=>c(l,h),{type:E,...Q}=B;switch(E){case"intersect":return l.booleans.intersect(...B.shapes.map(C));case"subtract":return l.booleans.subtract(...B.shapes.map(C));case"union":return l.booleans.union(...B.shapes.map(C));case"hull":return l.hulls.hull(...B.shapes.map(C));case"hullChain":return l.hulls.hullChain(...B.shapes.map(C));case"colorize":return l.colors.colorize(B.color,C(B.shape));case"cube":return l.primitives.cube(Q);case"sphere":return l.primitives.sphere(Q);case"cylinder":return l.primitives.cylinder(Q);case"polygon":return l.primitives.polygon(Q);case"cuboid":return l.primitives.cuboid(Q);case"roundedCuboid":return l.primitives.roundedCuboid(Q);case"rotate":return l.transforms.rotate(B.angles,C(B.shape));case"scale":return l.transforms.scale(B.factors,C(B.shape));case"translate":return l.transforms.translate(B.vector,C(B.shape));case"extrudeLinear":return l.extrusions.extrudeLinear(B.options,C(B.shape));case"extrudeRotate":return l.extrusions.extrudeRotate(B.options,C(B.shape));case"createGeom2":return l.geometries.geom2.create(B.points);case"createGeom3":return l.geometries.geom3.create(B.polygons);case"createPath2":return l.geometries.path2.create(B.points);case"measureBoundingBox":return l.measurements.measureBoundingBox(C(B.shape));case"measureArea":return l.measurements.measureArea(C(B.shape));case"measureVolume":return l.measurements.measureVolume(C(B.shape));case"degToRad":return l.utils.degToRad(B.degrees);case"radToDeg":return l.utils.radToDeg(B.radians);default:throw B.type===void 0?new Error(`Operation type is undefined. This usually means the operation object is malformed or not properly initialized. Operation: ${JSON.stringify(B,null,2).slice(0,200)}...`):new Error(`Unsupported operation type: ${B.type}. Operation: ${JSON.stringify(B,null,2)}`)}}}}),Rue=st({"node_modules/ms/index.js"(e,A){var t=1e3,i=t*60,n=i*60,o=n*24,s=o*7,r=o*365.25;A.exports=function(l,B){B=B||{};var C=typeof l;if(C==="string"&&l.length>0)return a(l);if(C==="number"&&isFinite(l))return B.long?I(l):g(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function a(l){if(l=String(l),!(l.length>100)){var B=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(B){var C=parseFloat(B[1]),E=(B[2]||"ms").toLowerCase();switch(E){case"years":case"year":case"yrs":case"yr":case"y":return C*r;case"weeks":case"week":case"w":return C*s;case"days":case"day":case"d":return C*o;case"hours":case"hour":case"hrs":case"hr":case"h":return C*n;case"minutes":case"minute":case"mins":case"min":case"m":return C*i;case"seconds":case"second":case"secs":case"sec":case"s":return C*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return C;default:return}}}}function g(l){var B=Math.abs(l);return B>=o?Math.round(l/o)+"d":B>=n?Math.round(l/n)+"h":B>=i?Math.round(l/i)+"m":B>=t?Math.round(l/t)+"s":l+"ms"}function I(l){var B=Math.abs(l);return B>=o?c(l,B,o,"day"):B>=n?c(l,B,n,"hour"):B>=i?c(l,B,i,"minute"):B>=t?c(l,B,t,"second"):l+" ms"}function c(l,B,C,E){var Q=B>=C*1.5;return Math.round(l/C)+" "+E+(Q?"s":"")}}}),Nue=st({"node_modules/debug/src/common.js"(e,A){function t(i){o.debug=o,o.default=o,o.coerce=c,o.disable=g,o.enable=r,o.enabled=I,o.humanize=Rue(),o.destroy=l,Object.keys(i).forEach(B=>{o[B]=i[B]}),o.names=[],o.skips=[],o.formatters={};function n(B){let C=0;for(let E=0;E<B.length;E++)C=(C<<5)-C+B.charCodeAt(E),C|=0;return o.colors[Math.abs(C)%o.colors.length]}o.selectColor=n;function o(B){let C,E=null,Q,h;function u(...d){if(!u.enabled)return;const f=u,m=Number(new Date),w=m-(C||m);f.diff=w,f.prev=C,f.curr=m,C=m,d[0]=o.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let D=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(k,x)=>{if(k==="%%")return"%";D++;const N=o.formatters[x];if(typeof N=="function"){const R=d[D];k=N.call(f,R),d.splice(D,1),D--}return k}),o.formatArgs.call(f,d),(f.log||o.log).apply(f,d)}return u.namespace=B,u.useColors=o.useColors(),u.color=o.selectColor(B),u.extend=s,u.destroy=o.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(Q!==o.namespaces&&(Q=o.namespaces,h=o.enabled(B)),h),set:d=>{E=d}}),typeof o.init=="function"&&o.init(u),u}function s(B,C){const E=o(this.namespace+(typeof C>"u"?":":C)+B);return E.log=this.log,E}function r(B){o.save(B),o.namespaces=B,o.names=[],o.skips=[];const C=(typeof B=="string"?B:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const E of C)E[0]==="-"?o.skips.push(E.slice(1)):o.names.push(E)}function a(B,C){let E=0,Q=0,h=-1,u=0;for(;E<B.length;)if(Q<C.length&&(C[Q]===B[E]||C[Q]==="*"))C[Q]==="*"?(h=Q,u=E,Q++):(E++,Q++);else if(h!==-1)Q=h+1,u++,E=u;else return!1;for(;Q<C.length&&C[Q]==="*";)Q++;return Q===C.length}function g(){const B=[...o.names,...o.skips.map(C=>"-"+C)].join(",");return o.enable(""),B}function I(B){for(const C of o.skips)if(a(B,C))return!1;for(const C of o.names)if(a(B,C))return!0;return!1}function c(B){return B instanceof Error?B.stack||B.message:B}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}A.exports=t}}),vue=st({"node_modules/debug/src/browser.js"(e,A){e.formatArgs=i,e.save=n,e.load=o,e.useColors=t,e.storage=s(),e.destroy=(()=>{let a=!1;return()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let a;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(a=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(a[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function i(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+A.exports.humanize(this.diff),!this.useColors)return;const g="color: "+this.color;a.splice(1,0,g,"color: inherit");let I=0,c=0;a[0].replace(/%[a-zA-Z%]/g,l=>{l!=="%%"&&(I++,l==="%c"&&(c=I))}),a.splice(c,0,g)}e.log=console.debug||console.log||(()=>{});function n(a){try{a?e.storage.setItem("debug",a):e.storage.removeItem("debug")}catch{}}function o(){let a;try{a=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch{}return!a&&typeof _QA<"u"&&"env"in _QA&&(a=_QA.env.DEBUG),a}function s(){try{return localStorage}catch{}}A.exports=Nue()(e);var{formatters:r}=A.exports;r.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}}}),lzA={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,backgroundStart:!0,backgroundEnd:!0},BzA=AA.createContext(void 0),Lue=({children:e})=>{const[A,t]=AA.useState(lzA),i=AA.useCallback((s,r)=>{t(a=>({...a,[s]:r}))},[]),n=AA.useCallback(()=>{t(lzA)},[]),o=AA.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:n}),[A,i,n]);return Z.jsx(BzA.Provider,{value:o,children:e})},qN=()=>{const e=AA.useContext(BzA);if(!e)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return e},eEA=1.2;function CzA(e){return AA.useMemo(()=>{if(!e)return eEA;try{return Si(e).pcb_board.list()[0]?.thickness??eEA}catch{return eEA}},[e])}var QzA=AA.createContext(null),Ku=()=>{const e=AA.useContext(QzA);if(!e)throw new Error("useThree must be used within a ThreeProvider");return e},eH=(e,A=[])=>{const{addFrameListener:t,removeFrameListener:i}=Ku();en.useEffect(()=>(t(e),()=>i(e)),[t,i,...A])},iH={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},EzA=({children:e,position:A,style:t})=>{const{camera:i,renderer:n}=Ku(),o=AA.useRef(document.createElement("div")),[s,r]=AA.useState(null);return AA.useEffect(()=>{const a=n?.domElement.parentNode;if(a)return a.style.position!=="relative"&&a.style.position!=="absolute"&&(a.style.position="relative"),a.appendChild(o.current),r(IK.createPortal(e,o.current)),()=>{a.contains(o.current)&&a.removeChild(o.current)}},[n,e]),eH(()=>{if(!i||!o.current||!n)return;const a=new Mt(...A);a.project(i);const g=n.domElement.getBoundingClientRect(),I=Math.round((a.x+1)/2*g.width),c=Math.round((-a.y+1)/2*g.height);o.current.style.position="absolute",o.current.style.left=`${I}px`,o.current.style.top=`${c}px`,o.current.style.pointerEvents="none",o.current.style.zIndex=iH.htmlElements.toString(),t&&Object.assign(o.current.style,t)},[i,n,A,t]),s},hzA={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},Gr=e=>{let A=typeof e=="number"?"mm":e.replace(/^[^a-zA-Z]+/g,"").toLowerCase();A||(A="mm");const t=typeof e=="number"?e:Number.parseFloat(e.split(A)[0]);if(A in hzA)return t*hzA[A];throw new Error(`Unsupported unit: ${A}`)},kl=Gr,Uue=Object.defineProperty,Hue=(e,A)=>{for(var t in A)Uue(e,t,{get:A[t],enumerable:!0})},ib={};Hue(ib,{axial:()=>ape,bga:()=>hde,breakoutheaders:()=>fpe,cap:()=>Oue,dfn:()=>Kde,diode:()=>que,dip:()=>Tue,electrolytic:()=>nye,hc49:()=>mpe,jst:()=>S0e,led:()=>Wue,lqfp:()=>dpe,m2host:()=>Dye,melf:()=>Nfe,micromelf:()=>Hfe,minimelf:()=>bfe,mlp:()=>Sde,ms012:()=>jde,ms013:()=>Xde,msop:()=>v0e,pad:()=>wpe,pinrow:()=>Ode,platedhole:()=>Eye,potentiometer:()=>tye,pushbutton:()=>Bpe,qfn:()=>mde,qfp:()=>Dde,quad:()=>WN,radial:()=>cpe,res:()=>Cde,sma:()=>Kfe,smb:()=>zfe,smbf:()=>sye,smc:()=>t0e,smf:()=>Wfe,smtpad:()=>Cye,sod110:()=>x0e,sod123:()=>npe,sod123f:()=>ofe,sod123fl:()=>gfe,sod123w:()=>Hpe,sod128:()=>hfe,sod323:()=>Kpe,sod323f:()=>tfe,sod323fl:()=>T0e,sod323w:()=>U0e,sod523:()=>_pe,sod723:()=>Bfe,sod80:()=>Npe,sod882:()=>zpe,sod882d:()=>Gfe,sod923:()=>Wpe,soic:()=>dde,solderjumper:()=>W0e,son:()=>O0e,sop8:()=>Mpe,sot:()=>uye,sot223:()=>o0e,sot23:()=>vde,sot23w:()=>C0e,sot25:()=>Yde,sot323:()=>Iye,sot343:()=>fye,sot363:()=>Fde,sot457:()=>j0e,sot563:()=>Zde,sot723:()=>Ape,sot886:()=>Rde,sot89:()=>mfe,sot963:()=>X0e,ssop:()=>xde,stampboard:()=>Qpe,stampreceiver:()=>upe,to220:()=>Dfe,to92:()=>bpe,to92l:()=>bye,to92s:()=>p0e,tqfp:()=>wde,tssop:()=>kde,vssop:()=>M0e});var Oi=(e,A,t)=>({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:t,pcb_component_id:"pcb_component_1",text:"{REF}",layer:"top",anchor_position:{x:e,y:A},anchor_alignment:"center"}),Wi=jA({norefdes:gt().optional().describe("disable reference designator label"),invert:gt().optional().describe("hint to invert the orientation of the 3D model"),faceup:gt().optional().describe("The male pin header should face upwards, out of the top layer"),nosilkscreen:gt().optional().describe("omit all silkscreen elements from the footprint")}),zo=(e,A,t,i,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:t,hole_diameter:Gr(i),outer_diameter:Gr(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[e.toString()]}),nb=(e,A,t,i,n,o,s,r)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circular_hole_with_rect_pad",x:A,y:t,hole_diameter:Gr(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:Gr(n),rect_pad_height:Gr(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[e.toString()],hole_offset_x:s,hole_offset_y:r}),uzA=Array.from({length:9},(e,A)=>Math.cos(A/8*Math.PI-Math.PI)).map(e=>({x:e,y:-Math.sqrt(1-e**2)}));function E_(e){return typeof e=="string"?e.trim().toLowerCase().endsWith("mil")?parseFloat(e)*.0254:parseFloat(e):Number(e)}var AW=Ze([J(),WA()]).transform(e=>E_(e)),Yue=e=>Wi.extend({fn:J(),num_pins:WA().optional().default(6),wide:gt().optional(),narrow:gt().optional(),w:AW.optional(),p:AW.default(e.p??"2.54mm"),id:AW.optional(),od:AW.optional(),nosquareplating:gt().optional().default(!1).describe("do not use rectangular pad for pin 1")}).transform(A=>(!A.id&&!A.od?Math.abs(A.p-1.27)<.01?(A.id=E_("0.55mm"),A.od=E_("0.95mm")):(A.id=E_("0.8mm"),A.od=E_("1.6mm")):A.id?A.od||(A.od=A.id*(1.5/1)):A.id=A.od*(1/1.5),A.w||(A.wide?A.w=E_("600mil"):A.narrow?A.w=E_("300mil"):A.w=E_(e.w??"300mil")),A)),Jue=Yue({}),dzA=(e,A,t,i,n)=>{const o=e/2,s=A<=o,r=o-1,a=i,g=a*r;return s?{x:-t/2,y:g/2-(A-1)*a}:{x:t/2,y:-g/2+(A-o-1)*a}},Tue=e=>{const A=Jue.parse(e),t=[];for(let g=0;g<A.num_pins;g++){const{x:I,y:c}=dzA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating);if(g===0&&!A.nosquareplating){t.push(nb(g+1,I,c,A.id??"0.8mm",A.od??"1mm",A.od??"1mm"));continue}t.push(zo(g+1,I,c,A.id??"0.8mm",A.od??"1mm"))}(A.num_pins/2-1)*A.p+A.od;const n=A.w-A.od-1,o=(A.num_pins/2-1)*A.p+A.od+.4,s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-n/2,y:-o/2},{x:-n/2,y:o/2},...uzA.map(({x:g,y:I})=>({x:g*n/6,y:I*n/6+o/2})),{x:n/2,y:o/2},{x:n/2,y:-o/2},{x:-n/2,y:-o/2}],type:"pcb_silkscreen_path",stroke_width:.1},r=[];for(let g=0;g<A.num_pins;g++){const I=g<A.num_pins/2,c=.6,{y:l}=dzA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating),B=I?-A.w/2-A.od/2-c:A.w/2+A.od/2+c,C=l;r.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`pin_${g+1}`,layer:"top",pcb_component_id:`pin_${g+1}`,text:`{pin${g+1}}`,anchor_position:{x:B,y:C},font_size:.3,font:"tscircuit2024",anchor_alignment:"top_left"})}const a=Oi(0,o/2+.5,.4);return{circuitJson:[...t,s,a,...r],parameters:A}},di=(e,A,t,i,n)=>({type:"pcb_smtpad",x:A,y:t,width:i,height:n,layer:"top",shape:"rect",pcb_smtpad_id:"",port_hints:Array.isArray(e)?e.map(o=>o.toString()):[e.toString()]}),pzA=[{imperial:"01005",metric:"0402",p_mm_min:.5,pw_mm_min:.4,ph_mm_min:.3,w_mm_min:.58,h_mm_min:.21},{imperial:"0504",metric:"1310",p_mm_min:1.1,pw_mm_min:.65,ph_mm_min:1.3,w_mm_min:.58,h_mm_min:.21},{imperial:"1812",metric:"4532",p_mm_min:4.275,pw_mm_min:1.125,ph_mm_min:3.4,w_mm_min:5.4,h_mm_min:3.4},{imperial:"0201",metric:"0603",p_mm_min:.66,pw_mm_min:.46,ph_mm_min:.4,w_mm_min:.9,h_mm_min:.3},{imperial:"0402",metric:"1005",p_mm_min:1.02,pw_mm_min:.54,ph_mm_min:.64,w_mm_min:1.56,h_mm_min:.64},{imperial:"0603",metric:"1608",p_mm_min:1.65,pw_mm_min:.8,ph_mm_min:.95,w_mm_min:2.45,h_mm_min:.95},{imperial:"0805",metric:"2012",p_mm_min:1.825,pw_mm_min:1.025,ph_mm_min:1.4,w_mm_min:2.8499999999999996,h_mm_min:1.4},{imperial:"1206",metric:"3216",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:1.75,w_mm_min:4.05,h_mm_min:1.75},{imperial:"1210",metric:"3225",p_mm_min:2.925,pw_mm_min:1.125,ph_mm_min:2.65,w_mm_min:4.05,h_mm_min:2.65},{imperial:"2010",metric:"5025",p_mm_min:4.625,pw_mm_min:1.225,ph_mm_min:2.65,w_mm_min:5.85,h_mm_min:2.65},{imperial:"2512",metric:"6332",p_mm_min:5.925,pw_mm_min:1.225,ph_mm_min:3.35,w_mm_min:7.15,h_mm_min:3.35}],Kue=Object.fromEntries(pzA.map(e=>[e.metric,e])),Pue=Object.fromEntries(pzA.map(e=>[e.imperial,e]));Wi.extend({tht:gt(),p:CA.optional(),pw:CA.optional(),ph:CA.optional(),metric:at.optional(),imperial:at.optional(),w:CA.optional(),h:CA.optional(),textbottom:gt().optional()});var tW=e=>{let{tht:A,p:t,pw:i,ph:n,metric:o,imperial:s,w:r,h:a,textbottom:g}=e;if(typeof r=="string"&&(r=kl(r)),typeof a=="string"&&(a=kl(a)),typeof t=="string"&&(t=kl(t)),typeof i=="string"&&(i=kl(i)),typeof n=="string"&&(n=kl(n)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let I;if(o&&(I=Kue[o]),s&&(I=Pue[s]),I&&(r=I.w_mm_min,a=I.h_mm_min,t=I.p_mm_min,i=I.pw_mm_min,n=I.ph_mm_min),t===void 0||i===void 0||n===void 0)throw new Error("Could not determine required pad dimensions (p, pw, ph)");const c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:t/2,y:n/2+.4},{x:-t/2-i/2-.2,y:n/2+.4},{x:-t/2-i/2-.2,y:-n/2-.4},{x:t/2,y:-n/2-.4}],stroke_width:.1,pcb_silkscreen_path_id:""},l=g?-n/2-.9:n/2+.9,B=Oi(0,l,.2);return A?[zo(1,-t/2,0,i,i*1/.8),zo(2,t/2,0,i,i*1/.8),c,B]:[di(["1","left"],-t/2,0,i,n),di(["2","right"],t/2,0,i,n),c,B]},que=e=>({circuitJson:tW(e),parameters:e}),Oue=e=>({circuitJson:tW(e),parameters:e}),Wue=e=>({circuitJson:tW(e),parameters:e}),ON=e=>{const{padSpacing:A,padWidth:t,padHeight:i,padPitch:n,numRows:o,textbottom:s}=e,r=[],a=(o-1)*(n/2);for(let b=0;b<o;b++)r.push(a-b*n);const g=[];r.forEach((b,k)=>{g.push(di(k+1,-A/2,b,t,i))}),r.slice().reverse().forEach((b,k)=>{g.push(di(k+o+1,A/2,b,t,i))});const I=Math.max(...r)+i/2+.4,c=Math.min(...r)-i/2-.4,l=-A/2-t/2-.4,B=A/2+t/2+.4,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B*.5,y:I},{x:l*.5,y:I}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:B*.5,y:c},{x:l*.5,y:c}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_bottom"},Q=-A/2,h=Math.max(...r),u=.2,d=Q-t/2-.1,f=h+i/2+.1,m={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:[{x:d,y:f},{x:d-u,y:f},{x:d,y:f+u},{x:d,y:f}],stroke_width:.1},w=s?c-.9:I+.9,D=Oi(0,w,.2);return[...g,C,E,m,D]},Zue=Wi.extend({pw:J().default("0.5mm"),ph:J().default("0.4mm"),p:J().default("0.7mm"),textbottom:gt().optional()}),Vue=1,jue=e=>{const A=Zue.parse(e),t=kl(A.pw),i=kl(A.ph),n=kl(A.p);return ON({padSpacing:Vue,padWidth:t,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom})},zue=Wi.extend({pw:J().default("0.5mm"),ph:J().default("0.32mm"),p:J().default("0.5mm"),textbottom:gt().optional()}),Xue=1,$ue=e=>{const A=zue.parse(e),t=kl(A.pw),i=kl(A.ph),n=kl(A.p);return ON({padSpacing:Xue,padWidth:t,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom})},Ade=Wi.extend({pw:J().default("0.9mm"),ph:J().default("0.4mm"),p:J().default("0.8mm"),textbottom:gt().optional()}),tde=1.7,ede=e=>{const A=Ade.parse(e),t=kl(A.pw),i=kl(A.ph),n=kl(A.p);return ON({padSpacing:tde,padWidth:t,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom})},ide=Wi.extend({pw:J().default("0.9mm"),ph:J().default("0.4mm"),p:J().default("0.8mm"),textbottom:gt().optional()}),nde=1.7,ode=e=>{const A=ide.parse(e),t=kl(A.pw),i=kl(A.ph),n=kl(A.p);return ON({padSpacing:nde,padWidth:t,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom})},sde=Wi.extend({pw:J().default("0.7mm"),ph:J().default("0.64mm"),p:J().default("0.94mm"),textbottom:gt().optional()}),rde=1.4,ade=e=>{const A=sde.parse(e),t=kl(A.pw),i=kl(A.ph),n=kl(A.p);return ON({padSpacing:rde,padWidth:t,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom})},gde=Wi.extend({pw:J().default("0.9mm"),ph:J().default("0.9mm"),p:J().default("1.34mm"),textbottom:gt().optional()}),Ide=3,cde=e=>{const A=gde.parse(e),t=kl(A.pw),i=kl(A.ph),n=kl(A.p);return ON({padSpacing:Ide,padWidth:t,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom})},lde=e=>{const A=e.array??e.x;if(typeof A=="number")return Number.isNaN(A)?void 0:A;if(typeof A=="string"){const t=Number.parseInt(A,10);return Number.isNaN(t)?void 0:t}if(typeof e.imperial=="string"){const i=e.imperial.match(/(?:array|x)(2|4)$/)?.[1];if(i)return Number.parseInt(i,10)}},Bde=e=>e?(typeof e=="number"?`${e}`:e).split("_")[0]:void 0,Cde=e=>{const A=lde(e),t=Bde(e.imperial);return A===2&&t==="0402"?{circuitJson:jue(e),parameters:e}:A===4&&t==="0402"?{circuitJson:$ue(e),parameters:e}:A===2&&t==="0603"?{circuitJson:ede(e),parameters:e}:A===4&&t==="0603"?{circuitJson:ode(e),parameters:e}:A===2&&t==="0606"?{circuitJson:ade(e),parameters:e}:A===4&&t==="1206"?{circuitJson:cde(e),parameters:e}:{circuitJson:tW(e),parameters:e}},fzA=(e,{x:A,y:t,radius:i})=>({type:"pcb_smtpad",x:A,y:t,radius:i,layer:"top",shape:"circle",pcb_smtpad_id:"",port_hints:Array.isArray(e)?e.map(n=>n.toString()):[e.toString()]}),yzA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",mzA=J().transform(e=>{const[A,t]=e.split(/[x ]/);return{x:parseFloat(A),y:parseFloat(t)}}).pipe(jA({x:WA(),y:WA()})),Qde=J().or(St(KI())).transform(e=>Array.isArray(e)?e:(e.startsWith("(")&&e.endsWith(")")&&(e=e.slice(1,-1)),e.split(",").map(A=>{const t=Number(A);return isNaN(t)?A:t}))).pipe(St(J().or(WA()))),Ede=Wi.extend({fn:J(),num_pins:WA().optional().default(64),grid:mzA.optional(),p:at.default("0.8mm"),w:CA.optional(),h:CA.optional(),ball:CA.optional().describe("ball diameter"),pad:CA.optional().describe("pad width/height"),circularpads:gt().optional().describe("use circular pads"),tlorigin:gt().optional(),blorigin:gt().optional(),trorigin:gt().optional(),brorigin:gt().optional(),missing:Qde.default([])}).transform(e=>{let A="tl";if(e.blorigin&&(A="bl"),e.trorigin&&(A="tr"),e.brorigin&&(A="br"),!e.grid){const i=Math.ceil(Math.sqrt(e.num_pins));e.grid={x:i,y:i}}return e.missing&&(e.missing=e.missing.map(i=>{if(typeof i=="number")return i;if(i==="center")return"center";if(i==="topleft")return"topleft";const n=i.match(/([A-Z]+)(\d+)/);if(!n)return i;const o=yzA.indexOf(n[1]),s=Number.parseInt(n[2])-1;return o*e.grid.x+s+1})),{...e,origin:A}}),hde=e=>{const A=Ede.parse(e);let{num_pins:t,grid:i,p:n,w:o,h:s,ball:r,pad:a,missing:g}=A;r??=.75/1.27*n,a??=r*.8;const I=[],c=(g??[]).filter(m=>typeof m=="number"),l=i.x*i.y-t;if(g.length===0&&l>0&&(Math.sqrt(l)%1===0?g.push("center"):l===1&&g.push("topleft")),g?.includes("center")){const m=Math.floor(Math.sqrt(l)),w=Math.floor((i.x-m)/2),D=Math.floor((i.y-m)/2);for(let b=D;b<D+m;b++)for(let k=w;k<w+m;k++)c.push(b*i.x+k+1)}g?.includes("topleft")&&c.push(1);const B=new Set(c);let C=0;for(let m=0;m<i.y;m++)for(let w=0;w<i.x;w++){const D=(w-(i.x-1)/2)*n,b=(m-(i.y-1)/2)*n;let k=w,x=m;switch(A.origin){case"bl":k=w,x=i.y-1-m;break;case"br":k=i.x-1-w,x=i.y-1-m;break;case"tr":k=i.x-1-w,x=m;break}let N=x*i.x+k+1;if(B.has(N)){C++;continue}N-=C;const R=[N,`${yzA[x]}${k+1}`];I.push(A.circularpads?fzA(R,{x:D,y:b,radius:a/2}):di(R,D,b,a,a))}const E=Oi(0,i.y*n/2,.2),Q=n/6;let h;const u=i.x*n/2,d=i.y*n/2;switch(A.origin){case"bl":h=[{x:-u,y:-d},{x:-u,y:-d-Q},{x:-u-Q,y:-d},{x:-u,y:-d}];break;case"br":h=[{x:u,y:-d},{x:u,y:-d-Q},{x:u+Q,y:-d},{x:u,y:-d}];break;case"tr":h=[{x:u,y:d},{x:u,y:d+Q},{x:u+Q,y:d},{x:u,y:d}];break;default:h=[{x:-u,y:d},{x:-u,y:d+Q},{x:-u-Q,y:d},{x:-u,y:d}];break}const f={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_marker",route:h,stroke_width:.05};return{circuitJson:[...I,E,f],parameters:A}},eW=(e,A,t,i,n)=>({type:"pcb_smtpad",x:A,y:t,width:i,height:n,radius:n/2,layer:"top",shape:"pill",pcb_smtpad_id:"",port_hints:Array.isArray(e)?e.map(o=>o.toString()):[e.toString()]}),gD=e=>Wi.extend({fn:J(),num_pins:WA().optional().default(8),w:CA.default(CA.parse(e.w??"5.3mm")),p:CA.default(CA.parse(e.p??"1.27mm")),pw:CA.default(CA.parse(e.pw??"0.6mm")),pl:CA.default(CA.parse(e.pl??"1.0mm")),legsoutside:gt().optional().default(e.legsoutside??!1),pillpads:gt().optional().default(e.pillpads??!1),silkscreen_stroke_width:WA().optional().default(.1)}).transform(A=>(!A.pw&&!A.pl?(A.pw=CA.parse("0.6mm"),A.pl=CA.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),ude=gD({}),iEA=e=>{e.widthincludeslegs!==void 0&&(e.legsoutside=!e.widthincludeslegs);const{num_pins:A,pn:t,w:i,p:n,pl:o,legsoutside:s}=e,r=A/2,a=t<=r,g=r-1,I=n,c=I*g,l=s?o/2:-o/2;return a?{x:-i/2-l,y:c/2-(t-1)*I}:{x:i/2+l,y:-c/2+(t-r-1)*I}},dde=e=>{const A=ude.parse(e);return{circuitJson:h_(A),parameters:A}},h_=e=>{const A=[];for(let r=0;r<e.num_pins;r++){const{x:a,y:g}=iEA({num_pins:e.num_pins,pn:r+1,w:e.w,p:e.p,pl:e.pl,legsoutside:e.legsoutside});e.pillpads?A.push(eW(r+1,a,g,e.pl,e.pw)):A.push(di(r+1,a,g,e.pl,e.pw))}const t=Math.min(1,e.p/2),i=e.w-(e.legsoutside?0:e.pl*2)-.2,n=(e.num_pins/2-1)*e.p+e.pw+t,o=Oi(0,n/2+.4,n/12),s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",stroke_width:e.silkscreen_stroke_width??.1,route:[{x:-i/2,y:-n/2},{x:-i/2,y:n/2},...uzA.map(({x:r,y:a})=>({x:r*i/6,y:a*i/6+n/2})),{x:i/2,y:n/2},{x:i/2,y:-n/2},{x:-i/2,y:-n/2}]};return[...A,s,o]},wzA=se(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),pde=({num_pins:e,cw:A,ccw:t,startingpin:i})=>{const n=[],o=e/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=o:r.bottomside&&r.leftpin?s=o+1:r.bottomside&&r.rightpin?s=o*2:r.rightside&&r.bottompin?s=o*2+1:r.rightside&&r.toppin?s=o*3:r.topside&&r.rightpin?s=o*3+1:r.topside&&r.leftpin&&(s=o*4),n.push(-1);for(let a=0;a<e;a++)n[s]=a+1,t||!A?(s++,s>e&&(s=1)):(s--,s<1&&(s=e));return n},nEA=Wi.extend({fn:J(),cc:gt().default(!0).optional(),ccw:gt().default(!0).optional(),startingpin:J().or(St(wzA)).transform(e=>typeof e=="string"?e.slice(1,-1).split(","):e).pipe(St(wzA)).optional(),num_pins:WA().optional().default(64),w:CA.optional(),h:CA.optional(),p:CA.default(CA.parse("0.5mm")),pw:CA.optional(),pl:CA.optional(),thermalpad:Ze([bA(!0),mzA]).optional(),legsoutside:gt().default(!1)}),oEA=e=>{e.w&&!e.h?e.h=e.w:!e.w&&e.h&&(e.w=e.h);const A=e.num_pins/4;if(!e.p&&!e.pw&&!e.pl&&e.w){const t=A+4;e.p=e.w/t}return!e.p&&e.w&&e.h&&e.pw&&e.pl&&(e.p=(e.w-e.pl*2)/(A-1)),!e.w&&!e.h&&e.p&&(e.w=e.p*(A+4),e.h=e.w),e.p&&!e.pw&&!e.pl?(e.pw=e.p/2,e.pl=e.p/2):e.pw?e.pl||(e.pl=e.pw*(1/.6)):e.pw=e.pl*(.6/1),e},DzA=nEA.transform(oEA),fde=["left","bottom","right","top"],yde=e=>{const{pin_count:A,pn:t,w:i,h:n,p:o,pl:s,legsoutside:r}=e,a=A/4,g=fde[Math.floor((t-1)/a)],I=(t-1)%a,c=o*(a-1),l=o*(a-1),B=r?s/2:-s/2;switch(g){case"left":return{x:-i/2-B+.1,y:l/2-I*o,o:"vert"};case"bottom":return{x:-c/2+I*o,y:-n/2-B+.1,o:"horz"};case"right":return{x:i/2+B-.1,y:-l/2+I*o,o:"vert"};case"top":return{x:c/2-I*o,y:n/2+B-.1,o:"horz"};default:throw new Error("Invalid pin number")}},WN=e=>{const A=DzA.parse(e),t=[],i=pde(A),n=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:I}=yde({pin_count:A.num_pins,pn:r+1,w:A.w,h:A.h,p:A.p??.5,pl:A.pl,legsoutside:A.legsoutside});let c=A.pw,l=A.pl;I==="vert"&&([c,l]=[l,c]);const B=i[r+1];t.push(di(B,a,g,c,l))}if(A.thermalpad)if(typeof A.thermalpad=="boolean"){const r=A.p*(n-1)+A.pw,a=A.p*(n-1)+A.pw;t.push(di(["thermalpad"],0,0,r,a))}else t.push(di(["thermalpad"],0,0,A.thermalpad.x,A.thermalpad.y));const o=[];for(const[r,a,g]of[["top-left",-1,1],["bottom-left",-1,-1],["bottom-right",1,-1],["top-right",1,1]]){const I=A.w/2*a,c=A.h/2*g;let l="none",B=I,C=c;const E=A.pw*2;i[1]===1&&r==="top-left"?l="in1":i[n*4]===1&&r==="top-left"||i[n*3+1]===1&&r==="top-right"?l="in2":i[n*3]===1&&r==="top-right"||i[n]===1&&r==="bottom-left"?l="in1":i[n+1]===1&&r==="bottom-left"?l="in2":i[n*2]===1&&r==="bottom-right"?l="in1":i[n*2+1]===1&&r==="bottom-right"&&(l="in2");const Q=l==="in1"?1:-1;if(A.legsoutside){const h=l==="in1"?A.pl/2:A.pw/2,u=l==="in1"?A.pw/2:A.pl/2;B+=h*a*Q,C-=u*g*Q}(l==="none"||A.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:I-E*a,y:c},{x:I,y:c},{x:I,y:c-E*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(l==="in1"||l==="in2")&&!A.legsoutside&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_1`,route:[{x:I-E*a,y:c},{x:I-E*a/2,y:c}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:I,y:c-E*g/2},{x:I,y:c-E*g}],type:"pcb_silkscreen_path",stroke_width:.1}),(l==="in1"||l==="in2")&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_3`,route:[{x:B-.2*-a,y:C+.2*Q},{x:B,y:C},{x:B+.2*Q*-a,y:C+.2},{x:B-.2*-a,y:C+.2*Q}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Oi(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...t,...o,s],parameters:A}};nEA.extend({}).transform(oEA);var mde=e=>(e.legsoutside=!1,e.pl||(e.pl=.875),e.pw||(e.pw=.25),WN(e)),wde=e=>{if(e.legsoutside=!0,!e.p)switch(e.num_pins){case 32:e.p=.8;break;case 44:case 48:e.p=.5;break;case 64:case 80:case 100:e.p=.5;break;case 144:e.p=.5;break}if(!e.pl)switch(e.num_pins){case 32:case 44:case 48:case 64:case 80:case 100:e.pl=1.475;break;case 144:e.pl=1.6;break}if(!e.pw)switch(e.num_pins){case 32:e.pw=.55;break;case 44:case 48:case 64:case 80:case 100:e.pw=.3;break;case 144:e.pw=.25;break}return WN(e)},Dde=e=>{e.legsoutside=!0;const A=DzA.parse(e);if(!e.p)switch(e.num_pins){case 44:case 64:e.p=.8;break;case 52:e.w===14?e.p=1:e.p=.65;break;case 208:e.p=.5;break}if(!e.pl)switch(e.num_pins){case 44:case 52:case 64:e.pl=2.25;break;case 208:e.pl=1.65;break;default:e.pl=A.pl*4;break}if(!e.pw)switch(e.num_pins){case 44:case 64:e.pw=.5;break;case 52:e.w===14?e.pw=.45:e.pw=.55;break;case 208:e.pw=.3;break;default:e.pw=A.pw;break}return WN(e)};nEA.extend({}).transform(oEA);var Sde=e=>(e.legsoutside=!1,e.thermalpad===void 0&&(e.thermalpad=!0),WN(e)),bde=gD({w:"3.9mm",p:"1.27mm"}),xde=e=>{const A=bde.parse(e);return{circuitJson:h_(A),parameters:A}},_de=gD({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),kde=e=>{const A=_de.parse(e);return{circuitJson:h_(A),parameters:A}},Gde=gD({}),Fde=e=>{const A=Gde.parse({fn:"sot363",num_pins:6,w:2.56,p:.65,pw:.4,pl:.65,legoutside:!0});return{circuitJson:h_(A),parameters:A}},Mde=Wi.extend({fn:J(),num_pins:bA(6).default(6),w:J().default("1.01mm"),h:J().default("1.45mm"),p:J().default("0.5mm"),pl:J().default("0.33mm"),pw:J().default("0.27mm"),string:J().optional()}),Rde=e=>{const A=Mde.parse({fn:"sot886",...e}),t=CA.parse(A.w),i=CA.parse(A.h),n=CA.parse(A.p),o=CA.parse(A.pl),s=CA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:E}=SzA(B+1,t,n,o);r.push(di(B+1,C,E,o,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:i/2},{x:t/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:-i/2},{x:t/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=SzA(1,t,n,o),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-o/2-.3,y:I.y},{x:I.x-o/2-.45,y:I.y+.15},{x:I.x-o/2-.45,y:I.y-.15},{x:I.x-o/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Oi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,c],parameters:A}},SzA=(e,A,t,i)=>{const n=A/2-i/2;return e<=3?{x:-n,y:t-(e-1)*t}:{x:n,y:-t+(e-4)*t}},bzA=Wi.extend({fn:J(),num_pins:WA().default(3),w:J().default("1.92mm"),h:J().default("2.74mm"),pl:J().default("1.32mm"),pw:J().default("0.6mm"),p:J().default("0.95mm"),string:J().optional()}),Nde=gD({p:"0.95mm",w:"1.6mm",legsoutside:!0}),vde=e=>{const A=e.string?.match(/^sot23_(\d+)/),t=A?Number.parseInt(A[1],10):3;if(t===6||t===8){const n=Nde.parse({...e,num_pins:t});return{circuitJson:h_(n),parameters:n}}const i=bzA.parse({...e,num_pins:t});if(i.num_pins===3)return{circuitJson:Ude(i),parameters:i};if(i.num_pins===5)return{circuitJson:_zA(i),parameters:i};throw new Error("Invalid number of pins")},Lde=e=>{const{pn:A,p:t}=e;return A===1?{x:-1.155,y:t}:A===2?{x:-1.155,y:-t}:{x:1.15,y:0}},Ude=e=>{const A=[];for(let i=0;i<e.num_pins;i++){const{x:n,y:o}=Lde({num_pins:e.num_pins,pn:i+1,w:Number.parseFloat(e.w),h:Number.parseFloat(e.h),pl:Number.parseFloat(e.pl),p:Number.parseFloat(e.p)});A.push(di(i+1,n,o,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}const t=Oi(0,Number.parseInt(e.h),.3);return[...A,t]},xzA=e=>{const{p:A,h:t,pn:i}=e;if(i===1)return{x:-t/2-.5,y:A};if(i===2)return{x:-t/2-.5,y:0};if(i===3)return{x:-t/2-.5,y:-A};if(i===4)return{x:t/2+.5,y:-A};if(i===5)return{x:t/2+.5,y:A};throw new Error("Invalid pin number")},_zA=e=>{const A=[];for(let c=1;c<=e.num_pins;c++){const{x:l,y:B}=xzA({h:Number.parseFloat(e.h),p:Number.parseFloat(e.p),pn:c});A.push(di(c,l,B,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}const t=(e.num_pins+1)/2*Number.parseFloat(e.p),i=Number.parseFloat(e.h),n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t/3,y:i/2+Number.parseFloat(e.p)/1.3},{x:t/3,y:i/2+Number.parseFloat(e.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t/3,y:-i/2-Number.parseFloat(e.p)/1.3},{x:t/3,y:-i/2-Number.parseFloat(e.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Oi(0,i+.3,.3),r=xzA({h:Number.parseFloat(e.h),p:Number.parseFloat(e.p),pn:1});r.x=r.x-Number.parseFloat(e.pw)*1.5;const a=.3,g=.4,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,n,o,I]},Hde=bzA.extend({}),Yde=e=>{const A=Hde.parse({...e,num_pins:5});return{circuitJson:_zA(A),parameters:A}},Jde=[{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}],Tde=gD({}),Kde=e=>{const A=Tde.parse(e),t=[];for(let c=0;c<A.num_pins;c++){const{x:l,y:B}=iEA({num_pins:A.num_pins,pn:c+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});t.push(di(c+1,l,B,A.pl??"1mm",A.pw??"0.6mm"))}const i=Math.min(1,A.p/2),n=A.w+i,o=(A.num_pins/2-1)*A.p+A.pw+i,s=[];for(const c of Jde){const{dx:l,dy:B}=c;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",route:[{x:l*n/2-l*A.p,y:B*o/2},{x:l*n/2,y:B*o/2},{x:l*n/2,y:B*o/2-B*A.p}],type:"pcb_silkscreen_path",stroke_width:.1})}const r=A.p/4,a=-n/2-r/2,g=o/2-A.p/2;s.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:a,y:g},{x:a-r,y:g+r},{x:a-r,y:g-r},{x:a,y:g}],stroke_width:.1});const I=Oi(0,o/2+.4,o/12);return{circuitJson:[...t,I,...s],parameters:A}},sEA=({fs:e,pn:A,anchor_x:t,anchor_y:i,textalign:n="center",orthogonal:o=!1,verticallyinverted:s=!1,layer:r="top"})=>{let a=0;o&&s?a=270:s?a=180:o?a=90:a=0;let g="center";return n==="left"&&(s?g="center_right":g="center_left"),n==="right"&&(s?g="center_left":g="center_right"),r==="bottom"&&(g==="center_left"?g="center_right":g==="center_right"&&(g="center_left")),{type:"pcb_silkscreen_text",pcb_silkscreen_text_id:"silkscreen_text_1",font:"tscircuit2024",font_size:e,pcb_component_id:"pcb_component_1",text:`{PIN${A}}`,layer:r,anchor_position:{x:t,y:i},anchor_alignment:g,ccw_rotation:a}};function Pde({pinlabeltextalignleft:e,pinlabeltextalignright:A,pinlabelorthogonal:t}){let i="top";return t?i="left":i="top",e&&(t?i="bottom":i="right"),A&&(t?i="top":i="left"),i}var qde=Wi.extend({fn:J(),num_pins:WA().optional().default(6),rows:Ze([J(),WA()]).transform(e=>Number(e)).optional().default(1).describe("number of rows"),p:CA.default("0.1in").describe("pitch"),id:CA.default("1.0mm").describe("inner diameter"),od:CA.default("1.5mm").describe("outer diameter"),male:gt().optional().describe("for male pin headers"),female:gt().optional().describe("for female pin headers"),smd:gt().optional().describe("surface mount device"),surfacemount:gt().optional().describe("surface mount device (verbose)"),rightangle:gt().optional().describe("right angle"),pw:CA.optional().default("1.0mm").describe("pad width for SMD"),pl:CA.optional().default("2.0mm").describe("pad length for SMD"),pinlabeltextalignleft:gt().optional().default(!1),pinlabeltextaligncenter:gt().optional().default(!1),pinlabeltextalignright:gt().optional().default(!1),pinlabelverticallyinverted:gt().optional().default(!1),pinlabelorthogonal:gt().optional().default(!1),nosquareplating:gt().optional().default(!1).describe("do not use rectangular pad for pin 1"),nopinlabels:gt().optional().default(!1).describe("omit silkscreen pin labels"),doublesidedpinlabel:gt().optional().default(!1).describe("add silkscreen pins in top and bottom layers"),bottomsidepinlabel:gt().optional().default(!1).describe("place the silkscreen reference text on the bottom layer instead of top")}).transform(e=>{const A=Pde(e);return{...e,pinlabelAnchorSide:A,male:e.male??!e.female,female:e.female??!1,smd:e.smd??e.surfacemount??!1,rightangle:e.rightangle??!1}}).superRefine((e,A)=>{e.male&&e.female&&A.addIssue({code:Oe.custom,message:"'male' and 'female' cannot both be true; it should be male or female.",path:["male","female"]})}),Ode=e=>{const A=qde.parse(e),{p:t,id:i,od:n,rows:o,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:I,pinlabeltextalignright:c,nopinlabels:l,doublesidedpinlabel:B,bottomsidepinlabel:C}=A;let E="center";I?E="left":c&&(E="right");const Q=[],h=Math.ceil(s/o),u=-t,d=({xoff:b,yoff:k,od:x,anchorSide:N,smd:R,pw:U,pl:Y})=>{let H=0,O=0;if(R){const W=x/5;switch(N){case"right":H=U/2+W;break;case"top":O=Y/2+W;break;case"bottom":O=-(Y/2+W);break;case"left":H=-(U/2+W);break}}else{const W=x*.75;switch(N){case"right":H=W;break;case"top":O=W;break;case"bottom":O=-W;break;case"left":H=-W;break}}return{anchor_x:b+H,anchor_y:k+O}},f=(b,k,x)=>{A.smd?Q.push(di(b,k,x,A.pw,A.pl)):b===1&&!A.nosquareplating?Q.push(nb(b,k,x,i,n,n,0,0)):Q.push(zo(b,k,x,i,n));const{anchor_x:N,anchor_y:R}=d({xoff:k,yoff:x,od:n,anchorSide:r,smd:A.smd,pw:A.pw,pl:A.pl});l||(C?Q.push(sEA({fs:n/5,pn:b,anchor_x:N,anchor_y:R,textalign:E,orthogonal:g,verticallyinverted:a,layer:"bottom"})):Q.push(sEA({fs:n/5,pn:b,anchor_x:N,anchor_y:R,textalign:E,orthogonal:g,verticallyinverted:a,layer:"top"})),B&&Q.push(sEA({fs:n/5,pn:b,anchor_x:N,anchor_y:R,textalign:E,orthogonal:g,verticallyinverted:a,layer:"bottom"})))},m=new Set,w=o>2&&h>2;if(o===1){const b=-((s-1)/2)*t;for(let k=0;k<s;k++){const x=k+1,N=b+k*t,R=`${N},0`;if(m.has(R))throw new Error(`Overlap at ${R}`);m.add(R),f(x,N,0)}}else if(w){const b=-((h-1)/2)*t;let k=1;for(let x=0;x<o&&k<=s;x++)for(let N=0;N<h&&k<=s;N++){const R=b+N*t,U=x*u,Y=`${R},${U}`;if(m.has(Y))throw new Error(`Overlap at ${Y}`);m.add(Y),f(k++,R,U)}}else{const b=-((h-1)/2)*t;let k=1,x=0,N=o-1,R=0,U=h-1;for(;k<=s&&x<=N&&R<=U;){for(let Y=x;Y<=N&&k<=s;Y++){const H=b+R*t,O=Y*u,W=`${H},${O}`;if(m.has(W))throw new Error(`Overlap at ${W}`);m.add(W),f(k++,H,O)}R++;for(let Y=R;Y<=U&&k<=s;Y++){const H=b+Y*t,O=N*u,W=`${H},${O}`;if(m.has(W))throw new Error(`Overlap at ${W}`);m.add(W),f(k++,H,O)}if(N--,R<=U){for(let Y=N;Y>=x&&k<=s;Y--){const H=b+U*t,O=Y*u,W=`${H},${O}`;if(m.has(W))throw new Error(`Overlap at ${W}`);m.add(W),f(k++,H,O)}U--}if(x<=N){for(let Y=U;Y>=R&&k<=s;Y--){const H=b+Y*t,O=x*u,W=`${H},${O}`;if(m.has(W))throw new Error(`Overlap at ${W}`);m.add(W),f(k++,H,O)}x++}}if(k-1<s)throw new Error(`Missing pins: assigned ${k-1}, expected ${s}`)}const D=Oi(0,t,.5);return{circuitJson:[...Q,D],parameters:A}},Wde=Wi.extend({fn:J(),num_pins:bA(6).default(6),w:J().default("2.1mm"),h:J().default("2.45mm"),p:J().default("0.5mm"),pl:J().default("0.675mm"),pw:J().default("0.35mm"),string:J().optional()}),Zde=e=>{const A=Wde.parse({...e,fn:"sot563"}),t=CA.parse(A.w),i=CA.parse(A.h),n=CA.parse(A.p),o=CA.parse(A.pl),s=CA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:E}=kzA(B+1,t,n,o);r.push(di(B+1,C,E,o,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:i/2},{x:t/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:-i/2},{x:t/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=kzA(1,t,n,o),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-o/2-.3,y:I.y},{x:I.x-o/2-.45,y:I.y+.15},{x:I.x-o/2-.45,y:I.y-.15},{x:I.x-o/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Oi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,c],parameters:A}},kzA=(e,A,t,i)=>{const n=A/2-i/2;return e<=3?{x:-n,y:t-(e-1)*t}:{x:n,y:-t+(e-4)*t}},Vde=gD({p:"1.27mm",w:"3.9mm",legsoutside:!0}),jde=e=>{const A=Vde.parse({...e,num_pins:8});return{circuitJson:h_(A),parameters:A}},zde=gD({p:"1.27mm",w:"7.5mm",legsoutside:!0}),Xde=e=>{const A=zde.parse({...e,num_pins:16});return{circuitJson:h_(A),parameters:A}},$de=Wi.extend({fn:J(),num_pins:bA(3).default(3),w:J().default("1.2mm"),h:J().default("1.2mm"),pw:J().default("0.40mm"),pl:J().default("0.45mm"),p:J().default("0.575mm")}),Ape=e=>{const A=$de.parse(e),t=epe(A),i=Oi(0,CA.parse(A.h),.2);return{circuitJson:[...t,i],parameters:A}},tpe=e=>{const{pn:A,p:t}=e;return A===1?{x:t,y:0}:A===2?{x:-t,y:-.4}:{x:-t,y:.4}},epe=e=>{const A=[];for(let t=0;t<3;t++){const{x:i,y:n}=tpe({num_pins:e.num_pins,pn:t+1,w:Number.parseFloat(e.w),h:Number.parseFloat(e.h),pl:Number.parseFloat(e.pl),p:Number.parseFloat(e.p)});A.push(di(t+1,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},ipe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("2.36mm"),h:J().default("1.22mm"),pl:J().default("0.9mm"),pw:J().default("1.2mm"),p:J().default("3.30mm")}),npe=e=>{const A=ipe.parse(e),t=Oi(0,CA.parse(A.h)/4+.4,.3);return{circuitJson:spe(A).concat(t),parameters:A}},ope=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},spe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=ope({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},rpe=Wi.extend({fn:J(),p:CA.optional().default("2.54mm"),id:CA.optional().default("0.7mm"),od:CA.optional().default("1.4mm")}),ape=e=>{const A=rpe.parse(e),{p:t,id:i,od:n}=A,o=[zo(1,-t/2,0,i,n),zo(2,t/2,0,i,n)],s={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2+n+i/2,y:0},{x:t/2-n-i/2,y:0}],stroke_width:.1,pcb_silkscreen_path_id:""},r=Oi(0,1.5,.5);return{circuitJson:[...o,s,r],parameters:A}},gpe=(e,A,t,i,n,o=.1)=>{const s=[],r=[],a=Math.max(1,Math.ceil(Math.PI*t/o)),g=Math.PI/a;for(let I=0;I<=a;I++){const c=I*g,l=e+Math.cos(c)*t,B=A+Math.sin(c)*t;l<e-i&&B>=A-n/2&&B<=A+n/2||s.push({x:l,y:B})}for(let I=0;I<=a;I++){const c=Math.PI+I*g,l=e+Math.cos(c)*t,B=A+Math.sin(c)*t;l<e-i&&B>=A-n/2&&B<=A+n/2||r.push({x:l,y:B})}return{topArc:s,bottomArc:r}},Ipe=Wi.extend({fn:J(),p:CA.optional().default("5mm"),id:CA.optional().default("0.8mm"),od:CA.optional().default("1.6mm"),ceramic:gt().optional(),electrolytic:gt().optional(),polarized:gt().optional()}),cpe=e=>{const A=Ipe.parse(e),{p:t,id:i,od:n}=A;i===.8&&n===1.6&&(A.id=t===5?.8:t*.25,A.od=t===5?1.6:t*.5);const o=[zo(1,-t/2,0,A.id,A.od),zo(2,t/2,0,A.id,A.od)],s=t+.1,{topArc:r,bottomArc:a}=gpe(0,0,s,A.od/2,A.od),g=.02*t,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:g,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:g,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:s},{x:0,y:-s}],stroke_width:g,pcb_silkscreen_path_id:""},B=.1*t,C=-(t+B+.04*t),E=s-B-.08*t,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C-B,y:E},{x:C+B,y:E}],stroke_width:g,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C,y:E-B},{x:C,y:E+B}],stroke_width:g,pcb_silkscreen_path_id:""},u=Oi(0,s+.12*t,.1*t),d=[...o,I,c,l,u];return(A.electrolytic===!0||A.polarized===!0)&&d.push(Q,h),{circuitJson:d,parameters:A}},iW=(e,A={})=>({type:"pcb_silkscreen_path",layer:A.layer||"top",pcb_component_id:A.pcb_component_id||"",pcb_silkscreen_path_id:A.pcb_silkscreen_path_id||"",route:e,stroke_width:A.stroke_width||.1}),lpe=Wi.extend({fn:bA("pushbutton"),w:CA.default(4.5),h:CA.default(6.5),id:CA.default(1),od:CA.default(1.2)}),Bpe=e=>{const A=lpe.parse(e),t=A.w,i=A.h,n=A.id,o=[zo(1,-t/2,i/2,n,n*1.5),zo(2,-t/2,-i/2,n,n*1.5),zo(3,t/2,-i/2,n,n*1.5),zo(4,t/2,i/2,n,n*1.5)],s=[iW([{x:-t/2,y:-i/2},{x:-t/2,y:i/2}]),iW([{x:t/2,y:-i/2},{x:t/2,y:i/2}]),iW([{x:-t/2,y:0},{x:-t/5,y:0},{x:t/5*1/Math.sqrt(2),y:i/8}]),iW([{x:t/2,y:0},{x:t/5,y:0}])],r=Oi(0,i/2+.4,.5);return{circuitJson:[...o,...s,r],parameters:A}},GzA=Wi.extend({fn:J(),w:CA.default("22.58mm"),h:CA.optional(),left:CA.optional().default(20),right:CA.optional().default(20),top:CA.optional().default(2),bottom:CA.optional().default(2),p:CA.default(CA.parse("2.54mm")),pw:CA.default(CA.parse("1.6mm")),pl:CA.default(CA.parse("2.4mm")),innerhole:gt().default(!1),innerholeedgedistance:CA.default(CA.parse("1.61mm")),silkscreenlabels:gt().default(!1),silkscreenlabelmargin:CA.default(CA.parse("0.1mm"))}),Cpe=e=>{const A=GzA.parse(e);return A.left&&A.right?Math.max(A.left,A.right)*A.p:A.left?A.left*A.p:A.right?A.right*A.p:51},nW=(e,A,t)=>{let i=[];return t==="right"&&(i=[{x:e+1/2,y:A},{x:e-1/2,y:A+.6/2},{x:e-1/2,y:A-.6/2},{x:e+1/2,y:A}]),t==="left"&&(i=[{x:e-1/2,y:A},{x:e+1/2,y:A+.6/2},{x:e+1/2,y:A-.6/2},{x:e-1/2,y:A}]),t==="top"&&(i=[{x:e,y:A+1/2},{x:e-.6/2,y:A-1/2},{x:e+.6/2,y:A-1/2},{x:e,y:A+1/2}]),t==="bottom"&&(i=[{x:e,y:A-1/2},{x:e-.6/2,y:A+1/2},{x:e+.6/2,y:A+1/2},{x:e,y:A-1/2}]),i},Qpe=e=>{const A=GzA.parse(e),t=A.h??Cpe(A),i=[],n=[],o=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),c=`pin${g}`.length*.7/2;if(A.right){const E=-((A.right-1)/2)*A.p;for(let Q=0;Q<A.right;Q++){if(Q===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=nW(A.w/2-A.pl*1.4,E+Q*A.p,"right")),i.push(di(Q+1+A.left+(A.bottom??0),A.w/2-A.pl/2,E+Q*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=Q+1+A.left+(A.bottom??0),u=`pin${h}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl-(c+A.silkscreenlabelmargin),y:E+Q*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(zo(Q+1+A.left+(A.bottom??0)+g,A.w/2,E+Q*A.p,r,a)),n.push(zo(Q+1+A.left+(A.bottom??0)+g*2,A.w/2-A.innerholeedgedistance,E+Q*A.p,r,a)))}}if(A.left){const E=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++){if(Q===0&&!A.silkscreenlabels&&(s=nW(-A.w/2+A.pl*1.4,E-Q*A.p,"left")),i.push(di(Q+1,-A.w/2+A.pl/2,E-Q*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=Q+1,u=`pin${h}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl+(c+A.silkscreenlabelmargin),y:E-Q*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(zo(Q+1+g,-A.w/2,E-Q*A.p,r,a)),n.push(zo(Q+1+g*2,-A.w/2+A.innerholeedgedistance,E-Q*A.p,r,a)))}}if(A.top){const E=(A.top-1)/2*A.p;for(let Q=0;Q<A.top;Q++){if(Q===0&&!A.left&&!A.bottom&&!A.right&&!A.silkscreenlabels&&(s=nW(E-Q*A.p,t/2-A.pl*1.4,"top")),i.push(di(Q+1+A.left+A.right+(A.bottom??0),E-Q*A.p,t/2-A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=Q+1+A.left+A.right+(A.bottom??0),u=`pin${h}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:E-Q*A.p,y:t/2-A.pl-(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(n.push(zo(Q+1+A.left+A.right+(A.bottom??0)+g,E-Q*A.p,t/2,r,a)),n.push(zo(Q+1+A.left+A.right+(A.bottom??0)+g*2,E-Q*A.p,t/2-A.innerholeedgedistance,r,a)))}}if(A.bottom){const E=-((A.bottom-1)/2)*A.p;for(let Q=0;Q<A.bottom;Q++){if(Q===0&&!A.left&&!A.silkscreenlabels&&(s=nW(E+Q*A.p,-t/2+A.pl*1.4,"bottom")),i.push(di(Q+1+A.left,E+Q*A.p,-t/2+A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=Q+1+A.left,u=`pin${h}`;o.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${h}`,pcb_component_id:"1",layer:"top",anchor_position:{x:E+Q*A.p,y:-t/2+A.pl+(c+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(n.push(zo(Q+1+A.left+g,E+Q*A.p,-t/2,r,a)),n.push(zo(Q+1+A.left+g*2,E+Q*A.p,-t/2+A.innerholeedgedistance,r,a)))}}const l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_triangle_1",pcb_component_id:"2",route:s,stroke_width:.1,layer:"top"},B={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2,y:t/2},{x:A.w/2,y:t/2},{x:A.w/2,y:-t/2},{x:-A.w/2,y:-t/2},{x:-A.w/2,y:t/2}],stroke_width:.1,layer:"top"},C=Oi(0,t/1.8,t/25);return{circuitJson:[...i,...n,...o,B,...A.silkscreenlabels?[]:[l],C],parameters:A}},FzA=Wi.extend({fn:J(),w:CA.default("22.58mm"),h:CA.optional(),left:CA.optional().default(20),right:CA.optional().default(20),top:CA.optional().default(2),bottom:CA.optional().default(2),p:CA.default(CA.parse("2.54mm")),pw:CA.default(CA.parse("1.6mm")),pl:CA.default(CA.parse("3.2mm")),innerhole:gt().default(!1),innerholeedgedistance:CA.default(CA.parse("1.61mm"))}),Epe=e=>{const A=FzA.parse(e);return A.left&&A.right?Math.max(A.left,A.right)*A.p:A.left?A.left*A.p:A.right?A.right*A.p:51},hpe=(e,A,t,i=1,n=.6)=>{const o=i/2,s=n/2;return{left:[{x:e+o,y:A},{x:e-o,y:A+s},{x:e-o,y:A-s},{x:e+o,y:A}],right:[{x:e-o,y:A},{x:e+o,y:A+s},{x:e+o,y:A-s},{x:e-o,y:A}],top:[{x:e,y:A-o},{x:e-s,y:A+o},{x:e+s,y:A+o},{x:e,y:A-o}],bottom:[{x:e,y:A+o},{x:e-s,y:A-o},{x:e+s,y:A-o},{x:e,y:A+o}]}[t]},upe=e=>{const A=FzA.parse(e),t=A.h??Epe(A),i=[],n=[],o=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],I=1;if(A.left){const C=(A.left-1)/2*A.p;for(let E=0;E<A.left;E++)E===0&&(g=hpe(-A.w/2-A.pl/2,C-E*A.p,"left")),i.push(di(I,-A.w/2+A.pl/2,C-E*A.p,A.pl,A.pw)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:C-E*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(zo(I+a,-A.w/2+A.innerholeedgedistance,C-E*A.p,s,r))}if(A.bottom){const C=(A.bottom-1)/2*A.p;for(let E=A.bottom-1;E>=0;E--)i.push(di(I,C-E*A.p,-t/2+A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C-E*A.p,y:-t/2+A.pl/2-3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(zo(I+a,C-E*A.p,-t/2+A.innerholeedgedistance,s,r))}if(A.right){const C=-((A.right-1)/2)*A.p;for(let E=0;E<A.right;E++)i.push(di(I,A.w/2-A.pl/2,C+E*A.p,A.pl,A.pw)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:C+E*A.p},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(zo(I+a,A.w/2-A.innerholeedgedistance,C+E*A.p,s,r))}if(A.top){const C=-((A.top-1)/2)*A.p;for(let E=A.top-1;E>=0;E--)i.push(di(I,C+E*A.p,t/2-A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${I}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C+E*A.p,y:t/2-A.pl/2+3.2},text:`pin${I}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),I++,A.innerhole&&o.push(zo(I+a,C+E*A.p,t/2-A.innerholeedgedistance,s,r))}const c={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:g,stroke_width:.1},l={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-A.pl/3,y:t/2+A.pl/3},{x:A.w/2+A.pl/3,y:t/2+A.pl/3},{x:A.w/2+A.pl/3,y:-t/2-A.pl/3},{x:-A.w/2-A.pl/3,y:-t/2-A.pl/3},{x:-A.w/2-A.pl/3,y:t/2+A.pl/3}],stroke_width:.1,layer:"top"},B=Oi(0,t/1.8,t/25);return{circuitJson:[...o,...i,...n,l,c,B],parameters:A}},dpe=e=>(e.legsoutside=!0,e.pl||(e.pl=1.5),e.pw||(e.pw=.3),WN(e)),MzA=Wi.extend({fn:J(),w:CA.default("10mm"),h:CA.optional(),left:CA.optional().default(20),right:CA.optional().default(20),top:CA.optional().default(0),bottom:CA.optional().default(0),p:CA.default(CA.parse("2.54mm")),id:CA.optional().default(CA.parse("1mm")),od:CA.optional().default(CA.parse("1.5mm"))}),ppe=e=>{const A=MzA.parse(e);return A.left&&A.right?Math.max(A.left,A.right)*A.p:A.left?A.left*A.p:A.right?A.right*A.p:51},oW=(e,A,t,i=1,n=.6)=>{const o=i/2,s=n/2;return{left:[{x:e+o,y:A},{x:e-o,y:A+s},{x:e-o,y:A-s},{x:e+o,y:A}],right:[{x:e-o,y:A},{x:e+o,y:A+s},{x:e+o,y:A-s},{x:e-o,y:A}],top:[{x:e,y:A-o},{x:e-s,y:A+o},{x:e+s,y:A+o},{x:e,y:A-o}],bottom:[{x:e,y:A+o},{x:e-s,y:A-o},{x:e+s,y:A-o},{x:e,y:A+o}]}[t]},fpe=e=>{const A=MzA.parse(e),t=A.h??ppe(A),i=[],n=A.id,o=A.od;let s=[];if(A.right){const I=-((A.right-1)/2)*A.p;for(let c=0;c<A.right;c++)c===0&&!A.left&&!A.bottom&&(s=oW(A.w/2+o*1.4,I+c*A.p,"right")),i.push(zo(c+1+A.left+(A.bottom??0),A.w/2,I+c*A.p,n,o))}if(A.left){const I=-((A.left-1)/2)*A.p;for(let c=0;c<A.left;c++)c===A.left-1&&(s=oW(-A.w/2-o*1.4,I+c*A.p,"left")),i.push(zo(c+1,-A.w/2,I+c*A.p,n,o))}if(A.top){const I=-((A.top-1)/2)*A.p;for(let c=0;c<A.top;c++)c===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=oW(I+c*A.p,t/2+o*1.4,"top")),i.push(zo(c+1+A.right+(A.bottom??0)+A.left,I+c*A.p,t/2,n,o))}if(A.bottom){const I=-((A.bottom-1)/2)*A.p;for(let c=0;c<A.bottom;c++)c===0&&!A.left&&(s=oW(I+c*A.p,-t/2-o*1.4,"bottom")),i.push(zo(c+1+A.left,I+c*A.p,-t/2,n,o))}const r={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"1",pcb_component_id:"1",layer:"top",route:s,stroke_width:.1},a={type:"pcb_silkscreen_path",pcb_silkscreen_path_id:"pcb_silkscreen_path_1",pcb_component_id:"1",route:[{x:-A.w/2-o,y:t/2+o},{x:A.w/2+o,y:t/2+o},{x:A.w/2+o,y:-t/2-o},{x:-A.w/2-o,y:-t/2-o},{x:-A.w/2-o,y:t/2+o}],stroke_width:.1,layer:"top"},g=Oi(0,t/1.7,t/25);return{circuitJson:[...i,a,g,r],parameters:A}},RzA=(e,A,t,i)=>Array.from({length:25},(n,o)=>{const s=o/24*Math.PI-Math.PI/2;return{x:e+(i==="right"?1:-1)*Math.cos(s)*t,y:A+Math.sin(s)*t}}),ype=Wi.extend({fn:J(),p:CA.optional().default("4.88mm"),id:CA.optional().default("0.8mm"),od:CA.optional().default("1.5mm"),w:CA.optional().default("5.6mm"),h:CA.optional().default("3.5mm")}),mpe=e=>{const A=ype.parse(e),{p:t,id:i,od:n,w:o,h:s}=A,r=s/2,a=[zo(1,-t/2,0,i,n),zo(2,t/2,0,i,n)],g=RzA(-o/2,0,r,"left"),I=RzA(o/2,0,r,"right"),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...g,...g.slice(1).reverse(),{x:-o/2,y:-s/2},{x:o/2,y:-s/2},...I,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},l=Oi(0,t/4,.5);return{circuitJson:[...a,c,l],parameters:A}};Wi.extend({w:CA,h:CA});var wpe=e=>{const{w:A,h:t}=e,i=Gr(A),n=Gr(t);return{circuitJson:[di(1,0,0,i,n),Oi(0,n/2+.5,.2)],parameters:e}},nH=(e,A,t,i,n,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:A,y:t,outer_width:Gr(n),outer_height:Gr(o),hole_width:Gr(i),hole_height:Gr(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[e.toString()],ccw_rotation:0}),Dpe=Wi.extend({fn:J(),num_pins:Ze([bA(3),bA(2)]).default(3),p:J().default("1.27mm"),id:J().default("0.72mm"),od:J().default("0.95mm"),w:J().default("4.5mm"),h:J().default("4.5mm"),inline:gt().default(!1),string:J().optional()}),Spe=(e,A,t)=>Array.from({length:25},(i,n)=>{const o=n/24*Math.PI;return{x:e+Math.cos(o)*t,y:A+Math.sin(o)*t}}),bpe=e=>{const A=e.string?.match(/^to92_(\d+)/),t=A?Number.parseInt(A[1],10):3,i=Dpe.parse({...e,num_pins:t}),{p:n,id:o,od:s,w:r,h:a,inline:g}=i,I=Number.parseFloat(a)/2,c=Number.parseFloat(n),l=Number.parseFloat(o),B=Number.parseFloat(s),C=B,E=B*(1.5/1.05);let Q=[];if(i.num_pins===3)g?Q=[nb(1,-c,I-c,l,B,E,0,0),nH(2,0,I-c,l,C,E),nH(3,c,I-c,l,C,E)]:Q=[nb(1,-c,I-c,l,B,B,0,0),zo(2,0,I,l,B),zo(3,c,I-c,l,B)];else if(i.num_pins===2)Q=[nb(1,-c,I-c,l,C,E,0,0),nH(2,c,I-c,l,C,E)];else throw new Error("Invalid number of pins for TO-92");const h=Number.parseFloat(r)/2,u=Spe(0,I,h),d={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[...u,{x:-h,y:0},{x:h,y:0},u[0]],stroke_width:.1,pcb_silkscreen_path_id:""},f=Oi(0,I+1,.5);return{circuitJson:[...Q,d,f],parameters:i}},xpe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("2.15mm"),h:J().default("1.20mm"),pl:J().default("0.5mm"),pw:J().default("0.6mm"),p:J().default("1.4mm")}),_pe=e=>{const A=xpe.parse(e),t=Oi(0,CA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Gpe(A).concat(i,t),parameters:A}},kpe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Gpe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=kpe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Fpe=gD({}),Mpe=e=>{const A=Fpe.parse(e),t=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=iEA({num_pins:A.num_pins,pn:s+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});t.push(di(s+1,r,a,A.pl??"1.5mm",A.pw??"0.6mm"))}const i=(A.num_pins/2-1)*A.p+A.pw,n=Oi(0,i/2-.5,i/12),o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",type:"pcb_silkscreen_path",route:[{x:-A.w/3,y:i/2+.2},{x:A.w/3,y:i/2+.2}],stroke_width:.1};return{circuitJson:[...t,n,o],parameters:A}},Rpe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("5.0mm"),h:J().default("2.30mm"),pl:J().default("1.25mm"),pw:J().default("2mm"),p:J().default("3.75mm")}),Npe=e=>{const A=Rpe.parse(e),t=Oi(0,CA.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2+.5,y:CA.parse(A.h)/2+.5},{x:-CA.parse(A.w)/2-.5,y:CA.parse(A.h)/2+.5},{x:-CA.parse(A.w)/2-.5,y:-CA.parse(A.h)/2-.5},{x:CA.parse(A.p)/2+.5,y:-CA.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Lpe(A).concat(i,t),parameters:A}},vpe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Lpe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=vpe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Upe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("4.4mm"),h:J().default("2.1mm"),pl:J().default("1.2mm"),pw:J().default("1.2mm"),p:J().default("2.9mm")}),Hpe=e=>{const A=Upe.parse(e),t=Oi(0,CA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Jpe(A).concat(i,t),parameters:A}},Ype=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Jpe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Ype({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Tpe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("3.30mm"),h:J().default("1.80mm"),pl:J().default("0.60mm"),pw:J().default("0.45mm"),p:J().default("2.1mm")}),Kpe=e=>{const A=Tpe.parse(e),t=Oi(0,CA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:qpe(A).concat(i,t),parameters:A}},Ppe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},qpe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Ppe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Ope=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("1.4mm"),h:J().default("0.9mm"),pl:J().default("0.36mm"),pw:J().default("0.25mm"),p:J().default("0.85mm")}),Wpe=e=>{const A=Ope.parse(e),t=Oi(0,CA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2+.15,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.15,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.15,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2+.15,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Vpe(A).concat(i,t),parameters:A}},Zpe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Vpe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Zpe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},jpe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("1.3mm"),h:J().default("0.9mm"),pl:J().default("0.4mm"),pw:J().default("0.7mm"),p:J().default("0.7mm")}),zpe=e=>{const A=jpe.parse(e),t=Oi(0,CA.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2+.2,y:CA.parse(A.h)/2+.2},{x:-CA.parse(A.w)/2-.2,y:CA.parse(A.h)/2+.2},{x:-CA.parse(A.w)/2-.2,y:-CA.parse(A.h)/2-.2},{x:CA.parse(A.p)/2+.2,y:-CA.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:$pe(A).concat(i,t),parameters:A}},Xpe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},$pe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Xpe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Afe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("3,05mm"),h:J().default("1.65mm"),pl:J().default("0.6mm"),pw:J().default("0.6mm"),pad_spacing:J().default("2.2mm")}),tfe=e=>{const A=Afe.parse(e),t=Oi(0,CA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.pad_spacing)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:-CA.parse(A.h)/2},{x:CA.parse(A.pad_spacing)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ife(A).concat(i,t),parameters:A}},efe=e=>{const{pn:A,pad_spacing:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},ife=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=efe({pn:t,pad_spacing:Number.parseFloat(e.pad_spacing)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},nfe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("4.4mm"),h:J().default("2.1mm"),pl:J().default("1.2mm"),pw:J().default("1.2mm"),p:J().default("2.9mm")}),ofe=e=>{const A=nfe.parse(e),t=Oi(0,CA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:rfe(A).concat(i,t),parameters:A}},sfe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},rfe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=sfe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},afe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("4.4mm"),h:J().default("2.1mm"),pl:J().default("0.91mm"),pw:J().default("1.22mm"),p:J().default("3.146mm")}),gfe=e=>{const A=afe.parse(e),t=Oi(0,CA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:cfe(A).concat(i,t),parameters:A}},Ife=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},cfe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Ife({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},lfe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("1.80mm"),h:J().default("1.00mm"),pl:J().default("0.66mm"),pw:J().default("0.5mm"),p:J().default("0.8mm")}),Bfe=e=>{const A=lfe.parse(e),t=Oi(0,CA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.1,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.1,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Qfe(A).concat(i,t),parameters:A}},Cfe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Qfe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Cfe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Efe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("6.2mm"),h:J().default("3.4mm"),pl:J().default("1.4mm"),pw:J().default("2.1mm"),p:J().default("4.4mm")}),hfe=e=>{const A=Efe.parse(e),t=Oi(0,CA.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:dfe(A).concat(i,t),parameters:A}},ufe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},dfe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=ufe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},pfe=Wi.extend({fn:J(),num_pins:Ze([bA(3),bA(5)]).default(3),w:J().default("4.20mm"),h:J().default("4.80mm"),pl:J().default("1.3mm"),pw:J().default("0.9mm"),p:J().default("1.5mm"),string:J().optional()}),ffe=e=>{const A=[],t=Number.parseFloat(e.p),i=Number.parseFloat(e.pw),n=Number.parseFloat(e.w),o=Number.parseFloat(e.pl),s=.175,r=(o-(o+s))/2;A.push(di(1,-n/2+r,t,o,i),di(2,-n/2,0,o+s,i),di(3,-n/2+r,-t,o,i));const a=Oi(0,0,.3),g=Number.parseFloat(e.w)/2-1,I=Number.parseFloat(e.h)/2,c={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-g,y:I},{x:g,y:I},{x:g,y:I/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},l={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-g,y:-I},{x:g,y:-I},{x:g,y:-I/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,c,l,a]},yfe=e=>{const A=[];Number.parseFloat(e.p),Number.parseFloat(e.pw),Number.parseFloat(e.w),A.push(di(1,-1.85,-1.5,1.5,.7),di(2,-1.85,1.5,1.5,.7),di(3,0,0,.8,2),di(4,1.85,-1.5,1.5,.7),di(5,1.85,1.5,1.5,.7));const t=Oi(0,Number.parseFloat(e.h)/2+.5,.3),i=Number.parseFloat(e.w)/2-1,n=Number.parseFloat(e.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i,y:n}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n},{x:i,y:-n}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,t]},mfe=e=>{const A=e.string?.match(/^sot89_(\d+)/),t=A?Number.parseInt(A[1],10):3,i=pfe.parse({...e,num_pins:t});if(i.num_pins===3)return{circuitJson:ffe(i),parameters:i};if(i.num_pins===5)return{circuitJson:yfe(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},wfe=Wi.extend({fn:J(),p:CA.optional().default("5.0mm"),id:CA.optional().default("1.0mm"),od:CA.optional().default("1.9mm"),w:CA.optional().default("13mm"),h:CA.optional().default("7mm"),num_pins:WA().optional(),string:J().optional()}),Dfe=e=>{const A=wfe.parse(e),{fn:t,id:i,od:n,w:o,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,I=o/2,c=s/2,l=2.5,B=o*.4,C=Math.max(l,B/(a-1)),E=Array.from({length:a},(m,w)=>{const D=a%2===0?(w-a/2+.5)*C:(w-Math.floor(a/2))*C;return zo(w+1,D,g,i,n)}),Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:-c},{x:I,y:-c},{x:I,y:c},{x:-I,y:c},{x:-I,y:-c}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-c+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I,y:h},{x:I,y:h}],stroke_width:.1,pcb_silkscreen_path_id:""},d=[{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o/6,y:h},{x:-o/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""},{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:o/6,y:h},{x:o/6,y:c}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Oi(0,s/2+.6,.5);return{circuitJson:[...E,Q,u,...d,f],parameters:{...A,p:C}}},Sfe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("5.40mm"),h:J().default("2.30mm"),pl:J().default("1.30mm"),pw:J().default("1.70mm"),p:J().default("3.5mm")}),bfe=e=>{const A=Sfe.parse(e),t=Oi(0,CA.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:_fe(A).concat(i,t),parameters:A}},xfe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},_fe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=xfe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},kfe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("1.90mm"),h:J().default("1.33mm"),pl:J().default("0.5mm"),pw:J().default("0.7mm"),p:J().default("0.8mm")}),Gfe=e=>{const A=kfe.parse(e),t=Oi(0,CA.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2+.1,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2+.1,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Mfe(A).concat(i,t),parameters:A}},Ffe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Mfe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Ffe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Rfe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("7.0mm"),h:J().default("3.35mm"),pl:J().default("1.50mm"),pw:J().default("2.70mm"),p:J().default("4.8mm")}),Nfe=e=>{const A=Rfe.parse(e),t=Oi(0,CA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Lfe(A).concat(i,t),parameters:A}},vfe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Lfe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=vfe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Ufe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("3.0mm"),h:J().default("1.80mm"),pl:J().default("0.80mm"),pw:J().default("1.20mm"),p:J().default("1.6mm")}),Hfe=e=>{const A=Ufe.parse(e),t=Oi(0,CA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.1,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.1,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Jfe(A).concat(i,t),parameters:A}},Yfe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Jfe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Yfe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Tfe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("7.10mm"),h:J().default("3.40mm"),pl:J().default("2.45mm"),pw:J().default("1.80mm"),p:J().default("4.05mm")}),Kfe=e=>{const A=Tfe.parse(e),t=Oi(0,CA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.5,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.5,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:qfe(A).concat(i,t),parameters:A}},Pfe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},qfe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Pfe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Ofe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("4.80mm"),h:J().default("2.10mm"),pl:J().default("1.30mm"),pw:J().default("1.40mm"),p:J().default("2.9mm")}),Wfe=e=>{const A=Ofe.parse(e),t=Oi(0,CA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Vfe(A).concat(i,t),parameters:A}},Zfe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Vfe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Zfe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},jfe=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("7.30mm"),h:J().default("4.40mm"),pl:J().default("2.50mm"),pw:J().default("2.30mm"),p:J().default("4.30mm")}),zfe=e=>{const A=jfe.parse(e),t=Oi(0,CA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.1,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.1,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:$fe(A).concat(i,t),parameters:A}},Xfe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},$fe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Xfe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},A0e=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("10.70mm"),h:J().default("6.60mm"),pl:J().default("3.30mm"),pw:J().default("2.50mm"),p:J().default("6.80mm")}),t0e=e=>{const A=A0e.parse(e),t=Oi(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2-.8},{x:-CA.parse(A.w)/2-.8,y:CA.parse(A.h)/2-.8},{x:-CA.parse(A.w)/2-.8,y:-CA.parse(A.h)/2+.8},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:i0e(A).concat(i,t),parameters:A}},e0e=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},i0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=e0e({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},n0e=Wi.extend({fn:J(),num_pins:WA().default(4),w:J().default("8.50mm"),h:J().default("6.90mm"),pl:J().default("2mm"),pw:J().default("1.5mm"),p:J().default("2.30mm"),string:J().optional()}),o0e=e=>{const A=e.string?.match(/^sot223_(\d+)/),t=A?Number.parseInt(A[1],10):4;if(t===8){const n=a0e.parse({...e,num_pins:t});return{circuitJson:h_(n),parameters:n}}const i=n0e.parse({...e,num_pins:t});if(i.num_pins===4)return{circuitJson:r0e(i),parameters:i};if(i.num_pins===5)return{circuitJson:I0e(i),parameters:i};if(i.num_pins===6)return{circuitJson:l0e(i),parameters:i};throw new Error("Invalid number of pins")},s0e=e=>{const{pn:A,w:t,p:i}=e;return A===1?{x:-t/2+1.1,y:i}:A===2?{x:-t/2+1.1,y:0}:A===3?{x:-t/2+1.1,y:-i}:{x:t/2-1.1,y:0}},r0e=e=>{const A=[];for(let r=0;r<e.num_pins;r++){const{x:a,y:g}=s0e({num_pins:e.num_pins,pn:r+1,w:Number.parseFloat(e.w),h:Number.parseFloat(e.h),pl:Number.parseFloat(e.pl),p:Number.parseFloat(e.p)}),I=r===3?3.8:Number.parseFloat(e.pw);A.push(di(r+1,a,g,Number.parseFloat(e.pl),I))}const t=Oi(0,0,.3),i=Number.parseFloat(e.w)/2-2.4,n=Number.parseFloat(e.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i,y:n},{x:i,y:n/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n},{x:i,y:-n},{x:i,y:-n/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,t]},a0e=gD({p:"0.90mm",w:"2.8mm",legsoutside:!0}),g0e=e=>{const{p:A,pn:t,w:i}=e;if(t===1)return{x:-i/2+1.2,y:A/2+A};if(t===2)return{x:-i/2+1.2,y:A/2};if(t===3)return{x:-i/2+1.2,y:-A/2};if(t===4)return{x:-i/2+1.2,y:-A/2-A};if(t===5)return{x:i/2-1,y:0};throw new Error("Invalid pin number")},I0e=e=>{const A=[];for(let r=1;r<=e.num_pins;r++){const{x:a,y:g}=g0e({h:Number.parseFloat(e.h),p:1.5,pn:r,w:Number.parseFloat(e.w)});let I=Number.parseFloat(e.pw),c=Number.parseFloat(e.pl);r===5?(I=3.4,c=1.8):(I=1,c=2.2),A.push(di(r,a,g,c,I))}const t=Number.parseFloat(e.w)/2-2.4,i=Number.parseFloat(e.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t,y:i},{x:t,y:i},{x:t,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t,y:-i},{x:t,y:-i},{x:t,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Oi(0,0,.3);return[...A,n,o,s]},c0e=e=>{const{p:A,pn:t,w:i}=e;if(t===1)return{x:-i/2+1.2,y:2*A};if(t===2)return{x:-i/2+1.2,y:A};if(t===3)return{x:-i/2+1.2,y:0};if(t===4)return{x:-i/2+1.2,y:-A};if(t===5)return{x:-i/2+1.2,y:-2*A};if(t===6)return{x:i/2-1.175,y:0};throw new Error("Invalid pin number")},l0e=e=>{const A=[];for(let r=1;r<=e.num_pins;r++){const{x:a,y:g}=c0e({h:Number.parseFloat(e.h),p:1.3,pn:r,w:8.7});let I=Number.parseFloat(e.pw),c=Number.parseFloat(e.pl);r===6?(I=3.4,c=2.15):(I=.6,c=2.2),A.push(di(r,a,g,c,I))}const t=Number.parseFloat(e.w)/2-2.4,i=Number.parseFloat(e.h)/2,n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t,y:i},{x:t,y:i},{x:t,y:i/2+.5}],type:"pcb_silkscreen_path",stroke_width:.1},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t,y:-i},{x:t,y:-i},{x:t,y:-i/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1},s=Oi(0,0,.3);return[...A,n,o,s]},B0e=Wi.extend({fn:J(),num_pins:WA().default(3),w:J().default("3.40mm"),h:J().default("3.30mm"),pl:J().default("1mm"),pw:J().default("0.7mm"),p:J().default("1.2mm"),string:J().optional()}),C0e=e=>{const A=e.string?.match(/^sot23w_(\d+)/),t=A?Number.parseInt(A[1],3):3,i=B0e.parse({...e,num_pins:t});if(i.num_pins===3)return{circuitJson:E0e(i),parameters:i};throw new Error("Invalid number of pins")},Q0e=e=>{const{pn:A,p:t}=e;return A===1?{x:-t,y:.95}:A===2?{x:-t,y:-.95}:{x:t,y:0}},E0e=e=>{const A=[];for(let r=0;r<e.num_pins;r++){const{x:a,y:g}=Q0e({num_pins:e.num_pins,pn:r+1,w:Number.parseFloat(e.w),h:Number.parseFloat(e.h),pl:Number.parseFloat(e.pl),p:Number.parseFloat(e.p)});A.push(di(r+1,a,g,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}const t=Oi(0,Number.parseInt(e.h)/2+1,.3),i=Number.parseFloat(e.w)/2-1,n=Number.parseFloat(e.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n},{x:i+.3,y:n},{x:i+.3,y:n/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n},{x:i+.3,y:-n},{x:i+.3,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,t]},h0e=Wi.extend({fn:J(),num_pins:Ze([bA(3),bA(2)]).default(3),p:J().default("1.27mm"),id:J().default("0.72mm"),od:J().default("0.95mm"),w:J().default("2.5mm"),h:J().default("4.2mm"),string:J().optional()}),u0e=e=>{const{p:A,id:t,od:i,w:n,h:o}=e,s=Number.parseFloat(o)/2,r=Number.parseFloat(A);return[zo(1,-r,s-r,t,i),zo(2,0,s-r,t,i),zo(3,r,s-r,t,i)]},d0e=e=>{const{p:A,id:t,od:i,h:n}=e,o=Number.parseFloat(n)/2,s=Number.parseFloat(A);return[zo(1,-s,o-s,t,i),zo(2,s,o-s,t,i)]},p0e=e=>{const A=e.string?.match(/^to92s_(\d+)/),t=A?Number.parseInt(A[1],10):3,i=h0e.parse({...e,num_pins:t});let n=[];if(i.num_pins===3)n=u0e(i);else if(i.num_pins===2)n=d0e(i);else throw new Error("Invalid number of pins for TO-92");const o=Number.parseFloat(i.h)/2,s=Number.parseFloat(i.p),r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-o,y:o-s},{x:-1.9,y:0},{x:1.9,y:0},{x:o,y:o-s},{x:1.5,y:Number.parseFloat(i.h)/2+.5},{x:-1.5,y:Number.parseFloat(i.h)/2+.5},{x:-o,y:o-s}],stroke_width:.1,pcb_silkscreen_path_id:""},a=Oi(0,o+1,.5);return{circuitJson:[...n,r,a],parameters:i}},f0e=Wi.extend({fn:J(),p:CA.optional(),id:CA.optional(),pw:CA.optional(),pl:CA.optional(),w:CA.optional(),h:CA.optional(),sh:Ze([gt(),J(),WA()]).optional().transform(e=>{if(typeof e=="string"){const A=Number(e);return Number.isNaN(A)?!0:A}return e}).describe('JST SH (Surface-mount) connector family. SH stands for "Super High-density".'),ph:gt().optional().describe('JST PH (Through-hole) connector family. PH stands for "Pin Header".'),string:J().optional()}),y0e={ph:{p:CA.parse("2.2mm"),id:CA.parse("0.70mm"),pw:CA.parse("1.20mm"),pl:CA.parse("1.20mm"),w:CA.parse("6mm"),h:CA.parse("5mm")},sh:{p:CA.parse("1mm"),pw:CA.parse("0.6mm"),pl:CA.parse("1.55mm"),w:CA.parse("5.8mm"),h:CA.parse("7.8mm")}};function m0e(e){return e.sh?"sh":(e.ph,"ph")}function w0e(e,A,t,i,n,o){const s=[];if(e==="ph"){const r=t/2;s.push(nb(1,-r,2,i,n,o)),s.push(nb(2,r,2,i,n,o))}else{const r=-((A-1)/2)*t;for(let g=0;g<A;g++){const I=r+g*t;console.log("x si",I),s.push(di(g+1,I,-1.325,n,o))}const a=(A-1)/2*t+1.3;console.log("offset",a),s.push(di(A+1,-a,1.22,1.2,1.8)),s.push(di(A+2,a,1.22,1.2,1.8))}return s}function D0e(e,A,t){return e==="ph"?{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:""}:{type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[],stroke_width:.1,pcb_silkscreen_path_id:""}}var S0e=e=>{const A=f0e.parse(e),t=m0e(A),i=y0e[t],n=A.p??i.p,o=A.id??i.id,s=A.pw??i.pw,r=A.pl??i.pl,a=A.w??i.w,g=A.h??i.h;let I=t==="sh"?4:2;if(t==="sh"){const E=(typeof e.string=="string"?e.string:"").match(/sh(\d+)/);if(E&&E[1]){const Q=parseInt(E[1],10);Number.isNaN(Q)||(I=Q)}else typeof A.sh=="number"&&(I=A.sh)}const c=w0e(t,I,n,o,s,r),l=D0e(t),B=Oi(0,g/2+1,.5);return{circuitJson:[...c,l,B],parameters:{...A,p:n,id:o,pw:s,pl:r,w:a,h:g,num_pins:I,sh:t==="sh",ph:t==="ph"}}},b0e=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("3.30mm"),h:J().default("1.70mm"),pl:J().default("0.80mm"),pw:J().default("1mm"),p:J().default("1.90mm")}),x0e=e=>{const A=b0e.parse(e),t=Oi(0,CA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:k0e(A).concat(i,t),parameters:A}},_0e=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},k0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=_0e({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},G0e=e=>{switch(e){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"}}},F0e=Wi.extend({fn:J(),num_pins:Ze([bA(8),bA(10)]).default(8),w:J().optional(),h:J().optional(),p:J().optional(),pl:J().optional(),pw:J().optional(),string:J().optional()}),M0e=e=>{const A=F0e.parse(e),t=G0e(A.num_pins),i=CA.parse(A.w||t.w),n=CA.parse(A.h||t.h),o=CA.parse(A.p||t.p),s=CA.parse(A.pl||t.pl),r=CA.parse(A.pw||t.pw),a=[],g=A.num_pins/2;for(let u=0;u<A.num_pins;u++){const{x:d,y:f}=NzA(A.num_pins,u+1,i,o),m=u<g?u+1:A.num_pins-(u-g);a.push(di(m,d,f,s,r))}const I=i,c=n,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:c/2},{x:I/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-I/2,y:-c/2},{x:I/2,y:-c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=NzA(A.num_pins,1,I,o),E={x:C.x-.8,y:C.y},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:E.x-.4,y:E.y},{x:E.x-.7,y:E.y+.3},{x:E.x-.7,y:E.y-.3},{x:E.x-.4,y:E.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Oi(0,c/2+.5,.3);return{circuitJson:[...a,l,B,h,Q],parameters:A}},NzA=(e,A,t,i)=>{const n=e/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*CA.parse(e===8?"1.8mm":"2.2mm"),y:r*i}},R0e=e=>{switch(e){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"}}},N0e=Wi.extend({fn:J(),num_pins:Ze([bA(8),bA(10),bA(12),bA(16)]).default(8),w:J().optional(),h:J().optional(),p:J().optional(),pl:J().optional(),pw:J().optional(),string:J().optional()}),vzA=(e,A,t,i)=>{const n=e/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*CA.parse("2mm"),y:r*i}},v0e=e=>{const A=N0e.parse(e),t=R0e(A.num_pins),i=CA.parse(A.w||t.w),n=CA.parse(A.h||t.h),o=CA.parse(A.p||t.p),s=CA.parse(A.pl||t.pl),r=CA.parse(A.pw||t.pw),a=[];for(let h=0;h<A.num_pins;h++){const{x:u,y:d}=vzA(A.num_pins,h+1,i,o);a.push(di(h+1,u,d,s,r))}const g=i,I=n,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:I/2},{x:g/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-I/2},{x:g/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B=vzA(A.num_pins,1,g,o),C={x:B.x-.8,y:B.y},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:C.x-.4,y:C.y},{x:C.x-.7,y:C.y+.3},{x:C.x-.7,y:C.y-.3},{x:C.x-.4,y:C.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},Q=Oi(0,I/2+.5,.3);return{circuitJson:[...a,c,l,Q,E],parameters:A}},L0e=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("3.8mm"),h:J().default("1.65mm"),pl:J().default("1.2mm"),pw:J().default("1.2mm"),pad_spacing:J().default("2.6mm")}),U0e=e=>{const A=L0e.parse(e),t=Oi(0,CA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.pad_spacing)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:-CA.parse(A.h)/2},{x:CA.parse(A.pad_spacing)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Y0e(A).concat(i,t),parameters:A}},H0e=e=>{const{pn:A,pad_spacing:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Y0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=H0e({pn:t,pad_spacing:Number.parseFloat(e.pad_spacing)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},J0e=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("3.20mm"),h:J().default("1.65mm"),pl:J().default("0.8mm"),pw:J().default("0.9mm"),pad_spacing:J().default("2.1mm")}),T0e=e=>{const A=J0e.parse(e),t=Oi(0,CA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.pad_spacing)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.2,y:-CA.parse(A.h)/2},{x:CA.parse(A.pad_spacing)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:P0e(A).concat(i,t),parameters:A}},K0e=e=>{const{pn:A,pad_spacing:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},P0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=K0e({pn:t,pad_spacing:Number.parseFloat(e.pad_spacing)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},q0e=Wi.extend({fn:J(),num_pins:Ze([bA(6),bA(8)]).default(8),w:J().default("3mm"),h:J().default("3mm"),p:J().default("0.5mm"),pl:J().default("0.52mm"),pw:J().default("0.35mm"),epw:J().default("1.40mm"),eph:J().default("1.60mm"),string:J().optional(),ep:gt().default(!1)}),O0e=e=>{e.string&&e.string.includes("_ep")&&(e.ep=!0);const A=e.string?.match(/^son_(\d+)/),t=A?Number.parseInt(A[1],10):e.num_pins||8,i=q0e.parse({...e,num_pins:t}),n=CA.parse(i.w),o=CA.parse(i.h),s=CA.parse(i.p),r=CA.parse(i.pl),a=CA.parse(i.pw),g=CA.parse(i.epw),I=CA.parse(i.eph),c=[];for(let f=0;f<i.num_pins;f++){const{x:m,y:w}=LzA(i.num_pins,f+1,n,s);c.push(di(f+1,m,w,r,a))}i.ep&&c.push(di(i.num_pins+1,0,0,g,I));const l=n,B=o,C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:B/2},{x:l/2,y:B/2}],stroke_width:.05,pcb_silkscreen_path_id:""},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-l/2,y:-B/2},{x:l/2,y:-B/2}],stroke_width:.05,pcb_silkscreen_path_id:""},Q=LzA(i.num_pins,1,l,s),h={x:Q.x-.4,y:Q.y},u={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"},d=Oi(0,B/2+.5,.3);return{circuitJson:[...c,C,E,d,u],parameters:i}},LzA=(e,A,t,i)=>{const n=e/2,o=(A-1)%n,s=A<=n?-1:1,r=(n-1)/2-o;return{x:s*CA.parse("1.4mm"),y:r*i}},W0e=e=>{const{num_pins:A,bridged:t,p:i=2.54,pw:n=1.5,ph:o=1.5}=e,s=CA.parse(i),r=CA.parse(n),a=CA.parse(o),g=Math.min(a/4,.5),I=[];for(let f=0;f<A;f++)I.push(di(f+1,f*s,0,r,a));let c=[];if(t){const f=t.split("").map(Number);if(f.length>1)for(let m=0;m<f.length-1;m++){const w=f[m],D=f[m+1];if(typeof w=="number"&&typeof D=="number"&&!isNaN(w)&&!isNaN(D)){const b=(w-1)*s,k=(D-1)*s,x=Math.sign(k-b),N=b+x*(r/2),R=k-x*(r/2);c.push({type:"pcb_trace",pcb_trace_id:"",route:[{start_pcb_port_id:`{PIN${w}}`,x:N,y:0,width:g,layer:"top",route_type:"wire"},{end_pcb_port_id:`{PIN${D}}`,x:R,y:0,width:g,layer:"top",route_type:"wire"}]})}}}const l=(A-1)*s+r+.7,B=a+1,C=(A-1)*s/2,E=0,Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:C-l/2,y:E-B/2},{x:C+l/2,y:E-B/2},{x:C+l/2,y:E+B/2},{x:C-l/2,y:E+B/2},{x:C-l/2,y:E-B/2}],stroke_width:.15},u=E+B/2+.6,d=Oi(C,u,.4);return{circuitJson:[...I,...c,Q,d],parameters:e}},UzA={fn:bA("sot457"),num_pins:bA(6).default(6),pillh:J().default("0.45mm"),pillw:J().default("1.45mm"),pl:J(),pw:J(),p:J(),wave:gt().optional(),reflow:gt().optional()},Z0e=Wi.extend({...UzA,h:J().default("2.5mm"),w:J().default("2.7mm"),pl:J().default("0.8mm"),pw:J().default("0.55mm"),p:J().default("0.95mm")}),V0e=Wi.extend({...UzA,h:J().default("3mm"),w:J().default("4mm"),pillr:J().default("0.225mm"),pl:J().default("1.45mm"),pw:J().default("1.5mm"),p:J().default("1.475mm")}).transform(e=>({...e,wave:e.wave??(e.reflow===void 0?!0:!e.reflow),reflow:e.reflow??(e.wave===void 0?!1:!e.wave)})),ob=e=>Number.parseFloat(e.replace("mm","")),HzA=({pitch:e,width:A,pinNumber:t})=>{const o={1:{x:-A/2-.1,y:e},2:{x:-A/2-.1,y:0},3:{x:-A/2-.1,y:-e},4:{x:A/2+.1,y:-e},5:{x:A/2+.1,y:0},6:{x:A/2+.1,y:e}}[t];if(!o)throw new Error(`Invalid pin number: ${t}`);return o},YzA=e=>{const A=[],t=ob(e.p),i=ob(e.pl),n=ob(e.pw),o=ob(e.w),s=ob(e.h);if(e.wave){const C={1:({padWidth:E,padHeight:Q})=>di(1,-t,t,Q,E),2:({padWidth:E,padHeight:Q})=>di(2,-t,-t,Q,E),3:({padWidth:E,padHeight:Q})=>eW(3,-t,0,ob(e.pillw),ob(e.pillh)),4:({padWidth:E,padHeight:Q})=>eW(4,t,0,ob(e.pillw),ob(e.pillh)),5:({padWidth:E,padHeight:Q})=>di(5,t,t,Q,E),6:({padWidth:E,padHeight:Q})=>di(6,t,-t,Q,E)};for(let E=1;E<=e.num_pins;E++){const Q=C[E];Q&&A.push(Q({padWidth:i,padHeight:n}))}}else for(let C=1;C<=e.num_pins;C++){const{x:E,y:Q}=HzA({pitch:t,width:o,pinNumber:C});A.push(di(C,E,Q,i,n))}const r={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-o/3,y:s/2+t/1.3},{x:o/3,y:s/2+t/1.3}],stroke_width:.05},a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-o/3,y:-s/2-t/1.3},{x:o/3,y:-s/2-t/1.3}],stroke_width:.05},g=Oi(0,s+.5,.3),I=HzA({pitch:t,width:o,pinNumber:1}),c=e.wave?1:.5,l=e.wave?.7:.3;I.x-=e.wave?n:n*1.7;const B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:I.x+c/2,y:I.y},{x:I.x-c/2,y:I.y+l/2},{x:I.x-c/2,y:I.y-l/2},{x:I.x+c/2,y:I.y}],stroke_width:.05};return[g,r,a,B,...A]},j0e=e=>{if(e.wave){const t=V0e.parse({...e,fn:"sot457"});return{circuitJson:YzA(t),parameters:t}}const A=Z0e.parse(e);return{circuitJson:YzA(A),parameters:A}},z0e=Wi.extend({fn:J(),num_pins:bA(6).default(6),w:J().default("1.1mm"),h:J().default("1.45mm"),p:J().default("0.35mm"),pl:J().default("0.2mm"),pw:J().default("0.2mm"),string:J().optional()}),X0e=e=>{const A=z0e.parse({...e,fn:"sot963"}),t=CA.parse(A.w),i=CA.parse(A.h),n=CA.parse(A.p),o=CA.parse(A.pl),s=CA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:E}=JzA(B+1,t,n,o);r.push(di(B+1,C,E,o,s))}const a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:i/2},{x:t/2,y:i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-t/2,y:-i/2},{x:t/2,y:-i/2}],stroke_width:.05,pcb_silkscreen_path_id:""},I=JzA(1,t,n,o),c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:I.x-o/2-.3,y:I.y},{x:I.x-o/2-.45,y:I.y+.15},{x:I.x-o/2-.45,y:I.y-.15},{x:I.x-o/2-.3,y:I.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Oi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,c],parameters:A}},JzA=(e,A,t,i)=>{const n=A/2-i/2;return e<=3?{x:-n,y:t-(e-1)*t}:{x:n,y:-t+(e-4)*t}},$0e=Wi.extend({fn:J(),num_pins:Ze([bA(3),bA(2)]).default(3),p:J().default("3.8mm"),id:J().default("1.25mm"),od:J().default("2.35mm"),ca:J().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:J().default("5.35mm"),h:J().default("4mm"),string:J().optional()}),Aye=e=>{const{p:A,id:t,od:i,h:n,ca:o}=e,s=Number.parseFloat(n),r=Number.parseFloat(o);return[zo(1,0,r/4+.3,t,i),zo(2,s,0,t,i),zo(3,0,-r/4-.3,t,i)]},tye=e=>{const A=e.string?.match(/^potentiometer_(\d+)/),t=A?Number.parseInt(A[1],10):3,i=$0e.parse({...e,num_pins:t});let n=[];i.num_pins===3&&(n=Aye(i));const o=Number.parseFloat(i.ca)/2+.15,s=Number.parseFloat(i.w),r=Number.parseFloat(i.od)/2+.35,a={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o-1.75},{x:0,y:o},{x:s,y:o},{x:s,y:r}],stroke_width:.1,pcb_silkscreen_path_id:""},g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:s,y:-r},{x:s,y:-o},{x:0,y:-o},{x:0,y:-o+1.75}],stroke_width:.1,pcb_silkscreen_path_id:""},I=Number.parseFloat(i.w)/2,c=Oi(I,o+1,.5);return{circuitJson:[...n,a,g,c],parameters:i}},eye=Wi.extend({fn:J(),p:CA.optional().default("7.5mm"),id:CA.optional().default("1mm"),od:CA.optional().default("2mm"),d:CA.optional().default("10.5mm")}),iye=(e,A,t,i,n)=>{const o=[],s=[];for(let r=0;r<=50;r++){const a=r/50*Math.PI,g=e+Math.cos(a)*t,I=A+Math.sin(a)*t;g<e-i&&I>=A-n/2&&I<=A+n/2||o.push({x:g,y:I})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=e+Math.cos(a)*t,I=A+Math.sin(a)*t;g<e-i&&I>=A-n/2&&I<=A+n/2||s.push({x:g,y:I})}return{topArc:o,bottomArc:s}},nye=e=>{const A=eye.parse(e),{p:t,id:i,od:n,d:o}=A,s=[zo(1,-t/2,0,i,n),zo(2,t/2,0,i,n)],{topArc:r,bottomArc:a}=iye(0,0,o/2+.1,n/2,n),g={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:.1,pcb_silkscreen_path_id:""},I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:0,y:o/2+.1},{x:0,y:-(o/2+.1)}],stroke_width:.1,pcb_silkscreen_path_id:""},l=-(o/2+.5),B=n/2+1.5,C=.5,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l-C,y:B},{x:l+C,y:B}],stroke_width:.1,pcb_silkscreen_path_id:""},Q={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:l,y:B-C},{x:l,y:B+C}],stroke_width:.1,pcb_silkscreen_path_id:""},h=Oi(0,o/2+1,.5);return{circuitJson:[...s,g,I,c,E,Q,h],parameters:A}},oye=Wi.extend({fn:J(),num_pins:bA(2).default(2),w:J().default("6.5mm"),h:J().default("3mm"),pl:J().default("1.75mm"),pw:J().default("2.40mm"),p:J().default("4.75mm")}),sye=e=>{const A=oye.parse(e),t=Oi(0,CA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:CA.parse(A.p)/2,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.3,y:CA.parse(A.h)/2},{x:-CA.parse(A.w)/2-.3,y:-CA.parse(A.h)/2},{x:CA.parse(A.p)/2,y:-CA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:aye(A).concat(i,t),parameters:A}},rye=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},aye=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=rye({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},gye=Wi.extend({fn:J(),num_pins:WA().default(3),w:J().default("2.45mm"),h:J().default("2.40mm"),pl:J().default("1.225mm"),pw:J().default("0.5mm"),p:J().default("0.95mm"),string:J().optional()}),Iye=e=>{const A=e.string?.match(/^sot323_(\d+)/),t=A?Number.parseInt(A[1],3):3,i=gye.parse({...e,num_pins:t});if(i.num_pins===3)return{circuitJson:lye(i),parameters:i};throw new Error("Invalid number of pins")},cye=e=>{const{pn:A,p:t}=e;return A===1?{x:-t,y:.65}:A===2?{x:-t,y:-.65}:{x:t,y:0}},lye=e=>{const A=[];for(let r=0;r<e.num_pins;r++){const{x:a,y:g}=cye({num_pins:e.num_pins,pn:r+1,w:Number.parseFloat(e.w),h:Number.parseFloat(e.h),pl:Number.parseFloat(e.pl),p:Number.parseFloat(e.p)});A.push(di(r+1,a,g,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}const t=Oi(0,Number.parseInt(e.h)/2+1,.3),i=Number.parseFloat(e.w)/2-Number.parseFloat(e.pl),n=Number.parseFloat(e.h)/2,o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-i,y:n+.3},{x:i,y:n+.3},{x:i,y:n/2}],type:"pcb_silkscreen_path",stroke_width:.1},s={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-i,y:-n-.3},{x:i,y:-n-.3},{x:i,y:-n/2}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,o,s,t]},Bye=Wi.extend({fn:J(),circle:gt().optional(),rect:gt().optional(),square:gt().optional(),pill:gt().optional(),d:CA.optional(),pd:CA.optional(),diameter:CA.optional(),r:CA.optional(),pr:CA.optional(),radius:CA.optional(),w:CA.optional(),pw:CA.optional(),width:CA.optional(),h:CA.optional(),ph:CA.optional(),height:CA.optional(),s:CA.optional(),size:CA.optional(),string:J().optional()}).transform(e=>{let A="rect";e.circle&&(A="circle"),e.square&&(A="square"),e.rect&&(A="rect"),e.pill&&(A="pill");let t,i,n;return A==="circle"?e.r!==void 0?t=Gr(e.r):e.pr!==void 0?t=Gr(e.pr):e.radius!==void 0?t=Gr(e.radius):e.d!==void 0?t=Gr(e.d)/2:e.pd!==void 0?t=Gr(e.pd)/2:e.diameter!==void 0?t=Gr(e.diameter)/2:t=Gr("1mm")/2:(e.w!==void 0?i=Gr(e.w):e.pw!==void 0?i=Gr(e.pw):e.width!==void 0?i=Gr(e.width):e.s!==void 0?i=Gr(e.s):e.size!==void 0?i=Gr(e.size):i=Gr("1mm"),e.h!==void 0?n=Gr(e.h):e.ph!==void 0?n=Gr(e.ph):e.height!==void 0?n=Gr(e.height):A==="square"||A==="rect"?n=i:n=Gr("1mm")),{fn:e.fn,shape:A,radius:t,width:i,height:n}}),Cye=e=>{const A=Bye.parse(e),{shape:t,radius:i,width:n,height:o}=A;let s,r;return t==="circle"?(s=fzA(1,{x:0,y:0,radius:i}),r=i+.5):t==="pill"?(s=eW(1,0,0,n,o),r=Math.max(n,o)/2+.5):(s=di(1,0,0,n,o),r=o/2+.5),{circuitJson:[s,Oi(0,r,.2)],parameters:A}},Qye=Wi.extend({fn:J(),d:CA.optional(),hd:CA.optional(),r:CA.optional(),hr:CA.optional(),pd:CA.optional(),pr:CA.optional(),squarepad:gt().optional().default(!1)}).transform(e=>{let A;e.d!==void 0?A=Gr(e.d):e.hd!==void 0?A=Gr(e.hd):e.r!==void 0?A=Gr(e.r)*2:e.hr!==void 0?A=Gr(e.hr)*2:A=Gr("1mm");let t;return e.pd!==void 0?t=Gr(e.pd):e.pr!==void 0?t=Gr(e.pr)*2:t=A*(1.5/1),{fn:e.fn,d:A,pd:t,squarepad:e.squarepad??!1}}),Eye=e=>{const A=Qye.parse(e),{d:t,pd:i,squarepad:n}=A;return{circuitJson:[n?nb(1,0,0,t,i,i):zo(1,0,0,t,i),Oi(0,i/2+.5,.2)],parameters:A}},hye=Wi.extend({fn:J(),num_pins:bA(6).default(6),h:J().default("1.6mm"),pl:J().default("1mm"),pw:J().default("0.7mm"),p:J().default("0.95mm")}),uye=e=>{const A=hye.parse(e);return{circuitJson:dye(A),parameters:A}},TzA=e=>{const{p:A,h:t,pn:i}=e;if(i===1)return{x:-t/2-.5,y:A};if(i===2)return{x:-t/2-.5,y:0};if(i===3)return{x:-t/2-.5,y:-A};if(i===4)return{x:t/2+.5,y:-A};if(i===5)return{x:t/2+.5,y:0};if(i===6)return{x:t/2+.5,y:A};throw new Error("Invalid pin number")},dye=e=>{const A=[];for(let c=1;c<=e.num_pins;c++){const{x:l,y:B}=TzA({h:Number.parseFloat(e.h),p:Number.parseFloat(e.p),pn:c});A.push(di(c,l,B,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}const t=e.num_pins/2*Number.parseFloat(e.p),i=Number.parseFloat(e.h),n={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-t/3,y:i/2+Number.parseFloat(e.p)/1.3},{x:t/3,y:i/2+Number.parseFloat(e.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},o={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_2",route:[{x:-t/3,y:-i/2-Number.parseFloat(e.p)/1.3},{x:t/3,y:-i/2-Number.parseFloat(e.p)/1.3}],type:"pcb_silkscreen_path",stroke_width:.05},s=Oi(0,i+.3,.3),r=TzA({h:Number.parseFloat(e.h),p:Number.parseFloat(e.p),pn:1});r.x=r.x-Number.parseFloat(e.pw)*1.5;const a=.7,g=.3,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"pin1_indicator",route:[{x:r.x+a/2,y:r.y},{x:r.x-a/2,y:r.y+g/2},{x:r.x-a/2,y:r.y-g/2},{x:r.x+a/2,y:r.y}],stroke_width:.05};return[...A,s,n,o,I]},pye=Wi.extend({fn:J(),num_pins:WA().default(4),w:J().default("3.2mm"),h:J().default("2.6mm"),pl:J().default("1.35mm"),pw:J().default("0.50mm"),p:J().default("0.6mm"),string:J().optional()}),fye=e=>{const A=e.string?.match(/^sot343_(\d+)/),t=A?Number.parseInt(A[1],4):4,i=pye.parse({...e,num_pins:t});if(i.num_pins===4)return{circuitJson:mye(i),parameters:i};throw new Error("Invalid number of pins")},yye=e=>{const{pn:A,p:t}=e;return A===1?{x:-t*1.92,y:-.65}:A===2?{x:-t*1.92,y:.65}:A===3?{x:t,y:.65}:A===4?{x:t,y:-.65}:{x:0,y:0}},mye=e=>{const A=[],t=Number.parseFloat(e.w),i=Number.parseFloat(e.h),n=Number.parseFloat(e.pl),o=Number.parseFloat(e.pw),s=Number.parseFloat(e.p);let r=1/0,a=-1/0,g=1/0,I=-1/0;for(let d=0;d<e.num_pins;d++){const{x:f,y:m}=yye({num_pins:e.num_pins,pn:d+1,p:s});A.push(di(d+1,f,m,n,o)),f<r&&(r=f),f>a&&(a=f),m<g&&(g=m),m>I&&(I=m)}const c=(r+a)/2,l=I-g,B=i*.3,C=l/2+B;let E=t*.8;i<=2.6&&(E/=2);const Q=Oi(c,C+.5,.3),h={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:c-E/2,y:C},{x:c+E/2,y:C}],type:"pcb_silkscreen_path",stroke_width:.1},u={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_bottom",route:[{x:c-E/2,y:-C},{x:c+E/2,y:-C}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,h,u,Q]},wye=Wi.extend({fn:J()}),Dye=e=>{const A=wye.parse(e),t=[],i=.5-.15,n=1.5,s=.5/2,r=75,a=-37/2;for(let D=0;D<r;D++){const b=D+1;if(b>=24&&b<=31)continue;const k=a-D*s,x=b%2===0,N=n+(x?.25:0),U=.5-N/2,Y=di(b,U,k,N,i);Y.layer=x?"bottom":"top",t.push(Y)}const g=46*.0254,I=137*.0254,c=261*.0254,l={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-I/2+n/2,y:a-c},width:I,height:g},B={x:-.5,y:a},C={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:B.x-.4,y:B.y},{x:B.x-.7,y:B.y+.3},{x:B.x-.7,y:B.y-.3},{x:B.x-.4,y:B.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"};let E=1/0,Q=-1/0,h=1/0,u=-1/0;const d=(D,b,k=0,x=0)=>{E=Math.min(E,D-k/2),Q=Math.max(Q,D+k/2),h=Math.min(h,b-x/2),u=Math.max(u,b+x/2)};for(const D of t)d(D.x,D.y,D.width,D.height);d(l.center.x,l.center.y,l.width,l.height);for(const D of C.route)d(D.x,D.y);const f=(E+Q)/2,m=(h+u)/2,w=D=>{typeof D.x=="number"&&(D.x-=f),typeof D.y=="number"&&(D.y-=m),D.center&&(D.center.x-=f,D.center.y-=m),Array.isArray(D.route)&&(D.route=D.route.map(b=>({x:b.x-f,y:b.y-m})))};for(const D of t)w(D);return w(l),w(C),{circuitJson:[...t,l,C],parameters:A}},Sye=Wi.extend({fn:J(),num_pins:WA().default(3),inline:gt().default(!1),p:J().default("1.27mm"),id:J().default("0.75mm"),od:J().default("1.3mm"),w:J().default("4.8mm"),h:J().default("4.0mm")}),bye=e=>{const A=Sye.parse(e),t=Number.parseFloat(A.p),i=Number.parseFloat(A.w),n=Number.parseFloat(A.h),o=A.inline?1.05:Number.parseFloat(A.od),s=A.inline?1.5:o,r=[nb(1,0,0,A.id,o,s,0,0),A.inline?nH(2,t,0,A.id,o,s):zo(2,t,t,A.id,o),A.inline?nH(3,t*2,0,A.id,o,s):zo(3,t*2,0,A.id,o)],a=i/2,g=A.inline?t-.09:t,I=.2,c=I+a-n,l=Array.from({length:32},(E,Q)=>{const h=Math.PI*Q/31;return{x:g+a*Math.cos(h),y:I+a*Math.sin(h)}}),B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"",stroke_width:.12,route:[...l,{x:g-a,y:c},{x:g+a,y:c},l[0]]},C=Oi(g,I+a+1,.5);return{circuitJson:[...r,B,C],parameters:A}};function xye(e){return e!=null}var _ye=(e,A)=>{if(!A)return e;const t=e.filter(I=>I.type==="pcb_smtpad"||I.type==="pcb_plated_hole"||I.type==="pcb_thtpad");if(t.length===0)return e;let i=1/0,n=-1/0,o=1/0,s=-1/0;const r=(I,c,l=0,B=0)=>{const C=I-l/2,E=I+l/2,Q=c-B/2,h=c+B/2;i=Math.min(i,C),n=Math.max(n,E),o=Math.min(o,Q),s=Math.max(s,h)};for(const I of t)if(I.type==="pcb_smtpad"){const c=I.shape==="circle"?I.radius*2:I.width,l=I.shape==="circle"?I.radius*2:I.height;r(I.x,I.y,c,l)}else if(I.type==="pcb_plated_hole"){const c=I.outer_diameter??I.hole_diameter;r(I.x,I.y,c,c)}else if(I.type==="pcb_thtpad"){const c=I.diameter;r(I.x,I.y,c,c)}let a=0,g=0;switch(A){case"center":a=(i+n)/2,g=(o+s)/2;break;case"bottomleft":a=i,g=o;break;case"bottomcenter":case"centerbottom":a=(i+n)/2,g=o;break;case"topcenter":case"centertop":a=(i+n)/2,g=s;break;case"leftcenter":case"centerleft":a=i,g=(o+s)/2;break;case"rightcenter":case"centerright":a=n,g=(o+s)/2;break;case"pin1":const I=t.find(c=>c.port_hints?.[0]==="1")||t[0];a=I.x,g=I.y;break}if(a===0&&g===0)return e;for(const I of e){if(typeof I.x=="number"&&(I.x-=a),typeof I.y=="number"&&(I.y-=g),I.center&&typeof I.center.x=="number"&&(I.center.x-=a,I.center.y-=g),I.type==="pcb_silkscreen_path")for(const c of I.route)c.x-=a,c.y-=g;I.type==="pcb_silkscreen_text"&&I.anchor_position&&(I.anchor_position.x-=a,I.anchor_position.y-=g)}return e},kye=(e,A)=>{const t=e.filter(i=>i.type==="pcb_silkscreen_text");if(t.length===0)return e;for(const i of t)A.norefdes&&(i.text="");return e},Gye=(e,A)=>A.nosilkscreen?e.filter(t=>t.type!=="pcb_silkscreen_path"&&t.type!=="pcb_silkscreen_text"):e,Fye=e=>{let A=sW();const i=e.replace(/^((?:\d{4}|\d{5}))(?=$|_)/,"res$1").split(/_(?!metric)/).map(n=>{const o=n.match(/([a-zA-Z]+)([\(\d\.\+\?].*)?/);if(!o)return null;const[,s,r]=o;if(!s)return null;const a=s.toLowerCase();return r?.includes("?")?null:{fn:a,v:r}}).filter(xye);for(const{fn:n,v:o}of i)A=A[n](o);return A.setString(e),A},Mye=()=>Object.keys(ib),sW=()=>{const e=new Proxy({},{get:(A,t)=>{if(t==="soup"||t==="circuitJson"){if("fn"in A&&ib[A.fn])return()=>{const{circuitJson:i}=ib[A.fn](A),n=Gye(i,A),o=kye(n,A);return _ye(o,A.origin)};if(!ib[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>{throw new Error(`No function found for footprinter, make sure to specify .dip, .lr, .p, etc. Got "${t}"`)}}if(t==="json"){if(!ib[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>ib[A.fn](A).parameters}return t==="getFootprintNames"?()=>Object.keys(ib):t==="params"?()=>A:t==="setString"?i=>(A.string=i,e):i=>(Object.keys(A).length===0?`${t}${i}`in ib?(A[`${t}${i}`]=!0,A.fn=`${t}${i}`):(A[t]=!0,A.fn=t,t==="res"||t==="cap"?i&&(typeof i=="string"&&i.includes("_metric")?A.metric=i.split("_metric")[0]:A.imperial=i):A.num_pins=Number.isNaN(Number.parseFloat(i))?void 0:Number.parseFloat(i)):!i&&["w","h","p"].includes(t)||(A[t]=i??!0),e)}});return e};sW.string=Fye,sW.getFootprintNames=Mye;var Rye=sW,KzA=Symbol("Fragment");function rEA(e,A,...t){const i=t.length?t:A?.children!==void 0?[A.children]:[],n=[],o=(Array.isArray(i)?i:[i]).flat(1/0);for(const s of o)s==null||s===!1||(Array.isArray(s)?n.push(...s):n.push(s));return{type:e,props:(A&&A.children!==void 0?{...A,children:void 0}:A)||{},children:n}}var Qe=Symbol("Cuboid"),PzA=Symbol("Cube"),Gl=Symbol("Cylinder"),rW=Symbol("Sphere"),oH=Symbol("RoundedCuboid"),Pi=Symbol("Translate"),XB=Symbol("Rotate"),NQ=Symbol("Union"),jm=Symbol("Subtract"),uI=Symbol("Hull"),Ko=Symbol("Colorize"),sH=Symbol("Polygon"),rH=Symbol("ExtrudeLinear"),Cf=Symbol("RoundedCylinder"),Mn=KzA,zA=(e,A,t)=>rEA(e,A),Je=(e,A,t)=>rEA(e,A),gB=({center:e,width:A,length:t,height:i,heightAboveSurface:n=.15,color:o="#555",taperRatio:s=.12,faceRatio:r=.75,straightHeightRatio:a=.5,includeNotch:g=!0,notchRadius:I,notchPosition:c,notchRotation:l=[0,0,0],notchLength:B=.5,notchWidth:C=.25,chamferSize:E=0})=>{const Q=i*a,h=i-Q,u=Math.min(A,t)*s,d=Math.max(A-u,A*r),f=Math.max(t-u,t*r),m=Math.min(A,t)*.12,w=I??m,D={x:0,y:t/2-w*.25,z:i},b=c??D,k=Je(NQ,{children:[Je(uI,{children:[zA(Pi,{z:.005,children:zA(Qe,{size:[d,f,.01]})}),zA(Pi,{z:Q,children:zA(Qe,{size:[A,t,.01]})})]}),Je(uI,{children:[zA(Pi,{z:Q,children:zA(Qe,{size:[A,t,.01]})}),zA(Pi,{z:Q+h,children:zA(Qe,{size:[d,f,.01]})})]})]}),x=(R,U)=>zA(Pi,{offset:{x:R,y:U,z:0},children:zA(XB,{rotation:[0,0,Math.PI/4],children:zA(Qe,{size:[E*Math.SQRT2,E*Math.SQRT2,i*3]})})});let N=k;if(E>0){const R=A/2,U=t/2;N=Je(jm,{children:[k,x(R,U),x(-R,U),x(R,-U),x(-R,-U)]})}return zA(Ko,{color:o,children:zA(Pi,{offset:e,children:zA(Pi,{offset:{x:0,y:0,z:n},children:g?Je(jm,{children:[N,zA(Pi,{offset:b,children:zA(XB,{rotation:l,children:zA(Gl,{radius:w,height:C})})})]}):N})})})},Nye=e=>Array.from({length:e},(A,t)=>t);function aEA(e,A){if(e.length<2)throw new Error("Stroke must have at least two points");const t=Array.isArray(e[0])?e.map(([I,c])=>({x:I,y:c})):e,i=A/2,n=[],o=[];function s(I,c){const l=c.x-I.x,B=c.y-I.y,C=Math.sqrt(l*l+B*B);return{x:-B/C,y:l/C}}function r(I,c,l){const B={x:I.x+c.x*i*l,y:I.y+c.y*i*l};l>0?n.push(B):o.unshift(B)}const a=s(t[0],t[1]);r(t[0],a,1),r(t[0],a,-1);for(let I=1;I<t.length-1;I++){const c=t[I-1],l=t[I],B=t[I+1],C=s(c,l),E=s(l,B),Q=C.x+E.x,h=C.y+E.y,u=Math.sqrt(Q*Q+h*h);if(u/2>2*i)r(l,C,1),r(l,E,1),r(l,C,-1),r(l,E,-1);else{const f=1/u;r(l,{x:Q*f,y:h*f},1),r(l,{x:Q*f,y:h*f},-1)}}const g=s(t[t.length-2],t[t.length-1]);return r(t[t.length-1],g,1),r(t[t.length-1],g,-1),[...n,...o]}var vye=e=>{const A=Math.min(...e.map(r=>r.x)),t=Math.max(...e.map(r=>r.x)),i=Math.min(...e.map(r=>r.y)),s=5.47/(Math.max(...e.map(r=>r.y))-i);return e.map(r=>({x:(r.x-A-(t-A)/2)*s,y:(r.y-i)*s}))},Lye=vye([{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}]),qzA=5.47,aW=.5,Uye=({x:e,y:A,z:t})=>{const i=e>0;return Je(Mn,{children:[zA(Pi,{offset:{x:e+.25/2,y:A,z:t},children:zA(XB,{rotation:["-90deg",0,"90deg"],children:zA(rH,{height:.25,children:zA(sH,{points:Lye.slice().reverse().map(n=>[n.x,n.y])})})})}),zA(Pi,{offset:{x:e,y:A+(i?1:-1),z:t},children:zA(XB,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:zA(rH,{height:2,children:zA(sH,{points:aEA([[0,0],[-1,0],[-1,-1]],.25).map(n=>[n.x,n.y])})})})})]})},Hye=({numPins:e=8,pitch:A=2.54,bodyWidth:t=6.4,rowSpacing:i})=>{const n=Math.floor(e/2),o=i??(t>=7?t:t+1.22),s=t>=7?o-1.22:t;return Je(Mn,{children:[Nye(e).map(r=>{const a=r%n,g=(Math.floor(r/n)-.5)*2;return zA(Uye,{x:g*o/2,y:a*A-(n-1)/2*A,z:qzA/2+aW})}),zA(gB,{width:s,length:n*A+.5,height:qzA-aW,heightAboveSurface:aW,center:{x:0,y:0,z:aW}})]})};function Yye(e,{height:A,padContactLength:t,curveLength:i,bodyDistance:n,steepness:o=10}){i||(i=n*.3);let s=n-t-i;s<0&&(i+=s,s=0);const r=t*.75,a=t+i+(n-t-i)*.25;if(e<=r)return 0;if(e>=a)return A;const g=(e-r)/(a-r);return A/(1+Math.exp(-o*(g-.5)))}var Vn=e=>{const{thickness:A,width:t,padContactLength:i,bodyDistance:n,height:o,rotation:s}=e,r=15,a=Array.from({length:r}).map((I,c)=>c/(r-1)*n).map(I=>[I,Yye(I,e)]),g=aEA(a,A);return zA(Ko,{color:"#fff",children:zA(Pi,{offset:{z:0,y:0,x:0,...e.position},children:zA(XB,{rotation:["90deg",0,s??0],children:zA(Pi,{offset:{x:0,y:0,z:-t/2},children:zA(rH,{height:t,children:zA(sH,{points:g.map(I=>[I.x,I.y])})})})})})})},Jye=({pinCount:e,leadLength:A,leadWidth:t,pitch:i,bodyWidth:n})=>{const o=Math.ceil(e/2),s=i*e/2+t/2,r=(o-1)*i/2,a=.25;return Je(Mn,{children:[Array.from({length:o}).map((g,I)=>zA(Vn,{position:{x:-n/2-A,y:I*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:o}).map((g,I)=>zA(Vn,{rotation:Math.PI,position:{x:n/2+A,y:I*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),zA(gB,{center:{x:0,y:0,z:a/2},width:n-t-1,length:s,height:1.5})]})},Tye=({pinCount:e,padContactLength:A=.4,leadWidth:t=.2,pitch:i=.65,bodyWidth:n=3})=>{const o=Math.ceil(e/2),s=(o-1)*i/2,r=.2;return Je(Mn,{children:[Array.from({length:o}).map((a,g)=>zA(Vn,{position:{x:-n/2-A-.3,y:g*i-s,z:r/2},width:t,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),Array.from({length:o}).map((a,g)=>zA(Vn,{rotation:Math.PI,position:{x:n/2+A+.3,y:g*i-s,z:r/2},width:t,thickness:r,padContactLength:A,bodyDistance:A+.4,height:.6})),zA(gB,{center:{x:0,y:0,z:r/2},width:n,length:n,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},gEA=1,IEA=.5,ZN=.5,aH=.2,Kye=gEA-aH*2,OzA=({color:e="#333"})=>Je(Mn,{children:[zA(Qe,{size:[Kye,IEA,ZN],offset:[0,0,ZN/2],color:e}),zA(Qe,{size:[aH,ZN,IEA],offset:[gEA/2-aH/2,0,ZN/2],color:"#ccc"}),zA(Qe,{size:[aH,ZN,IEA],offset:[-gEA/2+aH/2,0,ZN/2],color:"#ccc"})]}),cEA=1.6,Pye=cEA-.3*2,gW=.3,lEA=.85,VN=.6,WzA=({color:e="#333"})=>Je(Mn,{children:[zA(Qe,{size:[Pye,lEA,VN],offset:[0,0,VN/2],color:e}),zA(Qe,{size:[gW,lEA,VN],offset:[cEA/2-gW/2,0,VN/2],color:"#ccc"}),zA(Qe,{size:[gW,lEA,VN],offset:[-cEA/2+gW/2,0,VN/2],color:"#ccc"})]}),BEA=2,CEA=1.25,jN=.55,gH=.5,qye=BEA-gH*2,ZzA=({color:e="#333"})=>Je(Mn,{children:[zA(Qe,{size:[qye,CEA,jN],offset:[0,0,jN/2],color:e}),zA(Qe,{size:[gH,CEA,jN],offset:[BEA/2-gH/2,0,jN/2],color:"#ccc"}),zA(Qe,{size:[gH,CEA,jN],offset:[-BEA/2+gH/2,0,jN/2],color:"#ccc"})]}),Oye=({pinCount:e,pitch:A,leadWidth:t,padContactLength:i,bodyWidth:n})=>{const o=e/4;A||(A=Wye(e,n)),i||(i=Zye(e)),t||(t=Vye(e,n)),n||(n=A*(o+4));const s=n,r=(o-1)*A/2,a=s+2*i,g=a,I=.8,c=.15,l=(g-n)/2+.5;return Je(Mn,{children:[Array.from({length:o}).map((B,C)=>zA(Vn,{position:{x:-g/2-.4,y:C*A-r,z:c/2},width:t,thickness:c,padContactLength:i,bodyDistance:l,height:I})),Array.from({length:o}).map((B,C)=>zA(Vn,{rotation:Math.PI,position:{x:g/2+.4,y:C*A-r,z:c/2},width:t,thickness:c,padContactLength:i,bodyDistance:l,height:I})),Array.from({length:o}).map((B,C)=>zA(Vn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.4,z:c/2},width:t,thickness:c,padContactLength:i,bodyDistance:l,height:I})),Array.from({length:o}).map((B,C)=>zA(Vn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.4,z:c/2},width:t,thickness:c,padContactLength:i,bodyDistance:l,height:I})),zA(gB,{center:{x:0,y:0,z:0},width:n,length:s,height:1.5,taperRatio:.03,chamferSize:.7,notchPosition:{x:-(s/2-1.5),y:n/2-1.5,z:1.5},notchRadius:1.5/2})]})},Wye=(e,A)=>{switch(e){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},Zye=e=>{switch(e){case 32:return .6;case 40:return .6;case 52:case 64:return .65;case 208:return 1.65;default:return .6}},Vye=(e,A)=>{switch(e){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},VzA=({x:e,y:A,pinThickness:t,shortSidePinLength:i,longSidePinLength:n,bodyHeight:o,bodyLength:s=2.54,bodyWidth:r=2.54,flipZ:a,faceup:g,smd:I,rightangle:c})=>Je(Mn,{children:[zA(Pi,{y:c?-3:0,children:zA(Qe,{color:"#222",size:[s,r,o],center:[e,A,a(o/2)]})}),!g&&zA(Ko,{color:"gold",children:I?zA(Vn,{rotation:-Math.PI/2,position:{x:e,y:A+1,z:t/2},thickness:t,width:t,height:t,padContactLength:2,bodyDistance:3}):Je(uI,{children:[zA(Qe,{color:"gold",size:[t,t,i*.9],center:[e,A,a(o*.9+o/2)]}),zA(Qe,{color:"gold",size:[t/1.8,t/1.8,i],center:[e,A,a(o+o/2)]})]})}),zA(Ko,{color:"gold",children:zA(Pi,{y:c?-3.9:0,z:c?1:0,children:zA(XB,{rotation:c?[-Math.PI/2,0,0]:[0,0,0],children:Je(uI,{children:[zA(Qe,{color:"gold",size:[t,t,n*.9],center:[e,A,a(-n/2*.9)]}),zA(Qe,{color:"gold",size:[t/1.8,t/1.8,n],center:[e,A,a(-n/2)]})]})})})})]}),jye=({numberOfPins:e,pitch:A=2.54,longSidePinLength:t=6,invert:i,faceup:n,rows:o=1,smd:s,rightangle:r})=>{const I=Math.ceil(e/o),c=2.54,l=3,B=-((I-1)/2)*A,C=!s&&!r?-2-1.6:0,E=Q=>(i||n?-Q+2:Q)+C;return zA(Mn,{children:Array.from({length:e},(Q,h)=>{const u=Math.floor(h/I),d=h%I,f=B+d*A,m=-u*c;return zA(VzA,{x:f,y:m,pinThickness:.63,shortSidePinLength:l,longSidePinLength:t,bodyHeight:2,flipZ:E,faceup:n,smd:s,rightangle:r},h)})})},zye=e=>{const A=["left","bottom","right","top"],{pin_count:t,pn:i,w:n,h:o,p:s,pl:r}=e,a=t/4,g=A[Math.floor((i-1)/a)],I=(i-1)%a,c=s*(a-1),l=s*(a-1),B=-r/2;switch(g){case"left":return{x:-n/2-B,y:l/2-I*s,o:"vert"};case"bottom":return{x:-c/2+I*s,y:-o/2-B,o:"horz"};case"right":return{x:n/2+B,y:-l/2+I*s,o:"vert"};case"top":return{x:c/2-I*s,y:o/2+B,o:"horz"};default:throw new Error("Invalid pin number")}},Xye=({num_pins:e,cw:A,ccw:t,startingpin:i})=>{const n=[],o=e/4;let s=1;const r={};for(const a of i??[])r[a]=!0;!r.leftside&&!r.topside&&!r.rightside&&!r.bottomside&&(r.leftside=!0),!r.bottompin&&!r.leftpin&&!r.rightpin&&!r.toppin&&(r.leftside?r.toppin=!0:r.topside?r.rightpin=!0:r.rightside?r.bottompin=!0:r.bottomside&&(r.leftpin=!0)),r.leftside&&r.toppin?s=1:r.leftside&&r.bottompin?s=o:r.bottomside&&r.leftpin?s=o+1:r.bottomside&&r.rightpin?s=o*2:r.rightside&&r.bottompin?s=o*2+1:r.rightside&&r.toppin?s=o*3:r.topside&&r.rightpin?s=o*3+1:r.topside&&r.leftpin&&(s=o*4),n.push(-1);for(let a=0;a<e;a++)n[s]=a+1,s++,s>e&&(s=1);return n},$ye=({num_pins:e=16,bodyWidth:A=9,bodyLength:t=9,bodyThickness:i=.8,thermalPadSize:n,padWidth:o=.25,padLength:s=.25,pitch:r=.5,thermalPadThickness:a=.05})=>{const g=Xye({num_pins:e,cw:!0,ccw:!0}),I=[];for(let c=0;c<e;c++){const{x:l,y:B,o:C}=zye({pin_count:e,pn:c+1,w:A,h:t,p:r,pl:s});let E=o,Q=s;C==="vert"&&([E,Q]=[Q,E]);const h=g[c+1];I.push({pn:h,x:l,y:B,pw:E,pl:Q})}return Je(Mn,{children:[zA(Ko,{color:"grey",children:zA(Qe,{center:{x:0,y:0,z:i/2},size:[A,t,i]})}),I.map((c,l)=>zA(Qe,{center:{x:c.x,y:c.y,z:a/2},size:[c.pw,c.pl,a]})),n?.length!==void 0&&n?.width!==void 0&&zA(Qe,{center:{x:0,y:0,z:a/2},size:[n.width,n.length,a]})]})},Ame=$ye,tme=()=>{const a=1.1999999999999997;return Je(Mn,{children:[zA(Vn,{rotation:Math.PI,position:{x:2.8/2+a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),zA(Vn,{rotation:Math.PI,position:{x:2.8/2+a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),zA(Vn,{position:{x:-2.8/2-a/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),zA(Vn,{position:{x:-2.8/2-a/4,y:-1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),zA(Vn,{position:{x:-2.8/2-a/4,y:1,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:a,height:.95}),zA(gB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},eme=tme,ime=({fullWidth:e=2.9,fullLength:A=2.8})=>{const I=(e-1.92)/2+.3;return Je(Mn,{children:[zA(Vn,{rotation:Math.PI,position:{x:e/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),zA(Vn,{position:{x:-e/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),zA(Vn,{position:{x:-e/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:I,height:.45}),zA(gB,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},QEA=.6,EEA=.3,zN=.33,IH=.1,nme=QEA-IH*2,jzA=({color:e="#333"})=>Je(Mn,{children:[zA(Qe,{size:[nme,EEA,zN],offset:[0,0,zN/2],color:e}),zA(Qe,{size:[IH,EEA,zN],offset:[QEA/2-IH/2,0,zN/2],color:"#ccc"}),zA(Qe,{size:[IH,EEA,zN],offset:[-QEA/2+IH/2,0,zN/2],color:"#ccc"})]}),hEA=.4,uEA=.2,XN=.13,cH=.07,ome=hEA-cH*2,zzA=({color:e="#333"})=>Je(Mn,{children:[zA(Qe,{size:[ome,uEA,XN],offset:[0,0,XN/2],color:e}),zA(Qe,{size:[cH,uEA,XN],offset:[hEA/2-cH/2,0,XN/2],color:"#ccc"}),zA(Qe,{size:[cH,uEA,XN],offset:[-hEA/2+cH/2,0,XN/2],color:"#ccc"})]}),dEA=3.2,pEA=1.6,$N=.9,lH=.5,sme=dEA-lH*2,XzA=({color:e="#333"})=>Je(Mn,{children:[zA(Qe,{size:[sme,pEA,$N],offset:[0,0,$N/2],color:e}),zA(Qe,{size:[lH,pEA,$N],offset:[dEA/2-lH/2,0,$N/2],color:"#ccc"}),zA(Qe,{size:[lH,pEA,$N],offset:[-dEA/2+lH/2,0,$N/2],color:"#ccc"})]}),fEA=3.2,yEA=2.5,Av=1,BH=.6,rme=fEA-BH*2,$zA=({color:e="#333"})=>Je(Mn,{children:[zA(Qe,{size:[rme,yEA,Av],offset:[0,0,Av/2],color:e}),zA(Qe,{size:[BH,yEA,Av],offset:[fEA/2-BH/2,0,Av/2],color:"#ccc"}),zA(Qe,{size:[BH,yEA,Av],offset:[-fEA/2+BH/2,0,Av/2],color:"#ccc"})]}),mEA=5,wEA=2.5,tv=1.4,CH=.6,ame=mEA-CH*2,AXA=({color:e="#333"})=>Je(Mn,{children:[zA(Qe,{size:[ame,wEA,tv],offset:[0,0,tv/2],color:e}),zA(Qe,{size:[CH,wEA,tv],offset:[mEA/2-CH/2,0,tv/2],color:"#ccc"}),zA(Qe,{size:[CH,wEA,tv],offset:[-mEA/2+CH/2,0,tv/2],color:"#ccc"})]}),DEA=6.3,SEA=3.2,ev=1.8,QH=.8,gme=DEA-QH*2,tXA=({color:e="#333"})=>Je(Mn,{children:[zA(Qe,{size:[gme,SEA,ev],offset:[0,0,ev/2],color:e}),zA(Qe,{size:[QH,SEA,ev],offset:[DEA/2-QH/2,0,ev/2],color:"#ccc"}),zA(Qe,{size:[QH,SEA,ev],offset:[-DEA/2+QH/2,0,ev/2],color:"#ccc"})]}),Ime=({x:e,y:A,pitch:t=2.54,legsLength:i=3,innerDiameter:n=.945,bodyHeight:o=5,bodyLength:s=t,bodyWidth:r=t,flipZ:a})=>{const g=n/1.5,I=g*1.6;return Je(Mn,{children:[zA(Ko,{color:"#1a1a1a",children:Je(jm,{children:[zA(Qe,{color:"#000",size:[s,r,o],center:[e,A,a(o/2)]}),n?zA(Gl,{height:o+.1,radius:n/2,center:[e,A,a(o/2)],color:"#222"}):zA(Qe,{size:[I,I,o],center:[e,A,a(o/2)]})]})}),Je(Ko,{color:"silver",children:[Je(uI,{children:[zA(Qe,{color:"silver",size:[g,g,i*.9],center:[e,A,a(-i/2*.9)]}),zA(Qe,{color:"silver",size:[g/1.8,g/1.8,i],center:[e,A,a(-i/2)]})]}),zA(Qe,{color:"silver",size:[I,I,I*.5],center:[e,A,a(I/2*.5)]})]})]})},cme=({numberOfPins:e,pitch:A=2.54,legsLength:t=3,innerDiameter:i=.945,rows:n=1,invert:o})=>{const r=Math.ceil(e/n),a=2.54,g=-((r-1)/2)*A,I=c=>o?-c+5:c;return zA(Mn,{children:Array.from({length:e},(c,l)=>{const B=Math.floor(l/r),C=l%r,E=g+C*A,Q=-B*a;return zA(Ime,{x:E,y:Q,pitch:A,legsLength:t,innerDiameter:i,flipZ:I},l)})})},lme=({width:e,length:A,innerDiameter:t=1})=>{const i=e,n=A,o=e*.7,s=t/2.5;return Je(Mn,{children:[zA(oH,{color:"#1a1a1f",center:[0,0,o/2],size:[n,n,o],roundRadius:.3}),zA(oH,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[n,n,o*.1],roundRadius:.14}),zA(Gl,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),zA(Gl,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[n/3,n/3,o+o*.1/2]}),zA(Gl,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-n/3,-n/3,o+o*.1/2]}),zA(Gl,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-n/3,n/3,o+o*.1/2]}),zA(Gl,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[n/3,-n/3,o+o*.1/2]}),zA(IW,{thickness:t/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:-n/2,z:-o*1.2}}),zA(IW,{thickness:t/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:n/2,z:-o*1.2},rotation:Math.PI}),zA(IW,{thickness:t/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:i/2,y:n/2,z:-o*1.2},rotation:Math.PI}),zA(IW,{thickness:t/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:i/2+t/3.6,y:-n/2,z:-o*1.2}})]})},IW=e=>{const{thickness:A,width:t,horizontalLength:i,verticalLength:n,rotation:o=0,position:s}=e,r=[[0,i],[-n/3,i/3],[-n/5,i/4],[0,0]],a=aEA(r,A);return zA(Ko,{color:"#f2f2f2",children:zA(Pi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:zA(XB,{rotation:[0,55,o],children:zA(rH,{height:t,children:zA(sH,{points:a.map(g=>[g.y,g.x])})})})})})},Bme=({pinCount:e,leadLength:A,leadWidth:t,pitch:i,bodyWidth:n})=>{const o=Math.ceil(e/2),s=(o-1)*i/2,r=.25,a=1,g=.8,I=A*0,c=i*(o-1)+t+.2,l=n*.55;return Je(Mn,{children:[Array.from({length:o}).map((B,C)=>zA(Vn,{position:{x:-n/2-I,y:C*i-s,z:r/2},width:t,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),Array.from({length:o}).map((B,C)=>zA(Vn,{rotation:Math.PI,position:{x:n/2+I,y:C*i-s,z:r/2},width:t,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),zA(gB,{center:{x:0,y:0,z:r/2},width:l,length:c,height:a})]})},Cme=({pinCount:e,pitch:A,leadWidth:t,leadLength:i,bodyWidth:n,bodyLength:o})=>{const s=e===8?{pitch:.65,leadWidth:.3}:{pitch:.5,leadWidth:.225},r=isNaN(parseFloat(A))?s.pitch:parseFloat(A),a=isNaN(parseFloat(t))?s.leadWidth:parseFloat(t)*.8,g=isNaN(parseFloat(n))?2.6:parseFloat(n)*.8,I=isNaN(parseFloat(o))?2+Number(r)*1.4:parseFloat(o),c=e/2,l=(c-1)*r/2,B=.15,C=.8,E=4.5,Q=(E-g)/2,h=Q*.5;return Je(Mn,{children:[Array.from({length:c}).map((u,d)=>zA(Vn,{position:{x:-E/2,y:l-d*r,z:B/2},width:a,thickness:B,padContactLength:h+.05,bodyDistance:Q+.1,height:C})),Array.from({length:c}).map((u,d)=>zA(Vn,{rotation:Math.PI,position:{x:E/2,y:l-d*r,z:B/2},width:a,thickness:B,padContactLength:h+.05,bodyDistance:Q+.1,height:C})),zA(gB,{center:{x:0,y:0,z:B/2},width:g,length:I,height:1})]})},Qme=()=>Je(Mn,{children:[zA(Qe,{color:"#ccc",size:[.5,.6,.12],center:[-.725,0,.12/2]}),zA(Qe,{color:"#ccc",size:[.5,.6,.12],center:[.725,0,.12/2]}),zA(Ko,{color:"#222",children:Je(NQ,{children:[zA(Pi,{z:.3/2,children:zA(Qe,{size:[1.65,.8,.3]})}),Je(uI,{children:[zA(Pi,{z:.3,children:zA(Qe,{size:[1.65,.8,.01]})}),zA(Pi,{z:.6,children:zA(Qe,{size:[1.65-.2,.8-.2,.01]})})]})]})})]}),Eme=()=>Je(Mn,{children:[zA(Qe,{color:"#ccc",size:[.26,.51,.12],center:[-.325,0,.12/2]}),zA(Qe,{color:"#ccc",size:[.26,.51,.12],center:[.325,0,.12/2]}),zA(Ko,{color:"#222",children:zA(Pi,{z:.47/2+.02,children:zA(Qe,{size:[.98,.58,.47]})})}),zA(Qe,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,.26/2,.47/4]}),zA(Qe,{color:"#ccc",size:[.98+.001,.26/2,.26/4],center:[0,-.26/2,.47/4]}),zA(Qe,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[.65/2,0,.47/4]}),zA(Qe,{color:"#ccc",size:[.26/1.5,.58+.001,.26/4],center:[-.65/2,0,.47/4]})]}),hme=()=>{const g=zA(Ko,{color:"#1a1a1a",children:Je(NQ,{children:[Je(uI,{children:[zA(Pi,{z:.13,children:zA(Qe,{size:[4,3,.03]})}),zA(Pi,{z:1.15,children:zA(Qe,{size:[4.4,3.4,.01]})})]}),Je(uI,{children:[zA(Pi,{z:1.15,children:zA(Qe,{size:[4.4,3.4,.01]})}),zA(Pi,{z:2.3,children:zA(Qe,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const C=c*1.78,E=c*(3.4/2-.2/2+1),Q=c*(3.4/2-.2/2),h=Math.abs(Q-E),u=(E+Q)/2;return zA(Ko,{color:"#c0c0c0",children:Je(NQ,{children:[zA(Qe,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),zA(Qe,{size:[.2,1.45,1.14],center:[E,0,1.14/2+.2]}),zA(Qe,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Je(Mn,{children:[zA(I,{xDir:1}),zA(I,{xDir:-1}),g]})},ume=()=>{const g=zA(Ko,{color:"#1a1a1a",children:Je(NQ,{children:[Je(uI,{children:[zA(Pi,{z:.13,children:zA(Qe,{size:[4,3,.03]})}),zA(Pi,{z:1.15,children:zA(Qe,{size:[4.4,3.4,.01]})})]}),Je(uI,{children:[zA(Pi,{z:1.15,children:zA(Qe,{size:[4.4,3.4,.01]})}),zA(Pi,{z:2.3,children:zA(Qe,{size:[4,3,.01]})})]})]})}),I=({xDir:c})=>{const C=c*1.78,E=c*(3.4/2-.2/2+1),Q=c*(3.4/2-.2/2),h=Math.abs(Q-E),u=(E+Q)/2;return zA(Ko,{color:"#c0c0c0",children:Je(NQ,{children:[zA(Qe,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),zA(Qe,{size:[.2,1.45,1.14],center:[E,0,1.14/2+.2]}),zA(Qe,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Je(Mn,{children:[zA(I,{xDir:1}),zA(I,{xDir:-1}),g]})},dme=()=>{const g=zA(Ko,{color:"#1a1a1a",children:Je(NQ,{children:[Je(uI,{children:[zA(Pi,{z:.21000000000000002,children:zA(Qe,{size:[6.3999999999999995,5.6,.03]})}),zA(Pi,{z:1.15,children:zA(Qe,{size:[6.8,6,.01]})})]}),Je(uI,{children:[zA(Pi,{z:1.15,children:zA(Qe,{size:[6.8,6,.01]})}),zA(Pi,{z:2.3,children:zA(Qe,{size:[6.3999999999999995,5.6,.01]})})]})]})}),I=({xDir:c})=>{const C=c*3.08,E=c*(6/2-.2/2+1),Q=c*(6/2-.2/2),h=Math.abs(Q-E),u=(E+Q)/2;return zA(Ko,{color:"#c0c0c0",children:Je(NQ,{children:[zA(Qe,{size:[2.3*.8,2.95,.2],center:[C,0,.2/2]}),zA(Qe,{size:[.2,2.95,1.14],center:[E,0,1.14/2+.2]}),zA(Qe,{size:[h,2.95,.2],center:[u,0,.2/2+1.14]})]})})};return Je(Mn,{children:[zA(I,{xDir:1}),zA(I,{xDir:-1}),g]})},pme=()=>{const c=zA(Ko,{color:"#222",children:Je(NQ,{children:[zA(Pi,{z:.27,children:zA(Qe,{size:[2.9,1.9,.54]})}),Je(uI,{children:[zA(Pi,{z:.54,children:zA(Qe,{size:[2.9,1.9,.01]})}),zA(Pi,{z:1.08,children:zA(Qe,{size:[2.6999999999999997,1.7,.01]})})]})]})});return Je(Mn,{children:[zA(Qe,{color:"#ccc",size:[1,1.2,.25],center:[-1.3,0,.25/2]}),zA(Qe,{color:"#ccc",size:[1,1.2,.25],center:[1.3,0,.25/2]}),c]})},fme=()=>Je(Mn,{children:[zA(Qe,{color:"#ccc",size:[1,.6,.12],center:[-1.3,0,.12/2]}),zA(Qe,{color:"#ccc",size:[1,.6,.12],center:[1.3,0,.12/2]}),zA(Ko,{color:"#222",children:Je(NQ,{children:[zA(Pi,{z:.55/2,children:zA(Qe,{size:[2.7,1.6,.55]})}),Je(uI,{children:[zA(Pi,{z:.55,children:zA(Qe,{size:[2.7,1.6,.01]})}),zA(Pi,{z:1.1,children:zA(Qe,{size:[2.7-.2,1.6-.2,.01]})})]})]})})]}),yme=()=>Je(Mn,{children:[zA(Qe,{color:"#ccc",size:[1,.9,.2],center:[-1.3,0,.2/2]}),zA(Qe,{color:"#ccc",size:[1,.9,.2],center:[1.3,0,.2/2]}),zA(Ko,{color:"#222",children:Je(NQ,{children:[zA(Pi,{z:.2/2,children:zA(Qe,{size:[2.75,1.8,.2]})}),Je(uI,{children:[zA(Pi,{z:.2,children:zA(Qe,{size:[2.75,1.8,.01]})}),zA(Pi,{z:1,children:zA(Qe,{size:[2.75-.4,1.8-.4,.01]})})]})]})}),zA(Qe,{color:"#777",size:[.2,1.8-.4,.01],center:[-1.3+.4,0,1]})]}),mme=()=>Je(Mn,{children:[zA(Qe,{color:"#ccc",size:[.9,.9,.2],center:[-1.225,0,.2/2]}),zA(Qe,{color:"#ccc",size:[.9,.9,.2],center:[1.225,0,.2/2]}),zA(Ko,{color:"#222",children:Je(NQ,{children:[Je(uI,{children:[zA(Pi,{z:.2,children:zA(Qe,{size:[2.6-.1/2,1.7-.1/2,.01]})}),zA(Pi,{z:.01,children:zA(Qe,{size:[2.6-.1,1.7-.1,.01]})})]}),Je(uI,{children:[zA(Pi,{z:.2,children:zA(Qe,{size:[2.6,1.7,.01]})}),zA(Pi,{z:1,children:zA(Qe,{size:[2.6-.4,1.7-.4,.01]})})]})]})}),zA(Qe,{color:"#777",size:[.2*2.7,1.7-.4,.02],center:[-1.225+.4,0,1]})]}),wme=()=>Je(Mn,{children:[zA(Qe,{color:"#ccc",size:[.9,1.75,.2],center:[-1.825,0,.2/2]}),zA(Qe,{color:"#ccc",size:[.9,1.75,.2],center:[1.825,0,.2/2]}),zA(Ko,{color:"#222",children:Je(NQ,{children:[Je(uI,{children:[zA(Pi,{z:.2,children:zA(Qe,{size:[3.8-.05/2,2.5-.05/2,.01]})}),zA(Pi,{z:.01,children:zA(Qe,{size:[3.8-.05,2.5-.05,.01]})})]}),Je(uI,{children:[zA(Pi,{z:.2,children:zA(Qe,{size:[3.8,2.5,.01]})}),zA(Pi,{z:1,children:zA(Qe,{size:[3.8-.4,2.5-.4,.01]})})]})]})}),zA(Qe,{color:"#777",size:[.2*2.7,2.5-.4,.02],center:[-1.825+.4,0,1]})]}),Dme=()=>Je(Mn,{children:[zA(Qe,{color:"#ccc",size:[.4,.25,.14],center:[-.4,0,.14/2]}),zA(Qe,{color:"#ccc",size:[.4,.25,.14],center:[.4,0,.14/2]}),zA(Ko,{color:"#222",children:Je(NQ,{children:[zA(Pi,{z:.14/2,children:zA(Qe,{size:[.8,.6,.14]})}),Je(uI,{children:[zA(Pi,{z:.14,children:zA(Qe,{size:[.8,.6,.01]})}),zA(Pi,{z:.37,children:zA(Qe,{size:[.8-.1,.6-.1,.01]})})]})]})})]}),Sme=()=>{const I=3.0999999999999996;return Je(Mn,{children:[zA(Vn,{rotation:Math.PI,position:{x:6.6/2+I/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),zA(Vn,{position:{x:-6.6/2-I/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),zA(Vn,{position:{x:-6.6/2-I/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),zA(Vn,{position:{x:-6.6/2-I/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:I,height:.75}),zA(gB,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},bme=()=>Je(Mn,{children:[Array.from({length:16}).map((B,C)=>zA(Vn,{position:{x:-10.5/2,y:C*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((B,C)=>zA(Vn,{rotation:Math.PI,position:{x:10.5/2,y:C*.5-3.75,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),Array.from({length:16}).map((B,C)=>zA(Vn,{rotation:Math.PI/2,position:{x:C*.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((B,C)=>zA(Vn,{rotation:-Math.PI/2,position:{x:C*.5-3.75,y:10.5/2,z:.25/2},width:.2,thickness:.25,padContactLength:.45,bodyDistance:.95,height:.65})),zA(gB,{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})]}),xme=bme,_me=()=>{const g=.7999999999999998;return Je(Mn,{children:[zA(Vn,{rotation:Math.PI,position:{x:2.05/2+g/4,y:0,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),zA(Vn,{position:{x:-2.05/2-g/4,y:-.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),zA(Vn,{position:{x:-2.05/2-g/4,y:.65,z:.18/2},width:.3,thickness:.18,padContactLength:.2,bodyDistance:g,height:.65}),zA(gB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},kme=({pinCount:e,pitch:A,leadWidth:t,padContactLength:i,bodyWidth:n})=>{const o=e/4;if(o!==Math.floor(o))throw new Error(`LQFP pinCount must be divisible by 4, got ${e}`);A||(A=.5),i||(i=.6),t||(t=.22),n||(n=A*(o+4));const s=n,r=(o-1)*A/2,a=s+3.3*i,g=a,I=.8,c=.2,l=(g-n)/2+.4;return Je(Mn,{children:[Array.from({length:o}).map((B,C)=>zA(Vn,{position:{x:-g/2-.36,y:C*A-r,z:c/2},width:t,thickness:c,padContactLength:i,bodyDistance:l,height:I})),Array.from({length:o}).map((B,C)=>zA(Vn,{rotation:Math.PI,position:{x:g/2+.36,y:C*A-r,z:c/2},width:t,thickness:c,padContactLength:i,bodyDistance:l,height:I})),Array.from({length:o}).map((B,C)=>zA(Vn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.36,z:c/2},width:t,thickness:c,padContactLength:i,bodyDistance:l,height:I})),Array.from({length:o}).map((B,C)=>zA(Vn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.36,z:c/2},width:t,thickness:c,padContactLength:i,bodyDistance:l,height:I})),zA(gB,{center:{x:0,y:0,z:0},width:n,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})]})},Gme=()=>{const i=.20900000000000002,n=.1,o=.3,s=.1,r=.2;return Je(Mn,{children:[zA(Ko,{color:"#222",children:Je(NQ,{children:[zA(Qe,{size:[.85,1.2,i],center:[0,0,i/2]}),Je(uI,{children:[zA(Pi,{z:i,children:zA(Qe,{size:[.85,1.2,.01]})}),zA(Pi,{z:.38,children:zA(Qe,{size:[.85-n,1.2-n,.01]})})]})]})}),zA(Qe,{color:"#ccc",size:[o,.25,s],center:[.55,0,s/2]}),zA(Qe,{color:"#ccc",size:[o,r,s],center:[-.55,.4,s/2]}),zA(Qe,{color:"#ccc",size:[o,r,s],center:[-.55,-.4,s/2]})]})},Fme=({num_pins:e,bodyWidth:A=5.3,bodyLength:t=5.3,bodyThickness:i=1,thermalPadSize:n,padWidth:o=t/5.3*.6,padLength:s=t/5.3*1,pitch:r=.5,thermalPadThickness:a=.2})=>{const g=[],I=Math.floor(e/2),c=r*(I-1);for(let l=0;l<e;l++){const B=l<I?"left":"right",C=l%I,E=c/2-C*r,Q=s,h=o,u=B==="left"?-A/2+Q/2:A/2-Q/2,d=l+1;g.push({pinNumber:d,x:u,y:E,padSizeX:Q,padSizeY:h})}return Je(Mn,{children:[zA(gB,{center:{x:0,y:0,z:0},width:A,length:t,height:i,heightAboveSurface:0,color:"grey",chamferSize:.2,taperRatio:0,notchPosition:{x:-(A/2-s),y:t/2-s,z:i}}),g.map((l,B)=>zA(Qe,{center:[l.x,l.y,a/2],size:[l.padSizeX,l.padSizeY,a]})),n?.length!==void 0&&n?.width!==void 0&&zA(Qe,{center:[0,0,a/2],size:[n.width,n.length,a]})]})},Mme=({bodyLength:e=10.2,bodyWidth:A=4.65,bodyHeight:t=13.46,leadSpacing:i=5,leadDiameter:n=.8,leadLength:o=12.7,color:s="#ddd",leadColor:r="#b87333"})=>{const a=e/2,g=A/2,I=a-g,c=i/2,l=.85;return Je(Mn,{children:[Je(Ko,{color:s,children:[Je(uI,{children:[zA(Cf,{height:t,roundRadius:.5,radius:g,center:[-I,0,t]}),zA(Cf,{height:t,roundRadius:.5,radius:g,center:[I,0,t]})]}),Je(uI,{children:[zA(Cf,{height:l,roundRadius:.1,radius:g+.85,center:[-I,0,t/2+l/2]}),zA(Cf,{height:l,roundRadius:.1,radius:g+.85,center:[I,0,t/2+l/2]})]})]}),Je(Ko,{color:r,children:[zA(Gl,{height:o+t/2,radius:n/2,center:[-c+.06,0,-(o/2)+t/2]}),zA(Gl,{height:o+t/2,radius:n/2,center:[c-.06,0,-(o/2)+t/2]})]})]})},Rme=({bodyLength:e=1.4,bodyDiameter:A=1.1,color:t="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:n="#111"})=>Je(Mn,{children:[zA(Ko,{color:t,children:Je(XB,{rotation:[0,"90deg",0],children:[zA(oH,{size:[A,A,e-.2],roundRadius:.2,center:[-A/2,0,.05]}),zA(Gl,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-e/2+.2/2]})]})}),zA(Ko,{color:n,children:zA(XB,{rotation:[0,"90deg",0],children:zA(oH,{size:[A*1.01,A*1.01,e/3],roundRadius:.2,center:[-A/2,0,-e/4+.1]})})}),zA(Ko,{color:i,children:zA(XB,{rotation:[0,"90deg",0],children:zA(Cf,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-e/2]})})}),zA(Ko,{color:i,children:zA(XB,{rotation:[0,"90deg",0],children:zA(Cf,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,e/2]})})})]}),Nme=({bodyLength:e=3.5,bodyDiameter:A=1.5,color:t="#3a3a3aff",contactColor:i="#c6c6c6"})=>Je(Mn,{children:[zA(Ko,{color:t,children:zA(XB,{rotation:[0,"90deg",0],children:zA(Cf,{height:e,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),zA(Ko,{color:i,children:zA(XB,{rotation:[0,"90deg",0],children:zA(Cf,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-e/2]})})}),zA(Ko,{color:i,children:zA(XB,{rotation:[0,"90deg",0],children:zA(Cf,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,e/2]})})})]}),vme=({bodyLength:e=3.9,bodyDiameter:A=2.5,color:t="#3a3a3aff",contactColor:i="#c6c6c6"})=>Je(Mn,{children:[zA(Ko,{color:t,children:zA(XB,{rotation:[0,"90deg",0],children:zA(Cf,{height:e,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),zA(Ko,{color:i,children:zA(XB,{rotation:[0,"90deg",0],children:zA(Cf,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-e/2]})})}),zA(Ko,{color:i,children:zA(XB,{rotation:[0,"90deg",0],children:zA(Cf,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,e/2]})})})]}),Lme=({pinCount:e,padContactLength:A=.6,leadWidth:t=.41,pitch:i=1.27})=>{if(e%2!==0)throw new Error("MS012 pinCount must be even");const n=e/2,o=4.9,s=3.9,r=(n-1)*i/2,a=.2;return Je(Mn,{children:[Array.from({length:n}).map((g,I)=>zA(Vn,{position:{x:-s/2-A-.3,y:I*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,I)=>zA(Vn,{rotation:Math.PI,position:{x:s/2+A+.3,y:I*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),zA(gB,{center:{x:0,y:0,z:a/2},width:s,length:o,height:1.55,notchPosition:{x:-.95,y:o/2-1,z:1.55},heightAboveSurface:.17,taperRatio:.09})]})},Ume=({pinCount:e=16,padContactLength:A=.6,leadWidth:t=.41,pitch:i=1.27})=>{if(e!==16)throw new Error("MS013 only supports 16 pins");const n=e/2,o=7.5,s=10.3,r=(n-1)*i/2,a=.2;return Je(Mn,{children:[Array.from({length:n}).map((g,I)=>zA(Vn,{position:{x:-o/2-A-.3,y:I*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,I)=>zA(Vn,{rotation:Math.PI,position:{x:o/2+A+.3,y:I*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),zA(gB,{center:{x:0,y:0,z:a/2},width:o,length:s,height:1.1,notchPosition:{x:-2.25,y:s/2-1.5,z:1.1},heightAboveSurface:.17,taperRatio:.05})]})},Hme=()=>{const E=7.050000000000001,Q=24.95+6.5/2;return zA(Pi,{center:[0,0,1],children:Je(Mn,{children:[Je(XB,{rotation:[0,55,-55],children:[Je(jm,{children:[zA(Qe,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[Q,0,1.3-2]}),zA(Gl,{color:"black",center:[Q,0,1.3-2],radius:3/2,height:1.3*1.2})]}),zA(Ko,{color:"#222",children:zA(gB,{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})})]}),zA(XB,{rotation:[0,55,55],children:Array.from({length:3}).map((h,u)=>{const d=E,f=(u-1)*2.7,m=-.5-.6;return Je(Ko,{color:"gold",children:[Je(uI,{children:[zA(Pi,{center:[15.05-4.5/2+.1,f,m],children:zA(Qe,{size:[4.5,.81+1,.5]})}),zA(Pi,{center:[15.05-4.5/2-1+.1,f,m],children:zA(Qe,{size:[4.5,.81,.5]})})]}),zA(Pi,{center:[d,f,m],children:zA(Qe,{size:[16+.1,.81,.5]})})]},`prong-${u}`)})})]})})},Yme=()=>{const g=1.1999999999999997;return Je(Mn,{children:[zA(Vn,{rotation:Math.PI,position:{x:2.8/2+g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(Vn,{rotation:Math.PI,position:{x:2.8/2+g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(Vn,{rotation:Math.PI,position:{x:2.8/2+g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(Vn,{position:{x:-2.8/2-g/4,y:0,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(Vn,{position:{x:-2.8/2-g/4,y:-.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(Vn,{position:{x:-2.8/2-g/4,y:.95,z:.15/2},width:.4,thickness:.15,padContactLength:.5,bodyDistance:g,height:.95}),zA(gB,{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})]})},Jme=()=>Je(Mn,{children:[zA(gB,{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(g=>{const I=-.35+g*.35;return zA(Qe,{center:[-.8/2+.19/2-.1,I,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(g=>{const I=-.35+g*.35;return zA(Qe,{center:[.8/2-.19/2+.1,I,.12/2],size:[.19,.15,.12]})})]}),Tme=()=>{const s="#222",a=[.43,.4,1.32],g=[.43,.4,.25],I=[0,0,-.66],c=[0,0,-1.32],l=[0,1.28,-2.72],B=[0,1.28,-8.9],C=-7.5;return Je(Pi,{center:[0,1,10.5],children:[zA(Ko,{color:s,children:Je(jm,{children:[zA(Pi,{center:[0,0,2.25],children:zA(Gl,{radius:2.4,height:4.5})}),zA(Pi,{center:[0,-1.8499999999999999,2.25],children:zA(Qe,{size:[2.4*2,1.1,4.5+.2]})})]})}),zA(Pi,{center:I,children:zA(Qe,{size:a})}),Je(uI,{children:[zA(Pi,{center:c,children:zA(Qe,{size:g})}),zA(Pi,{center:l,children:zA(Qe,{size:g})})]}),zA(Pi,{center:B,children:zA(Qe,{size:[.43,.4,12.2]})}),zA(Pi,{center:[1.3,0,C],children:zA(Qe,{size:[.43,.4,15]})}),zA(Pi,{center:[-1.3,0,C],children:zA(Qe,{size:[.43,.4,15]})})]})},Kme=()=>Je(Mn,{children:[zA(Vn,{rotation:Math.PI,position:{x:2/2+.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(Vn,{rotation:Math.PI,position:{x:2/2+.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(Vn,{rotation:Math.PI,position:{x:2/2+.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(Vn,{position:{x:-2/2-.75/4,y:0,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(Vn,{position:{x:-2/2-.75/4,y:-.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(Vn,{position:{x:-2/2-.75/4,y:.65,z:.15/2},width:.25,thickness:.15,padContactLength:.3,bodyDistance:.75,height:.85}),zA(gB,{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})]}),Pme=Kme,qme=()=>Je(Mn,{children:[zA(gB,{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(r=>{const a=-.5+r*.5;return zA(Qe,{center:[-1/2+.3/2,a,.05/2],size:[.3,.2,.05]})}),[0,1,2].map(r=>{const a=-.5+r*.5;return zA(Qe,{center:[1/2-.3/2,a,.05/2],size:[.3,.2,.05]})})]}),Ome=()=>Je(Mn,{children:[zA(Vn,{position:{x:-2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),zA(Vn,{rotation:Math.PI,position:{x:2.5/2,y:0,z:.175/2},width:.3,thickness:.175,padContactLength:.3,bodyDistance:.45,height:.7}),zA(Ko,{color:"#222",children:zA(gB,{center:{x:0,y:0,z:0},width:1.7,length:1.25,height:.95,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})}),zA(Qe,{color:"#777",size:[1.7/3,1.25-.075,.02],center:[-.85*2/3+.035,0,.95+.05]})]}),Wme=()=>Je(Mn,{children:[zA(Qe,{color:"#ccc",size:[.4,.325,.175],center:[-1.05,0,.175/2]}),zA(Qe,{color:"#ccc",size:[.4,.325,.175],center:[1.05,0,.175/2]}),zA(Ko,{color:"#222",children:Je(NQ,{children:[zA(Pi,{z:.175/2,children:zA(Qe,{size:[1.7,1.25,.175]})}),Je(uI,{children:[zA(Pi,{z:.175,children:zA(Qe,{size:[1.7,1.25,.01]})}),zA(Pi,{z:.725,children:zA(Qe,{size:[1.7-.2,1.25-.2,.01]})})]})]})}),zA(Qe,{color:"#777",size:[1.7/3,1.25-.2,.02],center:[-1.05+1.7/4.4+.2,0,.725]})]}),Zme=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return Je(Mn,{children:[zA(Qe,{color:"#ccc",size:[.4,.325,.13],center:[s,0,.13/2]}),zA(Qe,{color:"#ccc",size:[.4,.325,.13],center:[r,0,.13/2]}),zA(Ko,{color:"#222",children:zA(gB,{width:1.775,length:1.25,height:.725,center:{x:0,y:0,z:0},heightAboveSurface:0,straightHeightRatio:.7,taperRatio:.06,includeNotch:!1})}),zA(Qe,{color:"#777",size:[1.775/3,1.25-.05,.02],center:[s+1.775/4.4+.2,0,.725]})]})},Vme=({pitch:e=10})=>Je(Mn,{children:[zA(Gl,{height:4,radius:.5,center:[-e/2,0,.5]}),zA(rW,{radius:.5,center:[-e/2,0,2.5]}),zA(Pi,{x:-2.5,y:0,z:2.5,children:Je(XB,{rotation:[0,Math.PI/2,0],children:[zA(Gl,{height:e,radius:.5,center:[0,0,2.5]}),zA(Ko,{color:"#d2b48c",children:zA(Gl,{height:5,radius:1.3,center:[0,0,2.5]})})]})}),zA(Gl,{height:4,radius:.5,center:[e/2,0,.5]}),zA(rW,{radius:.5,center:[e/2,0,2.5]})]}),jme=({bodyWidth:e=21,boardThickness:A=.5,leadWidth:t=1.6,leadLength:i=2.4,leadsPitch:n=2.54,leadsLeft:o,leadsRight:s,leadsTop:r,leadsBottom:a,innerHoles:g=!0,innerHoleEdgeDistance:I=1.61,innerHoleDiameter:c=1})=>{const l=e/2,B=A/2,C=A*1.05,E=c/2,Q=Math.max(o||0,s||0,r||0,a||0)*n||51,h=[],u=[];if(s){const w=-((s-1)/2)*n;for(let D=0;D<s;D++){const b=w+D*n;h.push({x:-l+i/2,y:-b,pl:i,pw:t}),g&&u.push({x:-l,y:-b},{x:-l+I,y:-b})}}if(o){const w=-((o-1)/2)*n;for(let D=0;D<o;D++){const b=w+D*n;h.push({x:l-i/2,y:-b,pl:i,pw:t}),g&&u.push({x:l,y:-b},{x:l-I,y:-b})}}if(r){const w=-((r-1)/2)*n;for(let D=0;D<r;D++){const b=w+D*n;h.push({x:-b,y:-Q/2+i/2,pl:t,pw:i}),g&&u.push({x:-b,y:-Q/2},{x:-b,y:-Q/2+I})}}if(a){const w=-((a-1)/2)*n;for(let D=0;D<a;D++){const b=w+D*n;h.push({x:-b,y:Q/2-i/2,pl:t,pw:i}),g&&u.push({x:-b,y:Q/2},{x:-b,y:Q/2-I})}}const d=zA(Ko,{color:"#008080",children:Je(jm,{children:[zA(Qe,{center:[0,0,B],size:[e,Q,A]}),h.map((w,D)=>zA(Qe,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]},D))]})}),f=g&&u.map((w,D)=>zA(Gl,{color:"black",center:[w.x,w.y,B],radius:E,height:A*1.07})),m=h.map((w,D)=>zA(Qe,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]}));return Je(Mn,{children:[d,zA(Ko,{color:"#FFD700",children:g?Je(jm,{children:[zA(NQ,{children:h.map((w,D)=>zA(Qe,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]},D))}),f]}):m})]})},zme=({numPins:e=5,rows:A=1,p:t=2.54,id:i=1,od:n=1.5,boardThickness:o=1.6,width:s,height:r,pinRowSide:a="left",holes:g=[],holeInset:I=1,pinRowHoleEdgeToEdgeDist:c=2,nopin:l})=>{const B=o/2,C=Math.ceil(e/A);let E,Q;a==="left"||a==="right"?(E=(A-1)*t+2*c,Q=(C-1)*t+2*c):(Q=(A-1)*t+2*c,E=(C-1)*t+2*c),e===0&&(E=10,Q=10);const h=Number(s??E),u=Number(r??Q),d=[];let f=0,m=0,w=0,D=0,b=0,k=0;a==="left"||a==="right"?(f=a==="left"?-h/2+c:h/2-c,m=-((C-1)/2)*t,w=0,D=t,b=a==="left"?t:-t,k=0):(f=-((C-1)/2)*t,m=a==="top"?u/2-c:-u/2+c,w=t,D=0,b=0,k=a==="top"?-t:t);let x=0;for(let rA=0;rA<A&&x<e;rA++)for(let tA=0;tA<C&&x<e;tA++){const oA=f+tA*w+rA*b,aA=m+tA*D+rA*k;d.push({x:oA,y:aA}),x++}const N=[];if(g)for(const rA of g){let tA=0,oA=0;rA==="topleft"?(tA=-h/2+I,oA=u/2-I):rA==="topright"?(tA=h/2-I,oA=u/2-I):rA==="bottomleft"?(tA=-h/2+I,oA=-u/2+I):rA==="bottomright"?(tA=h/2-I,oA=-u/2+I):rA==="center"&&(tA=0,oA=0),N.push({x:tA,y:oA})}const R=.63,U=2,Y=6,H=3,O=l?0:U,W=zA(Ko,{color:"#008080",children:Je(jm,{children:[zA(Qe,{center:[0,0,B+O],size:[h,u,o]}),N.map((rA,tA)=>zA(Gl,{center:[rA.x,rA.y,B+O],radius:n/2,height:o},`hole-${tA}`)),d.map((rA,tA)=>zA(Gl,{center:[rA.x,rA.y,B+O],radius:n/2,height:o},`pin-hole-${tA}`))]})}),$=d.map((rA,tA)=>zA(Ko,{color:"#FFD700",children:Je(jm,{children:[zA(Gl,{center:[rA.x,rA.y,o/2+O],radius:n/2,height:o}),zA(Gl,{center:[rA.x,rA.y,o/2+O],radius:i/2,height:o})]})})),iA=d.map((rA,tA)=>zA(VzA,{x:rA.x,y:rA.y,pinThickness:R,shortSidePinLength:H,longSidePinLength:Y,bodyHeight:U,flipZ:oA=>oA}));return Je(Mn,{children:[W,$,!l&&iA]})},Xme=({footprint:e})=>{const A=Rye.string(e).json();switch(A.fn){case"dip":return zA(Hye,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"axial":return zA(Vme,{pitch:A.p});case"tssop":return zA(Jye,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return zA(Tye,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return zA(Cme,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return zA(Oye,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return zA(xme,{});case"lqfp":return zA(kme,{pinCount:A.num_pins});case"qfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return zA(Ame,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:n?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"dfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return zA(Fme,{num_pins:A.num_pins,bodyWidth:A.w,bodyLength:A.h,pitch:A.p,padLength:A.pl,padWidth:A.pw,thermalPadSize:n?{width:A.thermalpad.x,length:A.thermalpad.y}:void 0})}case"pinrow":{const n=e.match(/_rows(\d+)/),o=n&&n[1]?parseInt(n[1],10):1;if(A.male)return zA(jye,{numberOfPins:A.num_pins,pitch:A.p,invert:A.invert,faceup:A.faceup,rows:o,smd:A.smd||A.surface_mount,rightangle:A.rightangle});if(A.female)return zA(cme,{numberOfPins:A.num_pins,pitch:A.p,rows:o})}case"cap":switch(A.imperial){case"0402":return zA(OzA,{color:"#856c4d"});case"0603":return zA(WzA,{color:"#856c4d"});case"0805":return zA(ZzA,{color:"#856c4d"});case"0201":return zA(jzA,{color:"#856c4d"});case"01005":return zA(zzA,{color:"#856c4d"});case"1206":return zA(XzA,{color:"#856c4d"});case"1210":return zA($zA,{color:"#856c4d"});case"2010":return zA(AXA,{color:"#856c4d"});case"2512":return zA(tXA,{color:"#856c4d"})}case"sot235":return zA(eme,{});case"sot457":return zA(Yme,{});case"sot223":return zA(Sme,{});case"sot23w":return zA(ime,{});case"sot323":return zA(_me,{});case"sod323f":return zA(Wme,{});case"sod323fl":return zA(Zme,{});case"sot363":return zA(Pme,{});case"sot886":return zA(qme,{});case"sot963":return zA(Jme,{});case"pushbutton":return zA(lme,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return zA(Bme,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return zA(Qme,{});case"sod882":return zA(Eme,{});case"sma":return zA(hme,{});case"smb":return zA(ume,{});case"smc":return zA(dme,{});case"smf":return zA(pme,{});case"sod123f":return zA(fme,{});case"sod123fl":return zA(yme,{});case"sod123w":return zA(mme,{});case"sod128":return zA(wme,{});case"sod323":return zA(Ome,{});case"sod923":return zA(Dme,{});case"hc49":return zA(Mme,{});case"micromelf":return zA(Rme,{});case"minimelf":return zA(Nme,{});case"melf":return zA(vme,{});case"ms012":return zA(Lme,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return zA(Ume,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return zA(Gme,{});case"to220":return zA(Hme,{});case"to92":return zA(Tme,{});case"stampboard":case"stampreceiver":return zA(jme,{bodyWidth:A.w,leadsLeft:A.left,leadsRight:A.right,leadsTop:A.top,leadsBottom:A.bottom,leadsPitch:A.p,leadWidth:A.pw,leadLength:A.pl,innerHoles:A.innerhole,innerHoleEdgeDistance:A.innerholeedgedistance});case"mountedpcbmodule":{const n=A.rows??1,o=A.pinRowSide??"left",s=A.holeInset,r=A.width,a=A.height,g=A.pinrow,I=A.pinRowHoleEdgeToEdgeDist,c=Array.isArray(A.holes)?A.holes:[];return zA(zme,{numPins:g,rows:n,p:A.p,id:A.id,od:A.od,width:r,height:a,pinRowSide:o,holes:c,holeInset:s,pinRowHoleEdgeToEdgeDist:I,nopin:A.nopin})}}const t=e.match(/_color\(([^)]+)\)/),i=t?t[1]:void 0;switch(A.imperial){case"0402":return zA(OzA,{color:i});case"0603":return zA(WzA,{color:i});case"0805":return zA(ZzA,{color:i});case"0201":return zA(jzA,{color:i});case"01005":return zA(zzA,{color:i});case"1206":return zA(XzA,{color:i});case"1210":return zA($zA,{color:i});case"2010":return zA(AXA,{color:i});case"2512":return zA(tXA,{color:i})}return null},$me=e=>e&&typeof e=="object"&&"type"in e,iv=e=>{if(typeof e=="number")return e;if(typeof e=="string"){const A=/^(-?\d+(?:\.\d+)?)\s*deg$/i.exec(e);if(A)return parseFloat(A[1])*Math.PI/180;const t=Number(e);if(!Number.isNaN(t))return t}return 0},Awe=e=>Array.isArray(e)?[Number(e[0])||0,Number(e[1])||0,Number(e[2])||0]:typeof e=="object"&&e?[Number(e.x)||0,Number(e.y)||0,Number(e.z)||0]:[0,0,0];function ID(e,A,t){const{jscad:{primitives:i,booleans:n,hulls:o,geometries:s,extrusions:r,transforms:a}}=t;if(e==null||e===!1)return[];if(Array.isArray(e))return e.flatMap(l=>ID(l,A,t));if(!$me(e))return[];const{type:g,props:I,children:c}=e;if(g===KzA)return(c??[]).flatMap(l=>ID(l,A,t));if(g===Ko){const l=I?.color;return(c??[]).flatMap(B=>ID(B,l??A,t))}if(g===Pi){const l=Awe(I?.offset??I?.center??{x:I?.x,y:I?.y,z:I?.z});return(c??[]).flatMap(C=>ID(C,A,t)).map(({geom:C,color:E})=>({geom:a.translate(l,C),color:E??A}))}if(g===XB){const l=Array.isArray(I?.rotation)?[iv(I.rotation[0]),iv(I.rotation[1]),iv(I.rotation[2])]:[iv(I?.x??0),iv(I?.y??0),iv(I?.z??0)];return(c??[]).flatMap(C=>ID(C,A,t)).map(({geom:C,color:E})=>({geom:a.rotateZ(l[2],a.rotateY(l[1],a.rotateX(l[0],C))),color:E}))}if(g===NQ||g===jm||g===uI){const l=(c??[]).flatMap(C=>ID(C,A,t)).map(C=>C.geom);if(l.length===0)return[];let B;return g===NQ?B=n.union(l):g===jm?B=n.subtract(l[0],l.slice(1)):B=o.hull(l),[{geom:B,color:A}]}if(g===sH){const l=I?.points??[];return[{geom:s.geom2.fromPoints(l),color:A??I?.color}]}if(g===rH){const l=(c??[]).flatMap(Q=>ID(Q,A,t)).map(Q=>Q.geom);if(l.length===0)return[];const B=l.length>1?n.union(l):l[0],C=I?.height??I?.h??1;let E=r.extrudeLinear({height:C},B);if(E.polygons)for(const Q of E.polygons)!Q.plane||!Q.vertices||Q.vertices.length<3||Q.vertices.reverse();return[{geom:E,color:A??I?.color}]}if(g===Qe||g===PzA||g===Gl||g===rW||g===oH||g===Cf){let l;if(g===Qe){const B=I?.size??[1,1,1],C=I?.offset,E=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);l=i.cuboid({size:B,center:E})}else if(g===PzA){const B=I?.size??1,C=I?.offset,E=I?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);l=i.cube({size:B,center:E})}else if(g===Gl){const B=I?.height??1,C=I?.radius??1,E=I?.center??[0,0,0];l=i.cylinder({height:B,radius:C,center:E})}else if(g===rW){const B=I?.radius??1,C=I?.center??[0,0,0];l=i.sphere({radius:B,center:C})}else if(g===Cf){const B=I?.height??1,C=I?.radius??1,E=I?.roundRadius??.1,Q=I?.center??[0,0,0];l=i.roundedCylinder({height:B,radius:C,roundRadius:E,center:Q})}else{const B=I?.size??[1,1,1],C=I?.roundRadius??.1,E=I?.center??[0,0,0];l=i.roundedCuboid({size:B,roundRadius:C,center:E})}return[{geom:l,color:A??I?.color}]}if(typeof g=="function"){const l=g(I??{});return ID(l,A,t)}return(c??[]).flatMap(l=>ID(l,A,t))}function twe(e,A){return{geometries:ID(e,void 0,{jscad:A})}}function eXA(e){if(e.polygons){const A=[],t=[],i=[];let n=0;for(const s of e.polygons){for(const a of s.vertices)a.index=n,A.push(a[0],a[1],a[2]),e.color&&e.color.length>=3?i.push(e.color[0],e.color[1],e.color[2]):i.push(1,1,1),n++;const r=s.vertices[0].index;for(let a=2;a<s.vertices.length;a++){const g=s.vertices[a-1].index,I=s.vertices[a].index;t.push(r,g,I)}}const o=new yg;if(o.setAttribute("position",new QI(new Float32Array(A),3)),o.setIndex(t),i.length>0&&o.setAttribute("color",new QI(new Float32Array(i),3)),e.transforms){const s=new rs;s.fromArray(e.transforms),o.applyMatrix4(s)}return o.computeVertexNormals(),o}if(e.sides){const A=[],t=[];for(const n of e.sides)A.push(n[0][0],n[0][1],0),e.color&&e.color.length>=3?t.push(e.color[0],e.color[1],e.color[2]):t.push(1,1,1);const i=new yg;if(i.setAttribute("position",new QI(new Float32Array(A),3)),t.length>0&&i.setAttribute("color",new QI(new Float32Array(t),3)),e.transforms){const n=new rs;n.fromArray(e.transforms),i.applyMatrix4(n)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new yg}function ewe(e,A){const t=rEA(Xme,{footprint:e});return twe(t,A)}var iwe=Kr($8()),iXA=AA.createContext(null),nwe=()=>{const e=AA.useContext(iXA);if(!e)throw new Error("useHover must be used within a HoverProvider");return e},owe=({children:e})=>{const{camera:A,renderer:t}=Ku(),[i,n]=AA.useState([]),o=AA.useMemo(()=>new rMt,[]),s=AA.useMemo(()=>new En,[]),r=AA.useRef(i);r.current=i;const a=AA.useRef(null),g=AA.useCallback(C=>{n(E=>[...E,C])},[]),I=AA.useCallback(C=>{if(a.current){let E=!1,Q=a.current.object;for(;Q;){if(Q===C){E=!0;break}Q=Q.parent}E&&(a.current.onUnhover(),a.current=null)}n(E=>E.filter(Q=>Q.object!==C))},[]),c=AA.useCallback(C=>{let E=C;for(;E;){const Q=r.current.find(h=>h.object===E);if(Q)return Q;E=E.parent}},[]),l=AA.useCallback(C=>{if(!t.domElement)return;const E=t.domElement.getBoundingClientRect();s.x=(C.clientX-E.left)/E.width*2-1,s.y=-((C.clientY-E.top)/E.height)*2+1,o.setFromCamera(s,A);const Q=r.current.map(u=>u.object);if(Q.length===0){a.current&&(a.current.onUnhover(),a.current=null);return}const h=o.intersectObjects(Q,!0);if(h.length>0){const u=h[0],d=c(u.object);if(d){const f={mousePosition:[u.point.x,u.point.y,u.point.z]};a.current!==d?(a.current?.onUnhover(),d.onHover(f),a.current=d):d.onHover(f)}else a.current&&(a.current.onUnhover(),a.current=null)}else a.current&&(a.current.onUnhover(),a.current=null)},[A,t,o,s,c]);AA.useEffect(()=>{const C=t.domElement;return C.addEventListener("mousemove",l),()=>{C.removeEventListener("mousemove",l)}},[t,l]);const B=AA.useMemo(()=>({addHoverable:g,removeHoverable:I}),[g,I]);return Z.jsx(iXA.Provider,{value:B,children:e})},swe=({children:e,object:A,onHover:t,onUnhover:i,isHovered:n})=>{const{addHoverable:o,removeHoverable:s}=nwe();return AA.useEffect(()=>A?(o({object:A,onHover:t,onUnhover:i}),()=>{s(A)}):void 0,[A,t,i,o,s]),Z.jsx(Z.Fragment,{children:e})},EH=swe,rwe=({positionOffset:e,footprint:A,rotationOffset:t,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=Ku(),g=AA.useMemo(()=>{if(!A)return null;const{geometries:I}=ewe(A,iwe),c=new nf;for(const l of I.flat(1/0)){const B=l.geom;if(!B||!B.polygons&&!B.sides)continue;const C=new Ji(l.color);C.convertLinearToSRGB();const E={...B,color:[C.r,C.g,C.b]},Q=eXA(E),h=new wh({vertexColors:!0,side:jB,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new to(Q,h);c.add(u)}return c},[A,r]);return AA.useEffect(()=>{if(!(!g||!a))return a.add(g),()=>{a.remove(g)}},[a,g]),AA.useEffect(()=>{g&&(e&&g.position.fromArray(e),t&&g.rotation.fromArray(t),s!==void 0&&g.scale.setScalar(s))},[g,e?.[0],e?.[1],e?.[2],t?.[0],t?.[1],t?.[2],s]),AA.useEffect(()=>{g&&g.traverse(I=>{I instanceof to&&I.material instanceof wh&&(o?(I.material.emissive.setHex(255),I.material.emissiveIntensity=.2):I.material.emissiveIntensity=0)})},[o,g]),g?Z.jsx(EH,{isHovered:o,onHover:i,onUnhover:n,object:g}):null},nXA=new WeakMap,awe=()=>{const e=new Wc;return e.name="fallback-environment-map",e.mapping=KK,e},gwe=e=>{if(!e)return null;const A=e,t=nXA.get(A);if(t)return t;let i;if(e instanceof fP){const n=new $6(e);i=n.fromScene(lNt(),.04).texture,n.dispose()}else i=awe();return nXA.set(A,i),i},oXA=1.25;function sXA({gltfUrl:e,position:A,rotation:t,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=Ku(),[I,c]=AA.useState(null),[l,B]=AA.useState(null);if(AA.useEffect(()=>{if(!e)return;const C=new CNt;let E=!0;return C.load(e,Q=>{if(!E)return;const h=Q.scene;h.traverse(u=>{if(u instanceof to&&u.material){const d=f=>{f.transparent=r,f.opacity=r?.5:1,f.depthWrite=!r,f.needsUpdate=!0};Array.isArray(u.material)?u.material.forEach(d):d(u.material)}}),c(h)},void 0,Q=>{if(!E)return;console.error(`An error happened loading ${e}`,Q);const h=Q instanceof Error?Q:new Error(`Failed to load glTF model from ${e}`);B(h)}),()=>{E=!1}},[e,r]),AA.useEffect(()=>{I&&(A&&I.position.fromArray(A),t&&I.rotation.fromArray(t),s!==void 0&&I.scale.setScalar(s))},[I,A?.[0],A?.[1],A?.[2],t?.[0],t?.[1],t?.[2],s]),AA.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),AA.useEffect(()=>{if(!I||!a)return;const C=gwe(a);if(!C)return;const E=[],Q=h=>{h instanceof wh&&(E.push({material:h,envMap:h.envMap??null,envMapIntensity:h.envMapIntensity??1}),h.envMap=C,(typeof h.envMapIntensity!="number"||h.envMapIntensity<oXA)&&(h.envMapIntensity=oXA),h.needsUpdate=!0)};return I.traverse(h=>{if(!(h instanceof to))return;const u=h.material;Array.isArray(u)?u.forEach(Q):u&&Q(u)}),()=>{E.forEach(({material:h,envMap:u,envMapIntensity:d})=>{h.envMap=u,h.envMapIntensity=d,h.needsUpdate=!0})}},[I,a]),AA.useEffect(()=>{I&&I.traverse(C=>{C instanceof to&&C.material instanceof wh&&(o?(C.material.emissive.setHex(255),C.material.emissiveIntensity=.2):C.material.emissiveIntensity=0)})},[o,I]),l)throw l;return I?Z.jsx(EH,{isHovered:o,onHover:i,onUnhover:n,object:I}):null}var Iwe=Kr(czA()),cwe=Kr($8()),lwe=({jscadPlan:e,positionOffset:A,rotationOffset:t,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=Ku(),{threeGeom:g,material:I}=AA.useMemo(()=>{const l=(0,Iwe.executeJscadOperations)(cwe.default,e);if(!l||!l.polygons&&!l.sides)return{threeGeom:null,material:null};const B=eXA(l),C=new wh({vertexColors:!0,side:jB,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:B,material:C}},[e,r]),c=AA.useMemo(()=>g?new to(g,I):null,[g,I]);return AA.useEffect(()=>{if(!(!c||!a))return a.add(c),()=>{a.remove(c)}},[a,c]),AA.useEffect(()=>{c&&(A&&c.position.fromArray(A),t&&c.rotation.fromArray(t),s!==void 0&&c.scale.setScalar(s))},[c,A?.[0],A?.[1],A?.[2],t?.[0],t?.[1],t?.[2],s]),AA.useMemo(()=>{if(I)if(o){const l=new Ji(I.color.getHex());I.emissive.copy(l),I.emissive.setRGB(0,0,1),I.emissiveIntensity=.2}else I.emissiveIntensity=0},[o,I]),g?Z.jsx(EH,{isHovered:o,onHover:i,onUnhover:n,object:c}):null};function Bwe(e){return e.replace(/(DEF|USE)\s+([^\s]+)/g,(A,t,i)=>`${t} ${i.replace(/-/g,"_")}`)}async function Cwe(e){const A=await fetch(e);if(!A.ok)throw new Error(`Failed to fetch "${e}": ${A.status} ${A.statusText}`);const t=await A.text();return new $Nt().parse(Bwe(t),e)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function Qwe(e){const[A,t]=AA.useState(null);return AA.useEffect(()=>{if(!e)return;const i=e.replace(/&cachebust_origin=$/,""),n=window.TSCIRCUIT_OBJ_LOADER_CACHE;let o=!1;async function s(){try{if(i.endsWith(".wrl"))return await Cwe(i);const a=await fetch(i);if(!a.ok)throw new Error(`Failed to fetch "${i}": ${a.status} ${a.statusText}`);const g=await a.text(),I=g.match(/newmtl[\s\S]*?endmtl/g),c=new avt;if(I?.length){const l=I.join(`
|
|
5134
|
-
`).replace(/d 0\./g,"d 1."),B=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new jNt;C.setMaterialOptions({invertTrProperty:!0});const E=C.parse(l.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return c.setMaterials(E),c.parse(B)}return c.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(n.has(i)){const g=n.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(I=>I instanceof Error?I:I.clone())}const a=s().then(g=>(g instanceof Error||n.set(i,{...n.get(i),result:g}),g));return n.set(i,{promise:a,result:null}),a}return r().then(a=>{o||t(a)}).catch(a=>{console.error(a)}),()=>{o=!0}},[e]),A}function Ewe({url:e,position:A,rotation:t,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const a=Qwe(e),{rootObject:g}=Ku(),I=AA.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(c=>{if(c instanceof to&&c.material){const l=B=>{B.transparent=r,B.opacity=r?.5:1,B.depthWrite=!r,B.needsUpdate=!0};Array.isArray(c.material)?c.material.forEach(l):l(c.material)}}),a):new to(new Fm(.5,.5,.5),new wh({transparent:!0,color:"red",opacity:.25})),[a,r]);if(AA.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),AA.useEffect(()=>{I&&(A&&(Array.isArray(A)?I.position.fromArray(A):I.position.copy(A)),t&&(Array.isArray(t)?I.rotation.fromArray(t):I.rotation.copy(t)),s!==void 0&&I.scale.setScalar(s))},[I,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(t)?t[0]:t?.x,Array.isArray(t)?t[1]:t?.y,Array.isArray(t)?t[2]:t?.z,s]),a instanceof Error)throw a;return Z.jsx(EH,{isHovered:o,onHover:i,onUnhover:n,object:I})}var bEA,hwe="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function uwe(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&"default"in e&&typeof e.default=="function")return e.default;throw new Error("Unable to resolve occt-import-js factory export")}async function dwe(){if(!bEA){const e=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");bEA=uwe(e)({locateFile:t=>`${hwe}/${t}`})}return bEA}function pwe(e){const A=new nf;for(const t of e){const i=t.attributes.position?.array??[],n=t.index?.array??[];if(!i.length||!n.length)continue;const o=new yg;o.setAttribute("position",new To(i,3));const s=t.attributes.normal?.array??[];s.length?o.setAttribute("normal",new To(s,3)):o.computeVertexNormals(),o.setIndex(n);const r=new wh({color:t.color?new Ji(t.color[0],t.color[1],t.color[2]):new Ji(.82,.82,.82)}),a=new to(o,r);a.name=t.name,A.add(a)}return A}async function fwe(e){const A=await fetch(e);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const t=await A.arrayBuffer(),n=(await dwe()).ReadStepFile(new Uint8Array(t),null);if(!n.success||!n.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=pwe(n.meshes),s=new m$;return await new Promise((a,g)=>{s.parse(o,I=>{I instanceof ArrayBuffer?a(I):g(new Error("GLTFExporter did not return binary output"))},I=>{g(I)},{binary:!0})})}var rXA="step-glb-cache:";function ywe(e){const A=new Uint8Array(e),t=32768;let i="";for(let n=0;n<A.length;n+=t){const o=A.subarray(n,n+t);i+=String.fromCharCode(...o)}return btoa(i)}function mwe(e){const A=atob(e),t=new Uint8Array(A.length);for(let i=0;i<A.length;i+=1)t[i]=A.charCodeAt(i);return t.buffer}function wwe(e){try{const A=localStorage.getItem(`${rXA}${e}`);return A?mwe(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function aXA(e,A){try{const t=ywe(A);localStorage.setItem(`${rXA}${e}`,t)}catch(t){console.warn("Failed to write STEP GLB cache",t)}}function Dwe(){const e=globalThis;return e.stepUrlToGltfModelConversions||(e.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),e.stepUrlToGltfModelConversions}var Swe=({stepUrl:e,position:A,rotation:t,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r})=>{const[a,g]=AA.useState(null);return AA.useEffect(()=>{let I=!0,c=null,l=!0;const B=Dwe(),C=wwe(e);if(C){const h={arrayBuffer:C,blobUrl:URL.createObjectURL(new Blob([C],{type:"model/gltf-binary"}))};return B.completed.set(e,h),c=h.blobUrl,l=!1,g(h.blobUrl),()=>{I=!1,c&&l&&URL.revokeObjectURL(c)}}const E=B.completed.get(e);if(E)return c=E.blobUrl,l=!1,g(E.blobUrl),aXA(e,E.arrayBuffer),()=>{I=!1,c&&l&&URL.revokeObjectURL(c)};let Q=B.inProgress.get(e);return Q||(Q=fwe(e).then(h=>{const u={arrayBuffer:h,blobUrl:URL.createObjectURL(new Blob([h],{type:"model/gltf-binary"}))};return B.completed.set(e,u),B.inProgress.delete(e),u}).catch(h=>{throw B.inProgress.delete(e),h}),B.inProgress.set(e,Q)),Q.then(h=>{I&&(c=h.blobUrl,l=!1,g(h.blobUrl),aXA(e,h.arrayBuffer))}).catch(h=>{console.error("Failed to convert STEP file to GLB",h),I&&g(null)}),()=>{I=!1,c&&l&&URL.revokeObjectURL(c)}},[e]),a?Z.jsx(sXA,{gltfUrl:a,position:A,rotation:t,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r}):null},bwe=(e,A)=>{if(e)return A?A(e):e},gXA=(...e)=>e,IXA=({cad_component:e,circuitJson:A,resolveStaticAsset:t})=>{const i=CzA(A),[n,o]=AA.useState(!1),{visibility:s}=qN(),[r,a]=AA.useState(null),g=AA.useCallback(w=>{w?.mousePosition?(o(!0),a(w.mousePosition)):(o(!1),a(null))},[]),I=AA.useCallback(()=>{o(!1),a(null)},[]),c=AA.useMemo(()=>Si(A).source_component.getUsing({source_component_id:e.source_component_id})?.name,[A,e.source_component_id]),l=AA.useMemo(()=>A.filter(D=>D.type==="pcb_plated_hole"&&D.pcb_component_id===e.pcb_component_id).length>0,[A,e.pcb_component_id]),B=AA.useCallback(w=>bwe(w,t),[t]),C=B(e.model_obj_url??e.model_wrl_url??e.model_stl_url),E=B(e.model_glb_url??e.model_gltf_url),Q=B(e.model_step_url),u=A.find(w=>w.type==="pcb_component"&&w.source_component_id===e.source_component_id)?.layer??"top",d=AA.useMemo(()=>e.rotation?gXA(e.rotation.x*Math.PI/180,e.rotation.y*Math.PI/180,e.rotation.z*Math.PI/180):gXA(0,0,0),[e.rotation,u]),f=AA.useMemo(()=>{if(!e.position)return;let w;return u==="top"?w=i/2:u==="bottom"?w=-(i/2):w=e.position.z,[e.position.x,e.position.y,w]},[e.position,u,i]);let m=null;if(C?m=Z.jsx(Ewe,{url:C,position:f,rotation:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:I,isHovered:n,isTranslucent:e.show_as_translucent_model},e.cad_component_id):E?m=Z.jsx(sXA,{gltfUrl:E,position:f,rotation:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:I,isHovered:n,isTranslucent:e.show_as_translucent_model},e.cad_component_id):Q&&!e.model_jscad&&!e.footprinter_string?m=Z.jsx(Swe,{stepUrl:Q,position:f,rotation:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:I,isHovered:n,isTranslucent:e.show_as_translucent_model}):e.model_jscad?m=Z.jsx(lwe,{jscadPlan:e.model_jscad,positionOffset:f,rotationOffset:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:I,isHovered:n,isTranslucent:e.show_as_translucent_model},e.cad_component_id):e.footprinter_string&&(m=Z.jsx(rwe,{positionOffset:f,rotationOffset:d,footprint:e.footprinter_string,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:I,isHovered:n,isTranslucent:e.show_as_translucent_model})),e.show_as_translucent_model){if(!s.translucentModels)return null}else if(l&&!s.throughHoleModels||!l&&!s.smtModels)return null;return Z.jsxs(Z.Fragment,{children:[m,n&&r?Z.jsx(EzA,{position:r,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:c??"<unknown>"}):null]})},cXA={version:"0.0.510"};function xwe(e){e.querySelectorAll("canvas").forEach(A=>A.remove())}var _we=e=>{e.outputColorSpace=mm,e.toneMapping=G_A,e.toneMappingExposure=1},lXA="cadViewerCameraStateSession",BXA=(e,A)=>{try{const t={position:e.position.toArray(),quaternion:e.quaternion.toArray(),up:e.up.toArray(),fov:e.fov??50,target:A.target.toArray()};sessionStorage.setItem(lXA,JSON.stringify(t))}catch(t){console.warn("Failed to save camera:",t)}},xEA=(e,A)=>{try{const t=sessionStorage.getItem(lXA);if(!t)return!1;const i=JSON.parse(t);if(e.position.fromArray(i.position),e.quaternion.fromArray(i.quaternion),e.up.fromArray(i.up),"fov"in e){const n=e;n.fov=i.fov,n.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),e.updateMatrixWorld(),!0}catch(t){return console.warn("Failed to restore camera:",t),!1}},CXA=AA.createContext(void 0),kwe=({children:e,defaultTarget:A,initialCameraPosition:t})=>{const i=AA.useRef(null),n=AA.useRef(null),[o,s]=AA.useState(null),[r,a]=AA.useState("perspective"),[g,I]=AA.useState(t??null),[c,l]=AA.useState(new tf(0,0,0)),B=AA.useMemo(()=>{const[h,u,d]=t??[5,-5,5],f=Math.hypot(h-A.x,u-A.y,d-A.z);return f>0?f:5},[t,A]),C=AA.useCallback(h=>{const u=[A.x,A.y,A.z],d=n.current,f=i.current;let m=B;switch(d&&f&&(m=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const w=m/Math.sqrt(2);return{position:[A.x,A.y-w,A.z+w],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+m],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-m,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+m,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-m,A.z],target:u,up:[0,0,1]};default:return null}},[B,A,n,i]),E=AA.useCallback(h=>{i.current=h},[]),Q=AA.useMemo(()=>({controlsRef:i,mainCameraRef:n,defaultTarget:A,baseDistance:B,controller:o,setController:s,getPresetConfig:C,handleControlsChange:E,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:I,cameraRotation:c,setCameraRotation:l,saveCameraToSession:BXA,loadCameraFromSession:xEA}),[A,B,o,C,E,r,g,c]);return Z.jsx(CXA.Provider,{value:Q,children:e})},u_=()=>{const e=AA.useContext(CXA);if(!e)throw new Error("useCameraController must be used within a CameraControllerProvider");return e},Gwe=AA.forwardRef(({children:e,scene:A,camera:t,style:i,onCreated:n},o)=>{const{cameraType:s}=u_(),r=AA.useRef(null),[a,g]=AA.useState(null),I=AA.useRef([]),c=AA.useRef(void 0);c.current=n;const l=AA.useRef(null),B=AA.useCallback(h=>{I.current.push(h)},[]),C=AA.useCallback(h=>{I.current=I.current.filter(u=>u!==h)},[]),E=AA.useMemo(()=>new eG,[]);A?.up&&E.up.set(A.up.x,A.up.y,A.up.z);const Q=AA.useRef(new fg);return AA.useImperativeHandle(o,()=>Q.current),AA.useEffect(()=>{if(!r.current)return;xwe(r.current);const h=new fP({antialias:!0,alpha:!0});_we(h),h.setSize(r.current.clientWidth,r.current.clientHeight),h.setPixelRatio(window.devicePixelRatio),r.current.appendChild(h.domElement);const u=r.current.clientWidth/r.current.clientHeight,d=s==="perspective"?new mE(75,u,.1,1e3):new V2(-10*u,10*u,10,-10,-1e3,1e3);l.current?(d.position.copy(l.current.position),d.quaternion.copy(l.current.quaternion),d.up.copy(l.current.up)):(t?.up&&d.up.set(t.up[0],t.up[1],t.up[2]),t?.position&&d.position.set(t.position[0],t.position[1],t.position[2]),d.lookAt(0,0,0)),E.add(Q.current),window.__TSCIRCUIT_THREE_OBJECT=Q.current,g({scene:E,camera:d,renderer:h,rootObject:Q.current,addFrameListener:B,removeFrameListener:C}),c.current?.({camera:d,renderer:h});let f;const m=new zFt,w=()=>{const b=m.getElapsedTime(),k=m.getDelta();I.current.forEach(x=>x(b,k)),h.render(E,d),f=requestAnimationFrame(w)};w();const D=()=>{if(r.current){const b=r.current.clientWidth/r.current.clientHeight;d instanceof mE?d.aspect=b:d instanceof V2&&(d.left=-10*b,d.right=10*b,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),h.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",D),()=>{l.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",D),cancelAnimationFrame(f),r.current&&h.domElement&&r.current.removeChild(h.domElement),h.dispose(),E.remove(Q.current),window.__TSCIRCUIT_THREE_OBJECT===Q.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[E,B,C,s]),Z.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&Z.jsx(QzA.Provider,{value:a,children:Z.jsx(owe,{children:e})})})}),Fwe=({autoRotate:e,autoRotateSpeed:A,onStart:t,panSpeed:i,rotateSpeed:n,zoomSpeed:o,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:I,renderer:c}=Ku(),l=AA.useMemo(()=>!I||!c?null:new Ivt(I,c.domElement),[I,c]);return AA.useEffect(()=>(g?.(l??null),()=>g?.(null)),[l,g]),AA.useEffect(()=>{if(!l)return;const B=()=>{g?.(l)};return l.addEventListener("change",B),()=>{l.removeEventListener("change",B)}},[l,g]),AA.useEffect(()=>{l&&(l.autoRotate=e||!1,l.autoRotateSpeed=A||1,i!==void 0&&(l.panSpeed=i),n!==void 0&&(l.rotateSpeed=n),o!==void 0&&(l.zoomSpeed=o),s!==void 0&&(l.enableDamping=s),r!==void 0&&(l.dampingFactor=r),l.zoomToCursor=!0,l.mouseButtons={LEFT:Qx.ROTATE,MIDDLE:Qx.PAN,RIGHT:null},a&&(l.target.set(a[0],a[1],a[2]),l.update()))},[l,e,A,i,n,o,s,r,a]),AA.useEffect(()=>{if(!(!l||!t))return l.addEventListener("start",t),()=>{l.removeEventListener("start",t)}},[l,t]),AA.useEffect(()=>{if(l)return()=>{l.dispose()}},[l]),eH(()=>{l?.update()},[l]),null},Mwe=`
|
|
5134
|
+
`).replace(/d 0\./g,"d 1."),B=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new jNt;C.setMaterialOptions({invertTrProperty:!0});const E=C.parse(l.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return c.setMaterials(E),c.parse(B)}return c.parse(g.replace(/^mtllib.*/gm,""))}catch(a){return a}}function r(){if(n.has(i)){const g=n.get(i);return g.result?Promise.resolve(g.result.clone()):g.promise.then(I=>I instanceof Error?I:I.clone())}const a=s().then(g=>(g instanceof Error||n.set(i,{...n.get(i),result:g}),g));return n.set(i,{promise:a,result:null}),a}return r().then(a=>{o||t(a)}).catch(a=>{console.error(a)}),()=>{o=!0}},[e]),A}function Ewe({url:e,position:A,rotation:t,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const a=Qwe(e),{rootObject:g}=Ku(),I=AA.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(c=>{if(c instanceof to&&c.material){const l=B=>{B.transparent=r,B.opacity=r?.5:1,B.depthWrite=!r,B.needsUpdate=!0};Array.isArray(c.material)?c.material.forEach(l):l(c.material)}}),a):new to(new Fm(.5,.5,.5),new wh({transparent:!0,color:"red",opacity:.25})),[a,r]);if(AA.useEffect(()=>{if(!(!g||!I))return g.add(I),()=>{g.remove(I)}},[g,I]),AA.useEffect(()=>{I&&(A&&(Array.isArray(A)?I.position.fromArray(A):I.position.copy(A)),t&&(Array.isArray(t)?I.rotation.fromArray(t):I.rotation.copy(t)),s!==void 0&&I.scale.setScalar(s))},[I,Array.isArray(A)?A[0]:A?.x,Array.isArray(A)?A[1]:A?.y,Array.isArray(A)?A[2]:A?.z,Array.isArray(t)?t[0]:t?.x,Array.isArray(t)?t[1]:t?.y,Array.isArray(t)?t[2]:t?.z,s]),a instanceof Error)throw a;return Z.jsx(EH,{isHovered:o,onHover:i,onUnhover:n,object:I})}var bEA,hwe="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function uwe(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&"default"in e&&typeof e.default=="function")return e.default;throw new Error("Unable to resolve occt-import-js factory export")}async function dwe(){if(!bEA){const e=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");bEA=uwe(e)({locateFile:t=>`${hwe}/${t}`})}return bEA}function pwe(e){const A=new nf;for(const t of e){const i=t.attributes.position?.array??[],n=t.index?.array??[];if(!i.length||!n.length)continue;const o=new yg;o.setAttribute("position",new To(i,3));const s=t.attributes.normal?.array??[];s.length?o.setAttribute("normal",new To(s,3)):o.computeVertexNormals(),o.setIndex(n);const r=new wh({color:t.color?new Ji(t.color[0],t.color[1],t.color[2]):new Ji(.82,.82,.82)}),a=new to(o,r);a.name=t.name,A.add(a)}return A}async function fwe(e){const A=await fetch(e);if(!A.ok)throw new Error(`Failed to fetch STEP file: ${A.statusText}`);const t=await A.arrayBuffer(),n=(await dwe()).ReadStepFile(new Uint8Array(t),null);if(!n.success||!n.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=pwe(n.meshes),s=new m$;return await new Promise((a,g)=>{s.parse(o,I=>{I instanceof ArrayBuffer?a(I):g(new Error("GLTFExporter did not return binary output"))},I=>{g(I)},{binary:!0})})}var rXA="step-glb-cache:";function ywe(e){const A=new Uint8Array(e),t=32768;let i="";for(let n=0;n<A.length;n+=t){const o=A.subarray(n,n+t);i+=String.fromCharCode(...o)}return btoa(i)}function mwe(e){const A=atob(e),t=new Uint8Array(A.length);for(let i=0;i<A.length;i+=1)t[i]=A.charCodeAt(i);return t.buffer}function wwe(e){try{const A=localStorage.getItem(`${rXA}${e}`);return A?mwe(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function aXA(e,A){try{const t=ywe(A);localStorage.setItem(`${rXA}${e}`,t)}catch(t){console.warn("Failed to write STEP GLB cache",t)}}function Dwe(){const e=globalThis;return e.stepUrlToGltfModelConversions||(e.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),e.stepUrlToGltfModelConversions}var Swe=({stepUrl:e,position:A,rotation:t,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r})=>{const[a,g]=AA.useState(null);return AA.useEffect(()=>{let I=!0,c=null,l=!0;const B=Dwe(),C=wwe(e);if(C){const h={arrayBuffer:C,blobUrl:URL.createObjectURL(new Blob([C],{type:"model/gltf-binary"}))};return B.completed.set(e,h),c=h.blobUrl,l=!1,g(h.blobUrl),()=>{I=!1,c&&l&&URL.revokeObjectURL(c)}}const E=B.completed.get(e);if(E)return c=E.blobUrl,l=!1,g(E.blobUrl),aXA(e,E.arrayBuffer),()=>{I=!1,c&&l&&URL.revokeObjectURL(c)};let Q=B.inProgress.get(e);return Q||(Q=fwe(e).then(h=>{const u={arrayBuffer:h,blobUrl:URL.createObjectURL(new Blob([h],{type:"model/gltf-binary"}))};return B.completed.set(e,u),B.inProgress.delete(e),u}).catch(h=>{throw B.inProgress.delete(e),h}),B.inProgress.set(e,Q)),Q.then(h=>{I&&(c=h.blobUrl,l=!1,g(h.blobUrl),aXA(e,h.arrayBuffer))}).catch(h=>{console.error("Failed to convert STEP file to GLB",h),I&&g(null)}),()=>{I=!1,c&&l&&URL.revokeObjectURL(c)}},[e]),a?Z.jsx(sXA,{gltfUrl:a,position:A,rotation:t,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r}):null},bwe=(e,A)=>{if(e)return A?A(e):e},gXA=(...e)=>e,IXA=({cad_component:e,circuitJson:A,resolveStaticAsset:t})=>{const i=CzA(A),[n,o]=AA.useState(!1),{visibility:s}=qN(),[r,a]=AA.useState(null),g=AA.useCallback(w=>{w?.mousePosition?(o(!0),a(w.mousePosition)):(o(!1),a(null))},[]),I=AA.useCallback(()=>{o(!1),a(null)},[]),c=AA.useMemo(()=>Si(A).source_component.getUsing({source_component_id:e.source_component_id})?.name,[A,e.source_component_id]),l=AA.useMemo(()=>A.filter(D=>D.type==="pcb_plated_hole"&&D.pcb_component_id===e.pcb_component_id).length>0,[A,e.pcb_component_id]),B=AA.useCallback(w=>bwe(w,t),[t]),C=B(e.model_obj_url??e.model_wrl_url??e.model_stl_url),E=B(e.model_glb_url??e.model_gltf_url),Q=B(e.model_step_url),u=A.find(w=>w.type==="pcb_component"&&w.source_component_id===e.source_component_id)?.layer??"top",d=AA.useMemo(()=>e.rotation?gXA(e.rotation.x*Math.PI/180,e.rotation.y*Math.PI/180,e.rotation.z*Math.PI/180):gXA(0,0,0),[e.rotation,u]),f=AA.useMemo(()=>{if(!e.position)return;let w;return u==="top"?w=e.position.z:u==="bottom"?w=-(e.position.z+i):w=e.position.z,[e.position.x,e.position.y,w]},[e.position,u,i]);let m=null;if(C?m=Z.jsx(Ewe,{url:C,position:f,rotation:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:I,isHovered:n,isTranslucent:e.show_as_translucent_model},e.cad_component_id):E?m=Z.jsx(sXA,{gltfUrl:E,position:f,rotation:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:I,isHovered:n,isTranslucent:e.show_as_translucent_model},e.cad_component_id):Q&&!e.model_jscad&&!e.footprinter_string?m=Z.jsx(Swe,{stepUrl:Q,position:f,rotation:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:I,isHovered:n,isTranslucent:e.show_as_translucent_model}):e.model_jscad?m=Z.jsx(lwe,{jscadPlan:e.model_jscad,positionOffset:f,rotationOffset:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:I,isHovered:n,isTranslucent:e.show_as_translucent_model},e.cad_component_id):e.footprinter_string&&(m=Z.jsx(rwe,{positionOffset:f,rotationOffset:d,footprint:e.footprinter_string,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:I,isHovered:n,isTranslucent:e.show_as_translucent_model})),e.show_as_translucent_model){if(!s.translucentModels)return null}else if(l&&!s.throughHoleModels||!l&&!s.smtModels)return null;return Z.jsxs(Z.Fragment,{children:[m,n&&r?Z.jsx(EzA,{position:r,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:c??"<unknown>"}):null]})},cXA={version:"0.0.511"};function xwe(e){e.querySelectorAll("canvas").forEach(A=>A.remove())}var _we=e=>{e.outputColorSpace=mm,e.toneMapping=G_A,e.toneMappingExposure=1},lXA="cadViewerCameraStateSession",BXA=(e,A)=>{try{const t={position:e.position.toArray(),quaternion:e.quaternion.toArray(),up:e.up.toArray(),fov:e.fov??50,target:A.target.toArray()};sessionStorage.setItem(lXA,JSON.stringify(t))}catch(t){console.warn("Failed to save camera:",t)}},xEA=(e,A)=>{try{const t=sessionStorage.getItem(lXA);if(!t)return!1;const i=JSON.parse(t);if(e.position.fromArray(i.position),e.quaternion.fromArray(i.quaternion),e.up.fromArray(i.up),"fov"in e){const n=e;n.fov=i.fov,n.updateProjectionMatrix?.()}return A.target.fromArray(i.target),A.update(),e.updateMatrixWorld(),!0}catch(t){return console.warn("Failed to restore camera:",t),!1}},CXA=AA.createContext(void 0),kwe=({children:e,defaultTarget:A,initialCameraPosition:t})=>{const i=AA.useRef(null),n=AA.useRef(null),[o,s]=AA.useState(null),[r,a]=AA.useState("perspective"),[g,I]=AA.useState(t??null),[c,l]=AA.useState(new tf(0,0,0)),B=AA.useMemo(()=>{const[h,u,d]=t??[5,-5,5],f=Math.hypot(h-A.x,u-A.y,d-A.z);return f>0?f:5},[t,A]),C=AA.useCallback(h=>{const u=[A.x,A.y,A.z],d=n.current,f=i.current;let m=B;switch(d&&f&&(m=d.position.distanceTo(f.target)),h){case"Top Center Angled":{const w=m/Math.sqrt(2);return{position:[A.x,A.y-w,A.z+w],target:u,up:[0,0,1]}}case"Top Down":return{position:[A.x,A.y,A.z+m],target:u,up:[0,0,1]};case"Top Left Corner":return{position:[A.x-m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Top Right Corner":return{position:[A.x+m*.6,A.y-m*.6,A.z+m*.6],target:u,up:[0,0,1]};case"Left Sideview":return{position:[A.x-m,A.y,A.z],target:u,up:[0,0,1]};case"Right Sideview":return{position:[A.x+m,A.y,A.z],target:u,up:[0,0,1]};case"Front":return{position:[A.x,A.y-m,A.z],target:u,up:[0,0,1]};default:return null}},[B,A,n,i]),E=AA.useCallback(h=>{i.current=h},[]),Q=AA.useMemo(()=>({controlsRef:i,mainCameraRef:n,defaultTarget:A,baseDistance:B,controller:o,setController:s,getPresetConfig:C,handleControlsChange:E,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:I,cameraRotation:c,setCameraRotation:l,saveCameraToSession:BXA,loadCameraFromSession:xEA}),[A,B,o,C,E,r,g,c]);return Z.jsx(CXA.Provider,{value:Q,children:e})},u_=()=>{const e=AA.useContext(CXA);if(!e)throw new Error("useCameraController must be used within a CameraControllerProvider");return e},Gwe=AA.forwardRef(({children:e,scene:A,camera:t,style:i,onCreated:n},o)=>{const{cameraType:s}=u_(),r=AA.useRef(null),[a,g]=AA.useState(null),I=AA.useRef([]),c=AA.useRef(void 0);c.current=n;const l=AA.useRef(null),B=AA.useCallback(h=>{I.current.push(h)},[]),C=AA.useCallback(h=>{I.current=I.current.filter(u=>u!==h)},[]),E=AA.useMemo(()=>new eG,[]);A?.up&&E.up.set(A.up.x,A.up.y,A.up.z);const Q=AA.useRef(new fg);return AA.useImperativeHandle(o,()=>Q.current),AA.useEffect(()=>{if(!r.current)return;xwe(r.current);const h=new fP({antialias:!0,alpha:!0});_we(h),h.setSize(r.current.clientWidth,r.current.clientHeight),h.setPixelRatio(window.devicePixelRatio),r.current.appendChild(h.domElement);const u=r.current.clientWidth/r.current.clientHeight,d=s==="perspective"?new mE(75,u,.1,1e3):new V2(-10*u,10*u,10,-10,-1e3,1e3);l.current?(d.position.copy(l.current.position),d.quaternion.copy(l.current.quaternion),d.up.copy(l.current.up)):(t?.up&&d.up.set(t.up[0],t.up[1],t.up[2]),t?.position&&d.position.set(t.position[0],t.position[1],t.position[2]),d.lookAt(0,0,0)),E.add(Q.current),window.__TSCIRCUIT_THREE_OBJECT=Q.current,g({scene:E,camera:d,renderer:h,rootObject:Q.current,addFrameListener:B,removeFrameListener:C}),c.current?.({camera:d,renderer:h});let f;const m=new zFt,w=()=>{const b=m.getElapsedTime(),k=m.getDelta();I.current.forEach(x=>x(b,k)),h.render(E,d),f=requestAnimationFrame(w)};w();const D=()=>{if(r.current){const b=r.current.clientWidth/r.current.clientHeight;d instanceof mE?d.aspect=b:d instanceof V2&&(d.left=-10*b,d.right=10*b,d.top=10,d.bottom=-10),d.updateProjectionMatrix(),h.setSize(r.current.clientWidth,r.current.clientHeight)}};return window.addEventListener("resize",D),()=>{l.current={position:d.position.clone(),quaternion:d.quaternion.clone(),up:d.up.clone()},window.removeEventListener("resize",D),cancelAnimationFrame(f),r.current&&h.domElement&&r.current.removeChild(h.domElement),h.dispose(),E.remove(Q.current),window.__TSCIRCUIT_THREE_OBJECT===Q.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[E,B,C,s]),Z.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&Z.jsx(QzA.Provider,{value:a,children:Z.jsx(owe,{children:e})})})}),Fwe=({autoRotate:e,autoRotateSpeed:A,onStart:t,panSpeed:i,rotateSpeed:n,zoomSpeed:o,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:I,renderer:c}=Ku(),l=AA.useMemo(()=>!I||!c?null:new Ivt(I,c.domElement),[I,c]);return AA.useEffect(()=>(g?.(l??null),()=>g?.(null)),[l,g]),AA.useEffect(()=>{if(!l)return;const B=()=>{g?.(l)};return l.addEventListener("change",B),()=>{l.removeEventListener("change",B)}},[l,g]),AA.useEffect(()=>{l&&(l.autoRotate=e||!1,l.autoRotateSpeed=A||1,i!==void 0&&(l.panSpeed=i),n!==void 0&&(l.rotateSpeed=n),o!==void 0&&(l.zoomSpeed=o),s!==void 0&&(l.enableDamping=s),r!==void 0&&(l.dampingFactor=r),l.zoomToCursor=!0,l.mouseButtons={LEFT:Qx.ROTATE,MIDDLE:Qx.PAN,RIGHT:null},a&&(l.target.set(a[0],a[1],a[2]),l.update()))},[l,e,A,i,n,o,s,r,a]),AA.useEffect(()=>{if(!(!l||!t))return l.addEventListener("start",t),()=>{l.removeEventListener("start",t)}},[l,t]),AA.useEffect(()=>{if(l)return()=>{l.dispose()}},[l]),eH(()=>{l?.update()},[l]),null},Mwe=`
|
|
5135
5135
|
varying vec3 worldPosition;
|
|
5136
5136
|
void main() {
|
|
5137
5137
|
worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
@@ -5682,7 +5682,7 @@ test("${g} should solve problem correctly", () => {
|
|
|
5682
5682
|
// Add more specific assertions based on expected output
|
|
5683
5683
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5684
5684
|
})
|
|
5685
|
-
`,c=new Blob([I],{type:"text/plain"}),l=URL.createObjectURL(c),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:n,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.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:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},qgt=e=>e.activeSubSolver?[e,...qgt(e.activeSubSolver)]:[e],BWe=({solver:e})=>{const A=qgt(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(lWe,{solver:t})]},t.constructor.name))})},CWe=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(E=>!E,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},I=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},c=()=>{const E=e;if(E.getCurrentPhase&&!e.solved&&!e.failed){const Q=E.getCurrentPhase();for(;E.getCurrentPhase()===Q&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const E=window.prompt("Step until which iteration?",`${e.iterations}`);if(E===null)return;const Q=Number(E);if(!Number.isFinite(Q)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<Q&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(BWe,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:I,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),Z.jsx("button",{onClick:l,disabled:e.solved||e.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&Z.jsx("button",{onClick:c,disabled:e.solved||e.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},QWe=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},EWe=(e,A)=>{const i=e.pipelineDef[A].solverName,n=QWe(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let I=0;n==="Completed"?I=1:n==="In Progress"&&o&&(I=o.progress??0);const c=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:o??null}},hWe=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},uWe=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},dWe=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),pWe=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=dWe(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},qpA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(qpA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=qpA(i));return A},fWe=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=qpA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},yWe=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>EWe(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):fWe(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.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"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(hWe,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(uWe,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(pWe,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.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"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},mWe=class extends en.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function wWe({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(Q,h)=>{typeof Q=="number"&&(Q<s&&(s=Q),Q>a&&(a=Q)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const Q of A)I(Q.x,Q.y);for(const Q of t){const h=Q.points??[];for(const u of h)I(u.x,u.y)}for(const Q of i){const h=Q.x??0,u=Q.y??0,d=Q.width??0,f=Q.height??0;I(h,u),I(h+d,u+f)}for(const Q of n){const h=Q.x??0,u=Q.y??0,d=Q.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const Q of o)I(Q.x,Q.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,l=s-c,B=r-c,C=Math.max(1,a-s+2*c),E=Math.max(1,g-r+2*c);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${E}`,role:"img","aria-label":"Graphics fallback",children:[i.map((Q,h)=>Z.jsx("rect",{x:Q.x??0,y:Q.y??0,width:Q.width??0,height:Q.height??0,fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`rect-${h}`)),t.map((Q,h)=>Z.jsx("polyline",{fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1,points:(Q.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),n.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.fillColor??"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`circle-${h}`)),A.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.color??"black"},`point-${h}`)),o.map((Q,h)=>Z.jsx("text",{x:Q.x??0,y:Q.y??0,fontSize:Q.fontSize??10,fill:Q.color??"black",children:Q.text??""},`text-${h}`))]})}var DWe=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[e,n]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=e.pipelineDef!==void 0,g=I=>{const c=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(l=>l.solverName===I);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(CWe,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(mWe,{fallback:Z.jsx(wWe,{graphics:s}),children:Z.jsx(cWe,{graphics:s})}),a&&Z.jsx(yWe,{solver:e,onStepUntilPhase:g})]})};const SWe=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},bWe=e=>e.toLowerCase().includes("pack")?DGe:e.toLowerCase().includes("rout")?GGe:EGe,xWe=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);SWe();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),n=AA.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=AA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=irA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(irA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.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."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.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:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const I=bWe(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?Z.jsx(dD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:Z.jsx(DWe,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&Z.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:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Ogt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{UK.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{UK.captureException(n,{error_type:i.type})}catch{}}},[t])},Wgt="0.0.1589",_We={version:Wgt},OpA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},WpA=new Map,I9=e=>{const A=WpA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},kWe=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=WpA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return WpA.set(t.name,n),{type:"tracked",store:e,...n}},Zgt=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(OpA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(OpA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:I,...c}=kWe(r,g,a);let l=!0;n.setState=(E,Q,h)=>{const u=t(E,Q);if(!l)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...I9(a.name),[r]:n.getState()}),u)};const B=(...E)=>{const Q=l;l=!1,t(...E),l=Q},C=e(n.setState,i,n);if(c.type==="untracked"?I?.init(C):(c.stores[c.store]=n,I?.init(Object.fromEntries(Object.entries(c.stores).map(([E,Q])=>[E,E===c.store?C:Q.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let E=!1;const Q=n.dispatch;n.dispatch=(...h)=>{(OpA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!E&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),E=!0),Q(...h)}}return I.subscribe(E=>{var Q;switch(E.type){case"ACTION":if(typeof E.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return ZpA(E.payload,h=>{if(h.type==="__setState"){if(r===void 0){B(h.state);return}Object.keys(h.state).length!==1&&console.error(`
|
|
5685
|
+
`,c=new Blob([I],{type:"text/plain"}),l=URL.createObjectURL(c),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:n,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.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:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},qgt=e=>e.activeSubSolver?[e,...qgt(e.activeSubSolver)]:[e],BWe=({solver:e})=>{const A=qgt(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(lWe,{solver:t})]},t.constructor.name))})},CWe=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(E=>!E,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},I=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},c=()=>{const E=e;if(E.getCurrentPhase&&!e.solved&&!e.failed){const Q=E.getCurrentPhase();for(;E.getCurrentPhase()===Q&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const E=window.prompt("Step until which iteration?",`${e.iterations}`);if(E===null)return;const Q=Number(E);if(!Number.isFinite(Q)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<Q&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(BWe,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:I,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),Z.jsx("button",{onClick:l,disabled:e.solved||e.failed||o,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),B&&Z.jsx("button",{onClick:c,disabled:e.solved||e.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},QWe=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},EWe=(e,A)=>{const i=e.pipelineDef[A].solverName,n=QWe(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let I=0;n==="Completed"?I=1:n==="In Progress"&&o&&(I=o.progress??0);const c=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:o??null}},hWe=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},uWe=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},dWe=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),pWe=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=dWe(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},qpA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(qpA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=qpA(i));return A},fWe=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=qpA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},yWe=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>EWe(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):fWe(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.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"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(hWe,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(uWe,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(pWe,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.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"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},mWe=class extends en.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function wWe({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(Q,h)=>{typeof Q=="number"&&(Q<s&&(s=Q),Q>a&&(a=Q)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const Q of A)I(Q.x,Q.y);for(const Q of t){const h=Q.points??[];for(const u of h)I(u.x,u.y)}for(const Q of i){const h=Q.x??0,u=Q.y??0,d=Q.width??0,f=Q.height??0;I(h,u),I(h+d,u+f)}for(const Q of n){const h=Q.x??0,u=Q.y??0,d=Q.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const Q of o)I(Q.x,Q.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,l=s-c,B=r-c,C=Math.max(1,a-s+2*c),E=Math.max(1,g-r+2*c);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${E}`,role:"img","aria-label":"Graphics fallback",children:[i.map((Q,h)=>Z.jsx("rect",{x:Q.x??0,y:Q.y??0,width:Q.width??0,height:Q.height??0,fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`rect-${h}`)),t.map((Q,h)=>Z.jsx("polyline",{fill:"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1,points:(Q.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),n.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.fillColor??"none",stroke:Q.strokeColor??"black",strokeWidth:Q.strokeWidth??1},`circle-${h}`)),A.map((Q,h)=>Z.jsx("circle",{cx:Q.x??0,cy:Q.y??0,r:Q.radius??1.5,fill:Q.color??"black"},`point-${h}`)),o.map((Q,h)=>Z.jsx("text",{x:Q.x??0,y:Q.y??0,fontSize:Q.fontSize??10,fill:Q.color??"black",children:Q.text??""},`text-${h}`))]})}var DWe=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[e,n]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=e.pipelineDef!==void 0,g=I=>{const c=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(l=>l.solverName===I);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(CWe,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(mWe,{fallback:Z.jsx(wWe,{graphics:s}),children:Z.jsx(cWe,{graphics:s})}),a&&Z.jsx(yWe,{solver:e,onStepUntilPhase:g})]})};const SWe=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},bWe=e=>e.toLowerCase().includes("pack")?DGe:e.toLowerCase().includes("rout")?GGe:EGe,xWe=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);SWe();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),n=AA.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=AA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=irA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(irA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.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."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.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:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const I=bWe(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?Z.jsx(dD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:Z.jsx(DWe,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&Z.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:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Ogt=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{UK.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{UK.captureException(n,{error_type:i.type})}catch{}}},[t])},Wgt="0.0.1590",_We={version:Wgt},OpA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},WpA=new Map,I9=e=>{const A=WpA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},kWe=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=WpA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return WpA.set(t.name,n),{type:"tracked",store:e,...n}},Zgt=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(OpA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(OpA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:I,...c}=kWe(r,g,a);let l=!0;n.setState=(E,Q,h)=>{const u=t(E,Q);if(!l)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...I9(a.name),[r]:n.getState()}),u)};const B=(...E)=>{const Q=l;l=!1,t(...E),l=Q},C=e(n.setState,i,n);if(c.type==="untracked"?I?.init(C):(c.stores[c.store]=n,I?.init(Object.fromEntries(Object.entries(c.stores).map(([E,Q])=>[E,E===c.store?C:Q.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let E=!1;const Q=n.dispatch;n.dispatch=(...h)=>{(OpA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!E&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),E=!0),Q(...h)}}return I.subscribe(E=>{var Q;switch(E.type){case"ACTION":if(typeof E.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return ZpA(E.payload,h=>{if(h.type==="__setState"){if(r===void 0){B(h.state);return}Object.keys(h.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" } } }
|