@tscircuit/runframe 0.0.1635 → 0.0.1636
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.
|
@@ -5133,7 +5133,7 @@ ${a.join(`
|
|
|
5133
5133
|
${Q}polygon: ${C.polygon.vertices}
|
|
5134
5134
|
`:a+=`
|
|
5135
5135
|
`,C.children.length>0&&c.push(C.children)}return a}};A.exports=s}}),Yue=ot({"node_modules/@jscad/modeling/src/operations/booleans/trees/Tree.js"(e,A){var t=vue(),i=Hue(),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}}),XQA=ot({"node_modules/@jscad/modeling/src/operations/booleans/trees/index.js"(e,A){A.exports={Tree:Yue()}}}),Jue=ot({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3Sub.js"(e,A){var t=Vo(),i=zQA(),{Tree:n}=XQA(),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 c=a.allPolygons();return t.create(c)};A.exports=o}}),fzA=ot({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom3.js"(e,A){var t=Ro(),i=eH(),n=Jue(),o=(...s)=>{s=t(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),Tue=ot({"node_modules/@jscad/modeling/src/operations/booleans/intersectGeom2.js"(e,A){var t=Ro(),i=Vo(),n=h_(),o=VQA(),s=jQA(),r=fzA(),a=(...g)=>{g=t(g);const c=g.map(B=>s({z0:-1,z1:1},B)),I=r(c),l=n(I);return o(l,i.toPolygons(I))};A.exports=a}}),Kue=ot({"node_modules/@jscad/modeling/src/operations/booleans/intersect.js"(e,A){var t=Ro(),i=tH(),n=Zo(),o=Vo(),s=Tue(),r=fzA(),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 c=g[0];return n.isA(c)?s(g):o.isA(c)?r(g):c};A.exports=a}}),Pue=ot({"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(e,A){var t=mn(),i=h_(),n=Vo(),o=g=>g.sort((c,I)=>c-I).filter((c,I,l)=>!I||c!==l[I-1]),s=(g,c,I)=>{const l=`${c}`,B=g.get(l);B===void 0?g.set(l,[I]):B.push(I)},r=(g,c)=>{const I=`${c}`;return g.get(I)},a=g=>{const c=i(g),I=n.toPolygons(g),l=I.length,B=new Map,C=t.create();I.forEach((d,f)=>{d.vertices.forEach(m=>{s(B,t.snap(C,m,c),f)})});const Q=I.map(d=>{let f=[];return d.vertices.forEach(m=>{f=f.concat(r(B,t.snap(C,m,c)))}),{e:1,d:o(f)}});B.clear();let E=0;const h=Q.length;for(let d=0;d<h;d++){const f=Q[d];if(f.e>0){const m=new Array(l);m[d]=!0;do E=0,m.forEach((w,D)=>{const b=Q[D];if(b.e>0){b.e=-1;for(let k=0;k<b.d.length;k++)m[b.d[k]]=!0;E++}});while(E>0);f.indexes=m}}const u=[];for(let d=0;d<h;d++)if(Q[d].indexes){const f=[];Q[d].indexes.forEach((m,w)=>f.push(I[w])),u.push(n.create(f))}return u};A.exports=a}}),que=ot({"node_modules/@jscad/modeling/src/operations/booleans/scission.js"(e,A){var t=Ro(),i=Vo(),n=Pue(),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}}),Oue=ot({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3Sub.js"(e,A){var t=Vo(),i=zQA(),{Tree:n}=XQA(),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 c=a.allPolygons();return t.create(c)};A.exports=o}}),yzA=ot({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom3.js"(e,A){var t=Ro(),i=eH(),n=Oue(),o=(...s)=>{s=t(s);let r=s.shift();return s.forEach(a=>{r=n(r,a)}),r=i(r),r};A.exports=o}}),Wue=ot({"node_modules/@jscad/modeling/src/operations/booleans/subtractGeom2.js"(e,A){var t=Ro(),i=Vo(),n=h_(),o=VQA(),s=jQA(),r=yzA(),a=(...g)=>{g=t(g);const c=g.map(B=>s({z0:-1,z1:1},B)),I=r(c),l=n(I);return o(l,i.toPolygons(I))};A.exports=a}}),Zue=ot({"node_modules/@jscad/modeling/src/operations/booleans/subtract.js"(e,A){var t=Ro(),i=tH(),n=Zo(),o=Vo(),s=Wue(),r=yzA(),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 c=g[0];return n.isA(c)?s(g):o.isA(c)?r(g):c};A.exports=a}}),mzA=ot({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3Sub.js"(e,A){var t=Vo(),i=zQA(),{Tree:n}=XQA(),o=(r,a)=>{if(!i(r,a))return s(r,a);const g=new n(t.toPolygons(r)),c=new n(t.toPolygons(a));g.clipTo(c,!1),c.clipTo(g),c.invert(),c.clipTo(g),c.invert();const I=g.allPolygons().concat(c.allPolygons());return t.create(I)},s=(r,a)=>{let g=t.toPolygons(r);return g=g.concat(t.toPolygons(a)),t.create(g)};A.exports=o}}),wzA=ot({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom3.js"(e,A){var t=Ro(),i=eH(),n=mzA(),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}}),DzA=ot({"node_modules/@jscad/modeling/src/operations/booleans/unionGeom2.js"(e,A){var t=Ro(),i=Vo(),n=h_(),o=VQA(),s=jQA(),r=wzA(),a=(...g)=>{g=t(g);const c=g.map(B=>s({z0:-1,z1:1},B)),I=r(c),l=n(I);return o(l,i.toPolygons(I))};A.exports=a}}),$QA=ot({"node_modules/@jscad/modeling/src/operations/booleans/union.js"(e,A){var t=Ro(),i=tH(),n=Zo(),o=Vo(),s=DzA(),r=wzA(),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 c=g[0];return n.isA(c)?s(g):o.isA(c)?r(g):c};A.exports=a}}),ZN=ot({"node_modules/@jscad/modeling/src/operations/booleans/index.js"(e,A){A.exports={intersect:Kue(),scission:que(),subtract:Zue(),union:$QA()}}}),X8=ot({"node_modules/@jscad/modeling/src/operations/expansions/offsetFromPoints.js"(e,A){var{EPS:t,TAU:i}=dr(),n=AzA(),o=KQA(),s=ds(),r=V8(),a=(g,c)=>{const I={delta:1,corners:"edge",closed:!1,segments:16};let{delta:l,corners:B,closed:C,segments:Q}=Object.assign({},I,g);if(Math.abs(l)<t)return c;let E=g.closed?r(c):1;E===0&&(E=1);const h=E>0&&l>=0||E<0&&l<0;l=Math.abs(l);let u=null,d=[];const f=[],m=s.create(),w=c.length;for(let D=0;D<w;D++){const b=(D+1)%w,k=c[D],x=c[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 T=n(u[0],u[1],U[0],U[1]);T?(d.pop(),U[0]=T):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=c[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(Q/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(Q*(Math.abs(x)/i));const N=x/D,R=s.angle(s.subtract(b,k.s0[1],k.c)),U=[];for(let T=1;T<D;T++){const Y=R+N*T,O=s.fromAngleRadians(s.create(),Y);s.scale(O,O,l),s.add(O,O,k.c),U.push(O)}if(U.length>0){const T=k.s0[1];let Y=d.findIndex(O=>s.equals(T,O));Y=(Y+1)%d.length,d.splice(Y,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}}),Vue=ot({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom2.js"(e,A){var t=Zo(),i=X8(),n=(o,s)=>{const r={delta:1,corners:"edge",segments:16},{delta:a,corners:g,segments:c}=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:c},i(o,C))).reduce((C,Q)=>C.concat(t.toSides(t.fromPoints(Q))),[]);return t.create(B)};A.exports=n}}),jue=ot({"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(e,A){var t=Kg(),i=mn(),n=Vo(),o=or(),s=(r,a)=>{i.dot(o.plane(a),r)>0&&(a=o.invert(a));const c=[a],I=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,Q=o.create([a.vertices[B],I.vertices[B],I.vertices[C],a.vertices[C]]);c.push(Q)}return c.push(o.invert(I)),n.create(c)};A.exports=s}}),zue=ot({"node_modules/@jscad/modeling/src/operations/expansions/expandShell.js"(e,A){var{EPS:t,TAU:i}=dr(),n=Kg(),o=mn(),s=dzA(),r=Vo(),a=or(),g=lzA(),c=eH(),I=mzA(),l=jue(),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)}},Q=(h,u)=>{h.findIndex(f=>f===u)<0&&h.push(u)},E=(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 T=o.scale(o.create(),a.plane(R),2*f),Y=a.transform(n.fromTranslation(n.create(),o.scale(o.create(),T,-.5)),R),O=l(T,Y);w=I(w,O);const W=R.vertices;for(let X=0;X<W.length;X++){B(D,W[X],a.plane(R));const iA=(X+1)%W.length,aA=[W[X],W[iA]];C(b,aA,a.plane(R))}}),b.forEach(R=>{const U=R[0],T=R[1],Y=U[0],O=U[1],W=o.subtract(o.create(),O,Y);o.normalize(W,W);const X=T[0],iA=o.cross(o.create(),X,W);let aA=[];for(let TA=0;TA<m;TA++)Q(aA,TA*i/m);for(let TA=0,hA=T.length;TA<hA;TA++){const kA=T[TA],dA=o.dot(iA,kA),qA=o.dot(X,kA);let ZA=Math.atan2(dA,qA);ZA<0&&(ZA+=i),Q(aA,ZA),ZA=Math.atan2(-dA,-qA),ZA<0&&(ZA+=i),Q(aA,ZA)}aA=aA.sort(s);const tA=aA.length;let oA,rA;const CA=[],SA=[],MA=[];for(let TA=-1;TA<tA;TA++){const hA=aA[TA<0?TA+tA:TA],kA=Math.sin(hA),dA=Math.cos(hA);o.scale(k,X,dA*f),o.scale(x,iA,kA*f),o.add(k,k,x);const qA=o.add(o.create(),Y,k),ZA=o.add(o.create(),O,k);let rt=!1;if(TA>=0&&o.distance(qA,oA)<t&&(rt=!0),!rt){if(TA>=0){CA.push(qA),SA.push(ZA);const yA=[rA,ZA,qA,oA],$A=a.create(yA);MA.push($A)}oA=qA,rA=ZA}}SA.reverse(),MA.push(a.create(CA)),MA.push(a.create(SA));const GA=r.create(MA);w=I(w,GA)}),D.forEach(R=>{const U=R[0],T=R[1],Y=T[0];let O=null,W=0;for(let tA=1;tA<T.length;tA++){const oA=T[tA],rA=o.cross(k,Y,oA),CA=o.length(rA);CA>.05&&CA>W&&(W=CA,O=oA)}O||(O=o.orthogonal(k,Y));const X=o.cross(k,Y,O);o.normalize(X,X);const iA=o.cross(x,X,Y),aA=g({center:[U[0],U[1],U[2]],radius:f,segments:m,axes:[Y,X,iA]});w=I(w,aA)}),c(w)};A.exports=E}}),Xue=ot({"node_modules/@jscad/modeling/src/operations/expansions/expandGeom3.js"(e,A){var t=Vo(),i=$QA(),n=zue(),o=(s,r)=>{const a={delta:1,corners:"round",segments:12},{delta:g,corners:c,segments:I}=Object.assign({},a,s);if(c!=="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:c,segments:I};const B=n(s,r);return i(r,B)};A.exports=o}}),$ue=ot({"node_modules/@jscad/modeling/src/operations/expansions/expandPath2.js"(e,A){var t=V8(),i=ds(),n=Zo(),o=wg(),s=X8(),r=c=>{let{external:I,internal:l}=c;t(I)<0?I=I.reverse():l=l.reverse();const B=o.fromPoints({closed:!0},I),C=o.fromPoints({closed:!0},l),Q=n.toSides(n.fromPoints(o.toPoints(B))),E=n.toSides(n.fromPoints(o.toPoints(C)));return Q.push(...E),n.create(Q)},a=(c,I,l,B)=>{const{points:C,external:Q,internal:E}=c,h=Math.floor(I/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(),Q[Q.length-1],w)),b=C[0],k=i.angle(i.subtract(i.create(),E[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(...Q,...u,...E.reverse(),...d),n.fromPoints(f)},g=(c,I)=>{c=Object.assign({},{delta:1,corners:"edge",segments:16},c);const{delta:B,corners:C,segments:Q}=c;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 E=I.isClosed,h=o.toPoints(I);if(h.length===0)throw new Error("the given geometry cannot be empty");const u={points:h,external:s({delta:B,corners:C,segments:Q,closed:E},h),internal:s({delta:-B,corners:C,segments:Q,closed:E},h)};return I.isClosed?r(u):a(u,Q,C,B)};A.exports=g}}),AEA=ot({"node_modules/@jscad/modeling/src/operations/expansions/expand.js"(e,A){var t=Ro(),i=Zo(),n=Vo(),o=wg(),s=Vue(),r=Xue(),a=$ue(),g=(c,...I)=>{if(I=t(I),I.length===0)throw new Error("wrong number of arguments");const l=I.map(B=>o.isA(B)?a(c,B):i.isA(B)?s(c,B):n.isA(B)?r(c,B):B);return l.length===1?l[0]:l};A.exports=g}}),Ade=ot({"node_modules/@jscad/modeling/src/operations/expansions/offsetGeom2.js"(e,A){var t=Zo(),i=UQA(),n=X8(),o=(s,r)=>{const a={delta:1,corners:"edge",segments:0},{delta:g,corners:c,segments:I}=Object.assign({},a,s);if(!(c==="edge"||c==="chamfer"||c==="round"))throw new Error('corners must be "edge", "chamfer", or "round"');const l=t.toOutlines(r),C=l.map(Q=>(s={delta:l.reduce((u,d)=>u+i.arePointsInside(Q,i.create(d)),0)%2===0?g:-g,corners:c,closed:!0,segments:I},n(s,Q))).reduce((Q,E)=>Q.concat(t.toSides(t.fromPoints(E))),[]);return t.create(C)};A.exports=o}}),tde=ot({"node_modules/@jscad/modeling/src/operations/expansions/offsetPath2.js"(e,A){var t=wg(),i=X8(),n=(o,s)=>{const r={delta:1,corners:"edge",closed:s.isClosed,segments:16},{delta:a,corners:g,closed:c,segments:I}=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:c,segments:I};const l=i(o,t.toPoints(s));return t.fromPoints({closed:c},l)};A.exports=n}}),ede=ot({"node_modules/@jscad/modeling/src/operations/expansions/offset.js"(e,A){var t=Ro(),i=Zo(),n=wg(),o=Ade(),s=tde(),r=(a,...g)=>{if(g=t(g),g.length===0)throw new Error("wrong number of arguments");const c=g.map(I=>n.isA(I)?s(a,I):i.isA(I)?o(a,I):I);return c.length===1?c[0]:c};A.exports=r}}),SzA=ot({"node_modules/@jscad/modeling/src/operations/expansions/index.js"(e,A){A.exports={expand:AEA(),offset:ede()}}}),$8=ot({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(e,A){var t=Kg(),i=mn(),n=Zo(),o=WN(),s=z8(),r=(a,g)=>{const c={offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0};let{offset:I,twistAngle:l,twistSteps:B,repair:C}=Object.assign({},c,a);if(B<1)throw new Error("twistSteps must be 1 or more");l===0&&(B=1);const Q=i.clone(I),E=n.toSides(g);if(E.length===0)throw new Error("the given geometry cannot be empty");const h=o.fromSides(E);Q[2]<0&&o.reverse(h,h);const u=t.create(),d=(f,m,w)=>{const D=m/B*l,b=i.scale(i.create(),Q,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}}),ide=ot({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearPath2.js"(e,A){var t=Zo(),i=wg(),n=$8(),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}}),nde=ot({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinear.js"(e,A){var t=Ro(),i=Zo(),n=wg(),o=$8(),s=ide(),r=(a,...g)=>{const c={height:1,twistAngle:0,twistSteps:1,repair:!0},{height:I,twistAngle:l,twistSteps:B,repair:C}=Object.assign({},c,a);if(g=t(g),g.length===0)throw new Error("wrong number of arguments");a={offset:[0,0,I],twistAngle:l,twistSteps:B,repair:C};const Q=g.map(E=>n.isA(E)?s(a,E):i.isA(E)?o(a,E):E);return Q.length===1?Q[0]:Q};A.exports=r}}),ode=ot({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularPath2.js"(e,A){var t=wg(),i=AEA(),n=$8(),o=(s,r)=>{const a={size:1,height:1},{size:g,height:c}=Object.assign({},a,s);if(s.delta=g,s.offset=[0,0,c],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}}),sde=ot({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangularGeom2.js"(e,A){var{area:t}=zU(),i=Zo(),n=wg(),o=AEA(),s=$8(),r=(a,g)=>{const c={size:1,height:1},{size:I,height:l}=Object.assign({},c,a);a.delta=I,a.offset=[0,0,l];const B=i.toOutlines(g);if(B.length===0)throw new Error("the given geometry cannot be empty");const Q=B.map(h=>(t(h)<0&&h.reverse(),o(a,n.fromPoints({closed:!0},h)))).reduce((h,u)=>h.concat(i.toSides(u)),[]),E=i.create(Q);return s(a,E)};A.exports=r}}),rde=ot({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeRectangular.js"(e,A){var t=Ro(),i=Zo(),n=wg(),o=ode(),s=sde(),r=(a,...g)=>{const c={size:1,height:1},{size:I,height:l}=Object.assign({},c,a);if(g=t(g),g.length===0)throw new Error("wrong number of arguments");if(I<=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}}),ade=ot({"node_modules/@jscad/modeling/src/operations/extrusions/extrudeHelical.js"(e,A){var{TAU:t}=dr(),i=Kg(),n=Zo(),o=z8(),s=WN(),r=(a,g)=>{const c={angle:t,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:I,startAngle:l,pitch:B,height:C,endOffset:Q,segmentsPerRotation:E}=Object.assign({},c,a);if(C!=0&&(B=C/(I/t)),E<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(E/t*Math.abs(I)),w=m>=2?m:2,D=i.create(),b=i.create(),k=(x,N,R)=>{const U=l+I/w*N,T=Q/w*N,Y=(U-l)/t*B;return i.multiply(D,i.fromTranslation(i.create(),[T,0,Y*Math.sign(I)]),i.fromXRotation(i.create(),-t/4*Math.sign(I))),i.multiply(b,i.fromZRotation(i.create(),U),D),s.transform(b,R)};return o({numberOfSlices:w+1,callback:k},f)};A.exports=r}}),gde=ot({"node_modules/@jscad/modeling/src/operations/extrusions/project.js"(e,A){var t=Ro(),i=TQA(),n=rD(),o=Kg(),s=Zo(),r=Vo(),a=or(),g=h_(),c=DzA(),I=(B,C)=>{const Q=n.fromNormalAndPoint(n.create(),B.axis,B.origin);if(Number.isNaN(Q[0])||Number.isNaN(Q[1])||Number.isNaN(Q[2])||Number.isNaN(Q[3]))throw new Error("project: invalid axis or origin");const E=g(C),h=E*E*Math.sqrt(3)/4;if(E===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(Q,k)),D=a.create(w),b=a.plane(D);i(Q,b)&&(a.measureArea(D)<h||d.push(D))}if(!i(Q,[0,0,1])){const m=o.fromVectorRotation(o.create(),Q,[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 c(f)},l=(B,...C)=>{const Q={axis:[0,0,1],origin:[0,0,0]},{axis:E,origin:h}=Object.assign({},Q,B);if(C=t(C),C.length===0)throw new Error("wrong number of arguments");B={axis:E,origin:h};const u=C.map(d=>r.isA(d)?I(B,d):d);return u.length===1?u[0]:u};A.exports=l}}),iH=ot({"node_modules/@jscad/modeling/src/operations/extrusions/index.js"(e,A){A.exports={extrudeFromSlices:z8(),extrudeLinear:nde(),extrudeRectangular:rde(),extrudeRotate:EzA(),extrudeHelical:ade(),project:gde(),slice:WN()}}}),tEA=ot({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints2.js"(e,A){var t=ds(),i=s=>{let r=t.fromValues(1/0,1/0);s.forEach(c=>{(c[1]<r[1]||c[1]===r[1]&&c[0]<r[0])&&(r=c)});const a=[];s.forEach(c=>{const I=o(c[1]-r[1],c[0]-r[0]),l=t.squaredDistance(c,r);a.push({point:c,angle:I,distSq:l})}),a.sort((c,I)=>c.angle!==I.angle?c.angle-I.angle:c.distSq-I.distSq);const g=[];return a.forEach(c=>{let I=g.length;for(;I>1&&n(g[I-2],g[I-1],c.point)<=Number.EPSILON;)g.pop(),I=g.length;g.push(c.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}}),eEA=ot({"node_modules/@jscad/modeling/src/operations/hulls/toUniquePoints.js"(e,A){var t=Zo(),i=Vo(),n=wg(),o=s=>{const r=new Set,a=[],g=c=>{const I=c.toString();r.has(I)||(a.push(c),r.add(I))};return s.forEach(c=>{t.isA(c)?t.toPoints(c).forEach(g):i.isA(c)?i.toPoints(c).forEach(I=>I.forEach(g)):n.isA(c)&&n.toPoints(c).forEach(g)}),a};A.exports=o}}),cde=ot({"node_modules/@jscad/modeling/src/operations/hulls/hullPath2.js"(e,A){var t=Ro(),i=wg(),n=tEA(),o=eEA(),s=(...r)=>{r=t(r);const a=o(r),g=n(a);return i.fromPoints({closed:!0},g)};A.exports=s}}),Ide=ot({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom2.js"(e,A){var t=Ro(),i=Zo(),n=tEA(),o=eEA(),s=(...r)=>{r=t(r);const a=o(r),g=n(a);return g.length<3?i.create():i.fromPoints(g)};A.exports=s}}),bzA=ot({"node_modules/@jscad/modeling/src/operations/hulls/hullPoints3.js"(e,A){var t=or(),i=DjA(),n=o=>i(o,{skipTriangulation:!0}).map(a=>{const g=a.map(c=>o[c]);return t.create(g)});A.exports=n}}),lde=ot({"node_modules/@jscad/modeling/src/operations/hulls/hullGeom3.js"(e,A){var t=Ro(),i=Vo(),n=eEA(),o=bzA(),s=(...r)=>{r=t(r);const a=n(r);return a.length===0?i.create():i.create(o(a))};A.exports=s}}),xzA=ot({"node_modules/@jscad/modeling/src/operations/hulls/hull.js"(e,A){var t=Ro(),i=tH(),n=Zo(),o=Vo(),s=wg(),r=cde(),a=Ide(),g=lde(),c=(...I)=>{if(I=t(I),I.length===0)throw new Error("wrong number of arguments");if(!i(I))throw new Error("only hulls of the same type are supported");const l=I[0];return s.isA(l)?r(I):n.isA(l)?a(I):o.isA(l)?g(I):l};A.exports=c}}),Bde=ot({"node_modules/@jscad/modeling/src/operations/hulls/hullChain.js"(e,A){var t=Ro(),i=$QA(),n=xzA(),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}}),Cde=ot({"node_modules/@jscad/modeling/src/operations/hulls/index.js"(e,A){A.exports={hull:xzA(),hullChain:Bde(),hullPoints2:tEA(),hullPoints3:bzA()}}}),_zA=ot({"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(c=>{const I=c.vertices.map(C=>t.snap(t.create(),C,s)),l=[];for(let C=0;C<I.length;C++){const Q=(C+1)%I.length;t.equals(I[C],I[Q])||l.push(I[C])}const B=i.create(l);return c.color&&(B.color=c.color),B});const g=s*s*Math.sqrt(3)/4;return a=a.filter(c=>n(g,c)),a};A.exports=o}}),Qde=ot({"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(e,A){var t=TQA(),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]},c=i.create(),I=i.create(),l=(h,u,d,f)=>{const m=i.subtract(c,u,h),w=i.subtract(I,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 T=(Y,O,W)=>{const X={v1:W.v1,v2:O.v2,next:O.next,prev:W.prev};W.prev.next=X,O.next.prev=X,r(Y,O),O.v1=null,O.v2=null,O.next=null,O.prev=null,r(Y,W),W.v1=null,W.v2=null,W.next=null,W.prev=null};N[0]===0&&T(f,R,R.prev),N[1]===0&&T(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},Q=(h,u)=>Math.abs(h[3]-u[3])<15e-8?t(h,u):!1,E=(h,u)=>{const d=[];u.forEach(m=>{const w=d.find(D=>Q(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=E}}),Ede=ot({"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(e,A){var t=dr(),i=mn(),n=or(),o=g=>`${g}`,s=(g,c,I,l,B,C)=>{const Q=o(l),E=o(B),h=`${Q}/${E}`,u=`${E}/${Q}`;if(g.has(u))return r(g,c,I,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]),c.has(Q)?c.get(Q).push(h):c.set(Q,[h]),I.has(E)?I.get(E).push(h):I.set(E,[h]),h},r=(g,c,I,l,B,C)=>{const Q=o(l),E=o(B),h=`${Q}/${E}`;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===Q&&(w=o(m.vertex1),w===E&&!(C!==null&&m.polygonindex!==C))){u=f;break}}d.splice(u,1),d.length===0&&g.delete(h),u=c.get(Q).indexOf(h),c.get(Q).splice(u,1),c.get(Q).length===0&&c.delete(Q),u=I.get(E).indexOf(h),I.get(E).splice(u,1),I.get(E).length===0&&I.delete(E)},a=g=>{const c=new Map;for(let I=0;I<g.length;I++){const l=g[I],B=l.vertices.length;if(B>=3){let C=l.vertices[0],Q=o(C);for(let E=0;E<B;E++){let h=E+1;h===B&&(h=0);const u=l.vertices[h],d=o(u),f=`${Q}/${d}`,m=`${d}/${Q}`;if(c.has(m)){const w=c.get(m);w.splice(-1,1),w.length===0&&c.delete(m)}else{const w={vertex0:C,vertex1:u,polygonindex:I};c.has(f)?c.get(f).push(w):c.set(f,[w])}C=u,Q=d}}else console.warn("warning: invalid polygon found during insertTjunctions")}if(c.size>0){const I=new Map,l=new Map,B=new Map;for(const[Q,E]of c)B.set(Q,!0),E.forEach(h=>{const u=o(h.vertex0),d=o(h.vertex1);I.has(u)?I.get(u).push(Q):I.set(u,[Q]),l.has(d)?l.get(d).push(Q):l.set(d,[Q])});const C=g.slice(0);for(;c.size!==0;){for(const E of c.keys())B.set(E,!0);let Q=!1;for(;;){const E=Array.from(B.keys());if(E.length===0)break;const h=E[0];let u=!0;if(c.has(h)){const f=c.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)):I.has(b)&&(x=I.get(b));for(let N=0;N<x.length;N++){const R=x[N],U=c.get(R)[0],T=m===0?U.vertex0:U.vertex1;if(m===0?U.vertex1:U.vertex0,o(T)===k){r(c,I,l,w,D,null),r(c,I,l,D,w,null),u=!1,m=2,Q=!0;break}else{const O=w,W=D,X=T,iA=i.subtract(i.create(),X,O),aA=i.dot(i.subtract(i.create(),W,O),iA)/i.dot(iA,iA);if(aA>0&&aA<1){const tA=i.scale(i.create(),iA,aA);if(i.add(tA,tA,O),i.squaredDistance(tA,W)<t.EPS*t.EPS){const rA=U.polygonindex,CA=C[rA],SA=o(U.vertex1);let MA=-1;for(let dA=0;dA<CA.vertices.length;dA++)if(o(CA.vertices[dA])===SA){MA=dA;break}const GA=CA.vertices.slice(0);GA.splice(MA,0,D);const TA=n.create(GA);C[rA]=TA,r(c,I,l,U.vertex0,U.vertex1,rA);const hA=s(c,I,l,U.vertex0,D,rA),kA=s(c,I,l,D,U.vertex1,rA);hA!==null&&B.set(hA,!0),kA!==null&&B.set(kA,!0),u=!1,m=2,Q=!0;break}}}}}}u&&B.delete(h)}if(!Q)break}g=C}return c.clear(),g};A.exports=a}}),hde=ot({"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 c=i.create([r.vertices[0],r.vertices[1],r.vertices[2]]),I=i.create([r.vertices[0],r.vertices[2],r.vertices[3]]);r.color&&(c.color=r.color,I.color=r.color),a.push(c,I);return}a.push(r)},o=(s,r)=>{const a=[];return r.forEach(g=>{n(s,g,a)}),a};A.exports=o}}),ude=ot({"node_modules/@jscad/modeling/src/operations/modifiers/generalize.js"(e,A){var t=Ro(),i=h_(),n=Zo(),o=Vo(),s=wg(),r=_zA(),a=Qde(),g=Ede(),c=hde(),I=(Q,E)=>E,l=(Q,E)=>E,B=(Q,E)=>{const h={snap:!1,simplify:!1,triangulate:!1},{snap:u,simplify:d,triangulate:f}=Object.assign({},h,Q),m=i(E);let w=o.toPolygons(E);u&&(w=r(m,w)),d&&(w=a(m,w)),f&&(w=g(w),w=c(m,w));const D=Object.assign({},E);return D.polygons=w,D},C=(Q,...E)=>{if(E=t(E),E.length===0)throw new Error("wrong number of arguments");const h=E.map(u=>{if(s.isA(u))return I(Q,u);if(n.isA(u))return l(Q,u);if(o.isA(u))return B(Q,u);throw new Error("invalid geometry")});return h.length===1?h[0]:h};A.exports=C}}),dde=ot({"node_modules/@jscad/modeling/src/operations/modifiers/snap.js"(e,A){var t=Ro(),i=ds(),n=Zo(),o=Vo(),s=wg(),r=h_(),a=_zA(),g=B=>{const C=r(B),E=s.toPoints(B).map(h=>i.snap(i.create(),h,C));return s.create(E)},c=B=>{const C=r(B);let E=n.toSides(B).map(h=>[i.snap(i.create(),h[0],C),i.snap(i.create(),h[1],C)]);return E=E.filter(h=>!i.equals(h[0],h[1])),n.create(E)},I=B=>{const C=r(B),Q=o.toPolygons(B),E=a(C,Q);return o.create(E)},l=(...B)=>{if(B=t(B),B.length===0)throw new Error("wrong number of arguments");const C=B.map(Q=>s.isA(Q)?g(Q):n.isA(Q)?c(Q):o.isA(Q)?I(Q):Q);return C.length===1?C[0]:C};A.exports=l}}),pde=ot({"node_modules/@jscad/modeling/src/operations/modifiers/index.js"(e,A){A.exports={generalize:ude(),snap:dde(),retessellate:eH()}}}),fde=ot({"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}}),yde=ot({"node_modules/@jscad/modeling/src/operations/transforms/align.js"(e,A){var t=Ro(),i=fde(),n=PQA(),{translate:o}=WF(),s=c=>{if(!Array.isArray(c.modes)||c.modes.length>3)throw new Error("align(): modes must be an array of length <= 3");if(c.modes=i(c.modes,"none",3),c.modes.filter(I=>["center","max","min","none"].includes(I)).length!==3)throw new Error('align(): all modes must be one of "center", "max" or "min"');if(!Array.isArray(c.relativeTo)||c.relativeTo.length>3)throw new Error("align(): relativeTo must be an array of length <= 3");if(c.relativeTo=i(c.relativeTo,0,3),c.relativeTo.filter(I=>Number.isFinite(I)||I==null).length!==3)throw new Error("align(): all relativeTo values must be a number, or null.");if(typeof c.grouped!="boolean")throw new Error("align(): grouped must be a boolean value.");return c},r=(c,I,l)=>{for(let B=0;B<3;B++)c[B]==null&&(I[B]==="center"?c[B]=(l[0][B]+l[1][B])/2:I[B]==="max"?c[B]=l[1][B]:I[B]==="min"&&(c[B]=l[0][B]));return c},a=(c,I,l)=>{const B=n(c),C=[0,0,0];for(let Q=0;Q<3;Q++)I[Q]==="center"?C[Q]=l[Q]-(B[0][Q]+B[1][Q])/2:I[Q]==="max"?C[Q]=l[Q]-B[1][Q]:I[Q]==="min"&&(C[Q]=l[Q]-B[0][Q]);return o(C,c)},g=(c,...I)=>{c=Object.assign({},{modes:["center","center","min"],relativeTo:[0,0,0],grouped:!1},c),c=s(c);let{modes:B,relativeTo:C,grouped:Q}=c;if(I=t(I),I.length===0)throw new Error("align(): No geometries were provided to act upon");if(C.filter(E=>E==null).length){const E=n(I);C=r(C,B,E)}return Q?I=a(I,B,C):I=I.map(E=>a(E,B,C)),I.length===1?I[0]:I};A.exports=g}}),AW=ot({"node_modules/@jscad/modeling/src/operations/transforms/center.js"(e,A){var t=Ro(),i=Zo(),n=Vo(),o=wg(),s=qF(),{translate:r}=WF(),a=(B,C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,B),u=s(C),d=[0,0,0];return E[0]&&(d[0]=h[0]-(u[0][0]+(u[1][0]-u[0][0])/2)),E[1]&&(d[1]=h[1]-(u[0][1]+(u[1][1]-u[0][1])/2)),E[2]&&(d[2]=h[2]-(u[0][2]+(u[1][2]-u[0][2])/2)),r(d,C)},g=(B,...C)=>{const Q={axes:[!0,!0,!0],relativeTo:[0,0,0]},{axes:E,relativeTo:h}=Object.assign({},Q,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:E,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},c=(...B)=>g({axes:[!0,!1,!1]},B),I=(...B)=>g({axes:[!1,!0,!1]},B),l=(...B)=>g({axes:[!1,!1,!0]},B);A.exports={center:g,centerX:c,centerY:I,centerZ:l}}}),tW=ot({"node_modules/@jscad/modeling/src/operations/transforms/scale.js"(e,A){var t=Ro(),i=Kg(),n=Zo(),o=Vo(),s=wg(),r=(I,...l)=>{if(!Array.isArray(I))throw new Error("factors must be an array");if(l=t(l),l.length===0)throw new Error("wrong number of arguments");for(I=I.slice();I.length<3;)I.push(1);if(I[0]<=0||I[1]<=0||I[2]<=0)throw new Error("factors must be positive");const B=i.fromScaling(i.create(),I),C=l.map(Q=>s.isA(Q)?s.transform(B,Q):n.isA(Q)?n.transform(B,Q):o.isA(Q)?o.transform(B,Q):Q);return C.length===1?C[0]:C},a=(I,...l)=>r([I,1,1],l),g=(I,...l)=>r([1,I,1],l),c=(I,...l)=>r([1,1,I],l);A.exports={scale:r,scaleX:a,scaleY:g,scaleZ:c}}}),mde=ot({"node_modules/@jscad/modeling/src/operations/transforms/transform.js"(e,A){var t=Ro(),i=Zo(),n=Vo(),o=wg(),s=(r,...a)=>{if(a=t(a),a.length===0)throw new Error("wrong number of arguments");const g=a.map(c=>o.isA(c)?o.transform(r,c):i.isA(c)?i.transform(r,c):n.isA(c)?n.transform(r,c):c);return g.length===1?g[0]:g};A.exports=s}}),ZF=ot({"node_modules/@jscad/modeling/src/operations/transforms/index.js"(e,A){A.exports={align:yde(),center:AW().center,centerX:AW().centerX,centerY:AW().centerY,centerZ:AW().centerZ,mirror:$U().mirror,mirrorX:$U().mirrorX,mirrorY:$U().mirrorY,mirrorZ:$U().mirrorZ,rotate:AH().rotate,rotateX:AH().rotateX,rotateY:AH().rotateY,rotateZ:AH().rotateZ,scale:tW().scale,scaleX:tW().scaleX,scaleY:tW().scaleY,scaleZ:tW().scaleZ,transform:mde(),translate:WF().translate,translateX:WF().translateX,translateY:WF().translateY,translateZ:WF().translateZ}}}),eW=ot({"node_modules/@jscad/modeling/src/index.js"(e,A){A.exports={colors:Z8(),curves:dhe(),geometries:HQA(),maths:Phe(),measurements:Xhe(),primitives:u_(),text:ZQA(),utils:pzA(),booleans:ZN(),expansions:SzA(),extrusions:iH(),hulls:Cde(),modifiers:pde(),transforms:ZF()}}}),kzA=ot({"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,Q)=>{if(B&&typeof B=="object"||typeof B=="function")for(let E of n(B))!o.call(l,E)&&E!==C&&t(l,E,{get:()=>B[E],enumerable:!(Q=i(B,E))||Q.enumerable});return l},a=l=>r(t({},"__esModule",{value:!0}),l),g={};s(g,{executeJscadOperations:()=>I,jscadPlanner:()=>c}),A.exports=a(g);var c={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}},I=(l,B)=>{if(Array.isArray(B)&&B.length===1)return I(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=>I(l,h),{type:Q,...E}=B;switch(Q){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(E);case"sphere":return l.primitives.sphere(E);case"cylinder":return l.primitives.cylinder(E);case"polygon":return l.primitives.polygon(E);case"cuboid":return l.primitives.cuboid(E);case"roundedCuboid":return l.primitives.roundedCuboid(E);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)}`)}}}}),wde=ot({"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?c(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]),Q=(B[2]||"ms").toLowerCase();switch(Q){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 c(l){var B=Math.abs(l);return B>=o?I(l,B,o,"day"):B>=n?I(l,B,n,"hour"):B>=i?I(l,B,i,"minute"):B>=t?I(l,B,t,"second"):l+" ms"}function I(l,B,C,Q){var E=B>=C*1.5;return Math.round(l/C)+" "+Q+(E?"s":"")}}}),Dde=ot({"node_modules/debug/src/common.js"(e,A){function t(i){o.debug=o,o.default=o,o.coerce=I,o.disable=g,o.enable=r,o.enabled=c,o.humanize=wde(),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 Q=0;Q<B.length;Q++)C=(C<<5)-C+B.charCodeAt(Q),C|=0;return o.colors[Math.abs(C)%o.colors.length]}o.selectColor=n;function o(B){let C,Q=null,E,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:()=>Q!==null?Q:(E!==o.namespaces&&(E=o.namespaces,h=o.enabled(B)),h),set:d=>{Q=d}}),typeof o.init=="function"&&o.init(u),u}function s(B,C){const Q=o(this.namespace+(typeof C>"u"?":":C)+B);return Q.log=this.log,Q}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 Q of C)Q[0]==="-"?o.skips.push(Q.slice(1)):o.names.push(Q)}function a(B,C){let Q=0,E=0,h=-1,u=0;for(;Q<B.length;)if(E<C.length&&(C[E]===B[Q]||C[E]==="*"))C[E]==="*"?(h=E,u=Q,E++):(Q++,E++);else if(h!==-1)E=h+1,u++,Q=u;else return!1;for(;E<C.length&&C[E]==="*";)E++;return E===C.length}function g(){const B=[...o.names,...o.skips.map(C=>"-"+C)].join(",");return o.enable(""),B}function c(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 I(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}}),Sde=ot({"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 c=0,I=0;a[0].replace(/%[a-zA-Z%]/g,l=>{l!=="%%"&&(c++,l==="%c"&&(I=c))}),a.splice(I,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 kQA<"u"&&"env"in kQA&&(a=kQA.env.DEBUG),a}function s(){try{return localStorage}catch{}}A.exports=Dde()(e);var{formatters:r}=A.exports;r.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}}}),FzA={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},GzA=AA.createContext(void 0),bde=({children:e})=>{const[A,t]=AA.useState(FzA),i=AA.useCallback((s,r)=>{t(a=>({...a,[s]:r}))},[]),n=AA.useCallback(()=>{t(FzA)},[]),o=AA.useMemo(()=>({visibility:A,setLayerVisibility:i,resetToDefaults:n}),[A,i,n]);return Z.jsx(GzA.Provider,{value:o,children:e})},VF=()=>{const e=AA.useContext(GzA);if(!e)throw new Error("useLayerVisibility must be used within a LayerVisibilityProvider");return e},iEA=1.2;function MzA(e){return AA.useMemo(()=>{if(!e)return iEA;try{return Ji(e).pcb_board.list()[0]?.thickness??iEA}catch{return iEA}},[e])}var RzA=AA.createContext(null),Lu=()=>{const e=AA.useContext(RzA);if(!e)throw new Error("useThree must be used within a ThreeProvider");return e},nH=(e,A=[])=>{const{addFrameListener:t,removeFrameListener:i}=Lu();nn.useEffect(()=>(t(e),()=>i(e)),[t,i,...A])},oH={clickToInteractOverlay:100,htmlElements:95,orientationCube:95,contextMenu:90,appearanceMenu:91},NzA=({children:e,position:A,style:t})=>{const{camera:i,renderer:n}=Lu(),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(gK.createPortal(e,o.current)),()=>{a.contains(o.current)&&a.removeChild(o.current)}},[n,e]),nH(()=>{if(!i||!o.current||!n)return;const a=new Mt(...A);a.project(i);const g=n.domElement.getBoundingClientRect(),c=Math.round((a.x+1)/2*g.width),I=Math.round((-a.y+1)/2*g.height);o.current.style.position="absolute",o.current.style.left=`${c}px`,o.current.style.top=`${I}px`,o.current.style.pointerEvents="none",o.current.style.zIndex=oH.htmlElements.toString(),t&&Object.assign(o.current.style,t)},[i,n,A,t]),s},vzA={in:25.4,inch:25.4,mil:.0254,mm:1,m:1e3,cm:10,ft:304.8,feet:304.8},Fr=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 vzA)return t*vzA[A];throw new Error(`Unsupported unit: ${A}`)},_l=Fr,xde=Object.defineProperty,_de=(e,A)=>{for(var t in A)xde(e,t,{get:A[t],enumerable:!0})},ob={};_de(ob,{axial:()=>Xpe,bga:()=>rpe,breakoutheaders:()=>Ife,cap:()=>vde,dfn:()=>Mpe,diode:()=>Nde,dip:()=>Gde,electrolytic:()=>Zye,hc49:()=>Bfe,jst:()=>Eye,led:()=>Lde,lqfp:()=>gfe,m2host:()=>Qme,melf:()=>D0e,micromelf:()=>_0e,minimelf:()=>h0e,mlp:()=>Epe,ms012:()=>Ype,ms013:()=>Tpe,msop:()=>Sye,pad:()=>Cfe,pinrow:()=>vpe,platedhole:()=>sme,potentiometer:()=>qye,pushbutton:()=>ife,qfn:()=>Bpe,qfp:()=>Qpe,quad:()=>jN,radial:()=>tfe,res:()=>npe,sma:()=>M0e,smb:()=>J0e,smbf:()=>jye,smc:()=>q0e,smf:()=>L0e,smtpad:()=>nme,sod110:()=>uye,sod123:()=>Zpe,sod123f:()=>Vfe,sod123fl:()=>$fe,sod123w:()=>_fe,sod128:()=>r0e,sod323:()=>Mfe,sod323f:()=>qfe,sod323fl:()=>Gye,sod323w:()=>xye,sod523:()=>dfe,sod723:()=>i0e,sod80:()=>Dfe,sod882:()=>Jfe,sod882d:()=>f0e,sod923:()=>Lfe,soic:()=>gpe,solderjumper:()=>Lye,son:()=>vye,sop8:()=>mfe,sot:()=>ame,sot223:()=>V0e,sot23:()=>Spe,sot23w:()=>nye,sot25:()=>kpe,sot323:()=>Ame,sot343:()=>Ime,sot363:()=>ype,sot457:()=>Yye,sot563:()=>Upe,sot723:()=>Ppe,sot886:()=>wpe,sot89:()=>B0e,sot963:()=>Tye,ssop:()=>upe,stampboard:()=>ofe,stampreceiver:()=>afe,to220:()=>Q0e,to92:()=>hfe,to92l:()=>hme,to92s:()=>cye,tqfp:()=>Cpe,tssop:()=>ppe,vssop:()=>mye});var Wi=(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"}),Zi=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")}),jo=(e,A,t,i,n)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"circle",x:A,y:t,hole_diameter:Fr(i),outer_diameter:Fr(n),pcb_port_id:"",layers:["top","bottom"],port_hints:[e.toString()]}),sb=(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:Fr(i),hole_shape:"circle",pad_shape:"rect",rect_pad_width:Fr(n),rect_pad_height:Fr(o),pcb_port_id:"",layers:["top","bottom"],port_hints:[e.toString()],hole_offset_x:s,hole_offset_y:r}),LzA=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 d_(e){return typeof e=="string"?e.trim().toLowerCase().endsWith("mil")?parseFloat(e)*.0254:parseFloat(e):Number(e)}var iW=Ze([H(),WA()]).transform(e=>d_(e)),kde=e=>Zi.extend({fn:H(),num_pins:WA().optional().default(6),wide:gt().optional(),narrow:gt().optional(),w:iW.optional(),p:iW.default(e.p??"2.54mm"),id:iW.optional(),od:iW.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=d_("0.55mm"),A.od=d_("0.95mm")):(A.id=d_("0.8mm"),A.od=d_("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=d_("600mil"):A.narrow?A.w=d_("300mil"):A.w=d_(e.w??"300mil")),A)),Fde=kde({}),UzA=(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}},Gde=e=>{const A=Fde.parse(e),t=[];for(let g=0;g<A.num_pins;g++){const{x:c,y:I}=UzA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating);if(g===0&&!A.nosquareplating){t.push(sb(g+1,c,I,A.id??"0.8mm",A.od??"1mm",A.od??"1mm"));continue}t.push(jo(g+1,c,I,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},...LzA.map(({x:g,y:c})=>({x:g*n/6,y:c*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 c=g<A.num_pins/2,I=.6,{y:l}=UzA(A.num_pins,g+1,A.w,A.p??2.54,A.nosquareplating),B=c?-A.w/2-A.od/2-I:A.w/2+A.od/2+I,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=Wi(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()]}),HzA=[{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}],Mde=Object.fromEntries(HzA.map(e=>[e.metric,e])),Rde=Object.fromEntries(HzA.map(e=>[e.imperial,e]));Zi.extend({tht:gt(),p:QA.optional(),pw:QA.optional(),ph:QA.optional(),metric:at.optional(),imperial:at.optional(),w:QA.optional(),h:QA.optional(),textbottom:gt().optional()});var nW=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=_l(r)),typeof a=="string"&&(a=_l(a)),typeof t=="string"&&(t=_l(t)),typeof i=="string"&&(i=_l(i)),typeof n=="string"&&(n=_l(n)),a!==void 0&&r!==void 0&&a>r)throw new Error("height cannot be greater than width (rotated footprint not yet implemented)");let c;if(o&&(c=Mde[o]),s&&(c=Rde[s]),c&&(r=c.w_mm_min,a=c.h_mm_min,t=c.p_mm_min,i=c.pw_mm_min,n=c.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 I={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=Wi(0,l,.2);return A?[jo(1,-t/2,0,i,i*1/.8),jo(2,t/2,0,i,i*1/.8),I,B]:[di(["1","left"],-t/2,0,i,n),di(["2","right"],t/2,0,i,n),I,B]},Nde=e=>({circuitJson:nW(e),parameters:e}),vde=e=>({circuitJson:nW(e),parameters:e}),Lde=e=>({circuitJson:nW(e),parameters:e}),VN=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 c=Math.max(...r)+i/2+.4,I=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:c},{x:l*.5,y:c}],stroke_width:.12,pcb_silkscreen_path_id:"silkscreen_top"},Q={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_bottom"},E=-A/2,h=Math.max(...r),u=.2,d=E-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?I-.9:c+.9,D=Wi(0,w,.2);return[...g,C,Q,m,D]},Ude=Zi.extend({pw:H().default("0.5mm"),ph:H().default("0.4mm"),p:H().default("0.7mm"),textbottom:gt().optional()}),Hde=1,Yde=e=>{const A=Ude.parse(e),t=_l(A.pw),i=_l(A.ph),n=_l(A.p);return VN({padSpacing:Hde,padWidth:t,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom})},Jde=Zi.extend({pw:H().default("0.5mm"),ph:H().default("0.32mm"),p:H().default("0.5mm"),textbottom:gt().optional()}),Tde=1,Kde=e=>{const A=Jde.parse(e),t=_l(A.pw),i=_l(A.ph),n=_l(A.p);return VN({padSpacing:Tde,padWidth:t,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom})},Pde=Zi.extend({pw:H().default("0.9mm"),ph:H().default("0.4mm"),p:H().default("0.8mm"),textbottom:gt().optional()}),qde=1.7,Ode=e=>{const A=Pde.parse(e),t=_l(A.pw),i=_l(A.ph),n=_l(A.p);return VN({padSpacing:qde,padWidth:t,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom})},Wde=Zi.extend({pw:H().default("0.9mm"),ph:H().default("0.4mm"),p:H().default("0.8mm"),textbottom:gt().optional()}),Zde=1.7,Vde=e=>{const A=Wde.parse(e),t=_l(A.pw),i=_l(A.ph),n=_l(A.p);return VN({padSpacing:Zde,padWidth:t,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom})},jde=Zi.extend({pw:H().default("0.7mm"),ph:H().default("0.64mm"),p:H().default("0.94mm"),textbottom:gt().optional()}),zde=1.4,Xde=e=>{const A=jde.parse(e),t=_l(A.pw),i=_l(A.ph),n=_l(A.p);return VN({padSpacing:zde,padWidth:t,padHeight:i,padPitch:n,numRows:2,textbottom:A.textbottom})},$de=Zi.extend({pw:H().default("0.9mm"),ph:H().default("0.9mm"),p:H().default("1.34mm"),textbottom:gt().optional()}),Ape=3,tpe=e=>{const A=$de.parse(e),t=_l(A.pw),i=_l(A.ph),n=_l(A.p);return VN({padSpacing:Ape,padWidth:t,padHeight:i,padPitch:n,numRows:4,textbottom:A.textbottom})},epe=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)}},ipe=e=>e?(typeof e=="number"?`${e}`:e).split("_")[0]:void 0,npe=e=>{const A=epe(e),t=ipe(e.imperial);return A===2&&t==="0402"?{circuitJson:Yde(e),parameters:e}:A===4&&t==="0402"?{circuitJson:Kde(e),parameters:e}:A===2&&t==="0603"?{circuitJson:Ode(e),parameters:e}:A===4&&t==="0603"?{circuitJson:Vde(e),parameters:e}:A===2&&t==="0606"?{circuitJson:Xde(e),parameters:e}:A===4&&t==="1206"?{circuitJson:tpe(e),parameters:e}:{circuitJson:nW(e),parameters:e}},YzA=(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()]}),JzA="ABCDEFGHIJKLMNOPQRSTUVWXYZ",TzA=H().transform(e=>{const[A,t]=e.split(/[x ]/);return{x:parseFloat(A),y:parseFloat(t)}}).pipe(jA({x:WA(),y:WA()})),ope=H().or(St(Yc())).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(H().or(WA()))),spe=Zi.extend({fn:H(),num_pins:WA().optional().default(64),grid:TzA.optional(),p:at.default("0.8mm"),w:QA.optional(),h:QA.optional(),ball:QA.optional().describe("ball diameter"),pad:QA.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:ope.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=JzA.indexOf(n[1]),s=Number.parseInt(n[2])-1;return o*e.grid.x+s+1})),{...e,origin:A}}),rpe=e=>{const A=spe.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 c=[],I=(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++)I.push(b*i.x+k+1)}g?.includes("topleft")&&I.push(1);const B=new Set(I);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,`${JzA[x]}${k+1}`];c.push(A.circularpads?YzA(R,{x:D,y:b,radius:a/2}):di(R,D,b,a,a))}const Q=Wi(0,i.y*n/2,.2),E=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-E},{x:-u-E,y:-d},{x:-u,y:-d}];break;case"br":h=[{x:u,y:-d},{x:u,y:-d-E},{x:u+E,y:-d},{x:u,y:-d}];break;case"tr":h=[{x:u,y:d},{x:u,y:d+E},{x:u+E,y:d},{x:u,y:d}];break;default:h=[{x:-u,y:d},{x:-u,y:d+E},{x:-u-E,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:[...c,Q,f],parameters:A}},oW=(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()]}),aD=e=>Zi.extend({fn:H(),num_pins:WA().optional().default(8),w:QA.default(QA.parse(e.w??"5.3mm")),p:QA.default(QA.parse(e.p??"1.27mm")),pw:QA.default(QA.parse(e.pw??"0.6mm")),pl:QA.default(QA.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=QA.parse("0.6mm"),A.pl=QA.parse("1.0mm")):A.pw?A.pl||(A.pl=A.pw*(1/.6)):A.pw=A.pl*(.6/1),A)),ape=aD({}),nEA=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,c=n,I=c*g,l=s?o/2:-o/2;return a?{x:-i/2-l,y:I/2-(t-1)*c}:{x:i/2+l,y:-I/2+(t-r-1)*c}},gpe=e=>{const A=ape.parse(e);return{circuitJson:p_(A),parameters:A}},p_=e=>{const A=[];for(let r=0;r<e.num_pins;r++){const{x:a,y:g}=nEA({num_pins:e.num_pins,pn:r+1,w:e.w,p:e.p,pl:e.pl,legsoutside:e.legsoutside});e.pillpads?A.push(oW(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=Wi(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},...LzA.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]},KzA=se(["leftside","topside","rightside","bottomside","toppin","bottompin","leftpin","rightpin"]),cpe=({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},oEA=Zi.extend({fn:H(),cc:gt().default(!0).optional(),ccw:gt().default(!0).optional(),startingpin:H().or(St(KzA)).transform(e=>typeof e=="string"?e.slice(1,-1).split(","):e).pipe(St(KzA)).optional(),num_pins:WA().optional().default(64),w:QA.optional(),h:QA.optional(),p:QA.default(QA.parse("0.5mm")),pw:QA.optional(),pl:QA.optional(),thermalpad:Ze([xA(!0),TzA]).optional(),legsoutside:gt().default(!1)}),sEA=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},PzA=oEA.transform(sEA),Ipe=["left","bottom","right","top"],lpe=e=>{const{pin_count:A,pn:t,w:i,h:n,p:o,pl:s,legsoutside:r}=e,a=A/4,g=Ipe[Math.floor((t-1)/a)],c=(t-1)%a,I=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-c*o,o:"vert"};case"bottom":return{x:-I/2+c*o,y:-n/2-B+.1,o:"horz"};case"right":return{x:i/2+B-.1,y:-l/2+c*o,o:"vert"};case"top":return{x:I/2-c*o,y:n/2+B-.1,o:"horz"};default:throw new Error("Invalid pin number")}},jN=e=>{const A=PzA.parse(e),t=[],i=cpe(A),n=A.num_pins/4;for(let r=0;r<A.num_pins;r++){const{x:a,y:g,o:c}=lpe({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 I=A.pw,l=A.pl;c==="vert"&&([I,l]=[l,I]);const B=i[r+1];t.push(di(B,a,g,I,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 c=A.w/2*a,I=A.h/2*g;let l="none",B=c,C=I;const Q=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 E=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*E,C-=u*g*E}(l==="none"||A.legsoutside)&&o.push({layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}`,route:[{x:c-Q*a,y:I},{x:c,y:I},{x:c,y:I-Q*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:c-Q*a,y:I},{x:c-Q*a/2,y:I}],type:"pcb_silkscreen_path",stroke_width:0},{layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:`pcb_silkscreen_path_${r}_2`,route:[{x:c,y:I-Q*g/2},{x:c,y:I-Q*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*E},{x:B,y:C},{x:B+.2*E*-a,y:C+.2},{x:B-.2*-a,y:C+.2*E}],type:"pcb_silkscreen_path",stroke_width:.1})}const s=Wi(0,A.h/2+(A.legsoutside?A.pl*1.2:.5),.3);return{circuitJson:[...t,...o,s],parameters:A}};oEA.extend({}).transform(sEA);var Bpe=e=>(e.legsoutside=!1,e.pl||(e.pl=.875),e.pw||(e.pw=.25),jN(e)),Cpe=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 jN(e)},Qpe=e=>{e.legsoutside=!0;const A=PzA.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 jN(e)};oEA.extend({}).transform(sEA);var Epe=e=>(e.legsoutside=!1,e.thermalpad===void 0&&(e.thermalpad=!0),jN(e)),hpe=aD({w:"3.9mm",p:"1.27mm"}),upe=e=>{const A=hpe.parse(e);return{circuitJson:p_(A),parameters:A}},dpe=aD({w:"7.1mm",p:"0.65mm",pl:"1.35mm",pw:"0.40mm",legsoutside:!0}),ppe=e=>{const A=dpe.parse(e);return{circuitJson:p_(A),parameters:A}},fpe=aD({}),ype=e=>{const A=fpe.parse({fn:"sot363",num_pins:6,w:2.56,p:.65,pw:.4,pl:.65,legoutside:!0});return{circuitJson:p_(A),parameters:A}},mpe=Zi.extend({fn:H(),num_pins:xA(6).default(6),w:H().default("1.01mm"),h:H().default("1.45mm"),p:H().default("0.5mm"),pl:H().default("0.33mm"),pw:H().default("0.27mm"),string:H().optional()}),wpe=e=>{const A=mpe.parse({fn:"sot886",...e}),t=QA.parse(A.w),i=QA.parse(A.h),n=QA.parse(A.p),o=QA.parse(A.pl),s=QA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=qzA(B+1,t,n,o);r.push(di(B+1,C,Q,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:""},c=qzA(1,t,n,o),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-o/2-.3,y:c.y},{x:c.x-o/2-.45,y:c.y+.15},{x:c.x-o/2-.45,y:c.y-.15},{x:c.x-o/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Wi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},qzA=(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}},OzA=Zi.extend({fn:H(),num_pins:WA().default(3),w:H().default("1.92mm"),h:H().default("2.74mm"),pl:H().default("1.32mm"),pw:H().default("0.6mm"),p:H().default("0.95mm"),string:H().optional()}),Dpe=aD({p:"0.95mm",w:"1.6mm",legsoutside:!0}),Spe=e=>{const A=e.string?.match(/^sot23_(\d+)/),t=A?Number.parseInt(A[1],10):3;if(t===6||t===8){const n=Dpe.parse({...e,num_pins:t});return{circuitJson:p_(n),parameters:n}}const i=OzA.parse({...e,num_pins:t});if(i.num_pins===3)return{circuitJson:xpe(i),parameters:i};if(i.num_pins===5)return{circuitJson:ZzA(i),parameters:i};throw new Error("Invalid number of pins")},bpe=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}},xpe=e=>{const A=[];for(let i=0;i<e.num_pins;i++){const{x:n,y:o}=bpe({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=Wi(0,Number.parseInt(e.h),.3);return[...A,t]},WzA=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")},ZzA=e=>{const A=[];for(let I=1;I<=e.num_pins;I++){const{x:l,y:B}=WzA({h:Number.parseFloat(e.h),p:Number.parseFloat(e.p),pn:I});A.push(di(I,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=Wi(0,i+.3,.3),r=WzA({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,c={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,c]},_pe=OzA.extend({}),kpe=e=>{const A=_pe.parse({...e,num_pins:5});return{circuitJson:ZzA(A),parameters:A}},Fpe=[{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}],Gpe=aD({}),Mpe=e=>{const A=Gpe.parse(e),t=[];for(let I=0;I<A.num_pins;I++){const{x:l,y:B}=nEA({num_pins:A.num_pins,pn:I+1,w:A.w,p:A.p??1.27,pl:A.pl,widthincludeslegs:!0});t.push(di(I+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 I of Fpe){const{dx:l,dy:B}=I;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 c=Wi(0,o/2+.4,o/12);return{circuitJson:[...t,c,...s],parameters:A}},rEA=({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 Rpe({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 Npe=Zi.extend({fn:H(),num_pins:WA().optional().default(6),rows:Ze([H(),WA()]).transform(e=>Number(e)).optional().default(1).describe("number of rows"),p:QA.default("0.1in").describe("pitch"),id:QA.default("1.0mm").describe("inner diameter"),od:QA.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:QA.optional().default("1.0mm").describe("pad width for SMD"),pl:QA.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=Rpe(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"]})}),vpe=e=>{const A=Npe.parse(e),{p:t,id:i,od:n,rows:o,num_pins:s,pinlabelAnchorSide:r,pinlabelverticallyinverted:a,pinlabelorthogonal:g,pinlabeltextalignleft:c,pinlabeltextalignright:I,nopinlabels:l,doublesidedpinlabel:B,bottomsidepinlabel:C}=A;let Q="center";c?Q="left":I&&(Q="right");const E=[],h=Math.ceil(s/o),u=-t,d=({xoff:b,yoff:k,od:x,anchorSide:N,smd:R,pw:U,pl:T})=>{let Y=0,O=0;if(R){const W=x/5;switch(N){case"right":Y=U/2+W;break;case"top":O=T/2+W;break;case"bottom":O=-(T/2+W);break;case"left":Y=-(U/2+W);break}}else{const W=x*.75;switch(N){case"right":Y=W;break;case"top":O=W;break;case"bottom":O=-W;break;case"left":Y=-W;break}}return{anchor_x:b+Y,anchor_y:k+O}},f=(b,k,x)=>{A.smd?E.push(di(b,k,x,A.pw,A.pl)):b===1&&!A.nosquareplating?E.push(sb(b,k,x,i,n,n,0,0)):E.push(jo(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?E.push(rEA({fs:n/5,pn:b,anchor_x:N,anchor_y:R,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"bottom"})):E.push(rEA({fs:n/5,pn:b,anchor_x:N,anchor_y:R,textalign:Q,orthogonal:g,verticallyinverted:a,layer:"top"})),B&&E.push(rEA({fs:n/5,pn:b,anchor_x:N,anchor_y:R,textalign:Q,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,T=`${R},${U}`;if(m.has(T))throw new Error(`Overlap at ${T}`);m.add(T),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 T=x;T<=N&&k<=s;T++){const Y=b+R*t,O=T*u,W=`${Y},${O}`;if(m.has(W))throw new Error(`Overlap at ${W}`);m.add(W),f(k++,Y,O)}R++;for(let T=R;T<=U&&k<=s;T++){const Y=b+T*t,O=N*u,W=`${Y},${O}`;if(m.has(W))throw new Error(`Overlap at ${W}`);m.add(W),f(k++,Y,O)}if(N--,R<=U){for(let T=N;T>=x&&k<=s;T--){const Y=b+U*t,O=T*u,W=`${Y},${O}`;if(m.has(W))throw new Error(`Overlap at ${W}`);m.add(W),f(k++,Y,O)}U--}if(x<=N){for(let T=U;T>=R&&k<=s;T--){const Y=b+T*t,O=x*u,W=`${Y},${O}`;if(m.has(W))throw new Error(`Overlap at ${W}`);m.add(W),f(k++,Y,O)}x++}}if(k-1<s)throw new Error(`Missing pins: assigned ${k-1}, expected ${s}`)}const D=Wi(0,t,.5);return{circuitJson:[...E,D],parameters:A}},Lpe=Zi.extend({fn:H(),num_pins:xA(6).default(6),w:H().default("2.1mm"),h:H().default("2.45mm"),p:H().default("0.5mm"),pl:H().default("0.675mm"),pw:H().default("0.35mm"),string:H().optional()}),Upe=e=>{const A=Lpe.parse({...e,fn:"sot563"}),t=QA.parse(A.w),i=QA.parse(A.h),n=QA.parse(A.p),o=QA.parse(A.pl),s=QA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=VzA(B+1,t,n,o);r.push(di(B+1,C,Q,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:""},c=VzA(1,t,n,o),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-o/2-.3,y:c.y},{x:c.x-o/2-.45,y:c.y+.15},{x:c.x-o/2-.45,y:c.y-.15},{x:c.x-o/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Wi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},VzA=(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}},Hpe=aD({p:"1.27mm",w:"3.9mm",legsoutside:!0}),Ype=e=>{const A=Hpe.parse({...e,num_pins:8});return{circuitJson:p_(A),parameters:A}},Jpe=aD({p:"1.27mm",w:"7.5mm",legsoutside:!0}),Tpe=e=>{const A=Jpe.parse({...e,num_pins:16});return{circuitJson:p_(A),parameters:A}},Kpe=Zi.extend({fn:H(),num_pins:xA(3).default(3),w:H().default("1.2mm"),h:H().default("1.2mm"),pw:H().default("0.40mm"),pl:H().default("0.45mm"),p:H().default("0.575mm")}),Ppe=e=>{const A=Kpe.parse(e),t=Ope(A),i=Wi(0,QA.parse(A.h),.2);return{circuitJson:[...t,i],parameters:A}},qpe=e=>{const{pn:A,p:t}=e;return A===1?{x:t,y:0}:A===2?{x:-t,y:-.4}:{x:-t,y:.4}},Ope=e=>{const A=[];for(let t=0;t<3;t++){const{x:i,y:n}=qpe({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},Wpe=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("2.36mm"),h:H().default("1.22mm"),pl:H().default("0.9mm"),pw:H().default("1.2mm"),p:H().default("3.30mm")}),Zpe=e=>{const A=Wpe.parse(e),t=Wi(0,QA.parse(A.h)/4+.4,.3);return{circuitJson:jpe(A).concat(t),parameters:A}},Vpe=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}=Vpe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},zpe=Zi.extend({fn:H(),p:QA.optional().default("2.54mm"),id:QA.optional().default("0.7mm"),od:QA.optional().default("1.4mm")}),Xpe=e=>{const A=zpe.parse(e),{p:t,id:i,od:n}=A,o=[jo(1,-t/2,0,i,n),jo(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=Wi(0,1.5,.5);return{circuitJson:[...o,s,r],parameters:A}},$pe=(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 c=0;c<=a;c++){const I=c*g,l=e+Math.cos(I)*t,B=A+Math.sin(I)*t;l<e-i&&B>=A-n/2&&B<=A+n/2||s.push({x:l,y:B})}for(let c=0;c<=a;c++){const I=Math.PI+c*g,l=e+Math.cos(I)*t,B=A+Math.sin(I)*t;l<e-i&&B>=A-n/2&&B<=A+n/2||r.push({x:l,y:B})}return{topArc:s,bottomArc:r}},Afe=Zi.extend({fn:H(),p:QA.optional().default("5mm"),id:QA.optional().default("0.8mm"),od:QA.optional().default("1.6mm"),ceramic:gt().optional(),electrolytic:gt().optional(),polarized:gt().optional()}),tfe=e=>{const A=Afe.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=[jo(1,-t/2,0,A.id,A.od),jo(2,t/2,0,A.id,A.od)],s=t+.1,{topArc:r,bottomArc:a}=$pe(0,0,s,A.od/2,A.od),g=.02*t,c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:r,stroke_width:g,pcb_silkscreen_path_id:""},I={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),Q=s-B-.08*t,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C-B,y:Q},{x:C+B,y:Q}],stroke_width:g,pcb_silkscreen_path_id:""},h={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:C,y:Q-B},{x:C,y:Q+B}],stroke_width:g,pcb_silkscreen_path_id:""},u=Wi(0,s+.12*t,.1*t),d=[...o,c,I,l,u];return(A.electrolytic===!0||A.polarized===!0)&&d.push(E,h),{circuitJson:d,parameters:A}},sW=(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}),efe=Zi.extend({fn:xA("pushbutton"),w:QA.default(4.5),h:QA.default(6.5),id:QA.default(1),od:QA.default(1.2)}),ife=e=>{const A=efe.parse(e),t=A.w,i=A.h,n=A.id,o=[jo(1,-t/2,i/2,n,n*1.5),jo(2,-t/2,-i/2,n,n*1.5),jo(3,t/2,-i/2,n,n*1.5),jo(4,t/2,i/2,n,n*1.5)],s=[sW([{x:-t/2,y:-i/2},{x:-t/2,y:i/2}]),sW([{x:t/2,y:-i/2},{x:t/2,y:i/2}]),sW([{x:-t/2,y:0},{x:-t/5,y:0},{x:t/5*1/Math.sqrt(2),y:i/8}]),sW([{x:t/2,y:0},{x:t/5,y:0}])],r=Wi(0,i/2+.4,.5);return{circuitJson:[...o,...s,r],parameters:A}},jzA=Zi.extend({fn:H(),w:QA.default("22.58mm"),h:QA.optional(),left:QA.optional().default(20),right:QA.optional().default(20),top:QA.optional().default(2),bottom:QA.optional().default(2),p:QA.default(QA.parse("2.54mm")),pw:QA.default(QA.parse("1.6mm")),pl:QA.default(QA.parse("2.4mm")),innerhole:gt().default(!1),innerholeedgedistance:QA.default(QA.parse("1.61mm")),silkscreenlabels:gt().default(!1),silkscreenlabelmargin:QA.default(QA.parse("0.1mm"))}),nfe=e=>{const A=jzA.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},rW=(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},ofe=e=>{const A=jzA.parse(e),t=A.h??nfe(A),i=[],n=[],o=[];let s=[];const r=1,a=r,g=A.left+A.right+(A.bottom??0)+(A.top??0),I=`pin${g}`.length*.7/2;if(A.right){const Q=-((A.right-1)/2)*A.p;for(let E=0;E<A.right;E++){if(E===0&&!A.left&&!A.bottom&&!A.silkscreenlabels&&(s=rW(A.w/2-A.pl*1.4,Q+E*A.p,"right")),i.push(di(E+1+A.left+(A.bottom??0),A.w/2-A.pl/2,Q+E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+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-(I+A.silkscreenlabelmargin),y:Q+E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(jo(E+1+A.left+(A.bottom??0)+g,A.w/2,Q+E*A.p,r,a)),n.push(jo(E+1+A.left+(A.bottom??0)+g*2,A.w/2-A.innerholeedgedistance,Q+E*A.p,r,a)))}}if(A.left){const Q=(A.left-1)/2*A.p;for(let E=0;E<A.left;E++){if(E===0&&!A.silkscreenlabels&&(s=rW(-A.w/2+A.pl*1.4,Q-E*A.p,"left")),i.push(di(E+1,-A.w/2+A.pl/2,Q-E*A.p,A.pl,A.pw)),A.silkscreenlabels){const h=E+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+(I+A.silkscreenlabelmargin),y:Q-E*A.p},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"})}A.innerhole&&(n.push(jo(E+1+g,-A.w/2,Q-E*A.p,r,a)),n.push(jo(E+1+g*2,-A.w/2+A.innerholeedgedistance,Q-E*A.p,r,a)))}}if(A.top){const Q=(A.top-1)/2*A.p;for(let E=0;E<A.top;E++){if(E===0&&!A.left&&!A.bottom&&!A.right&&!A.silkscreenlabels&&(s=rW(Q-E*A.p,t/2-A.pl*1.4,"top")),i.push(di(E+1+A.left+A.right+(A.bottom??0),Q-E*A.p,t/2-A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+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:Q-E*A.p,y:t/2-A.pl-(I+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:270})}A.innerhole&&(n.push(jo(E+1+A.left+A.right+(A.bottom??0)+g,Q-E*A.p,t/2,r,a)),n.push(jo(E+1+A.left+A.right+(A.bottom??0)+g*2,Q-E*A.p,t/2-A.innerholeedgedistance,r,a)))}}if(A.bottom){const Q=-((A.bottom-1)/2)*A.p;for(let E=0;E<A.bottom;E++){if(E===0&&!A.left&&!A.silkscreenlabels&&(s=rW(Q+E*A.p,-t/2+A.pl*1.4,"bottom")),i.push(di(E+1+A.left,Q+E*A.p,-t/2+A.pl/2,A.pw,A.pl)),A.silkscreenlabels){const h=E+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:Q+E*A.p,y:-t/2+A.pl+(I+A.silkscreenlabelmargin)},text:u,font_size:.7,font:"tscircuit2024",anchor_alignment:"center",ccw_rotation:90})}A.innerhole&&(n.push(jo(E+1+A.left+g,Q+E*A.p,-t/2,r,a)),n.push(jo(E+1+A.left+g*2,Q+E*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=Wi(0,t/1.8,t/25);return{circuitJson:[...i,...n,...o,B,...A.silkscreenlabels?[]:[l],C],parameters:A}},zzA=Zi.extend({fn:H(),w:QA.default("22.58mm"),h:QA.optional(),left:QA.optional().default(20),right:QA.optional().default(20),top:QA.optional().default(2),bottom:QA.optional().default(2),p:QA.default(QA.parse("2.54mm")),pw:QA.default(QA.parse("1.6mm")),pl:QA.default(QA.parse("3.2mm")),innerhole:gt().default(!1),innerholeedgedistance:QA.default(QA.parse("1.61mm"))}),sfe=e=>{const A=zzA.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},rfe=(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]},afe=e=>{const A=zzA.parse(e),t=A.h??sfe(A),i=[],n=[],o=[],s=1,r=1.2,a=A.left+A.right+(A.bottom??0)+(A.top??0);let g=[],c=1;if(A.left){const C=(A.left-1)/2*A.p;for(let Q=0;Q<A.left;Q++)Q===0&&(g=rfe(-A.w/2-A.pl/2,C-Q*A.p,"left")),i.push(di(c,-A.w/2+A.pl/2,C-Q*A.p,A.pl,A.pw)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:-A.w/2+A.pl/2-4.5,y:C-Q*A.p},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&o.push(jo(c+a,-A.w/2+A.innerholeedgedistance,C-Q*A.p,s,r))}if(A.bottom){const C=(A.bottom-1)/2*A.p;for(let Q=A.bottom-1;Q>=0;Q--)i.push(di(c,C-Q*A.p,-t/2+A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C-Q*A.p,y:-t/2+A.pl/2-3.2},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&o.push(jo(c+a,C-Q*A.p,-t/2+A.innerholeedgedistance,s,r))}if(A.right){const C=-((A.right-1)/2)*A.p;for(let Q=0;Q<A.right;Q++)i.push(di(c,A.w/2-A.pl/2,C+Q*A.p,A.pl,A.pw)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:A.w/2-A.pl/2+3.7,y:C+Q*A.p},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&o.push(jo(c+a,A.w/2-A.innerholeedgedistance,C+Q*A.p,s,r))}if(A.top){const C=-((A.top-1)/2)*A.p;for(let Q=A.top-1;Q>=0;Q--)i.push(di(c,C+Q*A.p,t/2-A.pl/2,A.pw,A.pl)),n.push({type:"pcb_silkscreen_text",pcb_silkscreen_text_id:`pin_${c}`,pcb_component_id:"1",layer:"top",anchor_position:{x:C+Q*A.p,y:t/2-A.pl/2+3.2},text:`pin${c}`,font_size:.7,font:"tscircuit2024",anchor_alignment:"center"}),c++,A.innerhole&&o.push(jo(c+a,C+Q*A.p,t/2-A.innerholeedgedistance,s,r))}const I={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=Wi(0,t/1.8,t/25);return{circuitJson:[...o,...i,...n,l,I,B],parameters:A}},gfe=e=>(e.legsoutside=!0,e.pl||(e.pl=1.5),e.pw||(e.pw=.3),jN(e)),XzA=Zi.extend({fn:H(),w:QA.default("10mm"),h:QA.optional(),left:QA.optional().default(20),right:QA.optional().default(20),top:QA.optional().default(0),bottom:QA.optional().default(0),p:QA.default(QA.parse("2.54mm")),id:QA.optional().default(QA.parse("1mm")),od:QA.optional().default(QA.parse("1.5mm"))}),cfe=e=>{const A=XzA.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},aW=(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]},Ife=e=>{const A=XzA.parse(e),t=A.h??cfe(A),i=[],n=A.id,o=A.od;let s=[];if(A.right){const c=-((A.right-1)/2)*A.p;for(let I=0;I<A.right;I++)I===0&&!A.left&&!A.bottom&&(s=aW(A.w/2+o*1.4,c+I*A.p,"right")),i.push(jo(I+1+A.left+(A.bottom??0),A.w/2,c+I*A.p,n,o))}if(A.left){const c=-((A.left-1)/2)*A.p;for(let I=0;I<A.left;I++)I===A.left-1&&(s=aW(-A.w/2-o*1.4,c+I*A.p,"left")),i.push(jo(I+1,-A.w/2,c+I*A.p,n,o))}if(A.top){const c=-((A.top-1)/2)*A.p;for(let I=0;I<A.top;I++)I===A.top-1&&!A.left&&!A.bottom&&!A.right&&(s=aW(c+I*A.p,t/2+o*1.4,"top")),i.push(jo(I+1+A.right+(A.bottom??0)+A.left,c+I*A.p,t/2,n,o))}if(A.bottom){const c=-((A.bottom-1)/2)*A.p;for(let I=0;I<A.bottom;I++)I===0&&!A.left&&(s=aW(c+I*A.p,-t/2-o*1.4,"bottom")),i.push(jo(I+1+A.left,c+I*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=Wi(0,t/1.7,t/25);return{circuitJson:[...i,a,g,r],parameters:A}},$zA=(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}}),lfe=Zi.extend({fn:H(),p:QA.optional().default("4.88mm"),id:QA.optional().default("0.8mm"),od:QA.optional().default("1.5mm"),w:QA.optional().default("5.6mm"),h:QA.optional().default("3.5mm")}),Bfe=e=>{const A=lfe.parse(e),{p:t,id:i,od:n,w:o,h:s}=A,r=s/2,a=[jo(1,-t/2,0,i,n),jo(2,t/2,0,i,n)],g=$zA(-o/2,0,r,"left"),c=$zA(o/2,0,r,"right"),I={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},...c,{x:o/2,y:s/2},{x:-o/2,y:s/2}],stroke_width:.1,pcb_silkscreen_path_id:""},l=Wi(0,t/4,.5);return{circuitJson:[...a,I,l],parameters:A}};Zi.extend({w:QA,h:QA});var Cfe=e=>{const{w:A,h:t}=e,i=Fr(A),n=Fr(t);return{circuitJson:[di(1,0,0,i,n),Wi(0,n/2+.5,.2)],parameters:e}},sH=(e,A,t,i,n,o)=>({pcb_plated_hole_id:"",type:"pcb_plated_hole",shape:"pill",x:A,y:t,outer_width:Fr(n),outer_height:Fr(o),hole_width:Fr(i),hole_height:Fr(i),pcb_port_id:"",layers:["top","bottom"],port_hints:[e.toString()],ccw_rotation:0}),Qfe=Zi.extend({fn:H(),num_pins:Ze([xA(3),xA(2)]).default(3),p:H().default("1.27mm"),id:H().default("0.72mm"),od:H().default("0.95mm"),w:H().default("4.5mm"),h:H().default("4.5mm"),inline:gt().default(!1),string:H().optional()}),Efe=(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}}),hfe=e=>{const A=e.string?.match(/^to92_(\d+)/),t=A?Number.parseInt(A[1],10):3,i=Qfe.parse({...e,num_pins:t}),{p:n,id:o,od:s,w:r,h:a,inline:g}=i,c=Number.parseFloat(a)/2,I=Number.parseFloat(n),l=Number.parseFloat(o),B=Number.parseFloat(s),C=B,Q=B*(1.5/1.05);let E=[];if(i.num_pins===3)g?E=[sb(1,-I,c-I,l,B,Q,0,0),sH(2,0,c-I,l,C,Q),sH(3,I,c-I,l,C,Q)]:E=[sb(1,-I,c-I,l,B,B,0,0),jo(2,0,c,l,B),jo(3,I,c-I,l,B)];else if(i.num_pins===2)E=[sb(1,-I,c-I,l,C,Q,0,0),sH(2,I,c-I,l,C,Q)];else throw new Error("Invalid number of pins for TO-92");const h=Number.parseFloat(r)/2,u=Efe(0,c,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=Wi(0,c+1,.5);return{circuitJson:[...E,d,f],parameters:i}},ufe=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("2.15mm"),h:H().default("1.20mm"),pl:H().default("0.5mm"),pw:H().default("0.6mm"),p:H().default("1.4mm")}),dfe=e=>{const A=ufe.parse(e),t=Wi(0,QA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:ffe(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}},ffe=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},yfe=aD({}),mfe=e=>{const A=yfe.parse(e),t=[];for(let s=0;s<A.num_pins;s++){const{x:r,y:a}=nEA({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=Wi(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}},wfe=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("5.0mm"),h:H().default("2.30mm"),pl:H().default("1.25mm"),pw:H().default("2mm"),p:H().default("3.75mm")}),Dfe=e=>{const A=wfe.parse(e),t=Wi(0,QA.parse(A.h)/2+1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2+.5,y:QA.parse(A.h)/2+.5},{x:-QA.parse(A.w)/2-.5,y:QA.parse(A.h)/2+.5},{x:-QA.parse(A.w)/2-.5,y:-QA.parse(A.h)/2-.5},{x:QA.parse(A.p)/2+.5,y:-QA.parse(A.h)/2-.5}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:bfe(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}},bfe=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},xfe=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("1.2mm"),pw:H().default("1.2mm"),p:H().default("2.9mm")}),_fe=e=>{const A=xfe.parse(e),t=Wi(0,QA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Ffe(A).concat(i,t),parameters:A}},kfe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Ffe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=kfe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Gfe=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("3.30mm"),h:H().default("1.80mm"),pl:H().default("0.60mm"),pw:H().default("0.45mm"),p:H().default("2.1mm")}),Mfe=e=>{const A=Gfe.parse(e),t=Wi(0,QA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Nfe(A).concat(i,t),parameters:A}},Rfe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Nfe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Rfe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},vfe=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("1.4mm"),h:H().default("0.9mm"),pl:H().default("0.36mm"),pw:H().default("0.25mm"),p:H().default("0.85mm")}),Lfe=e=>{const A=vfe.parse(e),t=Wi(0,QA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2+.15,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.15,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.15,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2+.15,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Hfe(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}},Hfe=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},Yfe=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("1.3mm"),h:H().default("0.9mm"),pl:H().default("0.4mm"),pw:H().default("0.7mm"),p:H().default("0.7mm")}),Jfe=e=>{const A=Yfe.parse(e),t=Wi(0,QA.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2+.2,y:QA.parse(A.h)/2+.2},{x:-QA.parse(A.w)/2-.2,y:QA.parse(A.h)/2+.2},{x:-QA.parse(A.w)/2-.2,y:-QA.parse(A.h)/2-.2},{x:QA.parse(A.p)/2+.2,y:-QA.parse(A.h)/2-.2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Kfe(A).concat(i,t),parameters:A}},Tfe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Kfe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Tfe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Pfe=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("3,05mm"),h:H().default("1.65mm"),pl:H().default("0.6mm"),pw:H().default("0.6mm"),pad_spacing:H().default("2.2mm")}),qfe=e=>{const A=Pfe.parse(e),t=Wi(0,QA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.pad_spacing)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:-QA.parse(A.h)/2},{x:QA.parse(A.pad_spacing)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Wfe(A).concat(i,t),parameters:A}},Ofe=e=>{const{pn:A,pad_spacing:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Wfe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Ofe({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},Zfe=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("1.2mm"),pw:H().default("1.2mm"),p:H().default("2.9mm")}),Vfe=e=>{const A=Zfe.parse(e),t=Wi(0,QA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:zfe(A).concat(i,t),parameters:A}},jfe=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},zfe=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=jfe({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Xfe=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("4.4mm"),h:H().default("2.1mm"),pl:H().default("0.91mm"),pw:H().default("1.22mm"),p:H().default("3.146mm")}),$fe=e=>{const A=Xfe.parse(e),t=Wi(0,QA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:t0e(A).concat(i,t),parameters:A}},A0e=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},t0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=A0e({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},e0e=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("1.80mm"),h:H().default("1.00mm"),pl:H().default("0.66mm"),pw:H().default("0.5mm"),p:H().default("0.8mm")}),i0e=e=>{const A=e0e.parse(e),t=Wi(0,QA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.1,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.1,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:o0e(A).concat(i,t),parameters:A}},n0e=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},o0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=n0e({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},s0e=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("6.2mm"),h:H().default("3.4mm"),pl:H().default("1.4mm"),pw:H().default("2.1mm"),p:H().default("4.4mm")}),r0e=e=>{const A=s0e.parse(e),t=Wi(0,QA.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:g0e(A).concat(i,t),parameters:A}},a0e=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},g0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=a0e({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},c0e=Zi.extend({fn:H(),num_pins:Ze([xA(3),xA(5)]).default(3),w:H().default("4.20mm"),h:H().default("4.80mm"),pl:H().default("1.3mm"),pw:H().default("0.9mm"),p:H().default("1.5mm"),string:H().optional()}),I0e=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=Wi(0,0,.3),g=Number.parseFloat(e.w)/2-1,c=Number.parseFloat(e.h)/2,I={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_1",route:[{x:-g,y:c},{x:g,y:c},{x:g,y:c/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:-c},{x:g,y:-c},{x:g,y:-c/2-.5}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,I,l,a]},l0e=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=Wi(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]},B0e=e=>{const A=e.string?.match(/^sot89_(\d+)/),t=A?Number.parseInt(A[1],10):3,i=c0e.parse({...e,num_pins:t});if(i.num_pins===3)return{circuitJson:I0e(i),parameters:i};if(i.num_pins===5)return{circuitJson:l0e(i),parameters:i};throw new Error("Invalid number of pins for SOT89")},C0e=Zi.extend({fn:H(),p:QA.optional().default("5.0mm"),id:QA.optional().default("1.0mm"),od:QA.optional().default("1.9mm"),w:QA.optional().default("13mm"),h:QA.optional().default("7mm"),num_pins:WA().optional(),string:H().optional()}),Q0e=e=>{const A=C0e.parse(e),{fn:t,id:i,od:n,w:o,h:s,string:r}=A,a=Number.parseInt(r?.split("_")[1]??"3"),g=-1,c=o/2,I=s/2,l=2.5,B=o*.4,C=Math.max(l,B/(a-1)),Q=Array.from({length:a},(m,w)=>{const D=a%2===0?(w-a/2+.5)*C:(w-Math.floor(a/2))*C;return jo(w+1,D,g,i,n)}),E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:-I},{x:c,y:-I},{x:c,y:I},{x:-c,y:I},{x:-c,y:-I}],stroke_width:.1,pcb_silkscreen_path_id:""},h=-I+2*s/3,u={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c,y:h},{x:c,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:I}],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:I}],stroke_width:.1,pcb_silkscreen_path_id:""}],f=Wi(0,s/2+.6,.5);return{circuitJson:[...Q,E,u,...d,f],parameters:{...A,p:C}}},E0e=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("5.40mm"),h:H().default("2.30mm"),pl:H().default("1.30mm"),pw:H().default("1.70mm"),p:H().default("3.5mm")}),h0e=e=>{const A=E0e.parse(e),t=Wi(0,QA.parse(A.h)/2+.4,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:d0e(A).concat(i,t),parameters:A}},u0e=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},d0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=u0e({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},p0e=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("1.90mm"),h:H().default("1.33mm"),pl:H().default("0.5mm"),pw:H().default("0.7mm"),p:H().default("0.8mm")}),f0e=e=>{const A=p0e.parse(e),t=Wi(0,QA.parse(A.h)+.1,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2+.1,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2+.1,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:m0e(A).concat(i,t),parameters:A}},y0e=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},m0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=y0e({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},w0e=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("7.0mm"),h:H().default("3.35mm"),pl:H().default("1.50mm"),pw:H().default("2.70mm"),p:H().default("4.8mm")}),D0e=e=>{const A=w0e.parse(e),t=Wi(0,QA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:b0e(A).concat(i,t),parameters:A}},S0e=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},b0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=S0e({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},x0e=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("3.0mm"),h:H().default("1.80mm"),pl:H().default("0.80mm"),pw:H().default("1.20mm"),p:H().default("1.6mm")}),_0e=e=>{const A=x0e.parse(e),t=Wi(0,QA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.1,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.1,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:F0e(A).concat(i,t),parameters:A}},k0e=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},F0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=k0e({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},G0e=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("7.10mm"),h:H().default("3.40mm"),pl:H().default("2.45mm"),pw:H().default("1.80mm"),p:H().default("4.05mm")}),M0e=e=>{const A=G0e.parse(e),t=Wi(0,QA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.5,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.5,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:N0e(A).concat(i,t),parameters:A}},R0e=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},N0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=R0e({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},v0e=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("4.80mm"),h:H().default("2.10mm"),pl:H().default("1.30mm"),pw:H().default("1.40mm"),p:H().default("2.9mm")}),L0e=e=>{const A=v0e.parse(e),t=Wi(0,QA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:H0e(A).concat(i,t),parameters:A}},U0e=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},H0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=U0e({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Y0e=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("7.30mm"),h:H().default("4.40mm"),pl:H().default("2.50mm"),pw:H().default("2.30mm"),p:H().default("4.30mm")}),J0e=e=>{const A=Y0e.parse(e),t=Wi(0,QA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.1,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.1,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:K0e(A).concat(i,t),parameters:A}},T0e=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}=T0e({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},P0e=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("10.70mm"),h:H().default("6.60mm"),pl:H().default("3.30mm"),pw:H().default("2.50mm"),p:H().default("6.80mm")}),q0e=e=>{const A=P0e.parse(e),t=Wi(0,3,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2-.8},{x:-QA.parse(A.w)/2-.8,y:QA.parse(A.h)/2-.8},{x:-QA.parse(A.w)/2-.8,y:-QA.parse(A.h)/2+.8},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2+.8}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:W0e(A).concat(i,t),parameters:A}},O0e=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},W0e=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=O0e({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},Z0e=Zi.extend({fn:H(),num_pins:WA().default(4),w:H().default("8.50mm"),h:H().default("6.90mm"),pl:H().default("2mm"),pw:H().default("1.5mm"),p:H().default("2.30mm"),string:H().optional()}),V0e=e=>{const A=e.string?.match(/^sot223_(\d+)/),t=A?Number.parseInt(A[1],10):4;if(t===8){const n=X0e.parse({...e,num_pins:t});return{circuitJson:p_(n),parameters:n}}const i=Z0e.parse({...e,num_pins:t});if(i.num_pins===4)return{circuitJson:z0e(i),parameters:i};if(i.num_pins===5)return{circuitJson:Aye(i),parameters:i};if(i.num_pins===6)return{circuitJson:eye(i),parameters:i};throw new Error("Invalid number of pins")},j0e=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}},z0e=e=>{const A=[];for(let r=0;r<e.num_pins;r++){const{x:a,y:g}=j0e({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)}),c=r===3?3.8:Number.parseFloat(e.pw);A.push(di(r+1,a,g,Number.parseFloat(e.pl),c))}const t=Wi(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]},X0e=aD({p:"0.90mm",w:"2.8mm",legsoutside:!0}),$0e=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")},Aye=e=>{const A=[];for(let r=1;r<=e.num_pins;r++){const{x:a,y:g}=$0e({h:Number.parseFloat(e.h),p:1.5,pn:r,w:Number.parseFloat(e.w)});let c=Number.parseFloat(e.pw),I=Number.parseFloat(e.pl);r===5?(c=3.4,I=1.8):(c=1,I=2.2),A.push(di(r,a,g,I,c))}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=Wi(0,0,.3);return[...A,n,o,s]},tye=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")},eye=e=>{const A=[];for(let r=1;r<=e.num_pins;r++){const{x:a,y:g}=tye({h:Number.parseFloat(e.h),p:1.3,pn:r,w:8.7});let c=Number.parseFloat(e.pw),I=Number.parseFloat(e.pl);r===6?(c=3.4,I=2.15):(c=.6,I=2.2),A.push(di(r,a,g,I,c))}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=Wi(0,0,.3);return[...A,n,o,s]},iye=Zi.extend({fn:H(),num_pins:WA().default(3),w:H().default("3.40mm"),h:H().default("3.30mm"),pl:H().default("1mm"),pw:H().default("0.7mm"),p:H().default("1.2mm"),string:H().optional()}),nye=e=>{const A=e.string?.match(/^sot23w_(\d+)/),t=A?Number.parseInt(A[1],3):3,i=iye.parse({...e,num_pins:t});if(i.num_pins===3)return{circuitJson:sye(i),parameters:i};throw new Error("Invalid number of pins")},oye=e=>{const{pn:A,p:t}=e;return A===1?{x:-t,y:.95}:A===2?{x:-t,y:-.95}:{x:t,y:0}},sye=e=>{const A=[];for(let r=0;r<e.num_pins;r++){const{x:a,y:g}=oye({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=Wi(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]},rye=Zi.extend({fn:H(),num_pins:Ze([xA(3),xA(2)]).default(3),p:H().default("1.27mm"),id:H().default("0.72mm"),od:H().default("0.95mm"),w:H().default("2.5mm"),h:H().default("4.2mm"),string:H().optional()}),aye=e=>{const{p:A,id:t,od:i,w:n,h:o}=e,s=Number.parseFloat(o)/2,r=Number.parseFloat(A);return[jo(1,-r,s-r,t,i),jo(2,0,s-r,t,i),jo(3,r,s-r,t,i)]},gye=e=>{const{p:A,id:t,od:i,h:n}=e,o=Number.parseFloat(n)/2,s=Number.parseFloat(A);return[jo(1,-s,o-s,t,i),jo(2,s,o-s,t,i)]},cye=e=>{const A=e.string?.match(/^to92s_(\d+)/),t=A?Number.parseInt(A[1],10):3,i=rye.parse({...e,num_pins:t});let n=[];if(i.num_pins===3)n=aye(i);else if(i.num_pins===2)n=gye(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=Wi(0,o+1,.5);return{circuitJson:[...n,r,a],parameters:i}},Iye=Zi.extend({fn:H(),p:QA.optional(),id:QA.optional(),pw:QA.optional(),pl:QA.optional(),w:QA.optional(),h:QA.optional(),sh:Ze([gt(),H(),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:H().optional()}),lye={ph:{p:QA.parse("2.2mm"),id:QA.parse("0.70mm"),pw:QA.parse("1.20mm"),pl:QA.parse("1.20mm"),w:QA.parse("6mm"),h:QA.parse("5mm")},sh:{p:QA.parse("1mm"),pw:QA.parse("0.6mm"),pl:QA.parse("1.55mm"),w:QA.parse("5.8mm"),h:QA.parse("7.8mm")}};function Bye(e){return e.sh?"sh":(e.ph,"ph")}function Cye(e,A,t,i,n,o){const s=[];if(e==="ph"){const r=t/2;s.push(sb(1,-r,2,i,n,o)),s.push(sb(2,r,2,i,n,o))}else{const r=-((A-1)/2)*t;for(let g=0;g<A;g++){const c=r+g*t;console.log("x si",c),s.push(di(g+1,c,-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 Qye(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 Eye=e=>{const A=Iye.parse(e),t=Bye(A),i=lye[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 c=t==="sh"?4:2;if(t==="sh"){const Q=(typeof e.string=="string"?e.string:"").match(/sh(\d+)/);if(Q&&Q[1]){const E=parseInt(Q[1],10);Number.isNaN(E)||(c=E)}else typeof A.sh=="number"&&(c=A.sh)}const I=Cye(t,c,n,o,s,r),l=Qye(t),B=Wi(0,g/2+1,.5);return{circuitJson:[...I,l,B],parameters:{...A,p:n,id:o,pw:s,pl:r,w:a,h:g,num_pins:c,sh:t==="sh",ph:t==="ph"}}},hye=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("3.30mm"),h:H().default("1.70mm"),pl:H().default("0.80mm"),pw:H().default("1mm"),p:H().default("1.90mm")}),uye=e=>{const A=hye.parse(e),t=Wi(0,QA.parse(A.h)/2+.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:pye(A).concat(i,t),parameters:A}},dye=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},pye=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=dye({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},fye=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"}}},yye=Zi.extend({fn:H(),num_pins:Ze([xA(8),xA(10)]).default(8),w:H().optional(),h:H().optional(),p:H().optional(),pl:H().optional(),pw:H().optional(),string:H().optional()}),mye=e=>{const A=yye.parse(e),t=fye(A.num_pins),i=QA.parse(A.w||t.w),n=QA.parse(A.h||t.h),o=QA.parse(A.p||t.p),s=QA.parse(A.pl||t.pl),r=QA.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}=AXA(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 c=i,I=n,l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:I/2},{x:c/2,y:I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-c/2,y:-I/2},{x:c/2,y:-I/2}],stroke_width:.05,pcb_silkscreen_path_id:""},C=AXA(A.num_pins,1,c,o),Q={x:C.x-.8,y:C.y},E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:Q.x-.4,y:Q.y},{x:Q.x-.7,y:Q.y+.3},{x:Q.x-.7,y:Q.y-.3},{x:Q.x-.4,y:Q.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},h=Wi(0,I/2+.5,.3);return{circuitJson:[...a,l,B,h,E],parameters:A}},AXA=(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*QA.parse(e===8?"1.8mm":"2.2mm"),y:r*i}},wye=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"}}},Dye=Zi.extend({fn:H(),num_pins:Ze([xA(8),xA(10),xA(12),xA(16)]).default(8),w:H().optional(),h:H().optional(),p:H().optional(),pl:H().optional(),pw:H().optional(),string:H().optional()}),tXA=(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*QA.parse("2mm"),y:r*i}},Sye=e=>{const A=Dye.parse(e),t=wye(A.num_pins),i=QA.parse(A.w||t.w),n=QA.parse(A.h||t.h),o=QA.parse(A.p||t.p),s=QA.parse(A.pl||t.pl),r=QA.parse(A.pw||t.pw),a=[];for(let h=0;h<A.num_pins;h++){const{x:u,y:d}=tXA(A.num_pins,h+1,i,o);a.push(di(h+1,u,d,s,r))}const g=i,c=n,I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:c/2},{x:g/2,y:c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},l={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:-g/2,y:-c/2},{x:g/2,y:-c/2}],stroke_width:.05,pcb_silkscreen_path_id:""},B=tXA(A.num_pins,1,g,o),C={x:B.x-.8,y:B.y},Q={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"},E=Wi(0,c/2+.5,.3);return{circuitJson:[...a,I,l,E,Q],parameters:A}},bye=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("3.8mm"),h:H().default("1.65mm"),pl:H().default("1.2mm"),pw:H().default("1.2mm"),pad_spacing:H().default("2.6mm")}),xye=e=>{const A=bye.parse(e),t=Wi(0,QA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.pad_spacing)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:-QA.parse(A.h)/2},{x:QA.parse(A.pad_spacing)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:kye(A).concat(i,t),parameters:A}},_ye=e=>{const{pn:A,pad_spacing:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},kye=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=_ye({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},Fye=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("3.20mm"),h:H().default("1.65mm"),pl:H().default("0.8mm"),pw:H().default("0.9mm"),pad_spacing:H().default("2.1mm")}),Gye=e=>{const A=Fye.parse(e),t=Wi(0,QA.parse(A.h),.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.pad_spacing)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.2,y:-QA.parse(A.h)/2},{x:QA.parse(A.pad_spacing)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Rye(A).concat(i,t),parameters:A}},Mye=e=>{const{pn:A,pad_spacing:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Rye=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=Mye({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},Nye=Zi.extend({fn:H(),num_pins:Ze([xA(6),xA(8)]).default(8),w:H().default("3mm"),h:H().default("3mm"),p:H().default("0.5mm"),pl:H().default("0.52mm"),pw:H().default("0.35mm"),epw:H().default("1.40mm"),eph:H().default("1.60mm"),string:H().optional(),ep:gt().default(!1)}),vye=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=Nye.parse({...e,num_pins:t}),n=QA.parse(i.w),o=QA.parse(i.h),s=QA.parse(i.p),r=QA.parse(i.pl),a=QA.parse(i.pw),g=QA.parse(i.epw),c=QA.parse(i.eph),I=[];for(let f=0;f<i.num_pins;f++){const{x:m,y:w}=eXA(i.num_pins,f+1,n,s);I.push(di(f+1,m,w,r,a))}i.ep&&I.push(di(i.num_pins+1,0,0,g,c));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:""},Q={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=eXA(i.num_pins,1,l,s),h={x:E.x-.4,y:E.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=Wi(0,B/2+.5,.3);return{circuitJson:[...I,C,Q,d,u],parameters:i}},eXA=(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*QA.parse("1.4mm"),y:r*i}},Lye=e=>{const{num_pins:A,bridged:t,p:i=2.54,pw:n=1.5,ph:o=1.5}=e,s=QA.parse(i),r=QA.parse(n),a=QA.parse(o),g=Math.min(a/4,.5),c=[];for(let f=0;f<A;f++)c.push(di(f+1,f*s,0,r,a));let I=[];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);I.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,Q=0,E={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"outline",route:[{x:C-l/2,y:Q-B/2},{x:C+l/2,y:Q-B/2},{x:C+l/2,y:Q+B/2},{x:C-l/2,y:Q+B/2},{x:C-l/2,y:Q-B/2}],stroke_width:.15},u=Q+B/2+.6,d=Wi(C,u,.4);return{circuitJson:[...c,...I,E,d],parameters:e}},iXA={fn:xA("sot457"),num_pins:xA(6).default(6),pillh:H().default("0.45mm"),pillw:H().default("1.45mm"),pl:H(),pw:H(),p:H(),wave:gt().optional(),reflow:gt().optional()},Uye=Zi.extend({...iXA,h:H().default("2.5mm"),w:H().default("2.7mm"),pl:H().default("0.8mm"),pw:H().default("0.55mm"),p:H().default("0.95mm")}),Hye=Zi.extend({...iXA,h:H().default("3mm"),w:H().default("4mm"),pillr:H().default("0.225mm"),pl:H().default("1.45mm"),pw:H().default("1.5mm"),p:H().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)})),rb=e=>Number.parseFloat(e.replace("mm","")),nXA=({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},oXA=e=>{const A=[],t=rb(e.p),i=rb(e.pl),n=rb(e.pw),o=rb(e.w),s=rb(e.h);if(e.wave){const C={1:({padWidth:Q,padHeight:E})=>di(1,-t,t,E,Q),2:({padWidth:Q,padHeight:E})=>di(2,-t,-t,E,Q),3:({padWidth:Q,padHeight:E})=>oW(3,-t,0,rb(e.pillw),rb(e.pillh)),4:({padWidth:Q,padHeight:E})=>oW(4,t,0,rb(e.pillw),rb(e.pillh)),5:({padWidth:Q,padHeight:E})=>di(5,t,t,E,Q),6:({padWidth:Q,padHeight:E})=>di(6,t,-t,E,Q)};for(let Q=1;Q<=e.num_pins;Q++){const E=C[Q];E&&A.push(E({padWidth:i,padHeight:n}))}}else for(let C=1;C<=e.num_pins;C++){const{x:Q,y:E}=nXA({pitch:t,width:o,pinNumber:C});A.push(di(C,Q,E,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=Wi(0,s+.5,.3),c=nXA({pitch:t,width:o,pinNumber:1}),I=e.wave?1:.5,l=e.wave?.7:.3;c.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:c.x+I/2,y:c.y},{x:c.x-I/2,y:c.y+l/2},{x:c.x-I/2,y:c.y-l/2},{x:c.x+I/2,y:c.y}],stroke_width:.05};return[g,r,a,B,...A]},Yye=e=>{if(e.wave){const t=Hye.parse({...e,fn:"sot457"});return{circuitJson:oXA(t),parameters:t}}const A=Uye.parse(e);return{circuitJson:oXA(A),parameters:A}},Jye=Zi.extend({fn:H(),num_pins:xA(6).default(6),w:H().default("1.1mm"),h:H().default("1.45mm"),p:H().default("0.35mm"),pl:H().default("0.2mm"),pw:H().default("0.2mm"),string:H().optional()}),Tye=e=>{const A=Jye.parse({...e,fn:"sot963"}),t=QA.parse(A.w),i=QA.parse(A.h),n=QA.parse(A.p),o=QA.parse(A.pl),s=QA.parse(A.pw),r=[];for(let B=0;B<6;B++){const{x:C,y:Q}=sXA(B+1,t,n,o);r.push(di(B+1,C,Q,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:""},c=sXA(1,t,n,o),I={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"pin_marker_1",route:[{x:c.x-o/2-.3,y:c.y},{x:c.x-o/2-.45,y:c.y+.15},{x:c.x-o/2-.45,y:c.y-.15},{x:c.x-o/2-.3,y:c.y}],stroke_width:.05,pcb_silkscreen_path_id:"pin_marker_1"},l=Wi(0,i/2+.4,.25);return{circuitJson:[...r,a,g,l,I],parameters:A}},sXA=(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}},Kye=Zi.extend({fn:H(),num_pins:Ze([xA(3),xA(2)]).default(3),p:H().default("3.8mm"),id:H().default("1.25mm"),od:H().default("2.35mm"),ca:H().default("14mm").describe("Caliper axis (width or diameter of the potentiometer body or adjustment knob)"),w:H().default("5.35mm"),h:H().default("4mm"),string:H().optional()}),Pye=e=>{const{p:A,id:t,od:i,h:n,ca:o}=e,s=Number.parseFloat(n),r=Number.parseFloat(o);return[jo(1,0,r/4+.3,t,i),jo(2,s,0,t,i),jo(3,0,-r/4-.3,t,i)]},qye=e=>{const A=e.string?.match(/^potentiometer_(\d+)/),t=A?Number.parseInt(A[1],10):3,i=Kye.parse({...e,num_pins:t});let n=[];i.num_pins===3&&(n=Pye(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:""},c=Number.parseFloat(i.w)/2,I=Wi(c,o+1,.5);return{circuitJson:[...n,a,g,I],parameters:i}},Oye=Zi.extend({fn:H(),p:QA.optional().default("7.5mm"),id:QA.optional().default("1mm"),od:QA.optional().default("2mm"),d:QA.optional().default("10.5mm")}),Wye=(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,c=A+Math.sin(a)*t;g<e-i&&c>=A-n/2&&c<=A+n/2||o.push({x:g,y:c})}for(let r=0;r<=50;r++){const a=Math.PI+r/50*Math.PI,g=e+Math.cos(a)*t,c=A+Math.sin(a)*t;g<e-i&&c>=A-n/2&&c<=A+n/2||s.push({x:g,y:c})}return{topArc:o,bottomArc:s}},Zye=e=>{const A=Oye.parse(e),{p:t,id:i,od:n,d:o}=A,s=[jo(1,-t/2,0,i,n),jo(2,t/2,0,i,n)],{topArc:r,bottomArc:a}=Wye(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:""},c={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:a,stroke_width:.1,pcb_silkscreen_path_id:""},I={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,Q={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:""},E={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=Wi(0,o/2+1,.5);return{circuitJson:[...s,g,c,I,Q,E,h],parameters:A}},Vye=Zi.extend({fn:H(),num_pins:xA(2).default(2),w:H().default("6.5mm"),h:H().default("3mm"),pl:H().default("1.75mm"),pw:H().default("2.40mm"),p:H().default("4.75mm")}),jye=e=>{const A=Vye.parse(e),t=Wi(0,QA.parse(A.h)-.5,.3),i={type:"pcb_silkscreen_path",layer:"top",pcb_component_id:"",route:[{x:QA.parse(A.p)/2,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.3,y:QA.parse(A.h)/2},{x:-QA.parse(A.w)/2-.3,y:-QA.parse(A.h)/2},{x:QA.parse(A.p)/2,y:-QA.parse(A.h)/2}],stroke_width:.1,pcb_silkscreen_path_id:""};return{circuitJson:Xye(A).concat(i,t),parameters:A}},zye=e=>{const{pn:A,p:t}=e;return A===1?{x:-t/2,y:0}:{x:t/2,y:0}},Xye=e=>{const A=[];for(let t=1;t<=e.num_pins;t++){const{x:i,y:n}=zye({pn:t,p:Number.parseFloat(e.p)});A.push(di(t,i,n,Number.parseFloat(e.pl),Number.parseFloat(e.pw)))}return A},$ye=Zi.extend({fn:H(),num_pins:WA().default(3),w:H().default("2.45mm"),h:H().default("2.40mm"),pl:H().default("1.225mm"),pw:H().default("0.5mm"),p:H().default("0.95mm"),string:H().optional()}),Ame=e=>{const A=e.string?.match(/^sot323_(\d+)/),t=A?Number.parseInt(A[1],3):3,i=$ye.parse({...e,num_pins:t});if(i.num_pins===3)return{circuitJson:eme(i),parameters:i};throw new Error("Invalid number of pins")},tme=e=>{const{pn:A,p:t}=e;return A===1?{x:-t,y:.65}:A===2?{x:-t,y:-.65}:{x:t,y:0}},eme=e=>{const A=[];for(let r=0;r<e.num_pins;r++){const{x:a,y:g}=tme({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=Wi(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]},ime=Zi.extend({fn:H(),circle:gt().optional(),rect:gt().optional(),square:gt().optional(),pill:gt().optional(),d:QA.optional(),pd:QA.optional(),diameter:QA.optional(),r:QA.optional(),pr:QA.optional(),radius:QA.optional(),w:QA.optional(),pw:QA.optional(),width:QA.optional(),h:QA.optional(),ph:QA.optional(),height:QA.optional(),s:QA.optional(),size:QA.optional(),string:H().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=Fr(e.r):e.pr!==void 0?t=Fr(e.pr):e.radius!==void 0?t=Fr(e.radius):e.d!==void 0?t=Fr(e.d)/2:e.pd!==void 0?t=Fr(e.pd)/2:e.diameter!==void 0?t=Fr(e.diameter)/2:t=Fr("1mm")/2:(e.w!==void 0?i=Fr(e.w):e.pw!==void 0?i=Fr(e.pw):e.width!==void 0?i=Fr(e.width):e.s!==void 0?i=Fr(e.s):e.size!==void 0?i=Fr(e.size):i=Fr("1mm"),e.h!==void 0?n=Fr(e.h):e.ph!==void 0?n=Fr(e.ph):e.height!==void 0?n=Fr(e.height):A==="square"||A==="rect"?n=i:n=Fr("1mm")),{fn:e.fn,shape:A,radius:t,width:i,height:n}}),nme=e=>{const A=ime.parse(e),{shape:t,radius:i,width:n,height:o}=A;let s,r;return t==="circle"?(s=YzA(1,{x:0,y:0,radius:i}),r=i+.5):t==="pill"?(s=oW(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,Wi(0,r,.2)],parameters:A}},ome=Zi.extend({fn:H(),d:QA.optional(),hd:QA.optional(),r:QA.optional(),hr:QA.optional(),pd:QA.optional(),pr:QA.optional(),squarepad:gt().optional().default(!1)}).transform(e=>{let A;e.d!==void 0?A=Fr(e.d):e.hd!==void 0?A=Fr(e.hd):e.r!==void 0?A=Fr(e.r)*2:e.hr!==void 0?A=Fr(e.hr)*2:A=Fr("1mm");let t;return e.pd!==void 0?t=Fr(e.pd):e.pr!==void 0?t=Fr(e.pr)*2:t=A*(1.5/1),{fn:e.fn,d:A,pd:t,squarepad:e.squarepad??!1}}),sme=e=>{const A=ome.parse(e),{d:t,pd:i,squarepad:n}=A;return{circuitJson:[n?sb(1,0,0,t,i,i):jo(1,0,0,t,i),Wi(0,i/2+.5,.2)],parameters:A}},rme=Zi.extend({fn:H(),num_pins:xA(6).default(6),h:H().default("1.6mm"),pl:H().default("1mm"),pw:H().default("0.7mm"),p:H().default("0.95mm")}),ame=e=>{const A=rme.parse(e);return{circuitJson:gme(A),parameters:A}},rXA=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")},gme=e=>{const A=[];for(let I=1;I<=e.num_pins;I++){const{x:l,y:B}=rXA({h:Number.parseFloat(e.h),p:Number.parseFloat(e.p),pn:I});A.push(di(I,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=Wi(0,i+.3,.3),r=rXA({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,c={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,c]},cme=Zi.extend({fn:H(),num_pins:WA().default(4),w:H().default("3.2mm"),h:H().default("2.6mm"),pl:H().default("1.35mm"),pw:H().default("0.50mm"),p:H().default("0.6mm"),string:H().optional()}),Ime=e=>{const A=e.string?.match(/^sot343_(\d+)/),t=A?Number.parseInt(A[1],4):4,i=cme.parse({...e,num_pins:t});if(i.num_pins===4)return{circuitJson:Bme(i),parameters:i};throw new Error("Invalid number of pins")},lme=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}},Bme=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,c=-1/0;for(let d=0;d<e.num_pins;d++){const{x:f,y:m}=lme({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>c&&(c=m)}const I=(r+a)/2,l=c-g,B=i*.3,C=l/2+B;let Q=t*.8;i<=2.6&&(Q/=2);const E=Wi(I,C+.5,.3),h={layer:"top",pcb_component_id:"",pcb_silkscreen_path_id:"silkscreen_path_top",route:[{x:I-Q/2,y:C},{x:I+Q/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:I-Q/2,y:-C},{x:I+Q/2,y:-C}],type:"pcb_silkscreen_path",stroke_width:.1};return[...A,h,u,E]},Cme=Zi.extend({fn:H()}),Qme=e=>{const A=Cme.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,T=di(b,U,k,N,i);T.layer=x?"bottom":"top",t.push(T)}const g=46*.0254,c=137*.0254,I=261*.0254,l={type:"pcb_cutout",pcb_cutout_id:"",shape:"rect",center:{x:-c/2+n/2,y:a-I},width:c,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 Q=1/0,E=-1/0,h=1/0,u=-1/0;const d=(D,b,k=0,x=0)=>{Q=Math.min(Q,D-k/2),E=Math.max(E,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=(Q+E)/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}},Eme=Zi.extend({fn:H(),num_pins:WA().default(3),inline:gt().default(!1),p:H().default("1.27mm"),id:H().default("0.75mm"),od:H().default("1.3mm"),w:H().default("4.8mm"),h:H().default("4.0mm")}),hme=e=>{const A=Eme.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=[sb(1,0,0,A.id,o,s,0,0),A.inline?sH(2,t,0,A.id,o,s):jo(2,t,t,A.id,o),A.inline?sH(3,t*2,0,A.id,o,s):jo(3,t*2,0,A.id,o)],a=i/2,g=A.inline?t-.09:t,c=.2,I=c+a-n,l=Array.from({length:32},(Q,E)=>{const h=Math.PI*E/31;return{x:g+a*Math.cos(h),y:c+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:I},{x:g+a,y:I},l[0]]},C=Wi(g,c+a+1,.5);return{circuitJson:[...r,B,C],parameters:A}};function ume(e){return e!=null}var dme=(e,A)=>{if(!A)return e;const t=e.filter(c=>c.type==="pcb_smtpad"||c.type==="pcb_plated_hole"||c.type==="pcb_thtpad");if(t.length===0)return e;let i=1/0,n=-1/0,o=1/0,s=-1/0;const r=(c,I,l=0,B=0)=>{const C=c-l/2,Q=c+l/2,E=I-B/2,h=I+B/2;i=Math.min(i,C),n=Math.max(n,Q),o=Math.min(o,E),s=Math.max(s,h)};for(const c of t)if(c.type==="pcb_smtpad"){const I=c.shape==="circle"?c.radius*2:c.width,l=c.shape==="circle"?c.radius*2:c.height;r(c.x,c.y,I,l)}else if(c.type==="pcb_plated_hole"){const I=c.outer_diameter??c.hole_diameter;r(c.x,c.y,I,I)}else if(c.type==="pcb_thtpad"){const I=c.diameter;r(c.x,c.y,I,I)}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 c=t.find(I=>I.port_hints?.[0]==="1")||t[0];a=c.x,g=c.y;break}if(a===0&&g===0)return e;for(const c of e){if(typeof c.x=="number"&&(c.x-=a),typeof c.y=="number"&&(c.y-=g),c.center&&typeof c.center.x=="number"&&(c.center.x-=a,c.center.y-=g),c.type==="pcb_silkscreen_path")for(const I of c.route)I.x-=a,I.y-=g;c.type==="pcb_silkscreen_text"&&c.anchor_position&&(c.anchor_position.x-=a,c.anchor_position.y-=g)}return e},pme=(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},fme=(e,A)=>A.nosilkscreen?e.filter(t=>t.type!=="pcb_silkscreen_path"&&t.type!=="pcb_silkscreen_text"):e,yme=e=>{let A=gW();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(ume);for(const{fn:n,v:o}of i)A=A[n](o);return A.setString(e),A},mme=()=>Object.keys(ob),gW=()=>{const e=new Proxy({},{get:(A,t)=>{if(t==="soup"||t==="circuitJson"){if("fn"in A&&ob[A.fn])return()=>{const{circuitJson:i}=ob[A.fn](A),n=fme(i,A),o=pme(n,A);return dme(o,A.origin)};if(!ob[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(!ob[A.fn])throw new Error(`Invalid footprint function, got "${A.fn}"${A.string?`, from string "${A.string}"`:""}`);return()=>ob[A.fn](A).parameters}return t==="getFootprintNames"?()=>Object.keys(ob):t==="params"?()=>A:t==="setString"?i=>(A.string=i,e):i=>(Object.keys(A).length===0?`${t}${i}`in ob?(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};gW.string=yme,gW.getFootprintNames=mme;var wme=gW,aXA=Symbol("Fragment");function aEA(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"),gXA=Symbol("Cube"),kl=Symbol("Cylinder"),cW=Symbol("Sphere"),rH=Symbol("RoundedCuboid"),Pi=Symbol("Translate"),ZB=Symbol("Rotate"),kQ=Symbol("Union"),Zm=Symbol("Subtract"),Cc=Symbol("Hull"),To=Symbol("Colorize"),aH=Symbol("Polygon"),gH=Symbol("ExtrudeLinear"),sf=Symbol("RoundedCylinder"),Mn=aXA,zA=(e,A,t)=>aEA(e,A),Te=(e,A,t)=>aEA(e,A),sB=({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:c,notchPosition:I,notchRotation:l=[0,0,0],notchLength:B=.5,notchWidth:C=.25,chamferSize:Q=0})=>{const E=i*a,h=i-E,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=c??m,D={x:0,y:t/2-w*.25,z:i},b=I??D,k=Te(kQ,{children:[Te(Cc,{children:[zA(Pi,{z:.005,children:zA(Qe,{size:[d,f,.01]})}),zA(Pi,{z:E,children:zA(Qe,{size:[A,t,.01]})})]}),Te(Cc,{children:[zA(Pi,{z:E,children:zA(Qe,{size:[A,t,.01]})}),zA(Pi,{z:E+h,children:zA(Qe,{size:[d,f,.01]})})]})]}),x=(R,U)=>zA(Pi,{offset:{x:R,y:U,z:0},children:zA(ZB,{rotation:[0,0,Math.PI/4],children:zA(Qe,{size:[Q*Math.SQRT2,Q*Math.SQRT2,i*3]})})});let N=k;if(Q>0){const R=A/2,U=t/2;N=Te(Zm,{children:[k,x(R,U),x(-R,U),x(R,-U),x(-R,-U)]})}return zA(To,{color:o,children:zA(Pi,{offset:e,children:zA(Pi,{offset:{x:0,y:0,z:n},children:g?Te(Zm,{children:[N,zA(Pi,{offset:b,children:zA(ZB,{rotation:l,children:zA(kl,{radius:w,height:C})})})]}):N})})})},Dme=e=>Array.from({length:e},(A,t)=>t);function gEA(e,A){if(e.length<2)throw new Error("Stroke must have at least two points");const t=Array.isArray(e[0])?e.map(([c,I])=>({x:c,y:I})):e,i=A/2,n=[],o=[];function s(c,I){const l=I.x-c.x,B=I.y-c.y,C=Math.sqrt(l*l+B*B);return{x:-B/C,y:l/C}}function r(c,I,l){const B={x:c.x+I.x*i*l,y:c.y+I.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 c=1;c<t.length-1;c++){const I=t[c-1],l=t[c],B=t[c+1],C=s(I,l),Q=s(l,B),E=C.x+Q.x,h=C.y+Q.y,u=Math.sqrt(E*E+h*h);if(u/2>2*i)r(l,C,1),r(l,Q,1),r(l,C,-1),r(l,Q,-1);else{const f=1/u;r(l,{x:E*f,y:h*f},1),r(l,{x:E*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 Sme=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}))},bme=Sme([{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}]),cXA=5.47,IW=.5,xme=({x:e,y:A,z:t})=>{const i=e>0;return Te(Mn,{children:[zA(Pi,{offset:{x:e+.25/2,y:A,z:t},children:zA(ZB,{rotation:["-90deg",0,"90deg"],children:zA(gH,{height:.25,children:zA(aH,{points:bme.slice().reverse().map(n=>[n.x,n.y])})})})}),zA(Pi,{offset:{x:e,y:A+(i?1:-1),z:t},children:zA(ZB,{rotation:["-90deg","90deg",i?"180deg":"0deg"],children:zA(gH,{height:2,children:zA(aH,{points:gEA([[0,0],[-1,0],[-1,-1]],.25).map(n=>[n.x,n.y])})})})})]})},_me=({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 Te(Mn,{children:[Dme(e).map(r=>{const a=r%n,g=(Math.floor(r/n)-.5)*2;return zA(xme,{x:g*o/2,y:a*A-(n-1)/2*A,z:cXA/2+IW})}),zA(sB,{width:s,length:n*A+.5,height:cXA-IW,heightAboveSurface:IW,center:{x:0,y:0,z:IW}})]})};function kme(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((c,I)=>I/(r-1)*n).map(c=>[c,kme(c,e)]),g=gEA(a,A);return zA(To,{color:"#fff",children:zA(Pi,{offset:{z:0,y:0,x:0,...e.position},children:zA(ZB,{rotation:["90deg",0,s??0],children:zA(Pi,{offset:{x:0,y:0,z:-t/2},children:zA(gH,{height:t,children:zA(aH,{points:g.map(c=>[c.x,c.y])})})})})})})},Fme=({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 Te(Mn,{children:[Array.from({length:o}).map((g,c)=>zA(Vn,{position:{x:-n/2-A,y:c*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),Array.from({length:o}).map((g,c)=>zA(Vn,{rotation:Math.PI,position:{x:n/2+A,y:c*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+1,height:.8})),zA(sB,{center:{x:0,y:0,z:a/2},width:n-t-1,length:s,height:1.5})]})},Gme=({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 Te(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(sB,{center:{x:0,y:0,z:r/2},width:n,length:n,height:1.1,notchRadius:.35,heightAboveSurface:.1,taperRatio:.09})]})},cEA=1,IEA=.5,zN=.5,cH=.2,Mme=cEA-cH*2,IXA=({color:e="#333"})=>Te(Mn,{children:[zA(Qe,{size:[Mme,IEA,zN],offset:[0,0,zN/2],color:e}),zA(Qe,{size:[cH,zN,IEA],offset:[cEA/2-cH/2,0,zN/2],color:"#ccc"}),zA(Qe,{size:[cH,zN,IEA],offset:[-cEA/2+cH/2,0,zN/2],color:"#ccc"})]}),lEA=1.6,Rme=lEA-.3*2,lW=.3,BEA=.85,XN=.6,lXA=({color:e="#333"})=>Te(Mn,{children:[zA(Qe,{size:[Rme,BEA,XN],offset:[0,0,XN/2],color:e}),zA(Qe,{size:[lW,BEA,XN],offset:[lEA/2-lW/2,0,XN/2],color:"#ccc"}),zA(Qe,{size:[lW,BEA,XN],offset:[-lEA/2+lW/2,0,XN/2],color:"#ccc"})]}),CEA=2,QEA=1.25,$N=.55,IH=.5,Nme=CEA-IH*2,BXA=({color:e="#333"})=>Te(Mn,{children:[zA(Qe,{size:[Nme,QEA,$N],offset:[0,0,$N/2],color:e}),zA(Qe,{size:[IH,QEA,$N],offset:[CEA/2-IH/2,0,$N/2],color:"#ccc"}),zA(Qe,{size:[IH,QEA,$N],offset:[-CEA/2+IH/2,0,$N/2],color:"#ccc"})]}),vme=({pinCount:e,pitch:A,leadWidth:t,padContactLength:i,bodyWidth:n})=>{const o=e/4;A||(A=Lme(e,n)),i||(i=Ume(e)),t||(t=Hme(e,n)),n||(n=A*(o+4));const s=n,r=(o-1)*A/2,a=s+2*i,g=a,c=.8,I=.15,l=(g-n)/2+.5;return Te(Mn,{children:[Array.from({length:o}).map((B,C)=>zA(Vn,{position:{x:-g/2-.4,y:C*A-r,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(Vn,{rotation:Math.PI,position:{x:g/2+.4,y:C*A-r,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(Vn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.4,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(Vn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.4,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),zA(sB,{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})]})},Lme=(e,A)=>{switch(e){case 44:case 64:return .8;case 52:return A===14?1:.65;case 208:return .5;default:return .5}},Ume=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}},Hme=(e,A)=>{switch(e){case 44:case 64:return .5;case 52:return A===14?.45:.55;case 208:return .3;default:return .25}},CXA=({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:c,rightangle:I})=>Te(Mn,{children:[zA(Pi,{y:I?-3:0,children:zA(Qe,{color:"#222",size:[s,r,o],center:[e,A,a(o/2)]})}),!g&&zA(To,{color:"gold",children:c?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}):Te(Cc,{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(To,{color:"gold",children:zA(Pi,{y:I?-3.9:0,z:I?1:0,children:zA(ZB,{rotation:I?[-Math.PI/2,0,0]:[0,0,0],children:Te(Cc,{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)]})]})})})})]}),Yme=({numberOfPins:e,pitch:A=2.54,longSidePinLength:t=6,invert:i,faceup:n,rows:o=1,smd:s,rightangle:r})=>{const c=Math.ceil(e/o),I=2.54,l=3,B=-((c-1)/2)*A,C=!s&&!r?-2-1.6:0,Q=E=>(i||n?-E+2:E)+C;return zA(Mn,{children:Array.from({length:e},(E,h)=>{const u=Math.floor(h/c),d=h%c,f=B+d*A,m=-u*I;return zA(CXA,{x:f,y:m,pinThickness:.63,shortSidePinLength:l,longSidePinLength:t,bodyHeight:2,flipZ:Q,faceup:n,smd:s,rightangle:r},h)})})},Jme=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)],c=(i-1)%a,I=s*(a-1),l=s*(a-1),B=-r/2;switch(g){case"left":return{x:-n/2-B,y:l/2-c*s,o:"vert"};case"bottom":return{x:-I/2+c*s,y:-o/2-B,o:"horz"};case"right":return{x:n/2+B,y:-l/2+c*s,o:"vert"};case"top":return{x:I/2-c*s,y:o/2+B,o:"horz"};default:throw new Error("Invalid pin number")}},Tme=({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},Kme=({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=Tme({num_pins:e,cw:!0,ccw:!0}),c=[];for(let I=0;I<e;I++){const{x:l,y:B,o:C}=Jme({pin_count:e,pn:I+1,w:A,h:t,p:r,pl:s});let Q=o,E=s;C==="vert"&&([Q,E]=[E,Q]);const h=g[I+1];c.push({pn:h,x:l,y:B,pw:Q,pl:E})}return Te(Mn,{children:[zA(To,{color:"grey",children:zA(Qe,{center:{x:0,y:0,z:i/2},size:[A,t,i]})}),c.map((I,l)=>zA(Qe,{center:{x:I.x,y:I.y,z:a/2},size:[I.pw,I.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]})]})},Pme=Kme,qme=()=>{const a=1.1999999999999997;return Te(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(sB,{center:{x:0,y:0,z:0},width:1.6,length:2.9,height:1.2})]})},Ome=qme,Wme=({fullWidth:e=2.9,fullLength:A=2.8})=>{const c=(e-1.92)/2+.3;return Te(Mn,{children:[zA(Vn,{rotation:Math.PI,position:{x:e/2,y:0,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),zA(Vn,{position:{x:-e/2,y:-.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),zA(Vn,{position:{x:-e/2,y:.95,z:.075},width:.4,thickness:.15,padContactLength:.25,bodyDistance:c,height:.45}),zA(sB,{center:{x:0,y:0,z:0},width:1.92,length:2.9,height:1.1,straightHeightRatio:.45,heightAboveSurface:.05})]})},EEA=.6,hEA=.3,Av=.33,lH=.1,Zme=EEA-lH*2,QXA=({color:e="#333"})=>Te(Mn,{children:[zA(Qe,{size:[Zme,hEA,Av],offset:[0,0,Av/2],color:e}),zA(Qe,{size:[lH,hEA,Av],offset:[EEA/2-lH/2,0,Av/2],color:"#ccc"}),zA(Qe,{size:[lH,hEA,Av],offset:[-EEA/2+lH/2,0,Av/2],color:"#ccc"})]}),uEA=.4,dEA=.2,tv=.13,BH=.07,Vme=uEA-BH*2,EXA=({color:e="#333"})=>Te(Mn,{children:[zA(Qe,{size:[Vme,dEA,tv],offset:[0,0,tv/2],color:e}),zA(Qe,{size:[BH,dEA,tv],offset:[uEA/2-BH/2,0,tv/2],color:"#ccc"}),zA(Qe,{size:[BH,dEA,tv],offset:[-uEA/2+BH/2,0,tv/2],color:"#ccc"})]}),pEA=3.2,fEA=1.6,ev=.9,CH=.5,jme=pEA-CH*2,hXA=({color:e="#333"})=>Te(Mn,{children:[zA(Qe,{size:[jme,fEA,ev],offset:[0,0,ev/2],color:e}),zA(Qe,{size:[CH,fEA,ev],offset:[pEA/2-CH/2,0,ev/2],color:"#ccc"}),zA(Qe,{size:[CH,fEA,ev],offset:[-pEA/2+CH/2,0,ev/2],color:"#ccc"})]}),yEA=3.2,mEA=2.5,iv=1,QH=.6,zme=yEA-QH*2,uXA=({color:e="#333"})=>Te(Mn,{children:[zA(Qe,{size:[zme,mEA,iv],offset:[0,0,iv/2],color:e}),zA(Qe,{size:[QH,mEA,iv],offset:[yEA/2-QH/2,0,iv/2],color:"#ccc"}),zA(Qe,{size:[QH,mEA,iv],offset:[-yEA/2+QH/2,0,iv/2],color:"#ccc"})]}),wEA=5,DEA=2.5,nv=1.4,EH=.6,Xme=wEA-EH*2,dXA=({color:e="#333"})=>Te(Mn,{children:[zA(Qe,{size:[Xme,DEA,nv],offset:[0,0,nv/2],color:e}),zA(Qe,{size:[EH,DEA,nv],offset:[wEA/2-EH/2,0,nv/2],color:"#ccc"}),zA(Qe,{size:[EH,DEA,nv],offset:[-wEA/2+EH/2,0,nv/2],color:"#ccc"})]}),SEA=6.3,bEA=3.2,ov=1.8,hH=.8,$me=SEA-hH*2,pXA=({color:e="#333"})=>Te(Mn,{children:[zA(Qe,{size:[$me,bEA,ov],offset:[0,0,ov/2],color:e}),zA(Qe,{size:[hH,bEA,ov],offset:[SEA/2-hH/2,0,ov/2],color:"#ccc"}),zA(Qe,{size:[hH,bEA,ov],offset:[-SEA/2+hH/2,0,ov/2],color:"#ccc"})]}),Awe=({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,c=g*1.6;return Te(Mn,{children:[zA(To,{color:"#1a1a1a",children:Te(Zm,{children:[zA(Qe,{color:"#000",size:[s,r,o],center:[e,A,a(o/2)]}),n?zA(kl,{height:o+.1,radius:n/2,center:[e,A,a(o/2)],color:"#222"}):zA(Qe,{size:[c,c,o],center:[e,A,a(o/2)]})]})}),Te(To,{color:"silver",children:[Te(Cc,{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:[c,c,c*.5],center:[e,A,a(c/2*.5)]})]})]})},twe=({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,c=I=>o?-I+5:I;return zA(Mn,{children:Array.from({length:e},(I,l)=>{const B=Math.floor(l/r),C=l%r,Q=g+C*A,E=-B*a;return zA(Awe,{x:Q,y:E,pitch:A,legsLength:t,innerDiameter:i,flipZ:c},l)})})},ewe=({width:e,length:A,innerDiameter:t=1})=>{const i=e,n=A,o=e*.7,s=t/2.5;return Te(Mn,{children:[zA(rH,{color:"#1a1a1f",center:[0,0,o/2],size:[n,n,o],roundRadius:.3}),zA(rH,{color:"#f2f2f2",center:[0,0,o+o*.1/2.5],size:[n,n,o*.1],roundRadius:.14}),zA(kl,{color:"#1a1a1f",height:o*.8,radius:i/3,center:[0,0,o+o*.8/2]}),zA(kl,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[n/3,n/3,o+o*.1/2]}),zA(kl,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-n/3,-n/3,o+o*.1/2]}),zA(kl,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[-n/3,n/3,o+o*.1/2]}),zA(kl,{color:"#1a1a1f",height:o*.2,radius:t/2,center:[n/3,-n/3,o+o*.1/2]}),zA(BW,{thickness:t/3,width:s,horizontalLength:n*.8,verticalLength:o/2,position:{x:-i/2,y:-n/2,z:-o*1.2}}),zA(BW,{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(BW,{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(BW,{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}})]})},BW=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=gEA(r,A);return zA(To,{color:"#f2f2f2",children:zA(Pi,{offset:{x:s?.x||0,y:s?.y||0,z:s?.z||0},children:zA(ZB,{rotation:[0,55,o],children:zA(gH,{height:t,children:zA(aH,{points:a.map(g=>[g.y,g.x])})})})})})},iwe=({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,c=A*0,I=i*(o-1)+t+.2,l=n*.55;return Te(Mn,{children:[Array.from({length:o}).map((B,C)=>zA(Vn,{position:{x:-n/2-c,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+c,y:C*i-s,z:r/2},width:t,thickness:r,padContactLength:A/2,bodyDistance:A+.3,height:g})),zA(sB,{center:{x:0,y:0,z:r/2},width:l,length:I,height:a})]})},nwe=({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,c=isNaN(parseFloat(o))?2+Number(r)*1.4:parseFloat(o),I=e/2,l=(I-1)*r/2,B=.15,C=.8,Q=4.5,E=(Q-g)/2,h=E*.5;return Te(Mn,{children:[Array.from({length:I}).map((u,d)=>zA(Vn,{position:{x:-Q/2,y:l-d*r,z:B/2},width:a,thickness:B,padContactLength:h+.05,bodyDistance:E+.1,height:C})),Array.from({length:I}).map((u,d)=>zA(Vn,{rotation:Math.PI,position:{x:Q/2,y:l-d*r,z:B/2},width:a,thickness:B,padContactLength:h+.05,bodyDistance:E+.1,height:C})),zA(sB,{center:{x:0,y:0,z:B/2},width:g,length:c,height:1})]})},owe=()=>Te(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(To,{color:"#222",children:Te(kQ,{children:[zA(Pi,{z:.3/2,children:zA(Qe,{size:[1.65,.8,.3]})}),Te(Cc,{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]})})]})]})})]}),swe=()=>Te(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(To,{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]})]}),rwe=()=>{const g=zA(To,{color:"#1a1a1a",children:Te(kQ,{children:[Te(Cc,{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]})})]}),Te(Cc,{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]})})]})]})}),c=({xDir:I})=>{const C=I*1.78,Q=I*(3.4/2-.2/2+1),E=I*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return zA(To,{color:"#c0c0c0",children:Te(kQ,{children:[zA(Qe,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),zA(Qe,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),zA(Qe,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Te(Mn,{children:[zA(c,{xDir:1}),zA(c,{xDir:-1}),g]})},awe=()=>{const g=zA(To,{color:"#1a1a1a",children:Te(kQ,{children:[Te(Cc,{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]})})]}),Te(Cc,{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]})})]})]})}),c=({xDir:I})=>{const C=I*1.78,Q=I*(3.4/2-.2/2+1),E=I*(3.4/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return zA(To,{color:"#c0c0c0",children:Te(kQ,{children:[zA(Qe,{size:[2.3*.8,1.45,.2],center:[C,0,.2/2]}),zA(Qe,{size:[.2,1.45,1.14],center:[Q,0,1.14/2+.2]}),zA(Qe,{size:[h,1.45,.2],center:[u,0,.2/2+1.14]})]})})};return Te(Mn,{children:[zA(c,{xDir:1}),zA(c,{xDir:-1}),g]})},gwe=()=>{const g=zA(To,{color:"#1a1a1a",children:Te(kQ,{children:[Te(Cc,{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]})})]}),Te(Cc,{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]})})]})]})}),c=({xDir:I})=>{const C=I*3.08,Q=I*(6/2-.2/2+1),E=I*(6/2-.2/2),h=Math.abs(E-Q),u=(Q+E)/2;return zA(To,{color:"#c0c0c0",children:Te(kQ,{children:[zA(Qe,{size:[2.3*.8,2.95,.2],center:[C,0,.2/2]}),zA(Qe,{size:[.2,2.95,1.14],center:[Q,0,1.14/2+.2]}),zA(Qe,{size:[h,2.95,.2],center:[u,0,.2/2+1.14]})]})})};return Te(Mn,{children:[zA(c,{xDir:1}),zA(c,{xDir:-1}),g]})},cwe=()=>{const I=zA(To,{color:"#222",children:Te(kQ,{children:[zA(Pi,{z:.27,children:zA(Qe,{size:[2.9,1.9,.54]})}),Te(Cc,{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 Te(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]}),I]})},Iwe=()=>Te(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(To,{color:"#222",children:Te(kQ,{children:[zA(Pi,{z:.55/2,children:zA(Qe,{size:[2.7,1.6,.55]})}),Te(Cc,{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]})})]})]})})]}),lwe=()=>Te(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(To,{color:"#222",children:Te(kQ,{children:[zA(Pi,{z:.2/2,children:zA(Qe,{size:[2.75,1.8,.2]})}),Te(Cc,{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]})]}),Bwe=()=>Te(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(To,{color:"#222",children:Te(kQ,{children:[Te(Cc,{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]})})]}),Te(Cc,{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]})]}),Cwe=()=>Te(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(To,{color:"#222",children:Te(kQ,{children:[Te(Cc,{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]})})]}),Te(Cc,{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]})]}),Qwe=()=>Te(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(To,{color:"#222",children:Te(kQ,{children:[zA(Pi,{z:.14/2,children:zA(Qe,{size:[.8,.6,.14]})}),Te(Cc,{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]})})]})]})})]}),Ewe=()=>{const c=3.0999999999999996;return Te(Mn,{children:[zA(Vn,{rotation:Math.PI,position:{x:6.6/2+c/4,y:0,z:.25/2},width:3,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(Vn,{position:{x:-6.6/2-c/4,y:0,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(Vn,{position:{x:-6.6/2-c/4,y:-2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(Vn,{position:{x:-6.6/2-c/4,y:2.3,z:.25/2},width:.7,thickness:.25,padContactLength:.5,bodyDistance:c,height:.75}),zA(sB,{center:{x:0,y:0,z:0},width:3.5,length:6.5,height:1.7,includeNotch:!1,taperRatio:.06,straightHeightRatio:.45})]})},hwe=()=>Te(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(sB,{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})]}),uwe=hwe,dwe=()=>{const g=.7999999999999998;return Te(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(sB,{center:{x:0,y:0,z:0},width:1.25,length:2,height:.9,includeNotch:!1,taperRatio:.06,straightHeightRatio:.7,heightAboveSurface:.05})]})},pwe=({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,c=.8,I=.2,l=(g-n)/2+.4;return Te(Mn,{children:[Array.from({length:o}).map((B,C)=>zA(Vn,{position:{x:-g/2-.36,y:C*A-r,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(Vn,{rotation:Math.PI,position:{x:g/2+.36,y:C*A-r,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(Vn,{rotation:Math.PI/2,position:{x:C*A-r,y:-a/2-.36,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),Array.from({length:o}).map((B,C)=>zA(Vn,{rotation:-Math.PI/2,position:{x:C*A-r,y:a/2+.36,z:I/2},width:t,thickness:I,padContactLength:i,bodyDistance:l,height:c})),zA(sB,{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})]})},fwe=()=>{const i=.20900000000000002,n=.1,o=.3,s=.1,r=.2;return Te(Mn,{children:[zA(To,{color:"#222",children:Te(kQ,{children:[zA(Qe,{size:[.85,1.2,i],center:[0,0,i/2]}),Te(Cc,{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]})]})},ywe=({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=[],c=Math.floor(e/2),I=r*(c-1);for(let l=0;l<e;l++){const B=l<c?"left":"right",C=l%c,Q=I/2-C*r,E=s,h=o,u=B==="left"?-A/2+E/2:A/2-E/2,d=l+1;g.push({pinNumber:d,x:u,y:Q,padSizeX:E,padSizeY:h})}return Te(Mn,{children:[zA(sB,{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]})]})},mwe=({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,c=a-g,I=i/2,l=.85;return Te(Mn,{children:[Te(To,{color:s,children:[Te(Cc,{children:[zA(sf,{height:t,roundRadius:.5,radius:g,center:[-c,0,t]}),zA(sf,{height:t,roundRadius:.5,radius:g,center:[c,0,t]})]}),Te(Cc,{children:[zA(sf,{height:l,roundRadius:.1,radius:g+.85,center:[-c,0,t/2+l/2]}),zA(sf,{height:l,roundRadius:.1,radius:g+.85,center:[c,0,t/2+l/2]})]})]}),Te(To,{color:r,children:[zA(kl,{height:o+t/2,radius:n/2,center:[-I+.06,0,-(o/2)+t/2]}),zA(kl,{height:o+t/2,radius:n/2,center:[I-.06,0,-(o/2)+t/2]})]})]})},wwe=({bodyLength:e=1.4,bodyDiameter:A=1.1,color:t="#3a3a3aff",contactColor:i="#c6c6c6",cathodeIdentification:n="#111"})=>Te(Mn,{children:[zA(To,{color:t,children:Te(ZB,{rotation:[0,"90deg",0],children:[zA(rH,{size:[A,A,e-.2],roundRadius:.2,center:[-A/2,0,.05]}),zA(kl,{height:.2/2,radius:A/2-.2,center:[-A/2,0,-e/2+.2/2]})]})}),zA(To,{color:n,children:zA(ZB,{rotation:[0,"90deg",0],children:zA(rH,{size:[A*1.01,A*1.01,e/3],roundRadius:.2,center:[-A/2,0,-e/4+.1]})})}),zA(To,{color:i,children:zA(ZB,{rotation:[0,"90deg",0],children:zA(sf,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,-e/2]})})}),zA(To,{color:i,children:zA(ZB,{rotation:[0,"90deg",0],children:zA(sf,{height:.2,radius:A/2,roundRadius:.2/3,center:[-A/2,0,e/2]})})})]}),Dwe=({bodyLength:e=3.5,bodyDiameter:A=1.5,color:t="#3a3a3aff",contactColor:i="#c6c6c6"})=>Te(Mn,{children:[zA(To,{color:t,children:zA(ZB,{rotation:[0,"90deg",0],children:zA(sf,{height:e,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),zA(To,{color:i,children:zA(ZB,{rotation:[0,"90deg",0],children:zA(sf,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,-e/2]})})}),zA(To,{color:i,children:zA(ZB,{rotation:[0,"90deg",0],children:zA(sf,{height:.5,radius:A/2,roundRadius:.2,center:[-A/2,0,e/2]})})})]}),Swe=({bodyLength:e=3.9,bodyDiameter:A=2.5,color:t="#3a3a3aff",contactColor:i="#c6c6c6"})=>Te(Mn,{children:[zA(To,{color:t,children:zA(ZB,{rotation:[0,"90deg",0],children:zA(sf,{height:e,radius:A/2,roundRadius:.3,center:[-A/2,0,0]})})}),zA(To,{color:i,children:zA(ZB,{rotation:[0,"90deg",0],children:zA(sf,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,-e/2]})})}),zA(To,{color:i,children:zA(ZB,{rotation:[0,"90deg",0],children:zA(sf,{height:.55,radius:A/2,roundRadius:.2,center:[-A/2,0,e/2]})})})]}),bwe=({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 Te(Mn,{children:[Array.from({length:n}).map((g,c)=>zA(Vn,{position:{x:-s/2-A-.3,y:c*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,c)=>zA(Vn,{rotation:Math.PI,position:{x:s/2+A+.3,y:c*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),zA(sB,{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})]})},xwe=({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 Te(Mn,{children:[Array.from({length:n}).map((g,c)=>zA(Vn,{position:{x:-o/2-A-.3,y:c*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),Array.from({length:n}).map((g,c)=>zA(Vn,{rotation:Math.PI,position:{x:o/2+A+.3,y:c*i-r,z:a/2},width:t,thickness:a,padContactLength:A,bodyDistance:A+.4,height:.85})),zA(sB,{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})]})},_we=()=>{const Q=7.050000000000001,E=24.95+6.5/2;return zA(Pi,{center:[0,0,1],children:Te(Mn,{children:[Te(ZB,{rotation:[0,55,-55],children:[Te(Zm,{children:[zA(Qe,{color:"#ccc",size:[6.5+.1,9.9,1.3],center:[E,0,1.3-2]}),zA(kl,{color:"black",center:[E,0,1.3-2],radius:3/2,height:1.3*1.2})]}),zA(To,{color:"#222",children:zA(sB,{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(ZB,{rotation:[0,55,55],children:Array.from({length:3}).map((h,u)=>{const d=Q,f=(u-1)*2.7,m=-.5-.6;return Te(To,{color:"gold",children:[Te(Cc,{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}`)})})]})})},kwe=()=>{const g=1.1999999999999997;return Te(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(sB,{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})]})},Fwe=()=>Te(Mn,{children:[zA(sB,{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 c=-.35+g*.35;return zA(Qe,{center:[-.8/2+.19/2-.1,c,.12/2],size:[.19,.15,.12]})}),[0,1,2].map(g=>{const c=-.35+g*.35;return zA(Qe,{center:[.8/2-.19/2+.1,c,.12/2],size:[.19,.15,.12]})})]}),Gwe=()=>{const s="#222",a=[.43,.4,1.32],g=[.43,.4,.25],c=[0,0,-.66],I=[0,0,-1.32],l=[0,1.28,-2.72],B=[0,1.28,-8.9],C=-7.5;return Te(Pi,{center:[0,1,10.5],children:[zA(To,{color:s,children:Te(Zm,{children:[zA(Pi,{center:[0,0,2.25],children:zA(kl,{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:c,children:zA(Qe,{size:a})}),Te(Cc,{children:[zA(Pi,{center:I,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]})})]})},Mwe=()=>Te(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(sB,{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})]}),Rwe=Mwe,Nwe=()=>Te(Mn,{children:[zA(sB,{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]})})]}),vwe=()=>Te(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(To,{color:"#222",children:zA(sB,{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]})]}),Lwe=()=>Te(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(To,{color:"#222",children:Te(kQ,{children:[zA(Pi,{z:.175/2,children:zA(Qe,{size:[1.7,1.25,.175]})}),Te(Cc,{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]})]}),Uwe=()=>{const s=-1.0474999999999999,r=1.775/2+.4/2-.04;return Te(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(To,{color:"#222",children:zA(sB,{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]})]})},Hwe=({pitch:e=10})=>Te(Mn,{children:[zA(kl,{height:4,radius:.5,center:[-e/2,0,.5]}),zA(cW,{radius:.5,center:[-e/2,0,2.5]}),zA(Pi,{x:-2.5,y:0,z:2.5,children:Te(ZB,{rotation:[0,Math.PI/2,0],children:[zA(kl,{height:e,radius:.5,center:[0,0,2.5]}),zA(To,{color:"#d2b48c",children:zA(kl,{height:5,radius:1.3,center:[0,0,2.5]})})]})}),zA(kl,{height:4,radius:.5,center:[e/2,0,.5]}),zA(cW,{radius:.5,center:[e/2,0,2.5]})]}),Ywe=({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:c=1.61,innerHoleDiameter:I=1})=>{const l=e/2,B=A/2,C=A*1.05,Q=I/2,E=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+c,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-c,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:-E/2+i/2,pl:t,pw:i}),g&&u.push({x:-b,y:-E/2},{x:-b,y:-E/2+c})}}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:E/2-i/2,pl:t,pw:i}),g&&u.push({x:-b,y:E/2},{x:-b,y:E/2-c})}}const d=zA(To,{color:"#008080",children:Te(Zm,{children:[zA(Qe,{center:[0,0,B],size:[e,E,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(kl,{color:"black",center:[w.x,w.y,B],radius:Q,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 Te(Mn,{children:[d,zA(To,{color:"#FFD700",children:g?Te(Zm,{children:[zA(kQ,{children:h.map((w,D)=>zA(Qe,{center:[w.x,w.y,B],size:[w.pl+.01,w.pw+.01,C]},D))}),f]}):m})]})},Jwe=({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:c=1,pinRowHoleEdgeToEdgeDist:I=2,nopin:l})=>{const B=o/2,C=Math.ceil(e/A);let Q,E;a==="left"||a==="right"?(Q=(A-1)*t+2*I,E=(C-1)*t+2*I):(E=(A-1)*t+2*I,Q=(C-1)*t+2*I),e===0&&(Q=10,E=10);const h=Number(s??Q),u=Number(r??E),d=[];let f=0,m=0,w=0,D=0,b=0,k=0;a==="left"||a==="right"?(f=a==="left"?-h/2+I:h/2-I,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-I:-u/2+I,w=t,D=0,b=0,k=a==="top"?-t:t);let x=0;for(let aA=0;aA<A&&x<e;aA++)for(let tA=0;tA<C&&x<e;tA++){const oA=f+tA*w+aA*b,rA=m+tA*D+aA*k;d.push({x:oA,y:rA}),x++}const N=[];if(g)for(const aA of g){let tA=0,oA=0;aA==="topleft"?(tA=-h/2+c,oA=u/2-c):aA==="topright"?(tA=h/2-c,oA=u/2-c):aA==="bottomleft"?(tA=-h/2+c,oA=-u/2+c):aA==="bottomright"?(tA=h/2-c,oA=-u/2+c):aA==="center"&&(tA=0,oA=0),N.push({x:tA,y:oA})}const R=.63,U=2,T=6,Y=3,O=l?0:U,W=zA(To,{color:"#008080",children:Te(Zm,{children:[zA(Qe,{center:[0,0,B+O],size:[h,u,o]}),N.map((aA,tA)=>zA(kl,{center:[aA.x,aA.y,B+O],radius:n/2,height:o},`hole-${tA}`)),d.map((aA,tA)=>zA(kl,{center:[aA.x,aA.y,B+O],radius:n/2,height:o},`pin-hole-${tA}`))]})}),X=d.map((aA,tA)=>zA(To,{color:"#FFD700",children:Te(Zm,{children:[zA(kl,{center:[aA.x,aA.y,o/2+O],radius:n/2,height:o}),zA(kl,{center:[aA.x,aA.y,o/2+O],radius:i/2,height:o})]})})),iA=d.map((aA,tA)=>zA(CXA,{x:aA.x,y:aA.y,pinThickness:R,shortSidePinLength:Y,longSidePinLength:T,bodyHeight:U,flipZ:oA=>oA}));return Te(Mn,{children:[W,X,!l&&iA]})},Twe=({footprint:e})=>{const A=wme.string(e).json();switch(A.fn){case"dip":return zA(_me,{numPins:A.num_pins,pitch:A.p,bodyWidth:A.w});case"axial":return zA(Hwe,{pitch:A.p});case"tssop":return zA(Fme,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"msop":return zA(Gme,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"vssop":return zA(nwe,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w,bodyLength:A.h});case"qfp":return zA(vme,{pinCount:A.num_pins,pitch:A.p,leadWidth:A.pw,padContactLength:A.pl,bodyWidth:A.w});case"tqfp":return zA(uwe,{});case"lqfp":return zA(pwe,{pinCount:A.num_pins});case"qfn":{const n=typeof A.thermalpad?.x=="number"&&typeof A.thermalpad?.y=="number";return zA(Pme,{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(ywe,{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(Yme,{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(twe,{numberOfPins:A.num_pins,pitch:A.p,rows:o})}case"cap":switch(A.imperial){case"0402":return zA(IXA,{color:"#856c4d"});case"0603":return zA(lXA,{color:"#856c4d"});case"0805":return zA(BXA,{color:"#856c4d"});case"0201":return zA(QXA,{color:"#856c4d"});case"01005":return zA(EXA,{color:"#856c4d"});case"1206":return zA(hXA,{color:"#856c4d"});case"1210":return zA(uXA,{color:"#856c4d"});case"2010":return zA(dXA,{color:"#856c4d"});case"2512":return zA(pXA,{color:"#856c4d"})}case"sot235":return zA(Ome,{});case"sot457":return zA(kwe,{});case"sot223":return zA(Ewe,{});case"sot23w":return zA(Wme,{});case"sot323":return zA(dwe,{});case"sod323f":return zA(Lwe,{});case"sod323fl":return zA(Uwe,{});case"sot363":return zA(Rwe,{});case"sot886":return zA(Nwe,{});case"sot963":return zA(Fwe,{});case"pushbutton":return zA(ewe,{width:A.w,length:A.h,innerDiameter:A.id});case"soic":return zA(iwe,{pinCount:A.num_pins,leadLength:A.pl,leadWidth:A.pw,pitch:A.p,bodyWidth:A.w});case"sod523":return zA(owe,{});case"sod882":return zA(swe,{});case"sma":return zA(rwe,{});case"smb":return zA(awe,{});case"smc":return zA(gwe,{});case"smf":return zA(cwe,{});case"sod123f":return zA(Iwe,{});case"sod123fl":return zA(lwe,{});case"sod123w":return zA(Bwe,{});case"sod128":return zA(Cwe,{});case"sod323":return zA(vwe,{});case"sod923":return zA(Qwe,{});case"hc49":return zA(mwe,{});case"micromelf":return zA(wwe,{});case"minimelf":return zA(Dwe,{});case"melf":return zA(Swe,{});case"ms012":return zA(bwe,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"ms013":return zA(xwe,{pinCount:A.num_pins,padContactLength:A.pl,leadWidth:A.pw,pitch:A.p});case"sot723":return zA(fwe,{});case"to220":return zA(_we,{});case"to92":return zA(Gwe,{});case"stampboard":case"stampreceiver":return zA(Ywe,{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,c=A.pinRowHoleEdgeToEdgeDist,I=Array.isArray(A.holes)?A.holes:[];return zA(Jwe,{numPins:g,rows:n,p:A.p,id:A.id,od:A.od,width:r,height:a,pinRowSide:o,holes:I,holeInset:s,pinRowHoleEdgeToEdgeDist:c,nopin:A.nopin})}}const t=e.match(/_color\(([^)]+)\)/),i=t?t[1]:void 0;switch(A.imperial){case"0402":return zA(IXA,{color:i});case"0603":return zA(lXA,{color:i});case"0805":return zA(BXA,{color:i});case"0201":return zA(QXA,{color:i});case"01005":return zA(EXA,{color:i});case"1206":return zA(hXA,{color:i});case"1210":return zA(uXA,{color:i});case"2010":return zA(dXA,{color:i});case"2512":return zA(pXA,{color:i})}return null},Kwe=e=>e&&typeof e=="object"&&"type"in e,sv=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},Pwe=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 gD(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=>gD(l,A,t));if(!Kwe(e))return[];const{type:g,props:c,children:I}=e;if(g===aXA)return(I??[]).flatMap(l=>gD(l,A,t));if(g===To){const l=c?.color;return(I??[]).flatMap(B=>gD(B,l??A,t))}if(g===Pi){const l=Pwe(c?.offset??c?.center??{x:c?.x,y:c?.y,z:c?.z});return(I??[]).flatMap(C=>gD(C,A,t)).map(({geom:C,color:Q})=>({geom:a.translate(l,C),color:Q??A}))}if(g===ZB){const l=Array.isArray(c?.rotation)?[sv(c.rotation[0]),sv(c.rotation[1]),sv(c.rotation[2])]:[sv(c?.x??0),sv(c?.y??0),sv(c?.z??0)];return(I??[]).flatMap(C=>gD(C,A,t)).map(({geom:C,color:Q})=>({geom:a.rotateZ(l[2],a.rotateY(l[1],a.rotateX(l[0],C))),color:Q}))}if(g===kQ||g===Zm||g===Cc){const l=(I??[]).flatMap(C=>gD(C,A,t)).map(C=>C.geom);if(l.length===0)return[];let B;return g===kQ?B=n.union(l):g===Zm?B=n.subtract(l[0],l.slice(1)):B=o.hull(l),[{geom:B,color:A}]}if(g===aH){const l=c?.points??[];return[{geom:s.geom2.fromPoints(l),color:A??c?.color}]}if(g===gH){const l=(I??[]).flatMap(E=>gD(E,A,t)).map(E=>E.geom);if(l.length===0)return[];const B=l.length>1?n.union(l):l[0],C=c?.height??c?.h??1;let Q=r.extrudeLinear({height:C},B);if(Q.polygons)for(const E of Q.polygons)!E.plane||!E.vertices||E.vertices.length<3||E.vertices.reverse();return[{geom:Q,color:A??c?.color}]}if(g===Qe||g===gXA||g===kl||g===cW||g===rH||g===sf){let l;if(g===Qe){const B=c?.size??[1,1,1],C=c?.offset,Q=c?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);l=i.cuboid({size:B,center:Q})}else if(g===gXA){const B=c?.size??1,C=c?.offset,Q=c?.center??(C?[C[0],C[1],C[2]]:[0,0,0]);l=i.cube({size:B,center:Q})}else if(g===kl){const B=c?.height??1,C=c?.radius??1,Q=c?.center??[0,0,0];l=i.cylinder({height:B,radius:C,center:Q})}else if(g===cW){const B=c?.radius??1,C=c?.center??[0,0,0];l=i.sphere({radius:B,center:C})}else if(g===sf){const B=c?.height??1,C=c?.radius??1,Q=c?.roundRadius??.1,E=c?.center??[0,0,0];l=i.roundedCylinder({height:B,radius:C,roundRadius:Q,center:E})}else{const B=c?.size??[1,1,1],C=c?.roundRadius??.1,Q=c?.center??[0,0,0];l=i.roundedCuboid({size:B,roundRadius:C,center:Q})}return[{geom:l,color:A??c?.color}]}if(typeof g=="function"){const l=g(c??{});return gD(l,A,t)}return(I??[]).flatMap(l=>gD(l,A,t))}function qwe(e,A){return{geometries:gD(e,void 0,{jscad:A})}}function fXA(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,c=s.vertices[a].index;t.push(r,g,c)}}const o=new fg;if(o.setAttribute("position",new lc(new Float32Array(A),3)),o.setIndex(t),i.length>0&&o.setAttribute("color",new lc(new Float32Array(i),3)),e.transforms){const s=new ss;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 fg;if(i.setAttribute("position",new lc(new Float32Array(A),3)),t.length>0&&i.setAttribute("color",new lc(new Float32Array(t),3)),e.transforms){const n=new ss;n.fromArray(e.transforms),i.applyMatrix4(n)}return i}return console.error("Invalid CSG object: neither polygons nor sides found"),new fg}function Owe(e,A){const t=aEA(Twe,{footprint:e});return qwe(t,A)}var Wwe=Kr(eW()),yXA=AA.createContext(null),Zwe=()=>{const e=AA.useContext(yXA);if(!e)throw new Error("useHover must be used within a HoverProvider");return e},Vwe=({children:e})=>{const{camera:A,renderer:t}=Lu(),[i,n]=AA.useState([]),o=AA.useMemo(()=>new FMt,[]),s=AA.useMemo(()=>new En,[]),r=AA.useRef(i);r.current=i;const a=AA.useRef(null),g=AA.useCallback(C=>{n(Q=>[...Q,C])},[]),c=AA.useCallback(C=>{if(a.current){let Q=!1,E=a.current.object;for(;E;){if(E===C){Q=!0;break}E=E.parent}Q&&(a.current.onUnhover(),a.current=null)}n(Q=>Q.filter(E=>E.object!==C))},[]),I=AA.useCallback(C=>{let Q=C;for(;Q;){const E=r.current.find(h=>h.object===Q);if(E)return E;Q=Q.parent}},[]),l=AA.useCallback(C=>{if(!t.domElement)return;const Q=t.domElement.getBoundingClientRect();s.x=(C.clientX-Q.left)/Q.width*2-1,s.y=-((C.clientY-Q.top)/Q.height)*2+1,o.setFromCamera(s,A);const E=r.current.map(u=>u.object);if(E.length===0){a.current&&(a.current.onUnhover(),a.current=null);return}const h=o.intersectObjects(E,!0);if(h.length>0){const u=h[0],d=I(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,I]);AA.useEffect(()=>{const C=t.domElement;return C.addEventListener("mousemove",l),()=>{C.removeEventListener("mousemove",l)}},[t,l]);const B=AA.useMemo(()=>({addHoverable:g,removeHoverable:c}),[g,c]);return Z.jsx(yXA.Provider,{value:B,children:e})},jwe=({children:e,object:A,onHover:t,onUnhover:i,isHovered:n})=>{const{addHoverable:o,removeHoverable:s}=Zwe();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})},uH=jwe,zwe=({positionOffset:e,footprint:A,rotationOffset:t,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=Lu(),g=AA.useMemo(()=>{if(!A)return null;const{geometries:c}=Owe(A,Wwe),I=new Vp;for(const l of c.flat(1/0)){const B=l.geom;if(!B||!B.polygons&&!B.sides)continue;const C=new Oi(l.color);C.convertLinearToSRGB();const Q={...B,color:[C.r,C.g,C.b]},E=fXA(Q),h=new dh({vertexColors:!0,side:WB,transparent:r,opacity:r?.5:1,depthWrite:!r}),u=new Ao(E,h);I.add(u)}return I},[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(c=>{c instanceof Ao&&c.material instanceof dh&&(o?(c.material.emissive.setHex(255),c.material.emissiveIntensity=.2):c.material.emissiveIntensity=0)})},[o,g]),g?Z.jsx(uH,{isHovered:o,onHover:i,onUnhover:n,object:g}):null},mXA=new WeakMap,Xwe=()=>{const e=new Hc;return e.name="fallback-environment-map",e.mapping=TK,e},$we=e=>{if(!e)return null;const A=e,t=mXA.get(A);if(t)return t;let i;if(e instanceof pP){const n=new e7(e);i=n.fromScene(vNt(),.04).texture,n.dispose()}else i=Xwe();return mXA.set(A,i),i},wXA=1.25;function DXA({gltfUrl:e,position:A,rotation:t,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const{renderer:a,rootObject:g}=Lu(),[c,I]=AA.useState(null),[l,B]=AA.useState(null);if(AA.useEffect(()=>{if(!e)return;const C=new UNt;let Q=!0;return C.load(e,E=>{if(!Q)return;const h=E.scene;h.traverse(u=>{if(u instanceof Ao&&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)}}),I(h)},void 0,E=>{if(!Q)return;console.error(`An error happened loading ${e}`,E);const h=E instanceof Error?E:new Error(`Failed to load glTF model from ${e}`);B(h)}),()=>{Q=!1}},[e,r]),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.useEffect(()=>{if(!(!g||!c))return g.add(c),()=>{g.remove(c)}},[g,c]),AA.useEffect(()=>{if(!c||!a)return;const C=$we(a);if(!C)return;const Q=[],E=h=>{h instanceof dh&&(Q.push({material:h,envMap:h.envMap??null,envMapIntensity:h.envMapIntensity??1}),h.envMap=C,(typeof h.envMapIntensity!="number"||h.envMapIntensity<wXA)&&(h.envMapIntensity=wXA),h.needsUpdate=!0)};return c.traverse(h=>{if(!(h instanceof Ao))return;const u=h.material;Array.isArray(u)?u.forEach(E):u&&E(u)}),()=>{Q.forEach(({material:h,envMap:u,envMapIntensity:d})=>{h.envMap=u,h.envMapIntensity=d,h.needsUpdate=!0})}},[c,a]),AA.useEffect(()=>{c&&c.traverse(C=>{C instanceof Ao&&C.material instanceof dh&&(o?(C.material.emissive.setHex(255),C.material.emissiveIntensity=.2):C.material.emissiveIntensity=0)})},[o,c]),l)throw l;return c?Z.jsx(uH,{isHovered:o,onHover:i,onUnhover:n,object:c}):null}var ADe=Kr(kzA()),tDe=Kr(eW()),eDe=({jscadPlan:e,positionOffset:A,rotationOffset:t,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1})=>{const{rootObject:a}=Lu(),{threeGeom:g,material:c}=AA.useMemo(()=>{const l=(0,ADe.executeJscadOperations)(tDe.default,e);if(!l||!l.polygons&&!l.sides)return{threeGeom:null,material:null};const B=fXA(l),C=new dh({vertexColors:!0,side:WB,transparent:r,opacity:r?.5:1,depthWrite:!r});return{threeGeom:B,material:C}},[e,r]),I=AA.useMemo(()=>g?new Ao(g,c):null,[g,c]);return AA.useEffect(()=>{if(!(!I||!a))return a.add(I),()=>{a.remove(I)}},[a,I]),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.useMemo(()=>{if(c)if(o){const l=new Oi(c.color.getHex());c.emissive.copy(l),c.emissive.setRGB(0,0,1),c.emissiveIntensity=.2}else c.emissiveIntensity=0},[o,c]),g?Z.jsx(uH,{isHovered:o,onHover:i,onUnhover:n,object:I}):null};function iDe(e){return e.replace(/(DEF|USE)\s+([^\s]+)/g,(A,t,i)=>`${t} ${i.replace(/-/g,"_")}`)}async function nDe(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 mvt().parse(iDe(t),e)}typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function oDe(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 nDe(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(),c=g.match(/newmtl[\s\S]*?endmtl/g),I=new Gvt;if(c?.length){const l=c.join(`
|
|
5136
|
-
`).replace(/d 0\./g,"d 1."),B=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new pvt;C.setMaterialOptions({invertTrProperty:!0});const Q=C.parse(l.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return I.setMaterials(Q),I.parse(B)}return I.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(c=>c instanceof Error?c:c.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 sDe({url:e,position:A,rotation:t,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const a=oDe(e),{rootObject:g}=Lu(),c=AA.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(I=>{if(I instanceof Ao&&I.material){const l=B=>{B.transparent=r,B.opacity=r?.5:1,B.depthWrite=!r,B.needsUpdate=!0};Array.isArray(I.material)?I.material.forEach(l):l(I.material)}}),a):new Ao(new _m(.5,.5,.5),new dh({transparent:!0,color:"red",opacity:.25})),[a,r]);if(AA.useEffect(()=>{if(!(!g||!c))return g.add(c),()=>{g.remove(c)}},[g,c]),AA.useEffect(()=>{c&&(A&&(Array.isArray(A)?c.position.fromArray(A):c.position.copy(A)),t&&(Array.isArray(t)?c.rotation.fromArray(t):c.rotation.copy(t)),s!==void 0&&c.scale.setScalar(s))},[c,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(uH,{isHovered:o,onHover:i,onUnhover:n,object:c})}var xEA,rDe="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function aDe(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 gDe(){if(!xEA){const e=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");xEA=aDe(e)({locateFile:t=>`${rDe}/${t}`})}return xEA}function cDe(e){const A=new Vp;for(const t of e){const i=t.attributes.position?.array??[],n=t.index?.array??[];if(!i.length||!n.length)continue;const o=new fg;o.setAttribute("position",new Jo(i,3));const s=t.attributes.normal?.array??[];s.length?o.setAttribute("normal",new Jo(s,3)):o.computeVertexNormals(),o.setIndex(n);const r=new dh({color:t.color?new Oi(t.color[0],t.color[1],t.color[2]):new Oi(.82,.82,.82)}),a=new Ao(o,r);a.name=t.name,A.add(a)}return A}async function IDe(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 gDe()).ReadStepFile(new Uint8Array(t),null);if(!n.success||!n.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=cDe(n.meshes),s=new S$;return await new Promise((a,g)=>{s.parse(o,c=>{c instanceof ArrayBuffer?a(c):g(new Error("GLTFExporter did not return binary output"))},c=>{g(c)},{binary:!0})})}var SXA="step-glb-cache:";function lDe(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 BDe(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 CDe(e){try{const A=localStorage.getItem(`${SXA}${e}`);return A?BDe(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function bXA(e,A){try{const t=lDe(A);localStorage.setItem(`${SXA}${e}`,t)}catch(t){console.warn("Failed to write STEP GLB cache",t)}}function QDe(){const e=globalThis;return e.stepUrlToGltfModelConversions||(e.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),e.stepUrlToGltfModelConversions}var EDe=({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 c=!0,I=null,l=!0;const B=QDe(),C=CDe(e);if(C){const h={arrayBuffer:C,blobUrl:URL.createObjectURL(new Blob([C],{type:"model/gltf-binary"}))};return B.completed.set(e,h),I=h.blobUrl,l=!1,g(h.blobUrl),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)}}const Q=B.completed.get(e);if(Q)return I=Q.blobUrl,l=!1,g(Q.blobUrl),bXA(e,Q.arrayBuffer),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)};let E=B.inProgress.get(e);return E||(E=IDe(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,E)),E.then(h=>{c&&(I=h.blobUrl,l=!1,g(h.blobUrl),bXA(e,h.arrayBuffer))}).catch(h=>{console.error("Failed to convert STEP file to GLB",h),c&&g(null)}),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)}},[e]),a?Z.jsx(DXA,{gltfUrl:a,position:A,rotation:t,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r}):null},hDe=(e,A)=>{if(e)return A?A(e):e},xXA=(...e)=>e,_XA=({cad_component:e,circuitJson:A,resolveStaticAsset:t})=>{const i=MzA(A),[n,o]=AA.useState(!1),{visibility:s}=VF(),[r,a]=AA.useState(null),g=AA.useCallback(w=>{w?.mousePosition?(o(!0),a(w.mousePosition)):(o(!1),a(null))},[]),c=AA.useCallback(()=>{o(!1),a(null)},[]),I=AA.useMemo(()=>Ji(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=>hDe(w,t),[t]),C=B(e.model_obj_url??e.model_wrl_url??e.model_stl_url),Q=B(e.model_glb_url??e.model_gltf_url),E=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?xXA(e.rotation.x*Math.PI/180,e.rotation.y*Math.PI/180,e.rotation.z*Math.PI/180):xXA(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(sDe,{url:C,position:f,rotation:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:e.show_as_translucent_model},e.cad_component_id):Q?m=Z.jsx(DXA,{gltfUrl:Q,position:f,rotation:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:e.show_as_translucent_model},e.cad_component_id):E&&!e.model_jscad&&!e.footprinter_string?m=Z.jsx(EDe,{stepUrl:E,position:f,rotation:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:e.show_as_translucent_model}):e.model_jscad?m=Z.jsx(eDe,{jscadPlan:e.model_jscad,positionOffset:f,rotationOffset:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:e.show_as_translucent_model},e.cad_component_id):e.footprinter_string&&(m=Z.jsx(zwe,{positionOffset:f,rotationOffset:d,footprint:e.footprinter_string,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,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(NzA,{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:I??"<unknown>"}):null]})},kXA={version:"0.0.517"};function uDe(e){e.querySelectorAll("canvas").forEach(A=>A.remove())}var dDe=e=>{e.outputColorSpace=pm,e.toneMapping=U_A,e.toneMappingExposure=1},FXA="cadViewerCameraStateSession",GXA=(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(FXA,JSON.stringify(t))}catch(t){console.warn("Failed to save camera:",t)}},_EA=(e,A)=>{try{const t=sessionStorage.getItem(FXA);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}},MXA=AA.createContext(void 0),pDe=({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,c]=AA.useState(t??null),[I,l]=AA.useState(new Wp(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]),Q=AA.useCallback(h=>{i.current=h},[]),E=AA.useMemo(()=>({controlsRef:i,mainCameraRef:n,defaultTarget:A,baseDistance:B,controller:o,setController:s,getPresetConfig:C,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:c,cameraRotation:I,setCameraRotation:l,saveCameraToSession:GXA,loadCameraFromSession:_EA}),[A,B,o,C,Q,r,g,I]);return Z.jsx(MXA.Provider,{value:E,children:e})},f_=()=>{const e=AA.useContext(MXA);if(!e)throw new Error("useCameraController must be used within a CameraControllerProvider");return e},fDe=AA.forwardRef(({children:e,scene:A,camera:t,style:i,onCreated:n},o)=>{const{cameraType:s}=f_(),r=AA.useRef(null),[a,g]=AA.useState(null),c=AA.useRef([]),I=AA.useRef(void 0);I.current=n;const l=AA.useRef(null),B=AA.useCallback(h=>{c.current.push(h)},[]),C=AA.useCallback(h=>{c.current=c.current.filter(u=>u!==h)},[]),Q=AA.useMemo(()=>new nF,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const E=AA.useRef(new pg);return AA.useImperativeHandle(o,()=>E.current),AA.useEffect(()=>{if(!r.current)return;uDe(r.current);const h=new pP({antialias:!0,alpha:!0});dDe(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 uE(75,u,.1,1e3):new X2(-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)),Q.add(E.current),window.__TSCIRCUIT_THREE_OBJECT=E.current,g({scene:Q,camera:d,renderer:h,rootObject:E.current,addFrameListener:B,removeFrameListener:C}),I.current?.({camera:d,renderer:h});let f;const m=new fMt,w=()=>{const b=m.getElapsedTime(),k=m.getDelta();c.current.forEach(x=>x(b,k)),h.render(Q,d),f=requestAnimationFrame(w)};w();const D=()=>{if(r.current){const b=r.current.clientWidth/r.current.clientHeight;d instanceof uE?d.aspect=b:d instanceof X2&&(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(),Q.remove(E.current),window.__TSCIRCUIT_THREE_OBJECT===E.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,B,C,s]),Z.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&Z.jsx(RzA.Provider,{value:a,children:Z.jsx(Vwe,{children:e})})})}),yDe=({autoRotate:e,autoRotateSpeed:A,onStart:t,panSpeed:i,rotateSpeed:n,zoomSpeed:o,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:c,renderer:I}=Lu(),l=AA.useMemo(()=>!c||!I?null:new Rvt(c,I.domElement),[c,I]);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:hx.ROTATE,MIDDLE:hx.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]),nH(()=>{l?.update()},[l]),null},mDe=`
|
|
5136
|
+
`).replace(/d 0\./g,"d 1."),B=g.replace(/newmtl[\s\S]*?endmtl/g,"").replace(/^mtllib.*/gm,""),C=new pvt;C.setMaterialOptions({invertTrProperty:!0});const Q=C.parse(l.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"embedded.mtl");return I.setMaterials(Q),I.parse(B)}return I.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(c=>c instanceof Error?c:c.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 sDe({url:e,position:A,rotation:t,onHover:i,onUnhover:n,isHovered:o,scale:s,isTranslucent:r=!1}){const a=oDe(e),{rootObject:g}=Lu(),c=AA.useMemo(()=>a&&!(a instanceof Error)?(a.traverse(I=>{if(I instanceof Ao&&I.material){const l=B=>{B.transparent=r,B.opacity=r?.5:1,B.depthWrite=!r,B.needsUpdate=!0};Array.isArray(I.material)?I.material.forEach(l):l(I.material)}}),a):new Ao(new _m(.5,.5,.5),new dh({transparent:!0,color:"red",opacity:.25})),[a,r]);if(AA.useEffect(()=>{if(!(!g||!c))return g.add(c),()=>{g.remove(c)}},[g,c]),AA.useEffect(()=>{c&&(A&&(Array.isArray(A)?c.position.fromArray(A):c.position.copy(A)),t&&(Array.isArray(t)?c.rotation.fromArray(t):c.rotation.copy(t)),s!==void 0&&c.scale.setScalar(s))},[c,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(uH,{isHovered:o,onHover:i,onUnhover:n,object:c})}var xEA,rDe="https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/dist";function aDe(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 gDe(){if(!xEA){const e=await import("https://cdn.jsdelivr.net/npm/occt-import-js@0.0.23/+esm");xEA=aDe(e)({locateFile:t=>`${rDe}/${t}`})}return xEA}function cDe(e){const A=new Vp;for(const t of e){const i=t.attributes.position?.array??[],n=t.index?.array??[];if(!i.length||!n.length)continue;const o=new fg;o.setAttribute("position",new Jo(i,3));const s=t.attributes.normal?.array??[];s.length?o.setAttribute("normal",new Jo(s,3)):o.computeVertexNormals(),o.setIndex(n);const r=new dh({color:t.color?new Oi(t.color[0],t.color[1],t.color[2]):new Oi(.82,.82,.82)}),a=new Ao(o,r);a.name=t.name,A.add(a)}return A}async function IDe(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 gDe()).ReadStepFile(new Uint8Array(t),null);if(!n.success||!n.meshes.length)throw new Error("occt-import-js failed to convert STEP file");const o=cDe(n.meshes),s=new S$;return await new Promise((a,g)=>{s.parse(o,c=>{c instanceof ArrayBuffer?a(c):g(new Error("GLTFExporter did not return binary output"))},c=>{g(c)},{binary:!0})})}var SXA="step-glb-cache:";function lDe(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 BDe(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 CDe(e){try{const A=localStorage.getItem(`${SXA}${e}`);return A?BDe(A):null}catch(A){return console.warn("Failed to read STEP GLB cache",A),null}}function bXA(e,A){try{const t=lDe(A);localStorage.setItem(`${SXA}${e}`,t)}catch(t){console.warn("Failed to write STEP GLB cache",t)}}function QDe(){const e=globalThis;return e.stepUrlToGltfModelConversions||(e.stepUrlToGltfModelConversions={inProgress:new Map,completed:new Map}),e.stepUrlToGltfModelConversions}var EDe=({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 c=!0,I=null,l=!0;const B=QDe(),C=CDe(e);if(C){const h={arrayBuffer:C,blobUrl:URL.createObjectURL(new Blob([C],{type:"model/gltf-binary"}))};return B.completed.set(e,h),I=h.blobUrl,l=!1,g(h.blobUrl),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)}}const Q=B.completed.get(e);if(Q)return I=Q.blobUrl,l=!1,g(Q.blobUrl),bXA(e,Q.arrayBuffer),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)};let E=B.inProgress.get(e);return E||(E=IDe(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,E)),E.then(h=>{c&&(I=h.blobUrl,l=!1,g(h.blobUrl),bXA(e,h.arrayBuffer))}).catch(h=>{console.error("Failed to convert STEP file to GLB",h),c&&g(null)}),()=>{c=!1,I&&l&&URL.revokeObjectURL(I)}},[e]),a?Z.jsx(DXA,{gltfUrl:a,position:A,rotation:t,scale:i,onHover:n,onUnhover:o,isHovered:s,isTranslucent:r}):null},hDe=(e,A)=>{if(e)return A?A(e):e},xXA=(...e)=>e,_XA=({cad_component:e,circuitJson:A,resolveStaticAsset:t})=>{const i=MzA(A),[n,o]=AA.useState(!1),{visibility:s}=VF(),[r,a]=AA.useState(null),g=AA.useCallback(w=>{w?.mousePosition?(o(!0),a(w.mousePosition)):(o(!1),a(null))},[]),c=AA.useCallback(()=>{o(!1),a(null)},[]),I=AA.useMemo(()=>Ji(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=>hDe(w,t),[t]),C=B(e.model_obj_url??e.model_wrl_url??e.model_stl_url),Q=B(e.model_glb_url??e.model_gltf_url),E=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?xXA(e.rotation.x*Math.PI/180,e.rotation.y*Math.PI/180,e.rotation.z*Math.PI/180):xXA(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(sDe,{url:C,position:f,rotation:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:e.show_as_translucent_model},e.cad_component_id):Q?m=Z.jsx(DXA,{gltfUrl:Q,position:f,rotation:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:e.show_as_translucent_model},e.cad_component_id):E&&!e.model_jscad&&!e.footprinter_string?m=Z.jsx(EDe,{stepUrl:E,position:f,rotation:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:e.show_as_translucent_model}):e.model_jscad?m=Z.jsx(eDe,{jscadPlan:e.model_jscad,positionOffset:f,rotationOffset:d,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,isHovered:n,isTranslucent:e.show_as_translucent_model},e.cad_component_id):e.footprinter_string&&(m=Z.jsx(zwe,{positionOffset:f,rotationOffset:d,footprint:e.footprinter_string,scale:e.model_unit_to_mm_scale_factor,onHover:g,onUnhover:c,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(NzA,{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:I??"<unknown>"}):null]})},kXA={version:"0.0.518"};function uDe(e){e.querySelectorAll("canvas").forEach(A=>A.remove())}var dDe=e=>{e.outputColorSpace=pm,e.toneMapping=U_A,e.toneMappingExposure=1},FXA="cadViewerCameraStateSession",GXA=(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(FXA,JSON.stringify(t))}catch(t){console.warn("Failed to save camera:",t)}},_EA=(e,A)=>{try{const t=sessionStorage.getItem(FXA);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}},MXA=AA.createContext(void 0),pDe=({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,c]=AA.useState(t??null),[I,l]=AA.useState(new Wp(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]),Q=AA.useCallback(h=>{i.current=h},[]),E=AA.useMemo(()=>({controlsRef:i,mainCameraRef:n,defaultTarget:A,baseDistance:B,controller:o,setController:s,getPresetConfig:C,handleControlsChange:Q,cameraType:r,setCameraType:a,cameraPosition:g,setCameraPosition:c,cameraRotation:I,setCameraRotation:l,saveCameraToSession:GXA,loadCameraFromSession:_EA}),[A,B,o,C,Q,r,g,I]);return Z.jsx(MXA.Provider,{value:E,children:e})},f_=()=>{const e=AA.useContext(MXA);if(!e)throw new Error("useCameraController must be used within a CameraControllerProvider");return e},fDe=AA.forwardRef(({children:e,scene:A,camera:t,style:i,onCreated:n},o)=>{const{cameraType:s}=f_(),r=AA.useRef(null),[a,g]=AA.useState(null),c=AA.useRef([]),I=AA.useRef(void 0);I.current=n;const l=AA.useRef(null),B=AA.useCallback(h=>{c.current.push(h)},[]),C=AA.useCallback(h=>{c.current=c.current.filter(u=>u!==h)},[]),Q=AA.useMemo(()=>new nF,[]);A?.up&&Q.up.set(A.up.x,A.up.y,A.up.z);const E=AA.useRef(new pg);return AA.useImperativeHandle(o,()=>E.current),AA.useEffect(()=>{if(!r.current)return;uDe(r.current);const h=new pP({antialias:!0,alpha:!0});dDe(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 uE(75,u,.1,1e3):new X2(-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)),Q.add(E.current),window.__TSCIRCUIT_THREE_OBJECT=E.current,g({scene:Q,camera:d,renderer:h,rootObject:E.current,addFrameListener:B,removeFrameListener:C}),I.current?.({camera:d,renderer:h});let f;const m=new fMt,w=()=>{const b=m.getElapsedTime(),k=m.getDelta();c.current.forEach(x=>x(b,k)),h.render(Q,d),f=requestAnimationFrame(w)};w();const D=()=>{if(r.current){const b=r.current.clientWidth/r.current.clientHeight;d instanceof uE?d.aspect=b:d instanceof X2&&(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(),Q.remove(E.current),window.__TSCIRCUIT_THREE_OBJECT===E.current&&(window.__TSCIRCUIT_THREE_OBJECT=void 0)}},[Q,B,C,s]),Z.jsx("div",{ref:r,style:{width:"100%",height:"100%",...i},children:a&&Z.jsx(RzA.Provider,{value:a,children:Z.jsx(Vwe,{children:e})})})}),yDe=({autoRotate:e,autoRotateSpeed:A,onStart:t,panSpeed:i,rotateSpeed:n,zoomSpeed:o,enableDamping:s,dampingFactor:r,target:a,onControlsChange:g})=>{const{camera:c,renderer:I}=Lu(),l=AA.useMemo(()=>!c||!I?null:new Rvt(c,I.domElement),[c,I]);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:hx.ROTATE,MIDDLE:hx.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]),nH(()=>{l?.update()},[l]),null},mDe=`
|
|
5137
5137
|
varying vec3 worldPosition;
|
|
5138
5138
|
void main() {
|
|
5139
5139
|
worldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
@@ -5684,7 +5684,7 @@ test("${g} should solve problem correctly", () => {
|
|
|
5684
5684
|
// Add more specific assertions based on expected output
|
|
5685
5685
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5686
5686
|
})
|
|
5687
|
-
`,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),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"})]})]})},hct=e=>e.activeSubSolver?[e,...hct(e.activeSubSolver)]:[e],kZe=({solver:e})=>{const A=hct(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(_Ze,{solver:t})]},t.constructor.name))})},FZe=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(Q=>!Q,!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))},c=()=>{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))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<E&&!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(kZe,{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:c,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:I,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]})]})},GZe=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},MZe=(e,A)=>{const i=e.pipelineDef[A].solverName,n=GZe(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 c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},RZe=({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})},NZe=({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,"%"]})]})},vZe=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),LZe=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=vZe(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))})]})},jpA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(jpA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=jpA(i));return A},UZe=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=jpA(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)}`)}},HZe=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>MZe(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):UZe(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(RZe,{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(NZe,{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(LZe,{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))})]})})]})},YZe=class extends nn.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 JZe({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 c=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)c(E.x,E.y);for(const E of t){const h=E.points??[];for(const u of h)c(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;c(h,u),c(h+d,u+f)}for(const E of n){const h=E.x??0,u=E.y??0,d=E.radius??1;c(h-d,u-d),c(h+d,u+d)}for(const E of o)c(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>Z.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),t.map((E,h)=>Z.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),n.map((E,h)=>Z.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>Z.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),o.map((E,h)=>Z.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var TZe=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{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 c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(FZe,{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(YZe,{fallback:Z.jsx(JZe,{graphics:s}),children:Z.jsx(xZe,{graphics:s})}),a&&Z.jsx(HZe,{solver:e,onStepUntilPhase:g})]})};const KZe=()=>{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)},[])},PZe=e=>e.toLowerCase().includes("pack")?xGe:e.toLowerCase().includes("rout")?RGe:dGe,qZe=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);KZe();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=srA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(srA).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 c=PZe(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{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(pD,{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(TZe,{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"})})})]})},uct=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{LK.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{LK.captureException(n,{error_type:i.type})}catch{}}},[t])},dct="0.0.1634",OZe={version:dct},zpA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},XpA=new Map,l9=e=>{const A=XpA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},WZe=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=XpA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return XpA.set(t.name,n),{type:"tracked",store:e,...n}},pct=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(zpA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(zpA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:c,...I}=WZe(r,g,a);let l=!0;n.setState=(Q,E,h)=>{const u=t(Q,E);if(!l)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...l9(a.name),[r]:n.getState()}),u)};const B=(...Q)=>{const E=l;l=!1,t(...Q),l=E},C=e(n.setState,i,n);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=n,c?.init(Object.fromEntries(Object.entries(I.stores).map(([Q,E])=>[Q,Q===I.store?C:E.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let Q=!1;const E=n.dispatch;n.dispatch=(...h)=>{(zpA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),E(...h)}}return c.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return $pA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){B(h.state);return}Object.keys(h.state).length!==1&&console.error(`
|
|
5687
|
+
`,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),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"})]})]})},hct=e=>e.activeSubSolver?[e,...hct(e.activeSubSolver)]:[e],kZe=({solver:e})=>{const A=hct(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(_Ze,{solver:t})]},t.constructor.name))})},FZe=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(Q=>!Q,!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))},c=()=>{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))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<E&&!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(kZe,{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:c,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:I,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]})]})},GZe=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},MZe=(e,A)=>{const i=e.pipelineDef[A].solverName,n=GZe(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 c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},RZe=({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})},NZe=({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,"%"]})]})},vZe=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),LZe=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=vZe(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))})]})},jpA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(jpA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=jpA(i));return A},UZe=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=jpA(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)}`)}},HZe=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>MZe(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):UZe(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(RZe,{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(NZe,{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(LZe,{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))})]})})]})},YZe=class extends nn.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 JZe({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 c=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)c(E.x,E.y);for(const E of t){const h=E.points??[];for(const u of h)c(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;c(h,u),c(h+d,u+f)}for(const E of n){const h=E.x??0,u=E.y??0,d=E.radius??1;c(h-d,u-d),c(h+d,u+d)}for(const E of o)c(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>Z.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),t.map((E,h)=>Z.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),n.map((E,h)=>Z.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>Z.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),o.map((E,h)=>Z.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var TZe=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{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 c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(FZe,{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(YZe,{fallback:Z.jsx(JZe,{graphics:s}),children:Z.jsx(xZe,{graphics:s})}),a&&Z.jsx(HZe,{solver:e,onStepUntilPhase:g})]})};const KZe=()=>{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)},[])},PZe=e=>e.toLowerCase().includes("pack")?xGe:e.toLowerCase().includes("rout")?RGe:dGe,qZe=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);KZe();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=srA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(srA).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 c=PZe(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{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(pD,{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(TZe,{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"})})})]})},uct=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{LK.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{LK.captureException(n,{error_type:i.type})}catch{}}},[t])},dct="0.0.1635",OZe={version:dct},zpA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},XpA=new Map,l9=e=>{const A=XpA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},WZe=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=XpA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return XpA.set(t.name,n),{type:"tracked",store:e,...n}},pct=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(zpA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(zpA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:c,...I}=WZe(r,g,a);let l=!0;n.setState=(Q,E,h)=>{const u=t(Q,E);if(!l)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...l9(a.name),[r]:n.getState()}),u)};const B=(...Q)=>{const E=l;l=!1,t(...Q),l=E},C=e(n.setState,i,n);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=n,c?.init(Object.fromEntries(Object.entries(I.stores).map(([Q,E])=>[Q,Q===I.store?C:E.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let Q=!1;const E=n.dispatch;n.dispatch=(...h)=>{(zpA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),E(...h)}}return c.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return $pA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){B(h.state);return}Object.keys(h.state).length!==1&&console.error(`
|
|
5688
5688
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5689
5689
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5690
5690
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|